@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.
- package/LICENSE.md +7 -0
- package/README.md +41 -0
- package/action.d.ts +1 -0
- package/animate.d.ts +1 -0
- package/compiler/index.js +1 -0
- package/compiler/package.json +3 -0
- package/compiler.d.ts +1 -0
- package/easing.d.ts +1 -0
- package/elements.d.ts +2078 -0
- package/index.d.ts +1 -0
- package/legacy.d.ts +1 -0
- package/motion.d.ts +1 -0
- package/package.json +185 -0
- package/src/animate/index.js +78 -0
- package/src/attachments/index.js +113 -0
- package/src/compiler/errors.js +1719 -0
- package/src/compiler/index.js +198 -0
- package/src/compiler/legacy.js +637 -0
- package/src/compiler/migrate/index.js +1996 -0
- package/src/compiler/phases/1-parse/acorn.js +198 -0
- package/src/compiler/phases/1-parse/index.js +326 -0
- package/src/compiler/phases/1-parse/read/context.js +116 -0
- package/src/compiler/phases/1-parse/read/expression.js +93 -0
- package/src/compiler/phases/1-parse/read/options.js +263 -0
- package/src/compiler/phases/1-parse/read/script.js +97 -0
- package/src/compiler/phases/1-parse/read/style.js +637 -0
- package/src/compiler/phases/1-parse/remove_typescript_nodes.js +180 -0
- package/src/compiler/phases/1-parse/state/element.js +937 -0
- package/src/compiler/phases/1-parse/state/fragment.js +17 -0
- package/src/compiler/phases/1-parse/state/tag.js +751 -0
- package/src/compiler/phases/1-parse/state/text.js +23 -0
- package/src/compiler/phases/1-parse/utils/bracket.js +213 -0
- package/src/compiler/phases/1-parse/utils/create.js +16 -0
- package/src/compiler/phases/1-parse/utils/entities.js +2234 -0
- package/src/compiler/phases/1-parse/utils/fuzzymatch.js +281 -0
- package/src/compiler/phases/1-parse/utils/html.js +127 -0
- package/src/compiler/phases/2-analyze/css/css-analyze.js +331 -0
- package/src/compiler/phases/2-analyze/css/css-prune.js +1206 -0
- package/src/compiler/phases/2-analyze/css/css-warn.js +47 -0
- package/src/compiler/phases/2-analyze/css/utils.js +177 -0
- package/src/compiler/phases/2-analyze/index.js +1300 -0
- package/src/compiler/phases/2-analyze/utils/check_graph_for_cycles.js +47 -0
- package/src/compiler/phases/2-analyze/visitors/AnimateDirective.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/ArrowFunctionExpression.js +11 -0
- package/src/compiler/phases/2-analyze/visitors/AssignmentExpression.js +31 -0
- package/src/compiler/phases/2-analyze/visitors/AttachTag.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/Attribute.js +66 -0
- package/src/compiler/phases/2-analyze/visitors/AwaitBlock.js +48 -0
- package/src/compiler/phases/2-analyze/visitors/AwaitExpression.js +150 -0
- package/src/compiler/phases/2-analyze/visitors/BindDirective.js +280 -0
- package/src/compiler/phases/2-analyze/visitors/CallExpression.js +339 -0
- package/src/compiler/phases/2-analyze/visitors/ClassBody.js +156 -0
- package/src/compiler/phases/2-analyze/visitors/ClassDeclaration.js +25 -0
- package/src/compiler/phases/2-analyze/visitors/ClassDirective.js +13 -0
- package/src/compiler/phases/2-analyze/visitors/Component.js +26 -0
- package/src/compiler/phases/2-analyze/visitors/ConstTag.js +45 -0
- package/src/compiler/phases/2-analyze/visitors/DebugTag.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/EachBlock.js +97 -0
- package/src/compiler/phases/2-analyze/visitors/ExportDefaultDeclaration.js +20 -0
- package/src/compiler/phases/2-analyze/visitors/ExportNamedDeclaration.js +70 -0
- package/src/compiler/phases/2-analyze/visitors/ExportSpecifier.js +30 -0
- package/src/compiler/phases/2-analyze/visitors/ExpressionStatement.js +38 -0
- package/src/compiler/phases/2-analyze/visitors/ExpressionTag.js +26 -0
- package/src/compiler/phases/2-analyze/visitors/Fragment.js +10 -0
- package/src/compiler/phases/2-analyze/visitors/FunctionDeclaration.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/FunctionExpression.js +11 -0
- package/src/compiler/phases/2-analyze/visitors/HtmlTag.js +19 -0
- package/src/compiler/phases/2-analyze/visitors/Identifier.js +194 -0
- package/src/compiler/phases/2-analyze/visitors/IfBlock.js +46 -0
- package/src/compiler/phases/2-analyze/visitors/ImportDeclaration.js +31 -0
- package/src/compiler/phases/2-analyze/visitors/KeyBlock.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/LabeledStatement.js +95 -0
- package/src/compiler/phases/2-analyze/visitors/LetDirective.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/Literal.js +14 -0
- package/src/compiler/phases/2-analyze/visitors/MemberExpression.js +28 -0
- package/src/compiler/phases/2-analyze/visitors/NewExpression.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/OnDirective.js +28 -0
- package/src/compiler/phases/2-analyze/visitors/PropertyDefinition.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/RegularElement.js +240 -0
- package/src/compiler/phases/2-analyze/visitors/RenderTag.js +68 -0
- package/src/compiler/phases/2-analyze/visitors/SlotElement.js +42 -0
- package/src/compiler/phases/2-analyze/visitors/SnippetBlock.js +113 -0
- package/src/compiler/phases/2-analyze/visitors/SpreadAttribute.js +13 -0
- package/src/compiler/phases/2-analyze/visitors/SpreadElement.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/StyleDirective.js +39 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteBody.js +22 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteBoundary.js +30 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteComponent.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteDocument.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteElement.js +78 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteFragment.js +27 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteHead.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteSelf.js +36 -0
- package/src/compiler/phases/2-analyze/visitors/SvelteWindow.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/TaggedTemplateExpression.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/TemplateElement.js +12 -0
- package/src/compiler/phases/2-analyze/visitors/Text.js +52 -0
- package/src/compiler/phases/2-analyze/visitors/TitleElement.js +21 -0
- package/src/compiler/phases/2-analyze/visitors/TransitionDirective.js +19 -0
- package/src/compiler/phases/2-analyze/visitors/UpdateExpression.js +29 -0
- package/src/compiler/phases/2-analyze/visitors/UseDirective.js +18 -0
- package/src/compiler/phases/2-analyze/visitors/VariableDeclarator.js +160 -0
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/constants.js +334 -0
- package/src/compiler/phases/2-analyze/visitors/shared/a11y/index.js +981 -0
- package/src/compiler/phases/2-analyze/visitors/shared/attribute.js +125 -0
- package/src/compiler/phases/2-analyze/visitors/shared/component.js +177 -0
- package/src/compiler/phases/2-analyze/visitors/shared/element.js +160 -0
- package/src/compiler/phases/2-analyze/visitors/shared/fragment.js +15 -0
- package/src/compiler/phases/2-analyze/visitors/shared/function.js +24 -0
- package/src/compiler/phases/2-analyze/visitors/shared/snippets.js +17 -0
- package/src/compiler/phases/2-analyze/visitors/shared/special-element.js +16 -0
- package/src/compiler/phases/2-analyze/visitors/shared/utils.js +301 -0
- package/src/compiler/phases/3-transform/client/transform-client.js +719 -0
- package/src/compiler/phases/3-transform/client/transform-template/fix-attribute-casing.js +18 -0
- package/src/compiler/phases/3-transform/client/transform-template/index.js +67 -0
- package/src/compiler/phases/3-transform/client/transform-template/template.js +164 -0
- package/src/compiler/phases/3-transform/client/utils.js +181 -0
- package/src/compiler/phases/3-transform/client/visitors/AnimateDirective.js +38 -0
- package/src/compiler/phases/3-transform/client/visitors/ArrowFunctionExpression.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/AssignmentExpression.js +247 -0
- package/src/compiler/phases/3-transform/client/visitors/AttachTag.js +26 -0
- package/src/compiler/phases/3-transform/client/visitors/Attribute.js +14 -0
- package/src/compiler/phases/3-transform/client/visitors/AwaitBlock.js +124 -0
- package/src/compiler/phases/3-transform/client/visitors/AwaitExpression.js +25 -0
- package/src/compiler/phases/3-transform/client/visitors/BinaryExpression.js +34 -0
- package/src/compiler/phases/3-transform/client/visitors/BindDirective.js +290 -0
- package/src/compiler/phases/3-transform/client/visitors/BlockStatement.js +32 -0
- package/src/compiler/phases/3-transform/client/visitors/BreakStatement.js +20 -0
- package/src/compiler/phases/3-transform/client/visitors/CallExpression.js +136 -0
- package/src/compiler/phases/3-transform/client/visitors/ClassBody.js +111 -0
- package/src/compiler/phases/3-transform/client/visitors/Comment.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/Component.js +12 -0
- package/src/compiler/phases/3-transform/client/visitors/ConstTag.js +134 -0
- package/src/compiler/phases/3-transform/client/visitors/DebugTag.js +28 -0
- package/src/compiler/phases/3-transform/client/visitors/EachBlock.js +362 -0
- package/src/compiler/phases/3-transform/client/visitors/ExportNamedDeclaration.js +19 -0
- package/src/compiler/phases/3-transform/client/visitors/ExpressionStatement.js +20 -0
- package/src/compiler/phases/3-transform/client/visitors/ForOfStatement.js +25 -0
- package/src/compiler/phases/3-transform/client/visitors/Fragment.js +186 -0
- package/src/compiler/phases/3-transform/client/visitors/FunctionDeclaration.js +12 -0
- package/src/compiler/phases/3-transform/client/visitors/FunctionExpression.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/HtmlTag.js +53 -0
- package/src/compiler/phases/3-transform/client/visitors/Identifier.js +45 -0
- package/src/compiler/phases/3-transform/client/visitors/IfBlock.js +131 -0
- package/src/compiler/phases/3-transform/client/visitors/KeyBlock.js +45 -0
- package/src/compiler/phases/3-transform/client/visitors/LabeledStatement.js +64 -0
- package/src/compiler/phases/3-transform/client/visitors/LetDirective.js +55 -0
- package/src/compiler/phases/3-transform/client/visitors/MemberExpression.js +23 -0
- package/src/compiler/phases/3-transform/client/visitors/OnDirective.js +38 -0
- package/src/compiler/phases/3-transform/client/visitors/Program.js +153 -0
- package/src/compiler/phases/3-transform/client/visitors/RegularElement.js +725 -0
- package/src/compiler/phases/3-transform/client/visitors/RenderTag.js +95 -0
- package/src/compiler/phases/3-transform/client/visitors/SlotElement.js +94 -0
- package/src/compiler/phases/3-transform/client/visitors/SnippetBlock.js +94 -0
- package/src/compiler/phases/3-transform/client/visitors/SpreadAttribute.js +10 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteBody.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteBoundary.js +126 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteComponent.js +13 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteDocument.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteElement.js +161 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteFragment.js +17 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteHead.js +23 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteSelf.js +13 -0
- package/src/compiler/phases/3-transform/client/visitors/SvelteWindow.js +11 -0
- package/src/compiler/phases/3-transform/client/visitors/TitleElement.js +48 -0
- package/src/compiler/phases/3-transform/client/visitors/TransitionDirective.js +41 -0
- package/src/compiler/phases/3-transform/client/visitors/UpdateExpression.js +55 -0
- package/src/compiler/phases/3-transform/client/visitors/UseDirective.js +49 -0
- package/src/compiler/phases/3-transform/client/visitors/VariableDeclaration.js +422 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/component.js +536 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/declarations.js +53 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/element.js +263 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/events.js +180 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/fragment.js +185 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/function.js +17 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/special_element.js +22 -0
- package/src/compiler/phases/3-transform/client/visitors/shared/utils.js +513 -0
- package/src/compiler/phases/3-transform/css/index.js +479 -0
- package/src/compiler/phases/3-transform/index.js +118 -0
- package/src/compiler/phases/3-transform/server/transform-server.js +428 -0
- package/src/compiler/phases/3-transform/server/visitors/AssignmentExpression.js +124 -0
- package/src/compiler/phases/3-transform/server/visitors/AwaitBlock.js +36 -0
- package/src/compiler/phases/3-transform/server/visitors/AwaitExpression.js +40 -0
- package/src/compiler/phases/3-transform/server/visitors/CallExpression.js +71 -0
- package/src/compiler/phases/3-transform/server/visitors/ClassBody.js +81 -0
- package/src/compiler/phases/3-transform/server/visitors/Component.js +13 -0
- package/src/compiler/phases/3-transform/server/visitors/ConstTag.js +49 -0
- package/src/compiler/phases/3-transform/server/visitors/DebugTag.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/EachBlock.js +76 -0
- package/src/compiler/phases/3-transform/server/visitors/ExpressionStatement.js +23 -0
- package/src/compiler/phases/3-transform/server/visitors/Fragment.js +53 -0
- package/src/compiler/phases/3-transform/server/visitors/HtmlTag.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/Identifier.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/IfBlock.js +48 -0
- package/src/compiler/phases/3-transform/server/visitors/KeyBlock.js +22 -0
- package/src/compiler/phases/3-transform/server/visitors/LabeledStatement.js +24 -0
- package/src/compiler/phases/3-transform/server/visitors/MemberExpression.js +19 -0
- package/src/compiler/phases/3-transform/server/visitors/Program.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/PropertyDefinition.js +37 -0
- package/src/compiler/phases/3-transform/server/visitors/RegularElement.js +216 -0
- package/src/compiler/phases/3-transform/server/visitors/RenderTag.js +45 -0
- package/src/compiler/phases/3-transform/server/visitors/SlotElement.js +68 -0
- package/src/compiler/phases/3-transform/server/visitors/SnippetBlock.js +29 -0
- package/src/compiler/phases/3-transform/server/visitors/SpreadAttribute.js +10 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteBoundary.js +139 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteComponent.js +12 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteElement.js +89 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteFragment.js +11 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteHead.js +25 -0
- package/src/compiler/phases/3-transform/server/visitors/SvelteSelf.js +12 -0
- package/src/compiler/phases/3-transform/server/visitors/TitleElement.js +21 -0
- package/src/compiler/phases/3-transform/server/visitors/UpdateExpression.js +35 -0
- package/src/compiler/phases/3-transform/server/visitors/VariableDeclaration.js +247 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/component.js +359 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/element.js +557 -0
- package/src/compiler/phases/3-transform/server/visitors/shared/utils.js +408 -0
- package/src/compiler/phases/3-transform/shared/assignments.js +92 -0
- package/src/compiler/phases/3-transform/shared/transform-async.js +114 -0
- package/src/compiler/phases/3-transform/utils.js +451 -0
- package/src/compiler/phases/bindings.js +227 -0
- package/src/compiler/phases/css.js +14 -0
- package/src/compiler/phases/nodes.js +258 -0
- package/src/compiler/phases/patterns.js +27 -0
- package/src/compiler/phases/scope.js +1432 -0
- package/src/compiler/preprocess/decode_sourcemap.js +96 -0
- package/src/compiler/preprocess/index.js +368 -0
- package/src/compiler/preprocess/replace_in_code.js +72 -0
- package/src/compiler/print/index.js +911 -0
- package/src/compiler/state.js +144 -0
- package/src/compiler/utils/assert.js +9 -0
- package/src/compiler/utils/ast.js +639 -0
- package/src/compiler/utils/builders.js +698 -0
- package/src/compiler/utils/compile_diagnostic.js +107 -0
- package/src/compiler/utils/extract_svelte_ignore.js +104 -0
- package/src/compiler/utils/mapped_code.js +454 -0
- package/src/compiler/utils/push_array.js +13 -0
- package/src/compiler/utils/sanitize_template_string.js +7 -0
- package/src/compiler/utils/slot.js +20 -0
- package/src/compiler/utils/string.js +9 -0
- package/src/compiler/validate-options.js +324 -0
- package/src/compiler/warnings.js +845 -0
- package/src/constants.js +66 -0
- package/src/easing/index.js +286 -0
- package/src/escaping.js +26 -0
- package/src/events/index.js +1 -0
- package/src/html-tree-validation.js +238 -0
- package/src/index-client.js +255 -0
- package/src/index-server.js +56 -0
- package/src/internal/client/constants.js +77 -0
- package/src/internal/client/context.js +258 -0
- package/src/internal/client/dev/assign.js +79 -0
- package/src/internal/client/dev/console-log.js +37 -0
- package/src/internal/client/dev/css.js +31 -0
- package/src/internal/client/dev/debug.js +500 -0
- package/src/internal/client/dev/elements.js +63 -0
- package/src/internal/client/dev/equality.js +101 -0
- package/src/internal/client/dev/hmr.js +89 -0
- package/src/internal/client/dev/inspect.js +72 -0
- package/src/internal/client/dev/legacy.js +25 -0
- package/src/internal/client/dev/ownership.js +81 -0
- package/src/internal/client/dev/tracing.js +162 -0
- package/src/internal/client/dev/validation.js +16 -0
- package/src/internal/client/dom/blocks/async.js +71 -0
- package/src/internal/client/dom/blocks/await.js +142 -0
- package/src/internal/client/dom/blocks/boundary.js +534 -0
- package/src/internal/client/dom/blocks/branches.js +227 -0
- package/src/internal/client/dom/blocks/css-props.js +28 -0
- package/src/internal/client/dom/blocks/each.js +723 -0
- package/src/internal/client/dom/blocks/html.js +128 -0
- package/src/internal/client/dom/blocks/if.js +82 -0
- package/src/internal/client/dom/blocks/key.js +40 -0
- package/src/internal/client/dom/blocks/slot.js +44 -0
- package/src/internal/client/dom/blocks/snippet.js +103 -0
- package/src/internal/client/dom/blocks/svelte-component.js +61 -0
- package/src/internal/client/dom/blocks/svelte-element.js +152 -0
- package/src/internal/client/dom/blocks/svelte-head.js +61 -0
- package/src/internal/client/dom/css.js +33 -0
- package/src/internal/client/dom/elements/actions.js +43 -0
- package/src/internal/client/dom/elements/attachments.js +33 -0
- package/src/internal/client/dom/elements/attributes.js +657 -0
- package/src/internal/client/dom/elements/bindings/document.js +17 -0
- package/src/internal/client/dom/elements/bindings/input.js +312 -0
- package/src/internal/client/dom/elements/bindings/media.js +233 -0
- package/src/internal/client/dom/elements/bindings/navigator.js +11 -0
- package/src/internal/client/dom/elements/bindings/props.js +22 -0
- package/src/internal/client/dom/elements/bindings/select.js +159 -0
- package/src/internal/client/dom/elements/bindings/shared.js +76 -0
- package/src/internal/client/dom/elements/bindings/size.js +107 -0
- package/src/internal/client/dom/elements/bindings/this.js +61 -0
- package/src/internal/client/dom/elements/bindings/universal.js +75 -0
- package/src/internal/client/dom/elements/bindings/window.js +66 -0
- package/src/internal/client/dom/elements/class.js +51 -0
- package/src/internal/client/dom/elements/custom-element.js +344 -0
- package/src/internal/client/dom/elements/customizable-select.js +99 -0
- package/src/internal/client/dom/elements/events.js +355 -0
- package/src/internal/client/dom/elements/misc.js +58 -0
- package/src/internal/client/dom/elements/style.js +57 -0
- package/src/internal/client/dom/elements/transitions.js +471 -0
- package/src/internal/client/dom/hydration.js +125 -0
- package/src/internal/client/dom/legacy/event-modifiers.js +127 -0
- package/src/internal/client/dom/legacy/lifecycle.js +82 -0
- package/src/internal/client/dom/legacy/misc.js +68 -0
- package/src/internal/client/dom/operations.js +293 -0
- package/src/internal/client/dom/reconciler.js +25 -0
- package/src/internal/client/dom/task.js +42 -0
- package/src/internal/client/dom/template.js +401 -0
- package/src/internal/client/error-handling.js +118 -0
- package/src/internal/client/errors.js +510 -0
- package/src/internal/client/hydratable.js +33 -0
- package/src/internal/client/index.js +183 -0
- package/src/internal/client/legacy.js +46 -0
- package/src/internal/client/loop.js +48 -0
- package/src/internal/client/proxy.js +432 -0
- package/src/internal/client/reactivity/async.js +306 -0
- package/src/internal/client/reactivity/batch.js +1057 -0
- package/src/internal/client/reactivity/deriveds.js +426 -0
- package/src/internal/client/reactivity/effects.js +718 -0
- package/src/internal/client/reactivity/equality.js +31 -0
- package/src/internal/client/reactivity/props.js +430 -0
- package/src/internal/client/reactivity/sources.js +370 -0
- package/src/internal/client/reactivity/status.js +25 -0
- package/src/internal/client/reactivity/store.js +203 -0
- package/src/internal/client/reactivity/utils.js +40 -0
- package/src/internal/client/render.js +335 -0
- package/src/internal/client/runtime.js +827 -0
- package/src/internal/client/timing.js +16 -0
- package/src/internal/client/validate.js +54 -0
- package/src/internal/client/warnings.js +271 -0
- package/src/internal/disclose-version.js +6 -0
- package/src/internal/flags/async.js +3 -0
- package/src/internal/flags/index.js +23 -0
- package/src/internal/flags/legacy.js +3 -0
- package/src/internal/flags/tracing.js +3 -0
- package/src/internal/index.js +5 -0
- package/src/internal/server/abort-signal.js +13 -0
- package/src/internal/server/blocks/html.js +11 -0
- package/src/internal/server/blocks/snippet.js +24 -0
- package/src/internal/server/context.js +132 -0
- package/src/internal/server/crypto.js +45 -0
- package/src/internal/server/dev.js +115 -0
- package/src/internal/server/errors.js +131 -0
- package/src/internal/server/hydratable.js +142 -0
- package/src/internal/server/hydration.js +6 -0
- package/src/internal/server/index.js +544 -0
- package/src/internal/server/render-context.js +86 -0
- package/src/internal/server/renderer.js +923 -0
- package/src/internal/server/warnings.js +29 -0
- package/src/internal/shared/attributes.js +225 -0
- package/src/internal/shared/clone.js +137 -0
- package/src/internal/shared/dev.js +65 -0
- package/src/internal/shared/errors.js +134 -0
- package/src/internal/shared/utils.js +144 -0
- package/src/internal/shared/validate.js +47 -0
- package/src/internal/shared/warnings.js +40 -0
- package/src/legacy/legacy-client.js +281 -0
- package/src/legacy/legacy-server.js +112 -0
- package/src/motion/index.js +32 -0
- package/src/motion/spring.js +369 -0
- package/src/motion/tweened.js +306 -0
- package/src/motion/utils.js +7 -0
- package/src/reactivity/create-subscriber.js +95 -0
- package/src/reactivity/date.js +118 -0
- package/src/reactivity/index-client.js +7 -0
- package/src/reactivity/index-server.js +23 -0
- package/src/reactivity/map.js +273 -0
- package/src/reactivity/media-query.js +55 -0
- package/src/reactivity/reactive-value.js +24 -0
- package/src/reactivity/set.js +213 -0
- package/src/reactivity/url-search-params.js +174 -0
- package/src/reactivity/url.js +205 -0
- package/src/reactivity/window/index.js +161 -0
- package/src/server/index.js +1 -0
- package/src/store/index-client.js +169 -0
- package/src/store/index-server.js +101 -0
- package/src/store/shared/index.js +209 -0
- package/src/store/utils.js +36 -0
- package/src/transition/index.js +300 -0
- package/src/utils.js +504 -0
- package/src/version.js +8 -0
- package/store.d.ts +1 -0
- package/svelte-html.d.ts +245 -0
- package/transition.d.ts +1 -0
- package/types/compiler/interfaces.d.ts +1 -0
- package/types/compiler/preprocess.d.ts +1 -0
- package/types/index.d.ts +3744 -0
- package/types/index.d.ts.map +280 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
// Store the references to globals in case someone tries to monkey patch these, causing the below
|
|
2
|
+
// to de-opt (this occurs often when using popular extensions).
|
|
3
|
+
export var is_array = Array.isArray;
|
|
4
|
+
export var index_of = Array.prototype.indexOf;
|
|
5
|
+
export var includes = Array.prototype.includes;
|
|
6
|
+
export var array_from = Array.from;
|
|
7
|
+
export var object_keys = Object.keys;
|
|
8
|
+
export var define_property = Object.defineProperty;
|
|
9
|
+
export var get_descriptor = Object.getOwnPropertyDescriptor;
|
|
10
|
+
export var get_descriptors = Object.getOwnPropertyDescriptors;
|
|
11
|
+
export var object_prototype = Object.prototype;
|
|
12
|
+
export var array_prototype = Array.prototype;
|
|
13
|
+
export var get_prototype_of = Object.getPrototypeOf;
|
|
14
|
+
export var is_extensible = Object.isExtensible;
|
|
15
|
+
export var has_own_property = Object.prototype.hasOwnProperty;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {any} thing
|
|
19
|
+
* @returns {thing is Function}
|
|
20
|
+
*/
|
|
21
|
+
export function is_function(thing) {
|
|
22
|
+
return typeof thing === 'function';
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const noop = () => {};
|
|
26
|
+
|
|
27
|
+
// Adapted from https://github.com/then/is-promise/blob/master/index.js
|
|
28
|
+
// Distributed under MIT License https://github.com/then/is-promise/blob/master/LICENSE
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @template [T=any]
|
|
32
|
+
* @param {any} value
|
|
33
|
+
* @returns {value is PromiseLike<T>}
|
|
34
|
+
*/
|
|
35
|
+
export function is_promise(value) {
|
|
36
|
+
return typeof value?.then === 'function';
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** @param {Function} fn */
|
|
40
|
+
export function run(fn) {
|
|
41
|
+
return fn();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** @param {Array<() => void>} arr */
|
|
45
|
+
export function run_all(arr) {
|
|
46
|
+
for (var i = 0; i < arr.length; i++) {
|
|
47
|
+
arr[i]();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* TODO replace with Promise.withResolvers once supported widely enough
|
|
53
|
+
* @template [T=void]
|
|
54
|
+
*/
|
|
55
|
+
export function deferred() {
|
|
56
|
+
/** @type {(value: T) => void} */
|
|
57
|
+
var resolve;
|
|
58
|
+
|
|
59
|
+
/** @type {(reason: any) => void} */
|
|
60
|
+
var reject;
|
|
61
|
+
|
|
62
|
+
/** @type {Promise<T>} */
|
|
63
|
+
var promise = new Promise((res, rej) => {
|
|
64
|
+
resolve = res;
|
|
65
|
+
reject = rej;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// @ts-expect-error
|
|
69
|
+
return { promise, resolve, reject };
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @template V
|
|
74
|
+
* @param {V} value
|
|
75
|
+
* @param {V | (() => V)} fallback
|
|
76
|
+
* @param {boolean} [lazy]
|
|
77
|
+
* @returns {V}
|
|
78
|
+
*/
|
|
79
|
+
export function fallback(value, fallback, lazy = false) {
|
|
80
|
+
return value === undefined
|
|
81
|
+
? lazy
|
|
82
|
+
? /** @type {() => V} */ (fallback)()
|
|
83
|
+
: /** @type {V} */ (fallback)
|
|
84
|
+
: value;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* When encountering a situation like `let [a, b, c] = $derived(blah())`,
|
|
89
|
+
* we need to stash an intermediate value that `a`, `b`, and `c` derive
|
|
90
|
+
* from, in case it's an iterable
|
|
91
|
+
* @template T
|
|
92
|
+
* @param {ArrayLike<T> | Iterable<T>} value
|
|
93
|
+
* @param {number} [n]
|
|
94
|
+
* @returns {Array<T>}
|
|
95
|
+
*/
|
|
96
|
+
export function to_array(value, n) {
|
|
97
|
+
// return arrays unchanged
|
|
98
|
+
if (Array.isArray(value)) {
|
|
99
|
+
return value;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// if value is not iterable, or `n` is unspecified (indicates a rest
|
|
103
|
+
// element, which means we're not concerned about unbounded iterables)
|
|
104
|
+
// convert to an array with `Array.from`
|
|
105
|
+
if (n === undefined || !(Symbol.iterator in value)) {
|
|
106
|
+
return Array.from(value);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// otherwise, populate an array with `n` values
|
|
110
|
+
|
|
111
|
+
/** @type {T[]} */
|
|
112
|
+
const array = [];
|
|
113
|
+
|
|
114
|
+
for (const element of value) {
|
|
115
|
+
array.push(element);
|
|
116
|
+
if (array.length === n) break;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return array;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* @param {Record<string | symbol, unknown>} obj
|
|
124
|
+
* @param {Array<string | symbol>} keys
|
|
125
|
+
* @returns {Record<string | symbol, unknown>}
|
|
126
|
+
*/
|
|
127
|
+
export function exclude_from_object(obj, keys) {
|
|
128
|
+
/** @type {Record<string | symbol, unknown>} */
|
|
129
|
+
var result = {};
|
|
130
|
+
|
|
131
|
+
for (var key in obj) {
|
|
132
|
+
if (!keys.includes(key)) {
|
|
133
|
+
result[key] = obj[key];
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (var symbol of Object.getOwnPropertySymbols(obj)) {
|
|
138
|
+
if (Object.propertyIsEnumerable.call(obj, symbol) && !keys.includes(symbol)) {
|
|
139
|
+
result[symbol] = obj[symbol];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return result;
|
|
144
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { is_void } from '../../utils.js';
|
|
2
|
+
import * as w from './warnings.js';
|
|
3
|
+
import * as e from './errors.js';
|
|
4
|
+
|
|
5
|
+
export { invalid_default_snippet } from './errors.js';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @param {() => string} tag_fn
|
|
9
|
+
* @returns {void}
|
|
10
|
+
*/
|
|
11
|
+
export function validate_void_dynamic_element(tag_fn) {
|
|
12
|
+
const tag = tag_fn();
|
|
13
|
+
if (tag && is_void(tag)) {
|
|
14
|
+
w.dynamic_void_element_content(tag);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** @param {() => unknown} tag_fn */
|
|
19
|
+
export function validate_dynamic_element_tag(tag_fn) {
|
|
20
|
+
const tag = tag_fn();
|
|
21
|
+
const is_string = typeof tag === 'string';
|
|
22
|
+
if (tag && !is_string) {
|
|
23
|
+
e.svelte_element_invalid_this_value();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* @param {any} store
|
|
29
|
+
* @param {string} name
|
|
30
|
+
*/
|
|
31
|
+
export function validate_store(store, name) {
|
|
32
|
+
if (store != null && typeof store.subscribe !== 'function') {
|
|
33
|
+
e.store_invalid_shape(name);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* @template {(...args: any[]) => unknown} T
|
|
39
|
+
* @param {T} fn
|
|
40
|
+
*/
|
|
41
|
+
export function prevent_snippet_stringification(fn) {
|
|
42
|
+
fn.toString = () => {
|
|
43
|
+
e.snippet_without_render_tag();
|
|
44
|
+
return '';
|
|
45
|
+
};
|
|
46
|
+
return fn;
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* This file is generated by scripts/process-messages/index.js. Do not edit! */
|
|
2
|
+
|
|
3
|
+
import { DEV } from 'esm-env';
|
|
4
|
+
|
|
5
|
+
var bold = 'font-weight: bold';
|
|
6
|
+
var normal = 'font-weight: normal';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* `<svelte:element this="%tag%">` is a void element — it cannot have content
|
|
10
|
+
* @param {string} tag
|
|
11
|
+
*/
|
|
12
|
+
export function dynamic_void_element_content(tag) {
|
|
13
|
+
if (DEV) {
|
|
14
|
+
console.warn(`%c[svelte] dynamic_void_element_content\n%c\`<svelte:element this="${tag}">\` is a void element — it cannot have content\nhttps://svelte.dev/e/dynamic_void_element_content`, bold, normal);
|
|
15
|
+
} else {
|
|
16
|
+
console.warn(`https://svelte.dev/e/dynamic_void_element_content`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The following properties cannot be cloned with `$state.snapshot` — the return value contains the originals:
|
|
22
|
+
*
|
|
23
|
+
* %properties%
|
|
24
|
+
* @param {string | undefined | null} [properties]
|
|
25
|
+
*/
|
|
26
|
+
export function state_snapshot_uncloneable(properties) {
|
|
27
|
+
if (DEV) {
|
|
28
|
+
console.warn(
|
|
29
|
+
`%c[svelte] state_snapshot_uncloneable\n%c${properties
|
|
30
|
+
? `The following properties cannot be cloned with \`$state.snapshot\` — the return value contains the originals:
|
|
31
|
+
|
|
32
|
+
${properties}`
|
|
33
|
+
: 'Value cannot be cloned with `$state.snapshot` — the original value was returned'}\nhttps://svelte.dev/e/state_snapshot_uncloneable`,
|
|
34
|
+
bold,
|
|
35
|
+
normal
|
|
36
|
+
);
|
|
37
|
+
} else {
|
|
38
|
+
console.warn(`https://svelte.dev/e/state_snapshot_uncloneable`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/** @import { ComponentConstructorOptions, ComponentType, SvelteComponent, Component } from 'svelte' */
|
|
2
|
+
import { DIRTY, LEGACY_PROPS, MAYBE_DIRTY } from '../internal/client/constants.js';
|
|
3
|
+
import { user_pre_effect } from '../internal/client/reactivity/effects.js';
|
|
4
|
+
import { mutable_source, set } from '../internal/client/reactivity/sources.js';
|
|
5
|
+
import { hydrate, mount, unmount } from '../internal/client/render.js';
|
|
6
|
+
import { active_effect, get } from '../internal/client/runtime.js';
|
|
7
|
+
import { flushSync } from '../internal/client/reactivity/batch.js';
|
|
8
|
+
import { define_property, is_array } from '../internal/shared/utils.js';
|
|
9
|
+
import * as e from '../internal/client/errors.js';
|
|
10
|
+
import * as w from '../internal/client/warnings.js';
|
|
11
|
+
import { DEV } from 'esm-env';
|
|
12
|
+
import { FILENAME } from '../constants.js';
|
|
13
|
+
import { component_context, dev_current_component_function } from '../internal/client/context.js';
|
|
14
|
+
import { async_mode_flag } from '../internal/flags/index.js';
|
|
15
|
+
import { set_signal_status } from '../internal/client/reactivity/status.js';
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Takes the same options as a Svelte 4 component and the component function and returns a Svelte 4 compatible component.
|
|
19
|
+
*
|
|
20
|
+
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
|
|
21
|
+
*
|
|
22
|
+
* @template {Record<string, any>} Props
|
|
23
|
+
* @template {Record<string, any>} Exports
|
|
24
|
+
* @template {Record<string, any>} Events
|
|
25
|
+
* @template {Record<string, any>} Slots
|
|
26
|
+
*
|
|
27
|
+
* @param {ComponentConstructorOptions<Props> & {
|
|
28
|
+
* component: ComponentType<SvelteComponent<Props, Events, Slots>> | Component<Props>;
|
|
29
|
+
* }} options
|
|
30
|
+
* @returns {SvelteComponent<Props, Events, Slots> & Exports}
|
|
31
|
+
*/
|
|
32
|
+
export function createClassComponent(options) {
|
|
33
|
+
// @ts-expect-error $$prop_def etc are not actually defined
|
|
34
|
+
return new Svelte4Component(options);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Takes the component function and returns a Svelte 4 compatible component constructor.
|
|
39
|
+
*
|
|
40
|
+
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
|
|
41
|
+
*
|
|
42
|
+
* @template {Record<string, any>} Props
|
|
43
|
+
* @template {Record<string, any>} Exports
|
|
44
|
+
* @template {Record<string, any>} Events
|
|
45
|
+
* @template {Record<string, any>} Slots
|
|
46
|
+
*
|
|
47
|
+
* @param {SvelteComponent<Props, Events, Slots> | Component<Props>} component
|
|
48
|
+
* @returns {ComponentType<SvelteComponent<Props, Events, Slots> & Exports>}
|
|
49
|
+
*/
|
|
50
|
+
export function asClassComponent(component) {
|
|
51
|
+
// @ts-expect-error $$prop_def etc are not actually defined
|
|
52
|
+
return class extends Svelte4Component {
|
|
53
|
+
/** @param {any} options */
|
|
54
|
+
constructor(options) {
|
|
55
|
+
super({
|
|
56
|
+
component,
|
|
57
|
+
...options
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Support using the component as both a class and function during the transition period
|
|
65
|
+
* @typedef {{new (o: ComponentConstructorOptions): SvelteComponent;(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;}} LegacyComponentType
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
class Svelte4Component {
|
|
69
|
+
/** @type {any} */
|
|
70
|
+
#events;
|
|
71
|
+
|
|
72
|
+
/** @type {Record<string, any>} */
|
|
73
|
+
#instance;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* @param {ComponentConstructorOptions & {
|
|
77
|
+
* component: any;
|
|
78
|
+
* }} options
|
|
79
|
+
*/
|
|
80
|
+
constructor(options) {
|
|
81
|
+
var sources = new Map();
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* @param {string | symbol} key
|
|
85
|
+
* @param {unknown} value
|
|
86
|
+
*/
|
|
87
|
+
var add_source = (key, value) => {
|
|
88
|
+
var s = mutable_source(value, false, false);
|
|
89
|
+
sources.set(key, s);
|
|
90
|
+
return s;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
// Replicate coarse-grained props through a proxy that has a version source for
|
|
94
|
+
// each property, which is incremented on updates to the property itself. Do not
|
|
95
|
+
// use our $state proxy because that one has fine-grained reactivity.
|
|
96
|
+
const props = new Proxy(
|
|
97
|
+
{ ...(options.props || {}), $$events: {} },
|
|
98
|
+
{
|
|
99
|
+
get(target, prop) {
|
|
100
|
+
return get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
101
|
+
},
|
|
102
|
+
has(target, prop) {
|
|
103
|
+
// Necessary to not throw "invalid binding" validation errors on the component side
|
|
104
|
+
if (prop === LEGACY_PROPS) return true;
|
|
105
|
+
|
|
106
|
+
get(sources.get(prop) ?? add_source(prop, Reflect.get(target, prop)));
|
|
107
|
+
return Reflect.has(target, prop);
|
|
108
|
+
},
|
|
109
|
+
set(target, prop, value) {
|
|
110
|
+
set(sources.get(prop) ?? add_source(prop, value), value);
|
|
111
|
+
return Reflect.set(target, prop, value);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
this.#instance = (options.hydrate ? hydrate : mount)(options.component, {
|
|
117
|
+
target: options.target,
|
|
118
|
+
anchor: options.anchor,
|
|
119
|
+
props,
|
|
120
|
+
context: options.context,
|
|
121
|
+
intro: options.intro ?? false,
|
|
122
|
+
recover: options.recover,
|
|
123
|
+
transformError: options.transformError
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// We don't flushSync for custom element wrappers or if the user doesn't want it,
|
|
127
|
+
// or if we're in async mode since `flushSync()` will fail
|
|
128
|
+
if (!async_mode_flag && (!options?.props?.$$host || options.sync === false)) {
|
|
129
|
+
flushSync();
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
this.#events = props.$$events;
|
|
133
|
+
|
|
134
|
+
for (const key of Object.keys(this.#instance)) {
|
|
135
|
+
if (key === '$set' || key === '$destroy' || key === '$on') continue;
|
|
136
|
+
define_property(this, key, {
|
|
137
|
+
get() {
|
|
138
|
+
return this.#instance[key];
|
|
139
|
+
},
|
|
140
|
+
/** @param {any} value */
|
|
141
|
+
set(value) {
|
|
142
|
+
this.#instance[key] = value;
|
|
143
|
+
},
|
|
144
|
+
enumerable: true
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.#instance.$set = /** @param {Record<string, any>} next */ (next) => {
|
|
149
|
+
Object.assign(props, next);
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
this.#instance.$destroy = () => {
|
|
153
|
+
unmount(this.#instance);
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** @param {Record<string, any>} props */
|
|
158
|
+
$set(props) {
|
|
159
|
+
this.#instance.$set(props);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* @param {string} event
|
|
164
|
+
* @param {(...args: any[]) => any} callback
|
|
165
|
+
* @returns {any}
|
|
166
|
+
*/
|
|
167
|
+
$on(event, callback) {
|
|
168
|
+
this.#events[event] = this.#events[event] || [];
|
|
169
|
+
|
|
170
|
+
/** @param {any[]} args */
|
|
171
|
+
const cb = (...args) => callback.call(this, ...args);
|
|
172
|
+
this.#events[event].push(cb);
|
|
173
|
+
return () => {
|
|
174
|
+
this.#events[event] = this.#events[event].filter(/** @param {any} fn */ (fn) => fn !== cb);
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
$destroy() {
|
|
179
|
+
this.#instance.$destroy();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Runs the given function once immediately on the server, and works like `$effect.pre` on the client.
|
|
185
|
+
*
|
|
186
|
+
* @deprecated Use this only as a temporary solution to migrate your component code to Svelte 5.
|
|
187
|
+
* @param {() => void | (() => void)} fn
|
|
188
|
+
* @returns {void}
|
|
189
|
+
*/
|
|
190
|
+
export function run(fn) {
|
|
191
|
+
user_pre_effect(() => {
|
|
192
|
+
fn();
|
|
193
|
+
var effect = /** @type {import('#client').Effect} */ (active_effect);
|
|
194
|
+
// If the effect is immediately made dirty again, mark it as maybe dirty to emulate legacy behaviour
|
|
195
|
+
if ((effect.f & DIRTY) !== 0) {
|
|
196
|
+
let filename = "a file (we can't know which one)";
|
|
197
|
+
if (DEV) {
|
|
198
|
+
// @ts-ignore
|
|
199
|
+
filename = dev_current_component_function?.[FILENAME] ?? filename;
|
|
200
|
+
}
|
|
201
|
+
w.legacy_recursive_reactive_block(filename);
|
|
202
|
+
set_signal_status(effect, MAYBE_DIRTY);
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/**
|
|
208
|
+
* Function to mimic the multiple listeners available in svelte 4
|
|
209
|
+
* @deprecated
|
|
210
|
+
* @param {EventListener[]} handlers
|
|
211
|
+
* @returns {EventListener}
|
|
212
|
+
*/
|
|
213
|
+
export function handlers(...handlers) {
|
|
214
|
+
return function (event) {
|
|
215
|
+
const { stopImmediatePropagation } = event;
|
|
216
|
+
let stopped = false;
|
|
217
|
+
|
|
218
|
+
event.stopImmediatePropagation = () => {
|
|
219
|
+
stopped = true;
|
|
220
|
+
stopImmediatePropagation.call(event);
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
const errors = [];
|
|
224
|
+
|
|
225
|
+
for (const handler of handlers) {
|
|
226
|
+
try {
|
|
227
|
+
// @ts-expect-error `this` is not typed
|
|
228
|
+
handler?.call(this, event);
|
|
229
|
+
} catch (e) {
|
|
230
|
+
errors.push(e);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
if (stopped) {
|
|
234
|
+
break;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
for (let error of errors) {
|
|
239
|
+
queueMicrotask(() => {
|
|
240
|
+
throw error;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Function to create a `bubble` function that mimic the behavior of `on:click` without handler available in svelte 4.
|
|
248
|
+
* @deprecated Use this only as a temporary solution to migrate your automatically delegated events in Svelte 5.
|
|
249
|
+
*/
|
|
250
|
+
export function createBubbler() {
|
|
251
|
+
const active_component_context = component_context;
|
|
252
|
+
if (active_component_context === null) {
|
|
253
|
+
e.lifecycle_outside_component('createBubbler');
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return (/**@type {string}*/ type) => (/**@type {Event}*/ event) => {
|
|
257
|
+
const events = /** @type {Record<string, Function | Function[]>} */ (
|
|
258
|
+
active_component_context.s.$$events
|
|
259
|
+
)?.[/** @type {any} */ (type)];
|
|
260
|
+
|
|
261
|
+
if (events) {
|
|
262
|
+
const callbacks = is_array(events) ? events.slice() : [events];
|
|
263
|
+
for (const fn of callbacks) {
|
|
264
|
+
fn.call(active_component_context.x, event);
|
|
265
|
+
}
|
|
266
|
+
return !event.defaultPrevented;
|
|
267
|
+
}
|
|
268
|
+
return true;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export {
|
|
273
|
+
once,
|
|
274
|
+
preventDefault,
|
|
275
|
+
self,
|
|
276
|
+
stopImmediatePropagation,
|
|
277
|
+
stopPropagation,
|
|
278
|
+
trusted,
|
|
279
|
+
passive,
|
|
280
|
+
nonpassive
|
|
281
|
+
} from '../internal/client/dom/legacy/event-modifiers.js';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/** @import { SvelteComponent } from '../index.js' */
|
|
2
|
+
/** @import { Csp } from '#server' */
|
|
3
|
+
import { asClassComponent as as_class_component, createClassComponent } from './legacy-client.js';
|
|
4
|
+
import { render } from '../internal/server/index.js';
|
|
5
|
+
import { async_mode_flag } from '../internal/flags/index.js';
|
|
6
|
+
|
|
7
|
+
// By having this as a separate entry point for server environments, we save the client bundle from having to include the server runtime
|
|
8
|
+
|
|
9
|
+
export { createClassComponent };
|
|
10
|
+
|
|
11
|
+
/** @typedef {{ head: string, html: string, css: { code: string, map: null }; hashes?: { script: `sha256-${string}`[] } }} LegacyRenderResult */
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Takes a Svelte 5 component and returns a Svelte 4 compatible component constructor.
|
|
15
|
+
*
|
|
16
|
+
* @deprecated Use this only as a temporary solution to migrate your imperative component code to Svelte 5.
|
|
17
|
+
*
|
|
18
|
+
* @template {Record<string, any>} Props
|
|
19
|
+
* @template {Record<string, any>} Exports
|
|
20
|
+
* @template {Record<string, any>} Events
|
|
21
|
+
* @template {Record<string, any>} Slots
|
|
22
|
+
*
|
|
23
|
+
* @param {SvelteComponent<Props, Events, Slots>} component
|
|
24
|
+
* @returns {typeof SvelteComponent<Props, Events, Slots> & Exports}
|
|
25
|
+
*/
|
|
26
|
+
export function asClassComponent(component) {
|
|
27
|
+
const component_constructor = as_class_component(component);
|
|
28
|
+
/** @type {(props?: {}, opts?: { $$slots?: {}; context?: Map<any, any>; csp?: Csp; transformError?: (error: unknown) => unknown }) => LegacyRenderResult & PromiseLike<LegacyRenderResult> } */
|
|
29
|
+
const _render = (props, { context, csp, transformError } = {}) => {
|
|
30
|
+
// @ts-expect-error the typings are off, but this will work if the component is compiled in SSR mode
|
|
31
|
+
const result = render(component, { props, context, csp, transformError });
|
|
32
|
+
|
|
33
|
+
const munged = Object.defineProperties(
|
|
34
|
+
/** @type {LegacyRenderResult & PromiseLike<LegacyRenderResult>} */ ({}),
|
|
35
|
+
{
|
|
36
|
+
css: {
|
|
37
|
+
value: { code: '', map: null }
|
|
38
|
+
},
|
|
39
|
+
head: {
|
|
40
|
+
get: () => result.head
|
|
41
|
+
},
|
|
42
|
+
html: {
|
|
43
|
+
get: () => result.body
|
|
44
|
+
},
|
|
45
|
+
then: {
|
|
46
|
+
/**
|
|
47
|
+
* this is not type-safe, but honestly it's the best I can do right now, and it's a straightforward function.
|
|
48
|
+
*
|
|
49
|
+
* @template TResult1
|
|
50
|
+
* @template [TResult2=never]
|
|
51
|
+
* @param { (value: LegacyRenderResult) => TResult1 } onfulfilled
|
|
52
|
+
* @param { (reason: unknown) => TResult2 } onrejected
|
|
53
|
+
*/
|
|
54
|
+
value: (onfulfilled, onrejected) => {
|
|
55
|
+
if (!async_mode_flag) {
|
|
56
|
+
const user_result = onfulfilled({
|
|
57
|
+
css: munged.css,
|
|
58
|
+
head: munged.head,
|
|
59
|
+
html: munged.html
|
|
60
|
+
});
|
|
61
|
+
return Promise.resolve(user_result);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return result.then((result) => {
|
|
65
|
+
return onfulfilled({
|
|
66
|
+
css: munged.css,
|
|
67
|
+
head: result.head,
|
|
68
|
+
html: result.body,
|
|
69
|
+
hashes: result.hashes
|
|
70
|
+
});
|
|
71
|
+
}, onrejected);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
return munged;
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
// @ts-expect-error this is present for SSR
|
|
81
|
+
component_constructor.render = _render;
|
|
82
|
+
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
return component_constructor;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Runs the given function once immediately on the server, and works like `$effect.pre` on the client.
|
|
89
|
+
*
|
|
90
|
+
* @deprecated Use this only as a temporary solution to migrate your component code to Svelte 5.
|
|
91
|
+
* @param {() => void | (() => void)} fn
|
|
92
|
+
* @returns {void}
|
|
93
|
+
*/
|
|
94
|
+
export function run(fn) {
|
|
95
|
+
fn();
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const noop = () => {};
|
|
99
|
+
|
|
100
|
+
// event stuff, no need to worry about it for SSR but needs to be there or it will crash
|
|
101
|
+
export {
|
|
102
|
+
noop as handlers,
|
|
103
|
+
noop as createBubbler,
|
|
104
|
+
noop as once,
|
|
105
|
+
noop as preventDefault,
|
|
106
|
+
noop as self,
|
|
107
|
+
noop as stopImmediatePropagation,
|
|
108
|
+
noop as stopPropagation,
|
|
109
|
+
noop as trusted,
|
|
110
|
+
noop as passive,
|
|
111
|
+
noop as nonpassive
|
|
112
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { MediaQuery } from 'svelte/reactivity';
|
|
2
|
+
|
|
3
|
+
export * from './spring.js';
|
|
4
|
+
export * from './tweened.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A [media query](https://svelte.dev/docs/svelte/svelte-reactivity#MediaQuery) that matches if the user [prefers reduced motion](https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion).
|
|
8
|
+
*
|
|
9
|
+
* ```svelte
|
|
10
|
+
* <script>
|
|
11
|
+
* import { prefersReducedMotion } from 'svelte/motion';
|
|
12
|
+
* import { fly } from 'svelte/transition';
|
|
13
|
+
*
|
|
14
|
+
* let visible = $state(false);
|
|
15
|
+
* </script>
|
|
16
|
+
*
|
|
17
|
+
* <button onclick={() => visible = !visible}>
|
|
18
|
+
* toggle
|
|
19
|
+
* </button>
|
|
20
|
+
*
|
|
21
|
+
* {#if visible}
|
|
22
|
+
* <p transition:fly={{ y: prefersReducedMotion.current ? 0 : 200 }}>
|
|
23
|
+
* flies in, unless the user prefers reduced motion
|
|
24
|
+
* </p>
|
|
25
|
+
* {/if}
|
|
26
|
+
* ```
|
|
27
|
+
* @type {MediaQuery}
|
|
28
|
+
* @since 5.7.0
|
|
29
|
+
*/
|
|
30
|
+
export const prefersReducedMotion = /*@__PURE__*/ new MediaQuery(
|
|
31
|
+
'(prefers-reduced-motion: reduce)'
|
|
32
|
+
);
|