@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 @@
1
+ {"version":3,"file":"repairs.js","sourceRoot":"","sources":["../../../src/view/normalize/repairs.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,gGAAgG;AAChG,yFAAyF;AACzF,2EAA2E;AAC3E,OAAO,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAYjC,MAAM,GAAG,GAAG,CAAC,KAAa,EAAuB,EAAE,CAAC,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAE9E,MAAM,WAAW,GAAG,GAAG,CAAC,iDA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sC,EACtC,kFAAkF,CACnF,CAAC;AACJ,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,kBAAkB,CAAC,IAAY,EAAE,WAAoB;IACnE,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,WAAW,CAAC,CAAC;AAChE,CAAC","sourcesContent":["// Rule 7 by structure (view/09-template-rules.md \"How rule 7 is checked\"): start tags and text\n// that the WHATWG HTML tree builder would move, drop or implicitly close something for, checked\n// against the open-element stack. Only real repairs are flagged; the browser's own parse\n// (prepare.ts) and the compiler's parse5 check catch anything this misses.\nimport { msg } from './rules.js';\n\nexport type Ns = 'html' | 'svg' | 'math';\n\nexport interface OpenElement {\n readonly name: string;\n readonly ns: Ns;\n}\n\n/** How the tree builder treats content of a container (its insertion mode, roughly). */\nexport type Context = 'body' | 'table' | 'tbody' | 'tr' | 'colgroup';\n\nconst set = (names: string): ReadonlySet<string> => new Set(names.split(' '));\n\nconst TABLE_PARTS = set('caption col colgroup tbody td tfoot th thead tr');\nconst ALLOWED: Record<Exclude<Context, 'body'>, ReadonlySet<string>> = {\n table: set('caption colgroup thead tbody tfoot script style template'),\n tbody: set('tr script style template'),\n tr: set('td th script style template'),\n colgroup: set('col template'),\n};\nconst CLOSES_P = set(\n 'address article aside blockquote center details dialog dir div dl fieldset figcaption ' +\n 'figure footer header hgroup main menu nav ol p search section summary ul h1 h2 h3 h4 h5 h6 ' +\n 'pre listing form plaintext table hr xmp li dd dt',\n);\nconst HEADINGS = set('h1 h2 h3 h4 h5 h6');\nconst SCOPE: Record<Ns, ReadonlySet<string>> = {\n html: set('applet caption html table td th marquee object template'),\n math: set('mi mo mn ms mtext annotation-xml'),\n svg: set('foreignobject desc title'),\n};\nconst SPECIAL = set(\n 'address applet area article aside base basefont bgsound blockquote body br button caption ' +\n 'center col colgroup dd details dir div dl dt embed fieldset figcaption figure footer form ' +\n 'frame frameset h1 h2 h3 h4 h5 h6 head header hgroup hr html iframe img input keygen li link ' +\n 'listing main marquee menu meta nav noembed noframes noscript object ol p param plaintext ' +\n 'pre script search section select source style summary table tbody td template textarea ' +\n 'tfoot th thead title tr track ul wbr xmp',\n);\nconst LI = set('li');\nconst DD_DT = set('dd dt');\nconst FORM = set('form');\nconst TEMPLATE = set('template');\nconst OPTION = set('option');\nconst FORMATTING_MARKERS = set('applet marquee object template td th caption');\nconst BREAKOUT = set(\n 'b big blockquote body br center code dd div dl dt em embed h1 h2 h3 h4 h5 h6 head hr i img ' +\n 'li listing menu meta nobr ol p pre ruby s small span strong strike sub sup table tt u ul var',\n);\n\n/** The context an element's children are parsed in. */\nexport function contextOf(name: string): Context {\n if (name === 'table') return 'table';\n if (name === 'tbody' || name === 'thead' || name === 'tfoot') return 'tbody';\n if (name === 'tr' || name === 'colgroup') return name;\n return 'body';\n}\n\n/**\n * The context of a template root or <template> content: decided by its first start tag\n * (the \"in template\" insertion mode).\n */\nexport function rootContext(firstTag: string): Context {\n if (firstTag === 'tr') return 'tbody';\n if (firstTag === 'td' || firstTag === 'th') return 'tr';\n if (firstTag === 'col') return 'colgroup';\n return TABLE_PARTS.has(firstTag) ? 'table' : 'body';\n}\n\nconst isHtml = (el: OpenElement | undefined, names: ReadonlySet<string>): boolean =>\n el !== undefined && el.ns === 'html' && names.has(el.name);\n\nfunction inScope(stack: readonly OpenElement[], name: string, extra?: string): boolean {\n for (let k = stack.length - 1; k >= 0; k--) {\n const el = stack[k];\n if (el === undefined) break;\n if (el.ns === 'html' && el.name === name) return true;\n if (SCOPE[el.ns].has(el.name) || (el.ns === 'html' && el.name === extra)) return false;\n }\n return false;\n}\n\n/** An open <li> (or <dd>/<dt>) that a new one would close: the \"in body\" list-item walk. */\nfunction listItemOpen(stack: readonly OpenElement[], names: ReadonlySet<string>): boolean {\n for (let k = stack.length - 1; k >= 0; k--) {\n const el = stack[k];\n if (el === undefined) break;\n if (isHtml(el, names)) return true;\n const special = el.ns === 'html' ? SPECIAL.has(el.name) : SCOPE[el.ns].has(el.name);\n if (special && !(el.ns === 'html' && /^(address|div|p)$/.test(el.name))) return false;\n }\n return false;\n}\n\nfunction formattingOpen(stack: readonly OpenElement[], name: string): boolean {\n for (let k = stack.length - 1; k >= 0; k--) {\n const el = stack[k];\n if (el === undefined || isHtml(el, FORMATTING_MARKERS)) return false;\n if (el.ns === 'html' && el.name === name) return true;\n }\n return false;\n}\n\nfunction inTableMessage(name: string, ctx: Exclude<Context, 'body'>): string {\n const where = ctx === 'tbody' ? '<tbody>' : `<${ctx}>`;\n if (name === 'tr' || ((name === 'td' || name === 'th') && ctx === 'table')) {\n return msg.repaired(\n `<${name}> directly inside ${where}`,\n 'Wrap rows in <tbody>: <table><tbody><tr><td>…</td></tr></tbody></table>.',\n );\n }\n if (name === 'td' || name === 'th') {\n return msg.repaired(`<${name}> directly inside ${where}`, 'Wrap cells in <tr>.');\n }\n if (name === 'col')\n return msg.repaired(`<col> directly inside ${where}`, 'Wrap it in <colgroup>.');\n if (ctx === 'colgroup')\n return msg.repaired(`<${name}> inside <colgroup>`, 'Only <col> goes there.');\n return msg.repaired(\n `<${name}> directly inside ${where}`,\n 'The parser moves it out of the table. Put it inside a <td>, <th> or <caption>.',\n );\n}\n\n/**\n * Rule 7 for a start tag in the HTML namespace. `atRoot`: the container is the template root\n * or a <template>'s content, where content the parser would foster-parent stays in place.\n * Returns the error message, or undefined when the parser keeps the tag where it is written.\n */\nexport function startRepair(\n name: string,\n ctx: Context,\n atRoot: boolean,\n stack: readonly OpenElement[],\n hiddenInput: boolean,\n): string | undefined {\n if (ctx !== 'body') {\n if (ALLOWED[ctx].has(name) || (ctx === 'table' && name === 'input' && hiddenInput)) return;\n if (atRoot && ctx !== 'colgroup' && !TABLE_PARTS.has(name)) return;\n return inTableMessage(name, ctx);\n }\n const top = stack.at(-1);\n if (TABLE_PARTS.has(name)) {\n return msg.repaired(\n `<${name}> outside its table structure is dropped by the parser`,\n `Put it where it belongs: <table><tbody><tr><td>…</td></tr></tbody></table>.`,\n );\n }\n if (CLOSES_P.has(name) && inScope(stack, 'p', 'button')) {\n return msg.repaired(\n `<${name}> inside <p>: a paragraph holds only phrasing content, so the parser closes it`,\n `Close </p> before <${name}>, or use a <div> instead of the <p>.`,\n );\n }\n if (name === 'li' && listItemOpen(stack, LI)) {\n return msg.repaired(\n '<li> inside another <li> closes the first one',\n 'Close </li> first, or nest a list: <li>…<ul><li>…</li></ul></li>.',\n );\n }\n if ((name === 'dd' || name === 'dt') && listItemOpen(stack, DD_DT)) {\n return msg.repaired(`<${name}> inside <dd> or <dt> closes it`, 'Close it first.');\n }\n if (name === 'a' && formattingOpen(stack, 'a')) {\n return msg.repaired(\n \"<a> inside <a>: links can't nest\",\n 'Close the first </a> before the next <a>.',\n );\n }\n if (\n name === 'form' &&\n stack.some((el) => isHtml(el, FORM)) &&\n !stack.some((el) => isHtml(el, TEMPLATE))\n ) {\n return msg.repaired(\n '<form> inside <form> is dropped by the parser',\n 'Forms can\\'t nest: close the first form, and point controls at a form with form=\"id\".',\n );\n }\n if (HEADINGS.has(name) && isHtml(top, HEADINGS)) {\n return msg.repaired(`<${name}> inside a heading closes it`, 'Close the first heading first.');\n }\n if (name === 'button' && inScope(stack, 'button')) {\n return msg.repaired('<button> inside <button> closes the first one', \"Buttons can't nest.\");\n }\n if ((name === 'option' || name === 'optgroup') && isHtml(top, OPTION)) {\n return msg.repaired(`<${name}> inside <option> closes it`, 'Close </option> first.');\n }\n return undefined;\n}\n\n/** Rule 7 for static text: non-whitespace text in table structure is moved out of it. */\nexport function textRepair(raw: string, ctx: Context, atRoot: boolean): string | undefined {\n if (ctx === 'body' || !/[^\\t\\n\\f\\r ]/.test(raw) || (atRoot && ctx !== 'colgroup')) return;\n return msg.repaired(\n 'Text directly inside table structure',\n 'The parser moves it out of the table. Put text inside a <td>, <th> or <caption>.',\n );\n}\n\n/** Rule 7 in SVG/MathML: HTML tags that end the foreign element. */\nexport function breaksOutOfForeign(name: string, hasFontAttr: boolean): boolean {\n return BREAKOUT.has(name) || (name === 'font' && hasFontAttr);\n}\n"]}
@@ -0,0 +1,39 @@
1
+ /** Messages, by rule. Each names the fix. */
2
+ export declare const msg: {
3
+ eventBinding: (name: string) => string;
4
+ dynamicTag: () => string;
5
+ dynamicName: () => string;
6
+ inRawText: (tag: string) => string;
7
+ inComment: () => string;
8
+ inDoctype: () => string;
9
+ inTemplate: () => string;
10
+ formState: (tag: string, name: string, write: string) => string;
11
+ toggle: (tag: string, name: string) => string;
12
+ unquoted: (name: string) => string;
13
+ notSingle: (name: string) => string;
14
+ selfClosing: (tag: string) => string;
15
+ repaired: (what: string, write: string) => string;
16
+ badEndTag: () => string;
17
+ unterminated: (what: "comment" | "tag") => string;
18
+ svgOnly: (tag: string) => string;
19
+ htmlInSvg: (tag: string, top: boolean) => string;
20
+ namespacedAttr: (name: string) => string;
21
+ serverOnly: () => string;
22
+ textContent: (tag: string) => string;
23
+ booleanAttr: (tag: string, name: string) => string;
24
+ charRef: (ref: string) => string;
25
+ };
26
+ /**
27
+ * Rule 4: property bindings that would be form state (view/02-bindings.md "Live form state").
28
+ * Returns the spelling to use instead, or undefined when the binding is fine.
29
+ */
30
+ export declare function formStateFix(tag: string, name: string): string | undefined;
31
+ /**
32
+ * Rule 14: HTML boolean attributes (present means true). `hidden` is left out because
33
+ * hidden="until-found" is a real string value.
34
+ */
35
+ export declare const BOOLEAN_ATTRS: Set<string>;
36
+ /** Rule 10: SVG element names that HTML doesn't share (lower case). */
37
+ export declare const SVG_ONLY: Set<string>;
38
+ /** HTML void elements: no end tag, no content. */
39
+ export declare const VOID: Set<string>;
@@ -0,0 +1,120 @@
1
+ // The template rules of view/09-template-rules.md that one template's strings reveal: every
2
+ // message says what is wrong and what to write instead (core belief 7). The tokenizer
3
+ // (rules 1, 2, 3, 5), the tree builder (3, 4, 6, 7, 10, 12, 13) and repairs.ts (7) throw them
4
+ // through Source.fail; the browser's own parse (prepare.ts) backs rule 7 up, and
5
+ // template-element.ts throws rule 11 when a server template reaches the browser.
6
+ import { SERVER_ONLY } from './errors.js';
7
+ const H = '${…}';
8
+ /** Messages, by rule. Each names the fix. */
9
+ export const msg = {
10
+ // 1
11
+ eventBinding: (name) => `${name}=${H} is an event binding, and Gyral has none: views never attach listeners. ` +
12
+ `Name the intent instead, data-intent=\${i.Name}, and parse the event in the component's ` +
13
+ `intent (ADR 0001).`,
14
+ // 2
15
+ dynamicTag: () => `A hole can't be (part of) a tag name: <${H}> and </${H}> are not supported. Choose ` +
16
+ `between whole templates instead: \${cond ? html\`<a>…</a>\` : html\`<b>…</b>\`}. ` +
17
+ `For a literal "<" next to a value, write &lt;.`,
18
+ dynamicName: () => `A hole can't be (part of) an attribute name. Write the name statically (name=${H}), ` +
19
+ `use ?name=${H} to add or remove it, or choose between whole templates.`,
20
+ // 3
21
+ inRawText: (tag) => `A hole can't sit inside <${tag}>: no part can live there, and values in it are an ` +
22
+ `injection risk. Pass data through an attribute, styles through a CSS custom property ` +
23
+ `(style=\${\`--x: \${v}\`}), or trusted markup through raw().`,
24
+ inComment: () => `A hole can't sit inside an HTML comment: no part can live there. Move the value out of ` +
25
+ `the comment, or drop the comment.`,
26
+ inDoctype: () => `A hole can't sit inside <!doctype>. Write the doctype statically: <!doctype html>.`,
27
+ inTemplate: () => `A hole can't sit inside a <template> element: its content is inert and no part can live ` +
28
+ `there. Render the content with a nested html\`…\` template in a child hole instead.`,
29
+ // 4
30
+ formState: (tag, name, write) => `.${name}=${H} on <${tag}> binds form state as a property, which never reaches the ` +
31
+ `server and has a second spelling. Write ${write} instead: Gyral keeps it live ` +
32
+ `(view/02-bindings.md, "Live form state").`,
33
+ toggle: (tag, name) => name === 'modal'
34
+ ? `modal on <${tag}>: only a <dialog> opens as a modal, and only from ?modal=${H}, which ` +
35
+ `calls showModal() and close() as the value changes (view/02-bindings.md, "Dialogs and ` +
36
+ `popovers"). Write <dialog ?modal=${H}>.`
37
+ : `popover-open on <${tag}>: write ?popover-open=${H} on an element with a popover ` +
38
+ `attribute; it calls showPopover() and hidePopover() as the value changes ` +
39
+ `(view/02-bindings.md, "Dialogs and popovers").`,
40
+ // 5
41
+ unquoted: (name) => `${name}=… mixes static text and holes without quotes, which is ambiguous. Quote the ` +
42
+ `whole value: ${name}="a ${H}".`,
43
+ notSingle: (name) => `${name} takes exactly one value and no static text. Write ${name}=${H}, and build the ` +
44
+ `value in the expression.`,
45
+ // 6
46
+ selfClosing: (tag) => `<${tag} /> is not self-closing in HTML: the parser ignores the "/", so <${tag}> would ` +
47
+ `swallow the siblings that follow it. Write <${tag}></${tag}>.`,
48
+ // 7
49
+ repaired: (what, write) => `${what}. The HTML parser repairs this markup, so the DOM would differ from the template ` +
50
+ `and part paths would shift. ${write}`,
51
+ badEndTag: () => `"</" must start an end tag such as </p>. For a literal "</" in text, write &lt;/.`,
52
+ unterminated: (what) => what === 'comment'
53
+ ? `The template ends inside a comment or <!…> declaration. Close it with -->.`
54
+ : `The template ends inside a tag, so the parser would drop it. Close the tag with ">".`,
55
+ // 10
56
+ svgOnly: (tag) => `<${tag}> is an SVG element outside an <svg>: in an html template the parser creates SVG ` +
57
+ `elements only inside <svg>. For an SVG fragment of its own, write it with the svg tag ` +
58
+ `(import { svg } from '@gyral/core'): svg\`<${tag} …></${tag}>\`, rendered inside an <svg>. ` +
59
+ `Or wrap it: <svg viewBox="…"><${tag} …></${tag}></svg>.`,
60
+ htmlInSvg: (tag, top) => (top
61
+ ? `<${tag}> is HTML, but this is an svg template: its top level is SVG content (it renders ` +
62
+ `inside an <svg>), where the parser `
63
+ : `<${tag}> is an HTML element inside SVG content, where the parser `) +
64
+ `would not create an HTML <${tag}>. Write HTML with html\`…\`, or put it inside ` +
65
+ `<foreignObject>.`,
66
+ namespacedAttr: (name) => `${name}=${H} binds a namespaced attribute: the parser puts ${name} in its own namespace, ` +
67
+ `and a bound value can't be. Bind the plain attribute instead (SVG 2): href=${H} for ` +
68
+ `xlink:href, lang=${H} for xml:lang; write xmlns statically, if at all.`,
69
+ // 11
70
+ serverOnly: () => SERVER_ONLY,
71
+ // 12
72
+ textContent: (tag) => `A hole in <${tag}> must be its whole content. Write <${tag}>${H}</${tag}> and build the ` +
73
+ `text in the value: <${tag}>\${\`\${page} | Site\`}</${tag}>.`,
74
+ // 14
75
+ booleanAttr: (tag, name) => `${name}=${H} on <${tag}> sets a boolean attribute to a string: any value, even "false", ` +
76
+ `turns it on. Write ?${name}=${H} to add the attribute when the value is truthy and ` +
77
+ `remove it otherwise.`,
78
+ // 13
79
+ charRef: (ref) => `&${ref}; in the static text of a bound or custom-element attribute is a named character ` +
80
+ `reference the normalizer doesn't decode (it knows &amp; &lt; &gt; &quot; &apos; &nbsp;). ` +
81
+ `Write the character itself, or a numeric reference such as &#169;.`,
82
+ };
83
+ /**
84
+ * Rule 4: property bindings that would be form state (view/02-bindings.md "Live form state").
85
+ * Returns the spelling to use instead, or undefined when the binding is fine.
86
+ */
87
+ const FORM_STATE = {
88
+ input: { value: `value=${H}`, checked: `?checked=${H}`, indeterminate: `?indeterminate=${H}` },
89
+ textarea: { value: `<textarea>${H}</textarea>` },
90
+ select: { value: `?selected=${H} on the chosen <option>` },
91
+ option: { selected: `?selected=${H}`, value: `value=${H}` },
92
+ details: { open: `?open=${H}` },
93
+ dialog: { open: `?open=${H}`, modal: `?modal=${H}` },
94
+ };
95
+ /**
96
+ * Rule 4: property bindings that would be form state (view/02-bindings.md "Live form state").
97
+ * Returns the spelling to use instead, or undefined when the binding is fine.
98
+ */
99
+ export function formStateFix(tag, name) {
100
+ return FORM_STATE[tag]?.[name];
101
+ }
102
+ /**
103
+ * Rule 14: HTML boolean attributes (present means true). `hidden` is left out because
104
+ * hidden="until-found" is a real string value.
105
+ */
106
+ export const BOOLEAN_ATTRS = new Set(('allowfullscreen async autofocus autoplay checked controls default defer disabled ' +
107
+ 'disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop ' +
108
+ 'multiple muted nomodule novalidate open playsinline readonly required reversed selected ' +
109
+ 'shadowrootclonable shadowrootdelegatesfocus shadowrootserializable').split(' '));
110
+ /** Rule 10: SVG element names that HTML doesn't share (lower case). */
111
+ export const SVG_ONLY = new Set(('animate animatemotion animatetransform circle clippath defs desc ellipse feblend ' +
112
+ 'fecolormatrix fecomponenttransfer fecomposite feconvolvematrix fediffuselighting ' +
113
+ 'fedisplacementmap fedropshadow feflood fegaussianblur feimage femerge femergenode ' +
114
+ 'femorphology feoffset fespecularlighting fetile feturbulence filter foreignobject g line ' +
115
+ 'lineargradient marker mask metadata mpath path pattern polygon polyline radialgradient ' +
116
+ 'rect stop symbol text textpath tspan use').split(' '));
117
+ /** HTML void elements: no end tag, no content. */
118
+ export const VOID = new Set(('area base basefont bgsound br col embed frame hr img input keygen link meta param source ' +
119
+ 'track wbr').split(' '));
120
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../src/view/normalize/rules.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,sFAAsF;AACtF,8FAA8F;AAC9F,iFAAiF;AACjF,iFAAiF;AAEjF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,CAAC,GAAG,MAAM,CAAC;AAEjB,6CAA6C;AAC7C,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,IAAI;IACJ,YAAY,EAAE,CAAC,IAAY,EAAU,EAAE,CACrC,GAAG,IAAI,IAAI,CAAC,0EAA0E;QACtF,0FAA0F;QAC1F,oBAAoB;IACtB,IAAI;IACJ,UAAU,EAAE,GAAW,EAAE,CACvB,0CAA0C,CAAC,WAAW,CAAC,8BAA8B;QACrF,mFAAmF;QACnF,gDAAgD;IAClD,WAAW,EAAE,GAAW,EAAE,CACxB,gFAAgF,CAAC,KAAK;QACtF,aAAa,CAAC,0DAA0D;IAC1E,IAAI;IACJ,SAAS,EAAE,CAAC,GAAW,EAAU,EAAE,CACjC,4BAA4B,GAAG,qDAAqD;QACpF,uFAAuF;QACvF,8DAA8D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C,EAAE,EAAE;IAC9F,QAAQ,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,aAAa,EAAE;IAChD,MAAM,EAAE,EAAE,KAAK,EAAE,aAAa,CAAC,yBAAyB,EAAE;IAC1D,MAAM,EAAE,EAAE,QAAQ,EAAE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,EAAE,EAAE;IAC3D,OAAO,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE;IAC/B,MAAM,EAAE,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,KAAK,EAAE,UAAU,CAAC,EAAE,EAAE;CACrD,CAAC;AAEF;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,IAAY;IACpD,OAAO,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,GAAG,CAClC,CACE,mFAAmF;IACnF,0FAA0F;IAC1F,0FAA0F;IAC1F,oEAAoE,CACrE,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC;AAEF,uEAAuE;AACvE,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,GAAG,CAC7B,CACE,mFAAmF;IACnF,mFAAmF;IACnF,oFAAoF;IACpF,2FAA2F;IAC3F,yFAAyF;IACzF,0CAA0C,CAC3C,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC;AAEF,kDAAkD;AAClD,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,GAAG,CACzB,CACE,2FAA2F;IAC3F,WAAW,CACZ,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC","sourcesContent":["// The template rules of view/09-template-rules.md that one template's strings reveal: every\n// message says what is wrong and what to write instead (core belief 7). The tokenizer\n// (rules 1, 2, 3, 5), the tree builder (3, 4, 6, 7, 10, 12, 13) and repairs.ts (7) throw them\n// through Source.fail; the browser's own parse (prepare.ts) backs rule 7 up, and\n// template-element.ts throws rule 11 when a server template reaches the browser.\n\nimport { SERVER_ONLY } from './errors.js';\n\nconst H = '${…}';\n\n/** Messages, by rule. Each names the fix. */\nexport const msg = {\n // 1\n eventBinding: (name: string): string =>\n `${name}=${H} is an event binding, and Gyral has none: views never attach listeners. ` +\n `Name the intent instead, data-intent=\\${i.Name}, and parse the event in the component's ` +\n `intent (ADR 0001).`,\n // 2\n dynamicTag: (): string =>\n `A hole can't be (part of) a tag name: <${H}> and </${H}> are not supported. Choose ` +\n `between whole templates instead: \\${cond ? html\\`<a>…</a>\\` : html\\`<b>…</b>\\`}. ` +\n `For a literal \"<\" next to a value, write &lt;.`,\n dynamicName: (): string =>\n `A hole can't be (part of) an attribute name. Write the name statically (name=${H}), ` +\n `use ?name=${H} to add or remove it, or choose between whole templates.`,\n // 3\n inRawText: (tag: string): string =>\n `A hole can't sit inside <${tag}>: no part can live there, and values in it are an ` +\n `injection risk. Pass data through an attribute, styles through a CSS custom property ` +\n `(style=\\${\\`--x: \\${v}\\`}), or trusted markup through raw().`,\n inComment: (): string =>\n `A hole can't sit inside an HTML comment: no part can live there. Move the value out of ` +\n `the comment, or drop the comment.`,\n inDoctype: (): string =>\n `A hole can't sit inside <!doctype>. Write the doctype statically: <!doctype html>.`,\n inTemplate: (): string =>\n `A hole can't sit inside a <template> element: its content is inert and no part can live ` +\n `there. Render the content with a nested html\\`…\\` template in a child hole instead.`,\n // 4\n formState: (tag: string, name: string, write: string): string =>\n `.${name}=${H} on <${tag}> binds form state as a property, which never reaches the ` +\n `server and has a second spelling. Write ${write} instead: Gyral keeps it live ` +\n `(view/02-bindings.md, \"Live form state\").`,\n toggle: (tag: string, name: string): string =>\n name === 'modal'\n ? `modal on <${tag}>: only a <dialog> opens as a modal, and only from ?modal=${H}, which ` +\n `calls showModal() and close() as the value changes (view/02-bindings.md, \"Dialogs and ` +\n `popovers\"). Write <dialog ?modal=${H}>.`\n : `popover-open on <${tag}>: write ?popover-open=${H} on an element with a popover ` +\n `attribute; it calls showPopover() and hidePopover() as the value changes ` +\n `(view/02-bindings.md, \"Dialogs and popovers\").`,\n // 5\n unquoted: (name: string): string =>\n `${name}=… mixes static text and holes without quotes, which is ambiguous. Quote the ` +\n `whole value: ${name}=\"a ${H}\".`,\n notSingle: (name: string): string =>\n `${name} takes exactly one value and no static text. Write ${name}=${H}, and build the ` +\n `value in the expression.`,\n // 6\n selfClosing: (tag: string): string =>\n `<${tag} /> is not self-closing in HTML: the parser ignores the \"/\", so <${tag}> would ` +\n `swallow the siblings that follow it. Write <${tag}></${tag}>.`,\n // 7\n repaired: (what: string, write: string): string =>\n `${what}. The HTML parser repairs this markup, so the DOM would differ from the template ` +\n `and part paths would shift. ${write}`,\n badEndTag: (): string =>\n `\"</\" must start an end tag such as </p>. For a literal \"</\" in text, write &lt;/.`,\n unterminated: (what: 'comment' | 'tag'): string =>\n what === 'comment'\n ? `The template ends inside a comment or <!…> declaration. Close it with -->.`\n : `The template ends inside a tag, so the parser would drop it. Close the tag with \">\".`,\n // 10\n svgOnly: (tag: string): string =>\n `<${tag}> is an SVG element outside an <svg>: in an html template the parser creates SVG ` +\n `elements only inside <svg>. For an SVG fragment of its own, write it with the svg tag ` +\n `(import { svg } from '@gyral/core'): svg\\`<${tag} …></${tag}>\\`, rendered inside an <svg>. ` +\n `Or wrap it: <svg viewBox=\"…\"><${tag} …></${tag}></svg>.`,\n htmlInSvg: (tag: string, top: boolean): string =>\n (top\n ? `<${tag}> is HTML, but this is an svg template: its top level is SVG content (it renders ` +\n `inside an <svg>), where the parser `\n : `<${tag}> is an HTML element inside SVG content, where the parser `) +\n `would not create an HTML <${tag}>. Write HTML with html\\`…\\`, or put it inside ` +\n `<foreignObject>.`,\n namespacedAttr: (name: string): string =>\n `${name}=${H} binds a namespaced attribute: the parser puts ${name} in its own namespace, ` +\n `and a bound value can't be. Bind the plain attribute instead (SVG 2): href=${H} for ` +\n `xlink:href, lang=${H} for xml:lang; write xmlns statically, if at all.`,\n // 11\n serverOnly: (): string => SERVER_ONLY,\n // 12\n textContent: (tag: string): string =>\n `A hole in <${tag}> must be its whole content. Write <${tag}>${H}</${tag}> and build the ` +\n `text in the value: <${tag}>\\${\\`\\${page} | Site\\`}</${tag}>.`,\n // 14\n booleanAttr: (tag: string, name: string): string =>\n `${name}=${H} on <${tag}> sets a boolean attribute to a string: any value, even \"false\", ` +\n `turns it on. Write ?${name}=${H} to add the attribute when the value is truthy and ` +\n `remove it otherwise.`,\n // 13\n charRef: (ref: string): string =>\n `&${ref}; in the static text of a bound or custom-element attribute is a named character ` +\n `reference the normalizer doesn't decode (it knows &amp; &lt; &gt; &quot; &apos; &nbsp;). ` +\n `Write the character itself, or a numeric reference such as &#169;.`,\n};\n\n/**\n * Rule 4: property bindings that would be form state (view/02-bindings.md \"Live form state\").\n * Returns the spelling to use instead, or undefined when the binding is fine.\n */\nconst FORM_STATE: Record<string, Record<string, string> | undefined> = {\n input: { value: `value=${H}`, checked: `?checked=${H}`, indeterminate: `?indeterminate=${H}` },\n textarea: { value: `<textarea>${H}</textarea>` },\n select: { value: `?selected=${H} on the chosen <option>` },\n option: { selected: `?selected=${H}`, value: `value=${H}` },\n details: { open: `?open=${H}` },\n dialog: { open: `?open=${H}`, modal: `?modal=${H}` },\n};\n\n/**\n * Rule 4: property bindings that would be form state (view/02-bindings.md \"Live form state\").\n * Returns the spelling to use instead, or undefined when the binding is fine.\n */\nexport function formStateFix(tag: string, name: string): string | undefined {\n return FORM_STATE[tag]?.[name];\n}\n\n/**\n * Rule 14: HTML boolean attributes (present means true). `hidden` is left out because\n * hidden=\"until-found\" is a real string value.\n */\nexport const BOOLEAN_ATTRS = new Set(\n (\n 'allowfullscreen async autofocus autoplay checked controls default defer disabled ' +\n 'disablepictureinpicture disableremoteplayback formnovalidate inert ismap itemscope loop ' +\n 'multiple muted nomodule novalidate open playsinline readonly required reversed selected ' +\n 'shadowrootclonable shadowrootdelegatesfocus shadowrootserializable'\n ).split(' '),\n);\n\n/** Rule 10: SVG element names that HTML doesn't share (lower case). */\nexport const SVG_ONLY = new Set(\n (\n 'animate animatemotion animatetransform circle clippath defs desc ellipse feblend ' +\n 'fecolormatrix fecomponenttransfer fecomposite feconvolvematrix fediffuselighting ' +\n 'fedisplacementmap fedropshadow feflood fegaussianblur feimage femerge femergenode ' +\n 'femorphology feoffset fespecularlighting fetile feturbulence filter foreignobject g line ' +\n 'lineargradient marker mask metadata mpath path pattern polygon polyline radialgradient ' +\n 'rect stop symbol text textpath tspan use'\n ).split(' '),\n);\n\n/** HTML void elements: no end tag, no content. */\nexport const VOID = new Set(\n (\n 'area base basefont bgsound br col embed frame hr img input keygen link meta param source ' +\n 'track wbr'\n ).split(' '),\n);\n"]}
@@ -0,0 +1,5 @@
1
+ import type { Shape, TemplateObject } from './types.js';
2
+ /** The first place where `got` differs from `want`, as a message; undefined if none. */
3
+ export declare function shapeMismatch(want: Shape, got: Shape, path?: readonly number[]): string | undefined;
4
+ /** Rule 7's error for a parse that differs from the template's shape (`problem`). */
5
+ export declare function repairError(template: TemplateObject, parser: string, problem: string): Error;
@@ -0,0 +1,38 @@
1
+ // Rule 7 by comparison (view/09-template-rules.md "How rule 7 is checked"): the DOM an HTML
2
+ // parser built from a template's HTML, as a Shape, against the shape the normalizer computed
3
+ // the part paths for. Any difference means the parser repaired the markup. The runtime
4
+ // preparer feeds it the browser's own parse (prepare.ts); the Vite template compiler feeds it
5
+ // parse5's (src/compiler/parse5-check.ts). No DOM here: it runs in Node and in the browser.
6
+ import { TemplateError } from './errors.js';
7
+ const describe = (node) => node === undefined
8
+ ? 'nothing'
9
+ : typeof node === 'string'
10
+ ? node === '#text'
11
+ ? 'text'
12
+ : 'a comment'
13
+ : `<${node[0]}>`;
14
+ const same = (want, got) => typeof want === 'string' ? want === got : typeof got !== 'string' && want[0] === got[0];
15
+ /** The first place where `got` differs from `want`, as a message; undefined if none. */
16
+ export function shapeMismatch(want, got, path = []) {
17
+ for (let k = 0; k < Math.max(want.length, got.length); k++) {
18
+ const w = want[k];
19
+ const g = got[k];
20
+ if (w === undefined || g === undefined || !same(w, g)) {
21
+ return `at path [${[...path, k].join(', ')}]: expected ${describe(w)}, found ${describe(g)}`;
22
+ }
23
+ if (typeof w !== 'string' && typeof g !== 'string') {
24
+ const inner = shapeMismatch(w[1], g[1], [...path, k]);
25
+ if (inner !== undefined)
26
+ return inner;
27
+ }
28
+ }
29
+ return undefined;
30
+ }
31
+ /** Rule 7's error for a parse that differs from the template's shape (`problem`). */
32
+ export function repairError(template, parser, problem) {
33
+ return new TemplateError(7, `${parser} built a different DOM for this template ${problem}. It repaired the markup ` +
34
+ `(for example <tr> directly in <table>, a block element inside <p>, or <a> inside ` +
35
+ `<a>), so part paths would point at the wrong nodes. Write the valid structure ` +
36
+ `(<tbody>, closing </p> first, …).\n template: ${template.html.slice(0, 120)}`, template.loc);
37
+ }
38
+ //# sourceMappingURL=shape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shape.js","sourceRoot":"","sources":["../../../src/view/normalize/shape.ts"],"names":[],"mappings":"AAAA,4FAA4F;AAC5F,6FAA6F;AAC7F,uFAAuF;AACvF,8FAA8F;AAC9F,4FAA4F;AAC5F,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,MAAM,QAAQ,GAAG,CAAC,IAA2B,EAAU,EAAE,CACvD,IAAI,KAAK,SAAS;IAChB,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,OAAO,IAAI,KAAK,QAAQ;QACxB,CAAC,CAAC,IAAI,KAAK,OAAO;YAChB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,WAAW;QACf,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AAEvB,MAAM,IAAI,GAAG,CAAC,IAAe,EAAE,GAAc,EAAW,EAAE,CACxD,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC,OAAO,GAA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;QAChF,kDAAkD,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EACjF,QAAQ,CAAC,GAAG,CACb,CAAC;AACJ,CAAC","sourcesContent":["// Rule 7 by comparison (view/09-template-rules.md \"How rule 7 is checked\"): the DOM an HTML\n// parser built from a template's HTML, as a Shape, against the shape the normalizer computed\n// the part paths for. Any difference means the parser repaired the markup. The runtime\n// preparer feeds it the browser's own parse (prepare.ts); the Vite template compiler feeds it\n// parse5's (src/compiler/parse5-check.ts). No DOM here: it runs in Node and in the browser.\nimport { TemplateError } from './errors.js';\nimport type { Shape, ShapeNode, TemplateObject } from './types.js';\n\nconst describe = (node: ShapeNode | undefined): string =>\n node === undefined\n ? 'nothing'\n : typeof node === 'string'\n ? node === '#text'\n ? 'text'\n : 'a comment'\n : `<${node[0]}>`;\n\nconst same = (want: ShapeNode, got: ShapeNode): boolean =>\n typeof want === 'string' ? want === got : typeof got !== 'string' && want[0] === got[0];\n\n/** The first place where `got` differs from `want`, as a message; undefined if none. */\nexport function shapeMismatch(\n want: Shape,\n got: Shape,\n path: readonly number[] = [],\n): string | undefined {\n for (let k = 0; k < Math.max(want.length, got.length); k++) {\n const w = want[k];\n const g = got[k];\n if (w === undefined || g === undefined || !same(w, g)) {\n return `at path [${[...path, k].join(', ')}]: expected ${describe(w)}, found ${describe(g)}`;\n }\n if (typeof w !== 'string' && typeof g !== 'string') {\n const inner = shapeMismatch(w[1], g[1], [...path, k]);\n if (inner !== undefined) return inner;\n }\n }\n return undefined;\n}\n\n/** Rule 7's error for a parse that differs from the template's shape (`problem`). */\nexport function repairError(template: TemplateObject, parser: string, problem: string): Error {\n return new TemplateError(\n 7,\n `${parser} built a different DOM for this template ${problem}. It repaired the markup ` +\n `(for example <tr> directly in <table>, a block element inside <p>, or <a> inside ` +\n `<a>), so part paths would point at the wrong nodes. Write the valid structure ` +\n `(<tbody>, closing </p> first, …).\\n template: ${template.html.slice(0, 120)}`,\n template.loc,\n );\n}\n"]}
@@ -0,0 +1,13 @@
1
+ export declare class Source {
2
+ readonly strings: readonly string[];
3
+ readonly loc: string | undefined;
4
+ /** Index of the string being read, and the offset in it. */
5
+ i: number;
6
+ pos: number;
7
+ constructor(strings: readonly string[], loc: string | undefined);
8
+ get last(): boolean;
9
+ /** The markup around the current position, with holes shown as `${…}`. */
10
+ near(): string;
11
+ /** Throws rule `rule`'s error, quoting the markup at the current position. */
12
+ fail(rule: number, message: string): never;
13
+ }
@@ -0,0 +1,34 @@
1
+ // The strings being normalized and the tokenizer's position in them, so every rule violation
2
+ // (view/09-template-rules.md) can quote the markup it is about.
3
+ import { TemplateError } from './errors.js';
4
+ const HOLE = '${…}';
5
+ export class Source {
6
+ constructor(strings, loc) {
7
+ this.strings = strings;
8
+ this.loc = loc;
9
+ /** Index of the string being read, and the offset in it. */
10
+ this.i = 0;
11
+ this.pos = 0;
12
+ }
13
+ get last() {
14
+ return this.i === this.strings.length - 1;
15
+ }
16
+ /** The markup around the current position, with holes shown as `${…}`. */
17
+ near() {
18
+ const s = this.strings[this.i] ?? '';
19
+ let before = s.slice(Math.max(0, this.pos - 40), this.pos);
20
+ if (this.pos < 40 && this.i > 0) {
21
+ before = (this.strings[this.i - 1] ?? '').slice(this.pos - 40) + HOLE + before;
22
+ }
23
+ let after = s.slice(this.pos, this.pos + 20);
24
+ if (this.pos + 20 > s.length && !this.last) {
25
+ after += HOLE + (this.strings[this.i + 1] ?? '').slice(0, 20 - after.length);
26
+ }
27
+ return `${before}${after}`.replace(/\s+/g, ' ').trim();
28
+ }
29
+ /** Throws rule `rule`'s error, quoting the markup at the current position. */
30
+ fail(rule, message) {
31
+ throw new TemplateError(rule, message, this.loc, this.near());
32
+ }
33
+ }
34
+ //# sourceMappingURL=source.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"source.js","sourceRoot":"","sources":["../../../src/view/normalize/source.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,gEAAgE;AAChE,OAAO,E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AAO,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/E,CAAC;QACD,OAAO,GAAG,MAAM,GAAG,KAAK,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;IACzD,CAAC;IAED,8EAA8E;IAC9E,IAAI,CAAC,IAAY,EAAE,OAAe;QAChC,MAAM,IAAI,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;CACF","sourcesContent":["// The strings being normalized and the tokenizer's position in them, so every rule violation\n// (view/09-template-rules.md) can quote the markup it is about.\nimport { TemplateError } from './errors.js';\n\nconst HOLE = '${…}';\n\nexport class Source {\n /** Index of the string being read, and the offset in it. */\n i = 0;\n pos = 0;\n\n constructor(\n readonly strings: readonly string[],\n readonly loc: string | undefined,\n ) {}\n\n get last(): boolean {\n return this.i === this.strings.length - 1;\n }\n\n /** The markup around the current position, with holes shown as `${…}`. */\n near(): string {\n const s = this.strings[this.i] ?? '';\n let before = s.slice(Math.max(0, this.pos - 40), this.pos);\n if (this.pos < 40 && this.i > 0) {\n before = (this.strings[this.i - 1] ?? '').slice(this.pos - 40) + HOLE + before;\n }\n let after = s.slice(this.pos, this.pos + 20);\n if (this.pos + 20 > s.length && !this.last) {\n after += HOLE + (this.strings[this.i + 1] ?? '').slice(0, 20 - after.length);\n }\n return `${before}${after}`.replace(/\\s+/g, ' ').trim();\n }\n\n /** Throws rule `rule`'s error, quoting the markup at the current position. */\n fail(rule: number, message: string): never {\n throw new TemplateError(rule, message, this.loc, this.near());\n }\n}\n"]}
@@ -0,0 +1,14 @@
1
+ /** A bound attribute's name on an SVG element, as the parser spells it. */
2
+ export declare const svgAttr: (name: string) => string;
3
+ /**
4
+ * HTML elements that are not SVG elements, and that don't end SVG content either (those are
5
+ * repairs.ts's BREAKOUT): inside SVG content the parser creates an unknown SVG element.
6
+ */
7
+ export declare const HTML_ONLY: Set<string>;
8
+ /** HTML integration points in SVG: their content is HTML (WHATWG HTML, tree construction). */
9
+ export declare const SVG_HTML_POINT: RegExp;
10
+ /**
11
+ * A bound attribute the renderer can't set with `setAttribute` the way the parser would: the
12
+ * parser puts xlink:*, xml:* and xmlns* attributes in their own namespaces.
13
+ */
14
+ export declare const namespacedAttr: (name: string) => boolean;
@@ -0,0 +1,40 @@
1
+ // SVG content in the normalizer (view/01-templates.md "svg templates", view/09-template-rules.md
2
+ // rule 10), from WHATWG HTML "Parsing main inside foreign content" and "adjust SVG attributes":
3
+ // the HTML tokenizer lower-cases attribute names, then the tree builder restores the camelCase
4
+ // of SVG's own attributes. Bound attribute names on SVG elements are spelled the same way, so
5
+ // `viewbox=${v}` binds viewBox, as the parser does for the server's markup. HTML elements that
6
+ // are not SVG elements, inside SVG content, are rule 10 (they would be created as unknown SVG
7
+ // elements that render nothing); the ones that end the SVG element are in repairs.ts.
8
+ /** WHATWG HTML's "adjust SVG attributes" table: lower case → the SVG spelling. */
9
+ const CAMEL = 'attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits ' +
10
+ 'diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix ' +
11
+ 'kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight ' +
12
+ 'markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength ' +
13
+ 'patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ ' +
14
+ 'preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur ' +
15
+ 'requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod ' +
16
+ 'startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX ' +
17
+ 'targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan';
18
+ const ATTRS = new Map(CAMEL.split(' ').map((name) => [name.toLowerCase(), name]));
19
+ /** A bound attribute's name on an SVG element, as the parser spells it. */
20
+ export const svgAttr = (name) => {
21
+ const lower = name.toLowerCase();
22
+ return ATTRS.get(lower) ?? lower;
23
+ };
24
+ /**
25
+ * HTML elements that are not SVG elements, and that don't end SVG content either (those are
26
+ * repairs.ts's BREAKOUT): inside SVG content the parser creates an unknown SVG element.
27
+ */
28
+ export const HTML_ONLY = new Set(('abbr address area article aside audio bdi bdo button canvas caption cite col colgroup ' +
29
+ 'data datalist del details dfn dialog fieldset figcaption figure footer form header hgroup ' +
30
+ 'html iframe input ins kbd label legend main map mark meter nav noscript object optgroup ' +
31
+ 'option output picture progress q rp rt samp search section select slot source summary ' +
32
+ 'tbody td template textarea tfoot th thead time tr track video wbr').split(' '));
33
+ /** HTML integration points in SVG: their content is HTML (WHATWG HTML, tree construction). */
34
+ export const SVG_HTML_POINT = /^(foreignobject|desc|title)$/;
35
+ /**
36
+ * A bound attribute the renderer can't set with `setAttribute` the way the parser would: the
37
+ * parser puts xlink:*, xml:* and xmlns* attributes in their own namespaces.
38
+ */
39
+ export const namespacedAttr = (name) => /^(xlink:|xml:|xmlns)/i.test(name);
40
+ //# sourceMappingURL=svg.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svg.js","sourceRoot":"","sources":["../../../src/view/normalize/svg.ts"],"names":[],"mappings":"AAAA,iGAAiG;AACjG,gGAAgG;AAChG,+FAA+F;AAC/F,8FAA8F;AAC9F,+FAA+F;AAC/F,8FAA8F;AAC9F,sFAAsF;AAEtF,kFAAkF;AAClF,MAAM,KAAK,GACT,+EAA+E;IAC/E,6FAA6F;IAC7F,6FAA6F;IAC7F,2EAA2E;IAC3E,kFAAkF;IAClF,mFAAmF;IACnF,qFAAqF;IACrF,uFAAuF;IACvF,oFAAoF,CAAC;AACvF,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;AAElF,2EAA2E;AAC3E,MAAM,CAAC,MAAM,OAAO,GAAG,CAAC,IAAY,EAAU,EAAE;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACjC,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC;AACnC,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,IAAI,GAAG,CAC9B,CACE,wFAAwF;IACxF,4FAA4F;IAC5F,0FAA0F;IAC1F,wFAAwF;IACxF,mEAAmE,CACpE,CAAC,KAAK,CAAC,GAAG,CAAC,CACb,CAAC;AAEF,8FAA8F;AAC9F,MAAM,CAAC,MAAM,cAAc,GAAG,8BAA8B,CAAC;AAE7D;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC","sourcesContent":["// SVG content in the normalizer (view/01-templates.md \"svg templates\", view/09-template-rules.md\n// rule 10), from WHATWG HTML \"Parsing main inside foreign content\" and \"adjust SVG attributes\":\n// the HTML tokenizer lower-cases attribute names, then the tree builder restores the camelCase\n// of SVG's own attributes. Bound attribute names on SVG elements are spelled the same way, so\n// `viewbox=${v}` binds viewBox, as the parser does for the server's markup. HTML elements that\n// are not SVG elements, inside SVG content, are rule 10 (they would be created as unknown SVG\n// elements that render nothing); the ones that end the SVG element are in repairs.ts.\n\n/** WHATWG HTML's \"adjust SVG attributes\" table: lower case → the SVG spelling. */\nconst CAMEL =\n 'attributeName attributeType baseFrequency baseProfile calcMode clipPathUnits ' +\n 'diffuseConstant edgeMode filterUnits glyphRef gradientTransform gradientUnits kernelMatrix ' +\n 'kernelUnitLength keyPoints keySplines keyTimes lengthAdjust limitingConeAngle markerHeight ' +\n 'markerUnits markerWidth maskContentUnits maskUnits numOctaves pathLength ' +\n 'patternContentUnits patternTransform patternUnits pointsAtX pointsAtY pointsAtZ ' +\n 'preserveAlpha preserveAspectRatio primitiveUnits refX refY repeatCount repeatDur ' +\n 'requiredExtensions requiredFeatures specularConstant specularExponent spreadMethod ' +\n 'startOffset stdDeviation stitchTiles surfaceScale systemLanguage tableValues targetX ' +\n 'targetY textLength viewBox viewTarget xChannelSelector yChannelSelector zoomAndPan';\nconst ATTRS = new Map(CAMEL.split(' ').map((name) => [name.toLowerCase(), name]));\n\n/** A bound attribute's name on an SVG element, as the parser spells it. */\nexport const svgAttr = (name: string): string => {\n const lower = name.toLowerCase();\n return ATTRS.get(lower) ?? lower;\n};\n\n/**\n * HTML elements that are not SVG elements, and that don't end SVG content either (those are\n * repairs.ts's BREAKOUT): inside SVG content the parser creates an unknown SVG element.\n */\nexport const HTML_ONLY = new Set(\n (\n 'abbr address area article aside audio bdi bdo button canvas caption cite col colgroup ' +\n 'data datalist del details dfn dialog fieldset figcaption figure footer form header hgroup ' +\n 'html iframe input ins kbd label legend main map mark meter nav noscript object optgroup ' +\n 'option output picture progress q rp rt samp search section select slot source summary ' +\n 'tbody td template textarea tfoot th thead time tr track video wbr'\n ).split(' '),\n);\n\n/** HTML integration points in SVG: their content is HTML (WHATWG HTML, tree construction). */\nexport const SVG_HTML_POINT = /^(foreignobject|desc|title)$/;\n\n/**\n * A bound attribute the renderer can't set with `setAttribute` the way the parser would: the\n * parser puts xlink:*, xml:* and xmlns* attributes in their own namespaces.\n */\nexport const namespacedAttr = (name: string): boolean => /^(xlink:|xml:|xmlns)/i.test(name);\n"]}
@@ -0,0 +1,23 @@
1
+ import type { Source } from './source.js';
2
+ import { type Sink, type StartTag, type State } from './tokens.js';
3
+ export declare abstract class TagStates {
4
+ protected readonly src: Source;
5
+ protected readonly sink: Sink;
6
+ protected state: State;
7
+ protected buf: string;
8
+ protected rawEnd: string;
9
+ protected tag: StartTag;
10
+ private attrName;
11
+ private pieces;
12
+ constructor(src: Source, sink: Sink);
13
+ protected tagChar(c: string): void;
14
+ private startName;
15
+ private endValueless;
16
+ private pushStatic;
17
+ private endQuoted;
18
+ /** A bound attribute named `attrName`; `strings` for a multi-attribute. */
19
+ private pushBound;
20
+ private emitTag;
21
+ /** A hole in a start tag (after string `src.i`). */
22
+ protected holeInTag(): void;
23
+ }
@@ -0,0 +1,192 @@
1
+ // The start-tag states of the template tokenizer (WHATWG HTML: before/after attribute name,
2
+ // attribute name, before attribute value, attribute value in double/single/no quotes, after
3
+ // attribute value, self-closing start tag), and what a hole means in each: an attribute,
4
+ // multi-attribute, boolean, property or hook (view/02-bindings.md), or rule 1, 2 or 5
5
+ // (view/09-template-rules.md). tokenizer.ts adds the data, comment and raw text states.
6
+ import { msg } from './rules.js';
7
+ import { isWs, S } from './tokens.js';
8
+ export class TagStates {
9
+ constructor(src, sink) {
10
+ this.src = src;
11
+ this.sink = sink;
12
+ this.state = S.Data;
13
+ this.buf = '';
14
+ this.rawEnd = '';
15
+ this.tag = { name: '', raw: '', attrs: [], selfClosing: false };
16
+ this.attrName = '';
17
+ this.pieces = [];
18
+ }
19
+ tagChar(c) {
20
+ this.src.pos += 1;
21
+ switch (this.state) {
22
+ case S.BeforeName:
23
+ if (isWs(c))
24
+ return;
25
+ if (c === '/')
26
+ this.state = S.SelfClosing;
27
+ else if (c === '>')
28
+ this.emitTag();
29
+ else
30
+ this.startName(c);
31
+ return;
32
+ case S.Name:
33
+ if (isWs(c))
34
+ this.state = S.AfterName;
35
+ else if (c === '=')
36
+ this.state = S.BeforeValue;
37
+ else if (c === '/' || c === '>')
38
+ this.endValueless(c);
39
+ else
40
+ this.attrName += c;
41
+ return;
42
+ case S.AfterName:
43
+ if (isWs(c))
44
+ return;
45
+ if (c === '=')
46
+ this.state = S.BeforeValue;
47
+ else if (c === '/' || c === '>')
48
+ this.endValueless(c);
49
+ else {
50
+ this.pushStatic(null);
51
+ this.startName(c);
52
+ }
53
+ return;
54
+ case S.BeforeValue:
55
+ if (isWs(c))
56
+ return;
57
+ this.buf = '';
58
+ this.pieces = [];
59
+ if (c === '"')
60
+ this.state = S.ValueDq;
61
+ else if (c === "'")
62
+ this.state = S.ValueSq;
63
+ else if (c === '>') {
64
+ this.pushStatic('""');
65
+ this.emitTag();
66
+ }
67
+ else {
68
+ this.buf = c;
69
+ this.state = S.ValueUnq;
70
+ }
71
+ return;
72
+ case S.ValueDq:
73
+ case S.ValueSq:
74
+ if (c === (this.state === S.ValueDq ? '"' : "'"))
75
+ this.endQuoted(c);
76
+ else
77
+ this.buf += c;
78
+ return;
79
+ case S.ValueUnq:
80
+ if (isWs(c) || c === '>') {
81
+ this.pushStatic(this.buf);
82
+ this.state = S.BeforeName;
83
+ if (c === '>')
84
+ this.emitTag();
85
+ }
86
+ else
87
+ this.buf += c;
88
+ return;
89
+ default:
90
+ // AfterValueQ and SelfClosing: `>` ends the tag, anything else starts a new attribute.
91
+ if (c === '>') {
92
+ this.tag.selfClosing = this.state === S.SelfClosing;
93
+ this.emitTag();
94
+ }
95
+ else if (c === '/')
96
+ this.state = S.SelfClosing;
97
+ else if (!isWs(c))
98
+ this.startName(c);
99
+ else
100
+ this.state = S.BeforeName;
101
+ }
102
+ }
103
+ startName(c) {
104
+ this.attrName = c;
105
+ this.state = S.Name;
106
+ }
107
+ endValueless(c) {
108
+ this.pushStatic(null);
109
+ if (c === '>')
110
+ this.emitTag();
111
+ else
112
+ this.state = S.SelfClosing;
113
+ }
114
+ pushStatic(value) {
115
+ this.tag.attrs.push({ kind: 'static', name: this.attrName, value });
116
+ }
117
+ endQuoted(quote) {
118
+ this.state = S.AfterValueQ;
119
+ if (this.pieces.length === 0) {
120
+ this.pushStatic(quote + this.buf + quote);
121
+ return;
122
+ }
123
+ this.pieces.push(this.buf);
124
+ const single = this.pieces.length === 2 && this.pieces[0] === '' && this.pieces[1] === '';
125
+ this.pushBound(single ? undefined : this.pieces);
126
+ }
127
+ /** A bound attribute named `attrName`; `strings` for a multi-attribute. */
128
+ pushBound(strings) {
129
+ const name = this.attrName;
130
+ const prefix = name.charAt(0);
131
+ if (prefix === '@')
132
+ this.src.fail(1, msg.eventBinding(name));
133
+ if (prefix === '?' || prefix === '.') {
134
+ if (strings !== undefined)
135
+ this.src.fail(5, msg.notSingle(name));
136
+ const kind = prefix === '?' ? 'bool' : 'prop';
137
+ this.tag.attrs.push({ kind, name: name.slice(1) });
138
+ return;
139
+ }
140
+ this.tag.attrs.push(strings === undefined ? { kind: 'attr', name } : { kind: 'attr', name, strings });
141
+ }
142
+ emitTag() {
143
+ const mode = this.sink.start(this.tag);
144
+ this.rawEnd = this.tag.name;
145
+ this.state = mode === 'data' ? S.Data : mode === 'rawtext' ? S.RawText : S.RcData;
146
+ }
147
+ /** A hole in a start tag (after string `src.i`). */
148
+ holeInTag() {
149
+ const { src } = this;
150
+ const next = src.strings[src.i + 1] ?? '';
151
+ const c = next.charAt(0);
152
+ const event = this.attrName.startsWith('@');
153
+ switch (this.state) {
154
+ case S.Name:
155
+ if (event)
156
+ src.fail(1, msg.eventBinding(this.attrName));
157
+ src.fail(2, msg.dynamicName());
158
+ break;
159
+ case S.BeforeValue: {
160
+ // The template ending here is rule 7 (unterminated tag), reported by the tokenizer.
161
+ const atEnd = c === '' && src.i + 1 === src.strings.length - 1;
162
+ const ends = isWs(c) || c === '>' || next.startsWith('/>') || atEnd;
163
+ if (!event && !ends)
164
+ src.fail(5, msg.unquoted(this.attrName));
165
+ this.pushBound(undefined);
166
+ this.state = S.BeforeName;
167
+ break;
168
+ }
169
+ case S.ValueUnq:
170
+ if (event)
171
+ src.fail(1, msg.eventBinding(this.attrName));
172
+ src.fail(5, msg.unquoted(this.attrName));
173
+ break;
174
+ case S.ValueDq:
175
+ case S.ValueSq:
176
+ if (event)
177
+ src.fail(1, msg.eventBinding(this.attrName));
178
+ this.pieces.push(this.buf);
179
+ this.buf = '';
180
+ break;
181
+ default:
182
+ // Before an attribute name: an element hook.
183
+ if (this.state === S.AfterName)
184
+ this.pushStatic(null);
185
+ if (c !== '' && !isWs(c) && c !== '>' && c !== '/')
186
+ src.fail(2, msg.dynamicName());
187
+ this.tag.attrs.push({ kind: 'hook', name: '' });
188
+ this.state = S.BeforeName;
189
+ }
190
+ }
191
+ }
192
+ //# sourceMappingURL=tag-states.js.map