@ray-js/framework 1.3.22 → 1.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ Copyright © 2014-2022 Tuya.inc
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/lib/api/tabBar.js CHANGED
@@ -1,7 +1,6 @@
1
1
  import { appStoreEmitter, actions } from '../store/appStore';
2
2
  export function showTabBar(options) {
3
3
  var _options$success, _options$complete;
4
-
5
4
  appStoreEmitter.emit(actions.toggleTabBar, {
6
5
  visible: true,
7
6
  animation: options.animation
@@ -11,7 +10,6 @@ export function showTabBar(options) {
11
10
  }
12
11
  export function hideTabBar(options) {
13
12
  var _options$success2, _options$complete2;
14
-
15
13
  appStoreEmitter.emit(actions.toggleTabBar, {
16
14
  visible: false,
17
15
  animation: options.animation
@@ -7,15 +7,14 @@ import { Application } from '../components/Application';
7
7
  import { normalizeBasename } from '../utils';
8
8
  export function createApp(options) {
9
9
  var _cfg$globalConfig;
10
-
11
- var cfg = _objectSpread({}, options);
12
-
13
- var root = document.createElement('div');
10
+ const cfg = _objectSpread({}, options);
11
+ const root = document.createElement('div');
14
12
  root.id = 'root';
15
- document.body.appendChild(root); // 入口初始化 格式数据
16
-
13
+ document.body.appendChild(root);
14
+ // 入口初始化 格式数据
17
15
  set(cfg, 'globalConfig.basename', normalizeBasename((_cfg$globalConfig = cfg.globalConfig) === null || _cfg$globalConfig === void 0 ? void 0 : _cfg$globalConfig.basename));
18
- set(cfg, 'tabBar', normalizeTabBar(cfg.tabBar, cfg.routes)); // 作为 web 构建的启动入口文件
16
+ set(cfg, 'tabBar', normalizeTabBar(cfg.tabBar, cfg.routes));
19
17
 
18
+ // 作为 web 构建的启动入口文件
20
19
  ReactDOM.render( /*#__PURE__*/React.createElement(Application, cfg), root);
21
20
  }
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import ReactDOM from 'react-dom';
3
+ import set from 'lodash.set';
4
+ import { normalizeTabBar } from '@ray-js/framework-shared';
5
+ import { Application } from '../components/Application';
6
+ import { normalizeBasename } from '../utils';
7
+ export function createApp(options) {
8
+ var _a;
9
+ const cfg = Object.assign({}, options);
10
+ const root = document.createElement('div');
11
+ root.id = 'root';
12
+ document.body.appendChild(root);
13
+ // 入口初始化 格式数据
14
+ set(cfg, 'globalConfig.basename', normalizeBasename((_a = cfg.globalConfig) === null || _a === void 0 ? void 0 : _a.basename));
15
+ set(cfg, 'tabBar', normalizeTabBar(cfg.tabBar, cfg.routes));
16
+ // 作为 web 构建的启动入口文件
17
+ ReactDOM.render(<Application {...cfg}/>, root);
18
+ }
@@ -1,12 +1,12 @@
1
1
  import { getCurrent } from '@ray-js/runtime';
2
+
2
3
  /**
3
4
  * 创建抽象的 App Instance 对标到小程序,提供给 getApp() 进行使用
4
5
  * @param appThis
5
6
  */
6
-
7
7
  export function createAppInstance(appThis) {
8
- var current = getCurrent(); // App 实例仅且注册一次
9
-
8
+ const current = getCurrent();
9
+ // App 实例仅且注册一次
10
10
  if (!current.app) {
11
11
  current.app = appThis;
12
12
  }
@@ -0,0 +1,12 @@
1
+ import { getCurrent } from '@ray-js/runtime';
2
+ /**
3
+ * 创建抽象的 App Instance 对标到小程序,提供给 getApp() 进行使用
4
+ * @param appThis
5
+ */
6
+ export function createAppInstance(appThis) {
7
+ const current = getCurrent();
8
+ // App 实例仅且注册一次
9
+ if (!current.app) {
10
+ current.app = appThis;
11
+ }
12
+ }
package/lib/app/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { getCurrent } from '@ray-js/runtime';
2
2
  export * from './createApp';
3
3
  export function getApp() {
4
- var current = getCurrent();
4
+ const current = getCurrent();
5
5
  return current.app;
6
6
  }
@@ -0,0 +1,6 @@
1
+ import { getCurrent } from '@ray-js/runtime';
2
+ export * from './createApp';
3
+ export function getApp() {
4
+ const current = getCurrent();
5
+ return current.app;
6
+ }
@@ -3,5 +3,5 @@ export declare class AppWrapper extends React.Component<{
3
3
  children: any;
4
4
  }> {
5
5
  componentDidMount(): void;
6
- render(): JSX.Element;
6
+ render(): React.JSX.Element;
7
7
  }
@@ -1,53 +1,30 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _inherits from "@babel/runtime/helpers/esm/inherits";
4
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
5
1
  import React from 'react';
6
2
  import styles from './index.module.less';
7
3
  import { getApp } from '../../app';
8
4
  import location from '@ray-js/location';
9
- export var AppWrapper = /*#__PURE__*/function (_React$Component) {
10
- _inherits(AppWrapper, _React$Component);
11
-
12
- var _super = _createSuper(AppWrapper);
13
-
14
- function AppWrapper() {
15
- _classCallCheck(this, AppWrapper);
16
-
17
- return _super.apply(this, arguments);
18
- }
19
-
20
- _createClass(AppWrapper, [{
21
- key: "componentDidMount",
22
- value: function componentDidMount() {
23
- var app = getApp();
24
-
25
- if (typeof app.onLaunch === 'function') {
26
- app.onLaunch({
27
- path: location.pathname,
28
- query: location.query,
29
- params: location.params
30
- });
31
- } // 初次展现
32
-
33
-
34
- if (typeof app.onShow === 'function') {
35
- app.onShow({
36
- path: location.pathname,
37
- query: location.query,
38
- params: location.params
39
- });
40
- }
5
+ export class AppWrapper extends React.Component {
6
+ componentDidMount() {
7
+ const app = getApp();
8
+ if (typeof app.onLaunch === 'function') {
9
+ app.onLaunch({
10
+ path: location.pathname,
11
+ query: location.query,
12
+ params: location.params
13
+ });
41
14
  }
42
- }, {
43
- key: "render",
44
- value: function render() {
45
- return /*#__PURE__*/React.createElement("div", {
46
- id: "Application",
47
- className: styles.application
48
- }, this.props.children);
15
+ // 初次展现
16
+ if (typeof app.onShow === 'function') {
17
+ app.onShow({
18
+ path: location.pathname,
19
+ query: location.query,
20
+ params: location.params
21
+ });
49
22
  }
50
- }]);
51
-
52
- return AppWrapper;
53
- }(React.Component);
23
+ }
24
+ render() {
25
+ return /*#__PURE__*/React.createElement("div", {
26
+ id: "Application",
27
+ className: styles.application
28
+ }, this.props.children);
29
+ }
30
+ }
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import styles from './index.module.less';
3
+ import { getApp } from '../../app';
4
+ import location from '@ray-js/location';
5
+ export class AppWrapper extends React.Component {
6
+ componentDidMount() {
7
+ const app = getApp();
8
+ if (typeof app.onLaunch === 'function') {
9
+ app.onLaunch({
10
+ path: location.pathname,
11
+ query: location.query,
12
+ params: location.params,
13
+ });
14
+ }
15
+ // 初次展现
16
+ if (typeof app.onShow === 'function') {
17
+ app.onShow({
18
+ path: location.pathname,
19
+ query: location.query,
20
+ params: location.params,
21
+ });
22
+ }
23
+ }
24
+ render() {
25
+ return (<div id='Application' className={styles.application}>
26
+ {this.props.children}
27
+ </div>);
28
+ }
29
+ }
@@ -1,7 +1,7 @@
1
1
  import '../../runtime';
2
2
  import React from 'react';
3
3
  import * as types from '@ray-js/types';
4
- export declare type ApplicationProps = {
4
+ export type ApplicationProps = {
5
5
  globalConfig: types.GlobalConfig & types.WebGlobalConfig;
6
6
  routes: types.Routes;
7
7
  tabBar: types.TabBar;
@@ -15,5 +15,5 @@ export declare class Application extends React.Component<ApplicationProps, {
15
15
  constructor(props: Readonly<ApplicationProps>);
16
16
  componentDidMount(): void;
17
17
  getGlobalConfig: (path: string | string[], defaultValue?: any) => any;
18
- render(): JSX.Element | null;
18
+ render(): React.JSX.Element | null;
19
19
  }
@@ -1,9 +1,3 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
1
  import '../../runtime';
8
2
  import React from 'react';
9
3
  import { createRouter } from '@ray-js/router';
@@ -12,94 +6,73 @@ import { get } from '../../utils';
12
6
  import { AppWrapper } from '../AppWrapper';
13
7
  import { PageWrapper } from '../PageWrapper';
14
8
  import { TabBar } from '../TabBar';
15
-
16
- var isClassComponent = function (Component) {
9
+ const isClassComponent = Component => {
17
10
  return Component.prototype && typeof Component.prototype.render === 'function';
18
11
  };
19
-
20
- export var Application = /*#__PURE__*/function (_React$Component) {
21
- _inherits(Application, _React$Component);
22
-
23
- var _super = _createSuper(Application);
24
-
25
- function Application(props) {
26
- var _this;
27
-
28
- _classCallCheck(this, Application);
29
-
30
- _this = _super.call(this, props);
31
-
32
- _defineProperty(_assertThisInitialized(_this), "getGlobalConfig", function (path, defaultValue) {
33
- var _this$props$globalCon = _this.props.globalConfig,
34
- globalConfig = _this$props$globalCon === void 0 ? {} : _this$props$globalCon;
35
- var value = get(globalConfig, path, defaultValue);
36
- return value;
37
- });
38
-
39
- _this.state = {};
40
-
41
- var title = _this.getGlobalConfig(['window', 'navigationBarTitleText'], 'Ray App');
42
-
12
+ export class Application extends React.Component {
13
+ constructor(props) {
14
+ super(props);
15
+ this.state = {};
16
+ const title = this.getGlobalConfig(['window', 'navigationBarTitleText'], 'Ray App');
43
17
  document.title = title;
44
- return _this;
45
18
  }
46
-
47
- _createClass(Application, [{
48
- key: "componentDidMount",
49
- value: function componentDidMount() {
50
- var _this2 = this;
51
-
52
- var _this$props = this.props,
53
- routes = _this$props.routes,
54
- pages = _this$props.pages,
55
- tabBar = _this$props.tabBar;
56
- var basename = this.getGlobalConfig('basename', '/') || '/';
57
- var bgColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
58
- document.body.style.backgroundColor = bgColor;
59
- createRouter({
60
- basename: basename,
61
- routes: routes,
62
- pages: pages,
63
- tabBar: tabBar,
64
- onChange: function onChange(component, props) {
65
- _this2.setState({
66
- component: component,
67
- matchedPage: props.page
68
- });
69
- }
70
- });
71
- }
72
- }, {
73
- key: "render",
74
- value: function render() {
75
- var _this$props2 = this.props,
76
- App = _this$props2.app,
77
- tabBar = _this$props2.tabBar;
78
- var basename = this.getGlobalConfig('basename', '/') || '/';
79
- var _this$state = this.state,
80
- PageComponent = _this$state.component,
81
- matchedPage = _this$state.matchedPage; // 空页面暂不渲染,否则 appEvent 无法应用到页面内部
82
-
83
- if (!matchedPage) {
84
- return null;
19
+ componentDidMount() {
20
+ const {
21
+ routes,
22
+ pages,
23
+ tabBar
24
+ } = this.props;
25
+ const basename = this.getGlobalConfig('basename', '/') || '/';
26
+ const bgColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
27
+ document.body.style.backgroundColor = bgColor;
28
+ createRouter({
29
+ basename,
30
+ routes,
31
+ pages,
32
+ tabBar,
33
+ onChange: (component, props) => {
34
+ this.setState({
35
+ component,
36
+ matchedPage: props.page
37
+ });
85
38
  }
39
+ });
40
+ }
41
+ getGlobalConfig = (path, defaultValue) => {
42
+ const {
43
+ globalConfig = {}
44
+ } = this.props;
45
+ const value = get(globalConfig, path, defaultValue);
46
+ return value;
47
+ };
48
+ render() {
49
+ const {
50
+ app: App,
51
+ tabBar
52
+ } = this.props;
53
+ const basename = this.getGlobalConfig('basename', '/') || '/';
54
+ const {
55
+ component: PageComponent,
56
+ matchedPage
57
+ } = this.state;
86
58
 
87
- var isClassType = isClassComponent(PageComponent);
88
- return /*#__PURE__*/React.createElement(AppWrapper, null, /*#__PURE__*/React.createElement(App, {
89
- ref: function ref(appThis) {
90
- createAppInstance(appThis);
91
- }
92
- }, /*#__PURE__*/React.createElement(PageWrapper, {
93
- isClassType: isClassType,
94
- page: matchedPage,
95
- key: matchedPage.route,
96
- getGlobalConfig: this.getGlobalConfig
97
- }, /*#__PURE__*/React.createElement(PageComponent, null)), matchedPage.isTabBar && /*#__PURE__*/React.createElement(TabBar, {
98
- basename: basename,
99
- config: tabBar
100
- })));
59
+ // 空页面暂不渲染,否则 appEvent 无法应用到页面内部
60
+ if (!matchedPage) {
61
+ return null;
101
62
  }
102
- }]);
103
-
104
- return Application;
105
- }(React.Component);
63
+ const isClassType = isClassComponent(PageComponent);
64
+ return /*#__PURE__*/React.createElement(AppWrapper, null, /*#__PURE__*/React.createElement(App, {
65
+ ref: appThis => {
66
+ createAppInstance(appThis);
67
+ }
68
+ }, /*#__PURE__*/React.createElement(PageWrapper, {
69
+ isClassType: isClassType,
70
+ page: matchedPage,
71
+ key: matchedPage.route,
72
+ getGlobalConfig: this.getGlobalConfig
73
+ }, /*#__PURE__*/React.createElement(PageComponent, null)), matchedPage.isTabBar && /*#__PURE__*/React.createElement(TabBar, {
74
+ basename: basename,
75
+ config: tabBar
76
+ })));
77
+ }
78
+ }
@@ -0,0 +1,59 @@
1
+ import '../../runtime';
2
+ import React from 'react';
3
+ import { createRouter } from '@ray-js/router';
4
+ import { createAppInstance } from '../../app/createAppInstance';
5
+ import { get } from '../../utils';
6
+ import { AppWrapper } from '../AppWrapper';
7
+ import { PageWrapper } from '../PageWrapper';
8
+ import { TabBar } from '../TabBar';
9
+ const isClassComponent = (Component) => {
10
+ return Component.prototype && typeof Component.prototype.render === 'function';
11
+ };
12
+ export class Application extends React.Component {
13
+ constructor(props) {
14
+ super(props);
15
+ this.getGlobalConfig = (path, defaultValue) => {
16
+ const { globalConfig = {} } = this.props;
17
+ const value = get(globalConfig, path, defaultValue);
18
+ return value;
19
+ };
20
+ this.state = {};
21
+ const title = this.getGlobalConfig(['window', 'navigationBarTitleText'], 'Ray App');
22
+ document.title = title;
23
+ }
24
+ componentDidMount() {
25
+ const { routes, pages, tabBar } = this.props;
26
+ const basename = this.getGlobalConfig('basename', '/') || '/';
27
+ const bgColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
28
+ document.body.style.backgroundColor = bgColor;
29
+ createRouter({
30
+ basename,
31
+ routes,
32
+ pages,
33
+ tabBar,
34
+ onChange: (component, props) => {
35
+ this.setState({ component, matchedPage: props.page });
36
+ },
37
+ });
38
+ }
39
+ render() {
40
+ const { app: App, tabBar } = this.props;
41
+ const basename = this.getGlobalConfig('basename', '/') || '/';
42
+ const { component: PageComponent, matchedPage } = this.state;
43
+ // 空页面暂不渲染,否则 appEvent 无法应用到页面内部
44
+ if (!matchedPage) {
45
+ return null;
46
+ }
47
+ const isClassType = isClassComponent(PageComponent);
48
+ return (<AppWrapper>
49
+ <App ref={(appThis) => {
50
+ createAppInstance(appThis);
51
+ }}>
52
+ <PageWrapper isClassType={isClassType} page={matchedPage} key={matchedPage.route} getGlobalConfig={this.getGlobalConfig}>
53
+ <PageComponent />
54
+ </PageWrapper>
55
+ {matchedPage.isTabBar && <TabBar basename={basename} config={tabBar}/>}
56
+ </App>
57
+ </AppWrapper>);
58
+ }
59
+ }
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import { PageInstance } from '@ray-js/runtime';
3
3
  import { Page, PageConfig } from '@ray-js/types';
4
4
  import './index.module.less';
5
- declare type PageWrapperProps = {
5
+ type PageWrapperProps = {
6
6
  isClassType: boolean;
7
7
  page: Page;
8
8
  getGlobalConfig: (path: string | string[], defaultValue?: any) => any;
@@ -20,6 +20,6 @@ export declare class PageWrapper extends React.Component<PageWrapperProps, any>
20
20
  handlePageScroll: () => void;
21
21
  checkReachBottom: () => void;
22
22
  getPageConfig: (field: keyof PageConfig | string[], defaultValue?: any) => any;
23
- render(): JSX.Element;
23
+ render(): React.JSX.Element;
24
24
  }
25
25
  export {};
@@ -1,162 +1,131 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import "core-js/modules/es.object.to-string.js";
8
- import "core-js/modules/web.dom-collections.for-each.js";
9
- import "core-js/modules/es.object.keys.js";
10
1
  import React from 'react';
11
2
  import { lifecycle, PageInstance, PageInstanceContext } from '@ray-js/runtime';
12
3
  import { pageLifecycles } from '@ray-js/types';
13
4
  import { get } from '../../utils';
14
5
  import './index.module.less';
15
- export var PageWrapper = /*#__PURE__*/function (_React$Component) {
16
- _inherits(PageWrapper, _React$Component);
17
-
18
- var _super = _createSuper(PageWrapper);
19
-
20
- function PageWrapper(props) {
21
- var _this;
22
-
23
- _classCallCheck(this, PageWrapper);
24
-
25
- _this = _super.call(this, props);
6
+ export class PageWrapper extends React.Component {
7
+ $reachBottomDistance = 50;
8
+ constructor(props) {
9
+ super(props);
10
+ this.$instance = new PageInstance();
11
+ lifecycle.addInstance(this.$instance);
12
+ this.getGlobalConfig = this.props.getGlobalConfig;
13
+ }
14
+ componentDidMount() {
15
+ const title = this.getPageConfig('navigationBarTitleText', '');
16
+ document.title = title;
17
+ window.addEventListener('scroll', this.handlePageScroll);
18
+ window.addEventListener('resize', this.handlePageResize);
19
+ const backgroundColor = this.getPageConfig('backgroundColor');
20
+ if (backgroundColor) {
21
+ document.body.style.backgroundColor = backgroundColor;
22
+ }
26
23
 
27
- _defineProperty(_assertThisInitialized(_this), "$reachBottomDistance", 50);
24
+ // 获取页面触底的距离
25
+ this.$reachBottomDistance = this.getPageConfig('onReachBottomDistance', this.getGlobalConfig(['window', 'onReachBottomDistance'], 50) // 全局配置
26
+ );
28
27
 
29
- _defineProperty(_assertThisInitialized(_this), "handlePageResize", function () {
30
- var windowWidth = document.documentElement.clientWidth;
31
- var windowHeight = document.documentElement.clientHeight;
32
- lifecycle.emit({
33
- uniqueId: _this.$instance.uniqueId,
34
- name: pageLifecycles.onResize,
35
- args: {
36
- windowWidth: windowWidth,
37
- windowHeight: windowHeight
38
- }
39
- });
28
+ // FIXME: 应用实例化未完成,didMount 从内至外执行
29
+ // 此时触发 onShow onReady 获取不到 getApp 实例,组件内也存在这样的情况
30
+ lifecycle.emit({
31
+ uniqueId: this.$instance.uniqueId,
32
+ name: pageLifecycles.onShow
40
33
  });
41
-
42
- _defineProperty(_assertThisInitialized(_this), "handlePageScroll", function () {
43
- var event = {
44
- scrollTop: window.scrollY
45
- };
46
- lifecycle.emit({
47
- uniqueId: _this.$instance.uniqueId,
48
- name: pageLifecycles.onPageScroll,
49
- args: event
50
- });
51
-
52
- _this.checkReachBottom();
34
+ lifecycle.emit({
35
+ uniqueId: this.$instance.uniqueId,
36
+ name: pageLifecycles.onReady
53
37
  });
54
-
55
- _defineProperty(_assertThisInitialized(_this), "checkReachBottom", function () {
56
- var isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <= _this.$reachBottomDistance;
57
-
58
- if (!_this.$isReachBottom && isCurrentReachBottom) {
59
- _this.$isReachBottom = true;
60
- lifecycle.emit({
61
- uniqueId: _this.$instance.uniqueId,
62
- name: pageLifecycles.onReachBottom
63
- });
64
- return;
65
- }
66
-
67
- _this.$isReachBottom = isCurrentReachBottom;
38
+ }
39
+ componentWillUnmount() {
40
+ window.removeEventListener('scroll', this.handlePageScroll);
41
+ window.removeEventListener('resize', this.handlePageResize);
42
+
43
+ // FIXME: 目前是 SPA 的页面直接切换,卸载前直接调用事件
44
+ lifecycle.emit({
45
+ uniqueId: this.$instance.uniqueId,
46
+ name: pageLifecycles.onHide
68
47
  });
69
-
70
- _defineProperty(_assertThisInitialized(_this), "getPageConfig", function (field, defaultValue) {
71
- var page = _this.props.page;
72
- var pageConfig = page.config;
73
- return get(pageConfig, field, defaultValue);
48
+ lifecycle.emit({
49
+ uniqueId: this.$instance.uniqueId,
50
+ name: pageLifecycles.onUnload
74
51
  });
75
-
76
- _this.$instance = new PageInstance();
77
- lifecycle.addInstance(_this.$instance);
78
- _this.getGlobalConfig = _this.props.getGlobalConfig;
79
- return _this;
52
+ lifecycle.removeInstance(this.$instance);
53
+ // TODO: 实现 onPullDownRefresh 生命周期
80
54
  }
81
55
 
82
- _createClass(PageWrapper, [{
83
- key: "componentDidMount",
84
- value: function componentDidMount() {
85
- var title = this.getPageConfig('navigationBarTitleText', '');
86
- document.title = title;
87
- window.addEventListener('scroll', this.handlePageScroll);
88
- window.addEventListener('resize', this.handlePageResize);
89
- var backgroundColor = this.getPageConfig('backgroundColor');
90
-
91
- if (backgroundColor) {
92
- document.body.style.backgroundColor = backgroundColor;
93
- } // 获取页面触底的距离
94
-
95
-
96
- this.$reachBottomDistance = this.getPageConfig('onReachBottomDistance', this.getGlobalConfig(['window', 'onReachBottomDistance'], 50) // 全局配置
97
- ); // FIXME: 应用实例化未完成,didMount 从内至外执行
98
- // 此时触发 onShow onReady 获取不到 getApp 实例,组件内也存在这样的情况
99
-
100
- lifecycle.emit({
101
- uniqueId: this.$instance.uniqueId,
102
- name: pageLifecycles.onShow
103
- });
104
- lifecycle.emit({
105
- uniqueId: this.$instance.uniqueId,
106
- name: pageLifecycles.onReady
107
- });
108
- }
109
- }, {
110
- key: "componentWillUnmount",
111
- value: function componentWillUnmount() {
112
- window.removeEventListener('scroll', this.handlePageScroll);
113
- window.removeEventListener('resize', this.handlePageResize); // FIXME: 目前是 SPA 的页面直接切换,卸载前直接调用事件
114
-
115
- lifecycle.emit({
116
- uniqueId: this.$instance.uniqueId,
117
- name: pageLifecycles.onHide
118
- });
56
+ handlePageResize = () => {
57
+ const windowWidth = document.documentElement.clientWidth;
58
+ const windowHeight = document.documentElement.clientHeight;
59
+ lifecycle.emit({
60
+ uniqueId: this.$instance.uniqueId,
61
+ name: pageLifecycles.onResize,
62
+ args: {
63
+ windowWidth,
64
+ windowHeight
65
+ }
66
+ });
67
+ };
68
+ handlePageScroll = () => {
69
+ const event = {
70
+ scrollTop: window.scrollY
71
+ };
72
+ lifecycle.emit({
73
+ uniqueId: this.$instance.uniqueId,
74
+ name: pageLifecycles.onPageScroll,
75
+ args: event
76
+ });
77
+ this.checkReachBottom();
78
+ };
79
+ checkReachBottom = () => {
80
+ const isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <= this.$reachBottomDistance;
81
+ if (!this.$isReachBottom && isCurrentReachBottom) {
82
+ this.$isReachBottom = true;
119
83
  lifecycle.emit({
120
84
  uniqueId: this.$instance.uniqueId,
121
- name: pageLifecycles.onUnload
85
+ name: pageLifecycles.onReachBottom
122
86
  });
123
- lifecycle.removeInstance(this.$instance); // TODO: 实现 onPullDownRefresh 生命周期
87
+ return;
124
88
  }
125
- }, {
126
- key: "render",
127
- value: function render() {
128
- var _this$props = this.props,
129
- page = _this$props.page,
130
- children = _this$props.children,
131
- isClassType = _this$props.isClassType;
132
- var $instance = this.$instance;
133
- var globalBackgroundColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
134
- var backgroundColor = this.getPageConfig('backgroundColor', globalBackgroundColor);
135
- document.body.style.backgroundColor = backgroundColor;
136
- return /*#__PURE__*/React.createElement(PageInstanceContext.Provider, {
137
- value: {
138
- $instance: $instance,
139
- pageConfig: page.config
140
- }
141
- }, /*#__PURE__*/React.createElement("v-page", {
142
- "data-route": page.route
143
- }, isClassType ?
144
- /*#__PURE__*/
145
- // @ts-ignore
146
- React.cloneElement(children, {
147
- ref: function ref(ins) {
148
- if (ins) {
149
- // 实现 class 生命周期用法的挂载
150
- Object.keys(pageLifecycles).forEach(function (event) {
151
- if (typeof ins[event] === 'function') {
152
- $instance.registerLifecycle(event, ins, ins[event]);
153
- }
154
- });
155
- }
89
+ this.$isReachBottom = isCurrentReachBottom;
90
+ };
91
+ getPageConfig = (field, defaultValue) => {
92
+ const {
93
+ page
94
+ } = this.props;
95
+ const pageConfig = page.config;
96
+ return get(pageConfig, field, defaultValue);
97
+ };
98
+ render() {
99
+ const {
100
+ page,
101
+ children,
102
+ isClassType
103
+ } = this.props;
104
+ const $instance = this.$instance;
105
+ const globalBackgroundColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
106
+ const backgroundColor = this.getPageConfig('backgroundColor', globalBackgroundColor);
107
+ document.body.style.backgroundColor = backgroundColor;
108
+ return /*#__PURE__*/React.createElement(PageInstanceContext.Provider, {
109
+ value: {
110
+ $instance,
111
+ pageConfig: page.config
112
+ }
113
+ }, /*#__PURE__*/React.createElement("v-page", {
114
+ "data-route": page.route
115
+ }, isClassType ?
116
+ /*#__PURE__*/
117
+ // @ts-ignore
118
+ React.cloneElement(children, {
119
+ ref(ins) {
120
+ if (ins) {
121
+ // 实现 class 生命周期用法的挂载
122
+ Object.keys(pageLifecycles).forEach(event => {
123
+ if (typeof ins[event] === 'function') {
124
+ $instance.registerLifecycle(event, ins, ins[event]);
125
+ }
126
+ });
156
127
  }
157
- }) : children));
158
- }
159
- }]);
160
-
161
- return PageWrapper;
162
- }(React.Component);
128
+ }
129
+ }) : children));
130
+ }
131
+ }
@@ -0,0 +1,116 @@
1
+ import React from 'react';
2
+ import { lifecycle, PageInstance, PageInstanceContext } from '@ray-js/runtime';
3
+ import { pageLifecycles } from '@ray-js/types';
4
+ import { get } from '../../utils';
5
+ import './index.module.less';
6
+ export class PageWrapper extends React.Component {
7
+ constructor(props) {
8
+ super(props);
9
+ this.$reachBottomDistance = 50;
10
+ this.handlePageResize = () => {
11
+ const windowWidth = document.documentElement.clientWidth;
12
+ const windowHeight = document.documentElement.clientHeight;
13
+ lifecycle.emit({
14
+ uniqueId: this.$instance.uniqueId,
15
+ name: pageLifecycles.onResize,
16
+ args: { windowWidth, windowHeight },
17
+ });
18
+ };
19
+ this.handlePageScroll = () => {
20
+ const event = { scrollTop: window.scrollY };
21
+ lifecycle.emit({
22
+ uniqueId: this.$instance.uniqueId,
23
+ name: pageLifecycles.onPageScroll,
24
+ args: event,
25
+ });
26
+ this.checkReachBottom();
27
+ };
28
+ this.checkReachBottom = () => {
29
+ const isCurrentReachBottom = document.body.scrollHeight - (window.innerHeight + window.scrollY) <=
30
+ this.$reachBottomDistance;
31
+ if (!this.$isReachBottom && isCurrentReachBottom) {
32
+ this.$isReachBottom = true;
33
+ lifecycle.emit({
34
+ uniqueId: this.$instance.uniqueId,
35
+ name: pageLifecycles.onReachBottom,
36
+ });
37
+ return;
38
+ }
39
+ this.$isReachBottom = isCurrentReachBottom;
40
+ };
41
+ this.getPageConfig = (field, defaultValue) => {
42
+ const { page } = this.props;
43
+ const pageConfig = page.config;
44
+ return get(pageConfig, field, defaultValue);
45
+ };
46
+ this.$instance = new PageInstance();
47
+ lifecycle.addInstance(this.$instance);
48
+ this.getGlobalConfig = this.props.getGlobalConfig;
49
+ }
50
+ componentDidMount() {
51
+ const title = this.getPageConfig('navigationBarTitleText', '');
52
+ document.title = title;
53
+ window.addEventListener('scroll', this.handlePageScroll);
54
+ window.addEventListener('resize', this.handlePageResize);
55
+ const backgroundColor = this.getPageConfig('backgroundColor');
56
+ if (backgroundColor) {
57
+ document.body.style.backgroundColor = backgroundColor;
58
+ }
59
+ // 获取页面触底的距离
60
+ this.$reachBottomDistance = this.getPageConfig('onReachBottomDistance', this.getGlobalConfig(['window', 'onReachBottomDistance'], 50) // 全局配置
61
+ );
62
+ // FIXME: 应用实例化未完成,didMount 从内至外执行
63
+ // 此时触发 onShow onReady 获取不到 getApp 实例,组件内也存在这样的情况
64
+ lifecycle.emit({
65
+ uniqueId: this.$instance.uniqueId,
66
+ name: pageLifecycles.onShow,
67
+ });
68
+ lifecycle.emit({
69
+ uniqueId: this.$instance.uniqueId,
70
+ name: pageLifecycles.onReady,
71
+ });
72
+ }
73
+ componentWillUnmount() {
74
+ window.removeEventListener('scroll', this.handlePageScroll);
75
+ window.removeEventListener('resize', this.handlePageResize);
76
+ // FIXME: 目前是 SPA 的页面直接切换,卸载前直接调用事件
77
+ lifecycle.emit({
78
+ uniqueId: this.$instance.uniqueId,
79
+ name: pageLifecycles.onHide,
80
+ });
81
+ lifecycle.emit({
82
+ uniqueId: this.$instance.uniqueId,
83
+ name: pageLifecycles.onUnload,
84
+ });
85
+ lifecycle.removeInstance(this.$instance);
86
+ // TODO: 实现 onPullDownRefresh 生命周期
87
+ }
88
+ render() {
89
+ const { page, children, isClassType } = this.props;
90
+ const $instance = this.$instance;
91
+ const globalBackgroundColor = this.getGlobalConfig(['window', 'backgroundColor'], '#fff');
92
+ const backgroundColor = this.getPageConfig('backgroundColor', globalBackgroundColor);
93
+ document.body.style.backgroundColor = backgroundColor;
94
+ return (<PageInstanceContext.Provider value={{ $instance, pageConfig: page.config }}>
95
+ <v-page data-route={page.route}>
96
+ {isClassType
97
+ ? // @ts-ignore
98
+ React.cloneElement(children, {
99
+ ref(ins) {
100
+ if (ins) {
101
+ // 实现 class 生命周期用法的挂载
102
+ Object.keys(pageLifecycles).forEach((event) => {
103
+ if (typeof ins[event] === 'function') {
104
+ $instance.registerLifecycle(event, ins, ins[event]);
105
+ }
106
+ });
107
+ }
108
+ },
109
+ })
110
+ : children}
111
+ {/* TODO: 如果需要转场动画,需要在 PageWrapper 中渲染 */}
112
+ {/* {page?.isTabBar && <TabBar config={tabBarConfig} />} */}
113
+ </v-page>
114
+ </PageInstanceContext.Provider>);
115
+ }
116
+ }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
  import { TabBar as ITabBar } from '@ray-js/types';
3
3
  import { renderOptions } from '../../store/appStore';
4
- declare type TabBarProps = {
4
+ type TabBarProps = {
5
5
  config: ITabBar;
6
6
  basename?: string;
7
7
  };
@@ -20,6 +20,6 @@ export declare class TabBar extends React.Component<TabBarProps, {
20
20
  };
21
21
  componentDidMount(): void;
22
22
  componentWillUnmount(): void;
23
- render(): JSX.Element;
23
+ render(): React.JSX.Element;
24
24
  }
25
25
  export {};
@@ -1,102 +1,68 @@
1
- import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
- import _createClass from "@babel/runtime/helpers/esm/createClass";
3
- import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
- import _inherits from "@babel/runtime/helpers/esm/inherits";
5
- import _createSuper from "@babel/runtime/helpers/esm/createSuper";
6
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
7
- import "core-js/modules/es.array.concat.js";
8
- import "core-js/modules/es.array.map.js";
9
1
  import clsx from 'clsx';
10
2
  import React from 'react';
11
3
  import router from '@ray-js/router';
12
4
  import { events, appStoreEmitter, renderOptions } from '../../store/appStore';
13
5
  import { withPublicPath } from '../../utils';
14
6
  import styles from './index.module.less';
15
- export var TabBar = /*#__PURE__*/function (_React$Component) {
16
- _inherits(TabBar, _React$Component);
17
-
18
- var _super = _createSuper(TabBar);
19
-
20
- function TabBar() {
21
- var _this;
22
-
23
- _classCallCheck(this, TabBar);
24
-
25
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
26
- args[_key] = arguments[_key];
27
- }
28
-
29
- _this = _super.call.apply(_super, [this].concat(args));
30
-
31
- _defineProperty(_assertThisInitialized(_this), "state", {
32
- currentRoute: router.scheduler.currentRoute,
33
- renderOptions: renderOptions
34
- });
35
-
36
- return _this;
37
- }
38
-
39
- _createClass(TabBar, [{
40
- key: "componentDidMount",
41
- value: function componentDidMount() {
42
- var _this2 = this;
43
-
44
- this.unChangeHandle = router.scheduler.on('routeChange', function (route) {
45
- _this2.setState({
46
- currentRoute: route
47
- });
7
+ export class TabBar extends React.Component {
8
+ state = {
9
+ currentRoute: router.scheduler.currentRoute,
10
+ renderOptions: renderOptions
11
+ };
12
+ componentDidMount() {
13
+ this.unChangeHandle = router.scheduler.on('routeChange', route => {
14
+ this.setState({
15
+ currentRoute: route
48
16
  });
49
- this.unAppStoreChange = appStoreEmitter.on(events.tabBarChange, function (state) {
50
- _this2.setState({
51
- renderOptions: state
52
- });
17
+ });
18
+ this.unAppStoreChange = appStoreEmitter.on(events.tabBarChange, state => {
19
+ this.setState({
20
+ renderOptions: state
53
21
  });
54
- }
55
- }, {
56
- key: "componentWillUnmount",
57
- value: function componentWillUnmount() {
58
- var _this$unChangeHandle, _this$unAppStoreChang;
59
-
60
- (_this$unChangeHandle = this.unChangeHandle) === null || _this$unChangeHandle === void 0 ? void 0 : _this$unChangeHandle.call(this);
61
- (_this$unAppStoreChang = this.unAppStoreChange) === null || _this$unAppStoreChang === void 0 ? void 0 : _this$unAppStoreChang.call(this);
62
- }
63
- }, {
64
- key: "render",
65
- value: function render() {
66
- var _clsx;
67
-
68
- var config = this.props.config;
69
- var _this$state = this.state,
70
- currentRoute = _this$state.currentRoute,
71
- renderOptions = _this$state.renderOptions;
22
+ });
23
+ }
24
+ componentWillUnmount() {
25
+ var _this$unChangeHandle, _this$unAppStoreChang;
26
+ (_this$unChangeHandle = this.unChangeHandle) === null || _this$unChangeHandle === void 0 ? void 0 : _this$unChangeHandle.call(this);
27
+ (_this$unAppStoreChang = this.unAppStoreChange) === null || _this$unAppStoreChang === void 0 ? void 0 : _this$unAppStoreChang.call(this);
28
+ }
29
+ render() {
30
+ const {
31
+ config
32
+ } = this.props;
33
+ const {
34
+ currentRoute,
35
+ renderOptions
36
+ } = this.state;
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ "data-route": currentRoute,
39
+ className: clsx(styles.wrapper, {
40
+ [styles.hidden]: !renderOptions.tabBarVisible && !renderOptions.tabBarAnimation,
41
+ [styles.showIn]: renderOptions.tabBarVisible && renderOptions.tabBarAnimation,
42
+ [styles.hideOut]: !renderOptions.tabBarVisible && renderOptions.tabBarAnimation
43
+ })
44
+ }, /*#__PURE__*/React.createElement("div", {
45
+ className: styles.tabBar
46
+ }, config.list.map((item, index) => {
47
+ const fullRoute = item.route;
48
+ const isActive = currentRoute === fullRoute;
49
+ // console.log('>>>>>>>> currentRoute: %s, item: %s', currentRoute, item.route)
72
50
  return /*#__PURE__*/React.createElement("div", {
73
- "data-route": currentRoute,
74
- className: clsx(styles.wrapper, (_clsx = {}, _defineProperty(_clsx, styles.hidden, !renderOptions.tabBarVisible && !renderOptions.tabBarAnimation), _defineProperty(_clsx, styles.showIn, renderOptions.tabBarVisible && renderOptions.tabBarAnimation), _defineProperty(_clsx, styles.hideOut, !renderOptions.tabBarVisible && renderOptions.tabBarAnimation), _clsx))
75
- }, /*#__PURE__*/React.createElement("div", {
76
- className: styles.tabBar
77
- }, config.list.map(function (item, index) {
78
- var fullRoute = item.route;
79
- var isActive = currentRoute === fullRoute; // console.log('>>>>>>>> currentRoute: %s, item: %s', currentRoute, item.route)
80
-
81
- return /*#__PURE__*/React.createElement("div", {
82
- "data-full-route": fullRoute,
83
- key: item.pagePath + index,
84
- className: styles.item,
85
- onClick: function onClick() {
86
- router.push(item.route);
87
- }
88
- }, item.icon && /*#__PURE__*/React.createElement("img", {
89
- className: styles.icon,
90
- src: "".concat(withPublicPath(isActive ? item.activeIcon : item.icon))
91
- }), /*#__PURE__*/React.createElement("span", {
92
- className: styles.text,
93
- style: {
94
- color: isActive ? config.selectedColor : config.textColor
95
- }
96
- }, item.text));
97
- })));
98
- }
99
- }]);
100
-
101
- return TabBar;
102
- }(React.Component);
51
+ "data-full-route": fullRoute,
52
+ key: item.pagePath + index,
53
+ className: styles.item,
54
+ onClick: () => {
55
+ router.push(item.route);
56
+ }
57
+ }, item.icon && /*#__PURE__*/React.createElement("img", {
58
+ className: styles.icon,
59
+ src: `${withPublicPath(isActive ? item.activeIcon : item.icon)}`
60
+ }), /*#__PURE__*/React.createElement("span", {
61
+ className: styles.text,
62
+ style: {
63
+ color: isActive ? config.selectedColor : config.textColor
64
+ }
65
+ }, item.text));
66
+ })));
67
+ }
68
+ }
@@ -0,0 +1,55 @@
1
+ import clsx from 'clsx';
2
+ import React from 'react';
3
+ import router from '@ray-js/router';
4
+ import { events, appStoreEmitter, renderOptions } from '../../store/appStore';
5
+ import { withPublicPath } from '../../utils';
6
+ import styles from './index.module.less';
7
+ export class TabBar extends React.Component {
8
+ constructor() {
9
+ super(...arguments);
10
+ this.state = {
11
+ currentRoute: router.scheduler.currentRoute,
12
+ renderOptions: renderOptions,
13
+ };
14
+ }
15
+ componentDidMount() {
16
+ this.unChangeHandle = router.scheduler.on('routeChange', (route) => {
17
+ this.setState({
18
+ currentRoute: route,
19
+ });
20
+ });
21
+ this.unAppStoreChange = appStoreEmitter.on(events.tabBarChange, (state) => {
22
+ this.setState({ renderOptions: state });
23
+ });
24
+ }
25
+ componentWillUnmount() {
26
+ var _a, _b;
27
+ (_a = this.unChangeHandle) === null || _a === void 0 ? void 0 : _a.call(this);
28
+ (_b = this.unAppStoreChange) === null || _b === void 0 ? void 0 : _b.call(this);
29
+ }
30
+ render() {
31
+ const { config } = this.props;
32
+ const { currentRoute, renderOptions } = this.state;
33
+ return (<div data-route={currentRoute} className={clsx(styles.wrapper, {
34
+ [styles.hidden]: !renderOptions.tabBarVisible && !renderOptions.tabBarAnimation,
35
+ [styles.showIn]: renderOptions.tabBarVisible && renderOptions.tabBarAnimation,
36
+ [styles.hideOut]: !renderOptions.tabBarVisible && renderOptions.tabBarAnimation,
37
+ })}>
38
+ <div className={styles.tabBar}>
39
+ {config.list.map((item, index) => {
40
+ const fullRoute = item.route;
41
+ const isActive = currentRoute === fullRoute;
42
+ // console.log('>>>>>>>> currentRoute: %s, item: %s', currentRoute, item.route)
43
+ return (<div data-full-route={fullRoute} key={item.pagePath + index} className={styles.item} onClick={() => {
44
+ router.push(item.route);
45
+ }}>
46
+ {item.icon && (<img className={styles.icon} src={`${withPublicPath(isActive ? item.activeIcon : item.icon)}`}/>)}
47
+ <span className={styles.text} style={{ color: isActive ? config.selectedColor : config.textColor }}>
48
+ {item.text}
49
+ </span>
50
+ </div>);
51
+ })}
52
+ </div>
53
+ </div>);
54
+ }
55
+ }
@@ -1,3 +1,4 @@
1
- import { responsive } from './responsive'; // 响应式设计 rem 单位
1
+ import { responsive } from './responsive';
2
2
 
3
+ // 响应式设计 rem 单位
3
4
  responsive();
@@ -1,19 +1,17 @@
1
- import "core-js/modules/es.parse-float.js";
2
- var htmlRoot = document.querySelector('html');
1
+ const htmlRoot = document.querySelector('html');
3
2
  export function responsive() {
4
3
  function setRem() {
5
- var clientWidth = htmlRoot.clientWidth; // clientWidth = Math.min(clientWidth, 640); // PC 模式下限定最大值
6
-
7
- htmlRoot.style.fontSize = "".concat(clientWidth / 7.5, "px");
8
- var div = document.createElement('div');
4
+ let clientWidth = htmlRoot.clientWidth;
5
+ // clientWidth = Math.min(clientWidth, 640); // PC 模式下限定最大值
6
+ htmlRoot.style.fontSize = `${clientWidth / 7.5}px`;
7
+ const div = document.createElement('div');
9
8
  div.style.width = '7.5rem';
10
9
  document.body.appendChild(div);
11
- htmlRoot.style.fontSize = "".concat(parseFloat(htmlRoot.style.fontSize) * clientWidth / div.clientWidth, "px");
10
+ htmlRoot.style.fontSize = `${parseFloat(htmlRoot.style.fontSize) * clientWidth / div.clientWidth}px`;
12
11
  document.body.removeChild(div);
13
- document.body.style.fontSize = "16px";
12
+ document.body.style.fontSize = `16px`;
14
13
  }
15
-
16
- var b = null;
14
+ let b = null;
17
15
  window.addEventListener('resize', function () {
18
16
  clearTimeout(b);
19
17
  b = setTimeout(setRem, 100);
@@ -1,23 +1,20 @@
1
- import "core-js/modules/es.object.assign.js";
2
1
  import { Emitter } from '@ray-js/framework-shared';
3
- export var appStoreEmitter = new Emitter();
4
- export var renderOptions = {
2
+ export const appStoreEmitter = new Emitter();
3
+ export const renderOptions = {
5
4
  tabBarVisible: true,
6
5
  tabBarAnimation: false
7
6
  };
8
- export var actions = {
7
+ export const actions = {
9
8
  toggleTabBar: 'toggleTabBar',
10
9
  onChange: 'onChange'
11
10
  };
12
- export var events = {
11
+ export const events = {
13
12
  tabBarChange: 'tabBarChange'
14
13
  };
15
-
16
- var update = function (eventName, nextState) {
14
+ const update = (eventName, nextState) => {
17
15
  Object.assign(renderOptions, nextState);
18
16
  appStoreEmitter.emit(eventName, renderOptions);
19
17
  };
20
-
21
18
  appStoreEmitter.on(actions.toggleTabBar, function (next) {
22
19
  if (next.visible !== renderOptions.tabBarVisible) update(events.tabBarChange, {
23
20
  tabBarVisible: next.visible,
@@ -1,14 +1,9 @@
1
- import "core-js/modules/es.regexp.exec.js";
2
- import "core-js/modules/es.regexp.test.js";
3
1
  import slash from 'slash';
4
2
  export function normalizeBasename(p) {
5
3
  var _p;
6
-
7
4
  p = slash((_p = p) !== null && _p !== void 0 ? _p : '/');
8
-
9
5
  if (!/^\//.test(p)) {
10
6
  p = '/' + p;
11
7
  }
12
-
13
8
  return p;
14
9
  }
@@ -1,5 +1,3 @@
1
- import "core-js/modules/es.regexp.exec.js";
2
- import "core-js/modules/es.string.replace.js";
3
1
  export function withPublicPath(basePath) {
4
2
  return PUBLIC_PATH + basePath.replace(/^\//, '');
5
3
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ray-js/framework",
3
- "version": "1.3.22",
3
+ "version": "1.3.23",
4
4
  "description": "Ray Core",
5
5
  "keywords": [
6
6
  "ray"
@@ -20,12 +20,12 @@
20
20
  "watch": "tsc -p ./tsconfig.build.json --module esnext --outDir lib --watch"
21
21
  },
22
22
  "dependencies": {
23
- "@ray-js/framework-mp": "1.3.22",
24
- "@ray-js/framework-shared": "1.3.22",
25
- "@ray-js/library": "1.3.22",
26
- "@ray-js/location": "1.3.22",
27
- "@ray-js/router": "1.3.22",
28
- "@ray-js/runtime": "1.3.22",
23
+ "@ray-js/framework-mp": "1.3.23",
24
+ "@ray-js/framework-shared": "1.3.23",
25
+ "@ray-js/library": "1.3.23",
26
+ "@ray-js/location": "1.3.23",
27
+ "@ray-js/router": "1.3.23",
28
+ "@ray-js/runtime": "1.3.23",
29
29
  "clsx": "^1.1.1",
30
30
  "hoist-non-react-statics": "^3.3.2",
31
31
  "lodash.get": "^4.4.2",
@@ -34,8 +34,8 @@
34
34
  "tiny-invariant": "^1.1.0"
35
35
  },
36
36
  "devDependencies": {
37
- "@ray-js/cli": "1.3.22",
38
- "@ray-js/types": "1.3.22"
37
+ "@ray-js/cli": "1.3.23",
38
+ "@ray-js/types": "1.3.23"
39
39
  },
40
40
  "maintainers": [
41
41
  {
@@ -43,6 +43,6 @@
43
43
  "email": "tuyafe@tuya.com"
44
44
  }
45
45
  ],
46
- "gitHead": "14cb935df10f020e714b44bb41d4899646db751c",
46
+ "gitHead": "04708bb394d817a7a522fcde178f19f170d5d364",
47
47
  "repository": {}
48
48
  }