@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,45 @@
1
+ // One <template> element per template object, created on first use (view/01-templates.md
2
+ // "Instantiation"). The browser's own parser builds it from the template HTML; the runtime
3
+ // preparer then checks the parse (rule 7). Server templates never get one (rule 11). An svg
4
+ // template's is prepared by `svgTemplate` when its first result is made (template.ts `svg`), so
5
+ // apps without svg templates don't carry that code. Both parse through the `gyral` Trusted Types
6
+ // policy (trusted-html.ts).
7
+ import { verify } from '#prepare';
8
+ import { DEV } from '#view-dev';
9
+ import { message } from './message.js';
10
+ import { SERVER_ONLY, TemplateError } from './normalize/errors.js';
11
+ import { trustedHTML } from './trusted-html.js';
12
+ const elements = new WeakMap();
13
+ /** The cached <template> element for `template`, parsed (and checked) on first use. */
14
+ export function templateElement(template) {
15
+ const cached = elements.get(template);
16
+ if (cached !== undefined)
17
+ return cached;
18
+ if (template.server) {
19
+ // Production keeps a short message: the class and its explanation stay out of the bundle.
20
+ throw DEV ? new TemplateError(11, SERVER_ONLY, template.loc) : new Error(message(71));
21
+ }
22
+ const el = document.createElement('template');
23
+ el.innerHTML = trustedHTML(template.html);
24
+ verify(template, el);
25
+ elements.set(template, el);
26
+ return el;
27
+ }
28
+ /**
29
+ * Prepares an svg template's <template> element (01 "svg templates"): its HTML is parsed inside
30
+ * an <svg>, so the parser creates SVG elements (camelCase names and attributes, namespaced
31
+ * static attributes), and that <svg>'s children become the content. Called with every svg
32
+ * result, before anything renders it; outside a document (the server) there is nothing to do.
33
+ */
34
+ export function svgTemplate(template) {
35
+ if (elements.has(template) || typeof document === 'undefined')
36
+ return;
37
+ const el = document.createElement('template');
38
+ el.innerHTML = trustedHTML(`<svg>${template.html}</svg>`);
39
+ const content = el.content;
40
+ // Anything the parser moved out of the <svg> is dropped here, and the check reports it.
41
+ content.replaceChildren(...content.firstChild.childNodes);
42
+ verify(template, el);
43
+ elements.set(template, el);
44
+ }
45
+ //# sourceMappingURL=template-element.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template-element.js","sourceRoot":"","sources":["../../src/view/template-element.ts"],"names":[],"mappings":"AAAA,yFAAyF;AACzF,2FAA2F;AAC3F,4FAA4F;AAC5F,gGAAgG;AAChG,iGAAiG;AACjG,4BAA4B;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEnE,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,QAAQ,GAAG,IAAI,OAAO,EAAuC,CAAC;AAEpE,uFAAuF;AACvF,MAAM,UAAU,eAAe,CAAC,QAAwB;IACtD,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACtC,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC;IACxC,IAAI,QAAQ,CAAC,MAAM,EAAE,CAAC;QACpB,0FAA0F;QAC1F,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC;IACxF,CAAC;IACD,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC1C,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IAC3B,OAAO,EAAE,CAAC;AACZ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,WAAW,CAAC,QAAwB;IAClD,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IACtE,MAAM,EAAE,GAAG,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;IAC9C,EAAE,CAAC,SAAS,GAAG,WAAW,CAAC,QAAQ,QAAQ,CAAC,IAAI,QAAQ,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,EAAE,CAAC,OAAO,CAAC;IAC3B,wFAAwF;IACxF,OAAO,CAAC,eAAe,CAAC,GAAI,OAAO,CAAC,UAAsB,CAAC,UAAU,CAAC,CAAC;IACvE,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;IACrB,QAAQ,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;AAC7B,CAAC","sourcesContent":["// One <template> element per template object, created on first use (view/01-templates.md\n// \"Instantiation\"). The browser's own parser builds it from the template HTML; the runtime\n// preparer then checks the parse (rule 7). Server templates never get one (rule 11). An svg\n// template's is prepared by `svgTemplate` when its first result is made (template.ts `svg`), so\n// apps without svg templates don't carry that code. Both parse through the `gyral` Trusted Types\n// policy (trusted-html.ts).\nimport { verify } from '#prepare';\nimport { DEV } from '#view-dev';\nimport { message } from './message.js';\nimport { SERVER_ONLY, TemplateError } from './normalize/errors.js';\nimport type { TemplateObject } from './normalize/types.js';\nimport { trustedHTML } from './trusted-html.js';\n\nconst elements = new WeakMap<TemplateObject, HTMLTemplateElement>();\n\n/** The cached <template> element for `template`, parsed (and checked) on first use. */\nexport function templateElement(template: TemplateObject): HTMLTemplateElement {\n const cached = elements.get(template);\n if (cached !== undefined) return cached;\n if (template.server) {\n // Production keeps a short message: the class and its explanation stay out of the bundle.\n throw DEV ? new TemplateError(11, SERVER_ONLY, template.loc) : new Error(message(71));\n }\n const el = document.createElement('template');\n el.innerHTML = trustedHTML(template.html);\n verify(template, el);\n elements.set(template, el);\n return el;\n}\n\n/**\n * Prepares an svg template's <template> element (01 \"svg templates\"): its HTML is parsed inside\n * an <svg>, so the parser creates SVG elements (camelCase names and attributes, namespaced\n * static attributes), and that <svg>'s children become the content. Called with every svg\n * result, before anything renders it; outside a document (the server) there is nothing to do.\n */\nexport function svgTemplate(template: TemplateObject): void {\n if (elements.has(template) || typeof document === 'undefined') return;\n const el = document.createElement('template');\n el.innerHTML = trustedHTML(`<svg>${template.html}</svg>`);\n const content = el.content;\n // Anything the parser moved out of the <svg> is dropped here, and the check reports it.\n content.replaceChildren(...(content.firstChild as Element).childNodes);\n verify(template, el);\n elements.set(template, el);\n}\n"]}
@@ -0,0 +1,29 @@
1
+ import type { TemplateObject } from './normalize/types.js';
2
+ declare const SOURCE: unique symbol;
3
+ /** What `html` returns: a template plus this render's values. */
4
+ export interface TemplateResult {
5
+ readonly [SOURCE]: readonly string[] | TemplateObject;
6
+ readonly values: readonly unknown[];
7
+ }
8
+ /** The template tag: `` html`<p>${s.text}</p>` ``. */
9
+ export declare const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
10
+ /**
11
+ * The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it
12
+ * renders only inside an `<svg>` (or another SVG element) of an html template
13
+ * (view/01-templates.md "svg templates"). A whole `<svg>` graphic is written with html.
14
+ */
15
+ export declare const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult;
16
+ /** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */
17
+ export declare function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult;
18
+ /** Internal: what the template compiler rewrites `svg` calls into. */
19
+ export declare function compiledSvg(template: TemplateObject, values: readonly unknown[]): TemplateResult;
20
+ export declare function isTemplateResult(value: unknown): value is TemplateResult;
21
+ /** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
22
+ export declare const sourceOf: (result: TemplateResult) => readonly string[] | TemplateObject;
23
+ /**
24
+ * The template object of a result: compiled results carry it; a runtime result's call site is
25
+ * normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
26
+ * nor its cache).
27
+ */
28
+ export declare function templateOf(result: TemplateResult): TemplateObject;
29
+ export {};
@@ -0,0 +1,84 @@
1
+ // Template results and the `html` and `svg` tags (view/01-templates.md "Authoring", "Template
2
+ // results", "svg templates"). A result is a template source (the call site's strings, or a
3
+ // template object) plus this call's values, recognised by a module-private symbol so data from
4
+ // JSON can never pass for one. `templateOf` turns the source into the template object: compiled
5
+ // and svg results carry it, html results are normalized once per strings array through
6
+ // `#prepare` (prepare.ts). Development records each call site's source location (loc.ts) for
7
+ // error messages.
8
+ import { prepare } from '#prepare';
9
+ import { DEV } from '#view-dev';
10
+ import { callSite, locOf, setLoc } from './loc.js';
11
+ import { svgTemplate } from './template-element.js';
12
+ const SOURCE = Symbol('gyral.template');
13
+ /** The template tag, as `html` is in production. */
14
+ function tag(strings, ...values) {
15
+ // Development: the call site, from the stack, the first time (unless `html.at` gave it).
16
+ if (DEV && locOf(strings) === undefined)
17
+ setLoc(strings, callSite(new Error().stack));
18
+ return { [SOURCE]: strings, values };
19
+ }
20
+ /** The svg tag, as `svg` is in production: svg results carry their (prepared) template. */
21
+ function svgTag(strings, ...values) {
22
+ // Development: the call site, from the stack, the first time (unless `svg.at` gave it), so
23
+ // the normalizer's rule errors name it.
24
+ if (DEV && locOf(strings) === undefined)
25
+ setLoc(strings, callSite(new Error().stack));
26
+ return compiledSvg(prepare(strings, true), values);
27
+ }
28
+ /**
29
+ * Development: `html.at(loc)` (and `svg.at(loc)`) is the tag with a known call site. The Vite
30
+ * preset's dev transform (compiler/locate.ts) writes it at every call site, since stack
31
+ * positions in transformed modules aren't the author's lines. Attached here, not by a statement
32
+ * that mentions the tag, so production builds don't keep it alive (the compiler checks that).
33
+ */
34
+ function withAt(html) {
35
+ const tags = new Map();
36
+ const at = (loc) => {
37
+ let located = tags.get(loc);
38
+ if (located === undefined) {
39
+ located = (strings, ...values) => {
40
+ setLoc(strings, loc);
41
+ return html(strings, ...values);
42
+ };
43
+ tags.set(loc, located);
44
+ }
45
+ return located;
46
+ };
47
+ return Object.assign(html, { at });
48
+ }
49
+ /** The template tag: `` html`<p>${s.text}</p>` ``. */
50
+ export const html = DEV
51
+ ? withAt(tag)
52
+ : tag;
53
+ /**
54
+ * The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it
55
+ * renders only inside an `<svg>` (or another SVG element) of an html template
56
+ * (view/01-templates.md "svg templates"). A whole `<svg>` graphic is written with html.
57
+ */
58
+ export const svg = DEV
59
+ ? withAt(svgTag)
60
+ : svgTag;
61
+ /** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */
62
+ export function compiled(template, values) {
63
+ return { [SOURCE]: template, values };
64
+ }
65
+ /** Internal: what the template compiler rewrites `svg` calls into. */
66
+ export function compiledSvg(template, values) {
67
+ svgTemplate(template);
68
+ return { [SOURCE]: template, values };
69
+ }
70
+ export function isTemplateResult(value) {
71
+ return typeof value === 'object' && value !== null && SOURCE in value;
72
+ }
73
+ /** Internal: a result's source, compared by identity to skip `templateOf` on updates. */
74
+ export const sourceOf = (result) => result[SOURCE];
75
+ /**
76
+ * The template object of a result: compiled results carry it; a runtime result's call site is
77
+ * normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer
78
+ * nor its cache).
79
+ */
80
+ export function templateOf(result) {
81
+ const source = result[SOURCE];
82
+ return Array.isArray(source) ? prepare(source) : source;
83
+ }
84
+ //# sourceMappingURL=template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"template.js","sourceRoot":"","sources":["../../src/view/template.ts"],"names":[],"mappings":"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","sourcesContent":["// Template results and the `html` and `svg` tags (view/01-templates.md \"Authoring\", \"Template\n// results\", \"svg templates\"). A result is a template source (the call site's strings, or a\n// template object) plus this call's values, recognised by a module-private symbol so data from\n// JSON can never pass for one. `templateOf` turns the source into the template object: compiled\n// and svg results carry it, html results are normalized once per strings array through\n// `#prepare` (prepare.ts). Development records each call site's source location (loc.ts) for\n// error messages.\nimport { prepare } from '#prepare';\nimport { DEV } from '#view-dev';\nimport { callSite, locOf, setLoc } from './loc.js';\nimport type { TemplateObject } from './normalize/types.js';\nimport { svgTemplate } from './template-element.js';\n\nconst SOURCE: unique symbol = Symbol('gyral.template');\n\n/** What `html` returns: a template plus this render's values. */\nexport interface TemplateResult {\n readonly [SOURCE]: readonly string[] | TemplateObject;\n readonly values: readonly unknown[];\n}\n\n/** The template tag, as `html` is in production. */\nfunction tag(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult {\n // Development: the call site, from the stack, the first time (unless `html.at` gave it).\n if (DEV && locOf(strings) === undefined) setLoc(strings, callSite(new Error().stack));\n return { [SOURCE]: strings, values };\n}\n\n/** The svg tag, as `svg` is in production: svg results carry their (prepared) template. */\nfunction svgTag(strings: TemplateStringsArray, ...values: unknown[]): TemplateResult {\n // Development: the call site, from the stack, the first time (unless `svg.at` gave it), so\n // the normalizer's rule errors name it.\n if (DEV && locOf(strings) === undefined) setLoc(strings, callSite(new Error().stack));\n return compiledSvg(prepare(strings, true), values);\n}\n\ntype Tag = typeof tag;\n\n/**\n * Development: `html.at(loc)` (and `svg.at(loc)`) is the tag with a known call site. The Vite\n * preset's dev transform (compiler/locate.ts) writes it at every call site, since stack\n * positions in transformed modules aren't the author's lines. Attached here, not by a statement\n * that mentions the tag, so production builds don't keep it alive (the compiler checks that).\n */\nfunction withAt(html: Tag): Tag {\n const tags = new Map<string, Tag>();\n const at = (loc: string): Tag => {\n let located = tags.get(loc);\n if (located === undefined) {\n located = (strings, ...values) => {\n setLoc(strings, loc);\n return html(strings, ...values);\n };\n tags.set(loc, located);\n }\n return located;\n };\n return Object.assign(html, { at });\n}\n\n/** The template tag: `` html`<p>${s.text}</p>` ``. */\nexport const html: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult = DEV\n ? withAt(tag)\n : tag;\n\n/**\n * The SVG fragment tag: `` svg`<path d=${s.d} />` ``. Its top level is SVG content, so it\n * renders only inside an `<svg>` (or another SVG element) of an html template\n * (view/01-templates.md \"svg templates\"). A whole `<svg>` graphic is written with html.\n */\nexport const svg: (strings: TemplateStringsArray, ...values: unknown[]) => TemplateResult = DEV\n ? withAt(svgTag)\n : svgTag;\n\n/** Internal: what the template compiler (`@gyral/core/vite`) rewrites `html` calls into. */\nexport function compiled(template: TemplateObject, values: readonly unknown[]): TemplateResult {\n return { [SOURCE]: template, values };\n}\n\n/** Internal: what the template compiler rewrites `svg` calls into. */\nexport function compiledSvg(template: TemplateObject, values: readonly unknown[]): TemplateResult {\n svgTemplate(template);\n return { [SOURCE]: template, values };\n}\n\nexport function isTemplateResult(value: unknown): value is TemplateResult {\n return typeof value === 'object' && value !== null && SOURCE in value;\n}\n\n/** Internal: a result's source, compared by identity to skip `templateOf` on updates. */\nexport const sourceOf = (result: TemplateResult): readonly string[] | TemplateObject =>\n result[SOURCE];\n\n/**\n * The template object of a result: compiled results carry it; a runtime result's call site is\n * normalized once by `#prepare` (cached there, so compiled builds carry neither the preparer\n * nor its cache).\n */\nexport function templateOf(result: TemplateResult): TemplateObject {\n const source = result[SOURCE];\n return Array.isArray(source) ? prepare(source) : (source as TemplateObject);\n}\n"]}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser
3
+ * has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's
4
+ * `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.
5
+ */
6
+ export declare function trustedHTML(html: string): string;
@@ -0,0 +1,34 @@
1
+ // Trusted Types (view/01-templates.md "Instantiation", gyral-ei9): a document whose CSP says
2
+ // `require-trusted-types-for 'script'` refuses plain strings at HTML sinks such as `innerHTML`.
3
+ // The browser parses only two kinds of HTML for Gyral: a template's HTML, which is the author's
4
+ // own template strings (holes are markers, never values), and `raw()` markup, trusted by
5
+ // contract (view/02 "raw(html)"). Both go through one policy named `gyral`, created on first use
6
+ // where the browser has Trusted Types; an app allows it with `trusted-types gyral`. On first use
7
+ // rather than at import, so a policy that refuses the name fails where HTML is parsed, not when
8
+ // a module loads. A CSP whose `trusted-types` list leaves `gyral` out (with or without
9
+ // enforcement) makes `createPolicy` throw: Gyral then parses plain strings, as before Trusted
10
+ // Types, and warns in development; where Trusted Types are enforced the sink reports it.
11
+ import { DEV } from '#view-dev';
12
+ import { message } from './message.js';
13
+ const passThrough = { createHTML: (input) => input };
14
+ let policy;
15
+ /**
16
+ * `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser
17
+ * has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's
18
+ * `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.
19
+ */
20
+ export function trustedHTML(html) {
21
+ policy ??= create();
22
+ return policy.createHTML(html);
23
+ }
24
+ function create() {
25
+ try {
26
+ return (globalThis.trustedTypes?.createPolicy('gyral', passThrough) ?? passThrough);
27
+ }
28
+ catch (error) {
29
+ if (DEV)
30
+ console.warn(message(72), error);
31
+ return passThrough;
32
+ }
33
+ }
34
+ //# sourceMappingURL=trusted-html.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trusted-html.js","sourceRoot":"","sources":["../../src/view/trusted-html.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,gGAAgG;AAChG,gGAAgG;AAChG,yFAAyF;AACzF,iGAAiG;AACjG,iGAAiG;AACjG,gGAAgG;AAChG,uFAAuF;AACvF,8FAA8F;AAC9F,yFAAyF;AACzF,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAUvC,MAAM,WAAW,GAAW,EAAE,UAAU,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC;AAE7D,IAAI,MAA0B,CAAC;AAE/B;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,IAAY;IACtC,MAAM,KAAK,MAAM,EAAE,CAAC;IACpB,OAAO,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACjC,CAAC;AAED,SAAS,MAAM;IACb,IAAI,CAAC;QACH,OAAO,CACJ,UAA+C,CAAC,YAAY,EAAE,YAAY,CACzE,OAAO,EACP,WAAW,CACZ,IAAI,WAAW,CACjB,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,GAAG;YAAE,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;QAC1C,OAAO,WAAW,CAAC;IACrB,CAAC;AACH,CAAC","sourcesContent":["// Trusted Types (view/01-templates.md \"Instantiation\", gyral-ei9): a document whose CSP says\n// `require-trusted-types-for 'script'` refuses plain strings at HTML sinks such as `innerHTML`.\n// The browser parses only two kinds of HTML for Gyral: a template's HTML, which is the author's\n// own template strings (holes are markers, never values), and `raw()` markup, trusted by\n// contract (view/02 \"raw(html)\"). Both go through one policy named `gyral`, created on first use\n// where the browser has Trusted Types; an app allows it with `trusted-types gyral`. On first use\n// rather than at import, so a policy that refuses the name fails where HTML is parsed, not when\n// a module loads. A CSP whose `trusted-types` list leaves `gyral` out (with or without\n// enforcement) makes `createPolicy` throw: Gyral then parses plain strings, as before Trusted\n// Types, and warns in development; where Trusted Types are enforced the sink reports it.\nimport { DEV } from '#view-dev';\nimport { message } from './message.js';\n\ninterface Policy {\n createHTML(input: string): string;\n}\n\ninterface PolicyFactory {\n createPolicy(name: string, rules: Policy): Policy;\n}\n\nconst passThrough: Policy = { createHTML: (input) => input };\n\nlet policy: Policy | undefined;\n\n/**\n * `html` as an HTML sink accepts it: a `TrustedHTML` from the `gyral` policy where the browser\n * has Trusted Types, the string itself elsewhere. Typed as `string` because lib.dom's\n * `innerHTML` setter takes only strings; the browser stringifies a `TrustedHTML` to the same text.\n */\nexport function trustedHTML(html: string): string {\n policy ??= create();\n return policy.createHTML(html);\n}\n\nfunction create(): Policy {\n try {\n return (\n (globalThis as { trustedTypes?: PolicyFactory }).trustedTypes?.createPolicy(\n 'gyral',\n passThrough,\n ) ?? passThrough\n );\n } catch (error) {\n if (DEV) console.warn(message(72), error);\n return passThrough;\n }\n}\n"]}
package/dist/vite.d.ts CHANGED
@@ -1,18 +1,62 @@
1
- /** Every Lit package: resolve exactly one copy, even when Gyral is linked from elsewhere. */
2
- export declare const LIT_PACKAGES: readonly string[];
3
- /**
4
- * Lit modules that Gyral imports or re-exports. Pre-bundling them up front stops Vite from
5
- * discovering them mid-run, which reloads the page and fails the first browser test run.
6
- */
7
- export declare const LIT_PREBUNDLE: readonly string[];
1
+ import type { Plugin } from 'vite';
2
+ export interface TemplateCompilerOptions {
3
+ /**
4
+ * Module specifiers whose `html` (and `svg`) exports are the view layer's tags (default
5
+ * `DEFAULT_TEMPLATE_SOURCES`). An import matches when its specifier is listed, or when it
6
+ * resolves to the same module as a listed one; core's own view modules always match. A
7
+ * source other than '@gyral/core' must also export `compiled` (and `compiledSvg` when it
8
+ * exports `svg`).
9
+ */
10
+ readonly sources?: readonly string[];
11
+ /**
12
+ * Rule 7's extra check with parse5 (an optional peer dependency): `true` (default) uses
13
+ * 'parse5' when it is installed, a string names the module to load, `false` skips it.
14
+ */
15
+ readonly parse5?: boolean | string;
16
+ }
17
+ /** Where the preset looks for components and writes their typings (gyral-1zd.25). */
18
+ export interface ElementTypesOptions {
19
+ /** Source directories to scan, relative to the Vite root. Default `['src']`. */
20
+ readonly dirs?: readonly string[];
21
+ /** The declaration file to write, relative to the Vite root. Default `.gyral/elements.d.ts`. */
22
+ readonly out?: string;
23
+ }
8
24
  export interface GyralViteOptions {
9
- /** More modules to pre-bundle (e.g. 'lit/directives/unsafe-html.js'). */
25
+ /**
26
+ * Generated element typings (`.gyral/elements.d.ts`, see `ElementTypesOptions`), or `false`
27
+ * to write none. Default: on, scanning `src`.
28
+ */
29
+ readonly types?: ElementTypesOptions | false;
30
+ /** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */
10
31
  readonly optimize?: readonly string[];
32
+ /** Template compiler options (`vite build` only). */
33
+ readonly compiler?: TemplateCompilerOptions;
34
+ /**
35
+ * The app is never server-rendered: leave the hydration code out of the browser bundle
36
+ * (`gyralClientOnly()`, view/07-hydration.md "Client-only builds"). Default false.
37
+ */
38
+ readonly clientOnly?: boolean;
39
+ /**
40
+ * Automatic component loading (ADR 0016 addendum): every component defined under `include`
41
+ * gets a client module the build splits out, and a loader (`virtual:gyral/components`, added
42
+ * to the client build's input) imports a tag's module once that tag is in the page.
43
+ * `renderPage({ components })` then links exactly the components a page rendered, so pages
44
+ * need no client entry of their own and no side-effect imports. Default off.
45
+ */
46
+ readonly components?: boolean | ComponentsOptions;
47
+ }
48
+ export interface ComponentsOptions {
49
+ /** Directories (relative to Vite's root) whose modules' `define()` tags are found. Default `['src']`. */
50
+ readonly include?: readonly string[];
51
+ /**
52
+ * Tag → module (relative to Vite's root) for components the scan can't find: those defined
53
+ * through a wrapper such as `defineMemberForm({ tag: 'member-form' })`, which calls
54
+ * `define()` itself. Listed entries win over scanned ones.
55
+ */
56
+ readonly modules?: Readonly<Record<string, string>>;
11
57
  }
12
58
  export interface GyralViteConfig {
13
- readonly resolve: {
14
- readonly dedupe: string[];
15
- };
59
+ readonly plugins: Plugin[];
16
60
  readonly optimizeDeps: {
17
61
  readonly include: string[];
18
62
  };
@@ -21,5 +65,7 @@ export interface GyralViteConfig {
21
65
  * Spread into a Vite config, or into each Vitest project:
22
66
  *
23
67
  * export default defineConfig({ ...gyralVitePreset(), build: { … } });
68
+ *
69
+ * With plugins of your own, list both: `plugins: [...preset.plugins, mine()]`.
24
70
  */
25
71
  export declare function gyralVitePreset(options?: GyralViteOptions): GyralViteConfig;