marko 5.37.1 → 6.0.0-3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (638) hide show
  1. package/dist/common/attr-tag.d.ts +8 -0
  2. package/dist/common/compat-meta.d.ts +2 -0
  3. package/dist/common/for.d.ts +5 -0
  4. package/dist/common/helpers.d.ts +7 -0
  5. package/dist/common/meta.d.ts +2 -0
  6. package/dist/common/types.d.ts +105 -0
  7. package/dist/debug/dom.js +2112 -0
  8. package/dist/debug/dom.mjs +2089 -0
  9. package/dist/debug/html.js +2740 -0
  10. package/dist/debug/html.mjs +2663 -0
  11. package/dist/dom/abort-signal.d.ts +3 -0
  12. package/dist/dom/compat.d.ts +20 -0
  13. package/dist/dom/control-flow.d.ts +14 -0
  14. package/dist/dom/controllable.d.ts +12 -0
  15. package/dist/dom/dom.d.ts +19 -0
  16. package/dist/dom/event.d.ts +4 -0
  17. package/dist/dom/parse-html.d.ts +5 -0
  18. package/dist/dom/queue.d.ts +10 -0
  19. package/dist/dom/reconcile.d.ts +2 -0
  20. package/dist/dom/renderer.d.ts +21 -0
  21. package/dist/dom/resolve-cursor-position.d.ts +1 -0
  22. package/dist/dom/resume.d.ts +9 -0
  23. package/dist/dom/schedule.d.ts +2 -0
  24. package/dist/dom/scope.d.ts +7 -0
  25. package/dist/dom/signals.d.ts +39 -0
  26. package/dist/dom/template.d.ts +3 -0
  27. package/dist/dom/walker.d.ts +4 -0
  28. package/dist/dom.d.ts +15 -0
  29. package/dist/dom.js +1370 -0
  30. package/dist/dom.mjs +1350 -0
  31. package/dist/html/attrs.d.ts +14 -0
  32. package/dist/html/compat.d.ts +14 -0
  33. package/dist/html/content.d.ts +5 -0
  34. package/dist/html/dynamic-tag.d.ts +12 -0
  35. package/dist/html/for.d.ts +4 -0
  36. package/dist/html/inlined-runtimes.d.ts +2 -0
  37. package/dist/html/serializer.d.ts +14 -0
  38. package/dist/html/template.d.ts +3 -0
  39. package/dist/html/writer.d.ts +114 -0
  40. package/dist/html.d.ts +9 -0
  41. package/dist/html.js +1818 -0
  42. package/dist/html.mjs +1744 -0
  43. package/dist/translator/core/attrs.d.ts +3 -0
  44. package/dist/translator/core/client.d.ts +14 -0
  45. package/dist/translator/core/const.d.ts +3 -0
  46. package/dist/translator/core/debug.d.ts +3 -0
  47. package/dist/translator/core/define.d.ts +3 -0
  48. package/dist/translator/core/effect.d.ts +3 -0
  49. package/dist/translator/core/export.d.ts +3 -0
  50. package/dist/translator/core/for.d.ts +67 -0
  51. package/dist/translator/core/html-comment.d.ts +12 -0
  52. package/dist/translator/core/html-script.d.ts +9 -0
  53. package/dist/translator/core/html-style.d.ts +9 -0
  54. package/dist/translator/core/id.d.ts +3 -0
  55. package/dist/translator/core/if.d.ts +53 -0
  56. package/dist/translator/core/import.d.ts +3 -0
  57. package/dist/translator/core/index.d.ts +152 -0
  58. package/dist/translator/core/let.d.ts +8 -0
  59. package/dist/translator/core/lifecycle.d.ts +10 -0
  60. package/dist/translator/core/log.d.ts +3 -0
  61. package/dist/translator/core/return.d.ts +6 -0
  62. package/dist/translator/core/script.d.ts +3 -0
  63. package/dist/translator/core/server.d.ts +14 -0
  64. package/dist/translator/core/static.d.ts +14 -0
  65. package/dist/translator/core/style.d.ts +3 -0
  66. package/dist/translator/index.d.ts +201 -0
  67. package/dist/translator/index.js +9143 -489
  68. package/dist/translator/util/assert.d.ts +3 -0
  69. package/dist/translator/util/binding-has-downstream-expressions.d.ts +2 -0
  70. package/dist/translator/util/entry-builder.d.ts +19 -0
  71. package/dist/translator/util/evaluate.d.ts +11 -0
  72. package/dist/translator/util/for-each-identifier.d.ts +2 -0
  73. package/dist/translator/util/get-defined-binding-expression.d.ts +3 -0
  74. package/dist/translator/util/get-known-attr-values.d.ts +2 -0
  75. package/dist/translator/util/get-parent-tag.d.ts +2 -0
  76. package/dist/translator/util/get-root.d.ts +7 -0
  77. package/dist/translator/util/get-tag-name.d.ts +2 -0
  78. package/dist/translator/util/is-core-tag.d.ts +10 -0
  79. package/dist/translator/util/is-stateful.d.ts +3 -0
  80. package/dist/translator/util/is-static.d.ts +2 -0
  81. package/dist/translator/util/marko-config.d.ts +4 -0
  82. package/dist/translator/util/nested-attribute-tags.d.ts +17 -0
  83. package/dist/translator/util/normalize-string-expression.d.ts +3 -0
  84. package/dist/translator/util/optional.d.ts +20 -0
  85. package/dist/translator/util/plugin-hooks.d.ts +4 -0
  86. package/dist/translator/util/references.d.ts +84 -0
  87. package/dist/translator/util/runtime-info.d.ts +5 -0
  88. package/dist/translator/util/runtime.d.ts +15 -0
  89. package/dist/translator/util/scope-read.d.ts +6 -0
  90. package/dist/translator/util/sections.d.ts +51 -0
  91. package/dist/translator/util/signals.d.ts +61 -0
  92. package/dist/translator/util/simplify-fn.d.ts +5 -0
  93. package/dist/translator/util/state.d.ts +3 -0
  94. package/dist/translator/util/tag-name-type.d.ts +16 -0
  95. package/dist/translator/util/to-first-expression-or-block.d.ts +3 -0
  96. package/dist/translator/util/to-first-statement-or-block.d.ts +2 -0
  97. package/dist/translator/util/to-property-name.d.ts +7 -0
  98. package/dist/translator/util/translate-attrs.d.ts +12 -0
  99. package/dist/translator/util/translate-var.d.ts +2 -0
  100. package/dist/translator/util/traverse.d.ts +9 -0
  101. package/dist/translator/util/visitors.d.ts +11 -0
  102. package/dist/translator/util/walks.d.ts +15 -0
  103. package/dist/translator/util/with-previous-location.d.ts +2 -0
  104. package/dist/translator/util/writer.d.ts +13 -0
  105. package/dist/translator/visitors/cdata.d.ts +7 -0
  106. package/dist/translator/visitors/comment.d.ts +7 -0
  107. package/dist/translator/visitors/declaration.d.ts +7 -0
  108. package/dist/translator/visitors/document-type.d.ts +7 -0
  109. package/dist/translator/visitors/function.d.ts +19 -0
  110. package/dist/translator/visitors/import-declaration.d.ts +8 -0
  111. package/dist/translator/visitors/placeholder.d.ts +22 -0
  112. package/dist/translator/visitors/program/dom.d.ts +7 -0
  113. package/dist/translator/visitors/program/html.d.ts +8 -0
  114. package/dist/translator/visitors/program/index.d.ts +39 -0
  115. package/dist/translator/visitors/referenced-identifier.d.ts +7 -0
  116. package/dist/translator/visitors/scriptlet.d.ts +8 -0
  117. package/dist/translator/visitors/tag/attribute-tag.d.ts +11 -0
  118. package/dist/translator/visitors/tag/custom-tag.d.ts +19 -0
  119. package/dist/translator/visitors/tag/dynamic-tag.d.ts +18 -0
  120. package/dist/translator/visitors/tag/index.d.ts +15 -0
  121. package/dist/translator/visitors/tag/native-tag.d.ts +25 -0
  122. package/dist/translator/visitors/text.d.ts +7 -0
  123. package/package.json +32 -74
  124. package/README.md +0 -161
  125. package/bin/markoc +0 -2
  126. package/bin/markoc.js +0 -441
  127. package/browser-refresh.js +0 -5
  128. package/compiler-browser.marko +0 -15
  129. package/compiler.js +0 -7
  130. package/components-browser.marko +0 -15
  131. package/components.js +0 -7
  132. package/dist/build.json +0 -3
  133. package/dist/compiler/config.js +0 -45
  134. package/dist/compiler/index.js +0 -164
  135. package/dist/compiler/modules.js +0 -5
  136. package/dist/core-tags/components/init-components-tag.js +0 -54
  137. package/dist/core-tags/components/preferred-script-location-tag.js +0 -25
  138. package/dist/core-tags/components/preserve-tag.js +0 -1
  139. package/dist/core-tags/core/__flush_here_and_after__.js +0 -44
  140. package/dist/core-tags/core/await/AsyncValue.js +0 -121
  141. package/dist/core-tags/core/await/client-reorder-runtime.js +0 -51
  142. package/dist/core-tags/core/await/index.d.marko +0 -10
  143. package/dist/core-tags/core/await/renderer.js +0 -249
  144. package/dist/core-tags/core/await/reorderer-renderer.js +0 -156
  145. package/dist/index.js +0 -4
  146. package/dist/node-require/browser-refresh.js +0 -18
  147. package/dist/node-require/hot-reload.js +0 -45
  148. package/dist/node-require/index.js +0 -103
  149. package/dist/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  150. package/dist/node_modules/@internal/components-beginComponent/index.js +0 -84
  151. package/dist/node_modules/@internal/components-beginComponent/package.json +0 -11
  152. package/dist/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  153. package/dist/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  154. package/dist/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  155. package/dist/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  156. package/dist/node_modules/@internal/components-endComponent/index.js +0 -11
  157. package/dist/node_modules/@internal/components-endComponent/package.json +0 -11
  158. package/dist/node_modules/@internal/components-entry/index-browser.js +0 -11
  159. package/dist/node_modules/@internal/components-entry/index.js +0 -301
  160. package/dist/node_modules/@internal/components-entry/package.json +0 -11
  161. package/dist/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  162. package/dist/node_modules/@internal/components-entry-legacy/index.js +0 -16
  163. package/dist/node_modules/@internal/components-entry-legacy/package.json +0 -11
  164. package/dist/node_modules/@internal/components-registry/index-browser.js +0 -586
  165. package/dist/node_modules/@internal/components-registry/index.js +0 -44
  166. package/dist/node_modules/@internal/components-registry/package.json +0 -11
  167. package/dist/node_modules/@internal/components-util/index-browser.js +0 -152
  168. package/dist/node_modules/@internal/components-util/index.js +0 -75
  169. package/dist/node_modules/@internal/components-util/package.json +0 -11
  170. package/dist/node_modules/@internal/create-readable/index-browser.js +0 -30
  171. package/dist/node_modules/@internal/create-readable/index.js +0 -57
  172. package/dist/node_modules/@internal/create-readable/package.json +0 -11
  173. package/dist/node_modules/@internal/loader/fallback-node.js +0 -89
  174. package/dist/node_modules/@internal/loader/index-browser.js +0 -2
  175. package/dist/node_modules/@internal/loader/index.js +0 -23
  176. package/dist/node_modules/@internal/loader/package.json +0 -10
  177. package/dist/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  178. package/dist/node_modules/@internal/preserve-tag/index.js +0 -34
  179. package/dist/node_modules/@internal/preserve-tag/package.json +0 -11
  180. package/dist/node_modules/@internal/require/index-browser.js +0 -15
  181. package/dist/node_modules/@internal/require/index-legacy-browser.js +0 -20
  182. package/dist/node_modules/@internal/require/index-webpack.js +0 -16
  183. package/dist/node_modules/@internal/require/index.js +0 -15
  184. package/dist/node_modules/@internal/require/package.json +0 -11
  185. package/dist/node_modules/@internal/set-immediate/index-browser.js +0 -19
  186. package/dist/node_modules/@internal/set-immediate/index-worker.js +0 -31
  187. package/dist/node_modules/@internal/set-immediate/index.js +0 -3
  188. package/dist/node_modules/@internal/set-immediate/package.json +0 -11
  189. package/dist/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  190. package/dist/runtime/RenderResult.js +0 -112
  191. package/dist/runtime/components/Component.js +0 -663
  192. package/dist/runtime/components/ComponentDef.js +0 -169
  193. package/dist/runtime/components/ComponentsContext.js +0 -59
  194. package/dist/runtime/components/GlobalComponentsContext.js +0 -10
  195. package/dist/runtime/components/KeySequence.js +0 -16
  196. package/dist/runtime/components/ServerComponent.js +0 -73
  197. package/dist/runtime/components/State.js +0 -101
  198. package/dist/runtime/components/attach-detach.js +0 -60
  199. package/dist/runtime/components/defineComponent.js +0 -60
  200. package/dist/runtime/components/dom-data.js +0 -8
  201. package/dist/runtime/components/event-delegation.js +0 -144
  202. package/dist/runtime/components/index.js +0 -1
  203. package/dist/runtime/components/legacy/browser.json +0 -9
  204. package/dist/runtime/components/legacy/defineComponent-legacy.js +0 -27
  205. package/dist/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  206. package/dist/runtime/components/legacy/defineWidget-legacy.js +0 -1
  207. package/dist/runtime/components/legacy/dependencies/html.js +0 -3
  208. package/dist/runtime/components/legacy/dependencies/index.js +0 -177
  209. package/dist/runtime/components/legacy/dependencies/vdom.js +0 -3
  210. package/dist/runtime/components/legacy/index.js +0 -1
  211. package/dist/runtime/components/legacy/jquery.js +0 -52
  212. package/dist/runtime/components/legacy/ready.js +0 -152
  213. package/dist/runtime/components/legacy/renderer-legacy.js +0 -231
  214. package/dist/runtime/components/registry.js +0 -1
  215. package/dist/runtime/components/renderer.js +0 -236
  216. package/dist/runtime/components/update-manager.js +0 -94
  217. package/dist/runtime/createOut.js +0 -13
  218. package/dist/runtime/dom-insert.js +0 -77
  219. package/dist/runtime/events.js +0 -2
  220. package/dist/runtime/helpers/_change-case.js +0 -45
  221. package/dist/runtime/helpers/assign.js +0 -21
  222. package/dist/runtime/helpers/attr-tag.js +0 -43
  223. package/dist/runtime/helpers/class-value.js +0 -30
  224. package/dist/runtime/helpers/dynamic-tag.js +0 -181
  225. package/dist/runtime/helpers/empty-component.js +0 -1
  226. package/dist/runtime/helpers/merge.js +0 -13
  227. package/dist/runtime/helpers/of-fallback.js +0 -4
  228. package/dist/runtime/helpers/render-tag.js +0 -20
  229. package/dist/runtime/helpers/serialize-noop.js +0 -5
  230. package/dist/runtime/helpers/style-value.js +0 -45
  231. package/dist/runtime/helpers/tags-compat/dom-debug.js +0 -1
  232. package/dist/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  233. package/dist/runtime/helpers/tags-compat/dom.js +0 -1
  234. package/dist/runtime/helpers/tags-compat/dom.mjs +0 -4
  235. package/dist/runtime/helpers/tags-compat/html-debug.js +0 -3
  236. package/dist/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  237. package/dist/runtime/helpers/tags-compat/html.js +0 -3
  238. package/dist/runtime/helpers/tags-compat/html.mjs +0 -4
  239. package/dist/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  240. package/dist/runtime/helpers/tags-compat/runtime-html.js +0 -136
  241. package/dist/runtime/helpers/to-string.js +0 -5
  242. package/dist/runtime/html/AsyncStream.js +0 -805
  243. package/dist/runtime/html/BufferedWriter.js +0 -52
  244. package/dist/runtime/html/StringWriter.js +0 -73
  245. package/dist/runtime/html/helpers/_dynamic-attr.js +0 -35
  246. package/dist/runtime/html/helpers/attr.js +0 -80
  247. package/dist/runtime/html/helpers/attrs.js +0 -26
  248. package/dist/runtime/html/helpers/class-attr.js +0 -8
  249. package/dist/runtime/html/helpers/data-marko.js +0 -36
  250. package/dist/runtime/html/helpers/escape-quotes.js +0 -35
  251. package/dist/runtime/html/helpers/escape-script-placeholder.js +0 -24
  252. package/dist/runtime/html/helpers/escape-style-placeholder.js +0 -22
  253. package/dist/runtime/html/helpers/escape-xml.js +0 -21
  254. package/dist/runtime/html/helpers/merge-attrs.js +0 -55
  255. package/dist/runtime/html/helpers/props-script.js +0 -32
  256. package/dist/runtime/html/helpers/style-attr.js +0 -8
  257. package/dist/runtime/html/hot-reload.js +0 -26
  258. package/dist/runtime/html/index.js +0 -33
  259. package/dist/runtime/html/marko-namespace.js +0 -3
  260. package/dist/runtime/renderable.js +0 -194
  261. package/dist/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  262. package/dist/runtime/vdom/VComment.js +0 -24
  263. package/dist/runtime/vdom/VComponent.js +0 -17
  264. package/dist/runtime/vdom/VDocumentFragment.js +0 -34
  265. package/dist/runtime/vdom/VElement.js +0 -375
  266. package/dist/runtime/vdom/VFragment.js +0 -26
  267. package/dist/runtime/vdom/VNode.js +0 -100
  268. package/dist/runtime/vdom/VText.js +0 -25
  269. package/dist/runtime/vdom/helpers/attrs.js +0 -62
  270. package/dist/runtime/vdom/helpers/const-element.js +0 -25
  271. package/dist/runtime/vdom/helpers/merge-attrs.js +0 -16
  272. package/dist/runtime/vdom/hot-reload.js +0 -115
  273. package/dist/runtime/vdom/index.js +0 -30
  274. package/dist/runtime/vdom/is-text-only.js +0 -10
  275. package/dist/runtime/vdom/marko-namespace.js +0 -3
  276. package/dist/runtime/vdom/morphdom/fragment.js +0 -95
  277. package/dist/runtime/vdom/morphdom/helpers.js +0 -42
  278. package/dist/runtime/vdom/morphdom/index.js +0 -741
  279. package/dist/runtime/vdom/parse-html.js +0 -18
  280. package/dist/runtime/vdom/vdom.js +0 -88
  281. package/dist/taglib/index.js +0 -51
  282. package/dist/translator/cdata/index.js +0 -15
  283. package/dist/translator/cdata/index[html].js +0 -15
  284. package/dist/translator/cdata/index[vdom].js +0 -12
  285. package/dist/translator/class.js +0 -65
  286. package/dist/translator/comment/index.js +0 -15
  287. package/dist/translator/comment/index[html].js +0 -17
  288. package/dist/translator/comment/index[vdom].js +0 -3
  289. package/dist/translator/declaration/index.js +0 -15
  290. package/dist/translator/declaration/index[html].js +0 -12
  291. package/dist/translator/declaration/index[vdom].js +0 -3
  292. package/dist/translator/document-type/index.js +0 -15
  293. package/dist/translator/document-type/index[html].js +0 -12
  294. package/dist/translator/document-type/index[vdom].js +0 -3
  295. package/dist/translator/placeholder/index.js +0 -15
  296. package/dist/translator/placeholder/index[html].js +0 -93
  297. package/dist/translator/placeholder/index[vdom].js +0 -22
  298. package/dist/translator/scriptlet.js +0 -4
  299. package/dist/translator/tag/attribute/directives/class.js +0 -42
  300. package/dist/translator/tag/attribute/directives/index.js +0 -15
  301. package/dist/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  302. package/dist/translator/tag/attribute/directives/no-update-body.js +0 -10
  303. package/dist/translator/tag/attribute/directives/no-update-if.js +0 -12
  304. package/dist/translator/tag/attribute/directives/no-update.js +0 -48
  305. package/dist/translator/tag/attribute/directives/style.js +0 -42
  306. package/dist/translator/tag/attribute/index.js +0 -150
  307. package/dist/translator/tag/attribute/modifiers/index.js +0 -7
  308. package/dist/translator/tag/attribute/modifiers/no-update.js +0 -14
  309. package/dist/translator/tag/attribute/modifiers/scoped.js +0 -23
  310. package/dist/translator/tag/attribute-tag.js +0 -149
  311. package/dist/translator/tag/custom-tag.js +0 -146
  312. package/dist/translator/tag/dynamic-tag.js +0 -74
  313. package/dist/translator/tag/index.js +0 -287
  314. package/dist/translator/tag/macro-tag.js +0 -7
  315. package/dist/translator/tag/native-tag.js +0 -27
  316. package/dist/translator/tag/native-tag[html]/attributes.js +0 -151
  317. package/dist/translator/tag/native-tag[html]/index.js +0 -221
  318. package/dist/translator/tag/native-tag[vdom]/attributes.js +0 -105
  319. package/dist/translator/tag/native-tag[vdom]/index.js +0 -189
  320. package/dist/translator/tag/util.js +0 -246
  321. package/dist/translator/taglib/core/conditional/translate-else-if.js +0 -20
  322. package/dist/translator/taglib/core/conditional/translate-else.js +0 -20
  323. package/dist/translator/taglib/core/conditional/translate-if.js +0 -8
  324. package/dist/translator/taglib/core/conditional/util.js +0 -41
  325. package/dist/translator/taglib/core/index.js +0 -474
  326. package/dist/translator/taglib/core/macro/parse.js +0 -17
  327. package/dist/translator/taglib/core/macro/translate.js +0 -48
  328. package/dist/translator/taglib/core/parse-class.js +0 -79
  329. package/dist/translator/taglib/core/parse-export.js +0 -14
  330. package/dist/translator/taglib/core/parse-import.js +0 -14
  331. package/dist/translator/taglib/core/parse-module-code.js +0 -18
  332. package/dist/translator/taglib/core/parse-static.js +0 -18
  333. package/dist/translator/taglib/core/transform-style.js +0 -66
  334. package/dist/translator/taglib/core/translate-await.js +0 -41
  335. package/dist/translator/taglib/core/translate-body.js +0 -17
  336. package/dist/translator/taglib/core/translate-for.js +0 -156
  337. package/dist/translator/taglib/core/translate-html-comment.js +0 -52
  338. package/dist/translator/taglib/core/translate-include-content.js +0 -53
  339. package/dist/translator/taglib/core/translate-server-only.js +0 -5
  340. package/dist/translator/taglib/core/translate-while.js +0 -32
  341. package/dist/translator/taglib/index.js +0 -6
  342. package/dist/translator/taglib/migrate/all-templates.js +0 -46
  343. package/dist/translator/taglib/migrate/index.js +0 -5
  344. package/dist/translator/text/index.js +0 -10
  345. package/dist/translator/text/index[html].js +0 -12
  346. package/dist/translator/text/index[vdom].js +0 -20
  347. package/dist/translator/util/add-dependencies.js +0 -329
  348. package/dist/translator/util/escape-regexp.js +0 -4
  349. package/dist/translator/util/get-component-files.js +0 -86
  350. package/dist/translator/util/html-out-write.js +0 -15
  351. package/dist/translator/util/key-manager.js +0 -176
  352. package/dist/translator/util/optimize-html-writes.js +0 -52
  353. package/dist/translator/util/optimize-vdom-create.js +0 -164
  354. package/dist/translator/util/plugin-hooks.js +0 -22
  355. package/dist/translator/util/runtime-flags.js +0 -3
  356. package/dist/translator/util/vdom-out-write.js +0 -10
  357. package/dist/translator/util/with-previous-location.js +0 -6
  358. package/docs/10-awesome-marko-features.md +0 -291
  359. package/docs/body-content.md +0 -355
  360. package/docs/class-components.md +0 -1001
  361. package/docs/cloudflare-workers.md +0 -32
  362. package/docs/compiler-hooks.png +0 -0
  363. package/docs/compiler.md +0 -473
  364. package/docs/component-diagram.afdesign +0 -0
  365. package/docs/component-diagram.svg +0 -87
  366. package/docs/concise.md +0 -141
  367. package/docs/conditionals-and-lists.md +0 -72
  368. package/docs/core-tags.md +0 -325
  369. package/docs/custom-tags.md +0 -201
  370. package/docs/editor-plugins.md +0 -45
  371. package/docs/events.md +0 -131
  372. package/docs/express.md +0 -66
  373. package/docs/fastify.md +0 -65
  374. package/docs/getting-started.md +0 -95
  375. package/docs/http.md +0 -34
  376. package/docs/icons/js.svg +0 -4
  377. package/docs/icons/marko.svg +0 -1
  378. package/docs/icons/ts.svg +0 -1
  379. package/docs/installing.md +0 -51
  380. package/docs/koa.md +0 -35
  381. package/docs/lasso.md +0 -196
  382. package/docs/marko-5-upgrade.md +0 -59
  383. package/docs/marko-json.md +0 -248
  384. package/docs/marko-vs-react.md +0 -854
  385. package/docs/redux.md +0 -61
  386. package/docs/rendering.md +0 -268
  387. package/docs/rollup.md +0 -352
  388. package/docs/state.md +0 -105
  389. package/docs/structure.json +0 -49
  390. package/docs/styles.md +0 -29
  391. package/docs/syntax.md +0 -601
  392. package/docs/troubleshooting-streaming.md +0 -68
  393. package/docs/typescript.md +0 -406
  394. package/docs/vite.md +0 -86
  395. package/docs/webpack.md +0 -205
  396. package/docs/why-is-marko-fast.md +0 -239
  397. package/env.js +0 -7
  398. package/helpers/README.md +0 -3
  399. package/helpers/empty.js +0 -4
  400. package/helpers/notEmpty.js +0 -11
  401. package/index-browser.marko +0 -15
  402. package/index.d.ts +0 -375
  403. package/index.js +0 -7
  404. package/legacy-components-browser.marko +0 -15
  405. package/legacy-components.js +0 -7
  406. package/node-require.js +0 -8
  407. package/src/build.json +0 -3
  408. package/src/compiler/config.js +0 -45
  409. package/src/compiler/index.js +0 -164
  410. package/src/compiler/modules.js +0 -5
  411. package/src/core-tags/.eslintrc +0 -5
  412. package/src/core-tags/components/init-components-tag.js +0 -54
  413. package/src/core-tags/components/preferred-script-location-tag.js +0 -25
  414. package/src/core-tags/components/preserve-tag.js +0 -1
  415. package/src/core-tags/core/__flush_here_and_after__.js +0 -44
  416. package/src/core-tags/core/await/AsyncValue.js +0 -121
  417. package/src/core-tags/core/await/client-reorder-runtime.js +0 -51
  418. package/src/core-tags/core/await/index.d.marko +0 -10
  419. package/src/core-tags/core/await/renderer.js +0 -249
  420. package/src/core-tags/core/await/reorderer-renderer.js +0 -156
  421. package/src/index.js +0 -4
  422. package/src/node-require/browser-refresh.js +0 -18
  423. package/src/node-require/hot-reload.js +0 -45
  424. package/src/node-require/index.js +0 -103
  425. package/src/node_modules/@internal/components-beginComponent/index-browser.js +0 -23
  426. package/src/node_modules/@internal/components-beginComponent/index.js +0 -84
  427. package/src/node_modules/@internal/components-beginComponent/package.json +0 -11
  428. package/src/node_modules/@internal/components-define-widget-legacy/index-browser.js +0 -335
  429. package/src/node_modules/@internal/components-define-widget-legacy/index.js +0 -18
  430. package/src/node_modules/@internal/components-define-widget-legacy/package.json +0 -11
  431. package/src/node_modules/@internal/components-endComponent/index-browser.js +0 -5
  432. package/src/node_modules/@internal/components-endComponent/index.js +0 -11
  433. package/src/node_modules/@internal/components-endComponent/package.json +0 -11
  434. package/src/node_modules/@internal/components-entry/index-browser.js +0 -11
  435. package/src/node_modules/@internal/components-entry/index.js +0 -301
  436. package/src/node_modules/@internal/components-entry/package.json +0 -11
  437. package/src/node_modules/@internal/components-entry-legacy/index-browser.js +0 -76
  438. package/src/node_modules/@internal/components-entry-legacy/index.js +0 -16
  439. package/src/node_modules/@internal/components-entry-legacy/package.json +0 -11
  440. package/src/node_modules/@internal/components-registry/index-browser.js +0 -586
  441. package/src/node_modules/@internal/components-registry/index.js +0 -44
  442. package/src/node_modules/@internal/components-registry/package.json +0 -11
  443. package/src/node_modules/@internal/components-util/index-browser.js +0 -152
  444. package/src/node_modules/@internal/components-util/index.js +0 -75
  445. package/src/node_modules/@internal/components-util/package.json +0 -11
  446. package/src/node_modules/@internal/create-readable/index-browser.js +0 -30
  447. package/src/node_modules/@internal/create-readable/index.js +0 -57
  448. package/src/node_modules/@internal/create-readable/package.json +0 -11
  449. package/src/node_modules/@internal/loader/fallback-node.js +0 -89
  450. package/src/node_modules/@internal/loader/index-browser.js +0 -2
  451. package/src/node_modules/@internal/loader/index.js +0 -23
  452. package/src/node_modules/@internal/loader/package.json +0 -10
  453. package/src/node_modules/@internal/preserve-tag/index-browser.js +0 -46
  454. package/src/node_modules/@internal/preserve-tag/index.js +0 -34
  455. package/src/node_modules/@internal/preserve-tag/package.json +0 -11
  456. package/src/node_modules/@internal/require/index-browser.js +0 -15
  457. package/src/node_modules/@internal/require/index-legacy-browser.js +0 -20
  458. package/src/node_modules/@internal/require/index-webpack.js +0 -16
  459. package/src/node_modules/@internal/require/index.js +0 -15
  460. package/src/node_modules/@internal/require/package.json +0 -11
  461. package/src/node_modules/@internal/set-immediate/index-browser.js +0 -19
  462. package/src/node_modules/@internal/set-immediate/index-worker.js +0 -31
  463. package/src/node_modules/@internal/set-immediate/index.js +0 -3
  464. package/src/node_modules/@internal/set-immediate/package.json +0 -11
  465. package/src/node_modules/@internal/set-immediate/queueMicrotask.js +0 -8
  466. package/src/runtime/.eslintrc +0 -5
  467. package/src/runtime/RenderResult.js +0 -112
  468. package/src/runtime/components/Component.js +0 -663
  469. package/src/runtime/components/ComponentDef.js +0 -169
  470. package/src/runtime/components/ComponentsContext.js +0 -59
  471. package/src/runtime/components/GlobalComponentsContext.js +0 -10
  472. package/src/runtime/components/KeySequence.js +0 -16
  473. package/src/runtime/components/ServerComponent.js +0 -73
  474. package/src/runtime/components/State.js +0 -101
  475. package/src/runtime/components/attach-detach.js +0 -60
  476. package/src/runtime/components/defineComponent.js +0 -60
  477. package/src/runtime/components/dom-data.js +0 -8
  478. package/src/runtime/components/event-delegation.js +0 -144
  479. package/src/runtime/components/index.js +0 -1
  480. package/src/runtime/components/legacy/browser.json +0 -9
  481. package/src/runtime/components/legacy/defineComponent-legacy.js +0 -27
  482. package/src/runtime/components/legacy/defineRenderer-legacy.js +0 -171
  483. package/src/runtime/components/legacy/defineWidget-legacy.js +0 -1
  484. package/src/runtime/components/legacy/dependencies/html.js +0 -3
  485. package/src/runtime/components/legacy/dependencies/index.js +0 -177
  486. package/src/runtime/components/legacy/dependencies/vdom.js +0 -3
  487. package/src/runtime/components/legacy/index.js +0 -1
  488. package/src/runtime/components/legacy/jquery.js +0 -52
  489. package/src/runtime/components/legacy/ready.js +0 -152
  490. package/src/runtime/components/legacy/renderer-legacy.js +0 -231
  491. package/src/runtime/components/registry.js +0 -1
  492. package/src/runtime/components/renderer.js +0 -236
  493. package/src/runtime/components/update-manager.js +0 -94
  494. package/src/runtime/createOut.js +0 -13
  495. package/src/runtime/dom-insert.js +0 -77
  496. package/src/runtime/events.js +0 -2
  497. package/src/runtime/helpers/_change-case.js +0 -45
  498. package/src/runtime/helpers/assign.js +0 -21
  499. package/src/runtime/helpers/attr-tag.js +0 -43
  500. package/src/runtime/helpers/class-value.js +0 -30
  501. package/src/runtime/helpers/dynamic-tag.js +0 -181
  502. package/src/runtime/helpers/empty-component.js +0 -1
  503. package/src/runtime/helpers/merge.js +0 -13
  504. package/src/runtime/helpers/of-fallback.js +0 -4
  505. package/src/runtime/helpers/render-tag.js +0 -20
  506. package/src/runtime/helpers/serialize-noop.js +0 -5
  507. package/src/runtime/helpers/style-value.js +0 -45
  508. package/src/runtime/helpers/tags-compat/dom-debug.js +0 -1
  509. package/src/runtime/helpers/tags-compat/dom-debug.mjs +0 -4
  510. package/src/runtime/helpers/tags-compat/dom.js +0 -1
  511. package/src/runtime/helpers/tags-compat/dom.mjs +0 -4
  512. package/src/runtime/helpers/tags-compat/html-debug.js +0 -3
  513. package/src/runtime/helpers/tags-compat/html-debug.mjs +0 -4
  514. package/src/runtime/helpers/tags-compat/html.js +0 -3
  515. package/src/runtime/helpers/tags-compat/html.mjs +0 -4
  516. package/src/runtime/helpers/tags-compat/runtime-dom.js +0 -239
  517. package/src/runtime/helpers/tags-compat/runtime-html.js +0 -136
  518. package/src/runtime/helpers/to-string.js +0 -5
  519. package/src/runtime/html/AsyncStream.js +0 -805
  520. package/src/runtime/html/BufferedWriter.js +0 -52
  521. package/src/runtime/html/StringWriter.js +0 -73
  522. package/src/runtime/html/helpers/_dynamic-attr.js +0 -35
  523. package/src/runtime/html/helpers/attr.js +0 -80
  524. package/src/runtime/html/helpers/attrs.js +0 -26
  525. package/src/runtime/html/helpers/class-attr.js +0 -8
  526. package/src/runtime/html/helpers/data-marko.js +0 -36
  527. package/src/runtime/html/helpers/escape-quotes.js +0 -35
  528. package/src/runtime/html/helpers/escape-script-placeholder.js +0 -24
  529. package/src/runtime/html/helpers/escape-style-placeholder.js +0 -22
  530. package/src/runtime/html/helpers/escape-xml.js +0 -21
  531. package/src/runtime/html/helpers/merge-attrs.js +0 -55
  532. package/src/runtime/html/helpers/props-script.js +0 -32
  533. package/src/runtime/html/helpers/style-attr.js +0 -8
  534. package/src/runtime/html/hot-reload.js +0 -26
  535. package/src/runtime/html/index.js +0 -33
  536. package/src/runtime/html/marko-namespace.js +0 -3
  537. package/src/runtime/renderable.js +0 -194
  538. package/src/runtime/vdom/AsyncVDOMBuilder.js +0 -456
  539. package/src/runtime/vdom/VComment.js +0 -24
  540. package/src/runtime/vdom/VComponent.js +0 -17
  541. package/src/runtime/vdom/VDocumentFragment.js +0 -34
  542. package/src/runtime/vdom/VElement.js +0 -375
  543. package/src/runtime/vdom/VFragment.js +0 -26
  544. package/src/runtime/vdom/VNode.js +0 -100
  545. package/src/runtime/vdom/VText.js +0 -25
  546. package/src/runtime/vdom/helpers/attrs.js +0 -62
  547. package/src/runtime/vdom/helpers/const-element.js +0 -25
  548. package/src/runtime/vdom/helpers/merge-attrs.js +0 -16
  549. package/src/runtime/vdom/hot-reload.js +0 -115
  550. package/src/runtime/vdom/index.js +0 -30
  551. package/src/runtime/vdom/is-text-only.js +0 -10
  552. package/src/runtime/vdom/marko-namespace.js +0 -3
  553. package/src/runtime/vdom/morphdom/fragment.js +0 -95
  554. package/src/runtime/vdom/morphdom/helpers.js +0 -42
  555. package/src/runtime/vdom/morphdom/index.js +0 -741
  556. package/src/runtime/vdom/parse-html.js +0 -18
  557. package/src/runtime/vdom/vdom.js +0 -88
  558. package/src/taglib/index.js +0 -51
  559. package/src/translator/cdata/index.js +0 -15
  560. package/src/translator/cdata/index[html].js +0 -15
  561. package/src/translator/cdata/index[vdom].js +0 -12
  562. package/src/translator/class.js +0 -65
  563. package/src/translator/comment/index.js +0 -15
  564. package/src/translator/comment/index[html].js +0 -17
  565. package/src/translator/comment/index[vdom].js +0 -3
  566. package/src/translator/declaration/index.js +0 -15
  567. package/src/translator/declaration/index[html].js +0 -12
  568. package/src/translator/declaration/index[vdom].js +0 -3
  569. package/src/translator/document-type/index.js +0 -15
  570. package/src/translator/document-type/index[html].js +0 -12
  571. package/src/translator/document-type/index[vdom].js +0 -3
  572. package/src/translator/index.js +0 -551
  573. package/src/translator/placeholder/index.js +0 -15
  574. package/src/translator/placeholder/index[html].js +0 -93
  575. package/src/translator/placeholder/index[vdom].js +0 -22
  576. package/src/translator/scriptlet.js +0 -4
  577. package/src/translator/tag/attribute/directives/class.js +0 -42
  578. package/src/translator/tag/attribute/directives/index.js +0 -15
  579. package/src/translator/tag/attribute/directives/no-update-body-if.js +0 -15
  580. package/src/translator/tag/attribute/directives/no-update-body.js +0 -10
  581. package/src/translator/tag/attribute/directives/no-update-if.js +0 -12
  582. package/src/translator/tag/attribute/directives/no-update.js +0 -48
  583. package/src/translator/tag/attribute/directives/style.js +0 -42
  584. package/src/translator/tag/attribute/index.js +0 -150
  585. package/src/translator/tag/attribute/modifiers/index.js +0 -7
  586. package/src/translator/tag/attribute/modifiers/no-update.js +0 -14
  587. package/src/translator/tag/attribute/modifiers/scoped.js +0 -23
  588. package/src/translator/tag/attribute-tag.js +0 -149
  589. package/src/translator/tag/custom-tag.js +0 -146
  590. package/src/translator/tag/dynamic-tag.js +0 -74
  591. package/src/translator/tag/index.js +0 -287
  592. package/src/translator/tag/macro-tag.js +0 -7
  593. package/src/translator/tag/native-tag.js +0 -27
  594. package/src/translator/tag/native-tag[html]/attributes.js +0 -151
  595. package/src/translator/tag/native-tag[html]/index.js +0 -221
  596. package/src/translator/tag/native-tag[vdom]/attributes.js +0 -105
  597. package/src/translator/tag/native-tag[vdom]/index.js +0 -189
  598. package/src/translator/tag/util.js +0 -246
  599. package/src/translator/taglib/core/conditional/translate-else-if.js +0 -20
  600. package/src/translator/taglib/core/conditional/translate-else.js +0 -20
  601. package/src/translator/taglib/core/conditional/translate-if.js +0 -8
  602. package/src/translator/taglib/core/conditional/util.js +0 -41
  603. package/src/translator/taglib/core/index.js +0 -474
  604. package/src/translator/taglib/core/macro/parse.js +0 -17
  605. package/src/translator/taglib/core/macro/translate.js +0 -48
  606. package/src/translator/taglib/core/parse-class.js +0 -79
  607. package/src/translator/taglib/core/parse-export.js +0 -14
  608. package/src/translator/taglib/core/parse-import.js +0 -14
  609. package/src/translator/taglib/core/parse-module-code.js +0 -18
  610. package/src/translator/taglib/core/parse-static.js +0 -18
  611. package/src/translator/taglib/core/transform-style.js +0 -66
  612. package/src/translator/taglib/core/translate-await.js +0 -41
  613. package/src/translator/taglib/core/translate-body.js +0 -17
  614. package/src/translator/taglib/core/translate-for.js +0 -156
  615. package/src/translator/taglib/core/translate-html-comment.js +0 -52
  616. package/src/translator/taglib/core/translate-include-content.js +0 -53
  617. package/src/translator/taglib/core/translate-server-only.js +0 -5
  618. package/src/translator/taglib/core/translate-while.js +0 -32
  619. package/src/translator/taglib/index.js +0 -7
  620. package/src/translator/taglib/migrate/all-templates.js +0 -46
  621. package/src/translator/taglib/migrate/index.js +0 -5
  622. package/src/translator/text/index.js +0 -10
  623. package/src/translator/text/index[html].js +0 -12
  624. package/src/translator/text/index[vdom].js +0 -20
  625. package/src/translator/util/add-dependencies.js +0 -329
  626. package/src/translator/util/escape-regexp.js +0 -4
  627. package/src/translator/util/get-component-files.js +0 -86
  628. package/src/translator/util/html-out-write.js +0 -15
  629. package/src/translator/util/key-manager.js +0 -176
  630. package/src/translator/util/optimize-html-writes.js +0 -52
  631. package/src/translator/util/optimize-vdom-create.js +0 -164
  632. package/src/translator/util/plugin-hooks.js +0 -22
  633. package/src/translator/util/runtime-flags.js +0 -3
  634. package/src/translator/util/vdom-out-write.js +0 -10
  635. package/src/translator/util/with-previous-location.js +0 -6
  636. package/tags-html.d.ts +0 -3855
  637. package/translator/index.d.ts +0 -7
  638. package/translator/package.json +0 -5
package/dist/html.mjs ADDED
@@ -0,0 +1,1744 @@
1
+ // src/common/attr-tag.ts
2
+ var empty = [], rest = Symbol();
3
+ function attrTag(attrs2) {
4
+ return attrs2[Symbol.iterator] = attrTagIterator, attrs2[rest] = empty, attrs2;
5
+ }
6
+ function attrTags(first, attrs2) {
7
+ return first ? (first[rest] === empty ? first[rest] = [attrs2] : first[rest].push(attrs2), first) : attrTag(attrs2);
8
+ }
9
+ function* attrTagIterator() {
10
+ yield this, yield* this[rest];
11
+ }
12
+
13
+ // src/common/helpers.ts
14
+ function classValue(value) {
15
+ return toDelimitedString(value, " ", stringifyClassObject);
16
+ }
17
+ function stringifyClassObject(name, value) {
18
+ return value ? name : "";
19
+ }
20
+ function styleValue(value) {
21
+ return toDelimitedString(value, ";", stringifyStyleObject);
22
+ }
23
+ var NON_DIMENSIONAL = /^(--|ta|or|li|z)|n-c|i(do|nk|m|t)|w$|we/;
24
+ function stringifyStyleObject(name, value) {
25
+ return value || value === 0 ? `${name}:${typeof value == "number" && value && !NON_DIMENSIONAL.test(name) ? value + "px" : value}` : "";
26
+ }
27
+ function toDelimitedString(val, delimiter, stringify) {
28
+ switch (typeof val) {
29
+ case "string":
30
+ return val;
31
+ case "object":
32
+ if (val !== null) {
33
+ let result = "", curDelimiter = "";
34
+ if (Array.isArray(val))
35
+ for (let v of val) {
36
+ let part = toDelimitedString(v, delimiter, stringify);
37
+ part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
38
+ }
39
+ else
40
+ for (let name in val) {
41
+ let v = val[name], part = stringify(name, v);
42
+ part !== "" && (result += curDelimiter + part, curDelimiter = delimiter);
43
+ }
44
+ return result;
45
+ }
46
+ }
47
+ return "";
48
+ }
49
+ function isEventHandler(name) {
50
+ return /^on[A-Z-]/.test(name);
51
+ }
52
+ function getEventHandlerName(name) {
53
+ return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
54
+ }
55
+ function isVoid(value) {
56
+ return value == null || value === !1;
57
+ }
58
+ function normalizeDynamicRenderer(value) {
59
+ if (value) return value.renderBody || value.default || value;
60
+ }
61
+
62
+ // src/html/content.ts
63
+ function toString(val) {
64
+ return val ? val + "" : val === 0 ? "0" : "";
65
+ }
66
+ var unsafeXMLReg = /[<&]/g, replaceUnsafeXML = (c) => c === "&" ? "&amp;" : "&lt;", escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
67
+ function escapeXML(val) {
68
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "&zwj;";
69
+ }
70
+ function escapeTextAreaValue(val) {
71
+ return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "";
72
+ }
73
+ var unsafeScriptReg = /<\/script/g, escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
74
+ function escapeScript(val) {
75
+ return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
76
+ }
77
+ var unsafeStyleReg = /<\/style/g, escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
78
+ function escapeStyle(val) {
79
+ return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
80
+ }
81
+
82
+ // src/html/inlined-runtimes.ts
83
+ var WALKER_RUNTIME_CODE = '(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}))', REORDER_RUNTIME_CODE = '(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())}})';
84
+
85
+ // src/html/serializer.ts
86
+ var { hasOwnProperty } = {}, Generator = function* () {
87
+ }().constructor, AsyncGenerator = async function* () {
88
+ }().constructor, REGISTRY = /* @__PURE__ */ new WeakMap(), KNOWN_SYMBOLS = (() => {
89
+ let KNOWN_SYMBOLS2 = /* @__PURE__ */ new Map();
90
+ for (let name of Object.getOwnPropertyNames(Symbol)) {
91
+ let symbol = Symbol[name];
92
+ typeof symbol == "symbol" && KNOWN_SYMBOLS2.set(symbol, "Symbol." + name);
93
+ }
94
+ return KNOWN_SYMBOLS2;
95
+ })(), KNOWN_FUNCTIONS = /* @__PURE__ */ new Map([
96
+ // This is by no means an exhaustive list,
97
+ // but it should cover most of the built-in functions.
98
+ [AggregateError, "AggregateError"],
99
+ [Array, "Array"],
100
+ [Array.from, "Array.from"],
101
+ [Array.isArray, "Array.isArray"],
102
+ [Array.of, "Array.of"],
103
+ [ArrayBuffer, "ArrayBuffer"],
104
+ [ArrayBuffer.isView, "ArrayBuffer.isView"],
105
+ [Atomics.add, "Atomics.add"],
106
+ [Atomics.and, "Atomics.and"],
107
+ [Atomics.compareExchange, "Atomics.compareExchange"],
108
+ [Atomics.exchange, "Atomics.exchange"],
109
+ [Atomics.isLockFree, "Atomics.isLockFree"],
110
+ [Atomics.load, "Atomics.load"],
111
+ [Atomics.notify, "Atomics.notify"],
112
+ [Atomics.or, "Atomics.or"],
113
+ [Atomics.store, "Atomics.store"],
114
+ [Atomics.sub, "Atomics.sub"],
115
+ [Atomics.wait, "Atomics.wait"],
116
+ [BigInt, "BigInt"],
117
+ [BigInt.asIntN, "BigInt.asIntN"],
118
+ [BigInt.asUintN, "BigInt.asUintN"],
119
+ [BigInt64Array, "BigInt64Array"],
120
+ [BigInt64Array.from, "BigInt64Array.from"],
121
+ [BigInt64Array.of, "BigInt64Array.of"],
122
+ [BigUint64Array, "BigUint64Array"],
123
+ [BigUint64Array.from, "BigUint64Array.from"],
124
+ [BigUint64Array.of, "BigUint64Array.of"],
125
+ [Boolean, "Boolean"],
126
+ [console.assert, "console.assert"],
127
+ [console.clear, "console.clear"],
128
+ [console.count, "console.count"],
129
+ [console.countReset, "console.countReset"],
130
+ [console.debug, "console.debug"],
131
+ [console.dir, "console.dir"],
132
+ [console.dirxml, "console.dirxml"],
133
+ [console.error, "console.error"],
134
+ [console.group, "console.group"],
135
+ [console.groupCollapsed, "console.groupCollapsed"],
136
+ [console.groupEnd, "console.groupEnd"],
137
+ [console.info, "console.info"],
138
+ [console.log, "console.log"],
139
+ [console.table, "console.table"],
140
+ [console.time, "console.time"],
141
+ [console.timeEnd, "console.timeEnd"],
142
+ [console.timeLog, "console.timeLog"],
143
+ [console.timeStamp, "console.timeStamp"],
144
+ [console.trace, "console.trace"],
145
+ [console.warn, "console.warn"],
146
+ [DataView, "DataView"],
147
+ [Date, "Date"],
148
+ [Date.now, "Date.now"],
149
+ [Date.parse, "Date.parse"],
150
+ [Date.UTC, "Date.UTC"],
151
+ [decodeURI, "decodeURI"],
152
+ [decodeURIComponent, "decodeURIComponent"],
153
+ [encodeURI, "encodeURI"],
154
+ [encodeURIComponent, "encodeURIComponent"],
155
+ [Error, "Error"],
156
+ [EvalError, "EvalError"],
157
+ [Float32Array, "Float32Array"],
158
+ [Float32Array.from, "Float32Array.from"],
159
+ [Float32Array.of, "Float32Array.of"],
160
+ [Float64Array, "Float64Array"],
161
+ [Float64Array.from, "Float64Array.from"],
162
+ [Float64Array.of, "Float64Array.of"],
163
+ [Function, "Function"],
164
+ [globalThis.atob, "atob"],
165
+ [globalThis.btoa, "btoa"],
166
+ [globalThis.clearImmediate, "clearImmediate"],
167
+ [globalThis.clearInterval, "clearInterval"],
168
+ [globalThis.clearTimeout, "clearTimeout"],
169
+ [globalThis.crypto?.getRandomValues, "crypto.getRandomValues"],
170
+ [globalThis.crypto?.randomUUID, "crypto.randomUUID"],
171
+ [globalThis.fetch, "fetch"],
172
+ [globalThis.performance?.now, "performance.now"],
173
+ [globalThis.queueMicrotask, "queueMicrotask"],
174
+ [globalThis.setImmediate, "setImmediate"],
175
+ [globalThis.setInterval, "setInterval"],
176
+ [globalThis.setTimeout, "setTimeout"],
177
+ [globalThis.structuredClone, "structuredClone"],
178
+ [globalThis.URL, "URL"],
179
+ [globalThis.URLSearchParams, "URLSearchParams"],
180
+ [globalThis.WritableStream, "WritableStream"],
181
+ [Int16Array, "Int16Array"],
182
+ [Int16Array.from, "Int16Array.from"],
183
+ [Int16Array.of, "Int16Array.of"],
184
+ [Int32Array, "Int32Array"],
185
+ [Int32Array.from, "Int32Array.from"],
186
+ [Int32Array.of, "Int32Array.of"],
187
+ [Int8Array, "Int8Array"],
188
+ [Int8Array.from, "Int8Array.from"],
189
+ [Int8Array.of, "Int8Array.of"],
190
+ [Intl.Collator, "Intl.Collator"],
191
+ [Intl.DateTimeFormat, "Intl.DateTimeFormat"],
192
+ [Intl.DisplayNames, "Intl.DisplayNames"],
193
+ [Intl.getCanonicalLocales, "Intl.getCanonicalLocales"],
194
+ [Intl.ListFormat, "Intl.ListFormat"],
195
+ [Intl.Locale, "Intl.Locale"],
196
+ [Intl.NumberFormat, "Intl.NumberFormat"],
197
+ [Intl.PluralRules, "Intl.PluralRules"],
198
+ [Intl.RelativeTimeFormat, "Intl.RelativeTimeFormat"],
199
+ [Intl.Segmenter, "Intl.Segmenter"],
200
+ [Intl.supportedValuesOf, "Intl.supportedValuesOf"],
201
+ [isFinite, "isFinite"],
202
+ [isNaN, "isNaN"],
203
+ [JSON.parse, "JSON.parse"],
204
+ [JSON.stringify, "JSON.stringify"],
205
+ [Map, "Map"],
206
+ [Map.groupBy, "Map.groupBy"],
207
+ [Math.abs, "Math.abs"],
208
+ [Math.acos, "Math.acos"],
209
+ [Math.acosh, "Math.acosh"],
210
+ [Math.asin, "Math.asin"],
211
+ [Math.asinh, "Math.asinh"],
212
+ [Math.atan, "Math.atan"],
213
+ [Math.atan2, "Math.atan2"],
214
+ [Math.atanh, "Math.atanh"],
215
+ [Math.cbrt, "Math.cbrt"],
216
+ [Math.ceil, "Math.ceil"],
217
+ [Math.clz32, "Math.clz32"],
218
+ [Math.cos, "Math.cos"],
219
+ [Math.cosh, "Math.cosh"],
220
+ [Math.exp, "Math.exp"],
221
+ [Math.expm1, "Math.expm1"],
222
+ [Math.floor, "Math.floor"],
223
+ [Math.fround, "Math.fround"],
224
+ [Math.hypot, "Math.hypot"],
225
+ [Math.imul, "Math.imul"],
226
+ [Math.log, "Math.log"],
227
+ [Math.log10, "Math.log10"],
228
+ [Math.log1p, "Math.log1p"],
229
+ [Math.log2, "Math.log2"],
230
+ [Math.max, "Math.max"],
231
+ [Math.min, "Math.min"],
232
+ [Math.pow, "Math.pow"],
233
+ [Math.random, "Math.random"],
234
+ [Math.round, "Math.round"],
235
+ [Math.sign, "Math.sign"],
236
+ [Math.sin, "Math.sin"],
237
+ [Math.sinh, "Math.sinh"],
238
+ [Math.sqrt, "Math.sqrt"],
239
+ [Math.tan, "Math.tan"],
240
+ [Math.tanh, "Math.tanh"],
241
+ [Math.trunc, "Math.trunc"],
242
+ [Number, "Number"],
243
+ [Number.isFinite, "Number.isFinite"],
244
+ [Number.isInteger, "Number.isInteger"],
245
+ [Number.isNaN, "Number.isNaN"],
246
+ [Number.isSafeInteger, "Number.isSafeInteger"],
247
+ [Number.parseFloat, "Number.parseFloat"],
248
+ [Number.parseInt, "Number.parseInt"],
249
+ [Object, "Object"],
250
+ [Object.assign, "Object.assign"],
251
+ [Object.create, "Object.create"],
252
+ [Object.defineProperties, "Object.defineProperties"],
253
+ [Object.defineProperty, "Object.defineProperty"],
254
+ [Object.entries, "Object.entries"],
255
+ [Object.freeze, "Object.freeze"],
256
+ [Object.fromEntries, "Object.fromEntries"],
257
+ [Object.getOwnPropertyDescriptor, "Object.getOwnPropertyDescriptor"],
258
+ [Object.getOwnPropertyDescriptors, "Object.getOwnPropertyDescriptors"],
259
+ [Object.getOwnPropertyNames, "Object.getOwnPropertyNames"],
260
+ [Object.getOwnPropertySymbols, "Object.getOwnPropertySymbols"],
261
+ [Object.getPrototypeOf, "Object.getPrototypeOf"],
262
+ [Object.is, "Object.is"],
263
+ [Object.isExtensible, "Object.isExtensible"],
264
+ [Object.isFrozen, "Object.isFrozen"],
265
+ [Object.isSealed, "Object.isSealed"],
266
+ [Object.keys, "Object.keys"],
267
+ [Object.preventExtensions, "Object.preventExtensions"],
268
+ [Object.seal, "Object.seal"],
269
+ [Object.setPrototypeOf, "Object.setPrototypeOf"],
270
+ [Object.values, "Object.values"],
271
+ [parseFloat, "parseFloat"],
272
+ [parseInt, "parseInt"],
273
+ [Promise, "Promise"],
274
+ [Proxy, "Proxy"],
275
+ [RangeError, "RangeError"],
276
+ [ReferenceError, "ReferenceError"],
277
+ [Reflect.apply, "Reflect.apply"],
278
+ [Reflect.construct, "Reflect.construct"],
279
+ [Reflect.defineProperty, "Reflect.defineProperty"],
280
+ [Reflect.deleteProperty, "Reflect.deleteProperty"],
281
+ [Reflect.get, "Reflect.get"],
282
+ [Reflect.getOwnPropertyDescriptor, "Reflect.getOwnPropertyDescriptor"],
283
+ [Reflect.getPrototypeOf, "Reflect.getPrototypeOf"],
284
+ [Reflect.has, "Reflect.has"],
285
+ [Reflect.isExtensible, "Reflect.isExtensible"],
286
+ [Reflect.ownKeys, "Reflect.ownKeys"],
287
+ [Reflect.preventExtensions, "Reflect.preventExtensions"],
288
+ [Reflect.set, "Reflect.set"],
289
+ [Reflect.setPrototypeOf, "Reflect.setPrototypeOf"],
290
+ [RegExp, "RegExp"],
291
+ [Set, "Set"],
292
+ [String, "String"],
293
+ [String.fromCharCode, "String.fromCharCode"],
294
+ [String.fromCodePoint, "String.fromCodePoint"],
295
+ [String.raw, "String.raw"],
296
+ [Symbol, "Symbol"],
297
+ [Symbol.for, "Symbol.for"],
298
+ [SyntaxError, "SyntaxError"],
299
+ [TypeError, "TypeError"],
300
+ [Uint16Array, "Uint16Array"],
301
+ [Uint16Array.from, "Uint16Array.from"],
302
+ [Uint16Array.of, "Uint16Array.of"],
303
+ [Uint32Array, "Uint32Array"],
304
+ [Uint32Array.from, "Uint32Array.from"],
305
+ [Uint32Array.of, "Uint32Array.of"],
306
+ [Uint8Array, "Uint8Array"],
307
+ [Uint8Array.from, "Uint8Array.from"],
308
+ [Uint8Array.of, "Uint8Array.of"],
309
+ [Uint8ClampedArray, "Uint8ClampedArray"],
310
+ [Uint8ClampedArray.from, "Uint8ClampedArray.from"],
311
+ [Uint8ClampedArray.of, "Uint8ClampedArray.of"],
312
+ [URIError, "URIError"],
313
+ [WeakMap, "WeakMap"],
314
+ [WeakSet, "WeakSet"]
315
+ ]), KNOWN_OBJECTS = /* @__PURE__ */ new Map([
316
+ [Atomics, "Atomics"],
317
+ [console, "console"],
318
+ [globalThis, "globalThis"],
319
+ [globalThis.crypto, "crypto"],
320
+ [Intl, "Intl"],
321
+ [JSON, "JSON"],
322
+ [Math, "Math"],
323
+ [Reflect, "Reflect"]
324
+ ]), State = class {
325
+ ids = 0;
326
+ flush = 0;
327
+ flushed = !1;
328
+ buf = [];
329
+ refs = /* @__PURE__ */ new WeakMap();
330
+ assigned = /* @__PURE__ */ new Set();
331
+ boundary = void 0;
332
+ }, Reference = class {
333
+ constructor(parent, accessor, flush, pos = null, id = null) {
334
+ this.parent = parent;
335
+ this.accessor = accessor;
336
+ this.flush = flush;
337
+ this.pos = pos;
338
+ this.id = id;
339
+ this.parent = parent, this.accessor = accessor, this.flush = flush, this.pos = pos, this.id = id;
340
+ }
341
+ init = "";
342
+ assigns = "";
343
+ }, Serializer = class {
344
+ #state = new State();
345
+ get flushed() {
346
+ return this.#state.flushed;
347
+ }
348
+ stringify(val, boundary) {
349
+ try {
350
+ return this.#state.flushed = !1, this.#state.boundary = boundary, writeRoot(this.#state, val);
351
+ } finally {
352
+ this.#flush();
353
+ }
354
+ }
355
+ nextId() {
356
+ return nextId(this.#state);
357
+ }
358
+ symbol(id) {
359
+ let symbol = Symbol();
360
+ return this.#state.refs.set(symbol, new Reference(null, null, 0, null, id)), symbol;
361
+ }
362
+ #flush() {
363
+ this.#state.flush++, this.#state.buf = [], this.#state.assigned = /* @__PURE__ */ new Set();
364
+ }
365
+ };
366
+ function register(id, val, scope) {
367
+ return REGISTRY.set(val, { id, scope, access: "_._" + toAccess(toObjectKey(id)) }), val;
368
+ }
369
+ function getRegistered(val) {
370
+ let registered = REGISTRY.get(val);
371
+ if (registered)
372
+ return {
373
+ id: registered.id,
374
+ scope: registered.scope
375
+ };
376
+ }
377
+ function writeRoot(state, root) {
378
+ let { buf, assigned } = state, hadBuf = buf.length !== 0, result = "";
379
+ if (hadBuf && buf.push(","), writeProp(state, root, null, "")) {
380
+ let rootRef = state.refs.get(root);
381
+ rootRef && ensureId(state, rootRef), assigned.size && (assigned.delete(rootRef) ? (assigned.add(rootRef), writeAssigned(state)) : (writeAssigned(state), buf.push("," + rootRef.id))), result = "(", buf.push(")");
382
+ } else
383
+ hadBuf && (buf.pop(), writeAssigned(state)), result = "{", buf.push("}");
384
+ for (let chunk of buf)
385
+ result += chunk;
386
+ return "_=>" + result;
387
+ }
388
+ function writeAssigned(state) {
389
+ for (let valueRef of state.assigned)
390
+ state.buf.push("," + valueRef.assigns + (valueRef.init || valueRef.id)), valueRef.init = "";
391
+ }
392
+ function writeProp(state, val, parent, accessor) {
393
+ switch (typeof val) {
394
+ case "string":
395
+ return writeString(state, val);
396
+ case "number":
397
+ return writeNumber(state, val);
398
+ case "boolean":
399
+ return writeBoolean(state, val);
400
+ case "bigint":
401
+ return writeBigInt(state, val);
402
+ case "symbol":
403
+ return writeSymbol(state, val, parent, accessor);
404
+ case "function":
405
+ return writeFunction(state, val, parent, accessor);
406
+ case "object":
407
+ return writeObject(state, val, parent, accessor);
408
+ default:
409
+ return !1;
410
+ }
411
+ }
412
+ function writeReferenceOr(state, write2, val, parent, accessor) {
413
+ let ref = state.refs.get(val);
414
+ if (ref)
415
+ return ref.init ? (ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : isCircular(parent, ref) ? (ref.assigns || (ensureId(state, ref), state.assigned.add(ref)), ref.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1) : (state.buf.push(ensureId(state, ref)), !0);
416
+ let registered = REGISTRY.get(val);
417
+ return registered ? writeRegistered(state, val, parent, accessor, registered) : (state.refs.set(
418
+ val,
419
+ ref = new Reference(parent, accessor, state.flush, state.buf.length)
420
+ ), write2(state, val, ref) ? !0 : (state.refs.delete(ref), !1));
421
+ }
422
+ function writeRegistered(state, val, parent, accessor, { access, scope }) {
423
+ if (scope) {
424
+ let scopeRef = state.refs.get(scope), fnRef = new Reference(
425
+ parent,
426
+ accessor,
427
+ state.flush,
428
+ state.buf.length
429
+ );
430
+ if (state.refs.set(val, fnRef), scopeRef) {
431
+ let scopeId = ensureId(state, scopeRef);
432
+ if (isCircular(parent, scopeRef))
433
+ return state.assigned.add(fnRef), fnRef.init = access + "(" + scopeId + ")", fnRef.assigns += ensureId(state, parent) + toAccess(accessor) + "=", !1;
434
+ state.buf.push(access + "(" + scopeId + ")");
435
+ } else {
436
+ state.buf.push(access + "("), writeProp(state, scope, parent, "");
437
+ let scopeRef2 = state.refs.get(scope);
438
+ scopeRef2 && ensureId(state, scopeRef2), state.buf.push(")");
439
+ }
440
+ } else
441
+ state.buf.push(access);
442
+ return !0;
443
+ }
444
+ function writeString(state, val) {
445
+ return state.buf.push(quote(val, 0)), !0;
446
+ }
447
+ function writeNumber(state, val) {
448
+ return state.buf.push(val + ""), !0;
449
+ }
450
+ function writeBoolean(state, val) {
451
+ return state.buf.push(val ? "!0" : "!1"), !0;
452
+ }
453
+ function writeBigInt(state, val) {
454
+ return state.buf.push(val + "n"), !0;
455
+ }
456
+ function writeFunction(state, val, parent, accessor) {
457
+ let wellKnownFunction = KNOWN_FUNCTIONS.get(val);
458
+ return wellKnownFunction ? (state.buf.push(wellKnownFunction), !0) : writeReferenceOr(state, writeNever, val, parent, accessor);
459
+ }
460
+ function writeSymbol(state, val, parent, accessor) {
461
+ let wellKnownSymbol = KNOWN_SYMBOLS.get(val);
462
+ if (wellKnownSymbol)
463
+ return state.buf.push(wellKnownSymbol), !0;
464
+ let key = Symbol.keyFor(val);
465
+ return key !== void 0 ? (state.buf.push("Symbol.for(" + quote(key, 0) + ")"), !0) : writeReferenceOr(state, writeUnknownSymbol, val, parent, accessor);
466
+ }
467
+ function writeUnknownSymbol(state) {
468
+ return state.buf.push("Symbol()"), !0;
469
+ }
470
+ function writeNever() {
471
+ return !1;
472
+ }
473
+ function writeNull(state) {
474
+ return state.buf.push("null"), !0;
475
+ }
476
+ function writeObject(state, val, parent, accessor) {
477
+ if (val === null) return writeNull(state);
478
+ let wellKnownObject = KNOWN_OBJECTS.get(val);
479
+ return wellKnownObject ? (state.buf.push(wellKnownObject), !0) : writeReferenceOr(state, writeUnknownObject, val, parent, accessor);
480
+ }
481
+ function writeUnknownObject(state, val, ref) {
482
+ switch (val.constructor) {
483
+ case void 0:
484
+ return writeNullObject(state, val, ref);
485
+ case Object:
486
+ return writePlainObject(state, val, ref);
487
+ case Array:
488
+ return writeArray(state, val, ref);
489
+ case Date:
490
+ return writeDate(state, val);
491
+ case RegExp:
492
+ return writeRegExp(state, val);
493
+ case Promise:
494
+ return writePromise(state, val, ref);
495
+ case Map:
496
+ return writeMap(state, val, ref);
497
+ case Set:
498
+ return writeSet(state, val, ref);
499
+ case Generator:
500
+ return writeGenerator(state, val, ref);
501
+ case AsyncGenerator:
502
+ return writeAsyncGenerator(state, val, ref);
503
+ case Error:
504
+ case EvalError:
505
+ case RangeError:
506
+ case ReferenceError:
507
+ case SyntaxError:
508
+ case TypeError:
509
+ case URIError:
510
+ return writeError(state, val, ref);
511
+ case AggregateError:
512
+ return writeAggregateError(state, val, ref);
513
+ case ArrayBuffer:
514
+ return writeArrayBuffer(state, val);
515
+ case Int8Array:
516
+ case Uint8Array:
517
+ case Uint8ClampedArray:
518
+ case Int16Array:
519
+ case Uint16Array:
520
+ case Int32Array:
521
+ case Uint32Array:
522
+ case Float32Array:
523
+ case Float64Array:
524
+ return writeTypedArray(state, val, ref);
525
+ case WeakSet:
526
+ return writeWeakSet(state);
527
+ case WeakMap:
528
+ return writeWeakMap(state);
529
+ // The following references use `globalThis`
530
+ // since they are not implemented by all runtimes.
531
+ case globalThis.URL:
532
+ return writeURL(state, val);
533
+ case globalThis.URLSearchParams:
534
+ return writeURLSearchParams(state, val);
535
+ case globalThis.Headers:
536
+ return writeHeaders(state, val);
537
+ case globalThis.FormData:
538
+ return writeFormData(state, val);
539
+ case globalThis.ReadableStream:
540
+ return writeReadableStream(state, val, ref);
541
+ case globalThis.Request:
542
+ return writeRequest(state, val, ref);
543
+ case globalThis.Response:
544
+ return writeResponse(state, val, ref);
545
+ }
546
+ return !1;
547
+ }
548
+ function writePlainObject(state, val, ref) {
549
+ return state.buf.push("{"), writeObjectProps(state, val, ref), state.buf.push("}"), !0;
550
+ }
551
+ function writeArray(state, val, ref) {
552
+ state.buf.push("["), writeProp(state, val[0], ref, "0");
553
+ for (let i = 1; i < val.length; i++)
554
+ state.buf.push(","), writeProp(state, val[i], ref, "" + i);
555
+ return state.buf.push("]"), !0;
556
+ }
557
+ function writeDate(state, val) {
558
+ return state.buf.push('new Date("' + val.toISOString() + '")'), !0;
559
+ }
560
+ function writeRegExp(state, val) {
561
+ return state.buf.push(val + ""), !0;
562
+ }
563
+ function writePromise(state, val, ref) {
564
+ let { boundary } = state;
565
+ if (!boundary) return !1;
566
+ let pId = nextRefAccess(state), pRef = new Reference(ref, null, state.flush, null, pId);
567
+ return state.buf.push("new Promise((f,r)=>" + pId + "={f,r})"), val.then(
568
+ (v) => writeAsyncCall(state, boundary, pRef, "f", v, pId),
569
+ (v) => writeAsyncCall(state, boundary, pRef, "r", v, pId)
570
+ ), boundary.startAsync(), !0;
571
+ }
572
+ function writeMap(state, val, ref) {
573
+ if (!val.size)
574
+ return state.buf.push("new Map"), !0;
575
+ let items = [], assigns = "";
576
+ for (let [itemKey, itemValue] of val)
577
+ itemKey === val && (itemKey = void 0, assigns += "i[" + items.length + "][0]="), itemValue === val && (itemValue = void 0, assigns += "i[" + items.length + "][1]="), itemValue === void 0 ? items.push([itemKey]) : items.push([itemKey, itemValue]);
578
+ let arrayRef = new Reference(
579
+ ref,
580
+ null,
581
+ state.flush,
582
+ null,
583
+ nextRefAccess(state)
584
+ );
585
+ return state.buf.push(
586
+ (assigns ? "((m,i)=>(" + assigns + "m,i.forEach(i=>m.set(i[0],i[1])),m))(new Map," : "new Map(") + arrayRef.id + "="
587
+ ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
588
+ }
589
+ function writeSet(state, val, ref) {
590
+ if (!val.size)
591
+ return state.buf.push("new Set"), !0;
592
+ let items = [], assigns = "";
593
+ for (let item of val)
594
+ item === val && (item = void 0, assigns += "i[" + items.length + "]="), items.push(item);
595
+ let arrayRef = new Reference(
596
+ ref,
597
+ null,
598
+ state.flush,
599
+ null,
600
+ nextRefAccess(state)
601
+ );
602
+ return state.buf.push(
603
+ (assigns ? "((s,i)=>(" + assigns + "s,i.forEach(i=>s.add(i)),s))(new Set," : "new Set(") + arrayRef.id + "="
604
+ ), writeArray(state, items, arrayRef), state.buf.push(")"), !0;
605
+ }
606
+ function writeArrayBuffer(state, val) {
607
+ let result = "";
608
+ if (val.byteLength) {
609
+ let view = new Int8Array(val);
610
+ result = hasOnlyZeros(view) ? "new ArrayBuffer(" + val.byteLength + ")" : "new Int8Array(" + typedArrayToInitString(view) + ").buffer";
611
+ } else
612
+ result = "new ArrayBuffer";
613
+ return state.buf.push(result), !0;
614
+ }
615
+ function writeTypedArray(state, val, ref) {
616
+ return val.byteOffset || state.refs.has(val.buffer) ? (state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push(val.byteOffset ? "," + val.byteOffset + ")" : ")")) : (state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push(
617
+ "new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")")
618
+ )), !0;
619
+ }
620
+ function writeWeakSet(state) {
621
+ return state.buf.push("new WeakSet"), !0;
622
+ }
623
+ function writeWeakMap(state) {
624
+ return state.buf.push("new WeakMap"), !0;
625
+ }
626
+ function writeError(state, val, ref) {
627
+ let result = "new " + val.constructor.name + "(" + quote(val.message + "", 0);
628
+ return val.cause ? (state.buf.push(result + ",{cause:"), writeProp(state, val.cause, ref, "cause"), state.buf.push("})")) : state.buf.push(result + ")"), !0;
629
+ }
630
+ function writeAggregateError(state, val, ref) {
631
+ return state.buf.push("new AggregateError("), writeProp(state, val.errors, ref, "errors"), val.message ? state.buf.push("," + quote(val.message + "", 0) + ")") : state.buf.push(")"), !0;
632
+ }
633
+ function writeURL(state, val) {
634
+ return state.buf.push("new URL(" + quote(val.toString(), 0) + ")"), !0;
635
+ }
636
+ function writeURLSearchParams(state, val) {
637
+ let str = val.toString();
638
+ return str ? state.buf.push("new URLSearchParams(" + quote(str, 0) + ")") : state.buf.push("new URLSearchParams"), !0;
639
+ }
640
+ function writeHeaders(state, val) {
641
+ let headers = stringEntriesToProps(val);
642
+ return state.buf.push("new Headers" + (headers ? "({" + headers + "})" : "")), !0;
643
+ }
644
+ function writeFormData(state, val) {
645
+ let sep = "[", valStr = "";
646
+ for (let [key, value] of val)
647
+ typeof value == "string" && (valStr += sep + "[" + quote(key, 0) + "," + quote(value, 0) + "]", sep = ",");
648
+ return sep === "[" ? state.buf.push("new FormData") : state.buf.push(
649
+ "((f,i)=>(f,i.forEach(i=>f.append(i[0],i[1])),f))(new FormData," + valStr + "])"
650
+ ), !0;
651
+ }
652
+ function writeRequest(state, val, ref) {
653
+ let sep = "", hasBody = val.body && !val.bodyUsed && val.duplex === "half";
654
+ state.buf.push("new Request(" + quote(val.url, 0)), hasBody && (state.buf.push(",{body:"), writeProp(state, val.body, ref, "body") ? (state.buf.push(',duplex:"half"'), sep = ",") : state.buf.pop());
655
+ let options = "";
656
+ val.cache !== "default" && (options += sep + "cache:" + quote(val.cache, 0), sep = ","), val.credentials !== "same-origin" && (options += sep + "credentials:" + quote(val.credentials, 0), sep = ",");
657
+ let headers = stringEntriesToProps(val.headers);
658
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), val.integrity && (options += sep + "integrity:" + quote(val.integrity, 0), sep = ","), val.keepalive && (options += sep + "keepalive:true", sep = ","), val.method !== "GET" && (options += sep + "method:" + quote(val.method, 0), sep = ","), val.mode !== "cors" && (options += sep + "mode:" + quote(val.mode, 0), sep = ","), val.redirect !== "follow" && (options += sep + "redirect:" + quote(val.redirect, 0), sep = ","), val.referrer !== "about:client" && (options += sep + "referrer:" + quote(val.referrer, 0), sep = ","), val.referrerPolicy && (options += sep + "referrerPolicy:" + quote(val.referrerPolicy, 0), sep = ","), state.buf.push(
659
+ hasBody ? options + "})" : options ? ",{" + options + "})" : ")"
660
+ ), !0;
661
+ }
662
+ function writeResponse(state, val, ref) {
663
+ let sep = "", options = "";
664
+ val.status !== 200 && (options += "status:" + val.status, sep = ","), val.statusText && (options += sep + "statusText:" + quote(val.statusText, 0), sep = ",");
665
+ let headers = stringEntriesToProps(val.headers);
666
+ return state.refs.set(val.headers, new Reference(ref, "headers", state.flush, null)), headers && (options += sep + "headers:{" + headers + "}", sep = ","), !val.body || val.bodyUsed ? state.buf.push(
667
+ "new Response" + (options ? "(null,{" + options + "})" : "")
668
+ ) : (state.buf.push("new Response("), state.buf.push(
669
+ (writeProp(state, val.body, ref, "body") ? "" : "null") + (options ? ",{" + options + "})" : ")")
670
+ )), !0;
671
+ }
672
+ function writeReadableStream(state, val, ref) {
673
+ let { boundary } = state;
674
+ if (!boundary || val.locked) return !1;
675
+ let reader = val.getReader(), iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
676
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (reader.read().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
677
+ }, onRejected = (reason) => {
678
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
679
+ };
680
+ return state.buf.push(
681
+ "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))}})"
682
+ ), reader.read().then(onFulfilled, onRejected), boundary.startAsync(), !0;
683
+ }
684
+ function writeGenerator(state, iter, ref) {
685
+ let sep = "";
686
+ for (state.buf.push("(function*(){"); ; ) {
687
+ let { value, done } = iter.next();
688
+ if (done) {
689
+ value !== void 0 && (state.buf.push(sep + "return "), writeProp(state, value, ref, ""));
690
+ break;
691
+ }
692
+ value === void 0 ? state.buf.push(sep + "yield") : (state.buf.push(sep + "yield "), writeProp(state, value, ref, "")), sep = ";";
693
+ }
694
+ return state.buf.push("})()"), !0;
695
+ }
696
+ function writeAsyncGenerator(state, iter, ref) {
697
+ let { boundary } = state;
698
+ if (!boundary) return !1;
699
+ let iterId = nextRefAccess(state), iterRef = new Reference(ref, null, state.flush, null, iterId), onFulfilled = ({ value, done }) => {
700
+ done ? writeAsyncCall(state, boundary, iterRef, "r", value) : boundary.signal.aborted || (iter.next().then(onFulfilled, onRejected), boundary.startAsync(), writeAsyncCall(state, boundary, iterRef, "f", value));
701
+ }, onRejected = (reason) => {
702
+ writeAsyncCall(state, boundary, iterRef, "j", reason);
703
+ };
704
+ return state.buf.push(
705
+ "(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 + "={})"
706
+ ), iter.next().then(onFulfilled, onRejected), boundary.startAsync(), !0;
707
+ }
708
+ function writeNullObject(state, val, ref) {
709
+ return state.buf.push("{"), state.buf.push(writeObjectProps(state, val, ref) + "__proto__:null}"), !0;
710
+ }
711
+ function writeObjectProps(state, val, ref) {
712
+ let sep = "";
713
+ for (let key in val)
714
+ if (hasOwnProperty.call(val, key)) {
715
+ let escapedKey = toObjectKey(key);
716
+ state.buf.push(sep + escapedKey + ":"), writeProp(
717
+ state,
718
+ val[key],
719
+ ref,
720
+ escapedKey
721
+ ) ? sep = "," : state.buf.pop();
722
+ }
723
+ if (hasSymbolIterator(val) && (state.buf.push(sep + "[Symbol.iterator]:"), sep = ",", !writeReferenceOr(
724
+ state,
725
+ writeNever,
726
+ val[Symbol.iterator],
727
+ ref,
728
+ "Symbol.iterator"
729
+ ))) {
730
+ let arrayRef = new Reference(
731
+ ref,
732
+ null,
733
+ state.flush,
734
+ null,
735
+ nextRefAccess(state)
736
+ );
737
+ state.buf.push("(a=>()=>a.values())(" + arrayRef.id + "="), writeArray(state, [...val], arrayRef), state.buf.push(")");
738
+ }
739
+ return sep;
740
+ }
741
+ function writeAsyncCall(state, boundary, ref, method, value, preferredValueId = null) {
742
+ if (boundary.signal.aborted) return;
743
+ state.flushed = !0;
744
+ let valueStartIndex = state.buf.push(
745
+ (state.buf.length === 0 ? "" : ",") + ref.id + "." + method + "("
746
+ );
747
+ if (writeProp(state, value, ref, "")) {
748
+ let valueRef = state.refs.get(value);
749
+ valueRef && !valueRef.id && (valueRef.id = preferredValueId || nextRefAccess(state), state.buf[valueStartIndex] = valueRef.id + "=" + state.buf[valueStartIndex]);
750
+ }
751
+ state.buf.push(")"), boundary.endAsync();
752
+ }
753
+ function isCircular(parent, ref) {
754
+ let cur = parent;
755
+ for (; cur; ) {
756
+ if (cur === ref) return !0;
757
+ cur = cur.parent;
758
+ }
759
+ return !1;
760
+ }
761
+ function toObjectKey(name) {
762
+ if (name === "")
763
+ return '""';
764
+ let startChar = name[0];
765
+ if (isDigit(startChar)) {
766
+ if (startChar === "0") {
767
+ if (name !== "0")
768
+ return quote(name, 1);
769
+ } else
770
+ for (let i = 1; i < name.length; i++)
771
+ if (!isDigit(name[i]))
772
+ return quote(name, i);
773
+ } else if (isWord(startChar)) {
774
+ for (let i = 1; i < name.length; i++)
775
+ if (!isWordOrDigit(name[i]))
776
+ return quote(name, i);
777
+ } else
778
+ return quote(name, 0);
779
+ return name;
780
+ }
781
+ function toAccess(accessor) {
782
+ let start = accessor[0];
783
+ return start === '"' || start >= "0" && start <= "9" ? "[" + accessor + "]" : "." + accessor;
784
+ }
785
+ function quote(str, startPos) {
786
+ let result = "", lastPos = 0;
787
+ for (let i = startPos; i < str.length; i++) {
788
+ let replacement;
789
+ switch (str[i]) {
790
+ case '"':
791
+ replacement = '\\"';
792
+ break;
793
+ case "\\":
794
+ replacement = "\\\\";
795
+ break;
796
+ case "<":
797
+ replacement = "\\x3C";
798
+ break;
799
+ case `
800
+ `:
801
+ replacement = "\\n";
802
+ break;
803
+ case "\r":
804
+ replacement = "\\r";
805
+ break;
806
+ case "\u2028":
807
+ replacement = "\\u2028";
808
+ break;
809
+ case "\u2029":
810
+ replacement = "\\u2029";
811
+ break;
812
+ default:
813
+ continue;
814
+ }
815
+ result += str.slice(lastPos, i) + replacement, lastPos = i + 1;
816
+ }
817
+ return '"' + (lastPos === startPos ? str : result + str.slice(lastPos)) + '"';
818
+ }
819
+ function ensureId(state, ref) {
820
+ return ref.id || assignId(state, ref);
821
+ }
822
+ function assignId(state, ref) {
823
+ let { pos } = ref;
824
+ if (ref.id = nextRefAccess(state), pos !== null && ref.flush === state.flush)
825
+ return pos === 0 ? state.buf[0] = ref.id + "=" + state.buf[0] : state.buf[pos - 1] += ref.id + "=", ref.id;
826
+ let cur = ref, accessPrevValue = "";
827
+ do {
828
+ accessPrevValue = toAccess(cur.accessor) + accessPrevValue;
829
+ let parent = cur.parent;
830
+ if (parent.id) {
831
+ accessPrevValue = parent.id + accessPrevValue;
832
+ break;
833
+ }
834
+ if (parent.flush === state.flush) {
835
+ accessPrevValue = ensureId(state, parent) + accessPrevValue;
836
+ break;
837
+ }
838
+ cur = parent;
839
+ } while (cur);
840
+ return ref.id + "=" + accessPrevValue;
841
+ }
842
+ function nextRefAccess(state) {
843
+ return "_." + nextId(state);
844
+ }
845
+ function nextId(state) {
846
+ let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 11, index = state.ids++, mod = index % encodeStartLen, id = encodeChars[mod];
847
+ for (index = (index - mod) / encodeStartLen; index > 0; )
848
+ mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
849
+ return id;
850
+ }
851
+ function hasSymbolIterator(value) {
852
+ return Symbol.iterator in value;
853
+ }
854
+ function stringEntriesToProps(entries) {
855
+ let result = "", sep = "";
856
+ for (let [key, value] of entries)
857
+ result += sep + toObjectKey(key) + ":" + quote(value, 0), sep = ",";
858
+ return result;
859
+ }
860
+ function typedArrayToInitString(view) {
861
+ let result = "[", sep = "";
862
+ for (let i = 0; i < view.length; i++)
863
+ result += sep + view[i], sep = ",";
864
+ return result += "]", result;
865
+ }
866
+ function hasOnlyZeros(typedArray) {
867
+ for (let i = 0; i < typedArray.length; i++)
868
+ if (typedArray[i] !== 0) return !1;
869
+ return !0;
870
+ }
871
+ function isWordOrDigit(char) {
872
+ return isWord(char) || isDigit(char);
873
+ }
874
+ function isDigit(char) {
875
+ return char >= "0" && char <= "9";
876
+ }
877
+ function isWord(char) {
878
+ return char >= "a" && char <= "z" || char >= "A" && char <= "Z" || char === "_" || char === "$";
879
+ }
880
+
881
+ // src/html/writer.ts
882
+ var $chunk, NOOP = () => {
883
+ }, K_SCOPE_ID = Symbol("Scope ID");
884
+ function getChunk() {
885
+ return $chunk;
886
+ }
887
+ function getScopeId(scope) {
888
+ return scope[K_SCOPE_ID];
889
+ }
890
+ function write(html) {
891
+ $chunk.writeHTML(html);
892
+ }
893
+ function writeScript(script) {
894
+ $chunk.writeScript(script);
895
+ }
896
+ function writeEffect(scopeId, registryId) {
897
+ $chunk.boundary.state.needsMainRuntime = !0, $chunk.writeEffect(scopeId, registryId);
898
+ }
899
+ var kPendingContexts = Symbol("Pending Contexts");
900
+ function withContext(key, value, cb) {
901
+ let ctx = $chunk.context ||= { [kPendingContexts]: 0 }, prev = ctx[key];
902
+ ctx[kPendingContexts]++, ctx[key] = value;
903
+ try {
904
+ cb();
905
+ } finally {
906
+ ctx[kPendingContexts]--, ctx[key] = prev;
907
+ }
908
+ }
909
+ function register2(val, id, scopeId) {
910
+ return scopeId === void 0 ? register(id, val) : register(id, val, ensureScopeWithId(scopeId));
911
+ }
912
+ function nextTagId() {
913
+ let state = $chunk.boundary.state, { $global: $global2 } = state;
914
+ return "s" + $global2.runtimeId + $global2.renderId + (state.tagIndex++).toString(36);
915
+ }
916
+ function nextScopeId() {
917
+ return $chunk.boundary.state.scopeIndex++;
918
+ }
919
+ function peekNextScopeId() {
920
+ return $chunk.boundary.state.scopeIndex;
921
+ }
922
+ function peekNextScope() {
923
+ return ensureScopeWithId(peekNextScopeId());
924
+ }
925
+ function getScopeById(scopeId) {
926
+ if (scopeId !== void 0)
927
+ return $chunk.boundary.state.scopes.get(scopeId);
928
+ }
929
+ function markResumeNode(scopeId, accessor) {
930
+ let { state } = $chunk.boundary;
931
+ return state.needsMainRuntime = !0, state.mark("*" /* Node */, scopeId + " " + accessor);
932
+ }
933
+ function nodeRef(scopeId, id) {
934
+ let getter = () => {
935
+ };
936
+ return id ? register2(getter, id, scopeId) : getter;
937
+ }
938
+ function markResumeScopeStart(scopeId, index) {
939
+ return $chunk.boundary.state.mark(
940
+ "[" /* SectionStart */,
941
+ scopeId + (index ? " " + index : "")
942
+ );
943
+ }
944
+ function markResumeControlEnd(scopeId, accessor) {
945
+ return $chunk.boundary.state.mark("]" /* SectionEnd */, scopeId + " " + accessor);
946
+ }
947
+ function markResumeControlSingleNodeEnd(scopeId, accessor, childScopeIds) {
948
+ return $chunk.boundary.state.mark(
949
+ "|" /* SectionSingleNodesEnd */,
950
+ scopeId + " " + accessor + " " + (childScopeIds ?? "")
951
+ );
952
+ }
953
+ function markResumeCleanup(scopeId) {
954
+ return $chunk.boundary.state.mark("$" /* Cleanup */, "" + scopeId);
955
+ }
956
+ function writeScope(scopeId, partialScope) {
957
+ let { state } = $chunk.boundary, { scopes } = state, scope = scopes.get(scopeId);
958
+ return state.needsMainRuntime = !0, scope ? Object.assign(scope, partialScope) : (scope = partialScope, scope[K_SCOPE_ID] = scopeId, state.scopes.set(scopeId, scope)), state.writeScopes ? state.writeScopes[scopeId] = scope : state.hasGlobals ? state.writeScopes = { [scopeId]: scope } : (state.hasGlobals = !0, state.writeScopes = {
959
+ $: getFilteredGlobals(state.$global),
960
+ [scopeId]: scope
961
+ }), scope;
962
+ }
963
+ function writeExistingScope(scope) {
964
+ return writeScope(scope[K_SCOPE_ID], scope);
965
+ }
966
+ function ensureScopeWithId(scopeId) {
967
+ let { state } = $chunk.boundary, scope = state.scopes.get(scopeId);
968
+ return scope || (scope = { [K_SCOPE_ID]: scopeId }, state.scopes.set(scopeId, scope)), scope;
969
+ }
970
+ function $global() {
971
+ return $chunk.boundary.state.$global;
972
+ }
973
+ function fork(promise, renderBody) {
974
+ if (!isPromise(promise)) {
975
+ renderBody(promise);
976
+ return;
977
+ }
978
+ let chunk = $chunk, { boundary } = chunk;
979
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, chunk.context), chunk.async = !0, chunk.context?.[kPendingContexts] && (chunk.context = { ...chunk.context, [kPendingContexts]: 0 }), boundary.startAsync(), promise.then(
980
+ (value) => {
981
+ chunk.async && (chunk.async = !1, boundary.signal.aborted || (chunk.render(renderBody, value), boundary.endAsync(chunk)));
982
+ },
983
+ (err) => {
984
+ chunk.async = !1, boundary.abort(err);
985
+ }
986
+ );
987
+ }
988
+ function tryPlaceholder(renderBody, renderPlaceholder) {
989
+ let chunk = $chunk, { boundary } = chunk, body = new Chunk(boundary, null, chunk.context);
990
+ if (body === body.render(renderBody)) {
991
+ chunk.append(body);
992
+ return;
993
+ }
994
+ chunk.next = $chunk = new Chunk(boundary, chunk.next, body.context), chunk.placeholderBody = body, chunk.placeholderRender = renderPlaceholder;
995
+ }
996
+ function tryCatch(renderBody, renderCatch) {
997
+ let chunk = $chunk, { boundary } = chunk, { state } = boundary, catchBoundary = new Boundary(state), body = new Chunk(catchBoundary, null, chunk.context), bodyEnd = body.render(renderBody);
998
+ if (catchBoundary.signal.aborted) {
999
+ renderCatch(catchBoundary.signal.reason);
1000
+ return;
1001
+ }
1002
+ if (body === bodyEnd) {
1003
+ chunk.append(body);
1004
+ return;
1005
+ }
1006
+ let reorderId = state.nextReorderId(), endMarker = state.mark("!" /* PlaceholderEnd */, reorderId), bodyNext = bodyEnd.next = $chunk = new Chunk(boundary, chunk.next, body.context);
1007
+ chunk.next = body, chunk.writeHTML(state.mark("!^" /* Placeholder */, reorderId)), bodyEnd.writeHTML(endMarker), boundary.startAsync(), catchBoundary.onNext = () => {
1008
+ if (!boundary.signal.aborted)
1009
+ if (catchBoundary.signal.aborted) {
1010
+ if (!bodyEnd.consumed) {
1011
+ let cur = body, writeMarker = !0;
1012
+ do {
1013
+ let next = cur.next;
1014
+ cur.boundary !== catchBoundary && cur.boundary.abort(catchBoundary.signal.reason), writeMarker && !cur.consumed && (writeMarker = !1, cur.async = !1, cur.next = bodyNext, cur.html = endMarker, cur.scripts = cur.effects = "", cur.placeholderBody = cur.placeholderRender = cur.reorderId = null), cur = next;
1015
+ } while (cur !== bodyNext);
1016
+ }
1017
+ let catchChunk = new Chunk(boundary, null, chunk.context);
1018
+ catchChunk.reorderId = reorderId, catchChunk.render(renderCatch, catchBoundary.signal.reason), state.reorder(catchChunk), boundary.endAsync();
1019
+ } else catchBoundary.done ? boundary.endAsync() : boundary.onNext();
1020
+ };
1021
+ }
1022
+ var State2 = class {
1023
+ constructor($global2) {
1024
+ this.$global = $global2;
1025
+ this.$global = $global2, $global2.cspNonce && (this.nonceAttr = " " + escapeAttrValue($global2.cspNonce + ""));
1026
+ }
1027
+ tagIndex = 0;
1028
+ scopeIndex = 0;
1029
+ reorderIndex = 0;
1030
+ hasGlobals = !1;
1031
+ needsMainRuntime = !1;
1032
+ hasMainRuntime = !1;
1033
+ hasReorderRuntime = !1;
1034
+ hasWrittenResume = !1;
1035
+ trailerHTML = "";
1036
+ nonceAttr = "";
1037
+ serializer = new Serializer();
1038
+ writeReorders = null;
1039
+ scopes = /* @__PURE__ */ new Map();
1040
+ writeScopes = null;
1041
+ get runtimePrefix() {
1042
+ let { $global: $global2 } = this;
1043
+ return $global2.runtimeId + "." + $global2.renderId;
1044
+ }
1045
+ get commentPrefix() {
1046
+ let { $global: $global2 } = this;
1047
+ return $global2.runtimeId + $global2.renderId;
1048
+ }
1049
+ reorder(chunk) {
1050
+ this.writeReorders ? this.writeReorders.push(chunk) : (this.needsMainRuntime = !0, this.writeReorders = [chunk]);
1051
+ }
1052
+ nextReorderId() {
1053
+ let encodeChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$_0123456789", encodeLen = encodeChars.length, encodeStartLen = encodeLen - 10, index = this.reorderIndex++, mod = index % encodeStartLen, id = encodeChars[mod];
1054
+ for (index = (index - mod) / encodeStartLen; index > 0; )
1055
+ mod = index % encodeLen, id += encodeChars[mod], index = (index - mod) / encodeLen;
1056
+ return id;
1057
+ }
1058
+ mark(code, str) {
1059
+ return "<!--" + this.commentPrefix + code + str + "-->";
1060
+ }
1061
+ }, Boundary = class extends AbortController {
1062
+ constructor(state, parent) {
1063
+ super();
1064
+ this.state = state;
1065
+ this.state = state, this.signal.addEventListener("abort", () => {
1066
+ this.count = 0, this.state = new State2(this.state.$global), this.onNext();
1067
+ }), parent && (parent.aborted ? this.abort(parent.reason) : parent.addEventListener("abort", () => {
1068
+ this.abort(parent.reason);
1069
+ }));
1070
+ }
1071
+ onNext = NOOP;
1072
+ count = 0;
1073
+ get done() {
1074
+ return this.count === 0;
1075
+ }
1076
+ startAsync() {
1077
+ this.signal.aborted || this.count++;
1078
+ }
1079
+ endAsync(chunk) {
1080
+ !this.signal.aborted && this.count && (this.count--, chunk?.reorderId && this.state.reorder(chunk), this.onNext());
1081
+ }
1082
+ }, Chunk = class {
1083
+ constructor(boundary, next, context) {
1084
+ this.boundary = boundary;
1085
+ this.next = next;
1086
+ this.context = context;
1087
+ this.boundary = boundary, this.next = next, this.context = context;
1088
+ }
1089
+ html = "";
1090
+ scripts = "";
1091
+ effects = "";
1092
+ async = !1;
1093
+ consumed = !1;
1094
+ reorderId = null;
1095
+ placeholderBody = null;
1096
+ placeholderRender = null;
1097
+ writeHTML(html) {
1098
+ this.html += html;
1099
+ }
1100
+ writeEffect(scopeId, registryId) {
1101
+ this.effects = concatEffects(
1102
+ this.effects,
1103
+ scopeId + ',"' + registryId + '"'
1104
+ );
1105
+ }
1106
+ writeScript(script) {
1107
+ this.scripts = concatScripts(this.scripts, script);
1108
+ }
1109
+ append(chunk) {
1110
+ this.html += chunk.html, this.effects = concatEffects(this.effects, chunk.effects), this.scripts = concatScripts(this.scripts, chunk.scripts);
1111
+ }
1112
+ flushPlaceholder() {
1113
+ if (this.placeholderBody) {
1114
+ let body = this.placeholderBody.consume();
1115
+ if (body.async) {
1116
+ let { state } = this.boundary, reorderId = body.reorderId = state.nextReorderId();
1117
+ this.writeHTML(state.mark("!^" /* Placeholder */, reorderId));
1118
+ let after = this.render(this.placeholderRender);
1119
+ after !== this && this.boundary.abort(
1120
+ new Error("An @placeholder cannot contain async content.")
1121
+ ), after.writeHTML(state.mark("!" /* PlaceholderEnd */, reorderId)), state.reorder(body);
1122
+ } else
1123
+ body.next = this.next, this.next = body;
1124
+ this.placeholderRender = this.placeholderBody = null;
1125
+ }
1126
+ }
1127
+ consume() {
1128
+ let cur = this;
1129
+ if (cur.next && !cur.async) {
1130
+ let html = "", effects = "", scripts = "";
1131
+ do
1132
+ cur.flushPlaceholder(), html += cur.html, effects += cur.effects, scripts = concatScripts(scripts, cur.scripts), cur.consumed = !0, cur = cur.next;
1133
+ while (cur.next && !cur.async);
1134
+ cur.html = html + cur.html, cur.effects = concatEffects(effects, cur.effects), cur.scripts = concatScripts(scripts, cur.scripts);
1135
+ }
1136
+ return cur;
1137
+ }
1138
+ render(renderBody, val) {
1139
+ let prev = $chunk;
1140
+ $chunk = this;
1141
+ try {
1142
+ return renderBody(val), $chunk;
1143
+ } catch (err) {
1144
+ return this.boundary.abort(err), this;
1145
+ } finally {
1146
+ $chunk = prev;
1147
+ }
1148
+ }
1149
+ };
1150
+ function prepareChunk(chunk) {
1151
+ let head = chunk.consume(), { boundary, effects } = head, { state } = boundary, { $global: $global2, runtimePrefix, serializer, nonceAttr } = state, { html, scripts } = head, hasWalk = !1;
1152
+ head.effects = "", state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(
1153
+ scripts,
1154
+ WALKER_RUNTIME_CODE + '("' + $global2.runtimeId + '")("' + $global2.renderId + '")'
1155
+ ));
1156
+ let resumes = "";
1157
+ if ((state.writeScopes || serializer.flushed) && (resumes = state.serializer.stringify(state.writeScopes || {}, boundary), state.writeScopes = null), effects && (hasWalk = !0, resumes = resumes ? resumes + "," + effects : effects), boundary.done && (resumes || state.hasWrittenResume) && (resumes = resumes ? resumes + ",0" : "0"), resumes && (state.hasWrittenResume ? scripts = concatScripts(
1158
+ scripts,
1159
+ runtimePrefix + ".r.push(" + resumes + ")"
1160
+ ) : (state.hasWrittenResume = !0, scripts = concatScripts(
1161
+ scripts,
1162
+ runtimePrefix + ".r=[" + resumes + "]"
1163
+ ))), state.writeReorders) {
1164
+ hasWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, html += "<style " + state.commentPrefix + nonceAttr + ">t{display:none}</style>", scripts = concatScripts(
1165
+ scripts,
1166
+ REORDER_RUNTIME_CODE + "(" + runtimePrefix + ")"
1167
+ ));
1168
+ for (let reorderedChunk of state.writeReorders) {
1169
+ let { reorderId } = reorderedChunk, isSync = !0, reorderHTML = "", reorderEffects = "", reorderScripts = "", cur = reorderedChunk;
1170
+ for (reorderedChunk.reorderId = null; cur.flushPlaceholder(), reorderHTML += cur.html, reorderEffects = concatEffects(reorderEffects, cur.effects), reorderScripts = concatScripts(reorderScripts, cur.scripts), cur.async && (reorderHTML += state.mark(
1171
+ "#" /* ReorderMarker */,
1172
+ cur.reorderId = state.nextReorderId()
1173
+ ), cur.html = cur.effects = cur.scripts = "", isSync = !1), cur.next; )
1174
+ cur = cur.next;
1175
+ reorderEffects && (state.hasWrittenResume || (state.hasWrittenResume = !0, scripts = concatScripts(
1176
+ scripts,
1177
+ runtimePrefix + ".r=[]"
1178
+ )), reorderScripts = concatScripts(
1179
+ reorderScripts,
1180
+ "_.push(" + reorderEffects + ")"
1181
+ )), scripts = concatScripts(
1182
+ scripts,
1183
+ reorderScripts && runtimePrefix + ".j." + reorderId + "=_=>{" + reorderScripts + "}"
1184
+ ), html += "<t " + (isSync ? "c " : "") + state.commentPrefix + "=" + reorderId + ">" + reorderHTML + "</t>";
1185
+ }
1186
+ state.writeReorders = null;
1187
+ }
1188
+ return hasWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), head.html = html, head.scripts = scripts, head;
1189
+ }
1190
+ function flushChunk(head, last) {
1191
+ let { boundary } = head, { state } = boundary, { html, scripts } = head, { $global: $global2 } = state, { __flush__ } = $global2, result = html;
1192
+ return head.html = head.scripts = "", scripts && (result += "<script" + state.nonceAttr + ">" + scripts + "</script>"), __flush__ && ($global2.__flush__ = void 0, result = __flush__($global2, result)), last && state.trailerHTML && (result += state.trailerHTML), result;
1193
+ }
1194
+ function writeTrailers(html) {
1195
+ $chunk.boundary.state.trailerHTML += html;
1196
+ }
1197
+ function concatEffects(a, b) {
1198
+ return a ? b ? a + "," + b : a : b;
1199
+ }
1200
+ function concatScripts(a, b) {
1201
+ return a ? b ? a + ";" + b : a : b;
1202
+ }
1203
+ var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb)), tickQueue;
1204
+ function queueTick(cb) {
1205
+ tickQueue ? tickQueue.add(cb) : (tickQueue = /* @__PURE__ */ new Set([cb]), tick(flushTickQueue));
1206
+ }
1207
+ function offTick(cb) {
1208
+ tickQueue?.delete(cb);
1209
+ }
1210
+ function flushTickQueue() {
1211
+ let queue = tickQueue;
1212
+ tickQueue = void 0;
1213
+ for (let cb of queue)
1214
+ cb(!0);
1215
+ }
1216
+ function isPromise(value) {
1217
+ return value != null && typeof value.then == "function";
1218
+ }
1219
+ function getFilteredGlobals($global2) {
1220
+ if (!$global2) return;
1221
+ let serializedGlobals = $global2.serializedGlobals;
1222
+ if (!serializedGlobals) return;
1223
+ let filtered;
1224
+ if (Array.isArray(serializedGlobals))
1225
+ for (let key of serializedGlobals) {
1226
+ let value = $global2[key];
1227
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1228
+ }
1229
+ else
1230
+ for (let key in serializedGlobals)
1231
+ if (serializedGlobals[key]) {
1232
+ let value = $global2[key];
1233
+ value !== void 0 && (filtered ? filtered[key] = value : filtered = { [key]: value });
1234
+ }
1235
+ return filtered;
1236
+ }
1237
+
1238
+ // src/html/attrs.ts
1239
+ function classAttr(val) {
1240
+ return stringAttr("class", classValue(val));
1241
+ }
1242
+ function styleAttr(val) {
1243
+ return stringAttr("style", styleValue(val));
1244
+ }
1245
+ function optionValueAttr(value) {
1246
+ let { [kSelectedValue]: selectedValue } = getChunk()?.context || {};
1247
+ return attr("value", value) + (!isVoid(value) && (Array.isArray(value) ? selectedValue.includes(value) : selectedValue === value) ? " selected" : "");
1248
+ }
1249
+ var kSelectedValue = Symbol("selectedValue");
1250
+ function controllable_select_value(scopeId, nodeAccessor, value, valueChange, renderBody) {
1251
+ valueChange && writeControlledScope(
1252
+ 3 /* SelectValue */,
1253
+ scopeId,
1254
+ nodeAccessor,
1255
+ value,
1256
+ valueChange
1257
+ ), renderBody && withContext(kSelectedValue, value, renderBody);
1258
+ }
1259
+ function controllable_textarea_value(scopeId, nodeAccessor, value, valueChange) {
1260
+ return valueChange && writeControlledScope(
1261
+ 2 /* InputValue */,
1262
+ scopeId,
1263
+ nodeAccessor,
1264
+ void 0,
1265
+ valueChange
1266
+ ), escapeTextAreaValue(value);
1267
+ }
1268
+ function controllable_input_value(scopeId, nodeAccessor, value, valueChange) {
1269
+ return valueChange && writeControlledScope(
1270
+ 2 /* InputValue */,
1271
+ scopeId,
1272
+ nodeAccessor,
1273
+ void 0,
1274
+ valueChange
1275
+ ), attr("value", value);
1276
+ }
1277
+ function controllable_input_checked(scopeId, nodeAccessor, checked, checkedChange) {
1278
+ return checkedChange && writeControlledScope(
1279
+ 0 /* InputChecked */,
1280
+ scopeId,
1281
+ nodeAccessor,
1282
+ void 0,
1283
+ checkedChange
1284
+ ), attr("checked", checked);
1285
+ }
1286
+ function controllable_input_checkedValue(scopeId, nodeAccessor, checkedValue, checkedValueChange, value) {
1287
+ let multiple = Array.isArray(checkedValue), valueAttr = attr("value", value);
1288
+ return checkedValueChange && writeControlledScope(
1289
+ 1 /* InputCheckedValue */,
1290
+ scopeId,
1291
+ nodeAccessor,
1292
+ multiple ? checkedValue : void 0,
1293
+ checkedValueChange
1294
+ ), (multiple ? checkedValue.includes(value) : checkedValue === value) ? valueAttr + " checked" : valueAttr;
1295
+ }
1296
+ function controllable_detailsOrDialog_open(scopeId, nodeAccessor, open, openChange) {
1297
+ return openChange && writeControlledScope(
1298
+ 4 /* DetailsOrDialogOpen */,
1299
+ scopeId,
1300
+ nodeAccessor,
1301
+ open,
1302
+ openChange
1303
+ ), attr("open", open);
1304
+ }
1305
+ function attr(name, val) {
1306
+ return isVoid(val) ? "" : nonVoidAttr(name, val);
1307
+ }
1308
+ function attrs(data, nodeAccessor, scopeId, tagName) {
1309
+ let result = "", skip = /[\s/>"'=]/, events;
1310
+ switch (tagName) {
1311
+ case "input":
1312
+ if (data.checkedChange)
1313
+ result += controllable_input_checked(
1314
+ scopeId,
1315
+ nodeAccessor,
1316
+ data.checked,
1317
+ data.checkedChange
1318
+ );
1319
+ else if (data.checkedValue || data.checkedValueChange)
1320
+ result += controllable_input_checkedValue(
1321
+ scopeId,
1322
+ nodeAccessor,
1323
+ data.checkedValue,
1324
+ data.checkedValueChange,
1325
+ data.value
1326
+ );
1327
+ else if (data.valueChange)
1328
+ result += controllable_input_value(
1329
+ scopeId,
1330
+ nodeAccessor,
1331
+ data.value,
1332
+ data.valueChange
1333
+ );
1334
+ else
1335
+ break;
1336
+ skip = /^(?:value|checked(?:Value)?)(?:Change)?$|[\s/>"'=]/;
1337
+ break;
1338
+ case "select":
1339
+ case "textarea":
1340
+ (data.value || data.valueChange) && (skip = /^value(?:Change)?$|[\s/>"'=]/);
1341
+ break;
1342
+ case "option":
1343
+ data.value && (result += optionValueAttr(data.value), skip = /^value$|[\s/>"'=]/);
1344
+ break;
1345
+ case "details":
1346
+ case "dialog":
1347
+ data.openChange && (result += controllable_detailsOrDialog_open(
1348
+ scopeId,
1349
+ nodeAccessor,
1350
+ data.open,
1351
+ data.openChange
1352
+ ), skip = /^open(?:Change)?$|[\s/>"'=]/);
1353
+ break;
1354
+ }
1355
+ for (let name in data) {
1356
+ let val = data[name];
1357
+ switch (name) {
1358
+ case "class":
1359
+ result += classAttr(val);
1360
+ break;
1361
+ case "style":
1362
+ result += styleAttr(val);
1363
+ break;
1364
+ case "":
1365
+ case "renderBody":
1366
+ break;
1367
+ default:
1368
+ isVoid(val) || (isEventHandler(name) ? (events || (events = {}, writeScope(scopeId, {
1369
+ [nodeAccessor + "~" /* EventAttributes */]: events
1370
+ })), events[getEventHandlerName(name)] = val) : skip.test(name) || (result += nonVoidAttr(name, val)));
1371
+ break;
1372
+ }
1373
+ }
1374
+ return result;
1375
+ }
1376
+ function partialAttrs(data, skip, nodeAccessor, scopeId, tagName) {
1377
+ let partial = {};
1378
+ for (let key in data)
1379
+ skip[key] || (partial[key] = data[key]);
1380
+ return attrs(partial, nodeAccessor, scopeId, tagName);
1381
+ }
1382
+ function writeControlledScope(type, scopeId, nodeAccessor, value, valueChange) {
1383
+ writeScope(scopeId, {
1384
+ [nodeAccessor + "=" /* ControlledType */]: type,
1385
+ [nodeAccessor + ":" /* ControlledValue */]: value,
1386
+ [nodeAccessor + ";" /* ControlledHandler */]: valueChange
1387
+ });
1388
+ }
1389
+ function stringAttr(name, val) {
1390
+ return val && ` ${name}=${escapeAttrValue(val)}`;
1391
+ }
1392
+ function nonVoidAttr(name, val) {
1393
+ switch (typeof val) {
1394
+ case "string":
1395
+ return ` ${name + attrAssignment(val)}`;
1396
+ case "boolean":
1397
+ return ` ${name}`;
1398
+ case "number":
1399
+ return ` ${name}=${val}`;
1400
+ case "object":
1401
+ if (val instanceof RegExp)
1402
+ return ` ${name + attrAssignment(val.source)}`;
1403
+ break;
1404
+ }
1405
+ return ` ${name + attrAssignment(val + "")}`;
1406
+ }
1407
+ function attrAssignment(val) {
1408
+ return val ? `=${escapeAttrValue(val)}` : "";
1409
+ }
1410
+ var unsafeAttrChars = /["'>\s]/g;
1411
+ function escapeAttrValue(str) {
1412
+ if (unsafeAttrChars.test(str)) {
1413
+ let c = str[unsafeAttrChars.lastIndex - 1];
1414
+ return unsafeAttrChars.lastIndex = 0, c === '"' ? `'${str.replace(/'/g, "&#39;")}'` : `"${str.replace(/"/g, "&#34;")}"`;
1415
+ }
1416
+ return str;
1417
+ }
1418
+
1419
+ // src/common/compat-meta.ts
1420
+ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID = prefix + "s";
1421
+
1422
+ // src/common/meta.ts
1423
+ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
1424
+
1425
+ // src/html/dynamic-tag.ts
1426
+ var voidElementsReg = /^(?:area|b(?:ase|r)|col|embed|hr|i(?:mg|nput)|link|meta|param|source|track|wbr)$/;
1427
+ function dynamicTagInput(scope, tag, input, renderBody, tagVar) {
1428
+ if (!tag && !renderBody) return;
1429
+ let scopeId = getScopeId(scope);
1430
+ return write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), tag ? typeof tag == "string" ? (nextScopeId(), write(
1431
+ `<${tag}${attrs(input, 0, scopeId, tag)}>`
1432
+ ), voidElementsReg.test(tag) || (tag === "textarea" ? write(
1433
+ controllable_textarea_value(
1434
+ scopeId,
1435
+ 0,
1436
+ input.value,
1437
+ input.valueChange
1438
+ )
1439
+ ) : renderBody && (tag === "select" && ("value" in input || "valueChange" in input) ? controllable_select_value(
1440
+ scopeId,
1441
+ 0,
1442
+ input.value,
1443
+ input.valueChange,
1444
+ renderBody
1445
+ ) : renderBody()), write(`</${tag}>`)), null) : getDynamicRenderer(tag)(renderBody ? { ...input, renderBody } : input, tagVar) : renderBody();
1446
+ }
1447
+ function dynamicTagArgs(scope, tag, args) {
1448
+ if (!tag) return;
1449
+ let scopeId = getScopeId(scope);
1450
+ if (write(`${markResumeScopeStart(scopeId)}`), writeScope(scopeId, scope), typeof tag == "string") {
1451
+ nextScopeId(), write(
1452
+ `<${tag}${attrs(args[0], 0, scopeId, tag)}>`
1453
+ ), voidElementsReg.test(tag) || write(`</${tag}>`);
1454
+ return;
1455
+ }
1456
+ return getDynamicRenderer(tag)(...args);
1457
+ }
1458
+ var getDynamicRenderer = normalizeDynamicRenderer, createRenderer = (fn) => fn;
1459
+ function patchDynamicTag(newGetDynamicRenderer, newCreateRenderer) {
1460
+ getDynamicRenderer = newGetDynamicRenderer, createRenderer = newCreateRenderer;
1461
+ }
1462
+
1463
+ // src/html/compat.ts
1464
+ var K_TAGS_API_STATE = Symbol(), COMPAT_REGISTRY = /* @__PURE__ */ new WeakMap(), compat = {
1465
+ fork,
1466
+ write,
1467
+ writeScript,
1468
+ nextScopeId,
1469
+ patchDynamicTag,
1470
+ writeSetScopeForComponent(m5c) {
1471
+ let scopeId = nextScopeId();
1472
+ writeScope(scopeId, { m5c }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1473
+ },
1474
+ toJSON() {
1475
+ let compatRegistered = COMPAT_REGISTRY.get(this);
1476
+ if (!compatRegistered) {
1477
+ let registered = getRegistered(this);
1478
+ if (registered) {
1479
+ let scopeId = getScopeId(registered.scope);
1480
+ scopeId !== void 0 && writeScope(scopeId, {}), COMPAT_REGISTRY.set(
1481
+ this,
1482
+ compatRegistered = [registered.id, scopeId]
1483
+ );
1484
+ }
1485
+ }
1486
+ return compatRegistered;
1487
+ },
1488
+ render(renderer, willRerender, classAPIOut, component, input) {
1489
+ let $global2 = classAPIOut.global, state = $global2[K_TAGS_API_STATE] ||= getChunk()?.boundary.state;
1490
+ state || ($global2.runtimeId ||= DEFAULT_RUNTIME_ID, $global2.renderId ||= $global2.componentIdPrefix || DEFAULT_RENDER_ID, $global2[K_TAGS_API_STATE] = state = new State2($global2));
1491
+ let boundary = new Boundary(state), head = new Chunk(
1492
+ boundary,
1493
+ null,
1494
+ null
1495
+ );
1496
+ head.render(() => {
1497
+ if (willRerender) {
1498
+ let scopeId = peekNextScopeId();
1499
+ writeScope(scopeId, { m5c: component.id }), writeEffect(scopeId, SET_SCOPE_REGISTER_ID);
1500
+ }
1501
+ renderer(input);
1502
+ });
1503
+ let asyncOut = classAPIOut.beginAsync();
1504
+ (boundary.onNext = () => {
1505
+ boundary.done && (boundary.signal.aborted ? asyncOut.error(boundary.signal.reason) : queueMicrotask(() => {
1506
+ let { scripts, html } = head = prepareChunk(head);
1507
+ asyncOut.script(scripts), asyncOut.write(html), asyncOut.end(), head.html = head.scripts = "";
1508
+ }));
1509
+ })();
1510
+ },
1511
+ registerRenderer(renderer, id) {
1512
+ return register(
1513
+ RENDERER_REGISTER_ID,
1514
+ renderer,
1515
+ register(id, () => {
1516
+ })
1517
+ );
1518
+ }
1519
+ };
1520
+
1521
+ // src/common/for.ts
1522
+ function forIn(obj, cb) {
1523
+ for (let key in obj)
1524
+ cb(key, obj[key]);
1525
+ }
1526
+ function forOf(list, cb) {
1527
+ if (list) {
1528
+ let i = 0;
1529
+ for (let item of list)
1530
+ cb(item, i++);
1531
+ }
1532
+ }
1533
+ function forTo(to, from, step, cb) {
1534
+ let start = from || 0, delta = step || 1;
1535
+ for (let steps = (to - start) / delta, i = 0; i <= steps; i++)
1536
+ cb(start + i * delta);
1537
+ }
1538
+
1539
+ // src/html/for.ts
1540
+ function forOfBy(by, item, index) {
1541
+ return by ? typeof by == "string" ? item[by] : by(item, index) : index;
1542
+ }
1543
+ function forInBy(by, name, value) {
1544
+ return by ? by(name, value) : name;
1545
+ }
1546
+ function forToBy(by, index) {
1547
+ return by ? by(index) : index;
1548
+ }
1549
+
1550
+ // src/html/template.ts
1551
+ var createTemplate = (templateId, renderer) => (renderer.render = render, renderer._ = renderer, register2(renderer, templateId));
1552
+ function render(input = {}) {
1553
+ let { $global: $global2 } = input;
1554
+ $global2 ? ({ $global: $global2, ...input } = input, $global2 = {
1555
+ runtimeId: DEFAULT_RUNTIME_ID,
1556
+ renderId: DEFAULT_RENDER_ID,
1557
+ ...$global2
1558
+ }) : $global2 = {
1559
+ runtimeId: DEFAULT_RUNTIME_ID,
1560
+ renderId: DEFAULT_RENDER_ID
1561
+ };
1562
+ let head = new Chunk(
1563
+ new Boundary(new State2($global2), $global2.signal),
1564
+ null,
1565
+ null
1566
+ );
1567
+ return head.render(this, input), new ServerRenderResult(head);
1568
+ }
1569
+ var ServerRenderResult = class {
1570
+ #head;
1571
+ #cachedPromise = null;
1572
+ constructor(head) {
1573
+ this.#head = head;
1574
+ }
1575
+ [Symbol.asyncIterator]() {
1576
+ let resolve, reject, value = "", done = !1, aborted = !1, reason, boundary = this.#read(
1577
+ (html) => {
1578
+ value += html, resolve && (resolve({ value, done }), value = "");
1579
+ },
1580
+ (err) => {
1581
+ aborted = !0, reason = err, reject && reject(err);
1582
+ },
1583
+ () => {
1584
+ done = !0, resolve && resolve({ value, done: !value });
1585
+ }
1586
+ );
1587
+ return {
1588
+ next() {
1589
+ if (value) {
1590
+ let result = { value, done: !1 };
1591
+ return value = "", Promise.resolve(result);
1592
+ }
1593
+ return done ? Promise.resolve({ value: "", done }) : aborted ? Promise.reject(reason) : new Promise(exec);
1594
+ },
1595
+ throw(error) {
1596
+ return done || aborted || boundary?.abort(error), Promise.resolve({
1597
+ value: "",
1598
+ done: !0
1599
+ });
1600
+ },
1601
+ return(value2) {
1602
+ return done || aborted || boundary?.abort(new Error("Iterator returned before consumed.")), Promise.resolve({
1603
+ value: value2,
1604
+ done: !0
1605
+ });
1606
+ }
1607
+ };
1608
+ function exec(_resolve, _reject) {
1609
+ resolve = _resolve, reject = _reject;
1610
+ }
1611
+ }
1612
+ pipe(stream) {
1613
+ this.#read(
1614
+ (html) => {
1615
+ stream.write(html);
1616
+ },
1617
+ (err) => {
1618
+ let socket = "socket" in stream && stream.socket;
1619
+ if (socket && typeof socket.destroySoon == "function" && socket.destroySoon(), !stream.emit?.("error", err))
1620
+ throw err;
1621
+ },
1622
+ () => {
1623
+ stream.end();
1624
+ }
1625
+ );
1626
+ }
1627
+ toReadable() {
1628
+ return new ReadableStream({
1629
+ start: (ctrl) => {
1630
+ this.#read(
1631
+ (html) => {
1632
+ ctrl.enqueue(html);
1633
+ },
1634
+ (err) => {
1635
+ ctrl.error(err);
1636
+ },
1637
+ () => {
1638
+ ctrl.close();
1639
+ }
1640
+ );
1641
+ }
1642
+ });
1643
+ }
1644
+ then(onfulfilled, onrejected) {
1645
+ return this.#promise().then(onfulfilled, onrejected);
1646
+ }
1647
+ catch(onrejected) {
1648
+ return this.#promise().catch(onrejected);
1649
+ }
1650
+ finally(onfinally) {
1651
+ return this.#promise().finally(onfinally);
1652
+ }
1653
+ #promise() {
1654
+ return this.#cachedPromise ||= new Promise((resolve, reject) => {
1655
+ let head = this.#head;
1656
+ if (this.#head = null, !head)
1657
+ return reject(new Error("Cannot read from a consumed render result"));
1658
+ let { boundary } = head;
1659
+ (boundary.onNext = () => {
1660
+ boundary.done && (boundary.signal.aborted ? reject(boundary.signal.reason) : (head = prepareChunk(head), boundary.done && resolve(flushChunk(head, !0))));
1661
+ })();
1662
+ });
1663
+ }
1664
+ #read(onWrite, onAbort, onClose) {
1665
+ let tick2 = !0, head = this.#head;
1666
+ if (this.#head = null, !head) {
1667
+ onAbort(new Error("Cannot read from a consumed render result"));
1668
+ return;
1669
+ }
1670
+ let { boundary } = head, onNext = boundary.onNext = (write2) => {
1671
+ if (write2 || boundary.done) {
1672
+ if (boundary.signal.aborted) {
1673
+ tick2 || offTick(onNext), onAbort(boundary.signal.reason);
1674
+ return;
1675
+ }
1676
+ head = prepareChunk(head);
1677
+ }
1678
+ if (write2 || boundary.done) {
1679
+ let html = flushChunk(head, boundary.done);
1680
+ html && onWrite(html), boundary.done ? (tick2 || offTick(onNext), onClose()) : tick2 = !0;
1681
+ } else tick2 && (tick2 = !1, queueTick(onNext));
1682
+ };
1683
+ return onNext(), boundary;
1684
+ }
1685
+ toString() {
1686
+ let head = this.#head;
1687
+ if (!head) throw new Error("Cannot read from a consumed render result");
1688
+ if (head.next) throw new Error("Cannot fork in sync mode");
1689
+ return this.#head = null, flushChunk(prepareChunk(head), !0);
1690
+ }
1691
+ };
1692
+ export {
1693
+ $global,
1694
+ attr,
1695
+ attrTag,
1696
+ attrTags,
1697
+ attrs,
1698
+ classAttr,
1699
+ compat,
1700
+ controllable_detailsOrDialog_open,
1701
+ controllable_input_checked,
1702
+ controllable_input_checkedValue,
1703
+ controllable_input_value,
1704
+ controllable_select_value,
1705
+ controllable_textarea_value,
1706
+ createRenderer,
1707
+ createTemplate,
1708
+ dynamicTagArgs,
1709
+ dynamicTagInput,
1710
+ ensureScopeWithId,
1711
+ escapeScript,
1712
+ escapeStyle,
1713
+ escapeXML,
1714
+ forIn,
1715
+ forInBy,
1716
+ forOf,
1717
+ forOfBy,
1718
+ forTo,
1719
+ forToBy,
1720
+ fork,
1721
+ getScopeById,
1722
+ markResumeCleanup,
1723
+ markResumeControlEnd,
1724
+ markResumeControlSingleNodeEnd,
1725
+ markResumeNode,
1726
+ markResumeScopeStart,
1727
+ nextScopeId,
1728
+ nextTagId,
1729
+ nodeRef,
1730
+ normalizeDynamicRenderer,
1731
+ optionValueAttr,
1732
+ partialAttrs,
1733
+ peekNextScope,
1734
+ register2 as register,
1735
+ styleAttr,
1736
+ toString,
1737
+ tryCatch,
1738
+ tryPlaceholder,
1739
+ write,
1740
+ writeEffect,
1741
+ writeExistingScope,
1742
+ writeScope,
1743
+ writeTrailers
1744
+ };