@rsmax/runtime 1.0.1
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/CHANGELOG.md +6 -0
- package/cjs/AppContainer.d.ts +22 -0
- package/cjs/AppContainer.js +40 -0
- package/cjs/Container.d.ts +39 -0
- package/cjs/Container.js +120 -0
- package/cjs/ReactPortal.d.ts +2 -0
- package/cjs/ReactPortal.js +15 -0
- package/cjs/SyntheticEvent/constants.d.ts +2 -0
- package/cjs/SyntheticEvent/constants.js +13 -0
- package/cjs/SyntheticEvent/createCallbackProxy.d.ts +2 -0
- package/cjs/SyntheticEvent/createCallbackProxy.js +59 -0
- package/cjs/SyntheticEvent/stopPropagation.d.ts +13 -0
- package/cjs/SyntheticEvent/stopPropagation.js +33 -0
- package/cjs/VNode.d.ts +45 -0
- package/cjs/VNode.js +276 -0
- package/cjs/constants.d.ts +3 -0
- package/cjs/constants.js +6 -0
- package/cjs/createAppConfig.d.ts +2 -0
- package/cjs/createAppConfig.js +124 -0
- package/cjs/createComponentConfig.d.ts +2 -0
- package/cjs/createComponentConfig.js +74 -0
- package/cjs/createComponentConfig.wechat.d.ts +2 -0
- package/cjs/createComponentConfig.wechat.js +89 -0
- package/cjs/createHostComponent.d.ts +2 -0
- package/cjs/createHostComponent.js +20 -0
- package/cjs/createNativeComponent.d.ts +2 -0
- package/cjs/createNativeComponent.js +23 -0
- package/cjs/createPageConfig.d.ts +3 -0
- package/cjs/createPageConfig.js +191 -0
- package/cjs/hooks/index.d.ts +3 -0
- package/cjs/hooks/index.js +15 -0
- package/cjs/hooks/useNativeEffect.d.ts +3 -0
- package/cjs/hooks/useNativeEffect.js +13 -0
- package/cjs/hooks/useQuery.d.ts +3 -0
- package/cjs/hooks/useQuery.js +9 -0
- package/cjs/hostConfig/diffProperties.d.ts +1 -0
- package/cjs/hostConfig/diffProperties.js +100 -0
- package/cjs/hostConfig/index.d.ts +42 -0
- package/cjs/hostConfig/index.js +159 -0
- package/cjs/index.d.ts +14 -0
- package/cjs/index.js +43 -0
- package/cjs/instanceId.d.ts +2 -0
- package/cjs/instanceId.js +14 -0
- package/cjs/nativeEffect.d.ts +10 -0
- package/cjs/nativeEffect.js +25 -0
- package/cjs/polyfills/Function.d.ts +0 -0
- package/cjs/polyfills/Function.js +29 -0
- package/cjs/propsAlias.d.ts +6 -0
- package/cjs/propsAlias.js +51 -0
- package/cjs/render.d.ts +6 -0
- package/cjs/render.js +35 -0
- package/cjs/stopPullDownRefresh/index.ali.d.ts +2 -0
- package/cjs/stopPullDownRefresh/index.ali.js +3 -0
- package/cjs/stopPullDownRefresh/index.d.ts +1 -0
- package/cjs/stopPullDownRefresh/index.js +6 -0
- package/cjs/stopPullDownRefresh/index.toutiao.d.ts +2 -0
- package/cjs/stopPullDownRefresh/index.toutiao.js +3 -0
- package/cjs/stopPullDownRefresh/index.wechat.d.ts +2 -0
- package/cjs/stopPullDownRefresh/index.wechat.js +3 -0
- package/cjs/utils/capitalize.d.ts +1 -0
- package/cjs/utils/capitalize.js +6 -0
- package/cjs/utils/isClassComponent.d.ts +2 -0
- package/cjs/utils/isClassComponent.js +6 -0
- package/cjs/utils/lowercase.d.ts +1 -0
- package/cjs/utils/lowercase.js +6 -0
- package/cjs/utils/plainStyle/CSSProperty.d.ts +6 -0
- package/cjs/utils/plainStyle/CSSProperty.js +71 -0
- package/cjs/utils/plainStyle/index.d.ts +2 -0
- package/cjs/utils/plainStyle/index.js +45 -0
- package/esm/AppContainer.d.ts +22 -0
- package/esm/AppContainer.js +34 -0
- package/esm/Container.d.ts +39 -0
- package/esm/Container.js +114 -0
- package/esm/ReactPortal.d.ts +2 -0
- package/esm/ReactPortal.js +11 -0
- package/esm/SyntheticEvent/constants.d.ts +2 -0
- package/esm/SyntheticEvent/constants.js +10 -0
- package/esm/SyntheticEvent/createCallbackProxy.d.ts +2 -0
- package/esm/SyntheticEvent/createCallbackProxy.js +32 -0
- package/esm/SyntheticEvent/stopPropagation.d.ts +13 -0
- package/esm/SyntheticEvent/stopPropagation.js +28 -0
- package/esm/VNode.d.ts +45 -0
- package/esm/VNode.js +250 -0
- package/esm/constants.d.ts +3 -0
- package/esm/constants.js +3 -0
- package/esm/createAppConfig.d.ts +2 -0
- package/esm/createAppConfig.js +95 -0
- package/esm/createComponentConfig.d.ts +2 -0
- package/esm/createComponentConfig.js +45 -0
- package/esm/createComponentConfig.wechat.d.ts +2 -0
- package/esm/createComponentConfig.wechat.js +60 -0
- package/esm/createHostComponent.d.ts +2 -0
- package/esm/createHostComponent.js +14 -0
- package/esm/createNativeComponent.d.ts +2 -0
- package/esm/createNativeComponent.js +17 -0
- package/esm/createPageConfig.d.ts +3 -0
- package/esm/createPageConfig.js +183 -0
- package/esm/hooks/index.d.ts +3 -0
- package/esm/hooks/index.js +3 -0
- package/esm/hooks/useNativeEffect.d.ts +3 -0
- package/esm/hooks/useNativeEffect.js +7 -0
- package/esm/hooks/useQuery.d.ts +3 -0
- package/esm/hooks/useQuery.js +6 -0
- package/esm/hostConfig/diffProperties.d.ts +1 -0
- package/esm/hostConfig/diffProperties.js +97 -0
- package/esm/hostConfig/index.d.ts +42 -0
- package/esm/hostConfig/index.js +154 -0
- package/esm/index.d.ts +14 -0
- package/esm/index.js +14 -0
- package/esm/instanceId.d.ts +2 -0
- package/esm/instanceId.js +9 -0
- package/esm/nativeEffect.d.ts +10 -0
- package/esm/nativeEffect.js +23 -0
- package/esm/polyfills/Function.d.ts +0 -0
- package/esm/polyfills/Function.js +29 -0
- package/esm/propsAlias.d.ts +6 -0
- package/esm/propsAlias.js +42 -0
- package/esm/render.d.ts +6 -0
- package/esm/render.js +28 -0
- package/esm/stopPullDownRefresh/index.ali.d.ts +2 -0
- package/esm/stopPullDownRefresh/index.ali.js +1 -0
- package/esm/stopPullDownRefresh/index.d.ts +1 -0
- package/esm/stopPullDownRefresh/index.js +3 -0
- package/esm/stopPullDownRefresh/index.toutiao.d.ts +2 -0
- package/esm/stopPullDownRefresh/index.toutiao.js +1 -0
- package/esm/stopPullDownRefresh/index.wechat.d.ts +2 -0
- package/esm/stopPullDownRefresh/index.wechat.js +1 -0
- package/esm/utils/capitalize.d.ts +1 -0
- package/esm/utils/capitalize.js +3 -0
- package/esm/utils/isClassComponent.d.ts +2 -0
- package/esm/utils/isClassComponent.js +3 -0
- package/esm/utils/lowercase.d.ts +1 -0
- package/esm/utils/lowercase.js +3 -0
- package/esm/utils/plainStyle/CSSProperty.d.ts +6 -0
- package/esm/utils/plainStyle/CSSProperty.js +68 -0
- package/esm/utils/plainStyle/index.d.ts +2 -0
- package/esm/utils/plainStyle/index.js +43 -0
- package/package.json +56 -0
- package/typings/index.d.ts +6 -0
- package/vitest.config.js +9 -0
package/esm/render.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import ReactReconciler from 'react-reconciler';
|
|
3
|
+
import Container from './Container';
|
|
4
|
+
import AppContainer from './AppContainer';
|
|
5
|
+
export declare const ReactReconcilerInst: ReactReconciler.Reconciler<unknown, unknown, unknown, unknown, unknown>;
|
|
6
|
+
export default function render(rootElement: React.ReactElement | null, container: Container | AppContainer): any;
|
package/esm/render.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import ReactReconciler from 'react-reconciler';
|
|
2
|
+
import hostConfig from './hostConfig';
|
|
3
|
+
export const ReactReconcilerInst = ReactReconciler(hostConfig);
|
|
4
|
+
if (process.env.NODE_ENV === 'development') {
|
|
5
|
+
ReactReconcilerInst.injectIntoDevTools({
|
|
6
|
+
bundleType: 1,
|
|
7
|
+
version: '18.3.0',
|
|
8
|
+
rendererPackageName: 'remax',
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
function getPublicRootInstance(container) {
|
|
12
|
+
const containerFiber = container.current;
|
|
13
|
+
if (!containerFiber.child) {
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
return containerFiber.child.stateNode;
|
|
17
|
+
}
|
|
18
|
+
export default function render(rootElement, container) {
|
|
19
|
+
// Create a root Container if it doesnt exist
|
|
20
|
+
if (!container._rootContainer) {
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
22
|
+
container._rootContainer = ReactReconcilerInst.createContainer(container, 0, null, false, null, '', () => { }, null);
|
|
23
|
+
}
|
|
24
|
+
ReactReconcilerInst.updateContainer(rootElement, container._rootContainer, null, () => {
|
|
25
|
+
// ignore
|
|
26
|
+
});
|
|
27
|
+
return getPublicRootInstance(container._rootContainer);
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default my.stopPullDownRefresh;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function stopPullDownRefresh(): void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default tt.stopPullDownRefresh;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default wx.stopPullDownRefresh;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function capitalize(str: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function lowercase(str: string): string;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// https://github.com/facebook/react/blob/master/packages/react-dom/src/shared/CSSProperty.js
|
|
2
|
+
/**
|
|
3
|
+
* CSS properties which accept numbers but are not in units of "px".
|
|
4
|
+
*/
|
|
5
|
+
export const isUnitlessNumber = {
|
|
6
|
+
animationIterationCount: true,
|
|
7
|
+
borderImageOutset: true,
|
|
8
|
+
borderImageSlice: true,
|
|
9
|
+
borderImageWidth: true,
|
|
10
|
+
boxFlex: true,
|
|
11
|
+
boxFlexGroup: true,
|
|
12
|
+
boxOrdinalGroup: true,
|
|
13
|
+
columnCount: true,
|
|
14
|
+
columns: true,
|
|
15
|
+
flex: true,
|
|
16
|
+
flexGrow: true,
|
|
17
|
+
flexPositive: true,
|
|
18
|
+
flexShrink: true,
|
|
19
|
+
flexNegative: true,
|
|
20
|
+
flexOrder: true,
|
|
21
|
+
gridArea: true,
|
|
22
|
+
gridRow: true,
|
|
23
|
+
gridRowEnd: true,
|
|
24
|
+
gridRowSpan: true,
|
|
25
|
+
gridRowStart: true,
|
|
26
|
+
gridColumn: true,
|
|
27
|
+
gridColumnEnd: true,
|
|
28
|
+
gridColumnSpan: true,
|
|
29
|
+
gridColumnStart: true,
|
|
30
|
+
fontWeight: true,
|
|
31
|
+
lineClamp: true,
|
|
32
|
+
lineHeight: true,
|
|
33
|
+
opacity: true,
|
|
34
|
+
order: true,
|
|
35
|
+
orphans: true,
|
|
36
|
+
tabSize: true,
|
|
37
|
+
widows: true,
|
|
38
|
+
zIndex: true,
|
|
39
|
+
zoom: true,
|
|
40
|
+
// SVG-related properties
|
|
41
|
+
fillOpacity: true,
|
|
42
|
+
floodOpacity: true,
|
|
43
|
+
stopOpacity: true,
|
|
44
|
+
strokeDasharray: true,
|
|
45
|
+
strokeDashoffset: true,
|
|
46
|
+
strokeMiterlimit: true,
|
|
47
|
+
strokeOpacity: true,
|
|
48
|
+
strokeWidth: true,
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* @param {string} prefix vendor-specific prefix, eg: Webkit
|
|
52
|
+
* @param {string} key style name, eg: transitionDuration
|
|
53
|
+
* @return {string} style name prefixed with `prefix`, properly camelCased, eg:
|
|
54
|
+
* WebkitTransitionDuration
|
|
55
|
+
*/
|
|
56
|
+
function prefixKey(prefix, key) {
|
|
57
|
+
return prefix + key.charAt(0).toUpperCase() + key.substring(1);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Support style names that may come passed in prefixed by adding permutations
|
|
61
|
+
* of vendor prefixes.
|
|
62
|
+
*/
|
|
63
|
+
const prefixes = ['Webkit', 'ms', 'Moz', 'O'];
|
|
64
|
+
for (const prop in isUnitlessNumber) {
|
|
65
|
+
prefixes.forEach(function (prefix) {
|
|
66
|
+
isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
|
|
67
|
+
});
|
|
68
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { isUnitlessNumber } from './CSSProperty';
|
|
2
|
+
import { find, RuntimeOptions } from '@rsmax/framework-shared';
|
|
3
|
+
const vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
|
4
|
+
const transformReactStyleKey = (key) => {
|
|
5
|
+
// css3 var
|
|
6
|
+
if (key === null || key === void 0 ? void 0 : key.startsWith('--')) {
|
|
7
|
+
return key;
|
|
8
|
+
}
|
|
9
|
+
let styleValue = key.replace(/\.?([A-Z]+)/g, function (_x, y) {
|
|
10
|
+
return '-' + y.toLowerCase();
|
|
11
|
+
});
|
|
12
|
+
// vendor prefix
|
|
13
|
+
if (styleValue === null || styleValue === void 0 ? void 0 : styleValue.startsWith('-')) {
|
|
14
|
+
const firstWord = styleValue.split('-').filter(s => s)[0];
|
|
15
|
+
styleValue = styleValue.replace(/^-/, '');
|
|
16
|
+
if (find(vendorPrefixes, prefix => prefix === firstWord)) {
|
|
17
|
+
styleValue = '-' + styleValue;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return styleValue;
|
|
21
|
+
};
|
|
22
|
+
const transformPx = (value) => {
|
|
23
|
+
if (typeof value !== 'string') {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
return value.replace(/\b(\d+(\.\d+)?)px\b/g, function (match, x) {
|
|
27
|
+
const targetUnit = 'rpx';
|
|
28
|
+
const size = Number(x);
|
|
29
|
+
return size % 1 === 0 ? size + targetUnit : size.toFixed(2) + targetUnit;
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
const plainStyle = (style) => {
|
|
33
|
+
return Object.keys(style)
|
|
34
|
+
.reduce((acc, key) => {
|
|
35
|
+
let value = style[key];
|
|
36
|
+
if (!Number.isNaN(Number(value)) && !isUnitlessNumber[key] && !(key === null || key === void 0 ? void 0 : key.startsWith('--'))) {
|
|
37
|
+
value = value + 'rpx';
|
|
38
|
+
}
|
|
39
|
+
return [...acc, `${transformReactStyleKey(key)}:${RuntimeOptions.get('pxToRpx') ? transformPx(value) : value};`];
|
|
40
|
+
}, [])
|
|
41
|
+
.join('');
|
|
42
|
+
};
|
|
43
|
+
export default plainStyle;
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rsmax/runtime",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"description": "Rsmax 是一个全新的基于 React 的小程序开发框架",
|
|
5
|
+
"main": "./cjs/index.js",
|
|
6
|
+
"esnext": "./esm/index.js",
|
|
7
|
+
"module": "./esm/index.js",
|
|
8
|
+
"typings": "./esm/index.d.ts",
|
|
9
|
+
"keywords": [
|
|
10
|
+
"react",
|
|
11
|
+
"miniapp",
|
|
12
|
+
"mini-program",
|
|
13
|
+
"wechat"
|
|
14
|
+
],
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/remaxjs/remax/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/remaxjs/remax.git"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://remaxjs.org",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"clean": "rimraf esm cjs tsconfig.tsbuildinfo",
|
|
26
|
+
"prebuild": "npm run clean",
|
|
27
|
+
"build": "tsc",
|
|
28
|
+
"build:cjs": "tsc --module CommonJS --outDir cjs",
|
|
29
|
+
"test": "vitest run"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@rsmax/framework-shared": "workspace:*",
|
|
33
|
+
"@rsmax/shared": "workspace:*",
|
|
34
|
+
"@rsmax/web": "workspace:*",
|
|
35
|
+
"qs": "^6.9.3",
|
|
36
|
+
"react-is": "^18.3.0",
|
|
37
|
+
"react-reconciler": "0.29.0",
|
|
38
|
+
"scheduler": "0.19.1"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@rsmax/types": "workspace:*",
|
|
42
|
+
"@types/lodash.merge": "^4.6.6",
|
|
43
|
+
"@types/node": "^18",
|
|
44
|
+
"@types/qs": "^6.9.3",
|
|
45
|
+
"@types/react": "^18.3.0",
|
|
46
|
+
"@types/react-is": "^18.3.0",
|
|
47
|
+
"@types/react-reconciler": "0.28.8",
|
|
48
|
+
"@types/react-test-renderer": "^18.3.0",
|
|
49
|
+
"object-path-immutable": "^4.0.2",
|
|
50
|
+
"react-test-renderer": "^18.3.0"
|
|
51
|
+
},
|
|
52
|
+
"publishConfig": {
|
|
53
|
+
"access": "public"
|
|
54
|
+
},
|
|
55
|
+
"gitHead": "d2ff644810449152d124a9da76218bcd9fdfff46"
|
|
56
|
+
}
|