@gyral/core 0.3.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 (381) hide show
  1. package/CHANGELOG.md +42 -0
  2. package/NOTICE +19 -0
  3. package/README.md +30 -5
  4. package/dist/call.d.ts +32 -0
  5. package/dist/call.js +63 -0
  6. package/dist/call.js.map +1 -0
  7. package/dist/children.d.ts +25 -3
  8. package/dist/children.js +18 -1
  9. package/dist/children.js.map +1 -1
  10. package/dist/cli/gyral-types.d.ts +2 -0
  11. package/dist/cli/gyral-types.js +23 -0
  12. package/dist/cli/gyral-types.js.map +1 -0
  13. package/dist/command.d.ts +54 -12
  14. package/dist/command.js +25 -11
  15. package/dist/command.js.map +1 -1
  16. package/dist/compiler/ast.d.ts +2 -0
  17. package/dist/compiler/ast.js +5 -1
  18. package/dist/compiler/ast.js.map +1 -1
  19. package/dist/compiler/compile.d.ts +5 -2
  20. package/dist/compiler/compile.js +36 -17
  21. package/dist/compiler/compile.js.map +1 -1
  22. package/dist/compiler/component-entries.d.ts +7 -0
  23. package/dist/compiler/component-entries.js +42 -0
  24. package/dist/compiler/component-entries.js.map +1 -0
  25. package/dist/compiler/components.d.ts +4 -0
  26. package/dist/compiler/components.js +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 +4 -0
  35. package/dist/compiler/hooks.js +144 -89
  36. package/dist/compiler/hooks.js.map +1 -1
  37. package/dist/compiler/loader-source.d.ts +14 -0
  38. package/dist/compiler/loader-source.js +86 -0
  39. package/dist/compiler/loader-source.js.map +1 -0
  40. package/dist/compiler/locate.d.ts +14 -0
  41. package/dist/compiler/locate.js +78 -0
  42. package/dist/compiler/locate.js.map +1 -0
  43. package/dist/compiler/parse5-check.d.ts +1 -1
  44. package/dist/compiler/parse5-check.js +8 -3
  45. package/dist/compiler/parse5-check.js.map +1 -1
  46. package/dist/compiler/prop-schemas.d.ts +4 -0
  47. package/dist/compiler/prop-schemas.js +108 -0
  48. package/dist/compiler/prop-schemas.js.map +1 -0
  49. package/dist/compiler/scan.d.ts +13 -3
  50. package/dist/compiler/scan.js +21 -13
  51. package/dist/compiler/scan.js.map +1 -1
  52. package/dist/compiler/scope.d.ts +8 -0
  53. package/dist/compiler/scope.js +116 -0
  54. package/dist/compiler/scope.js.map +1 -0
  55. package/dist/compiler/tag-map.d.ts +41 -0
  56. package/dist/compiler/tag-map.js +126 -0
  57. package/dist/compiler/tag-map.js.map +1 -0
  58. package/dist/components-ready.d.ts +7 -0
  59. package/dist/components-ready.js +19 -0
  60. package/dist/components-ready.js.map +1 -0
  61. package/dist/define.d.ts +13 -4
  62. package/dist/define.js +8 -12
  63. package/dist/define.js.map +1 -1
  64. package/dist/devtools-events.d.ts +8 -0
  65. package/dist/devtools-events.js.map +1 -1
  66. package/dist/devtools-off.d.ts +1 -0
  67. package/dist/devtools-off.js +1 -0
  68. package/dist/devtools-off.js.map +1 -1
  69. package/dist/devtools.d.ts +3 -0
  70. package/dist/devtools.js +14 -0
  71. package/dist/devtools.js.map +1 -1
  72. package/dist/drivers-scope.js.map +1 -1
  73. package/dist/element-internals.d.ts +1 -0
  74. package/dist/element-internals.js +11 -0
  75. package/dist/element-internals.js.map +1 -0
  76. package/dist/element-types.d.ts +6 -2
  77. package/dist/element-types.js.map +1 -1
  78. package/dist/element.js +80 -27
  79. package/dist/element.js.map +1 -1
  80. package/dist/error-view.d.ts +10 -0
  81. package/dist/error-view.js +30 -0
  82. package/dist/error-view.js.map +1 -0
  83. package/dist/errors.d.ts +21 -0
  84. package/dist/errors.js +47 -0
  85. package/dist/errors.js.map +1 -0
  86. package/dist/errors.json +289 -0
  87. package/dist/eslint/imports.d.ts +2 -0
  88. package/dist/eslint/imports.js +2 -2
  89. package/dist/eslint/imports.js.map +1 -1
  90. package/dist/eslint/index.d.ts +2 -1
  91. package/dist/eslint/index.js +11 -3
  92. package/dist/eslint/index.js.map +1 -1
  93. package/dist/eslint/template-rule.d.ts +1 -0
  94. package/dist/eslint/template-rule.js +15 -5
  95. package/dist/eslint/template-rule.js.map +1 -1
  96. package/dist/eslint/unused-intent-rule.d.ts +2 -0
  97. package/dist/eslint/unused-intent-rule.js +186 -0
  98. package/dist/eslint/unused-intent-rule.js.map +1 -0
  99. package/dist/features.d.ts +2 -2
  100. package/dist/features.js.map +1 -1
  101. package/dist/focus.d.ts +6 -0
  102. package/dist/focus.js +32 -2
  103. package/dist/focus.js.map +1 -1
  104. package/dist/form-associated.d.ts +46 -0
  105. package/dist/form-associated.js +77 -0
  106. package/dist/form-associated.js.map +1 -0
  107. package/dist/forms.d.ts +42 -30
  108. package/dist/forms.js +85 -41
  109. package/dist/forms.js.map +1 -1
  110. package/dist/frame-lane.d.ts +11 -0
  111. package/dist/frame-lane.js +28 -0
  112. package/dist/frame-lane.js.map +1 -0
  113. package/dist/head.d.ts +61 -0
  114. package/dist/head.js +85 -0
  115. package/dist/head.js.map +1 -0
  116. package/dist/host-model.d.ts +34 -5
  117. package/dist/host-model.js +146 -23
  118. package/dist/host-model.js.map +1 -1
  119. package/dist/hydration-client.js +2 -2
  120. package/dist/hydration-client.js.map +1 -1
  121. package/dist/hydration-loader.d.ts +13 -0
  122. package/dist/hydration-loader.js +58 -0
  123. package/dist/hydration-loader.js.map +1 -0
  124. package/dist/hydration-off.d.ts +8 -0
  125. package/dist/hydration-off.js +25 -0
  126. package/dist/hydration-off.js.map +1 -0
  127. package/dist/hydration.d.ts +0 -12
  128. package/dist/hydration.js +3 -52
  129. package/dist/hydration.js.map +1 -1
  130. package/dist/index.d.ts +20 -24
  131. package/dist/index.js +10 -19
  132. package/dist/index.js.map +1 -1
  133. package/dist/indexeddb-types.d.ts +97 -0
  134. package/dist/indexeddb-types.js +2 -0
  135. package/dist/indexeddb-types.js.map +1 -0
  136. package/dist/indexeddb.d.ts +5 -0
  137. package/dist/indexeddb.js +118 -0
  138. package/dist/indexeddb.js.map +1 -0
  139. package/dist/intent.d.ts +41 -19
  140. package/dist/intent.js +144 -106
  141. package/dist/intent.js.map +1 -1
  142. package/dist/internal/indexeddb-open.d.ts +8 -0
  143. package/dist/internal/indexeddb-open.js +96 -0
  144. package/dist/internal/indexeddb-open.js.map +1 -0
  145. package/dist/internal/indexeddb-transaction.d.ts +4 -0
  146. package/dist/internal/indexeddb-transaction.js +134 -0
  147. package/dist/internal/indexeddb-transaction.js.map +1 -0
  148. package/dist/internal/interpreter.d.ts +12 -4
  149. package/dist/internal/interpreter.js +36 -48
  150. package/dist/internal/interpreter.js.map +1 -1
  151. package/dist/internal/token.d.ts +1 -0
  152. package/dist/internal/token.js +7 -0
  153. package/dist/internal/token.js.map +1 -0
  154. package/dist/internal.d.ts +20 -0
  155. package/dist/internal.js +22 -0
  156. package/dist/internal.js.map +1 -0
  157. package/dist/invoker-fallback-used.d.ts +4 -0
  158. package/dist/invoker-fallback-used.js +10 -0
  159. package/dist/invoker-fallback-used.js.map +1 -0
  160. package/dist/invoker-fallback.d.ts +4 -0
  161. package/dist/invoker-fallback.js +15 -0
  162. package/dist/invoker-fallback.js.map +1 -0
  163. package/dist/light-dom.d.ts +1 -1
  164. package/dist/light-dom.js.map +1 -1
  165. package/dist/prop.d.ts +30 -7
  166. package/dist/prop.js +19 -0
  167. package/dist/prop.js.map +1 -1
  168. package/dist/props.d.ts +8 -3
  169. package/dist/props.js +22 -15
  170. package/dist/props.js.map +1 -1
  171. package/dist/retry.d.ts +15 -0
  172. package/dist/retry.js +48 -0
  173. package/dist/retry.js.map +1 -0
  174. package/dist/scheduler.d.ts +7 -3
  175. package/dist/scheduler.js +38 -56
  176. package/dist/scheduler.js.map +1 -1
  177. package/dist/script-json.d.ts +2 -0
  178. package/dist/script-json.js +13 -0
  179. package/dist/script-json.js.map +1 -0
  180. package/dist/server-component.d.ts +1 -1
  181. package/dist/server-component.js +45 -14
  182. package/dist/server-component.js.map +1 -1
  183. package/dist/server.d.ts +8 -2
  184. package/dist/server.js +11 -2
  185. package/dist/server.js.map +1 -1
  186. package/dist/settled.d.ts +4 -3
  187. package/dist/settled.js +48 -26
  188. package/dist/settled.js.map +1 -1
  189. package/dist/spec-features-used.d.ts +21 -0
  190. package/dist/spec-features-used.js +50 -0
  191. package/dist/spec-features-used.js.map +1 -0
  192. package/dist/spec-features.d.ts +28 -0
  193. package/dist/spec-features.js +42 -0
  194. package/dist/spec-features.js.map +1 -0
  195. package/dist/states.d.ts +3 -5
  196. package/dist/states.js +22 -8
  197. package/dist/states.js.map +1 -1
  198. package/dist/storage.d.ts +69 -0
  199. package/dist/storage.js +158 -0
  200. package/dist/storage.js.map +1 -0
  201. package/dist/store-binding.js +2 -2
  202. package/dist/store-binding.js.map +1 -1
  203. package/dist/store-scope.d.ts +2 -4
  204. package/dist/store-scope.js +6 -16
  205. package/dist/store-scope.js.map +1 -1
  206. package/dist/store.js +36 -8
  207. package/dist/store.js.map +1 -1
  208. package/dist/subscription.d.ts +35 -0
  209. package/dist/subscription.js +74 -0
  210. package/dist/subscription.js.map +1 -0
  211. package/dist/subscriptions.d.ts +26 -0
  212. package/dist/subscriptions.js +98 -0
  213. package/dist/subscriptions.js.map +1 -0
  214. package/dist/transitions.d.ts +4 -5
  215. package/dist/transitions.js +10 -4
  216. package/dist/transitions.js.map +1 -1
  217. package/dist/types.d.ts +124 -27
  218. package/dist/types.js.map +1 -1
  219. package/dist/use-dialogs.d.ts +2 -0
  220. package/dist/use-dialogs.js +9 -0
  221. package/dist/use-dialogs.js.map +1 -0
  222. package/dist/use-disposal.d.ts +2 -0
  223. package/dist/use-disposal.js +9 -0
  224. package/dist/use-disposal.js.map +1 -0
  225. package/dist/use-error-view.d.ts +2 -0
  226. package/dist/use-error-view.js +9 -0
  227. package/dist/use-error-view.js.map +1 -0
  228. package/dist/use-errored.d.ts +2 -0
  229. package/dist/use-errored.js +9 -0
  230. package/dist/use-errored.js.map +1 -0
  231. package/dist/use-form-associated.d.ts +2 -0
  232. package/dist/use-form-associated.js +7 -0
  233. package/dist/use-form-associated.js.map +1 -0
  234. package/dist/use-frame-lane.d.ts +2 -0
  235. package/dist/use-frame-lane.js +10 -0
  236. package/dist/use-frame-lane.js.map +1 -0
  237. package/dist/use-invokers.d.ts +2 -0
  238. package/dist/use-invokers.js +10 -0
  239. package/dist/use-invokers.js.map +1 -0
  240. package/dist/use-states.d.ts +2 -0
  241. package/dist/use-states.js +10 -0
  242. package/dist/use-states.js.map +1 -0
  243. package/dist/use-subscriptions.d.ts +2 -0
  244. package/dist/use-subscriptions.js +10 -0
  245. package/dist/use-subscriptions.js.map +1 -0
  246. package/dist/use-transitions.d.ts +2 -0
  247. package/dist/use-transitions.js +10 -0
  248. package/dist/use-transitions.js.map +1 -0
  249. package/dist/view/attributes.d.ts +5 -0
  250. package/dist/view/attributes.js +5 -0
  251. package/dist/view/attributes.js.map +1 -1
  252. package/dist/view/compiled.d.ts +1 -1
  253. package/dist/view/compiled.js +1 -1
  254. package/dist/view/compiled.js.map +1 -1
  255. package/dist/view/index.d.ts +9 -4
  256. package/dist/view/index.js +9 -3
  257. package/dist/view/index.js.map +1 -1
  258. package/dist/view/loc.d.ts +9 -0
  259. package/dist/view/loc.js +50 -0
  260. package/dist/view/loc.js.map +1 -0
  261. package/dist/view/message.d.ts +17 -0
  262. package/dist/view/message.js +40 -0
  263. package/dist/view/message.js.map +1 -0
  264. package/dist/view/messages.d.ts +43 -0
  265. package/dist/view/messages.js +84 -0
  266. package/dist/view/messages.js.map +1 -0
  267. package/dist/view/normalize/check.d.ts +5 -2
  268. package/dist/view/normalize/check.js +6 -3
  269. package/dist/view/normalize/check.js.map +1 -1
  270. package/dist/view/normalize/emit.d.ts +2 -0
  271. package/dist/view/normalize/emit.js +40 -11
  272. package/dist/view/normalize/emit.js.map +1 -1
  273. package/dist/view/normalize/errors.js +1 -1
  274. package/dist/view/normalize/errors.js.map +1 -1
  275. package/dist/view/normalize/id.d.ts +5 -2
  276. package/dist/view/normalize/id.js +9 -2
  277. package/dist/view/normalize/id.js.map +1 -1
  278. package/dist/view/normalize/normalize.d.ts +7 -4
  279. package/dist/view/normalize/normalize.js +15 -9
  280. package/dist/view/normalize/normalize.js.map +1 -1
  281. package/dist/view/normalize/rules.d.ts +9 -0
  282. package/dist/view/normalize/rules.js +35 -5
  283. package/dist/view/normalize/rules.js.map +1 -1
  284. package/dist/view/normalize/svg.d.ts +14 -0
  285. package/dist/view/normalize/svg.js +40 -0
  286. package/dist/view/normalize/svg.js.map +1 -0
  287. package/dist/view/normalize/tokens.d.ts +5 -1
  288. package/dist/view/normalize/tokens.js.map +1 -1
  289. package/dist/view/normalize/tree.d.ts +8 -2
  290. package/dist/view/normalize/tree.js +58 -13
  291. package/dist/view/normalize/tree.js.map +1 -1
  292. package/dist/view/normalize/types.d.ts +24 -4
  293. package/dist/view/normalize/types.js +4 -1
  294. package/dist/view/normalize/types.js.map +1 -1
  295. package/dist/view/normalize/whitespace.js +4 -3
  296. package/dist/view/normalize/whitespace.js.map +1 -1
  297. package/dist/view/prepare-stub.js +2 -2
  298. package/dist/view/prepare-stub.js.map +1 -1
  299. package/dist/view/prepare.d.ts +5 -2
  300. package/dist/view/prepare.js +9 -3
  301. package/dist/view/prepare.js.map +1 -1
  302. package/dist/view/registry.d.ts +15 -0
  303. package/dist/view/registry.js +10 -2
  304. package/dist/view/registry.js.map +1 -1
  305. package/dist/view/render/adopt-attr.js +7 -1
  306. package/dist/view/render/adopt-attr.js.map +1 -1
  307. package/dist/view/render/adopt.js +21 -4
  308. package/dist/view/render/adopt.js.map +1 -1
  309. package/dist/view/render/attr-parts.d.ts +12 -1
  310. package/dist/view/render/attr-parts.js +38 -5
  311. package/dist/view/render/attr-parts.js.map +1 -1
  312. package/dist/view/render/child-part.js +5 -2
  313. package/dist/view/render/child-part.js.map +1 -1
  314. package/dist/view/render/dispose.d.ts +3 -0
  315. package/dist/view/render/dispose.js +76 -0
  316. package/dist/view/render/dispose.js.map +1 -0
  317. package/dist/view/render/hook-part.d.ts +3 -1
  318. package/dist/view/render/hook-part.js +21 -5
  319. package/dist/view/render/hook-part.js.map +1 -1
  320. package/dist/view/render/hook-run.d.ts +2 -0
  321. package/dist/view/render/hook-run.js +72 -0
  322. package/dist/view/render/hook-run.js.map +1 -0
  323. package/dist/view/render/hooks.d.ts +73 -5
  324. package/dist/view/render/hooks.js +79 -17
  325. package/dist/view/render/hooks.js.map +1 -1
  326. package/dist/view/render/hydrate.js +2 -2
  327. package/dist/view/render/hydrate.js.map +1 -1
  328. package/dist/view/render/keyed.d.ts +6 -0
  329. package/dist/view/render/keyed.js +15 -0
  330. package/dist/view/render/keyed.js.map +1 -0
  331. package/dist/view/render/mismatch.js +5 -3
  332. package/dist/view/render/mismatch.js.map +1 -1
  333. package/dist/view/render/modal.d.ts +3 -0
  334. package/dist/view/render/modal.js +39 -0
  335. package/dist/view/render/modal.js.map +1 -0
  336. package/dist/view/render/raw.d.ts +4 -1
  337. package/dist/view/render/raw.js +6 -2
  338. package/dist/view/render/raw.js.map +1 -1
  339. package/dist/view/render/render.d.ts +4 -1
  340. package/dist/view/render/render.js +17 -12
  341. package/dist/view/render/render.js.map +1 -1
  342. package/dist/view/render/toggles.d.ts +6 -0
  343. package/dist/view/render/toggles.js +6 -0
  344. package/dist/view/render/toggles.js.map +1 -0
  345. package/dist/view/render/warn.d.ts +14 -0
  346. package/dist/view/render/warn.js +45 -0
  347. package/dist/view/render/warn.js.map +1 -1
  348. package/dist/view/server/component.d.ts +6 -3
  349. package/dist/view/server/component.js +29 -7
  350. package/dist/view/server/component.js.map +1 -1
  351. package/dist/view/server/index.d.ts +20 -0
  352. package/dist/view/server/index.js +12 -4
  353. package/dist/view/server/index.js.map +1 -1
  354. package/dist/view/server/tags.d.ts +13 -2
  355. package/dist/view/server/tags.js +13 -2
  356. package/dist/view/server/tags.js.map +1 -1
  357. package/dist/view/server/values.d.ts +2 -0
  358. package/dist/view/server/values.js +8 -0
  359. package/dist/view/server/values.js.map +1 -1
  360. package/dist/view/server/writer.d.ts +9 -4
  361. package/dist/view/server/writer.js +33 -18
  362. package/dist/view/server/writer.js.map +1 -1
  363. package/dist/view/template-element.d.ts +7 -0
  364. package/dist/view/template-element.js +25 -5
  365. package/dist/view/template-element.js.map +1 -1
  366. package/dist/view/template.d.ts +10 -2
  367. package/dist/view/template.js +62 -8
  368. package/dist/view/template.js.map +1 -1
  369. package/dist/view/trusted-html.d.ts +6 -0
  370. package/dist/view/trusted-html.js +34 -0
  371. package/dist/view/trusted-html.js.map +1 -0
  372. package/dist/vite.d.ts +38 -31
  373. package/dist/vite.js +198 -31
  374. package/dist/vite.js.map +1 -1
  375. package/package.json +34 -3
  376. package/dist/hooks/labelled-by.d.ts +0 -13
  377. package/dist/hooks/labelled-by.js +0 -51
  378. package/dist/hooks/labelled-by.js.map +0 -1
  379. package/dist/random.d.ts +0 -13
  380. package/dist/random.js +0 -19
  381. package/dist/random.js.map +0 -1
@@ -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,10 +1,11 @@
1
1
  import type { Plugin } from 'vite';
2
2
  export interface TemplateCompilerOptions {
3
3
  /**
4
- * Module specifiers whose `html` export is the view layer's tag (default
4
+ * Module specifiers whose `html` (and `svg`) exports are the view layer's tags (default
5
5
  * `DEFAULT_TEMPLATE_SOURCES`). An import matches when its specifier is listed, or when it
6
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`.
7
+ * source other than '@gyral/core' must also export `compiled` (and `compiledSvg` when it
8
+ * exports `svg`).
8
9
  */
9
10
  readonly sources?: readonly string[];
10
11
  /**
@@ -13,43 +14,49 @@ export interface TemplateCompilerOptions {
13
14
  */
14
15
  readonly parse5?: boolean | string;
15
16
  }
16
- /** Where the view layer's `html` comes from: core's main entry (ADR 0018, Phase 3). */
17
- export declare const DEFAULT_TEMPLATE_SOURCES: readonly string[];
18
- /** The resolve condition that maps core's `#prepare` to its stub (ADR 0017's mechanism). */
19
- export declare const COMPILED_CONDITION = "gyral-compiled";
20
- /** Vite 8's default resolve conditions (`defaultClientConditions`, server ones without browser). */
21
- export declare const CLIENT_CONDITIONS: readonly string[];
22
- export declare const SERVER_CONDITIONS: readonly string[];
23
- /** The template compiler alone (`gyralVitePreset()` includes it). */
24
- export declare function gyralTemplateCompiler(options?: TemplateCompilerOptions): Plugin;
25
- /** Gyral's packages: the dev server runs them through Vite, never Node (view/06). */
26
- export declare const GYRAL_PACKAGES: RegExp;
27
- /**
28
- * The app's direct dependencies that depend on a Gyral package (a design system, say). They
29
- * import @gyral/core, so they must share the copy the dev server runs.
30
- */
31
- export declare function gyralDependents(root: string): string[];
32
- /**
33
- * Development output from the dev server's SSR (`ssrLoadModule`, view/06 "Development
34
- * markers"). Vite externalizes installed packages there and Node imports them itself, resolving
35
- * core's `#view-dev` without the `development` condition (Vite's `externalConditions` only pick
36
- * the entry file, not the package's own imports), so the server rendered production output.
37
- * In serve mode this plugin keeps Gyral's packages, and the app's dependencies that use them,
38
- * out of externalization in server environments: Vite resolves them with its conditions
39
- * (`development` in dev), and they all share one copy of core. `vite build` is unaffected.
40
- */
41
- export declare function gyralDevServer(): Plugin;
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
+ }
42
24
  export interface GyralViteOptions {
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;
43
30
  /** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */
44
31
  readonly optimize?: readonly string[];
45
32
  /** Template compiler options (`vite build` only). */
46
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>>;
47
57
  }
48
58
  export interface GyralViteConfig {
49
59
  readonly plugins: Plugin[];
50
- readonly resolve: {
51
- readonly dedupe: string[];
52
- };
53
60
  readonly optimizeDeps: {
54
61
  readonly include: string[];
55
62
  };
package/dist/vite.js CHANGED
@@ -6,37 +6,42 @@
6
6
  // runner. The compiler is a plugin applied in `vite build` only, so dev servers and test runs
7
7
  // keep the runtime template path; its implementation (./compiler/) loads on the first build
8
8
  // hook, with `require` (Node loads ES modules with it too): a module runner that loaded this
9
- // file may be closed by then, and would reject a dynamic import().
9
+ // file may be closed by then, and would reject a dynamic import(). Public: the preset,
10
+ // gyralTemplateCompiler and gyralClientOnly (docs/references/public-api-0.3.1.md); the other
11
+ // plugins and constants here are internal.
10
12
  import { readFileSync } from 'node:fs';
11
13
  import { createRequire } from 'node:module';
12
14
  import { dirname, join, resolve } from 'node:path';
13
15
  import { fileURLToPath } from 'node:url';
14
16
  /** Where the view layer's `html` comes from: core's main entry (ADR 0018, Phase 3). */
15
- export const DEFAULT_TEMPLATE_SOURCES = ['@gyral/core'];
17
+ const DEFAULT_TEMPLATE_SOURCES = ['@gyral/core'];
16
18
  /** The resolve condition that maps core's `#prepare` to its stub (ADR 0017's mechanism). */
17
- export const COMPILED_CONDITION = 'gyral-compiled';
19
+ const COMPILED_CONDITION = 'gyral-compiled';
20
+ /** The client's resolve condition in client-only builds (view/07 "Client-only builds"). */
21
+ const CLIENT_ONLY_CONDITION = 'gyral-client-only';
18
22
  /** Vite 8's default resolve conditions (`defaultClientConditions`, server ones without browser). */
19
- export const CLIENT_CONDITIONS = ['module', 'browser', 'development|production'];
20
- export const SERVER_CONDITIONS = ['module', 'node', 'development|production'];
23
+ const CLIENT_CONDITIONS = ['module', 'browser', 'development|production'];
24
+ const SERVER_CONDITIONS = ['module', 'node', 'development|production'];
21
25
  /**
22
- * Adds the `gyral-compiled` condition to an environment, on top of the app's conditions or
23
- * Vite's defaults: Vite replaces the defaults when a config names any condition.
26
+ * Adds `condition` (default `gyral-compiled`) to an environment, on top of the app's
27
+ * conditions or Vite's defaults: Vite replaces the defaults when a config names any condition.
28
+ * `clientOnly`: only to environments that build for the browser.
24
29
  */
25
- function addCondition(name, config, env) {
30
+ function addCondition(name, config, env, condition = COMPILED_CONDITION, clientOnly = false) {
26
31
  const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');
27
32
  const client = consumer === 'client' || env.isSsrTargetWebworker === true;
33
+ if (clientOnly && consumer !== 'client')
34
+ return;
28
35
  const current = config.resolve?.conditions ?? (client ? CLIENT_CONDITIONS : SERVER_CONDITIONS);
29
- if (!current.includes(COMPILED_CONDITION)) {
30
- config.resolve = { ...config.resolve, conditions: [...current, COMPILED_CONDITION] };
36
+ if (!current.includes(condition)) {
37
+ config.resolve = { ...config.resolve, conditions: [...current, condition] };
31
38
  }
32
39
  }
33
- /**
34
- * The compiler's hooks. From core's TypeScript source (this workspace, `link:` checkouts) they
35
- * load through Vite's module runner, as a vite.config.ts would; from the published package,
36
- * with require.
37
- */
38
- async function loadHooks(options) {
39
- const settings = {
40
+ /** The compiled entry of this copy of core, next to this module. */
41
+ const OWN_COMPILED = fileURLToPath(new URL(import.meta.url.endsWith('.ts') ? './view/compiled.ts' : './view/compiled.js', import.meta.url));
42
+ /** The settings both plugins pass to their lazily loaded implementation. */
43
+ function settingsOf(options) {
44
+ return {
40
45
  sources: options.sources ?? DEFAULT_TEMPLATE_SOURCES,
41
46
  parse5: options.parse5 === false
42
47
  ? undefined
@@ -44,21 +49,32 @@ async function loadHooks(options) {
44
49
  ? options.parse5
45
50
  : 'parse5',
46
51
  };
52
+ }
53
+ /**
54
+ * A module of ./compiler/. From core's TypeScript source (this workspace, `link:` checkouts) it
55
+ * loads through Vite's module runner, as a vite.config.ts would; from the published package,
56
+ * with require.
57
+ */
58
+ async function loadCompiler(name) {
47
59
  const require = createRequire(import.meta.url);
48
- if (!import.meta.url.endsWith('.ts')) {
49
- return require('./compiler/hooks.js').createCompiler(settings);
50
- }
60
+ if (!import.meta.url.endsWith('.ts'))
61
+ return require(`./compiler/${name}.js`);
51
62
  const { runnerImport } = require('vite');
52
63
  const nodeEnv = process.env['NODE_ENV']; // the runner sets it when unset; the build owns it
53
- const { module } = await runnerImport(fileURLToPath(new URL('./compiler/hooks.ts', import.meta.url)), { configFile: false, logLevel: 'silent' });
64
+ const { module } = await runnerImport(fileURLToPath(new URL(`./compiler/${name}.ts`, import.meta.url)), { configFile: false, logLevel: 'silent' });
54
65
  if (nodeEnv === undefined)
55
66
  delete process.env['NODE_ENV'];
56
67
  else
57
68
  process.env['NODE_ENV'] = nodeEnv;
58
- return module.createCompiler(settings);
69
+ return module;
70
+ }
71
+ /** The compiler's hooks (`vite build`). */
72
+ async function loadHooks(options) {
73
+ const hooks = await loadCompiler('hooks');
74
+ return hooks.createCompiler({ ...settingsOf(options), ownEntry: OWN_COMPILED });
59
75
  }
60
76
  /** The template compiler alone (`gyralVitePreset()` includes it). */
61
- export function gyralTemplateCompiler(options = {}) {
77
+ function gyralTemplateCompiler(options = {}) {
62
78
  let hooks;
63
79
  const ready = () => {
64
80
  if (hooks === undefined)
@@ -77,8 +93,20 @@ export function gyralTemplateCompiler(options = {}) {
77
93
  buildStart(input) {
78
94
  return ready().buildStart.call(this, input);
79
95
  },
96
+ // The registration modules of spec-field features (./compiler/features.ts).
97
+ resolveId(source, importer, opts) {
98
+ return ready().resolveId.call(this, source, importer, opts);
99
+ },
100
+ load(id, opts) {
101
+ return ready().load.call(this, id, opts);
102
+ },
80
103
  transform: {
81
- filter: { id: /\.[cm]?[jt]sx?$/, code: 'html' },
104
+ // Modules naming a template tag (html or svg; core's template module names both), or a
105
+ // spec field whose machinery the build adds only when named (view/05).
106
+ filter: {
107
+ id: /\.[cm]?[jt]sx?$/,
108
+ code: /html|svg|viewTransition|renderOnFrame|states|formAssociated|subscriptions|\.value\s*\(/,
109
+ },
82
110
  handler(code, id, opts) {
83
111
  return ready().transform.call(this, code, id, opts);
84
112
  },
@@ -88,8 +116,43 @@ export function gyralTemplateCompiler(options = {}) {
88
116
  },
89
117
  };
90
118
  }
91
- /** Gyral's packages: the dev server runs them through Vite, never Node (view/06). */
92
- export const GYRAL_PACKAGES = /^@gyral\//;
119
+ /**
120
+ * Development source locations (view/01-templates.md "Source locations"): in `vite serve` (the
121
+ * dev server, Vitest) each html`…` and svg`…` call site of the template sources tells the
122
+ * runtime where it was written, so template rule errors and hydration mismatches name
123
+ * `file:line:col` (./compiler/locate.ts, loaded on the first hook). `vite build` compiles
124
+ * templates instead.
125
+ */
126
+ function gyralTemplateLocations(options = {}) {
127
+ let hooks;
128
+ const ready = () => {
129
+ if (hooks === undefined)
130
+ throw new Error('gyral: the template locator is not loaded yet');
131
+ return hooks;
132
+ };
133
+ return {
134
+ name: 'gyral:template-locations',
135
+ enforce: 'pre',
136
+ apply: 'serve',
137
+ async configResolved(config) {
138
+ const locate = await loadCompiler('locate');
139
+ hooks = locate.createLocator(settingsOf(options).sources);
140
+ await hooks.configResolved.call(this, config);
141
+ },
142
+ transform: {
143
+ // Modules naming a template tag (html or svg), as the compiler's filter.
144
+ filter: { id: /\.[cm]?[jt]sx?$/, code: /html|svg/ },
145
+ handler(code, id, opts) {
146
+ return ready().transform.call(this, code, id, opts);
147
+ },
148
+ },
149
+ };
150
+ }
151
+ /**
152
+ * Gyral's packages: the dev server runs them through Vite, never Node (view/06). The feature
153
+ * scan's scope (./compiler/scope.ts) uses the same pattern.
154
+ */
155
+ const GYRAL_PACKAGES = /^@gyral\//;
93
156
  function manifest(file) {
94
157
  try {
95
158
  return JSON.parse(readFileSync(file, 'utf8'));
@@ -108,9 +171,9 @@ function installed(root, name) {
108
171
  }
109
172
  /**
110
173
  * The app's direct dependencies that depend on a Gyral package (a design system, say). They
111
- * import @gyral/core, so they must share the copy the dev server runs.
174
+ * import `@gyral/core`, so they must share the copy the dev server runs.
112
175
  */
113
- export function gyralDependents(root) {
176
+ function gyralDependents(root) {
114
177
  const app = manifest(join(root, 'package.json'));
115
178
  const names = Object.keys({ ...app?.dependencies, ...app?.devDependencies });
116
179
  return names.filter((name) => {
@@ -129,7 +192,7 @@ export function gyralDependents(root) {
129
192
  * out of externalization in server environments: Vite resolves them with its conditions
130
193
  * (`development` in dev), and they all share one copy of core. `vite build` is unaffected.
131
194
  */
132
- export function gyralDevServer() {
195
+ function gyralDevSsr() {
133
196
  let root = process.cwd();
134
197
  return {
135
198
  name: 'gyral:dev-server',
@@ -145,6 +208,71 @@ export function gyralDevServer() {
145
208
  },
146
209
  };
147
210
  }
211
+ /**
212
+ * Client-only builds (view/07-hydration.md "Client-only builds", gyral-c5d.11), for apps no
213
+ * server renders: the browser environment resolves core with the `gyral-client-only`
214
+ * condition, so the bundle carries no hydration code (no seed reading, no hydration chunk and
215
+ * its import()), and in `vite build` the invoker-command fallback only when a module that can
216
+ * affect Gyral components (the app's own, or a package that reaches a Gyral package) may use
217
+ * command intents (./compiler/features.ts). With no other import(), Vite's preload helper goes
218
+ * too. Server-rendered markup met anyway renders fresh (development warns). Dev servers and
219
+ * test runs get the condition too, and always keep the invoker fallback.
220
+ */
221
+ function gyralClientOnly() {
222
+ let hooks;
223
+ let root = process.cwd();
224
+ return {
225
+ name: 'gyral:client-only',
226
+ enforce: 'pre',
227
+ configEnvironment(name, config, env) {
228
+ addCondition(name, config, env, CLIENT_ONLY_CONDITION, true);
229
+ },
230
+ async configResolved(config) {
231
+ root = config.root;
232
+ if (config.command !== 'build')
233
+ return;
234
+ const features = await loadCompiler('features');
235
+ hooks = features.createFeatures(['invokers'], OWN_COMPILED);
236
+ },
237
+ async buildStart() {
238
+ await hooks?.buildStart((source, importer) => this.resolve(source, importer), root);
239
+ },
240
+ resolveId(source) {
241
+ return hooks?.resolveId(source) ?? null;
242
+ },
243
+ load(id) {
244
+ return hooks?.load(id) ?? null;
245
+ },
246
+ transform: {
247
+ // features.ts FEATURE_HINTS.invokers: any import or export may reach `raw`.
248
+ filter: { id: /\.[cm]?[jt]sx?$/, code: /data-intent-on|command|raw|import|export/i },
249
+ async handler(code, id) {
250
+ if (hooks === undefined || this.environment.config.consumer !== 'client')
251
+ return null;
252
+ const imports = await hooks.inject(code, id, {
253
+ parse: (text, lang) => this.parse(text, { lang }),
254
+ resolve: (source, importer) => this.resolve(source, importer),
255
+ });
256
+ // Appended after the last line: no code moves, so the incoming source map holds.
257
+ return imports === '' ? null : { code: code + imports, map: null };
258
+ },
259
+ },
260
+ };
261
+ }
262
+ /**
263
+ * Writes `HTMLElementTagNameMap` entries for every exported `define()` component (a
264
+ * `.gyral/elements.d.ts` to gitignore and include in tsconfig) at the start of a build, dev
265
+ * server or test run, and again when a source file changes. ./compiler/tag-map imports Node
266
+ * built-ins only, so Node's require loads it, from TypeScript source too: no module runner,
267
+ * which may be closed by the time a build starts (see loadCompiler).
268
+ */
269
+ function gyralElementTypes(options) {
270
+ const source = import.meta.url.endsWith('.ts')
271
+ ? './compiler/tag-map.ts'
272
+ : './compiler/tag-map.js';
273
+ const tagMap = createRequire(import.meta.url)(source);
274
+ return tagMap.elementTypesPlugin(options);
275
+ }
148
276
  /**
149
277
  * Spread into a Vite config, or into each Vitest project:
150
278
  *
@@ -154,9 +282,48 @@ export function gyralDevServer() {
154
282
  */
155
283
  export function gyralVitePreset(options = {}) {
156
284
  return {
157
- plugins: [gyralTemplateCompiler(options.compiler), gyralDevServer()],
158
- resolve: { dedupe: [] },
285
+ plugins: [
286
+ // Before the compiler: its feature scan reads the author's templates, not compiled ones.
287
+ ...(options.clientOnly === true ? [gyralClientOnly()] : []),
288
+ gyralTemplateCompiler(options.compiler),
289
+ gyralTemplateLocations(options.compiler),
290
+ gyralDevSsr(),
291
+ ...(options.components === undefined || options.components === false
292
+ ? []
293
+ : [gyralComponents(options.components === true ? {} : options.components)]),
294
+ ...(options.types === false ? [] : [gyralElementTypes(options.types ?? {})]),
295
+ ],
159
296
  optimizeDeps: { include: [...new Set(options.optimize ?? [])] },
160
297
  };
161
298
  }
299
+ /**
300
+ * Automatic component loading (`gyralVitePreset({ components })`): a shell whose hooks run
301
+ * ./compiler/components.ts, loaded on the first hook (`config`) like the compiler.
302
+ */
303
+ function gyralComponents(options) {
304
+ let impl;
305
+ const run = (name) => function (...args) {
306
+ const hook = impl?.[name];
307
+ return hook?.call(this, ...args) ?? null;
308
+ };
309
+ const hook = (name) => run(name);
310
+ return {
311
+ name: 'gyral:components',
312
+ api: {
313
+ tags: () => impl?.api?.tags?.() ??
314
+ new Map(),
315
+ },
316
+ async config(...args) {
317
+ const components = await loadCompiler('components');
318
+ impl = components.createComponents(options);
319
+ return run('config').apply(this, args);
320
+ },
321
+ configResolved: hook('configResolved'),
322
+ buildStart: hook('buildStart'),
323
+ resolveId: hook('resolveId'),
324
+ load: hook('load'),
325
+ configureServer: hook('configureServer'),
326
+ generateBundle: hook('generateBundle'),
327
+ };
328
+ }
162
329
  //# sourceMappingURL=vite.js.map
package/dist/vite.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,0FAA0F;AAC1F,wFAAwF;AACxF,+FAA+F;AAC/F,0FAA0F;AAC1F,8FAA8F;AAC9F,4FAA4F;AAC5F,6FAA6F;AAC7F,mEAAmE;AACnE,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAmBzC,uFAAuF;AACvF,MAAM,CAAC,MAAM,wBAAwB,GAAsB,CAAC,aAAa,CAAC,CAAC;AAE3E,4FAA4F;AAC5F,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAC;AACnD,oGAAoG;AACpG,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,QAAQ,EAAE,SAAS,EAAE,wBAAwB,CAAC,CAAC;AACpG,MAAM,CAAC,MAAM,iBAAiB,GAAsB,CAAC,QAAQ,EAAE,MAAM,EAAE,wBAAwB,CAAC,CAAC;AAEjG;;;GAGG;AACH,SAAS,YAAY,CACnB,IAAY,EACZ,M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;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,UAA4B,EAAE;IAC5D,OAAO;QACL,OAAO,EAAE,CAAC,qBAAqB,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;QACpE,OAAO,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QACvB,YAAY,EAAE,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,EAAE;KAChE,CAAC;AACJ,CAAC","sourcesContent":["// Vite / Vitest settings every Gyral app needs (gyral-a7r, docs/references/consumer-setup.md):\n// the template compiler (view/01-templates.md \"Compiled\") and, in serve mode, development\n// output from the dev server's SSR (view/06-server.md \"Development markers\"). Only Node\n// built-ins are imported up front, so it loads from vite.config.ts and vitest.config.ts in any\n// way: bundled with the config, by Node from source (type stripping), or by a Vite module\n// runner. The compiler is a plugin applied in `vite build` only, so dev servers and test runs\n// keep the runtime template path; its implementation (./compiler/) loads on the first build\n// hook, with `require` (Node loads ES modules with it too): a module runner that loaded this\n// file may be closed by then, and would reject a dynamic import().\nimport { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ConfigEnv, EnvironmentOptions, Plugin } from 'vite';\nimport type { CompilerHooks } from './compiler/hooks.js';\n\nexport interface TemplateCompilerOptions {\n /**\n * Module specifiers whose `html` export is the view layer's tag (default\n * `DEFAULT_TEMPLATE_SOURCES`). An import matches when its specifier is listed, or when it\n * resolves to the same module as a listed one; core's own view modules always match. A\n * source other than '@gyral/core' must also export `compiled`.\n */\n readonly sources?: readonly string[];\n /**\n * Rule 7's extra check with parse5 (an optional peer dependency): `true` (default) uses\n * 'parse5' when it is installed, a string names the module to load, `false` skips it.\n */\n readonly parse5?: boolean | string;\n}\n\n/** Where the view layer's `html` comes from: core's main entry (ADR 0018, Phase 3). */\nexport const DEFAULT_TEMPLATE_SOURCES: readonly string[] = ['@gyral/core'];\n\n/** The resolve condition that maps core's `#prepare` to its stub (ADR 0017's mechanism). */\nexport const COMPILED_CONDITION = 'gyral-compiled';\n/** Vite 8's default resolve conditions (`defaultClientConditions`, server ones without browser). */\nexport const CLIENT_CONDITIONS: readonly string[] = ['module', 'browser', 'development|production'];\nexport const SERVER_CONDITIONS: readonly string[] = ['module', 'node', 'development|production'];\n\n/**\n * Adds the `gyral-compiled` condition to an environment, on top of the app's conditions or\n * Vite's defaults: Vite replaces the defaults when a config names any condition.\n */\nfunction addCondition(\n name: string,\n config: EnvironmentOptions,\n env: ConfigEnv & { isSsrTargetWebworker?: boolean },\n): void {\n const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');\n const client = consumer === 'client' || env.isSsrTargetWebworker === true;\n const current = config.resolve?.conditions ?? (client ? CLIENT_CONDITIONS : SERVER_CONDITIONS);\n if (!current.includes(COMPILED_CONDITION)) {\n config.resolve = { ...config.resolve, conditions: [...current, COMPILED_CONDITION] };\n }\n}\n\n/**\n * The compiler's hooks. From core's TypeScript source (this workspace, `link:` checkouts) they\n * load through Vite's module runner, as a vite.config.ts would; from the published package,\n * with require.\n */\nasync function loadHooks(options: TemplateCompilerOptions): Promise<CompilerHooks> {\n const settings = {\n sources: options.sources ?? DEFAULT_TEMPLATE_SOURCES,\n parse5:\n options.parse5 === false\n ? undefined\n : typeof options.parse5 === 'string'\n ? options.parse5\n : 'parse5',\n };\n const require = createRequire(import.meta.url);\n if (!import.meta.url.endsWith('.ts')) {\n return (require('./compiler/hooks.js') as typeof import('./compiler/hooks.js')).createCompiler(\n settings,\n );\n }\n const { runnerImport } = require('vite') as typeof import('vite');\n const nodeEnv = process.env['NODE_ENV']; // the runner sets it when unset; the build owns it\n const { module } = await runnerImport<typeof import('./compiler/hooks.js')>(\n fileURLToPath(new URL('./compiler/hooks.ts', import.meta.url)),\n { configFile: false, logLevel: 'silent' },\n );\n if (nodeEnv === undefined) delete process.env['NODE_ENV'];\n else process.env['NODE_ENV'] = nodeEnv;\n return module.createCompiler(settings);\n}\n\n/** The template compiler alone (`gyralVitePreset()` includes it). */\nexport function gyralTemplateCompiler(options: TemplateCompilerOptions = {}): Plugin {\n let hooks: CompilerHooks | undefined;\n const ready = (): CompilerHooks => {\n if (hooks === undefined) throw new Error('gyral: the template compiler is not loaded yet');\n return hooks;\n };\n return {\n name: 'gyral:template-compiler',\n enforce: 'pre',\n apply: 'build',\n configEnvironment: addCondition,\n async configResolved(config) {\n hooks = await loadHooks(options);\n await hooks.configResolved.call(this, config);\n },\n buildStart(input) {\n return ready().buildStart.call(this, input);\n },\n transform: {\n filter: { id: /\\.[cm]?[jt]sx?$/, code: 'html' },\n handler(code, id, opts) {\n return ready().transform.call(this, code, id, opts);\n },\n },\n generateBundle(output, bundle, isWrite) {\n return ready().generateBundle.call(this, output, bundle, isWrite);\n },\n };\n}\n\n/** Gyral's packages: the dev server runs them through Vite, never Node (view/06). */\nexport const GYRAL_PACKAGES = /^@gyral\\//;\n\ntype Manifest = Partial<Record<'dependencies' | 'devDependencies' | 'peerDependencies', object>>;\n\nfunction manifest(file: string): Manifest | undefined {\n try {\n return JSON.parse(readFileSync(file, 'utf8')) as Manifest;\n } catch {\n return undefined;\n }\n}\n\n/** The installed manifest of `name`, looked up from `root` the way Node does (no exports map). */\nfunction installed(root: string, name: string): Manifest | undefined {\n for (let dir = root; ; dir = dirname(dir)) {\n const found = manifest(join(dir, 'node_modules', name, 'package.json'));\n if (found !== undefined || dirname(dir) === dir) return found;\n }\n}\n\n/**\n * The app's direct dependencies that depend on a Gyral package (a design system, say). They\n * import @gyral/core, so they must share the copy the dev server runs.\n */\nexport function gyralDependents(root: string): string[] {\n const app = manifest(join(root, 'package.json'));\n const names = Object.keys({ ...app?.dependencies, ...app?.devDependencies });\n return names.filter((name) => {\n if (GYRAL_PACKAGES.test(name)) return false;\n const dep = installed(root, name);\n return Object.keys({ ...dep?.dependencies, ...dep?.peerDependencies }).some((d) =>\n GYRAL_PACKAGES.test(d),\n );\n });\n}\n\n/**\n * Development output from the dev server's SSR (`ssrLoadModule`, view/06 \"Development\n * markers\"). Vite externalizes installed packages there and Node imports them itself, resolving\n * core's `#view-dev` without the `development` condition (Vite's `externalConditions` only pick\n * the entry file, not the package's own imports), so the server rendered production output.\n * In serve mode this plugin keeps Gyral's packages, and the app's dependencies that use them,\n * out of externalization in server environments: Vite resolves them with its conditions\n * (`development` in dev), and they all share one copy of core. `vite build` is unaffected.\n */\nexport function gyralDevServer(): Plugin {\n let root = process.cwd();\n return {\n name: 'gyral:dev-server',\n apply: 'serve',\n config(config) {\n root = resolve(config.root ?? process.cwd());\n },\n configEnvironment(name, config) {\n const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');\n if (consumer === 'client') return undefined;\n return { resolve: { noExternal: [GYRAL_PACKAGES, ...gyralDependents(root)] } };\n },\n };\n}\n\nexport interface GyralViteOptions {\n /** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */\n readonly optimize?: readonly string[];\n /** Template compiler options (`vite build` only). */\n readonly compiler?: TemplateCompilerOptions;\n}\n\nexport interface GyralViteConfig {\n readonly plugins: Plugin[];\n readonly resolve: { readonly dedupe: string[] };\n readonly optimizeDeps: { readonly include: string[] };\n}\n\n/**\n * Spread into a Vite config, or into each Vitest project:\n *\n * export default defineConfig({ ...gyralVitePreset(), build: { … } });\n *\n * With plugins of your own, list both: `plugins: [...preset.plugins, mine()]`.\n */\nexport function gyralVitePreset(options: GyralViteOptions = {}): GyralViteConfig {\n return {\n plugins: [gyralTemplateCompiler(options.compiler), gyralDevServer()],\n resolve: { dedupe: [] },\n optimizeDeps: { include: [...new Set(options.optimize ?? [])] },\n };\n}\n"]}
1
+ {"version":3,"file":"vite.js","sourceRoot":"","sources":["../src/vite.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,0FAA0F;AAC1F,wFAAwF;AACxF,+FAA+F;AAC/F,0FAA0F;AAC1F,8FAA8F;AAC9F,4FA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MAAM,UAAU,GACd,MAAM,YAAY,CAA4C,YAAY,CAAC,CAAC;YAC9E,IAAI,GAAG,UAAU,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;YAC5C,OAAO,GAAG,CAAC,QAAQ,CAAC,CAAC,KAAK,CAAC,IAAI,EAAE,IAAI,CAAc,CAAC;QACtD,CAAC;QACD,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC;QACtC,UAAU,EAAE,IAAI,CAAC,YAAY,CAAC;QAC9B,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;QAC5B,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;QAClB,eAAe,EAAE,IAAI,CAAC,iBAAiB,CAAC;QACxC,cAAc,EAAE,IAAI,CAAC,gBAAgB,CAAC;KACvC,CAAC;AACJ,CAAC","sourcesContent":["// Vite / Vitest settings every Gyral app needs (gyral-a7r, docs/references/consumer-setup.md):\n// the template compiler (view/01-templates.md \"Compiled\") and, in serve mode, development\n// output from the dev server's SSR (view/06-server.md \"Development markers\"). Only Node\n// built-ins are imported up front, so it loads from vite.config.ts and vitest.config.ts in any\n// way: bundled with the config, by Node from source (type stripping), or by a Vite module\n// runner. The compiler is a plugin applied in `vite build` only, so dev servers and test runs\n// keep the runtime template path; its implementation (./compiler/) loads on the first build\n// hook, with `require` (Node loads ES modules with it too): a module runner that loaded this\n// file may be closed by then, and would reject a dynamic import(). Public: the preset,\n// gyralTemplateCompiler and gyralClientOnly (docs/references/public-api-0.3.1.md); the other\n// plugins and constants here are internal.\nimport { readFileSync } from 'node:fs';\nimport { createRequire } from 'node:module';\nimport { dirname, join, resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport type { ConfigEnv, EnvironmentOptions, Plugin } from 'vite';\nimport type { FeatureHooks } from './compiler/features.js';\nimport type { CompilerHooks } from './compiler/hooks.js';\nimport type { LocatorHooks } from './compiler/locate.js';\n\nexport interface TemplateCompilerOptions {\n /**\n * Module specifiers whose `html` (and `svg`) exports are the view layer's tags (default\n * `DEFAULT_TEMPLATE_SOURCES`). An import matches when its specifier is listed, or when it\n * resolves to the same module as a listed one; core's own view modules always match. A\n * source other than '@gyral/core' must also export `compiled` (and `compiledSvg` when it\n * exports `svg`).\n */\n readonly sources?: readonly string[];\n /**\n * Rule 7's extra check with parse5 (an optional peer dependency): `true` (default) uses\n * 'parse5' when it is installed, a string names the module to load, `false` skips it.\n */\n readonly parse5?: boolean | string;\n}\n\n/** Where the view layer's `html` comes from: core's main entry (ADR 0018, Phase 3). */\nconst DEFAULT_TEMPLATE_SOURCES: readonly string[] = ['@gyral/core'];\n\n/** The resolve condition that maps core's `#prepare` to its stub (ADR 0017's mechanism). */\nconst COMPILED_CONDITION = 'gyral-compiled';\n/** The client's resolve condition in client-only builds (view/07 \"Client-only builds\"). */\nconst CLIENT_ONLY_CONDITION = 'gyral-client-only';\n/** Vite 8's default resolve conditions (`defaultClientConditions`, server ones without browser). */\nconst CLIENT_CONDITIONS: readonly string[] = ['module', 'browser', 'development|production'];\nconst SERVER_CONDITIONS: readonly string[] = ['module', 'node', 'development|production'];\n\n/**\n * Adds `condition` (default `gyral-compiled`) to an environment, on top of the app's\n * conditions or Vite's defaults: Vite replaces the defaults when a config names any condition.\n * `clientOnly`: only to environments that build for the browser.\n */\nfunction addCondition(\n name: string,\n config: EnvironmentOptions,\n env: ConfigEnv & { isSsrTargetWebworker?: boolean },\n condition = COMPILED_CONDITION,\n clientOnly = false,\n): void {\n const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');\n const client = consumer === 'client' || env.isSsrTargetWebworker === true;\n if (clientOnly && consumer !== 'client') return;\n const current = config.resolve?.conditions ?? (client ? CLIENT_CONDITIONS : SERVER_CONDITIONS);\n if (!current.includes(condition)) {\n config.resolve = { ...config.resolve, conditions: [...current, condition] };\n }\n}\n\n/** The compiled entry of this copy of core, next to this module. */\nconst OWN_COMPILED = fileURLToPath(\n new URL(\n import.meta.url.endsWith('.ts') ? './view/compiled.ts' : './view/compiled.js',\n import.meta.url,\n ),\n);\n\n/** The settings both plugins pass to their lazily loaded implementation. */\nfunction settingsOf(options: TemplateCompilerOptions) {\n return {\n sources: options.sources ?? DEFAULT_TEMPLATE_SOURCES,\n parse5:\n options.parse5 === false\n ? undefined\n : typeof options.parse5 === 'string'\n ? options.parse5\n : 'parse5',\n };\n}\n\n/**\n * A module of ./compiler/. From core's TypeScript source (this workspace, `link:` checkouts) it\n * loads through Vite's module runner, as a vite.config.ts would; from the published package,\n * with require.\n */\nasync function loadCompiler<M>(name: string): Promise<M> {\n const require = createRequire(import.meta.url);\n if (!import.meta.url.endsWith('.ts')) return require(`./compiler/${name}.js`) as M;\n const { runnerImport } = require('vite') as typeof import('vite');\n const nodeEnv = process.env['NODE_ENV']; // the runner sets it when unset; the build owns it\n const { module } = await runnerImport<M>(\n fileURLToPath(new URL(`./compiler/${name}.ts`, import.meta.url)),\n { configFile: false, logLevel: 'silent' },\n );\n if (nodeEnv === undefined) delete process.env['NODE_ENV'];\n else process.env['NODE_ENV'] = nodeEnv;\n return module;\n}\n\n/** The compiler's hooks (`vite build`). */\nasync function loadHooks(options: TemplateCompilerOptions): Promise<CompilerHooks> {\n const hooks = await loadCompiler<typeof import('./compiler/hooks.js')>('hooks');\n return hooks.createCompiler({ ...settingsOf(options), ownEntry: OWN_COMPILED });\n}\n\n/** The template compiler alone (`gyralVitePreset()` includes it). */\nfunction gyralTemplateCompiler(options: TemplateCompilerOptions = {}): Plugin {\n let hooks: CompilerHooks | undefined;\n const ready = (): CompilerHooks => {\n if (hooks === undefined) throw new Error('gyral: the template compiler is not loaded yet');\n return hooks;\n };\n return {\n name: 'gyral:template-compiler',\n enforce: 'pre',\n apply: 'build',\n configEnvironment: addCondition,\n async configResolved(config) {\n hooks = await loadHooks(options);\n await hooks.configResolved.call(this, config);\n },\n buildStart(input) {\n return ready().buildStart.call(this, input);\n },\n // The registration modules of spec-field features (./compiler/features.ts).\n resolveId(source, importer, opts) {\n return ready().resolveId.call(this, source, importer, opts);\n },\n load(id, opts) {\n return ready().load.call(this, id, opts);\n },\n transform: {\n // Modules naming a template tag (html or svg; core's template module names both), or a\n // spec field whose machinery the build adds only when named (view/05).\n filter: {\n id: /\\.[cm]?[jt]sx?$/,\n code: /html|svg|viewTransition|renderOnFrame|states|formAssociated|subscriptions|\\.value\\s*\\(/,\n },\n handler(code, id, opts) {\n return ready().transform.call(this, code, id, opts);\n },\n },\n generateBundle(output, bundle, isWrite) {\n return ready().generateBundle.call(this, output, bundle, isWrite);\n },\n };\n}\n\n/**\n * Development source locations (view/01-templates.md \"Source locations\"): in `vite serve` (the\n * dev server, Vitest) each html`…` and svg`…` call site of the template sources tells the\n * runtime where it was written, so template rule errors and hydration mismatches name\n * `file:line:col` (./compiler/locate.ts, loaded on the first hook). `vite build` compiles\n * templates instead.\n */\nfunction gyralTemplateLocations(options: TemplateCompilerOptions = {}): Plugin {\n let hooks: LocatorHooks | undefined;\n const ready = (): LocatorHooks => {\n if (hooks === undefined) throw new Error('gyral: the template locator is not loaded yet');\n return hooks;\n };\n return {\n name: 'gyral:template-locations',\n enforce: 'pre',\n apply: 'serve',\n async configResolved(config) {\n const locate = await loadCompiler<typeof import('./compiler/locate.js')>('locate');\n hooks = locate.createLocator(settingsOf(options).sources);\n await hooks.configResolved.call(this, config);\n },\n transform: {\n // Modules naming a template tag (html or svg), as the compiler's filter.\n filter: { id: /\\.[cm]?[jt]sx?$/, code: /html|svg/ },\n handler(code, id, opts) {\n return ready().transform.call(this, code, id, opts);\n },\n },\n };\n}\n\n/**\n * Gyral's packages: the dev server runs them through Vite, never Node (view/06). The feature\n * scan's scope (./compiler/scope.ts) uses the same pattern.\n */\nconst GYRAL_PACKAGES = /^@gyral\\//;\n\ntype Manifest = Partial<Record<'dependencies' | 'devDependencies' | 'peerDependencies', object>>;\n\nfunction manifest(file: string): Manifest | undefined {\n try {\n return JSON.parse(readFileSync(file, 'utf8')) as Manifest;\n } catch {\n return undefined;\n }\n}\n\n/** The installed manifest of `name`, looked up from `root` the way Node does (no exports map). */\nfunction installed(root: string, name: string): Manifest | undefined {\n for (let dir = root; ; dir = dirname(dir)) {\n const found = manifest(join(dir, 'node_modules', name, 'package.json'));\n if (found !== undefined || dirname(dir) === dir) return found;\n }\n}\n\n/**\n * The app's direct dependencies that depend on a Gyral package (a design system, say). They\n * import `@gyral/core`, so they must share the copy the dev server runs.\n */\nfunction gyralDependents(root: string): string[] {\n const app = manifest(join(root, 'package.json'));\n const names = Object.keys({ ...app?.dependencies, ...app?.devDependencies });\n return names.filter((name) => {\n if (GYRAL_PACKAGES.test(name)) return false;\n const dep = installed(root, name);\n return Object.keys({ ...dep?.dependencies, ...dep?.peerDependencies }).some((d) =>\n GYRAL_PACKAGES.test(d),\n );\n });\n}\n\n/**\n * Development output from the dev server's SSR (`ssrLoadModule`, view/06 \"Development\n * markers\"). Vite externalizes installed packages there and Node imports them itself, resolving\n * core's `#view-dev` without the `development` condition (Vite's `externalConditions` only pick\n * the entry file, not the package's own imports), so the server rendered production output.\n * In serve mode this plugin keeps Gyral's packages, and the app's dependencies that use them,\n * out of externalization in server environments: Vite resolves them with its conditions\n * (`development` in dev), and they all share one copy of core. `vite build` is unaffected.\n */\nfunction gyralDevSsr(): Plugin {\n let root = process.cwd();\n return {\n name: 'gyral:dev-server',\n apply: 'serve',\n config(config) {\n root = resolve(config.root ?? process.cwd());\n },\n configEnvironment(name, config) {\n const consumer = config.consumer ?? (name === 'client' ? 'client' : 'server');\n if (consumer === 'client') return undefined;\n return { resolve: { noExternal: [GYRAL_PACKAGES, ...gyralDependents(root)] } };\n },\n };\n}\n\n/**\n * Client-only builds (view/07-hydration.md \"Client-only builds\", gyral-c5d.11), for apps no\n * server renders: the browser environment resolves core with the `gyral-client-only`\n * condition, so the bundle carries no hydration code (no seed reading, no hydration chunk and\n * its import()), and in `vite build` the invoker-command fallback only when a module that can\n * affect Gyral components (the app's own, or a package that reaches a Gyral package) may use\n * command intents (./compiler/features.ts). With no other import(), Vite's preload helper goes\n * too. Server-rendered markup met anyway renders fresh (development warns). Dev servers and\n * test runs get the condition too, and always keep the invoker fallback.\n */\nfunction gyralClientOnly(): Plugin {\n let hooks: FeatureHooks | undefined;\n let root = process.cwd();\n return {\n name: 'gyral:client-only',\n enforce: 'pre',\n configEnvironment(name, config, env) {\n addCondition(name, config, env, CLIENT_ONLY_CONDITION, true);\n },\n async configResolved(config) {\n root = config.root;\n if (config.command !== 'build') return;\n const features = await loadCompiler<typeof import('./compiler/features.js')>('features');\n hooks = features.createFeatures(['invokers'], OWN_COMPILED);\n },\n async buildStart() {\n await hooks?.buildStart((source, importer) => this.resolve(source, importer), root);\n },\n resolveId(source) {\n return hooks?.resolveId(source) ?? null;\n },\n load(id) {\n return hooks?.load(id) ?? null;\n },\n transform: {\n // features.ts FEATURE_HINTS.invokers: any import or export may reach `raw`.\n filter: { id: /\\.[cm]?[jt]sx?$/, code: /data-intent-on|command|raw|import|export/i },\n async handler(code, id) {\n if (hooks === undefined || this.environment.config.consumer !== 'client') return null;\n const imports = await hooks.inject(code, id, {\n parse: (text, lang) => this.parse(text, { lang }),\n resolve: (source, importer) => this.resolve(source, importer),\n });\n // Appended after the last line: no code moves, so the incoming source map holds.\n return imports === '' ? null : { code: code + imports, map: null };\n },\n },\n };\n}\n\n/** Where the preset looks for components and writes their typings (gyral-1zd.25). */\nexport interface ElementTypesOptions {\n /** Source directories to scan, relative to the Vite root. Default `['src']`. */\n readonly dirs?: readonly string[];\n /** The declaration file to write, relative to the Vite root. Default `.gyral/elements.d.ts`. */\n readonly out?: string;\n}\n\n/**\n * Writes `HTMLElementTagNameMap` entries for every exported `define()` component (a\n * `.gyral/elements.d.ts` to gitignore and include in tsconfig) at the start of a build, dev\n * server or test run, and again when a source file changes. ./compiler/tag-map imports Node\n * built-ins only, so Node's require loads it, from TypeScript source too: no module runner,\n * which may be closed by the time a build starts (see loadCompiler).\n */\nfunction gyralElementTypes(options: ElementTypesOptions): Plugin {\n const source = import.meta.url.endsWith('.ts')\n ? './compiler/tag-map.ts'\n : './compiler/tag-map.js';\n const tagMap = createRequire(import.meta.url)(source) as typeof import('./compiler/tag-map.js');\n return tagMap.elementTypesPlugin(options);\n}\n\nexport interface GyralViteOptions {\n /**\n * Generated element typings (`.gyral/elements.d.ts`, see `ElementTypesOptions`), or `false`\n * to write none. Default: on, scanning `src`.\n */\n readonly types?: ElementTypesOptions | false;\n /** Modules to pre-bundle in dev, so Vite doesn't discover them mid-run and reload. */\n readonly optimize?: readonly string[];\n /** Template compiler options (`vite build` only). */\n readonly compiler?: TemplateCompilerOptions;\n /**\n * The app is never server-rendered: leave the hydration code out of the browser bundle\n * (`gyralClientOnly()`, view/07-hydration.md \"Client-only builds\"). Default false.\n */\n readonly clientOnly?: boolean;\n /**\n * Automatic component loading (ADR 0016 addendum): every component defined under `include`\n * gets a client module the build splits out, and a loader (`virtual:gyral/components`, added\n * to the client build's input) imports a tag's module once that tag is in the page.\n * `renderPage({ components })` then links exactly the components a page rendered, so pages\n * need no client entry of their own and no side-effect imports. Default off.\n */\n readonly components?: boolean | ComponentsOptions;\n}\n\nexport interface ComponentsOptions {\n /** Directories (relative to Vite's root) whose modules' `define()` tags are found. Default `['src']`. */\n readonly include?: readonly string[];\n /**\n * Tag → module (relative to Vite's root) for components the scan can't find: those defined\n * through a wrapper such as `defineMemberForm({ tag: 'member-form' })`, which calls\n * `define()` itself. Listed entries win over scanned ones.\n */\n readonly modules?: Readonly<Record<string, string>>;\n}\n\nexport interface GyralViteConfig {\n readonly plugins: Plugin[];\n readonly optimizeDeps: { readonly include: string[] };\n}\n\n/**\n * Spread into a Vite config, or into each Vitest project:\n *\n * export default defineConfig({ ...gyralVitePreset(), build: { … } });\n *\n * With plugins of your own, list both: `plugins: [...preset.plugins, mine()]`.\n */\nexport function gyralVitePreset(options: GyralViteOptions = {}): GyralViteConfig {\n return {\n plugins: [\n // Before the compiler: its feature scan reads the author's templates, not compiled ones.\n ...(options.clientOnly === true ? [gyralClientOnly()] : []),\n gyralTemplateCompiler(options.compiler),\n gyralTemplateLocations(options.compiler),\n gyralDevSsr(),\n ...(options.components === undefined || options.components === false\n ? []\n : [gyralComponents(options.components === true ? {} : options.components)]),\n ...(options.types === false ? [] : [gyralElementTypes(options.types ?? {})]),\n ],\n optimizeDeps: { include: [...new Set(options.optimize ?? [])] },\n };\n}\n\ntype Hook = (this: unknown, ...args: unknown[]) => unknown;\n\n/**\n * Automatic component loading (`gyralVitePreset({ components })`): a shell whose hooks run\n * ./compiler/components.ts, loaded on the first hook (`config`) like the compiler.\n */\nfunction gyralComponents(options: ComponentsOptions): Plugin {\n let impl: Plugin | undefined;\n const run = (name: keyof Plugin) =>\n function (this: unknown, ...args: unknown[]): unknown {\n const hook = impl?.[name] as Hook | undefined;\n return hook?.call(this, ...args) ?? null;\n };\n const hook = <K extends keyof Plugin>(name: K) => run(name) as NonNullable<Plugin[K]>;\n return {\n name: 'gyral:components',\n api: {\n tags: (): ReadonlyMap<string, string> =>\n (impl?.api as { tags?: () => ReadonlyMap<string, string> } | undefined)?.tags?.() ??\n new Map(),\n },\n async config(...args) {\n const components =\n await loadCompiler<typeof import('./compiler/components.js')>('components');\n impl = components.createComponents(options);\n return run('config').apply(this, args) as undefined;\n },\n configResolved: hook('configResolved'),\n buildStart: hook('buildStart'),\n resolveId: hook('resolveId'),\n load: hook('load'),\n configureServer: hook('configureServer'),\n generateBundle: hook('generateBundle'),\n };\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gyral/core",
3
- "version": "0.3.0",
4
- "description": "Gyral core: Model-View-Intent web components on the web platform, with their own view layer. Inspired by Cycle.js.",
3
+ "version": "0.3.1",
4
+ "description": "Gyral core: Model-View-Intent web components on the web platform, with their own view layer.",
5
5
  "license": "MIT",
6
6
  "author": "Mike Zupper",
7
7
  "homepage": "https://github.com/gyraljs/gyral/tree/main/packages/core#readme",
@@ -14,16 +14,23 @@
14
14
  "url": "https://github.com/gyraljs/gyral/issues"
15
15
  },
16
16
  "type": "module",
17
+ "bin": {
18
+ "gyral-types": "./dist/cli/gyral-types.js"
19
+ },
17
20
  "sideEffects": false,
18
21
  "exports": {
19
22
  ".": {
20
23
  "types": "./dist/index.d.ts",
21
24
  "default": "./dist/index.js"
22
25
  },
23
- "./server": {
26
+ "./internal/server": {
24
27
  "types": "./dist/server.d.ts",
25
28
  "default": "./dist/server.js"
26
29
  },
30
+ "./internal": {
31
+ "types": "./dist/internal.d.ts",
32
+ "default": "./dist/internal.js"
33
+ },
27
34
  "./vite": {
28
35
  "types": "./dist/vite.d.ts",
29
36
  "default": "./dist/vite.js"
@@ -35,6 +42,15 @@
35
42
  "./eslint": {
36
43
  "types": "./dist/eslint/index.d.ts",
37
44
  "default": "./dist/eslint/index.js"
45
+ },
46
+ "./errors.json": "./dist/errors.json",
47
+ "./storage": {
48
+ "types": "./dist/storage.d.ts",
49
+ "default": "./dist/storage.js"
50
+ },
51
+ "./indexeddb": {
52
+ "types": "./dist/indexeddb.d.ts",
53
+ "default": "./dist/indexeddb.js"
38
54
  }
39
55
  },
40
56
  "imports": {
@@ -49,6 +65,21 @@
49
65
  "#view-dev": {
50
66
  "development": "./dist/view/dev.js",
51
67
  "default": "./dist/view/dev-off.js"
68
+ },
69
+ "#hydration-loader": {
70
+ "gyral-client-only": "./dist/hydration-off.js",
71
+ "default": "./dist/hydration-loader.js"
72
+ },
73
+ "#invoker-fallback": {
74
+ "gyral-client-only": {
75
+ "development": "./dist/invoker-fallback.js",
76
+ "default": "./dist/invoker-fallback-used.js"
77
+ },
78
+ "default": "./dist/invoker-fallback.js"
79
+ },
80
+ "#spec-features": {
81
+ "gyral-compiled": "./dist/spec-features-used.js",
82
+ "default": "./dist/spec-features.js"
52
83
  }
53
84
  },
54
85
  "files": [
@@ -1,13 +0,0 @@
1
- /** The element with `id`, searched from `from`'s own root outward to the document. */
2
- export declare function findInScope(from: Element, id: string): Element | null;
3
- /**
4
- * Names the element after the element with `id`, even outside this component's shadow root:
5
- *
6
- * <form ${labelledBy('page-title', 'Sign in')}>
7
- *
8
- * Uses `ariaLabelledByElements` (ARIA element reflection) where the browser has it, so the name
9
- * stays in sync with the heading. Elsewhere it sets `aria-label` from `fallback`, or from the
10
- * target's text. It has no server half (as before): render a plain `aria-label` too (from a
11
- * `label` prop) for the page before scripts run; the reflected `aria-labelledby` wins over it.
12
- */
13
- export declare const labelledBy: (id: string, fallback?: string | undefined) => import("../index.js").HookResult<[id: string, fallback?: string]>;