重构了初始化过程,简化了调用逻辑
This commit is contained in:
parent
fd5dba5556
commit
204044faa5
|
|
@ -1,4 +1,4 @@
|
|||
import { AspectWrapper, EntityDict } from 'oak-domain/lib/types';
|
||||
import { Aspect, AspectWrapper, EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { Cache } from './cache';
|
||||
|
|
@ -15,27 +15,16 @@ import { Navigator } from './navigator';
|
|||
import { Port } from './port';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt>>(aspectWrapper: AspectWrapper<ED, Cxt, AD>, storageSchema: StorageSchema<ED>, contextBuilder: () => FrontCxt, store: CacheStore<ED, FrontCxt>): {
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>, storageSchema: StorageSchema<ED>, contextBuilder: () => FrontCxt, store: CacheStore<ED, FrontCxt>): BasicFeatures<ED, Cxt, FrontCxt, AD>;
|
||||
export declare type BasicFeatures<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>> = {
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
location: Location;
|
||||
runningTree: RunningTree<ED, Cxt, FrontCxt, AD>;
|
||||
locales: Locales<ED, Cxt, AD>;
|
||||
runningTree: RunningTree<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
locales: Locales<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
eventBus: EventBus;
|
||||
localStorage: LocalStorage;
|
||||
notification: Notification;
|
||||
message: Message;
|
||||
navigator: Navigator;
|
||||
port: Port<ED, Cxt, AD>;
|
||||
};
|
||||
export declare type BasicFeatures<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt>> = {
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||
location: Location;
|
||||
runningTree: RunningTree<ED, Cxt, FrontCxt, AD>;
|
||||
locales: Locales<ED, Cxt, AD>;
|
||||
eventBus: EventBus;
|
||||
localStorage: LocalStorage;
|
||||
notification: Notification;
|
||||
message: Message;
|
||||
navigator: Navigator;
|
||||
port: Port<ED, Cxt, AD>;
|
||||
port: Port<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import { Aspect, Checker, Trigger, StorageSchema, Watcher, Routine, Timer, AuthD
|
|||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Exportation, Importation } from 'oak-domain/lib/types/Port';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
|
|
@ -23,8 +22,8 @@ import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
|||
* @param actionDict
|
||||
* @returns
|
||||
*/
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, backendContextBuilder: (contextStr?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, timers?: Array<Timer<ED, Cxt>>, startRoutines?: Array<Routine<ED, Cxt>>, initialData?: {
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(storageSchema: StorageSchema<ED>, frontendContextBuilder: () => (store: CacheStore<ED, FrontCxt>) => FrontCxt, backendContextBuilder: (contextStr?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, timers?: Array<Timer<ED, Cxt>>, startRoutines?: Array<Routine<ED, Cxt>>, initialData?: {
|
||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
}, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>, importations?: Importation<ED, keyof ED, any>[], exportations?: Exportation<ED, keyof ED, any>[]): {
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
features: BasicFeatures<ED, Cxt, FrontCxt, CommonAspectDict<ED, Cxt> & AD>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ var CacheStore_1 = require("./cacheStore/CacheStore");
|
|||
* @param actionDict
|
||||
* @returns
|
||||
*/
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, importations, exportations) {
|
||||
function initialize(storageSchema, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, importations, exportations) {
|
||||
var _this = this;
|
||||
var intersected = (0, lodash_1.intersection)(Object.keys(oak_common_aspect_1.default), Object.keys(aspectDict));
|
||||
if (intersected.length > 0) {
|
||||
|
|
@ -34,7 +34,6 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, backe
|
|||
var checkers2 = (checkers || []).concat((0, index_1.createDynamicCheckers)(storageSchema, authDict));
|
||||
var triggers2 = (0, index_2.createDynamicTriggers)(storageSchema).concat(triggers || []);
|
||||
var debugStore = (0, debugStore_1.createDebugStore)(storageSchema, backendContextBuilder, triggers2, checkers2, watchers || [], timers, startRoutines, initialData, actionDict);
|
||||
var features = {};
|
||||
var cacheStore = new CacheStore_1.CacheStore(storageSchema, function () { return debugStore.getCurrentData(); }, function () { return (0, debugStore_1.clearMaterializedData)(); });
|
||||
var wrapper = {
|
||||
exec: function (name, params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
|
|
@ -42,7 +41,7 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, backe
|
|||
return tslib_1.__generator(this, function (_a) {
|
||||
switch (_a.label) {
|
||||
case 0:
|
||||
context = frontendContextBuilder(features)(cacheStore);
|
||||
context = frontendContextBuilder()(cacheStore);
|
||||
str = context.toString();
|
||||
return [4 /*yield*/, backendContextBuilder(str)(debugStore)];
|
||||
case 1:
|
||||
|
|
@ -75,13 +74,7 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, backe
|
|||
});
|
||||
}); },
|
||||
};
|
||||
var basicFeatures = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder(features)(cacheStore); }, cacheStore);
|
||||
var userDefinedfeatures = createFeatures(basicFeatures);
|
||||
intersected = (0, lodash_1.intersection)(Object.keys(basicFeatures), Object.keys(userDefinedfeatures));
|
||||
if (intersected.length > 0) {
|
||||
throw new Error("\u7528\u6237\u5B9A\u4E49\u7684feature\u4E2D\u4E0D\u80FD\u548C\u7CFB\u7EDFfeature\u540C\u540D\uFF1A\u300C".concat(intersected.join(','), "\u300D"));
|
||||
}
|
||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore);
|
||||
checkers2.forEach(function (checker) { return cacheStore.registerChecker(checker); });
|
||||
if (actionDict) {
|
||||
var adCheckers = (0, actionDef_1.analyzeActionDefDict)(storageSchema, actionDict).checkers;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
import { Aspect, Checker, StorageSchema, Connector, AuthDefDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
|
|
@ -21,6 +19,6 @@ import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
|||
* @param actionDict
|
||||
* @returns
|
||||
*/
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, connector: Connector<ED, Cxt, FrontCxt>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>): {
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>>(storageSchema: StorageSchema<ED>, frontendContextBuilder: () => (store: CacheStore<ED, FrontCxt>) => FrontCxt, connector: Connector<ED, Cxt, FrontCxt>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>): {
|
||||
features: import("./features").BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||
exports.initialize = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var features_1 = require("./features");
|
||||
var lodash_1 = require("oak-domain/lib/utils/lodash");
|
||||
var actionDef_1 = require("oak-domain/lib/store/actionDef");
|
||||
var CacheStore_1 = require("./cacheStore/CacheStore");
|
||||
var checkers_1 = require("oak-domain/lib/checkers");
|
||||
|
|
@ -20,10 +19,9 @@ var checkers_1 = require("oak-domain/lib/checkers");
|
|||
* @param actionDict
|
||||
* @returns
|
||||
*/
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, connector, checkers, actionDict, authDict) {
|
||||
function initialize(storageSchema, frontendContextBuilder, connector, checkers, actionDict, authDict) {
|
||||
var _this = this;
|
||||
var checkers2 = (checkers || []).concat((0, checkers_1.createDynamicCheckers)(storageSchema, authDict));
|
||||
var features = {};
|
||||
var cacheStore = new CacheStore_1.CacheStore(storageSchema);
|
||||
var wrapper = {
|
||||
exec: function (name, params) { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
||||
|
|
@ -31,7 +29,7 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, conne
|
|||
return tslib_1.__generator(this, function (_b) {
|
||||
switch (_b.label) {
|
||||
case 0:
|
||||
context = frontendContextBuilder(features)(cacheStore);
|
||||
context = frontendContextBuilder()(cacheStore);
|
||||
return [4 /*yield*/, connector.callAspect(name, params, context)];
|
||||
case 1:
|
||||
_a = _b.sent(), result = _a.result, opRecords = _a.opRecords, message = _a.message;
|
||||
|
|
@ -44,13 +42,7 @@ function initialize(storageSchema, createFeatures, frontendContextBuilder, conne
|
|||
});
|
||||
}); },
|
||||
};
|
||||
var basicFeatures = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder(features)(cacheStore); }, cacheStore);
|
||||
var userDefinedfeatures = createFeatures(basicFeatures);
|
||||
var intersected = (0, lodash_1.intersection)(Object.keys(basicFeatures), Object.keys(userDefinedfeatures));
|
||||
if (intersected.length > 0) {
|
||||
throw new Error("\u7528\u6237\u5B9A\u4E49\u7684feature\u4E2D\u4E0D\u80FD\u548C\u7CFB\u7EDFfeature\u540C\u540D\uFF1A\u300C".concat(intersected.join(','), "\u300D"));
|
||||
}
|
||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||
var features = (0, features_1.initialize)(wrapper, storageSchema, function () { return frontendContextBuilder()(cacheStore); }, cacheStore);
|
||||
checkers2.forEach(function (checker) { return cacheStore.registerChecker(checker); });
|
||||
if (actionDict) {
|
||||
var adCheckers = (0, actionDef_1.analyzeActionDefDict)(storageSchema, actionDict).checkers;
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.dev.mp.ts获initialize.dev.web.ts
|
||||
*/
|
||||
import { initialize as initMp } from './initialize.dev.mp';
|
||||
export declare const initialize: typeof initMp;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.dev.mp.ts获initialize.dev.web.ts
|
||||
*/
|
||||
var initialize_dev_mp_1 = require("./initialize.dev.mp");
|
||||
console.log('不应该跑到这里');
|
||||
exports.initialize = initialize_dev_mp_1.initialize;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import { Aspect, Routine, Checker, Trigger, StorageSchema, Watcher, Timer, AuthDefDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Exportation, Importation } from 'oak-domain/lib/types/Port';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { I18nOptions } from './platforms/wechatMp/i18n';
|
||||
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, backendContextBuilder: (contextStr?: string) => (store: AsyncRowStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, timers?: Array<Timer<ED, Cxt>>, startRoutines?: Array<Routine<ED, Cxt>>, initialData?: {
|
||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
}, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>, i18nOptions?: I18nOptions, importations?: Importation<ED, keyof ED, any>[], exportations?: Exportation<ED, keyof ED, any>[]): {
|
||||
i18n: import("./platforms/wechatMp/i18n").I18nWechatMpRuntimeBase;
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
require("./utils/wx.polyfill");
|
||||
var page_mp_1 = require("./page.mp");
|
||||
var initialize_dev_1 = require("./initialize-dev");
|
||||
var i18n_1 = require("./platforms/wechatMp/i18n");
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, i18nOptions, importations, exportations) {
|
||||
var features = (0, initialize_dev_1.initialize)(storageSchema, createFeatures, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, importations, exportations).features;
|
||||
// 初始化i8n配置
|
||||
var i18n = (0, i18n_1.getI18next)(i18nOptions);
|
||||
Object.assign(global, {
|
||||
OakComponent: function (options) {
|
||||
return (0, page_mp_1.createComponent)(options, features);
|
||||
},
|
||||
});
|
||||
return {
|
||||
i18n: i18n,
|
||||
features: features,
|
||||
};
|
||||
}
|
||||
exports.initialize = initialize;
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import { Aspect, Checker, Trigger, StorageSchema, Watcher, Routine, Timer, AuthDefDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Exportation, Importation } from 'oak-domain/lib/types/Port';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { I18nOptions } from './platforms/web/i18n';
|
||||
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, backendContextBuilder: (contextStr?: string) => (store: AsyncRowStore<ED, Cxt>) => Promise<Cxt>, aspectDict: AD, triggers?: Array<Trigger<ED, keyof ED, Cxt>>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, watchers?: Array<Watcher<ED, keyof ED, Cxt>>, timers?: Array<Timer<ED, Cxt>>, startRoutines?: Array<Routine<ED, Cxt>>, initialData?: {
|
||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
}, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>, i18nOptions?: I18nOptions, importations?: Importation<ED, keyof ED, any>[], exportations?: Exportation<ED, keyof ED, any>[]): {
|
||||
i18n: import("i18next").i18n;
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
require("./utils/wx.polyfill");
|
||||
var page_web_1 = require("./page.web");
|
||||
var initialize_dev_1 = require("./initialize-dev");
|
||||
var i18n_1 = require("./platforms/web/i18n");
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, i18nOptions, importations, exportations) {
|
||||
var features = (0, initialize_dev_1.initialize)(storageSchema, createFeatures, frontendContextBuilder, backendContextBuilder, aspectDict, triggers, checkers, watchers, timers, startRoutines, initialData, actionDict, authDict, importations, exportations).features;
|
||||
// 初始化i8n配置
|
||||
var i18n = (0, i18n_1.getI18next)(i18nOptions);
|
||||
Object.assign(global, {
|
||||
OakComponent: function (options) {
|
||||
return (0, page_web_1.createComponent)(options, features);
|
||||
},
|
||||
});
|
||||
return {
|
||||
i18n: i18n,
|
||||
features: features,
|
||||
};
|
||||
}
|
||||
exports.initialize = initialize;
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.prod.mp.ts获initialize.prod.web.ts
|
||||
*/
|
||||
import { initialize as initMp } from './initialize.prod.mp';
|
||||
export declare const initialize: typeof initMp;
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.prod.mp.ts获initialize.prod.web.ts
|
||||
*/
|
||||
var initialize_prod_mp_1 = require("./initialize.prod.mp");
|
||||
console.log('不应该跑到这里');
|
||||
exports.initialize = initialize_prod_mp_1.initialize;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import { Aspect, Checker, StorageSchema, Connector, AuthDefDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { I18nOptions } from './platforms/wechatMp/i18n';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, connector: Connector<ED, Cxt, FrontCxt>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>, i18nOptions?: I18nOptions): {
|
||||
i18n: import("./platforms/wechatMp/i18n").I18nWechatMpRuntimeBase;
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
require("./utils/wx.polyfill");
|
||||
var page_mp_1 = require("./page.mp");
|
||||
var initialize_prod_1 = require("./initialize-prod");
|
||||
var i18n_1 = require("./platforms/wechatMp/i18n");
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, connector, checkers, actionDict, authDict, i18nOptions) {
|
||||
var features = (0, initialize_prod_1.initialize)(storageSchema, createFeatures, frontendContextBuilder, connector, checkers, actionDict, authDict).features;
|
||||
// 初始化locales
|
||||
var i18n = (0, i18n_1.getI18next)(i18nOptions);
|
||||
Object.assign(global, {
|
||||
OakComponent: function (options) {
|
||||
return (0, page_mp_1.createComponent)(options, features);
|
||||
},
|
||||
});
|
||||
return {
|
||||
i18n: i18n,
|
||||
features: features,
|
||||
};
|
||||
}
|
||||
exports.initialize = initialize;
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import { Aspect, Checker, StorageSchema, Connector, AuthDefDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Feature } from './types/Feature';
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { I18nOptions } from './platforms/web/i18n';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
export declare function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>, FD extends Record<string, Feature>>(storageSchema: StorageSchema<ED>, createFeatures: (basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => FD, frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt, connector: Connector<ED, Cxt, FrontCxt>, checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>, actionDict?: ActionDictOfEntityDict<ED>, authDict?: AuthDefDict<ED>, i18nOptions?: I18nOptions): {
|
||||
i18n: import("i18next").i18n;
|
||||
features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.initialize = void 0;
|
||||
require("./utils/wx.polyfill");
|
||||
var page_web_1 = require("./page.web");
|
||||
var initialize_prod_1 = require("./initialize-prod");
|
||||
var i18n_1 = require("./platforms/web/i18n");
|
||||
function initialize(storageSchema, createFeatures, frontendContextBuilder, connector, checkers, actionDict, authDict, i18nOptions) {
|
||||
var features = (0, initialize_prod_1.initialize)(storageSchema, createFeatures, frontendContextBuilder, connector, checkers, actionDict, authDict).features;
|
||||
// 初始化i8n配置
|
||||
var i18n = (0, i18n_1.getI18next)(i18nOptions);
|
||||
Object.assign(global, {
|
||||
OakComponent: function (options) {
|
||||
return (0, page_web_1.createComponent)(options, features);
|
||||
},
|
||||
});
|
||||
return {
|
||||
i18n: i18n,
|
||||
features: features,
|
||||
};
|
||||
}
|
||||
exports.initialize = initialize;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
import { AspectWrapper, EntityDict } from 'oak-domain/lib/types';
|
||||
import { Aspect, AspectWrapper, EntityDict } from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
|
|
@ -17,21 +17,21 @@ import { Port } from './port';
|
|||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
|
||||
export function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends CommonAspectDict<ED, Cxt>> (
|
||||
aspectWrapper: AspectWrapper<ED, Cxt, AD>,
|
||||
export function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends AsyncContext<ED>, FrontCxt extends SyncContext<ED>, AD extends Record<string, Aspect<ED, Cxt>>> (
|
||||
aspectWrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
storageSchema: StorageSchema<ED>,
|
||||
contextBuilder: () => FrontCxt,
|
||||
store: CacheStore<ED, FrontCxt>) {
|
||||
const cache = new Cache<ED, Cxt, FrontCxt, AD>(aspectWrapper, contextBuilder, store);
|
||||
const cache = new Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper, contextBuilder, store);
|
||||
const location = new Location();
|
||||
const runningTree = new RunningTree<ED, Cxt, FrontCxt, AD>(aspectWrapper, cache, storageSchema);
|
||||
const runningTree = new RunningTree<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper, cache, storageSchema);
|
||||
const locales = new Locales(aspectWrapper);
|
||||
const eventBus = new EventBus();
|
||||
const localStorage = new LocalStorage();
|
||||
const notification = new Notification();
|
||||
const message = new Message();
|
||||
const navigator = new Navigator();
|
||||
const port = new Port<ED, Cxt, AD>(aspectWrapper);
|
||||
const port = new Port<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>(aspectWrapper);
|
||||
return {
|
||||
cache,
|
||||
location,
|
||||
|
|
@ -43,23 +43,23 @@ export function initialize<ED extends EntityDict & BaseEntityDict, Cxt extends A
|
|||
message,
|
||||
navigator,
|
||||
port,
|
||||
};
|
||||
} as BasicFeatures<ED, Cxt, FrontCxt, AD>;
|
||||
}
|
||||
|
||||
export type BasicFeatures<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends CommonAspectDict<ED, Cxt>
|
||||
AD extends Record<string, Aspect<ED, Cxt>>
|
||||
> = {
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD>;
|
||||
cache: Cache<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
location: Location;
|
||||
runningTree: RunningTree<ED, Cxt, FrontCxt, AD>;
|
||||
locales: Locales<ED, Cxt, AD>;
|
||||
runningTree: RunningTree<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
locales: Locales<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
eventBus: EventBus;
|
||||
localStorage: LocalStorage;
|
||||
notification: Notification;
|
||||
message: Message;
|
||||
navigator: Navigator;
|
||||
port: Port<ED, Cxt, AD>;
|
||||
port: Port<ED, Cxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,13 +47,9 @@ export function initialize<
|
|||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
frontendContextBuilder: () => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
backendContextBuilder: (contextStr?: string) => (store: DebugStore<ED, Cxt>) => Promise<Cxt>,
|
||||
aspectDict: AD,
|
||||
triggers?: Array<Trigger<ED, keyof ED, Cxt>>,
|
||||
|
|
@ -90,8 +86,6 @@ export function initialize<
|
|||
actionDict
|
||||
);
|
||||
|
||||
const features = {} as FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
|
||||
const cacheStore = new CacheStore(
|
||||
storageSchema,
|
||||
() => debugStore.getCurrentData(),
|
||||
|
|
@ -100,7 +94,7 @@ export function initialize<
|
|||
|
||||
const wrapper: AspectWrapper<ED, Cxt, CommonAspectDict<ED, Cxt> & AD> = {
|
||||
exec: async (name, params) => {
|
||||
const context = frontendContextBuilder(features)(cacheStore);
|
||||
const context = frontendContextBuilder()(cacheStore);
|
||||
const str = context.toString();
|
||||
const contextBackend = await backendContextBuilder(str)(debugStore);
|
||||
await contextBackend.begin();
|
||||
|
|
@ -120,19 +114,8 @@ export function initialize<
|
|||
},
|
||||
};
|
||||
|
||||
const basicFeatures = initBasicFeatures(wrapper, storageSchema, () => frontendContextBuilder(features)(cacheStore), cacheStore);
|
||||
const userDefinedfeatures = createFeatures(basicFeatures);
|
||||
|
||||
intersected = intersection(Object.keys(basicFeatures), Object.keys(userDefinedfeatures));
|
||||
if (intersected.length > 0) {
|
||||
throw new Error(
|
||||
`用户定义的feature中不能和系统feature同名:「${intersected.join(
|
||||
','
|
||||
)}」`
|
||||
);
|
||||
}
|
||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||
|
||||
const features = initBasicFeatures(wrapper, storageSchema, () => frontendContextBuilder()(cacheStore), cacheStore);
|
||||
|
||||
checkers2.forEach((checker) => cacheStore.registerChecker(checker as Checker<ED, keyof ED, SyncContext<ED>>));
|
||||
if (actionDict) {
|
||||
const { checkers: adCheckers } = analyzeActionDefDict(
|
||||
|
|
|
|||
|
|
@ -3,18 +3,14 @@ import {
|
|||
AspectWrapper,
|
||||
Checker,
|
||||
StorageSchema,
|
||||
Context,
|
||||
RowStore,
|
||||
Connector,
|
||||
AuthDefDict,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
|
||||
import { Feature } from './types/Feature';
|
||||
|
||||
import { initialize as initBasicFeatures, BasicFeatures } from './features';
|
||||
import { intersection } from 'oak-domain/lib/utils/lodash';
|
||||
import { initialize as initBasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { analyzeActionDefDict } from 'oak-domain/lib/store/actionDef';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
|
|
@ -40,14 +36,10 @@ export function initialize<
|
|||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
AD extends Record<string, Aspect<ED, Cxt>>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
frontendContextBuilder: () => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
connector: Connector<ED, Cxt, FrontCxt>,
|
||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||
actionDict?: ActionDictOfEntityDict<ED>,
|
||||
|
|
@ -55,15 +47,13 @@ export function initialize<
|
|||
) {
|
||||
const checkers2 = (checkers || []).concat(createDynamicCheckers<ED, Cxt | FrontCxt>(storageSchema, authDict));
|
||||
|
||||
const features = {} as FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>;
|
||||
|
||||
const cacheStore = new CacheStore(
|
||||
storageSchema,
|
||||
);
|
||||
|
||||
const wrapper: AspectWrapper<ED, Cxt, AD & CommonAspectDict<ED, Cxt>> = {
|
||||
exec: async (name, params) => {
|
||||
const context = frontendContextBuilder(features)(cacheStore);
|
||||
const context = frontendContextBuilder()(cacheStore);
|
||||
const { result, opRecords, message } = await connector.callAspect(name as string, params, context);
|
||||
return {
|
||||
result,
|
||||
|
|
@ -73,18 +63,7 @@ export function initialize<
|
|||
},
|
||||
};
|
||||
|
||||
const basicFeatures = initBasicFeatures(wrapper, storageSchema, () => frontendContextBuilder(features)(cacheStore), cacheStore);
|
||||
const userDefinedfeatures = createFeatures(basicFeatures);
|
||||
|
||||
const intersected = intersection(Object.keys(basicFeatures), Object.keys(userDefinedfeatures));
|
||||
if (intersected.length > 0) {
|
||||
throw new Error(
|
||||
`用户定义的feature中不能和系统feature同名:「${intersected.join(
|
||||
','
|
||||
)}」`
|
||||
);
|
||||
}
|
||||
Object.assign(features, basicFeatures, userDefinedfeatures);
|
||||
const features = initBasicFeatures(wrapper, storageSchema, () => frontendContextBuilder()(cacheStore), cacheStore);
|
||||
|
||||
checkers2.forEach((checker) => cacheStore.registerChecker(checker as Checker<ED, keyof ED, SyncContext<ED>>));
|
||||
if (actionDict) {
|
||||
|
|
|
|||
|
|
@ -1,124 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import {
|
||||
Aspect,
|
||||
Routine,
|
||||
Checker,
|
||||
Trigger,
|
||||
StorageSchema,
|
||||
Watcher,
|
||||
Timer,
|
||||
AuthDefDict,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Exportation, Importation } from 'oak-domain/lib/types/Port';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
|
||||
import { Feature } from './types/Feature';
|
||||
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import {
|
||||
DataOption,
|
||||
PropertyOption,
|
||||
MethodOption,
|
||||
OakComponentOption } from './types/Page';
|
||||
import { createComponent } from './page.mp';
|
||||
import { initialize as initDev } from './initialize-dev';
|
||||
import { getI18next, I18nOptions } from './platforms/wechatMp/i18n';
|
||||
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
|
||||
export function initialize<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
backendContextBuilder: (contextStr?: string) => (store: AsyncRowStore<ED, Cxt>) => Promise<Cxt>,
|
||||
aspectDict: AD,
|
||||
triggers?: Array<Trigger<ED, keyof ED, Cxt>>,
|
||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||
watchers?: Array<Watcher<ED, keyof ED, Cxt>>,
|
||||
timers?: Array<Timer<ED, Cxt>>,
|
||||
startRoutines?: Array<Routine<ED, Cxt>>,
|
||||
initialData?: {
|
||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
},
|
||||
actionDict?: ActionDictOfEntityDict<ED>,
|
||||
authDict?: AuthDefDict<ED>,
|
||||
i18nOptions?: I18nOptions,
|
||||
importations?: Importation<ED, keyof ED, any>[],
|
||||
exportations?: Exportation<ED, keyof ED, any>[]
|
||||
) {
|
||||
const { features } = initDev<ED, Cxt, FrontCxt, AD, FD>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
frontendContextBuilder,
|
||||
backendContextBuilder,
|
||||
aspectDict,
|
||||
triggers,
|
||||
checkers,
|
||||
watchers,
|
||||
timers,
|
||||
startRoutines,
|
||||
initialData,
|
||||
actionDict,
|
||||
authDict,
|
||||
importations,
|
||||
exportations
|
||||
);
|
||||
|
||||
// 初始化i8n配置
|
||||
const i18n = getI18next(i18nOptions);
|
||||
|
||||
Object.assign(global, {
|
||||
OakComponent: <
|
||||
T extends keyof ED,
|
||||
FormedData extends DataOption,
|
||||
IsList extends boolean,
|
||||
TData extends DataOption = {},
|
||||
TProperty extends PropertyOption = {},
|
||||
TMethod extends MethodOption = {}
|
||||
>(
|
||||
options: OakComponentOption<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>
|
||||
) =>
|
||||
createComponent<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>(options, features),
|
||||
});
|
||||
|
||||
return {
|
||||
i18n,
|
||||
features,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.dev.mp.ts获initialize.dev.web.ts
|
||||
*/
|
||||
import { initialize as initMp } from './initialize.dev.mp';
|
||||
|
||||
console.log('不应该跑到这里');
|
||||
export const initialize = initMp;
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import {
|
||||
Aspect,
|
||||
Checker,
|
||||
Trigger,
|
||||
StorageSchema,
|
||||
Watcher,
|
||||
Routine,
|
||||
Timer,
|
||||
AuthDefDict,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
import { Exportation, Importation } from 'oak-domain/lib/types/Port';
|
||||
|
||||
import { Feature } from './types/Feature';
|
||||
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { createComponent } from './page.web';
|
||||
import { initialize as initDev } from './initialize-dev';
|
||||
import { getI18next, I18nOptions } from './platforms/web/i18n';
|
||||
import { AsyncContext, AsyncRowStore } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
import {
|
||||
DataOption,
|
||||
PropertyOption,
|
||||
MethodOption,
|
||||
OakComponentOption } from './types/Page';
|
||||
|
||||
export function initialize<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
backendContextBuilder: (contextStr?: string) => (store: AsyncRowStore<ED, Cxt>) => Promise<Cxt>,
|
||||
aspectDict: AD,
|
||||
triggers?: Array<Trigger<ED, keyof ED, Cxt>>,
|
||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||
watchers?: Array<Watcher<ED, keyof ED, Cxt>>,
|
||||
timers?: Array<Timer<ED, Cxt>>,
|
||||
startRoutines?: Array<Routine<ED, Cxt>>,
|
||||
initialData?: {
|
||||
[T in keyof ED]?: Array<ED[T]['OpSchema']>;
|
||||
},
|
||||
actionDict?: ActionDictOfEntityDict<ED>,
|
||||
authDict?: AuthDefDict<ED>,
|
||||
i18nOptions?: I18nOptions,
|
||||
importations?: Importation<ED, keyof ED, any>[],
|
||||
exportations?: Exportation<ED, keyof ED, any>[]
|
||||
|
||||
) {
|
||||
const { features } = initDev<ED, Cxt, FrontCxt, AD, FD>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
frontendContextBuilder,
|
||||
backendContextBuilder,
|
||||
aspectDict,
|
||||
triggers,
|
||||
checkers,
|
||||
watchers,
|
||||
timers,
|
||||
startRoutines,
|
||||
initialData,
|
||||
actionDict,
|
||||
authDict,
|
||||
importations,
|
||||
exportations
|
||||
);
|
||||
|
||||
// 初始化i8n配置
|
||||
const i18n = getI18next(i18nOptions);
|
||||
|
||||
Object.assign(global, {
|
||||
OakComponent: <
|
||||
T extends keyof ED,
|
||||
FormedData extends DataOption,
|
||||
IsList extends boolean,
|
||||
TData extends DataOption = {},
|
||||
TProperty extends PropertyOption = {},
|
||||
TMethod extends MethodOption = {}
|
||||
>(
|
||||
options: OakComponentOption<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>
|
||||
) =>
|
||||
createComponent<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>(options, features),
|
||||
});
|
||||
|
||||
return {
|
||||
i18n,
|
||||
features,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import {
|
||||
Aspect,
|
||||
AspectWrapper,
|
||||
Checker,
|
||||
StorageSchema,
|
||||
Context,
|
||||
RowStore,
|
||||
OakException,
|
||||
Connector,
|
||||
AuthDefDict,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
|
||||
import { Feature } from './types/Feature';
|
||||
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import { createComponent } from './page.mp';
|
||||
import { initialize as initProd } from './initialize-prod';
|
||||
import { getI18next, I18nOptions } from './platforms/wechatMp/i18n';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
import {
|
||||
DataOption,
|
||||
PropertyOption,
|
||||
MethodOption,
|
||||
OakComponentOption } from './types/Page';
|
||||
|
||||
export function initialize<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
connector: Connector<ED, Cxt, FrontCxt>,
|
||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||
actionDict?: ActionDictOfEntityDict<ED>,
|
||||
authDict?: AuthDefDict<ED>,
|
||||
i18nOptions?: I18nOptions
|
||||
) {
|
||||
const { features } = initProd<ED, Cxt, FrontCxt, AD, FD>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
frontendContextBuilder,
|
||||
connector,
|
||||
checkers,
|
||||
actionDict,
|
||||
authDict
|
||||
);
|
||||
|
||||
// 初始化locales
|
||||
const i18n = getI18next(i18nOptions);
|
||||
|
||||
Object.assign(global, {
|
||||
OakComponent: <
|
||||
T extends keyof ED,
|
||||
FormedData extends DataOption,
|
||||
IsList extends boolean,
|
||||
TData extends DataOption = {},
|
||||
TProperty extends PropertyOption = {},
|
||||
TMethod extends MethodOption = {}
|
||||
>(
|
||||
options: OakComponentOption<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>
|
||||
) =>
|
||||
createComponent<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>(options, features),
|
||||
});
|
||||
|
||||
return {
|
||||
i18n,
|
||||
features,
|
||||
};
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
/**
|
||||
* 此文件是为了vs code能正确定位,在webpack编译时应该跳过,直接去获取initialize.prod.mp.ts获initialize.prod.web.ts
|
||||
*/
|
||||
import { initialize as initMp } from './initialize.prod.mp';
|
||||
|
||||
console.log('不应该跑到这里');
|
||||
export const initialize = initMp;
|
||||
|
||||
|
|
@ -1,106 +0,0 @@
|
|||
import './utils/wx.polyfill';
|
||||
import {
|
||||
Aspect,
|
||||
AspectWrapper,
|
||||
Checker,
|
||||
StorageSchema,
|
||||
Context,
|
||||
RowStore,
|
||||
OakException,
|
||||
Connector,
|
||||
AuthDefDict,
|
||||
} from 'oak-domain/lib/types';
|
||||
import { EntityDict as BaseEntityDict } from 'oak-domain/lib/base-app-domain';
|
||||
import { EntityDict } from 'oak-domain/lib/types/Entity';
|
||||
|
||||
import { Feature } from './types/Feature';
|
||||
|
||||
import { BasicFeatures } from './features';
|
||||
import { ActionDictOfEntityDict } from 'oak-domain/lib/types/Action';
|
||||
import { CommonAspectDict } from 'oak-common-aspect';
|
||||
import {
|
||||
DataOption,
|
||||
PropertyOption,
|
||||
MethodOption,
|
||||
OakComponentOption } from './types/Page';
|
||||
import { createComponent } from './page.web';
|
||||
import { initialize as initProd } from './initialize-prod';
|
||||
import { getI18next, I18nOptions } from './platforms/web/i18n';
|
||||
import { AsyncContext } from 'oak-domain/lib/store/AsyncRowStore';
|
||||
import { SyncContext } from 'oak-domain/lib/store/SyncRowStore';
|
||||
import { CacheStore } from './cacheStore/CacheStore';
|
||||
|
||||
export function initialize<
|
||||
ED extends EntityDict & BaseEntityDict,
|
||||
Cxt extends AsyncContext<ED>,
|
||||
FrontCxt extends SyncContext<ED>,
|
||||
AD extends Record<string, Aspect<ED, Cxt>>,
|
||||
FD extends Record<string, Feature>
|
||||
>(
|
||||
storageSchema: StorageSchema<ED>,
|
||||
createFeatures: (
|
||||
basicFeatures: BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>,
|
||||
) => FD,
|
||||
frontendContextBuilder: (features: FD & BasicFeatures<ED, Cxt, FrontCxt, AD & CommonAspectDict<ED, Cxt>>) => (store: CacheStore<ED, FrontCxt>) => FrontCxt,
|
||||
connector: Connector<ED, Cxt, FrontCxt>,
|
||||
checkers?: Array<Checker<ED, keyof ED, FrontCxt | Cxt>>,
|
||||
actionDict?: ActionDictOfEntityDict<ED>,
|
||||
authDict?: AuthDefDict<ED>,
|
||||
i18nOptions?: I18nOptions
|
||||
) {
|
||||
const { features } = initProd<ED, Cxt, FrontCxt, AD, FD>(
|
||||
storageSchema,
|
||||
createFeatures,
|
||||
frontendContextBuilder,
|
||||
connector,
|
||||
checkers,
|
||||
actionDict,
|
||||
authDict
|
||||
);
|
||||
|
||||
// 初始化i8n配置
|
||||
const i18n = getI18next(i18nOptions);
|
||||
|
||||
Object.assign(global, {
|
||||
OakComponent: <
|
||||
T extends keyof ED,
|
||||
FormedData extends DataOption,
|
||||
IsList extends boolean,
|
||||
TData extends DataOption = {},
|
||||
TProperty extends PropertyOption = {},
|
||||
TMethod extends MethodOption = {}
|
||||
>(
|
||||
options: OakComponentOption<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>
|
||||
) =>
|
||||
createComponent<
|
||||
ED,
|
||||
T,
|
||||
Cxt,
|
||||
FrontCxt,
|
||||
AD,
|
||||
FD,
|
||||
FormedData,
|
||||
IsList,
|
||||
TData,
|
||||
TProperty,
|
||||
TMethod
|
||||
>(options, features),
|
||||
});
|
||||
|
||||
return {
|
||||
i18n,
|
||||
features,
|
||||
};
|
||||
}
|
||||
|
|
@ -72,6 +72,7 @@
|
|||
],
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx",
|
||||
],
|
||||
"exclude": [
|
||||
"node_modules",
|
||||
|
|
|
|||
Loading…
Reference in New Issue