@seed-design/stackflow 1.1.18 → 1.1.19

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/lib/plugin.cjs CHANGED
@@ -9,8 +9,9 @@ const GlobalInteraction = require('./primitive/GlobalInteraction/GlobalInteracti
9
9
 
10
10
  const seedPlugin = (options) => () => ({
11
11
  key: "seed-design",
12
- wrapStack({ stack }) {
13
- return /* @__PURE__ */ jsxRuntime.jsx(AppScreen.AppScreenPropsProvider, { value: options, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalInteraction.GlobalInteraction, { children: stack.render() }) });
12
+ wrapStack({ stack, initialContext }) {
13
+ const resolved = typeof options === "function" ? options({ initialContext }) : options;
14
+ return /* @__PURE__ */ jsxRuntime.jsx(AppScreen.AppScreenPropsProvider, { value: resolved, children: /* @__PURE__ */ jsxRuntime.jsx(GlobalInteraction.GlobalInteraction, { children: stack.render() }) });
14
15
  }
15
16
  });
16
17
 
package/lib/plugin.d.ts CHANGED
@@ -2,4 +2,6 @@ import { StackflowReactPlugin } from '@stackflow/react';
2
2
  export interface SeedPluginOptions {
3
3
  theme: "android" | "cupertino";
4
4
  }
5
- export declare const seedPlugin: (options: SeedPluginOptions) => StackflowReactPlugin;
5
+ export declare const seedPlugin: (options: SeedPluginOptions | ((args: {
6
+ initialContext?: any;
7
+ }) => SeedPluginOptions)) => StackflowReactPlugin;
package/lib/plugin.js CHANGED
@@ -5,8 +5,9 @@ import { GlobalInteraction } from './primitive/GlobalInteraction/GlobalInteracti
5
5
 
6
6
  const seedPlugin = (options) => () => ({
7
7
  key: "seed-design",
8
- wrapStack({ stack }) {
9
- return /* @__PURE__ */ jsx(AppScreenPropsProvider, { value: options, children: /* @__PURE__ */ jsx(GlobalInteraction, { children: stack.render() }) });
8
+ wrapStack({ stack, initialContext }) {
9
+ const resolved = typeof options === "function" ? options({ initialContext }) : options;
10
+ return /* @__PURE__ */ jsx(AppScreenPropsProvider, { value: resolved, children: /* @__PURE__ */ jsx(GlobalInteraction, { children: stack.render() }) });
10
11
  }
11
12
  });
12
13
 
@@ -53,7 +53,7 @@ function useGlobalInteraction() {
53
53
  );
54
54
  const moveSwipeBack = React.useCallback(
55
55
  ({ x, t }) => {
56
- const displacement = x - swipeBackContextRef.current.x0;
56
+ const displacement = Math.max(0, x - swipeBackContextRef.current.x0);
57
57
  const displacementRatio = displacement / window.innerWidth;
58
58
  const velocity = displacement / (t - swipeBackContextRef.current.t0);
59
59
  setSwipeBackContext({
@@ -49,7 +49,7 @@ function useGlobalInteraction() {
49
49
  );
50
50
  const moveSwipeBack = useCallback(
51
51
  ({ x, t }) => {
52
- const displacement = x - swipeBackContextRef.current.x0;
52
+ const displacement = Math.max(0, x - swipeBackContextRef.current.x0);
53
53
  const displacementRatio = displacement / window.innerWidth;
54
54
  const velocity = displacement / (t - swipeBackContextRef.current.t0);
55
55
  setSwipeBackContext({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seed-design/stackflow",
3
- "version": "1.1.18",
3
+ "version": "1.1.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/daangn/seed-design.git",
@@ -36,7 +36,7 @@
36
36
  "clsx": "^2.1.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@seed-design/css": "1.2.5",
39
+ "@seed-design/css": "1.2.6",
40
40
  "@stackflow/core": "^1.2.0",
41
41
  "@stackflow/react": "^1.5.1",
42
42
  "@types/react": "^19.2.2",
package/src/plugin.tsx CHANGED
@@ -7,12 +7,19 @@ export interface SeedPluginOptions {
7
7
  }
8
8
 
9
9
  export const seedPlugin =
10
- (options: SeedPluginOptions): StackflowReactPlugin =>
10
+ (
11
+ options:
12
+ | SeedPluginOptions
13
+ // biome-ignore lint/suspicious/noExplicitAny: matches upstream @stackflow/react's `initialContext: any`
14
+ | ((args: { initialContext?: any }) => SeedPluginOptions),
15
+ ): StackflowReactPlugin =>
11
16
  () => ({
12
17
  key: "seed-design",
13
- wrapStack({ stack }) {
18
+ wrapStack({ stack, initialContext }) {
19
+ const resolved = typeof options === "function" ? options({ initialContext }) : options;
20
+
14
21
  return (
15
- <AppScreenPropsProvider value={options}>
22
+ <AppScreenPropsProvider value={resolved}>
16
23
  <GlobalInteraction>{stack.render()}</GlobalInteraction>
17
24
  </AppScreenPropsProvider>
18
25
  );
@@ -96,7 +96,7 @@ export function useGlobalInteraction() {
96
96
 
97
97
  const moveSwipeBack = useCallback(
98
98
  ({ x, t }: MoveSwipeBackProps) => {
99
- const displacement = x - swipeBackContextRef.current.x0;
99
+ const displacement = Math.max(0, x - swipeBackContextRef.current.x0);
100
100
  const displacementRatio = displacement / window.innerWidth;
101
101
  const velocity = displacement / (t - swipeBackContextRef.current.t0);
102
102
  setSwipeBackContext({