@rsmax/runtime 1.3.14 → 2.0.0-canary.91
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/cjs/Container.js +83 -25
- package/cjs/ReactPortal.js +1 -2
- package/cjs/SyntheticEvent/constants.js +1 -0
- package/cjs/SyntheticEvent/createCallbackProxy.js +20 -12
- package/cjs/SyntheticEvent/stopPropagation.js +3 -3
- package/cjs/VNode.js +22 -14
- package/cjs/createAppConfig.js +18 -8
- package/cjs/createComponentConfig.js +18 -8
- package/cjs/createComponentConfig.wechat.js +25 -24
- package/cjs/createHostComponent.js +1 -1
- package/cjs/createNativeComponent.js +1 -1
- package/cjs/createPageConfig.js +2 -3
- package/cjs/hooks/useNativeEffect.js +4 -2
- package/cjs/hooks/useQuery.js +1 -1
- package/cjs/hostConfig/diffProperties.js +1 -1
- package/cjs/hostConfig/index.d.ts +1 -1
- package/cjs/hostConfig/index.js +3 -2
- package/cjs/instanceId.js +2 -3
- package/cjs/propsAlias.js +3 -4
- package/cjs/render.js +4 -5
- package/cjs/stopPullDownRefresh/index.js +1 -1
- package/cjs/utils/capitalize.js +1 -1
- package/cjs/utils/isClassComponent.js +1 -1
- package/cjs/utils/lowercase.js +1 -1
- package/cjs/utils/plainStyle/index.js +8 -6
- package/esm/Container.js +83 -25
- package/esm/SyntheticEvent/constants.js +1 -0
- package/esm/SyntheticEvent/createCallbackProxy.js +2 -3
- package/esm/VNode.js +5 -7
- package/esm/createComponentConfig.wechat.js +7 -16
- package/esm/hooks/useNativeEffect.js +4 -2
- package/esm/hostConfig/index.d.ts +1 -1
- package/esm/hostConfig/index.js +3 -2
- package/esm/render.js +3 -4
- package/esm/utils/plainStyle/index.js +9 -7
- package/package.json +6 -6
package/cjs/Container.js
CHANGED
|
@@ -40,32 +40,70 @@ class Container {
|
|
|
40
40
|
$batchedUpdates = this.context.$batchedUpdates;
|
|
41
41
|
}
|
|
42
42
|
$batchedUpdates(() => {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
43
|
+
if (framework_shared_1.RuntimeOptions.get('mergeSpliceData')) {
|
|
44
|
+
const splicePayload = {};
|
|
45
|
+
const setPayload = {};
|
|
46
|
+
this.updateQueue.forEach(update => {
|
|
47
|
+
if (update.type === 'splice') {
|
|
48
|
+
splicePayload[this.normalizeUpdatePath([...update.path, 'children'])] = [
|
|
49
|
+
update.start,
|
|
50
|
+
update.deleteCount,
|
|
51
|
+
...update.items,
|
|
52
|
+
];
|
|
53
|
+
}
|
|
54
|
+
else if (update.type === 'set') {
|
|
55
|
+
setPayload[this.normalizeUpdatePath([...update.path, update.name])] = update.value;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const hasSplice = Object.keys(splicePayload).length > 0;
|
|
59
|
+
const hasSet = Object.keys(setPayload).length > 0;
|
|
60
|
+
const total = (hasSplice ? 1 : 0) + (hasSet ? 1 : 0);
|
|
61
|
+
let done = 0;
|
|
62
|
+
const doneCallback = () => {
|
|
63
|
+
done += 1;
|
|
64
|
+
if (done === total) {
|
|
47
65
|
nativeEffect_1.default.run();
|
|
48
66
|
/* istanbul ignore next */
|
|
49
67
|
if (framework_shared_1.RuntimeOptions.get('debug')) {
|
|
50
68
|
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`);
|
|
51
69
|
}
|
|
52
|
-
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
if (hasSplice) {
|
|
73
|
+
this.context.$spliceData(splicePayload, doneCallback);
|
|
53
74
|
}
|
|
54
|
-
if (
|
|
55
|
-
this.context
|
|
56
|
-
[this.normalizeUpdatePath([...update.path, 'children'])]: [
|
|
57
|
-
update.start,
|
|
58
|
-
update.deleteCount,
|
|
59
|
-
...update.items,
|
|
60
|
-
],
|
|
61
|
-
}, callback);
|
|
62
|
-
}
|
|
63
|
-
if (update.type === 'set') {
|
|
64
|
-
this.context.setData({
|
|
65
|
-
[this.normalizeUpdatePath([...update.path, update.name])]: update.value,
|
|
66
|
-
}, callback);
|
|
75
|
+
if (hasSet) {
|
|
76
|
+
this.context.setData(setPayload, doneCallback);
|
|
67
77
|
}
|
|
68
|
-
}
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.updateQueue.map((update, index) => {
|
|
81
|
+
let callback = undefined;
|
|
82
|
+
if (index + 1 === this.updateQueue.length) {
|
|
83
|
+
callback = () => {
|
|
84
|
+
nativeEffect_1.default.run();
|
|
85
|
+
/* istanbul ignore next */
|
|
86
|
+
if (framework_shared_1.RuntimeOptions.get('debug')) {
|
|
87
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
if (update.type === 'splice') {
|
|
92
|
+
this.context.$spliceData({
|
|
93
|
+
[this.normalizeUpdatePath([...update.path, 'children'])]: [
|
|
94
|
+
update.start,
|
|
95
|
+
update.deleteCount,
|
|
96
|
+
...update.items,
|
|
97
|
+
],
|
|
98
|
+
}, callback);
|
|
99
|
+
}
|
|
100
|
+
if (update.type === 'set') {
|
|
101
|
+
this.context.setData({
|
|
102
|
+
[this.normalizeUpdatePath([...update.path, update.name])]: update.value,
|
|
103
|
+
}, callback);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
69
107
|
});
|
|
70
108
|
this.updateQueue = [];
|
|
71
109
|
return;
|
|
@@ -85,13 +123,33 @@ class Container {
|
|
|
85
123
|
}
|
|
86
124
|
return acc;
|
|
87
125
|
}, {});
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
126
|
+
const chunkSize = framework_shared_1.RuntimeOptions.get('setDataChunkSize');
|
|
127
|
+
const entries = Object.entries(updatePayload);
|
|
128
|
+
if (chunkSize && chunkSize > 0 && entries.length > chunkSize) {
|
|
129
|
+
for (let i = 0; i < entries.length; i += chunkSize) {
|
|
130
|
+
const slice = entries.slice(i, i + chunkSize);
|
|
131
|
+
const payloadChunk = Object.fromEntries(slice);
|
|
132
|
+
const isLast = i + chunkSize >= entries.length;
|
|
133
|
+
this.context.setData(payloadChunk, () => {
|
|
134
|
+
if (isLast) {
|
|
135
|
+
nativeEffect_1.default.run();
|
|
136
|
+
/* istanbul ignore next */
|
|
137
|
+
if (framework_shared_1.RuntimeOptions.get('debug')) {
|
|
138
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`, payloadChunk);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
});
|
|
93
142
|
}
|
|
94
|
-
}
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
this.context.setData(updatePayload, () => {
|
|
146
|
+
nativeEffect_1.default.run();
|
|
147
|
+
/* istanbul ignore next */
|
|
148
|
+
if (framework_shared_1.RuntimeOptions.get('debug')) {
|
|
149
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`, updatePayload);
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
95
153
|
this.updateQueue = [];
|
|
96
154
|
}
|
|
97
155
|
clearUpdate() {
|
package/cjs/ReactPortal.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createPortal =
|
|
3
|
+
exports.createPortal = createPortal;
|
|
4
4
|
const react_is_1 = require("react-is");
|
|
5
5
|
function createPortal(children, containerInfo, key) {
|
|
6
6
|
return {
|
|
@@ -12,4 +12,3 @@ function createPortal(children, containerInfo, key) {
|
|
|
12
12
|
implementation: null,
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
|
-
exports.createPortal = createPortal;
|
|
@@ -15,23 +15,32 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.createCallbackProxy =
|
|
27
|
-
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
36
|
+
exports.createCallbackProxy = createCallbackProxy;
|
|
28
37
|
const constants_1 = require("./constants");
|
|
29
38
|
const stopPropagation_1 = __importStar(require("./stopPropagation"));
|
|
30
39
|
function isSyntheticType(inputType) {
|
|
31
40
|
if (constants_1.DEPRECATED_CATCH_TYPE === inputType) {
|
|
32
|
-
console.warn('DEPRECATION:
|
|
41
|
+
console.warn('DEPRECATION: rsmax 已支持在 onClick 事件中使用 stopPropagation 阻止事件冒泡,请尽量不要使用 catchClick');
|
|
33
42
|
}
|
|
34
|
-
return
|
|
43
|
+
return constants_1.SYNTHETIC_TYPES.includes(inputType);
|
|
35
44
|
}
|
|
36
45
|
function createBaseSyntheticEvent(node, eventType, nativeEvent) {
|
|
37
46
|
if (!nativeEvent) {
|
|
@@ -56,4 +65,3 @@ function createCallbackProxy(eventType, node, callback) {
|
|
|
56
65
|
return callback(syntheticEvent, ...restParams);
|
|
57
66
|
};
|
|
58
67
|
}
|
|
59
|
-
exports.createCallbackProxy = createCallbackProxy;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.isPropagationStopped = void 0;
|
|
4
|
+
exports.validate = validate;
|
|
5
|
+
exports.default = stopPropagation;
|
|
4
6
|
const constants_1 = require("./constants");
|
|
5
7
|
exports.isPropagationStopped = {};
|
|
6
8
|
constants_1.SYNTHETIC_TYPES.forEach(type => {
|
|
@@ -25,9 +27,7 @@ function validate(node, eventType) {
|
|
|
25
27
|
}
|
|
26
28
|
validate(parent, eventType);
|
|
27
29
|
}
|
|
28
|
-
exports.validate = validate;
|
|
29
30
|
function stopPropagation(node, eventType) {
|
|
30
31
|
exports.isPropagationStopped[eventType] = true;
|
|
31
32
|
validate(node, eventType);
|
|
32
33
|
}
|
|
33
|
-
exports.default = stopPropagation;
|
package/cjs/VNode.js
CHANGED
|
@@ -15,13 +15,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
36
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
27
37
|
const createCallbackProxy_1 = require("./SyntheticEvent/createCallbackProxy");
|
|
@@ -249,21 +259,19 @@ class VNode {
|
|
|
249
259
|
// while 循环已经保证了不会有空值
|
|
250
260
|
const stackItem = stack.pop();
|
|
251
261
|
const { children = [], currentNode } = stackItem;
|
|
252
|
-
for (let i =
|
|
262
|
+
for (let i = 0; i < children.length; i++) {
|
|
253
263
|
const currentVNode = children[i];
|
|
254
264
|
const currentRawNode = toRawNode(currentVNode);
|
|
255
|
-
if (framework_shared_1.RuntimeOptions.get('platform') !== 'ali') {
|
|
256
|
-
currentNode.children.unshift(currentRawNode.id);
|
|
257
|
-
}
|
|
258
|
-
else {
|
|
259
|
-
currentNode.children.unshift(currentRawNode);
|
|
260
|
-
}
|
|
261
265
|
if (framework_shared_1.RuntimeOptions.get('platform') !== 'ali') {
|
|
262
266
|
if (!currentNode.nodes) {
|
|
263
267
|
currentNode.nodes = {};
|
|
264
268
|
}
|
|
269
|
+
currentNode.children.push(currentRawNode.id);
|
|
265
270
|
currentNode.nodes[currentRawNode.id] = currentRawNode;
|
|
266
271
|
}
|
|
272
|
+
else {
|
|
273
|
+
currentNode.children.push(currentRawNode);
|
|
274
|
+
}
|
|
267
275
|
stack.push({
|
|
268
276
|
currentNode: currentRawNode,
|
|
269
277
|
children: currentVNode.children,
|
package/cjs/createAppConfig.js
CHANGED
|
@@ -15,17 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = createAppConfig;
|
|
29
40
|
require("./polyfills/Function");
|
|
30
41
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
31
42
|
const React = __importStar(require("react"));
|
|
@@ -122,4 +133,3 @@ function createAppConfig(App) {
|
|
|
122
133
|
};
|
|
123
134
|
return createConfig(WrappedApp);
|
|
124
135
|
}
|
|
125
|
-
exports.default = createAppConfig;
|
|
@@ -15,17 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = createComponentConfig;
|
|
29
40
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
30
41
|
const React = __importStar(require("react"));
|
|
31
42
|
const Container_1 = __importDefault(require("./Container"));
|
|
@@ -71,4 +82,3 @@ function createComponentConfig(Component) {
|
|
|
71
82
|
};
|
|
72
83
|
return config;
|
|
73
84
|
}
|
|
74
|
-
exports.default = createComponentConfig;
|
|
@@ -15,17 +15,28 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
|
|
|
15
15
|
}) : function(o, v) {
|
|
16
16
|
o["default"] = v;
|
|
17
17
|
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
};
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
25
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
37
|
};
|
|
28
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = createComponentConfig;
|
|
29
40
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
30
41
|
const React = __importStar(require("react"));
|
|
31
42
|
const Container_1 = __importDefault(require("./Container"));
|
|
@@ -41,6 +52,13 @@ function createComponentConfig(Component) {
|
|
|
41
52
|
children: [],
|
|
42
53
|
},
|
|
43
54
|
},
|
|
55
|
+
observers: {
|
|
56
|
+
'**'(nextProps) {
|
|
57
|
+
if (this.container && this.properties !== nextProps) {
|
|
58
|
+
this.render();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
},
|
|
44
62
|
attached: function () {
|
|
45
63
|
// 在组件实例进入页面节点树时执行
|
|
46
64
|
if (!this.container) {
|
|
@@ -52,22 +70,6 @@ function createComponentConfig(Component) {
|
|
|
52
70
|
this.container.clearUpdate();
|
|
53
71
|
(0, render_1.default)(null, this.container);
|
|
54
72
|
},
|
|
55
|
-
/*
|
|
56
|
-
TODO: 当前微信无对应语法支持监听props
|
|
57
|
-
且必须显示设定 properties,才能在组件中使用 this.properties.name
|
|
58
|
-
所以当前的实现不支持在微信端 props
|
|
59
|
-
eg:
|
|
60
|
-
properties: {
|
|
61
|
-
name: String
|
|
62
|
-
},
|
|
63
|
-
|
|
64
|
-
didUpdate(prevProps: any, prevData: any) {
|
|
65
|
-
if (prevData !== this.data) {
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
this.render();
|
|
70
|
-
},*/
|
|
71
73
|
methods: {
|
|
72
74
|
init() {
|
|
73
75
|
this.component = framework_shared_1.RuntimeOptions.get('pluginDriver').onMiniComponent({
|
|
@@ -86,4 +88,3 @@ function createComponentConfig(Component) {
|
|
|
86
88
|
};
|
|
87
89
|
return config;
|
|
88
90
|
}
|
|
89
|
-
exports.default = createComponentConfig;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createHostComponent;
|
|
6
7
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
7
8
|
const react_1 = __importDefault(require("react"));
|
|
8
9
|
function createHostComponent(name, component) {
|
|
@@ -17,4 +18,3 @@ function createHostComponent(name, component) {
|
|
|
17
18
|
Component.displayName = name;
|
|
18
19
|
return framework_shared_1.RuntimeOptions.get('pluginDriver').onCreateHostComponent(Component);
|
|
19
20
|
}
|
|
20
|
-
exports.default = createHostComponent;
|
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = createNativeComponent;
|
|
6
7
|
const react_1 = __importDefault(require("react"));
|
|
7
8
|
function createNativeComponent(name) {
|
|
8
9
|
const Component = react_1.default.forwardRef((props, ref) => {
|
|
@@ -20,4 +21,3 @@ function createNativeComponent(name) {
|
|
|
20
21
|
Component.displayName = name;
|
|
21
22
|
return Component;
|
|
22
23
|
}
|
|
23
|
-
exports.default = createNativeComponent;
|
package/cjs/createPageConfig.js
CHANGED
|
@@ -3,7 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.resetPageId =
|
|
6
|
+
exports.resetPageId = resetPageId;
|
|
7
|
+
exports.default = createPageConfig;
|
|
7
8
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
8
9
|
const react_1 = __importDefault(require("react"));
|
|
9
10
|
const Container_1 = __importDefault(require("./Container"));
|
|
@@ -22,7 +23,6 @@ function generatePageId() {
|
|
|
22
23
|
function resetPageId() {
|
|
23
24
|
idCounter = 0;
|
|
24
25
|
}
|
|
25
|
-
exports.resetPageId = resetPageId;
|
|
26
26
|
function createPageConfig(Page, name) {
|
|
27
27
|
var _a;
|
|
28
28
|
let app;
|
|
@@ -189,4 +189,3 @@ function createPageConfig(Page, name) {
|
|
|
189
189
|
});
|
|
190
190
|
return framework_shared_1.RuntimeOptions.get('pluginDriver').onPageConfig({ config, page: name });
|
|
191
191
|
}
|
|
192
|
-
exports.default = createPageConfig;
|
|
@@ -3,11 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = useNativeEffect;
|
|
6
7
|
const react_1 = require("react");
|
|
7
8
|
const nativeEffect_1 = __importDefault(require("../nativeEffect"));
|
|
9
|
+
// 创建服务端安全的effect hook
|
|
10
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? react_1.useLayoutEffect : react_1.useEffect;
|
|
8
11
|
function useNativeEffect(listener, deps) {
|
|
9
|
-
(
|
|
12
|
+
useIsomorphicLayoutEffect(() => {
|
|
10
13
|
return nativeEffect_1.default.connect(listener, !!deps);
|
|
11
14
|
}, deps);
|
|
12
15
|
}
|
|
13
|
-
exports.default = useNativeEffect;
|
package/cjs/hooks/useQuery.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = useQuery;
|
|
3
4
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
4
5
|
const react_1 = require("react");
|
|
5
6
|
function useQuery() {
|
|
6
7
|
const pageInstance = (0, react_1.useContext)(framework_shared_1.PageInstanceContext);
|
|
7
8
|
return pageInstance.query;
|
|
8
9
|
}
|
|
9
|
-
exports.default = useQuery;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = diffProperties;
|
|
3
4
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
4
5
|
const STYLE = ['style', 'placeholderStyle'];
|
|
5
6
|
const CHILDREN = 'children';
|
|
@@ -97,4 +98,3 @@ function diffProperties(lastRawProps, nextRawProps) {
|
|
|
97
98
|
}
|
|
98
99
|
return updatePayload.length ? updatePayload : null;
|
|
99
100
|
}
|
|
100
|
-
exports.default = diffProperties;
|
|
@@ -4,7 +4,7 @@ declare const _default: {
|
|
|
4
4
|
now: any;
|
|
5
5
|
getPublicInstance: <T>(inst: T) => T;
|
|
6
6
|
getRootHostContext: () => {};
|
|
7
|
-
shouldSetTextContent(type: string):
|
|
7
|
+
shouldSetTextContent(type: string): type is "stub-block";
|
|
8
8
|
prepareForCommit: () => null;
|
|
9
9
|
preparePortalMount: () => void;
|
|
10
10
|
clearContainer: () => void;
|
package/cjs/hostConfig/index.js
CHANGED
|
@@ -3,6 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
6
7
|
const scheduler_1 = __importDefault(require("scheduler"));
|
|
7
8
|
const VNode_1 = __importDefault(require("../VNode"));
|
|
8
9
|
const constants_1 = require("../constants");
|
|
@@ -62,11 +63,11 @@ exports.default = {
|
|
|
62
63
|
return childHostContext;
|
|
63
64
|
},
|
|
64
65
|
createInstance(type, newProps, container) {
|
|
65
|
-
var _a;
|
|
66
|
+
var _a, _b, _c;
|
|
66
67
|
const id = (0, instanceId_1.generate)();
|
|
67
68
|
const node = new VNode_1.default({
|
|
68
69
|
id,
|
|
69
|
-
type: (_a = DOM_TAG_MAP[type]) !== null &&
|
|
70
|
+
type: (_c = (_b = (_a = framework_shared_1.RuntimeOptions.get('tagMap')) === null || _a === void 0 ? void 0 : _a[type]) !== null && _b !== void 0 ? _b : DOM_TAG_MAP[type]) !== null && _c !== void 0 ? _c : type,
|
|
70
71
|
props: {},
|
|
71
72
|
container,
|
|
72
73
|
});
|
package/cjs/instanceId.js
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.reset = reset;
|
|
4
|
+
exports.generate = generate;
|
|
4
5
|
let instanceId = 0;
|
|
5
6
|
function reset() {
|
|
6
7
|
instanceId = 0;
|
|
7
8
|
}
|
|
8
|
-
exports.reset = reset;
|
|
9
9
|
function generate() {
|
|
10
10
|
const id = instanceId;
|
|
11
11
|
instanceId += 1;
|
|
12
12
|
return id;
|
|
13
13
|
}
|
|
14
|
-
exports.generate = generate;
|
package/cjs/propsAlias.js
CHANGED
|
@@ -3,7 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
6
|
+
exports.getAlias = getAlias;
|
|
7
|
+
exports.propAlias = propAlias;
|
|
8
|
+
exports.default = propsAlias;
|
|
7
9
|
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
8
10
|
const plainStyle_1 = __importDefault(require("./utils/plainStyle"));
|
|
9
11
|
function getAlias(prop, type) {
|
|
@@ -16,7 +18,6 @@ function getAlias(prop, type) {
|
|
|
16
18
|
}
|
|
17
19
|
return (_b = (_a = hostComponent === null || hostComponent === void 0 ? void 0 : hostComponent.alias) === null || _a === void 0 ? void 0 : _a[prop]) !== null && _b !== void 0 ? _b : prop;
|
|
18
20
|
}
|
|
19
|
-
exports.getAlias = getAlias;
|
|
20
21
|
function getValue(prop, value) {
|
|
21
22
|
if (prop.toLowerCase().endsWith('style') && Object.prototype.toString.call(value) === '[object Object]') {
|
|
22
23
|
return (0, plainStyle_1.default)(value);
|
|
@@ -26,7 +27,6 @@ function getValue(prop, value) {
|
|
|
26
27
|
function propAlias(prop, value, type) {
|
|
27
28
|
return [getAlias(prop, type), getValue(prop, value)];
|
|
28
29
|
}
|
|
29
|
-
exports.propAlias = propAlias;
|
|
30
30
|
function propsAlias(props, type) {
|
|
31
31
|
if (!props) {
|
|
32
32
|
return props;
|
|
@@ -48,4 +48,3 @@ function propsAlias(props, type) {
|
|
|
48
48
|
}
|
|
49
49
|
return aliasProps;
|
|
50
50
|
}
|
|
51
|
-
exports.default = propsAlias;
|
package/cjs/render.js
CHANGED
|
@@ -4,6 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.ReactReconcilerInst = void 0;
|
|
7
|
+
exports.default = render;
|
|
8
|
+
const framework_shared_1 = require("@rsmax/framework-shared");
|
|
7
9
|
const react_reconciler_1 = __importDefault(require("react-reconciler"));
|
|
8
10
|
const hostConfig_1 = __importDefault(require("./hostConfig"));
|
|
9
11
|
exports.ReactReconcilerInst = (0, react_reconciler_1.default)(hostConfig_1.default);
|
|
@@ -11,7 +13,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
11
13
|
exports.ReactReconcilerInst.injectIntoDevTools({
|
|
12
14
|
bundleType: 1,
|
|
13
15
|
version: '18.3.0',
|
|
14
|
-
rendererPackageName: '
|
|
16
|
+
rendererPackageName: 'rsmax',
|
|
15
17
|
});
|
|
16
18
|
}
|
|
17
19
|
function getPublicRootInstance(container) {
|
|
@@ -22,14 +24,11 @@ function getPublicRootInstance(container) {
|
|
|
22
24
|
return containerFiber.child.stateNode;
|
|
23
25
|
}
|
|
24
26
|
function render(rootElement, container) {
|
|
25
|
-
// Create a root Container if it doesnt exist
|
|
26
27
|
if (!container._rootContainer) {
|
|
27
|
-
|
|
28
|
-
container._rootContainer = exports.ReactReconcilerInst.createContainer(container, 0, null, false, null, '', () => { }, null);
|
|
28
|
+
container._rootContainer = exports.ReactReconcilerInst.createContainer(container, framework_shared_1.RuntimeOptions.get('concurrent') ? 1 : 0, null, false, null, '', () => { }, null);
|
|
29
29
|
}
|
|
30
30
|
exports.ReactReconcilerInst.updateContainer(rootElement, container._rootContainer, null, () => {
|
|
31
31
|
// ignore
|
|
32
32
|
});
|
|
33
33
|
return getPublicRootInstance(container._rootContainer);
|
|
34
34
|
}
|
|
35
|
-
exports.default = render;
|
package/cjs/utils/capitalize.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = isClassComponent;
|
|
3
4
|
function isClassComponent(Component) {
|
|
4
5
|
return Component.prototype && typeof Component.prototype.render === 'function';
|
|
5
6
|
}
|
|
6
|
-
exports.default = isClassComponent;
|
package/cjs/utils/lowercase.js
CHANGED
|
@@ -13,7 +13,7 @@ const transformReactStyleKey = (key) => {
|
|
|
13
13
|
if (styleValue === null || styleValue === void 0 ? void 0 : styleValue.startsWith('-')) {
|
|
14
14
|
const firstWord = styleValue.split('-').filter(s => s)[0];
|
|
15
15
|
styleValue = styleValue.replace(/^-/, '');
|
|
16
|
-
if (
|
|
16
|
+
if (vendorPrefixes.includes(firstWord)) {
|
|
17
17
|
styleValue = `-${styleValue}`;
|
|
18
18
|
}
|
|
19
19
|
}
|
|
@@ -30,14 +30,16 @@ const transformPx = (value) => {
|
|
|
30
30
|
});
|
|
31
31
|
};
|
|
32
32
|
const plainStyle = (style) => {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
const acc = [];
|
|
34
|
+
const keys = Object.keys(style);
|
|
35
|
+
for (let i = 0; i < keys.length; i++) {
|
|
36
|
+
const key = keys[i];
|
|
35
37
|
let value = style[key];
|
|
36
38
|
if (!Number.isNaN(Number(value)) && !CSSProperty_1.isUnitlessNumber[key] && !(key === null || key === void 0 ? void 0 : key.startsWith('--'))) {
|
|
37
39
|
value = `${value}rpx`;
|
|
38
40
|
}
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
41
|
+
acc.push(`${transformReactStyleKey(key)}:${framework_shared_1.RuntimeOptions.get('pxToRpx') ? transformPx(value) : value};`);
|
|
42
|
+
}
|
|
43
|
+
return acc.join('');
|
|
42
44
|
};
|
|
43
45
|
exports.default = plainStyle;
|
package/esm/Container.js
CHANGED
|
@@ -35,32 +35,70 @@ export default class Container {
|
|
|
35
35
|
$batchedUpdates = this.context.$batchedUpdates;
|
|
36
36
|
}
|
|
37
37
|
$batchedUpdates(() => {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
if (RuntimeOptions.get('mergeSpliceData')) {
|
|
39
|
+
const splicePayload = {};
|
|
40
|
+
const setPayload = {};
|
|
41
|
+
this.updateQueue.forEach(update => {
|
|
42
|
+
if (update.type === 'splice') {
|
|
43
|
+
splicePayload[this.normalizeUpdatePath([...update.path, 'children'])] = [
|
|
44
|
+
update.start,
|
|
45
|
+
update.deleteCount,
|
|
46
|
+
...update.items,
|
|
47
|
+
];
|
|
48
|
+
}
|
|
49
|
+
else if (update.type === 'set') {
|
|
50
|
+
setPayload[this.normalizeUpdatePath([...update.path, update.name])] = update.value;
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
const hasSplice = Object.keys(splicePayload).length > 0;
|
|
54
|
+
const hasSet = Object.keys(setPayload).length > 0;
|
|
55
|
+
const total = (hasSplice ? 1 : 0) + (hasSet ? 1 : 0);
|
|
56
|
+
let done = 0;
|
|
57
|
+
const doneCallback = () => {
|
|
58
|
+
done += 1;
|
|
59
|
+
if (done === total) {
|
|
42
60
|
nativeEffector.run();
|
|
43
61
|
/* istanbul ignore next */
|
|
44
62
|
if (RuntimeOptions.get('debug')) {
|
|
45
63
|
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`);
|
|
46
64
|
}
|
|
47
|
-
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
if (hasSplice) {
|
|
68
|
+
this.context.$spliceData(splicePayload, doneCallback);
|
|
48
69
|
}
|
|
49
|
-
if (
|
|
50
|
-
this.context
|
|
51
|
-
[this.normalizeUpdatePath([...update.path, 'children'])]: [
|
|
52
|
-
update.start,
|
|
53
|
-
update.deleteCount,
|
|
54
|
-
...update.items,
|
|
55
|
-
],
|
|
56
|
-
}, callback);
|
|
57
|
-
}
|
|
58
|
-
if (update.type === 'set') {
|
|
59
|
-
this.context.setData({
|
|
60
|
-
[this.normalizeUpdatePath([...update.path, update.name])]: update.value,
|
|
61
|
-
}, callback);
|
|
70
|
+
if (hasSet) {
|
|
71
|
+
this.context.setData(setPayload, doneCallback);
|
|
62
72
|
}
|
|
63
|
-
}
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
this.updateQueue.map((update, index) => {
|
|
76
|
+
let callback = undefined;
|
|
77
|
+
if (index + 1 === this.updateQueue.length) {
|
|
78
|
+
callback = () => {
|
|
79
|
+
nativeEffector.run();
|
|
80
|
+
/* istanbul ignore next */
|
|
81
|
+
if (RuntimeOptions.get('debug')) {
|
|
82
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`);
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
if (update.type === 'splice') {
|
|
87
|
+
this.context.$spliceData({
|
|
88
|
+
[this.normalizeUpdatePath([...update.path, 'children'])]: [
|
|
89
|
+
update.start,
|
|
90
|
+
update.deleteCount,
|
|
91
|
+
...update.items,
|
|
92
|
+
],
|
|
93
|
+
}, callback);
|
|
94
|
+
}
|
|
95
|
+
if (update.type === 'set') {
|
|
96
|
+
this.context.setData({
|
|
97
|
+
[this.normalizeUpdatePath([...update.path, update.name])]: update.value,
|
|
98
|
+
}, callback);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
64
102
|
});
|
|
65
103
|
this.updateQueue = [];
|
|
66
104
|
return;
|
|
@@ -80,13 +118,33 @@ export default class Container {
|
|
|
80
118
|
}
|
|
81
119
|
return acc;
|
|
82
120
|
}, {});
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
121
|
+
const chunkSize = RuntimeOptions.get('setDataChunkSize');
|
|
122
|
+
const entries = Object.entries(updatePayload);
|
|
123
|
+
if (chunkSize && chunkSize > 0 && entries.length > chunkSize) {
|
|
124
|
+
for (let i = 0; i < entries.length; i += chunkSize) {
|
|
125
|
+
const slice = entries.slice(i, i + chunkSize);
|
|
126
|
+
const payloadChunk = Object.fromEntries(slice);
|
|
127
|
+
const isLast = i + chunkSize >= entries.length;
|
|
128
|
+
this.context.setData(payloadChunk, () => {
|
|
129
|
+
if (isLast) {
|
|
130
|
+
nativeEffector.run();
|
|
131
|
+
/* istanbul ignore next */
|
|
132
|
+
if (RuntimeOptions.get('debug')) {
|
|
133
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`, payloadChunk);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
88
137
|
}
|
|
89
|
-
}
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
this.context.setData(updatePayload, () => {
|
|
141
|
+
nativeEffector.run();
|
|
142
|
+
/* istanbul ignore next */
|
|
143
|
+
if (RuntimeOptions.get('debug')) {
|
|
144
|
+
console.log(`setData => 回调时间:${new Date().getTime() - startTime}ms`, updatePayload);
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
90
148
|
this.updateQueue = [];
|
|
91
149
|
}
|
|
92
150
|
clearUpdate() {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { find } from '@rsmax/framework-shared';
|
|
2
1
|
import { DEPRECATED_CATCH_TYPE, SYNTHETIC_TYPES } from './constants';
|
|
3
2
|
import stopPropagation, { validate as validatePropagation, isPropagationStopped } from './stopPropagation';
|
|
4
3
|
function isSyntheticType(inputType) {
|
|
5
4
|
if (DEPRECATED_CATCH_TYPE === inputType) {
|
|
6
|
-
console.warn('DEPRECATION:
|
|
5
|
+
console.warn('DEPRECATION: rsmax 已支持在 onClick 事件中使用 stopPropagation 阻止事件冒泡,请尽量不要使用 catchClick');
|
|
7
6
|
}
|
|
8
|
-
return
|
|
7
|
+
return SYNTHETIC_TYPES.includes(inputType);
|
|
9
8
|
}
|
|
10
9
|
function createBaseSyntheticEvent(node, eventType, nativeEvent) {
|
|
11
10
|
if (!nativeEvent) {
|
package/esm/VNode.js
CHANGED
|
@@ -224,21 +224,19 @@ export default class VNode {
|
|
|
224
224
|
// while 循环已经保证了不会有空值
|
|
225
225
|
const stackItem = stack.pop();
|
|
226
226
|
const { children = [], currentNode } = stackItem;
|
|
227
|
-
for (let i =
|
|
227
|
+
for (let i = 0; i < children.length; i++) {
|
|
228
228
|
const currentVNode = children[i];
|
|
229
229
|
const currentRawNode = toRawNode(currentVNode);
|
|
230
|
-
if (RuntimeOptions.get('platform') !== 'ali') {
|
|
231
|
-
currentNode.children.unshift(currentRawNode.id);
|
|
232
|
-
}
|
|
233
|
-
else {
|
|
234
|
-
currentNode.children.unshift(currentRawNode);
|
|
235
|
-
}
|
|
236
230
|
if (RuntimeOptions.get('platform') !== 'ali') {
|
|
237
231
|
if (!currentNode.nodes) {
|
|
238
232
|
currentNode.nodes = {};
|
|
239
233
|
}
|
|
234
|
+
currentNode.children.push(currentRawNode.id);
|
|
240
235
|
currentNode.nodes[currentRawNode.id] = currentRawNode;
|
|
241
236
|
}
|
|
237
|
+
else {
|
|
238
|
+
currentNode.children.push(currentRawNode);
|
|
239
|
+
}
|
|
242
240
|
stack.push({
|
|
243
241
|
currentNode: currentRawNode,
|
|
244
242
|
children: currentVNode.children,
|
|
@@ -13,6 +13,13 @@ export default function createComponentConfig(Component) {
|
|
|
13
13
|
children: [],
|
|
14
14
|
},
|
|
15
15
|
},
|
|
16
|
+
observers: {
|
|
17
|
+
'**'(nextProps) {
|
|
18
|
+
if (this.container && this.properties !== nextProps) {
|
|
19
|
+
this.render();
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
},
|
|
16
23
|
attached: function () {
|
|
17
24
|
// 在组件实例进入页面节点树时执行
|
|
18
25
|
if (!this.container) {
|
|
@@ -24,22 +31,6 @@ export default function createComponentConfig(Component) {
|
|
|
24
31
|
this.container.clearUpdate();
|
|
25
32
|
render(null, this.container);
|
|
26
33
|
},
|
|
27
|
-
/*
|
|
28
|
-
TODO: 当前微信无对应语法支持监听props
|
|
29
|
-
且必须显示设定 properties,才能在组件中使用 this.properties.name
|
|
30
|
-
所以当前的实现不支持在微信端 props
|
|
31
|
-
eg:
|
|
32
|
-
properties: {
|
|
33
|
-
name: String
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
didUpdate(prevProps: any, prevData: any) {
|
|
37
|
-
if (prevData !== this.data) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
this.render();
|
|
42
|
-
},*/
|
|
43
34
|
methods: {
|
|
44
35
|
init() {
|
|
45
36
|
this.component = RuntimeOptions.get('pluginDriver').onMiniComponent({
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import { useLayoutEffect } from 'react';
|
|
1
|
+
import { useEffect, useLayoutEffect } from 'react';
|
|
2
2
|
import nativeEffect from '../nativeEffect';
|
|
3
|
+
// 创建服务端安全的effect hook
|
|
4
|
+
const useIsomorphicLayoutEffect = typeof window !== 'undefined' ? useLayoutEffect : useEffect;
|
|
3
5
|
export default function useNativeEffect(listener, deps) {
|
|
4
|
-
|
|
6
|
+
useIsomorphicLayoutEffect(() => {
|
|
5
7
|
return nativeEffect.connect(listener, !!deps);
|
|
6
8
|
}, deps);
|
|
7
9
|
}
|
|
@@ -4,7 +4,7 @@ declare const _default: {
|
|
|
4
4
|
now: any;
|
|
5
5
|
getPublicInstance: <T>(inst: T) => T;
|
|
6
6
|
getRootHostContext: () => {};
|
|
7
|
-
shouldSetTextContent(type: string):
|
|
7
|
+
shouldSetTextContent(type: string): type is "stub-block";
|
|
8
8
|
prepareForCommit: () => null;
|
|
9
9
|
preparePortalMount: () => void;
|
|
10
10
|
clearContainer: () => void;
|
package/esm/hostConfig/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RuntimeOptions } from '@rsmax/framework-shared';
|
|
1
2
|
import scheduler from 'scheduler';
|
|
2
3
|
import VNode from '../VNode';
|
|
3
4
|
import { TYPE_TEXT } from '../constants';
|
|
@@ -57,11 +58,11 @@ export default {
|
|
|
57
58
|
return childHostContext;
|
|
58
59
|
},
|
|
59
60
|
createInstance(type, newProps, container) {
|
|
60
|
-
var _a;
|
|
61
|
+
var _a, _b, _c;
|
|
61
62
|
const id = generate();
|
|
62
63
|
const node = new VNode({
|
|
63
64
|
id,
|
|
64
|
-
type: (_a = DOM_TAG_MAP[type]) !== null &&
|
|
65
|
+
type: (_c = (_b = (_a = RuntimeOptions.get('tagMap')) === null || _a === void 0 ? void 0 : _a[type]) !== null && _b !== void 0 ? _b : DOM_TAG_MAP[type]) !== null && _c !== void 0 ? _c : type,
|
|
65
66
|
props: {},
|
|
66
67
|
container,
|
|
67
68
|
});
|
package/esm/render.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RuntimeOptions } from '@rsmax/framework-shared';
|
|
1
2
|
import ReactReconciler from 'react-reconciler';
|
|
2
3
|
import hostConfig from './hostConfig';
|
|
3
4
|
export const ReactReconcilerInst = ReactReconciler(hostConfig);
|
|
@@ -5,7 +6,7 @@ if (process.env.NODE_ENV === 'development') {
|
|
|
5
6
|
ReactReconcilerInst.injectIntoDevTools({
|
|
6
7
|
bundleType: 1,
|
|
7
8
|
version: '18.3.0',
|
|
8
|
-
rendererPackageName: '
|
|
9
|
+
rendererPackageName: 'rsmax',
|
|
9
10
|
});
|
|
10
11
|
}
|
|
11
12
|
function getPublicRootInstance(container) {
|
|
@@ -16,10 +17,8 @@ function getPublicRootInstance(container) {
|
|
|
16
17
|
return containerFiber.child.stateNode;
|
|
17
18
|
}
|
|
18
19
|
export default function render(rootElement, container) {
|
|
19
|
-
// Create a root Container if it doesnt exist
|
|
20
20
|
if (!container._rootContainer) {
|
|
21
|
-
|
|
22
|
-
container._rootContainer = ReactReconcilerInst.createContainer(container, 0, null, false, null, '', () => { }, null);
|
|
21
|
+
container._rootContainer = ReactReconcilerInst.createContainer(container, RuntimeOptions.get('concurrent') ? 1 : 0, null, false, null, '', () => { }, null);
|
|
23
22
|
}
|
|
24
23
|
ReactReconcilerInst.updateContainer(rootElement, container._rootContainer, null, () => {
|
|
25
24
|
// ignore
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RuntimeOptions
|
|
1
|
+
import { RuntimeOptions } from '@rsmax/framework-shared';
|
|
2
2
|
import { isUnitlessNumber } from './CSSProperty';
|
|
3
3
|
const vendorPrefixes = ['webkit', 'moz', 'ms', 'o'];
|
|
4
4
|
const transformReactStyleKey = (key) => {
|
|
@@ -11,7 +11,7 @@ const transformReactStyleKey = (key) => {
|
|
|
11
11
|
if (styleValue === null || styleValue === void 0 ? void 0 : styleValue.startsWith('-')) {
|
|
12
12
|
const firstWord = styleValue.split('-').filter(s => s)[0];
|
|
13
13
|
styleValue = styleValue.replace(/^-/, '');
|
|
14
|
-
if (
|
|
14
|
+
if (vendorPrefixes.includes(firstWord)) {
|
|
15
15
|
styleValue = `-${styleValue}`;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -28,14 +28,16 @@ const transformPx = (value) => {
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
const plainStyle = (style) => {
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
const acc = [];
|
|
32
|
+
const keys = Object.keys(style);
|
|
33
|
+
for (let i = 0; i < keys.length; i++) {
|
|
34
|
+
const key = keys[i];
|
|
33
35
|
let value = style[key];
|
|
34
36
|
if (!Number.isNaN(Number(value)) && !isUnitlessNumber[key] && !(key === null || key === void 0 ? void 0 : key.startsWith('--'))) {
|
|
35
37
|
value = `${value}rpx`;
|
|
36
38
|
}
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
39
|
+
acc.push(`${transformReactStyleKey(key)}:${RuntimeOptions.get('pxToRpx') ? transformPx(value) : value};`);
|
|
40
|
+
}
|
|
41
|
+
return acc.join('');
|
|
40
42
|
};
|
|
41
43
|
export default plainStyle;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsmax/runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-canary.91+5982cbe",
|
|
4
4
|
"description": "Rsmax 是一个全新的基于 React 的小程序开发框架",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -28,16 +28,16 @@
|
|
|
28
28
|
"test": "rstest run"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@rsmax/framework-shared": "
|
|
32
|
-
"@rsmax/shared": "
|
|
33
|
-
"@rsmax/web": "
|
|
31
|
+
"@rsmax/framework-shared": "2.0.0-canary.91+5982cbe",
|
|
32
|
+
"@rsmax/shared": "2.0.0-canary.91+5982cbe",
|
|
33
|
+
"@rsmax/web": "2.0.0-canary.91+5982cbe",
|
|
34
34
|
"qs": "^6.9.3",
|
|
35
35
|
"react-is": "^18.3.0",
|
|
36
36
|
"react-reconciler": "0.29.0",
|
|
37
37
|
"scheduler": "0.23.2"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
|
-
"@rsmax/types": "
|
|
40
|
+
"@rsmax/types": "2.0.0-canary.91+5982cbe",
|
|
41
41
|
"@types/lodash.merge": "^4.6.6",
|
|
42
42
|
"@types/node": "^18",
|
|
43
43
|
"@types/qs": "^6.9.3",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
54
|
"esnext": "./esm/index.js",
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "5982cbe3e1e3a3bf52fa41d0c31bfb043277f669"
|
|
56
56
|
}
|