marko 5.37.2 → 6.0.0-3.5

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 (638) hide show
  1. package/dist/common/attr-tag.d.ts +8 -0
  2. package/dist/common/compat-meta.d.ts +2 -0
  3. package/dist/common/for.d.ts +5 -0
  4. package/dist/common/helpers.d.ts +7 -0
  5. package/dist/common/meta.d.ts +2 -0
  6. package/dist/common/types.d.ts +105 -0
  7. package/dist/debug/dom.js +2112 -0
  8. package/dist/debug/dom.mjs +2089 -0
  9. package/dist/debug/html.js +2740 -0
  10. package/dist/debug/html.mjs +2663 -0
  11. package/dist/dom/abort-signal.d.ts +3 -0
  12. package/dist/dom/compat.d.ts +20 -0
  13. package/dist/dom/control-flow.d.ts +14 -0
  14. package/dist/dom/controllable.d.ts +12 -0
  15. package/dist/dom/dom.d.ts +19 -0
  16. package/dist/dom/event.d.ts +4 -0
  17. package/dist/dom/parse-html.d.ts +5 -0
  18. package/dist/dom/queue.d.ts +10 -0
  19. package/dist/dom/reconcile.d.ts +2 -0
  20. package/dist/dom/renderer.d.ts +21 -0
  21. package/dist/dom/resolve-cursor-position.d.ts +1 -0
  22. package/dist/dom/resume.d.ts +9 -0
  23. package/dist/dom/schedule.d.ts +2 -0
  24. package/dist/dom/scope.d.ts +7 -0
  25. package/dist/dom/signals.d.ts +39 -0
  26. package/dist/dom/template.d.ts +3 -0
  27. package/dist/dom/walker.d.ts +4 -0
  28. package/dist/dom.d.ts +15 -0
  29. package/dist/dom.js +1370 -0
  30. package/dist/dom.mjs +1350 -0
  31. package/dist/html/attrs.d.ts +14 -0
  32. package/dist/html/compat.d.ts +14 -0
  33. package/dist/html/content.d.ts +5 -0
  34. package/dist/html/dynamic-tag.d.ts +12 -0
  35. package/dist/html/for.d.ts +4 -0
  36. package/dist/html/inlined-runtimes.d.ts +2 -0
  37. package/dist/html/serializer.d.ts +14 -0
  38. package/dist/html/template.d.ts +3 -0
  39. package/dist/html/writer.d.ts +114 -0
  40. package/dist/html.d.ts +9 -0
  41. package/dist/html.js +1818 -0
  42. package/dist/html.mjs +1744 -0
  43. package/dist/translator/core/attrs.d.ts +3 -0
  44. package/dist/translator/core/client.d.ts +14 -0
  45. package/dist/translator/core/const.d.ts +3 -0
  46. package/dist/translator/core/debug.d.ts +3 -0
  47. package/dist/translator/core/define.d.ts +3 -0
  48. package/dist/translator/core/effect.d.ts +3 -0
  49. package/dist/translator/core/export.d.ts +3 -0
  50. package/dist/translator/core/for.d.ts +67 -0
  51. package/dist/translator/core/html-comment.d.ts +12 -0
  52. package/dist/translator/core/html-script.d.ts +9 -0
  53. package/dist/translator/core/html-style.d.ts +9 -0
  54. package/dist/translator/core/id.d.ts +3 -0
  55. package/dist/translator/core/if.d.ts +53 -0
  56. package/dist/translator/core/import.d.ts +3 -0
  57. package/dist/translator/core/index.d.ts +152 -0
  58. package/dist/translator/core/let.d.ts +8 -0
  59. package/dist/translator/core/lifecycle.d.ts +10 -0
  60. package/dist/translator/core/log.d.ts +3 -0
  61. package/dist/translator/core/return.d.ts +6 -0
  62. package/dist/translator/core/script.d.ts +3 -0
  63. package/dist/translator/core/server.d.ts +14 -0
  64. package/dist/translator/core/static.d.ts +14 -0
  65. package/dist/translator/core/style.d.ts +3 -0
  66. package/dist/translator/index.d.ts +201 -0
  67. package/dist/translator/index.js +9143 -489
  68. package/dist/translator/util/assert.d.ts +3 -0
  69. package/dist/translator/util/binding-has-downstream-expressions.d.ts +2 -0
  70. package/dist/translator/util/entry-builder.d.ts +19 -0
  71. package/dist/translator/util/evaluate.d.ts +11 -0
  72. package/dist/translator/util/for-each-identifier.d.ts +2 -0
  73. package/dist/translator/util/get-defined-binding-expression.d.ts +3 -0
  74. package/dist/translator/util/get-known-attr-values.d.ts +2 -0
  75. package/dist/translator/util/get-parent-tag.d.ts +2 -0
  76. package/dist/translator/util/get-root.d.ts +7 -0
  77. package/dist/translator/util/get-tag-name.d.ts +2 -0
  78. package/dist/translator/util/is-core-tag.d.ts +10 -0
  79. package/dist/translator/util/is-stateful.d.ts +3 -0
  80. package/dist/translator/util/is-static.d.ts +2 -0
  81. package/dist/translator/util/marko-config.d.ts +4 -0
  82. package/dist/translator/util/nested-attribute-tags.d.ts +17 -0
  83. package/dist/translator/util/normalize-string-expression.d.ts +3 -0
  84. package/dist/translator/util/optional.d.ts +20 -0
  85. package/dist/translator/util/plugin-hooks.d.ts +4 -0
  86. package/dist/translator/util/references.d.ts +84 -0
  87. package/dist/translator/util/runtime-info.d.ts +5 -0
  88. package/dist/translator/util/runtime.d.ts +15 -0
  89. package/dist/translator/util/scope-read.d.ts +6 -0
  90. package/dist/translator/util/sections.d.ts +51 -0
  91. package/dist/translator/util/signals.d.ts +61 -0
  92. package/dist/translator/util/simplify-fn.d.ts +5 -0
  93. package/dist/translator/util/state.d.ts +3 -0
  94. package/dist/translator/util/tag-name-type.d.ts +16 -0
  95. package/dist/translator/util/to-first-expression-or-block.d.ts +3 -0
  96. package/dist/translator/util/to-first-statement-or-block.d.ts +2 -0
  97. package/dist/translator/util/to-property-name.d.ts +7 -0
  98. package/dist/translator/util/translate-attrs.d.ts +12 -0
  99. package/dist/translator/util/translate-var.d.ts +2 -0
  100. package/dist/translator/util/traverse.d.ts +9 -0
  101. package/dist/translator/util/visitors.d.ts +11 -0
  102. package/dist/translator/util/walks.d.ts +15 -0
  103. package/dist/translator/util/with-previous-location.d.ts +2 -0
  104. package/dist/translator/util/writer.d.ts +13 -0
  105. package/dist/translator/visitors/cdata.d.ts +7 -0
  106. package/dist/translator/visitors/comment.d.ts +7 -0
  107. package/dist/translator/visitors/declaration.d.ts +7 -0
  108. package/dist/translator/visitors/document-type.d.ts +7 -0
  109. package/dist/translator/visitors/function.d.ts +19 -0
  110. package/dist/translator/visitors/import-declaration.d.ts +8 -0
  111. package/dist/translator/visitors/placeholder.d.ts +22 -0
  112. package/dist/translator/visitors/program/dom.d.ts +7 -0
  113. package/dist/translator/visitors/program/html.d.ts +8 -0
  114. package/dist/translator/visitors/program/index.d.ts +39 -0
  115. package/dist/translator/visitors/referenced-identifier.d.ts +7 -0
  116. package/dist/translator/visitors/scriptlet.d.ts +8 -0
  117. package/dist/translator/visitors/tag/attribute-tag.d.ts +11 -0
  118. package/dist/translator/visitors/tag/custom-tag.d.ts +19 -0
  119. package/dist/translator/visitors/tag/dynamic-tag.d.ts +18 -0
  120. package/dist/translator/visitors/tag/index.d.ts +15 -0
  121. package/dist/translator/visitors/tag/native-tag.d.ts +25 -0
  122. package/dist/translator/visitors/text.d.ts +7 -0
  123. package/package.json +32 -74
  124. package/README.md +0 -161
  125. package/bin/markoc +0 -2
  126. package/bin/markoc.js +0 -441
  127. package/browser-refresh.js +0 -5
  128. package/compiler-browser.marko +0 -15
  129. package/compiler.js +0 -7
  130. package/components-browser.marko +0 -15
  131. package/components.js +0 -7
  132. package/dist/build.json +0 -3
  133. package/dist/compiler/config.js +0 -45
  134. package/dist/compiler/index.js +0 -164
  135. package/dist/compiler/modules.js +0 -5
  136. package/dist/core-tags/components/init-components-tag.js +0 -54
  137. package/dist/core-tags/components/preferred-script-location-tag.js +0 -25
  138. package/dist/core-tags/components/preserve-tag.js +0 -1
  139. package/dist/core-tags/core/__flush_here_and_after__.js +0 -44
  140. package/dist/core-tags/core/await/AsyncValue.js +0 -121
  141. package/dist/core-tags/core/await/client-reorder-runtime.js +0 -51
  142. package/dist/core-tags/core/await/index.d.marko +0 -10
  143. package/dist/core-tags/core/await/renderer.js +0 -249
  144. package/dist/core-tags/core/await/reorderer-renderer.js +0 -156
  145. package/dist/index.js +0 -4
  146. package/dist/node-require/browser-refresh.js +0 -18
  147. package/dist/node-require/hot-reload.js +0 -45
  148. package/dist/node-require/index.js +0 -103
  149. package/dist/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  150. package/dist/node_modules/@internal/components-beginComponent/index.js +0 -84
  151. package/dist/node_modules/@internal/components-beginComponent/package.json +0 -11
  152. package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  153. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  154. package/dist/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  155. package/dist/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  156. package/dist/node_modules/@internal/components-endComponent/index.js +0 -11
  157. package/dist/node_modules/@internal/components-endComponent/package.json +0 -11
  158. package/dist/node_modules/@internal/components-entry/index-browser.js +0 -11
  159. package/dist/node_modules/@internal/components-entry/index.js +0 -301
  160. package/dist/node_modules/@internal/components-entry/package.json +0 -11
  161. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  162. package/dist/node_modules/@internal/components-entry-legacy/index.js +0 -16
  163. package/dist/node_modules/@internal/components-entry-legacy/package.json +0 -11
  164. package/dist/node_modules/@internal/components-registry/index-browser.js +0 -586
  165. package/dist/node_modules/@internal/components-registry/index.js +0 -44
  166. package/dist/node_modules/@internal/components-registry/package.json +0 -11
  167. package/dist/node_modules/@internal/components-util/index-browser.js +0 -152
  168. package/dist/node_modules/@internal/components-util/index.js +0 -75
  169. package/dist/node_modules/@internal/components-util/package.json +0 -11
  170. package/dist/node_modules/@internal/create-readable/index-browser.js +0 -30
  171. package/dist/node_modules/@internal/create-readable/index.js +0 -57
  172. package/dist/node_modules/@internal/create-readable/package.json +0 -11
  173. package/dist/node_modules/@internal/loader/fallback-node.js +0 -89
  174. package/dist/node_modules/@internal/loader/index-browser.js +0 -2
  175. package/dist/node_modules/@internal/loader/index.js +0 -23
  176. package/dist/node_modules/@internal/loader/package.json +0 -10
  177. package/dist/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  178. package/dist/node_modules/@internal/preserve-tag/index.js +0 -34
  179. package/dist/node_modules/@internal/preserve-tag/package.json +0 -11
  180. package/dist/node_modules/@internal/require/index-browser.js +0 -15
  181. package/dist/node_modules/@internal/require/index-legacy-browser.js +0 -20
  182. package/dist/node_modules/@internal/require/index-webpack.js +0 -16
  183. package/dist/node_modules/@internal/require/index.js +0 -15
  184. package/dist/node_modules/@internal/require/package.json +0 -11
  185. package/dist/node_modules/@internal/set-immediate/index-browser.js +0 -19
  186. package/dist/node_modules/@internal/set-immediate/index-worker.js +0 -31
  187. package/dist/node_modules/@internal/set-immediate/index.js +0 -3
  188. package/dist/node_modules/@internal/set-immediate/package.json +0 -11
  189. package/dist/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  190. package/dist/runtime/RenderResult.js +0 -112
  191. package/dist/runtime/components/Component.js +0 -663
  192. package/dist/runtime/components/ComponentDef.js +0 -169
  193. package/dist/runtime/components/ComponentsContext.js +0 -59
  194. package/dist/runtime/components/GlobalComponentsContext.js +0 -10
  195. package/dist/runtime/components/KeySequence.js +0 -16
  196. package/dist/runtime/components/ServerComponent.js +0 -73
  197. package/dist/runtime/components/State.js +0 -101
  198. package/dist/runtime/components/attach-detach.js +0 -60
  199. package/dist/runtime/components/defineComponent.js +0 -60
  200. package/dist/runtime/components/dom-data.js +0 -8
  201. package/dist/runtime/components/event-delegation.js +0 -144
  202. package/dist/runtime/components/index.js +0 -1
  203. package/dist/runtime/components/legacy/browser.json +0 -9
  204. package/dist/runtime/components/legacy/defineComponent-legacy.js +0 -27
  205. package/dist/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  206. package/dist/runtime/components/legacy/defineWidget-legacy.js +0 -1
  207. package/dist/runtime/components/legacy/dependencies/html.js +0 -3
  208. package/dist/runtime/components/legacy/dependencies/index.js +0 -177
  209. package/dist/runtime/components/legacy/dependencies/vdom.js +0 -3
  210. package/dist/runtime/components/legacy/index.js +0 -1
  211. package/dist/runtime/components/legacy/jquery.js +0 -52
  212. package/dist/runtime/components/legacy/ready.js +0 -152
  213. package/dist/runtime/components/legacy/renderer-legacy.js +0 -231
  214. package/dist/runtime/components/registry.js +0 -1
  215. package/dist/runtime/components/renderer.js +0 -236
  216. package/dist/runtime/components/update-manager.js +0 -94
  217. package/dist/runtime/createOut.js +0 -13
  218. package/dist/runtime/dom-insert.js +0 -77
  219. package/dist/runtime/events.js +0 -2
  220. package/dist/runtime/helpers/_change-case.js +0 -45
  221. package/dist/runtime/helpers/assign.js +0 -21
  222. package/dist/runtime/helpers/attr-tag.js +0 -43
  223. package/dist/runtime/helpers/class-value.js +0 -30
  224. package/dist/runtime/helpers/dynamic-tag.js +0 -181
  225. package/dist/runtime/helpers/empty-component.js +0 -1
  226. package/dist/runtime/helpers/merge.js +0 -13
  227. package/dist/runtime/helpers/of-fallback.js +0 -4
  228. package/dist/runtime/helpers/render-tag.js +0 -20
  229. package/dist/runtime/helpers/serialize-noop.js +0 -5
  230. package/dist/runtime/helpers/style-value.js +0 -45
  231. package/dist/runtime/helpers/tags-compat/dom-debug.js +0 -1
  232. package/dist/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  233. package/dist/runtime/helpers/tags-compat/dom.js +0 -1
  234. package/dist/runtime/helpers/tags-compat/dom.mjs +0 -4
  235. package/dist/runtime/helpers/tags-compat/html-debug.js +0 -3
  236. package/dist/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  237. package/dist/runtime/helpers/tags-compat/html.js +0 -3
  238. package/dist/runtime/helpers/tags-compat/html.mjs +0 -4
  239. package/dist/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  240. package/dist/runtime/helpers/tags-compat/runtime-html.js +0 -136
  241. package/dist/runtime/helpers/to-string.js +0 -5
  242. package/dist/runtime/html/AsyncStream.js +0 -805
  243. package/dist/runtime/html/BufferedWriter.js +0 -52
  244. package/dist/runtime/html/StringWriter.js +0 -73
  245. package/dist/runtime/html/helpers/_dynamic-attr.js +0 -35
  246. package/dist/runtime/html/helpers/attr.js +0 -80
  247. package/dist/runtime/html/helpers/attrs.js +0 -26
  248. package/dist/runtime/html/helpers/class-attr.js +0 -8
  249. package/dist/runtime/html/helpers/data-marko.js +0 -36
  250. package/dist/runtime/html/helpers/escape-quotes.js +0 -35
  251. package/dist/runtime/html/helpers/escape-script-placeholder.js +0 -24
  252. package/dist/runtime/html/helpers/escape-style-placeholder.js +0 -22
  253. package/dist/runtime/html/helpers/escape-xml.js +0 -21
  254. package/dist/runtime/html/helpers/merge-attrs.js +0 -55
  255. package/dist/runtime/html/helpers/props-script.js +0 -32
  256. package/dist/runtime/html/helpers/style-attr.js +0 -8
  257. package/dist/runtime/html/hot-reload.js +0 -26
  258. package/dist/runtime/html/index.js +0 -33
  259. package/dist/runtime/html/marko-namespace.js +0 -3
  260. package/dist/runtime/renderable.js +0 -194
  261. package/dist/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  262. package/dist/runtime/vdom/VComment.js +0 -24
  263. package/dist/runtime/vdom/VComponent.js +0 -17
  264. package/dist/runtime/vdom/VDocumentFragment.js +0 -34
  265. package/dist/runtime/vdom/VElement.js +0 -375
  266. package/dist/runtime/vdom/VFragment.js +0 -26
  267. package/dist/runtime/vdom/VNode.js +0 -100
  268. package/dist/runtime/vdom/VText.js +0 -25
  269. package/dist/runtime/vdom/helpers/attrs.js +0 -62
  270. package/dist/runtime/vdom/helpers/const-element.js +0 -25
  271. package/dist/runtime/vdom/helpers/merge-attrs.js +0 -16
  272. package/dist/runtime/vdom/hot-reload.js +0 -115
  273. package/dist/runtime/vdom/index.js +0 -30
  274. package/dist/runtime/vdom/is-text-only.js +0 -10
  275. package/dist/runtime/vdom/marko-namespace.js +0 -3
  276. package/dist/runtime/vdom/morphdom/fragment.js +0 -95
  277. package/dist/runtime/vdom/morphdom/helpers.js +0 -42
  278. package/dist/runtime/vdom/morphdom/index.js +0 -741
  279. package/dist/runtime/vdom/parse-html.js +0 -18
  280. package/dist/runtime/vdom/vdom.js +0 -88
  281. package/dist/taglib/index.js +0 -51
  282. package/dist/translator/cdata/index.js +0 -15
  283. package/dist/translator/cdata/index[html].js +0 -15
  284. package/dist/translator/cdata/index[vdom].js +0 -12
  285. package/dist/translator/class.js +0 -65
  286. package/dist/translator/comment/index.js +0 -15
  287. package/dist/translator/comment/index[html].js +0 -17
  288. package/dist/translator/comment/index[vdom].js +0 -3
  289. package/dist/translator/declaration/index.js +0 -15
  290. package/dist/translator/declaration/index[html].js +0 -12
  291. package/dist/translator/declaration/index[vdom].js +0 -3
  292. package/dist/translator/document-type/index.js +0 -15
  293. package/dist/translator/document-type/index[html].js +0 -12
  294. package/dist/translator/document-type/index[vdom].js +0 -3
  295. package/dist/translator/placeholder/index.js +0 -15
  296. package/dist/translator/placeholder/index[html].js +0 -93
  297. package/dist/translator/placeholder/index[vdom].js +0 -22
  298. package/dist/translator/scriptlet.js +0 -4
  299. package/dist/translator/tag/attribute/directives/class.js +0 -42
  300. package/dist/translator/tag/attribute/directives/index.js +0 -15
  301. package/dist/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  302. package/dist/translator/tag/attribute/directives/no-update-body.js +0 -10
  303. package/dist/translator/tag/attribute/directives/no-update-if.js +0 -12
  304. package/dist/translator/tag/attribute/directives/no-update.js +0 -48
  305. package/dist/translator/tag/attribute/directives/style.js +0 -42
  306. package/dist/translator/tag/attribute/index.js +0 -150
  307. package/dist/translator/tag/attribute/modifiers/index.js +0 -7
  308. package/dist/translator/tag/attribute/modifiers/no-update.js +0 -14
  309. package/dist/translator/tag/attribute/modifiers/scoped.js +0 -23
  310. package/dist/translator/tag/attribute-tag.js +0 -149
  311. package/dist/translator/tag/custom-tag.js +0 -146
  312. package/dist/translator/tag/dynamic-tag.js +0 -74
  313. package/dist/translator/tag/index.js +0 -287
  314. package/dist/translator/tag/macro-tag.js +0 -7
  315. package/dist/translator/tag/native-tag.js +0 -27
  316. package/dist/translator/tag/native-tag[html]/attributes.js +0 -151
  317. package/dist/translator/tag/native-tag[html]/index.js +0 -221
  318. package/dist/translator/tag/native-tag[vdom]/attributes.js +0 -105
  319. package/dist/translator/tag/native-tag[vdom]/index.js +0 -189
  320. package/dist/translator/tag/util.js +0 -246
  321. package/dist/translator/taglib/core/conditional/translate-else-if.js +0 -20
  322. package/dist/translator/taglib/core/conditional/translate-else.js +0 -20
  323. package/dist/translator/taglib/core/conditional/translate-if.js +0 -8
  324. package/dist/translator/taglib/core/conditional/util.js +0 -41
  325. package/dist/translator/taglib/core/index.js +0 -474
  326. package/dist/translator/taglib/core/macro/parse.js +0 -17
  327. package/dist/translator/taglib/core/macro/translate.js +0 -48
  328. package/dist/translator/taglib/core/parse-class.js +0 -79
  329. package/dist/translator/taglib/core/parse-export.js +0 -14
  330. package/dist/translator/taglib/core/parse-import.js +0 -14
  331. package/dist/translator/taglib/core/parse-module-code.js +0 -18
  332. package/dist/translator/taglib/core/parse-static.js +0 -18
  333. package/dist/translator/taglib/core/transform-style.js +0 -66
  334. package/dist/translator/taglib/core/translate-await.js +0 -41
  335. package/dist/translator/taglib/core/translate-body.js +0 -17
  336. package/dist/translator/taglib/core/translate-for.js +0 -156
  337. package/dist/translator/taglib/core/translate-html-comment.js +0 -52
  338. package/dist/translator/taglib/core/translate-include-content.js +0 -53
  339. package/dist/translator/taglib/core/translate-server-only.js +0 -5
  340. package/dist/translator/taglib/core/translate-while.js +0 -32
  341. package/dist/translator/taglib/index.js +0 -6
  342. package/dist/translator/taglib/migrate/all-templates.js +0 -46
  343. package/dist/translator/taglib/migrate/index.js +0 -5
  344. package/dist/translator/text/index.js +0 -10
  345. package/dist/translator/text/index[html].js +0 -12
  346. package/dist/translator/text/index[vdom].js +0 -20
  347. package/dist/translator/util/add-dependencies.js +0 -329
  348. package/dist/translator/util/escape-regexp.js +0 -4
  349. package/dist/translator/util/get-component-files.js +0 -86
  350. package/dist/translator/util/html-out-write.js +0 -15
  351. package/dist/translator/util/key-manager.js +0 -176
  352. package/dist/translator/util/optimize-html-writes.js +0 -52
  353. package/dist/translator/util/optimize-vdom-create.js +0 -164
  354. package/dist/translator/util/plugin-hooks.js +0 -22
  355. package/dist/translator/util/runtime-flags.js +0 -3
  356. package/dist/translator/util/vdom-out-write.js +0 -10
  357. package/dist/translator/util/with-previous-location.js +0 -6
  358. package/docs/10-awesome-marko-features.md +0 -291
  359. package/docs/body-content.md +0 -355
  360. package/docs/class-components.md +0 -1001
  361. package/docs/cloudflare-workers.md +0 -32
  362. package/docs/compiler-hooks.png +0 -0
  363. package/docs/compiler.md +0 -473
  364. package/docs/component-diagram.afdesign +0 -0
  365. package/docs/component-diagram.svg +0 -87
  366. package/docs/concise.md +0 -141
  367. package/docs/conditionals-and-lists.md +0 -72
  368. package/docs/core-tags.md +0 -325
  369. package/docs/custom-tags.md +0 -201
  370. package/docs/editor-plugins.md +0 -45
  371. package/docs/events.md +0 -131
  372. package/docs/express.md +0 -66
  373. package/docs/fastify.md +0 -65
  374. package/docs/getting-started.md +0 -95
  375. package/docs/http.md +0 -34
  376. package/docs/icons/js.svg +0 -4
  377. package/docs/icons/marko.svg +0 -1
  378. package/docs/icons/ts.svg +0 -1
  379. package/docs/installing.md +0 -51
  380. package/docs/koa.md +0 -35
  381. package/docs/lasso.md +0 -196
  382. package/docs/marko-5-upgrade.md +0 -59
  383. package/docs/marko-json.md +0 -248
  384. package/docs/marko-vs-react.md +0 -854
  385. package/docs/redux.md +0 -61
  386. package/docs/rendering.md +0 -268
  387. package/docs/rollup.md +0 -352
  388. package/docs/state.md +0 -105
  389. package/docs/structure.json +0 -49
  390. package/docs/styles.md +0 -29
  391. package/docs/syntax.md +0 -601
  392. package/docs/troubleshooting-streaming.md +0 -68
  393. package/docs/typescript.md +0 -406
  394. package/docs/vite.md +0 -86
  395. package/docs/webpack.md +0 -205
  396. package/docs/why-is-marko-fast.md +0 -239
  397. package/env.js +0 -7
  398. package/helpers/README.md +0 -3
  399. package/helpers/empty.js +0 -4
  400. package/helpers/notEmpty.js +0 -11
  401. package/index-browser.marko +0 -15
  402. package/index.d.ts +0 -375
  403. package/index.js +0 -7
  404. package/legacy-components-browser.marko +0 -15
  405. package/legacy-components.js +0 -7
  406. package/node-require.js +0 -8
  407. package/src/build.json +0 -3
  408. package/src/compiler/config.js +0 -45
  409. package/src/compiler/index.js +0 -164
  410. package/src/compiler/modules.js +0 -5
  411. package/src/core-tags/.eslintrc +0 -5
  412. package/src/core-tags/components/init-components-tag.js +0 -54
  413. package/src/core-tags/components/preferred-script-location-tag.js +0 -25
  414. package/src/core-tags/components/preserve-tag.js +0 -1
  415. package/src/core-tags/core/__flush_here_and_after__.js +0 -44
  416. package/src/core-tags/core/await/AsyncValue.js +0 -121
  417. package/src/core-tags/core/await/client-reorder-runtime.js +0 -51
  418. package/src/core-tags/core/await/index.d.marko +0 -10
  419. package/src/core-tags/core/await/renderer.js +0 -249
  420. package/src/core-tags/core/await/reorderer-renderer.js +0 -156
  421. package/src/index.js +0 -4
  422. package/src/node-require/browser-refresh.js +0 -18
  423. package/src/node-require/hot-reload.js +0 -45
  424. package/src/node-require/index.js +0 -103
  425. package/src/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  426. package/src/node_modules/@internal/components-beginComponent/index.js +0 -84
  427. package/src/node_modules/@internal/components-beginComponent/package.json +0 -11
  428. package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  429. package/src/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  430. package/src/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  431. package/src/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  432. package/src/node_modules/@internal/components-endComponent/index.js +0 -11
  433. package/src/node_modules/@internal/components-endComponent/package.json +0 -11
  434. package/src/node_modules/@internal/components-entry/index-browser.js +0 -11
  435. package/src/node_modules/@internal/components-entry/index.js +0 -301
  436. package/src/node_modules/@internal/components-entry/package.json +0 -11
  437. package/src/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  438. package/src/node_modules/@internal/components-entry-legacy/index.js +0 -16
  439. package/src/node_modules/@internal/components-entry-legacy/package.json +0 -11
  440. package/src/node_modules/@internal/components-registry/index-browser.js +0 -586
  441. package/src/node_modules/@internal/components-registry/index.js +0 -44
  442. package/src/node_modules/@internal/components-registry/package.json +0 -11
  443. package/src/node_modules/@internal/components-util/index-browser.js +0 -152
  444. package/src/node_modules/@internal/components-util/index.js +0 -75
  445. package/src/node_modules/@internal/components-util/package.json +0 -11
  446. package/src/node_modules/@internal/create-readable/index-browser.js +0 -30
  447. package/src/node_modules/@internal/create-readable/index.js +0 -57
  448. package/src/node_modules/@internal/create-readable/package.json +0 -11
  449. package/src/node_modules/@internal/loader/fallback-node.js +0 -89
  450. package/src/node_modules/@internal/loader/index-browser.js +0 -2
  451. package/src/node_modules/@internal/loader/index.js +0 -23
  452. package/src/node_modules/@internal/loader/package.json +0 -10
  453. package/src/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  454. package/src/node_modules/@internal/preserve-tag/index.js +0 -34
  455. package/src/node_modules/@internal/preserve-tag/package.json +0 -11
  456. package/src/node_modules/@internal/require/index-browser.js +0 -15
  457. package/src/node_modules/@internal/require/index-legacy-browser.js +0 -20
  458. package/src/node_modules/@internal/require/index-webpack.js +0 -16
  459. package/src/node_modules/@internal/require/index.js +0 -15
  460. package/src/node_modules/@internal/require/package.json +0 -11
  461. package/src/node_modules/@internal/set-immediate/index-browser.js +0 -19
  462. package/src/node_modules/@internal/set-immediate/index-worker.js +0 -31
  463. package/src/node_modules/@internal/set-immediate/index.js +0 -3
  464. package/src/node_modules/@internal/set-immediate/package.json +0 -11
  465. package/src/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  466. package/src/runtime/.eslintrc +0 -5
  467. package/src/runtime/RenderResult.js +0 -112
  468. package/src/runtime/components/Component.js +0 -663
  469. package/src/runtime/components/ComponentDef.js +0 -169
  470. package/src/runtime/components/ComponentsContext.js +0 -59
  471. package/src/runtime/components/GlobalComponentsContext.js +0 -10
  472. package/src/runtime/components/KeySequence.js +0 -16
  473. package/src/runtime/components/ServerComponent.js +0 -73
  474. package/src/runtime/components/State.js +0 -101
  475. package/src/runtime/components/attach-detach.js +0 -60
  476. package/src/runtime/components/defineComponent.js +0 -60
  477. package/src/runtime/components/dom-data.js +0 -8
  478. package/src/runtime/components/event-delegation.js +0 -144
  479. package/src/runtime/components/index.js +0 -1
  480. package/src/runtime/components/legacy/browser.json +0 -9
  481. package/src/runtime/components/legacy/defineComponent-legacy.js +0 -27
  482. package/src/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  483. package/src/runtime/components/legacy/defineWidget-legacy.js +0 -1
  484. package/src/runtime/components/legacy/dependencies/html.js +0 -3
  485. package/src/runtime/components/legacy/dependencies/index.js +0 -177
  486. package/src/runtime/components/legacy/dependencies/vdom.js +0 -3
  487. package/src/runtime/components/legacy/index.js +0 -1
  488. package/src/runtime/components/legacy/jquery.js +0 -52
  489. package/src/runtime/components/legacy/ready.js +0 -152
  490. package/src/runtime/components/legacy/renderer-legacy.js +0 -231
  491. package/src/runtime/components/registry.js +0 -1
  492. package/src/runtime/components/renderer.js +0 -236
  493. package/src/runtime/components/update-manager.js +0 -94
  494. package/src/runtime/createOut.js +0 -13
  495. package/src/runtime/dom-insert.js +0 -77
  496. package/src/runtime/events.js +0 -2
  497. package/src/runtime/helpers/_change-case.js +0 -45
  498. package/src/runtime/helpers/assign.js +0 -21
  499. package/src/runtime/helpers/attr-tag.js +0 -43
  500. package/src/runtime/helpers/class-value.js +0 -30
  501. package/src/runtime/helpers/dynamic-tag.js +0 -181
  502. package/src/runtime/helpers/empty-component.js +0 -1
  503. package/src/runtime/helpers/merge.js +0 -13
  504. package/src/runtime/helpers/of-fallback.js +0 -4
  505. package/src/runtime/helpers/render-tag.js +0 -20
  506. package/src/runtime/helpers/serialize-noop.js +0 -5
  507. package/src/runtime/helpers/style-value.js +0 -45
  508. package/src/runtime/helpers/tags-compat/dom-debug.js +0 -1
  509. package/src/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  510. package/src/runtime/helpers/tags-compat/dom.js +0 -1
  511. package/src/runtime/helpers/tags-compat/dom.mjs +0 -4
  512. package/src/runtime/helpers/tags-compat/html-debug.js +0 -3
  513. package/src/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  514. package/src/runtime/helpers/tags-compat/html.js +0 -3
  515. package/src/runtime/helpers/tags-compat/html.mjs +0 -4
  516. package/src/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  517. package/src/runtime/helpers/tags-compat/runtime-html.js +0 -136
  518. package/src/runtime/helpers/to-string.js +0 -5
  519. package/src/runtime/html/AsyncStream.js +0 -805
  520. package/src/runtime/html/BufferedWriter.js +0 -52
  521. package/src/runtime/html/StringWriter.js +0 -73
  522. package/src/runtime/html/helpers/_dynamic-attr.js +0 -35
  523. package/src/runtime/html/helpers/attr.js +0 -80
  524. package/src/runtime/html/helpers/attrs.js +0 -26
  525. package/src/runtime/html/helpers/class-attr.js +0 -8
  526. package/src/runtime/html/helpers/data-marko.js +0 -36
  527. package/src/runtime/html/helpers/escape-quotes.js +0 -35
  528. package/src/runtime/html/helpers/escape-script-placeholder.js +0 -24
  529. package/src/runtime/html/helpers/escape-style-placeholder.js +0 -22
  530. package/src/runtime/html/helpers/escape-xml.js +0 -21
  531. package/src/runtime/html/helpers/merge-attrs.js +0 -55
  532. package/src/runtime/html/helpers/props-script.js +0 -32
  533. package/src/runtime/html/helpers/style-attr.js +0 -8
  534. package/src/runtime/html/hot-reload.js +0 -26
  535. package/src/runtime/html/index.js +0 -33
  536. package/src/runtime/html/marko-namespace.js +0 -3
  537. package/src/runtime/renderable.js +0 -194
  538. package/src/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  539. package/src/runtime/vdom/VComment.js +0 -24
  540. package/src/runtime/vdom/VComponent.js +0 -17
  541. package/src/runtime/vdom/VDocumentFragment.js +0 -34
  542. package/src/runtime/vdom/VElement.js +0 -375
  543. package/src/runtime/vdom/VFragment.js +0 -26
  544. package/src/runtime/vdom/VNode.js +0 -100
  545. package/src/runtime/vdom/VText.js +0 -25
  546. package/src/runtime/vdom/helpers/attrs.js +0 -62
  547. package/src/runtime/vdom/helpers/const-element.js +0 -25
  548. package/src/runtime/vdom/helpers/merge-attrs.js +0 -16
  549. package/src/runtime/vdom/hot-reload.js +0 -115
  550. package/src/runtime/vdom/index.js +0 -30
  551. package/src/runtime/vdom/is-text-only.js +0 -10
  552. package/src/runtime/vdom/marko-namespace.js +0 -3
  553. package/src/runtime/vdom/morphdom/fragment.js +0 -95
  554. package/src/runtime/vdom/morphdom/helpers.js +0 -42
  555. package/src/runtime/vdom/morphdom/index.js +0 -741
  556. package/src/runtime/vdom/parse-html.js +0 -18
  557. package/src/runtime/vdom/vdom.js +0 -88
  558. package/src/taglib/index.js +0 -51
  559. package/src/translator/cdata/index.js +0 -15
  560. package/src/translator/cdata/index[html].js +0 -15
  561. package/src/translator/cdata/index[vdom].js +0 -12
  562. package/src/translator/class.js +0 -65
  563. package/src/translator/comment/index.js +0 -15
  564. package/src/translator/comment/index[html].js +0 -17
  565. package/src/translator/comment/index[vdom].js +0 -3
  566. package/src/translator/declaration/index.js +0 -15
  567. package/src/translator/declaration/index[html].js +0 -12
  568. package/src/translator/declaration/index[vdom].js +0 -3
  569. package/src/translator/document-type/index.js +0 -15
  570. package/src/translator/document-type/index[html].js +0 -12
  571. package/src/translator/document-type/index[vdom].js +0 -3
  572. package/src/translator/index.js +0 -551
  573. package/src/translator/placeholder/index.js +0 -15
  574. package/src/translator/placeholder/index[html].js +0 -93
  575. package/src/translator/placeholder/index[vdom].js +0 -22
  576. package/src/translator/scriptlet.js +0 -4
  577. package/src/translator/tag/attribute/directives/class.js +0 -42
  578. package/src/translator/tag/attribute/directives/index.js +0 -15
  579. package/src/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  580. package/src/translator/tag/attribute/directives/no-update-body.js +0 -10
  581. package/src/translator/tag/attribute/directives/no-update-if.js +0 -12
  582. package/src/translator/tag/attribute/directives/no-update.js +0 -48
  583. package/src/translator/tag/attribute/directives/style.js +0 -42
  584. package/src/translator/tag/attribute/index.js +0 -150
  585. package/src/translator/tag/attribute/modifiers/index.js +0 -7
  586. package/src/translator/tag/attribute/modifiers/no-update.js +0 -14
  587. package/src/translator/tag/attribute/modifiers/scoped.js +0 -23
  588. package/src/translator/tag/attribute-tag.js +0 -149
  589. package/src/translator/tag/custom-tag.js +0 -146
  590. package/src/translator/tag/dynamic-tag.js +0 -74
  591. package/src/translator/tag/index.js +0 -287
  592. package/src/translator/tag/macro-tag.js +0 -7
  593. package/src/translator/tag/native-tag.js +0 -27
  594. package/src/translator/tag/native-tag[html]/attributes.js +0 -151
  595. package/src/translator/tag/native-tag[html]/index.js +0 -221
  596. package/src/translator/tag/native-tag[vdom]/attributes.js +0 -105
  597. package/src/translator/tag/native-tag[vdom]/index.js +0 -189
  598. package/src/translator/tag/util.js +0 -246
  599. package/src/translator/taglib/core/conditional/translate-else-if.js +0 -20
  600. package/src/translator/taglib/core/conditional/translate-else.js +0 -20
  601. package/src/translator/taglib/core/conditional/translate-if.js +0 -8
  602. package/src/translator/taglib/core/conditional/util.js +0 -41
  603. package/src/translator/taglib/core/index.js +0 -474
  604. package/src/translator/taglib/core/macro/parse.js +0 -17
  605. package/src/translator/taglib/core/macro/translate.js +0 -48
  606. package/src/translator/taglib/core/parse-class.js +0 -79
  607. package/src/translator/taglib/core/parse-export.js +0 -14
  608. package/src/translator/taglib/core/parse-import.js +0 -14
  609. package/src/translator/taglib/core/parse-module-code.js +0 -18
  610. package/src/translator/taglib/core/parse-static.js +0 -18
  611. package/src/translator/taglib/core/transform-style.js +0 -66
  612. package/src/translator/taglib/core/translate-await.js +0 -41
  613. package/src/translator/taglib/core/translate-body.js +0 -17
  614. package/src/translator/taglib/core/translate-for.js +0 -156
  615. package/src/translator/taglib/core/translate-html-comment.js +0 -52
  616. package/src/translator/taglib/core/translate-include-content.js +0 -53
  617. package/src/translator/taglib/core/translate-server-only.js +0 -5
  618. package/src/translator/taglib/core/translate-while.js +0 -32
  619. package/src/translator/taglib/index.js +0 -7
  620. package/src/translator/taglib/migrate/all-templates.js +0 -46
  621. package/src/translator/taglib/migrate/index.js +0 -5
  622. package/src/translator/text/index.js +0 -10
  623. package/src/translator/text/index[html].js +0 -12
  624. package/src/translator/text/index[vdom].js +0 -20
  625. package/src/translator/util/add-dependencies.js +0 -329
  626. package/src/translator/util/escape-regexp.js +0 -4
  627. package/src/translator/util/get-component-files.js +0 -86
  628. package/src/translator/util/html-out-write.js +0 -15
  629. package/src/translator/util/key-manager.js +0 -176
  630. package/src/translator/util/optimize-html-writes.js +0 -52
  631. package/src/translator/util/optimize-vdom-create.js +0 -164
  632. package/src/translator/util/plugin-hooks.js +0 -22
  633. package/src/translator/util/runtime-flags.js +0 -3
  634. package/src/translator/util/vdom-out-write.js +0 -10
  635. package/src/translator/util/with-previous-location.js +0 -6
  636. package/tags-html.d.ts +0 -3855
  637. package/translator/index.d.ts +0 -7
  638. package/translator/package.json +0 -5
@@ -0,0 +1,2663 @@
1
+ // src/common/attr-tag.ts
2
+ var empty = [];
3
+ var rest = true ? Symbol("Attribute Tag") : Symbol();
4
+ function attrTag(attrs2) {
5
+ attrs2[Symbol.iterator] = attrTagIterator;
6
+ attrs2[rest] = empty;
7
+ return attrs2;
8
+ }
9
+ function attrTags(first, attrs2) {
10
+ if (first) {
11
+ if (first[rest] === empty) {
12
+ first[rest] = [attrs2];
13
+ } else {
14
+ first[rest].push(attrs2);
15
+ }
16
+ return first;
17
+ }
18
+ return attrTag(attrs2);
19
+ }
20
+ function* attrTagIterator() {
21
+ yield this;
22
+ yield* this[rest];
23
+ }
24
+
25
+ // src/common/helpers.ts
26
+ function classValue(value) {
27
+ return toDelimitedString(value, " ", stringifyClassObject);
28
+ }
29
+ function stringifyClassObject(name, value) {
30
+ return value ? name : "";
31
+ }
32
+ function styleValue(value) {
33
+ return toDelimitedString(value, ";", stringifyStyleObject);
34
+ }
35
+ var NON_DIMENSIONAL = /^(--|ta|or|li|z)|n-c|i(do|nk|m|t)|w$|we/;
36
+ function stringifyStyleObject(name, value) {
37
+ return value || value === 0 ? `${name}:${typeof value === "number" && value && !NON_DIMENSIONAL.test(name) ? value + "px" : value}` : "";
38
+ }
39
+ function toDelimitedString(val, delimiter, stringify) {
40
+ switch (typeof val) {
41
+ case "string":
42
+ return val;
43
+ case "object":
44
+ if (val !== null) {
45
+ let result = "";
46
+ let curDelimiter = "";
47
+ if (Array.isArray(val)) {
48
+ for (const v of val) {
49
+ const part = toDelimitedString(v, delimiter, stringify);
50
+ if (part !== "") {
51
+ result += curDelimiter + part;
52
+ curDelimiter = delimiter;
53
+ }
54
+ }
55
+ } else {
56
+ for (const name in val) {
57
+ const v = val[name];
58
+ const part = stringify(name, v);
59
+ if (part !== "") {
60
+ result += curDelimiter + part;
61
+ curDelimiter = delimiter;
62
+ }
63
+ }
64
+ }
65
+ return result;
66
+ }
67
+ }
68
+ return "";
69
+ }
70
+ function isEventHandler(name) {
71
+ return /^on[A-Z-]/.test(name);
72
+ }
73
+ function getEventHandlerName(name) {
74
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
75
+ }
76
+ function isVoid(value) {
77
+ return value == null || value === false;
78
+ }
79
+ function normalizeDynamicRenderer(value) {
80
+ if (value) return value.renderBody || value.default || value;
81
+ }
82
+
83
+ // src/html/content.ts
84
+ function toString(val) {
85
+ return val ? val + "" : val === 0 ? "0" : "";
86
+ }
87
+ var unsafeXMLReg = /[<&]/g;
88
+ var replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;";
89
+ var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
90
+ function escapeXML(val) {
91
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
92
+ }
93
+ function escapeTextAreaValue(val) {
94
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
95
+ }
96
+ var unsafeScriptReg = /<\/script/g;
97
+ var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
98
+ function escapeScript(val) {
99
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
100
+ }
101
+ var unsafeStyleReg = /<\/style/g;
102
+ var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
103
+ function escapeStyle(val) {
104
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
105
+ }
106
+
107
+ // src/html/inlined-runtimes.ts
108
+ var WALKER_RUNTIME_CODE = true ? `((runtimeId) =>
109
+ (self[runtimeId] =
110
+ self[runtimeId] ||
111
+ ((renderId) => {
112
+ let id,
113
+ markers = {},
114
+ visits = [],
115
+ doc = document,
116
+ walker = doc.createTreeWalker(
117
+ doc,
118
+ 129,
119
+ ) /* NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_ELEMENT */,
120
+ op = (self[runtimeId][renderId] = {
121
+ i: (renderId = runtimeId + renderId),
122
+ d: doc,
123
+ l: markers,
124
+ v: visits,
125
+ x() {},
126
+ w(node) {
127
+ while ((node = walker.nextNode())) {
128
+ this.x(
129
+ (op =
130
+ (op = node.data) &&
131
+ !op.indexOf(renderId) &&
132
+ ((markers[(id = op.slice(prefix + 1))] = node), op[prefix])),
133
+ id,
134
+ node,
135
+ );
136
+
137
+ if (op > "#") {
138
+ visits.push(node);
139
+ }
140
+ }
141
+ },
142
+ }),
143
+ prefix = renderId.length;
144
+ })))` : `(e=>self[e]=self[e]||(l=>{let t,d={},f=[],s=document,a=s.createTreeWalker(s,129),r=self[e][l]={i:l=e+l,d:s,l:d,v:f,x(){},w(e){for(;e=a.nextNode();)this.x(r=(r=e.data)&&!r.indexOf(l)&&(d[t=r.slice(x+1)]=e,r[x]),t,e),r>"#"&&f.push(e)}},x=l.length}))`;
145
+ var REORDER_RUNTIME_CODE = true ? `((runtime) => {
146
+ let insertOne,
147
+ placeholder,
148
+ nextSibling,
149
+ previousSibling,
150
+ placeholders = {},
151
+ replace = (marker, container) => {
152
+ marker.replaceWith(...container.childNodes);
153
+ container.remove();
154
+ };
155
+ runtime.d.head.append(
156
+ runtime.d.querySelector("style[" + runtime.i + "]") || "",
157
+ );
158
+ runtime.j = {};
159
+ runtime.x = (op, id, node, start, placeholderCallback) => {
160
+ // "node" and "end" are all closed over and can't be repurposed. "start" is too but only in the new placeholder case
161
+
162
+ if (op == "#") {
163
+ (placeholders[id] = placeholder).i++;
164
+ } else if (node == nextSibling) {
165
+ insertOne();
166
+ }
167
+
168
+ if (node.tagName == "T" && (id = node.getAttribute(runtime.i))) {
169
+ start = runtime.l["^" + id];
170
+
171
+ if (start) {
172
+ placeholder = placeholders[id] = {
173
+ i: 0,
174
+ c(end = runtime.l[id] || previousSibling || node) {
175
+ while (end.parentNode !== start.parentNode) {
176
+ end = end.parentNode;
177
+ }
178
+
179
+ for (
180
+ ;
181
+ end != nextSibling;
182
+ (nextSibling = start.nextSibling).remove()
183
+ );
184
+ replace(start, node);
185
+ },
186
+ };
187
+ } else {
188
+ insertOne = () => {
189
+ previousSibling = node.previousSibling;
190
+ replace(runtime.l[id], node);
191
+ if (!--start.i) {
192
+ start.c();
193
+ }
194
+ };
195
+
196
+ // repurpose "start" to hold this placeholder
197
+ start = placeholder = placeholders[id];
198
+ nextSibling = node.nextElementSibling || insertOne();
199
+ }
200
+
201
+ // repurpose "op" for callbacks ...carefully
202
+ placeholderCallback = placeholder.c;
203
+ (op = runtime.j[id]) &&
204
+ (placeholder.c = () => placeholderCallback() + op(runtime));
205
+
206
+ if (node.attributes.c) placeholder.c();
207
+ }
208
+ };
209
+ })` : `(e=>{let i,t,r,l,d={},n=(e,i)=>{e.replaceWith(...i.childNodes),i.remove()};e.d.head.append(e.d.querySelector("style["+e.i+"]")||""),e.j={},e.x=(o,a,c,p,b)=>{"#"==o?(d[a]=t).i++:c==r&&i(),"T"==c.tagName&&(a=c.getAttribute(e.i))&&((p=e.l["^"+a])?t=d[a]={i:0,c(i=e.l[a]||l||c){for(;i.parentNode!==p.parentNode;)i=i.parentNode;for(;i!=r;(r=p.nextSibling).remove());n(p,c)}}:(i=()=>{l=c.previousSibling,n(e.l[a],c),--p.i||p.c()},p=t=d[a],r=c.nextElementSibling||i()),b=t.c,(o=e.j[a])&&(t.c=()=>b()+o(e)),c.attributes.c&&t.c())}})`;
210
+
211
+ // src/html/serializer.ts
212
+ var { hasOwnProperty } = {};
213
+ var Generator = function* () {
214
+ }().constructor;
215
+ var AsyncGenerator = async function* () {
216
+ }().constructor;
217
+ var REGISTRY = /* @__PURE__ */ new WeakMap();
218
+ var KNOWN_SYMBOLS = (() => {
219
+ const KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
220
+ for (const name of Object.getOwnPropertyNames(Symbol)) {
221
+ const symbol = Symbol[name];
222
+ if (typeof symbol === "symbol") {
223
+ KNOWN_SYMBOLS2.set(symbol, "Symbol." + name);
224
+ }
225
+ }
226
+ return KNOWN_SYMBOLS2;
227
+ })();
228
+ var KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
229
+ // This is by no means an exhaustive list,
230
+ // but it should cover most of the built-in functions.
231
+ [AggregateError, "AggregateError"],
232
+ [Array, "Array"],
233
+ [Array.from, "Array.from"],
234
+ [Array.isArray, "Array.isArray"],
235
+ [Array.of, "Array.of"],
236
+ [ArrayBuffer, "ArrayBuffer"],
237
+ [ArrayBuffer.isView, "ArrayBuffer.isView"],
238
+ [Atomics.add, "Atomics.add"],
239
+ [Atomics.and, "Atomics.and"],
240
+ [Atomics.compareExchange, "Atomics.compareExchange"],
241
+ [Atomics.exchange, "Atomics.exchange"],
242
+ [Atomics.isLockFree, "Atomics.isLockFree"],
243
+ [Atomics.load, "Atomics.load"],
244
+ [Atomics.notify, "Atomics.notify"],
245
+ [Atomics.or, "Atomics.or"],
246
+ [Atomics.store, "Atomics.store"],
247
+ [Atomics.sub, "Atomics.sub"],
248
+ [Atomics.wait, "Atomics.wait"],
249
+ [BigInt, "BigInt"],
250
+ [BigInt.asIntN, "BigInt.asIntN"],
251
+ [BigInt.asUintN, "BigInt.asUintN"],
252
+ [BigInt64Array, "BigInt64Array"],
253
+ [BigInt64Array.from, "BigInt64Array.from"],
254
+ [BigInt64Array.of, "BigInt64Array.of"],
255
+ [BigUint64Array, "BigUint64Array"],
256
+ [BigUint64Array.from, "BigUint64Array.from"],
257
+ [BigUint64Array.of, "BigUint64Array.of"],
258
+ [Boolean, "Boolean"],
259
+ [console.assert, "console.assert"],
260
+ [console.clear, "console.clear"],
261
+ [console.count, "console.count"],
262
+ [console.countReset, "console.countReset"],
263
+ [console.debug, "console.debug"],
264
+ [console.dir, "console.dir"],
265
+ [console.dirxml, "console.dirxml"],
266
+ [console.error, "console.error"],
267
+ [console.group, "console.group"],
268
+ [console.groupCollapsed, "console.groupCollapsed"],
269
+ [console.groupEnd, "console.groupEnd"],
270
+ [console.info, "console.info"],
271
+ [console.log, "console.log"],
272
+ [console.table, "console.table"],
273
+ [console.time, "console.time"],
274
+ [console.timeEnd, "console.timeEnd"],
275
+ [console.timeLog, "console.timeLog"],
276
+ [console.timeStamp, "console.timeStamp"],
277
+ [console.trace, "console.trace"],
278
+ [console.warn, "console.warn"],
279
+ [DataView, "DataView"],
280
+ [Date, "Date"],
281
+ [Date.now, "Date.now"],
282
+ [Date.parse, "Date.parse"],
283
+ [Date.UTC, "Date.UTC"],
284
+ [decodeURI, "decodeURI"],
285
+ [decodeURIComponent, "decodeURIComponent"],
286
+ [encodeURI, "encodeURI"],
287
+ [encodeURIComponent, "encodeURIComponent"],
288
+ [Error, "Error"],
289
+ [EvalError, "EvalError"],
290
+ [Float32Array, "Float32Array"],
291
+ [Float32Array.from, "Float32Array.from"],
292
+ [Float32Array.of, "Float32Array.of"],
293
+ [Float64Array, "Float64Array"],
294
+ [Float64Array.from, "Float64Array.from"],
295
+ [Float64Array.of, "Float64Array.of"],
296
+ [Function, "Function"],
297
+ [globalThis.atob, "atob"],
298
+ [globalThis.btoa, "btoa"],
299
+ [globalThis.clearImmediate, "clearImmediate"],
300
+ [globalThis.clearInterval, "clearInterval"],
301
+ [globalThis.clearTimeout, "clearTimeout"],
302
+ [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
303
+ [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
304
+ [globalThis.fetch, "fetch"],
305
+ [globalThis.performance?.now, "performance.now"],
306
+ [globalThis.queueMicrotask, "queueMicrotask"],
307
+ [globalThis.setImmediate, "setImmediate"],
308
+ [globalThis.setInterval, "setInterval"],
309
+ [globalThis.setTimeout, "setTimeout"],
310
+ [globalThis.structuredClone, "structuredClone"],
311
+ [globalThis.URL, "URL"],
312
+ [globalThis.URLSearchParams, "URLSearchParams"],
313
+ [globalThis.WritableStream, "WritableStream"],
314
+ [Int16Array, "Int16Array"],
315
+ [Int16Array.from, "Int16Array.from"],
316
+ [Int16Array.of, "Int16Array.of"],
317
+ [Int32Array, "Int32Array"],
318
+ [Int32Array.from, "Int32Array.from"],
319
+ [Int32Array.of, "Int32Array.of"],
320
+ [Int8Array, "Int8Array"],
321
+ [Int8Array.from, "Int8Array.from"],
322
+ [Int8Array.of, "Int8Array.of"],
323
+ [Intl.Collator, "Intl.Collator"],
324
+ [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
325
+ [Intl.DisplayNames, "Intl.DisplayNames"],
326
+ [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
327
+ [Intl.ListFormat, "Intl.ListFormat"],
328
+ [Intl.Locale, "Intl.Locale"],
329
+ [Intl.NumberFormat, "Intl.NumberFormat"],
330
+ [Intl.PluralRules, "Intl.PluralRules"],
331
+ [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
332
+ [Intl.Segmenter, "Intl.Segmenter"],
333
+ [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
334
+ [isFinite, "isFinite"],
335
+ [isNaN, "isNaN"],
336
+ [JSON.parse, "JSON.parse"],
337
+ [JSON.stringify, "JSON.stringify"],
338
+ [Map, "Map"],
339
+ [Map.groupBy, "Map.groupBy"],
340
+ [Math.abs, "Math.abs"],
341
+ [Math.acos, "Math.acos"],
342
+ [Math.acosh, "Math.acosh"],
343
+ [Math.asin, "Math.asin"],
344
+ [Math.asinh, "Math.asinh"],
345
+ [Math.atan, "Math.atan"],
346
+ [Math.atan2, "Math.atan2"],
347
+ [Math.atanh, "Math.atanh"],
348
+ [Math.cbrt, "Math.cbrt"],
349
+ [Math.ceil, "Math.ceil"],
350
+ [Math.clz32, "Math.clz32"],
351
+ [Math.cos, "Math.cos"],
352
+ [Math.cosh, "Math.cosh"],
353
+ [Math.exp, "Math.exp"],
354
+ [Math.expm1, "Math.expm1"],
355
+ [Math.floor, "Math.floor"],
356
+ [Math.fround, "Math.fround"],
357
+ [Math.hypot, "Math.hypot"],
358
+ [Math.imul, "Math.imul"],
359
+ [Math.log, "Math.log"],
360
+ [Math.log10, "Math.log10"],
361
+ [Math.log1p, "Math.log1p"],
362
+ [Math.log2, "Math.log2"],
363
+ [Math.max, "Math.max"],
364
+ [Math.min, "Math.min"],
365
+ [Math.pow, "Math.pow"],
366
+ [Math.random, "Math.random"],
367
+ [Math.round, "Math.round"],
368
+ [Math.sign, "Math.sign"],
369
+ [Math.sin, "Math.sin"],
370
+ [Math.sinh, "Math.sinh"],
371
+ [Math.sqrt, "Math.sqrt"],
372
+ [Math.tan, "Math.tan"],
373
+ [Math.tanh, "Math.tanh"],
374
+ [Math.trunc, "Math.trunc"],
375
+ [Number, "Number"],
376
+ [Number.isFinite, "Number.isFinite"],
377
+ [Number.isInteger, "Number.isInteger"],
378
+ [Number.isNaN, "Number.isNaN"],
379
+ [Number.isSafeInteger, "Number.isSafeInteger"],
380
+ [Number.parseFloat, "Number.parseFloat"],
381
+ [Number.parseInt, "Number.parseInt"],
382
+ [Object, "Object"],
383
+ [Object.assign, "Object.assign"],
384
+ [Object.create, "Object.create"],
385
+ [Object.defineProperties, "Object.defineProperties"],
386
+ [Object.defineProperty, "Object.defineProperty"],
387
+ [Object.entries, "Object.entries"],
388
+ [Object.freeze, "Object.freeze"],
389
+ [Object.fromEntries, "Object.fromEntries"],
390
+ [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
391
+ [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
392
+ [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
393
+ [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
394
+ [Object.getPrototypeOf, "Object.getPrototypeOf"],
395
+ [Object.is, "Object.is"],
396
+ [Object.isExtensible, "Object.isExtensible"],
397
+ [Object.isFrozen, "Object.isFrozen"],
398
+ [Object.isSealed, "Object.isSealed"],
399
+ [Object.keys, "Object.keys"],
400
+ [Object.preventExtensions, "Object.preventExtensions"],
401
+ [Object.seal, "Object.seal"],
402
+ [Object.setPrototypeOf, "Object.setPrototypeOf"],
403
+ [Object.values, "Object.values"],
404
+ [parseFloat, "parseFloat"],
405
+ [parseInt, "parseInt"],
406
+ [Promise, "Promise"],
407
+ [Proxy, "Proxy"],
408
+ [RangeError, "RangeError"],
409
+ [ReferenceError, "ReferenceError"],
410
+ [Reflect.apply, "Reflect.apply"],
411
+ [Reflect.construct, "Reflect.construct"],
412
+ [Reflect.defineProperty, "Reflect.defineProperty"],
413
+ [Reflect.deleteProperty, "Reflect.deleteProperty"],
414
+ [Reflect.get, "Reflect.get"],
415
+ [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
416
+ [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
417
+ [Reflect.has, "Reflect.has"],
418
+ [Reflect.isExtensible, "Reflect.isExtensible"],
419
+ [Reflect.ownKeys, "Reflect.ownKeys"],
420
+ [Reflect.preventExtensions, "Reflect.preventExtensions"],
421
+ [Reflect.set, "Reflect.set"],
422
+ [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
423
+ [RegExp, "RegExp"],
424
+ [Set, "Set"],
425
+ [String, "String"],
426
+ [String.fromCharCode, "String.fromCharCode"],
427
+ [String.fromCodePoint, "String.fromCodePoint"],
428
+ [String.raw, "String.raw"],
429
+ [Symbol, "Symbol"],
430
+ [Symbol.for, "Symbol.for"],
431
+ [SyntaxError, "SyntaxError"],
432
+ [TypeError, "TypeError"],
433
+ [Uint16Array, "Uint16Array"],
434
+ [Uint16Array.from, "Uint16Array.from"],
435
+ [Uint16Array.of, "Uint16Array.of"],
436
+ [Uint32Array, "Uint32Array"],
437
+ [Uint32Array.from, "Uint32Array.from"],
438
+ [Uint32Array.of, "Uint32Array.of"],
439
+ [Uint8Array, "Uint8Array"],
440
+ [Uint8Array.from, "Uint8Array.from"],
441
+ [Uint8Array.of, "Uint8Array.of"],
442
+ [Uint8ClampedArray, "Uint8ClampedArray"],
443
+ [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
444
+ [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
445
+ [URIError, "URIError"],
446
+ [WeakMap, "WeakMap"],
447
+ [WeakSet, "WeakSet"]
448
+ ]);
449
+ var KNOWN_OBJECTS = /* @__PURE__ */ new Map([
450
+ [Atomics, "Atomics"],
451
+ [console, "console"],
452
+ [globalThis, "globalThis"],
453
+ [globalThis.crypto, "crypto"],
454
+ [Intl, "Intl"],
455
+ [JSON, "JSON"],
456
+ [Math, "Math"],
457
+ [Reflect, "Reflect"]
458
+ ]);
459
+ var State = class {
460
+ ids = 0;
461
+ flush = 0;
462
+ flushed = false;
463
+ buf = [];
464
+ refs = /* @__PURE__ */ new WeakMap();
465
+ assigned = /* @__PURE__ */ new Set();
466
+ boundary = void 0;
467
+ };
468
+ var Reference = class {
469
+ constructor(parent, accessor, flush, pos = null, id = null) {
470
+ this.parent = parent;
471
+ this.accessor = accessor;
472
+ this.flush = flush;
473
+ this.pos = pos;
474
+ this.id = id;
475
+ this.parent = parent;
476
+ this.accessor = accessor;
477
+ this.flush = flush;
478
+ this.pos = pos;
479
+ this.id = id;
480
+ }
481
+ init = "";
482
+ assigns = "";
483
+ };
484
+ var Serializer = class {
485
+ #state = new State();
486
+ get flushed() {
487
+ return this.#state.flushed;
488
+ }
489
+ stringify(val, boundary) {
490
+ try {
491
+ this.#state.flushed = false;
492
+ this.#state.boundary = boundary;
493
+ return writeRoot(this.#state, val);
494
+ } finally {
495
+ this.#flush();
496
+ }
497
+ }
498
+ nextId() {
499
+ return nextId(this.#state);
500
+ }
501
+ symbol(id) {
502
+ const symbol = Symbol();
503
+ this.#state.refs.set(symbol, new Reference(null, null, 0, null, id));
504
+ return symbol;
505
+ }
506
+ #flush() {
507
+ this.#state.flush++;
508
+ this.#state.buf = [];
509
+ this.#state.assigned = /* @__PURE__ */ new Set();
510
+ }
511
+ };
512
+ function register(id, val, scope) {
513
+ REGISTRY.set(val, { id, scope, access: "_._" + toAccess(toObjectKey(id)) });
514
+ return val;
515
+ }
516
+ function getRegistered(val) {
517
+ const registered = REGISTRY.get(val);
518
+ if (registered) {
519
+ return {
520
+ id: registered.id,
521
+ scope: registered.scope
522
+ };
523
+ }
524
+ }
525
+ function writeRoot(state, root) {
526
+ const { buf, assigned } = state;
527
+ const hadBuf = buf.length !== 0;
528
+ let result = "";
529
+ if (hadBuf) {
530
+ buf.push(",");
531
+ }
532
+ if (writeProp(state, root, null, "")) {
533
+ const rootRef = state.refs.get(root);
534
+ if (rootRef) {
535
+ ensureId(state, rootRef);
536
+ }
537
+ if (assigned.size) {
538
+ if (assigned.delete(rootRef)) {
539
+ assigned.add(rootRef);
540
+ writeAssigned(state);
541
+ } else {
542
+ writeAssigned(state);
543
+ buf.push("," + rootRef.id);
544
+ }
545
+ }
546
+ result = "(";
547
+ buf.push(")");
548
+ } else {
549
+ if (hadBuf) {
550
+ buf.pop();
551
+ writeAssigned(state);
552
+ }
553
+ result = "{";
554
+ buf.push("}");
555
+ }
556
+ for (const chunk of buf) {
557
+ result += chunk;
558
+ }
559
+ return "_=>" + result;
560
+ }
561
+ function writeAssigned(state) {
562
+ for (const valueRef of state.assigned) {
563
+ state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id));
564
+ valueRef.init = "";
565
+ }
566
+ }
567
+ function writeProp(state, val, parent, accessor) {
568
+ switch (typeof val) {
569
+ case "string":
570
+ return writeString(state, val);
571
+ case "number":
572
+ return writeNumber(state, val);
573
+ case "boolean":
574
+ return writeBoolean(state, val);
575
+ case "bigint":
576
+ return writeBigInt(state, val);
577
+ case "symbol":
578
+ return writeSymbol(state, val, parent, accessor);
579
+ case "function":
580
+ return writeFunction(state, val, parent, accessor);
581
+ case "object":
582
+ return writeObject(state, val, parent, accessor);
583
+ default:
584
+ return false;
585
+ }
586
+ }
587
+ function writeReferenceOr(state, write2, val, parent, accessor) {
588
+ let ref = state.refs.get(val);
589
+ if (ref) {
590
+ if (ref.init) {
591
+ ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
592
+ return false;
593
+ }
594
+ if (isCircular(parent, ref)) {
595
+ if (!ref.assigns) {
596
+ ensureId(state, ref);
597
+ state.assigned.add(ref);
598
+ }
599
+ ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
600
+ return false;
601
+ }
602
+ state.buf.push(ensureId(state, ref));
603
+ return true;
604
+ }
605
+ const registered = REGISTRY.get(val);
606
+ if (registered)
607
+ return writeRegistered(state, val, parent, accessor, registered);
608
+ state.refs.set(
609
+ val,
610
+ ref = new Reference(parent, accessor, state.flush, state.buf.length)
611
+ );
612
+ if (write2(state, val, ref)) return true;
613
+ state.refs.delete(ref);
614
+ return false;
615
+ }
616
+ function writeRegistered(state, val, parent, accessor, { access, scope }) {
617
+ if (scope) {
618
+ const scopeRef = state.refs.get(scope);
619
+ const fnRef = new Reference(
620
+ parent,
621
+ accessor,
622
+ state.flush,
623
+ state.buf.length
624
+ );
625
+ state.refs.set(val, fnRef);
626
+ if (scopeRef) {
627
+ const scopeId = ensureId(state, scopeRef);
628
+ if (isCircular(parent, scopeRef)) {
629
+ state.assigned.add(fnRef);
630
+ fnRef.init = access + "(" + scopeId + ")";
631
+ fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=";
632
+ return false;
633
+ }
634
+ state.buf.push(access + "(" + scopeId + ")");
635
+ } else {
636
+ state.buf.push(access + "(");
637
+ writeProp(state, scope, parent, "");
638
+ const scopeRef2 = state.refs.get(scope);
639
+ if (scopeRef2) ensureId(state, scopeRef2);
640
+ state.buf.push(")");
641
+ }
642
+ } else {
643
+ state.buf.push(access);
644
+ }
645
+ return true;
646
+ }
647
+ function writeString(state, val) {
648
+ state.buf.push(quote(val, 0));
649
+ return true;
650
+ }
651
+ function writeNumber(state, val) {
652
+ state.buf.push(val + "");
653
+ return true;
654
+ }
655
+ function writeBoolean(state, val) {
656
+ state.buf.push(val ? "!0" : "!1");
657
+ return true;
658
+ }
659
+ function writeBigInt(state, val) {
660
+ state.buf.push(val + "n");
661
+ return true;
662
+ }
663
+ function writeFunction(state, val, parent, accessor) {
664
+ const wellKnownFunction = KNOWN_FUNCTIONS.get(val);
665
+ if (wellKnownFunction) {
666
+ state.buf.push(wellKnownFunction);
667
+ return true;
668
+ }
669
+ return writeReferenceOr(state, writeNever, val, parent, accessor);
670
+ }
671
+ function writeSymbol(state, val, parent, accessor) {
672
+ const wellKnownSymbol = KNOWN_SYMBOLS.get(val);
673
+ if (wellKnownSymbol) {
674
+ state.buf.push(wellKnownSymbol);
675
+ return true;
676
+ }
677
+ const key = Symbol.keyFor(val);
678
+ if (key !== void 0) {
679
+ state.buf.push("Symbol.for(" + quote(key, 0) + ")");
680
+ return true;
681
+ }
682
+ return writeReferenceOr(state, writeUnknownSymbol, val, parent, accessor);
683
+ }
684
+ function writeUnknownSymbol(state) {
685
+ state.buf.push("Symbol()");
686
+ return true;
687
+ }
688
+ function writeNever() {
689
+ return false;
690
+ }
691
+ function writeNull(state) {
692
+ state.buf.push("null");
693
+ return true;
694
+ }
695
+ function writeObject(state, val, parent, accessor) {
696
+ if (val === null) return writeNull(state);
697
+ const wellKnownObject = KNOWN_OBJECTS.get(val);
698
+ if (wellKnownObject) {
699
+ state.buf.push(wellKnownObject);
700
+ return true;
701
+ }
702
+ return writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
703
+ }
704
+ function writeUnknownObject(state, val, ref) {
705
+ switch (val.constructor) {
706
+ case void 0:
707
+ return writeNullObject(state, val, ref);
708
+ case Object:
709
+ return writePlainObject(state, val, ref);
710
+ case Array:
711
+ return writeArray(state, val, ref);
712
+ case Date:
713
+ return writeDate(state, val);
714
+ case RegExp:
715
+ return writeRegExp(state, val);
716
+ case Promise:
717
+ return writePromise(state, val, ref);
718
+ case Map:
719
+ return writeMap(state, val, ref);
720
+ case Set:
721
+ return writeSet(state, val, ref);
722
+ case Generator:
723
+ return writeGenerator(state, val, ref);
724
+ case AsyncGenerator:
725
+ return writeAsyncGenerator(state, val, ref);
726
+ case Error:
727
+ case EvalError:
728
+ case RangeError:
729
+ case ReferenceError:
730
+ case SyntaxError:
731
+ case TypeError:
732
+ case URIError:
733
+ return writeError(state, val, ref);
734
+ case AggregateError:
735
+ return writeAggregateError(state, val, ref);
736
+ case ArrayBuffer:
737
+ return writeArrayBuffer(state, val);
738
+ case Int8Array:
739
+ case Uint8Array:
740
+ case Uint8ClampedArray:
741
+ case Int16Array:
742
+ case Uint16Array:
743
+ case Int32Array:
744
+ case Uint32Array:
745
+ case Float32Array:
746
+ case Float64Array:
747
+ return writeTypedArray(state, val, ref);
748
+ case WeakSet:
749
+ return writeWeakSet(state);
750
+ case WeakMap:
751
+ return writeWeakMap(state);
752
+ // The following references use `globalThis`
753
+ // since they are not implemented by all runtimes.
754
+ case globalThis.URL:
755
+ return writeURL(state, val);
756
+ case globalThis.URLSearchParams:
757
+ return writeURLSearchParams(state, val);
758
+ case globalThis.Headers:
759
+ return writeHeaders(state, val);
760
+ case globalThis.FormData:
761
+ return writeFormData(state, val);
762
+ case globalThis.ReadableStream:
763
+ return writeReadableStream(state, val, ref);
764
+ case globalThis.Request:
765
+ return writeRequest(state, val, ref);
766
+ case globalThis.Response:
767
+ return writeResponse(state, val, ref);
768
+ }
769
+ return false;
770
+ }
771
+ function writePlainObject(state, val, ref) {
772
+ state.buf.push("{");
773
+ writeObjectProps(state, val, ref);
774
+ state.buf.push("}");
775
+ return true;
776
+ }
777
+ function writeArray(state, val, ref) {
778
+ state.buf.push("[");
779
+ writeProp(state, val[0], ref, "0");
780
+ for (let i = 1; i < val.length; i++) {
781
+ state.buf.push(",");
782
+ writeProp(state, val[i], ref, "" + i);
783
+ }
784
+ state.buf.push("]");
785
+ return true;
786
+ }
787
+ function writeDate(state, val) {
788
+ state.buf.push('new Date("' + val.toISOString() + '")');
789
+ return true;
790
+ }
791
+ function writeRegExp(state, val) {
792
+ state.buf.push(val + "");
793
+ return true;
794
+ }
795
+ function writePromise(state, val, ref) {
796
+ const { boundary } = state;
797
+ if (!boundary) return false;
798
+ const pId = nextRefAccess(state);
799
+ const pRef = new Reference(ref, null, state.flush, null, pId);
800
+ state.buf.push("new Promise((f,r)=>" + pId + "={f,r})");
801
+ val.then(
802
+ (v) => writeAsyncCall(state, boundary, pRef, "f", v, pId),
803
+ (v) => writeAsyncCall(state, boundary, pRef, "r", v, pId)
804
+ );
805
+ boundary.startAsync();
806
+ return true;
807
+ }
808
+ function writeMap(state, val, ref) {
809
+ if (!val.size) {
810
+ state.buf.push("new Map");
811
+ return true;
812
+ }
813
+ const items = [];
814
+ let assigns = "";
815
+ for (let [itemKey, itemValue] of val) {
816
+ if (itemKey === val) {
817
+ itemKey = void 0;
818
+ assigns += "i[" + items.length + "][0]=";
819
+ }
820
+ if (itemValue === val) {
821
+ itemValue = void 0;
822
+ assigns += "i[" + items.length + "][1]=";
823
+ }
824
+ if (itemValue === void 0) {
825
+ items.push([itemKey]);
826
+ } else {
827
+ items.push([itemKey, itemValue]);
828
+ }
829
+ }
830
+ const arrayRef = new Reference(
831
+ ref,
832
+ null,
833
+ state.flush,
834
+ null,
835
+ nextRefAccess(state)
836
+ );
837
+ state.buf.push(
838
+ (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
839
+ );
840
+ writeArray(state, items, arrayRef);
841
+ state.buf.push(")");
842
+ return true;
843
+ }
844
+ function writeSet(state, val, ref) {
845
+ if (!val.size) {
846
+ state.buf.push("new Set");
847
+ return true;
848
+ }
849
+ const items = [];
850
+ let assigns = "";
851
+ for (let item of val) {
852
+ if (item === val) {
853
+ item = void 0;
854
+ assigns += "i[" + items.length + "]=";
855
+ }
856
+ items.push(item);
857
+ }
858
+ const arrayRef = new Reference(
859
+ ref,
860
+ null,
861
+ state.flush,
862
+ null,
863
+ nextRefAccess(state)
864
+ );
865
+ state.buf.push(
866
+ (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
867
+ );
868
+ writeArray(state, items, arrayRef);
869
+ state.buf.push(")");
870
+ return true;
871
+ }
872
+ function writeArrayBuffer(state, val) {
873
+ let result = "";
874
+ if (val.byteLength) {
875
+ const view = new Int8Array(val);
876
+ result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
877
+ } else {
878
+ result = "new ArrayBuffer";
879
+ }
880
+ state.buf.push(result);
881
+ return true;
882
+ }
883
+ function writeTypedArray(state, val, ref) {
884
+ if (val.byteOffset || state.refs.has(val.buffer)) {
885
+ state.buf.push("new " + val.constructor.name + "(");
886
+ writeProp(state, val.buffer, ref, "buffer");
887
+ state.buf.push(val.byteOffset ? "," + val.byteOffset + ")" : ")");
888
+ } else {
889
+ state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null));
890
+ state.buf.push(
891
+ "new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")")
892
+ );
893
+ }
894
+ return true;
895
+ }
896
+ function writeWeakSet(state) {
897
+ state.buf.push("new WeakSet");
898
+ return true;
899
+ }
900
+ function writeWeakMap(state) {
901
+ state.buf.push("new WeakMap");
902
+ return true;
903
+ }
904
+ function writeError(state, val, ref) {
905
+ const result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
906
+ if (val.cause) {
907
+ state.buf.push(result + ",{cause:");
908
+ writeProp(state, val.cause, ref, "cause");
909
+ state.buf.push("})");
910
+ } else {
911
+ state.buf.push(result + ")");
912
+ }
913
+ return true;
914
+ }
915
+ function writeAggregateError(state, val, ref) {
916
+ state.buf.push("new AggregateError(");
917
+ writeProp(state, val.errors, ref, "errors");
918
+ if (val.message) {
919
+ state.buf.push("," + quote(val.message + "", 0) + ")");
920
+ } else {
921
+ state.buf.push(")");
922
+ }
923
+ return true;
924
+ }
925
+ function writeURL(state, val) {
926
+ state.buf.push("new URL(" + quote(val.toString(), 0) + ")");
927
+ return true;
928
+ }
929
+ function writeURLSearchParams(state, val) {
930
+ const str = val.toString();
931
+ if (str) {
932
+ state.buf.push("new URLSearchParams(" + quote(str, 0) + ")");
933
+ } else {
934
+ state.buf.push("new URLSearchParams");
935
+ }
936
+ return true;
937
+ }
938
+ function writeHeaders(state, val) {
939
+ const headers = stringEntriesToProps(val);
940
+ state.buf.push("new Headers" + (headers ? "({" + headers + "})" : ""));
941
+ return true;
942
+ }
943
+ function writeFormData(state, val) {
944
+ let sep = "[";
945
+ let valStr = "";
946
+ for (const [key, value] of val) {
947
+ if (typeof value === "string") {
948
+ valStr += sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]";
949
+ sep = ",";
950
+ }
951
+ }
952
+ if (sep === "[") {
953
+ state.buf.push("new FormData");
954
+ } else {
955
+ state.buf.push(
956
+ "((f,i)=>(f,i.forEach(i=>f.append(i[0],i[1])),f))(new FormData," + valStr + "])"
957
+ );
958
+ }
959
+ return true;
960
+ }
961
+ function writeRequest(state, val, ref) {
962
+ let sep = "";
963
+ const hasBody = val.body && !val.bodyUsed && val.duplex === "half";
964
+ state.buf.push("new Request(" + quote(val.url, 0));
965
+ if (hasBody) {
966
+ state.buf.push(",{body:");
967
+ if (writeProp(state, val.body, ref, "body")) {
968
+ state.buf.push(',duplex:"half"');
969
+ sep = ",";
970
+ } else {
971
+ state.buf.pop();
972
+ }
973
+ }
974
+ let options = "";
975
+ if (val.cache !== "default") {
976
+ options += sep + "cache:" + quote(val.cache, 0);
977
+ sep = ",";
978
+ }
979
+ if (val.credentials !== "same-origin") {
980
+ options += sep + "credentials:" + quote(val.credentials, 0);
981
+ sep = ",";
982
+ }
983
+ const headers = stringEntriesToProps(val.headers);
984
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
985
+ if (headers) {
986
+ options += sep + "headers:{" + headers + "}";
987
+ sep = ",";
988
+ }
989
+ if (val.integrity) {
990
+ options += sep + "integrity:" + quote(val.integrity, 0);
991
+ sep = ",";
992
+ }
993
+ if (val.keepalive) {
994
+ options += sep + "keepalive:true";
995
+ sep = ",";
996
+ }
997
+ if (val.method !== "GET") {
998
+ options += sep + "method:" + quote(val.method, 0);
999
+ sep = ",";
1000
+ }
1001
+ if (val.mode !== "cors") {
1002
+ options += sep + "mode:" + quote(val.mode, 0);
1003
+ sep = ",";
1004
+ }
1005
+ if (val.redirect !== "follow") {
1006
+ options += sep + "redirect:" + quote(val.redirect, 0);
1007
+ sep = ",";
1008
+ }
1009
+ if (val.referrer !== "about:client") {
1010
+ options += sep + "referrer:" + quote(val.referrer, 0);
1011
+ sep = ",";
1012
+ }
1013
+ if (val.referrerPolicy) {
1014
+ options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0);
1015
+ sep = ",";
1016
+ }
1017
+ state.buf.push(
1018
+ hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
1019
+ );
1020
+ return true;
1021
+ }
1022
+ function writeResponse(state, val, ref) {
1023
+ let sep = "";
1024
+ let options = "";
1025
+ if (val.status !== 200) {
1026
+ options += "status:" + val.status;
1027
+ sep = ",";
1028
+ }
1029
+ if (val.statusText) {
1030
+ options += sep + "statusText:" + quote(val.statusText, 0);
1031
+ sep = ",";
1032
+ }
1033
+ const headers = stringEntriesToProps(val.headers);
1034
+ state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null));
1035
+ if (headers) {
1036
+ options += sep + "headers:{" + headers + "}";
1037
+ sep = ",";
1038
+ }
1039
+ if (!val.body || val.bodyUsed) {
1040
+ state.buf.push(
1041
+ "new Response" + (options ? "(null,{" + options + "})" : "")
1042
+ );
1043
+ } else {
1044
+ state.buf.push("new Response(");
1045
+ state.buf.push(
1046
+ (writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
1047
+ );
1048
+ }
1049
+ return true;
1050
+ }
1051
+ function writeReadableStream(state, val, ref) {
1052
+ const { boundary } = state;
1053
+ if (!boundary || val.locked) return false;
1054
+ const reader = val.getReader();
1055
+ const iterId = nextRefAccess(state);
1056
+ const iterRef = new Reference(ref, null, state.flush, null, iterId);
1057
+ const onFulfilled = ({ value, done }) => {
1058
+ if (done) {
1059
+ writeAsyncCall(state, boundary, iterRef, "r", value);
1060
+ } else if (!boundary.signal.aborted) {
1061
+ reader.read().then(onFulfilled, onRejected);
1062
+ boundary.startAsync();
1063
+ writeAsyncCall(state, boundary, iterRef, "f", value);
1064
+ }
1065
+ };
1066
+ const onRejected = (reason) => {
1067
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
1068
+ };
1069
+ state.buf.push(
1070
+ "new ReadableStream({start(c){(async(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()]))=>{for(i of a)v=await i,i==l?c.close():c.enqueue(v)})(" + iterId + "={}).catch(e=>c.error(e))}})"
1071
+ );
1072
+ reader.read().then(onFulfilled, onRejected);
1073
+ boundary.startAsync();
1074
+ return true;
1075
+ }
1076
+ function writeGenerator(state, iter, ref) {
1077
+ let sep = "";
1078
+ state.buf.push("(function*(){");
1079
+ while (true) {
1080
+ const { value, done } = iter.next();
1081
+ if (done) {
1082
+ if (value !== void 0) {
1083
+ state.buf.push(sep + "return ");
1084
+ writeProp(state, value, ref, "");
1085
+ }
1086
+ break;
1087
+ }
1088
+ if (value === void 0) {
1089
+ state.buf.push(sep + "yield");
1090
+ } else {
1091
+ state.buf.push(sep + "yield ");
1092
+ writeProp(state, value, ref, "");
1093
+ }
1094
+ sep = ";";
1095
+ }
1096
+ state.buf.push("})()");
1097
+ return true;
1098
+ }
1099
+ function writeAsyncGenerator(state, iter, ref) {
1100
+ const { boundary } = state;
1101
+ if (!boundary) return false;
1102
+ const iterId = nextRefAccess(state);
1103
+ const iterRef = new Reference(ref, null, state.flush, null, iterId);
1104
+ const onFulfilled = ({ value, done }) => {
1105
+ if (done) {
1106
+ writeAsyncCall(state, boundary, iterRef, "r", value);
1107
+ } else if (!boundary.signal.aborted) {
1108
+ iter.next().then(onFulfilled, onRejected);
1109
+ boundary.startAsync();
1110
+ writeAsyncCall(state, boundary, iterRef, "f", value);
1111
+ }
1112
+ };
1113
+ const onRejected = (reason) => {
1114
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
1115
+ };
1116
+ state.buf.push(
1117
+ "(async function*(_,f,v,l,i,p=a=>l=new Promise((r,j)=>{f=_.r=r;_.j=j}),a=((_.f=v=>{f(v);a.push(p())}),[p()])){for(i of a)v=await i,i!=l&&(yield v);return v})(" + iterId + "={})"
1118
+ );
1119
+ iter.next().then(onFulfilled, onRejected);
1120
+ boundary.startAsync();
1121
+ return true;
1122
+ }
1123
+ function writeNullObject(state, val, ref) {
1124
+ state.buf.push("{");
1125
+ state.buf.push(writeObjectProps(state, val, ref) + "__proto__:null}");
1126
+ return true;
1127
+ }
1128
+ function writeObjectProps(state, val, ref) {
1129
+ let sep = "";
1130
+ for (const key in val) {
1131
+ if (hasOwnProperty.call(val, key)) {
1132
+ const escapedKey = toObjectKey(key);
1133
+ state.buf.push(sep + escapedKey + ":");
1134
+ if (writeProp(
1135
+ state,
1136
+ val[key],
1137
+ ref,
1138
+ escapedKey
1139
+ )) {
1140
+ sep = ",";
1141
+ } else {
1142
+ state.buf.pop();
1143
+ }
1144
+ }
1145
+ }
1146
+ if (hasSymbolIterator(val)) {
1147
+ state.buf.push(sep + "[Symbol.iterator]:");
1148
+ sep = ",";
1149
+ if (!writeReferenceOr(
1150
+ state,
1151
+ writeNever,
1152
+ val[Symbol.iterator],
1153
+ ref,
1154
+ "Symbol.iterator"
1155
+ )) {
1156
+ const arrayRef = new Reference(
1157
+ ref,
1158
+ null,
1159
+ state.flush,
1160
+ null,
1161
+ nextRefAccess(state)
1162
+ );
1163
+ state.buf.push("(a=>()=>a.values())(" + arrayRef.id + "=");
1164
+ writeArray(state, [...val], arrayRef);
1165
+ state.buf.push(")");
1166
+ }
1167
+ }
1168
+ return sep;
1169
+ }
1170
+ function writeAsyncCall(state, boundary, ref, method, value, preferredValueId = null) {
1171
+ if (boundary.signal.aborted) return;
1172
+ state.flushed = true;
1173
+ const valueStartIndex = state.buf.push(
1174
+ (state.buf.length === 0 ? "" : ",") + ref.id + "." + method + "("
1175
+ );
1176
+ if (writeProp(state, value, ref, "")) {
1177
+ const valueRef = state.refs.get(value);
1178
+ if (valueRef && !valueRef.id) {
1179
+ valueRef.id = preferredValueId || nextRefAccess(state);
1180
+ state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex];
1181
+ }
1182
+ }
1183
+ state.buf.push(")");
1184
+ boundary.endAsync();
1185
+ }
1186
+ function isCircular(parent, ref) {
1187
+ let cur = parent;
1188
+ while (cur) {
1189
+ if (cur === ref) return true;
1190
+ cur = cur.parent;
1191
+ }
1192
+ return false;
1193
+ }
1194
+ function toObjectKey(name) {
1195
+ if (name === "") {
1196
+ return '""';
1197
+ }
1198
+ const startChar = name[0];
1199
+ if (isDigit(startChar)) {
1200
+ if (startChar === "0") {
1201
+ if (name !== "0") {
1202
+ return quote(name, 1);
1203
+ }
1204
+ } else {
1205
+ for (let i = 1; i < name.length; i++) {
1206
+ if (!isDigit(name[i])) {
1207
+ return quote(name, i);
1208
+ }
1209
+ }
1210
+ }
1211
+ } else if (isWord(startChar)) {
1212
+ for (let i = 1; i < name.length; i++) {
1213
+ if (!isWordOrDigit(name[i])) {
1214
+ return quote(name, i);
1215
+ }
1216
+ }
1217
+ } else {
1218
+ return quote(name, 0);
1219
+ }
1220
+ return name;
1221
+ }
1222
+ function toAccess(accessor) {
1223
+ const start = accessor[0];
1224
+ return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
1225
+ }
1226
+ function quote(str, startPos) {
1227
+ let result = "";
1228
+ let lastPos = 0;
1229
+ for (let i = startPos; i < str.length; i++) {
1230
+ let replacement;
1231
+ switch (str[i]) {
1232
+ case '"':
1233
+ replacement = '\\"';
1234
+ break;
1235
+ case "\\":
1236
+ replacement = "\\\\";
1237
+ break;
1238
+ case "<":
1239
+ replacement = "\\x3C";
1240
+ break;
1241
+ case "\n":
1242
+ replacement = "\\n";
1243
+ break;
1244
+ case "\r":
1245
+ replacement = "\\r";
1246
+ break;
1247
+ case "\u2028":
1248
+ replacement = "\\u2028";
1249
+ break;
1250
+ case "\u2029":
1251
+ replacement = "\\u2029";
1252
+ break;
1253
+ default:
1254
+ continue;
1255
+ }
1256
+ result += str.slice(lastPos, i) + replacement;
1257
+ lastPos = i + 1;
1258
+ }
1259
+ return '"' + (lastPos === startPos ? str : result + str.slice(lastPos)) + '"';
1260
+ }
1261
+ function ensureId(state, ref) {
1262
+ return ref.id || assignId(state, ref);
1263
+ }
1264
+ function assignId(state, ref) {
1265
+ const { pos } = ref;
1266
+ ref.id = nextRefAccess(state);
1267
+ if (pos !== null && ref.flush === state.flush) {
1268
+ if (pos === 0) {
1269
+ state.buf[0] = ref.id + "=" + state.buf[0];
1270
+ } else {
1271
+ state.buf[pos - 1] += ref.id + "=";
1272
+ }
1273
+ return ref.id;
1274
+ }
1275
+ let cur = ref;
1276
+ let accessPrevValue = "";
1277
+ do {
1278
+ accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
1279
+ const parent = cur.parent;
1280
+ if (parent.id) {
1281
+ accessPrevValue = parent.id + accessPrevValue;
1282
+ break;
1283
+ }
1284
+ if (parent.flush === state.flush) {
1285
+ accessPrevValue = ensureId(state, parent) + accessPrevValue;
1286
+ break;
1287
+ }
1288
+ cur = parent;
1289
+ } while (cur);
1290
+ return ref.id + "=" + accessPrevValue;
1291
+ }
1292
+ function nextRefAccess(state) {
1293
+ return "_." + nextId(state);
1294
+ }
1295
+ function nextId(state) {
1296
+ const encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
1297
+ const encodeLen = encodeChars.length;
1298
+ const encodeStartLen = encodeLen - 11;
1299
+ let index = state.ids++;
1300
+ let mod = index % encodeStartLen;
1301
+ let id = encodeChars[mod];
1302
+ index = (index - mod) / encodeStartLen;
1303
+ while (index > 0) {
1304
+ mod = index % encodeLen;
1305
+ id += encodeChars[mod];
1306
+ index = (index - mod) / encodeLen;
1307
+ }
1308
+ return id;
1309
+ }
1310
+ function hasSymbolIterator(value) {
1311
+ return Symbol.iterator in value;
1312
+ }
1313
+ function stringEntriesToProps(entries) {
1314
+ let result = "";
1315
+ let sep = "";
1316
+ for (const [key, value] of entries) {
1317
+ result += sep + toObjectKey(key) + ":" + quote(value, 0);
1318
+ sep = ",";
1319
+ }
1320
+ return result;
1321
+ }
1322
+ function typedArrayToInitString(view) {
1323
+ let result = "[";
1324
+ let sep = "";
1325
+ for (let i = 0; i < view.length; i++) {
1326
+ result += sep + view[i];
1327
+ sep = ",";
1328
+ }
1329
+ result += "]";
1330
+ return result;
1331
+ }
1332
+ function hasOnlyZeros(typedArray) {
1333
+ for (let i = 0; i < typedArray.length; i++) {
1334
+ if (typedArray[i] !== 0) return false;
1335
+ }
1336
+ return true;
1337
+ }
1338
+ function isWordOrDigit(char) {
1339
+ return isWord(char) || isDigit(char);
1340
+ }
1341
+ function isDigit(char) {
1342
+ return char >= "0" && char <= "9";
1343
+ }
1344
+ function isWord(char) {
1345
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
1346
+ }
1347
+
1348
+ // src/html/writer.ts
1349
+ var $chunk;
1350
+ var NOOP = () => {
1351
+ };
1352
+ var K_SCOPE_ID = Symbol("Scope ID");
1353
+ function getChunk() {
1354
+ return $chunk;
1355
+ }
1356
+ function getScopeId(scope) {
1357
+ return scope[K_SCOPE_ID];
1358
+ }
1359
+ function write(html) {
1360
+ $chunk.writeHTML(html);
1361
+ }
1362
+ function writeScript(script) {
1363
+ $chunk.writeScript(script);
1364
+ }
1365
+ function writeEffect(scopeId, registryId) {
1366
+ $chunk.boundary.state.needsMainRuntime = true;
1367
+ $chunk.writeEffect(scopeId, registryId);
1368
+ }
1369
+ var kPendingContexts = Symbol("Pending Contexts");
1370
+ function withContext(key, value, cb) {
1371
+ const ctx = $chunk.context ||= { [kPendingContexts]: 0 };
1372
+ const prev = ctx[key];
1373
+ ctx[kPendingContexts]++;
1374
+ ctx[key] = value;
1375
+ try {
1376
+ cb();
1377
+ } finally {
1378
+ ctx[kPendingContexts]--;
1379
+ ctx[key] = prev;
1380
+ }
1381
+ }
1382
+ function register2(val, id, scopeId) {
1383
+ return scopeId === void 0 ? register(id, val) : register(id, val, ensureScopeWithId(scopeId));
1384
+ }
1385
+ function nextTagId() {
1386
+ const state = $chunk.boundary.state;
1387
+ const { $global: $global2 } = state;
1388
+ return "s" + $global2.runtimeId + $global2.renderId + (state.tagIndex++).toString(36);
1389
+ }
1390
+ function nextScopeId() {
1391
+ return $chunk.boundary.state.scopeIndex++;
1392
+ }
1393
+ function peekNextScopeId() {
1394
+ return $chunk.boundary.state.scopeIndex;
1395
+ }
1396
+ function peekNextScope() {
1397
+ return ensureScopeWithId(peekNextScopeId());
1398
+ }
1399
+ function getScopeById(scopeId) {
1400
+ if (scopeId !== void 0) {
1401
+ return $chunk.boundary.state.scopes.get(scopeId);
1402
+ }
1403
+ }
1404
+ function markResumeNode(scopeId, accessor) {
1405
+ const { state } = $chunk.boundary;
1406
+ state.needsMainRuntime = true;
1407
+ return state.mark("*" /* Node */, scopeId + " " + accessor);
1408
+ }
1409
+ function nodeRef(scopeId, id) {
1410
+ const getter = () => {
1411
+ if (true) {
1412
+ throw new Error("Cannot read a node reference on the server.");
1413
+ }
1414
+ };
1415
+ return id ? register2(getter, id, scopeId) : getter;
1416
+ }
1417
+ function markResumeScopeStart(scopeId, index) {
1418
+ return $chunk.boundary.state.mark(
1419
+ "[" /* SectionStart */,
1420
+ scopeId + (index ? " " + index : "")
1421
+ );
1422
+ }
1423
+ function markResumeControlEnd(scopeId, accessor) {
1424
+ return $chunk.boundary.state.mark("]" /* SectionEnd */, scopeId + " " + accessor);
1425
+ }
1426
+ function markResumeControlSingleNodeEnd(scopeId, accessor, childScopeIds) {
1427
+ return $chunk.boundary.state.mark(
1428
+ "|" /* SectionSingleNodesEnd */,
1429
+ scopeId + " " + accessor + " " + (childScopeIds ?? "")
1430
+ );
1431
+ }
1432
+ function markResumeCleanup(scopeId) {
1433
+ return $chunk.boundary.state.mark("$" /* Cleanup */, "" + scopeId);
1434
+ }
1435
+ function writeScope(scopeId, partialScope) {
1436
+ const { state } = $chunk.boundary;
1437
+ const { scopes } = state;
1438
+ let scope = scopes.get(scopeId);
1439
+ state.needsMainRuntime = true;
1440
+ if (scope) {
1441
+ Object.assign(scope, partialScope);
1442
+ } else {
1443
+ scope = partialScope;
1444
+ scope[K_SCOPE_ID] = scopeId;
1445
+ state.scopes.set(scopeId, scope);
1446
+ }
1447
+ if (state.writeScopes) {
1448
+ state.writeScopes[scopeId] = scope;
1449
+ } else if (state.hasGlobals) {
1450
+ state.writeScopes = { [scopeId]: scope };
1451
+ } else {
1452
+ state.hasGlobals = true;
1453
+ state.writeScopes = {
1454
+ $: getFilteredGlobals(state.$global),
1455
+ [scopeId]: scope
1456
+ };
1457
+ }
1458
+ return scope;
1459
+ }
1460
+ function writeExistingScope(scope) {
1461
+ return writeScope(scope[K_SCOPE_ID], scope);
1462
+ }
1463
+ function ensureScopeWithId(scopeId) {
1464
+ const { state } = $chunk.boundary;
1465
+ let scope = state.scopes.get(scopeId);
1466
+ if (!scope) {
1467
+ scope = { [K_SCOPE_ID]: scopeId };
1468
+ state.scopes.set(scopeId, scope);
1469
+ }
1470
+ return scope;
1471
+ }
1472
+ function $global() {
1473
+ return $chunk.boundary.state.$global;
1474
+ }
1475
+ function fork(promise, renderBody) {
1476
+ if (!isPromise(promise)) {
1477
+ renderBody(promise);
1478
+ return;
1479
+ }
1480
+ const chunk = $chunk;
1481
+ const { boundary } = chunk;
1482
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context);
1483
+ chunk.async = true;
1484
+ if (chunk.context?.[kPendingContexts]) {
1485
+ chunk.context = { ...chunk.context, [kPendingContexts]: 0 };
1486
+ }
1487
+ boundary.startAsync();
1488
+ promise.then(
1489
+ (value) => {
1490
+ if (chunk.async) {
1491
+ chunk.async = false;
1492
+ if (!boundary.signal.aborted) {
1493
+ chunk.render(renderBody, value);
1494
+ boundary.endAsync(chunk);
1495
+ }
1496
+ }
1497
+ },
1498
+ (err) => {
1499
+ chunk.async = false;
1500
+ boundary.abort(err);
1501
+ }
1502
+ );
1503
+ }
1504
+ function tryPlaceholder(renderBody, renderPlaceholder) {
1505
+ const chunk = $chunk;
1506
+ const { boundary } = chunk;
1507
+ const body = new Chunk(boundary, null, chunk.context);
1508
+ if (body === body.render(renderBody)) {
1509
+ chunk.append(body);
1510
+ return;
1511
+ }
1512
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1513
+ chunk.placeholderBody = body;
1514
+ chunk.placeholderRender = renderPlaceholder;
1515
+ }
1516
+ function tryCatch(renderBody, renderCatch) {
1517
+ const chunk = $chunk;
1518
+ const { boundary } = chunk;
1519
+ const { state } = boundary;
1520
+ const catchBoundary = new Boundary(state);
1521
+ const body = new Chunk(catchBoundary, null, chunk.context);
1522
+ const bodyEnd = body.render(renderBody);
1523
+ if (catchBoundary.signal.aborted) {
1524
+ renderCatch(catchBoundary.signal.reason);
1525
+ return;
1526
+ }
1527
+ if (body === bodyEnd) {
1528
+ chunk.append(body);
1529
+ return;
1530
+ }
1531
+ const reorderId = state.nextReorderId();
1532
+ const endMarker = state.mark("!" /* PlaceholderEnd */, reorderId);
1533
+ const bodyNext = bodyEnd.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1534
+ chunk.next = body;
1535
+ chunk.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
1536
+ bodyEnd.writeHTML(endMarker);
1537
+ boundary.startAsync();
1538
+ catchBoundary.onNext = () => {
1539
+ if (boundary.signal.aborted) return;
1540
+ if (catchBoundary.signal.aborted) {
1541
+ if (!bodyEnd.consumed) {
1542
+ let cur = body;
1543
+ let writeMarker = true;
1544
+ do {
1545
+ const next = cur.next;
1546
+ if (cur.boundary !== catchBoundary) {
1547
+ cur.boundary.abort(catchBoundary.signal.reason);
1548
+ }
1549
+ if (writeMarker && !cur.consumed) {
1550
+ writeMarker = false;
1551
+ cur.async = false;
1552
+ cur.next = bodyNext;
1553
+ cur.html = endMarker;
1554
+ cur.scripts = cur.effects = "";
1555
+ cur.placeholderBody = cur.placeholderRender = cur.reorderId = null;
1556
+ }
1557
+ cur = next;
1558
+ } while (cur !== bodyNext);
1559
+ }
1560
+ const catchChunk = new Chunk(boundary, null, chunk.context);
1561
+ catchChunk.reorderId = reorderId;
1562
+ catchChunk.render(renderCatch, catchBoundary.signal.reason);
1563
+ state.reorder(catchChunk);
1564
+ boundary.endAsync();
1565
+ } else if (catchBoundary.done) {
1566
+ boundary.endAsync();
1567
+ } else {
1568
+ boundary.onNext();
1569
+ }
1570
+ };
1571
+ }
1572
+ var State2 = class {
1573
+ constructor($global2) {
1574
+ this.$global = $global2;
1575
+ this.$global = $global2;
1576
+ if ($global2.cspNonce) {
1577
+ this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + "");
1578
+ }
1579
+ }
1580
+ tagIndex = 0;
1581
+ scopeIndex = 0;
1582
+ reorderIndex = 0;
1583
+ hasGlobals = false;
1584
+ needsMainRuntime = false;
1585
+ hasMainRuntime = false;
1586
+ hasReorderRuntime = false;
1587
+ hasWrittenResume = false;
1588
+ trailerHTML = "";
1589
+ nonceAttr = "";
1590
+ serializer = new Serializer();
1591
+ writeReorders = null;
1592
+ scopes = /* @__PURE__ */ new Map();
1593
+ writeScopes = null;
1594
+ get runtimePrefix() {
1595
+ const { $global: $global2 } = this;
1596
+ return $global2.runtimeId + "." + $global2.renderId;
1597
+ }
1598
+ get commentPrefix() {
1599
+ const { $global: $global2 } = this;
1600
+ return $global2.runtimeId + $global2.renderId;
1601
+ }
1602
+ reorder(chunk) {
1603
+ if (this.writeReorders) {
1604
+ this.writeReorders.push(chunk);
1605
+ } else {
1606
+ this.needsMainRuntime = true;
1607
+ this.writeReorders = [chunk];
1608
+ }
1609
+ }
1610
+ nextReorderId() {
1611
+ const encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789";
1612
+ const encodeLen = encodeChars.length;
1613
+ const encodeStartLen = encodeLen - 10;
1614
+ let index = this.reorderIndex++;
1615
+ let mod = index % encodeStartLen;
1616
+ let id = encodeChars[mod];
1617
+ index = (index - mod) / encodeStartLen;
1618
+ while (index > 0) {
1619
+ mod = index % encodeLen;
1620
+ id += encodeChars[mod];
1621
+ index = (index - mod) / encodeLen;
1622
+ }
1623
+ return id;
1624
+ }
1625
+ mark(code, str) {
1626
+ return "<!--" + this.commentPrefix + code + str + "-->";
1627
+ }
1628
+ };
1629
+ var Boundary = class extends AbortController {
1630
+ constructor(state, parent) {
1631
+ super();
1632
+ this.state = state;
1633
+ this.state = state;
1634
+ this.signal.addEventListener("abort", () => {
1635
+ this.count = 0;
1636
+ this.state = new State2(this.state.$global);
1637
+ this.onNext();
1638
+ });
1639
+ if (parent) {
1640
+ if (parent.aborted) {
1641
+ this.abort(parent.reason);
1642
+ } else {
1643
+ parent.addEventListener("abort", () => {
1644
+ this.abort(parent.reason);
1645
+ });
1646
+ }
1647
+ }
1648
+ }
1649
+ onNext = NOOP;
1650
+ count = 0;
1651
+ get done() {
1652
+ return this.count === 0;
1653
+ }
1654
+ startAsync() {
1655
+ if (!this.signal.aborted) {
1656
+ this.count++;
1657
+ }
1658
+ }
1659
+ endAsync(chunk) {
1660
+ if (!this.signal.aborted && this.count) {
1661
+ this.count--;
1662
+ if (chunk?.reorderId) {
1663
+ this.state.reorder(chunk);
1664
+ }
1665
+ this.onNext();
1666
+ }
1667
+ }
1668
+ };
1669
+ var Chunk = class {
1670
+ constructor(boundary, next, context) {
1671
+ this.boundary = boundary;
1672
+ this.next = next;
1673
+ this.context = context;
1674
+ this.boundary = boundary;
1675
+ this.next = next;
1676
+ this.context = context;
1677
+ }
1678
+ html = "";
1679
+ scripts = "";
1680
+ effects = "";
1681
+ async = false;
1682
+ consumed = false;
1683
+ reorderId = null;
1684
+ placeholderBody = null;
1685
+ placeholderRender = null;
1686
+ writeHTML(html) {
1687
+ this.html += html;
1688
+ }
1689
+ writeEffect(scopeId, registryId) {
1690
+ this.effects = concatEffects(
1691
+ this.effects,
1692
+ scopeId + ',"' + registryId + '"'
1693
+ );
1694
+ }
1695
+ writeScript(script) {
1696
+ this.scripts = concatScripts(this.scripts, script);
1697
+ }
1698
+ append(chunk) {
1699
+ this.html += chunk.html;
1700
+ this.effects = concatEffects(this.effects, chunk.effects);
1701
+ this.scripts = concatScripts(this.scripts, chunk.scripts);
1702
+ }
1703
+ flushPlaceholder() {
1704
+ if (this.placeholderBody) {
1705
+ const body = this.placeholderBody.consume();
1706
+ if (body.async) {
1707
+ const { state } = this.boundary;
1708
+ const reorderId = body.reorderId = state.nextReorderId();
1709
+ this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
1710
+ const after = this.render(this.placeholderRender);
1711
+ if (after !== this) {
1712
+ this.boundary.abort(
1713
+ new Error("An @placeholder cannot contain async content.")
1714
+ );
1715
+ }
1716
+ after.writeHTML(state.mark("!" /* PlaceholderEnd */, reorderId));
1717
+ state.reorder(body);
1718
+ } else {
1719
+ body.next = this.next;
1720
+ this.next = body;
1721
+ }
1722
+ this.placeholderRender = this.placeholderBody = null;
1723
+ }
1724
+ }
1725
+ consume() {
1726
+ let cur = this;
1727
+ if (cur.next && !cur.async) {
1728
+ let html = "";
1729
+ let effects = "";
1730
+ let scripts = "";
1731
+ do {
1732
+ cur.flushPlaceholder();
1733
+ html += cur.html;
1734
+ effects += cur.effects;
1735
+ scripts = concatScripts(scripts, cur.scripts);
1736
+ cur.consumed = true;
1737
+ cur = cur.next;
1738
+ } while (cur.next && !cur.async);
1739
+ cur.html = html + cur.html;
1740
+ cur.effects = concatEffects(effects, cur.effects);
1741
+ cur.scripts = concatScripts(scripts, cur.scripts);
1742
+ }
1743
+ return cur;
1744
+ }
1745
+ render(renderBody, val) {
1746
+ const prev = $chunk;
1747
+ $chunk = this;
1748
+ try {
1749
+ renderBody(val);
1750
+ return $chunk;
1751
+ } catch (err) {
1752
+ this.boundary.abort(err);
1753
+ return this;
1754
+ } finally {
1755
+ $chunk = prev;
1756
+ }
1757
+ }
1758
+ };
1759
+ function prepareChunk(chunk) {
1760
+ const head = chunk.consume();
1761
+ const { boundary, effects } = head;
1762
+ const { state } = boundary;
1763
+ const { $global: $global2, runtimePrefix, serializer, nonceAttr } = state;
1764
+ let { html, scripts } = head;
1765
+ let hasWalk = false;
1766
+ head.effects = "";
1767
+ if (state.needsMainRuntime && !state.hasMainRuntime) {
1768
+ state.hasMainRuntime = true;
1769
+ scripts = concatScripts(
1770
+ scripts,
1771
+ WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1772
+ );
1773
+ }
1774
+ let resumes = "";
1775
+ if (state.writeScopes || serializer.flushed) {
1776
+ resumes = state.serializer.stringify(state.writeScopes || {}, boundary);
1777
+ state.writeScopes = null;
1778
+ }
1779
+ if (effects) {
1780
+ hasWalk = true;
1781
+ resumes = resumes ? resumes + "," + effects : effects;
1782
+ }
1783
+ if (boundary.done && (resumes || state.hasWrittenResume)) {
1784
+ resumes = resumes ? resumes + ",0" : "0";
1785
+ }
1786
+ if (resumes) {
1787
+ if (state.hasWrittenResume) {
1788
+ scripts = concatScripts(
1789
+ scripts,
1790
+ runtimePrefix + ".r.push(" + resumes + ")"
1791
+ );
1792
+ } else {
1793
+ state.hasWrittenResume = true;
1794
+ scripts = concatScripts(
1795
+ scripts,
1796
+ runtimePrefix + ".r=[" + resumes + "]"
1797
+ );
1798
+ }
1799
+ }
1800
+ if (state.writeReorders) {
1801
+ hasWalk = true;
1802
+ if (!state.hasReorderRuntime) {
1803
+ state.hasReorderRuntime = true;
1804
+ html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>";
1805
+ scripts = concatScripts(
1806
+ scripts,
1807
+ REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1808
+ );
1809
+ }
1810
+ for (const reorderedChunk of state.writeReorders) {
1811
+ const { reorderId } = reorderedChunk;
1812
+ let isSync = true;
1813
+ let reorderHTML = "";
1814
+ let reorderEffects = "";
1815
+ let reorderScripts = "";
1816
+ let cur = reorderedChunk;
1817
+ reorderedChunk.reorderId = null;
1818
+ for (; ; ) {
1819
+ cur.flushPlaceholder();
1820
+ reorderHTML += cur.html;
1821
+ reorderEffects = concatEffects(reorderEffects, cur.effects);
1822
+ reorderScripts = concatScripts(reorderScripts, cur.scripts);
1823
+ if (cur.async) {
1824
+ reorderHTML += state.mark(
1825
+ "#" /* ReorderMarker */,
1826
+ cur.reorderId = state.nextReorderId()
1827
+ );
1828
+ cur.html = cur.effects = cur.scripts = "";
1829
+ isSync = false;
1830
+ }
1831
+ if (cur.next) {
1832
+ cur = cur.next;
1833
+ } else {
1834
+ break;
1835
+ }
1836
+ }
1837
+ if (reorderEffects) {
1838
+ if (!state.hasWrittenResume) {
1839
+ state.hasWrittenResume = true;
1840
+ scripts = concatScripts(
1841
+ scripts,
1842
+ runtimePrefix + ".r=[]"
1843
+ );
1844
+ }
1845
+ reorderScripts = concatScripts(
1846
+ reorderScripts,
1847
+ "_.push(" + reorderEffects + ")"
1848
+ );
1849
+ }
1850
+ scripts = concatScripts(
1851
+ scripts,
1852
+ reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1853
+ );
1854
+ html += "<t " + (isSync ? "c " : "") + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1855
+ }
1856
+ state.writeReorders = null;
1857
+ }
1858
+ if (hasWalk) {
1859
+ scripts = concatScripts(scripts, runtimePrefix + ".w()");
1860
+ }
1861
+ head.html = html;
1862
+ head.scripts = scripts;
1863
+ return head;
1864
+ }
1865
+ function flushChunk(head, last) {
1866
+ const { boundary } = head;
1867
+ const { state } = boundary;
1868
+ const { html, scripts } = head;
1869
+ const { $global: $global2 } = state;
1870
+ const { __flush__ } = $global2;
1871
+ let result = html;
1872
+ head.html = head.scripts = "";
1873
+ if (scripts) {
1874
+ result += "<script" + state.nonceAttr + ">" + scripts + "</script>";
1875
+ }
1876
+ if (__flush__) {
1877
+ $global2.__flush__ = void 0;
1878
+ result = __flush__($global2, result);
1879
+ }
1880
+ if (last && state.trailerHTML) {
1881
+ result += state.trailerHTML;
1882
+ }
1883
+ return result;
1884
+ }
1885
+ function writeTrailers(html) {
1886
+ $chunk.boundary.state.trailerHTML += html;
1887
+ }
1888
+ function concatEffects(a, b) {
1889
+ return a ? b ? a + "," + b : a : b;
1890
+ }
1891
+ function concatScripts(a, b) {
1892
+ return a ? b ? a + ";" + b : a : b;
1893
+ }
1894
+ var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb));
1895
+ var tickQueue;
1896
+ function queueTick(cb) {
1897
+ if (tickQueue) {
1898
+ tickQueue.add(cb);
1899
+ } else {
1900
+ tickQueue = /* @__PURE__ */ new Set([cb]);
1901
+ tick(flushTickQueue);
1902
+ }
1903
+ }
1904
+ function offTick(cb) {
1905
+ tickQueue?.delete(cb);
1906
+ }
1907
+ function flushTickQueue() {
1908
+ const queue = tickQueue;
1909
+ tickQueue = void 0;
1910
+ for (const cb of queue) {
1911
+ cb(true);
1912
+ }
1913
+ }
1914
+ function isPromise(value) {
1915
+ return value != null && typeof value.then === "function";
1916
+ }
1917
+ function getFilteredGlobals($global2) {
1918
+ if (!$global2) return void 0;
1919
+ const serializedGlobals = $global2.serializedGlobals;
1920
+ if (!serializedGlobals) return void 0;
1921
+ let filtered;
1922
+ if (Array.isArray(serializedGlobals)) {
1923
+ for (const key of serializedGlobals) {
1924
+ const value = $global2[key];
1925
+ if (value !== void 0) {
1926
+ if (filtered) {
1927
+ filtered[key] = value;
1928
+ } else {
1929
+ filtered = { [key]: value };
1930
+ }
1931
+ }
1932
+ }
1933
+ } else {
1934
+ for (const key in serializedGlobals) {
1935
+ if (serializedGlobals[key]) {
1936
+ const value = $global2[key];
1937
+ if (value !== void 0) {
1938
+ if (filtered) {
1939
+ filtered[key] = value;
1940
+ } else {
1941
+ filtered = { [key]: value };
1942
+ }
1943
+ }
1944
+ }
1945
+ }
1946
+ }
1947
+ return filtered;
1948
+ }
1949
+
1950
+ // src/html/attrs.ts
1951
+ function classAttr(val) {
1952
+ return stringAttr("class", classValue(val));
1953
+ }
1954
+ function styleAttr(val) {
1955
+ return stringAttr("style", styleValue(val));
1956
+ }
1957
+ function optionValueAttr(value) {
1958
+ const { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
1959
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? ` selected` : "");
1960
+ }
1961
+ var kSelectedValue = Symbol("selectedValue");
1962
+ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, renderBody) {
1963
+ if (valueChange) {
1964
+ writeControlledScope(
1965
+ 3 /* SelectValue */,
1966
+ scopeId,
1967
+ nodeAccessor,
1968
+ value,
1969
+ valueChange
1970
+ );
1971
+ }
1972
+ if (renderBody) {
1973
+ withContext(kSelectedValue, value, renderBody);
1974
+ }
1975
+ }
1976
+ function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1977
+ if (valueChange) {
1978
+ writeControlledScope(
1979
+ 2 /* InputValue */,
1980
+ scopeId,
1981
+ nodeAccessor,
1982
+ void 0,
1983
+ valueChange
1984
+ );
1985
+ }
1986
+ return escapeTextAreaValue(value);
1987
+ }
1988
+ function controllable_input_value(scopeId, nodeAccessor, value, valueChange) {
1989
+ if (valueChange) {
1990
+ writeControlledScope(
1991
+ 2 /* InputValue */,
1992
+ scopeId,
1993
+ nodeAccessor,
1994
+ void 0,
1995
+ valueChange
1996
+ );
1997
+ }
1998
+ return attr("value", value);
1999
+ }
2000
+ function controllable_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
2001
+ if (checkedChange) {
2002
+ writeControlledScope(
2003
+ 0 /* InputChecked */,
2004
+ scopeId,
2005
+ nodeAccessor,
2006
+ void 0,
2007
+ checkedChange
2008
+ );
2009
+ }
2010
+ return attr("checked", checked);
2011
+ }
2012
+ function controllable_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
2013
+ const multiple = Array.isArray(checkedValue);
2014
+ const valueAttr = attr("value", value);
2015
+ if (checkedValueChange) {
2016
+ writeControlledScope(
2017
+ 1 /* InputCheckedValue */,
2018
+ scopeId,
2019
+ nodeAccessor,
2020
+ multiple ? checkedValue : void 0,
2021
+ checkedValueChange
2022
+ );
2023
+ }
2024
+ return (multiple ? checkedValue.includes(value) : checkedValue === value) ? valueAttr + " checked" : valueAttr;
2025
+ }
2026
+ function controllable_detailsOrDialog_open(scopeId, nodeAccessor, open, openChange) {
2027
+ if (openChange) {
2028
+ writeControlledScope(
2029
+ 4 /* DetailsOrDialogOpen */,
2030
+ scopeId,
2031
+ nodeAccessor,
2032
+ open,
2033
+ openChange
2034
+ );
2035
+ }
2036
+ return attr("open", open);
2037
+ }
2038
+ function attr(name, val) {
2039
+ return isVoid(val) ? "" : nonVoidAttr(name, val);
2040
+ }
2041
+ function attrs(data, nodeAccessor, scopeId, tagName) {
2042
+ let result = "";
2043
+ let skip = /[\s/>"'=]/;
2044
+ let events;
2045
+ switch (tagName) {
2046
+ case "input":
2047
+ if (data.checkedChange) {
2048
+ result += controllable_input_checked(
2049
+ scopeId,
2050
+ nodeAccessor,
2051
+ data.checked,
2052
+ data.checkedChange
2053
+ );
2054
+ } else if (data.checkedValue || data.checkedValueChange) {
2055
+ result += controllable_input_checkedValue(
2056
+ scopeId,
2057
+ nodeAccessor,
2058
+ data.checkedValue,
2059
+ data.checkedValueChange,
2060
+ data.value
2061
+ );
2062
+ } else if (data.valueChange) {
2063
+ result += controllable_input_value(
2064
+ scopeId,
2065
+ nodeAccessor,
2066
+ data.value,
2067
+ data.valueChange
2068
+ );
2069
+ } else {
2070
+ break;
2071
+ }
2072
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
2073
+ break;
2074
+ case "select":
2075
+ case "textarea":
2076
+ if (data.value || data.valueChange) {
2077
+ skip = /^value(?:Change)?$|[\s/>"'=]/;
2078
+ }
2079
+ break;
2080
+ case "option":
2081
+ if (data.value) {
2082
+ result += optionValueAttr(data.value);
2083
+ skip = /^value$|[\s/>"'=]/;
2084
+ }
2085
+ break;
2086
+ case "details":
2087
+ case "dialog":
2088
+ if (data.openChange) {
2089
+ result += controllable_detailsOrDialog_open(
2090
+ scopeId,
2091
+ nodeAccessor,
2092
+ data.open,
2093
+ data.openChange
2094
+ );
2095
+ skip = /^open(?:Change)?$|[\s/>"'=]/;
2096
+ }
2097
+ break;
2098
+ }
2099
+ for (const name in data) {
2100
+ const val = data[name];
2101
+ switch (name) {
2102
+ case "class":
2103
+ result += classAttr(val);
2104
+ break;
2105
+ case "style":
2106
+ result += styleAttr(val);
2107
+ break;
2108
+ case "":
2109
+ case "renderBody":
2110
+ break;
2111
+ default:
2112
+ if (!isVoid(val)) {
2113
+ if (isEventHandler(name)) {
2114
+ if (!events) {
2115
+ events = {};
2116
+ writeScope(scopeId, {
2117
+ [nodeAccessor + "~" /* EventAttributes */]: events
2118
+ });
2119
+ }
2120
+ events[getEventHandlerName(name)] = val;
2121
+ } else if (!skip.test(name)) {
2122
+ result += nonVoidAttr(name, val);
2123
+ }
2124
+ }
2125
+ break;
2126
+ }
2127
+ }
2128
+ return result;
2129
+ }
2130
+ function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
2131
+ const partial = {};
2132
+ for (const key in data) {
2133
+ if (!skip[key]) partial[key] = data[key];
2134
+ }
2135
+ return attrs(partial, nodeAccessor, scopeId, tagName);
2136
+ }
2137
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
2138
+ writeScope(scopeId, {
2139
+ [nodeAccessor + "=" /* ControlledType */]: type,
2140
+ [nodeAccessor + ":" /* ControlledValue */]: value,
2141
+ [nodeAccessor + ";" /* ControlledHandler */]: valueChange
2142
+ });
2143
+ }
2144
+ function stringAttr(name, val) {
2145
+ return val && ` ${name}=${escapeAttrValue(val)}`;
2146
+ }
2147
+ function nonVoidAttr(name, val) {
2148
+ switch (typeof val) {
2149
+ case "string":
2150
+ return ` ${name + attrAssignment(val)}`;
2151
+ case "boolean":
2152
+ return ` ${name}`;
2153
+ case "number":
2154
+ return ` ${name}=${val}`;
2155
+ case "object":
2156
+ if (val instanceof RegExp) {
2157
+ return ` ${name + attrAssignment(val.source)}`;
2158
+ }
2159
+ break;
2160
+ }
2161
+ return ` ${name + attrAssignment(val + "")}`;
2162
+ }
2163
+ function attrAssignment(val) {
2164
+ return val ? `=${escapeAttrValue(val)}` : "";
2165
+ }
2166
+ var unsafeAttrChars = /["'>\s]/g;
2167
+ function escapeAttrValue(str) {
2168
+ if (unsafeAttrChars.test(str)) {
2169
+ const c = str[unsafeAttrChars.lastIndex - 1];
2170
+ unsafeAttrChars.lastIndex = 0;
2171
+ return c === '"' ? `'${str.replace(/'/g, "&#39;")}'` : `"${str.replace(/"/g, "&#34;")}"`;
2172
+ }
2173
+ return str;
2174
+ }
2175
+
2176
+ // src/common/compat-meta.ts
2177
+ var prefix = true ? "$compat_" : "$C_";
2178
+ var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
2179
+ var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
2180
+
2181
+ // src/common/meta.ts
2182
+ var DEFAULT_RUNTIME_ID = "M";
2183
+ var DEFAULT_RENDER_ID = "_";
2184
+
2185
+ // src/html/dynamic-tag.ts
2186
+ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
2187
+ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
2188
+ if (!tag && !renderBody) return void 0;
2189
+ const scopeId = getScopeId(scope);
2190
+ write(`${markResumeScopeStart(scopeId)}`);
2191
+ writeScope(scopeId, scope);
2192
+ if (!tag) {
2193
+ return renderBody();
2194
+ }
2195
+ if (typeof tag === "string") {
2196
+ nextScopeId();
2197
+ write(
2198
+ `<${tag}${attrs(input, true ? `#${tag}/0` : 0, scopeId, tag)}>`
2199
+ );
2200
+ if (!voidElementsReg.test(tag)) {
2201
+ if (tag === "textarea") {
2202
+ if (renderBody) {
2203
+ throw new Error(
2204
+ "A dynamic tag rendering a `<textarea>` cannot have a `renderBody` and must use the `value` attribute instead."
2205
+ );
2206
+ }
2207
+ write(
2208
+ controllable_textarea_value(
2209
+ scopeId,
2210
+ true ? `#${tag}/0` : 0,
2211
+ input.value,
2212
+ input.valueChange
2213
+ )
2214
+ );
2215
+ } else if (renderBody) {
2216
+ if (tag === "select" && ("value" in input || "valueChange" in input)) {
2217
+ controllable_select_value(
2218
+ scopeId,
2219
+ true ? `#${tag}/0` : 0,
2220
+ input.value,
2221
+ input.valueChange,
2222
+ renderBody
2223
+ );
2224
+ } else {
2225
+ renderBody();
2226
+ }
2227
+ }
2228
+ write(`</${tag}>`);
2229
+ } else if (renderBody) {
2230
+ throw new Error(
2231
+ `A renderBody was provided for a "${tag}" tag, which cannot have children.`
2232
+ );
2233
+ }
2234
+ return null;
2235
+ }
2236
+ const renderer = getDynamicRenderer(tag);
2237
+ if (true) {
2238
+ if (typeof renderer !== "function") {
2239
+ throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2240
+ }
2241
+ }
2242
+ return renderer(renderBody ? { ...input, renderBody } : input, tagVar);
2243
+ }
2244
+ function dynamicTagArgs(scope, tag, args) {
2245
+ if (!tag) return void 0;
2246
+ const scopeId = getScopeId(scope);
2247
+ write(`${markResumeScopeStart(scopeId)}`);
2248
+ writeScope(scopeId, scope);
2249
+ if (typeof tag === "string") {
2250
+ nextScopeId();
2251
+ write(
2252
+ `<${tag}${attrs(args[0], true ? `#${tag}/0` : 0, scopeId, tag)}>`
2253
+ );
2254
+ if (!voidElementsReg.test(tag)) {
2255
+ write(`</${tag}>`);
2256
+ }
2257
+ return void 0;
2258
+ }
2259
+ const renderer = getDynamicRenderer(tag);
2260
+ if (true) {
2261
+ if (typeof renderer !== "function") {
2262
+ throw new Error(`Invalid renderer passed for dynamic tag: ${tag}`);
2263
+ }
2264
+ }
2265
+ return renderer(...args);
2266
+ }
2267
+ var getDynamicRenderer = normalizeDynamicRenderer;
2268
+ var createRenderer = (fn) => fn;
2269
+ function patchDynamicTag(newGetDynamicRenderer, newCreateRenderer) {
2270
+ getDynamicRenderer = newGetDynamicRenderer;
2271
+ createRenderer = newCreateRenderer;
2272
+ }
2273
+
2274
+ // src/html/compat.ts
2275
+ var K_TAGS_API_STATE = Symbol();
2276
+ var COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap();
2277
+ var compat = {
2278
+ fork,
2279
+ write,
2280
+ writeScript,
2281
+ nextScopeId,
2282
+ patchDynamicTag,
2283
+ writeSetScopeForComponent(m5c) {
2284
+ const scopeId = nextScopeId();
2285
+ writeScope(scopeId, { m5c });
2286
+ writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
2287
+ },
2288
+ toJSON() {
2289
+ let compatRegistered = COMPAT_REGISTRY.get(this);
2290
+ if (!compatRegistered) {
2291
+ const registered = getRegistered(this);
2292
+ if (registered) {
2293
+ const scopeId = getScopeId(registered.scope);
2294
+ if (scopeId !== void 0) {
2295
+ writeScope(scopeId, {});
2296
+ }
2297
+ COMPAT_REGISTRY.set(
2298
+ this,
2299
+ compatRegistered = [registered.id, scopeId]
2300
+ );
2301
+ }
2302
+ }
2303
+ return compatRegistered;
2304
+ },
2305
+ render(renderer, willRerender, classAPIOut, component, input) {
2306
+ const $global2 = classAPIOut.global;
2307
+ let state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
2308
+ if (!state) {
2309
+ $global2.runtimeId ||= DEFAULT_RUNTIME_ID;
2310
+ $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID;
2311
+ $global2[K_TAGS_API_STATE] = state = new State2($global2);
2312
+ }
2313
+ const boundary = new Boundary(state);
2314
+ let head = new Chunk(
2315
+ boundary,
2316
+ null,
2317
+ null
2318
+ );
2319
+ head.render(() => {
2320
+ if (willRerender) {
2321
+ const scopeId = peekNextScopeId();
2322
+ writeScope(scopeId, { m5c: component.id });
2323
+ writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
2324
+ }
2325
+ renderer(input);
2326
+ });
2327
+ const asyncOut = classAPIOut.beginAsync();
2328
+ (boundary.onNext = () => {
2329
+ if (boundary.done) {
2330
+ if (boundary.signal.aborted) {
2331
+ asyncOut.error(boundary.signal.reason);
2332
+ } else {
2333
+ queueMicrotask(() => {
2334
+ const { scripts, html } = head = prepareChunk(head);
2335
+ asyncOut.script(scripts);
2336
+ asyncOut.write(html);
2337
+ asyncOut.end();
2338
+ head.html = head.scripts = "";
2339
+ });
2340
+ }
2341
+ }
2342
+ })();
2343
+ },
2344
+ registerRenderer(renderer, id) {
2345
+ return register(
2346
+ RENDERER_REGISTER_ID,
2347
+ renderer,
2348
+ register(id, () => {
2349
+ })
2350
+ );
2351
+ }
2352
+ };
2353
+
2354
+ // src/common/for.ts
2355
+ function forIn(obj, cb) {
2356
+ for (const key in obj) {
2357
+ cb(key, obj[key]);
2358
+ }
2359
+ }
2360
+ function forOf(list, cb) {
2361
+ if (list) {
2362
+ let i = 0;
2363
+ for (const item of list) {
2364
+ cb(item, i++);
2365
+ }
2366
+ }
2367
+ }
2368
+ function forTo(to, from, step, cb) {
2369
+ const start = from || 0;
2370
+ const delta = step || 1;
2371
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++) {
2372
+ cb(start + i * delta);
2373
+ }
2374
+ }
2375
+
2376
+ // src/html/for.ts
2377
+ function forOfBy(by, item, index) {
2378
+ if (by) {
2379
+ if (typeof by === "string") {
2380
+ return item[by];
2381
+ }
2382
+ return by(item, index);
2383
+ }
2384
+ return index;
2385
+ }
2386
+ function forInBy(by, name, value) {
2387
+ if (by) {
2388
+ return by(name, value);
2389
+ }
2390
+ return name;
2391
+ }
2392
+ function forToBy(by, index) {
2393
+ if (by) {
2394
+ return by(index);
2395
+ }
2396
+ return index;
2397
+ }
2398
+
2399
+ // src/html/template.ts
2400
+ var createTemplate = (templateId, renderer) => {
2401
+ renderer.render = render;
2402
+ renderer._ = renderer;
2403
+ if (true) {
2404
+ renderer.mount = () => {
2405
+ throw new Error(
2406
+ `mount() is not implemented for the HTML compilation of a Marko template`
2407
+ );
2408
+ };
2409
+ }
2410
+ return register2(renderer, templateId);
2411
+ };
2412
+ function render(input = {}) {
2413
+ let { $global: $global2 } = input;
2414
+ if ($global2) {
2415
+ ({ $global: $global2, ...input } = input);
2416
+ $global2 = {
2417
+ runtimeId: DEFAULT_RUNTIME_ID,
2418
+ renderId: DEFAULT_RENDER_ID,
2419
+ ...$global2
2420
+ };
2421
+ } else {
2422
+ $global2 = {
2423
+ runtimeId: DEFAULT_RUNTIME_ID,
2424
+ renderId: DEFAULT_RENDER_ID
2425
+ };
2426
+ }
2427
+ const head = new Chunk(
2428
+ new Boundary(new State2($global2), $global2.signal),
2429
+ null,
2430
+ null
2431
+ );
2432
+ head.render(this, input);
2433
+ return new ServerRenderResult(head);
2434
+ }
2435
+ var ServerRenderResult = class {
2436
+ #head;
2437
+ #cachedPromise = null;
2438
+ constructor(head) {
2439
+ this.#head = head;
2440
+ }
2441
+ [Symbol.asyncIterator]() {
2442
+ let resolve;
2443
+ let reject;
2444
+ let value = "";
2445
+ let done = false;
2446
+ let aborted = false;
2447
+ let reason;
2448
+ const boundary = this.#read(
2449
+ (html) => {
2450
+ value += html;
2451
+ if (resolve) {
2452
+ resolve({ value, done });
2453
+ value = "";
2454
+ }
2455
+ },
2456
+ (err) => {
2457
+ aborted = true;
2458
+ reason = err;
2459
+ if (reject) {
2460
+ reject(err);
2461
+ }
2462
+ },
2463
+ () => {
2464
+ done = true;
2465
+ if (resolve) {
2466
+ resolve({ value, done: !value });
2467
+ }
2468
+ }
2469
+ );
2470
+ return {
2471
+ next() {
2472
+ if (value) {
2473
+ const result = { value, done: false };
2474
+ value = "";
2475
+ return Promise.resolve(result);
2476
+ }
2477
+ return done ? Promise.resolve({ value: "", done }) : aborted ? Promise.reject(reason) : new Promise(exec);
2478
+ },
2479
+ throw(error) {
2480
+ if (!(done || aborted)) {
2481
+ boundary?.abort(error);
2482
+ }
2483
+ return Promise.resolve({
2484
+ value: "",
2485
+ done: true
2486
+ });
2487
+ },
2488
+ return(value2) {
2489
+ if (!(done || aborted)) {
2490
+ boundary?.abort(new Error("Iterator returned before consumed."));
2491
+ }
2492
+ return Promise.resolve({
2493
+ value: value2,
2494
+ done: true
2495
+ });
2496
+ }
2497
+ };
2498
+ function exec(_resolve, _reject) {
2499
+ resolve = _resolve;
2500
+ reject = _reject;
2501
+ }
2502
+ }
2503
+ pipe(stream) {
2504
+ this.#read(
2505
+ (html) => {
2506
+ stream.write(html);
2507
+ },
2508
+ (err) => {
2509
+ const socket = "socket" in stream && stream.socket;
2510
+ if (socket && typeof socket.destroySoon === "function") {
2511
+ socket.destroySoon();
2512
+ }
2513
+ if (!stream.emit?.("error", err)) {
2514
+ throw err;
2515
+ }
2516
+ },
2517
+ () => {
2518
+ stream.end();
2519
+ }
2520
+ );
2521
+ }
2522
+ toReadable() {
2523
+ return new ReadableStream({
2524
+ start: (ctrl) => {
2525
+ this.#read(
2526
+ (html) => {
2527
+ ctrl.enqueue(html);
2528
+ },
2529
+ (err) => {
2530
+ ctrl.error(err);
2531
+ },
2532
+ () => {
2533
+ ctrl.close();
2534
+ }
2535
+ );
2536
+ }
2537
+ });
2538
+ }
2539
+ then(onfulfilled, onrejected) {
2540
+ return this.#promise().then(onfulfilled, onrejected);
2541
+ }
2542
+ catch(onrejected) {
2543
+ return this.#promise().catch(onrejected);
2544
+ }
2545
+ finally(onfinally) {
2546
+ return this.#promise().finally(onfinally);
2547
+ }
2548
+ #promise() {
2549
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
2550
+ let head = this.#head;
2551
+ this.#head = null;
2552
+ if (!head) {
2553
+ return reject(new Error("Cannot read from a consumed render result"));
2554
+ }
2555
+ const { boundary } = head;
2556
+ (boundary.onNext = () => {
2557
+ if (boundary.done) {
2558
+ if (boundary.signal.aborted) {
2559
+ reject(boundary.signal.reason);
2560
+ } else {
2561
+ head = prepareChunk(head);
2562
+ if (boundary.done) resolve(flushChunk(head, true));
2563
+ }
2564
+ }
2565
+ })();
2566
+ });
2567
+ }
2568
+ #read(onWrite, onAbort, onClose) {
2569
+ let tick2 = true;
2570
+ let head = this.#head;
2571
+ this.#head = null;
2572
+ if (!head) {
2573
+ onAbort(new Error("Cannot read from a consumed render result"));
2574
+ return;
2575
+ }
2576
+ const { boundary } = head;
2577
+ const onNext = boundary.onNext = (write2) => {
2578
+ if (write2 || boundary.done) {
2579
+ if (boundary.signal.aborted) {
2580
+ if (!tick2) offTick(onNext);
2581
+ onAbort(boundary.signal.reason);
2582
+ return;
2583
+ }
2584
+ head = prepareChunk(head);
2585
+ }
2586
+ if (write2 || boundary.done) {
2587
+ const html = flushChunk(head, boundary.done);
2588
+ if (html) onWrite(html);
2589
+ if (boundary.done) {
2590
+ if (!tick2) offTick(onNext);
2591
+ onClose();
2592
+ } else {
2593
+ tick2 = true;
2594
+ }
2595
+ } else if (tick2) {
2596
+ tick2 = false;
2597
+ queueTick(onNext);
2598
+ }
2599
+ };
2600
+ onNext();
2601
+ return boundary;
2602
+ }
2603
+ toString() {
2604
+ const head = this.#head;
2605
+ if (!head) throw new Error("Cannot read from a consumed render result");
2606
+ if (head.next) throw new Error("Cannot fork in sync mode");
2607
+ this.#head = null;
2608
+ return flushChunk(prepareChunk(head), true);
2609
+ }
2610
+ };
2611
+ export {
2612
+ $global,
2613
+ attr,
2614
+ attrTag,
2615
+ attrTags,
2616
+ attrs,
2617
+ classAttr,
2618
+ compat,
2619
+ controllable_detailsOrDialog_open,
2620
+ controllable_input_checked,
2621
+ controllable_input_checkedValue,
2622
+ controllable_input_value,
2623
+ controllable_select_value,
2624
+ controllable_textarea_value,
2625
+ createRenderer,
2626
+ createTemplate,
2627
+ dynamicTagArgs,
2628
+ dynamicTagInput,
2629
+ ensureScopeWithId,
2630
+ escapeScript,
2631
+ escapeStyle,
2632
+ escapeXML,
2633
+ forIn,
2634
+ forInBy,
2635
+ forOf,
2636
+ forOfBy,
2637
+ forTo,
2638
+ forToBy,
2639
+ fork,
2640
+ getScopeById,
2641
+ markResumeCleanup,
2642
+ markResumeControlEnd,
2643
+ markResumeControlSingleNodeEnd,
2644
+ markResumeNode,
2645
+ markResumeScopeStart,
2646
+ nextScopeId,
2647
+ nextTagId,
2648
+ nodeRef,
2649
+ normalizeDynamicRenderer,
2650
+ optionValueAttr,
2651
+ partialAttrs,
2652
+ peekNextScope,
2653
+ register2 as register,
2654
+ styleAttr,
2655
+ toString,
2656
+ tryCatch,
2657
+ tryPlaceholder,
2658
+ write,
2659
+ writeEffect,
2660
+ writeExistingScope,
2661
+ writeScope,
2662
+ writeTrailers
2663
+ };