@goldfishjs/composition-api
Advanced tools
Comparing version 2.10.0 to 2.11.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [2.11.0](https://github.com/alipay/goldfish/compare/v2.10.0...v2.11.0) (2022-03-25) | ||
### Features | ||
* optimize ([c5f0a7c](https://github.com/alipay/goldfish/commit/c5f0a7c428c8882f74fba5bca131ad6c7d9e6294)) | ||
# [2.10.0](https://github.com/alipay/goldfish/compare/v2.9.0...v2.10.0) (2022-03-23) | ||
@@ -8,0 +19,0 @@ |
@@ -0,1 +1,2 @@ | ||
import AppSetup from './AppSetup'; | ||
import ComponentSetup from './ComponentSetup'; | ||
@@ -5,4 +6,4 @@ import PageSetup from './PageSetup'; | ||
private map; | ||
add(id: string, setup: ComponentSetup | PageSetup): void; | ||
get(id: string): PageSetup | ComponentSetup | null; | ||
add(id: string, setup: ComponentSetup | PageSetup | AppSetup): void; | ||
get(id: string): PageSetup | ComponentSetup | AppSetup | null; | ||
remove(id: string): void; | ||
@@ -9,0 +10,0 @@ } |
/// <reference types="mini-types" /> | ||
import { ISetupFunction } from './setup/CommonSetup'; | ||
export declare const APP_SETUP_ID_KEY = "$$appSetupId"; | ||
export default function setupApp(fn: ISetupFunction): tinyapp.AppOptions; |
@@ -6,2 +6,3 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray"; | ||
import _typeof from "@babel/runtime/helpers/typeof"; | ||
import _uniqueId from "@goldfishjs/utils/lib/uniqueId"; | ||
@@ -15,11 +16,18 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; } | ||
import appendFn from './appendFn'; | ||
import setupManager from './setup/setupManager'; | ||
var lifeCycleMethods = ['onLaunch', 'onShow', 'onHide', 'onError', 'onUnhandledRejection']; | ||
export var APP_SETUP_ID_KEY = '$$appSetupId'; | ||
export default function setupApp(fn) { | ||
var options = {}; // Create the setup instance. | ||
var options = {}; | ||
var finalData = {}; // Create the setup instance. | ||
var setup = new AppSetup(); // Execute the setup function. | ||
var setup = new AppSetup(); | ||
var appSetupId = _uniqueId('app-setup-'); | ||
finalData[APP_SETUP_ID_KEY] = appSetupId; | ||
setupManager.add(appSetupId, setup); // Execute the setup function. | ||
setup.executeSetupFunction(fn); // Set the global data. | ||
var finalData = options.globalData; | ||
var compositionData = setup.compositionState; | ||
@@ -51,11 +59,15 @@ | ||
this.setData = function (obj) { | ||
for (var key in obj) { | ||
var _loop = function _loop(key) { | ||
var keyPathList = keyPathGet(key); | ||
keyPathList.reduce(function (prevData, key, index, list) { | ||
keyPathList.reduce(function (prevData, keySeg, index, list) { | ||
if (index === list.length - 1) { | ||
prevData[key] = obj[key]; | ||
prevData[keySeg] = obj[key]; | ||
} | ||
return prevData[key]; | ||
return prevData[keySeg]; | ||
}, _this.globalData); | ||
}; | ||
for (var key in obj) { | ||
_loop(key); | ||
} | ||
@@ -65,13 +77,17 @@ }; | ||
this.$spliceData = function (obj) { | ||
for (var key in obj) { | ||
var _loop2 = function _loop2(key) { | ||
var keyPathList = keyPathGet(key); | ||
keyPathList.reduce(function (prevData, key, index, list) { | ||
keyPathList.reduce(function (prevData, keySeg, index, list) { | ||
if (index === list.length - 1) { | ||
var _prevData$key; | ||
var _prevData$keySeg; | ||
(_prevData$key = prevData[key]).splice.apply(_prevData$key, [obj[key][0], obj[key][1]].concat(_toConsumableArray(obj[key].slice(2)))); | ||
(_prevData$keySeg = prevData[keySeg]).splice.apply(_prevData$keySeg, [obj[key][0], obj[key][1]].concat(_toConsumableArray(obj[key].slice(2)))); | ||
} | ||
return prevData[key]; | ||
return prevData[keySeg]; | ||
}, _this.globalData); | ||
}; | ||
for (var key in obj) { | ||
_loop2(key); | ||
} | ||
@@ -78,0 +94,0 @@ }; |
/// <reference types="mini-types" /> | ||
import { IProps } from '@goldfishjs/reactive-connect'; | ||
import { ISetupFunction } from './setup/CommonSetup'; | ||
export declare const COMPONENT_SETUP_ID_KEY = "$$componentSetupId"; | ||
export declare function buildComponentOptions<P extends Record<string, any>, D = any>(arg1: P | ISetupFunction, arg2?: ISetupFunction, isComponent2Param?: boolean): tinyapp.ComponentOptions<P, D, {}>; | ||
export default function setupComponent<P extends IProps, D = Record<string, any>>(passInFn: ISetupFunction): tinyapp.ComponentOptions<P, D, {}>; | ||
export default function setupComponent<P, D = Record<string, any>>(passInProps: P, passInFn: ISetupFunction): tinyapp.ComponentOptions<P, D, {}>; |
@@ -17,3 +17,3 @@ import _attachLogic from "@goldfishjs/reactive-connect/lib/attachLogic"; | ||
var lifeCycleMethods = ['onInit', 'deriveDataFromProps', 'didMount', 'didUpdate', 'didUnmount']; | ||
var COMPONENT_SETUP_ID_KEY = '$$componentSetupId'; | ||
export var COMPONENT_SETUP_ID_KEY = '$$componentSetupId'; | ||
export function buildComponentOptions(arg1, arg2) { | ||
@@ -20,0 +20,0 @@ var isComponent2Param = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : isComponent2; |
/// <reference types="mini-types" /> | ||
import { ISetupFunction } from './setup/CommonSetup'; | ||
export declare const PAGE_SETUP_ID_KEY = "$$pageSetupId"; | ||
export default function setupPage<D>(fn: ISetupFunction): tinyapp.PageOptions<D>; |
@@ -16,3 +16,3 @@ import _attachLogic from "@goldfishjs/reactive-connect/lib/attachLogic"; | ||
var pageEventMethods = ['onBack', 'onKeyboardHeight', 'onOptionMenuClick', 'onPopMenuClick', 'onPullIntercept', 'onPullDownRefresh', 'onTitleClick', 'onTabItemTap', 'beforeTabItemTap']; | ||
var PAGE_SETUP_ID_KEY = '$$pageSetupId'; | ||
export var PAGE_SETUP_ID_KEY = '$$pageSetupId'; | ||
@@ -19,0 +19,0 @@ function integratePageEventMethods(pageMethods) { |
{ | ||
"name": "@goldfishjs/composition-api", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "goldfish-composition-api", | ||
@@ -17,6 +17,6 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@goldfishjs/module-usage": "^2.10.0", | ||
"@goldfishjs/reactive": "^2.10.0", | ||
"@goldfishjs/reactive-connect": "^2.10.0", | ||
"@goldfishjs/utils": "^2.10.0", | ||
"@goldfishjs/module-usage": "^2.11.0", | ||
"@goldfishjs/reactive": "^2.11.0", | ||
"@goldfishjs/reactive-connect": "^2.11.0", | ||
"@goldfishjs/utils": "^2.11.0", | ||
"mini-types": "^0.1.3" | ||
@@ -23,0 +23,0 @@ }, |
67568
1340