@bytedance/mona
Advanced tools
Comparing version 0.2.0-alpha.6 to 0.2.0-alpha.7
@@ -12,3 +12,4 @@ export interface PageConfig { | ||
onReachBottomDistance?: number; | ||
usingComponents?: Record<string, string>; | ||
} | ||
export declare function createPageConfig(pageConfig: PageConfig): PageConfig; |
@@ -0,1 +1,3 @@ | ||
import { PluginOptions } from 'copy-webpack-plugin'; | ||
import Config from 'webpack-chain'; | ||
interface PxtransformConfig { | ||
@@ -26,11 +28,19 @@ unitPrecision: number; | ||
transformSvgToComponentInWeb?: boolean; | ||
raw?: (options: any) => any; | ||
abilities?: { | ||
define?: Record<string, string>; | ||
copy?: PluginOptions; | ||
css?: { | ||
postcss?: { | ||
pxtransform?: PostcssPxtransformProps; | ||
}; | ||
}; | ||
sourceMap?: Config.DevTool; | ||
alias?: Record<string, string>; | ||
}; | ||
dev?: { | ||
port?: number | string; | ||
}; | ||
postcss?: { | ||
pxtransform?: PostcssPxtransformProps; | ||
}; | ||
chain?: (config: Config) => void; | ||
} | ||
export declare function createProjectConfig(projectConfig: ProjectConfig): ProjectConfig; | ||
export {}; |
@@ -30,7 +30,5 @@ import React from 'react'; | ||
export declare class LifecycleContext { | ||
lifecycle: { | ||
[key: string]: Callback[]; | ||
}; | ||
lifecycle: Record<string, Set<Callback>>; | ||
constructor(); | ||
registerLifecycle(rawName: string, callback: Callback): void; | ||
registerLifecycle(name: string, callback: Callback): (() => void) | undefined; | ||
} | ||
@@ -37,0 +35,0 @@ export declare const PageLifecycleGlobalContext: React.Context<LifecycleContext | null>; |
@@ -39,11 +39,26 @@ "use strict"; | ||
constructor() { | ||
this.lifecycle = {}; | ||
this.lifecycle = new Proxy({}, { | ||
get: function (target, property) { | ||
if (typeof property === 'string') { | ||
return target[property.toLowerCase().replace(/^on/, '')]; | ||
} | ||
return; | ||
}, | ||
set: function (target, property, value) { | ||
if (typeof property === 'string') { | ||
target[property.toLowerCase().replace(/^on/, '')] = value; | ||
} | ||
return true; | ||
}, | ||
}); | ||
} | ||
registerLifecycle(rawName, callback) { | ||
registerLifecycle(name, callback) { | ||
if (typeof callback !== 'function') { | ||
return; | ||
} | ||
const name = rawName.toLowerCase().replace(/^on/, ''); | ||
this.lifecycle[name] = this.lifecycle[name] || []; | ||
this.lifecycle[name].push(callback); | ||
this.lifecycle[name] = this.lifecycle[name] || new Set([]); | ||
this.lifecycle[name].add(callback); | ||
return () => { | ||
this.lifecycle[name].delete(callback); | ||
}; | ||
} | ||
@@ -50,0 +65,0 @@ } |
@@ -10,6 +10,5 @@ "use strict"; | ||
(0, react_1.useLayoutEffect)(() => { | ||
if (appLifecycle) { | ||
appLifecycle.registerLifecycle(eventName, callback); | ||
} | ||
}); | ||
let clear = appLifecycle === null || appLifecycle === void 0 ? void 0 : appLifecycle.registerLifecycle(eventName, callback); | ||
return () => clear === null || clear === void 0 ? void 0 : clear(); | ||
}, [callback, eventName, appLifecycle]); | ||
} | ||
@@ -21,8 +20,7 @@ exports.useAppEvent = useAppEvent; | ||
(0, react_1.useLayoutEffect)(() => { | ||
if (pageLifecycleContext) { | ||
pageLifecycleContext.registerLifecycle(eventName, callback); | ||
} | ||
}); | ||
let clear = pageLifecycleContext === null || pageLifecycleContext === void 0 ? void 0 : pageLifecycleContext.registerLifecycle(eventName, callback); | ||
return () => clear === null || clear === void 0 ? void 0 : clear(); | ||
}, [callback, eventName, pageLifecycleContext]); | ||
} | ||
exports.usePageEvent = usePageEvent; | ||
//# sourceMappingURL=hooks.js.map |
{ | ||
"name": "@bytedance/mona", | ||
"version": "0.2.0-alpha.6", | ||
"version": "0.2.0-alpha.7", | ||
"description": "Merchant app's developing and building tools", | ||
@@ -9,3 +9,4 @@ "main": "./dist/index", | ||
"start": "ttsc -b -w", | ||
"clean": "rm -rf dist" | ||
"clean": "rm -rf dist", | ||
"test": "jest" | ||
}, | ||
@@ -22,3 +23,6 @@ "files": [ | ||
"devDependencies": { | ||
"react": "^17.0.2" | ||
"copy-webpack-plugin": "^10.2.0", | ||
"react": "^17.0.2", | ||
"webpack": "^5.58.2", | ||
"webpack-chain": "^6.5.1" | ||
}, | ||
@@ -28,3 +32,3 @@ "peerDependencies": { | ||
}, | ||
"gitHead": "3d2361f23b3fbf0a1b6c885929851a2d3af1305f" | ||
"gitHead": "8cafcf9a9ec6a2c4ed7d3ca33468f426fb8a0467" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
93924
2360
4