diff --git a/lib/features/runningTree.d.ts b/lib/features/runningTree.d.ts index 30e46f0b..dd1672aa 100644 --- a/lib/features/runningTree.d.ts +++ b/lib/features/runningTree.d.ts @@ -117,7 +117,7 @@ declare class ListNode; loadMore(): Promise; setCurrentPage(currentPage: number): void; - clean(): void; + clean(dontPublish?: true): void; getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined; } declare class SingleNode extends Node { @@ -179,7 +179,7 @@ declare class SingleNode): void; refresh(): Promise; - clean(): void; + clean(dontPublish?: true): void; private getFilter; getIntrinsticFilters(): ED[T]["Selection"]["filter"] | undefined; /** @@ -217,7 +217,7 @@ declare class VirtualNode extends Featur setExecuting(executing: boolean): void; isExecuting(): boolean; isLoading(): boolean; - clean(): void; + clean(dontPublish?: true): void; checkIfClean(): void; } export type CreateNodeOptions = { diff --git a/lib/features/runningTree.js b/lib/features/runningTree.js index 32579540..125854ca 100644 --- a/lib/features/runningTree.js +++ b/lib/features/runningTree.js @@ -726,7 +726,7 @@ class ListNode extends Node { constructSelection(withParent, ignoreNewParent, ignoreUnapplied) { const { sorters, getTotal } = this; const data = this.getProjection(); - // (0, assert_1.assert)(data, '取数据时找不到projection信息'); + // assert(data, '取数据时找不到projection信息'); const sorterArr = sorters.filter(ele => !ignoreUnapplied || ele.applied).map((ele) => { const { sorter } = ele; if (typeof sorter === 'function') { @@ -841,15 +841,17 @@ class ListNode extends Node { setCurrentPage(currentPage) { this.refresh(currentPage, false); } - clean() { + clean(dontPublish) { if (this.dirty) { const originUpdates = this.updates; this.updates = {}; for (const k in this.children) { - this.children[k].clean(); + this.children[k].clean(dontPublish); } this.dirty = undefined; - this.publish(); + if (!dontPublish) { + this.publish(); + } } } // 查看这个list上所有数据必须遵守的限制 @@ -1117,14 +1119,14 @@ class SingleNode extends Node { if (attr === 'entityId') { (0, assert_1.assert)(data.entity, '设置entityId时请将entity也传入'); if (this.children[data.entity]) { - this.children[data.entity].clean(); + this.children[data.entity].clean(true); this.passRsToChild(data.entity); } } else if (this.schema[this.entity].attributes[attr]?.type === 'ref') { const refKey = attr.slice(0, attr.length - 2); if (this.children[refKey]) { - this.children[refKey].clean(); + this.children[refKey].clean(true); this.passRsToChild(refKey); } } @@ -1331,14 +1333,16 @@ class SingleNode extends Node { this.publish(); } } - clean() { + clean(dontPublish) { if (this.dirty) { this.operation = undefined; for (const child in this.children) { - this.children[child].clean(); + this.children[child].clean(dontPublish); } this.dirty = undefined; - this.publish(); + if (!dontPublish) { + this.publish(); + } } } getFilter() { @@ -1550,12 +1554,14 @@ class VirtualNode extends Feature_1.Feature { isLoading() { return this.loading; } - clean() { + clean(dontPublish) { for (const ele in this.children) { - this.children[ele].clean(); + this.children[ele].clean(dontPublish); } this.dirty = false; - this.publish(); + if (!dontPublish) { + this.publish(); + } } checkIfClean() { for (const k in this.children) { @@ -2044,7 +2050,7 @@ class RunningTree extends Feature_1.Feature { .filter((ele) => !!ele) .map((ele) => ele.operation), undefined, () => { // 清空缓存 - node.clean(); + node.clean(true); if (node instanceof SingleNode) { (0, assert_1.assert)(operations.length === 1); // 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108 @@ -2058,7 +2064,7 @@ class RunningTree extends Feature_1.Feature { }); return result; } - node.clean(); + node.clean(true); node.setExecuting(false); return { message: 'No Operation' }; } diff --git a/lib/page.mp.js b/lib/page.mp.js index 6e536a30..a2f50f70 100644 --- a/lib/page.mp.js +++ b/lib/page.mp.js @@ -163,11 +163,11 @@ const oakBehavior = Behavior({ switchTab(option, state) { return this.features.navigator.switchTab(option, state); }, - clean(path) { + clean(dontPublish, path) { const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath; - return this.features.runningTree.clean(path2); + return this.features.runningTree.clean(path2, dontPublish); }, isDirty(path) { return this.features.runningTree.isDirty(path || this.state.oakFullpath); diff --git a/lib/page.native.d.ts b/lib/page.native.d.ts index 7db4a537..efba48a1 100644 --- a/lib/page.native.d.ts +++ b/lib/page.native.d.ts @@ -5,4 +5,4 @@ import { Feature } from './types/Feature'; import { DataOption, OakComponentOption } from './types/Page'; import { SyncContext } from 'oak-domain/lib/store/SyncRowStore'; import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore'; -export declare function createComponent, FrontCxt extends SyncContext, AD extends Record>>, FD extends Record, FormedData extends Record, TData extends Record = {}, TProperty extends DataOption = {}, TMethod extends Record = {}>(option: OakComponentOption, features: BasicFeatures & FD): (props: any) => import("react/jsx-runtime").JSX.Element; +export declare function createComponent, FrontCxt extends SyncContext, AD extends Record>>, FD extends Record, FormedData extends Record, TData extends Record = {}, TProperty extends DataOption = {}, TMethod extends Record = {}>(option: OakComponentOption, features: BasicFeatures & FD): (props: any) => any; diff --git a/lib/page.react.d.ts b/lib/page.react.d.ts index ec791472..f9017a96 100644 --- a/lib/page.react.d.ts +++ b/lib/page.react.d.ts @@ -1,10 +1,9 @@ -import React from 'react'; import { Aspect, CheckerType, EntityDict, OpRecord } from 'oak-domain/lib/types'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain'; import { BasicFeatures } from './features'; import { NamedFilterItem, NamedSorterItem } from './types/NamedCondition'; import { Feature } from './types/Feature'; -import { DataOption, ComponentData, ComponentProps, OakComponentOption, OakNavigateToParameters } from './types/Page'; +import { DataOption, ComponentProps, OakComponentOption, OakNavigateToParameters } from './types/Page'; import { MessageProps } from './types/Message'; import { NotificationProps } from './types/Notification'; import { SyncContext } from 'oak-domain/lib/store/SyncRowStore'; @@ -64,7 +63,7 @@ export declare function createComponent(data: Omit, path?: string | undefined): void; remove(path?: string | undefined): void; isCreation(path?: string | undefined): boolean; - clean(path?: string | undefined): void; + clean(dontPublish?: true | undefined, path?: string | undefined): void; t(key: string, params?: object | undefined): string; execute(action?: ED[T]["Action"] | undefined, messageProps?: boolean | MessageProps | undefined, path?: string | undefined, opers?: { entity: T; @@ -101,23 +100,5 @@ export declare function createComponent[]) => void): Promise; unsubDataEvents(events: string[], moduleName: string): Promise; - context: unknown; - setState>(state: ComponentData | ((prevState: Readonly>, props: Readonly>) => ComponentData | Pick, K> | null) | Pick, K> | null, callback?: (() => void) | undefined): void; - forceUpdate(callback?: (() => void) | undefined): void; - readonly props: Readonly>; - state: Readonly>; - refs: { - [key: string]: React.ReactInstance; - }; - shouldComponentUpdate?(nextProps: Readonly>, nextState: Readonly>, nextContext: any): boolean; - componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; - getSnapshotBeforeUpdate?(prevProps: Readonly>, prevState: Readonly>): any; - componentWillMount?(): void; - UNSAFE_componentWillMount?(): void; - componentWillReceiveProps?(nextProps: Readonly>, nextContext: any): void; - UNSAFE_componentWillReceiveProps?(nextProps: Readonly>, nextContext: any): void; - componentWillUpdate?(nextProps: Readonly>, nextState: Readonly>, nextContext: any): void; - UNSAFE_componentWillUpdate?(nextProps: Readonly>, nextState: Readonly>, nextContext: any): void; }; - contextType?: React.Context | undefined; }; diff --git a/lib/page.react.js b/lib/page.react.js index d2dbe426..a622107a 100644 --- a/lib/page.react.js +++ b/lib/page.react.js @@ -157,11 +157,11 @@ class OakComponentBase extends react_1.default.PureComponent { throw err; } } - clean(path) { + clean(dontPublish, path) { const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath; - this.features.runningTree.clean(path2); + this.features.runningTree.clean(path2, dontPublish); } t(key, params) { return this.features.locales.t(key, params); @@ -456,8 +456,8 @@ function createComponent(option, features) { redirectTo: (options, state, disableNamespace) => { return this.redirectTo(options, state, disableNamespace); }, - clean: (path) => { - return this.clean(path); + clean: (dontPublish, path) => { + return this.clean(dontPublish, path); }, checkOperation: (entity, operation, checkerTypes) => { return this.checkOperation(entity, operation, checkerTypes); diff --git a/lib/page.web.d.ts b/lib/page.web.d.ts index 2f5bea53..a94c1ec6 100644 --- a/lib/page.web.d.ts +++ b/lib/page.web.d.ts @@ -1,4 +1,3 @@ -import React from 'react'; import { Aspect, EntityDict } from 'oak-domain/lib/types'; import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain'; import { BasicFeatures } from './features'; @@ -6,4 +5,4 @@ import { Feature } from './types/Feature'; import { DataOption, OakComponentOption } from './types/Page'; import { SyncContext } from 'oak-domain/lib/store/SyncRowStore'; import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore'; -export declare function createComponent, FrontCxt extends SyncContext, AD extends Record>>, FD extends Record, FormedData extends Record, TData extends Record = {}, TProperty extends DataOption = {}, TMethod extends Record = {}>(option: OakComponentOption, features: BasicFeatures & FD): React.ForwardRefExoticComponent>; +export declare function createComponent, FrontCxt extends SyncContext, AD extends Record>>, FD extends Record, FormedData extends Record, TData extends Record = {}, TProperty extends DataOption = {}, TMethod extends Record = {}>(option: OakComponentOption, features: BasicFeatures & FD): any; diff --git a/lib/page.web.js b/lib/page.web.js index b277db9f..e2a074ff 100644 --- a/lib/page.web.js +++ b/lib/page.web.js @@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.createComponent = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); +const react_1 = tslib_1.__importDefault(require("react")); const withRouter_1 = tslib_1.__importDefault(require("./platforms/web/router/withRouter")); const PullToRefresh_1 = tslib_1.__importDefault(require("./platforms/web/PullToRefresh")); const page_react_1 = require("./page.react"); diff --git a/lib/platforms/native/features/index.d.ts b/lib/platforms/native/features/index.d.ts index ed07a4f1..61a6578a 100644 --- a/lib/platforms/native/features/index.d.ts +++ b/lib/platforms/native/features/index.d.ts @@ -4,6 +4,6 @@ type Props = { features: Record; children: React.ReactNode; }; -declare const FeaturesProvider: (props: Props) => import("react/jsx-runtime").JSX.Element; -declare const useFeatures: >() => FD2; +declare const FeaturesProvider: (props: Props) => any; +declare const useFeatures: >() => any; export { FeaturesProvider, useFeatures }; diff --git a/lib/platforms/native/router/withRouter.d.ts b/lib/platforms/native/router/withRouter.d.ts index 3bc7084f..e1f32c1b 100644 --- a/lib/platforms/native/router/withRouter.d.ts +++ b/lib/platforms/native/router/withRouter.d.ts @@ -1,7 +1,6 @@ -import React from 'react'; type OakComponentProperties = { path?: string; properties?: Record; }; -declare const withRouter: (Component: React.ComponentType, { path, properties }: OakComponentProperties) => (props: any) => import("react/jsx-runtime").JSX.Element; +declare const withRouter: (Component: React.ComponentType, { path, properties }: OakComponentProperties) => (props: any) => any; export default withRouter; diff --git a/lib/platforms/native/router/withRouter.js b/lib/platforms/native/router/withRouter.js index 39cb68cf..a0858dde 100644 --- a/lib/platforms/native/router/withRouter.js +++ b/lib/platforms/native/router/withRouter.js @@ -1,6 +1,8 @@ "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); +const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); +const react_1 = tslib_1.__importDefault(require("react")); const assert_1 = require("oak-domain/lib/utils/assert"); function getParams(params, properties) { const props = getProps(params, properties); diff --git a/lib/platforms/web/PullToRefresh.js b/lib/platforms/web/PullToRefresh.js index a2170211..cbab5c59 100644 --- a/lib/platforms/web/PullToRefresh.js +++ b/lib/platforms/web/PullToRefresh.js @@ -2,6 +2,7 @@ Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); +const react_1 = tslib_1.__importDefault(require("react")); const rmc_pull_to_refresh_1 = tslib_1.__importDefault(require("rmc-pull-to-refresh")); require("./PullToRefresh.css"); const OakPullToRefresh = (props) => { diff --git a/lib/platforms/web/features/index.d.ts b/lib/platforms/web/features/index.d.ts index 18e3356a..08182f40 100644 --- a/lib/platforms/web/features/index.d.ts +++ b/lib/platforms/web/features/index.d.ts @@ -4,5 +4,5 @@ declare const FeaturesProvider: React.FC<{ features: Record; children: React.ReactNode; }>; -declare const useFeatures: >() => FD2; +declare const useFeatures: >() => any; export { FeaturesProvider, useFeatures }; diff --git a/lib/platforms/web/responsive/context.d.ts b/lib/platforms/web/responsive/context.d.ts index 08e5d73e..0fded541 100644 --- a/lib/platforms/web/responsive/context.d.ts +++ b/lib/platforms/web/responsive/context.d.ts @@ -1,4 +1,3 @@ -import React from 'react'; export type Width = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl'; export type Keys = Width[]; export type Values = { @@ -16,6 +15,4 @@ export type Breakpoints = { export declare const keys: Keys; export declare const values: Values; export declare const defaultBreakpoints: Breakpoints; -export declare const ResponsiveContext: React.Context<{ - breakpoints?: Breakpoints | undefined; -}>; +export declare const ResponsiveContext: any; diff --git a/lib/platforms/web/router/withRouter.d.ts b/lib/platforms/web/router/withRouter.d.ts index 5eda84fb..21857320 100644 --- a/lib/platforms/web/router/withRouter.d.ts +++ b/lib/platforms/web/router/withRouter.d.ts @@ -1,7 +1,6 @@ -import React from 'react'; type OakComponentProperties = { path?: string; properties?: Record; }; -declare const withRouter: (Component: React.ComponentType, { path, properties }: OakComponentProperties) => React.ForwardRefExoticComponent>; +declare const withRouter: (Component: React.ComponentType, { path, properties }: OakComponentProperties) => any; export default withRouter; diff --git a/lib/types/Page.d.ts b/lib/types/Page.d.ts index aa964a8b..7b835149 100644 --- a/lib/types/Page.d.ts +++ b/lib/types/Page.d.ts @@ -156,7 +156,7 @@ export type OakCommonComponentMethods Promise; redirectTo: (options: Parameters[0] & OakNavigateToParameters, state?: Record, disableNamespace?: boolean) => Promise; switchTab: (options: Parameters[0] & OakNavigateToParameters, state?: Record, disableNamespace?: boolean) => Promise; - clean: (path?: string) => void; + clean: (dontPublish?: true, path?: string) => void; isDirty: (path?: string) => boolean; t(key: string, params?: object): string; execute: (action?: ED[T]['Action'], messageProps?: boolean | MessageProps, path?: string, opers?: Array<{ diff --git a/src/features/runningTree.ts b/src/features/runningTree.ts index 129d02a7..2a5f3e4a 100644 --- a/src/features/runningTree.ts +++ b/src/features/runningTree.ts @@ -1027,16 +1027,18 @@ class ListNode< this.refresh(currentPage, false); } - clean() { + clean(dontPublish?: true) { if (this.dirty) { const originUpdates = this.updates; this.updates = {}; for (const k in this.children) { - this.children[k].clean(); + this.children[k].clean(dontPublish); } this.dirty = undefined; - this.publish(); + if (!dontPublish) { + this.publish(); + } } } @@ -1346,14 +1348,14 @@ class SingleNode extends Feature undefined, () => { // 清空缓存 - node.clean(); + node.clean(true); if (node instanceof SingleNode) { assert(operations.length === 1); // 这逻辑有点扯,页面自己决定后续逻辑 by Xc 20231108 @@ -2523,7 +2529,7 @@ export class RunningTree extends Feature return result; } - node.clean(); + node.clean(true); node.setExecuting(false); return { message: 'No Operation' }; @@ -2536,10 +2542,10 @@ export class RunningTree extends Feature } } - clean(path: string) { + clean(path: string, dontPublish?: true) { const node = this.findNode(path)!; - node.clean(); + node.clean(dontPublish); const parent = node.getParent(); if (parent) { parent.checkIfClean(); diff --git a/src/page.mp.ts b/src/page.mp.ts index 4f75e0be..0cc4ec6d 100644 --- a/src/page.mp.ts +++ b/src/page.mp.ts @@ -279,11 +279,11 @@ const oakBehavior = Behavior< return this.features.navigator.switchTab(option, state); }, - clean(path) { + clean(dontPublish, path) { const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath; - return this.features.runningTree.clean(path2); + return this.features.runningTree.clean(path2, dontPublish); }, isDirty(path) { diff --git a/src/page.react.tsx b/src/page.react.tsx index 9408dd6a..a7dd8b29 100644 --- a/src/page.react.tsx +++ b/src/page.react.tsx @@ -301,11 +301,11 @@ abstract class OakComponentBase< } } - clean(path?: string) { + clean(dontPublish?: true, path?: string) { const path2 = path ? `${this.state.oakFullpath}.${path}` : this.state.oakFullpath; - this.features.runningTree.clean(path2); + this.features.runningTree.clean(path2, dontPublish); } t(key: string, params?: object) { @@ -762,8 +762,8 @@ export function createComponent< disableNamespace ); }, - clean: (path?: string) => { - return this.clean(path); + clean: (dontPublish?: true, path?: string) => { + return this.clean(dontPublish, path); }, checkOperation: (entity: T2, operation: ED[T2]['Operation'], checkerTypes?: CheckerType[]) => { return this.checkOperation(entity, operation, checkerTypes); diff --git a/src/types/Page.ts b/src/types/Page.ts index 8b3ebd94..26fd87ff 100644 --- a/src/types/Page.ts +++ b/src/types/Page.ts @@ -369,7 +369,7 @@ export type OakCommonComponentMethods< disableNamespace?: boolean ) => Promise; // setProps: (props: Record, usingState?: true) => void; - clean: (path?: string) => void; + clean: (dontPublish?: true, path?: string) => void; isDirty: (path?: string) => boolean; t(key: string, params?: object): string;