@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,471 @@
|
|
|
1
|
+
/** @import { AnimateFn, Animation, AnimationConfig, EachItem, Effect, EffectNodes, TransitionFn, TransitionManager } from '#client' */
|
|
2
|
+
import { noop, is_function } from '../../../shared/utils.js';
|
|
3
|
+
import { effect } from '../../reactivity/effects.js';
|
|
4
|
+
import { active_effect, untrack } from '../../runtime.js';
|
|
5
|
+
import { loop } from '../../loop.js';
|
|
6
|
+
import { should_intro } from '../../render.js';
|
|
7
|
+
import { TRANSITION_GLOBAL, TRANSITION_IN, TRANSITION_OUT } from '../../../../constants.js';
|
|
8
|
+
import { BLOCK_EFFECT, REACTION_RAN, EFFECT_TRANSPARENT } from '#client/constants';
|
|
9
|
+
import { queue_micro_task } from '../task.js';
|
|
10
|
+
import { without_reactive_context } from './bindings/shared.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @param {Element} element
|
|
14
|
+
* @param {'introstart' | 'introend' | 'outrostart' | 'outroend'} type
|
|
15
|
+
* @returns {void}
|
|
16
|
+
*/
|
|
17
|
+
function dispatch_event(element, type) {
|
|
18
|
+
without_reactive_context(() => {
|
|
19
|
+
element.dispatchEvent(new CustomEvent(type));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Converts a property to the camel-case format expected by Element.animate(), KeyframeEffect(), and KeyframeEffect.setKeyframes().
|
|
25
|
+
* @param {string} style
|
|
26
|
+
* @returns {string}
|
|
27
|
+
*/
|
|
28
|
+
function css_property_to_camelcase(style) {
|
|
29
|
+
// in compliance with spec
|
|
30
|
+
if (style === 'float') return 'cssFloat';
|
|
31
|
+
if (style === 'offset') return 'cssOffset';
|
|
32
|
+
|
|
33
|
+
// do not rename custom @properties
|
|
34
|
+
if (style.startsWith('--')) return style;
|
|
35
|
+
|
|
36
|
+
const parts = style.split('-');
|
|
37
|
+
if (parts.length === 1) return parts[0];
|
|
38
|
+
return (
|
|
39
|
+
parts[0] +
|
|
40
|
+
parts
|
|
41
|
+
.slice(1)
|
|
42
|
+
.map(/** @param {any} word */ (word) => word[0].toUpperCase() + word.slice(1))
|
|
43
|
+
.join('')
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param {string} css
|
|
49
|
+
* @returns {Keyframe}
|
|
50
|
+
*/
|
|
51
|
+
function css_to_keyframe(css) {
|
|
52
|
+
/** @type {Keyframe} */
|
|
53
|
+
const keyframe = {};
|
|
54
|
+
const parts = css.split(';');
|
|
55
|
+
for (const part of parts) {
|
|
56
|
+
const [property, value] = part.split(':');
|
|
57
|
+
if (!property || value === undefined) break;
|
|
58
|
+
|
|
59
|
+
const formatted_property = css_property_to_camelcase(property.trim());
|
|
60
|
+
keyframe[formatted_property] = value.trim();
|
|
61
|
+
}
|
|
62
|
+
return keyframe;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** @param {number} t */
|
|
66
|
+
const linear = (t) => t;
|
|
67
|
+
|
|
68
|
+
/** @type {Effect | null} */
|
|
69
|
+
let animation_effect_override = null;
|
|
70
|
+
|
|
71
|
+
/** @param {Effect | null} v */
|
|
72
|
+
export function set_animation_effect_override(v) {
|
|
73
|
+
animation_effect_override = v;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Called inside keyed `{#each ...}` blocks (as `$.animation(...)`). This creates an animation manager
|
|
78
|
+
* and attaches it to the block, so that moves can be animated following reconciliation.
|
|
79
|
+
* @template P
|
|
80
|
+
* @param {Element} element
|
|
81
|
+
* @param {() => AnimateFn<P | undefined>} get_fn
|
|
82
|
+
* @param {(() => P) | null} get_params
|
|
83
|
+
*/
|
|
84
|
+
export function animation(element, get_fn, get_params) {
|
|
85
|
+
var effect = animation_effect_override ?? /** @type {Effect} */ (active_effect);
|
|
86
|
+
var nodes = /** @type {EffectNodes} */ (effect.nodes);
|
|
87
|
+
|
|
88
|
+
/** @type {DOMRect} */
|
|
89
|
+
var from;
|
|
90
|
+
|
|
91
|
+
/** @type {DOMRect} */
|
|
92
|
+
var to;
|
|
93
|
+
|
|
94
|
+
/** @type {Animation | undefined} */
|
|
95
|
+
var animation;
|
|
96
|
+
|
|
97
|
+
/** @type {null | { position: string, width: string, height: string, transform: string }} */
|
|
98
|
+
var original_styles = null;
|
|
99
|
+
|
|
100
|
+
nodes.a ??= {
|
|
101
|
+
element,
|
|
102
|
+
measure() {
|
|
103
|
+
from = this.element.getBoundingClientRect();
|
|
104
|
+
},
|
|
105
|
+
apply() {
|
|
106
|
+
animation?.abort();
|
|
107
|
+
|
|
108
|
+
to = this.element.getBoundingClientRect();
|
|
109
|
+
|
|
110
|
+
if (
|
|
111
|
+
from.left !== to.left ||
|
|
112
|
+
from.right !== to.right ||
|
|
113
|
+
from.top !== to.top ||
|
|
114
|
+
from.bottom !== to.bottom
|
|
115
|
+
) {
|
|
116
|
+
const options = get_fn()(this.element, { from, to }, get_params?.());
|
|
117
|
+
|
|
118
|
+
animation = animate(this.element, options, undefined, 1, () => {
|
|
119
|
+
animation?.abort();
|
|
120
|
+
animation = undefined;
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
fix() {
|
|
125
|
+
// If an animation is already running, transforming the element is likely to fail,
|
|
126
|
+
// because the styles applied by the animation take precedence. In the case of crossfade,
|
|
127
|
+
// that means the `translate(...)` of the crossfade transition overrules the `translate(...)`
|
|
128
|
+
// we would apply below, leading to the element jumping somewhere to the top left.
|
|
129
|
+
if (element.getAnimations().length) return;
|
|
130
|
+
|
|
131
|
+
// It's important to destructure these to get fixed values - the object itself has getters,
|
|
132
|
+
// and changing the style to 'absolute' can for example influence the width.
|
|
133
|
+
var { position, width, height } = getComputedStyle(element);
|
|
134
|
+
|
|
135
|
+
if (position !== 'absolute' && position !== 'fixed') {
|
|
136
|
+
var style = /** @type {HTMLElement | SVGElement} */ (element).style;
|
|
137
|
+
|
|
138
|
+
original_styles = {
|
|
139
|
+
position: style.position,
|
|
140
|
+
width: style.width,
|
|
141
|
+
height: style.height,
|
|
142
|
+
transform: style.transform
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
style.position = 'absolute';
|
|
146
|
+
style.width = width;
|
|
147
|
+
style.height = height;
|
|
148
|
+
var to = element.getBoundingClientRect();
|
|
149
|
+
|
|
150
|
+
if (from.left !== to.left || from.top !== to.top) {
|
|
151
|
+
var transform = `translate(${from.left - to.left}px, ${from.top - to.top}px)`;
|
|
152
|
+
style.transform = style.transform ? `${style.transform} ${transform}` : transform;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
unfix() {
|
|
157
|
+
if (original_styles) {
|
|
158
|
+
var style = /** @type {HTMLElement | SVGElement} */ (element).style;
|
|
159
|
+
|
|
160
|
+
style.position = original_styles.position;
|
|
161
|
+
style.width = original_styles.width;
|
|
162
|
+
style.height = original_styles.height;
|
|
163
|
+
style.transform = original_styles.transform;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// in the case of a `<svelte:element>`, it's possible for `$.animation(...)` to be called
|
|
169
|
+
// when an animation manager already exists, if the tag changes. in that case, we need to
|
|
170
|
+
// swap out the element rather than creating a new manager, in case it happened at the same
|
|
171
|
+
// moment as a reconciliation
|
|
172
|
+
nodes.a.element = element;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Called inside block effects as `$.transition(...)`. This creates a transition manager and
|
|
177
|
+
* attaches it to the current effect — later, inside `pause_effect` and `resume_effect`, we
|
|
178
|
+
* use this to create `intro` and `outro` transitions.
|
|
179
|
+
* @template P
|
|
180
|
+
* @param {number} flags
|
|
181
|
+
* @param {HTMLElement} element
|
|
182
|
+
* @param {() => TransitionFn<P | undefined>} get_fn
|
|
183
|
+
* @param {(() => P) | null} get_params
|
|
184
|
+
* @returns {void}
|
|
185
|
+
*/
|
|
186
|
+
export function transition(flags, element, get_fn, get_params) {
|
|
187
|
+
var is_intro = (flags & TRANSITION_IN) !== 0;
|
|
188
|
+
var is_outro = (flags & TRANSITION_OUT) !== 0;
|
|
189
|
+
var is_both = is_intro && is_outro;
|
|
190
|
+
var is_global = (flags & TRANSITION_GLOBAL) !== 0;
|
|
191
|
+
|
|
192
|
+
/** @type {'in' | 'out' | 'both'} */
|
|
193
|
+
var direction = is_both ? 'both' : is_intro ? 'in' : 'out';
|
|
194
|
+
|
|
195
|
+
/** @type {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig) | undefined} */
|
|
196
|
+
var current_options;
|
|
197
|
+
|
|
198
|
+
var inert = element.inert;
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* The default overflow style, stashed so we can revert changes during the transition
|
|
202
|
+
* that are necessary to work around a Safari <18 bug
|
|
203
|
+
* TODO 6.0 remove this, if older versions of Safari have died out enough
|
|
204
|
+
*/
|
|
205
|
+
var overflow = element.style.overflow;
|
|
206
|
+
|
|
207
|
+
/** @type {Animation | undefined} */
|
|
208
|
+
var intro;
|
|
209
|
+
|
|
210
|
+
/** @type {Animation | undefined} */
|
|
211
|
+
var outro;
|
|
212
|
+
|
|
213
|
+
function get_options() {
|
|
214
|
+
return without_reactive_context(() => {
|
|
215
|
+
// If a transition is still ongoing, we use the existing options rather than generating
|
|
216
|
+
// new ones. This ensures that reversible transitions reverse smoothly, rather than
|
|
217
|
+
// jumping to a new spot because (for example) a different `duration` was used
|
|
218
|
+
return (current_options ??= get_fn()(element, get_params?.() ?? /** @type {P} */ ({}), {
|
|
219
|
+
direction
|
|
220
|
+
}));
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/** @type {TransitionManager} */
|
|
225
|
+
var transition = {
|
|
226
|
+
is_global,
|
|
227
|
+
in() {
|
|
228
|
+
element.inert = inert;
|
|
229
|
+
|
|
230
|
+
if (!is_intro) {
|
|
231
|
+
outro?.abort();
|
|
232
|
+
outro?.reset?.();
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
if (!is_outro) {
|
|
237
|
+
// if we intro then outro then intro again, we want to abort the first intro,
|
|
238
|
+
// if it's not a bidirectional transition
|
|
239
|
+
intro?.abort();
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
intro = animate(element, get_options(), outro, 1, () => {
|
|
243
|
+
dispatch_event(element, 'introend');
|
|
244
|
+
|
|
245
|
+
// Ensure we cancel the animation to prevent leaking
|
|
246
|
+
intro?.abort();
|
|
247
|
+
intro = current_options = undefined;
|
|
248
|
+
|
|
249
|
+
element.style.overflow = overflow;
|
|
250
|
+
});
|
|
251
|
+
},
|
|
252
|
+
out(fn) {
|
|
253
|
+
if (!is_outro) {
|
|
254
|
+
fn?.();
|
|
255
|
+
current_options = undefined;
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
element.inert = true;
|
|
260
|
+
|
|
261
|
+
outro = animate(element, get_options(), intro, 0, () => {
|
|
262
|
+
dispatch_event(element, 'outroend');
|
|
263
|
+
fn?.();
|
|
264
|
+
});
|
|
265
|
+
},
|
|
266
|
+
stop: () => {
|
|
267
|
+
intro?.abort();
|
|
268
|
+
outro?.abort();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
|
|
272
|
+
var e = /** @type {Effect & { nodes: EffectNodes }} */ (active_effect);
|
|
273
|
+
|
|
274
|
+
(e.nodes.t ??= []).push(transition);
|
|
275
|
+
|
|
276
|
+
// if this is a local transition, we only want to run it if the parent (branch) effect's
|
|
277
|
+
// parent (block) effect is where the state change happened. we can determine that by
|
|
278
|
+
// looking at whether the block effect is currently initializing
|
|
279
|
+
if (is_intro && should_intro) {
|
|
280
|
+
var run = is_global;
|
|
281
|
+
|
|
282
|
+
if (!run) {
|
|
283
|
+
var block = /** @type {Effect | null} */ (e.parent);
|
|
284
|
+
|
|
285
|
+
// skip over transparent blocks (e.g. snippets, else-if blocks)
|
|
286
|
+
while (block && (block.f & EFFECT_TRANSPARENT) !== 0) {
|
|
287
|
+
while ((block = block.parent)) {
|
|
288
|
+
if ((block.f & BLOCK_EFFECT) !== 0) break;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
run = !block || (block.f & REACTION_RAN) !== 0;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
if (run) {
|
|
296
|
+
effect(() => {
|
|
297
|
+
untrack(() => transition.in());
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Animates an element, according to the provided configuration
|
|
305
|
+
* @param {Element} element
|
|
306
|
+
* @param {AnimationConfig | ((opts: { direction: 'in' | 'out' }) => AnimationConfig)} options
|
|
307
|
+
* @param {Animation | undefined} counterpart The corresponding intro/outro to this outro/intro
|
|
308
|
+
* @param {number} t2 The target `t` value — `1` for intro, `0` for outro
|
|
309
|
+
* @param {(() => void)} on_finish Called after successfully completing the animation
|
|
310
|
+
* @returns {Animation}
|
|
311
|
+
*/
|
|
312
|
+
function animate(element, options, counterpart, t2, on_finish) {
|
|
313
|
+
var is_intro = t2 === 1;
|
|
314
|
+
|
|
315
|
+
if (is_function(options)) {
|
|
316
|
+
// In the case of a deferred transition (such as `crossfade`), `option` will be
|
|
317
|
+
// a function rather than an `AnimationConfig`. We need to call this function
|
|
318
|
+
// once the DOM has been updated...
|
|
319
|
+
/** @type {Animation} */
|
|
320
|
+
var a;
|
|
321
|
+
var aborted = false;
|
|
322
|
+
|
|
323
|
+
queue_micro_task(() => {
|
|
324
|
+
if (aborted) return;
|
|
325
|
+
var o = options({ direction: is_intro ? 'in' : 'out' });
|
|
326
|
+
a = animate(element, o, counterpart, t2, on_finish);
|
|
327
|
+
});
|
|
328
|
+
|
|
329
|
+
// ...but we want to do so without using `async`/`await` everywhere, so
|
|
330
|
+
// we return a facade that allows everything to remain synchronous
|
|
331
|
+
return {
|
|
332
|
+
abort: () => {
|
|
333
|
+
aborted = true;
|
|
334
|
+
a?.abort();
|
|
335
|
+
},
|
|
336
|
+
deactivate: () => a.deactivate(),
|
|
337
|
+
reset: () => a.reset(),
|
|
338
|
+
t: () => a.t()
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
counterpart?.deactivate();
|
|
343
|
+
|
|
344
|
+
if (!options?.duration && !options?.delay) {
|
|
345
|
+
dispatch_event(element, is_intro ? 'introstart' : 'outrostart');
|
|
346
|
+
on_finish();
|
|
347
|
+
|
|
348
|
+
return {
|
|
349
|
+
abort: noop,
|
|
350
|
+
deactivate: noop,
|
|
351
|
+
reset: noop,
|
|
352
|
+
t: () => t2
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const { delay = 0, css, tick, easing = linear } = options;
|
|
357
|
+
|
|
358
|
+
var keyframes = [];
|
|
359
|
+
|
|
360
|
+
if (is_intro && counterpart === undefined) {
|
|
361
|
+
if (tick) {
|
|
362
|
+
tick(0, 1); // TODO put in nested effect, to avoid interleaved reads/writes?
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
if (css) {
|
|
366
|
+
var styles = css_to_keyframe(css(0, 1));
|
|
367
|
+
keyframes.push(styles, styles);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
var get_t = () => 1 - t2;
|
|
372
|
+
|
|
373
|
+
// create a dummy animation that lasts as long as the delay (but with whatever devtools
|
|
374
|
+
// multiplier is in effect). in the common case that it is `0`, we keep it anyway so that
|
|
375
|
+
// the CSS keyframes aren't created until the DOM is updated
|
|
376
|
+
//
|
|
377
|
+
// fill forwards to prevent the element from rendering without styles applied
|
|
378
|
+
// see https://github.com/sveltejs/svelte/issues/14732
|
|
379
|
+
var animation = element.animate(keyframes, { duration: delay, fill: 'forwards' });
|
|
380
|
+
|
|
381
|
+
animation.onfinish = () => {
|
|
382
|
+
// remove dummy animation from the stack to prevent conflict with main animation
|
|
383
|
+
animation.cancel();
|
|
384
|
+
|
|
385
|
+
dispatch_event(element, is_intro ? 'introstart' : 'outrostart');
|
|
386
|
+
|
|
387
|
+
// for bidirectional transitions, we start from the current position,
|
|
388
|
+
// rather than doing a full intro/outro
|
|
389
|
+
var t1 = counterpart?.t() ?? 1 - t2;
|
|
390
|
+
counterpart?.abort();
|
|
391
|
+
|
|
392
|
+
var delta = t2 - t1;
|
|
393
|
+
var duration = /** @type {number} */ (options.duration) * Math.abs(delta);
|
|
394
|
+
var keyframes = [];
|
|
395
|
+
|
|
396
|
+
if (duration > 0) {
|
|
397
|
+
/**
|
|
398
|
+
* Whether or not the CSS includes `overflow: hidden`, in which case we need to
|
|
399
|
+
* add it as an inline style to work around a Safari <18 bug
|
|
400
|
+
* TODO 6.0 remove this, if possible
|
|
401
|
+
*/
|
|
402
|
+
var needs_overflow_hidden = false;
|
|
403
|
+
|
|
404
|
+
if (css) {
|
|
405
|
+
var n = Math.ceil(duration / (1000 / 60)); // `n` must be an integer, or we risk missing the `t2` value
|
|
406
|
+
|
|
407
|
+
for (var i = 0; i <= n; i += 1) {
|
|
408
|
+
var t = t1 + delta * easing(i / n);
|
|
409
|
+
var styles = css_to_keyframe(css(t, 1 - t));
|
|
410
|
+
keyframes.push(styles);
|
|
411
|
+
|
|
412
|
+
needs_overflow_hidden ||= styles.overflow === 'hidden';
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
if (needs_overflow_hidden) {
|
|
417
|
+
/** @type {HTMLElement} */ (element).style.overflow = 'hidden';
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
get_t = () => {
|
|
421
|
+
var time = /** @type {number} */ (
|
|
422
|
+
/** @type {globalThis.Animation} */ (animation).currentTime
|
|
423
|
+
);
|
|
424
|
+
|
|
425
|
+
return t1 + delta * easing(time / duration);
|
|
426
|
+
};
|
|
427
|
+
|
|
428
|
+
if (tick) {
|
|
429
|
+
loop(() => {
|
|
430
|
+
if (animation.playState !== 'running') return false;
|
|
431
|
+
|
|
432
|
+
var t = get_t();
|
|
433
|
+
tick(t, 1 - t);
|
|
434
|
+
|
|
435
|
+
return true;
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
animation = element.animate(keyframes, { duration, fill: 'forwards' });
|
|
441
|
+
|
|
442
|
+
animation.onfinish = () => {
|
|
443
|
+
get_t = () => t2;
|
|
444
|
+
tick?.(t2, 1 - t2);
|
|
445
|
+
on_finish();
|
|
446
|
+
};
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
return {
|
|
450
|
+
abort: () => {
|
|
451
|
+
if (animation) {
|
|
452
|
+
animation.cancel();
|
|
453
|
+
// This prevents memory leaks in Chromium
|
|
454
|
+
animation.effect = null;
|
|
455
|
+
// This prevents onfinish to be launched after cancel(),
|
|
456
|
+
// which can happen in some rare cases
|
|
457
|
+
// see https://github.com/sveltejs/svelte/issues/13681
|
|
458
|
+
animation.onfinish = noop;
|
|
459
|
+
}
|
|
460
|
+
},
|
|
461
|
+
deactivate: () => {
|
|
462
|
+
on_finish = noop;
|
|
463
|
+
},
|
|
464
|
+
reset: () => {
|
|
465
|
+
if (t2 === 0) {
|
|
466
|
+
tick?.(1, 0);
|
|
467
|
+
}
|
|
468
|
+
},
|
|
469
|
+
t: () => get_t()
|
|
470
|
+
};
|
|
471
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
/** @import { TemplateNode } from '#client' */
|
|
2
|
+
|
|
3
|
+
import { COMMENT_NODE } from '#client/constants';
|
|
4
|
+
import {
|
|
5
|
+
HYDRATION_END,
|
|
6
|
+
HYDRATION_ERROR,
|
|
7
|
+
HYDRATION_START,
|
|
8
|
+
HYDRATION_START_ELSE
|
|
9
|
+
} from '../../../constants.js';
|
|
10
|
+
import * as w from '../warnings.js';
|
|
11
|
+
import { get_next_sibling } from './operations.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Use this variable to guard everything related to hydration code so it can be treeshaken out
|
|
15
|
+
* if the user doesn't use the `hydrate` method and these code paths are therefore not needed.
|
|
16
|
+
*/
|
|
17
|
+
export let hydrating = false;
|
|
18
|
+
|
|
19
|
+
/** @param {boolean} value */
|
|
20
|
+
export function set_hydrating(value) {
|
|
21
|
+
hydrating = value;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The node that is currently being hydrated. This starts out as the first node inside the opening
|
|
26
|
+
* <!--[--> comment, and updates each time a component calls `$.child(...)` or `$.sibling(...)`.
|
|
27
|
+
* When entering a block (e.g. `{#if ...}`), `hydrate_node` is the block opening comment; by the
|
|
28
|
+
* time we leave the block it is the closing comment, which serves as the block's anchor.
|
|
29
|
+
* @type {TemplateNode}
|
|
30
|
+
*/
|
|
31
|
+
export let hydrate_node;
|
|
32
|
+
|
|
33
|
+
/** @param {TemplateNode | null} node */
|
|
34
|
+
export function set_hydrate_node(node) {
|
|
35
|
+
if (node === null) {
|
|
36
|
+
w.hydration_mismatch();
|
|
37
|
+
throw HYDRATION_ERROR;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return (hydrate_node = node);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function hydrate_next() {
|
|
44
|
+
return set_hydrate_node(get_next_sibling(hydrate_node));
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** @param {TemplateNode} node */
|
|
48
|
+
export function reset(node) {
|
|
49
|
+
if (!hydrating) return;
|
|
50
|
+
|
|
51
|
+
// If the node has remaining siblings, something has gone wrong
|
|
52
|
+
if (get_next_sibling(hydrate_node) !== null) {
|
|
53
|
+
w.hydration_mismatch();
|
|
54
|
+
throw HYDRATION_ERROR;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
hydrate_node = node;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @param {HTMLTemplateElement} template
|
|
62
|
+
*/
|
|
63
|
+
export function hydrate_template(template) {
|
|
64
|
+
if (hydrating) {
|
|
65
|
+
// @ts-expect-error TemplateNode doesn't include DocumentFragment, but it's actually fine
|
|
66
|
+
hydrate_node = template.content;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function next(count = 1) {
|
|
71
|
+
if (hydrating) {
|
|
72
|
+
var i = count;
|
|
73
|
+
var node = hydrate_node;
|
|
74
|
+
|
|
75
|
+
while (i--) {
|
|
76
|
+
node = /** @type {TemplateNode} */ (get_next_sibling(node));
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
hydrate_node = node;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Skips or removes (depending on {@link remove}) all nodes starting at `hydrate_node` up until the next hydration end comment
|
|
85
|
+
* @param {boolean} remove
|
|
86
|
+
*/
|
|
87
|
+
export function skip_nodes(remove = true) {
|
|
88
|
+
var depth = 0;
|
|
89
|
+
var node = hydrate_node;
|
|
90
|
+
|
|
91
|
+
while (true) {
|
|
92
|
+
if (node.nodeType === COMMENT_NODE) {
|
|
93
|
+
var data = /** @type {Comment} */ (node).data;
|
|
94
|
+
|
|
95
|
+
if (data === HYDRATION_END) {
|
|
96
|
+
if (depth === 0) return node;
|
|
97
|
+
depth -= 1;
|
|
98
|
+
} else if (
|
|
99
|
+
data === HYDRATION_START ||
|
|
100
|
+
data === HYDRATION_START_ELSE ||
|
|
101
|
+
// "[1", "[2", etc. for if blocks
|
|
102
|
+
(data[0] === '[' && !isNaN(Number(data.slice(1))))
|
|
103
|
+
) {
|
|
104
|
+
depth += 1;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
var next = /** @type {TemplateNode} */ (get_next_sibling(node));
|
|
109
|
+
if (remove) node.remove();
|
|
110
|
+
node = next;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
*
|
|
116
|
+
* @param {TemplateNode} node
|
|
117
|
+
*/
|
|
118
|
+
export function read_hydration_instruction(node) {
|
|
119
|
+
if (!node || node.nodeType !== COMMENT_NODE) {
|
|
120
|
+
w.hydration_mismatch();
|
|
121
|
+
throw HYDRATION_ERROR;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return /** @type {Comment} */ (node).data;
|
|
125
|
+
}
|