@gyral/core 0.3.0 → 0.3.2

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 (386) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/NOTICE +19 -0
  3. package/README.md +36 -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 +25 -3
  8. package/dist/children.js +18 -1
  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 +25 -11
  15. package/dist/command.js.map +1 -1
  16. package/dist/compiler/ast.d.ts +2 -0
  17. package/dist/compiler/ast.js +5 -1
  18. package/dist/compiler/ast.js.map +1 -1
  19. package/dist/compiler/compile.d.ts +5 -2
  20. package/dist/compiler/compile.js +36 -17
  21. package/dist/compiler/compile.js.map +1 -1
  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 +190 -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 +4 -0
  35. package/dist/compiler/hooks.js +144 -89
  36. package/dist/compiler/hooks.js.map +1 -1
  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 +90 -0
  42. package/dist/compiler/locate.js.map +1 -0
  43. package/dist/compiler/parse5-check.d.ts +1 -1
  44. package/dist/compiler/parse5-check.js +8 -3
  45. package/dist/compiler/parse5-check.js.map +1 -1
  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 +13 -3
  50. package/dist/compiler/scan.js +21 -13
  51. package/dist/compiler/scan.js.map +1 -1
  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/tag-map.d.ts +41 -0
  56. package/dist/compiler/tag-map.js +126 -0
  57. package/dist/compiler/tag-map.js.map +1 -0
  58. package/dist/components-ready.d.ts +7 -0
  59. package/dist/components-ready.js +19 -0
  60. package/dist/components-ready.js.map +1 -0
  61. package/dist/define.d.ts +12 -4
  62. package/dist/define.js +8 -12
  63. package/dist/define.js.map +1 -1
  64. package/dist/devtools-events.d.ts +8 -0
  65. package/dist/devtools-events.js.map +1 -1
  66. package/dist/devtools-off.d.ts +1 -0
  67. package/dist/devtools-off.js +1 -0
  68. package/dist/devtools-off.js.map +1 -1
  69. package/dist/devtools.d.ts +3 -0
  70. package/dist/devtools.js +14 -0
  71. package/dist/devtools.js.map +1 -1
  72. package/dist/drivers-scope.js.map +1 -1
  73. package/dist/element-internals.d.ts +1 -0
  74. package/dist/element-internals.js +11 -0
  75. package/dist/element-internals.js.map +1 -0
  76. package/dist/element-types.d.ts +7 -4
  77. package/dist/element-types.js.map +1 -1
  78. package/dist/element.js +80 -27
  79. package/dist/element.js.map +1 -1
  80. package/dist/error-view.d.ts +10 -0
  81. package/dist/error-view.js +30 -0
  82. package/dist/error-view.js.map +1 -0
  83. package/dist/errors.d.ts +21 -0
  84. package/dist/errors.js +47 -0
  85. package/dist/errors.js.map +1 -0
  86. package/dist/errors.json +289 -0
  87. package/dist/eslint/imports.d.ts +2 -0
  88. package/dist/eslint/imports.js +2 -2
  89. package/dist/eslint/imports.js.map +1 -1
  90. package/dist/eslint/index.d.ts +2 -1
  91. package/dist/eslint/index.js +11 -3
  92. package/dist/eslint/index.js.map +1 -1
  93. package/dist/eslint/template-rule.d.ts +1 -0
  94. package/dist/eslint/template-rule.js +15 -5
  95. package/dist/eslint/template-rule.js.map +1 -1
  96. package/dist/eslint/unused-intent-rule.d.ts +2 -0
  97. package/dist/eslint/unused-intent-rule.js +186 -0
  98. package/dist/eslint/unused-intent-rule.js.map +1 -0
  99. package/dist/features.d.ts +2 -2
  100. package/dist/features.js.map +1 -1
  101. package/dist/focus.d.ts +6 -0
  102. package/dist/focus.js +32 -2
  103. package/dist/focus.js.map +1 -1
  104. package/dist/form-associated.d.ts +46 -0
  105. package/dist/form-associated.js +77 -0
  106. package/dist/form-associated.js.map +1 -0
  107. package/dist/forms.d.ts +42 -30
  108. package/dist/forms.js +85 -41
  109. package/dist/forms.js.map +1 -1
  110. package/dist/frame-lane.d.ts +11 -0
  111. package/dist/frame-lane.js +28 -0
  112. package/dist/frame-lane.js.map +1 -0
  113. package/dist/head.d.ts +61 -0
  114. package/dist/head.js +85 -0
  115. package/dist/head.js.map +1 -0
  116. package/dist/host-model.d.ts +34 -5
  117. package/dist/host-model.js +146 -23
  118. package/dist/host-model.js.map +1 -1
  119. package/dist/hydration-client.js +2 -2
  120. package/dist/hydration-client.js.map +1 -1
  121. package/dist/hydration-loader.d.ts +13 -0
  122. package/dist/hydration-loader.js +58 -0
  123. package/dist/hydration-loader.js.map +1 -0
  124. package/dist/hydration-off.d.ts +8 -0
  125. package/dist/hydration-off.js +25 -0
  126. package/dist/hydration-off.js.map +1 -0
  127. package/dist/hydration.d.ts +0 -12
  128. package/dist/hydration.js +3 -52
  129. package/dist/hydration.js.map +1 -1
  130. package/dist/index.d.ts +21 -24
  131. package/dist/index.js +10 -19
  132. package/dist/index.js.map +1 -1
  133. package/dist/indexeddb-types.d.ts +97 -0
  134. package/dist/indexeddb-types.js +2 -0
  135. package/dist/indexeddb-types.js.map +1 -0
  136. package/dist/indexeddb.d.ts +5 -0
  137. package/dist/indexeddb.js +118 -0
  138. package/dist/indexeddb.js.map +1 -0
  139. package/dist/intent.d.ts +42 -20
  140. package/dist/intent.js +145 -107
  141. package/dist/intent.js.map +1 -1
  142. package/dist/internal/indexeddb-open.d.ts +8 -0
  143. package/dist/internal/indexeddb-open.js +96 -0
  144. package/dist/internal/indexeddb-open.js.map +1 -0
  145. package/dist/internal/indexeddb-transaction.d.ts +4 -0
  146. package/dist/internal/indexeddb-transaction.js +134 -0
  147. package/dist/internal/indexeddb-transaction.js.map +1 -0
  148. package/dist/internal/interpreter.d.ts +12 -4
  149. package/dist/internal/interpreter.js +36 -48
  150. package/dist/internal/interpreter.js.map +1 -1
  151. package/dist/internal/token.d.ts +1 -0
  152. package/dist/internal/token.js +7 -0
  153. package/dist/internal/token.js.map +1 -0
  154. package/dist/internal.d.ts +20 -0
  155. package/dist/internal.js +22 -0
  156. package/dist/internal.js.map +1 -0
  157. package/dist/invoker-fallback-used.d.ts +4 -0
  158. package/dist/invoker-fallback-used.js +10 -0
  159. package/dist/invoker-fallback-used.js.map +1 -0
  160. package/dist/invoker-fallback.d.ts +4 -0
  161. package/dist/invoker-fallback.js +15 -0
  162. package/dist/invoker-fallback.js.map +1 -0
  163. package/dist/light-dom.d.ts +1 -1
  164. package/dist/light-dom.js.map +1 -1
  165. package/dist/prop.d.ts +30 -7
  166. package/dist/prop.js +19 -0
  167. package/dist/prop.js.map +1 -1
  168. package/dist/props.d.ts +8 -3
  169. package/dist/props.js +22 -15
  170. package/dist/props.js.map +1 -1
  171. package/dist/retry.d.ts +15 -0
  172. package/dist/retry.js +48 -0
  173. package/dist/retry.js.map +1 -0
  174. package/dist/scheduler.d.ts +7 -3
  175. package/dist/scheduler.js +38 -56
  176. package/dist/scheduler.js.map +1 -1
  177. package/dist/script-json.d.ts +2 -0
  178. package/dist/script-json.js +13 -0
  179. package/dist/script-json.js.map +1 -0
  180. package/dist/server-component.d.ts +1 -1
  181. package/dist/server-component.js +45 -14
  182. package/dist/server-component.js.map +1 -1
  183. package/dist/server.d.ts +9 -3
  184. package/dist/server.js +12 -3
  185. package/dist/server.js.map +1 -1
  186. package/dist/settled.d.ts +4 -3
  187. package/dist/settled.js +48 -26
  188. package/dist/settled.js.map +1 -1
  189. package/dist/spec-features-used.d.ts +21 -0
  190. package/dist/spec-features-used.js +50 -0
  191. package/dist/spec-features-used.js.map +1 -0
  192. package/dist/spec-features.d.ts +28 -0
  193. package/dist/spec-features.js +42 -0
  194. package/dist/spec-features.js.map +1 -0
  195. package/dist/states.d.ts +3 -5
  196. package/dist/states.js +22 -8
  197. package/dist/states.js.map +1 -1
  198. package/dist/storage.d.ts +69 -0
  199. package/dist/storage.js +158 -0
  200. package/dist/storage.js.map +1 -0
  201. package/dist/store-binding.js +2 -2
  202. package/dist/store-binding.js.map +1 -1
  203. package/dist/store-scope.d.ts +2 -4
  204. package/dist/store-scope.js +6 -16
  205. package/dist/store-scope.js.map +1 -1
  206. package/dist/store.d.ts +2 -6
  207. package/dist/store.js +36 -8
  208. package/dist/store.js.map +1 -1
  209. package/dist/subscription.d.ts +35 -0
  210. package/dist/subscription.js +74 -0
  211. package/dist/subscription.js.map +1 -0
  212. package/dist/subscriptions.d.ts +26 -0
  213. package/dist/subscriptions.js +98 -0
  214. package/dist/subscriptions.js.map +1 -0
  215. package/dist/transitions.d.ts +4 -5
  216. package/dist/transitions.js +10 -4
  217. package/dist/transitions.js.map +1 -1
  218. package/dist/types.d.ts +141 -32
  219. package/dist/types.js.map +1 -1
  220. package/dist/use-dialogs.d.ts +2 -0
  221. package/dist/use-dialogs.js +9 -0
  222. package/dist/use-dialogs.js.map +1 -0
  223. package/dist/use-disposal.d.ts +2 -0
  224. package/dist/use-disposal.js +9 -0
  225. package/dist/use-disposal.js.map +1 -0
  226. package/dist/use-error-view.d.ts +2 -0
  227. package/dist/use-error-view.js +9 -0
  228. package/dist/use-error-view.js.map +1 -0
  229. package/dist/use-errored.d.ts +2 -0
  230. package/dist/use-errored.js +9 -0
  231. package/dist/use-errored.js.map +1 -0
  232. package/dist/use-form-associated.d.ts +2 -0
  233. package/dist/use-form-associated.js +7 -0
  234. package/dist/use-form-associated.js.map +1 -0
  235. package/dist/use-frame-lane.d.ts +2 -0
  236. package/dist/use-frame-lane.js +10 -0
  237. package/dist/use-frame-lane.js.map +1 -0
  238. package/dist/use-invokers.d.ts +2 -0
  239. package/dist/use-invokers.js +10 -0
  240. package/dist/use-invokers.js.map +1 -0
  241. package/dist/use-states.d.ts +2 -0
  242. package/dist/use-states.js +10 -0
  243. package/dist/use-states.js.map +1 -0
  244. package/dist/use-subscriptions.d.ts +2 -0
  245. package/dist/use-subscriptions.js +10 -0
  246. package/dist/use-subscriptions.js.map +1 -0
  247. package/dist/use-transitions.d.ts +2 -0
  248. package/dist/use-transitions.js +10 -0
  249. package/dist/use-transitions.js.map +1 -0
  250. package/dist/view/attributes.d.ts +5 -0
  251. package/dist/view/attributes.js +5 -0
  252. package/dist/view/attributes.js.map +1 -1
  253. package/dist/view/compiled.d.ts +1 -1
  254. package/dist/view/compiled.js +1 -1
  255. package/dist/view/compiled.js.map +1 -1
  256. package/dist/view/index.d.ts +9 -4
  257. package/dist/view/index.js +9 -3
  258. package/dist/view/index.js.map +1 -1
  259. package/dist/view/loc.d.ts +9 -0
  260. package/dist/view/loc.js +50 -0
  261. package/dist/view/loc.js.map +1 -0
  262. package/dist/view/message.d.ts +17 -0
  263. package/dist/view/message.js +40 -0
  264. package/dist/view/message.js.map +1 -0
  265. package/dist/view/messages.d.ts +43 -0
  266. package/dist/view/messages.js +84 -0
  267. package/dist/view/messages.js.map +1 -0
  268. package/dist/view/normalize/check.d.ts +5 -2
  269. package/dist/view/normalize/check.js +6 -3
  270. package/dist/view/normalize/check.js.map +1 -1
  271. package/dist/view/normalize/emit.d.ts +2 -0
  272. package/dist/view/normalize/emit.js +40 -11
  273. package/dist/view/normalize/emit.js.map +1 -1
  274. package/dist/view/normalize/errors.js +1 -1
  275. package/dist/view/normalize/errors.js.map +1 -1
  276. package/dist/view/normalize/id.d.ts +5 -2
  277. package/dist/view/normalize/id.js +9 -2
  278. package/dist/view/normalize/id.js.map +1 -1
  279. package/dist/view/normalize/normalize.d.ts +7 -4
  280. package/dist/view/normalize/normalize.js +15 -9
  281. package/dist/view/normalize/normalize.js.map +1 -1
  282. package/dist/view/normalize/rules.d.ts +9 -0
  283. package/dist/view/normalize/rules.js +35 -5
  284. package/dist/view/normalize/rules.js.map +1 -1
  285. package/dist/view/normalize/svg.d.ts +14 -0
  286. package/dist/view/normalize/svg.js +40 -0
  287. package/dist/view/normalize/svg.js.map +1 -0
  288. package/dist/view/normalize/tokens.d.ts +5 -1
  289. package/dist/view/normalize/tokens.js.map +1 -1
  290. package/dist/view/normalize/tree.d.ts +8 -2
  291. package/dist/view/normalize/tree.js +58 -13
  292. package/dist/view/normalize/tree.js.map +1 -1
  293. package/dist/view/normalize/types.d.ts +24 -4
  294. package/dist/view/normalize/types.js +4 -1
  295. package/dist/view/normalize/types.js.map +1 -1
  296. package/dist/view/normalize/whitespace.js +4 -3
  297. package/dist/view/normalize/whitespace.js.map +1 -1
  298. package/dist/view/prepare-stub.js +2 -2
  299. package/dist/view/prepare-stub.js.map +1 -1
  300. package/dist/view/prepare.d.ts +5 -2
  301. package/dist/view/prepare.js +9 -3
  302. package/dist/view/prepare.js.map +1 -1
  303. package/dist/view/registry.d.ts +15 -0
  304. package/dist/view/registry.js +10 -2
  305. package/dist/view/registry.js.map +1 -1
  306. package/dist/view/render/adopt-attr.js +7 -1
  307. package/dist/view/render/adopt-attr.js.map +1 -1
  308. package/dist/view/render/adopt.js +21 -4
  309. package/dist/view/render/adopt.js.map +1 -1
  310. package/dist/view/render/attr-parts.d.ts +12 -1
  311. package/dist/view/render/attr-parts.js +38 -5
  312. package/dist/view/render/attr-parts.js.map +1 -1
  313. package/dist/view/render/child-part.js +5 -2
  314. package/dist/view/render/child-part.js.map +1 -1
  315. package/dist/view/render/dispose.d.ts +3 -0
  316. package/dist/view/render/dispose.js +76 -0
  317. package/dist/view/render/dispose.js.map +1 -0
  318. package/dist/view/render/hook-part.d.ts +3 -1
  319. package/dist/view/render/hook-part.js +21 -5
  320. package/dist/view/render/hook-part.js.map +1 -1
  321. package/dist/view/render/hook-run.d.ts +2 -0
  322. package/dist/view/render/hook-run.js +72 -0
  323. package/dist/view/render/hook-run.js.map +1 -0
  324. package/dist/view/render/hooks.d.ts +74 -6
  325. package/dist/view/render/hooks.js +79 -17
  326. package/dist/view/render/hooks.js.map +1 -1
  327. package/dist/view/render/hydrate.js +2 -2
  328. package/dist/view/render/hydrate.js.map +1 -1
  329. package/dist/view/render/keyed.d.ts +6 -0
  330. package/dist/view/render/keyed.js +15 -0
  331. package/dist/view/render/keyed.js.map +1 -0
  332. package/dist/view/render/list.d.ts +1 -1
  333. package/dist/view/render/list.js.map +1 -1
  334. package/dist/view/render/mismatch.js +5 -3
  335. package/dist/view/render/mismatch.js.map +1 -1
  336. package/dist/view/render/modal.d.ts +3 -0
  337. package/dist/view/render/modal.js +39 -0
  338. package/dist/view/render/modal.js.map +1 -0
  339. package/dist/view/render/raw.d.ts +4 -1
  340. package/dist/view/render/raw.js +6 -2
  341. package/dist/view/render/raw.js.map +1 -1
  342. package/dist/view/render/render.d.ts +4 -1
  343. package/dist/view/render/render.js +17 -12
  344. package/dist/view/render/render.js.map +1 -1
  345. package/dist/view/render/toggles.d.ts +6 -0
  346. package/dist/view/render/toggles.js +6 -0
  347. package/dist/view/render/toggles.js.map +1 -0
  348. package/dist/view/render/values.d.ts +1 -1
  349. package/dist/view/render/values.js.map +1 -1
  350. package/dist/view/render/warn.d.ts +14 -0
  351. package/dist/view/render/warn.js +45 -0
  352. package/dist/view/render/warn.js.map +1 -1
  353. package/dist/view/server/component.d.ts +6 -3
  354. package/dist/view/server/component.js +29 -7
  355. package/dist/view/server/component.js.map +1 -1
  356. package/dist/view/server/index.d.ts +20 -0
  357. package/dist/view/server/index.js +12 -4
  358. package/dist/view/server/index.js.map +1 -1
  359. package/dist/view/server/tags.d.ts +13 -2
  360. package/dist/view/server/tags.js +13 -2
  361. package/dist/view/server/tags.js.map +1 -1
  362. package/dist/view/server/values.d.ts +2 -0
  363. package/dist/view/server/values.js +8 -0
  364. package/dist/view/server/values.js.map +1 -1
  365. package/dist/view/server/writer.d.ts +9 -4
  366. package/dist/view/server/writer.js +33 -18
  367. package/dist/view/server/writer.js.map +1 -1
  368. package/dist/view/template-element.d.ts +7 -0
  369. package/dist/view/template-element.js +25 -5
  370. package/dist/view/template-element.js.map +1 -1
  371. package/dist/view/template.d.ts +9 -2
  372. package/dist/view/template.js +61 -8
  373. package/dist/view/template.js.map +1 -1
  374. package/dist/view/trusted-html.d.ts +6 -0
  375. package/dist/view/trusted-html.js +34 -0
  376. package/dist/view/trusted-html.js.map +1 -0
  377. package/dist/vite.d.ts +38 -31
  378. package/dist/vite.js +206 -31
  379. package/dist/vite.js.map +1 -1
  380. package/package.json +34 -3
  381. package/dist/hooks/labelled-by.d.ts +0 -13
  382. package/dist/hooks/labelled-by.js +0 -51
  383. package/dist/hooks/labelled-by.js.map +0 -1
  384. package/dist/random.d.ts +0 -13
  385. package/dist/random.js +0 -19
  386. package/dist/random.js.map +0 -1
@@ -2,10 +2,11 @@
2
2
  // structure (its parsed content) and the server DOM together, and builds the same parts the
3
3
  // client renderer would, with this render's values as committed values. It writes nothing,
4
4
  // except splitting merged text at known lengths (`splitText`), creating the empty Text node of
5
- // an `''` value, joining text the parser split, and removing development markers. Nested
6
- // templates, lists (rows one after another, no markers), arrays and `raw()` are walked in
7
- // turn. Nested Gyral hosts: a shadow host's light children are the parent's content (slotted)
8
- // and are walked; its shadow root never is; a light host (`data-gyral-light`) is opaque.
5
+ // an `''` value, joining text the parser split, removing development markers, and writing a
6
+ // `style` attribute a strict CSP blocked through the CSSOM. Nested templates, lists (rows one
7
+ // after another, no markers), arrays and `raw()` are walked in turn. Nested Gyral hosts: a
8
+ // shadow host's light children are the parent's content (slotted) and are walked; its shadow
9
+ // root never is; a light host (`data-gyral-light`) is opaque.
9
10
  // Development checks every node, text and bound attribute, and the `<!--gyral:ID-->` markers
10
11
  // when present; production checks node types, local names and text lengths.
11
12
  import { DEV } from '#view-dev';
@@ -105,6 +106,9 @@ function text(want) {
105
106
  }
106
107
  function instance(result, holder) {
107
108
  const template = templateOf(result);
109
+ if (DEV && template.svg && !svgContent(parent)) {
110
+ fail(`an svg template inside SVG content (view/01-templates.md "svg templates")`, parent);
111
+ }
108
112
  const a = adoptionOf(template);
109
113
  // A development server's marker: checked when present (a production server writes none),
110
114
  // against the id when the template has one (production client objects don't, 01).
@@ -180,6 +184,12 @@ function node(t, a, inst, values) {
180
184
  return c;
181
185
  }
182
186
  const WHITESPACE_ONLY = /^[\t\n\f\r ]*$/;
187
+ /**
188
+ * Development: where an svg template may be (warn.ts `checkSvgParent`, checked here so the lazy
189
+ * chunk imports no development-only function: production bundles drop this).
190
+ */
191
+ const svgContent = (el) => el.namespaceURI === 'http://www.w3.org/2000/svg' &&
192
+ !/^(foreignObject|desc|title)$/.test(el.localName);
183
193
  function element(t, a, inst, values) {
184
194
  const el = cur;
185
195
  if (el === null || el.localName !== t.localName)
@@ -193,6 +203,13 @@ function element(t, a, inst, values) {
193
203
  adoptAttr(part, values);
194
204
  if (DEV)
195
205
  checkAttr(part, fail);
206
+ // A server-written style a strict CSP blocked has no declarations: write the adopted value
207
+ // through the CSSOM, which the CSP allows (08 "Style attributes under a strict CSP").
208
+ // After the development check, which compares the attribute as the server wrote it.
209
+ const v = part.value;
210
+ if (part.name === 'style' && typeof v === 'string' && !el.style.length) {
211
+ part.write(v);
212
+ }
196
213
  if (kind === TEXTAREA || kind === TITLE)
197
214
  whole = true; // the part owns the content
198
215
  }
@@ -1 +1 @@
1
- {"version":3,"file":"adopt.js","sourceRoot":"","sources":["../../../src/view/render/adopt.ts"],"names":[],"mappings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GAAG,IAAI,CAAE,CAAU,CAAC,IAAI,CAAC,CAAC;aAC9C,CAAC;YACJ,MAAM,GAAG,GAAG,GAAG,CAAC;YAChB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7F,GAAG,GAAG,GAAG,CAAC;YACV,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC;QACxB,CAAC;IACH,CAAC;IACD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAChB,IAAI,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// The parallel walk (view/07-hydration.md \"The parallel walk\"): visits a template's static\n// structure (its parsed content) and the server DOM together, and builds the same parts the\n// client renderer would, with this render's values as committed values. It writes nothing,\n// except splitting merged text at known lengths (`splitText`), creating the empty Text node of\n// an `''` value, joining text the parser split, and removing development markers. Nested\n// templates, lists (rows one after another, no markers), arrays and `raw()` are walked in\n// turn. Nested Gyral hosts: a shadow host's light children are the parent's content (slotted)\n// and are walked; its shadow root never is; a light host (`data-gyral-light`) is opaque.\n// Development checks every node, text and bound attribute, and the `<!--gyral:ID-->` markers\n// when present; production checks node types, local names and text lengths.\nimport { DEV } from '#view-dev';\nimport { LIGHT_ATTRIBUTE } from '../attributes.js';\nimport { CHILD_BEFORE, type PartSpec, type TemplateObject } from '../normalize/types.js';\nimport { isTemplateResult, sourceOf, templateOf, type TemplateResult } from '../template.js';\nimport { adoptionOf, type Adoption } from './adopt-plan.js';\nimport { adoptAttr, checkAttr } from './adopt-attr.js';\nimport { attrPart, TEXTAREA, TITLE } from './attr-parts.js';\nimport { ChildPart, INSTANCE, ITEMS, LIST, RAW, TEXT } from './child-part.js';\nimport { checkKeys } from './dev-check.js';\nimport { Instance } from './instance.js';\nimport { mismatch } from './mismatch.js';\nimport { ROOT, SOLE } from './plan.js';\nimport { parse, RawRange } from './raw.js';\nimport { report } from './seen.js';\nimport { List } from './rows.js';\nimport { isList, rawHtml, type ListResult } from './values.js';\n\n/** The walk's position: the next DOM node; null at the end of `parent`'s children. */\nlet cur: Node | null = null;\nlet parent: Node;\n/** For mismatch messages: the host's root, the component, the template being walked. */\nlet top: Node;\nlet host = '';\nlet current: TemplateObject | undefined;\n\nconst fail = (expected: string, found: Node | string | null = cur, at: Node = parent): never =>\n mismatch(expected, found, at, top, host, current?.loc);\n\n/** Adopts the server DOM in `root` (a host's root) as `part`'s content for `value`. */\nexport function adopt(part: ChildPart, value: unknown, root: Node, label: string): void {\n top = parent = root;\n cur = root.firstChild;\n host = label;\n current = undefined;\n content(part, value);\n if (cur !== null) fail('the end of the view');\n}\n\n/** A child value at the walk's position (view/02-bindings.md \"Child values\"). */\nfunction content(part: ChildPart, v: unknown): void {\n switch (typeof v) {\n case 'string':\n case 'number': {\n const data = typeof v === 'string' ? v : String(v);\n part.kind = TEXT;\n part.value = v;\n if (data !== '') part.content = text(data);\n else parent.insertBefore((part.content = document.createTextNode('')), cur);\n return;\n }\n case 'object':\n if (v === null) return;\n if (isTemplateResult(v)) {\n part.kind = INSTANCE;\n part.content = instance(v, part);\n } else if (isList(v)) rows(part, v.items, v);\n else if (Array.isArray(v)) rows(part, v, undefined);\n else {\n const markup = rawHtml(v);\n if (markup !== undefined) raw(part, markup);\n else if (DEV) part.commit(v);\n }\n return;\n default:\n // Development: a value no hole renders throws (or warns, for `true`) as on the client.\n // Called through the part, so this chunk imports no development-only function.\n if (DEV) part.commit(v);\n }\n}\n\n/** Static text or a text value: exactly `want`'s length, split off a longer Text node. */\nfunction text(want: string): Text {\n // The parser turns CR and CRLF into LF.\n const data = want.includes('\\r') ? want.replace(/\\r\\n?/g, '\\n') : want;\n const t = cur as Text | null;\n if (t !== null && t.nodeType === 3) {\n // Join text the parser split (very long runs).\n for (let n = t.nextSibling; t.length < data.length && n !== null && n.nodeType === 3;) {\n t.appendData((n as Text).data);\n (n as Text).remove();\n n = t.nextSibling;\n }\n if (t.length >= data.length && (!DEV || t.data.startsWith(data))) {\n if (t.length > data.length) t.splitText(data.length);\n cur = t.nextSibling;\n return t;\n }\n }\n return fail(`text ${JSON.stringify(data.slice(0, 40))}`);\n}\n\nfunction instance(result: TemplateResult, holder: ChildPart): Instance {\n const template = templateOf(result);\n const a = adoptionOf(template);\n // A development server's marker: checked when present (a production server writes none),\n // against the id when the template has one (production client objects don't, 01).\n const marker = cur as Comment | null;\n if (marker !== null && marker.nodeType === 8 && marker.data.startsWith('gyral:')) {\n const id = template.id;\n if (DEV && id !== undefined && marker.data !== `gyral:${id}`) fail(`<!--gyral:${id}-->`);\n cur = marker.nextSibling;\n marker.remove();\n }\n const outer = current;\n current = template;\n const inst = new Instance(template, sourceOf(result), holder, true);\n children(a.plan.content, a, inst, result.values);\n current = outer;\n return inst;\n}\n\n/** The children of template node `t`, with the child holes between them. */\nfunction children(t: Node, a: Adoption, inst: Instance, values: readonly unknown[]): void {\n const holes = a.holes.get(t);\n const root = t === a.plan.content;\n let h = 0;\n for (let n = t.firstChild, j = 0; ; n = n.nextSibling, j++) {\n if (holes !== undefined && h < holes.length) {\n const i = holes[h] as number;\n const spec = a.specs[i] as PartSpec;\n const ref = spec[0] === CHILD_BEFORE ? spec[2] : null;\n if (n === null ? ref === null : ref === j) {\n hole(i, ref, a, inst, values);\n h++;\n }\n }\n if (n === null) return;\n const dom = node(n, a, inst, values);\n if (root) {\n if (j === 0) inst.start = dom;\n inst.end = dom;\n }\n }\n}\n\n/** A child hole: its content, then its reference node (the DOM node the walk reached). */\nfunction hole(\n i: number,\n ref: number | null,\n a: Adoption,\n inst: Instance,\n values: readonly unknown[],\n): void {\n const kind = a.plan.kinds[i] as number;\n const at = a.plan.at[i] as number;\n const part =\n kind === ROOT\n ? new ChildPart(null, null, null, 0, false, at)\n : new ChildPart(parent, null, null, 0, kind === SOLE, at);\n inst.parts[i] = part;\n content(part, values[at]);\n if (ref !== null) {\n part.ref = cur;\n if (kind === ROOT && ref === 0) inst.head = part;\n } else if (kind === ROOT) {\n part.owner = inst;\n inst.tail = part;\n }\n}\n\nfunction node(t: Node, a: Adoption, inst: Instance, values: readonly unknown[]): Node {\n if (t.nodeType === 3) return text((t as Text).data);\n if (t.nodeType !== 8) return element(t as Element, a, inst, values);\n const c = cur as Comment | null;\n if (c === null || c.nodeType !== 8 || (DEV && c.data !== (t as Comment).data)) {\n return fail(`<!--${(t as Comment).data}-->`);\n }\n cur = c.nextSibling;\n return c;\n}\n\nconst WHITESPACE_ONLY = /^[\\t\\n\\f\\r ]*$/;\n\nfunction element(t: Element, a: Adoption, inst: Instance, values: readonly unknown[]): Element {\n const el = cur as Element | null;\n if (el === null || el.localName !== t.localName) return fail(`<${t.localName}>`);\n cur = el.nextSibling;\n let whole = false;\n for (const i of a.attrs.get(t) ?? []) {\n const kind = a.plan.kinds[i] as number;\n const part = attrPart(el, kind, a.specs[i] as PartSpec, a.plan.at[i] as number);\n inst.parts[i] = part;\n adoptAttr(part, values);\n if (DEV) checkAttr(part, fail);\n if (kind === TEXTAREA || kind === TITLE) whole = true; // the part owns the content\n }\n let holes = a.holes.has(t);\n if (whole) return el;\n if (el.hasAttribute(LIGHT_ATTRIBUTE)) {\n // A light host owns its children (ADR 0014): its parent writes none (06 \"Components\").\n for (let c = t.firstChild; c !== null; c = c.nextSibling) {\n if (c.nodeType !== 3 || !WHITESPACE_ONLY.test((c as Text).data)) holes = true;\n }\n if (holes) fail(`no children from the parent in light host <${t.localName}>`, el, el);\n return el;\n }\n // A custom element without children in the template: what it holds is its own.\n if (!holes && t.firstChild === null && t.localName.includes('-')) return el;\n const outer = cur;\n const outerParent = parent;\n parent = el;\n cur = el.firstChild;\n children(t, a, inst, values);\n if (cur !== null) fail(`the end of <${t.localName}>`);\n cur = outer;\n parent = outerParent;\n return el;\n}\n\n/** Rows of `each` (keyed) or items of an array (`l` undefined), one after another. */\nfunction rows(part: ChildPart, values: readonly unknown[], l: ListResult | undefined): void {\n const list = new List(part);\n part.kind = l === undefined ? ITEMS : LIST;\n part.content = list;\n if (DEV && l !== undefined) checkKeys(values, l.key);\n for (let i = 0; i < values.length; i++) {\n const row = new ChildPart(null, null, list, i, false, -1);\n list.rows.push(row);\n if (l === undefined) {\n content(row, values[i]);\n continue;\n }\n const item = values[i];\n row.key = l.key(item);\n row.item = item;\n row.picked = l.pick === undefined ? undefined : l.pick(item);\n content(row, l.row(item, row.picked));\n }\n}\n\n/** `raw()`: its start anchor, then the nodes its markup parses to (texts by length). */\nfunction raw(part: ChildPart, markup: string): void {\n report({ html: markup });\n const start = cur as Comment | null;\n if (start === null || start.nodeType !== 8) return fail('the raw() start anchor <!---->');\n cur = start.nextSibling;\n let end: Node = start;\n for (let n = parse(markup).firstChild; n !== null; n = n.nextSibling) {\n if (n.nodeType === 3) end = text((n as Text).data);\n else {\n const dom = cur;\n if (dom === null || dom.nodeName !== n.nodeName) return fail(`raw() markup's ${n.nodeName}`);\n end = dom;\n cur = dom.nextSibling;\n }\n }\n part.kind = RAW;\n part.content = new RawRange(start, end, markup);\n}\n"]}
1
+ {"version":3,"file":"adopt.js","sourceRoot":"","sources":["../../../src/view/render/adopt.ts"],"names":[],"mappings":"AAAA,2FAA2F;AAC3F,4FAA4F;AAC5F,2FAA2F;AAC3F,+FAA+F;AAC/F,4FAA4F;AAC5F,8FAA8F;AAC9F,2FAA2F;AAC3F,6FAA6F;AAC7F,8DAA8D;AAC9D,6FAA6F;AAC7F,4EAA4E;AAC5E,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAsC,MAAM,uBAAuB,CAAC;AACzF,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,UAAU,EA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ACtB,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QACrE,IAAI,CAAC,CAAC,QAAQ,KAAK,CAAC;YAAE,GAAG,GAAG,IAAI,CAAE,CAAU,CAAC,IAAI,CAAC,CAAC;aAC9C,CAAC;YACJ,MAAM,GAAG,GAAG,GAAG,CAAC;YAChB,IAAI,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,QAAQ,KAAK,CAAC,CAAC,QAAQ;gBAAE,OAAO,IAAI,CAAC,kBAAkB,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC;YAC7F,GAAG,GAAG,GAAG,CAAC;YACV,GAAG,GAAG,GAAG,CAAC,WAAW,CAAC;QACxB,CAAC;IACH,CAAC;IACD,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAChB,IAAI,CAAC,OAAO,GAAG,IAAI,QAAQ,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;AAClD,CAAC","sourcesContent":["// The parallel walk (view/07-hydration.md \"The parallel walk\"): visits a template's static\n// structure (its parsed content) and the server DOM together, and builds the same parts the\n// client renderer would, with this render's values as committed values. It writes nothing,\n// except splitting merged text at known lengths (`splitText`), creating the empty Text node of\n// an `''` value, joining text the parser split, removing development markers, and writing a\n// `style` attribute a strict CSP blocked through the CSSOM. Nested templates, lists (rows one\n// after another, no markers), arrays and `raw()` are walked in turn. Nested Gyral hosts: a\n// shadow host's light children are the parent's content (slotted) and are walked; its shadow\n// root never is; a light host (`data-gyral-light`) is opaque.\n// Development checks every node, text and bound attribute, and the `<!--gyral:ID-->` markers\n// when present; production checks node types, local names and text lengths.\nimport { DEV } from '#view-dev';\nimport { LIGHT_ATTRIBUTE } from '../attributes.js';\nimport { CHILD_BEFORE, type PartSpec, type TemplateObject } from '../normalize/types.js';\nimport { isTemplateResult, sourceOf, templateOf, type TemplateResult } from '../template.js';\nimport { adoptionOf, type Adoption } from './adopt-plan.js';\nimport { adoptAttr, checkAttr } from './adopt-attr.js';\nimport { attrPart, TEXTAREA, TITLE } from './attr-parts.js';\nimport { ChildPart, INSTANCE, ITEMS, LIST, RAW, TEXT } from './child-part.js';\nimport { checkKeys } from './dev-check.js';\nimport { Instance } from './instance.js';\nimport { mismatch } from './mismatch.js';\nimport { ROOT, SOLE } from './plan.js';\nimport { parse, RawRange } from './raw.js';\nimport { report } from './seen.js';\nimport { List } from './rows.js';\nimport { isList, rawHtml, type ListResult } from './values.js';\n\n/** The walk's position: the next DOM node; null at the end of `parent`'s children. */\nlet cur: Node | null = null;\nlet parent: Node;\n/** For mismatch messages: the host's root, the component, the template being walked. */\nlet top: Node;\nlet host = '';\nlet current: TemplateObject | undefined;\n\nconst fail = (expected: string, found: Node | string | null = cur, at: Node = parent): never =>\n mismatch(expected, found, at, top, host, current?.loc);\n\n/** Adopts the server DOM in `root` (a host's root) as `part`'s content for `value`. */\nexport function adopt(part: ChildPart, value: unknown, root: Node, label: string): void {\n top = parent = root;\n cur = root.firstChild;\n host = label;\n current = undefined;\n content(part, value);\n if (cur !== null) fail('the end of the view');\n}\n\n/** A child value at the walk's position (view/02-bindings.md \"Child values\"). */\nfunction content(part: ChildPart, v: unknown): void {\n switch (typeof v) {\n case 'string':\n case 'number': {\n const data = typeof v === 'string' ? v : String(v);\n part.kind = TEXT;\n part.value = v;\n if (data !== '') part.content = text(data);\n else parent.insertBefore((part.content = document.createTextNode('')), cur);\n return;\n }\n case 'object':\n if (v === null) return;\n if (isTemplateResult(v)) {\n part.kind = INSTANCE;\n part.content = instance(v, part);\n } else if (isList(v)) rows(part, v.items, v);\n else if (Array.isArray(v)) rows(part, v, undefined);\n else {\n const markup = rawHtml(v);\n if (markup !== undefined) raw(part, markup);\n else if (DEV) part.commit(v);\n }\n return;\n default:\n // Development: a value no hole renders throws (or warns, for `true`) as on the client.\n // Called through the part, so this chunk imports no development-only function.\n if (DEV) part.commit(v);\n }\n}\n\n/** Static text or a text value: exactly `want`'s length, split off a longer Text node. */\nfunction text(want: string): Text {\n // The parser turns CR and CRLF into LF.\n const data = want.includes('\\r') ? want.replace(/\\r\\n?/g, '\\n') : want;\n const t = cur as Text | null;\n if (t !== null && t.nodeType === 3) {\n // Join text the parser split (very long runs).\n for (let n = t.nextSibling; t.length < data.length && n !== null && n.nodeType === 3;) {\n t.appendData((n as Text).data);\n (n as Text).remove();\n n = t.nextSibling;\n }\n if (t.length >= data.length && (!DEV || t.data.startsWith(data))) {\n if (t.length > data.length) t.splitText(data.length);\n cur = t.nextSibling;\n return t;\n }\n }\n return fail(`text ${JSON.stringify(data.slice(0, 40))}`);\n}\n\nfunction instance(result: TemplateResult, holder: ChildPart): Instance {\n const template = templateOf(result);\n if (DEV && template.svg && !svgContent(parent)) {\n fail(`an svg template inside SVG content (view/01-templates.md \"svg templates\")`, parent);\n }\n const a = adoptionOf(template);\n // A development server's marker: checked when present (a production server writes none),\n // against the id when the template has one (production client objects don't, 01).\n const marker = cur as Comment | null;\n if (marker !== null && marker.nodeType === 8 && marker.data.startsWith('gyral:')) {\n const id = template.id;\n if (DEV && id !== undefined && marker.data !== `gyral:${id}`) fail(`<!--gyral:${id}-->`);\n cur = marker.nextSibling;\n marker.remove();\n }\n const outer = current;\n current = template;\n const inst = new Instance(template, sourceOf(result), holder, true);\n children(a.plan.content, a, inst, result.values);\n current = outer;\n return inst;\n}\n\n/** The children of template node `t`, with the child holes between them. */\nfunction children(t: Node, a: Adoption, inst: Instance, values: readonly unknown[]): void {\n const holes = a.holes.get(t);\n const root = t === a.plan.content;\n let h = 0;\n for (let n = t.firstChild, j = 0; ; n = n.nextSibling, j++) {\n if (holes !== undefined && h < holes.length) {\n const i = holes[h] as number;\n const spec = a.specs[i] as PartSpec;\n const ref = spec[0] === CHILD_BEFORE ? spec[2] : null;\n if (n === null ? ref === null : ref === j) {\n hole(i, ref, a, inst, values);\n h++;\n }\n }\n if (n === null) return;\n const dom = node(n, a, inst, values);\n if (root) {\n if (j === 0) inst.start = dom;\n inst.end = dom;\n }\n }\n}\n\n/** A child hole: its content, then its reference node (the DOM node the walk reached). */\nfunction hole(\n i: number,\n ref: number | null,\n a: Adoption,\n inst: Instance,\n values: readonly unknown[],\n): void {\n const kind = a.plan.kinds[i] as number;\n const at = a.plan.at[i] as number;\n const part =\n kind === ROOT\n ? new ChildPart(null, null, null, 0, false, at)\n : new ChildPart(parent, null, null, 0, kind === SOLE, at);\n inst.parts[i] = part;\n content(part, values[at]);\n if (ref !== null) {\n part.ref = cur;\n if (kind === ROOT && ref === 0) inst.head = part;\n } else if (kind === ROOT) {\n part.owner = inst;\n inst.tail = part;\n }\n}\n\nfunction node(t: Node, a: Adoption, inst: Instance, values: readonly unknown[]): Node {\n if (t.nodeType === 3) return text((t as Text).data);\n if (t.nodeType !== 8) return element(t as Element, a, inst, values);\n const c = cur as Comment | null;\n if (c === null || c.nodeType !== 8 || (DEV && c.data !== (t as Comment).data)) {\n return fail(`<!--${(t as Comment).data}-->`);\n }\n cur = c.nextSibling;\n return c;\n}\n\nconst WHITESPACE_ONLY = /^[\\t\\n\\f\\r ]*$/;\n\n/**\n * Development: where an svg template may be (warn.ts `checkSvgParent`, checked here so the lazy\n * chunk imports no development-only function: production bundles drop this).\n */\nconst svgContent = (el: Node): boolean =>\n (el as Element).namespaceURI === 'http://www.w3.org/2000/svg' &&\n !/^(foreignObject|desc|title)$/.test((el as Element).localName);\n\nfunction element(t: Element, a: Adoption, inst: Instance, values: readonly unknown[]): Element {\n const el = cur as Element | null;\n if (el === null || el.localName !== t.localName) return fail(`<${t.localName}>`);\n cur = el.nextSibling;\n let whole = false;\n for (const i of a.attrs.get(t) ?? []) {\n const kind = a.plan.kinds[i] as number;\n const part = attrPart(el, kind, a.specs[i] as PartSpec, a.plan.at[i] as number);\n inst.parts[i] = part;\n adoptAttr(part, values);\n if (DEV) checkAttr(part, fail);\n // A server-written style a strict CSP blocked has no declarations: write the adopted value\n // through the CSSOM, which the CSP allows (08 \"Style attributes under a strict CSP\").\n // After the development check, which compares the attribute as the server wrote it.\n const v = part.value;\n if (part.name === 'style' && typeof v === 'string' && !(el as HTMLElement).style.length) {\n part.write(v);\n }\n if (kind === TEXTAREA || kind === TITLE) whole = true; // the part owns the content\n }\n let holes = a.holes.has(t);\n if (whole) return el;\n if (el.hasAttribute(LIGHT_ATTRIBUTE)) {\n // A light host owns its children (ADR 0014): its parent writes none (06 \"Components\").\n for (let c = t.firstChild; c !== null; c = c.nextSibling) {\n if (c.nodeType !== 3 || !WHITESPACE_ONLY.test((c as Text).data)) holes = true;\n }\n if (holes) fail(`no children from the parent in light host <${t.localName}>`, el, el);\n return el;\n }\n // A custom element without children in the template: what it holds is its own.\n if (!holes && t.firstChild === null && t.localName.includes('-')) return el;\n const outer = cur;\n const outerParent = parent;\n parent = el;\n cur = el.firstChild;\n children(t, a, inst, values);\n if (cur !== null) fail(`the end of <${t.localName}>`);\n cur = outer;\n parent = outerParent;\n return el;\n}\n\n/** Rows of `each` (keyed) or items of an array (`l` undefined), one after another. */\nfunction rows(part: ChildPart, values: readonly unknown[], l: ListResult | undefined): void {\n const list = new List(part);\n part.kind = l === undefined ? ITEMS : LIST;\n part.content = list;\n if (DEV && l !== undefined) checkKeys(values, l.key);\n for (let i = 0; i < values.length; i++) {\n const row = new ChildPart(null, null, list, i, false, -1);\n list.rows.push(row);\n if (l === undefined) {\n content(row, values[i]);\n continue;\n }\n const item = values[i];\n row.key = l.key(item);\n row.item = item;\n row.picked = l.pick === undefined ? undefined : l.pick(item);\n content(row, l.row(item, row.picked));\n }\n}\n\n/** `raw()`: its start anchor, then the nodes its markup parses to (texts by length). */\nfunction raw(part: ChildPart, markup: string): void {\n report({ html: markup });\n const start = cur as Comment | null;\n if (start === null || start.nodeType !== 8) return fail('the raw() start anchor <!---->');\n cur = start.nextSibling;\n let end: Node = start;\n for (let n = parse(markup).firstChild; n !== null; n = n.nextSibling) {\n if (n.nodeType === 3) end = text((n as Text).data);\n else {\n const dom = cur;\n if (dom === null || dom.nodeName !== n.nodeName) return fail(`raw() markup's ${n.nodeName}`);\n end = dom;\n cur = dom.nextSibling;\n }\n }\n part.kind = RAW;\n part.content = new RawRange(start, end, markup);\n}\n"]}
@@ -26,6 +26,8 @@ export declare const TITLE = 8;
26
26
  export declare const TEXTAREA = 9;
27
27
  /** `${hook(…)}` in a start tag. */
28
28
  export declare const HOOK = 10;
29
+ /** `?modal` on `<dialog>`, `?popover-open` on `[popover]`: opened and closed (toggles.ts). */
30
+ export declare const TOGGLE = 11;
29
31
  /** Input types whose `value` is a submitted value, not state the user edits. */
30
32
  export declare const PLAIN: RegExp;
31
33
  export declare const absent: (v: unknown) => boolean;
@@ -52,7 +54,16 @@ export declare class AttrPart implements Part {
52
54
  prev: readonly unknown[] | undefined;
53
55
  constructor(el: Element, kind: number, name: string, at: number, strings?: readonly string[]);
54
56
  set(values: readonly unknown[]): void;
55
- /** MULTI: pieces joined with the static strings; `nothing` in any piece removes. */
57
+ /**
58
+ * Writes the attribute; `style` through the CSSOM (`.style.cssText`), which a strict CSP
59
+ * (`style-src` without `'unsafe-inline'`) allows where `setAttribute('style', …)` is blocked.
60
+ * HTML, SVG and MathML elements all have `.style`.
61
+ */
62
+ write(s: string): void;
63
+ /**
64
+ * MULTI: pieces joined with the static strings; `nothing` in any piece removes. With no
65
+ * pieces it is a static `style` attribute (01 "Normalization"): written once, at creation.
66
+ */
56
67
  private multi;
57
68
  /** The joined value of `pieces`, or null when one is `nothing`. */
58
69
  join(pieces: readonly unknown[]): string | null;
@@ -8,10 +8,12 @@
8
8
  // unchanged model never touches the control. Constructors only record nodes; hydration
9
9
  // (view/07-hydration.md) builds the same parts over server DOM and adopts this render's values
10
10
  // as committed (adopt-attr.ts), so edits made before scripts ran stay by the same rule.
11
+ // `style` is written through the CSSOM, never `setAttribute`, so a strict CSP allows it.
11
12
  import { DEV } from '#view-dev';
12
13
  import { COMMIT_HOOK, isHook } from './hooks.js';
14
+ import { toggle } from './toggles.js';
13
15
  import { nothing, UNSET } from './values.js';
14
- import { badHook, warnTrue, warnValue } from './warn.js';
16
+ import { badHook, warnFunctionProp, warnToggle, warnTrue, warnValue } from './warn.js';
15
17
  /** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */
16
18
  export const ATTR = 0;
17
19
  /** `name="a ${x} b"`. */
@@ -34,6 +36,8 @@ export const TITLE = 8;
34
36
  export const TEXTAREA = 9;
35
37
  /** `${hook(…)}` in a start tag. */
36
38
  export const HOOK = 10;
39
+ /** `?modal` on `<dialog>`, `?popover-open` on `[popover]`: opened and closed (toggles.ts). */
40
+ export const TOGGLE = 11;
37
41
  /** Input types whose `value` is a submitted value, not state the user edits. */
38
42
  export const PLAIN = /^(checkbox|radio|hidden|button|submit|reset|image|file)$/;
39
43
  /** `String(v)`: numbers and booleans as text (objects warn in development first). */
@@ -64,6 +68,8 @@ export function attrKind(el, name, bool) {
64
68
  return name === 'checked' ? CHECKED : name === 'indeterminate' ? STATE : BOOL;
65
69
  if (tag === 'option' && name === 'selected')
66
70
  return CHECKED;
71
+ if (name === 'modal' || name === 'popover-open')
72
+ return TOGGLE;
67
73
  return name === 'open' && (tag === 'details' || tag === 'dialog') ? OPEN : BOOL;
68
74
  }
69
75
  /** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */
@@ -99,7 +105,7 @@ export class AttrPart {
99
105
  else {
100
106
  if (DEV && isObject(v))
101
107
  warnValue(this, v, `the attribute ${this.name}`);
102
- el.setAttribute(this.name, typeof v === 'string' ? v : text(v));
108
+ this.write(typeof v === 'string' ? v : text(v));
103
109
  }
104
110
  return;
105
111
  case MULTI:
@@ -116,6 +122,8 @@ export class AttrPart {
116
122
  case PROP:
117
123
  if (Object.is(v, this.value))
118
124
  return;
125
+ if (DEV && typeof v === 'function')
126
+ warnFunctionProp(this, el, this.name);
119
127
  this.value = v;
120
128
  live[this.name] = v;
121
129
  return;
@@ -158,6 +166,17 @@ export class AttrPart {
158
166
  el.toggleAttribute('open', on);
159
167
  return;
160
168
  }
169
+ case TOGGLE: {
170
+ const on = truthy(v);
171
+ if (on === this.value)
172
+ return;
173
+ this.value = on;
174
+ if (toggle !== undefined)
175
+ toggle(this, this.name, on);
176
+ else if (DEV)
177
+ warnToggle(el, this.name);
178
+ return;
179
+ }
161
180
  case TITLE:
162
181
  case TEXTAREA: {
163
182
  const s = textOf(this, v);
@@ -176,7 +195,21 @@ export class AttrPart {
176
195
  this.hook(v);
177
196
  }
178
197
  }
179
- /** MULTI: pieces joined with the static strings; `nothing` in any piece removes. */
198
+ /**
199
+ * Writes the attribute; `style` through the CSSOM (`.style.cssText`), which a strict CSP
200
+ * (`style-src` without `'unsafe-inline'`) allows where `setAttribute('style', …)` is blocked.
201
+ * HTML, SVG and MathML elements all have `.style`.
202
+ */
203
+ write(s) {
204
+ if (this.name === 'style')
205
+ this.el.style.cssText = s;
206
+ else
207
+ this.el.setAttribute(this.name, s);
208
+ }
209
+ /**
210
+ * MULTI: pieces joined with the static strings; `nothing` in any piece removes. With no
211
+ * pieces it is a static `style` attribute (01 "Normalization"): written once, at creation.
212
+ */
180
213
  multi(values) {
181
214
  const pieces = this.pieces;
182
215
  let changed = false;
@@ -187,7 +220,7 @@ export class AttrPart {
187
220
  changed = true;
188
221
  }
189
222
  }
190
- if (!changed)
223
+ if (!changed && this.value !== UNSET)
191
224
  return;
192
225
  const joined = this.join(pieces);
193
226
  if (joined === this.value)
@@ -196,7 +229,7 @@ export class AttrPart {
196
229
  if (joined === null)
197
230
  this.el.removeAttribute(this.name);
198
231
  else
199
- this.el.setAttribute(this.name, joined);
232
+ this.write(joined);
200
233
  }
201
234
  /** The joined value of `pieces`, or null when one is `nothing`. */
202
235
  join(pieces) {
@@ -1 +1 @@
1
- {"version":3,"file":"attr-parts.js","sourceRoot":"","sources":["../../../src/view/render/attr-parts.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,0FAA0F;AAC1F,0FAA0F;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M,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAY,CAAC;QACxF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,wFAAwF;IACxF,IAAI,CAAC,CAAU;QACb,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,EAAE,CAAe,CAAC,CAAC;aACnD,IAAI,GAAG;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Element parts (view/02-bindings.md \"Attribute values\", \"Boolean attributes\", \"Properties\",\n// \"Live form state\", \"Element hooks\"): every hole on or inside one element that isn't a child\n// hole, as one class with a kind, so an instance's update loop sees only two part shapes.\n// Every part compares with its committed value and writes only on change. Live form state\n// sets the attribute too on first creation (the default, so `form.reset()` returns to the\n// model's first value); when the model's value changes it compares with the element's live\n// state and writes only on a difference, so the change lands even over a user's edit, and an\n// unchanged model never touches the control. Constructors only record nodes; hydration\n// (view/07-hydration.md) builds the same parts over server DOM and adopts this render's values\n// as committed (adopt-attr.ts), so edits made before scripts ran stay by the same rule.\nimport { DEV } from '#view-dev';\nimport type { PartSpec } from '../normalize/types.js';\nimport { COMMIT_HOOK, isHook, type HookResult, type HookSpec } from './hooks.js';\nimport { nothing, UNSET } from './values.js';\nimport { badHook, warnTrue, warnValue } from './warn.js';\n\n/** What every part of an instance implements: commit its value(s) from this render's values. */\nexport interface Part {\n set(values: readonly unknown[]): void;\n}\n\n/** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */\nexport const ATTR = 0;\n/** `name=\"a ${x} b\"`. */\nexport const MULTI = 1;\n/** `?name=${v}`. */\nexport const BOOL = 2;\n/** `.name=${v}`. */\nexport const PROP = 3;\n/** `value=${v}` on `<input>`: live `.value`. */\nexport const VALUE = 4;\n/** `?checked` on `<input>`, `?selected` on `<option>`: attribute first, then the live property. */\nexport const CHECKED = 5;\n/** `?indeterminate` on `<input>`: the property only. */\nexport const STATE = 6;\n/** `?open` on `<details>`/`<dialog>`: the attribute, compared with its live presence. */\nexport const OPEN = 7;\n/** `<title>${v}</title>`: text content. */\nexport const TITLE = 8;\n/** `<textarea>${v}</textarea>`: text content first, then the live `.value`. */\nexport const TEXTAREA = 9;\n/** `${hook(…)}` in a start tag. */\nexport const HOOK = 10;\n\n/** Input types whose `value` is a submitted value, not state the user edits. */\nexport const PLAIN = /^(checkbox|radio|hidden|button|submit|reset|image|file)$/;\n\n/** `String(v)`: numbers and booleans as text (objects warn in development first). */\nconst text = String as (value: unknown) => string;\n\nexport const absent = (v: unknown): boolean => v === null || v === undefined || v === nothing;\nexport const truthy = (v: unknown): boolean => v !== nothing && !!v;\n\nconst isObject = (v: unknown): boolean =>\n (typeof v === 'object' && v !== null) || typeof v === 'function';\n\n/** The text of a `<textarea>`/`<title>` value: child-hole rules, as one string. */\nexport function textOf(part: object, v: unknown): string {\n if (typeof v === 'string') return v;\n if (typeof v === 'number') return String(v);\n if (DEV) {\n if (v === true) warnTrue(part);\n else if (isObject(v)) warnValue(part, v, 'the text content');\n }\n return absent(v) || typeof v === 'boolean' ? '' : text(v);\n}\n\n/** The kind of a bound attribute (`?name` when `bool`) on `el`. */\nexport function attrKind(el: Element, name: string, bool: boolean): number {\n const tag = el.localName;\n if (!bool) return name === 'value' && tag === 'input' ? VALUE : ATTR;\n if (tag === 'input')\n return name === 'checked' ? CHECKED : name === 'indeterminate' ? STATE : BOOL;\n if (tag === 'option' && name === 'selected') return CHECKED;\n return name === 'open' && (tag === 'details' || tag === 'dialog') ? OPEN : BOOL;\n}\n\n/** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */\nexport function attrPart(el: Element, kind: number, spec: PartSpec, at: number): AttrPart {\n const s = spec as readonly [number, unknown, string?, (readonly string[])?];\n return new AttrPart(el, kind, s[2] ?? '', at, s[3]);\n}\n\nexport class AttrPart implements Part {\n readonly el: Element;\n kind: number;\n readonly name: string;\n readonly at: number;\n /** The committed value: raw (ATTR, PROP, VALUE), boolean, string (MULTI, text), or UNSET. */\n value: unknown;\n /** MULTI: the static strings and the committed pieces. */\n readonly strings: readonly string[] | undefined;\n readonly pieces: unknown[] | undefined;\n /** HOOK: the hook, its committed arguments and the ones before. */\n spec: HookSpec<readonly unknown[]> | null;\n args: readonly unknown[] | undefined;\n prev: readonly unknown[] | undefined;\n\n constructor(el: Element, kind: number, name: string, at: number, strings?: readonly string[]) {\n this.el = el;\n this.kind = kind;\n this.name = name;\n this.at = at;\n this.value = UNSET;\n this.strings = strings;\n this.pieces =\n strings === undefined ? undefined : new Array<unknown>(strings.length - 1).fill(UNSET);\n this.spec = null;\n this.args = undefined;\n this.prev = undefined;\n }\n\n set(values: readonly unknown[]): void {\n const v = values[this.at];\n const el = this.el;\n const live = el as unknown as Record<string, unknown>;\n switch (this.kind) {\n case ATTR:\n if (v === this.value) return;\n this.value = v;\n if (absent(v)) el.removeAttribute(this.name);\n else {\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n el.setAttribute(this.name, typeof v === 'string' ? v : text(v));\n }\n return;\n case MULTI:\n this.multi(values);\n return;\n case BOOL: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n el.toggleAttribute(this.name, on);\n return;\n }\n case PROP:\n if (Object.is(v, this.value)) return;\n this.value = v;\n live[this.name] = v;\n return;\n case VALUE: {\n if (v === this.value) return;\n const s = absent(v) ? '' : text(v);\n if (this.value === UNSET) {\n // First creation: the attribute (the default), then the live value.\n if (absent(v)) el.removeAttribute('value');\n else el.setAttribute('value', s);\n if (PLAIN.test((el as HTMLInputElement).type)) this.kind = ATTR;\n }\n this.value = v;\n if (this.kind === VALUE && live.value !== s) live.value = s;\n return;\n }\n case CHECKED:\n case STATE: {\n const on = truthy(v);\n if (on === this.value) return;\n if (this.kind === CHECKED && this.value === UNSET) el.toggleAttribute(this.name, on);\n this.value = on;\n if (live[this.name] !== on) live[this.name] = on;\n return;\n }\n case OPEN: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n if (el.hasAttribute('open') !== on) el.toggleAttribute('open', on);\n return;\n }\n case TITLE:\n case TEXTAREA: {\n const s = textOf(this, v);\n if (s === this.value) return;\n if (this.kind === TEXTAREA && this.value !== UNSET) {\n if (live.value !== s) live.value = s;\n } else el.textContent = s;\n this.value = s;\n return;\n }\n default:\n this.hook(v);\n }\n }\n\n /** MULTI: pieces joined with the static strings; `nothing` in any piece removes. */\n private multi(values: readonly unknown[]): void {\n const pieces = this.pieces as unknown[];\n let changed = false;\n for (let i = 0; i < pieces.length; i++) {\n const v = values[this.at + i];\n if (v !== pieces[i]) {\n pieces[i] = v;\n changed = true;\n }\n }\n if (!changed) return;\n const joined = this.join(pieces);\n if (joined === this.value) return;\n this.value = joined;\n if (joined === null) this.el.removeAttribute(this.name);\n else this.el.setAttribute(this.name, joined);\n }\n\n /** The joined value of `pieces`, or null when one is `nothing`. */\n join(pieces: readonly unknown[]): string | null {\n const strings = this.strings as readonly string[];\n let joined = strings[0] as string;\n for (let i = 0; i < pieces.length; i++) {\n const v = pieces[i];\n if (v === nothing) return null;\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n joined += (v === null || v === undefined ? '' : text(v)) + (strings[i + 1] as string);\n }\n return joined;\n }\n\n /** HOOK: the result commits itself (hook-part.ts); an absent value forgets the hook. */\n hook(v: unknown): void {\n if (absent(v)) {\n this.spec = null;\n this.args = undefined;\n return;\n }\n const commit = isHook(v) ? v[COMMIT_HOOK] : undefined;\n if (commit !== undefined) commit(this, v as HookResult);\n else if (DEV) badHook(v);\n }\n}\n"]}
1
+ {"version":3,"file":"attr-parts.js","sourceRoot":"","sources":["../../../src/view/render/attr-parts.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,8FAA8F;AAC9F,0FAA0F;AAC1F,0FAA0F;AAC1F,0FAA0F;AAC1F,2FAA2F;AAC3F,6FAA6F;AAC7F,uFAAuF;AACvF,+FAA+F;AAC/F,wFAAwF;AACxF,yFAAyF;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEhC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAkC,MAAM,YAAY,CAAC;AACjF,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAOvF,yFAAyF;AACzF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,yBAAyB;AACzB,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AACvB,oBAAoB;AACpB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,oBAAoB;AACpB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,gDAAgD;AAChD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AACvB,mGAAmG;AACnG,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,CAAC;AACzB,wDAAwD;AACxD,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AACvB,yFAAyF;AACzF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,2CAA2C;AAC3C,MAAM,CAAC,MAAM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;YACzE,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAI,OAAO,CAAC,CAAC,GAAG,CAAC,CAAY,CAAC;QACxF,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,wFAAwF;IACxF,IAAI,CAAC,CAAU;QACb,IAAI,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;YACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;YACjB,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;YACtB,OAAO;QACT,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACtD,IAAI,MAAM,KAAK,SAAS;YAAE,MAAM,CAAC,IAAI,EAAE,CAAe,CAAC,CAAC;aACnD,IAAI,GAAG;YAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["// Element parts (view/02-bindings.md \"Attribute values\", \"Boolean attributes\", \"Properties\",\n// \"Live form state\", \"Element hooks\"): every hole on or inside one element that isn't a child\n// hole, as one class with a kind, so an instance's update loop sees only two part shapes.\n// Every part compares with its committed value and writes only on change. Live form state\n// sets the attribute too on first creation (the default, so `form.reset()` returns to the\n// model's first value); when the model's value changes it compares with the element's live\n// state and writes only on a difference, so the change lands even over a user's edit, and an\n// unchanged model never touches the control. Constructors only record nodes; hydration\n// (view/07-hydration.md) builds the same parts over server DOM and adopts this render's values\n// as committed (adopt-attr.ts), so edits made before scripts ran stay by the same rule.\n// `style` is written through the CSSOM, never `setAttribute`, so a strict CSP allows it.\nimport { DEV } from '#view-dev';\nimport type { PartSpec } from '../normalize/types.js';\nimport { COMMIT_HOOK, isHook, type HookResult, type HookSpec } from './hooks.js';\nimport { toggle } from './toggles.js';\nimport { nothing, UNSET } from './values.js';\nimport { badHook, warnFunctionProp, warnToggle, warnTrue, warnValue } from './warn.js';\n\n/** What every part of an instance implements: commit its value(s) from this render's values. */\nexport interface Part {\n set(values: readonly unknown[]): void;\n}\n\n/** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */\nexport const ATTR = 0;\n/** `name=\"a ${x} b\"`. */\nexport const MULTI = 1;\n/** `?name=${v}`. */\nexport const BOOL = 2;\n/** `.name=${v}`. */\nexport const PROP = 3;\n/** `value=${v}` on `<input>`: live `.value`. */\nexport const VALUE = 4;\n/** `?checked` on `<input>`, `?selected` on `<option>`: attribute first, then the live property. */\nexport const CHECKED = 5;\n/** `?indeterminate` on `<input>`: the property only. */\nexport const STATE = 6;\n/** `?open` on `<details>`/`<dialog>`: the attribute, compared with its live presence. */\nexport const OPEN = 7;\n/** `<title>${v}</title>`: text content. */\nexport const TITLE = 8;\n/** `<textarea>${v}</textarea>`: text content first, then the live `.value`. */\nexport const TEXTAREA = 9;\n/** `${hook(…)}` in a start tag. */\nexport const HOOK = 10;\n/** `?modal` on `<dialog>`, `?popover-open` on `[popover]`: opened and closed (toggles.ts). */\nexport const TOGGLE = 11;\n\n/** Input types whose `value` is a submitted value, not state the user edits. */\nexport const PLAIN = /^(checkbox|radio|hidden|button|submit|reset|image|file)$/;\n\n/** `String(v)`: numbers and booleans as text (objects warn in development first). */\nconst text = String as (value: unknown) => string;\n\nexport const absent = (v: unknown): boolean => v === null || v === undefined || v === nothing;\nexport const truthy = (v: unknown): boolean => v !== nothing && !!v;\n\nconst isObject = (v: unknown): boolean =>\n (typeof v === 'object' && v !== null) || typeof v === 'function';\n\n/** The text of a `<textarea>`/`<title>` value: child-hole rules, as one string. */\nexport function textOf(part: object, v: unknown): string {\n if (typeof v === 'string') return v;\n if (typeof v === 'number') return String(v);\n if (DEV) {\n if (v === true) warnTrue(part);\n else if (isObject(v)) warnValue(part, v, 'the text content');\n }\n return absent(v) || typeof v === 'boolean' ? '' : text(v);\n}\n\n/** The kind of a bound attribute (`?name` when `bool`) on `el`. */\nexport function attrKind(el: Element, name: string, bool: boolean): number {\n const tag = el.localName;\n if (!bool) return name === 'value' && tag === 'input' ? VALUE : ATTR;\n if (tag === 'input')\n return name === 'checked' ? CHECKED : name === 'indeterminate' ? STATE : BOOL;\n if (tag === 'option' && name === 'selected') return CHECKED;\n if (name === 'modal' || name === 'popover-open') return TOGGLE;\n return name === 'open' && (tag === 'details' || tag === 'dialog') ? OPEN : BOOL;\n}\n\n/** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */\nexport function attrPart(el: Element, kind: number, spec: PartSpec, at: number): AttrPart {\n const s = spec as readonly [number, unknown, string?, (readonly string[])?];\n return new AttrPart(el, kind, s[2] ?? '', at, s[3]);\n}\n\nexport class AttrPart implements Part {\n readonly el: Element;\n kind: number;\n readonly name: string;\n readonly at: number;\n /** The committed value: raw (ATTR, PROP, VALUE), boolean, string (MULTI, text), or UNSET. */\n value: unknown;\n /** MULTI: the static strings and the committed pieces. */\n readonly strings: readonly string[] | undefined;\n readonly pieces: unknown[] | undefined;\n /** HOOK: the hook, its committed arguments and the ones before. */\n spec: HookSpec<readonly unknown[]> | null;\n args: readonly unknown[] | undefined;\n prev: readonly unknown[] | undefined;\n\n constructor(el: Element, kind: number, name: string, at: number, strings?: readonly string[]) {\n this.el = el;\n this.kind = kind;\n this.name = name;\n this.at = at;\n this.value = UNSET;\n this.strings = strings;\n this.pieces =\n strings === undefined ? undefined : new Array<unknown>(strings.length - 1).fill(UNSET);\n this.spec = null;\n this.args = undefined;\n this.prev = undefined;\n }\n\n set(values: readonly unknown[]): void {\n const v = values[this.at];\n const el = this.el;\n const live = el as unknown as Record<string, unknown>;\n switch (this.kind) {\n case ATTR:\n if (v === this.value) return;\n this.value = v;\n if (absent(v)) el.removeAttribute(this.name);\n else {\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n this.write(typeof v === 'string' ? v : text(v));\n }\n return;\n case MULTI:\n this.multi(values);\n return;\n case BOOL: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n el.toggleAttribute(this.name, on);\n return;\n }\n case PROP:\n if (Object.is(v, this.value)) return;\n if (DEV && typeof v === 'function') warnFunctionProp(this, el, this.name);\n this.value = v;\n live[this.name] = v;\n return;\n case VALUE: {\n if (v === this.value) return;\n const s = absent(v) ? '' : text(v);\n if (this.value === UNSET) {\n // First creation: the attribute (the default), then the live value.\n if (absent(v)) el.removeAttribute('value');\n else el.setAttribute('value', s);\n if (PLAIN.test((el as HTMLInputElement).type)) this.kind = ATTR;\n }\n this.value = v;\n if (this.kind === VALUE && live.value !== s) live.value = s;\n return;\n }\n case CHECKED:\n case STATE: {\n const on = truthy(v);\n if (on === this.value) return;\n if (this.kind === CHECKED && this.value === UNSET) el.toggleAttribute(this.name, on);\n this.value = on;\n if (live[this.name] !== on) live[this.name] = on;\n return;\n }\n case OPEN: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n if (el.hasAttribute('open') !== on) el.toggleAttribute('open', on);\n return;\n }\n case TOGGLE: {\n const on = truthy(v);\n if (on === this.value) return;\n this.value = on;\n if (toggle !== undefined) toggle(this, this.name, on);\n else if (DEV) warnToggle(el, this.name);\n return;\n }\n case TITLE:\n case TEXTAREA: {\n const s = textOf(this, v);\n if (s === this.value) return;\n if (this.kind === TEXTAREA && this.value !== UNSET) {\n if (live.value !== s) live.value = s;\n } else el.textContent = s;\n this.value = s;\n return;\n }\n default:\n this.hook(v);\n }\n }\n\n /**\n * Writes the attribute; `style` through the CSSOM (`.style.cssText`), which a strict CSP\n * (`style-src` without `'unsafe-inline'`) allows where `setAttribute('style', …)` is blocked.\n * HTML, SVG and MathML elements all have `.style`.\n */\n write(s: string): void {\n if (this.name === 'style') (this.el as Element & ElementCSSInlineStyle).style.cssText = s;\n else this.el.setAttribute(this.name, s);\n }\n\n /**\n * MULTI: pieces joined with the static strings; `nothing` in any piece removes. With no\n * pieces it is a static `style` attribute (01 \"Normalization\"): written once, at creation.\n */\n private multi(values: readonly unknown[]): void {\n const pieces = this.pieces as unknown[];\n let changed = false;\n for (let i = 0; i < pieces.length; i++) {\n const v = values[this.at + i];\n if (v !== pieces[i]) {\n pieces[i] = v;\n changed = true;\n }\n }\n if (!changed && this.value !== UNSET) return;\n const joined = this.join(pieces);\n if (joined === this.value) return;\n this.value = joined;\n if (joined === null) this.el.removeAttribute(this.name);\n else this.write(joined);\n }\n\n /** The joined value of `pieces`, or null when one is `nothing`. */\n join(pieces: readonly unknown[]): string | null {\n const strings = this.strings as readonly string[];\n let joined = strings[0] as string;\n for (let i = 0; i < pieces.length; i++) {\n const v = pieces[i];\n if (v === nothing) return null;\n if (DEV && isObject(v)) warnValue(this, v, `the attribute ${this.name}`);\n joined += (v === null || v === undefined ? '' : text(v)) + (strings[i + 1] as string);\n }\n return joined;\n }\n\n /** HOOK: the result commits itself (hook-part.ts); an absent value forgets the hook. */\n hook(v: unknown): void {\n if (absent(v)) {\n this.spec = null;\n this.args = undefined;\n return;\n }\n const commit = isHook(v) ? v[COMMIT_HOOK] : undefined;\n if (commit !== undefined) commit(this, v as HookResult);\n else if (DEV) badHook(v);\n }\n}\n"]}
@@ -8,7 +8,7 @@ import { isTemplateResult, sourceOf, templateOf } from '../template.js';
8
8
  import { Instance } from './instance.js';
9
9
  import { clearList, commitItems } from './list.js';
10
10
  import { EACH, isList, isRaw, MARKUP, nothing } from './values.js';
11
- import { badChild, warnTrue } from './warn.js';
11
+ import { badChild, checkSvgParent, warnTrue } from './warn.js';
12
12
  /** What a child part holds. */
13
13
  export const EMPTY = 0;
14
14
  export const TEXT = 1;
@@ -147,7 +147,10 @@ export class ChildPart {
147
147
  this.create(result, source);
148
148
  }
149
149
  create(result, source) {
150
- const instance = new Instance(templateOf(result), source, this);
150
+ const template = templateOf(result);
151
+ if (DEV && template.svg)
152
+ checkSvgParent(this.parent());
153
+ const instance = new Instance(template, source, this);
151
154
  instance.update(result.values);
152
155
  instance.insert(this.parent(), this.end());
153
156
  this.kind = INSTANCE;
@@ -1 +1 @@
1
- {"version":3,"file":"child-part.js","sourceRoot":"","sources":["../../../src/view/render/child-part.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,2FAA2F;AAC3F,2FAA2F;AAC3F,4FAA4F;AAC5F,sFAAsF;AACtF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAuB,MAAM,gBAAgB,CAAC;AAC7F,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,WAAW,EAAa,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE/C,+BAA+B;AAC/B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AACvB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,CAAC;AAC1B,MAAM,CAAC,MAAM,KAAK,GAAG,CAAC,CAAC;AACvB,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC;AACtB,MAAM,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC;AAWrB,MAAM,OAAO,SAAS;IAsBpB,YACE,UAAuB,EACvB,GAAgB,EAChB,KAAmB,EACnB,KAAa,EACb,IAAa,EACb,EAAU;QAEV,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAA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CAAC,OAAO,GAAG,QAAQ,CAAC;IAC1B,CAAC;IAED,mDAAmD;IACnD,KAAK;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAG,OAAgB,CAAC,MAAM,EAAE,CAAC;aAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,SAAS,CAAC,IAAI,EAAE,OAAe,CAAC,CAAC;aAChF,IAAI,OAAO,KAAK,IAAI;YAAG,OAA+B,CAAC,MAAM,EAAE,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF","sourcesContent":["// The child part (view/02-bindings.md \"Child values\", \"The anchor rule\"): one class for every\n// child hole, list row, array item and render root, so its call sites stay monomorphic. It\n// inserts before its reference node: a static node of the template (`ref`), the end of its\n// parent element (`ref` null), or, for root-level holes, rows and items, wherever its owner\n// says (the instance's or list's position, resolved only when something is inserted).\nimport { DEV } from '#view-dev';\nimport { isTemplateResult, sourceOf, templateOf, type TemplateResult } from '../template.js';\nimport { Instance } from './instance.js';\nimport { clearList, commitItems, type List } from './list.js';\nimport { EACH, isList, isRaw, MARKUP, nothing } from './values.js';\nimport type { RawRange } from './raw.js';\nimport { badChild, warnTrue } from './warn.js';\n\n/** What a child part holds. */\nexport const EMPTY = 0;\nexport const TEXT = 1;\nexport const INSTANCE = 2;\nexport const ITEMS = 3;\nexport const LIST = 4;\nexport const RAW = 5;\n\n/** Resolves the position of the parts it owns (root-level open parts, rows, items). */\nexport interface Owner {\n parentFor(index: number): Node;\n endFor(index: number): Node | null;\n}\n\n/** What a child part's content can be, besides text. */\ntype Span = Instance | List | RawRange;\n\nexport class ChildPart {\n /** The parent element, when fixed (holes inside an element, the render root). */\n parentNode: Node | null;\n /** The static reference node; null: the end of `parentNode`. Unused when `owner` is set. */\n ref: Node | null;\n /** Set for open parts: their position comes from the owner. */\n owner: Owner | null;\n /** Position among the owner's rows or items. */\n index: number;\n /** Index of the value in the instance's values. */\n readonly at: number;\n /** The part is its parent element's only content (lists clear with replaceChildren). */\n readonly sole: boolean;\n kind: number;\n /** Committed text value (TEXT). */\n value: unknown;\n content: Text | Instance | List | RawRange | null;\n /** Rows of `each` (view/03-lists.md): key, item and pick result last rendered. */\n key: unknown;\n item: unknown;\n picked: unknown;\n\n constructor(\n parentNode: Node | null,\n ref: Node | null,\n owner: Owner | null,\n index: number,\n sole: boolean,\n at: number,\n ) {\n this.parentNode = parentNode;\n this.ref = ref;\n this.owner = owner;\n this.index = index;\n this.at = at;\n this.sole = sole;\n this.kind = EMPTY;\n this.value = undefined;\n this.content = null;\n this.key = undefined;\n this.item = undefined;\n this.picked = undefined;\n }\n\n set(values: readonly unknown[]): void {\n this.commit(values[this.at]);\n }\n\n /** The node new content goes into. */\n parent(): Node {\n if (this.parentNode !== null) return this.parentNode;\n if (this.owner !== null) return this.owner.parentFor(this.index);\n return (this.ref as Node).parentNode as Node;\n }\n\n /** The node after this part's content (null: the end of the parent). */\n end(): Node | null {\n return this.owner === null ? this.ref : this.owner.endFor(this.index);\n }\n\n first(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).first();\n }\n\n last(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).last();\n }\n\n commit(value: unknown): void {\n switch (typeof value) {\n case 'string':\n case 'number':\n this.text(value);\n return;\n case 'object':\n if (value === null) break;\n if (isTemplateResult(value)) {\n this.template(value);\n return;\n }\n if (isList(value)) {\n value[EACH](this, value);\n return;\n }\n if (Array.isArray(value)) {\n commitItems(this, value);\n return;\n }\n if (isRaw(value)) {\n value[MARKUP](this, value.html);\n return;\n }\n if (DEV) badChild(value);\n break;\n case 'boolean':\n if (DEV && value) warnTrue(this);\n break;\n case 'undefined':\n break;\n default:\n if (DEV && value !== nothing) badChild(value);\n }\n if (this.kind !== EMPTY) this.clear();\n }\n\n private text(value: string | number): void {\n if (this.kind === TEXT) {\n if (value !== this.value) {\n this.value = value;\n (this.content as Text).data = typeof value === 'string' ? value : String(value);\n }\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n const data = typeof value === 'string' ? value : String(value);\n const parent = this.parentNode;\n let node: Text;\n if (this.sole && parent !== null && data !== '') {\n // The parent's only content: one DOM call creates and inserts the Text node.\n parent.textContent = data;\n node = parent.firstChild as Text;\n } else {\n node = document.createTextNode(data);\n this.parent().insertBefore(node, this.end());\n }\n this.kind = TEXT;\n this.content = node;\n this.value = value;\n }\n\n private template(result: TemplateResult): void {\n const source = sourceOf(result);\n if (this.kind === INSTANCE) {\n const instance = this.content as Instance;\n if (instance.source === source) {\n instance.update(result.values);\n return;\n }\n // Another source with the same id (a second call site, a module reloaded in development)\n // is the same template. Production client objects have no id: each is its own template,\n // so a different object replaces the instance (01 \"Template ids\").\n const template = templateOf(result);\n if (template.id !== undefined && template.id === instance.template.id) {\n instance.source = source;\n instance.update(result.values);\n return;\n }\n this.clear();\n this.create(result, source);\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n this.create(result, source);\n }\n\n private create(result: TemplateResult, source: unknown): void {\n const instance = new Instance(templateOf(result), source, this);\n instance.update(result.values);\n instance.insert(this.parent(), this.end());\n this.kind = INSTANCE;\n this.content = instance;\n }\n\n /** Removes the content; the part becomes empty. */\n clear(): void {\n const content = this.content;\n if (this.kind === TEXT) (content as Text).remove();\n else if (this.kind === ITEMS || this.kind === LIST) clearList(this, content as List);\n else if (content !== null) (content as Instance | RawRange).remove();\n this.kind = EMPTY;\n this.content = null;\n this.value = undefined;\n }\n}\n"]}
1
+ {"version":3,"file":"child-part.js","sourceRoot":"","sources":["../../../src/view/render/child-part.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,2FAA2F;AAC3F,2FAA2F;AAC3F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AAC;IAC1B,CAAC;IAED,mDAAmD;IACnD,KAAK;QACH,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC7B,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAG,OAAgB,CAAC,MAAM,EAAE,CAAC;aAC9C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;YAAE,SAAS,CAAC,IAAI,EAAE,OAAe,CAAC,CAAC;aAChF,IAAI,OAAO,KAAK,IAAI;YAAG,OAA+B,CAAC,MAAM,EAAE,CAAC;QACrE,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC;QAClB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;CACF","sourcesContent":["// The child part (view/02-bindings.md \"Child values\", \"The anchor rule\"): one class for every\n// child hole, list row, array item and render root, so its call sites stay monomorphic. It\n// inserts before its reference node: a static node of the template (`ref`), the end of its\n// parent element (`ref` null), or, for root-level holes, rows and items, wherever its owner\n// says (the instance's or list's position, resolved only when something is inserted).\nimport { DEV } from '#view-dev';\nimport { isTemplateResult, sourceOf, templateOf, type TemplateResult } from '../template.js';\nimport { Instance } from './instance.js';\nimport { clearList, commitItems, type List } from './list.js';\nimport { EACH, isList, isRaw, MARKUP, nothing } from './values.js';\nimport type { RawRange } from './raw.js';\nimport { badChild, checkSvgParent, warnTrue } from './warn.js';\n\n/** What a child part holds. */\nexport const EMPTY = 0;\nexport const TEXT = 1;\nexport const INSTANCE = 2;\nexport const ITEMS = 3;\nexport const LIST = 4;\nexport const RAW = 5;\n\n/** Resolves the position of the parts it owns (root-level open parts, rows, items). */\nexport interface Owner {\n parentFor(index: number): Node;\n endFor(index: number): Node | null;\n}\n\n/** What a child part's content can be, besides text. */\ntype Span = Instance | List | RawRange;\n\nexport class ChildPart {\n /** The parent element, when fixed (holes inside an element, the render root). */\n parentNode: Node | null;\n /** The static reference node; null: the end of `parentNode`. Unused when `owner` is set. */\n ref: Node | null;\n /** Set for open parts: their position comes from the owner. */\n owner: Owner | null;\n /** Position among the owner's rows or items. */\n index: number;\n /** Index of the value in the instance's values. */\n readonly at: number;\n /** The part is its parent element's only content (lists clear with replaceChildren). */\n readonly sole: boolean;\n kind: number;\n /** Committed text value (TEXT). */\n value: unknown;\n content: Text | Instance | List | RawRange | null;\n /** Rows of `each` (view/03-lists.md): key, item and pick result last rendered. */\n key: unknown;\n item: unknown;\n picked: unknown;\n\n constructor(\n parentNode: Node | null,\n ref: Node | null,\n owner: Owner | null,\n index: number,\n sole: boolean,\n at: number,\n ) {\n this.parentNode = parentNode;\n this.ref = ref;\n this.owner = owner;\n this.index = index;\n this.at = at;\n this.sole = sole;\n this.kind = EMPTY;\n this.value = undefined;\n this.content = null;\n this.key = undefined;\n this.item = undefined;\n this.picked = undefined;\n }\n\n set(values: readonly unknown[]): void {\n this.commit(values[this.at]);\n }\n\n /** The node new content goes into. */\n parent(): Node {\n if (this.parentNode !== null) return this.parentNode;\n if (this.owner !== null) return this.owner.parentFor(this.index);\n return (this.ref as Node).parentNode as Node;\n }\n\n /** The node after this part's content (null: the end of the parent). */\n end(): Node | null {\n return this.owner === null ? this.ref : this.owner.endFor(this.index);\n }\n\n first(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).first();\n }\n\n last(): Node | null {\n const content = this.content;\n return this.kind === TEXT ? (content as Text) : content && (content as Span).last();\n }\n\n commit(value: unknown): void {\n switch (typeof value) {\n case 'string':\n case 'number':\n this.text(value);\n return;\n case 'object':\n if (value === null) break;\n if (isTemplateResult(value)) {\n this.template(value);\n return;\n }\n if (isList(value)) {\n value[EACH](this, value);\n return;\n }\n if (Array.isArray(value)) {\n commitItems(this, value);\n return;\n }\n if (isRaw(value)) {\n value[MARKUP](this, value.html);\n return;\n }\n if (DEV) badChild(value);\n break;\n case 'boolean':\n if (DEV && value) warnTrue(this);\n break;\n case 'undefined':\n break;\n default:\n if (DEV && value !== nothing) badChild(value);\n }\n if (this.kind !== EMPTY) this.clear();\n }\n\n private text(value: string | number): void {\n if (this.kind === TEXT) {\n if (value !== this.value) {\n this.value = value;\n (this.content as Text).data = typeof value === 'string' ? value : String(value);\n }\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n const data = typeof value === 'string' ? value : String(value);\n const parent = this.parentNode;\n let node: Text;\n if (this.sole && parent !== null && data !== '') {\n // The parent's only content: one DOM call creates and inserts the Text node.\n parent.textContent = data;\n node = parent.firstChild as Text;\n } else {\n node = document.createTextNode(data);\n this.parent().insertBefore(node, this.end());\n }\n this.kind = TEXT;\n this.content = node;\n this.value = value;\n }\n\n private template(result: TemplateResult): void {\n const source = sourceOf(result);\n if (this.kind === INSTANCE) {\n const instance = this.content as Instance;\n if (instance.source === source) {\n instance.update(result.values);\n return;\n }\n // Another source with the same id (a second call site, a module reloaded in development)\n // is the same template. Production client objects have no id: each is its own template,\n // so a different object replaces the instance (01 \"Template ids\").\n const template = templateOf(result);\n if (template.id !== undefined && template.id === instance.template.id) {\n instance.source = source;\n instance.update(result.values);\n return;\n }\n this.clear();\n this.create(result, source);\n return;\n }\n if (this.kind !== EMPTY) this.clear();\n this.create(result, source);\n }\n\n private create(result: TemplateResult, source: unknown): void {\n const template = templateOf(result);\n if (DEV && template.svg) checkSvgParent(this.parent());\n const instance = new Instance(template, source, this);\n instance.update(result.values);\n instance.insert(this.parent(), this.end());\n this.kind = INSTANCE;\n this.content = instance;\n }\n\n /** Removes the content; the part becomes empty. */\n clear(): void {\n const content = this.content;\n if (this.kind === TEXT) (content as Text).remove();\n else if (this.kind === ITEMS || this.kind === LIST) clearList(this, content as List);\n else if (content !== null) (content as Instance | RawRange).remove();\n this.kind = EMPTY;\n this.content = null;\n this.value = undefined;\n }\n}\n"]}
@@ -0,0 +1,3 @@
1
+ import { type HookPart, type HookResult } from './hooks.js';
2
+ /** Commits a disposable hook, then tracks it for removal and disconnects. */
3
+ export declare function commitTracked(part: HookPart, result: HookResult): void;
@@ -0,0 +1,76 @@
1
+ // Disposable hooks (view/02-bindings.md "Widgets with a lifecycle"): hooks whose spec has
2
+ // `dispose`, and the tracking behind it. A disposable hook is tracked per render root from its commit
3
+ // (`track`), with the spec and arguments to dispose (`kept`, `keptArgs`). After each render of
4
+ // a root commits, before its client calls, `run` disposes every tracked hook whose element left
5
+ // the root (Gyral removed it: a cleared part, a replaced instance, a removed row; moves keep it
6
+ // inside) or whose position no longer holds it (`nothing`, another hook); a disposable hook
7
+ // replacing one disposes the old one in `track`. When the host disconnects, `run(root, true)`
8
+ // disposes the root's hooks and marks them `off`: the render on reconnect re-commits them from
9
+ // scratch (`prev` undefined) or, for skipped rows, `run` queues their `client` again. Nothing
10
+ // here is bundled unless it is registered (`#spec-features`, or use-disposal.ts when a module
11
+ // names `dispose`: gyral-c5d.2, gyral-1zd.24), and nothing runs until such a hook commits.
12
+ import { commitHook } from './hook-part.js';
13
+ import { committing, queueHook, useDisposal, } from './hooks.js';
14
+ /** Parts committed since their root's hooks last ran, with that root. */
15
+ let fresh = [];
16
+ const live = new WeakMap();
17
+ const dispose = (p) => {
18
+ p.kept.dispose?.(p.el, p.keptArgs);
19
+ };
20
+ function run(root, disconnect) {
21
+ let tracked = live.get(root);
22
+ if (disconnect !== true) {
23
+ // Inside a flush several roots commit before their hooks run: keep the others' parts.
24
+ const rest = [];
25
+ for (const entry of fresh) {
26
+ const [p, owner] = entry;
27
+ if (owner !== root) {
28
+ if (p.el.isConnected)
29
+ rest.push(entry);
30
+ continue;
31
+ }
32
+ if (!root.contains(p.el))
33
+ continue; // left over from a render that threw
34
+ if (tracked === undefined)
35
+ live.set(root, (tracked = new Set()));
36
+ tracked.add(p);
37
+ }
38
+ fresh = rest;
39
+ }
40
+ if (tracked === undefined)
41
+ return false;
42
+ for (const p of tracked) {
43
+ const off = p.off;
44
+ p.off = disconnect;
45
+ if (disconnect === true || !root.contains(p.el) || p.spec !== p.kept) {
46
+ if (disconnect !== true)
47
+ tracked.delete(p);
48
+ if (off !== true)
49
+ dispose(p);
50
+ }
51
+ else if (off === true) {
52
+ p.prev = undefined; // a skipped row's hook: client again, from scratch
53
+ queueHook(p);
54
+ }
55
+ }
56
+ return tracked.size > 0;
57
+ }
58
+ /** A disposable hook committed at `part`: tracks it, and turns disposal on. */
59
+ function track(part) {
60
+ useDisposal(run);
61
+ // Replaced by this one, unless a disconnect disposed it already.
62
+ if (part.off !== true && part.kept !== undefined && part.kept !== part.spec)
63
+ dispose(part);
64
+ part.off = false;
65
+ part.kept = part.spec ?? undefined;
66
+ part.keptArgs = part.args;
67
+ fresh.push([part, committing()]);
68
+ }
69
+ /** Commits a disposable hook, then tracks it for removal and disconnects. */
70
+ export function commitTracked(part, result) {
71
+ if (part.off === true)
72
+ part.spec = null; // disposed by a disconnect: start over, always queued
73
+ commitHook(part, result);
74
+ track(part);
75
+ }
76
+ //# sourceMappingURL=dispose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dispose.js","sourceRoot":"","sources":["../../../src/view/render/dispose.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,sGAAsG;AACtG,+FAA+F;AAC/F,gGAAgG;AAChG,gGAAgG;AAChG,4FAA4F;AAC5F,8FAA8F;AAC9F,+FAA+F;AAC/F,8FAA8F;AAC9F,8FAA8F;AAC9F,2FAA2F;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,GAIZ,MAAM,YAAY,CAAC;AAEpB,yEAAyE;AACzE,IAAI,KAAK,GAAmC,EAAE,CAAC;AAC/C,MAAM,IAAI,GAAG,IAAI,OAAO,EAAuB,CAAC;AAEhD,MAAM,OAAO,GAAG,CAAC,CAAW,EAAQ,EAAE;IACnC,CAAC,CAAC,IAAqC,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,QAA8B,CAAC,CAAC;AAC7F,CAA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,IAAI,GAAG,KAAK,IAAI;gBAAE,OAAO,CAAC,CAAC,CAAC,CAAC;QAC/B,CAAC;aAAM,IAAI,GAAG,KAAK,IAAI,EAAE,CAAC;YACxB,CAAC,CAAC,IAAI,GAAG,SAAS,CAAC,CAAC,mDAAmD;YACvE,SAAS,CAAC,CAAC,CAAC,CAAC;QACf,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC,IAAI,GAAG,CAAC,CAAC;AAC1B,CAAC;AAED,+EAA+E;AAC/E,SAAS,KAAK,CAAC,IAAc;IAC3B,WAAW,CAAC,GAAG,CAAC,CAAC;IACjB,iEAAiE;IACjE,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI,IAAI,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI;QAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3F,IAAI,CAAC,GAAG,GAAG,KAAK,CAAC;IACjB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,SAAS,CAAC;IACnC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;IAC1B,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC;AACnC,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,aAAa,CAAC,IAAc,EAAE,MAAkB;IAC9D,IAAI,IAAI,CAAC,GAAG,KAAK,IAAI;QAAE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,sDAAsD;IAC/F,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACzB,KAAK,CAAC,IAAI,CAAC,CAAC;AACd,CAAC","sourcesContent":["// Disposable hooks (view/02-bindings.md \"Widgets with a lifecycle\"): hooks whose spec has\n// `dispose`, and the tracking behind it. A disposable hook is tracked per render root from its commit\n// (`track`), with the spec and arguments to dispose (`kept`, `keptArgs`). After each render of\n// a root commits, before its client calls, `run` disposes every tracked hook whose element left\n// the root (Gyral removed it: a cleared part, a replaced instance, a removed row; moves keep it\n// inside) or whose position no longer holds it (`nothing`, another hook); a disposable hook\n// replacing one disposes the old one in `track`. When the host disconnects, `run(root, true)`\n// disposes the root's hooks and marks them `off`: the render on reconnect re-commits them from\n// scratch (`prev` undefined) or, for skipped rows, `run` queues their `client` again. Nothing\n// here is bundled unless it is registered (`#spec-features`, or use-disposal.ts when a module\n// names `dispose`: gyral-c5d.2, gyral-1zd.24), and nothing runs until such a hook commits.\nimport { commitHook } from './hook-part.js';\nimport {\n committing,\n queueHook,\n useDisposal,\n type HookPart,\n type HookResult,\n type HookSpec,\n} from './hooks.js';\n\n/** Parts committed since their root's hooks last ran, with that root. */\nlet fresh: [HookPart, Node | undefined][] = [];\nconst live = new WeakMap<Node, Set<HookPart>>();\n\nconst dispose = (p: HookPart): void => {\n (p.kept as HookSpec<readonly unknown[]>).dispose?.(p.el, p.keptArgs as readonly unknown[]);\n};\n\nfunction run(root: Node, disconnect?: boolean): boolean {\n let tracked = live.get(root);\n if (disconnect !== true) {\n // Inside a flush several roots commit before their hooks run: keep the others' parts.\n const rest: [HookPart, Node | undefined][] = [];\n for (const entry of fresh) {\n const [p, owner] = entry;\n if (owner !== root) {\n if (p.el.isConnected) rest.push(entry);\n continue;\n }\n if (!root.contains(p.el)) continue; // left over from a render that threw\n if (tracked === undefined) live.set(root, (tracked = new Set()));\n tracked.add(p);\n }\n fresh = rest;\n }\n if (tracked === undefined) return false;\n for (const p of tracked) {\n const off = p.off;\n p.off = disconnect;\n if (disconnect === true || !root.contains(p.el) || p.spec !== p.kept) {\n if (disconnect !== true) tracked.delete(p);\n if (off !== true) dispose(p);\n } else if (off === true) {\n p.prev = undefined; // a skipped row's hook: client again, from scratch\n queueHook(p);\n }\n }\n return tracked.size > 0;\n}\n\n/** A disposable hook committed at `part`: tracks it, and turns disposal on. */\nfunction track(part: HookPart): void {\n useDisposal(run);\n // Replaced by this one, unless a disconnect disposed it already.\n if (part.off !== true && part.kept !== undefined && part.kept !== part.spec) dispose(part);\n part.off = false;\n part.kept = part.spec ?? undefined;\n part.keptArgs = part.args;\n fresh.push([part, committing()]);\n}\n\n/** Commits a disposable hook, then tracks it for removal and disconnects. */\nexport function commitTracked(part: HookPart, result: HookResult): void {\n if (part.off === true) part.spec = null; // disposed by a disconnect: start over, always queued\n commitHook(part, result);\n track(part);\n}\n"]}
@@ -1,3 +1,5 @@
1
- import { type HookResult, type HookSpec } from './hooks.js';
1
+ import { type HookPart, type HookResult, type HookSpec } from './hooks.js';
2
+ /** Queues the client call when the hook or its arguments changed, or always (`update`). */
3
+ export declare function commitHook(part: HookPart, result: HookResult): void;
2
4
  /** Defines an element hook: a small behaviour attached to the element it sits on. */
3
5
  export declare function defineHook<A extends readonly unknown[]>(spec: HookSpec<A>): (...args: A) => HookResult<A>;