@depup/svelte 5.53.3-depup.0

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 (386) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +41 -0
  3. package/action.d.ts +1 -0
  4. package/animate.d.ts +1 -0
  5. package/compiler/index.js +1 -0
  6. package/compiler/package.json +3 -0
  7. package/compiler.d.ts +1 -0
  8. package/easing.d.ts +1 -0
  9. package/elements.d.ts +2078 -0
  10. package/index.d.ts +1 -0
  11. package/legacy.d.ts +1 -0
  12. package/motion.d.ts +1 -0
  13. package/package.json +185 -0
  14. package/src/animate/index.js +78 -0
  15. package/src/attachments/index.js +113 -0
  16. package/src/compiler/errors.js +1719 -0
  17. package/src/compiler/index.js +198 -0
  18. package/src/compiler/legacy.js +637 -0
  19. package/src/compiler/migrate/index.js +1996 -0
  20. package/src/compiler/phases/1-parse/acorn.js +198 -0
  21. package/src/compiler/phases/1-parse/index.js +326 -0
  22. package/src/compiler/phases/1-parse/read/context.js +116 -0
  23. package/src/compiler/phases/1-parse/read/expression.js +93 -0
  24. package/src/compiler/phases/1-parse/read/options.js +263 -0
  25. package/src/compiler/phases/1-parse/read/script.js +97 -0
  26. package/src/compiler/phases/1-parse/read/style.js +637 -0
  27. package/src/compiler/phases/1-parse/remove_typescript_nodes.js +180 -0
  28. package/src/compiler/phases/1-parse/state/element.js +937 -0
  29. package/src/compiler/phases/1-parse/state/fragment.js +17 -0
  30. package/src/compiler/phases/1-parse/state/tag.js +751 -0
  31. package/src/compiler/phases/1-parse/state/text.js +23 -0
  32. package/src/compiler/phases/1-parse/utils/bracket.js +213 -0
  33. package/src/compiler/phases/1-parse/utils/create.js +16 -0
  34. package/src/compiler/phases/1-parse/utils/entities.js +2234 -0
  35. package/src/compiler/phases/1-parse/utils/fuzzymatch.js +281 -0
  36. package/src/compiler/phases/1-parse/utils/html.js +127 -0
  37. package/src/compiler/phases/2-analyze/css/css-analyze.js +331 -0
  38. package/src/compiler/phases/2-analyze/css/css-prune.js +1206 -0
  39. package/src/compiler/phases/2-analyze/css/css-warn.js +47 -0
  40. package/src/compiler/phases/2-analyze/css/utils.js +177 -0
  41. package/src/compiler/phases/2-analyze/index.js +1300 -0
  42. package/src/compiler/phases/2-analyze/utils/check_graph_for_cycles.js +47 -0
  43. package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +15 -0
  44. package/src/compiler/phases/2-analyze/visitors/ArrowFunctionExpression.js +11 -0
  45. package/src/compiler/phases/2-analyze/visitors/AssignmentExpression.js +31 -0
  46. package/src/compiler/phases/2-analyze/visitors/AttachTag.js +17 -0
  47. package/src/compiler/phases/2-analyze/visitors/Attribute.js +66 -0
  48. package/src/compiler/phases/2-analyze/visitors/AwaitBlock.js +48 -0
  49. package/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +150 -0
  50. package/src/compiler/phases/2-analyze/visitors/BindDirective.js +280 -0
  51. package/src/compiler/phases/2-analyze/visitors/CallExpression.js +339 -0
  52. package/src/compiler/phases/2-analyze/visitors/ClassBody.js +156 -0
  53. package/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js +25 -0
  54. package/src/compiler/phases/2-analyze/visitors/ClassDirective.js +13 -0
  55. package/src/compiler/phases/2-analyze/visitors/Component.js +26 -0
  56. package/src/compiler/phases/2-analyze/visitors/ConstTag.js +45 -0
  57. package/src/compiler/phases/2-analyze/visitors/DebugTag.js +15 -0
  58. package/src/compiler/phases/2-analyze/visitors/EachBlock.js +97 -0
  59. package/src/compiler/phases/2-analyze/visitors/ExportDefaultDeclaration.js +20 -0
  60. package/src/compiler/phases/2-analyze/visitors/ExportNamedDeclaration.js +70 -0
  61. package/src/compiler/phases/2-analyze/visitors/ExportSpecifier.js +30 -0
  62. package/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js +38 -0
  63. package/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +26 -0
  64. package/src/compiler/phases/2-analyze/visitors/Fragment.js +10 -0
  65. package/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js +16 -0
  66. package/src/compiler/phases/2-analyze/visitors/FunctionExpression.js +11 -0
  67. package/src/compiler/phases/2-analyze/visitors/HtmlTag.js +19 -0
  68. package/src/compiler/phases/2-analyze/visitors/Identifier.js +194 -0
  69. package/src/compiler/phases/2-analyze/visitors/IfBlock.js +46 -0
  70. package/src/compiler/phases/2-analyze/visitors/ImportDeclaration.js +31 -0
  71. package/src/compiler/phases/2-analyze/visitors/KeyBlock.js +21 -0
  72. package/src/compiler/phases/2-analyze/visitors/LabeledStatement.js +95 -0
  73. package/src/compiler/phases/2-analyze/visitors/LetDirective.js +24 -0
  74. package/src/compiler/phases/2-analyze/visitors/Literal.js +14 -0
  75. package/src/compiler/phases/2-analyze/visitors/MemberExpression.js +28 -0
  76. package/src/compiler/phases/2-analyze/visitors/NewExpression.js +17 -0
  77. package/src/compiler/phases/2-analyze/visitors/OnDirective.js +28 -0
  78. package/src/compiler/phases/2-analyze/visitors/PropertyDefinition.js +21 -0
  79. package/src/compiler/phases/2-analyze/visitors/RegularElement.js +240 -0
  80. package/src/compiler/phases/2-analyze/visitors/RenderTag.js +68 -0
  81. package/src/compiler/phases/2-analyze/visitors/SlotElement.js +42 -0
  82. package/src/compiler/phases/2-analyze/visitors/SnippetBlock.js +113 -0
  83. package/src/compiler/phases/2-analyze/visitors/SpreadAttribute.js +13 -0
  84. package/src/compiler/phases/2-analyze/visitors/SpreadElement.js +16 -0
  85. package/src/compiler/phases/2-analyze/visitors/StyleDirective.js +39 -0
  86. package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +22 -0
  87. package/src/compiler/phases/2-analyze/visitors/SvelteBoundary.js +30 -0
  88. package/src/compiler/phases/2-analyze/visitors/SvelteComponent.js +18 -0
  89. package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +24 -0
  90. package/src/compiler/phases/2-analyze/visitors/SvelteElement.js +78 -0
  91. package/src/compiler/phases/2-analyze/visitors/SvelteFragment.js +27 -0
  92. package/src/compiler/phases/2-analyze/visitors/SvelteHead.js +18 -0
  93. package/src/compiler/phases/2-analyze/visitors/SvelteSelf.js +36 -0
  94. package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +24 -0
  95. package/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js +16 -0
  96. package/src/compiler/phases/2-analyze/visitors/TemplateElement.js +12 -0
  97. package/src/compiler/phases/2-analyze/visitors/Text.js +52 -0
  98. package/src/compiler/phases/2-analyze/visitors/TitleElement.js +21 -0
  99. package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +19 -0
  100. package/src/compiler/phases/2-analyze/visitors/UpdateExpression.js +29 -0
  101. package/src/compiler/phases/2-analyze/visitors/UseDirective.js +18 -0
  102. package/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +160 -0
  103. package/src/compiler/phases/2-analyze/visitors/shared/a11y/constants.js +334 -0
  104. package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +981 -0
  105. package/src/compiler/phases/2-analyze/visitors/shared/attribute.js +125 -0
  106. package/src/compiler/phases/2-analyze/visitors/shared/component.js +177 -0
  107. package/src/compiler/phases/2-analyze/visitors/shared/element.js +160 -0
  108. package/src/compiler/phases/2-analyze/visitors/shared/fragment.js +15 -0
  109. package/src/compiler/phases/2-analyze/visitors/shared/function.js +24 -0
  110. package/src/compiler/phases/2-analyze/visitors/shared/snippets.js +17 -0
  111. package/src/compiler/phases/2-analyze/visitors/shared/special-element.js +16 -0
  112. package/src/compiler/phases/2-analyze/visitors/shared/utils.js +301 -0
  113. package/src/compiler/phases/3-transform/client/transform-client.js +719 -0
  114. package/src/compiler/phases/3-transform/client/transform-template/fix-attribute-casing.js +18 -0
  115. package/src/compiler/phases/3-transform/client/transform-template/index.js +67 -0
  116. package/src/compiler/phases/3-transform/client/transform-template/template.js +164 -0
  117. package/src/compiler/phases/3-transform/client/utils.js +181 -0
  118. package/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js +38 -0
  119. package/src/compiler/phases/3-transform/client/visitors/ArrowFunctionExpression.js +11 -0
  120. package/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +247 -0
  121. package/src/compiler/phases/3-transform/client/visitors/AttachTag.js +26 -0
  122. package/src/compiler/phases/3-transform/client/visitors/Attribute.js +14 -0
  123. package/src/compiler/phases/3-transform/client/visitors/AwaitBlock.js +124 -0
  124. package/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js +25 -0
  125. package/src/compiler/phases/3-transform/client/visitors/BinaryExpression.js +34 -0
  126. package/src/compiler/phases/3-transform/client/visitors/BindDirective.js +290 -0
  127. package/src/compiler/phases/3-transform/client/visitors/BlockStatement.js +32 -0
  128. package/src/compiler/phases/3-transform/client/visitors/BreakStatement.js +20 -0
  129. package/src/compiler/phases/3-transform/client/visitors/CallExpression.js +136 -0
  130. package/src/compiler/phases/3-transform/client/visitors/ClassBody.js +111 -0
  131. package/src/compiler/phases/3-transform/client/visitors/Comment.js +11 -0
  132. package/src/compiler/phases/3-transform/client/visitors/Component.js +12 -0
  133. package/src/compiler/phases/3-transform/client/visitors/ConstTag.js +134 -0
  134. package/src/compiler/phases/3-transform/client/visitors/DebugTag.js +28 -0
  135. package/src/compiler/phases/3-transform/client/visitors/EachBlock.js +362 -0
  136. package/src/compiler/phases/3-transform/client/visitors/ExportNamedDeclaration.js +19 -0
  137. package/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js +20 -0
  138. package/src/compiler/phases/3-transform/client/visitors/ForOfStatement.js +25 -0
  139. package/src/compiler/phases/3-transform/client/visitors/Fragment.js +186 -0
  140. package/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js +12 -0
  141. package/src/compiler/phases/3-transform/client/visitors/FunctionExpression.js +11 -0
  142. package/src/compiler/phases/3-transform/client/visitors/HtmlTag.js +53 -0
  143. package/src/compiler/phases/3-transform/client/visitors/Identifier.js +45 -0
  144. package/src/compiler/phases/3-transform/client/visitors/IfBlock.js +131 -0
  145. package/src/compiler/phases/3-transform/client/visitors/KeyBlock.js +45 -0
  146. package/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js +64 -0
  147. package/src/compiler/phases/3-transform/client/visitors/LetDirective.js +55 -0
  148. package/src/compiler/phases/3-transform/client/visitors/MemberExpression.js +23 -0
  149. package/src/compiler/phases/3-transform/client/visitors/OnDirective.js +38 -0
  150. package/src/compiler/phases/3-transform/client/visitors/Program.js +153 -0
  151. package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +725 -0
  152. package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +95 -0
  153. package/src/compiler/phases/3-transform/client/visitors/SlotElement.js +94 -0
  154. package/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +94 -0
  155. package/src/compiler/phases/3-transform/client/visitors/SpreadAttribute.js +10 -0
  156. package/src/compiler/phases/3-transform/client/visitors/SvelteBody.js +11 -0
  157. package/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +126 -0
  158. package/src/compiler/phases/3-transform/client/visitors/SvelteComponent.js +13 -0
  159. package/src/compiler/phases/3-transform/client/visitors/SvelteDocument.js +11 -0
  160. package/src/compiler/phases/3-transform/client/visitors/SvelteElement.js +161 -0
  161. package/src/compiler/phases/3-transform/client/visitors/SvelteFragment.js +17 -0
  162. package/src/compiler/phases/3-transform/client/visitors/SvelteHead.js +23 -0
  163. package/src/compiler/phases/3-transform/client/visitors/SvelteSelf.js +13 -0
  164. package/src/compiler/phases/3-transform/client/visitors/SvelteWindow.js +11 -0
  165. package/src/compiler/phases/3-transform/client/visitors/TitleElement.js +48 -0
  166. package/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js +41 -0
  167. package/src/compiler/phases/3-transform/client/visitors/UpdateExpression.js +55 -0
  168. package/src/compiler/phases/3-transform/client/visitors/UseDirective.js +49 -0
  169. package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +422 -0
  170. package/src/compiler/phases/3-transform/client/visitors/shared/component.js +536 -0
  171. package/src/compiler/phases/3-transform/client/visitors/shared/declarations.js +53 -0
  172. package/src/compiler/phases/3-transform/client/visitors/shared/element.js +263 -0
  173. package/src/compiler/phases/3-transform/client/visitors/shared/events.js +180 -0
  174. package/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +185 -0
  175. package/src/compiler/phases/3-transform/client/visitors/shared/function.js +17 -0
  176. package/src/compiler/phases/3-transform/client/visitors/shared/special_element.js +22 -0
  177. package/src/compiler/phases/3-transform/client/visitors/shared/utils.js +513 -0
  178. package/src/compiler/phases/3-transform/css/index.js +479 -0
  179. package/src/compiler/phases/3-transform/index.js +118 -0
  180. package/src/compiler/phases/3-transform/server/transform-server.js +428 -0
  181. package/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js +124 -0
  182. package/src/compiler/phases/3-transform/server/visitors/AwaitBlock.js +36 -0
  183. package/src/compiler/phases/3-transform/server/visitors/AwaitExpression.js +40 -0
  184. package/src/compiler/phases/3-transform/server/visitors/CallExpression.js +71 -0
  185. package/src/compiler/phases/3-transform/server/visitors/ClassBody.js +81 -0
  186. package/src/compiler/phases/3-transform/server/visitors/Component.js +13 -0
  187. package/src/compiler/phases/3-transform/server/visitors/ConstTag.js +49 -0
  188. package/src/compiler/phases/3-transform/server/visitors/DebugTag.js +24 -0
  189. package/src/compiler/phases/3-transform/server/visitors/EachBlock.js +76 -0
  190. package/src/compiler/phases/3-transform/server/visitors/ExpressionStatement.js +23 -0
  191. package/src/compiler/phases/3-transform/server/visitors/Fragment.js +53 -0
  192. package/src/compiler/phases/3-transform/server/visitors/HtmlTag.js +25 -0
  193. package/src/compiler/phases/3-transform/server/visitors/Identifier.js +24 -0
  194. package/src/compiler/phases/3-transform/server/visitors/IfBlock.js +48 -0
  195. package/src/compiler/phases/3-transform/server/visitors/KeyBlock.js +22 -0
  196. package/src/compiler/phases/3-transform/server/visitors/LabeledStatement.js +24 -0
  197. package/src/compiler/phases/3-transform/server/visitors/MemberExpression.js +19 -0
  198. package/src/compiler/phases/3-transform/server/visitors/Program.js +25 -0
  199. package/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js +37 -0
  200. package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +216 -0
  201. package/src/compiler/phases/3-transform/server/visitors/RenderTag.js +45 -0
  202. package/src/compiler/phases/3-transform/server/visitors/SlotElement.js +68 -0
  203. package/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js +29 -0
  204. package/src/compiler/phases/3-transform/server/visitors/SpreadAttribute.js +10 -0
  205. package/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js +139 -0
  206. package/src/compiler/phases/3-transform/server/visitors/SvelteComponent.js +12 -0
  207. package/src/compiler/phases/3-transform/server/visitors/SvelteElement.js +89 -0
  208. package/src/compiler/phases/3-transform/server/visitors/SvelteFragment.js +11 -0
  209. package/src/compiler/phases/3-transform/server/visitors/SvelteHead.js +25 -0
  210. package/src/compiler/phases/3-transform/server/visitors/SvelteSelf.js +12 -0
  211. package/src/compiler/phases/3-transform/server/visitors/TitleElement.js +21 -0
  212. package/src/compiler/phases/3-transform/server/visitors/UpdateExpression.js +35 -0
  213. package/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +247 -0
  214. package/src/compiler/phases/3-transform/server/visitors/shared/component.js +359 -0
  215. package/src/compiler/phases/3-transform/server/visitors/shared/element.js +557 -0
  216. package/src/compiler/phases/3-transform/server/visitors/shared/utils.js +408 -0
  217. package/src/compiler/phases/3-transform/shared/assignments.js +92 -0
  218. package/src/compiler/phases/3-transform/shared/transform-async.js +114 -0
  219. package/src/compiler/phases/3-transform/utils.js +451 -0
  220. package/src/compiler/phases/bindings.js +227 -0
  221. package/src/compiler/phases/css.js +14 -0
  222. package/src/compiler/phases/nodes.js +258 -0
  223. package/src/compiler/phases/patterns.js +27 -0
  224. package/src/compiler/phases/scope.js +1432 -0
  225. package/src/compiler/preprocess/decode_sourcemap.js +96 -0
  226. package/src/compiler/preprocess/index.js +368 -0
  227. package/src/compiler/preprocess/replace_in_code.js +72 -0
  228. package/src/compiler/print/index.js +911 -0
  229. package/src/compiler/state.js +144 -0
  230. package/src/compiler/utils/assert.js +9 -0
  231. package/src/compiler/utils/ast.js +639 -0
  232. package/src/compiler/utils/builders.js +698 -0
  233. package/src/compiler/utils/compile_diagnostic.js +107 -0
  234. package/src/compiler/utils/extract_svelte_ignore.js +104 -0
  235. package/src/compiler/utils/mapped_code.js +454 -0
  236. package/src/compiler/utils/push_array.js +13 -0
  237. package/src/compiler/utils/sanitize_template_string.js +7 -0
  238. package/src/compiler/utils/slot.js +20 -0
  239. package/src/compiler/utils/string.js +9 -0
  240. package/src/compiler/validate-options.js +324 -0
  241. package/src/compiler/warnings.js +845 -0
  242. package/src/constants.js +66 -0
  243. package/src/easing/index.js +286 -0
  244. package/src/escaping.js +26 -0
  245. package/src/events/index.js +1 -0
  246. package/src/html-tree-validation.js +238 -0
  247. package/src/index-client.js +255 -0
  248. package/src/index-server.js +56 -0
  249. package/src/internal/client/constants.js +77 -0
  250. package/src/internal/client/context.js +258 -0
  251. package/src/internal/client/dev/assign.js +79 -0
  252. package/src/internal/client/dev/console-log.js +37 -0
  253. package/src/internal/client/dev/css.js +31 -0
  254. package/src/internal/client/dev/debug.js +500 -0
  255. package/src/internal/client/dev/elements.js +63 -0
  256. package/src/internal/client/dev/equality.js +101 -0
  257. package/src/internal/client/dev/hmr.js +89 -0
  258. package/src/internal/client/dev/inspect.js +72 -0
  259. package/src/internal/client/dev/legacy.js +25 -0
  260. package/src/internal/client/dev/ownership.js +81 -0
  261. package/src/internal/client/dev/tracing.js +162 -0
  262. package/src/internal/client/dev/validation.js +16 -0
  263. package/src/internal/client/dom/blocks/async.js +71 -0
  264. package/src/internal/client/dom/blocks/await.js +142 -0
  265. package/src/internal/client/dom/blocks/boundary.js +534 -0
  266. package/src/internal/client/dom/blocks/branches.js +227 -0
  267. package/src/internal/client/dom/blocks/css-props.js +28 -0
  268. package/src/internal/client/dom/blocks/each.js +723 -0
  269. package/src/internal/client/dom/blocks/html.js +128 -0
  270. package/src/internal/client/dom/blocks/if.js +82 -0
  271. package/src/internal/client/dom/blocks/key.js +40 -0
  272. package/src/internal/client/dom/blocks/slot.js +44 -0
  273. package/src/internal/client/dom/blocks/snippet.js +103 -0
  274. package/src/internal/client/dom/blocks/svelte-component.js +61 -0
  275. package/src/internal/client/dom/blocks/svelte-element.js +152 -0
  276. package/src/internal/client/dom/blocks/svelte-head.js +61 -0
  277. package/src/internal/client/dom/css.js +33 -0
  278. package/src/internal/client/dom/elements/actions.js +43 -0
  279. package/src/internal/client/dom/elements/attachments.js +33 -0
  280. package/src/internal/client/dom/elements/attributes.js +657 -0
  281. package/src/internal/client/dom/elements/bindings/document.js +17 -0
  282. package/src/internal/client/dom/elements/bindings/input.js +312 -0
  283. package/src/internal/client/dom/elements/bindings/media.js +233 -0
  284. package/src/internal/client/dom/elements/bindings/navigator.js +11 -0
  285. package/src/internal/client/dom/elements/bindings/props.js +22 -0
  286. package/src/internal/client/dom/elements/bindings/select.js +159 -0
  287. package/src/internal/client/dom/elements/bindings/shared.js +76 -0
  288. package/src/internal/client/dom/elements/bindings/size.js +107 -0
  289. package/src/internal/client/dom/elements/bindings/this.js +61 -0
  290. package/src/internal/client/dom/elements/bindings/universal.js +75 -0
  291. package/src/internal/client/dom/elements/bindings/window.js +66 -0
  292. package/src/internal/client/dom/elements/class.js +51 -0
  293. package/src/internal/client/dom/elements/custom-element.js +344 -0
  294. package/src/internal/client/dom/elements/customizable-select.js +99 -0
  295. package/src/internal/client/dom/elements/events.js +355 -0
  296. package/src/internal/client/dom/elements/misc.js +58 -0
  297. package/src/internal/client/dom/elements/style.js +57 -0
  298. package/src/internal/client/dom/elements/transitions.js +471 -0
  299. package/src/internal/client/dom/hydration.js +125 -0
  300. package/src/internal/client/dom/legacy/event-modifiers.js +127 -0
  301. package/src/internal/client/dom/legacy/lifecycle.js +82 -0
  302. package/src/internal/client/dom/legacy/misc.js +68 -0
  303. package/src/internal/client/dom/operations.js +293 -0
  304. package/src/internal/client/dom/reconciler.js +25 -0
  305. package/src/internal/client/dom/task.js +42 -0
  306. package/src/internal/client/dom/template.js +401 -0
  307. package/src/internal/client/error-handling.js +118 -0
  308. package/src/internal/client/errors.js +510 -0
  309. package/src/internal/client/hydratable.js +33 -0
  310. package/src/internal/client/index.js +183 -0
  311. package/src/internal/client/legacy.js +46 -0
  312. package/src/internal/client/loop.js +48 -0
  313. package/src/internal/client/proxy.js +432 -0
  314. package/src/internal/client/reactivity/async.js +306 -0
  315. package/src/internal/client/reactivity/batch.js +1057 -0
  316. package/src/internal/client/reactivity/deriveds.js +426 -0
  317. package/src/internal/client/reactivity/effects.js +718 -0
  318. package/src/internal/client/reactivity/equality.js +31 -0
  319. package/src/internal/client/reactivity/props.js +430 -0
  320. package/src/internal/client/reactivity/sources.js +370 -0
  321. package/src/internal/client/reactivity/status.js +25 -0
  322. package/src/internal/client/reactivity/store.js +203 -0
  323. package/src/internal/client/reactivity/utils.js +40 -0
  324. package/src/internal/client/render.js +335 -0
  325. package/src/internal/client/runtime.js +827 -0
  326. package/src/internal/client/timing.js +16 -0
  327. package/src/internal/client/validate.js +54 -0
  328. package/src/internal/client/warnings.js +271 -0
  329. package/src/internal/disclose-version.js +6 -0
  330. package/src/internal/flags/async.js +3 -0
  331. package/src/internal/flags/index.js +23 -0
  332. package/src/internal/flags/legacy.js +3 -0
  333. package/src/internal/flags/tracing.js +3 -0
  334. package/src/internal/index.js +5 -0
  335. package/src/internal/server/abort-signal.js +13 -0
  336. package/src/internal/server/blocks/html.js +11 -0
  337. package/src/internal/server/blocks/snippet.js +24 -0
  338. package/src/internal/server/context.js +132 -0
  339. package/src/internal/server/crypto.js +45 -0
  340. package/src/internal/server/dev.js +115 -0
  341. package/src/internal/server/errors.js +131 -0
  342. package/src/internal/server/hydratable.js +142 -0
  343. package/src/internal/server/hydration.js +6 -0
  344. package/src/internal/server/index.js +544 -0
  345. package/src/internal/server/render-context.js +86 -0
  346. package/src/internal/server/renderer.js +923 -0
  347. package/src/internal/server/warnings.js +29 -0
  348. package/src/internal/shared/attributes.js +225 -0
  349. package/src/internal/shared/clone.js +137 -0
  350. package/src/internal/shared/dev.js +65 -0
  351. package/src/internal/shared/errors.js +134 -0
  352. package/src/internal/shared/utils.js +144 -0
  353. package/src/internal/shared/validate.js +47 -0
  354. package/src/internal/shared/warnings.js +40 -0
  355. package/src/legacy/legacy-client.js +281 -0
  356. package/src/legacy/legacy-server.js +112 -0
  357. package/src/motion/index.js +32 -0
  358. package/src/motion/spring.js +369 -0
  359. package/src/motion/tweened.js +306 -0
  360. package/src/motion/utils.js +7 -0
  361. package/src/reactivity/create-subscriber.js +95 -0
  362. package/src/reactivity/date.js +118 -0
  363. package/src/reactivity/index-client.js +7 -0
  364. package/src/reactivity/index-server.js +23 -0
  365. package/src/reactivity/map.js +273 -0
  366. package/src/reactivity/media-query.js +55 -0
  367. package/src/reactivity/reactive-value.js +24 -0
  368. package/src/reactivity/set.js +213 -0
  369. package/src/reactivity/url-search-params.js +174 -0
  370. package/src/reactivity/url.js +205 -0
  371. package/src/reactivity/window/index.js +161 -0
  372. package/src/server/index.js +1 -0
  373. package/src/store/index-client.js +169 -0
  374. package/src/store/index-server.js +101 -0
  375. package/src/store/shared/index.js +209 -0
  376. package/src/store/utils.js +36 -0
  377. package/src/transition/index.js +300 -0
  378. package/src/utils.js +504 -0
  379. package/src/version.js +8 -0
  380. package/store.d.ts +1 -0
  381. package/svelte-html.d.ts +245 -0
  382. package/transition.d.ts +1 -0
  383. package/types/compiler/interfaces.d.ts +1 -0
  384. package/types/compiler/preprocess.d.ts +1 -0
  385. package/types/index.d.ts +3744 -0
  386. package/types/index.d.ts.map +280 -0
@@ -0,0 +1,128 @@
1
+ /** @import { Effect, TemplateNode } from '#client' */
2
+ /** @import {} from 'trusted-types' */
3
+ import {
4
+ FILENAME,
5
+ HYDRATION_ERROR,
6
+ NAMESPACE_SVG,
7
+ NAMESPACE_MATHML
8
+ } from '../../../../constants.js';
9
+ import { remove_effect_dom, template_effect } from '../../reactivity/effects.js';
10
+ import { hydrate_next, hydrate_node, hydrating, set_hydrate_node } from '../hydration.js';
11
+
12
+ import { assign_nodes } from '../template.js';
13
+ import * as w from '../../warnings.js';
14
+ import { hash, sanitize_location } from '../../../../utils.js';
15
+ import { DEV } from 'esm-env';
16
+ import { dev_current_component_function } from '../../context.js';
17
+ import { create_element, get_first_child, get_next_sibling } from '../operations.js';
18
+ import { active_effect } from '../../runtime.js';
19
+ import { COMMENT_NODE } from '#client/constants';
20
+
21
+ /**
22
+ * @param {Element} element
23
+ * @param {string | null} server_hash
24
+ * @param {string | TrustedHTML} value
25
+ */
26
+ function check_hash(element, server_hash, value) {
27
+ if (!server_hash || server_hash === hash(String(value ?? ''))) return;
28
+
29
+ let location;
30
+
31
+ // @ts-expect-error
32
+ const loc = element.__svelte_meta?.loc;
33
+ if (loc) {
34
+ location = `near ${loc.file}:${loc.line}:${loc.column}`;
35
+ } else if (dev_current_component_function?.[FILENAME]) {
36
+ location = `in ${dev_current_component_function[FILENAME]}`;
37
+ }
38
+
39
+ w.hydration_html_changed(sanitize_location(location));
40
+ }
41
+
42
+ /**
43
+ * @param {Element | Text | Comment} node
44
+ * @param {() => string | TrustedHTML} get_value
45
+ * @param {boolean} [svg]
46
+ * @param {boolean} [mathml]
47
+ * @param {boolean} [skip_warning]
48
+ * @returns {void}
49
+ */
50
+ export function html(node, get_value, svg = false, mathml = false, skip_warning = false) {
51
+ var anchor = node;
52
+
53
+ /** @type {string | TrustedHTML} */
54
+ var value = '';
55
+
56
+ template_effect(() => {
57
+ var effect = /** @type {Effect} */ (active_effect);
58
+
59
+ if (value === (value = get_value() ?? '')) {
60
+ if (hydrating) hydrate_next();
61
+ return;
62
+ }
63
+
64
+ if (effect.nodes !== null) {
65
+ remove_effect_dom(effect.nodes.start, /** @type {TemplateNode} */ (effect.nodes.end));
66
+ effect.nodes = null;
67
+ }
68
+
69
+ if (value === '') return;
70
+
71
+ if (hydrating) {
72
+ // We're deliberately not trying to repair mismatches between server and client,
73
+ // as it's costly and error-prone (and it's an edge case to have a mismatch anyway)
74
+ var hash = /** @type {Comment} */ (hydrate_node).data;
75
+
76
+ /** @type {TemplateNode | null} */
77
+ var next = hydrate_next();
78
+ var last = next;
79
+
80
+ while (
81
+ next !== null &&
82
+ (next.nodeType !== COMMENT_NODE || /** @type {Comment} */ (next).data !== '')
83
+ ) {
84
+ last = next;
85
+ next = get_next_sibling(next);
86
+ }
87
+
88
+ if (next === null) {
89
+ w.hydration_mismatch();
90
+ throw HYDRATION_ERROR;
91
+ }
92
+
93
+ if (DEV && !skip_warning) {
94
+ check_hash(/** @type {Element} */ (next.parentNode), hash, value);
95
+ }
96
+
97
+ assign_nodes(hydrate_node, last);
98
+ anchor = set_hydrate_node(next);
99
+ return;
100
+ }
101
+
102
+ // Don't use create_fragment_with_script_from_html here because that would mean script tags are executed.
103
+ // @html is basically `.innerHTML = ...` and that doesn't execute scripts either due to security reasons.
104
+ // Use a <template>, <svg>, or <math> wrapper depending on context. If value is a TrustedHTML object,
105
+ // it will be assigned directly to innerHTML without coercion — this allows {@html policy.createHTML(...)} to work.
106
+ var ns = svg ? NAMESPACE_SVG : mathml ? NAMESPACE_MATHML : undefined;
107
+ var wrapper = /** @type {HTMLTemplateElement | SVGElement | MathMLElement} */ (
108
+ create_element(svg ? 'svg' : mathml ? 'math' : 'template', ns)
109
+ );
110
+ wrapper.innerHTML = /** @type {any} */ (value);
111
+
112
+ /** @type {DocumentFragment | Element} */
113
+ var node = svg || mathml ? wrapper : /** @type {HTMLTemplateElement} */ (wrapper).content;
114
+
115
+ assign_nodes(
116
+ /** @type {TemplateNode} */ (get_first_child(node)),
117
+ /** @type {TemplateNode} */ (node.lastChild)
118
+ );
119
+
120
+ if (svg || mathml) {
121
+ while (get_first_child(node)) {
122
+ anchor.before(/** @type {TemplateNode} */ (get_first_child(node)));
123
+ }
124
+ } else {
125
+ anchor.before(node);
126
+ }
127
+ });
128
+ }
@@ -0,0 +1,82 @@
1
+ /** @import { TemplateNode } from '#client' */
2
+ import { EFFECT_TRANSPARENT } from '#client/constants';
3
+ import {
4
+ hydrate_next,
5
+ hydrating,
6
+ read_hydration_instruction,
7
+ skip_nodes,
8
+ set_hydrate_node,
9
+ set_hydrating
10
+ } from '../hydration.js';
11
+ import { block } from '../../reactivity/effects.js';
12
+ import { BranchManager } from './branches.js';
13
+ import { HYDRATION_START, HYDRATION_START_ELSE } from '../../../../constants.js';
14
+
15
+ /**
16
+ * @param {TemplateNode} node
17
+ * @param {(branch: (fn: (anchor: Node) => void, key?: number | false) => void) => void} fn
18
+ * @param {boolean} [elseif] True if this is an `{:else if ...}` block rather than an `{#if ...}`, as that affects which transitions are considered 'local'
19
+ * @returns {void}
20
+ */
21
+ export function if_block(node, fn, elseif = false) {
22
+ if (hydrating) {
23
+ hydrate_next();
24
+ }
25
+
26
+ var branches = new BranchManager(node);
27
+ var flags = elseif ? EFFECT_TRANSPARENT : 0;
28
+
29
+ /**
30
+ * @param {number | false} key
31
+ * @param {null | ((anchor: Node) => void)} fn
32
+ */
33
+ function update_branch(key, fn) {
34
+ if (hydrating) {
35
+ const data = read_hydration_instruction(node);
36
+
37
+ /**
38
+ * @type {number | false}
39
+ * "[" = branch 0, "[1" = branch 1, "[2" = branch 2, ..., "[!" = else (false)
40
+ */
41
+ var hydrated_key;
42
+
43
+ if (data === HYDRATION_START) {
44
+ hydrated_key = 0;
45
+ } else if (data === HYDRATION_START_ELSE) {
46
+ hydrated_key = false;
47
+ } else {
48
+ hydrated_key = parseInt(data.substring(1)); // "[1", "[2", etc.
49
+ }
50
+
51
+ if (key !== hydrated_key) {
52
+ // Hydration mismatch: remove everything inside the anchor and start fresh.
53
+ // This could happen with `{#if browser}...{/if}`, for example
54
+ var anchor = skip_nodes();
55
+
56
+ set_hydrate_node(anchor);
57
+ branches.anchor = anchor;
58
+
59
+ set_hydrating(false);
60
+ branches.ensure(key, fn);
61
+ set_hydrating(true);
62
+
63
+ return;
64
+ }
65
+ }
66
+
67
+ branches.ensure(key, fn);
68
+ }
69
+
70
+ block(() => {
71
+ var has_branch = false;
72
+
73
+ fn((fn, key = 0) => {
74
+ has_branch = true;
75
+ update_branch(key, fn);
76
+ });
77
+
78
+ if (!has_branch) {
79
+ update_branch(false, null);
80
+ }
81
+ }, flags);
82
+ }
@@ -0,0 +1,40 @@
1
+ /** @import { TemplateNode } from '#client' */
2
+ import { is_runes } from '../../context.js';
3
+ import { block } from '../../reactivity/effects.js';
4
+ import { hydrate_next, hydrating } from '../hydration.js';
5
+ import { BranchManager } from './branches.js';
6
+
7
+ const NAN = Symbol('NaN');
8
+
9
+ /**
10
+ * @template V
11
+ * @param {TemplateNode} node
12
+ * @param {() => V} get_key
13
+ * @param {(anchor: Node) => TemplateNode | void} render_fn
14
+ * @returns {void}
15
+ */
16
+ export function key(node, get_key, render_fn) {
17
+ if (hydrating) {
18
+ hydrate_next();
19
+ }
20
+
21
+ var branches = new BranchManager(node);
22
+
23
+ var legacy = !is_runes();
24
+
25
+ block(() => {
26
+ var key = get_key();
27
+
28
+ // NaN !== NaN, hence we do this workaround to not trigger remounts unnecessarily
29
+ if (key !== key) {
30
+ key = /** @type {any} */ (NAN);
31
+ }
32
+
33
+ // key blocks in Svelte <5 had stupid semantics
34
+ if (legacy && key !== null && typeof key === 'object') {
35
+ key = /** @type {V} */ ({});
36
+ }
37
+
38
+ branches.ensure(key, render_fn);
39
+ });
40
+ }
@@ -0,0 +1,44 @@
1
+ import { hydrate_next, hydrating } from '../hydration.js';
2
+
3
+ /**
4
+ * @param {Comment} anchor
5
+ * @param {Record<string, any>} $$props
6
+ * @param {string} name
7
+ * @param {Record<string, unknown>} slot_props
8
+ * @param {null | ((anchor: Comment) => void)} fallback_fn
9
+ */
10
+ export function slot(anchor, $$props, name, slot_props, fallback_fn) {
11
+ if (hydrating) {
12
+ hydrate_next();
13
+ }
14
+
15
+ var slot_fn = $$props.$$slots?.[name];
16
+ // Interop: Can use snippets to fill slots
17
+ var is_interop = false;
18
+ if (slot_fn === true) {
19
+ slot_fn = $$props[name === 'default' ? 'children' : name];
20
+ is_interop = true;
21
+ }
22
+
23
+ if (slot_fn === undefined) {
24
+ if (fallback_fn !== null) {
25
+ fallback_fn(anchor);
26
+ }
27
+ } else {
28
+ slot_fn(anchor, is_interop ? () => slot_props : slot_props);
29
+ }
30
+ }
31
+
32
+ /**
33
+ * @param {Record<string, any>} props
34
+ * @returns {Record<string, boolean>}
35
+ */
36
+ export function sanitize_slots(props) {
37
+ /** @type {Record<string, boolean>} */
38
+ const sanitized = {};
39
+ if (props.children) sanitized.default = true;
40
+ for (const key in props.$$slots) {
41
+ sanitized[key] = true;
42
+ }
43
+ return sanitized;
44
+ }
@@ -0,0 +1,103 @@
1
+ /** @import { Snippet } from 'svelte' */
2
+ /** @import { TemplateNode } from '#client' */
3
+ /** @import { Getters } from '#shared' */
4
+ import { EFFECT_TRANSPARENT, ELEMENT_NODE } from '#client/constants';
5
+ import { block, teardown } from '../../reactivity/effects.js';
6
+ import {
7
+ dev_current_component_function,
8
+ set_dev_current_component_function
9
+ } from '../../context.js';
10
+ import { hydrate_next, hydrate_node, hydrating } from '../hydration.js';
11
+ import { create_fragment_from_html } from '../reconciler.js';
12
+ import { assign_nodes } from '../template.js';
13
+ import * as w from '../../warnings.js';
14
+ import * as e from '../../errors.js';
15
+ import { DEV } from 'esm-env';
16
+ import { get_first_child, get_next_sibling } from '../operations.js';
17
+ import { prevent_snippet_stringification } from '../../../shared/validate.js';
18
+ import { BranchManager } from './branches.js';
19
+
20
+ /**
21
+ * @template {(node: TemplateNode, ...args: any[]) => void} SnippetFn
22
+ * @param {TemplateNode} node
23
+ * @param {() => SnippetFn | null | undefined} get_snippet
24
+ * @param {(() => any)[]} args
25
+ * @returns {void}
26
+ */
27
+ export function snippet(node, get_snippet, ...args) {
28
+ var branches = new BranchManager(node);
29
+
30
+ block(() => {
31
+ const snippet = get_snippet() ?? null;
32
+
33
+ if (DEV && snippet == null) {
34
+ e.invalid_snippet();
35
+ }
36
+
37
+ branches.ensure(snippet, snippet && ((anchor) => snippet(anchor, ...args)));
38
+ }, EFFECT_TRANSPARENT);
39
+ }
40
+
41
+ /**
42
+ * In development, wrap the snippet function so that it passes validation, and so that the
43
+ * correct component context is set for ownership checks
44
+ * @param {any} component
45
+ * @param {(node: TemplateNode, ...args: any[]) => void} fn
46
+ */
47
+ export function wrap_snippet(component, fn) {
48
+ const snippet = (/** @type {TemplateNode} */ node, /** @type {any[]} */ ...args) => {
49
+ var previous_component_function = dev_current_component_function;
50
+ set_dev_current_component_function(component);
51
+
52
+ try {
53
+ return fn(node, ...args);
54
+ } finally {
55
+ set_dev_current_component_function(previous_component_function);
56
+ }
57
+ };
58
+
59
+ prevent_snippet_stringification(snippet);
60
+
61
+ return snippet;
62
+ }
63
+
64
+ /**
65
+ * Create a snippet programmatically
66
+ * @template {unknown[]} Params
67
+ * @param {(...params: Getters<Params>) => {
68
+ * render: () => string
69
+ * setup?: (element: Element) => void | (() => void)
70
+ * }} fn
71
+ * @returns {Snippet<Params>}
72
+ */
73
+ export function createRawSnippet(fn) {
74
+ // @ts-expect-error the types are a lie
75
+ return (/** @type {TemplateNode} */ anchor, /** @type {Getters<Params>} */ ...params) => {
76
+ var snippet = fn(...params);
77
+
78
+ /** @type {Element} */
79
+ var element;
80
+
81
+ if (hydrating) {
82
+ element = /** @type {Element} */ (hydrate_node);
83
+ hydrate_next();
84
+ } else {
85
+ var html = snippet.render().trim();
86
+ var fragment = create_fragment_from_html(html);
87
+ element = /** @type {Element} */ (get_first_child(fragment));
88
+
89
+ if (DEV && (get_next_sibling(element) !== null || element.nodeType !== ELEMENT_NODE)) {
90
+ w.invalid_raw_snippet_render();
91
+ }
92
+
93
+ anchor.before(element);
94
+ }
95
+
96
+ const result = snippet.setup?.(element);
97
+ assign_nodes(element, element);
98
+
99
+ if (typeof result === 'function') {
100
+ teardown(result);
101
+ }
102
+ };
103
+ }
@@ -0,0 +1,61 @@
1
+ /** @import { TemplateNode, Dom } from '#client' */
2
+ import { EFFECT_TRANSPARENT } from '#client/constants';
3
+ import { block } from '../../reactivity/effects.js';
4
+ import {
5
+ hydrate_next,
6
+ hydrate_node,
7
+ hydrating,
8
+ read_hydration_instruction,
9
+ set_hydrate_node,
10
+ set_hydrating,
11
+ skip_nodes
12
+ } from '../hydration.js';
13
+ import { BranchManager } from './branches.js';
14
+ import { HYDRATION_START, HYDRATION_START_ELSE } from '../../../../constants.js';
15
+
16
+ /**
17
+ * @template P
18
+ * @template {(props: P) => void} C
19
+ * @param {TemplateNode} node
20
+ * @param {() => C} get_component
21
+ * @param {(anchor: TemplateNode, component: C) => Dom | void} render_fn
22
+ * @returns {void}
23
+ */
24
+ export function component(node, get_component, render_fn) {
25
+ /** @type {TemplateNode | undefined} */
26
+ var hydration_start_node;
27
+
28
+ if (hydrating) {
29
+ hydration_start_node = hydrate_node;
30
+ hydrate_next();
31
+ }
32
+
33
+ var branches = new BranchManager(node);
34
+
35
+ block(() => {
36
+ var component = get_component() ?? null;
37
+
38
+ if (hydrating) {
39
+ var data = read_hydration_instruction(/** @type {TemplateNode} */ (hydration_start_node));
40
+
41
+ var server_had_component = data === HYDRATION_START;
42
+ var client_has_component = component !== null;
43
+
44
+ if (server_had_component !== client_has_component) {
45
+ // Hydration mismatch: skip the server-rendered nodes and render fresh
46
+ var anchor = skip_nodes();
47
+
48
+ set_hydrate_node(anchor);
49
+ branches.anchor = anchor;
50
+
51
+ set_hydrating(false);
52
+ branches.ensure(component, component && ((target) => render_fn(target, component)));
53
+ set_hydrating(true);
54
+
55
+ return;
56
+ }
57
+ }
58
+
59
+ branches.ensure(component, component && ((target) => render_fn(target, component)));
60
+ }, EFFECT_TRANSPARENT);
61
+ }
@@ -0,0 +1,152 @@
1
+ /** @import { Effect, EffectNodes, TemplateNode } from '#client' */
2
+ import { FILENAME, NAMESPACE_SVG } from '../../../../constants.js';
3
+ import {
4
+ hydrate_next,
5
+ hydrate_node,
6
+ hydrating,
7
+ set_hydrate_node,
8
+ set_hydrating
9
+ } from '../hydration.js';
10
+ import { create_element, create_text, get_first_child } from '../operations.js';
11
+ import { block, teardown } from '../../reactivity/effects.js';
12
+ import { set_should_intro } from '../../render.js';
13
+ import { active_effect } from '../../runtime.js';
14
+ import { component_context, dev_stack } from '../../context.js';
15
+ import { DEV } from 'esm-env';
16
+ import { EFFECT_TRANSPARENT, ELEMENT_NODE } from '#client/constants';
17
+ import { assign_nodes } from '../template.js';
18
+ import { is_raw_text_element } from '../../../../utils.js';
19
+ import { BranchManager } from './branches.js';
20
+ import { set_animation_effect_override } from '../elements/transitions.js';
21
+
22
+ /**
23
+ * @param {Comment | Element} node
24
+ * @param {() => string} get_tag
25
+ * @param {boolean} is_svg
26
+ * @param {undefined | ((element: Element, anchor: Node | null) => void)} render_fn,
27
+ * @param {undefined | (() => string)} get_namespace
28
+ * @param {undefined | [number, number]} location
29
+ * @returns {void}
30
+ */
31
+ export function element(node, get_tag, is_svg, render_fn, get_namespace, location) {
32
+ let was_hydrating = hydrating;
33
+
34
+ if (hydrating) {
35
+ hydrate_next();
36
+ }
37
+
38
+ var filename = DEV && location && component_context?.function[FILENAME];
39
+
40
+ /** @type {null | Element} */
41
+ var element = null;
42
+
43
+ if (hydrating && hydrate_node.nodeType === ELEMENT_NODE) {
44
+ element = /** @type {Element} */ (hydrate_node);
45
+ hydrate_next();
46
+ }
47
+
48
+ var anchor = /** @type {TemplateNode} */ (hydrating ? hydrate_node : node);
49
+
50
+ /**
51
+ * We track this so we can set it when changing the element, allowing any
52
+ * `animate:` directive to bind itself to the correct block
53
+ */
54
+ var parent_effect = /** @type {Effect} */ (active_effect);
55
+
56
+ var branches = new BranchManager(anchor, false);
57
+
58
+ block(() => {
59
+ const next_tag = get_tag() || null;
60
+ var ns = get_namespace
61
+ ? get_namespace()
62
+ : is_svg || next_tag === 'svg'
63
+ ? NAMESPACE_SVG
64
+ : undefined;
65
+
66
+ if (next_tag === null) {
67
+ branches.ensure(null, null);
68
+ set_should_intro(true);
69
+ return;
70
+ }
71
+
72
+ branches.ensure(next_tag, (anchor) => {
73
+ if (next_tag) {
74
+ element = hydrating ? /** @type {Element} */ (element) : create_element(next_tag, ns);
75
+
76
+ if (DEV && location) {
77
+ // @ts-expect-error
78
+ element.__svelte_meta = {
79
+ parent: dev_stack,
80
+ loc: {
81
+ file: filename,
82
+ line: location[0],
83
+ column: location[1]
84
+ }
85
+ };
86
+ }
87
+
88
+ assign_nodes(element, element);
89
+
90
+ if (render_fn) {
91
+ if (hydrating && is_raw_text_element(next_tag)) {
92
+ // prevent hydration glitches
93
+ element.append(document.createComment(''));
94
+ }
95
+
96
+ // If hydrating, use the existing ssr comment as the anchor so that the
97
+ // inner open and close methods can pick up the existing nodes correctly
98
+ var child_anchor = hydrating
99
+ ? get_first_child(element)
100
+ : element.appendChild(create_text());
101
+
102
+ if (hydrating) {
103
+ if (child_anchor === null) {
104
+ set_hydrating(false);
105
+ } else {
106
+ set_hydrate_node(child_anchor);
107
+ }
108
+ }
109
+
110
+ set_animation_effect_override(parent_effect);
111
+
112
+ // `child_anchor` is undefined if this is a void element, but we still
113
+ // need to call `render_fn` in order to run actions etc. If the element
114
+ // contains children, it's a user error (which is warned on elsewhere)
115
+ // and the DOM will be silently discarded
116
+ render_fn(element, child_anchor);
117
+
118
+ set_animation_effect_override(null);
119
+ }
120
+
121
+ // we do this after calling `render_fn` so that child effects don't override `nodes.end`
122
+ /** @type {Effect & { nodes: EffectNodes }} */ (active_effect).nodes.end = element;
123
+
124
+ anchor.before(element);
125
+ }
126
+
127
+ if (hydrating) {
128
+ set_hydrate_node(anchor);
129
+ }
130
+ });
131
+
132
+ // revert to the default state after the effect has been created
133
+ set_should_intro(true);
134
+
135
+ return () => {
136
+ if (next_tag) {
137
+ // if we're in this callback because we're re-running the effect,
138
+ // disable intros (unless no element is currently displayed)
139
+ set_should_intro(false);
140
+ }
141
+ };
142
+ }, EFFECT_TRANSPARENT);
143
+
144
+ teardown(() => {
145
+ set_should_intro(true);
146
+ });
147
+
148
+ if (was_hydrating) {
149
+ set_hydrating(true);
150
+ set_hydrate_node(anchor);
151
+ }
152
+ }
@@ -0,0 +1,61 @@
1
+ /** @import { TemplateNode } from '#client' */
2
+ import { hydrate_node, hydrating, set_hydrate_node, set_hydrating } from '../hydration.js';
3
+ import { create_text, get_first_child, get_next_sibling } from '../operations.js';
4
+ import { block } from '../../reactivity/effects.js';
5
+ import { COMMENT_NODE, EFFECT_PRESERVED, HEAD_EFFECT } from '#client/constants';
6
+
7
+ /**
8
+ * @param {string} hash
9
+ * @param {(anchor: Node) => void} render_fn
10
+ * @returns {void}
11
+ */
12
+ export function head(hash, render_fn) {
13
+ // The head function may be called after the first hydration pass and ssr comment nodes may still be present,
14
+ // therefore we need to skip that when we detect that we're not in hydration mode.
15
+ let previous_hydrate_node = null;
16
+ let was_hydrating = hydrating;
17
+
18
+ /** @type {Comment | Text} */
19
+ var anchor;
20
+
21
+ if (hydrating) {
22
+ previous_hydrate_node = hydrate_node;
23
+
24
+ var head_anchor = get_first_child(document.head);
25
+
26
+ // There might be multiple head blocks in our app, and they could have been
27
+ // rendered in an arbitrary order — find one corresponding to this component
28
+ while (
29
+ head_anchor !== null &&
30
+ (head_anchor.nodeType !== COMMENT_NODE || /** @type {Comment} */ (head_anchor).data !== hash)
31
+ ) {
32
+ head_anchor = get_next_sibling(head_anchor);
33
+ }
34
+
35
+ // If we can't find an opening hydration marker, skip hydration (this can happen
36
+ // if a framework rendered body but not head content)
37
+ if (head_anchor === null) {
38
+ set_hydrating(false);
39
+ } else {
40
+ var start = /** @type {TemplateNode} */ (get_next_sibling(head_anchor));
41
+ head_anchor.remove(); // in case this component is repeated
42
+
43
+ set_hydrate_node(start);
44
+ }
45
+ }
46
+
47
+ if (!hydrating) {
48
+ anchor = document.head.appendChild(create_text());
49
+ }
50
+
51
+ try {
52
+ // normally a branch is the child of a block and would have the EFFECT_PRESERVED flag,
53
+ // but since head blocks don't necessarily only have direct branch children we add it on the block itself
54
+ block(() => render_fn(anchor), HEAD_EFFECT | EFFECT_PRESERVED);
55
+ } finally {
56
+ if (was_hydrating) {
57
+ set_hydrating(true);
58
+ set_hydrate_node(/** @type {TemplateNode} */ (previous_hydrate_node));
59
+ }
60
+ }
61
+ }