@cuipengyu5/build-plugin-lowcode 0.0.1 → 0.0.2
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/README.md +47 -0
- package/package.json +2 -2
- package/src/compile/babel.js +198 -0
- package/src/compile/meta.js +87 -0
- package/src/config/user-config.js +71 -0
- package/src/constants.js +135 -0
- package/src/public/designer.html +302 -0
- package/src/public/index.html +308 -0
- package/src/public/preview.html +38 -0
- package/src/templates/assets.json +31 -0
- package/src/templates/component-meta.js +11 -0
- package/src/templates/index.jsx +273 -0
- package/src/templates/meta.js +168 -0
- package/src/templates/preview.jsx +93 -0
- package/src/templates/view.js +24 -0
- package/src/utils/getDemoDir.js +16 -0
- package/src/utils/index.js +252 -0
- package/src/utils/npm.js +41 -0
- package/src/utils/parse-props.js +261 -0
- package/demo/antd-setter-map/src/index.tsx +0 -5
- package/demo/component/src/index.tsx +0 -6
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
7
|
+
<title>DEMO 预览</title>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial,
|
|
11
|
+
PingFang SC-Light, Microsoft YaHei;
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body,
|
|
20
|
+
#lce-container {
|
|
21
|
+
position: fixed;
|
|
22
|
+
left: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
top: 0;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
padding: 0;
|
|
28
|
+
margin: 0;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
text-rendering: optimizeLegibility;
|
|
31
|
+
-webkit-user-select: none;
|
|
32
|
+
-webkit-user-drag: none;
|
|
33
|
+
-webkit-text-size-adjust: none;
|
|
34
|
+
-webkit-touch-callout: none;
|
|
35
|
+
-webkit-font-smoothing: antialiased;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
html {
|
|
39
|
+
min-width: 1024px;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
|
|
44
|
+
<body>
|
|
45
|
+
<link rel="stylesheet" href="<%= engineCoreCssUrl %>" />
|
|
46
|
+
<link rel="stylesheet" href="<%= engineExtCssUrl %>" />
|
|
47
|
+
<link rel="stylesheet" href="<%= enginePresetCssUrl %>" />
|
|
48
|
+
<link href="<%= themeVariableUrl %>" rel="stylesheet" />
|
|
49
|
+
<link href="<%= themeStyleUrl %>" rel="stylesheet" />
|
|
50
|
+
<div id="lce-container"></div>
|
|
51
|
+
<script src="https://g.alicdn.com/code/lib/rax/1.1.0/rax.umd.min.js"></script>
|
|
52
|
+
<script src="https://g.alicdn.com/code/lib/react/16.9.0/umd/react.development.js"></script>
|
|
53
|
+
<script src="https://g.alicdn.com/code/lib/react-dom/16.9.0/umd/react-dom.development.js"></script>
|
|
54
|
+
<script src="https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js"></script>
|
|
55
|
+
<script>
|
|
56
|
+
React.PropTypes = PropTypes;
|
|
57
|
+
</script>
|
|
58
|
+
<script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script>
|
|
59
|
+
<script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script>
|
|
60
|
+
<script src="https://g.alicdn.com/code/lib/alifd__next/1.23.20/next-with-locales.min.js"></script>
|
|
61
|
+
<script crossorigin="anonymous" src="<%= engineCoreJsUrl %>"></script>
|
|
62
|
+
<script crossorigin="anonymous" src="<%= engineExtJsUrl %>"></script>
|
|
63
|
+
<script>
|
|
64
|
+
if (!window.AliLowCodeEngine.common) {
|
|
65
|
+
window.AliLowCodeEngine.common = {
|
|
66
|
+
designerCabin: window.AliLowCodeEngine.designerCabin,
|
|
67
|
+
editorCabin: window.AliLowCodeEngine.editorCabin,
|
|
68
|
+
skeletonCabin: window.AliLowCodeEngine.skeletonCabin,
|
|
69
|
+
utils: window.AliLowCodeEngine.utils,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
</script>
|
|
73
|
+
<script src="<%= enginePresetJsUrl %>"></script>
|
|
74
|
+
<script type="text/javascript" charset="utf-8" src="./index.js"></script>
|
|
75
|
+
<script>
|
|
76
|
+
(function (factory) {
|
|
77
|
+
if (typeof define === 'function' && define.amd) {
|
|
78
|
+
define([], factory);
|
|
79
|
+
} else if (typeof module === 'object' && module.exports) {
|
|
80
|
+
module.exports = factory();
|
|
81
|
+
} else {
|
|
82
|
+
window.idleCallbackShim = factory();
|
|
83
|
+
}
|
|
84
|
+
})(function () {
|
|
85
|
+
'use strict';
|
|
86
|
+
var scheduleStart, throttleDelay, lazytimer, lazyraf;
|
|
87
|
+
var root =
|
|
88
|
+
typeof window != 'undefined' ? window : typeof global != undefined ? global : this || {};
|
|
89
|
+
var requestAnimationFrame =
|
|
90
|
+
(root.cancelRequestAnimationFrame && root.requestAnimationFrame) || setTimeout;
|
|
91
|
+
var cancelRequestAnimationFrame = root.cancelRequestAnimationFrame || clearTimeout;
|
|
92
|
+
var tasks = [];
|
|
93
|
+
var runAttempts = 0;
|
|
94
|
+
var isRunning = false;
|
|
95
|
+
var remainingTime = 7;
|
|
96
|
+
var minThrottle = 35;
|
|
97
|
+
var throttle = 125;
|
|
98
|
+
var index = 0;
|
|
99
|
+
var taskStart = 0;
|
|
100
|
+
var tasklength = 0;
|
|
101
|
+
var IdleDeadline = {
|
|
102
|
+
get didTimeout() {
|
|
103
|
+
return false;
|
|
104
|
+
},
|
|
105
|
+
timeRemaining: function () {
|
|
106
|
+
var timeRemaining = remainingTime - (Date.now() - taskStart);
|
|
107
|
+
return Math.max(0, timeRemaining);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
var setInactive = debounce(function () {
|
|
111
|
+
remainingTime = 22;
|
|
112
|
+
throttle = 66;
|
|
113
|
+
minThrottle = 0;
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
function debounce(fn) {
|
|
117
|
+
var id, timestamp;
|
|
118
|
+
var wait = 99;
|
|
119
|
+
var check = function () {
|
|
120
|
+
var last = Date.now() - timestamp;
|
|
121
|
+
|
|
122
|
+
if (last < wait) {
|
|
123
|
+
id = setTimeout(check, wait - last);
|
|
124
|
+
} else {
|
|
125
|
+
id = null;
|
|
126
|
+
fn();
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return function () {
|
|
130
|
+
timestamp = Date.now();
|
|
131
|
+
if (!id) {
|
|
132
|
+
id = setTimeout(check, wait);
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function abortRunning() {
|
|
138
|
+
if (isRunning) {
|
|
139
|
+
if (lazyraf) {
|
|
140
|
+
cancelRequestAnimationFrame(lazyraf);
|
|
141
|
+
}
|
|
142
|
+
if (lazytimer) {
|
|
143
|
+
clearTimeout(lazytimer);
|
|
144
|
+
}
|
|
145
|
+
isRunning = false;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function onInputorMutation() {
|
|
150
|
+
if (throttle != 125) {
|
|
151
|
+
remainingTime = 7;
|
|
152
|
+
throttle = 125;
|
|
153
|
+
minThrottle = 35;
|
|
154
|
+
|
|
155
|
+
if (isRunning) {
|
|
156
|
+
abortRunning();
|
|
157
|
+
scheduleLazy();
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
setInactive();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
function scheduleAfterRaf() {
|
|
164
|
+
lazyraf = null;
|
|
165
|
+
lazytimer = setTimeout(runTasks, 0);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
function scheduleRaf() {
|
|
169
|
+
lazytimer = null;
|
|
170
|
+
requestAnimationFrame(scheduleAfterRaf);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function scheduleLazy() {
|
|
174
|
+
if (isRunning) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
throttleDelay = throttle - (Date.now() - taskStart);
|
|
178
|
+
|
|
179
|
+
scheduleStart = Date.now();
|
|
180
|
+
|
|
181
|
+
isRunning = true;
|
|
182
|
+
|
|
183
|
+
if (minThrottle && throttleDelay < minThrottle) {
|
|
184
|
+
throttleDelay = minThrottle;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
if (throttleDelay > 9) {
|
|
188
|
+
lazytimer = setTimeout(scheduleRaf, throttleDelay);
|
|
189
|
+
} else {
|
|
190
|
+
throttleDelay = 0;
|
|
191
|
+
scheduleRaf();
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function runTasks() {
|
|
196
|
+
var task, i, len;
|
|
197
|
+
var timeThreshold = remainingTime > 9 ? 9 : 1;
|
|
198
|
+
taskStart = Date.now();
|
|
199
|
+
isRunning = false;
|
|
200
|
+
|
|
201
|
+
lazytimer = null;
|
|
202
|
+
|
|
203
|
+
if (runAttempts > 2 || taskStart - throttleDelay - 50 < scheduleStart) {
|
|
204
|
+
for (
|
|
205
|
+
i = 0, len = tasks.length;
|
|
206
|
+
i < len && IdleDeadline.timeRemaining() > timeThreshold;
|
|
207
|
+
i++
|
|
208
|
+
) {
|
|
209
|
+
task = tasks.shift();
|
|
210
|
+
tasklength++;
|
|
211
|
+
if (task) {
|
|
212
|
+
task(IdleDeadline);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (tasks.length) {
|
|
218
|
+
scheduleLazy();
|
|
219
|
+
} else {
|
|
220
|
+
runAttempts = 0;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function requestIdleCallbackShim(task) {
|
|
225
|
+
index++;
|
|
226
|
+
tasks.push(task);
|
|
227
|
+
scheduleLazy();
|
|
228
|
+
return index;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
function cancelIdleCallbackShim(id) {
|
|
232
|
+
var index = id - 1 - tasklength;
|
|
233
|
+
if (tasks[index]) {
|
|
234
|
+
tasks[index] = null;
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
if (!root.requestIdleCallback || !root.cancelIdleCallback) {
|
|
239
|
+
root.requestIdleCallback = requestIdleCallbackShim;
|
|
240
|
+
root.cancelIdleCallback = cancelIdleCallbackShim;
|
|
241
|
+
|
|
242
|
+
if (root.document && document.addEventListener) {
|
|
243
|
+
root.addEventListener('scroll', onInputorMutation, true);
|
|
244
|
+
root.addEventListener('resize', onInputorMutation);
|
|
245
|
+
|
|
246
|
+
document.addEventListener('focus', onInputorMutation, true);
|
|
247
|
+
document.addEventListener('mouseover', onInputorMutation, true);
|
|
248
|
+
['click', 'keypress', 'touchstart', 'mousedown'].forEach(function (name) {
|
|
249
|
+
document.addEventListener(name, onInputorMutation, { capture: true, passive: true });
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
if (root.MutationObserver) {
|
|
253
|
+
new MutationObserver(onInputorMutation).observe(document.documentElement, {
|
|
254
|
+
childList: true,
|
|
255
|
+
subtree: true,
|
|
256
|
+
attributes: true,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
} else {
|
|
261
|
+
try {
|
|
262
|
+
root.requestIdleCallback(function () {}, { timeout: 0 });
|
|
263
|
+
} catch (e) {
|
|
264
|
+
(function (rIC) {
|
|
265
|
+
var timeRemainingProto, timeRemaining;
|
|
266
|
+
root.requestIdleCallback = function (fn, timeout) {
|
|
267
|
+
if (timeout && typeof timeout.timeout == 'number') {
|
|
268
|
+
return rIC(fn, timeout.timeout);
|
|
269
|
+
}
|
|
270
|
+
return rIC(fn);
|
|
271
|
+
};
|
|
272
|
+
if (
|
|
273
|
+
root.IdleCallbackDeadline &&
|
|
274
|
+
(timeRemainingProto = IdleCallbackDeadline.prototype)
|
|
275
|
+
) {
|
|
276
|
+
timeRemaining = Object.getOwnPropertyDescriptor(
|
|
277
|
+
timeRemainingProto,
|
|
278
|
+
'timeRemaining',
|
|
279
|
+
);
|
|
280
|
+
if (!timeRemaining || !timeRemaining.configurable || !timeRemaining.get) {
|
|
281
|
+
return;
|
|
282
|
+
}
|
|
283
|
+
Object.defineProperty(timeRemainingProto, 'timeRemaining', {
|
|
284
|
+
value: function () {
|
|
285
|
+
return timeRemaining.get.call(this);
|
|
286
|
+
},
|
|
287
|
+
enumerable: true,
|
|
288
|
+
configurable: true,
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
})(root.requestIdleCallback);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
return {
|
|
296
|
+
request: requestIdleCallbackShim,
|
|
297
|
+
cancel: cancelIdleCallbackShim,
|
|
298
|
+
};
|
|
299
|
+
});
|
|
300
|
+
</script>
|
|
301
|
+
</body>
|
|
302
|
+
</html>
|
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
|
|
7
|
+
<title>DEMO 预览</title>
|
|
8
|
+
<style>
|
|
9
|
+
body {
|
|
10
|
+
font-family: PingFangSC-Regular, Roboto, Helvetica Neue, Helvetica, Tahoma, Arial,
|
|
11
|
+
PingFang SC-Light, Microsoft YaHei;
|
|
12
|
+
font-size: 12px;
|
|
13
|
+
|
|
14
|
+
* {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
body,
|
|
20
|
+
#lce-container {
|
|
21
|
+
position: fixed;
|
|
22
|
+
left: 0;
|
|
23
|
+
right: 0;
|
|
24
|
+
bottom: 0;
|
|
25
|
+
top: 0;
|
|
26
|
+
box-sizing: border-box;
|
|
27
|
+
padding: 0;
|
|
28
|
+
margin: 0;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
text-rendering: optimizeLegibility;
|
|
31
|
+
-webkit-user-select: none;
|
|
32
|
+
-webkit-user-drag: none;
|
|
33
|
+
-webkit-text-size-adjust: none;
|
|
34
|
+
-webkit-touch-callout: none;
|
|
35
|
+
-webkit-font-smoothing: antialiased;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
html {
|
|
39
|
+
min-width: 1024px;
|
|
40
|
+
}
|
|
41
|
+
</style>
|
|
42
|
+
</head>
|
|
43
|
+
|
|
44
|
+
<body>
|
|
45
|
+
<link rel="stylesheet" href="<%= engineCoreCssUrl %>" />
|
|
46
|
+
<link rel="stylesheet" href="<%= engineExtCssUrl %>" />
|
|
47
|
+
<link rel="stylesheet" href="<%= enginePresetCssUrl %>" />
|
|
48
|
+
<link href="<%= themeVariableUrl %>" rel="stylesheet" />
|
|
49
|
+
<link href="<%= themeStyleUrl %>" rel="stylesheet" />
|
|
50
|
+
<% if (typeof antdCssUrl === 'string') { %>
|
|
51
|
+
<link href="<%= antdCssUrl %>" rel="stylesheet" />
|
|
52
|
+
<% } %>
|
|
53
|
+
<div id="lce-container"></div>
|
|
54
|
+
<script src="https://g.alicdn.com/code/lib/rax/1.1.0/rax.umd.min.js"></script>
|
|
55
|
+
<script src="https://g.alicdn.com/code/lib/react/16.9.0/umd/react.development.js"></script>
|
|
56
|
+
<script src="https://g.alicdn.com/code/lib/react-dom/16.9.0/umd/react-dom.development.js"></script>
|
|
57
|
+
<script src="https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js"></script>
|
|
58
|
+
<script>
|
|
59
|
+
React.PropTypes = PropTypes;
|
|
60
|
+
</script>
|
|
61
|
+
<script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script>
|
|
62
|
+
<script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script>
|
|
63
|
+
<script src="https://g.alicdn.com/code/lib/alifd__next/1.23.20/next-with-locales.min.js"></script>
|
|
64
|
+
<% if (typeof antdJsUrl === 'string') { %>
|
|
65
|
+
<script crossorigin="anonymous" src="<%= antdJsUrl %>"></script>
|
|
66
|
+
<% } %>
|
|
67
|
+
<script crossorigin="anonymous" src="<%= engineCoreJsUrl %>"></script>
|
|
68
|
+
<script crossorigin="anonymous" src="<%= engineExtJsUrl %>"></script>
|
|
69
|
+
<script>
|
|
70
|
+
if (!window.AliLowCodeEngine.common) {
|
|
71
|
+
window.AliLowCodeEngine.common = {
|
|
72
|
+
designerCabin: window.AliLowCodeEngine.designerCabin,
|
|
73
|
+
editorCabin: window.AliLowCodeEngine.editorCabin,
|
|
74
|
+
skeletonCabin: window.AliLowCodeEngine.skeletonCabin,
|
|
75
|
+
utils: window.AliLowCodeEngine.utils,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
</script>
|
|
79
|
+
<script src="<%= enginePresetJsUrl %>"></script>
|
|
80
|
+
<script type="text/javascript" charset="utf-8" src="./index.js"></script>
|
|
81
|
+
<script>
|
|
82
|
+
(function (factory) {
|
|
83
|
+
if (typeof define === 'function' && define.amd) {
|
|
84
|
+
define([], factory);
|
|
85
|
+
} else if (typeof module === 'object' && module.exports) {
|
|
86
|
+
module.exports = factory();
|
|
87
|
+
} else {
|
|
88
|
+
window.idleCallbackShim = factory();
|
|
89
|
+
}
|
|
90
|
+
})(function () {
|
|
91
|
+
'use strict';
|
|
92
|
+
var scheduleStart, throttleDelay, lazytimer, lazyraf;
|
|
93
|
+
var root =
|
|
94
|
+
typeof window != 'undefined' ? window : typeof global != undefined ? global : this || {};
|
|
95
|
+
var requestAnimationFrame =
|
|
96
|
+
(root.cancelRequestAnimationFrame && root.requestAnimationFrame) || setTimeout;
|
|
97
|
+
var cancelRequestAnimationFrame = root.cancelRequestAnimationFrame || clearTimeout;
|
|
98
|
+
var tasks = [];
|
|
99
|
+
var runAttempts = 0;
|
|
100
|
+
var isRunning = false;
|
|
101
|
+
var remainingTime = 7;
|
|
102
|
+
var minThrottle = 35;
|
|
103
|
+
var throttle = 125;
|
|
104
|
+
var index = 0;
|
|
105
|
+
var taskStart = 0;
|
|
106
|
+
var tasklength = 0;
|
|
107
|
+
var IdleDeadline = {
|
|
108
|
+
get didTimeout() {
|
|
109
|
+
return false;
|
|
110
|
+
},
|
|
111
|
+
timeRemaining: function () {
|
|
112
|
+
var timeRemaining = remainingTime - (Date.now() - taskStart);
|
|
113
|
+
return Math.max(0, timeRemaining);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
var setInactive = debounce(function () {
|
|
117
|
+
remainingTime = 22;
|
|
118
|
+
throttle = 66;
|
|
119
|
+
minThrottle = 0;
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
function debounce(fn) {
|
|
123
|
+
var id, timestamp;
|
|
124
|
+
var wait = 99;
|
|
125
|
+
var check = function () {
|
|
126
|
+
var last = Date.now() - timestamp;
|
|
127
|
+
|
|
128
|
+
if (last < wait) {
|
|
129
|
+
id = setTimeout(check, wait - last);
|
|
130
|
+
} else {
|
|
131
|
+
id = null;
|
|
132
|
+
fn();
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
return function () {
|
|
136
|
+
timestamp = Date.now();
|
|
137
|
+
if (!id) {
|
|
138
|
+
id = setTimeout(check, wait);
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function abortRunning() {
|
|
144
|
+
if (isRunning) {
|
|
145
|
+
if (lazyraf) {
|
|
146
|
+
cancelRequestAnimationFrame(lazyraf);
|
|
147
|
+
}
|
|
148
|
+
if (lazytimer) {
|
|
149
|
+
clearTimeout(lazytimer);
|
|
150
|
+
}
|
|
151
|
+
isRunning = false;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function onInputorMutation() {
|
|
156
|
+
if (throttle != 125) {
|
|
157
|
+
remainingTime = 7;
|
|
158
|
+
throttle = 125;
|
|
159
|
+
minThrottle = 35;
|
|
160
|
+
|
|
161
|
+
if (isRunning) {
|
|
162
|
+
abortRunning();
|
|
163
|
+
scheduleLazy();
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
setInactive();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
function scheduleAfterRaf() {
|
|
170
|
+
lazyraf = null;
|
|
171
|
+
lazytimer = setTimeout(runTasks, 0);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
function scheduleRaf() {
|
|
175
|
+
lazytimer = null;
|
|
176
|
+
requestAnimationFrame(scheduleAfterRaf);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function scheduleLazy() {
|
|
180
|
+
if (isRunning) {
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
throttleDelay = throttle - (Date.now() - taskStart);
|
|
184
|
+
|
|
185
|
+
scheduleStart = Date.now();
|
|
186
|
+
|
|
187
|
+
isRunning = true;
|
|
188
|
+
|
|
189
|
+
if (minThrottle && throttleDelay < minThrottle) {
|
|
190
|
+
throttleDelay = minThrottle;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
if (throttleDelay > 9) {
|
|
194
|
+
lazytimer = setTimeout(scheduleRaf, throttleDelay);
|
|
195
|
+
} else {
|
|
196
|
+
throttleDelay = 0;
|
|
197
|
+
scheduleRaf();
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function runTasks() {
|
|
202
|
+
var task, i, len;
|
|
203
|
+
var timeThreshold = remainingTime > 9 ? 9 : 1;
|
|
204
|
+
taskStart = Date.now();
|
|
205
|
+
isRunning = false;
|
|
206
|
+
|
|
207
|
+
lazytimer = null;
|
|
208
|
+
|
|
209
|
+
if (runAttempts > 2 || taskStart - throttleDelay - 50 < scheduleStart) {
|
|
210
|
+
for (
|
|
211
|
+
i = 0, len = tasks.length;
|
|
212
|
+
i < len && IdleDeadline.timeRemaining() > timeThreshold;
|
|
213
|
+
i++
|
|
214
|
+
) {
|
|
215
|
+
task = tasks.shift();
|
|
216
|
+
tasklength++;
|
|
217
|
+
if (task) {
|
|
218
|
+
task(IdleDeadline);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
if (tasks.length) {
|
|
224
|
+
scheduleLazy();
|
|
225
|
+
} else {
|
|
226
|
+
runAttempts = 0;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function requestIdleCallbackShim(task) {
|
|
231
|
+
index++;
|
|
232
|
+
tasks.push(task);
|
|
233
|
+
scheduleLazy();
|
|
234
|
+
return index;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function cancelIdleCallbackShim(id) {
|
|
238
|
+
var index = id - 1 - tasklength;
|
|
239
|
+
if (tasks[index]) {
|
|
240
|
+
tasks[index] = null;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
if (!root.requestIdleCallback || !root.cancelIdleCallback) {
|
|
245
|
+
root.requestIdleCallback = requestIdleCallbackShim;
|
|
246
|
+
root.cancelIdleCallback = cancelIdleCallbackShim;
|
|
247
|
+
|
|
248
|
+
if (root.document && document.addEventListener) {
|
|
249
|
+
root.addEventListener('scroll', onInputorMutation, true);
|
|
250
|
+
root.addEventListener('resize', onInputorMutation);
|
|
251
|
+
|
|
252
|
+
document.addEventListener('focus', onInputorMutation, true);
|
|
253
|
+
document.addEventListener('mouseover', onInputorMutation, true);
|
|
254
|
+
['click', 'keypress', 'touchstart', 'mousedown'].forEach(function (name) {
|
|
255
|
+
document.addEventListener(name, onInputorMutation, { capture: true, passive: true });
|
|
256
|
+
});
|
|
257
|
+
|
|
258
|
+
if (root.MutationObserver) {
|
|
259
|
+
new MutationObserver(onInputorMutation).observe(document.documentElement, {
|
|
260
|
+
childList: true,
|
|
261
|
+
subtree: true,
|
|
262
|
+
attributes: true,
|
|
263
|
+
});
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
} else {
|
|
267
|
+
try {
|
|
268
|
+
root.requestIdleCallback(function () {}, { timeout: 0 });
|
|
269
|
+
} catch (e) {
|
|
270
|
+
(function (rIC) {
|
|
271
|
+
var timeRemainingProto, timeRemaining;
|
|
272
|
+
root.requestIdleCallback = function (fn, timeout) {
|
|
273
|
+
if (timeout && typeof timeout.timeout == 'number') {
|
|
274
|
+
return rIC(fn, timeout.timeout);
|
|
275
|
+
}
|
|
276
|
+
return rIC(fn);
|
|
277
|
+
};
|
|
278
|
+
if (
|
|
279
|
+
root.IdleCallbackDeadline &&
|
|
280
|
+
(timeRemainingProto = IdleCallbackDeadline.prototype)
|
|
281
|
+
) {
|
|
282
|
+
timeRemaining = Object.getOwnPropertyDescriptor(
|
|
283
|
+
timeRemainingProto,
|
|
284
|
+
'timeRemaining',
|
|
285
|
+
);
|
|
286
|
+
if (!timeRemaining || !timeRemaining.configurable || !timeRemaining.get) {
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
289
|
+
Object.defineProperty(timeRemainingProto, 'timeRemaining', {
|
|
290
|
+
value: function () {
|
|
291
|
+
return timeRemaining.get.call(this);
|
|
292
|
+
},
|
|
293
|
+
enumerable: true,
|
|
294
|
+
configurable: true,
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
})(root.requestIdleCallback);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
return {
|
|
302
|
+
request: requestIdleCallbackShim,
|
|
303
|
+
cancel: cancelIdleCallbackShim,
|
|
304
|
+
};
|
|
305
|
+
});
|
|
306
|
+
</script>
|
|
307
|
+
</body>
|
|
308
|
+
</html>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<meta
|
|
6
|
+
name="viewport"
|
|
7
|
+
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
|
|
8
|
+
/>
|
|
9
|
+
<title>App 渲染器</title>
|
|
10
|
+
<link href="https://g.alicdn.com/code/lib/alifd__next/1.23.20/next.min.css" rel="stylesheet" />
|
|
11
|
+
<% if (isRax && typeof raxRenderCssUrl === 'string') { %>
|
|
12
|
+
<link href="<%= raxRenderCssUrl %>" rel="stylesheet" />
|
|
13
|
+
<% } %>
|
|
14
|
+
<link href="<%= previewCssUrl %>" rel="stylesheet" />
|
|
15
|
+
</head>
|
|
16
|
+
<body>
|
|
17
|
+
<div id="ice-container"></div>
|
|
18
|
+
<script>
|
|
19
|
+
window.g_config = {
|
|
20
|
+
locale: 'zh_CN',
|
|
21
|
+
};
|
|
22
|
+
</script>
|
|
23
|
+
<% if (isRax && typeof raxRenderJsUrl === 'string') { %>
|
|
24
|
+
<script src="https://g.alicdn.com/code/lib/rax/1.1.0/rax.umd.min.js"></script>
|
|
25
|
+
<script src="<%= raxRenderJsUrl %>"></script>
|
|
26
|
+
<% } %>
|
|
27
|
+
<script src="https://g.alicdn.com/code/lib/react/16.9.0/umd/react.development.js"></script>
|
|
28
|
+
<script src="https://g.alicdn.com/code/lib/react-dom/16.9.0/umd/react-dom.development.js"></script>
|
|
29
|
+
<script src="https://g.alicdn.com/code/lib/prop-types/15.7.2/prop-types.js"></script>
|
|
30
|
+
<script>
|
|
31
|
+
React.PropTypes = PropTypes;
|
|
32
|
+
</script>
|
|
33
|
+
<script src="https://g.alicdn.com/platform/c/??react15-polyfill/0.0.1/dist/index.js,lodash/4.6.1/lodash.min.js,immutable/3.7.6/dist/immutable.min.js,natty-storage/2.0.2/dist/natty-storage.min.js,natty-fetch/2.6.0/dist/natty-fetch.pc.min.js,tinymce/4.2.5/tinymce-full.js"></script>
|
|
34
|
+
<script src="https://g.alicdn.com/mylib/moment/2.24.0/min/moment.min.js"></script>
|
|
35
|
+
<script src="https://g.alicdn.com/code/lib/alifd__next/1.23.20/next-with-locales.min.js"></script>
|
|
36
|
+
<script type="text/javascript" src="./preview.js"></script>
|
|
37
|
+
</body>
|
|
38
|
+
</html>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"packages": [
|
|
3
|
+
{
|
|
4
|
+
"package": "{{{package}}}",
|
|
5
|
+
"version": "{{{version}}}",
|
|
6
|
+
"library": "{{{library}}}",
|
|
7
|
+
"urls": {{{urls}}},
|
|
8
|
+
"editUrls": {{{editUrls}}},
|
|
9
|
+
"advancedUrls": {{{advancedRenderUrls}}},
|
|
10
|
+
"advancedEditUrls": {{{advancedEditUrls}}}
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
"components": [
|
|
14
|
+
{
|
|
15
|
+
"exportName": "{{{metaExportName}}}",
|
|
16
|
+
"npm": {
|
|
17
|
+
"package": "{{{package}}}",
|
|
18
|
+
"version": "{{{version}}}"
|
|
19
|
+
},
|
|
20
|
+
"url": "{{{metaUrl}}}",
|
|
21
|
+
"urls": {{{metaUrls}}},
|
|
22
|
+
"advancedUrls": {{{advancedMetaUrls}}}
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"sort": {
|
|
26
|
+
"groupList": {{{groups}}},
|
|
27
|
+
"categoryList": {{{categories}}}
|
|
28
|
+
},
|
|
29
|
+
"groupList": {{{groups}}},
|
|
30
|
+
"ignoreComponents": {{{ignoreComponents}}}
|
|
31
|
+
}
|