From e89b0b817be916b43c5e189b6d5bb2145ddcd032 Mon Sep 17 00:00:00 2001 From: MrWangJustToDo <2711470541@qq.com> Date: Thu, 19 Dec 2024 10:40:07 +0800 Subject: [PATCH] update api --- app/.vitepress/theme/components/example.vue | 2 +- package.json | 3 +- packages/r-store/global.d.ts | 1 + packages/r-store/index.d.ts | 1029 ++++++++++--------- packages/r-store/package.json | 6 +- packages/r-store/src/shared/controller.ts | 12 +- packages/r-store/tsconfig.json | 2 + pnpm-lock.yaml | 210 ++-- scripts/rollupBuild.ts | 48 +- scripts/rollupWatch.ts | 48 +- 10 files changed, 801 insertions(+), 560 deletions(-) diff --git a/app/.vitepress/theme/components/example.vue b/app/.vitepress/theme/components/example.vue index 9935aae..716fc43 100644 --- a/app/.vitepress/theme/components/example.vue +++ b/app/.vitepress/theme/components/example.vue @@ -58,7 +58,7 @@ onMounted(() => { return createElement( Fragment, null, - createElement("p", { className: "text" }, "Reactive count component: "), + createElement("p", { className: "text" }, "Reactive count component:"), createElement( "button", { diff --git a/package.json b/package.json index 781f27e..a1ef77a 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@types/node": "^22.8.5", "@types/react": "^18.2.79", "@types/react-dom": "^18.2.25", + "@vue/reactivity": "~3.5.13", "eslint": "^8.57.0", "husky": "^8.0.2", "lodash": "^4.17.21", @@ -51,7 +52,7 @@ "tslib": "^2.8.0", "typescript": "^5.3.3", "vitepress": "^1.3.4", - "vue": "^3.5.12", + "vue": "^3.5.13", "zustand": "^5.0.0" } } diff --git a/packages/r-store/global.d.ts b/packages/r-store/global.d.ts index 594b2af..abfbe12 100644 --- a/packages/r-store/global.d.ts +++ b/packages/r-store/global.d.ts @@ -1,6 +1,7 @@ declare global { const __DEV__: boolean; const __VERSION__: string; + const __VUE_VERSION__: string; namespace NodeJS { interface ProcessEnv { diff --git a/packages/r-store/index.d.ts b/packages/r-store/index.d.ts index b8ef29e..4249a69 100644 --- a/packages/r-store/index.d.ts +++ b/packages/r-store/index.d.ts @@ -1,468 +1,561 @@ -import type { DeepReadonly } from "@vue/reactivity"; -import type { ReactElement } from "react"; -import type { ReactNode } from "react"; -import type { UnwrapNestedRefs } from "@vue/reactivity"; - -/** - * @public - */ -export declare function createState, P extends Record>( - setup: Setup> -): UseSelectorWithState; - -/** - * @public - */ -export declare function createState>(setup: Setup): UseSelectorWithState; - -/** - * @public - */ -export declare function createState, P extends Record>( - setup: Setup> -): UseSelectorWithState, P>; - -/** - * @public - */ -export declare function createState, P extends Record, L extends Record>( - setup: Setup>, - options: { - withActions: WithActionsProps["generateActions"]; - withPersist?: string | WithPersistProps; - withNamespace?: string | WithNamespaceProps; - withDeepSelector?: boolean; - withStableSelector?: boolean; - } -): UseSelectorWithState; - -/** - * @public - */ -export declare function createState, P extends Record>( - setup: Setup, - options: { - withActions: WithActionsProps["generateActions"]; - withPersist?: string | WithPersistProps; - withNamespace?: string | WithNamespaceProps; - withDeepSelector?: boolean; - withStableSelector?: boolean; - } -): UseSelectorWithState; - -/** - * @public - */ -export declare function createState, P extends Record>( - setup: Setup>, - options: { - withPersist?: string | WithPersistProps; - withNamespace?: string | WithNamespaceProps; - withDeepSelector?: boolean; - withStableSelector?: boolean; - } -): UseSelectorWithState; - -/** - * @public - */ -export declare function createState>( - setup: Setup, - options: { - withPersist?: string | WithPersistProps; - withNamespace?: string | WithNamespaceProps; - withDeepSelector?: boolean; - withStableSelector?: boolean; - } -): UseSelectorWithState; - -/** - * @public - */ -export declare const createStore: >(creator: Creator) => UseSelectorWithStore; - -/** - * @public - * @deprecated - * not recommend to use this function, use `createStore` instead - */ -export declare function createStoreWithComponent>( - props: CreateStoreWithComponentProps, T> -): ({ children }: { children?: (p: DeepReadonly>) => ReactNode }) => ReactElement; - -/** - * @public - * @deprecated - * not recommend to use this function, use `createStore` instead - */ -export declare function createStoreWithComponent

, T extends Record>( - props: CreateStoreWithComponentProps -): ({ - children, -}: { - children?: (p: P & DeepReadonly>) => ReactNode; -} & P) => ReactElement; - -/** - * @public - */ -export declare type CreateStoreWithComponentProps

, T extends Record> = { - setup: Creator; - render?: (props: P & DeepReadonly>) => ReactNode; -}; - -/** - * @public - */ -export declare type Creator> = () => T; - -/** - * @public - * @deprecated - * no need to use this function - */ -export declare const getBatch: () => (cb: () => void) => void; - -/** - * @public - */ -declare type LifeCycle = { - onBeforeMount: Array<() => void>; - onMounted: Array<() => void>; - onBeforeUpdate: Array<() => void>; - onUpdated: Array<() => void>; - onBeforeUnmount: Array<() => void>; - onUnmounted: Array<() => void>; - hasHookInstall: boolean; - canUpdateComponent: boolean; - syncUpdateComponent: boolean; -}; - -/** - * @public - */ -export declare type MaybeStateWithMiddleware = T | StateWithMiddleware; - -/** - * @public - */ -export declare const onBeforeMount: (cb: () => void) => void; - -/** - * @public - */ -export declare const onBeforeUnmount: (cb: () => void) => void; - -/** - * @public - */ -export declare const onBeforeUpdate: (cb: () => void) => void; - -/** - * @public - */ -export declare const onMounted: (cb: () => void) => void; - -/** - * @public - */ -export declare const onUnmounted: (cb: () => void) => void; - -/** - * @public - */ -export declare const onUpdated: (cb: () => void) => void; - -/** - * @public - * @deprecated - * no need to use this function - */ -export declare const resetBatch: () => void; - -/** - * @public - * @deprecated - * no need to use this function - */ -export declare const setBatch: (batch: (cb: () => void) => void) => void; - -/** - * @public - */ -export declare type Setup = () => T; - -/** - * @public - */ -export declare type StateWithMiddleware = { - ["$$__state__$$"]: T; - ["$$__middleware__$$"]: Record; - ["$$__actions__$$"]: P; - ["$$__namespace__$$"]: WithNamespaceProps; - ["$$__selectorOptions__$$"]: WithSelectorOptionsProps; -}; - -/** - * @public - */ -export declare type UnWrapMiddleware = T extends StateWithMiddleware ? UnWrapMiddleware : T; - -/** - * @public - */ -export declare const useReactiveEffect: (effectCallback: () => void | (() => void)) => void; - -/** - * @public - */ -export declare const useReactiveState: >( - initialState: T | (() => T) -) => [DeepReadonly>, (payload: UnwrapNestedRefs | ((t: UnwrapNestedRefs) => void)) => void]; - -/** - * @public - */ -export declare type UseSelectorWithState = { - (): DeepReadonly> & C; - /** - * @param selector - a method to select the state - * @param compare - a method to compare the previous state and the next state, if the result is `true`, the component will not be updated - * @returns the selected state - */ -

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; - /** - * @deprecated - * use `getReactiveState` / `getReadonlyState` instead - */ - getState: () => T; - /** - * get the actions what defined in the `withActions` middleware function - * @returns the actions - */ - getActions: () => C; - /** - * internal lifeCycle object, if you do not know what it is, you can ignore it - * @returns the lifeCycle object - */ - getLifeCycle: () => LifeCycle; - /** - * get the reactive state, change the state will trigger the component update - * @returns the reactive state - */ - getReactiveState: () => UnwrapNestedRefs; - /** - * get a readonly state, you can not change the state, it is a safe way to get the state and can be used in anywhere - * @returns the readonly state - */ - getReadonlyState: () => DeepReadonly>; - /** - * - * @param selector - a method to select the state, when the state change, the `cb` will be called - * @param cb - a callback function - * @returns a unsubscribe function - */ - subscribe:

(selector: (state: DeepReadonly>) => P, cb?: () => void, shallow?: boolean) => () => void; - useDeepSelector: { - (): DeepReadonly> & C; -

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useDeepStableSelector: { - (): DeepReadonly> & C; -

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useShallowSelector: { - (): DeepReadonly> & C; -

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useShallowStableSelector: { - (): DeepReadonly> & C; -

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; -}; - -/** - * @public - */ -export declare type UseSelectorWithStore = { - (): DeepReadonly>; - /** - * @param selector - a method to select the state - * @param compare - a method to compare the previous state and the next state, if the result is `true`, the component will not be updated - * @returns the selected state - */ -

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; - /** - * @deprecated - * use `getReactiveState` / `getReadonlyState` instead - */ - getState: () => T; - /** - * internal lifeCycle object, if you do not know what it is, you can ignore it - * @returns the lifeCycle object - */ - getLifeCycle: () => LifeCycle; - /** - * get the reactive state, change the state will trigger the component update - * @returns the reactive state - */ - getReactiveState: () => UnwrapNestedRefs; - /** - * get a readonly state, you can not change the state, it is a safe way to get the state and can be used in anywhere - * @returns the readonly state - */ - getReadonlyState: () => DeepReadonly>; - /** - * - * @param selector - a method to select the state, when the state change, the `cb` will be called - * @param cb - a callback function - * @returns a unsubscribe function - */ - subscribe:

(selector: (state: DeepReadonly>) => P, cb?: () => void, shallow?: boolean) => () => void; - useShallowSelector: { - (): DeepReadonly>; -

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useShallowStableSelector: { - (): DeepReadonly>; -

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useDeepSelector: { - (): DeepReadonly>; -

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; - useDeepStableSelector: { - (): DeepReadonly>; -

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; - }; -}; - -/** - * @public - */ -export declare const version: string; - -/** - * @public - */ -export declare function withActions< - T extends StateWithMiddleware, - Q extends Record, - P extends Record, - L extends Record, ->(setup: Setup>, options: WithActionsProps): Setup, P & L>>; - -/** - * @public - */ -export declare function withActions, P extends Record>( - setup: Setup, - options: WithActionsProps -): Setup>; - -/** - * @public - */ -export declare type WithActionsProps = { - generateActions?: (state: T) => P; - /** - * @deprecated - * - * no need this option anymore - */ - automaticBatchAction?: boolean; -}; - -/** - * @public - * @deprecated - * use `withSelectorOptions` instead - */ -export declare const withDeepSelector: typeof withSelectorOptions; - -/** - * @public - */ -export declare function withNamespace, P extends Record>( - setup: Setup>, - options: WithNamespaceProps -): Setup>; - -/** - * @public - */ -export declare function withNamespace>(setup: Setup, options: WithNamespaceProps): Setup>; - -/** - * @public - */ -export declare type WithNamespaceProps = { - namespace: string; - reduxDevTool?: boolean; - shallow?: boolean; - listener?: (state: T) => any; -}; - -/** - * @public - */ -export declare function withPersist, P extends Record>( - setup: Setup>, - options: WithPersistProps -): Setup>; - -/** - * @public - */ -export declare function withPersist>(setup: Setup, options: WithPersistProps): Setup>; - -/** - * @public - */ -export declare type WithPersistProps> = { - key: string; - version?: string; - debounceTime?: number; - getStorage?: () => Storage; - stringify?: (s: T) => string; - parse?: (s: string) => Partial; - merge?: (fromCreator: T, fromStorage: Partial) => T; - devLog?: boolean; - shallow?: boolean; - listener?: (state: T) => any; -}; - -/** - * @public - */ -export declare function withSelectorOptions, P extends Record>( - setup: Setup>, - options: WithSelectorOptionsProps -): Setup>; - -/** - * @public - */ -export declare function withSelectorOptions>( - setup: Setup, - options: WithSelectorOptionsProps -): Setup>; - -/** - * @public - */ -declare type WithSelectorOptionsProps = { - deepSelector?: boolean; - stableSelector?: boolean; -}; - -/** - * @public - * @deprecated - * no need to use this function - */ -export declare const wrapperBatchUpdate: (cb: T) => T; - -export * from "@vue/reactivity"; - -export {}; +import type { DeepReadonly } from '@vue/reactivity'; +import type { ReactElement } from 'react'; +import type { ReactNode } from 'react'; +import type { UnwrapNestedRefs } from '@vue/reactivity'; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState, P extends Record>(setup: Setup>): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState>(setup: Setup): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState, P extends Record>(setup: Setup>): UseSelectorWithState, P>; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState, P extends Record, L extends Record>(setup: Setup>, options: { + withActions: WithActionsProps["generateActions"]; + withPersist?: string | WithPersistProps; + withNamespace?: string | WithNamespaceProps; + withDeepSelector?: boolean; + withStableSelector?: boolean; +}): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState, P extends Record>(setup: Setup, options: { + withActions: WithActionsProps["generateActions"]; + withPersist?: string | WithPersistProps; + withNamespace?: string | WithNamespaceProps; + withDeepSelector?: boolean; + withStableSelector?: boolean; +}): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState, P extends Record>(setup: Setup>, options: { + withPersist?: string | WithPersistProps; + withNamespace?: string | WithNamespaceProps; + withDeepSelector?: boolean; + withStableSelector?: boolean; +}): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createState } from "r-store"; + * + * const count = createState(() => ({state: 0}), { + * withPersist: "count", + * withActions: (state) => ({ + * increment: () => { + * state.state++; + * }, + * }), + * withNamespace: "count", + * withDeepSelector: true, + * withStableSelector: true, + * }); + * ``` + */ +export declare function createState>(setup: Setup, options: { + withPersist?: string | WithPersistProps; + withNamespace?: string | WithNamespaceProps; + withDeepSelector?: boolean; + withStableSelector?: boolean; +}): UseSelectorWithState; + +/** + * @public + * + * @example + * ```typescript + * import { createStore, ref } from "r-store"; + * + * const count = createStore(() => { + * const state = ref(0); + * + * const increment = () => { + * state.value++; + * }; + * + * return { state, increment }; + * }); + * ``` + */ +export declare const createStore: >(creator: Creator) => UseSelectorWithStore; + +/** + * @public + * @deprecated + * not recommend to use this function, use `createStore` instead + */ +export declare function createStoreWithComponent>(props: CreateStoreWithComponentProps, T>): ({ children }: { + children?: (p: DeepReadonly>) => ReactNode; +}) => ReactElement; + +/** + * @public + * @deprecated + * not recommend to use this function, use `createStore` instead + */ +export declare function createStoreWithComponent

, T extends Record>(props: CreateStoreWithComponentProps): ({ children }: { + children?: (p: P & DeepReadonly>) => ReactNode; +} & P) => ReactElement; + +/** + * @public + */ +export declare type CreateStoreWithComponentProps

, T extends Record> = { + setup: Creator; + render?: (props: P & DeepReadonly>) => ReactNode; +}; + +/** + * @public + */ +export declare type Creator> = () => T; + +/** + * @public + * @deprecated + * no need to use this function + */ +export declare const getBatch: () => (cb: () => void) => void; + +/** + * @public + */ +declare type LifeCycle = { + onBeforeMount: Array<() => void>; + onMounted: Array<() => void>; + onBeforeUpdate: Array<() => void>; + onUpdated: Array<() => void>; + onBeforeUnmount: Array<() => void>; + onUnmounted: Array<() => void>; + hasHookInstall: boolean; + canUpdateComponent: boolean; + syncUpdateComponent: boolean; +}; + +/** + * @public + */ +export declare type MaybeStateWithMiddleware = T | StateWithMiddleware; + +/** + * @public + */ +export declare const onBeforeMount: (cb: () => void) => void; + +/** + * @public + */ +export declare const onBeforeUnmount: (cb: () => void) => void; + +/** + * @public + */ +export declare const onBeforeUpdate: (cb: () => void) => void; + +/** + * @public + */ +export declare const onMounted: (cb: () => void) => void; + +/** + * @public + */ +export declare const onUnmounted: (cb: () => void) => void; + +/** + * @public + */ +export declare const onUpdated: (cb: () => void) => void; + +/** + * @public + * @deprecated + * no need to use this function + */ +export declare const resetBatch: () => void; + +/** + * @public + * @deprecated + * no need to use this function + */ +export declare const setBatch: (batch: (cb: () => void) => void) => void; + +/** + * @public + */ +export declare type Setup = () => T; + +/** + * @public + */ +export declare type StateWithMiddleware = { + ["$$__state__$$"]: T; + ["$$__middleware__$$"]: Record; + ["$$__actions__$$"]: P; + ["$$__namespace__$$"]: WithNamespaceProps; + ["$$__selectorOptions__$$"]: WithSelectorOptionsProps; +}; + +/** + * @public + */ +export declare type UnWrapMiddleware = T extends StateWithMiddleware ? UnWrapMiddleware : T; + +/** + * @public + */ +export declare const useReactiveEffect: (effectCallback: () => void | (() => void)) => void; + +/** + * @public + */ +export declare const useReactiveState: >(initialState: T | (() => T)) => [DeepReadonly>, (payload: UnwrapNestedRefs | ((t: UnwrapNestedRefs) => void)) => void]; + +/** + * @public + */ +export declare type UseSelectorWithState = { + (): DeepReadonly> & C; + /** + * @param selector - a method to select the state + * @param compare - a method to compare the previous state and the next state, if the result is `true`, the component will not be updated + * @returns the selected state + */ +

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; + /** + * @deprecated + * use `getReactiveState` / `getReadonlyState` instead + */ + getState: () => T; + /** + * get the actions what defined in the `withActions` middleware function + * @returns the actions + */ + getActions: () => C; + /** + * internal lifeCycle object, if you do not know what it is, you can ignore it + * @returns the lifeCycle object + */ + getLifeCycle: () => LifeCycle; + /** + * get the reactive state, change the state will trigger the component update + * @returns the reactive state + */ + getReactiveState: () => UnwrapNestedRefs; + /** + * get a readonly state, you can not change the state, it is a safe way to get the state and can be used in anywhere + * @returns the readonly state + */ + getReadonlyState: () => DeepReadonly>; + /** + * + * @param selector - a method to select the state, when the state change, the `cb` will be called + * @param cb - a callback function + * @returns a unsubscribe function + */ + subscribe:

(selector: (state: DeepReadonly>) => P, cb?: () => void, shallow?: boolean) => () => void; + useDeepSelector: { + (): DeepReadonly> & C; +

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useDeepStableSelector: { + (): DeepReadonly> & C; +

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useShallowSelector: { + (): DeepReadonly> & C; +

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useShallowStableSelector: { + (): DeepReadonly> & C; +

(selector: (state: DeepReadonly> & C) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; +}; + +/** + * @public + */ +export declare type UseSelectorWithStore = { + (): DeepReadonly>; + /** + * @param selector - a method to select the state + * @param compare - a method to compare the previous state and the next state, if the result is `true`, the component will not be updated + * @returns the selected state + */ +

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; + /** + * @deprecated + * use `getReactiveState` / `getReadonlyState` instead + */ + getState: () => T; + /** + * internal lifeCycle object, if you do not know what it is, you can ignore it + * @returns the lifeCycle object + */ + getLifeCycle: () => LifeCycle; + /** + * get the reactive state, change the state will trigger the component update + * @returns the reactive state + */ + getReactiveState: () => UnwrapNestedRefs; + /** + * get a readonly state, you can not change the state, it is a safe way to get the state and can be used in anywhere + * @returns the readonly state + */ + getReadonlyState: () => DeepReadonly>; + /** + * + * @param selector - a method to select the state, when the state change, the `cb` will be called + * @param cb - a callback function + * @returns a unsubscribe function + */ + subscribe:

(selector: (state: DeepReadonly>) => P, cb?: () => void, shallow?: boolean) => () => void; + useShallowSelector: { + (): DeepReadonly>; +

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useShallowStableSelector: { + (): DeepReadonly>; +

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useDeepSelector: { + (): DeepReadonly>; +

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; + useDeepStableSelector: { + (): DeepReadonly>; +

(selector: (state: DeepReadonly>) => P, compare?: (prev: Q, next: Q) => boolean): P; + }; +}; + +/** + * @public + */ +export declare const version: string; + +/** + * @public + */ +export declare function withActions, Q extends Record, P extends Record, L extends Record>(setup: Setup>, options: WithActionsProps): Setup, P & L>>; + +/** + * @public + */ +export declare function withActions, P extends Record>(setup: Setup, options: WithActionsProps): Setup>; + +/** + * @public + */ +export declare type WithActionsProps = { + generateActions?: (state: T) => P; + /** + * @deprecated + * + * no need this option anymore + */ + automaticBatchAction?: boolean; +}; + +/** + * @public + * @deprecated + * use `withSelectorOptions` instead + */ +export declare const withDeepSelector: typeof withSelectorOptions; + +/** + * @public + */ +export declare function withNamespace, P extends Record>(setup: Setup>, options: WithNamespaceProps): Setup>; + +/** + * @public + */ +export declare function withNamespace>(setup: Setup, options: WithNamespaceProps): Setup>; + +/** + * @public + */ +export declare type WithNamespaceProps = { + namespace: string; + reduxDevTool?: boolean; + shallow?: boolean; + listener?: (state: T) => any; +}; + +/** + * @public + */ +export declare function withPersist, P extends Record>(setup: Setup>, options: WithPersistProps): Setup>; + +/** + * @public + */ +export declare function withPersist>(setup: Setup, options: WithPersistProps): Setup>; + +/** + * @public + */ +export declare type WithPersistProps> = { + key: string; + version?: string; + debounceTime?: number; + getStorage?: () => Storage; + stringify?: (s: T) => string; + parse?: (s: string) => Partial; + merge?: (fromCreator: T, fromStorage: Partial) => T; + devLog?: boolean; + shallow?: boolean; + listener?: (state: T) => any; +}; + +/** + * @public + */ +export declare function withSelectorOptions, P extends Record>(setup: Setup>, options: WithSelectorOptionsProps): Setup>; + +/** + * @public + */ +export declare function withSelectorOptions>(setup: Setup, options: WithSelectorOptionsProps): Setup>; + +/** + * @public + */ +declare type WithSelectorOptionsProps = { + deepSelector?: boolean; + stableSelector?: boolean; +}; + +/** + * @public + * @deprecated + * no need to use this function + */ +export declare const wrapperBatchUpdate: (cb: T) => T; + + +export * from "@vue/reactivity"; + +export { } diff --git a/packages/r-store/package.json b/packages/r-store/package.json index 009aca3..b902571 100644 --- a/packages/r-store/package.json +++ b/packages/r-store/package.json @@ -61,10 +61,10 @@ "state-management, reactive, vue, react" ], "dependencies": { - "@vue/reactivity": "~3.5.12", - "@vue/shared": "~3.5.12", + "@vue/reactivity": "~3.5.13", + "@vue/shared": "~3.5.13", "jsan": "^3.1.14", - "use-sync-external-store": "^1.2.2" + "use-sync-external-store": "^1.4.0" }, "peerDependencies": { "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0" diff --git a/packages/r-store/src/shared/controller.ts b/packages/r-store/src/shared/controller.ts index e3a6a09..9fe9e04 100644 --- a/packages/r-store/src/shared/controller.ts +++ b/packages/r-store/src/shared/controller.ts @@ -6,10 +6,20 @@ import { queueJob } from "./queue"; import type { LifeCycle } from "./lifeCycle"; -class ControllerEffect extends ReactiveEffect { +class ControllerEffect extends ReactiveEffect { + _devVersion: string; + get _isControllerEffect() { return true; } + + constructor(getter: () => T) { + super(getter); + + if (__DEV__) { + this._devVersion = __VUE_VERSION__; + } + } } const catchError = (cb: () => T, instance: Controller) => { diff --git a/packages/r-store/tsconfig.json b/packages/r-store/tsconfig.json index 6272e0d..309e4ba 100644 --- a/packages/r-store/tsconfig.json +++ b/packages/r-store/tsconfig.json @@ -2,6 +2,8 @@ "compilerOptions": { "target": "ES6", "moduleResolution": "node", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, "jsx": "react-jsx", "stripInternal": true }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cd50a46..86a5765 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -32,6 +32,9 @@ importers: '@types/react-dom': specifier: ^18.2.25 version: 18.2.25 + '@vue/reactivity': + specifier: ~3.5.13 + version: 3.5.13 eslint: specifier: ^8.57.0 version: 8.57.0 @@ -75,20 +78,20 @@ importers: specifier: ^1.3.4 version: 1.3.4(@algolia/client-search@4.24.0)(@types/node@22.8.5)(@types/react@18.2.79)(axios@1.7.7)(postcss@8.4.47)(react-dom@18.2.0(react@18.2.0))(react@18.2.0)(search-insights@2.17.0)(terser@5.26.0)(typescript@5.3.3) vue: - specifier: ^3.5.12 - version: 3.5.12(typescript@5.3.3) + specifier: ^3.5.13 + version: 3.5.13(typescript@5.3.3) zustand: specifier: ^5.0.0 - version: 5.0.0(@types/react@18.2.79)(react@18.2.0)(use-sync-external-store@1.2.2(react@18.2.0)) + version: 5.0.0(@types/react@18.2.79)(react@18.2.0)(use-sync-external-store@1.4.0(react@18.2.0)) packages/r-store: dependencies: '@vue/reactivity': - specifier: ~3.5.12 - version: 3.5.12 + specifier: ~3.5.13 + version: 3.5.13 '@vue/shared': - specifier: ~3.5.12 - version: 3.5.12 + specifier: ~3.5.13 + version: 3.5.13 jsan: specifier: ^3.1.14 version: 3.1.14 @@ -96,8 +99,8 @@ importers: specifier: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 version: 18.2.0 use-sync-external-store: - specifier: ^1.2.2 - version: 1.2.2(react@18.2.0) + specifier: ^1.4.0 + version: 1.4.0(react@18.2.0) devDependencies: '@microsoft/api-extractor': specifier: ^7.47.7 @@ -1042,14 +1045,20 @@ packages: '@vue/compiler-core@3.5.12': resolution: {integrity: sha512-ISyBTRMmMYagUxhcpyEH0hpXRd/KqDU4ymofPgl2XAkY9ZhQ+h0ovEZJIiPop13UmR/54oA2cgMDjgroRelaEw==} + '@vue/compiler-core@3.5.13': + resolution: {integrity: sha512-oOdAkwqUfW1WqpwSYJce06wvt6HljgY3fGeM9NcVA1HaYOij3mZG9Rkysn0OHuyUAGMbEbARIpsG+LPVlBJ5/Q==} + '@vue/compiler-dom@3.5.12': resolution: {integrity: sha512-9G6PbJ03uwxLHKQ3P42cMTi85lDRvGLB2rSGOiQqtXELat6uI4n8cNz9yjfVHRPIu+MsK6TE418Giruvgptckg==} - '@vue/compiler-sfc@3.5.12': - resolution: {integrity: sha512-2k973OGo2JuAa5+ZlekuQJtitI5CgLMOwgl94BzMCsKZCX/xiqzJYzapl4opFogKHqwJk34vfsaKpfEhd1k5nw==} + '@vue/compiler-dom@3.5.13': + resolution: {integrity: sha512-ZOJ46sMOKUjO3e94wPdCzQ6P1Lx/vhp2RSvfaab88Ajexs0AHeV0uasYhi99WPaogmBlRHNRuly8xV75cNTMDA==} + + '@vue/compiler-sfc@3.5.13': + resolution: {integrity: sha512-6VdaljMpD82w6c2749Zhf5T9u5uLBWKnVue6XWxprDobftnletJ8+oel7sexFfM3qIxNmVE7LSFGTpv6obNyaQ==} - '@vue/compiler-ssr@3.5.12': - resolution: {integrity: sha512-eLwc7v6bfGBSM7wZOGPmRavSWzNFF6+PdRhE+VFJhNCgHiF8AM7ccoqcv5kBXA2eWUfigD7byekvf/JsOfKvPA==} + '@vue/compiler-ssr@3.5.13': + resolution: {integrity: sha512-wMH6vrYHxQl/IybKJagqbquvxpWCuVYpoUJfCqFZwa/JY1GdATAQ+TgVtgrwwMZ0D07QhA99rs/EAAWfvG6KpA==} '@vue/compiler-vue2@2.7.16': resolution: {integrity: sha512-qYC3Psj9S/mfu9uVi5WvNZIzq+xnXMhOwbTFKKDD7b1lhpnn71jXSFdTQ+WsIEk0ONCd7VV2IMm7ONl6tbQ86A==} @@ -1071,23 +1080,26 @@ packages: typescript: optional: true - '@vue/reactivity@3.5.12': - resolution: {integrity: sha512-UzaN3Da7xnJXdz4Okb/BGbAaomRHc3RdoWqTzlvd9+WBR5m3J39J1fGcHes7U3za0ruYn/iYy/a1euhMEHvTAg==} + '@vue/reactivity@3.5.13': + resolution: {integrity: sha512-NaCwtw8o48B9I6L1zl2p41OHo/2Z4wqYGGIK1Khu5T7yxrn+ATOixn/Udn2m+6kZKB/J7cuT9DbWWhRxqixACg==} - '@vue/runtime-core@3.5.12': - resolution: {integrity: sha512-hrMUYV6tpocr3TL3Ad8DqxOdpDe4zuQY4HPY3X/VRh+L2myQO8MFXPAMarIOSGNu0bFAjh1yBkMPXZBqCk62Uw==} + '@vue/runtime-core@3.5.13': + resolution: {integrity: sha512-Fj4YRQ3Az0WTZw1sFe+QDb0aXCerigEpw418pw1HBUKFtnQHWzwojaukAs2X/c9DQz4MQ4bsXTGlcpGxU/RCIw==} - '@vue/runtime-dom@3.5.12': - resolution: {integrity: sha512-q8VFxR9A2MRfBr6/55Q3umyoN7ya836FzRXajPB6/Vvuv0zOPL+qltd9rIMzG/DbRLAIlREmnLsplEF/kotXKA==} + '@vue/runtime-dom@3.5.13': + resolution: {integrity: sha512-dLaj94s93NYLqjLiyFzVs9X6dWhTdAlEAciC3Moq7gzAc13VJUdCnjjRurNM6uTLFATRHexHCTu/Xp3eW6yoog==} - '@vue/server-renderer@3.5.12': - resolution: {integrity: sha512-I3QoeDDeEPZm8yR28JtY+rk880Oqmj43hreIBVTicisFTx/Dl7JpG72g/X7YF8hnQD3IFhkky5i2bPonwrTVPg==} + '@vue/server-renderer@3.5.13': + resolution: {integrity: sha512-wAi4IRJV/2SAW3htkTlB+dHeRmpTiVIK1OGLWV1yeStVSebSQQOwGwIq0D3ZIoBj2C2qpgz5+vX9iEBkTdk5YA==} peerDependencies: - vue: 3.5.12 + vue: 3.5.13 '@vue/shared@3.5.12': resolution: {integrity: sha512-L2RPSAwUFbgZH20etwrXyVyCBu9OxRSi8T/38QsvnkJyvq2LufW2lDCOzm7t/U9C1mkhJGWYfCuFBCmIuNivrg==} + '@vue/shared@3.5.13': + resolution: {integrity: sha512-/hnE/qP5ZoGpol0a5mDi45bOd7t3tjYJBjsgCsivow7D48cJeV5l05RD82lPqi7gRiphZM37rnhW1l6ZoCNNnQ==} + '@vueuse/core@11.0.3': resolution: {integrity: sha512-RENlh64+SYA9XMExmmH1a3TPqeIuJBNNB/63GT35MZI+zpru3oMRUA6cEFr9HmGqEgUisurwGwnIieF6qu3aXw==} @@ -2487,6 +2499,9 @@ packages: picocolors@1.1.0: resolution: {integrity: sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==} + picocolors@1.1.1: + resolution: {integrity: sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==} + picomatch@2.3.1: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} @@ -2551,6 +2566,10 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} + postcss@8.4.49: + resolution: {integrity: sha512-OCVPnIObs4N29kxTjzLfUryOkvZEq+pf8jTF0lg8E7uETuWHA+v7j3c/xJmiqpX450191LlmZfUKkXxkTry7nA==} + engines: {node: ^10 || ^12 || >=14} + preact@10.19.3: resolution: {integrity: sha512-nHHTeFVBTHRGxJXKkKu5hT8C/YWBkPso4/Gad6xuj5dbptt9iF9NZr9pHbPhBrnT2klheu7mHTxTZ/LjwJiEiQ==} @@ -3072,10 +3091,10 @@ packages: uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} - use-sync-external-store@1.2.2: - resolution: {integrity: sha512-PElTlVMwpblvbNqQ82d2n6RjStvdSoNe9FG28kNfz3WiXilJm4DdNkEzRhCZuIDwY8U08WVihhGR5iRqAwfDiw==} + use-sync-external-store@1.4.0: + resolution: {integrity: sha512-9WXSPC5fMv61vaupRkCKCxsPxBocVnwakBEkMIHHpkTTg6icbJtg6jzgtLDm4bl3cSHAca52rYWih0k4K3PfHw==} peerDependencies: - react: ^16.8.0 || ^17.0.0 || ^18.0.0 + react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0 util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} @@ -3148,8 +3167,8 @@ packages: peerDependencies: vue: ^3.0.0 - vue@3.5.12: - resolution: {integrity: sha512-CLVZtXtn2ItBIi/zHZ0Sg1Xkb7+PU32bJJ8Bmy7ts3jxXTcbfsEfBivFYYWz1Hur+lalqGAh65Coin0r+HRUfg==} + vue@3.5.13: + resolution: {integrity: sha512-wmeiSMxkZCSc+PM2w2VRsOYAZC8GdipNFRTsLSfodVqI9mbejKeXEGr8SckuLnrQPGe3oJN5c3K0vpoU9q/wCQ==} peerDependencies: typescript: '*' peerDependenciesMeta: @@ -3855,14 +3874,14 @@ snapshots: '@shikijs/vitepress-twoslash@1.22.2(typescript@5.3.3)': dependencies: '@shikijs/twoslash': 1.22.2(typescript@5.3.3) - floating-vue: 5.2.2(vue@3.5.12(typescript@5.3.3)) + floating-vue: 5.2.2(vue@3.5.13(typescript@5.3.3)) mdast-util-from-markdown: 2.0.2 mdast-util-gfm: 3.0.0 mdast-util-to-hast: 13.2.0 shiki: 1.22.2 twoslash: 0.2.12(typescript@5.3.3) twoslash-vue: 0.2.12(typescript@5.3.3) - vue: 3.5.12(typescript@5.3.3) + vue: 3.5.13(typescript@5.3.3) transitivePeerDependencies: - '@nuxt/kit' - supports-color @@ -4085,10 +4104,10 @@ snapshots: '@ungap/structured-clone@1.2.0': {} - '@vitejs/plugin-vue@5.1.2(vite@5.4.2(@types/node@22.8.5)(terser@5.26.0))(vue@3.5.12(typescript@5.3.3))': + '@vitejs/plugin-vue@5.1.2(vite@5.4.2(@types/node@22.8.5)(terser@5.26.0))(vue@3.5.13(typescript@5.3.3))': dependencies: vite: 5.4.2(@types/node@22.8.5)(terser@5.26.0) - vue: 3.5.12(typescript@5.3.3) + vue: 3.5.13(typescript@5.3.3) '@volar/language-core@2.4.6': dependencies: @@ -4104,27 +4123,40 @@ snapshots: estree-walker: 2.0.2 source-map-js: 1.2.1 + '@vue/compiler-core@3.5.13': + dependencies: + '@babel/parser': 7.25.4 + '@vue/shared': 3.5.13 + entities: 4.5.0 + estree-walker: 2.0.2 + source-map-js: 1.2.1 + '@vue/compiler-dom@3.5.12': dependencies: '@vue/compiler-core': 3.5.12 '@vue/shared': 3.5.12 - '@vue/compiler-sfc@3.5.12': + '@vue/compiler-dom@3.5.13': + dependencies: + '@vue/compiler-core': 3.5.13 + '@vue/shared': 3.5.13 + + '@vue/compiler-sfc@3.5.13': dependencies: '@babel/parser': 7.25.4 - '@vue/compiler-core': 3.5.12 - '@vue/compiler-dom': 3.5.12 - '@vue/compiler-ssr': 3.5.12 - '@vue/shared': 3.5.12 + '@vue/compiler-core': 3.5.13 + '@vue/compiler-dom': 3.5.13 + '@vue/compiler-ssr': 3.5.13 + '@vue/shared': 3.5.13 estree-walker: 2.0.2 magic-string: 0.30.12 - postcss: 8.4.47 + postcss: 8.4.49 source-map-js: 1.2.1 - '@vue/compiler-ssr@3.5.12': + '@vue/compiler-ssr@3.5.13': dependencies: - '@vue/compiler-dom': 3.5.12 - '@vue/shared': 3.5.12 + '@vue/compiler-dom': 3.5.13 + '@vue/shared': 3.5.13 '@vue/compiler-vue2@2.7.16': dependencies: @@ -4154,7 +4186,7 @@ snapshots: '@volar/language-core': 2.4.6 '@vue/compiler-dom': 3.5.12 '@vue/compiler-vue2': 2.7.16 - '@vue/shared': 3.5.12 + '@vue/shared': 3.5.13 computeds: 0.0.1 minimatch: 9.0.5 muggle-string: 0.4.1 @@ -4162,45 +4194,47 @@ snapshots: optionalDependencies: typescript: 5.3.3 - '@vue/reactivity@3.5.12': + '@vue/reactivity@3.5.13': dependencies: - '@vue/shared': 3.5.12 + '@vue/shared': 3.5.13 - '@vue/runtime-core@3.5.12': + '@vue/runtime-core@3.5.13': dependencies: - '@vue/reactivity': 3.5.12 - '@vue/shared': 3.5.12 + '@vue/reactivity': 3.5.13 + '@vue/shared': 3.5.13 - '@vue/runtime-dom@3.5.12': + '@vue/runtime-dom@3.5.13': dependencies: - '@vue/reactivity': 3.5.12 - '@vue/runtime-core': 3.5.12 - '@vue/shared': 3.5.12 + '@vue/reactivity': 3.5.13 + '@vue/runtime-core': 3.5.13 + '@vue/shared': 3.5.13 csstype: 3.1.3 - '@vue/server-renderer@3.5.12(vue@3.5.12(typescript@5.3.3))': + '@vue/server-renderer@3.5.13(vue@3.5.13(typescript@5.3.3))': dependencies: - '@vue/compiler-ssr': 3.5.12 - '@vue/shared': 3.5.12 - vue: 3.5.12(typescript@5.3.3) + '@vue/compiler-ssr': 3.5.13 + '@vue/shared': 3.5.13 + vue: 3.5.13(typescript@5.3.3) '@vue/shared@3.5.12': {} - '@vueuse/core@11.0.3(vue@3.5.12(typescript@5.3.3))': + '@vue/shared@3.5.13': {} + + '@vueuse/core@11.0.3(vue@3.5.13(typescript@5.3.3))': dependencies: '@types/web-bluetooth': 0.0.20 '@vueuse/metadata': 11.0.3 - '@vueuse/shared': 11.0.3(vue@3.5.12(typescript@5.3.3)) - vue-demi: 0.14.10(vue@3.5.12(typescript@5.3.3)) + '@vueuse/shared': 11.0.3(vue@3.5.13(typescript@5.3.3)) + vue-demi: 0.14.10(vue@3.5.13(typescript@5.3.3)) transitivePeerDependencies: - '@vue/composition-api' - vue - '@vueuse/integrations@11.0.3(axios@1.7.7)(focus-trap@7.5.4)(vue@3.5.12(typescript@5.3.3))': + '@vueuse/integrations@11.0.3(axios@1.7.7)(focus-trap@7.5.4)(vue@3.5.13(typescript@5.3.3))': dependencies: - '@vueuse/core': 11.0.3(vue@3.5.12(typescript@5.3.3)) - '@vueuse/shared': 11.0.3(vue@3.5.12(typescript@5.3.3)) - vue-demi: 0.14.10(vue@3.5.12(typescript@5.3.3)) + '@vueuse/core': 11.0.3(vue@3.5.13(typescript@5.3.3)) + '@vueuse/shared': 11.0.3(vue@3.5.13(typescript@5.3.3)) + vue-demi: 0.14.10(vue@3.5.13(typescript@5.3.3)) optionalDependencies: axios: 1.7.7 focus-trap: 7.5.4 @@ -4210,9 +4244,9 @@ snapshots: '@vueuse/metadata@11.0.3': {} - '@vueuse/shared@11.0.3(vue@3.5.12(typescript@5.3.3))': + '@vueuse/shared@11.0.3(vue@3.5.13(typescript@5.3.3))': dependencies: - vue-demi: 0.14.10(vue@3.5.12(typescript@5.3.3)) + vue-demi: 0.14.10(vue@3.5.13(typescript@5.3.3)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -4995,11 +5029,11 @@ snapshots: flatted@3.3.1: {} - floating-vue@5.2.2(vue@3.5.12(typescript@5.3.3)): + floating-vue@5.2.2(vue@3.5.13(typescript@5.3.3)): dependencies: '@floating-ui/dom': 1.1.1 - vue: 3.5.12(typescript@5.3.3) - vue-resize: 2.0.0-alpha.1(vue@3.5.12(typescript@5.3.3)) + vue: 3.5.13(typescript@5.3.3) + vue-resize: 2.0.0-alpha.1(vue@3.5.13(typescript@5.3.3)) focus-trap@7.5.4: dependencies: @@ -5811,6 +5845,8 @@ snapshots: picocolors@1.1.0: {} + picocolors@1.1.1: {} + picomatch@2.3.1: {} picomatch@4.0.2: {} @@ -5889,6 +5925,12 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 + postcss@8.4.49: + dependencies: + nanoid: 3.3.7 + picocolors: 1.1.1 + source-map-js: 1.2.1 + preact@10.19.3: {} prelude-ls@1.2.1: {} @@ -6565,7 +6607,7 @@ snapshots: dependencies: punycode: 2.3.1 - use-sync-external-store@1.2.2(react@18.2.0): + use-sync-external-store@1.4.0(react@18.2.0): dependencies: react: 18.2.0 @@ -6600,17 +6642,17 @@ snapshots: '@shikijs/core': 1.14.1 '@shikijs/transformers': 1.14.1 '@types/markdown-it': 14.1.2 - '@vitejs/plugin-vue': 5.1.2(vite@5.4.2(@types/node@22.8.5)(terser@5.26.0))(vue@3.5.12(typescript@5.3.3)) + '@vitejs/plugin-vue': 5.1.2(vite@5.4.2(@types/node@22.8.5)(terser@5.26.0))(vue@3.5.13(typescript@5.3.3)) '@vue/devtools-api': 7.3.9 - '@vue/shared': 3.5.12 - '@vueuse/core': 11.0.3(vue@3.5.12(typescript@5.3.3)) - '@vueuse/integrations': 11.0.3(axios@1.7.7)(focus-trap@7.5.4)(vue@3.5.12(typescript@5.3.3)) + '@vue/shared': 3.5.13 + '@vueuse/core': 11.0.3(vue@3.5.13(typescript@5.3.3)) + '@vueuse/integrations': 11.0.3(axios@1.7.7)(focus-trap@7.5.4)(vue@3.5.13(typescript@5.3.3)) focus-trap: 7.5.4 mark.js: 8.11.1 minisearch: 7.1.0 shiki: 1.22.2 vite: 5.4.2(@types/node@22.8.5)(terser@5.26.0) - vue: 3.5.12(typescript@5.3.3) + vue: 3.5.13(typescript@5.3.3) optionalDependencies: postcss: 8.4.47 transitivePeerDependencies: @@ -6641,21 +6683,21 @@ snapshots: - typescript - universal-cookie - vue-demi@0.14.10(vue@3.5.12(typescript@5.3.3)): + vue-demi@0.14.10(vue@3.5.13(typescript@5.3.3)): dependencies: - vue: 3.5.12(typescript@5.3.3) + vue: 3.5.13(typescript@5.3.3) - vue-resize@2.0.0-alpha.1(vue@3.5.12(typescript@5.3.3)): + vue-resize@2.0.0-alpha.1(vue@3.5.13(typescript@5.3.3)): dependencies: - vue: 3.5.12(typescript@5.3.3) + vue: 3.5.13(typescript@5.3.3) - vue@3.5.12(typescript@5.3.3): + vue@3.5.13(typescript@5.3.3): dependencies: - '@vue/compiler-dom': 3.5.12 - '@vue/compiler-sfc': 3.5.12 - '@vue/runtime-dom': 3.5.12 - '@vue/server-renderer': 3.5.12(vue@3.5.12(typescript@5.3.3)) - '@vue/shared': 3.5.12 + '@vue/compiler-dom': 3.5.13 + '@vue/compiler-sfc': 3.5.13 + '@vue/runtime-dom': 3.5.13 + '@vue/server-renderer': 3.5.13(vue@3.5.13(typescript@5.3.3)) + '@vue/shared': 3.5.13 optionalDependencies: typescript: 5.3.3 @@ -6718,10 +6760,10 @@ snapshots: yocto-queue@0.1.0: {} - zustand@5.0.0(@types/react@18.2.79)(react@18.2.0)(use-sync-external-store@1.2.2(react@18.2.0)): + zustand@5.0.0(@types/react@18.2.79)(react@18.2.0)(use-sync-external-store@1.4.0(react@18.2.0)): optionalDependencies: '@types/react': 18.2.79 react: 18.2.0 - use-sync-external-store: 1.2.2(react@18.2.0) + use-sync-external-store: 1.4.0(react@18.2.0) zwitch@2.0.4: {} diff --git a/scripts/rollupBuild.ts b/scripts/rollupBuild.ts index fd43d4a..3e41df1 100644 --- a/scripts/rollupBuild.ts +++ b/scripts/rollupBuild.ts @@ -1,7 +1,53 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ import { rollupBuild } from "project-tool/rollup"; const start = async () => { - await rollupBuild({ packageName: "r-store", packageScope: "packages" }); + await rollupBuild({ + packageName: "r-store", + packageScope: "packages", + plugins: { + singleOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleDevUMD: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleDevOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleProdOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleProdUMD: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + }, + }); process.exit(0); }; diff --git a/scripts/rollupWatch.ts b/scripts/rollupWatch.ts index 57a00ba..b922d1a 100644 --- a/scripts/rollupWatch.ts +++ b/scripts/rollupWatch.ts @@ -1,3 +1,49 @@ +/* eslint-disable @typescript-eslint/no-var-requires */ import { rollupWatch } from "project-tool/rollup"; -rollupWatch({ packageName: "r-store", packageScope: "packages" }); +rollupWatch({ + packageName: "r-store", + packageScope: "packages", + plugins: { + singleOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleDevUMD: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleDevOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleProdOther: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + multipleProdUMD: ({ defaultPlugins, defaultPluginPackages: { replace } }) => { + return [ + ...defaultPlugins, + replace({ + __VUE_VERSION__: JSON.stringify(require("@vue/reactivity/package.json").version), + }), + ]; + }, + }, +});