motion-start 0.1.20 → 0.1.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/components/AnimatePresence/AnimatePresence.svelte +221 -188
  2. package/dist/components/AnimatePresence/AnimatePresence.svelte.d.ts.map +1 -1
  3. package/dist/components/AnimatePresence/PresenceChild/PresenceChild.svelte +77 -63
  4. package/dist/components/AnimatePresence/PresenceChild/PresenceChild.svelte.d.ts.map +1 -1
  5. package/dist/components/AnimatePresence/PresenceChild/types.d.ts +1 -0
  6. package/dist/components/AnimatePresence/PresenceChild/types.d.ts.map +1 -1
  7. package/dist/components/AnimatePresence/use-presence.d.ts.map +1 -1
  8. package/dist/components/AnimatePresence/use-presence.js +15 -12
  9. package/dist/context/LayoutEpochContext.d.ts +9 -0
  10. package/dist/context/LayoutEpochContext.d.ts.map +1 -0
  11. package/dist/context/LayoutEpochContext.js +13 -0
  12. package/dist/context/PresenceContext.d.ts +1 -0
  13. package/dist/context/PresenceContext.d.ts.map +1 -1
  14. package/dist/motion/features/Exit.svelte +6 -10
  15. package/dist/motion/features/Exit.svelte.d.ts +19 -5
  16. package/dist/motion/features/Exit.svelte.d.ts.map +1 -1
  17. package/dist/motion/features/layout/Animate.svelte +2 -0
  18. package/dist/motion/features/layout/Animate.svelte.d.ts.map +1 -1
  19. package/dist/motion/features/layout/Measure.svelte +144 -100
  20. package/dist/motion/features/layout/Measure.svelte.d.ts.map +1 -1
  21. package/dist/motion/features/layout/MeasureContextProvider.svelte +14 -1
  22. package/dist/motion/features/layout/MeasureContextProvider.svelte.d.ts.map +1 -1
  23. package/dist/motion/utils/UseVisualElement.svelte +10 -6
  24. package/dist/motion/utils/UseVisualElement.svelte.d.ts.map +1 -1
  25. package/package.json +6 -12
@@ -1,188 +1,221 @@
1
- <!-- based on framer-motion@4.0.3,
2
- Copyright (c) 2018 Framer B.V. -->
3
-
4
- <script lang="ts" generics="T extends {key:any}">
5
- import type { ConditionalGeneric, AnimatePresenceProps } from "./index.js";
6
- import { getContext } from "svelte";
7
- import {
8
- SharedLayoutContext,
9
- isSharedLayout,
10
- } from "../../context/SharedLayoutContext.js";
11
- import PresenceChild from "./PresenceChild/PresenceChild.svelte";
12
- import type { Writable } from "svelte/store";
13
- import {
14
- type SharedLayoutSyncMethods,
15
- type SyncLayoutBatcher,
16
- } from "../AnimateSharedLayout/types.js";
17
-
18
- type $$Props = AnimatePresenceProps<ConditionalGeneric<T>>;
19
-
20
- export let list: $$Props["list"] = undefined,
21
- custom: $$Props["custom"] = undefined,
22
- initial: $$Props["initial"] = true,
23
- onExitComplete: $$Props["onExitComplete"] = undefined,
24
- exitBeforeEnter: $$Props["exitBeforeEnter"] = undefined,
25
- presenceAffectsLayout = true,
26
- show: $$Props["show"] = undefined,
27
- isCustom = false;
28
-
29
- let _list = list !== undefined ? list : show ? [{ key: 1 }] : [];
30
- $: _list = list !== undefined ? list : show ? [{ key: 1 }] : [];
31
-
32
- const layoutContext =
33
- getContext<Writable<SyncLayoutBatcher | SharedLayoutSyncMethods>>(
34
- SharedLayoutContext,
35
- ) || SharedLayoutContext(isCustom);
36
-
37
- $: forceRender = () => {
38
- if (isSharedLayout($layoutContext)) {
39
- $layoutContext.forceUpdate();
40
- }
41
- _list = [..._list];
42
- };
43
-
44
- function getChildKey(child: { key: number }) {
45
- return child.key || "";
46
- }
47
-
48
- let isInitialRender = true;
49
- let filteredChildren = _list;
50
- $: filteredChildren = _list;
51
-
52
- let presentChildren = filteredChildren;
53
- let allChildren = new Map<string | number, { key: number }>();
54
- let exiting = new Set<"" | number>();
55
- const updateChildLookup = (
56
- children: { key: number }[],
57
- allChild: Map<string | number, { key: number }>,
58
- ) => {
59
- children.forEach((child) => {
60
- const key = getChildKey(child);
61
- allChild.set(key, child);
62
- });
63
- };
64
- $: updateChildLookup(filteredChildren, allChildren);
65
-
66
- let childrenToRender: {
67
- present: boolean;
68
- item: any;
69
- key: any;
70
- onExit: undefined | (() => void);
71
- }[] = [
72
- ...filteredChildren.map((v) => ({
73
- present: true,
74
- item: v,
75
- key: v.key,
76
- onExit: undefined,
77
- })),
78
- ];
79
-
80
- $: if (!isInitialRender) {
81
- // If this is a subsequent render, deal with entering and exiting children
82
- childrenToRender = [
83
- ...filteredChildren.map((v) => ({
84
- present: true,
85
- item: v,
86
- key: v.key,
87
- onExit: undefined,
88
- })),
89
- ];
90
-
91
- // Diff the keys of the currently-present and target children to update our
92
- // exiting list.
93
- const presentKeys = presentChildren.map(getChildKey);
94
- const targetKeys = filteredChildren.map(getChildKey);
95
- // Diff the present children with our target children and mark those that are exiting
96
- const numPresent = presentKeys.length;
97
- for (let i = 0; i < numPresent; i++) {
98
- const key = presentKeys[i];
99
- if (targetKeys.indexOf(key) === -1) {
100
- exiting.add(key);
101
- } else {
102
- // In case this key has re-entered, remove from the exiting list
103
- exiting.delete(key);
104
- }
105
- }
106
-
107
- // If we currently have exiting children, and we're deferring rendering incoming children
108
- // until after all current children have exiting, empty the childrenToRender array
109
- if (exitBeforeEnter && exiting.size) {
110
- childrenToRender = [];
111
- }
112
- // Loop through all currently exiting components and clone them to overwrite `animate`
113
- // with any `exit` prop they might have defined.
114
- exiting.forEach((key) => {
115
- // If this component is actually entering again, early return
116
- if (targetKeys.indexOf(key) !== -1) return;
117
-
118
- const child = allChildren.get(key);
119
- if (!child) return;
120
-
121
- const insertionIndex = presentKeys.indexOf(key);
122
-
123
- const onExit = () => {
124
- allChildren.delete(key);
125
- exiting.delete(key);
126
-
127
- // Remove this child from the present children
128
- const removeIndex = presentChildren.findIndex(
129
- (presentChild) => presentChild.key === key,
130
- );
131
-
132
- if (removeIndex < 0) {
133
- return;
134
- }
135
- presentChildren.splice(removeIndex, 1);
136
-
137
- // Defer re-rendering until all exiting children have indeed left
138
- if (!exiting.size) {
139
- presentChildren = [...filteredChildren];
140
- forceRender();
141
- onExitComplete && onExitComplete();
142
- }
143
- };
144
-
145
- childrenToRender.splice(insertionIndex, 0, {
146
- present: false,
147
- item: child,
148
- key: getChildKey(child),
149
- onExit,
150
- });
151
- });
152
- // Add `MotionContext` even to children that don't need it to ensure we're rendering
153
- // the same tree between renders
154
-
155
- /*
156
- childrenToRender = childrenToRender.map((child) => {
157
- const key = child.key as string | number;
158
- return exiting.has(key) ? (
159
- child
160
- ) : (
161
- <PresenceChild
162
- key={getChildKey(child)}
163
- isPresent
164
- presenceAffectsLayout={presenceAffectsLayout}
165
- >
166
- {child}
167
- </PresenceChild>
168
- );
169
- });
170
- */
171
- presentChildren = childrenToRender;
172
- } else {
173
- isInitialRender = false;
174
- }
175
- </script>
176
-
177
- {#each childrenToRender as child (getChildKey(child))}
178
- <PresenceChild
179
- isPresent={child.present}
180
- initial={initial ? undefined : false}
181
- custom={child.onExit ? custom : undefined}
182
- {presenceAffectsLayout}
183
- onExitComplete={child.onExit}
184
- {isCustom}
185
- >
186
- <slot item={child.item} />
187
- </PresenceChild>
188
- {/each}
1
+ <!-- based on framer-motion@4.0.3,
2
+ Copyright (c) 2018 Framer B.V. -->
3
+
4
+ <script lang="ts" generics="T extends {key:any}">
5
+ import type { ConditionalGeneric, AnimatePresenceProps } from "./index.js";
6
+ import { getContext, setContext, tick } from "svelte";
7
+ import {
8
+ SharedLayoutContext,
9
+ isSharedLayout,
10
+ } from "../../context/SharedLayoutContext.js";
11
+ import PresenceChild from "./PresenceChild/PresenceChild.svelte";
12
+ import type { Writable } from "svelte/store";
13
+ import {
14
+ type SharedLayoutSyncMethods,
15
+ type SyncLayoutBatcher,
16
+ } from "../AnimateSharedLayout/types.js";
17
+ import {
18
+ LayoutEpochContext,
19
+ createLayoutEpoch,
20
+ type LayoutEpoch,
21
+ } from "../../context/LayoutEpochContext.js";
22
+
23
+ type $$Props = AnimatePresenceProps<ConditionalGeneric<T>>;
24
+
25
+ export let list: $$Props["list"] = undefined,
26
+ custom: $$Props["custom"] = undefined,
27
+ initial: $$Props["initial"] = true,
28
+ onExitComplete: $$Props["onExitComplete"] = undefined,
29
+ exitBeforeEnter: $$Props["exitBeforeEnter"] = undefined,
30
+ presenceAffectsLayout = true,
31
+ show: $$Props["show"] = undefined,
32
+ isCustom = false;
33
+
34
+ let _list = list !== undefined ? list : show ? [{ key: 1 }] : [];
35
+ $: _list = list !== undefined ? list : show ? [{ key: 1 }] : [];
36
+
37
+ const layoutContext =
38
+ getContext<Writable<SyncLayoutBatcher | SharedLayoutSyncMethods>>(
39
+ SharedLayoutContext,
40
+ ) || SharedLayoutContext(isCustom);
41
+
42
+ // Single epoch store. Measure subscribes to it for synchronous snapshots
43
+ // (store.update fires subscribers before DOM changes) and MeasureContextProvider
44
+ // reads it reactively to trigger afterU → syncLayout.flush() after DOM settles.
45
+ const layoutEpoch = createLayoutEpoch();
46
+ setContext(LayoutEpochContext, layoutEpoch);
47
+
48
+ // Snapshot sibling positions (snapshot=true) and notify shared layout before
49
+ // a DOM change so Measure can FLIP elements to their new spots.
50
+ // Called by forceRender (post-exit) and by the addition path in the reactive
51
+ // block below — both cases need the same snapshot + shared-layout notification.
52
+ function snapshotLayout() {
53
+ if (presenceAffectsLayout) {
54
+ layoutEpoch.update((v) => ({ n: v.n + 1, snapshot: true }));
55
+ }
56
+ if (isSharedLayout($layoutContext)) {
57
+ $layoutContext.forceUpdate();
58
+ }
59
+ }
60
+
61
+ $: forceRender = () => {
62
+ snapshotLayout();
63
+ _list = [..._list];
64
+ };
65
+
66
+ function getChildKey(child: { key: number }) {
67
+ return child.key || "";
68
+ }
69
+
70
+ let isInitialRender = true;
71
+ let filteredChildren = _list;
72
+ $: filteredChildren = _list;
73
+
74
+ let presentChildren = filteredChildren;
75
+ let allChildren = new Map<string | number, { key: number }>();
76
+ let exiting = new Set<"" | number>();
77
+ const updateChildLookup = (
78
+ children: { key: number }[],
79
+ allChild: Map<string | number, { key: number }>,
80
+ ) => {
81
+ children.forEach((child) => {
82
+ const key = getChildKey(child);
83
+ allChild.set(key, child);
84
+ });
85
+ };
86
+ $: updateChildLookup(filteredChildren, allChildren);
87
+
88
+ let childrenToRender: {
89
+ present: boolean;
90
+ item: any;
91
+ key: any;
92
+ onExit: undefined | (() => void);
93
+ }[] = [
94
+ ...filteredChildren.map((v) => ({
95
+ present: true,
96
+ item: v,
97
+ key: v.key,
98
+ onExit: undefined,
99
+ })),
100
+ ];
101
+
102
+ $: if (!isInitialRender) {
103
+ const presentKeys = presentChildren.map(getChildKey);
104
+ const targetKeys = filteredChildren.map(getChildKey);
105
+
106
+ const hasRemovals = presentKeys.some(
107
+ (k) => targetKeys.indexOf(k) === -1,
108
+ );
109
+ const hasAdditions = targetKeys.some(
110
+ (k) => presentKeys.indexOf(k) === -1,
111
+ );
112
+
113
+ if (hasRemovals) {
114
+ // Flush-only epoch (snapshot=false): drives animateF → safeToRemove for the
115
+ // exiting layout element (id2 registration). Deferred by one tick so that
116
+ // PresenceChild's $effect (Svelte 5) has fired, updating PresenceContext and
117
+ // therefore visualElement.isPresent before Measure.svelte's epoch handler
118
+ // checks !visualElement.isPresent. Siblings are skipped here; forceRender
119
+ // fires snapshotLayout() after the exit completes so they FLIP.
120
+ tick().then(() =>
121
+ layoutEpoch.update((v) => ({ n: v.n + 1, snapshot: false })),
122
+ );
123
+ } else if (hasAdditions) {
124
+ // Snapshot sibling positions before the DOM update (same logic as
125
+ // forceRender) so they FLIP to their new positions after the incoming
126
+ // element shifts them. presenceAffectsLayout and shared-layout notify
127
+ // are handled inside snapshotLayout().
128
+ snapshotLayout();
129
+ }
130
+ // No epoch when hasRemovals=false && hasAdditions=false: this is a
131
+ // forceRender-triggered re-run (no real diff). forceRender already fired
132
+ // snapshotLayout() before _list=[..._list], so we must not fire again.
133
+
134
+ // If this is a subsequent render, deal with entering and exiting children
135
+ childrenToRender = [
136
+ ...filteredChildren.map((v) => ({
137
+ present: true,
138
+ item: v,
139
+ key: v.key,
140
+ onExit: undefined,
141
+ })),
142
+ ];
143
+
144
+ // Diff the present children with our target children and mark those that are exiting
145
+ const numPresent = presentKeys.length;
146
+ for (let i = 0; i < numPresent; i++) {
147
+ const key = presentKeys[i];
148
+ if (targetKeys.indexOf(key) === -1) {
149
+ exiting.add(key);
150
+ } else {
151
+ // In case this key has re-entered, remove from the exiting list
152
+ exiting.delete(key);
153
+ }
154
+ }
155
+
156
+ // If we currently have exiting children, and we're deferring rendering incoming children
157
+ // until after all current children have exiting, empty the childrenToRender array
158
+ if (exitBeforeEnter && exiting.size) {
159
+ childrenToRender = [];
160
+ }
161
+ // Loop through all currently exiting components and clone them to overwrite animate
162
+ // with any exit prop they might have defined.
163
+ exiting.forEach((key) => {
164
+ // If this component is actually entering again, early return
165
+ if (targetKeys.indexOf(key) !== -1) return;
166
+
167
+ const child = allChildren.get(key);
168
+ if (!child) return;
169
+
170
+ const insertionIndex = presentKeys.indexOf(key);
171
+
172
+ const onExit = () => {
173
+ allChildren.delete(key);
174
+ exiting.delete(key);
175
+
176
+ // Remove this child from the present children
177
+ const removeIndex = presentChildren.findIndex(
178
+ (presentChild) => presentChild.key === key,
179
+ );
180
+
181
+ if (removeIndex < 0) {
182
+ return;
183
+ }
184
+ presentChildren.splice(removeIndex, 1);
185
+
186
+ // Defer re-rendering until all exiting children have indeed left
187
+ if (!exiting.size) {
188
+ presentChildren = [...filteredChildren];
189
+ forceRender();
190
+ onExitComplete && onExitComplete();
191
+ }
192
+ };
193
+
194
+ childrenToRender.splice(insertionIndex, 0, {
195
+ present: false,
196
+ item: child,
197
+ key: getChildKey(child),
198
+ onExit,
199
+ });
200
+ });
201
+ presentChildren = childrenToRender;
202
+ // framermotion doesn't pass initial after initial render, but we want to be able to trigger it on new children
203
+ initial = true;
204
+ } else {
205
+ isInitialRender = false;
206
+ }
207
+ </script>
208
+
209
+ {#each childrenToRender as child (getChildKey(child))}
210
+ <PresenceChild
211
+ isPresent={child.present}
212
+ initial={initial ? undefined : false}
213
+ custom={child.onExit ? custom : undefined}
214
+ {presenceAffectsLayout}
215
+ onExitComplete={child.onExit}
216
+ {isCustom}
217
+ presenceKey={child.key}
218
+ >
219
+ <slot item={child.item} />
220
+ </PresenceChild>
221
+ {/each}
@@ -1 +1 @@
1
- {"version":3,"file":"AnimatePresence.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/components/AnimatePresence/AnimatePresence.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AA8L3E,cAAM,iBAAiB,CAAC,CAAC,SAAS;IAAC,GAAG,EAAC,GAAG,CAAA;CAAC;IACvC,KAAK;IAGL,MAAM;;;IAGN,KAAK;;;;;IAGL,QAAQ;IACR,OAAO;CACV;AAED,UAAU,qBAAqB;IAC3B,KAAK,CAAC,SAAS;QAAC,GAAG,EAAC,GAAG,CAAA;KAAC,EAAE,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAE;QAAC,QAAQ,CAAC,EAAE,GAAG,CAAA;KAAC,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAA;KAAE,GAAG,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;IACha,CAAC,CAAC,SAAS;QAAC,GAAG,EAAC,GAAG,CAAA;KAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,GAAG;QAA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  <script lang="ts" module>
6
- let presenceId = 0;
7
- function getPresenceId() {
8
- const id = presenceId;
9
- presenceId++;
10
- return id;
11
- }
12
- function newChildrenMap(): Map<number, boolean> {
13
- return new Map<number, boolean>();
14
- }
6
+ let presenceId = 0;
7
+ function getPresenceId() {
8
+ const id = presenceId;
9
+ presenceId++;
10
+ return id;
11
+ }
12
+ function newChildrenMap(): Map<number, boolean> {
13
+ return new Map<number, boolean>();
14
+ }
15
15
  </script>
16
16
 
17
17
  <script lang="ts">
18
- import { setContext, tick } from "svelte";
19
- import { setDomContext } from "../../../context/DOMcontext.js";
20
- import { PresenceContext } from "../../../context/PresenceContext.js";
21
- import type { PresenceChildProps } from "./index.js";
18
+ import { setContext, tick, untrack } from "svelte";
19
+ import { setDomContext } from "../../../context/DOMcontext.js";
20
+ import { PresenceContext } from "../../../context/PresenceContext.js";
21
+ import type { PresenceChildProps } from "./index.js";
22
22
 
23
- interface Props extends PresenceChildProps {}
23
+ interface Props extends PresenceChildProps {}
24
24
 
25
- let {
26
- isPresent,
27
- onExitComplete = undefined,
28
- initial = undefined,
29
- custom = undefined,
30
- presenceAffectsLayout,
31
- isCustom,
32
- children,
33
- }: Props = $props();
25
+ let {
26
+ isPresent,
27
+ onExitComplete = undefined,
28
+ initial = undefined,
29
+ custom = undefined,
30
+ presenceAffectsLayout,
31
+ isCustom,
32
+ children,
33
+ presenceKey = undefined,
34
+ }: Props = $props();
34
35
 
35
- const presenceChildren = newChildrenMap();
36
- const id = getPresenceId();
36
+ const presenceChildren = newChildrenMap();
37
+ const id = getPresenceId();
37
38
 
38
- const refresh = $derived(presenceAffectsLayout ? undefined : isPresent);
39
+ const refresh = $derived(presenceAffectsLayout ? undefined : isPresent);
39
40
 
40
- const memoContext = (flag?: boolean) => {
41
- return {
42
- id,
43
- initial,
44
- isPresent,
45
- custom,
46
- onExitComplete: (childId: number) => {
47
- presenceChildren.set(childId, true);
48
- let allComplete = true;
49
- presenceChildren.forEach((isComplete) => {
50
- if (!isComplete) allComplete = false;
51
- });
41
+ const memoContext = (flag?: boolean) => {
42
+ return {
43
+ id,
44
+ presenceKey,
45
+ initial,
46
+ isPresent,
47
+ custom,
48
+ onExitComplete: (childId: number) => {
49
+ if (!presenceChildren.has(childId)) return;
50
+ if (presenceChildren.get(childId) === true) return;
51
+ presenceChildren.set(childId, true);
52
+ let allComplete = true;
53
+ presenceChildren.forEach((isComplete) => {
54
+ if (!isComplete) allComplete = false;
55
+ });
52
56
 
53
- allComplete && onExitComplete?.();
54
- },
55
- register: (childId: number) => {
56
- presenceChildren.set(childId, false);
57
- return () => presenceChildren.delete(childId);
58
- },
59
- };
57
+ allComplete && onExitComplete?.();
58
+ },
59
+ register: (childId: number) => {
60
+ presenceChildren.set(childId, false);
61
+ return () => presenceChildren.delete(childId);
62
+ },
60
63
  };
61
- let context = PresenceContext();
62
-
63
- $effect(() => {
64
- if (presenceAffectsLayout) {
65
- context.set(memoContext());
66
- }
67
- });
64
+ };
65
+ let context = PresenceContext();
66
+ // Set synchronously so children's usePresence() sees a non-null value via get()
67
+ context.set(memoContext());
68
68
 
69
- $effect(() => context.set(memoContext(refresh)));
69
+ // Update context when relevant props change
70
+ $effect(() => {
71
+ if (presenceAffectsLayout) {
72
+ // Track all relevant props
73
+ isPresent;
74
+ initial;
75
+ custom;
76
+ // But set context without tracking to avoid loops
77
+ untrack(() => context.set(memoContext()));
78
+ } else {
79
+ // When presenceAffectsLayout is false, only track isPresent via refresh
80
+ refresh;
81
+ untrack(() => context.set(memoContext()));
82
+ }
83
+ });
70
84
 
71
- const keyset = (flag?: boolean) => {
72
- presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
73
- };
74
- $effect(() => {
75
- keyset(isPresent);
76
- tick().then(() => {
77
- !isPresent && !presenceChildren.size && onExitComplete?.();
78
- });
85
+ const keyset = (flag?: boolean) => {
86
+ presenceChildren.forEach((_, key) => presenceChildren.set(key, false));
87
+ };
88
+ $effect(() => {
89
+ keyset(isPresent);
90
+ tick().then(() => {
91
+ !isPresent && !presenceChildren.size && onExitComplete?.();
79
92
  });
80
- setContext(PresenceContext, context);
81
- setDomContext("Presence", isCustom, context);
93
+ });
94
+ setContext(PresenceContext, context);
95
+ setDomContext("Presence", isCustom, context);
82
96
  </script>
83
97
 
84
98
  {@render children?.()}
@@ -1 +1 @@
1
- {"version":3,"file":"PresenceChild.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/components/AnimatePresence/PresenceChild/PresenceChild.svelte.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGjD,UAAU,KAAM,SAAQ,kBAAkB;CAAG;AA4EjD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
1
+ {"version":3,"file":"PresenceChild.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/components/AnimatePresence/PresenceChild/PresenceChild.svelte.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAGnD,UAAU,KAAM,SAAQ,kBAAkB;CAAG;AA0F/C,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
@@ -8,5 +8,6 @@ export interface PresenceChildProps {
8
8
  custom?: any;
9
9
  presenceAffectsLayout: boolean;
10
10
  isCustom: boolean;
11
+ presenceKey?: any;
11
12
  }
12
13
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/components/AnimatePresence/PresenceChild/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;CAClB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/components/AnimatePresence/PresenceChild/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,MAAM,WAAW,kBAAkB;IAClC,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,qBAAqB,EAAE,OAAO,CAAC;IAC/B,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,GAAG,CAAC;CAClB"}
@@ -1 +1 @@
1
- {"version":3,"file":"use-presence.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/components/AnimatePresence/use-presence.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAO1E,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC;AACtC,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAK/C,wBAAgB,SAAS,CAAC,OAAO,EAAE,oBAAoB,WAEtD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GAAI,kBAAgB,KAAG,QAAQ,CAAC,OAAO,CAG/D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,kBAAgB,KAAG,QAAQ,CAAC,aAAa,GAAG,OAAO,GAAG,UAAU,CAkB3F,CAAA"}
1
+ {"version":3,"file":"use-presence.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/components/AnimatePresence/use-presence.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,OAAO,KAAK,EAAE,QAAQ,EAAY,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAO1E,MAAM,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC;AACtC,MAAM,MAAM,aAAa,GAAG,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;AACzC,MAAM,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;AAC7B,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;AAK/C,wBAAgB,SAAS,CAAC,OAAO,EAAE,oBAAoB,WAEtD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,YAAY,GAAI,kBAAgB,KAAG,QAAQ,CAAC,OAAO,CAG/D,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,GAAI,kBAAgB,KAAG,QAAQ,CAAC,aAAa,GAAG,OAAO,GAAG,UAAU,CAmB3F,CAAA"}
@@ -1,6 +1,6 @@
1
1
  import { derived, get, readable } from 'svelte/store';
2
2
  import { PresenceContext } from '../../context/PresenceContext.js';
3
- import { getContext, onMount } from "svelte";
3
+ import { getContext, onDestroy } from "svelte";
4
4
  let counter = 0;
5
5
  const incrementId = () => counter++;
6
6
  export function isPresent(context) {
@@ -54,16 +54,19 @@ export const useIsPresent = (isCustom = false) => {
54
54
  */
55
55
  export const usePresence = (isCustom = false) => {
56
56
  const context = getContext(PresenceContext) || PresenceContext(isCustom);
57
- const id = get(context) === null ? undefined : incrementId();
58
- onMount(() => {
59
- if (get(context) !== null) {
60
- get(context).register(id);
61
- }
62
- });
63
- if (get(context) === null) {
57
+ const contextValue = get(context);
58
+ // PresenceChild sets context synchronously before children initialize,
59
+ // so get() always returns the real value here — no subscription needed.
60
+ if (contextValue === null)
64
61
  return readable([true, null]);
65
- }
66
- return derived(context, $v => (!$v.isPresent && $v.onExitComplete) ?
67
- [false, () => $v.onExitComplete?.(id)] :
68
- [true]);
62
+ const id = incrementId();
63
+ const unregister = contextValue.register(id);
64
+ onDestroy(unregister);
65
+ return derived(context, $v => {
66
+ if ($v === null)
67
+ return [true, null];
68
+ return (!$v.isPresent && $v.onExitComplete) ?
69
+ [false, () => $v.onExitComplete?.(id)] :
70
+ [true];
71
+ });
69
72
  };
@@ -0,0 +1,9 @@
1
+ export type LayoutEpoch = {
2
+ n: number;
3
+ snapshot: boolean;
4
+ };
5
+ /** Used as the setContext / getContext key. */
6
+ export declare const LayoutEpochContext: unique symbol;
7
+ /** Factory — call once per AnimatePresence instance and set in context. */
8
+ export declare const createLayoutEpoch: () => import("svelte/store").Writable<LayoutEpoch>;
9
+ //# sourceMappingURL=LayoutEpochContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LayoutEpochContext.d.ts","sourceRoot":"","sources":["../../src/lib/motion-start/context/LayoutEpochContext.ts"],"names":[],"mappings":"AAUA,MAAM,MAAM,WAAW,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAAC;AAE3D,+CAA+C;AAC/C,eAAO,MAAM,kBAAkB,eAA+B,CAAC;AAE/D,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,oDAAyD,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Epoch store that AnimatePresence increments whenever its rendered children
3
+ * change. Measure.svelte subscribes synchronously to snapshot positions and
4
+ * MeasureContextProvider reads it reactively to trigger afterU → flush.
5
+ *
6
+ * `snapshot: true` — take a FLIP snapshot AND flush (presenceAffectsLayout=true)
7
+ * `snapshot: false` — flush only for exiting elements, no sibling snapshot
8
+ */
9
+ import { writable } from 'svelte/store';
10
+ /** Used as the setContext / getContext key. */
11
+ export const LayoutEpochContext = Symbol('LayoutEpochContext');
12
+ /** Factory — call once per AnimatePresence instance and set in context. */
13
+ export const createLayoutEpoch = () => writable({ n: 0, snapshot: false });
@@ -9,6 +9,7 @@ import type { Writable } from 'svelte/store';
9
9
  */
10
10
  export interface PresenceContextProps {
11
11
  id: number;
12
+ presenceKey?: any;
12
13
  isPresent: boolean;
13
14
  register: (id: number) => () => void;
14
15
  onExitComplete?: (id: number) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"PresenceContext.d.ts","sourceRoot":"","sources":["../../src/lib/motion-start/context/PresenceContext.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;CAChB;AAMD;;GAEG;AAEH,eAAO,MAAM,eAAe,GAAI,IAAI,GAAG,KAAG,QAAQ,CAAC,oBAAoB,GAAG,IAAI,CAAmD,CAAC"}
1
+ {"version":3,"file":"PresenceContext.d.ts","sourceRoot":"","sources":["../../src/lib/motion-start/context/PresenceContext.ts"],"names":[],"mappings":"AAAA;;;EAGE;AACF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AACrD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AAC5C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,IAAI,CAAC;IACrC,cAAc,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,OAAO,CAAC,EAAE,KAAK,GAAG,aAAa,CAAC;IAChC,MAAM,CAAC,EAAE,GAAG,CAAC;CAChB;AAMD;;GAEG;AAEH,eAAO,MAAM,eAAe,GAAI,IAAI,GAAG,KAAG,QAAQ,CAAC,oBAAoB,GAAG,IAAI,CAAmD,CAAC"}
@@ -1,6 +1,5 @@
1
1
  <!-- based on framer-motion@4.0.3,
2
2
  Copyright (c) 2018 Framer B.V. -->
3
- <svelte:options runes />
4
3
 
5
4
  <script lang="ts">
6
5
  import { getContext } from "svelte";
@@ -17,14 +16,13 @@ Copyright (c) 2018 Framer B.V. -->
17
16
  import { AnimationType } from "../../render/utils/types.js";
18
17
  import type { Writable } from "svelte/store";
19
18
 
20
- let { props, visualElement, isCustom, children } = $props();
21
- const { custom } = $derived(props);
19
+ export let props: any, visualElement: any, isCustom: boolean;
20
+ $: custom = props?.custom;
22
21
 
23
- const presenceContext = $derived(
22
+ const presenceContext =
24
23
  getContext<Writable<PresenceContextProps>>(PresenceContext) ||
25
- PresenceContext(isCustom),
26
- );
27
- const presence = $derived(usePresence(isCustom));
24
+ PresenceContext(isCustom);
25
+ const presence = usePresence(isCustom);
28
26
 
29
27
  const _effect = (pres: AlwaysPresent | Present | NotPresent) => {
30
28
  const [isPresent, onExitComplete] = pres;
@@ -37,7 +35,5 @@ Copyright (c) 2018 Framer B.V. -->
37
35
 
38
36
  !isPresent && animation?.then(onExitComplete);
39
37
  };
40
- $effect(() => _effect($presence));
38
+ $: _effect($presence);
41
39
  </script>
42
-
43
- {@render children?.()}
@@ -1,9 +1,23 @@
1
- declare const Exit: import("svelte").Component<{
1
+ interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
2
+ new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
3
+ $$bindings?: Bindings;
4
+ } & Exports;
5
+ (internal: unknown, props: Props & {
6
+ $$events?: Events;
7
+ $$slots?: Slots;
8
+ }): Exports & {
9
+ $set?: any;
10
+ $on?: any;
11
+ };
12
+ z_$$bindings?: Bindings;
13
+ }
14
+ declare const Exit: $$__sveltets_2_IsomorphicComponent<{
2
15
  props: any;
3
16
  visualElement: any;
4
- isCustom: any;
5
- children: any;
6
- }, {}, "">;
7
- type Exit = ReturnType<typeof Exit>;
17
+ isCustom: boolean;
18
+ }, {
19
+ [evt: string]: CustomEvent<any>;
20
+ }, {}, {}, string>;
21
+ type Exit = InstanceType<typeof Exit>;
8
22
  export default Exit;
9
23
  //# sourceMappingURL=Exit.svelte.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Exit.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/motion/features/Exit.svelte.ts"],"names":[],"mappings":"AAsDA,QAAA,MAAM,IAAI;WAhC4C,GAAG;mBAAiB,GAAG;cAAY,GAAG;cAAY,GAAG;UAgCzD,CAAC;AACnD,KAAK,IAAI,GAAG,UAAU,CAAC,OAAO,IAAI,CAAC,CAAC;AACpC,eAAe,IAAI,CAAC"}
1
+ {"version":3,"file":"Exit.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/motion/features/Exit.svelte.ts"],"names":[],"mappings":"AAkDA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,IAAI;WAVoF,GAAG;mBAAiB,GAAG;cAAY,OAAO;;;kBAU/C,CAAC;AACxE,KAAK,IAAI,GAAG,YAAY,CAAC,OAAO,IAAI,CAAC,CAAC;AACxC,eAAe,IAAI,CAAC"}
@@ -306,7 +306,9 @@ Copyright (c) 2018 Framer B.V. -->
306
306
 
307
307
  addScaleCorrection(defaultScaleCorrectors);
308
308
 
309
+ // The returned function runs when the component is unmounted
309
310
  return () => {
311
+ // this should be onmount cleanup function that gets run sync on component unmount
310
312
  unsubLayoutReady();
311
313
  eachAxis((axis) => stopAxisAnimation[axis]?.());
312
314
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Animate.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/motion/features/layout/Animate.svelte.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAwS9D,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,OAAO;mBAVmG,aAAa;;;;;kBAUjC,CAAC;AAC3E,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAC9C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Animate.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/motion/features/layout/Animate.svelte.ts"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AA0S9D,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,OAAO;mBAVmG,aAAa;;;;;kBAUjC,CAAC;AAC3E,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAC9C,eAAe,OAAO,CAAC"}
@@ -1,100 +1,144 @@
1
- <!-- based on framer-motion@4.1.16,
2
- Copyright (c) 2018 Framer B.V. -->
3
-
4
- <script lang="ts">
5
- import { afterUpdate, beforeUpdate, getContext, onMount } from "svelte";
6
- import { get, type Writable } from "svelte/store";
7
- import {
8
- ScaleCorrectionContext,
9
- ScaleCorrectionParentContext,
10
- } from "../../../context/ScaleCorrectionProvider.svelte";
11
- import { isSharedLayout } from "../../../context/SharedLayoutContext.js";
12
- import { snapshotViewportBox } from "../../../render/dom/projection/utils.js";
13
-
14
- export let visualElement, syncLayout, framerSyncLayout, update;
15
-
16
- const scaleCorrectionContext = getContext<Writable<any[]>>(
17
- ScaleCorrectionContext,
18
- );
19
- const scaleCorrectionParentContext = getContext<Writable<any[]>>(
20
- ScaleCorrectionParentContext,
21
- );
22
-
23
- onMount(() => {
24
- isSharedLayout(syncLayout) && syncLayout.register(visualElement);
25
- isSharedLayout(framerSyncLayout) &&
26
- framerSyncLayout.register(visualElement);
27
-
28
- visualElement.onUnmount(() => {
29
- if (isSharedLayout(syncLayout)) {
30
- syncLayout.remove(visualElement);
31
- }
32
-
33
- if (isSharedLayout(framerSyncLayout)) {
34
- framerSyncLayout.remove(visualElement);
35
- }
36
- });
37
- });
38
- /**
39
- * If this is a child of a SyncContext, notify it that it needs to re-render. It will then
40
- * handle the snapshotting.
41
- *
42
- * If it is stand-alone component, add it to the batcher.
43
- */
44
-
45
- let updated = false;
46
- const updater = (nc = false) => {
47
- if (updated) {
48
- return null;
49
- }
50
- updated = true;
51
-
52
- // in React the updater function is called on children first, in Svelte the child does not call it.
53
- get(scaleCorrectionContext).forEach((v) => {
54
- v.updater?.(true);
55
- });
56
-
57
- if (isSharedLayout(syncLayout)) {
58
- syncLayout.syncUpdate();
59
- } else {
60
- snapshotViewportBox(visualElement, nc);
61
- syncLayout.add(visualElement);
62
- }
63
-
64
- return null;
65
- };
66
-
67
- $: update !== undefined && updater(update);
68
-
69
- if (update === undefined) {
70
- beforeUpdate(updater);
71
- }
72
- const afterU = (nc = false) => {
73
- updated = false;
74
- /* Second part of the updater calling in child layouts first.*/
75
- const scc = get(scaleCorrectionContext);
76
-
77
- scc.forEach((v: any, i) => {
78
- v.afterU?.(true);
79
- });
80
-
81
- if (!isSharedLayout(syncLayout)) {
82
- syncLayout.flush();
83
- }
84
-
85
- /**
86
- * If this axis isn't animating as a result of this render we want to reset the targetBox
87
- * to the measured box
88
- */
89
- //setCurrentViewportBox(visualElement);
90
- };
91
- scaleCorrectionParentContext.update((v) =>
92
- v.concat([
93
- {
94
- updater,
95
- afterU,
96
- },
97
- ]),
98
- );
99
- afterUpdate(afterU);
100
- </script>
1
+ <!-- based on framer-motion@4.1.16,
2
+ Copyright (c) 2018 Framer B.V. -->
3
+
4
+ <script lang="ts">
5
+ import {
6
+ afterUpdate,
7
+ beforeUpdate,
8
+ getContext,
9
+ onDestroy,
10
+ onMount,
11
+ } from "svelte";
12
+ import { get, type Writable } from "svelte/store";
13
+ import {
14
+ ScaleCorrectionContext,
15
+ ScaleCorrectionParentContext,
16
+ } from "../../../context/ScaleCorrectionProvider.svelte";
17
+ import { isSharedLayout } from "../../../context/SharedLayoutContext.js";
18
+ import { snapshotViewportBox } from "../../../render/dom/projection/utils.js";
19
+ import {
20
+ LayoutEpochContext,
21
+ type LayoutEpoch,
22
+ } from "../../../context/LayoutEpochContext.js";
23
+
24
+ export let visualElement, syncLayout, framerSyncLayout, update;
25
+
26
+ const scaleCorrectionContext = getContext<Writable<any[]>>(
27
+ ScaleCorrectionContext,
28
+ );
29
+ const scaleCorrectionParentContext = getContext<Writable<any[]>>(
30
+ ScaleCorrectionParentContext,
31
+ );
32
+
33
+ onMount(() => {
34
+ isSharedLayout(syncLayout) && syncLayout.register(visualElement);
35
+ isSharedLayout(framerSyncLayout) &&
36
+ framerSyncLayout.register(visualElement);
37
+
38
+ visualElement.onUnmount(() => {
39
+ if (isSharedLayout(syncLayout)) {
40
+ syncLayout.remove(visualElement);
41
+ }
42
+
43
+ if (isSharedLayout(framerSyncLayout)) {
44
+ framerSyncLayout.remove(visualElement);
45
+ }
46
+ });
47
+ });
48
+ /**
49
+ * If this is a child of a SyncContext, notify it that it needs to re-render. It will then
50
+ * handle the snapshotting.
51
+ *
52
+ * If it is stand-alone component, add it to the batcher.
53
+ */
54
+
55
+ let updated = false;
56
+ const updater = (nc = false) => {
57
+ if (updated) {
58
+ return null;
59
+ }
60
+ updated = true;
61
+
62
+ // in React the updater function is called on children first, in Svelte the child does not call it.
63
+ get(scaleCorrectionContext).forEach((v) => {
64
+ v.updater?.(true);
65
+ });
66
+
67
+ if (isSharedLayout(syncLayout)) {
68
+ syncLayout.syncUpdate();
69
+ } else {
70
+ snapshotViewportBox(visualElement, nc);
71
+ syncLayout.add(visualElement);
72
+ }
73
+
74
+ return null;
75
+ };
76
+
77
+ $: update !== undefined && updater(update);
78
+
79
+ if (update === undefined) {
80
+ beforeUpdate(updater);
81
+ }
82
+
83
+ const afterU = (nc = false) => {
84
+ updated = false;
85
+ /* Second part of the updater calling in child layouts first.*/
86
+ const scc = get(scaleCorrectionContext);
87
+
88
+ scc.forEach((v: any, i) => {
89
+ v.afterU?.(true);
90
+ });
91
+
92
+ if (!isSharedLayout(syncLayout)) {
93
+ syncLayout.flush();
94
+ }
95
+
96
+ /**
97
+ * If this axis isn't animating as a result of this render we want to reset the targetBox
98
+ * to the measured box
99
+ */
100
+ //setCurrentViewportBox(visualElement);
101
+ };
102
+
103
+ // Subscribe to LayoutEpochContext synchronously (store.update fires subscribers
104
+ // before DOM changes — required for FLIP "before" snapshot timing).
105
+ //
106
+ // snapshot=true (presenceAffectsLayout=true): full updater() — snapshot + add
107
+ // to syncLayout for all elements. MeasureContextProvider's $: epochUpdate
108
+ // triggers a Measure re-render → $: updater(update) guard + afterUpdate(afterU)
109
+ // → syncLayout.flush() after DOM settles.
110
+ //
111
+ // snapshot=false (presenceAffectsLayout=false): for the exiting element only
112
+ // (isPresent=false) add to syncLayout and flush immediately so animateF →
113
+ // safeToRemove fires. Siblings are skipped — they snap to new positions.
114
+ const layoutEpoch = getContext<Writable<LayoutEpoch>>(LayoutEpochContext);
115
+ if (layoutEpoch) {
116
+ let ready = false;
117
+ const unsub = layoutEpoch.subscribe((e) => {
118
+ if (!ready) {
119
+ ready = true;
120
+ return;
121
+ } // skip initial call at subscribe time
122
+ if (e.snapshot) {
123
+ updater();
124
+ } else if (!visualElement.isPresent) {
125
+ if (!isSharedLayout(syncLayout)) {
126
+ snapshotViewportBox(visualElement);
127
+ syncLayout.add(visualElement);
128
+ }
129
+ afterU();
130
+ }
131
+ });
132
+ onDestroy(unsub);
133
+ }
134
+
135
+ scaleCorrectionParentContext.update((v) =>
136
+ v.concat([
137
+ {
138
+ updater,
139
+ afterU,
140
+ },
141
+ ]),
142
+ );
143
+ afterUpdate(afterU);
144
+ </script>
@@ -1 +1 @@
1
- {"version":3,"file":"Measure.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/motion/features/layout/Measure.svelte.ts"],"names":[],"mappings":"AA+GA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,OAAO;;;;;;;kBAA+E,CAAC;AAC3E,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAC9C,eAAe,OAAO,CAAC"}
1
+ {"version":3,"file":"Measure.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/motion/features/layout/Measure.svelte.ts"],"names":[],"mappings":"AA4JA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,OAAO;;;;;;;kBAA+E,CAAC;AAC3E,KAAK,OAAO,GAAG,YAAY,CAAC,OAAO,OAAO,CAAC,CAAC;AAC9C,eAAe,OAAO,CAAC"}
@@ -12,11 +12,24 @@ Copyright (c) 2018 Framer B.V. -->
12
12
  FramerTreeLayoutContext,
13
13
  SharedLayoutContext,
14
14
  } from "../../../context/SharedLayoutContext.js";
15
+ import {
16
+ LayoutEpochContext,
17
+ type LayoutEpoch,
18
+ } from "../../../context/LayoutEpochContext.js";
15
19
  import Measure from "./Measure.svelte";
16
20
 
17
21
  export let visualElement, props, isCustom;
18
22
 
19
23
  $: ({ update } = props);
24
+
25
+ // When snapshot=true AnimatePresence wants a full FLIP snapshot+flush cycle.
26
+ // Pass epochUpdate only then so Measure re-renders → $: updater(update) →
27
+ // afterUpdate(afterU) → syncLayout.flush(). The flush-only (snapshot=false)
28
+ // path is handled directly inside Measure's layoutEpoch subscribe callback.
29
+ const layoutEpoch = getContext<Writable<LayoutEpoch>>(LayoutEpochContext);
30
+ $: epochUpdate =
31
+ layoutEpoch && $layoutEpoch.snapshot ? $layoutEpoch.n : undefined;
32
+
20
33
  const syncLayout =
21
34
  getContext<Writable<SyncLayoutBatcher | SharedLayoutSyncMethods>>(
22
35
  SharedLayoutContext,
@@ -31,5 +44,5 @@ Copyright (c) 2018 Framer B.V. -->
31
44
  syncLayout={$syncLayout}
32
45
  framerSyncLayout={$framerSyncLayout}
33
46
  {visualElement}
34
- {update}
47
+ update={update ?? epochUpdate}
35
48
  />
@@ -1 +1 @@
1
- {"version":3,"file":"MeasureContextProvider.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/motion-start/motion/features/layout/MeasureContextProvider.svelte.ts"],"names":[],"mappings":"AAyCA,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAA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,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AAKD,QAAA,MAAM,sBAAsB;;;;;;kBAA+E,CAAC;AAC1F,KAAK,sBAAsB,GAAG,YAAY,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAC5E,eAAe,sBAAsB,CAAC"}
@@ -26,7 +26,7 @@ Copyright (c) 2018 Framer B.V. -->
26
26
  PresenceContext,
27
27
  type PresenceContextProps,
28
28
  } from "../../context/PresenceContext.js";
29
- import type { VisualElement } from "../../render/types.js";
29
+ import type { VisualElement } from "../../render/types.js";
30
30
 
31
31
  export let createVisualElement = undefined,
32
32
  props,
@@ -35,16 +35,20 @@ Copyright (c) 2018 Framer B.V. -->
35
35
  isCustom;
36
36
 
37
37
  const config =
38
- getContext<Writable<MotionConfigContextObject>>(MotionConfigContext) || MotionConfigContext(isCustom);
38
+ getContext<Writable<MotionConfigContextObject>>(MotionConfigContext) ||
39
+ MotionConfigContext(isCustom);
39
40
 
40
41
  const presenceContext =
41
- getContext<Writable<PresenceContextProps>>(PresenceContext) || PresenceContext(isCustom);
42
+ getContext<Writable<PresenceContextProps>>(PresenceContext) ||
43
+ PresenceContext(isCustom);
42
44
 
43
45
  const lazyContext =
44
- getContext<Writable<LazyContextProps>>(LazyContext) || LazyContext(isCustom);
46
+ getContext<Writable<LazyContextProps>>(LazyContext) ||
47
+ LazyContext(isCustom);
45
48
 
46
49
  const mc =
47
- getContext<Writable<MotionContextProps>>(MotionContext) || MotionContext(isCustom);
50
+ getContext<Writable<MotionContextProps>>(MotionContext) ||
51
+ MotionContext(isCustom);
48
52
 
49
53
  let parent = get(mc).visualElement;
50
54
  $: parent = $mc.visualElement;
@@ -81,7 +85,7 @@ Copyright (c) 2018 Framer B.V. -->
81
85
  }
82
86
 
83
87
  let visualElement: VisualElement | undefined = visualElementRef;
84
- $:(visualElement = visualElementRef);
88
+ $: visualElement = visualElementRef;
85
89
 
86
90
  $: if (visualElement) {
87
91
  visualElement.setProps({
@@ -1 +1 @@
1
- {"version":3,"file":"UseVisualElement.svelte.d.ts","sourceRoot":"","sources":["../../../src/lib/motion-start/motion/utils/UseVisualElement.svelte.ts"],"names":[],"mappings":"AAGE,eAAO,MAAM,GAAG,QAAQ,CAAC;AAuB3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAuG3D,UAAU,kCAAkC,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,MAAM,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,GAAG,EAAE,OAAO,GAAG,EAAE,EAAE,QAAQ,GAAG,MAAM;IACpM,KAAK,OAAO,EAAE,OAAO,QAAQ,EAAE,2BAA2B,CAAC,KAAK,CAAC,GAAG,OAAO,QAAQ,EAAE,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,QAAQ,CAAA;KAAE,GAAG,OAAO,CAAC;IACjK,CAAC,QAAQ,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,GAAG;QAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,KAAK,CAAA;KAAC,GAAG,OAAO,GAAG;QAAE,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE,CAAC;IAC9G,YAAY,CAAC,EAAE,QAAQ,CAAC;CAC3B;AACD,KAAK,gCAAgC,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,GACvD,CAAC,KAAK,SAAS;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,C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C,CAAC,KAAK,EAAE,KAAK,IAAI,KAAK,GACvD,CAAC,KAAK,SAAS;IAAE,OAAO,EAAE,GAAG,CAAA;CAAE,GACzB,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,GACnC,GAAG,GACH;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAA;CAAE,GAClB,EAAE,CAAC,CAAC;AAId,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;cAAqF,CAAC;AAC1F,KAAK,gBAAgB,GAAG,YAAY,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAChE,eAAe,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "motion-start",
3
- "version": "0.1.20",
3
+ "version": "0.1.21",
4
4
  "description": "Svelte animation library inspired by the React library framer-motion.",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -12,6 +12,8 @@
12
12
  ".": {
13
13
  "types": "./dist/index.d.ts",
14
14
  "svelte": "./dist/index.js",
15
+ "import": "./dist/index.js",
16
+ "module": "./dist/index.js",
15
17
  "default": "./dist/index.js"
16
18
  },
17
19
  "./package.json": "./package.json",
@@ -38,17 +40,6 @@
38
40
  "svelte": "./dist/value/index.js",
39
41
  "import": "./dist/value/index.js",
40
42
  "default": "./dist/value/index.js"
41
- },
42
- "./src/*.js": {
43
- "types": "./dist/*.d.ts",
44
- "svelte": "./dist/*.js",
45
- "import": "./dist/*.js",
46
- "default": "./dist/*.js"
47
- },
48
- "./src/*.svelte": {
49
- "types": "./dist/*.d.ts",
50
- "svelte": "./dist/*.svelte",
51
- "default": "./dist/*.svelte"
52
43
  }
53
44
  },
54
45
  "files": [
@@ -56,8 +47,11 @@
56
47
  "!dist/**/*.test.*",
57
48
  "!dist/**/*.spec.*"
58
49
  ],
50
+ "main": "./dist/index.js",
51
+ "module": "./dist/index.js",
59
52
  "svelte": "./dist/index.js",
60
53
  "types": "./dist/index.d.ts",
54
+ "browser": "./dist/index.js",
61
55
  "type": "module",
62
56
  "scripts": {
63
57
  "dev": "vite dev",