@gyral/core 0.2.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (517) hide show
  1. package/CHANGELOG.md +129 -0
  2. package/NOTICE +19 -0
  3. package/README.md +35 -8
  4. package/dist/call.d.ts +32 -0
  5. package/dist/call.js +63 -0
  6. package/dist/call.js.map +1 -0
  7. package/dist/children.d.ts +30 -5
  8. package/dist/children.js +26 -4
  9. package/dist/children.js.map +1 -1
  10. package/dist/cli/gyral-types.d.ts +2 -0
  11. package/dist/cli/gyral-types.js +23 -0
  12. package/dist/cli/gyral-types.js.map +1 -0
  13. package/dist/command.d.ts +54 -12
  14. package/dist/command.js +31 -11
  15. package/dist/command.js.map +1 -1
  16. package/dist/compiler/ast.d.ts +23 -0
  17. package/dist/compiler/ast.js +149 -0
  18. package/dist/compiler/ast.js.map +1 -0
  19. package/dist/compiler/compile.d.ts +41 -0
  20. package/dist/compiler/compile.js +148 -0
  21. package/dist/compiler/compile.js.map +1 -0
  22. package/dist/compiler/component-entries.d.ts +7 -0
  23. package/dist/compiler/component-entries.js +42 -0
  24. package/dist/compiler/component-entries.js.map +1 -0
  25. package/dist/compiler/components.d.ts +4 -0
  26. package/dist/compiler/components.js +182 -0
  27. package/dist/compiler/components.js.map +1 -0
  28. package/dist/compiler/facts.d.ts +31 -0
  29. package/dist/compiler/facts.js +285 -0
  30. package/dist/compiler/facts.js.map +1 -0
  31. package/dist/compiler/features.d.ts +34 -0
  32. package/dist/compiler/features.js +158 -0
  33. package/dist/compiler/features.js.map +1 -0
  34. package/dist/compiler/hooks.d.ts +22 -0
  35. package/dist/compiler/hooks.js +241 -0
  36. package/dist/compiler/hooks.js.map +1 -0
  37. package/dist/compiler/loader-source.d.ts +14 -0
  38. package/dist/compiler/loader-source.js +86 -0
  39. package/dist/compiler/loader-source.js.map +1 -0
  40. package/dist/compiler/locate.d.ts +14 -0
  41. package/dist/compiler/locate.js +78 -0
  42. package/dist/compiler/locate.js.map +1 -0
  43. package/dist/compiler/parse5-check.d.ts +21 -0
  44. package/dist/compiler/parse5-check.js +60 -0
  45. package/dist/compiler/parse5-check.js.map +1 -0
  46. package/dist/compiler/prop-schemas.d.ts +4 -0
  47. package/dist/compiler/prop-schemas.js +108 -0
  48. package/dist/compiler/prop-schemas.js.map +1 -0
  49. package/dist/compiler/scan.d.ts +41 -0
  50. package/dist/compiler/scan.js +160 -0
  51. package/dist/compiler/scan.js.map +1 -0
  52. package/dist/compiler/scope.d.ts +8 -0
  53. package/dist/compiler/scope.js +116 -0
  54. package/dist/compiler/scope.js.map +1 -0
  55. package/dist/compiler/source.d.ts +34 -0
  56. package/dist/compiler/source.js +114 -0
  57. package/dist/compiler/source.js.map +1 -0
  58. package/dist/compiler/tag-map.d.ts +41 -0
  59. package/dist/compiler/tag-map.js +126 -0
  60. package/dist/compiler/tag-map.js.map +1 -0
  61. package/dist/components-ready.d.ts +7 -0
  62. package/dist/components-ready.js +19 -0
  63. package/dist/components-ready.js.map +1 -0
  64. package/dist/define.d.ts +13 -4
  65. package/dist/define.js +35 -331
  66. package/dist/define.js.map +1 -1
  67. package/dist/devtools-events.d.ts +13 -0
  68. package/dist/devtools-events.js.map +1 -1
  69. package/dist/devtools-off.d.ts +2 -0
  70. package/dist/devtools-off.js +2 -0
  71. package/dist/devtools-off.js.map +1 -1
  72. package/dist/devtools.d.ts +4 -0
  73. package/dist/devtools.js +17 -2
  74. package/dist/devtools.js.map +1 -1
  75. package/dist/drivers-scope.d.ts +1 -1
  76. package/dist/drivers-scope.js +1 -8
  77. package/dist/drivers-scope.js.map +1 -1
  78. package/dist/element-internals.d.ts +1 -0
  79. package/dist/element-internals.js +11 -0
  80. package/dist/element-internals.js.map +1 -0
  81. package/dist/element-types.d.ts +11 -5
  82. package/dist/element-types.js.map +1 -1
  83. package/dist/element.d.ts +3 -0
  84. package/dist/element.js +322 -0
  85. package/dist/element.js.map +1 -0
  86. package/dist/error-view.d.ts +10 -0
  87. package/dist/error-view.js +30 -0
  88. package/dist/error-view.js.map +1 -0
  89. package/dist/errors.d.ts +21 -0
  90. package/dist/errors.js +47 -0
  91. package/dist/errors.js.map +1 -0
  92. package/dist/errors.json +289 -0
  93. package/dist/eslint/imports.d.ts +26 -0
  94. package/dist/eslint/imports.js +78 -0
  95. package/dist/eslint/imports.js.map +1 -0
  96. package/dist/eslint/index.d.ts +16 -0
  97. package/dist/eslint/index.js +23 -0
  98. package/dist/eslint/index.js.map +1 -0
  99. package/dist/eslint/locate.d.ts +33 -0
  100. package/dist/eslint/locate.js +132 -0
  101. package/dist/eslint/locate.js.map +1 -0
  102. package/dist/eslint/row-purity-rule.d.ts +2 -0
  103. package/dist/eslint/row-purity-rule.js +103 -0
  104. package/dist/eslint/row-purity-rule.js.map +1 -0
  105. package/dist/eslint/template-rule.d.ts +6 -0
  106. package/dist/eslint/template-rule.js +76 -0
  107. package/dist/eslint/template-rule.js.map +1 -0
  108. package/dist/eslint/unused-intent-rule.d.ts +2 -0
  109. package/dist/eslint/unused-intent-rule.js +186 -0
  110. package/dist/eslint/unused-intent-rule.js.map +1 -0
  111. package/dist/features.d.ts +39 -0
  112. package/dist/features.js +2 -0
  113. package/dist/features.js.map +1 -0
  114. package/dist/focus.d.ts +13 -12
  115. package/dist/focus.js +44 -11
  116. package/dist/focus.js.map +1 -1
  117. package/dist/form-associated.d.ts +46 -0
  118. package/dist/form-associated.js +77 -0
  119. package/dist/form-associated.js.map +1 -0
  120. package/dist/forms.d.ts +42 -30
  121. package/dist/forms.js +85 -41
  122. package/dist/forms.js.map +1 -1
  123. package/dist/frame-lane.d.ts +11 -0
  124. package/dist/frame-lane.js +28 -0
  125. package/dist/frame-lane.js.map +1 -0
  126. package/dist/head.d.ts +61 -0
  127. package/dist/head.js +85 -0
  128. package/dist/head.js.map +1 -0
  129. package/dist/hooks/invalid.d.ts +14 -0
  130. package/dist/hooks/invalid.js +72 -0
  131. package/dist/hooks/invalid.js.map +1 -0
  132. package/dist/host-model.d.ts +77 -0
  133. package/dist/host-model.js +278 -0
  134. package/dist/host-model.js.map +1 -0
  135. package/dist/hydration-client.d.ts +9 -0
  136. package/dist/hydration-client.js +35 -0
  137. package/dist/hydration-client.js.map +1 -0
  138. package/dist/hydration-loader.d.ts +13 -0
  139. package/dist/hydration-loader.js +58 -0
  140. package/dist/hydration-loader.js.map +1 -0
  141. package/dist/hydration-off.d.ts +8 -0
  142. package/dist/hydration-off.js +25 -0
  143. package/dist/hydration-off.js.map +1 -0
  144. package/dist/hydration.d.ts +3 -21
  145. package/dist/hydration.js +14 -63
  146. package/dist/hydration.js.map +1 -1
  147. package/dist/index.d.ts +24 -36
  148. package/dist/index.js +14 -32
  149. package/dist/index.js.map +1 -1
  150. package/dist/indexeddb-types.d.ts +97 -0
  151. package/dist/indexeddb-types.js +2 -0
  152. package/dist/indexeddb-types.js.map +1 -0
  153. package/dist/indexeddb.d.ts +5 -0
  154. package/dist/indexeddb.js +118 -0
  155. package/dist/indexeddb.js.map +1 -0
  156. package/dist/intent.d.ts +62 -17
  157. package/dist/intent.js +193 -100
  158. package/dist/intent.js.map +1 -1
  159. package/dist/internal/indexeddb-open.d.ts +8 -0
  160. package/dist/internal/indexeddb-open.js +96 -0
  161. package/dist/internal/indexeddb-open.js.map +1 -0
  162. package/dist/internal/indexeddb-transaction.d.ts +4 -0
  163. package/dist/internal/indexeddb-transaction.js +134 -0
  164. package/dist/internal/indexeddb-transaction.js.map +1 -0
  165. package/dist/internal/interpreter.d.ts +15 -1
  166. package/dist/internal/interpreter.js +42 -47
  167. package/dist/internal/interpreter.js.map +1 -1
  168. package/dist/internal/token.d.ts +1 -0
  169. package/dist/internal/token.js +7 -0
  170. package/dist/internal/token.js.map +1 -0
  171. package/dist/internal.d.ts +20 -0
  172. package/dist/internal.js +22 -0
  173. package/dist/internal.js.map +1 -0
  174. package/dist/invoker-fallback-used.d.ts +4 -0
  175. package/dist/invoker-fallback-used.js +10 -0
  176. package/dist/invoker-fallback-used.js.map +1 -0
  177. package/dist/invoker-fallback.d.ts +4 -0
  178. package/dist/invoker-fallback.js +15 -0
  179. package/dist/invoker-fallback.js.map +1 -0
  180. package/dist/invokers-shim.d.ts +6 -0
  181. package/dist/invokers-shim.js +32 -0
  182. package/dist/invokers-shim.js.map +1 -0
  183. package/dist/invokers.d.ts +3 -5
  184. package/dist/invokers.js +11 -51
  185. package/dist/invokers.js.map +1 -1
  186. package/dist/islands.d.ts +0 -2
  187. package/dist/islands.js +4 -11
  188. package/dist/islands.js.map +1 -1
  189. package/dist/light-dom.d.ts +4 -53
  190. package/dist/light-dom.js +5 -100
  191. package/dist/light-dom.js.map +1 -1
  192. package/dist/prop.d.ts +89 -0
  193. package/dist/prop.js +41 -0
  194. package/dist/prop.js.map +1 -0
  195. package/dist/props.d.ts +57 -21
  196. package/dist/props.js +157 -34
  197. package/dist/props.js.map +1 -1
  198. package/dist/retry.d.ts +15 -0
  199. package/dist/retry.js +48 -0
  200. package/dist/retry.js.map +1 -0
  201. package/dist/scheduler.d.ts +43 -0
  202. package/dist/scheduler.js +212 -0
  203. package/dist/scheduler.js.map +1 -0
  204. package/dist/script-json.d.ts +2 -0
  205. package/dist/script-json.js +13 -0
  206. package/dist/script-json.js.map +1 -0
  207. package/dist/server-component.d.ts +10 -0
  208. package/dist/server-component.js +133 -0
  209. package/dist/server-component.js.map +1 -0
  210. package/dist/server-specs.d.ts +6 -0
  211. package/dist/server-specs.js +13 -0
  212. package/dist/server-specs.js.map +1 -0
  213. package/dist/server.d.ts +34 -0
  214. package/dist/server.js +59 -0
  215. package/dist/server.js.map +1 -0
  216. package/dist/settled.d.ts +11 -0
  217. package/dist/settled.js +62 -0
  218. package/dist/settled.js.map +1 -0
  219. package/dist/spec-features-used.d.ts +21 -0
  220. package/dist/spec-features-used.js +50 -0
  221. package/dist/spec-features-used.js.map +1 -0
  222. package/dist/spec-features.d.ts +28 -0
  223. package/dist/spec-features.js +42 -0
  224. package/dist/spec-features.js.map +1 -0
  225. package/dist/states.d.ts +3 -5
  226. package/dist/states.js +22 -11
  227. package/dist/states.js.map +1 -1
  228. package/dist/storage.d.ts +69 -0
  229. package/dist/storage.js +158 -0
  230. package/dist/storage.js.map +1 -0
  231. package/dist/store-binding.d.ts +6 -3
  232. package/dist/store-binding.js +7 -8
  233. package/dist/store-binding.js.map +1 -1
  234. package/dist/store-scope.d.ts +8 -11
  235. package/dist/store-scope.js +15 -40
  236. package/dist/store-scope.js.map +1 -1
  237. package/dist/store.d.ts +3 -0
  238. package/dist/store.js +45 -10
  239. package/dist/store.js.map +1 -1
  240. package/dist/stores-provider.d.ts +2 -6
  241. package/dist/stores-provider.js +21 -55
  242. package/dist/stores-provider.js.map +1 -1
  243. package/dist/subscription.d.ts +35 -0
  244. package/dist/subscription.js +74 -0
  245. package/dist/subscription.js.map +1 -0
  246. package/dist/subscriptions.d.ts +26 -0
  247. package/dist/subscriptions.js +98 -0
  248. package/dist/subscriptions.js.map +1 -0
  249. package/dist/transitions.d.ts +5 -7
  250. package/dist/transitions.js +17 -20
  251. package/dist/transitions.js.map +1 -1
  252. package/dist/types.d.ts +142 -49
  253. package/dist/types.js.map +1 -1
  254. package/dist/use-dialogs.d.ts +2 -0
  255. package/dist/use-dialogs.js +9 -0
  256. package/dist/use-dialogs.js.map +1 -0
  257. package/dist/use-disposal.d.ts +2 -0
  258. package/dist/use-disposal.js +9 -0
  259. package/dist/use-disposal.js.map +1 -0
  260. package/dist/use-error-view.d.ts +2 -0
  261. package/dist/use-error-view.js +9 -0
  262. package/dist/use-error-view.js.map +1 -0
  263. package/dist/use-errored.d.ts +2 -0
  264. package/dist/use-errored.js +9 -0
  265. package/dist/use-errored.js.map +1 -0
  266. package/dist/use-form-associated.d.ts +2 -0
  267. package/dist/use-form-associated.js +7 -0
  268. package/dist/use-form-associated.js.map +1 -0
  269. package/dist/use-frame-lane.d.ts +2 -0
  270. package/dist/use-frame-lane.js +10 -0
  271. package/dist/use-frame-lane.js.map +1 -0
  272. package/dist/use-invokers.d.ts +2 -0
  273. package/dist/use-invokers.js +10 -0
  274. package/dist/use-invokers.js.map +1 -0
  275. package/dist/use-states.d.ts +2 -0
  276. package/dist/use-states.js +10 -0
  277. package/dist/use-states.js.map +1 -0
  278. package/dist/use-subscriptions.d.ts +2 -0
  279. package/dist/use-subscriptions.js +10 -0
  280. package/dist/use-subscriptions.js.map +1 -0
  281. package/dist/use-transitions.d.ts +2 -0
  282. package/dist/use-transitions.js +10 -0
  283. package/dist/use-transitions.js.map +1 -0
  284. package/dist/view/attributes.d.ts +11 -0
  285. package/dist/view/attributes.js +15 -0
  286. package/dist/view/attributes.js.map +1 -0
  287. package/dist/view/compiled.d.ts +1 -0
  288. package/dist/view/compiled.js +6 -0
  289. package/dist/view/compiled.js.map +1 -0
  290. package/dist/view/dev-off.d.ts +1 -0
  291. package/dist/view/dev-off.js +4 -0
  292. package/dist/view/dev-off.js.map +1 -0
  293. package/dist/view/dev.d.ts +1 -0
  294. package/dist/view/dev.js +5 -0
  295. package/dist/view/dev.js.map +1 -0
  296. package/dist/view/flags.d.ts +1 -0
  297. package/dist/view/flags.js +4 -0
  298. package/dist/view/flags.js.map +1 -0
  299. package/dist/view/index.d.ts +26 -0
  300. package/dist/view/index.js +27 -0
  301. package/dist/view/index.js.map +1 -0
  302. package/dist/view/loc.d.ts +9 -0
  303. package/dist/view/loc.js +50 -0
  304. package/dist/view/loc.js.map +1 -0
  305. package/dist/view/message.d.ts +17 -0
  306. package/dist/view/message.js +40 -0
  307. package/dist/view/message.js.map +1 -0
  308. package/dist/view/messages.d.ts +43 -0
  309. package/dist/view/messages.js +84 -0
  310. package/dist/view/messages.js.map +1 -0
  311. package/dist/view/normalize/check.d.ts +23 -0
  312. package/dist/view/normalize/check.js +81 -0
  313. package/dist/view/normalize/check.js.map +1 -0
  314. package/dist/view/normalize/emit.d.ts +15 -0
  315. package/dist/view/normalize/emit.js +165 -0
  316. package/dist/view/normalize/emit.js.map +1 -0
  317. package/dist/view/normalize/entities.d.ts +4 -0
  318. package/dist/view/normalize/entities.js +38 -0
  319. package/dist/view/normalize/entities.js.map +1 -0
  320. package/dist/view/normalize/errors.d.ts +9 -0
  321. package/dist/view/normalize/errors.js +19 -0
  322. package/dist/view/normalize/errors.js.map +1 -0
  323. package/dist/view/normalize/id.d.ts +10 -0
  324. package/dist/view/normalize/id.js +55 -0
  325. package/dist/view/normalize/id.js.map +1 -0
  326. package/dist/view/normalize/normalize.d.ts +18 -0
  327. package/dist/view/normalize/normalize.js +42 -0
  328. package/dist/view/normalize/normalize.js.map +1 -0
  329. package/dist/view/normalize/repairs.d.ts +24 -0
  330. package/dist/view/normalize/repairs.js +166 -0
  331. package/dist/view/normalize/repairs.js.map +1 -0
  332. package/dist/view/normalize/rules.d.ts +39 -0
  333. package/dist/view/normalize/rules.js +120 -0
  334. package/dist/view/normalize/rules.js.map +1 -0
  335. package/dist/view/normalize/shape.d.ts +5 -0
  336. package/dist/view/normalize/shape.js +38 -0
  337. package/dist/view/normalize/shape.js.map +1 -0
  338. package/dist/view/normalize/source.d.ts +13 -0
  339. package/dist/view/normalize/source.js +34 -0
  340. package/dist/view/normalize/source.js.map +1 -0
  341. package/dist/view/normalize/svg.d.ts +14 -0
  342. package/dist/view/normalize/svg.js +40 -0
  343. package/dist/view/normalize/svg.js.map +1 -0
  344. package/dist/view/normalize/tag-states.d.ts +23 -0
  345. package/dist/view/normalize/tag-states.js +192 -0
  346. package/dist/view/normalize/tag-states.js.map +1 -0
  347. package/dist/view/normalize/tokenizer.d.ts +5 -0
  348. package/dist/view/normalize/tokenizer.js +233 -0
  349. package/dist/view/normalize/tokenizer.js.map +1 -0
  350. package/dist/view/normalize/tokens.d.ts +55 -0
  351. package/dist/view/normalize/tokens.js +24 -0
  352. package/dist/view/normalize/tokens.js.map +1 -0
  353. package/dist/view/normalize/tree.d.ts +65 -0
  354. package/dist/view/normalize/tree.js +235 -0
  355. package/dist/view/normalize/tree.js.map +1 -0
  356. package/dist/view/normalize/types.d.ts +146 -0
  357. package/dist/view/normalize/types.js +29 -0
  358. package/dist/view/normalize/types.js.map +1 -0
  359. package/dist/view/normalize/whitespace.d.ts +2 -0
  360. package/dist/{template-whitespace.js → view/normalize/whitespace.js} +27 -36
  361. package/dist/view/normalize/whitespace.js.map +1 -0
  362. package/dist/view/prepare-stub.d.ts +3 -0
  363. package/dist/view/prepare-stub.js +7 -0
  364. package/dist/view/prepare-stub.js.map +1 -0
  365. package/dist/view/prepare.d.ts +11 -0
  366. package/dist/view/prepare.js +63 -0
  367. package/dist/view/prepare.js.map +1 -0
  368. package/dist/view/registry.d.ts +78 -0
  369. package/dist/view/registry.js +27 -0
  370. package/dist/view/registry.js.map +1 -0
  371. package/dist/view/render/adopt-attr.d.ts +14 -0
  372. package/dist/view/render/adopt-attr.js +83 -0
  373. package/dist/view/render/adopt-attr.js.map +1 -0
  374. package/dist/view/render/adopt-plan.d.ts +10 -0
  375. package/dist/view/render/adopt-plan.js +26 -0
  376. package/dist/view/render/adopt-plan.js.map +1 -0
  377. package/dist/view/render/adopt.d.ts +3 -0
  378. package/dist/view/render/adopt.js +286 -0
  379. package/dist/view/render/adopt.js.map +1 -0
  380. package/dist/view/render/attr-parts.d.ts +72 -0
  381. package/dist/view/render/attr-parts.js +262 -0
  382. package/dist/view/render/attr-parts.js.map +1 -0
  383. package/dist/view/render/child-part.d.ts +51 -0
  384. package/dist/view/render/child-part.js +173 -0
  385. package/dist/view/render/child-part.js.map +1 -0
  386. package/dist/view/render/dev-check.d.ts +12 -0
  387. package/dist/view/render/dev-check.js +122 -0
  388. package/dist/view/render/dev-check.js.map +1 -0
  389. package/dist/view/render/dispose.d.ts +3 -0
  390. package/dist/view/render/dispose.js +76 -0
  391. package/dist/view/render/dispose.js.map +1 -0
  392. package/dist/view/render/hook-part.d.ts +5 -0
  393. package/dist/view/render/hook-part.js +36 -0
  394. package/dist/view/render/hook-part.js.map +1 -0
  395. package/dist/view/render/hook-run.d.ts +2 -0
  396. package/dist/view/render/hook-run.js +72 -0
  397. package/dist/view/render/hook-run.js.map +1 -0
  398. package/dist/view/render/hooks.d.ts +108 -0
  399. package/dist/view/render/hooks.js +108 -0
  400. package/dist/view/render/hooks.js.map +1 -0
  401. package/dist/view/render/hydrate.d.ts +10 -0
  402. package/dist/view/render/hydrate.js +33 -0
  403. package/dist/view/render/hydrate.js.map +1 -0
  404. package/dist/view/render/instance.d.ts +33 -0
  405. package/dist/view/render/instance.js +107 -0
  406. package/dist/view/render/instance.js.map +1 -0
  407. package/dist/view/render/keyed.d.ts +6 -0
  408. package/dist/view/render/keyed.js +15 -0
  409. package/dist/view/render/keyed.js.map +1 -0
  410. package/dist/view/render/list.d.ts +20 -0
  411. package/dist/view/render/list.js +156 -0
  412. package/dist/view/render/list.js.map +1 -0
  413. package/dist/view/render/mismatch.d.ts +10 -0
  414. package/dist/view/render/mismatch.js +55 -0
  415. package/dist/view/render/mismatch.js.map +1 -0
  416. package/dist/view/render/modal.d.ts +3 -0
  417. package/dist/view/render/modal.js +39 -0
  418. package/dist/view/render/modal.js.map +1 -0
  419. package/dist/view/render/nodes.d.ts +10 -0
  420. package/dist/view/render/nodes.js +37 -0
  421. package/dist/view/render/nodes.js.map +1 -0
  422. package/dist/view/render/place.d.ts +18 -0
  423. package/dist/view/render/place.js +69 -0
  424. package/dist/view/render/place.js.map +1 -0
  425. package/dist/view/render/plan.d.ts +26 -0
  426. package/dist/view/render/plan.js +124 -0
  427. package/dist/view/render/plan.js.map +1 -0
  428. package/dist/view/render/raw.d.ts +21 -0
  429. package/dist/view/render/raw.js +72 -0
  430. package/dist/view/render/raw.js.map +1 -0
  431. package/dist/view/render/render.d.ts +15 -0
  432. package/dist/view/render/render.js +65 -0
  433. package/dist/view/render/render.js.map +1 -0
  434. package/dist/view/render/reorder.d.ts +4 -0
  435. package/dist/view/render/reorder.js +101 -0
  436. package/dist/view/render/reorder.js.map +1 -0
  437. package/dist/view/render/rows.d.ts +23 -0
  438. package/dist/view/render/rows.js +95 -0
  439. package/dist/view/render/rows.js.map +1 -0
  440. package/dist/view/render/seen.d.ts +11 -0
  441. package/dist/view/render/seen.js +17 -0
  442. package/dist/view/render/seen.js.map +1 -0
  443. package/dist/view/render/toggles.d.ts +6 -0
  444. package/dist/view/render/toggles.js +6 -0
  445. package/dist/view/render/toggles.js.map +1 -0
  446. package/dist/view/render/values.d.ts +29 -0
  447. package/dist/view/render/values.js +13 -0
  448. package/dist/view/render/values.js.map +1 -0
  449. package/dist/view/render/warn.d.ts +28 -0
  450. package/dist/view/render/warn.js +114 -0
  451. package/dist/view/render/warn.js.map +1 -0
  452. package/dist/view/server/component.d.ts +12 -0
  453. package/dist/view/server/component.js +64 -0
  454. package/dist/view/server/component.js.map +1 -0
  455. package/dist/view/server/escape.d.ts +10 -0
  456. package/dist/view/server/escape.js +34 -0
  457. package/dist/view/server/escape.js.map +1 -0
  458. package/dist/view/server/index.d.ts +48 -0
  459. package/dist/view/server/index.js +80 -0
  460. package/dist/view/server/index.js.map +1 -0
  461. package/dist/view/server/sha256.d.ts +2 -0
  462. package/dist/view/server/sha256.js +75 -0
  463. package/dist/view/server/sha256.js.map +1 -0
  464. package/dist/view/server/tags.d.ts +68 -0
  465. package/dist/view/server/tags.js +132 -0
  466. package/dist/view/server/tags.js.map +1 -0
  467. package/dist/view/server/values.d.ts +18 -0
  468. package/dist/view/server/values.js +94 -0
  469. package/dist/view/server/values.js.map +1 -0
  470. package/dist/view/server/writer.d.ts +21 -0
  471. package/dist/view/server/writer.js +170 -0
  472. package/dist/view/server/writer.js.map +1 -0
  473. package/dist/view/styles.d.ts +25 -0
  474. package/dist/view/styles.js +58 -0
  475. package/dist/view/styles.js.map +1 -0
  476. package/dist/view/template-element.d.ts +10 -0
  477. package/dist/view/template-element.js +45 -0
  478. package/dist/view/template-element.js.map +1 -0
  479. package/dist/view/template.d.ts +29 -0
  480. package/dist/view/template.js +84 -0
  481. package/dist/view/template.js.map +1 -0
  482. package/dist/view/trusted-html.d.ts +6 -0
  483. package/dist/view/trusted-html.js +34 -0
  484. package/dist/view/trusted-html.js.map +1 -0
  485. package/dist/vite.d.ts +57 -11
  486. package/dist/vite.js +319 -27
  487. package/dist/vite.js.map +1 -1
  488. package/package.json +70 -4
  489. package/dist/accessible-name.d.ts +0 -19
  490. package/dist/accessible-name.js +0 -56
  491. package/dist/accessible-name.js.map +0 -1
  492. package/dist/element-directive.d.ts +0 -20
  493. package/dist/element-directive.js +0 -31
  494. package/dist/element-directive.js.map +0 -1
  495. package/dist/invalid.d.ts +0 -21
  496. package/dist/invalid.js +0 -70
  497. package/dist/invalid.js.map +0 -1
  498. package/dist/lit-html-check.d.ts +0 -6
  499. package/dist/lit-html-check.js +0 -48
  500. package/dist/lit-html-check.js.map +0 -1
  501. package/dist/live-boolean.d.ts +0 -22
  502. package/dist/live-boolean.js +0 -34
  503. package/dist/live-boolean.js.map +0 -1
  504. package/dist/random.d.ts +0 -13
  505. package/dist/random.js +0 -19
  506. package/dist/random.js.map +0 -1
  507. package/dist/styles.d.ts +0 -12
  508. package/dist/styles.js +0 -11
  509. package/dist/styles.js.map +0 -1
  510. package/dist/template-whitespace.d.ts +0 -7
  511. package/dist/template-whitespace.js.map +0 -1
  512. package/dist/templates.d.ts +0 -5
  513. package/dist/templates.js +0 -15
  514. package/dist/templates.js.map +0 -1
  515. package/dist/textarea.d.ts +0 -26
  516. package/dist/textarea.js +0 -85
  517. package/dist/textarea.js.map +0 -1
@@ -0,0 +1,286 @@
1
+ // The parallel walk (view/07-hydration.md "The parallel walk"): visits a template's static
2
+ // structure (its parsed content) and the server DOM together, and builds the same parts the
3
+ // client renderer would, with this render's values as committed values. It writes nothing,
4
+ // except splitting merged text at known lengths (`splitText`), creating the empty Text node of
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.
10
+ // Development checks every node, text and bound attribute, and the `<!--gyral:ID-->` markers
11
+ // when present; production checks node types, local names and text lengths.
12
+ import { DEV } from '#view-dev';
13
+ import { LIGHT_ATTRIBUTE } from '../attributes.js';
14
+ import { CHILD_BEFORE } from '../normalize/types.js';
15
+ import { isTemplateResult, sourceOf, templateOf } from '../template.js';
16
+ import { adoptionOf } from './adopt-plan.js';
17
+ import { adoptAttr, checkAttr } from './adopt-attr.js';
18
+ import { attrPart, TEXTAREA, TITLE } from './attr-parts.js';
19
+ import { ChildPart, INSTANCE, ITEMS, LIST, RAW, TEXT } from './child-part.js';
20
+ import { checkKeys } from './dev-check.js';
21
+ import { Instance } from './instance.js';
22
+ import { mismatch } from './mismatch.js';
23
+ import { ROOT, SOLE } from './plan.js';
24
+ import { parse, RawRange } from './raw.js';
25
+ import { report } from './seen.js';
26
+ import { List } from './rows.js';
27
+ import { isList, rawHtml } from './values.js';
28
+ /** The walk's position: the next DOM node; null at the end of `parent`'s children. */
29
+ let cur = null;
30
+ let parent;
31
+ /** For mismatch messages: the host's root, the component, the template being walked. */
32
+ let top;
33
+ let host = '';
34
+ let current;
35
+ const fail = (expected, found = cur, at = parent) => mismatch(expected, found, at, top, host, current?.loc);
36
+ /** Adopts the server DOM in `root` (a host's root) as `part`'s content for `value`. */
37
+ export function adopt(part, value, root, label) {
38
+ top = parent = root;
39
+ cur = root.firstChild;
40
+ host = label;
41
+ current = undefined;
42
+ content(part, value);
43
+ if (cur !== null)
44
+ fail('the end of the view');
45
+ }
46
+ /** A child value at the walk's position (view/02-bindings.md "Child values"). */
47
+ function content(part, v) {
48
+ switch (typeof v) {
49
+ case 'string':
50
+ case 'number': {
51
+ const data = typeof v === 'string' ? v : String(v);
52
+ part.kind = TEXT;
53
+ part.value = v;
54
+ if (data !== '')
55
+ part.content = text(data);
56
+ else
57
+ parent.insertBefore((part.content = document.createTextNode('')), cur);
58
+ return;
59
+ }
60
+ case 'object':
61
+ if (v === null)
62
+ return;
63
+ if (isTemplateResult(v)) {
64
+ part.kind = INSTANCE;
65
+ part.content = instance(v, part);
66
+ }
67
+ else if (isList(v))
68
+ rows(part, v.items, v);
69
+ else if (Array.isArray(v))
70
+ rows(part, v, undefined);
71
+ else {
72
+ const markup = rawHtml(v);
73
+ if (markup !== undefined)
74
+ raw(part, markup);
75
+ else if (DEV)
76
+ part.commit(v);
77
+ }
78
+ return;
79
+ default:
80
+ // Development: a value no hole renders throws (or warns, for `true`) as on the client.
81
+ // Called through the part, so this chunk imports no development-only function.
82
+ if (DEV)
83
+ part.commit(v);
84
+ }
85
+ }
86
+ /** Static text or a text value: exactly `want`'s length, split off a longer Text node. */
87
+ function text(want) {
88
+ // The parser turns CR and CRLF into LF.
89
+ const data = want.includes('\r') ? want.replace(/\r\n?/g, '\n') : want;
90
+ const t = cur;
91
+ if (t !== null && t.nodeType === 3) {
92
+ // Join text the parser split (very long runs).
93
+ for (let n = t.nextSibling; t.length < data.length && n !== null && n.nodeType === 3;) {
94
+ t.appendData(n.data);
95
+ n.remove();
96
+ n = t.nextSibling;
97
+ }
98
+ if (t.length >= data.length && (!DEV || t.data.startsWith(data))) {
99
+ if (t.length > data.length)
100
+ t.splitText(data.length);
101
+ cur = t.nextSibling;
102
+ return t;
103
+ }
104
+ }
105
+ return fail(`text ${JSON.stringify(data.slice(0, 40))}`);
106
+ }
107
+ function instance(result, holder) {
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
+ }
112
+ const a = adoptionOf(template);
113
+ // A development server's marker: checked when present (a production server writes none),
114
+ // against the id when the template has one (production client objects don't, 01).
115
+ const marker = cur;
116
+ if (marker !== null && marker.nodeType === 8 && marker.data.startsWith('gyral:')) {
117
+ const id = template.id;
118
+ if (DEV && id !== undefined && marker.data !== `gyral:${id}`)
119
+ fail(`<!--gyral:${id}-->`);
120
+ cur = marker.nextSibling;
121
+ marker.remove();
122
+ }
123
+ const outer = current;
124
+ current = template;
125
+ const inst = new Instance(template, sourceOf(result), holder, true);
126
+ children(a.plan.content, a, inst, result.values);
127
+ current = outer;
128
+ return inst;
129
+ }
130
+ /** The children of template node `t`, with the child holes between them. */
131
+ function children(t, a, inst, values) {
132
+ const holes = a.holes.get(t);
133
+ const root = t === a.plan.content;
134
+ let h = 0;
135
+ for (let n = t.firstChild, j = 0;; n = n.nextSibling, j++) {
136
+ if (holes !== undefined && h < holes.length) {
137
+ const i = holes[h];
138
+ const spec = a.specs[i];
139
+ const ref = spec[0] === CHILD_BEFORE ? spec[2] : null;
140
+ if (n === null ? ref === null : ref === j) {
141
+ hole(i, ref, a, inst, values);
142
+ h++;
143
+ }
144
+ }
145
+ if (n === null)
146
+ return;
147
+ const dom = node(n, a, inst, values);
148
+ if (root) {
149
+ if (j === 0)
150
+ inst.start = dom;
151
+ inst.end = dom;
152
+ }
153
+ }
154
+ }
155
+ /** A child hole: its content, then its reference node (the DOM node the walk reached). */
156
+ function hole(i, ref, a, inst, values) {
157
+ const kind = a.plan.kinds[i];
158
+ const at = a.plan.at[i];
159
+ const part = kind === ROOT
160
+ ? new ChildPart(null, null, null, 0, false, at)
161
+ : new ChildPart(parent, null, null, 0, kind === SOLE, at);
162
+ inst.parts[i] = part;
163
+ content(part, values[at]);
164
+ if (ref !== null) {
165
+ part.ref = cur;
166
+ if (kind === ROOT && ref === 0)
167
+ inst.head = part;
168
+ }
169
+ else if (kind === ROOT) {
170
+ part.owner = inst;
171
+ inst.tail = part;
172
+ }
173
+ }
174
+ function node(t, a, inst, values) {
175
+ if (t.nodeType === 3)
176
+ return text(t.data);
177
+ if (t.nodeType !== 8)
178
+ return element(t, a, inst, values);
179
+ const c = cur;
180
+ if (c === null || c.nodeType !== 8 || (DEV && c.data !== t.data)) {
181
+ return fail(`<!--${t.data}-->`);
182
+ }
183
+ cur = c.nextSibling;
184
+ return c;
185
+ }
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);
193
+ function element(t, a, inst, values) {
194
+ const el = cur;
195
+ if (el === null || el.localName !== t.localName)
196
+ return fail(`<${t.localName}>`);
197
+ cur = el.nextSibling;
198
+ let whole = false;
199
+ for (const i of a.attrs.get(t) ?? []) {
200
+ const kind = a.plan.kinds[i];
201
+ const part = attrPart(el, kind, a.specs[i], a.plan.at[i]);
202
+ inst.parts[i] = part;
203
+ adoptAttr(part, values);
204
+ if (DEV)
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
+ }
213
+ if (kind === TEXTAREA || kind === TITLE)
214
+ whole = true; // the part owns the content
215
+ }
216
+ let holes = a.holes.has(t);
217
+ if (whole)
218
+ return el;
219
+ if (el.hasAttribute(LIGHT_ATTRIBUTE)) {
220
+ // A light host owns its children (ADR 0014): its parent writes none (06 "Components").
221
+ for (let c = t.firstChild; c !== null; c = c.nextSibling) {
222
+ if (c.nodeType !== 3 || !WHITESPACE_ONLY.test(c.data))
223
+ holes = true;
224
+ }
225
+ if (holes)
226
+ fail(`no children from the parent in light host <${t.localName}>`, el, el);
227
+ return el;
228
+ }
229
+ // A custom element without children in the template: what it holds is its own.
230
+ if (!holes && t.firstChild === null && t.localName.includes('-'))
231
+ return el;
232
+ const outer = cur;
233
+ const outerParent = parent;
234
+ parent = el;
235
+ cur = el.firstChild;
236
+ children(t, a, inst, values);
237
+ if (cur !== null)
238
+ fail(`the end of <${t.localName}>`);
239
+ cur = outer;
240
+ parent = outerParent;
241
+ return el;
242
+ }
243
+ /** Rows of `each` (keyed) or items of an array (`l` undefined), one after another. */
244
+ function rows(part, values, l) {
245
+ const list = new List(part);
246
+ part.kind = l === undefined ? ITEMS : LIST;
247
+ part.content = list;
248
+ if (DEV && l !== undefined)
249
+ checkKeys(values, l.key);
250
+ for (let i = 0; i < values.length; i++) {
251
+ const row = new ChildPart(null, null, list, i, false, -1);
252
+ list.rows.push(row);
253
+ if (l === undefined) {
254
+ content(row, values[i]);
255
+ continue;
256
+ }
257
+ const item = values[i];
258
+ row.key = l.key(item);
259
+ row.item = item;
260
+ row.picked = l.pick === undefined ? undefined : l.pick(item);
261
+ content(row, l.row(item, row.picked));
262
+ }
263
+ }
264
+ /** `raw()`: its start anchor, then the nodes its markup parses to (texts by length). */
265
+ function raw(part, markup) {
266
+ report({ html: markup });
267
+ const start = cur;
268
+ if (start === null || start.nodeType !== 8)
269
+ return fail('the raw() start anchor <!---->');
270
+ cur = start.nextSibling;
271
+ let end = start;
272
+ for (let n = parse(markup).firstChild; n !== null; n = n.nextSibling) {
273
+ if (n.nodeType === 3)
274
+ end = text(n.data);
275
+ else {
276
+ const dom = cur;
277
+ if (dom === null || dom.nodeName !== n.nodeName)
278
+ return fail(`raw() markup's ${n.nodeName}`);
279
+ end = dom;
280
+ cur = dom.nextSibling;
281
+ }
282
+ }
283
+ part.kind = RAW;
284
+ part.content = new RawRange(start, end, markup);
285
+ }
286
+ //# sourceMappingURL=adopt.js.map
@@ -0,0 +1 @@
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,CAA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GAAG,GAAqB,CAAC;IACpC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,QAAQ,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC,gCAAgC,CAAC,CAAC;IAC1F,GAAG,GAAG,KAAK,CAAC,WAAW,CAAC;IACxB,IAAI,GAAG,GAAS,KAAK,CAAC;IACtB,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"]}
@@ -0,0 +1,72 @@
1
+ import type { PartSpec } from '../normalize/types.js';
2
+ import { type HookSpec } from './hooks.js';
3
+ /** What every part of an instance implements: commit its value(s) from this render's values. */
4
+ export interface Part {
5
+ set(values: readonly unknown[]): void;
6
+ }
7
+ /** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */
8
+ export declare const ATTR = 0;
9
+ /** `name="a ${x} b"`. */
10
+ export declare const MULTI = 1;
11
+ /** `?name=${v}`. */
12
+ export declare const BOOL = 2;
13
+ /** `.name=${v}`. */
14
+ export declare const PROP = 3;
15
+ /** `value=${v}` on `<input>`: live `.value`. */
16
+ export declare const VALUE = 4;
17
+ /** `?checked` on `<input>`, `?selected` on `<option>`: attribute first, then the live property. */
18
+ export declare const CHECKED = 5;
19
+ /** `?indeterminate` on `<input>`: the property only. */
20
+ export declare const STATE = 6;
21
+ /** `?open` on `<details>`/`<dialog>`: the attribute, compared with its live presence. */
22
+ export declare const OPEN = 7;
23
+ /** `<title>${v}</title>`: text content. */
24
+ export declare const TITLE = 8;
25
+ /** `<textarea>${v}</textarea>`: text content first, then the live `.value`. */
26
+ export declare const TEXTAREA = 9;
27
+ /** `${hook(…)}` in a start tag. */
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;
31
+ /** Input types whose `value` is a submitted value, not state the user edits. */
32
+ export declare const PLAIN: RegExp;
33
+ export declare const absent: (v: unknown) => boolean;
34
+ export declare const truthy: (v: unknown) => boolean;
35
+ /** The text of a `<textarea>`/`<title>` value: child-hole rules, as one string. */
36
+ export declare function textOf(part: object, v: unknown): string;
37
+ /** The kind of a bound attribute (`?name` when `bool`) on `el`. */
38
+ export declare function attrKind(el: Element, name: string, bool: boolean): number;
39
+ /** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */
40
+ export declare function attrPart(el: Element, kind: number, spec: PartSpec, at: number): AttrPart;
41
+ export declare class AttrPart implements Part {
42
+ readonly el: Element;
43
+ kind: number;
44
+ readonly name: string;
45
+ readonly at: number;
46
+ /** The committed value: raw (ATTR, PROP, VALUE), boolean, string (MULTI, text), or UNSET. */
47
+ value: unknown;
48
+ /** MULTI: the static strings and the committed pieces. */
49
+ readonly strings: readonly string[] | undefined;
50
+ readonly pieces: unknown[] | undefined;
51
+ /** HOOK: the hook, its committed arguments and the ones before. */
52
+ spec: HookSpec<readonly unknown[]> | null;
53
+ args: readonly unknown[] | undefined;
54
+ prev: readonly unknown[] | undefined;
55
+ constructor(el: Element, kind: number, name: string, at: number, strings?: readonly string[]);
56
+ set(values: readonly unknown[]): void;
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
+ */
67
+ private multi;
68
+ /** The joined value of `pieces`, or null when one is `nothing`. */
69
+ join(pieces: readonly unknown[]): string | null;
70
+ /** HOOK: the result commits itself (hook-part.ts); an absent value forgets the hook. */
71
+ hook(v: unknown): void;
72
+ }
@@ -0,0 +1,262 @@
1
+ // Element parts (view/02-bindings.md "Attribute values", "Boolean attributes", "Properties",
2
+ // "Live form state", "Element hooks"): every hole on or inside one element that isn't a child
3
+ // hole, as one class with a kind, so an instance's update loop sees only two part shapes.
4
+ // Every part compares with its committed value and writes only on change. Live form state
5
+ // sets the attribute too on first creation (the default, so `form.reset()` returns to the
6
+ // model's first value); when the model's value changes it compares with the element's live
7
+ // state and writes only on a difference, so the change lands even over a user's edit, and an
8
+ // unchanged model never touches the control. Constructors only record nodes; hydration
9
+ // (view/07-hydration.md) builds the same parts over server DOM and adopts this render's values
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.
12
+ import { DEV } from '#view-dev';
13
+ import { COMMIT_HOOK, isHook } from './hooks.js';
14
+ import { toggle } from './toggles.js';
15
+ import { nothing, UNSET } from './values.js';
16
+ import { badHook, warnFunctionProp, warnToggle, warnTrue, warnValue } from './warn.js';
17
+ /** `name=${v}`; `value=${v}` on a non-text input becomes this after its first commit. */
18
+ export const ATTR = 0;
19
+ /** `name="a ${x} b"`. */
20
+ export const MULTI = 1;
21
+ /** `?name=${v}`. */
22
+ export const BOOL = 2;
23
+ /** `.name=${v}`. */
24
+ export const PROP = 3;
25
+ /** `value=${v}` on `<input>`: live `.value`. */
26
+ export const VALUE = 4;
27
+ /** `?checked` on `<input>`, `?selected` on `<option>`: attribute first, then the live property. */
28
+ export const CHECKED = 5;
29
+ /** `?indeterminate` on `<input>`: the property only. */
30
+ export const STATE = 6;
31
+ /** `?open` on `<details>`/`<dialog>`: the attribute, compared with its live presence. */
32
+ export const OPEN = 7;
33
+ /** `<title>${v}</title>`: text content. */
34
+ export const TITLE = 8;
35
+ /** `<textarea>${v}</textarea>`: text content first, then the live `.value`. */
36
+ export const TEXTAREA = 9;
37
+ /** `${hook(…)}` in a start tag. */
38
+ export const HOOK = 10;
39
+ /** `?modal` on `<dialog>`, `?popover-open` on `[popover]`: opened and closed (toggles.ts). */
40
+ export const TOGGLE = 11;
41
+ /** Input types whose `value` is a submitted value, not state the user edits. */
42
+ export const PLAIN = /^(checkbox|radio|hidden|button|submit|reset|image|file)$/;
43
+ /** `String(v)`: numbers and booleans as text (objects warn in development first). */
44
+ const text = String;
45
+ export const absent = (v) => v === null || v === undefined || v === nothing;
46
+ export const truthy = (v) => v !== nothing && !!v;
47
+ const isObject = (v) => (typeof v === 'object' && v !== null) || typeof v === 'function';
48
+ /** The text of a `<textarea>`/`<title>` value: child-hole rules, as one string. */
49
+ export function textOf(part, v) {
50
+ if (typeof v === 'string')
51
+ return v;
52
+ if (typeof v === 'number')
53
+ return String(v);
54
+ if (DEV) {
55
+ if (v === true)
56
+ warnTrue(part);
57
+ else if (isObject(v))
58
+ warnValue(part, v, 'the text content');
59
+ }
60
+ return absent(v) || typeof v === 'boolean' ? '' : text(v);
61
+ }
62
+ /** The kind of a bound attribute (`?name` when `bool`) on `el`. */
63
+ export function attrKind(el, name, bool) {
64
+ const tag = el.localName;
65
+ if (!bool)
66
+ return name === 'value' && tag === 'input' ? VALUE : ATTR;
67
+ if (tag === 'input')
68
+ return name === 'checked' ? CHECKED : name === 'indeterminate' ? STATE : BOOL;
69
+ if (tag === 'option' && name === 'selected')
70
+ return CHECKED;
71
+ if (name === 'modal' || name === 'popover-open')
72
+ return TOGGLE;
73
+ return name === 'open' && (tag === 'details' || tag === 'dialog') ? OPEN : BOOL;
74
+ }
75
+ /** The element part for part table entry `spec`: `[kind, path, name?, strings?]` (01). */
76
+ export function attrPart(el, kind, spec, at) {
77
+ const s = spec;
78
+ return new AttrPart(el, kind, s[2] ?? '', at, s[3]);
79
+ }
80
+ export class AttrPart {
81
+ constructor(el, kind, name, at, strings) {
82
+ this.el = el;
83
+ this.kind = kind;
84
+ this.name = name;
85
+ this.at = at;
86
+ this.value = UNSET;
87
+ this.strings = strings;
88
+ this.pieces =
89
+ strings === undefined ? undefined : new Array(strings.length - 1).fill(UNSET);
90
+ this.spec = null;
91
+ this.args = undefined;
92
+ this.prev = undefined;
93
+ }
94
+ set(values) {
95
+ const v = values[this.at];
96
+ const el = this.el;
97
+ const live = el;
98
+ switch (this.kind) {
99
+ case ATTR:
100
+ if (v === this.value)
101
+ return;
102
+ this.value = v;
103
+ if (absent(v))
104
+ el.removeAttribute(this.name);
105
+ else {
106
+ if (DEV && isObject(v))
107
+ warnValue(this, v, `the attribute ${this.name}`);
108
+ this.write(typeof v === 'string' ? v : text(v));
109
+ }
110
+ return;
111
+ case MULTI:
112
+ this.multi(values);
113
+ return;
114
+ case BOOL: {
115
+ const on = truthy(v);
116
+ if (on === this.value)
117
+ return;
118
+ this.value = on;
119
+ el.toggleAttribute(this.name, on);
120
+ return;
121
+ }
122
+ case PROP:
123
+ if (Object.is(v, this.value))
124
+ return;
125
+ if (DEV && typeof v === 'function')
126
+ warnFunctionProp(this, el, this.name);
127
+ this.value = v;
128
+ live[this.name] = v;
129
+ return;
130
+ case VALUE: {
131
+ if (v === this.value)
132
+ return;
133
+ const s = absent(v) ? '' : text(v);
134
+ if (this.value === UNSET) {
135
+ // First creation: the attribute (the default), then the live value.
136
+ if (absent(v))
137
+ el.removeAttribute('value');
138
+ else
139
+ el.setAttribute('value', s);
140
+ if (PLAIN.test(el.type))
141
+ this.kind = ATTR;
142
+ }
143
+ this.value = v;
144
+ if (this.kind === VALUE && live.value !== s)
145
+ live.value = s;
146
+ return;
147
+ }
148
+ case CHECKED:
149
+ case STATE: {
150
+ const on = truthy(v);
151
+ if (on === this.value)
152
+ return;
153
+ if (this.kind === CHECKED && this.value === UNSET)
154
+ el.toggleAttribute(this.name, on);
155
+ this.value = on;
156
+ if (live[this.name] !== on)
157
+ live[this.name] = on;
158
+ return;
159
+ }
160
+ case OPEN: {
161
+ const on = truthy(v);
162
+ if (on === this.value)
163
+ return;
164
+ this.value = on;
165
+ if (el.hasAttribute('open') !== on)
166
+ el.toggleAttribute('open', on);
167
+ return;
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
+ }
180
+ case TITLE:
181
+ case TEXTAREA: {
182
+ const s = textOf(this, v);
183
+ if (s === this.value)
184
+ return;
185
+ if (this.kind === TEXTAREA && this.value !== UNSET) {
186
+ if (live.value !== s)
187
+ live.value = s;
188
+ }
189
+ else
190
+ el.textContent = s;
191
+ this.value = s;
192
+ return;
193
+ }
194
+ default:
195
+ this.hook(v);
196
+ }
197
+ }
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
+ */
213
+ multi(values) {
214
+ const pieces = this.pieces;
215
+ let changed = false;
216
+ for (let i = 0; i < pieces.length; i++) {
217
+ const v = values[this.at + i];
218
+ if (v !== pieces[i]) {
219
+ pieces[i] = v;
220
+ changed = true;
221
+ }
222
+ }
223
+ if (!changed && this.value !== UNSET)
224
+ return;
225
+ const joined = this.join(pieces);
226
+ if (joined === this.value)
227
+ return;
228
+ this.value = joined;
229
+ if (joined === null)
230
+ this.el.removeAttribute(this.name);
231
+ else
232
+ this.write(joined);
233
+ }
234
+ /** The joined value of `pieces`, or null when one is `nothing`. */
235
+ join(pieces) {
236
+ const strings = this.strings;
237
+ let joined = strings[0];
238
+ for (let i = 0; i < pieces.length; i++) {
239
+ const v = pieces[i];
240
+ if (v === nothing)
241
+ return null;
242
+ if (DEV && isObject(v))
243
+ warnValue(this, v, `the attribute ${this.name}`);
244
+ joined += (v === null || v === undefined ? '' : text(v)) + strings[i + 1];
245
+ }
246
+ return joined;
247
+ }
248
+ /** HOOK: the result commits itself (hook-part.ts); an absent value forgets the hook. */
249
+ hook(v) {
250
+ if (absent(v)) {
251
+ this.spec = null;
252
+ this.args = undefined;
253
+ return;
254
+ }
255
+ const commit = isHook(v) ? v[COMMIT_HOOK] : undefined;
256
+ if (commit !== undefined)
257
+ commit(this, v);
258
+ else if (DEV)
259
+ badHook(v);
260
+ }
261
+ }
262
+ //# sourceMappingURL=attr-parts.js.map