@gyral/core 0.2.0 → 0.3.1

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 (517) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/NOTICE +19 -0
  3. package/README.md +35 -8
  4. package/dist/call.d.ts +32 -0
  5. package/dist/call.js +63 -0
  6. package/dist/call.js.map +1 -0
  7. package/dist/children.d.ts +30 -5
  8. package/dist/children.js +26 -4
  9. package/dist/children.js.map +1 -1
  10. package/dist/cli/gyral-types.d.ts +2 -0
  11. package/dist/cli/gyral-types.js +23 -0
  12. package/dist/cli/gyral-types.js.map +1 -0
  13. package/dist/command.d.ts +54 -12
  14. package/dist/command.js +31 -11
  15. package/dist/command.js.map +1 -1
  16. package/dist/compiler/ast.d.ts +23 -0
  17. package/dist/compiler/ast.js +149 -0
  18. package/dist/compiler/ast.js.map +1 -0
  19. package/dist/compiler/compile.d.ts +41 -0
  20. package/dist/compiler/compile.js +148 -0
  21. package/dist/compiler/compile.js.map +1 -0
  22. package/dist/compiler/component-entries.d.ts +7 -0
  23. package/dist/compiler/component-entries.js +42 -0
  24. package/dist/compiler/component-entries.js.map +1 -0
  25. package/dist/compiler/components.d.ts +4 -0
  26. package/dist/compiler/components.js +182 -0
  27. package/dist/compiler/components.js.map +1 -0
  28. package/dist/compiler/facts.d.ts +31 -0
  29. package/dist/compiler/facts.js +285 -0
  30. package/dist/compiler/facts.js.map +1 -0
  31. package/dist/compiler/features.d.ts +34 -0
  32. package/dist/compiler/features.js +158 -0
  33. package/dist/compiler/features.js.map +1 -0
  34. package/dist/compiler/hooks.d.ts +22 -0
  35. package/dist/compiler/hooks.js +241 -0
  36. package/dist/compiler/hooks.js.map +1 -0
  37. package/dist/compiler/loader-source.d.ts +14 -0
  38. package/dist/compiler/loader-source.js +86 -0
  39. package/dist/compiler/loader-source.js.map +1 -0
  40. package/dist/compiler/locate.d.ts +14 -0
  41. package/dist/compiler/locate.js +78 -0
  42. package/dist/compiler/locate.js.map +1 -0
  43. package/dist/compiler/parse5-check.d.ts +21 -0
  44. package/dist/compiler/parse5-check.js +60 -0
  45. package/dist/compiler/parse5-check.js.map +1 -0
  46. package/dist/compiler/prop-schemas.d.ts +4 -0
  47. package/dist/compiler/prop-schemas.js +108 -0
  48. package/dist/compiler/prop-schemas.js.map +1 -0
  49. package/dist/compiler/scan.d.ts +41 -0
  50. package/dist/compiler/scan.js +160 -0
  51. package/dist/compiler/scan.js.map +1 -0
  52. package/dist/compiler/scope.d.ts +8 -0
  53. package/dist/compiler/scope.js +116 -0
  54. package/dist/compiler/scope.js.map +1 -0
  55. package/dist/compiler/source.d.ts +34 -0
  56. package/dist/compiler/source.js +114 -0
  57. package/dist/compiler/source.js.map +1 -0
  58. package/dist/compiler/tag-map.d.ts +41 -0
  59. package/dist/compiler/tag-map.js +126 -0
  60. package/dist/compiler/tag-map.js.map +1 -0
  61. package/dist/components-ready.d.ts +7 -0
  62. package/dist/components-ready.js +19 -0
  63. package/dist/components-ready.js.map +1 -0
  64. package/dist/define.d.ts +13 -4
  65. package/dist/define.js +35 -331
  66. package/dist/define.js.map +1 -1
  67. package/dist/devtools-events.d.ts +13 -0
  68. package/dist/devtools-events.js.map +1 -1
  69. package/dist/devtools-off.d.ts +2 -0
  70. package/dist/devtools-off.js +2 -0
  71. package/dist/devtools-off.js.map +1 -1
  72. package/dist/devtools.d.ts +4 -0
  73. package/dist/devtools.js +17 -2
  74. package/dist/devtools.js.map +1 -1
  75. package/dist/drivers-scope.d.ts +1 -1
  76. package/dist/drivers-scope.js +1 -8
  77. package/dist/drivers-scope.js.map +1 -1
  78. package/dist/element-internals.d.ts +1 -0
  79. package/dist/element-internals.js +11 -0
  80. package/dist/element-internals.js.map +1 -0
  81. package/dist/element-types.d.ts +11 -5
  82. package/dist/element-types.js.map +1 -1
  83. package/dist/element.d.ts +3 -0
  84. package/dist/element.js +322 -0
  85. package/dist/element.js.map +1 -0
  86. package/dist/error-view.d.ts +10 -0
  87. package/dist/error-view.js +30 -0
  88. package/dist/error-view.js.map +1 -0
  89. package/dist/errors.d.ts +21 -0
  90. package/dist/errors.js +47 -0
  91. package/dist/errors.js.map +1 -0
  92. package/dist/errors.json +289 -0
  93. package/dist/eslint/imports.d.ts +26 -0
  94. package/dist/eslint/imports.js +78 -0
  95. package/dist/eslint/imports.js.map +1 -0
  96. package/dist/eslint/index.d.ts +16 -0
  97. package/dist/eslint/index.js +23 -0
  98. package/dist/eslint/index.js.map +1 -0
  99. package/dist/eslint/locate.d.ts +33 -0
  100. package/dist/eslint/locate.js +132 -0
  101. package/dist/eslint/locate.js.map +1 -0
  102. package/dist/eslint/row-purity-rule.d.ts +2 -0
  103. package/dist/eslint/row-purity-rule.js +103 -0
  104. package/dist/eslint/row-purity-rule.js.map +1 -0
  105. package/dist/eslint/template-rule.d.ts +6 -0
  106. package/dist/eslint/template-rule.js +76 -0
  107. package/dist/eslint/template-rule.js.map +1 -0
  108. package/dist/eslint/unused-intent-rule.d.ts +2 -0
  109. package/dist/eslint/unused-intent-rule.js +186 -0
  110. package/dist/eslint/unused-intent-rule.js.map +1 -0
  111. package/dist/features.d.ts +39 -0
  112. package/dist/features.js +2 -0
  113. package/dist/features.js.map +1 -0
  114. package/dist/focus.d.ts +13 -12
  115. package/dist/focus.js +44 -11
  116. package/dist/focus.js.map +1 -1
  117. package/dist/form-associated.d.ts +46 -0
  118. package/dist/form-associated.js +77 -0
  119. package/dist/form-associated.js.map +1 -0
  120. package/dist/forms.d.ts +42 -30
  121. package/dist/forms.js +85 -41
  122. package/dist/forms.js.map +1 -1
  123. package/dist/frame-lane.d.ts +11 -0
  124. package/dist/frame-lane.js +28 -0
  125. package/dist/frame-lane.js.map +1 -0
  126. package/dist/head.d.ts +61 -0
  127. package/dist/head.js +85 -0
  128. package/dist/head.js.map +1 -0
  129. package/dist/hooks/invalid.d.ts +14 -0
  130. package/dist/hooks/invalid.js +72 -0
  131. package/dist/hooks/invalid.js.map +1 -0
  132. package/dist/host-model.d.ts +77 -0
  133. package/dist/host-model.js +278 -0
  134. package/dist/host-model.js.map +1 -0
  135. package/dist/hydration-client.d.ts +9 -0
  136. package/dist/hydration-client.js +35 -0
  137. package/dist/hydration-client.js.map +1 -0
  138. package/dist/hydration-loader.d.ts +13 -0
  139. package/dist/hydration-loader.js +58 -0
  140. package/dist/hydration-loader.js.map +1 -0
  141. package/dist/hydration-off.d.ts +8 -0
  142. package/dist/hydration-off.js +25 -0
  143. package/dist/hydration-off.js.map +1 -0
  144. package/dist/hydration.d.ts +3 -21
  145. package/dist/hydration.js +14 -63
  146. package/dist/hydration.js.map +1 -1
  147. package/dist/index.d.ts +24 -36
  148. package/dist/index.js +14 -32
  149. package/dist/index.js.map +1 -1
  150. package/dist/indexeddb-types.d.ts +97 -0
  151. package/dist/indexeddb-types.js +2 -0
  152. package/dist/indexeddb-types.js.map +1 -0
  153. package/dist/indexeddb.d.ts +5 -0
  154. package/dist/indexeddb.js +118 -0
  155. package/dist/indexeddb.js.map +1 -0
  156. package/dist/intent.d.ts +62 -17
  157. package/dist/intent.js +193 -100
  158. package/dist/intent.js.map +1 -1
  159. package/dist/internal/indexeddb-open.d.ts +8 -0
  160. package/dist/internal/indexeddb-open.js +96 -0
  161. package/dist/internal/indexeddb-open.js.map +1 -0
  162. package/dist/internal/indexeddb-transaction.d.ts +4 -0
  163. package/dist/internal/indexeddb-transaction.js +134 -0
  164. package/dist/internal/indexeddb-transaction.js.map +1 -0
  165. package/dist/internal/interpreter.d.ts +15 -1
  166. package/dist/internal/interpreter.js +42 -47
  167. package/dist/internal/interpreter.js.map +1 -1
  168. package/dist/internal/token.d.ts +1 -0
  169. package/dist/internal/token.js +7 -0
  170. package/dist/internal/token.js.map +1 -0
  171. package/dist/internal.d.ts +20 -0
  172. package/dist/internal.js +22 -0
  173. package/dist/internal.js.map +1 -0
  174. package/dist/invoker-fallback-used.d.ts +4 -0
  175. package/dist/invoker-fallback-used.js +10 -0
  176. package/dist/invoker-fallback-used.js.map +1 -0
  177. package/dist/invoker-fallback.d.ts +4 -0
  178. package/dist/invoker-fallback.js +15 -0
  179. package/dist/invoker-fallback.js.map +1 -0
  180. package/dist/invokers-shim.d.ts +6 -0
  181. package/dist/invokers-shim.js +32 -0
  182. package/dist/invokers-shim.js.map +1 -0
  183. package/dist/invokers.d.ts +3 -5
  184. package/dist/invokers.js +11 -51
  185. package/dist/invokers.js.map +1 -1
  186. package/dist/islands.d.ts +0 -2
  187. package/dist/islands.js +4 -11
  188. package/dist/islands.js.map +1 -1
  189. package/dist/light-dom.d.ts +4 -53
  190. package/dist/light-dom.js +5 -100
  191. package/dist/light-dom.js.map +1 -1
  192. package/dist/prop.d.ts +89 -0
  193. package/dist/prop.js +41 -0
  194. package/dist/prop.js.map +1 -0
  195. package/dist/props.d.ts +57 -21
  196. package/dist/props.js +157 -34
  197. package/dist/props.js.map +1 -1
  198. package/dist/retry.d.ts +15 -0
  199. package/dist/retry.js +48 -0
  200. package/dist/retry.js.map +1 -0
  201. package/dist/scheduler.d.ts +43 -0
  202. package/dist/scheduler.js +212 -0
  203. package/dist/scheduler.js.map +1 -0
  204. package/dist/script-json.d.ts +2 -0
  205. package/dist/script-json.js +13 -0
  206. package/dist/script-json.js.map +1 -0
  207. package/dist/server-component.d.ts +10 -0
  208. package/dist/server-component.js +133 -0
  209. package/dist/server-component.js.map +1 -0
  210. package/dist/server-specs.d.ts +6 -0
  211. package/dist/server-specs.js +13 -0
  212. package/dist/server-specs.js.map +1 -0
  213. package/dist/server.d.ts +34 -0
  214. package/dist/server.js +59 -0
  215. package/dist/server.js.map +1 -0
  216. package/dist/settled.d.ts +11 -0
  217. package/dist/settled.js +62 -0
  218. package/dist/settled.js.map +1 -0
  219. package/dist/spec-features-used.d.ts +21 -0
  220. package/dist/spec-features-used.js +50 -0
  221. package/dist/spec-features-used.js.map +1 -0
  222. package/dist/spec-features.d.ts +28 -0
  223. package/dist/spec-features.js +42 -0
  224. package/dist/spec-features.js.map +1 -0
  225. package/dist/states.d.ts +3 -5
  226. package/dist/states.js +22 -11
  227. package/dist/states.js.map +1 -1
  228. package/dist/storage.d.ts +69 -0
  229. package/dist/storage.js +158 -0
  230. package/dist/storage.js.map +1 -0
  231. package/dist/store-binding.d.ts +6 -3
  232. package/dist/store-binding.js +7 -8
  233. package/dist/store-binding.js.map +1 -1
  234. package/dist/store-scope.d.ts +8 -11
  235. package/dist/store-scope.js +15 -40
  236. package/dist/store-scope.js.map +1 -1
  237. package/dist/store.d.ts +3 -0
  238. package/dist/store.js +45 -10
  239. package/dist/store.js.map +1 -1
  240. package/dist/stores-provider.d.ts +2 -6
  241. package/dist/stores-provider.js +21 -55
  242. package/dist/stores-provider.js.map +1 -1
  243. package/dist/subscription.d.ts +35 -0
  244. package/dist/subscription.js +74 -0
  245. package/dist/subscription.js.map +1 -0
  246. package/dist/subscriptions.d.ts +26 -0
  247. package/dist/subscriptions.js +98 -0
  248. package/dist/subscriptions.js.map +1 -0
  249. package/dist/transitions.d.ts +5 -7
  250. package/dist/transitions.js +17 -20
  251. package/dist/transitions.js.map +1 -1
  252. package/dist/types.d.ts +142 -49
  253. package/dist/types.js.map +1 -1
  254. package/dist/use-dialogs.d.ts +2 -0
  255. package/dist/use-dialogs.js +9 -0
  256. package/dist/use-dialogs.js.map +1 -0
  257. package/dist/use-disposal.d.ts +2 -0
  258. package/dist/use-disposal.js +9 -0
  259. package/dist/use-disposal.js.map +1 -0
  260. package/dist/use-error-view.d.ts +2 -0
  261. package/dist/use-error-view.js +9 -0
  262. package/dist/use-error-view.js.map +1 -0
  263. package/dist/use-errored.d.ts +2 -0
  264. package/dist/use-errored.js +9 -0
  265. package/dist/use-errored.js.map +1 -0
  266. package/dist/use-form-associated.d.ts +2 -0
  267. package/dist/use-form-associated.js +7 -0
  268. package/dist/use-form-associated.js.map +1 -0
  269. package/dist/use-frame-lane.d.ts +2 -0
  270. package/dist/use-frame-lane.js +10 -0
  271. package/dist/use-frame-lane.js.map +1 -0
  272. package/dist/use-invokers.d.ts +2 -0
  273. package/dist/use-invokers.js +10 -0
  274. package/dist/use-invokers.js.map +1 -0
  275. package/dist/use-states.d.ts +2 -0
  276. package/dist/use-states.js +10 -0
  277. package/dist/use-states.js.map +1 -0
  278. package/dist/use-subscriptions.d.ts +2 -0
  279. package/dist/use-subscriptions.js +10 -0
  280. package/dist/use-subscriptions.js.map +1 -0
  281. package/dist/use-transitions.d.ts +2 -0
  282. package/dist/use-transitions.js +10 -0
  283. package/dist/use-transitions.js.map +1 -0
  284. package/dist/view/attributes.d.ts +11 -0
  285. package/dist/view/attributes.js +15 -0
  286. package/dist/view/attributes.js.map +1 -0
  287. package/dist/view/compiled.d.ts +1 -0
  288. package/dist/view/compiled.js +6 -0
  289. package/dist/view/compiled.js.map +1 -0
  290. package/dist/view/dev-off.d.ts +1 -0
  291. package/dist/view/dev-off.js +4 -0
  292. package/dist/view/dev-off.js.map +1 -0
  293. package/dist/view/dev.d.ts +1 -0
  294. package/dist/view/dev.js +5 -0
  295. package/dist/view/dev.js.map +1 -0
  296. package/dist/view/flags.d.ts +1 -0
  297. package/dist/view/flags.js +4 -0
  298. package/dist/view/flags.js.map +1 -0
  299. package/dist/view/index.d.ts +26 -0
  300. package/dist/view/index.js +27 -0
  301. package/dist/view/index.js.map +1 -0
  302. package/dist/view/loc.d.ts +9 -0
  303. package/dist/view/loc.js +50 -0
  304. package/dist/view/loc.js.map +1 -0
  305. package/dist/view/message.d.ts +17 -0
  306. package/dist/view/message.js +40 -0
  307. package/dist/view/message.js.map +1 -0
  308. package/dist/view/messages.d.ts +43 -0
  309. package/dist/view/messages.js +84 -0
  310. package/dist/view/messages.js.map +1 -0
  311. package/dist/view/normalize/check.d.ts +23 -0
  312. package/dist/view/normalize/check.js +81 -0
  313. package/dist/view/normalize/check.js.map +1 -0
  314. package/dist/view/normalize/emit.d.ts +15 -0
  315. package/dist/view/normalize/emit.js +165 -0
  316. package/dist/view/normalize/emit.js.map +1 -0
  317. package/dist/view/normalize/entities.d.ts +4 -0
  318. package/dist/view/normalize/entities.js +38 -0
  319. package/dist/view/normalize/entities.js.map +1 -0
  320. package/dist/view/normalize/errors.d.ts +9 -0
  321. package/dist/view/normalize/errors.js +19 -0
  322. package/dist/view/normalize/errors.js.map +1 -0
  323. package/dist/view/normalize/id.d.ts +10 -0
  324. package/dist/view/normalize/id.js +55 -0
  325. package/dist/view/normalize/id.js.map +1 -0
  326. package/dist/view/normalize/normalize.d.ts +18 -0
  327. package/dist/view/normalize/normalize.js +42 -0
  328. package/dist/view/normalize/normalize.js.map +1 -0
  329. package/dist/view/normalize/repairs.d.ts +24 -0
  330. package/dist/view/normalize/repairs.js +166 -0
  331. package/dist/view/normalize/repairs.js.map +1 -0
  332. package/dist/view/normalize/rules.d.ts +39 -0
  333. package/dist/view/normalize/rules.js +120 -0
  334. package/dist/view/normalize/rules.js.map +1 -0
  335. package/dist/view/normalize/shape.d.ts +5 -0
  336. package/dist/view/normalize/shape.js +38 -0
  337. package/dist/view/normalize/shape.js.map +1 -0
  338. package/dist/view/normalize/source.d.ts +13 -0
  339. package/dist/view/normalize/source.js +34 -0
  340. package/dist/view/normalize/source.js.map +1 -0
  341. package/dist/view/normalize/svg.d.ts +14 -0
  342. package/dist/view/normalize/svg.js +40 -0
  343. package/dist/view/normalize/svg.js.map +1 -0
  344. package/dist/view/normalize/tag-states.d.ts +23 -0
  345. package/dist/view/normalize/tag-states.js +192 -0
  346. package/dist/view/normalize/tag-states.js.map +1 -0
  347. package/dist/view/normalize/tokenizer.d.ts +5 -0
  348. package/dist/view/normalize/tokenizer.js +233 -0
  349. package/dist/view/normalize/tokenizer.js.map +1 -0
  350. package/dist/view/normalize/tokens.d.ts +55 -0
  351. package/dist/view/normalize/tokens.js +24 -0
  352. package/dist/view/normalize/tokens.js.map +1 -0
  353. package/dist/view/normalize/tree.d.ts +65 -0
  354. package/dist/view/normalize/tree.js +235 -0
  355. package/dist/view/normalize/tree.js.map +1 -0
  356. package/dist/view/normalize/types.d.ts +146 -0
  357. package/dist/view/normalize/types.js +29 -0
  358. package/dist/view/normalize/types.js.map +1 -0
  359. package/dist/view/normalize/whitespace.d.ts +2 -0
  360. package/dist/{template-whitespace.js → view/normalize/whitespace.js} +27 -36
  361. package/dist/view/normalize/whitespace.js.map +1 -0
  362. package/dist/view/prepare-stub.d.ts +3 -0
  363. package/dist/view/prepare-stub.js +7 -0
  364. package/dist/view/prepare-stub.js.map +1 -0
  365. package/dist/view/prepare.d.ts +11 -0
  366. package/dist/view/prepare.js +63 -0
  367. package/dist/view/prepare.js.map +1 -0
  368. package/dist/view/registry.d.ts +78 -0
  369. package/dist/view/registry.js +27 -0
  370. package/dist/view/registry.js.map +1 -0
  371. package/dist/view/render/adopt-attr.d.ts +14 -0
  372. package/dist/view/render/adopt-attr.js +83 -0
  373. package/dist/view/render/adopt-attr.js.map +1 -0
  374. package/dist/view/render/adopt-plan.d.ts +10 -0
  375. package/dist/view/render/adopt-plan.js +26 -0
  376. package/dist/view/render/adopt-plan.js.map +1 -0
  377. package/dist/view/render/adopt.d.ts +3 -0
  378. package/dist/view/render/adopt.js +286 -0
  379. package/dist/view/render/adopt.js.map +1 -0
  380. package/dist/view/render/attr-parts.d.ts +72 -0
  381. package/dist/view/render/attr-parts.js +262 -0
  382. package/dist/view/render/attr-parts.js.map +1 -0
  383. package/dist/view/render/child-part.d.ts +51 -0
  384. package/dist/view/render/child-part.js +173 -0
  385. package/dist/view/render/child-part.js.map +1 -0
  386. package/dist/view/render/dev-check.d.ts +12 -0
  387. package/dist/view/render/dev-check.js +122 -0
  388. package/dist/view/render/dev-check.js.map +1 -0
  389. package/dist/view/render/dispose.d.ts +3 -0
  390. package/dist/view/render/dispose.js +76 -0
  391. package/dist/view/render/dispose.js.map +1 -0
  392. package/dist/view/render/hook-part.d.ts +5 -0
  393. package/dist/view/render/hook-part.js +36 -0
  394. package/dist/view/render/hook-part.js.map +1 -0
  395. package/dist/view/render/hook-run.d.ts +2 -0
  396. package/dist/view/render/hook-run.js +72 -0
  397. package/dist/view/render/hook-run.js.map +1 -0
  398. package/dist/view/render/hooks.d.ts +108 -0
  399. package/dist/view/render/hooks.js +108 -0
  400. package/dist/view/render/hooks.js.map +1 -0
  401. package/dist/view/render/hydrate.d.ts +10 -0
  402. package/dist/view/render/hydrate.js +33 -0
  403. package/dist/view/render/hydrate.js.map +1 -0
  404. package/dist/view/render/instance.d.ts +33 -0
  405. package/dist/view/render/instance.js +107 -0
  406. package/dist/view/render/instance.js.map +1 -0
  407. package/dist/view/render/keyed.d.ts +6 -0
  408. package/dist/view/render/keyed.js +15 -0
  409. package/dist/view/render/keyed.js.map +1 -0
  410. package/dist/view/render/list.d.ts +20 -0
  411. package/dist/view/render/list.js +156 -0
  412. package/dist/view/render/list.js.map +1 -0
  413. package/dist/view/render/mismatch.d.ts +10 -0
  414. package/dist/view/render/mismatch.js +55 -0
  415. package/dist/view/render/mismatch.js.map +1 -0
  416. package/dist/view/render/modal.d.ts +3 -0
  417. package/dist/view/render/modal.js +39 -0
  418. package/dist/view/render/modal.js.map +1 -0
  419. package/dist/view/render/nodes.d.ts +10 -0
  420. package/dist/view/render/nodes.js +37 -0
  421. package/dist/view/render/nodes.js.map +1 -0
  422. package/dist/view/render/place.d.ts +18 -0
  423. package/dist/view/render/place.js +69 -0
  424. package/dist/view/render/place.js.map +1 -0
  425. package/dist/view/render/plan.d.ts +26 -0
  426. package/dist/view/render/plan.js +124 -0
  427. package/dist/view/render/plan.js.map +1 -0
  428. package/dist/view/render/raw.d.ts +21 -0
  429. package/dist/view/render/raw.js +72 -0
  430. package/dist/view/render/raw.js.map +1 -0
  431. package/dist/view/render/render.d.ts +15 -0
  432. package/dist/view/render/render.js +65 -0
  433. package/dist/view/render/render.js.map +1 -0
  434. package/dist/view/render/reorder.d.ts +4 -0
  435. package/dist/view/render/reorder.js +101 -0
  436. package/dist/view/render/reorder.js.map +1 -0
  437. package/dist/view/render/rows.d.ts +23 -0
  438. package/dist/view/render/rows.js +95 -0
  439. package/dist/view/render/rows.js.map +1 -0
  440. package/dist/view/render/seen.d.ts +11 -0
  441. package/dist/view/render/seen.js +17 -0
  442. package/dist/view/render/seen.js.map +1 -0
  443. package/dist/view/render/toggles.d.ts +6 -0
  444. package/dist/view/render/toggles.js +6 -0
  445. package/dist/view/render/toggles.js.map +1 -0
  446. package/dist/view/render/values.d.ts +29 -0
  447. package/dist/view/render/values.js +13 -0
  448. package/dist/view/render/values.js.map +1 -0
  449. package/dist/view/render/warn.d.ts +28 -0
  450. package/dist/view/render/warn.js +114 -0
  451. package/dist/view/render/warn.js.map +1 -0
  452. package/dist/view/server/component.d.ts +12 -0
  453. package/dist/view/server/component.js +64 -0
  454. package/dist/view/server/component.js.map +1 -0
  455. package/dist/view/server/escape.d.ts +10 -0
  456. package/dist/view/server/escape.js +34 -0
  457. package/dist/view/server/escape.js.map +1 -0
  458. package/dist/view/server/index.d.ts +48 -0
  459. package/dist/view/server/index.js +80 -0
  460. package/dist/view/server/index.js.map +1 -0
  461. package/dist/view/server/sha256.d.ts +2 -0
  462. package/dist/view/server/sha256.js +75 -0
  463. package/dist/view/server/sha256.js.map +1 -0
  464. package/dist/view/server/tags.d.ts +68 -0
  465. package/dist/view/server/tags.js +132 -0
  466. package/dist/view/server/tags.js.map +1 -0
  467. package/dist/view/server/values.d.ts +18 -0
  468. package/dist/view/server/values.js +94 -0
  469. package/dist/view/server/values.js.map +1 -0
  470. package/dist/view/server/writer.d.ts +21 -0
  471. package/dist/view/server/writer.js +170 -0
  472. package/dist/view/server/writer.js.map +1 -0
  473. package/dist/view/styles.d.ts +25 -0
  474. package/dist/view/styles.js +58 -0
  475. package/dist/view/styles.js.map +1 -0
  476. package/dist/view/template-element.d.ts +10 -0
  477. package/dist/view/template-element.js +45 -0
  478. package/dist/view/template-element.js.map +1 -0
  479. package/dist/view/template.d.ts +29 -0
  480. package/dist/view/template.js +84 -0
  481. package/dist/view/template.js.map +1 -0
  482. package/dist/view/trusted-html.d.ts +6 -0
  483. package/dist/view/trusted-html.js +34 -0
  484. package/dist/view/trusted-html.js.map +1 -0
  485. package/dist/vite.d.ts +57 -11
  486. package/dist/vite.js +319 -27
  487. package/dist/vite.js.map +1 -1
  488. package/package.json +70 -4
  489. package/dist/accessible-name.d.ts +0 -19
  490. package/dist/accessible-name.js +0 -56
  491. package/dist/accessible-name.js.map +0 -1
  492. package/dist/element-directive.d.ts +0 -20
  493. package/dist/element-directive.js +0 -31
  494. package/dist/element-directive.js.map +0 -1
  495. package/dist/invalid.d.ts +0 -21
  496. package/dist/invalid.js +0 -70
  497. package/dist/invalid.js.map +0 -1
  498. package/dist/lit-html-check.d.ts +0 -6
  499. package/dist/lit-html-check.js +0 -48
  500. package/dist/lit-html-check.js.map +0 -1
  501. package/dist/live-boolean.d.ts +0 -22
  502. package/dist/live-boolean.js +0 -34
  503. package/dist/live-boolean.js.map +0 -1
  504. package/dist/random.d.ts +0 -13
  505. package/dist/random.js +0 -19
  506. package/dist/random.js.map +0 -1
  507. package/dist/styles.d.ts +0 -12
  508. package/dist/styles.js +0 -11
  509. package/dist/styles.js.map +0 -1
  510. package/dist/template-whitespace.d.ts +0 -7
  511. package/dist/template-whitespace.js.map +0 -1
  512. package/dist/templates.d.ts +0 -5
  513. package/dist/templates.js +0 -15
  514. package/dist/templates.js.map +0 -1
  515. package/dist/textarea.d.ts +0 -26
  516. package/dist/textarea.js +0 -85
  517. package/dist/textarea.js.map +0 -1
@@ -0,0 +1,72 @@
1
+ // Running element hooks' queued client calls (view/02-bindings.md "Commit order",
2
+ // gyral-1zd.27). Inside a scheduler flush the calls wait until every dirty host has rendered,
3
+ // then run children first: one root's calls in document order, roots in reverse render order
4
+ // (the scheduler renders parents before children), so a parent's hook sees the child components
5
+ // it renders. Outside a flush a `render` call runs its own calls when it returns. Installed by
6
+ // `defineHook`/`defineHook` (hook-part.ts), so apps without hooks bundle none of it.
7
+ import { disposalPass, hookFailure, queue, setCommitting, } from './hooks.js';
8
+ /** Inside a flush: the roots rendered since the last flush of hooks (the queue starts empty). */
9
+ let batch;
10
+ /**
11
+ * Runs the calls queued since `mark` for `roots`: disposal first (dispose.ts), then each
12
+ * root's `client` calls in document order, the last-rendered root first. The scheduler renders
13
+ * parents before children, so children's hooks run first. Each hook on its own: one that
14
+ * throws doesn't keep the others from running.
15
+ */
16
+ function runQueued(mark, roots) {
17
+ try {
18
+ const dispose = disposalPass();
19
+ for (const root of roots) {
20
+ setCommitting(root);
21
+ dispose?.(root); // disposable hooks whose element left `root` dispose first
22
+ }
23
+ const failed = hookFailure();
24
+ // One root's calls are queued together: walk those runs from the end.
25
+ for (let end = queue.length; end > mark;) {
26
+ let start = end - 1;
27
+ while (start > mark && queue[start - 1]?.owner === queue[end - 1]?.owner)
28
+ start--;
29
+ for (let i = start; i < end; i++) {
30
+ const part = queue[i];
31
+ try {
32
+ part.spec.client(part.el, part.args, part.prev);
33
+ }
34
+ catch (error) {
35
+ failed(error, part.owner);
36
+ }
37
+ }
38
+ end = start;
39
+ }
40
+ }
41
+ finally {
42
+ queue.length = mark;
43
+ setCommitting(undefined);
44
+ }
45
+ }
46
+ function flush() {
47
+ if (batch === undefined || batch.length === 0)
48
+ return;
49
+ const roots = batch;
50
+ batch = [];
51
+ runQueued(0, roots);
52
+ }
53
+ export const runner = {
54
+ run(mark, root) {
55
+ if (batch !== undefined)
56
+ batch.push(root);
57
+ else
58
+ runQueued(mark, [root]);
59
+ },
60
+ start() {
61
+ batch = [];
62
+ },
63
+ flush,
64
+ end(ok) {
65
+ if (ok)
66
+ flush();
67
+ else
68
+ queue.length = 0;
69
+ batch = undefined;
70
+ },
71
+ };
72
+ //# sourceMappingURL=hook-run.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hook-run.js","sourceRoot":"","sources":["../../../src/view/render/hook-run.ts"],"names":[],"mappings":"AAAA,kFAAkF;AAClF,8FAA8F;AAC9F,6FAA6F;AAC7F,gGAAgG;AAChG,+FAA+F;AAC/F,qFAAqF;AACrF,OAAO,EACL,YAAY,EACZ,WAAW,EACX,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aAAa,CAAC,SAAS,CAAC,CAAC;IAC3B,CAAC;AACH,CAAC;AAED,SAAS,KAAK;IACZ,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO;IACtD,MAAM,KAAK,GAAG,KAAK,CAAC;IACpB,KAAK,GAAG,EAAE,CAAC;IACX,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;AACtB,CAAC;AAED,MAAM,CAAC,MAAM,MAAM,GAAe;IAChC,GAAG,CAAC,IAAI,EAAE,IAAI;QACZ,IAAI,KAAK,KAAK,SAAS;YAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YACrC,SAAS,CAAC,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IAC/B,CAAC;IACD,KAAK;QACH,KAAK,GAAG,EAAE,CAAC;IACb,CAAC;IACD,KAAK;IACL,GAAG,CAAC,EAAE;QACJ,IAAI,EAAE;YAAE,KAAK,EAAE,CAAC;;YACX,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC;QACtB,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;CACF,CAAC","sourcesContent":["// Running element hooks' queued client calls (view/02-bindings.md \"Commit order\",\n// gyral-1zd.27). Inside a scheduler flush the calls wait until every dirty host has rendered,\n// then run children first: one root's calls in document order, roots in reverse render order\n// (the scheduler renders parents before children), so a parent's hook sees the child components\n// it renders. Outside a flush a `render` call runs its own calls when it returns. Installed by\n// `defineHook`/`defineHook` (hook-part.ts), so apps without hooks bundle none of it.\nimport {\n disposalPass,\n hookFailure,\n queue,\n setCommitting,\n type HookPart,\n type HookRunner,\n type HookSpec,\n} from './hooks.js';\n\n/** Inside a flush: the roots rendered since the last flush of hooks (the queue starts empty). */\nlet batch: Node[] | undefined;\n\n/**\n * Runs the calls queued since `mark` for `roots`: disposal first (dispose.ts), then each\n * root's `client` calls in document order, the last-rendered root first. The scheduler renders\n * parents before children, so children's hooks run first. Each hook on its own: one that\n * throws doesn't keep the others from running.\n */\nfunction runQueued(mark: number, roots: readonly Node[]): void {\n try {\n const dispose = disposalPass();\n for (const root of roots) {\n setCommitting(root);\n dispose?.(root); // disposable hooks whose element left `root` dispose first\n }\n const failed = hookFailure();\n // One root's calls are queued together: walk those runs from the end.\n for (let end = queue.length; end > mark;) {\n let start = end - 1;\n while (start > mark && queue[start - 1]?.owner === queue[end - 1]?.owner) start--;\n for (let i = start; i < end; i++) {\n const part = queue[i] as HookPart;\n try {\n (part.spec as HookSpec<readonly unknown[]>).client(\n part.el,\n part.args as readonly unknown[],\n part.prev,\n );\n } catch (error) {\n failed(error, part.owner as Node);\n }\n }\n end = start;\n }\n } finally {\n queue.length = mark;\n setCommitting(undefined);\n }\n}\n\nfunction flush(): void {\n if (batch === undefined || batch.length === 0) return;\n const roots = batch;\n batch = [];\n runQueued(0, roots);\n}\n\nexport const runner: HookRunner = {\n run(mark, root) {\n if (batch !== undefined) batch.push(root);\n else runQueued(mark, [root]);\n },\n start() {\n batch = [];\n },\n flush,\n end(ok) {\n if (ok) flush();\n else queue.length = 0;\n batch = undefined;\n },\n};\n"]}
@@ -0,0 +1,108 @@
1
+ declare const HOOK: unique symbol;
2
+ /** Internal: a hook result's commit function (hook-part.ts), so apps without hooks skip it. */
3
+ export declare const COMMIT_HOOK: unique symbol;
4
+ /** Attributes a hook's server half adds to the start tag (`true`: present, no value). */
5
+ export type HookAttributes = Readonly<Record<string, string | true>>;
6
+ export interface HookSpec<A extends readonly unknown[]> {
7
+ /** Attributes for the server-rendered start tag (view/06-server.md). */
8
+ server?(args: A): HookAttributes;
9
+ /** Runs after the commit when `args` changed; `prev` is undefined the first time. */
10
+ client(el: Element, args: A, prev: A | undefined): void;
11
+ /**
12
+ * When `client` runs again: `'args'` (the default) when an argument changed (`Object.is`),
13
+ * `'always'` on every render that commits the hook's position (a skipped `each` row doesn't).
14
+ */
15
+ readonly update?: 'args' | 'always';
16
+ /**
17
+ * Teardown, with the last arguments `client` got (view/02 "Widgets with a lifecycle"): runs
18
+ * when Gyral removes the element, when the position stops holding this hook, or when the host
19
+ * disconnects (not on moves). After a host reconnects, `client` runs again with `prev`
20
+ * undefined.
21
+ */
22
+ dispose?(el: Element, args: A): void;
23
+ }
24
+ /** What a hook returns in a template: `<input ${invalid(errors)}>`. */
25
+ export interface HookResult<A extends readonly unknown[] = readonly unknown[]> {
26
+ readonly [HOOK]: HookSpec<A>;
27
+ readonly [COMMIT_HOOK]: (part: HookPart, result: HookResult) => void;
28
+ readonly args: A;
29
+ }
30
+ /** A hook position as committing sees it (an element part of kind HOOK). */
31
+ export interface HookPart {
32
+ readonly el: Element;
33
+ spec: HookSpec<readonly unknown[]> | null;
34
+ args: readonly unknown[] | undefined;
35
+ prev: readonly unknown[] | undefined;
36
+ /** dispose.ts: the tracked disposable hook, its last arguments, and whether a disconnect
37
+ * disposed it (`client` runs again after the next render). */
38
+ kept?: HookSpec<readonly unknown[]> | undefined;
39
+ keptArgs?: readonly unknown[] | undefined;
40
+ off?: boolean | undefined;
41
+ /** The render root it was queued for (hook-run.ts: failures, order). */
42
+ owner?: Node | undefined;
43
+ }
44
+ export declare const isHook: (value: unknown) => value is HookResult;
45
+ /** The spec of a hook result, or undefined for anything else. */
46
+ export declare const hookSpec: (value: unknown) => HookSpec<readonly unknown[]> | undefined;
47
+ /** Internal (hook-part.ts): a hook result. */
48
+ export declare const hookResult: <A extends readonly unknown[]>(spec: HookSpec<A>, args: A, commit: HookResult[typeof COMMIT_HOOK]) => HookResult<A>;
49
+ /** Shallow comparison of two argument lists, `Object.is` per argument. */
50
+ export declare function sameArgs(a: readonly unknown[], b: readonly unknown[] | undefined): boolean;
51
+ /**
52
+ * Hook disposal (dispose.ts), set when the first disposable hook commits: `disposal(root)`
53
+ * after a render of `root` commits (before its client calls), `disposal(root, true)` when the
54
+ * host owning `root` disconnects (true when hooks wait to run `client` again after the next
55
+ * render). A plain variable, not an object, to keep apps without it small.
56
+ */
57
+ declare let disposal: ((root: Node, disconnect?: boolean) => boolean) | undefined;
58
+ /** Internal (dispose.ts): turns hook disposal on. */
59
+ export declare function useDisposal(run: (root: Node, disconnect?: boolean) => boolean): void;
60
+ /** How a hook with `dispose` commits (dispose.ts `commitTracked`), once registered. */
61
+ export declare let disposableCommit: ((part: HookPart, result: HookResult) => void) | undefined;
62
+ /** Internal (`#spec-features`, use-disposal.ts): registers hook disposal. */
63
+ export declare function useDisposableHooks(commit: (part: HookPart, result: HookResult) => void): void;
64
+ /** The host owning `root` disconnected (element.ts): disposes its disposable hooks. */
65
+ export declare const suspendHooks: (root: Node | undefined) => boolean | undefined;
66
+ /** Internal (hook-run.ts): queued client calls. */
67
+ export declare const queue: HookPart[];
68
+ /** Queues `part`'s client call for the end of the render, or of the flush. */
69
+ export declare function queueHook(part: HookPart): void;
70
+ /** The root being committed (dispose.ts tracks disposable hooks per root). */
71
+ export declare const committing: () => Node | undefined;
72
+ /** Internal (hook-run.ts): sets the root being committed (disposal re-queues hooks for it). */
73
+ export declare function setCommitting(root: Node | undefined): void;
74
+ /** The queue position before a render of `root`, for `runHooks`/`dropHooks`. */
75
+ export declare function hookMark(root: Node): number;
76
+ /** Internal (core's element.ts): reports hook failures. */
77
+ export declare function onHookFailure(report: (error: unknown, root: Node) => void): void;
78
+ /** Internal (hook-run.ts): where failures go, and the disposal pass. */
79
+ export declare const hookFailure: () => ((error: unknown, root: Node) => void);
80
+ export declare const disposalPass: () => typeof disposal;
81
+ /**
82
+ * What runs queued client calls (hook-run.ts): ordering, batching across a flush, failures.
83
+ * Set by `defineHook`, so apps without hooks bundle none of it; without
84
+ * hooks nothing is ever queued.
85
+ */
86
+ export interface HookRunner {
87
+ /** `root` committed: run its calls now, or note it for the end of the flush. */
88
+ run(mark: number, root: Node): void;
89
+ /** A flush starts. */
90
+ start(): void;
91
+ /** Runs the calls of every root rendered in the flush so far. */
92
+ flush(): void;
93
+ /** A flush ends: runs what's left (or drops it when the flush threw). */
94
+ end(ok: boolean): void;
95
+ }
96
+ /** Internal (hook-part.ts): installs the runner. */
97
+ export declare function useHookRunner(run: HookRunner): void;
98
+ /** `root` committed: its queued `client` calls run now, or with the flush's (hook-run.ts). */
99
+ export declare function runHooks(mark: number, root: Node): void;
100
+ /** A flush starts (render.ts `renderBatch`). */
101
+ export declare function startHooks(): void;
102
+ /** Runs the hooks of every root rendered in this flush so far (the scheduler, after each pass). */
103
+ export declare function flushHooks(): void;
104
+ /** A flush ends. */
105
+ export declare function endHooks(ok: boolean): void;
106
+ /** Forgets the calls queued since `mark` (the render threw). */
107
+ export declare function dropHooks(mark: number): void;
108
+ export {};
@@ -0,0 +1,108 @@
1
+ // Element hooks (view/02-bindings.md "Element hooks", "Commit order"): their types and the
2
+ // queue of client calls. A hook position (attr-parts.ts, kind HOOK) queues itself when its
3
+ // arguments change (shallow `Object.is` per argument, hook-part.ts, which also holds
4
+ // `defineHook`), or on every commit with `update: 'always'`. Inside a scheduler flush
5
+ // (`renderBatch`) the queued `client` calls wait until every dirty host has rendered, then run
6
+ // children first, each root's calls in document order (hook-run.ts), so a parent's hook sees its
7
+ // child components rendered (view/02 "Commit order"). A `render` call outside a flush runs its
8
+ // own calls when it returns, in document order.
9
+ // A hook whose spec has `dispose` runs it when the element leaves its render root (Gyral removed
10
+ // it: its part cleared, its instance replaced, its row removed), when the position stops holding
11
+ // the hook, or when the host disconnects; not on moves. That machinery (dispose.ts) is reached
12
+ // through `disposableCommit`, filled by core's `#spec-features` (every build without the preset)
13
+ // or, with the preset, only when some module names `dispose` (compiler/features.ts): apps whose
14
+ // hooks have no teardown don't bundle it (gyral-c5d.2, gyral-1zd.24) and pay one empty check per
15
+ // render and per disconnect.
16
+ const HOOK = Symbol('gyral.hook');
17
+ /** Internal: a hook result's commit function (hook-part.ts), so apps without hooks skip it. */
18
+ export const COMMIT_HOOK = Symbol('gyral.hook.commit');
19
+ export const isHook = (value) => typeof value === 'object' && value !== null && HOOK in value;
20
+ /** The spec of a hook result, or undefined for anything else. */
21
+ export const hookSpec = (value) => isHook(value) ? value[HOOK] : undefined;
22
+ /** Internal (hook-part.ts): a hook result. */
23
+ export const hookResult = (spec, args, commit) => ({ [HOOK]: spec, [COMMIT_HOOK]: commit, args });
24
+ /** Shallow comparison of two argument lists, `Object.is` per argument. */
25
+ export function sameArgs(a, b) {
26
+ if (b === undefined || a.length !== b.length)
27
+ return false;
28
+ for (let i = 0; i < a.length; i++)
29
+ if (!Object.is(a[i], b[i]))
30
+ return false;
31
+ return true;
32
+ }
33
+ /**
34
+ * Hook disposal (dispose.ts), set when the first disposable hook commits: `disposal(root)`
35
+ * after a render of `root` commits (before its client calls), `disposal(root, true)` when the
36
+ * host owning `root` disconnects (true when hooks wait to run `client` again after the next
37
+ * render). A plain variable, not an object, to keep apps without it small.
38
+ */
39
+ let disposal;
40
+ /** Internal (dispose.ts): turns hook disposal on. */
41
+ export function useDisposal(run) {
42
+ disposal = run;
43
+ }
44
+ /** How a hook with `dispose` commits (dispose.ts `commitTracked`), once registered. */
45
+ export let disposableCommit;
46
+ /** Internal (`#spec-features`, use-disposal.ts): registers hook disposal. */
47
+ export function useDisposableHooks(commit) {
48
+ disposableCommit = commit;
49
+ }
50
+ /** The host owning `root` disconnected (element.ts): disposes its disposable hooks. */
51
+ export const suspendHooks = (root) => disposal?.(root, true);
52
+ /** Internal (hook-run.ts): queued client calls. */
53
+ export const queue = [];
54
+ /** The root being committed, so `queueHook` knows the owner. */
55
+ let current;
56
+ /** Queues `part`'s client call for the end of the render, or of the flush. */
57
+ export function queueHook(part) {
58
+ part.owner = current;
59
+ queue.push(part);
60
+ }
61
+ /** The root being committed (dispose.ts tracks disposable hooks per root). */
62
+ export const committing = () => current;
63
+ /** Internal (hook-run.ts): sets the root being committed (disposal re-queues hooks for it). */
64
+ export function setCommitting(root) {
65
+ current = root;
66
+ }
67
+ /** The queue position before a render of `root`, for `runHooks`/`dropHooks`. */
68
+ export function hookMark(root) {
69
+ current = root;
70
+ return queue.length;
71
+ }
72
+ /** Where a hook's failure goes (core reports it, ADR 0024); unset, `reportError`. */
73
+ let hookFailed;
74
+ /** Internal (core's element.ts): reports hook failures. */
75
+ export function onHookFailure(report) {
76
+ hookFailed = report;
77
+ }
78
+ /** Internal (hook-run.ts): where failures go, and the disposal pass. */
79
+ export const hookFailure = () => hookFailed ?? reportError;
80
+ export const disposalPass = () => disposal;
81
+ let runner;
82
+ /** Internal (hook-part.ts): installs the runner. */
83
+ export function useHookRunner(run) {
84
+ runner = run;
85
+ }
86
+ /** `root` committed: its queued `client` calls run now, or with the flush's (hook-run.ts). */
87
+ export function runHooks(mark, root) {
88
+ current = undefined;
89
+ runner?.run(mark, root);
90
+ }
91
+ /** A flush starts (render.ts `renderBatch`). */
92
+ export function startHooks() {
93
+ runner?.start();
94
+ }
95
+ /** Runs the hooks of every root rendered in this flush so far (the scheduler, after each pass). */
96
+ export function flushHooks() {
97
+ runner?.flush();
98
+ }
99
+ /** A flush ends. */
100
+ export function endHooks(ok) {
101
+ runner?.end(ok);
102
+ }
103
+ /** Forgets the calls queued since `mark` (the render threw). */
104
+ export function dropHooks(mark) {
105
+ queue.length = mark;
106
+ current = undefined;
107
+ }
108
+ //# sourceMappingURL=hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../../src/view/render/hooks.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,2FAA2F;AAC3F,qFAAqF;AACrF,sFAAsF;AACtF,+FAA+F;AAC/F,iGAAiG;AACjG,+FAA+F;AAC/F,gDAAgD;AAChD,iGAAiG;AACjG,iGAAiG;AACjG,+FAA+F;AAC/F,iGAAiG;AACjG,gGAAgG;AAChG,iGAAiG;AACjG,6BAA6B;AAE7B,MAAM,IAAI,GAAkB,MAAM,CAAC,YAAY,CAAC,CAAC;AACjD,+FAA+F;AAC/F,MAAM,CAAC,MAAM,WAAW,GAAkB,MAAM,CAAC,mBAAmB,CAAC,CAAC;AA8CtE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,KA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AE,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,gDAAgD;AAChD,MAAM,UAAU,UAAU;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,UAAU;IACxB,MAAM,EAAE,KAAK,EAAE,CAAC;AAClB,CAAC;AAED,oBAAoB;AACpB,MAAM,UAAU,QAAQ,CAAC,EAAW;IAClC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAAC;AAClB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,KAAK,CAAC,MAAM,GAAG,IAAI,CAAC;IACpB,OAAO,GAAG,SAAS,CAAC;AACtB,CAAC","sourcesContent":["// Element hooks (view/02-bindings.md \"Element hooks\", \"Commit order\"): their types and the\n// queue of client calls. A hook position (attr-parts.ts, kind HOOK) queues itself when its\n// arguments change (shallow `Object.is` per argument, hook-part.ts, which also holds\n// `defineHook`), or on every commit with `update: 'always'`. Inside a scheduler flush\n// (`renderBatch`) the queued `client` calls wait until every dirty host has rendered, then run\n// children first, each root's calls in document order (hook-run.ts), so a parent's hook sees its\n// child components rendered (view/02 \"Commit order\"). A `render` call outside a flush runs its\n// own calls when it returns, in document order.\n// A hook whose spec has `dispose` runs it when the element leaves its render root (Gyral removed\n// it: its part cleared, its instance replaced, its row removed), when the position stops holding\n// the hook, or when the host disconnects; not on moves. That machinery (dispose.ts) is reached\n// through `disposableCommit`, filled by core's `#spec-features` (every build without the preset)\n// or, with the preset, only when some module names `dispose` (compiler/features.ts): apps whose\n// hooks have no teardown don't bundle it (gyral-c5d.2, gyral-1zd.24) and pay one empty check per\n// render and per disconnect.\n\nconst HOOK: unique symbol = Symbol('gyral.hook');\n/** Internal: a hook result's commit function (hook-part.ts), so apps without hooks skip it. */\nexport const COMMIT_HOOK: unique symbol = Symbol('gyral.hook.commit');\n\n/** Attributes a hook's server half adds to the start tag (`true`: present, no value). */\nexport type HookAttributes = Readonly<Record<string, string | true>>;\n\nexport interface HookSpec<A extends readonly unknown[]> {\n /** Attributes for the server-rendered start tag (view/06-server.md). */\n server?(args: A): HookAttributes;\n /** Runs after the commit when `args` changed; `prev` is undefined the first time. */\n client(el: Element, args: A, prev: A | undefined): void;\n /**\n * When `client` runs again: `'args'` (the default) when an argument changed (`Object.is`),\n * `'always'` on every render that commits the hook's position (a skipped `each` row doesn't).\n */\n readonly update?: 'args' | 'always';\n /**\n * Teardown, with the last arguments `client` got (view/02 \"Widgets with a lifecycle\"): runs\n * when Gyral removes the element, when the position stops holding this hook, or when the host\n * disconnects (not on moves). After a host reconnects, `client` runs again with `prev`\n * undefined.\n */\n dispose?(el: Element, args: A): void;\n}\n\n/** What a hook returns in a template: `<input ${invalid(errors)}>`. */\nexport interface HookResult<A extends readonly unknown[] = readonly unknown[]> {\n readonly [HOOK]: HookSpec<A>;\n readonly [COMMIT_HOOK]: (part: HookPart, result: HookResult) => void;\n readonly args: A;\n}\n\n/** A hook position as committing sees it (an element part of kind HOOK). */\nexport interface HookPart {\n readonly el: Element;\n spec: HookSpec<readonly unknown[]> | null;\n args: readonly unknown[] | undefined;\n prev: readonly unknown[] | undefined;\n /** dispose.ts: the tracked disposable hook, its last arguments, and whether a disconnect\n * disposed it (`client` runs again after the next render). */\n kept?: HookSpec<readonly unknown[]> | undefined;\n keptArgs?: readonly unknown[] | undefined;\n off?: boolean | undefined;\n /** The render root it was queued for (hook-run.ts: failures, order). */\n owner?: Node | undefined;\n}\n\nexport const isHook = (value: unknown): value is HookResult =>\n typeof value === 'object' && value !== null && HOOK in value;\n\n/** The spec of a hook result, or undefined for anything else. */\nexport const hookSpec = (value: unknown): HookSpec<readonly unknown[]> | undefined =>\n isHook(value) ? value[HOOK] : undefined;\n\n/** Internal (hook-part.ts): a hook result. */\nexport const hookResult = <A extends readonly unknown[]>(\n spec: HookSpec<A>,\n args: A,\n commit: HookResult[typeof COMMIT_HOOK],\n): HookResult<A> => ({ [HOOK]: spec, [COMMIT_HOOK]: commit, args });\n\n/** Shallow comparison of two argument lists, `Object.is` per argument. */\nexport function sameArgs(a: readonly unknown[], b: readonly unknown[] | undefined): boolean {\n if (b === undefined || a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i])) return false;\n return true;\n}\n\n/**\n * Hook disposal (dispose.ts), set when the first disposable hook commits: `disposal(root)`\n * after a render of `root` commits (before its client calls), `disposal(root, true)` when the\n * host owning `root` disconnects (true when hooks wait to run `client` again after the next\n * render). A plain variable, not an object, to keep apps without it small.\n */\nlet disposal: ((root: Node, disconnect?: boolean) => boolean) | undefined;\n\n/** Internal (dispose.ts): turns hook disposal on. */\nexport function useDisposal(run: (root: Node, disconnect?: boolean) => boolean): void {\n disposal = run;\n}\n\n/** How a hook with `dispose` commits (dispose.ts `commitTracked`), once registered. */\nexport let disposableCommit: ((part: HookPart, result: HookResult) => void) | undefined;\n\n/** Internal (`#spec-features`, use-disposal.ts): registers hook disposal. */\nexport function useDisposableHooks(commit: (part: HookPart, result: HookResult) => void): void {\n disposableCommit = commit;\n}\n\n/** The host owning `root` disconnected (element.ts): disposes its disposable hooks. */\nexport const suspendHooks = (root: Node | undefined): boolean | undefined =>\n disposal?.(root as Node, true);\n\n/** Internal (hook-run.ts): queued client calls. */\nexport const queue: HookPart[] = [];\n/** The root being committed, so `queueHook` knows the owner. */\nlet current: Node | undefined;\n\n/** Queues `part`'s client call for the end of the render, or of the flush. */\nexport function queueHook(part: HookPart): void {\n part.owner = current;\n queue.push(part);\n}\n\n/** The root being committed (dispose.ts tracks disposable hooks per root). */\nexport const committing = (): Node | undefined => current;\n\n/** Internal (hook-run.ts): sets the root being committed (disposal re-queues hooks for it). */\nexport function setCommitting(root: Node | undefined): void {\n current = root;\n}\n\n/** The queue position before a render of `root`, for `runHooks`/`dropHooks`. */\nexport function hookMark(root: Node): number {\n current = root;\n return queue.length;\n}\n\n/** Where a hook's failure goes (core reports it, ADR 0024); unset, `reportError`. */\nlet hookFailed: ((error: unknown, root: Node) => void) | undefined;\n\n/** Internal (core's element.ts): reports hook failures. */\nexport function onHookFailure(report: (error: unknown, root: Node) => void): void {\n hookFailed = report;\n}\n\n/** Internal (hook-run.ts): where failures go, and the disposal pass. */\nexport const hookFailure = (): ((error: unknown, root: Node) => void) => hookFailed ?? reportError;\nexport const disposalPass = (): typeof disposal => disposal;\n\n/**\n * What runs queued client calls (hook-run.ts): ordering, batching across a flush, failures.\n * Set by `defineHook`, so apps without hooks bundle none of it; without\n * hooks nothing is ever queued.\n */\nexport interface HookRunner {\n /** `root` committed: run its calls now, or note it for the end of the flush. */\n run(mark: number, root: Node): void;\n /** A flush starts. */\n start(): void;\n /** Runs the calls of every root rendered in the flush so far. */\n flush(): void;\n /** A flush ends: runs what's left (or drops it when the flush threw). */\n end(ok: boolean): void;\n}\n\nlet runner: HookRunner | undefined;\n\n/** Internal (hook-part.ts): installs the runner. */\nexport function useHookRunner(run: HookRunner): void {\n runner = run;\n}\n\n/** `root` committed: its queued `client` calls run now, or with the flush's (hook-run.ts). */\nexport function runHooks(mark: number, root: Node): void {\n current = undefined;\n runner?.run(mark, root);\n}\n\n/** A flush starts (render.ts `renderBatch`). */\nexport function startHooks(): void {\n runner?.start();\n}\n\n/** Runs the hooks of every root rendered in this flush so far (the scheduler, after each pass). */\nexport function flushHooks(): void {\n runner?.flush();\n}\n\n/** A flush ends. */\nexport function endHooks(ok: boolean): void {\n runner?.end(ok);\n}\n\n/** Forgets the calls queued since `mark` (the render threw). */\nexport function dropHooks(mark: number): void {\n queue.length = mark;\n current = undefined;\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import { type SeenMarkup } from './seen.js';
2
+ import type { ChildValue } from './values.js';
3
+ /**
4
+ * Hydrates the server-rendered DOM in `root` with `value`, the first client render
5
+ * (view/07-hydration.md): builds the parts over the existing nodes, runs element hooks' client
6
+ * halves once, and leaves later `render` calls to update in place. Throws `HydrationMismatch`
7
+ * when the DOM doesn't match; `host` names the component in its message; `seen` is as for
8
+ * `render`.
9
+ */
10
+ export declare function hydrate(value: ChildValue, root: Element | ShadowRoot, host?: string, seen?: SeenMarkup): void;
@@ -0,0 +1,33 @@
1
+ // `hydrate(value, root)` (view/07-hydration.md): the first client render of server-rendered DOM.
2
+ // Kept apart from render.ts so the walk (adopt.ts) is bundled only where hydration is used: core
3
+ // loads it lazily, with the first server-rendered host (07 "Loading").
4
+ import { adopt } from './adopt.js';
5
+ import { ChildPart } from './child-part.js';
6
+ import { dropHooks, hookMark, runHooks } from './hooks.js';
7
+ import { setRootPart } from './render.js';
8
+ import { listenFor } from './seen.js';
9
+ /**
10
+ * Hydrates the server-rendered DOM in `root` with `value`, the first client render
11
+ * (view/07-hydration.md): builds the parts over the existing nodes, runs element hooks' client
12
+ * halves once, and leaves later `render` calls to update in place. Throws `HydrationMismatch`
13
+ * when the DOM doesn't match; `host` names the component in its message; `seen` is as for
14
+ * `render`.
15
+ */
16
+ export function hydrate(value, root, host = 'the root', seen) {
17
+ const part = new ChildPart(root, null, null, 0, false, 0);
18
+ const mark = hookMark(root);
19
+ const outer = listenFor(seen);
20
+ try {
21
+ adopt(part, value, root, host);
22
+ }
23
+ catch (error) {
24
+ dropHooks(mark);
25
+ throw error;
26
+ }
27
+ finally {
28
+ listenFor(outer);
29
+ }
30
+ setRootPart(root, part);
31
+ runHooks(mark, root);
32
+ }
33
+ //# sourceMappingURL=hydrate.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hydrate.js","sourceRoot":"","sources":["../../../src/view/render/hydrate.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,iGAAiG;AACjG,uEAAuE;AACvE,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAmB,MAAM,WAAW,CAAC;AAGvD;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CACrB,KAAiB,EACjB,IAA0B,EAC1B,IAAI,GAAG,UAAU,EACjB,IAAiB;IAEjB,MAAM,IAAI,GAAG,IAAI,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC;IAC1D,MAAM,IAAI,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC;IAC9B,IAAI,CAAC;QACH,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC;IACjC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,SAAS,CAAC,IAAI,CAAC,CAAC;QAChB,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,KAAK,CAAC,CAAC;IACnB,CAAC;IACD,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACvB,CAAC","sourcesContent":["// `hydrate(value, root)` (view/07-hydration.md): the first client render of server-rendered DOM.\n// Kept apart from render.ts so the walk (adopt.ts) is bundled only where hydration is used: core\n// loads it lazily, with the first server-rendered host (07 \"Loading\").\nimport { adopt } from './adopt.js';\nimport { ChildPart } from './child-part.js';\nimport { dropHooks, hookMark, runHooks } from './hooks.js';\nimport { setRootPart } from './render.js';\nimport { listenFor, type SeenMarkup } from './seen.js';\nimport type { ChildValue } from './values.js';\n\n/**\n * Hydrates the server-rendered DOM in `root` with `value`, the first client render\n * (view/07-hydration.md): builds the parts over the existing nodes, runs element hooks' client\n * halves once, and leaves later `render` calls to update in place. Throws `HydrationMismatch`\n * when the DOM doesn't match; `host` names the component in its message; `seen` is as for\n * `render`.\n */\nexport function hydrate(\n value: ChildValue,\n root: Element | ShadowRoot,\n host = 'the root',\n seen?: SeenMarkup,\n): void {\n const part = new ChildPart(root, null, null, 0, false, 0);\n const mark = hookMark(root);\n const outer = listenFor(seen);\n try {\n adopt(part, value, root, host);\n } catch (error) {\n dropHooks(mark);\n throw error;\n } finally {\n listenFor(outer);\n }\n setRootPart(root, part);\n runHooks(mark, root);\n}\n"]}
@@ -0,0 +1,33 @@
1
+ import type { TemplateObject } from '../normalize/types.js';
2
+ import { type Part } from './attr-parts.js';
3
+ import { ChildPart, type Owner } from './child-part.js';
4
+ /** The DOM cloned from one template, plus its parts. */
5
+ export declare class Instance implements Owner {
6
+ readonly template: TemplateObject;
7
+ /** The result source last rendered (strings array or compiled object), for a fast compare. */
8
+ source: unknown;
9
+ /** The child part whose content this instance is. */
10
+ readonly holder: ChildPart;
11
+ readonly parts: Part[];
12
+ /** First and last static root nodes; null when the template is a single hole. */
13
+ start: Node | null;
14
+ end: Node | null;
15
+ /** Root-level child parts before the first / after the last static root node. */
16
+ head: ChildPart | null;
17
+ tail: ChildPart | null;
18
+ /** The clone, until it is inserted. */
19
+ frag: DocumentFragment | null;
20
+ /** `adopt`: hydration (adopt.ts) fills the parts and root nodes from server DOM instead. */
21
+ constructor(template: TemplateObject, source: unknown, holder: ChildPart, adopt?: boolean);
22
+ private build;
23
+ /** Commits this render's values, part by part in document order. */
24
+ update(values: readonly unknown[]): void;
25
+ /** Inserts the (committed) clone; afterwards root-level parts resolve through the holder. */
26
+ insert(parent: Node, before: Node | null): void;
27
+ first(): Node | null;
28
+ last(): Node | null;
29
+ remove(): void;
30
+ /** Owner of root-level open parts: the clone while building, then the holder's parent. */
31
+ parentFor(): Node;
32
+ endFor(): Node | null;
33
+ }
@@ -0,0 +1,107 @@
1
+ import { attrPart } from './attr-parts.js';
2
+ import { ChildPart } from './child-part.js';
3
+ import { removeRange } from './nodes.js';
4
+ import { report } from './seen.js';
5
+ import { CHILD, nodes, planOf, ROOT, stack, walk } from './plan.js';
6
+ /** The DOM cloned from one template, plus its parts. */
7
+ export class Instance {
8
+ /** `adopt`: hydration (adopt.ts) fills the parts and root nodes from server DOM instead. */
9
+ constructor(template, source, holder, adopt) {
10
+ this.template = template;
11
+ this.source = source;
12
+ this.holder = holder;
13
+ this.parts = [];
14
+ this.head = null;
15
+ this.tail = null;
16
+ this.frag = this.start = this.end = null;
17
+ report(template);
18
+ if (adopt === true)
19
+ return;
20
+ const plan = planOf(template);
21
+ if (plan.single) {
22
+ const root = document.importNode(plan.content.firstChild, true);
23
+ stack[1] = root;
24
+ this.start = this.end = root;
25
+ }
26
+ else {
27
+ const frag = document.importNode(plan.content, true);
28
+ stack[0] = frag;
29
+ this.frag = frag;
30
+ this.start = frag.firstChild;
31
+ this.end = frag.lastChild;
32
+ }
33
+ walk(plan);
34
+ this.build(plan);
35
+ }
36
+ build(plan) {
37
+ const { a, b, at, kinds } = plan;
38
+ const specs = this.template.parts;
39
+ for (let i = 0; i < kinds.length; i++) {
40
+ const kind = kinds[i];
41
+ const node = nodes[a[i]];
42
+ if (kind >= 0) {
43
+ this.parts.push(attrPart(node, kind, specs[i], at[i]));
44
+ continue;
45
+ }
46
+ const r = b[i];
47
+ const ref = r >= 0 ? nodes[r] : null;
48
+ if (kind !== ROOT) {
49
+ this.parts.push(new ChildPart(node, ref, null, 0, kind !== CHILD, at[i]));
50
+ continue;
51
+ }
52
+ const part = new ChildPart(null, ref, ref === null ? this : null, 0, false, at[i]);
53
+ if (ref === null)
54
+ this.tail = part;
55
+ else if (ref === this.start)
56
+ this.head = part;
57
+ this.parts.push(part);
58
+ }
59
+ }
60
+ /** Commits this render's values, part by part in document order. */
61
+ update(values) {
62
+ const parts = this.parts;
63
+ for (let i = 0; i < parts.length; i++)
64
+ parts[i].set(values);
65
+ }
66
+ /** Inserts the (committed) clone; afterwards root-level parts resolve through the holder. */
67
+ insert(parent, before) {
68
+ parent.insertBefore(this.frag ?? this.start, before);
69
+ this.frag = null;
70
+ }
71
+ first() {
72
+ const head = this.head !== null ? this.head.first() : null;
73
+ if (head !== null)
74
+ return head;
75
+ if (this.start !== null)
76
+ return this.start;
77
+ return this.tail !== null ? this.tail.first() : null;
78
+ }
79
+ last() {
80
+ const tail = this.tail !== null ? this.tail.last() : null;
81
+ if (tail !== null)
82
+ return tail;
83
+ if (this.end !== null)
84
+ return this.end;
85
+ return this.head !== null ? this.head.last() : null;
86
+ }
87
+ remove() {
88
+ const first = this.first();
89
+ if (first === null)
90
+ return;
91
+ const last = this.last();
92
+ if (first === last)
93
+ first.remove();
94
+ else
95
+ removeRange(first, last);
96
+ }
97
+ /** Owner of root-level open parts: the clone while building, then the holder's parent. */
98
+ parentFor() {
99
+ if (this.frag !== null)
100
+ return this.frag;
101
+ return this.start !== null ? this.start.parentNode : this.holder.parent();
102
+ }
103
+ endFor() {
104
+ return this.frag !== null ? null : this.holder.end();
105
+ }
106
+ }
107
+ //# sourceMappingURL=instance.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"instance.js","sourceRoot":"","sources":["../../../src/view/render/instance.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,QAAQ,EAAa,MAAM,iBAAiB,CAAC;AACtD,OAAO,EAAE,SAAS,EAAc,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAa,MAAM,WAAW,CAAC;AAE/E,wDAAwD;AACxD,MAAM,OAAO,QAAQ;IAgBnB,4FAA4F;IAC5F,YAAY,QAAwB,EAAE,MAAe,EAAE,MAAiB,EAAE,KAAe;QACvF,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAA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AAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,CAAC;IAED,MAAM;QACJ,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;QAC3B,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO;QAC3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,EAAU,CAAC;QACjC,IAAI,KAAK,KAAK,IAAI;YAAG,KAAmB,CAAC,MAAM,EAAE,CAAC;;YAC7C,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,0FAA0F;IAC1F,SAAS;QACP,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC,IAAI,CAAC;QACzC,OAAO,IAAI,CAAC,KAAK,KAAK,IAAI,CAAC,CAAC,CAAE,IAAI,CAAC,KAAK,CAAC,UAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;IACtF,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACvD,CAAC;CACF","sourcesContent":["// Template instances (view/01-templates.md \"Instantiation\", view/02-bindings.md \"Commit order\").\n// An instance is cloned with `document.importNode` (nested custom elements upgrade at once),\n// every part's nodes are resolved from the clone first by child-index paths (firstChild/\n// nextSibling, sharing prefixes; no TreeWalker, no marker search), then the values commit while\n// the clone is still detached, and only then is it inserted, so child components connect with\n// their props set. A template with one root node and no root-level holes clones just that node.\n// How to reach the nodes, and what each part is, comes from the template's plan (plan.ts).\n// Hydration (adopt.ts) creates instances with `adopt` set and fills them from server DOM.\nimport type { PartSpec, TemplateObject } from '../normalize/types.js';\nimport { attrPart, type Part } from './attr-parts.js';\nimport { ChildPart, type Owner } from './child-part.js';\nimport { removeRange } from './nodes.js';\nimport { report } from './seen.js';\nimport { CHILD, nodes, planOf, ROOT, stack, walk, type Plan } from './plan.js';\n\n/** The DOM cloned from one template, plus its parts. */\nexport class Instance implements Owner {\n readonly template: TemplateObject;\n /** The result source last rendered (strings array or compiled object), for a fast compare. */\n source: unknown;\n /** The child part whose content this instance is. */\n readonly holder: ChildPart;\n readonly parts: Part[];\n /** First and last static root nodes; null when the template is a single hole. */\n start: Node | null;\n end: Node | null;\n /** Root-level child parts before the first / after the last static root node. */\n head: ChildPart | null;\n tail: ChildPart | null;\n /** The clone, until it is inserted. */\n frag: DocumentFragment | null;\n\n /** `adopt`: hydration (adopt.ts) fills the parts and root nodes from server DOM instead. */\n constructor(template: TemplateObject, source: unknown, holder: ChildPart, adopt?: boolean) {\n this.template = template;\n this.source = source;\n this.holder = holder;\n this.parts = [];\n this.head = null;\n this.tail = null;\n this.frag = this.start = this.end = null;\n report(template);\n if (adopt === true) return;\n const plan = planOf(template);\n if (plan.single) {\n const root = document.importNode(plan.content.firstChild as Node, true);\n stack[1] = root;\n this.start = this.end = root;\n } else {\n const frag = document.importNode(plan.content, true);\n stack[0] = frag;\n this.frag = frag;\n this.start = frag.firstChild;\n this.end = frag.lastChild;\n }\n walk(plan);\n this.build(plan);\n }\n\n private build(plan: Plan): void {\n const { a, b, at, kinds } = plan;\n const specs = this.template.parts;\n for (let i = 0; i < kinds.length; i++) {\n const kind = kinds[i] as number;\n const node = nodes[a[i] as number] as Element;\n if (kind >= 0) {\n this.parts.push(attrPart(node, kind, specs[i] as PartSpec, at[i] as number));\n continue;\n }\n const r = b[i] as number;\n const ref = r >= 0 ? (nodes[r] as Node) : null;\n if (kind !== ROOT) {\n this.parts.push(new ChildPart(node, ref, null, 0, kind !== CHILD, at[i] as number));\n continue;\n }\n const part = new ChildPart(null, ref, ref === null ? this : null, 0, false, at[i] as number);\n if (ref === null) this.tail = part;\n else if (ref === this.start) this.head = part;\n this.parts.push(part);\n }\n }\n\n /** Commits this render's values, part by part in document order. */\n update(values: readonly unknown[]): void {\n const parts = this.parts;\n for (let i = 0; i < parts.length; i++) (parts[i] as Part).set(values);\n }\n\n /** Inserts the (committed) clone; afterwards root-level parts resolve through the holder. */\n insert(parent: Node, before: Node | null): void {\n parent.insertBefore(this.frag ?? (this.start as Node), before);\n this.frag = null;\n }\n\n first(): Node | null {\n const head = this.head !== null ? this.head.first() : null;\n if (head !== null) return head;\n if (this.start !== null) return this.start;\n return this.tail !== null ? this.tail.first() : null;\n }\n\n last(): Node | null {\n const tail = this.tail !== null ? this.tail.last() : null;\n if (tail !== null) return tail;\n if (this.end !== null) return this.end;\n return this.head !== null ? this.head.last() : null;\n }\n\n remove(): void {\n const first = this.first();\n if (first === null) return;\n const last = this.last() as Node;\n if (first === last) (first as ChildNode).remove();\n else removeRange(first, last);\n }\n\n /** Owner of root-level open parts: the clone while building, then the holder's parent. */\n parentFor(): Node {\n if (this.frag !== null) return this.frag;\n return this.start !== null ? (this.start.parentNode as Node) : this.holder.parent();\n }\n\n endFor(): Node | null {\n return this.frag !== null ? null : this.holder.end();\n }\n}\n"]}
@@ -0,0 +1,6 @@
1
+ import type { ChildValue, ListResult } from './values.js';
2
+ /**
3
+ * Renders `value`, and replaces it with a fresh copy whenever `key` changes: a form cleared
4
+ * after sending, a CSS animation restarted, a child component reset.
5
+ */
6
+ export declare function keyed(key: string | number, value: ChildValue): ListResult;
@@ -0,0 +1,15 @@
1
+ // keyed(key, value): a child value that is recreated, DOM and nested component state included,
2
+ // whenever its key changes (view/03-lists.md "keyed"). It is a one-row each(), so it reuses the
3
+ // keyed list's reconciliation, server writer and hydration walk, and costs nothing in apps that
4
+ // don't call it.
5
+ import { each } from './list.js';
6
+ // One shared row function: each()'s development purity check is keyed by it.
7
+ const itself = (value) => value;
8
+ /**
9
+ * Renders `value`, and replaces it with a fresh copy whenever `key` changes: a form cleared
10
+ * after sending, a CSS animation restarted, a child component reset.
11
+ */
12
+ export function keyed(key, value) {
13
+ return each([value], () => key, itself);
14
+ }
15
+ //# sourceMappingURL=keyed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keyed.js","sourceRoot":"","sources":["../../../src/view/render/keyed.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,gGAAgG;AAChG,gGAAgG;AAChG,iBAAiB;AACjB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,6EAA6E;AAC7E,MAAM,MAAM,GAAG,CAAC,KAAiB,EAAc,EAAE,CAAC,KAAK,CAAC;AAExD;;;GAGG;AACH,MAAM,UAAU,KAAK,CAAC,GAAoB,EAAE,KAAiB;IAC3D,OAAO,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;AAC1C,CAAC","sourcesContent":["// keyed(key, value): a child value that is recreated, DOM and nested component state included,\n// whenever its key changes (view/03-lists.md \"keyed\"). It is a one-row each(), so it reuses the\n// keyed list's reconciliation, server writer and hydration walk, and costs nothing in apps that\n// don't call it.\nimport { each } from './list.js';\nimport type { ChildValue, ListResult } from './values.js';\n\n// One shared row function: each()'s development purity check is keyed by it.\nconst itself = (value: ChildValue): ChildValue => value;\n\n/**\n * Renders `value`, and replaces it with a fresh copy whenever `key` changes: a form cleared\n * after sending, a CSS animation restarted, a child component reset.\n */\nexport function keyed(key: string | number, value: ChildValue): ListResult {\n return each([value], () => key, itself);\n}\n"]}
@@ -0,0 +1,20 @@
1
+ import { ChildPart } from './child-part.js';
2
+ import { List } from './rows.js';
3
+ import { type ChildValue, type ListResult } from './values.js';
4
+ export { List } from './rows.js';
5
+ /** Removes every row; the list's part keeps its (now empty) list. */
6
+ export declare function clearList(part: ChildPart, list: List): void;
7
+ /**
8
+ * Creates rows for `l.items[from…to]` (keys from `keys[i - from]` when given) into one
9
+ * fragment, pushes them onto `rows` and inserts the fragment before `end`.
10
+ */
11
+ export declare function createRows(part: ChildPart, list: List, l: ListResult, rows: ChildPart[], from: number, to: number, end: Node | null, keys?: readonly unknown[]): void;
12
+ /**
13
+ * A keyed list (view/03-lists.md). `key` must give each item a unique string or number; `row`
14
+ * must depend only on its arguments: a row re-renders only when its item object or its `pick`
15
+ * result changes.
16
+ */
17
+ export declare function each<T>(items: readonly T[], key: (item: T) => string | number, row: (item: T) => ChildValue): ListResult;
18
+ export declare function each<T, P>(items: readonly T[], key: (item: T) => string | number, row: (item: T, picked: P) => ChildValue, pick: (item: T) => P): ListResult;
19
+ /** A positional array: items reused by index (view/02-bindings.md "Child values"). */
20
+ export declare function commitItems(part: ChildPart, values: readonly unknown[]): void;