Skip to content

Commit

Permalink
refactor: format filename
Browse files Browse the repository at this point in the history
  • Loading branch information
geekact committed Oct 20, 2023
1 parent 7abce13 commit adb1b2b
Show file tree
Hide file tree
Showing 73 changed files with 135 additions and 135 deletions.
2 changes: 1 addition & 1 deletion src/actions/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Action, AnyAction } from 'redux';
import { isFunction } from '../utils/isType';
import { isFunction } from '../utils/is-type';

export interface PreModelAction<State extends object = object, Payload = object>
extends Action<string> {
Expand Down
6 changes: 3 additions & 3 deletions src/api/getLoading.ts → src/api/get-loading.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { LOADING_CATEGORY } from '../actions/loading';
import { PromiseRoomEffect, PromiseEffect } from '../model/enhanceEffect';
import { loadingStore, FindLoading } from '../store/loadingStore';
import { isFunction } from '../utils/isType';
import { PromiseRoomEffect, PromiseEffect } from '../model/enhance-effect';
import { loadingStore, FindLoading } from '../store/loading-store';
import { isFunction } from '../utils/is-type';

/**
* 检测给定的effect方法中是否有正在执行的。支持多个方法同时传入。
Expand Down
4 changes: 2 additions & 2 deletions src/api/use-computed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComputedFlag } from '../model/types';
import { useModelSelector } from '../redux/useSelector';
import { toArgs } from '../utils/toArgs';
import { useModelSelector } from '../redux/use-selector';
import { toArgs } from '../utils/to-args';

export interface UseComputedFlag extends ComputedFlag {
(...args: any[]): any;
Expand Down
6 changes: 3 additions & 3 deletions src/api/use-isolate.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useEffect, useMemo, useRef, useState } from 'react';
import { DestroyLoadingAction, DESTROY_LOADING } from '../actions/loading';
import { loadingStore } from '../store/loadingStore';
import { modelStore } from '../store/modelStore';
import { cloneModel } from '../model/cloneModel';
import { loadingStore } from '../store/loading-store';
import { modelStore } from '../store/model-store';
import { cloneModel } from '../model/clone-model';
import { Model } from '../model/types';

let globalCounter = 0;
Expand Down
8 changes: 4 additions & 4 deletions src/api/useLoading.ts → src/api/use-loading.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { PromiseRoomEffect, PromiseEffect } from '../model/enhanceEffect';
import { FindLoading } from '../store/loadingStore';
import { useLoadingSelector } from '../redux/useSelector';
import { getLoading } from './getLoading';
import { PromiseRoomEffect, PromiseEffect } from '../model/enhance-effect';
import { FindLoading } from '../store/loading-store';
import { useLoadingSelector } from '../redux/use-selector';
import { getLoading } from './get-loading';

/**
* 检测给定的effect方法中是否有正在执行的。支持多个方法同时传入。
Expand Down
10 changes: 5 additions & 5 deletions src/model/useModel.ts → src/api/use-model.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { shallowEqual } from 'react-redux';
import { deepEqual } from '../utils/deepEqual';
import type { Model } from './types';
import { toArgs } from '../utils/toArgs';
import { useModelSelector } from '../redux/useSelector';
import { isFunction, isString } from '../utils/isType';
import { deepEqual } from '../utils/deep-equal';
import type { Model } from '../model/types';
import { toArgs } from '../utils/to-args';
import { useModelSelector } from '../redux/use-selector';
import { isFunction, isString } from '../utils/is-type';

/**
* hooks新旧数据的对比方式:
Expand Down
2 changes: 1 addition & 1 deletion src/engines/local.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StorageEngine } from './StorageEngine';
import type { StorageEngine } from './storage-engine';

export const local: StorageEngine = {
getItem(key) {
Expand Down
2 changes: 1 addition & 1 deletion src/engines/memory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StorageEngine } from './StorageEngine';
import type { StorageEngine } from './storage-engine';

let cache: Partial<Record<string, string>> = {};

Expand Down
2 changes: 1 addition & 1 deletion src/engines/session.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { StorageEngine } from './StorageEngine';
import type { StorageEngine } from './storage-engine';

export const session: StorageEngine = {
getItem(key) {
Expand Down
File renamed without changes.
16 changes: 8 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// 模型中使用
export { defineModel } from './model/defineModel';
export { cloneModel } from './model/cloneModel';
export { defineModel } from './model/define-model';
export { cloneModel } from './model/clone-model';

// 组件中使用
export { useModel } from './model/useModel';
export { useLoading } from './api/useLoading';
export { getLoading } from './api/getLoading';
export { useModel } from './api/use-model';
export { useLoading } from './api/use-loading';
export { getLoading } from './api/get-loading';
export { useComputed } from './api/use-computed';
export { useIsolate } from './api/use-isolate';
export { connect } from './redux/connect';

// 入口使用
export { compose } from 'redux';
export { modelStore as store } from './store/modelStore';
export { FocaProvider } from './redux/FocaProvider';
export { modelStore as store } from './store/model-store';
export { FocaProvider } from './redux/foca-provider';
export { engines } from './engines';
export { memoryStorage } from './engines/memory';

Expand All @@ -29,4 +29,4 @@ export type {
Unsubscribe,
} from 'redux';
export type { Model } from './model/types';
export type { StorageEngine } from './engines/StorageEngine';
export type { StorageEngine } from './engines/storage-engine';
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnyAction, Middleware } from 'redux';
import type { LoadingStore, LoadingStoreState } from '../store/loadingStore';
import type { LoadingStore, LoadingStoreState } from '../store/loading-store';
import { isLoadingAction } from '../actions/loading';

export const loadingInterceptor = (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AnyAction, Middleware } from 'redux';
import { deepEqual } from '../utils/deepEqual';
import { deepEqual } from '../utils/deep-equal';
import { isPreModelAction, PostModelAction } from '../actions/model';
import { immer } from '../utils/immer';

Expand Down
4 changes: 2 additions & 2 deletions src/model/cloneModel.ts → src/model/clone-model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { isFunction } from '../utils/isType';
import { defineModel } from './defineModel';
import { isFunction } from '../utils/is-type';
import { defineModel } from './define-model';
import type { DefineModelOptions, InternalModel, Model } from './types';

const editableKeys = [
Expand Down
20 changes: 10 additions & 10 deletions src/model/defineModel.ts → src/model/define-model.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { parseState, stringifyState } from '../utils/serialize';
import { deepEqual } from '../utils/deepEqual';
import { EnhancedAction, enhanceAction } from './enhanceAction';
import { EnhancedEffect, enhanceEffect } from './enhanceEffect';
import { modelStore } from '../store/modelStore';
import { createReducer } from '../redux/createReducer';
import { deepEqual } from '../utils/deep-equal';
import { EnhancedAction, enhanceAction } from './enhance-action';
import { EnhancedEffect, enhanceEffect } from './enhance-effect';
import { modelStore } from '../store/model-store';
import { createReducer } from '../redux/create-reducer';
import { composeGetter, defineGetter } from '../utils/getter';
import { getMethodCategory } from '../utils/getMethodCategory';
import { getMethodCategory } from '../utils/get-method-category';
import { guard } from './guard';
import { depsCollector } from '../reactive/depsCollector';
import { ObjectDeps } from '../reactive/ObjectDeps';
import { depsCollector } from '../reactive/deps-collector';
import { ObjectDeps } from '../reactive/object-deps';
import type {
ActionCtx,
EffectCtx,
Expand All @@ -22,10 +22,10 @@ import type {
SetStateCallback,
ComputedFlag,
} from './types';
import { isFunction } from '../utils/isType';
import { isFunction } from '../utils/is-type';
import { Unsubscribe } from 'redux';
import { freeze, original, isDraft } from 'immer';
import { isPromise } from '../utils/isPromise';
import { isPromise } from '../utils/is-promise';
import { enhanceComputed } from './enhance-computed';

export const defineModel = <
Expand Down
4 changes: 2 additions & 2 deletions src/model/enhanceAction.ts → src/model/enhance-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { PreModelAction } from '../actions/model';
import { modelStore } from '../store/modelStore';
import { toArgs } from '../utils/toArgs';
import { modelStore } from '../store/model-store';
import { toArgs } from '../utils/to-args';
import type { ActionCtx } from './types';

export interface EnhancedAction<State extends object> {
Expand Down
6 changes: 3 additions & 3 deletions src/model/enhance-computed.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ComputedValue } from '../reactive/ComputedValue';
import { modelStore } from '../store/modelStore';
import { toArgs } from '../utils/toArgs';
import { ComputedValue } from '../reactive/computed-value';
import { modelStore } from '../store/model-store';
import { toArgs } from '../utils/to-args';
import { ComputedCtx, ComputedFlag } from './types';

export const enhanceComputed = <State extends object>(
Expand Down
6 changes: 3 additions & 3 deletions src/model/enhanceEffect.ts → src/model/enhance-effect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
TYPE_SET_LOADING,
} from '../actions/loading';
import type { EffectCtx } from './types';
import { isPromise } from '../utils/isPromise';
import { toArgs } from '../utils/toArgs';
import { loadingStore } from '../store/loadingStore';
import { isPromise } from '../utils/is-promise';
import { toArgs } from '../utils/to-args';
import { loadingStore } from '../store/loading-store';

interface RoomFunc<P extends any[] = any[], R = Promise<any>> {
(category: number | string): {
Expand Down
4 changes: 2 additions & 2 deletions src/model/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { AnyAction } from 'redux';
import type { EnhancedEffect } from './enhanceEffect';
import type { PersistMergeMode } from '../persist/PersistItem';
import type { EnhancedEffect } from './enhance-effect';
import type { PersistMergeMode } from '../persist/persist-item';

export interface ComputedFlag {
readonly _computedFlag: never;
Expand Down
4 changes: 2 additions & 2 deletions src/persist/PersistGate.tsx → src/persist/persist-gate.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ReactNode, FC, useState, useEffect } from 'react';
import { modelStore } from '../store/modelStore';
import { isFunction } from '../utils/isType';
import { modelStore } from '../store/model-store';
import { isFunction } from '../utils/is-type';

export interface PersistGateProps {
loading?: ReactNode;
Expand Down
4 changes: 2 additions & 2 deletions src/persist/PersistItem.ts → src/persist/persist-item.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import type { StorageEngine } from '../engines/StorageEngine';
import type { StorageEngine } from '../engines/storage-engine';
import type {
GetInitialState,
InternalModel,
Model,
ModelPersist,
} from '../model/types';
import { isObject, isPlainObject, isString } from '../utils/isType';
import { isObject, isPlainObject, isString } from '../utils/is-type';
import { toPromise } from '../utils/to-promise';
import { parseState, stringifyState } from '../utils/serialize';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Reducer, Store, Unsubscribe } from 'redux';
import { actionHydrate, isHydrateAction } from '../actions/persist';
import { PersistItem, PersistOptions } from './PersistItem';
import { PersistItem, PersistOptions } from './persist-item';

export class PersistManager {
protected initialized: boolean = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { Store } from 'redux';
import { depsCollector } from './depsCollector';
import { createComputedDeps } from './createComputedDeps';
import type { Deps } from './ObjectDeps';
import { depsCollector } from './deps-collector';
import { createComputedDeps } from './create-computed-deps';
import type { Deps } from './object-deps';

export class ComputedValue<T = any> {
public deps: Deps[] = [];
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { shallowEqual } from 'react-redux';
import type { ComputedValue } from './ComputedValue';
import type { Deps } from './ObjectDeps';
import type { ComputedValue } from './computed-value';
import type { Deps } from './object-deps';

export const createComputedDeps = (body: ComputedValue): Deps => {
let snapshot: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Deps } from './ObjectDeps';
import type { Deps } from './object-deps';

const deps: Deps[][] = [];
let level = -1;
Expand Down
4 changes: 2 additions & 2 deletions src/reactive/ObjectDeps.ts → src/reactive/object-deps.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Store } from 'redux';
import { isObject } from '../utils/isType';
import { depsCollector } from './depsCollector';
import { isObject } from '../utils/is-type';
import { depsCollector } from './deps-collector';

export interface Deps {
id: string;
Expand Down
2 changes: 1 addition & 1 deletion src/redux/connect.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Connect, connect as originalConnect } from 'react-redux';
import { ProxyContext } from './contexts';
import { toArgs } from '../utils/toArgs';
import { toArgs } from '../utils/to-args';

export const connect: Connect = function () {
const args = toArgs<Parameters<Connect>>(arguments);
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions src/redux/FocaProvider.tsx → src/redux/foca-provider.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { FC } from 'react';
import { Provider } from 'react-redux';
import { ProxyContext, ModelContext, LoadingContext } from './contexts';
import { modelStore } from '../store/modelStore';
import { PersistGate, PersistGateProps } from '../persist/PersistGate';
import { proxyStore } from '../store/proxyStore';
import { loadingStore } from '../store/loadingStore';
import { isFunction } from '../utils/isType';
import { modelStore } from '../store/model-store';
import { PersistGate, PersistGateProps } from '../persist/persist-gate';
import { proxyStore } from '../store/proxy-store';
import { loadingStore } from '../store/loading-store';
import { isFunction } from '../utils/is-type';

interface OwnProps extends PersistGateProps {}

Expand Down
File renamed without changes.
14 changes: 7 additions & 7 deletions src/store/loadingStore.ts → src/store/loading-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ import {
legacy_createStore as createStore,
Middleware,
} from 'redux';
import type { PromiseRoomEffect, PromiseEffect } from '../model/enhanceEffect';
import { loadingInterceptor } from '../middleware/loadingInterceptor';
import type { PromiseRoomEffect, PromiseEffect } from '../model/enhance-effect';
import { loadingInterceptor } from '../middleware/loading.interceptor';
import { isDestroyLoadingAction, isLoadingAction } from '../actions/loading';
import { actionRefresh, isRefreshAction } from '../actions/refresh';
import { combine } from './proxyStore';
import { destroyLoadingInterceptor } from '../middleware/destroyLoadingInterceptor';
import { combine } from './proxy-store';
import { destroyLoadingInterceptor } from '../middleware/destroy-loading.interceptor';
import { immer } from '../utils/immer';
import { StoreBasic } from './StoreBasic';
import { modelStore } from './modelStore';
import { StoreBasic } from './store-basic';
import { modelStore } from './model-store';
import { freeze } from 'immer';
import { freezeStateMiddleware } from '../middleware/freezeStateMiddleware';
import { freezeStateMiddleware } from '../middleware/freeze-state.middleware';

export interface FindLoading {
find(category: number | string): boolean;
Expand Down
16 changes: 8 additions & 8 deletions src/store/modelStore.ts → src/store/model-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import {
} from 'redux';
import { Topic } from 'topic';
import { actionRefresh, RefreshAction } from '../actions/refresh';
import { modelInterceptor } from '../middleware/modelInterceptor';
import type { PersistOptions } from '../persist/PersistItem';
import { PersistManager } from '../persist/PersistManager';
import { combine } from './proxyStore';
import { OBJECT } from '../utils/isType';
import { StoreBasic } from './StoreBasic';
import { actionInActionInterceptor } from '../middleware/actionInActionInterceptor';
import { freezeStateMiddleware } from '../middleware/freezeStateMiddleware';
import { modelInterceptor } from '../middleware/model.interceptor';
import type { PersistOptions } from '../persist/persist-item';
import { PersistManager } from '../persist/persist-manager';
import { combine } from './proxy-store';
import { OBJECT } from '../utils/is-type';
import { StoreBasic } from './store-basic';
import { actionInActionInterceptor } from '../middleware/action-in-action.interceptor';
import { freezeStateMiddleware } from '../middleware/freeze-state.middleware';

type Compose =
| typeof compose
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/store/StoreBasic.ts → src/store/store-basic.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Store } from 'redux';
import { $$observable } from '../utils/symbolObservable';
import { $$observable } from '../utils/symbol-observable';

export abstract class StoreBasic<T> implements Store<T> {
protected origin: Store<T> | null = null;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/deepEqual.ts → src/utils/deep-equal.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OBJECT } from './isType';
import { OBJECT } from './is-type';

export const deepEqual = (a: any, b: any): boolean => {
if (a === b) return true;
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/getter.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { toArgs } from './toArgs';
import { toArgs } from './to-args';

export function composeGetter<
T extends object,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/isPromise.ts → src/utils/is-promise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FUNCTION, isFunction, isObject } from './isType';
import { FUNCTION, isFunction, isObject } from './is-type';

const hasPromise = typeof Promise === FUNCTION;

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/utils/serialize.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isObject } from './isType';
import { isObject } from './is-type';

const JSON_UNDEFINED = '__JSON_UNDEFINED__';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { FUNCTION } from './isType';
import { FUNCTION } from './is-type';

/**
* Inlined version of the `symbol-observable` polyfill
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/clone.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineModel, cloneModel, store } from '../src';
import type { InternalModel } from '../src/model/types';
import { basicModel } from './models/basicModel';
import { basicModel } from './models/basic.model';

let modelIndex = 0;

Expand Down
Loading

0 comments on commit adb1b2b

Please sign in to comment.