marko 5.37.6 → 6.0.0-3.12

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