@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,35 @@
1
+ /** @import { UpdateExpression } from 'estree' */
2
+ /** @import { Context } from '../types.js' */
3
+ import * as b from '#compiler/builders';
4
+
5
+ /**
6
+ * @param {UpdateExpression} node
7
+ * @param {Context} context
8
+ */
9
+ export function UpdateExpression(node, context) {
10
+ const argument = node.argument;
11
+
12
+ if (argument.type === 'Identifier') {
13
+ const binding = context.state.scope.get(argument.name);
14
+
15
+ if (binding?.kind === 'store_sub') {
16
+ return b.call(
17
+ node.prefix ? '$.update_store_pre' : '$.update_store',
18
+ b.assignment('??=', b.id('$$store_subs'), b.object([])),
19
+ b.literal(argument.name),
20
+ b.id(argument.name.slice(1)),
21
+ node.operator === '--' && b.literal(-1)
22
+ );
23
+ }
24
+
25
+ if (binding?.kind === 'derived') {
26
+ return b.call(
27
+ node.prefix ? '$.update_derived_pre' : '$.update_derived',
28
+ binding.node,
29
+ node.operator === '--' && b.literal(-1)
30
+ );
31
+ }
32
+ }
33
+
34
+ return context.next();
35
+ }
@@ -0,0 +1,247 @@
1
+ /** @import { VariableDeclaration, VariableDeclarator, Expression, CallExpression, Pattern, Identifier } from 'estree' */
2
+ /** @import { Binding } from '#compiler' */
3
+ /** @import { Context } from '../types.js' */
4
+ /** @import { ComponentAnalysis } from '../../../types.js' */
5
+ /** @import { Scope } from '../../../scope.js' */
6
+ import { build_fallback, extract_paths } from '../../../../utils/ast.js';
7
+ import * as b from '#compiler/builders';
8
+ import { get_rune } from '../../../scope.js';
9
+ import { walk } from 'zimmerframe';
10
+
11
+ /**
12
+ * @param {VariableDeclaration} node
13
+ * @param {Context} context
14
+ */
15
+ export function VariableDeclaration(node, context) {
16
+ /** @type {VariableDeclarator[]} */
17
+ const declarations = [];
18
+
19
+ if (context.state.analysis.runes) {
20
+ for (const declarator of node.declarations) {
21
+ const init = declarator.init;
22
+ const rune = get_rune(init, context.state.scope);
23
+ if (!rune || rune === '$effect.tracking' || rune === '$inspect' || rune === '$effect.root') {
24
+ declarations.push(/** @type {VariableDeclarator} */ (context.visit(declarator)));
25
+ continue;
26
+ }
27
+
28
+ if (rune === '$props.id') {
29
+ // skip
30
+ continue;
31
+ }
32
+
33
+ if (rune === '$props') {
34
+ let has_rest = false;
35
+ // remove $bindable() from props declaration
36
+ let id = walk(declarator.id, null, {
37
+ RestElement(node, context) {
38
+ if (context.path.at(-1) === declarator.id) {
39
+ has_rest = true;
40
+ }
41
+ },
42
+ AssignmentPattern(node) {
43
+ if (
44
+ node.right.type === 'CallExpression' &&
45
+ get_rune(node.right, context.state.scope) === '$bindable'
46
+ ) {
47
+ const right = node.right.arguments.length
48
+ ? /** @type {Expression} */ (context.visit(node.right.arguments[0]))
49
+ : b.void0;
50
+ return b.assignment_pattern(node.left, right);
51
+ }
52
+ }
53
+ });
54
+
55
+ // if `$$slots` is declared separately, deconflict
56
+ const slots_name = /** @type {ComponentAnalysis} */ (context.state.analysis).uses_slots
57
+ ? b.id('$$slots_')
58
+ : b.id('$$slots');
59
+
60
+ if (id.type === 'ObjectPattern' && has_rest) {
61
+ // If a rest pattern is used within an object pattern, we need to ensure we don't expose $$slots or $$events
62
+ id.properties.splice(
63
+ id.properties.length - 1,
64
+ 0,
65
+ // @ts-ignore
66
+ b.prop('init', b.id('$$slots'), slots_name),
67
+ b.prop('init', b.id('$$events'), b.id('$$events'))
68
+ );
69
+ } else if (id.type === 'Identifier') {
70
+ // If $props is referenced as an identifier, we need to ensure we don't expose $$slots or $$events as properties
71
+ // on the identifier reference
72
+ id = b.object_pattern([
73
+ b.prop('init', b.id('$$slots'), slots_name),
74
+ b.prop('init', b.id('$$events'), b.id('$$events')),
75
+ b.rest(b.id(id.name))
76
+ ]);
77
+ }
78
+ declarations.push(
79
+ b.declarator(/** @type {Pattern} */ (context.visit(id)), b.id('$$props'))
80
+ );
81
+ continue;
82
+ }
83
+
84
+ const args = /** @type {CallExpression} */ (init).arguments;
85
+ const value = args.length > 0 ? /** @type {Expression} */ (context.visit(args[0])) : b.void0;
86
+
87
+ if (rune === '$derived' || rune === '$derived.by') {
88
+ const is_async =
89
+ rune === '$derived' &&
90
+ context.state.analysis.async_deriveds.has(
91
+ /** @type {CallExpression} */ (declarator.init)
92
+ );
93
+
94
+ let init = is_async
95
+ ? b.await(b.call('$.async_derived', b.thunk(value, true)))
96
+ : b.call('$.derived', rune === '$derived' ? b.thunk(value) : value);
97
+
98
+ if (declarator.id.type === 'Identifier') {
99
+ declarations.push(
100
+ b.declarator(/** @type {Pattern} */ (context.visit(declarator.id)), init)
101
+ );
102
+ } else {
103
+ const call = /** @type {CallExpression} */ (declarator.init);
104
+
105
+ let rhs = value;
106
+
107
+ if (rune !== '$derived' || call.arguments[0].type !== 'Identifier') {
108
+ const id = b.id(context.state.scope.generate('$$d'));
109
+
110
+ rhs = b.call(id);
111
+ declarations.push(b.declarator(id, init));
112
+ }
113
+
114
+ const { inserts, paths } = extract_paths(declarator.id, rhs);
115
+
116
+ for (const { id, value } of inserts) {
117
+ id.name = context.state.scope.generate('$$derived_array');
118
+
119
+ const expression = /** @type {Expression} */ (context.visit(b.thunk(value)));
120
+ const call = b.call('$.derived', expression);
121
+
122
+ declarations.push(b.declarator(id, call));
123
+ }
124
+
125
+ for (const path of paths) {
126
+ const expression = /** @type {Expression} */ (context.visit(path.expression));
127
+ const call = b.call('$.derived', b.thunk(expression));
128
+
129
+ declarations.push(b.declarator(path.node, call));
130
+ }
131
+ }
132
+
133
+ continue;
134
+ }
135
+
136
+ if (declarator.id.type === 'Identifier') {
137
+ declarations.push(b.declarator(declarator.id, value));
138
+ continue;
139
+ }
140
+
141
+ declarations.push(...create_state_declarators(declarator, context.state.scope, value));
142
+ }
143
+ } else {
144
+ for (const declarator of node.declarations) {
145
+ const bindings = /** @type {Binding[]} */ (context.state.scope.get_bindings(declarator));
146
+ const has_state = bindings.some((binding) => binding.kind === 'state');
147
+ const has_props = bindings.some((binding) => binding.kind === 'bindable_prop');
148
+
149
+ if (!has_state && !has_props) {
150
+ declarations.push(/** @type {VariableDeclarator} */ (context.visit(declarator)));
151
+ continue;
152
+ }
153
+
154
+ if (has_props) {
155
+ if (declarator.id.type !== 'Identifier') {
156
+ // Turn export let into props. It's really really weird because export let { x: foo, z: [bar]} = ..
157
+ // means that foo and bar are the props (i.e. the leaves are the prop names), not x and z.
158
+ const tmp = b.id(context.state.scope.generate('tmp'));
159
+ const { inserts, paths } = extract_paths(declarator.id, tmp);
160
+
161
+ declarations.push(
162
+ b.declarator(
163
+ tmp,
164
+ /** @type {Expression} */ (context.visit(/** @type {Expression} */ (declarator.init)))
165
+ )
166
+ );
167
+
168
+ for (const { id, value } of inserts) {
169
+ id.name = context.state.scope.generate('$$array');
170
+ declarations.push(b.declarator(id, value));
171
+ }
172
+
173
+ for (const path of paths) {
174
+ const value = path.expression;
175
+ const name = /** @type {Identifier} */ (path.node).name;
176
+ const binding = /** @type {Binding} */ (context.state.scope.get(name));
177
+ const prop = b.member(b.id('$$props'), b.literal(binding.prop_alias ?? name), true);
178
+ declarations.push(b.declarator(path.node, build_fallback(prop, value)));
179
+ }
180
+
181
+ continue;
182
+ }
183
+
184
+ const binding = /** @type {Binding} */ (context.state.scope.get(declarator.id.name));
185
+ const prop = b.member(
186
+ b.id('$$props'),
187
+ b.literal(binding.prop_alias ?? declarator.id.name),
188
+ true
189
+ );
190
+
191
+ /** @type {Expression} */
192
+ let init = prop;
193
+ if (declarator.init) {
194
+ const default_value = /** @type {Expression} */ (context.visit(declarator.init));
195
+ init = build_fallback(prop, default_value);
196
+ }
197
+
198
+ declarations.push(b.declarator(declarator.id, init));
199
+
200
+ continue;
201
+ }
202
+
203
+ declarations.push(
204
+ ...create_state_declarators(
205
+ declarator,
206
+ context.state.scope,
207
+ /** @type {Expression} */ (declarator.init && context.visit(declarator.init))
208
+ )
209
+ );
210
+ }
211
+ }
212
+
213
+ if (declarations.length === 0) {
214
+ return b.empty;
215
+ }
216
+
217
+ return {
218
+ ...node,
219
+ declarations
220
+ };
221
+ }
222
+
223
+ /**
224
+ * @param {VariableDeclarator} declarator
225
+ * @param {Scope} scope
226
+ * @param {Expression} value
227
+ * @returns {VariableDeclarator[]}
228
+ */
229
+ function create_state_declarators(declarator, scope, value) {
230
+ if (declarator.id.type === 'Identifier') {
231
+ return [b.declarator(declarator.id, value)];
232
+ }
233
+
234
+ const tmp = b.id(scope.generate('tmp'));
235
+ const { paths, inserts } = extract_paths(declarator.id, tmp);
236
+ return [
237
+ b.declarator(tmp, value), // TODO inject declarator for opts, so we can use it below
238
+ ...inserts.map(({ id, value }) => {
239
+ id.name = scope.generate('$$array');
240
+ return b.declarator(id, value);
241
+ }),
242
+ ...paths.map((path) => {
243
+ const value = path.expression;
244
+ return b.declarator(path.node, value);
245
+ })
246
+ ];
247
+ }
@@ -0,0 +1,359 @@
1
+ /** @import { BlockStatement, Expression, Pattern, Property, SequenceExpression, Statement } from 'estree' */
2
+ /** @import { AST } from '#compiler' */
3
+ /** @import { ComponentContext } from '../../types.js' */
4
+ import {
5
+ empty_comment,
6
+ build_attribute_value,
7
+ PromiseOptimiser,
8
+ block_open_else,
9
+ block_open,
10
+ block_close
11
+ } from './utils.js';
12
+ import * as b from '#compiler/builders';
13
+ import { is_element_node } from '../../../../nodes.js';
14
+ import { dev } from '../../../../../state.js';
15
+
16
+ /**
17
+ * @param {AST.Component | AST.SvelteComponent | AST.SvelteSelf} node
18
+ * @param {Expression} expression
19
+ * @param {ComponentContext} context
20
+ */
21
+ export function build_inline_component(node, expression, context) {
22
+ /** @type {Array<Property[] | Expression>} */
23
+ const props_and_spreads = [];
24
+ /** @type {Array<() => void>} */
25
+ const delayed_props = [];
26
+
27
+ /** @type {Property[]} */
28
+ const custom_css_props = [];
29
+
30
+ /** @type {Record<string, AST.LetDirective[]>} */
31
+ const lets = { default: [] };
32
+
33
+ /**
34
+ * Children in the default slot are evaluated in the component scope,
35
+ * children in named slots are evaluated in the parent scope
36
+ */
37
+ const child_state = {
38
+ ...context.state,
39
+ scope: node.metadata.scopes.default
40
+ };
41
+
42
+ /** @type {Record<string, AST.TemplateNode[]>} */
43
+ const children = {};
44
+
45
+ /**
46
+ * If this component has a slot property, it is a named slot within another component. In this case
47
+ * the slot scope applies to the component itself, too, and not just its children.
48
+ */
49
+ const slot_scope_applies_to_itself = node.attributes.some(
50
+ (node) => node.type === 'Attribute' && node.name === 'slot'
51
+ );
52
+
53
+ /**
54
+ * Components may have a children prop and also have child nodes. In this case, we assume
55
+ * that the child component isn't using render tags yet and pass the slot as $$slots.default.
56
+ * We're not doing it for spread attributes, as this would result in too many false positives.
57
+ */
58
+ let has_children_prop = false;
59
+
60
+ /**
61
+ * @param {Property} prop
62
+ * @param {boolean} [delay]
63
+ */
64
+ function push_prop(prop, delay = false) {
65
+ const do_push = () => {
66
+ const current = props_and_spreads.at(-1);
67
+ const current_is_props = Array.isArray(current);
68
+ const props = current_is_props ? current : [];
69
+ props.push(prop);
70
+ if (!current_is_props) {
71
+ props_and_spreads.push(props);
72
+ }
73
+ };
74
+
75
+ if (delay) {
76
+ delayed_props.push(do_push);
77
+ } else {
78
+ do_push();
79
+ }
80
+ }
81
+
82
+ const optimiser = new PromiseOptimiser();
83
+
84
+ for (const attribute of node.attributes) {
85
+ if (attribute.type === 'LetDirective') {
86
+ if (!slot_scope_applies_to_itself) {
87
+ lets.default.push(attribute);
88
+ }
89
+ } else if (attribute.type === 'SpreadAttribute') {
90
+ let expression = /** @type {Expression} */ (context.visit(attribute));
91
+ props_and_spreads.push(optimiser.transform(expression, attribute.metadata.expression));
92
+ } else if (attribute.type === 'Attribute') {
93
+ const value = build_attribute_value(
94
+ attribute.value,
95
+ context,
96
+ optimiser.transform,
97
+ false,
98
+ true
99
+ );
100
+
101
+ if (attribute.name.startsWith('--')) {
102
+ custom_css_props.push(b.init(attribute.name, value));
103
+ continue;
104
+ }
105
+
106
+ if (attribute.name === 'children') {
107
+ has_children_prop = true;
108
+ }
109
+
110
+ push_prop(b.prop('init', b.key(attribute.name), value));
111
+ } else if (attribute.type === 'BindDirective') {
112
+ // Bindings are a bit special: we don't want to add them to (async) deriveds but we need to check if they have blockers
113
+ optimiser.check_blockers(attribute.metadata.expression);
114
+
115
+ if (attribute.name === 'this') {
116
+ // bind:this is client-only, but we still need to check for blockers to ensure
117
+ // the server generates matching hydration markers if the client wraps in $.async
118
+ continue;
119
+ }
120
+
121
+ if (attribute.expression.type === 'SequenceExpression') {
122
+ const [get, set] = /** @type {SequenceExpression} */ (context.visit(attribute.expression))
123
+ .expressions;
124
+ const get_id = b.id(context.state.scope.generate('bind_get'));
125
+ const set_id = b.id(context.state.scope.generate('bind_set'));
126
+
127
+ context.state.init.push(b.var(get_id, get));
128
+ context.state.init.push(b.var(set_id, set));
129
+
130
+ push_prop(b.get(attribute.name, [b.return(b.call(get_id))]));
131
+ push_prop(b.set(attribute.name, [b.stmt(b.call(set_id, b.id('$$value')))]));
132
+ } else {
133
+ // Delay prop pushes so bindings come at the end, to avoid spreads overwriting them
134
+ push_prop(
135
+ b.get(attribute.name, [
136
+ b.return(/** @type {Expression} */ (context.visit(attribute.expression)))
137
+ ]),
138
+ true
139
+ );
140
+
141
+ push_prop(
142
+ b.set(attribute.name, [
143
+ b.stmt(
144
+ /** @type {Expression} */ (
145
+ context.visit(b.assignment('=', attribute.expression, b.id('$$value')))
146
+ )
147
+ ),
148
+ b.stmt(b.assignment('=', b.id('$$settled'), b.false))
149
+ ]),
150
+ true
151
+ );
152
+ }
153
+ } else if (attribute.type === 'AttachTag') {
154
+ // While we don't run attachments on the server, on the client they might generate a surrounding blocker function which generates
155
+ // extra comments, and to prevent hydration mismatches we therefore have to account for them here to generate similar comments on the server.
156
+ optimiser.check_blockers(attribute.metadata.expression);
157
+ }
158
+ }
159
+
160
+ delayed_props.forEach((fn) => fn());
161
+
162
+ /** @type {Statement[]} */
163
+ const snippet_declarations = [];
164
+
165
+ /** @type {Property[]} */
166
+ const serialized_slots = [];
167
+
168
+ // Group children by slot
169
+ for (const child of node.fragment.nodes) {
170
+ if (child.type === 'SnippetBlock') {
171
+ // the SnippetBlock visitor adds a declaration to `init`, but if it's directly
172
+ // inside a component then we want to hoist them into a block so that they
173
+ // can be used as props without creating conflicts
174
+ context.visit(child, {
175
+ ...context.state,
176
+ init: snippet_declarations
177
+ });
178
+
179
+ push_prop(b.prop('init', child.expression, child.expression));
180
+
181
+ // Interop: allows people to pass snippets when component still uses slots
182
+ serialized_slots.push(
183
+ b.init(child.expression.name === 'children' ? 'default' : child.expression.name, b.true)
184
+ );
185
+
186
+ continue;
187
+ }
188
+
189
+ let slot_name = 'default';
190
+ if (is_element_node(child)) {
191
+ const slot = /** @type {AST.Attribute | undefined} */ (
192
+ child.attributes.find(
193
+ (attribute) => attribute.type === 'Attribute' && attribute.name === 'slot'
194
+ )
195
+ );
196
+
197
+ if (slot !== undefined) {
198
+ slot_name = /** @type {AST.Text[]} */ (slot.value)[0].data;
199
+
200
+ lets[slot_name] = child.attributes.filter((attribute) => attribute.type === 'LetDirective');
201
+ } else if (child.type === 'SvelteFragment') {
202
+ lets.default.push(
203
+ ...child.attributes.filter((attribute) => attribute.type === 'LetDirective')
204
+ );
205
+ }
206
+ }
207
+
208
+ children[slot_name] = children[slot_name] || [];
209
+ children[slot_name].push(child);
210
+ }
211
+
212
+ // Serialize each slot
213
+ for (const slot_name of Object.keys(children)) {
214
+ const block = /** @type {BlockStatement} */ (
215
+ context.visit(
216
+ {
217
+ ...node.fragment,
218
+ // @ts-expect-error
219
+ nodes: children[slot_name]
220
+ },
221
+ slot_name === 'default'
222
+ ? child_state
223
+ : {
224
+ ...context.state,
225
+ scope: node.metadata.scopes[slot_name]
226
+ }
227
+ )
228
+ );
229
+
230
+ if (block.body.length === 0) continue;
231
+
232
+ /** @type {Pattern[]} */
233
+ const params = [b.id('$$renderer')];
234
+
235
+ if (lets[slot_name].length > 0) {
236
+ const pattern = b.object_pattern(
237
+ lets[slot_name].map((node) => {
238
+ if (node.expression === null) {
239
+ return b.init(node.name, b.id(node.name));
240
+ }
241
+
242
+ if (node.expression.type === 'ObjectExpression') {
243
+ // @ts-expect-error it gets parsed as an `ObjectExpression` but is really an `ObjectPattern`
244
+ return b.init(node.name, b.object_pattern(node.expression.properties));
245
+ }
246
+
247
+ if (node.expression.type === 'ArrayExpression') {
248
+ // @ts-expect-error it gets parsed as an `ArrayExpression` but is really an `ArrayPattern`
249
+ return b.init(node.name, b.array_pattern(node.expression.elements));
250
+ }
251
+
252
+ return b.init(node.name, node.expression);
253
+ })
254
+ );
255
+
256
+ params.push(pattern);
257
+ }
258
+
259
+ const slot_fn = b.arrow(params, b.block(block.body));
260
+
261
+ if (slot_name === 'default' && !has_children_prop) {
262
+ if (
263
+ lets.default.length === 0 &&
264
+ children.default.every(
265
+ (node) =>
266
+ node.type !== 'SvelteFragment' ||
267
+ !node.attributes.some((attr) => attr.type === 'LetDirective')
268
+ )
269
+ ) {
270
+ // create `children` prop...
271
+ push_prop(
272
+ b.prop(
273
+ 'init',
274
+ b.id('children'),
275
+ dev ? b.call('$.prevent_snippet_stringification', slot_fn) : slot_fn
276
+ )
277
+ );
278
+
279
+ // and `$$slots.default: true` so that `<slot>` on the child works
280
+ serialized_slots.push(b.init(slot_name, b.true));
281
+ } else {
282
+ // create `$$slots.default`...
283
+ serialized_slots.push(b.init(slot_name, slot_fn));
284
+
285
+ // and a `children` prop that errors
286
+ push_prop(b.init('children', b.id('$.invalid_default_snippet')));
287
+ }
288
+ } else {
289
+ serialized_slots.push(b.init(slot_name, slot_fn));
290
+ }
291
+ }
292
+
293
+ if (serialized_slots.length > 0) {
294
+ push_prop(b.prop('init', b.id('$$slots'), b.object(serialized_slots)));
295
+ }
296
+
297
+ const props_expression =
298
+ props_and_spreads.length === 0 ||
299
+ (props_and_spreads.length === 1 && Array.isArray(props_and_spreads[0]))
300
+ ? b.object(/** @type {Property[]} */ (props_and_spreads[0] || []))
301
+ : b.call(
302
+ '$.spread_props',
303
+ b.array(props_and_spreads.map((p) => (Array.isArray(p) ? b.object(p) : p)))
304
+ );
305
+
306
+ const dynamic =
307
+ node.type === 'SvelteComponent' || (node.type === 'Component' && node.metadata.dynamic);
308
+
309
+ /** @type {Statement} */
310
+ let statement = b.stmt(b.call(expression, b.id('$$renderer'), props_expression));
311
+
312
+ if (dynamic) {
313
+ statement = b.if(
314
+ expression,
315
+ b.block([
316
+ b.stmt(b.call('$$renderer.push', block_open)),
317
+ statement,
318
+ b.stmt(b.call('$$renderer.push', block_close))
319
+ ]),
320
+ b.block([
321
+ b.stmt(b.call('$$renderer.push', block_open_else)),
322
+ b.stmt(b.call('$$renderer.push', block_close))
323
+ ])
324
+ );
325
+ }
326
+
327
+ if (snippet_declarations.length > 0) {
328
+ statement = b.block([...snippet_declarations, statement]);
329
+ }
330
+
331
+ if (custom_css_props.length > 0) {
332
+ statement = b.stmt(
333
+ b.call(
334
+ '$.css_props',
335
+ b.id('$$renderer'),
336
+ b.literal(context.state.namespace === 'svg' ? false : true),
337
+ b.object(custom_css_props),
338
+ b.thunk(b.block([statement])),
339
+ dynamic && b.true
340
+ )
341
+ );
342
+ }
343
+
344
+ if (node.type !== 'SvelteSelf') {
345
+ // Component name itself could be blocked on async values
346
+ optimiser.check_blockers(node.metadata.expression);
347
+ }
348
+
349
+ context.state.template.push(...optimiser.render_block([statement]));
350
+
351
+ if (
352
+ !dynamic &&
353
+ !optimiser.is_async() &&
354
+ !context.state.is_standalone &&
355
+ custom_css_props.length === 0
356
+ ) {
357
+ context.state.template.push(empty_comment);
358
+ }
359
+ }