@pixui-dev/pxw 0.1.16
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/bin/pxw.js +217 -0
- package/bin/wpbuild.js +10 -0
- package/config/default.conf +21 -0
- package/config/devops.js +358 -0
- package/config/h5es.js +10 -0
- package/config/index.html +181 -0
- package/config/pfbs.js +207 -0
- package/config/testhelp.js +0 -0
- package/config/util.js +140 -0
- package/config/webpack.js +291 -0
- package/lib/assets/border.png +0 -0
- package/lib/assets/check.html +62 -0
- package/lib/assets/pixui.png +0 -0
- package/lib/assets/preact.js +4354 -0
- package/lib/assets/preact.png +0 -0
- package/lib/check/main.less +63 -0
- package/lib/check/main.tsx +41 -0
- package/lib/check/tool.js +3 -0
- package/lib/check/util.tsx +110 -0
- package/lib/grpc-web/dist/ChunkParser.js +117 -0
- package/lib/grpc-web/dist/ChunkParser.js.map +1 -0
- package/lib/grpc-web/dist/Code.js +58 -0
- package/lib/grpc-web/dist/Code.js.map +1 -0
- package/lib/grpc-web/dist/client.js +299 -0
- package/lib/grpc-web/dist/client.js.map +1 -0
- package/lib/grpc-web/dist/debug.js +16 -0
- package/lib/grpc-web/dist/debug.js.map +1 -0
- package/lib/grpc-web/dist/detach.js +7 -0
- package/lib/grpc-web/dist/detach.js.map +1 -0
- package/lib/grpc-web/dist/index.js +29 -0
- package/lib/grpc-web/dist/index.js.map +1 -0
- package/lib/grpc-web/dist/invoke.js +32 -0
- package/lib/grpc-web/dist/invoke.js.map +1 -0
- package/lib/grpc-web/dist/message.js +3 -0
- package/lib/grpc-web/dist/message.js.map +1 -0
- package/lib/grpc-web/dist/metadata.js +5 -0
- package/lib/grpc-web/dist/metadata.js.map +1 -0
- package/lib/grpc-web/dist/service.js +3 -0
- package/lib/grpc-web/dist/service.js.map +1 -0
- package/lib/grpc-web/dist/transports/Transport.js +15 -0
- package/lib/grpc-web/dist/transports/Transport.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/fetch.js +117 -0
- package/lib/grpc-web/dist/transports/http/fetch.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/http.js +15 -0
- package/lib/grpc-web/dist/transports/http/http.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/xhr.js +136 -0
- package/lib/grpc-web/dist/transports/http/xhr.js.map +1 -0
- package/lib/grpc-web/dist/transports/http/xhrUtil.js +36 -0
- package/lib/grpc-web/dist/transports/http/xhrUtil.js.map +1 -0
- package/lib/grpc-web/dist/transports/websocket/websocket.js +95 -0
- package/lib/grpc-web/dist/transports/websocket/websocket.js.map +1 -0
- package/lib/grpc-web/dist/typings/ChunkParser.d.ts +17 -0
- package/lib/grpc-web/dist/typings/Code.d.ts +20 -0
- package/lib/grpc-web/dist/typings/client.d.ts +25 -0
- package/lib/grpc-web/dist/typings/debug.d.ts +1 -0
- package/lib/grpc-web/dist/typings/detach.d.ts +1 -0
- package/lib/grpc-web/dist/typings/index.d.ts +45 -0
- package/lib/grpc-web/dist/typings/invoke.d.ts +20 -0
- package/lib/grpc-web/dist/typings/message.d.ts +8 -0
- package/lib/grpc-web/dist/typings/metadata.d.ts +2 -0
- package/lib/grpc-web/dist/typings/service.d.ts +16 -0
- package/lib/grpc-web/dist/typings/transports/Transport.d.ts +22 -0
- package/lib/grpc-web/dist/typings/transports/http/fetch.d.ts +6 -0
- package/lib/grpc-web/dist/typings/transports/http/http.d.ts +5 -0
- package/lib/grpc-web/dist/typings/transports/http/xhr.d.ts +27 -0
- package/lib/grpc-web/dist/typings/transports/http/xhrUtil.d.ts +3 -0
- package/lib/grpc-web/dist/typings/transports/websocket/websocket.d.ts +2 -0
- package/lib/grpc-web/dist/typings/unary.d.ts +23 -0
- package/lib/grpc-web/dist/typings/util.d.ts +2 -0
- package/lib/grpc-web/dist/unary.js +44 -0
- package/lib/grpc-web/dist/unary.js.map +1 -0
- package/lib/grpc-web/dist/util.js +11 -0
- package/lib/grpc-web/dist/util.js.map +1 -0
- package/lib/grpcTransport/PixHttp2Transport.ts +107 -0
- package/lib/grpcTransport/PixLuaTransport.ts +82 -0
- package/lib/h5es-types/v1.9.2/h5es.d.ts +1698 -0
- package/lib/h5es-types/v3.5.0/h5es.d.ts +1788 -0
- package/lib/pi_component/tinyList/tinyList.js +483 -0
- package/lib/pi_component/tinyList/tinyList.tsx +517 -0
- package/lib/pika-svelte/compiler.js +29829 -0
- package/lib/pika-svelte/easing/index.js +158 -0
- package/lib/pika-svelte/index.js +72 -0
- package/lib/pika-svelte/internal/index.js +1926 -0
- package/lib/pika-svelte/motion/index.js +210 -0
- package/lib/pika-svelte/package.json +145 -0
- package/lib/pika-svelte/register.js +57 -0
- package/lib/pika-svelte/rollup.config.js +126 -0
- package/lib/pika-svelte/store/index.js +123 -0
- package/lib/pika-svelte/transition/index.js +185 -0
- package/lib/preact-router.js +395 -0
- package/lib/preact.js +4355 -0
- package/lib/preact.tq.js +4385 -0
- package/lib/react-window/src/FixedSizeGrid.js +172 -0
- package/lib/react-window/src/FixedSizeList.js +91 -0
- package/lib/react-window/src/VariableSizeGrid.js +329 -0
- package/lib/react-window/src/VariableSizeList.js +231 -0
- package/lib/react-window/src/__tests__/FixedSizeGrid.js +942 -0
- package/lib/react-window/src/__tests__/FixedSizeList.js +749 -0
- package/lib/react-window/src/__tests__/VariableSizeGrid.js +598 -0
- package/lib/react-window/src/__tests__/VariableSizeList.js +345 -0
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeGrid.js.snap +912 -0
- package/lib/react-window/src/__tests__/__snapshots__/FixedSizeList.js.snap +568 -0
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeGrid.js.snap +542 -0
- package/lib/react-window/src/__tests__/__snapshots__/VariableSizeList.js.snap +331 -0
- package/lib/react-window/src/__tests__/areEqual.js +28 -0
- package/lib/react-window/src/__tests__/shouldComponentUpdate.js +32 -0
- package/lib/react-window/src/areEqual.js +13 -0
- package/lib/react-window/src/createGridComponent.js +657 -0
- package/lib/react-window/src/createListComponent.js +574 -0
- package/lib/react-window/src/domHelpers.js +69 -0
- package/lib/react-window/src/index.js +9 -0
- package/lib/react-window/src/shallowDiffers.js +17 -0
- package/lib/react-window/src/shouldComponentUpdate.js +11 -0
- package/lib/react-window/src/test.js.flow +382 -0
- package/lib/react-window/src/timer.js +36 -0
- package/lib/svelte-tab/Tab.svelte +31 -0
- package/lib/svelte-tab/TabList.svelte +10 -0
- package/lib/svelte-tab/TabPanel.svelte +13 -0
- package/lib/svelte-tab/Tabs.svelte +68 -0
- package/lib/svelte-tab/tabs.js +4 -0
- package/lib/types/css.d.ts +7476 -0
- package/lib/types/dom.ts +17 -0
- package/lib/types/ext.d.ts +81 -0
- package/lib/types/internal.d.ts +94 -0
- package/lib/types/jsx.d.ts +309 -0
- package/lib/types/preact.d.ts +340 -0
- package/package.json +111 -0
- package/tsconfig.json +30 -0
|
@@ -0,0 +1,4354 @@
|
|
|
1
|
+
/******/ var __webpack_modules__ = {
|
|
2
|
+
/***/ './compat/src/Children.js':
|
|
3
|
+
/*!********************************!*\
|
|
4
|
+
!*** ./compat/src/Children.js ***!
|
|
5
|
+
\********************************/
|
|
6
|
+
/***/ (
|
|
7
|
+
__unused_webpack_module,
|
|
8
|
+
__webpack_exports__,
|
|
9
|
+
__webpack_require__
|
|
10
|
+
) => {
|
|
11
|
+
__webpack_require__.r(__webpack_exports__);
|
|
12
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
|
+
/* harmony export */ Children: () => /* binding */ Children,
|
|
14
|
+
/* harmony export */
|
|
15
|
+
});
|
|
16
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
17
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
18
|
+
|
|
19
|
+
var mapFn = function mapFn(children, fn) {
|
|
20
|
+
if (children == null) return null;
|
|
21
|
+
return (0, preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(
|
|
22
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(children).map(
|
|
23
|
+
fn
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// This API is completely unnecessary for Preact, so it's basically passthrough.
|
|
29
|
+
var Children = {
|
|
30
|
+
map: mapFn,
|
|
31
|
+
forEach: mapFn,
|
|
32
|
+
count: function count(children) {
|
|
33
|
+
return children
|
|
34
|
+
? (0, preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(children)
|
|
35
|
+
.length
|
|
36
|
+
: 0;
|
|
37
|
+
},
|
|
38
|
+
only: function only(children) {
|
|
39
|
+
var normalized = (0,
|
|
40
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(children);
|
|
41
|
+
if (normalized.length !== 1) throw 'Children.only';
|
|
42
|
+
return normalized[0];
|
|
43
|
+
},
|
|
44
|
+
toArray: preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/***/
|
|
48
|
+
},
|
|
49
|
+
|
|
50
|
+
/***/ './compat/src/PureComponent.js':
|
|
51
|
+
/*!*************************************!*\
|
|
52
|
+
!*** ./compat/src/PureComponent.js ***!
|
|
53
|
+
\*************************************/
|
|
54
|
+
/***/ (
|
|
55
|
+
__unused_webpack_module,
|
|
56
|
+
__webpack_exports__,
|
|
57
|
+
__webpack_require__
|
|
58
|
+
) => {
|
|
59
|
+
__webpack_require__.r(__webpack_exports__);
|
|
60
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
61
|
+
/* harmony export */ PureComponent: () => /* binding */ PureComponent,
|
|
62
|
+
/* harmony export */
|
|
63
|
+
});
|
|
64
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
65
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
66
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ =
|
|
67
|
+
__webpack_require__(/*! ./util */ './compat/src/util.js');
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Component class with a predefined `shouldComponentUpdate` implementation
|
|
71
|
+
*/
|
|
72
|
+
function PureComponent(p) {
|
|
73
|
+
this.props = p;
|
|
74
|
+
}
|
|
75
|
+
PureComponent.prototype =
|
|
76
|
+
new preact__WEBPACK_IMPORTED_MODULE_0__.Component();
|
|
77
|
+
// Some third-party libraries check if this property is present
|
|
78
|
+
PureComponent.prototype.isPureReactComponent = true;
|
|
79
|
+
PureComponent.prototype.shouldComponentUpdate = function (props, state) {
|
|
80
|
+
return (
|
|
81
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_1__.shallowDiffers)(
|
|
82
|
+
this.props,
|
|
83
|
+
props
|
|
84
|
+
) ||
|
|
85
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_1__.shallowDiffers)(
|
|
86
|
+
this.state,
|
|
87
|
+
state
|
|
88
|
+
)
|
|
89
|
+
);
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
/***/
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
/***/ './compat/src/forwardRef.js':
|
|
96
|
+
/*!**********************************!*\
|
|
97
|
+
!*** ./compat/src/forwardRef.js ***!
|
|
98
|
+
\**********************************/
|
|
99
|
+
/***/ (
|
|
100
|
+
__unused_webpack_module,
|
|
101
|
+
__webpack_exports__,
|
|
102
|
+
__webpack_require__
|
|
103
|
+
) => {
|
|
104
|
+
__webpack_require__.r(__webpack_exports__);
|
|
105
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
106
|
+
/* harmony export */ REACT_FORWARD_SYMBOL: () =>
|
|
107
|
+
/* binding */ REACT_FORWARD_SYMBOL,
|
|
108
|
+
/* harmony export */ forwardRef: () => /* binding */ forwardRef,
|
|
109
|
+
/* harmony export */
|
|
110
|
+
});
|
|
111
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
112
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
113
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ =
|
|
114
|
+
__webpack_require__(/*! ./util */ './compat/src/util.js');
|
|
115
|
+
|
|
116
|
+
var oldDiffHook = preact__WEBPACK_IMPORTED_MODULE_0__.options.__b;
|
|
117
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__b = function (vnode) {
|
|
118
|
+
if (vnode.type && vnode.type.__f && vnode.ref) {
|
|
119
|
+
vnode.props.ref = vnode.ref;
|
|
120
|
+
vnode.ref = null;
|
|
121
|
+
}
|
|
122
|
+
if (oldDiffHook) oldDiffHook(vnode);
|
|
123
|
+
};
|
|
124
|
+
var REACT_FORWARD_SYMBOL =
|
|
125
|
+
(typeof Symbol != 'undefined' &&
|
|
126
|
+
Symbol.for &&
|
|
127
|
+
Symbol.for('react.forward_ref')) ||
|
|
128
|
+
0xf47;
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Pass ref down to a child. This is mainly used in libraries with HOCs that
|
|
132
|
+
* wrap components. Using `forwardRef` there is an easy way to get a reference
|
|
133
|
+
* of the wrapped component instead of one of the wrapper itself.
|
|
134
|
+
* @param {import('./index').ForwardFn} fn
|
|
135
|
+
* @returns {import('./internal').FunctionComponent}
|
|
136
|
+
*/
|
|
137
|
+
function forwardRef(fn) {
|
|
138
|
+
function Forwarded(props) {
|
|
139
|
+
var clone = (0, _util__WEBPACK_IMPORTED_MODULE_1__.assign)({}, props);
|
|
140
|
+
delete clone.ref;
|
|
141
|
+
return fn(clone, props.ref || null);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// mobx-react checks for this being present
|
|
145
|
+
Forwarded.$$typeof = REACT_FORWARD_SYMBOL;
|
|
146
|
+
// mobx-react heavily relies on implementation details.
|
|
147
|
+
// It expects an object here with a `render` property,
|
|
148
|
+
// and prototype.render will fail. Without this
|
|
149
|
+
// mobx-react throws.
|
|
150
|
+
Forwarded.render = Forwarded;
|
|
151
|
+
Forwarded.prototype.isReactComponent = Forwarded.__f = true;
|
|
152
|
+
Forwarded.displayName =
|
|
153
|
+
'ForwardRef(' + (fn.displayName || fn.name) + ')';
|
|
154
|
+
return Forwarded;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/***/
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
/***/ './compat/src/memo.js':
|
|
161
|
+
/*!****************************!*\
|
|
162
|
+
!*** ./compat/src/memo.js ***!
|
|
163
|
+
\****************************/
|
|
164
|
+
/***/ (
|
|
165
|
+
__unused_webpack_module,
|
|
166
|
+
__webpack_exports__,
|
|
167
|
+
__webpack_require__
|
|
168
|
+
) => {
|
|
169
|
+
__webpack_require__.r(__webpack_exports__);
|
|
170
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
171
|
+
/* harmony export */ memo: () => /* binding */ memo,
|
|
172
|
+
/* harmony export */
|
|
173
|
+
});
|
|
174
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
175
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
176
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ =
|
|
177
|
+
__webpack_require__(/*! ./util */ './compat/src/util.js');
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Memoize a component, so that it only updates when the props actually have
|
|
181
|
+
* changed. This was previously known as `React.pure`.
|
|
182
|
+
* @param {import('./internal').FunctionComponent} c functional component
|
|
183
|
+
* @param {(prev: object, next: object) => boolean} [comparer] Custom equality function
|
|
184
|
+
* @returns {import('./internal').FunctionComponent}
|
|
185
|
+
*/
|
|
186
|
+
function memo(c, comparer) {
|
|
187
|
+
function shouldUpdate(nextProps) {
|
|
188
|
+
var ref = this.props.ref;
|
|
189
|
+
var updateRef = ref == nextProps.ref;
|
|
190
|
+
if (!updateRef && ref) {
|
|
191
|
+
ref.call ? ref(null) : (ref.current = null);
|
|
192
|
+
}
|
|
193
|
+
if (!comparer) {
|
|
194
|
+
return (0, _util__WEBPACK_IMPORTED_MODULE_1__.shallowDiffers)(
|
|
195
|
+
this.props,
|
|
196
|
+
nextProps
|
|
197
|
+
);
|
|
198
|
+
}
|
|
199
|
+
return !comparer(this.props, nextProps) || !updateRef;
|
|
200
|
+
}
|
|
201
|
+
function Memoed(props) {
|
|
202
|
+
this.shouldComponentUpdate = shouldUpdate;
|
|
203
|
+
return (0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
204
|
+
c,
|
|
205
|
+
props
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
Memoed.displayName = 'Memo(' + (c.displayName || c.name) + ')';
|
|
209
|
+
Memoed.prototype.isReactComponent = true;
|
|
210
|
+
Memoed.__f = true;
|
|
211
|
+
return Memoed;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/***/
|
|
215
|
+
},
|
|
216
|
+
|
|
217
|
+
/***/ './compat/src/portals.js':
|
|
218
|
+
/*!*******************************!*\
|
|
219
|
+
!*** ./compat/src/portals.js ***!
|
|
220
|
+
\*******************************/
|
|
221
|
+
/***/ (
|
|
222
|
+
__unused_webpack_module,
|
|
223
|
+
__webpack_exports__,
|
|
224
|
+
__webpack_require__
|
|
225
|
+
) => {
|
|
226
|
+
__webpack_require__.r(__webpack_exports__);
|
|
227
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
228
|
+
/* harmony export */ createPortal: () => /* binding */ createPortal,
|
|
229
|
+
/* harmony export */
|
|
230
|
+
});
|
|
231
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
232
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
233
|
+
|
|
234
|
+
/**
|
|
235
|
+
* @param {import('../../src/index').RenderableProps<{ context: any }>} props
|
|
236
|
+
*/
|
|
237
|
+
function ContextProvider(props) {
|
|
238
|
+
this.getChildContext = function () {
|
|
239
|
+
return props.context;
|
|
240
|
+
};
|
|
241
|
+
return props.children;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* Portal component
|
|
246
|
+
* @this {import('./internal').Component}
|
|
247
|
+
* @param {object | null | undefined} props
|
|
248
|
+
*
|
|
249
|
+
* TODO: use createRoot() instead of fake root
|
|
250
|
+
*/
|
|
251
|
+
function Portal(props) {
|
|
252
|
+
var _this = this;
|
|
253
|
+
var container = props._container;
|
|
254
|
+
_this.componentWillUnmount = function () {
|
|
255
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.render)(null, _this._temp);
|
|
256
|
+
_this._temp = null;
|
|
257
|
+
_this._container = null;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
// When we change container we should clear our old container and
|
|
261
|
+
// indicate a new mount.
|
|
262
|
+
if (_this._container && _this._container !== container) {
|
|
263
|
+
_this.componentWillUnmount();
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
// When props.vnode is undefined/false/null we are dealing with some kind of
|
|
267
|
+
// conditional vnode. This should not trigger a render.
|
|
268
|
+
if (props.__v) {
|
|
269
|
+
if (!_this._temp) {
|
|
270
|
+
_this._container = container;
|
|
271
|
+
|
|
272
|
+
// Create a fake DOM parent node that manages a subset of `container`'s children:
|
|
273
|
+
_this._temp = {
|
|
274
|
+
nodeType: 1,
|
|
275
|
+
parentNode: container,
|
|
276
|
+
childNodes: [],
|
|
277
|
+
appendChild: function appendChild(child) {
|
|
278
|
+
this.childNodes.push(child);
|
|
279
|
+
_this._container.appendChild(child);
|
|
280
|
+
},
|
|
281
|
+
insertBefore: function insertBefore(child, before) {
|
|
282
|
+
this.childNodes.push(child);
|
|
283
|
+
_this._container.appendChild(child);
|
|
284
|
+
},
|
|
285
|
+
removeChild: function removeChild(child) {
|
|
286
|
+
this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1);
|
|
287
|
+
_this._container.removeChild(child);
|
|
288
|
+
},
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
// Render our wrapping element into temp.
|
|
293
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.render)(
|
|
294
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
295
|
+
ContextProvider,
|
|
296
|
+
{
|
|
297
|
+
context: _this.context,
|
|
298
|
+
},
|
|
299
|
+
props.__v
|
|
300
|
+
),
|
|
301
|
+
_this._temp
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
// When we come from a conditional render, on a mounted
|
|
305
|
+
// portal we should clear the DOM.
|
|
306
|
+
else if (_this._temp) {
|
|
307
|
+
_this.componentWillUnmount();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/**
|
|
312
|
+
* Create a `Portal` to continue rendering the vnode tree at a different DOM node
|
|
313
|
+
* @param {import('./internal').VNode} vnode The vnode to render
|
|
314
|
+
* @param {import('./internal').PreactElement} container The DOM node to continue rendering in to.
|
|
315
|
+
*/
|
|
316
|
+
function createPortal(vnode, container) {
|
|
317
|
+
var el = (0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
318
|
+
Portal,
|
|
319
|
+
{
|
|
320
|
+
__v: vnode,
|
|
321
|
+
_container: container,
|
|
322
|
+
}
|
|
323
|
+
);
|
|
324
|
+
el.containerInfo = container;
|
|
325
|
+
return el;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/***/
|
|
329
|
+
},
|
|
330
|
+
|
|
331
|
+
/***/ './compat/src/render.js':
|
|
332
|
+
/*!******************************!*\
|
|
333
|
+
!*** ./compat/src/render.js ***!
|
|
334
|
+
\******************************/
|
|
335
|
+
/***/ (
|
|
336
|
+
__unused_webpack_module,
|
|
337
|
+
__webpack_exports__,
|
|
338
|
+
__webpack_require__
|
|
339
|
+
) => {
|
|
340
|
+
__webpack_require__.r(__webpack_exports__);
|
|
341
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
342
|
+
/* harmony export */ REACT_ELEMENT_TYPE: () =>
|
|
343
|
+
/* binding */ REACT_ELEMENT_TYPE,
|
|
344
|
+
/* harmony export */ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:
|
|
345
|
+
() =>
|
|
346
|
+
/* binding */ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
347
|
+
/* harmony export */ hydrate: () => /* binding */ hydrate,
|
|
348
|
+
/* harmony export */ render: () => /* binding */ render,
|
|
349
|
+
/* harmony export */
|
|
350
|
+
});
|
|
351
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
352
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
353
|
+
function _typeof(obj) {
|
|
354
|
+
'@babel/helpers - typeof';
|
|
355
|
+
return (
|
|
356
|
+
(_typeof =
|
|
357
|
+
'function' == typeof Symbol && 'symbol' == typeof Symbol.iterator
|
|
358
|
+
? function (obj) {
|
|
359
|
+
return typeof obj;
|
|
360
|
+
}
|
|
361
|
+
: function (obj) {
|
|
362
|
+
return obj &&
|
|
363
|
+
'function' == typeof Symbol &&
|
|
364
|
+
obj.constructor === Symbol &&
|
|
365
|
+
obj !== Symbol.prototype
|
|
366
|
+
? 'symbol'
|
|
367
|
+
: typeof obj;
|
|
368
|
+
}),
|
|
369
|
+
_typeof(obj)
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
var REACT_ELEMENT_TYPE =
|
|
374
|
+
(typeof Symbol != 'undefined' &&
|
|
375
|
+
Symbol.for &&
|
|
376
|
+
Symbol.for('react.element')) ||
|
|
377
|
+
0xeac7;
|
|
378
|
+
var CAMEL_PROPS =
|
|
379
|
+
/^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
|
380
|
+
var IS_DOM = typeof document !== 'undefined';
|
|
381
|
+
|
|
382
|
+
// Input types for which onchange should not be converted to oninput.
|
|
383
|
+
// type="file|checkbox|radio", plus "range" in IE11.
|
|
384
|
+
// (IE11 doesn't support Symbol, which we use here to turn `rad` into `ra` which matches "range")
|
|
385
|
+
var onChangeInputType = function onChangeInputType(type) {
|
|
386
|
+
return (
|
|
387
|
+
typeof Symbol != 'undefined' && _typeof(Symbol()) == 'symbol'
|
|
388
|
+
? /fil|che|rad/i
|
|
389
|
+
: /fil|che|ra/i
|
|
390
|
+
).test(type);
|
|
391
|
+
};
|
|
392
|
+
|
|
393
|
+
// Some libraries like `react-virtualized` explicitly check for this.
|
|
394
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype.isReactComponent =
|
|
395
|
+
{};
|
|
396
|
+
|
|
397
|
+
// `UNSAFE_*` lifecycle hooks
|
|
398
|
+
// Preact only ever invokes the unprefixed methods.
|
|
399
|
+
// Here we provide a base "fallback" implementation that calls any defined UNSAFE_ prefixed method.
|
|
400
|
+
// - If a component defines its own `componentDidMount()` (including via defineProperty), use that.
|
|
401
|
+
// - If a component defines `UNSAFE_componentDidMount()`, `componentDidMount` is the alias getter/setter.
|
|
402
|
+
// - If anything assigns to an `UNSAFE_*` property, the assignment is forwarded to the unprefixed property.
|
|
403
|
+
// See https://github.com/preactjs/preact/issues/1941
|
|
404
|
+
[
|
|
405
|
+
'componentWillMount',
|
|
406
|
+
'componentWillReceiveProps',
|
|
407
|
+
'componentWillUpdate',
|
|
408
|
+
].forEach(function (key) {
|
|
409
|
+
Object.defineProperty(
|
|
410
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.Component.prototype,
|
|
411
|
+
key,
|
|
412
|
+
{
|
|
413
|
+
configurable: true,
|
|
414
|
+
get: function get() {
|
|
415
|
+
return this['UNSAFE_' + key];
|
|
416
|
+
},
|
|
417
|
+
set: function set(v) {
|
|
418
|
+
Object.defineProperty(this, key, {
|
|
419
|
+
configurable: true,
|
|
420
|
+
writable: true,
|
|
421
|
+
value: v,
|
|
422
|
+
});
|
|
423
|
+
},
|
|
424
|
+
}
|
|
425
|
+
);
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* Proxy render() since React returns a Component reference.
|
|
430
|
+
* @param {import('./internal').VNode} vnode VNode tree to render
|
|
431
|
+
* @param {import('./internal').PreactElement} parent DOM node to render vnode tree into
|
|
432
|
+
* @param {() => void} [callback] Optional callback that will be called after rendering
|
|
433
|
+
* @returns {import('./internal').Component | null} The root component reference or null
|
|
434
|
+
*/
|
|
435
|
+
function render(vnode, parent, callback) {
|
|
436
|
+
// React destroys any existing DOM nodes, see #1727
|
|
437
|
+
// ...but only on the first render, see #1828
|
|
438
|
+
if (parent.__k == null) {
|
|
439
|
+
parent.textContent = '';
|
|
440
|
+
}
|
|
441
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.render)(vnode, parent);
|
|
442
|
+
if (typeof callback == 'function') callback();
|
|
443
|
+
return vnode ? vnode.__c : null;
|
|
444
|
+
}
|
|
445
|
+
function hydrate(vnode, parent, callback) {
|
|
446
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.hydrate)(vnode, parent);
|
|
447
|
+
if (typeof callback == 'function') callback();
|
|
448
|
+
return vnode ? vnode.__c : null;
|
|
449
|
+
}
|
|
450
|
+
var oldEventHook = preact__WEBPACK_IMPORTED_MODULE_0__.options.event;
|
|
451
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.event = function (e) {
|
|
452
|
+
if (oldEventHook) e = oldEventHook(e);
|
|
453
|
+
e.persist = empty;
|
|
454
|
+
e.isPropagationStopped = isPropagationStopped;
|
|
455
|
+
e.isDefaultPrevented = isDefaultPrevented;
|
|
456
|
+
return (e.nativeEvent = e);
|
|
457
|
+
};
|
|
458
|
+
function empty() {}
|
|
459
|
+
function isPropagationStopped() {
|
|
460
|
+
return this.cancelBubble;
|
|
461
|
+
}
|
|
462
|
+
function isDefaultPrevented() {
|
|
463
|
+
return this.defaultPrevented;
|
|
464
|
+
}
|
|
465
|
+
var classNameDescriptor = {
|
|
466
|
+
configurable: true,
|
|
467
|
+
get: function get() {
|
|
468
|
+
return this.class;
|
|
469
|
+
},
|
|
470
|
+
};
|
|
471
|
+
var oldVNodeHook = preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode;
|
|
472
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.vnode = function (vnode) {
|
|
473
|
+
var type = vnode.type;
|
|
474
|
+
var props = vnode.props;
|
|
475
|
+
var normalizedProps = props;
|
|
476
|
+
|
|
477
|
+
// only normalize props on Element nodes
|
|
478
|
+
if (typeof type === 'string') {
|
|
479
|
+
var nonCustomElement = type.indexOf('-') === -1;
|
|
480
|
+
normalizedProps = {};
|
|
481
|
+
for (var i in props) {
|
|
482
|
+
var value = props[i];
|
|
483
|
+
if (IS_DOM && i === 'children' && type === 'noscript') {
|
|
484
|
+
// Emulate React's behavior of not rendering the contents of noscript tags on the client.
|
|
485
|
+
continue;
|
|
486
|
+
}
|
|
487
|
+
else if (
|
|
488
|
+
i === 'value' &&
|
|
489
|
+
'defaultValue' in props &&
|
|
490
|
+
value == null
|
|
491
|
+
) {
|
|
492
|
+
// Skip applying value if it is null/undefined and we already set
|
|
493
|
+
// a default value
|
|
494
|
+
continue;
|
|
495
|
+
}
|
|
496
|
+
else if (
|
|
497
|
+
i === 'defaultValue' &&
|
|
498
|
+
'value' in props &&
|
|
499
|
+
props.value == null
|
|
500
|
+
) {
|
|
501
|
+
// `defaultValue` is treated as a fallback `value` when a value prop is present but null/undefined.
|
|
502
|
+
// `defaultValue` for Elements with no value prop is the same as the DOM defaultValue property.
|
|
503
|
+
i = 'value';
|
|
504
|
+
}
|
|
505
|
+
else if (i === 'download' && value === true) {
|
|
506
|
+
// Calling `setAttribute` with a truthy value will lead to it being
|
|
507
|
+
// passed as a stringified value, e.g. `download="true"`. React
|
|
508
|
+
// converts it to an empty string instead, otherwise the attribute
|
|
509
|
+
// value will be used as the file name and the file will be called
|
|
510
|
+
// "true" upon downloading it.
|
|
511
|
+
value = '';
|
|
512
|
+
}
|
|
513
|
+
else if (/ondoubleclick/i.test(i)) {
|
|
514
|
+
i = 'ondblclick';
|
|
515
|
+
}
|
|
516
|
+
else if (
|
|
517
|
+
/^onchange(textarea|input)/i.test(i + type) &&
|
|
518
|
+
!onChangeInputType(props.type)
|
|
519
|
+
) {
|
|
520
|
+
i = 'oninput';
|
|
521
|
+
}
|
|
522
|
+
else if (/^onfocus$/i.test(i)) {
|
|
523
|
+
i = 'onfocusin';
|
|
524
|
+
}
|
|
525
|
+
else if (/^onblur$/i.test(i)) {
|
|
526
|
+
i = 'onfocusout';
|
|
527
|
+
}
|
|
528
|
+
else if (/^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(i)) {
|
|
529
|
+
i = i.toLowerCase();
|
|
530
|
+
}
|
|
531
|
+
else if (nonCustomElement && CAMEL_PROPS.test(i)) {
|
|
532
|
+
i = i.replace(/[A-Z0-9]/g, '-$&').toLowerCase();
|
|
533
|
+
}
|
|
534
|
+
else if (value === null) {
|
|
535
|
+
value = undefined;
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
// Add support for onInput and onChange, see #3561
|
|
539
|
+
// if we have an oninput prop already change it to oninputCapture
|
|
540
|
+
if (/^oninput$/i.test(i)) {
|
|
541
|
+
i = i.toLowerCase();
|
|
542
|
+
if (normalizedProps[i]) {
|
|
543
|
+
i = 'oninputCapture';
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
normalizedProps[i] = value;
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
// Add support for array select values: <select multiple value={[]} />
|
|
550
|
+
if (
|
|
551
|
+
type == 'select' &&
|
|
552
|
+
normalizedProps.multiple &&
|
|
553
|
+
Array.isArray(normalizedProps.value)
|
|
554
|
+
) {
|
|
555
|
+
// forEach() always returns undefined, which we abuse here to unset the value prop.
|
|
556
|
+
normalizedProps.value = (0,
|
|
557
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(
|
|
558
|
+
props.children
|
|
559
|
+
).forEach(function (child) {
|
|
560
|
+
child.props.selected =
|
|
561
|
+
normalizedProps.value.indexOf(child.props.value) != -1;
|
|
562
|
+
});
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// Adding support for defaultValue in select tag
|
|
566
|
+
if (type == 'select' && normalizedProps.defaultValue != null) {
|
|
567
|
+
normalizedProps.value = (0,
|
|
568
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(
|
|
569
|
+
props.children
|
|
570
|
+
).forEach(function (child) {
|
|
571
|
+
if (normalizedProps.multiple) {
|
|
572
|
+
child.props.selected =
|
|
573
|
+
normalizedProps.defaultValue.indexOf(child.props.value) != -1;
|
|
574
|
+
}
|
|
575
|
+
else {
|
|
576
|
+
child.props.selected =
|
|
577
|
+
normalizedProps.defaultValue == child.props.value;
|
|
578
|
+
}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
581
|
+
vnode.props = normalizedProps;
|
|
582
|
+
if (props.class != props.className) {
|
|
583
|
+
classNameDescriptor.enumerable = 'className' in props;
|
|
584
|
+
if (props.className != null)
|
|
585
|
+
normalizedProps.class = props.className;
|
|
586
|
+
Object.defineProperty(
|
|
587
|
+
normalizedProps,
|
|
588
|
+
'className',
|
|
589
|
+
classNameDescriptor
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
vnode.$$typeof = REACT_ELEMENT_TYPE;
|
|
594
|
+
if (oldVNodeHook) oldVNodeHook(vnode);
|
|
595
|
+
};
|
|
596
|
+
|
|
597
|
+
// Only needed for react-relay
|
|
598
|
+
var currentComponent;
|
|
599
|
+
var oldBeforeRender = preact__WEBPACK_IMPORTED_MODULE_0__.options.__r;
|
|
600
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__r = function (vnode) {
|
|
601
|
+
if (oldBeforeRender) {
|
|
602
|
+
oldBeforeRender(vnode);
|
|
603
|
+
}
|
|
604
|
+
currentComponent = vnode.__c;
|
|
605
|
+
};
|
|
606
|
+
|
|
607
|
+
// This is a very very private internal function for React it
|
|
608
|
+
// is used to sort-of do runtime dependency injection. So far
|
|
609
|
+
// only `react-relay` makes use of it. It uses it to read the
|
|
610
|
+
// context value.
|
|
611
|
+
var __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = {
|
|
612
|
+
ReactCurrentDispatcher: {
|
|
613
|
+
current: {
|
|
614
|
+
readContext: function readContext(context) {
|
|
615
|
+
return currentComponent.__n[context.__c].props.value;
|
|
616
|
+
},
|
|
617
|
+
},
|
|
618
|
+
},
|
|
619
|
+
};
|
|
620
|
+
|
|
621
|
+
/***/
|
|
622
|
+
},
|
|
623
|
+
|
|
624
|
+
/***/ './compat/src/suspense-list.js':
|
|
625
|
+
/*!*************************************!*\
|
|
626
|
+
!*** ./compat/src/suspense-list.js ***!
|
|
627
|
+
\*************************************/
|
|
628
|
+
/***/ (
|
|
629
|
+
__unused_webpack_module,
|
|
630
|
+
__webpack_exports__,
|
|
631
|
+
__webpack_require__
|
|
632
|
+
) => {
|
|
633
|
+
__webpack_require__.r(__webpack_exports__);
|
|
634
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
635
|
+
/* harmony export */ SuspenseList: () => /* binding */ SuspenseList,
|
|
636
|
+
/* harmony export */
|
|
637
|
+
});
|
|
638
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
639
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
640
|
+
/* harmony import */ var _suspense_js__WEBPACK_IMPORTED_MODULE_1__ =
|
|
641
|
+
__webpack_require__(/*! ./suspense.js */ './compat/src/suspense.js');
|
|
642
|
+
|
|
643
|
+
// Indexes to linked list nodes (nodes are stored as arrays to save bytes).
|
|
644
|
+
var SUSPENDED_COUNT = 0;
|
|
645
|
+
var RESOLVED_COUNT = 1;
|
|
646
|
+
var NEXT_NODE = 2;
|
|
647
|
+
|
|
648
|
+
// Having custom inheritance instead of a class here saves a lot of bytes.
|
|
649
|
+
function SuspenseList() {
|
|
650
|
+
this._next = null;
|
|
651
|
+
this._map = null;
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
// Mark one of child's earlier suspensions as resolved.
|
|
655
|
+
// Some pending callbacks may become callable due to this
|
|
656
|
+
// (e.g. the last suspended descendant gets resolved when
|
|
657
|
+
// revealOrder === 'together'). Process those callbacks as well.
|
|
658
|
+
var resolve = function resolve(list, child, node) {
|
|
659
|
+
if (++node[RESOLVED_COUNT] === node[SUSPENDED_COUNT]) {
|
|
660
|
+
// The number a child (or any of its descendants) has been suspended
|
|
661
|
+
// matches the number of times it's been resolved. Therefore we
|
|
662
|
+
// mark the child as completely resolved by deleting it from ._map.
|
|
663
|
+
// This is used to figure out when *all* children have been completely
|
|
664
|
+
// resolved when revealOrder is 'together'.
|
|
665
|
+
list._map.delete(child);
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
// If revealOrder is falsy then we can do an early exit, as the
|
|
669
|
+
// callbacks won't get queued in the node anyway.
|
|
670
|
+
// If revealOrder is 'together' then also do an early exit
|
|
671
|
+
// if all suspended descendants have not yet been resolved.
|
|
672
|
+
if (
|
|
673
|
+
!list.props.revealOrder ||
|
|
674
|
+
(list.props.revealOrder[0] === 't' && list._map.size)
|
|
675
|
+
) {
|
|
676
|
+
return;
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
// Walk the currently suspended children in order, calling their
|
|
680
|
+
// stored callbacks on the way. Stop if we encounter a child that
|
|
681
|
+
// has not been completely resolved yet.
|
|
682
|
+
node = list._next;
|
|
683
|
+
while (node) {
|
|
684
|
+
while (node.length > 3) {
|
|
685
|
+
node.pop()();
|
|
686
|
+
}
|
|
687
|
+
if (node[RESOLVED_COUNT] < node[SUSPENDED_COUNT]) {
|
|
688
|
+
break;
|
|
689
|
+
}
|
|
690
|
+
list._next = node = node[NEXT_NODE];
|
|
691
|
+
}
|
|
692
|
+
};
|
|
693
|
+
|
|
694
|
+
// Things we do here to save some bytes but are not proper JS inheritance:
|
|
695
|
+
// - call `new Component()` as the prototype
|
|
696
|
+
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
|
697
|
+
SuspenseList.prototype =
|
|
698
|
+
new preact__WEBPACK_IMPORTED_MODULE_0__.Component();
|
|
699
|
+
SuspenseList.prototype.__a = function (child) {
|
|
700
|
+
var list = this;
|
|
701
|
+
var delegated = (0,
|
|
702
|
+
_suspense_js__WEBPACK_IMPORTED_MODULE_1__.suspended)(list.__v);
|
|
703
|
+
var node = list._map.get(child);
|
|
704
|
+
node[SUSPENDED_COUNT]++;
|
|
705
|
+
return function (unsuspend) {
|
|
706
|
+
var wrappedUnsuspend = function wrappedUnsuspend() {
|
|
707
|
+
if (!list.props.revealOrder) {
|
|
708
|
+
// Special case the undefined (falsy) revealOrder, as there
|
|
709
|
+
// is no need to coordinate a specific order or unsuspends.
|
|
710
|
+
unsuspend();
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
node.push(unsuspend);
|
|
714
|
+
resolve(list, child, node);
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
|
+
if (delegated) {
|
|
718
|
+
delegated(wrappedUnsuspend);
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
wrappedUnsuspend();
|
|
722
|
+
}
|
|
723
|
+
};
|
|
724
|
+
};
|
|
725
|
+
SuspenseList.prototype.render = function (props) {
|
|
726
|
+
this._next = null;
|
|
727
|
+
this._map = new Map();
|
|
728
|
+
var children = (0, preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray)(
|
|
729
|
+
props.children
|
|
730
|
+
);
|
|
731
|
+
if (props.revealOrder && props.revealOrder[0] === 'b') {
|
|
732
|
+
// If order === 'backwards' (or, well, anything starting with a 'b')
|
|
733
|
+
// then flip the child list around so that the last child will be
|
|
734
|
+
// the first in the linked list.
|
|
735
|
+
children.reverse();
|
|
736
|
+
}
|
|
737
|
+
// Build the linked list. Iterate through the children in reverse order
|
|
738
|
+
// so that `_next` points to the first linked list node to be resolved.
|
|
739
|
+
for (var i = children.length; i--; ) {
|
|
740
|
+
// Create a new linked list node as an array of form:
|
|
741
|
+
// [suspended_count, resolved_count, next_node]
|
|
742
|
+
// where suspended_count and resolved_count are numeric counters for
|
|
743
|
+
// keeping track how many times a node has been suspended and resolved.
|
|
744
|
+
//
|
|
745
|
+
// Note that suspended_count starts from 1 instead of 0, so we can block
|
|
746
|
+
// processing callbacks until componentDidMount has been called. In a sense
|
|
747
|
+
// node is suspended at least until componentDidMount gets called!
|
|
748
|
+
//
|
|
749
|
+
// Pending callbacks are added to the end of the node:
|
|
750
|
+
// [suspended_count, resolved_count, next_node, callback_0, callback_1, ...]
|
|
751
|
+
this._map.set(children[i], (this._next = [1, 0, this._next]));
|
|
752
|
+
}
|
|
753
|
+
return props.children;
|
|
754
|
+
};
|
|
755
|
+
SuspenseList.prototype.componentDidUpdate =
|
|
756
|
+
SuspenseList.prototype.componentDidMount = function () {
|
|
757
|
+
var _this = this;
|
|
758
|
+
// Iterate through all children after mounting for two reasons:
|
|
759
|
+
// 1. As each node[SUSPENDED_COUNT] starts from 1, this iteration increases
|
|
760
|
+
// each node[RELEASED_COUNT] by 1, therefore balancing the counters.
|
|
761
|
+
// The nodes can now be completely consumed from the linked list.
|
|
762
|
+
// 2. Handle nodes that might have gotten resolved between render and
|
|
763
|
+
// componentDidMount.
|
|
764
|
+
this._map.forEach(function (node, child) {
|
|
765
|
+
resolve(_this, child, node);
|
|
766
|
+
});
|
|
767
|
+
};
|
|
768
|
+
|
|
769
|
+
/***/
|
|
770
|
+
},
|
|
771
|
+
|
|
772
|
+
/***/ './compat/src/suspense.js':
|
|
773
|
+
/*!********************************!*\
|
|
774
|
+
!*** ./compat/src/suspense.js ***!
|
|
775
|
+
\********************************/
|
|
776
|
+
/***/ (
|
|
777
|
+
__unused_webpack_module,
|
|
778
|
+
__webpack_exports__,
|
|
779
|
+
__webpack_require__
|
|
780
|
+
) => {
|
|
781
|
+
__webpack_require__.r(__webpack_exports__);
|
|
782
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
783
|
+
/* harmony export */ Suspense: () => /* binding */ Suspense,
|
|
784
|
+
/* harmony export */ lazy: () => /* binding */ lazy,
|
|
785
|
+
/* harmony export */ suspended: () => /* binding */ suspended,
|
|
786
|
+
/* harmony export */
|
|
787
|
+
});
|
|
788
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
789
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
790
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_1__ =
|
|
791
|
+
__webpack_require__(/*! ./util */ './compat/src/util.js');
|
|
792
|
+
|
|
793
|
+
var oldCatchError = preact__WEBPACK_IMPORTED_MODULE_0__.options.__e;
|
|
794
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__e = function (
|
|
795
|
+
error,
|
|
796
|
+
newVNode,
|
|
797
|
+
oldVNode,
|
|
798
|
+
errorInfo
|
|
799
|
+
) {
|
|
800
|
+
if (error.then) {
|
|
801
|
+
/** @type {import('./internal').Component} */
|
|
802
|
+
var component;
|
|
803
|
+
var vnode = newVNode;
|
|
804
|
+
for (; (vnode = vnode.__); ) {
|
|
805
|
+
if ((component = vnode.__c) && component.__c) {
|
|
806
|
+
if (newVNode.__e == null) {
|
|
807
|
+
newVNode.__e = oldVNode.__e;
|
|
808
|
+
newVNode.__k = oldVNode.__k;
|
|
809
|
+
}
|
|
810
|
+
// Don't call oldCatchError if we found a Suspense
|
|
811
|
+
return component.__c(error, newVNode);
|
|
812
|
+
}
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
oldCatchError(error, newVNode, oldVNode, errorInfo);
|
|
816
|
+
};
|
|
817
|
+
var oldUnmount = preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount;
|
|
818
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount = function (vnode) {
|
|
819
|
+
/** @type {import('./internal').Component} */
|
|
820
|
+
var component = vnode.__c;
|
|
821
|
+
if (component && component.__R) {
|
|
822
|
+
component.__R();
|
|
823
|
+
}
|
|
824
|
+
|
|
825
|
+
// if the component is still hydrating
|
|
826
|
+
// most likely it is because the component is suspended
|
|
827
|
+
// we set the vnode.type as `null` so that it is not a typeof function
|
|
828
|
+
// so the unmount will remove the vnode._dom
|
|
829
|
+
if (component && vnode.__h === true) {
|
|
830
|
+
vnode.type = null;
|
|
831
|
+
}
|
|
832
|
+
if (oldUnmount) oldUnmount(vnode);
|
|
833
|
+
};
|
|
834
|
+
function detachedClone(vnode, detachedParent, parentDom) {
|
|
835
|
+
if (vnode) {
|
|
836
|
+
if (vnode.__c && vnode.__c.__H) {
|
|
837
|
+
vnode.__c.__H.__.forEach(function (effect) {
|
|
838
|
+
if (typeof effect.__c == 'function') effect.__c();
|
|
839
|
+
});
|
|
840
|
+
vnode.__c.__H = null;
|
|
841
|
+
}
|
|
842
|
+
vnode = (0, _util__WEBPACK_IMPORTED_MODULE_1__.assign)({}, vnode);
|
|
843
|
+
if (vnode.__c != null) {
|
|
844
|
+
if (vnode.__c.__P === parentDom) {
|
|
845
|
+
vnode.__c.__P = detachedParent;
|
|
846
|
+
}
|
|
847
|
+
vnode.__c = null;
|
|
848
|
+
}
|
|
849
|
+
vnode.__k =
|
|
850
|
+
vnode.__k &&
|
|
851
|
+
vnode.__k.map(function (child) {
|
|
852
|
+
return detachedClone(child, detachedParent, parentDom);
|
|
853
|
+
});
|
|
854
|
+
}
|
|
855
|
+
return vnode;
|
|
856
|
+
}
|
|
857
|
+
function removeOriginal(vnode, detachedParent, originalParent) {
|
|
858
|
+
if (vnode) {
|
|
859
|
+
vnode.__v = null;
|
|
860
|
+
vnode.__k =
|
|
861
|
+
vnode.__k &&
|
|
862
|
+
vnode.__k.map(function (child) {
|
|
863
|
+
return removeOriginal(child, detachedParent, originalParent);
|
|
864
|
+
});
|
|
865
|
+
if (vnode.__c) {
|
|
866
|
+
if (vnode.__c.__P === detachedParent) {
|
|
867
|
+
if (vnode.__e) {
|
|
868
|
+
originalParent.insertBefore(vnode.__e, vnode.__d);
|
|
869
|
+
}
|
|
870
|
+
vnode.__c.__e = true;
|
|
871
|
+
vnode.__c.__P = originalParent;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
}
|
|
875
|
+
return vnode;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
// having custom inheritance instead of a class here saves a lot of bytes
|
|
879
|
+
function Suspense() {
|
|
880
|
+
// we do not call super here to golf some bytes...
|
|
881
|
+
this.__u = 0;
|
|
882
|
+
this._suspenders = null;
|
|
883
|
+
this.__b = null;
|
|
884
|
+
}
|
|
885
|
+
|
|
886
|
+
// Things we do here to save some bytes but are not proper JS inheritance:
|
|
887
|
+
// - call `new Component()` as the prototype
|
|
888
|
+
// - do not set `Suspense.prototype.constructor` to `Suspense`
|
|
889
|
+
Suspense.prototype = new preact__WEBPACK_IMPORTED_MODULE_0__.Component();
|
|
890
|
+
|
|
891
|
+
/**
|
|
892
|
+
* @this {import('./internal').SuspenseComponent}
|
|
893
|
+
* @param {Promise} promise The thrown promise
|
|
894
|
+
* @param {import('./internal').VNode<any, any>} suspendingVNode The suspending component
|
|
895
|
+
*/
|
|
896
|
+
Suspense.prototype.__c = function (promise, suspendingVNode) {
|
|
897
|
+
var suspendingComponent = suspendingVNode.__c;
|
|
898
|
+
|
|
899
|
+
/** @type {import('./internal').SuspenseComponent} */
|
|
900
|
+
var c = this;
|
|
901
|
+
if (c._suspenders == null) {
|
|
902
|
+
c._suspenders = [];
|
|
903
|
+
}
|
|
904
|
+
c._suspenders.push(suspendingComponent);
|
|
905
|
+
var resolve = suspended(c.__v);
|
|
906
|
+
var resolved = false;
|
|
907
|
+
var onResolved = function onResolved() {
|
|
908
|
+
if (resolved) return;
|
|
909
|
+
resolved = true;
|
|
910
|
+
suspendingComponent.__R = null;
|
|
911
|
+
if (resolve) {
|
|
912
|
+
resolve(onSuspensionComplete);
|
|
913
|
+
}
|
|
914
|
+
else {
|
|
915
|
+
onSuspensionComplete();
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
suspendingComponent.__R = onResolved;
|
|
919
|
+
var onSuspensionComplete = function onSuspensionComplete() {
|
|
920
|
+
if (!--c.__u) {
|
|
921
|
+
// If the suspension was during hydration we don't need to restore the
|
|
922
|
+
// suspended children into the _children array
|
|
923
|
+
if (c.state.__a) {
|
|
924
|
+
var suspendedVNode = c.state.__a;
|
|
925
|
+
c.__v.__k[0] = removeOriginal(
|
|
926
|
+
suspendedVNode,
|
|
927
|
+
suspendedVNode.__c.__P,
|
|
928
|
+
suspendedVNode.__c.__O
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
c.setState({
|
|
932
|
+
__a: (c.__b = null),
|
|
933
|
+
});
|
|
934
|
+
var _suspended;
|
|
935
|
+
while ((_suspended = c._suspenders.pop())) {
|
|
936
|
+
_suspended.forceUpdate();
|
|
937
|
+
}
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
/**
|
|
942
|
+
* We do not set `suspended: true` during hydration because we want the actual markup
|
|
943
|
+
* to remain on screen and hydrate it when the suspense actually gets resolved.
|
|
944
|
+
* While in non-hydration cases the usual fallback -> component flow would occour.
|
|
945
|
+
*/
|
|
946
|
+
var wasHydrating = suspendingVNode.__h === true;
|
|
947
|
+
if (!c.__u++ && !wasHydrating) {
|
|
948
|
+
c.setState({
|
|
949
|
+
__a: (c.__b = c.__v.__k[0]),
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
promise.then(onResolved, onResolved);
|
|
953
|
+
};
|
|
954
|
+
Suspense.prototype.componentWillUnmount = function () {
|
|
955
|
+
this._suspenders = [];
|
|
956
|
+
};
|
|
957
|
+
|
|
958
|
+
/**
|
|
959
|
+
* @this {import('./internal').SuspenseComponent}
|
|
960
|
+
* @param {import('./internal').SuspenseComponent["props"]} props
|
|
961
|
+
* @param {import('./internal').SuspenseState} state
|
|
962
|
+
*/
|
|
963
|
+
Suspense.prototype.render = function (props, state) {
|
|
964
|
+
if (this.__b) {
|
|
965
|
+
// When the Suspense's _vnode was created by a call to createVNode
|
|
966
|
+
// (i.e. due to a setState further up in the tree)
|
|
967
|
+
// it's _children prop is null, in this case we "forget" about the parked vnodes to detach
|
|
968
|
+
if (this.__v.__k) {
|
|
969
|
+
var detachedParent = document.createElement('div');
|
|
970
|
+
var detachedComponent = this.__v.__k[0].__c;
|
|
971
|
+
this.__v.__k[0] = detachedClone(
|
|
972
|
+
this.__b,
|
|
973
|
+
detachedParent,
|
|
974
|
+
(detachedComponent.__O = detachedComponent.__P)
|
|
975
|
+
);
|
|
976
|
+
}
|
|
977
|
+
this.__b = null;
|
|
978
|
+
}
|
|
979
|
+
|
|
980
|
+
// Wrap fallback tree in a VNode that prevents itself from being marked as aborting mid-hydration:
|
|
981
|
+
/** @type {import('./internal').VNode} */
|
|
982
|
+
var fallback =
|
|
983
|
+
state.__a &&
|
|
984
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
985
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,
|
|
986
|
+
null,
|
|
987
|
+
props.fallback
|
|
988
|
+
);
|
|
989
|
+
if (fallback) fallback.__h = null;
|
|
990
|
+
return [
|
|
991
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
992
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,
|
|
993
|
+
null,
|
|
994
|
+
state.__a ? null : props.children
|
|
995
|
+
),
|
|
996
|
+
fallback,
|
|
997
|
+
];
|
|
998
|
+
};
|
|
999
|
+
|
|
1000
|
+
/**
|
|
1001
|
+
* Checks and calls the parent component's _suspended method, passing in the
|
|
1002
|
+
* suspended vnode. This is a way for a parent (e.g. SuspenseList) to get notified
|
|
1003
|
+
* that one of its children/descendants suspended.
|
|
1004
|
+
*
|
|
1005
|
+
* The parent MAY return a callback. The callback will get called when the
|
|
1006
|
+
* suspension resolves, notifying the parent of the fact.
|
|
1007
|
+
* Moreover, the callback gets function `unsuspend` as a parameter. The resolved
|
|
1008
|
+
* child descendant will not actually get unsuspended until `unsuspend` gets called.
|
|
1009
|
+
* This is a way for the parent to delay unsuspending.
|
|
1010
|
+
*
|
|
1011
|
+
* If the parent does not return a callback then the resolved vnode
|
|
1012
|
+
* gets unsuspended immediately when it resolves.
|
|
1013
|
+
*
|
|
1014
|
+
* @param {import('./internal').VNode} vnode
|
|
1015
|
+
* @returns {((unsuspend: () => void) => void)?}
|
|
1016
|
+
*/
|
|
1017
|
+
function suspended(vnode) {
|
|
1018
|
+
/** @type {import('./internal').Component} */
|
|
1019
|
+
var component = vnode.__.__c;
|
|
1020
|
+
return component && component.__a && component.__a(vnode);
|
|
1021
|
+
}
|
|
1022
|
+
function lazy(loader) {
|
|
1023
|
+
var prom;
|
|
1024
|
+
var component;
|
|
1025
|
+
var error;
|
|
1026
|
+
function Lazy(props) {
|
|
1027
|
+
if (!prom) {
|
|
1028
|
+
prom = loader();
|
|
1029
|
+
prom.then(
|
|
1030
|
+
function (exports) {
|
|
1031
|
+
component = exports.default || exports;
|
|
1032
|
+
},
|
|
1033
|
+
function (e) {
|
|
1034
|
+
error = e;
|
|
1035
|
+
}
|
|
1036
|
+
);
|
|
1037
|
+
}
|
|
1038
|
+
if (error) {
|
|
1039
|
+
throw error;
|
|
1040
|
+
}
|
|
1041
|
+
if (!component) {
|
|
1042
|
+
throw prom;
|
|
1043
|
+
}
|
|
1044
|
+
return (0, preact__WEBPACK_IMPORTED_MODULE_0__.createElement)(
|
|
1045
|
+
component,
|
|
1046
|
+
props
|
|
1047
|
+
);
|
|
1048
|
+
}
|
|
1049
|
+
Lazy.displayName = 'Lazy';
|
|
1050
|
+
Lazy.__f = true;
|
|
1051
|
+
return Lazy;
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
/***/
|
|
1055
|
+
},
|
|
1056
|
+
|
|
1057
|
+
/***/ './compat/src/util.js':
|
|
1058
|
+
/*!****************************!*\
|
|
1059
|
+
!*** ./compat/src/util.js ***!
|
|
1060
|
+
\****************************/
|
|
1061
|
+
/***/ (
|
|
1062
|
+
__unused_webpack_module,
|
|
1063
|
+
__webpack_exports__,
|
|
1064
|
+
__webpack_require__
|
|
1065
|
+
) => {
|
|
1066
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1067
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1068
|
+
/* harmony export */ assign: () => /* binding */ assign,
|
|
1069
|
+
/* harmony export */ is: () => /* binding */ is,
|
|
1070
|
+
/* harmony export */ removeNode: () => /* binding */ removeNode,
|
|
1071
|
+
/* harmony export */ shallowDiffers: () => /* binding */ shallowDiffers,
|
|
1072
|
+
/* harmony export */
|
|
1073
|
+
});
|
|
1074
|
+
/**
|
|
1075
|
+
* Assign properties from `props` to `obj`
|
|
1076
|
+
* @template O, P The obj and props types
|
|
1077
|
+
* @param {O} obj The object to copy properties to
|
|
1078
|
+
* @param {P} props The object to copy properties from
|
|
1079
|
+
* @returns {O & P}
|
|
1080
|
+
*/
|
|
1081
|
+
function assign(obj, props) {
|
|
1082
|
+
for (var i in props) {
|
|
1083
|
+
obj[i] = props[i];
|
|
1084
|
+
}
|
|
1085
|
+
return /** @type {O & P} */ obj;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
/**
|
|
1089
|
+
* Check if two objects have a different shape
|
|
1090
|
+
* @param {object} a
|
|
1091
|
+
* @param {object} b
|
|
1092
|
+
* @returns {boolean}
|
|
1093
|
+
*/
|
|
1094
|
+
function shallowDiffers(a, b) {
|
|
1095
|
+
for (var i in a) {
|
|
1096
|
+
if (i !== '__source' && !(i in b)) return true;
|
|
1097
|
+
}
|
|
1098
|
+
for (var _i in b) {
|
|
1099
|
+
if (_i !== '__source' && a[_i] !== b[_i]) return true;
|
|
1100
|
+
}
|
|
1101
|
+
return false;
|
|
1102
|
+
}
|
|
1103
|
+
function removeNode(node) {
|
|
1104
|
+
var parentNode = node.parentNode;
|
|
1105
|
+
if (parentNode) parentNode.removeChild(node);
|
|
1106
|
+
}
|
|
1107
|
+
|
|
1108
|
+
/**
|
|
1109
|
+
* Check if two values are the same value
|
|
1110
|
+
* @param {*} x
|
|
1111
|
+
* @param {*} y
|
|
1112
|
+
* @returns {boolean}
|
|
1113
|
+
*/
|
|
1114
|
+
function is(x, y) {
|
|
1115
|
+
return (
|
|
1116
|
+
(x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y)
|
|
1117
|
+
);
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/***/
|
|
1121
|
+
},
|
|
1122
|
+
|
|
1123
|
+
/***/ './hooks/src/index.js':
|
|
1124
|
+
/*!****************************!*\
|
|
1125
|
+
!*** ./hooks/src/index.js ***!
|
|
1126
|
+
\****************************/
|
|
1127
|
+
/***/ (
|
|
1128
|
+
__unused_webpack_module,
|
|
1129
|
+
__webpack_exports__,
|
|
1130
|
+
__webpack_require__
|
|
1131
|
+
) => {
|
|
1132
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1133
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1134
|
+
/* harmony export */ useCallback: () => /* binding */ useCallback,
|
|
1135
|
+
/* harmony export */ useContext: () => /* binding */ useContext,
|
|
1136
|
+
/* harmony export */ useDebugValue: () => /* binding */ useDebugValue,
|
|
1137
|
+
/* harmony export */ useEffect: () => /* binding */ useEffect,
|
|
1138
|
+
/* harmony export */ useErrorBoundary: () =>
|
|
1139
|
+
/* binding */ useErrorBoundary,
|
|
1140
|
+
/* harmony export */ useId: () => /* binding */ useId,
|
|
1141
|
+
/* harmony export */ useImperativeHandle: () =>
|
|
1142
|
+
/* binding */ useImperativeHandle,
|
|
1143
|
+
/* harmony export */ useLayoutEffect: () =>
|
|
1144
|
+
/* binding */ useLayoutEffect,
|
|
1145
|
+
/* harmony export */ useMemo: () => /* binding */ useMemo,
|
|
1146
|
+
/* harmony export */ useReducer: () => /* binding */ useReducer,
|
|
1147
|
+
/* harmony export */ useRef: () => /* binding */ useRef,
|
|
1148
|
+
/* harmony export */ useState: () => /* binding */ useState,
|
|
1149
|
+
/* harmony export */
|
|
1150
|
+
});
|
|
1151
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
1152
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
1153
|
+
|
|
1154
|
+
/** @type {number} */
|
|
1155
|
+
var currentIndex;
|
|
1156
|
+
|
|
1157
|
+
/** @type {import('./internal').Component} */
|
|
1158
|
+
var currentComponent;
|
|
1159
|
+
|
|
1160
|
+
/** @type {import('./internal').Component} */
|
|
1161
|
+
var previousComponent;
|
|
1162
|
+
|
|
1163
|
+
/** @type {number} */
|
|
1164
|
+
var currentHook = 0;
|
|
1165
|
+
|
|
1166
|
+
/** @type {Array<import('./internal').Component>} */
|
|
1167
|
+
var afterPaintEffects = [];
|
|
1168
|
+
var EMPTY = [];
|
|
1169
|
+
var oldBeforeDiff = preact__WEBPACK_IMPORTED_MODULE_0__.options.__b;
|
|
1170
|
+
var oldBeforeRender = preact__WEBPACK_IMPORTED_MODULE_0__.options.__r;
|
|
1171
|
+
var oldAfterDiff = preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed;
|
|
1172
|
+
var oldCommit = preact__WEBPACK_IMPORTED_MODULE_0__.options.__c;
|
|
1173
|
+
var oldBeforeUnmount =
|
|
1174
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount;
|
|
1175
|
+
var RAF_TIMEOUT = 100;
|
|
1176
|
+
var prevRaf;
|
|
1177
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__b = function (vnode) {
|
|
1178
|
+
currentComponent = null;
|
|
1179
|
+
if (oldBeforeDiff) oldBeforeDiff(vnode);
|
|
1180
|
+
};
|
|
1181
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__r = function (vnode) {
|
|
1182
|
+
if (oldBeforeRender) oldBeforeRender(vnode);
|
|
1183
|
+
currentComponent = vnode.__c;
|
|
1184
|
+
currentIndex = 0;
|
|
1185
|
+
var hooks = currentComponent.__H;
|
|
1186
|
+
if (hooks) {
|
|
1187
|
+
if (previousComponent === currentComponent) {
|
|
1188
|
+
hooks.__h = [];
|
|
1189
|
+
currentComponent.__h = [];
|
|
1190
|
+
hooks.__.forEach(function (hookItem) {
|
|
1191
|
+
if (hookItem.__N) {
|
|
1192
|
+
hookItem.__ = hookItem.__N;
|
|
1193
|
+
}
|
|
1194
|
+
hookItem.__V = EMPTY;
|
|
1195
|
+
hookItem.__N = hookItem._pendingArgs = undefined;
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
else {
|
|
1199
|
+
hooks.__h.forEach(invokeCleanup);
|
|
1200
|
+
hooks.__h.forEach(invokeEffect);
|
|
1201
|
+
hooks.__h = [];
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
previousComponent = currentComponent;
|
|
1205
|
+
};
|
|
1206
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.diffed = function (vnode) {
|
|
1207
|
+
if (oldAfterDiff) oldAfterDiff(vnode);
|
|
1208
|
+
var c = vnode.__c;
|
|
1209
|
+
if (c && c.__H) {
|
|
1210
|
+
if (c.__H.__h.length) afterPaint(afterPaintEffects.push(c));
|
|
1211
|
+
c.__H.__.forEach(function (hookItem) {
|
|
1212
|
+
if (hookItem._pendingArgs) {
|
|
1213
|
+
hookItem.__H = hookItem._pendingArgs;
|
|
1214
|
+
}
|
|
1215
|
+
if (hookItem.__V !== EMPTY) {
|
|
1216
|
+
hookItem.__ = hookItem.__V;
|
|
1217
|
+
}
|
|
1218
|
+
hookItem._pendingArgs = undefined;
|
|
1219
|
+
hookItem.__V = EMPTY;
|
|
1220
|
+
});
|
|
1221
|
+
}
|
|
1222
|
+
previousComponent = currentComponent = null;
|
|
1223
|
+
};
|
|
1224
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__c = function (
|
|
1225
|
+
vnode,
|
|
1226
|
+
commitQueue
|
|
1227
|
+
) {
|
|
1228
|
+
commitQueue.some(function (component) {
|
|
1229
|
+
try {
|
|
1230
|
+
component.__h.forEach(invokeCleanup);
|
|
1231
|
+
component.__h = component.__h.filter(function (cb) {
|
|
1232
|
+
return cb.__ ? invokeEffect(cb) : true;
|
|
1233
|
+
});
|
|
1234
|
+
}
|
|
1235
|
+
catch (e) {
|
|
1236
|
+
commitQueue.some(function (c) {
|
|
1237
|
+
if (c.__h) c.__h = [];
|
|
1238
|
+
});
|
|
1239
|
+
commitQueue = [];
|
|
1240
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__e(e, component.__v);
|
|
1241
|
+
}
|
|
1242
|
+
});
|
|
1243
|
+
if (oldCommit) oldCommit(vnode, commitQueue);
|
|
1244
|
+
};
|
|
1245
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.unmount = function (vnode) {
|
|
1246
|
+
if (oldBeforeUnmount) oldBeforeUnmount(vnode);
|
|
1247
|
+
var c = vnode.__c;
|
|
1248
|
+
if (c && c.__H) {
|
|
1249
|
+
var hasErrored;
|
|
1250
|
+
c.__H.__.forEach(function (s) {
|
|
1251
|
+
try {
|
|
1252
|
+
invokeCleanup(s);
|
|
1253
|
+
}
|
|
1254
|
+
catch (e) {
|
|
1255
|
+
hasErrored = e;
|
|
1256
|
+
}
|
|
1257
|
+
});
|
|
1258
|
+
c.__H = undefined;
|
|
1259
|
+
if (hasErrored)
|
|
1260
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__e(hasErrored, c.__v);
|
|
1261
|
+
}
|
|
1262
|
+
};
|
|
1263
|
+
|
|
1264
|
+
/**
|
|
1265
|
+
* Get a hook's state from the currentComponent
|
|
1266
|
+
* @param {number} index The index of the hook to get
|
|
1267
|
+
* @param {number} type The index of the hook to get
|
|
1268
|
+
* @returns {any}
|
|
1269
|
+
*/
|
|
1270
|
+
function getHookState(index, type) {
|
|
1271
|
+
if (preact__WEBPACK_IMPORTED_MODULE_0__.options.__h) {
|
|
1272
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__h(
|
|
1273
|
+
currentComponent,
|
|
1274
|
+
index,
|
|
1275
|
+
currentHook || type
|
|
1276
|
+
);
|
|
1277
|
+
}
|
|
1278
|
+
currentHook = 0;
|
|
1279
|
+
|
|
1280
|
+
// Largely inspired by:
|
|
1281
|
+
// * https://github.com/michael-klein/funcy.js/blob/f6be73468e6ec46b0ff5aa3cc4c9baf72a29025a/src/hooks/core_hooks.mjs
|
|
1282
|
+
// * https://github.com/michael-klein/funcy.js/blob/650beaa58c43c33a74820a3c98b3c7079cf2e333/src/renderer.mjs
|
|
1283
|
+
// Other implementations to look at:
|
|
1284
|
+
// * https://codesandbox.io/s/mnox05qp8
|
|
1285
|
+
var hooks =
|
|
1286
|
+
currentComponent.__H ||
|
|
1287
|
+
(currentComponent.__H = {
|
|
1288
|
+
__: [],
|
|
1289
|
+
__h: [],
|
|
1290
|
+
});
|
|
1291
|
+
if (index >= hooks.__.length) {
|
|
1292
|
+
hooks.__.push({
|
|
1293
|
+
__V: EMPTY,
|
|
1294
|
+
});
|
|
1295
|
+
}
|
|
1296
|
+
return hooks.__[index];
|
|
1297
|
+
}
|
|
1298
|
+
|
|
1299
|
+
/**
|
|
1300
|
+
* @param {import('./index').StateUpdater<any>} [initialState]
|
|
1301
|
+
*/
|
|
1302
|
+
function useState(initialState) {
|
|
1303
|
+
currentHook = 1;
|
|
1304
|
+
return useReducer(invokeOrReturn, initialState);
|
|
1305
|
+
}
|
|
1306
|
+
|
|
1307
|
+
/**
|
|
1308
|
+
* @param {import('./index').Reducer<any, any>} reducer
|
|
1309
|
+
* @param {import('./index').StateUpdater<any>} initialState
|
|
1310
|
+
* @param {(initialState: any) => void} [init]
|
|
1311
|
+
* @returns {[ any, (state: any) => void ]}
|
|
1312
|
+
*/
|
|
1313
|
+
function useReducer(reducer, initialState, init) {
|
|
1314
|
+
/** @type {import('./internal').ReducerHookState} */
|
|
1315
|
+
var hookState = getHookState(currentIndex++, 2);
|
|
1316
|
+
hookState._reducer = reducer;
|
|
1317
|
+
if (!hookState.__c) {
|
|
1318
|
+
hookState.__ = [
|
|
1319
|
+
!init
|
|
1320
|
+
? invokeOrReturn(undefined, initialState)
|
|
1321
|
+
: init(initialState),
|
|
1322
|
+
function (action) {
|
|
1323
|
+
var currentValue = hookState.__N
|
|
1324
|
+
? hookState.__N[0]
|
|
1325
|
+
: hookState.__[0];
|
|
1326
|
+
var nextValue = hookState._reducer(currentValue, action);
|
|
1327
|
+
if (currentValue !== nextValue) {
|
|
1328
|
+
hookState.__N = [nextValue, hookState.__[1]];
|
|
1329
|
+
hookState.__c.setState({});
|
|
1330
|
+
}
|
|
1331
|
+
},
|
|
1332
|
+
];
|
|
1333
|
+
hookState.__c = currentComponent;
|
|
1334
|
+
if (!currentComponent._hasScuFromHooks) {
|
|
1335
|
+
currentComponent._hasScuFromHooks = true;
|
|
1336
|
+
var prevScu = currentComponent.shouldComponentUpdate;
|
|
1337
|
+
|
|
1338
|
+
// This SCU has the purpose of bailing out after repeated updates
|
|
1339
|
+
// to stateful hooks.
|
|
1340
|
+
// we store the next value in _nextValue[0] and keep doing that for all
|
|
1341
|
+
// state setters, if we have next states and
|
|
1342
|
+
// all next states within a component end up being equal to their original state
|
|
1343
|
+
// we are safe to bail out for this specific component.
|
|
1344
|
+
currentComponent.shouldComponentUpdate = function (p, s, c) {
|
|
1345
|
+
if (!hookState.__c.__H) return true;
|
|
1346
|
+
var stateHooks = hookState.__c.__H.__.filter(function (x) {
|
|
1347
|
+
return x.__c;
|
|
1348
|
+
});
|
|
1349
|
+
var allHooksEmpty = stateHooks.every(function (x) {
|
|
1350
|
+
return !x.__N;
|
|
1351
|
+
});
|
|
1352
|
+
// When we have no updated hooks in the component we invoke the previous SCU or
|
|
1353
|
+
// traverse the VDOM tree further.
|
|
1354
|
+
if (allHooksEmpty) {
|
|
1355
|
+
return prevScu ? prevScu.call(this, p, s, c) : true;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
// We check whether we have components with a nextValue set that
|
|
1359
|
+
// have values that aren't equal to one another this pushes
|
|
1360
|
+
// us to update further down the tree
|
|
1361
|
+
var shouldUpdate = false;
|
|
1362
|
+
stateHooks.forEach(function (hookItem) {
|
|
1363
|
+
if (hookItem.__N) {
|
|
1364
|
+
var currentValue = hookItem.__[0];
|
|
1365
|
+
hookItem.__ = hookItem.__N;
|
|
1366
|
+
hookItem.__N = undefined;
|
|
1367
|
+
if (currentValue !== hookItem.__[0]) shouldUpdate = true;
|
|
1368
|
+
}
|
|
1369
|
+
});
|
|
1370
|
+
return shouldUpdate || hookState.__c.props !== p
|
|
1371
|
+
? prevScu
|
|
1372
|
+
? prevScu.call(this, p, s, c)
|
|
1373
|
+
: true
|
|
1374
|
+
: false;
|
|
1375
|
+
};
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1378
|
+
return hookState.__N || hookState.__;
|
|
1379
|
+
}
|
|
1380
|
+
|
|
1381
|
+
/**
|
|
1382
|
+
* @param {import('./internal').Effect} callback
|
|
1383
|
+
* @param {any[]} args
|
|
1384
|
+
*/
|
|
1385
|
+
function useEffect(callback, args) {
|
|
1386
|
+
/** @type {import('./internal').EffectHookState} */
|
|
1387
|
+
var state = getHookState(currentIndex++, 3);
|
|
1388
|
+
if (
|
|
1389
|
+
!preact__WEBPACK_IMPORTED_MODULE_0__.options.__s &&
|
|
1390
|
+
argsChanged(state.__H, args)
|
|
1391
|
+
) {
|
|
1392
|
+
state.__ = callback;
|
|
1393
|
+
state._pendingArgs = args;
|
|
1394
|
+
currentComponent.__H.__h.push(state);
|
|
1395
|
+
}
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
/**
|
|
1399
|
+
* @param {import('./internal').Effect} callback
|
|
1400
|
+
* @param {any[]} args
|
|
1401
|
+
*/
|
|
1402
|
+
function useLayoutEffect(callback, args) {
|
|
1403
|
+
/** @type {import('./internal').EffectHookState} */
|
|
1404
|
+
var state = getHookState(currentIndex++, 4);
|
|
1405
|
+
if (
|
|
1406
|
+
!preact__WEBPACK_IMPORTED_MODULE_0__.options.__s &&
|
|
1407
|
+
argsChanged(state.__H, args)
|
|
1408
|
+
) {
|
|
1409
|
+
state.__ = callback;
|
|
1410
|
+
state._pendingArgs = args;
|
|
1411
|
+
currentComponent.__h.push(state);
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
function useRef(initialValue) {
|
|
1415
|
+
currentHook = 5;
|
|
1416
|
+
return useMemo(function () {
|
|
1417
|
+
return {
|
|
1418
|
+
current: initialValue,
|
|
1419
|
+
};
|
|
1420
|
+
}, []);
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1423
|
+
/**
|
|
1424
|
+
* @param {object} ref
|
|
1425
|
+
* @param {() => object} createHandle
|
|
1426
|
+
* @param {any[]} args
|
|
1427
|
+
*/
|
|
1428
|
+
function useImperativeHandle(ref, createHandle, args) {
|
|
1429
|
+
currentHook = 6;
|
|
1430
|
+
useLayoutEffect(
|
|
1431
|
+
function () {
|
|
1432
|
+
if (typeof ref == 'function') {
|
|
1433
|
+
ref(createHandle());
|
|
1434
|
+
return function () {
|
|
1435
|
+
return ref(null);
|
|
1436
|
+
};
|
|
1437
|
+
}
|
|
1438
|
+
else if (ref) {
|
|
1439
|
+
ref.current = createHandle();
|
|
1440
|
+
return function () {
|
|
1441
|
+
return (ref.current = null);
|
|
1442
|
+
};
|
|
1443
|
+
}
|
|
1444
|
+
},
|
|
1445
|
+
args == null ? args : args.concat(ref)
|
|
1446
|
+
);
|
|
1447
|
+
}
|
|
1448
|
+
|
|
1449
|
+
/**
|
|
1450
|
+
* @param {() => any} factory
|
|
1451
|
+
* @param {any[]} args
|
|
1452
|
+
*/
|
|
1453
|
+
function useMemo(factory, args) {
|
|
1454
|
+
/** @type {import('./internal').MemoHookState} */
|
|
1455
|
+
var state = getHookState(currentIndex++, 7);
|
|
1456
|
+
if (argsChanged(state.__H, args)) {
|
|
1457
|
+
state.__V = factory();
|
|
1458
|
+
state._pendingArgs = args;
|
|
1459
|
+
state.__h = factory;
|
|
1460
|
+
return state.__V;
|
|
1461
|
+
}
|
|
1462
|
+
return state.__;
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* @param {() => void} callback
|
|
1467
|
+
* @param {any[]} args
|
|
1468
|
+
*/
|
|
1469
|
+
function useCallback(callback, args) {
|
|
1470
|
+
currentHook = 8;
|
|
1471
|
+
return useMemo(function () {
|
|
1472
|
+
return callback;
|
|
1473
|
+
}, args);
|
|
1474
|
+
}
|
|
1475
|
+
|
|
1476
|
+
/**
|
|
1477
|
+
* @param {import('./internal').PreactContext} context
|
|
1478
|
+
*/
|
|
1479
|
+
function useContext(context) {
|
|
1480
|
+
var provider = currentComponent.context[context.__c];
|
|
1481
|
+
// We could skip this call here, but than we'd not call
|
|
1482
|
+
// `options._hook`. We need to do that in order to make
|
|
1483
|
+
// the devtools aware of this hook.
|
|
1484
|
+
/** @type {import('./internal').ContextHookState} */
|
|
1485
|
+
var state = getHookState(currentIndex++, 9);
|
|
1486
|
+
// The devtools needs access to the context object to
|
|
1487
|
+
// be able to pull of the default value when no provider
|
|
1488
|
+
// is present in the tree.
|
|
1489
|
+
state.c = context;
|
|
1490
|
+
if (!provider) return context.__;
|
|
1491
|
+
// This is probably not safe to convert to "!"
|
|
1492
|
+
if (state.__ == null) {
|
|
1493
|
+
state.__ = true;
|
|
1494
|
+
provider.sub(currentComponent);
|
|
1495
|
+
}
|
|
1496
|
+
return provider.props.value;
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
/**
|
|
1500
|
+
* Display a custom label for a custom hook for the devtools panel
|
|
1501
|
+
* @type {<T>(value: T, cb?: (value: T) => string | number) => void}
|
|
1502
|
+
*/
|
|
1503
|
+
function useDebugValue(value, formatter) {
|
|
1504
|
+
if (preact__WEBPACK_IMPORTED_MODULE_0__.options.useDebugValue) {
|
|
1505
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.useDebugValue(
|
|
1506
|
+
formatter ? formatter(value) : value
|
|
1507
|
+
);
|
|
1508
|
+
}
|
|
1509
|
+
}
|
|
1510
|
+
|
|
1511
|
+
/**
|
|
1512
|
+
* @param {(error: any, errorInfo: import('preact').ErrorInfo) => void} cb
|
|
1513
|
+
*/
|
|
1514
|
+
function useErrorBoundary(cb) {
|
|
1515
|
+
/** @type {import('./internal').ErrorBoundaryHookState} */
|
|
1516
|
+
var state = getHookState(currentIndex++, 10);
|
|
1517
|
+
var errState = useState();
|
|
1518
|
+
state.__ = cb;
|
|
1519
|
+
if (!currentComponent.componentDidCatch) {
|
|
1520
|
+
currentComponent.componentDidCatch = function (err, errorInfo) {
|
|
1521
|
+
if (state.__) state.__(err, errorInfo);
|
|
1522
|
+
errState[1](err);
|
|
1523
|
+
};
|
|
1524
|
+
}
|
|
1525
|
+
return [
|
|
1526
|
+
errState[0],
|
|
1527
|
+
function () {
|
|
1528
|
+
errState[1](undefined);
|
|
1529
|
+
},
|
|
1530
|
+
];
|
|
1531
|
+
}
|
|
1532
|
+
function useId() {
|
|
1533
|
+
var state = getHookState(currentIndex++, 11);
|
|
1534
|
+
if (!state.__) {
|
|
1535
|
+
// Grab either the root node or the nearest async boundary node.
|
|
1536
|
+
/** @type {import('./internal.d').VNode} */
|
|
1537
|
+
var root = currentComponent.__v;
|
|
1538
|
+
while (root !== null && !root.__m && root.__ !== null) {
|
|
1539
|
+
root = root.__;
|
|
1540
|
+
}
|
|
1541
|
+
var mask = root.__m || (root.__m = [0, 0]);
|
|
1542
|
+
state.__ = 'P' + mask[0] + '-' + mask[1]++;
|
|
1543
|
+
}
|
|
1544
|
+
return state.__;
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* After paint effects consumer.
|
|
1548
|
+
*/
|
|
1549
|
+
function flushAfterPaintEffects() {
|
|
1550
|
+
var component;
|
|
1551
|
+
while ((component = afterPaintEffects.shift())) {
|
|
1552
|
+
if (!component.__P || !component.__H) continue;
|
|
1553
|
+
try {
|
|
1554
|
+
component.__H.__h.forEach(invokeCleanup);
|
|
1555
|
+
component.__H.__h.forEach(invokeEffect);
|
|
1556
|
+
component.__H.__h = [];
|
|
1557
|
+
}
|
|
1558
|
+
catch (e) {
|
|
1559
|
+
component.__H.__h = [];
|
|
1560
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.__e(e, component.__v);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
var HAS_RAF = typeof requestAnimationFrame == 'function';
|
|
1565
|
+
|
|
1566
|
+
/**
|
|
1567
|
+
* Schedule a callback to be invoked after the browser has a chance to paint a new frame.
|
|
1568
|
+
* Do this by combining requestAnimationFrame (rAF) + setTimeout to invoke a callback after
|
|
1569
|
+
* the next browser frame.
|
|
1570
|
+
*
|
|
1571
|
+
* Also, schedule a timeout in parallel to the the rAF to ensure the callback is invoked
|
|
1572
|
+
* even if RAF doesn't fire (for example if the browser tab is not visible)
|
|
1573
|
+
*
|
|
1574
|
+
* @param {() => void} callback
|
|
1575
|
+
*/
|
|
1576
|
+
function afterNextFrame(callback) {
|
|
1577
|
+
var done = function done() {
|
|
1578
|
+
clearTimeout(timeout);
|
|
1579
|
+
if (HAS_RAF) cancelAnimationFrame(raf);
|
|
1580
|
+
setTimeout(callback);
|
|
1581
|
+
};
|
|
1582
|
+
var timeout = setTimeout(done, RAF_TIMEOUT);
|
|
1583
|
+
var raf;
|
|
1584
|
+
if (HAS_RAF) {
|
|
1585
|
+
raf = requestAnimationFrame(done);
|
|
1586
|
+
}
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
// Note: if someone used options.debounceRendering = requestAnimationFrame,
|
|
1590
|
+
// then effects will ALWAYS run on the NEXT frame instead of the current one, incurring a ~16ms delay.
|
|
1591
|
+
// Perhaps this is not such a big deal.
|
|
1592
|
+
/**
|
|
1593
|
+
* Schedule afterPaintEffects flush after the browser paints
|
|
1594
|
+
* @param {number} newQueueLength
|
|
1595
|
+
*/
|
|
1596
|
+
function afterPaint(newQueueLength) {
|
|
1597
|
+
if (
|
|
1598
|
+
newQueueLength === 1 ||
|
|
1599
|
+
prevRaf !==
|
|
1600
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.requestAnimationFrame
|
|
1601
|
+
) {
|
|
1602
|
+
prevRaf =
|
|
1603
|
+
preact__WEBPACK_IMPORTED_MODULE_0__.options.requestAnimationFrame;
|
|
1604
|
+
(prevRaf || afterNextFrame)(flushAfterPaintEffects);
|
|
1605
|
+
}
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
/**
|
|
1609
|
+
* @param {import('./internal').EffectHookState} hook
|
|
1610
|
+
*/
|
|
1611
|
+
function invokeCleanup(hook) {
|
|
1612
|
+
// A hook cleanup can introduce a call to render which creates a new root, this will call options.vnode
|
|
1613
|
+
// and move the currentComponent away.
|
|
1614
|
+
var comp = currentComponent;
|
|
1615
|
+
var cleanup = hook.__c;
|
|
1616
|
+
if (typeof cleanup == 'function') {
|
|
1617
|
+
hook.__c = undefined;
|
|
1618
|
+
cleanup();
|
|
1619
|
+
}
|
|
1620
|
+
currentComponent = comp;
|
|
1621
|
+
}
|
|
1622
|
+
|
|
1623
|
+
/**
|
|
1624
|
+
* Invoke a Hook's effect
|
|
1625
|
+
* @param {import('./internal').EffectHookState} hook
|
|
1626
|
+
*/
|
|
1627
|
+
function invokeEffect(hook) {
|
|
1628
|
+
// A hook call can introduce a call to render which creates a new root, this will call options.vnode
|
|
1629
|
+
// and move the currentComponent away.
|
|
1630
|
+
var comp = currentComponent;
|
|
1631
|
+
hook.__c = hook.__();
|
|
1632
|
+
currentComponent = comp;
|
|
1633
|
+
}
|
|
1634
|
+
|
|
1635
|
+
/**
|
|
1636
|
+
* @param {any[]} oldArgs
|
|
1637
|
+
* @param {any[]} newArgs
|
|
1638
|
+
*/
|
|
1639
|
+
function argsChanged(oldArgs, newArgs) {
|
|
1640
|
+
return (
|
|
1641
|
+
!oldArgs ||
|
|
1642
|
+
oldArgs.length !== newArgs.length ||
|
|
1643
|
+
newArgs.some(function (arg, index) {
|
|
1644
|
+
return arg !== oldArgs[index];
|
|
1645
|
+
})
|
|
1646
|
+
);
|
|
1647
|
+
}
|
|
1648
|
+
function invokeOrReturn(arg, f) {
|
|
1649
|
+
return typeof f == 'function' ? f(arg) : f;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/***/
|
|
1653
|
+
},
|
|
1654
|
+
|
|
1655
|
+
/***/ './src/clone-element.js':
|
|
1656
|
+
/*!******************************!*\
|
|
1657
|
+
!*** ./src/clone-element.js ***!
|
|
1658
|
+
\******************************/
|
|
1659
|
+
/***/ (
|
|
1660
|
+
__unused_webpack_module,
|
|
1661
|
+
__webpack_exports__,
|
|
1662
|
+
__webpack_require__
|
|
1663
|
+
) => {
|
|
1664
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1665
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1666
|
+
/* harmony export */ cloneElement: () => /* binding */ cloneElement,
|
|
1667
|
+
/* harmony export */
|
|
1668
|
+
});
|
|
1669
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ =
|
|
1670
|
+
__webpack_require__(/*! ./util */ './src/util.js');
|
|
1671
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_1__ =
|
|
1672
|
+
__webpack_require__(/*! ./create-element */ './src/create-element.js');
|
|
1673
|
+
|
|
1674
|
+
/**
|
|
1675
|
+
* Clones the given VNode, optionally adding attributes/props and replacing its children.
|
|
1676
|
+
* @param {import('./internal').VNode} vnode The virtual DOM element to clone
|
|
1677
|
+
* @param {object} props Attributes/props to add when cloning
|
|
1678
|
+
* @param {Array<import('./internal').ComponentChildren>} rest Any additional arguments will be used as replacement children.
|
|
1679
|
+
* @returns {import('./internal').VNode}
|
|
1680
|
+
*/
|
|
1681
|
+
function cloneElement(vnode, props, children) {
|
|
1682
|
+
var normalizedProps = (0, _util__WEBPACK_IMPORTED_MODULE_0__.assign)(
|
|
1683
|
+
{},
|
|
1684
|
+
vnode.props
|
|
1685
|
+
),
|
|
1686
|
+
key,
|
|
1687
|
+
ref,
|
|
1688
|
+
i;
|
|
1689
|
+
for (i in props) {
|
|
1690
|
+
if (i == 'key') key = props[i];
|
|
1691
|
+
else if (i == 'ref') ref = props[i];
|
|
1692
|
+
else normalizedProps[i] = props[i];
|
|
1693
|
+
}
|
|
1694
|
+
if (arguments.length > 2) {
|
|
1695
|
+
normalizedProps.children =
|
|
1696
|
+
arguments.length > 3
|
|
1697
|
+
? _util__WEBPACK_IMPORTED_MODULE_0__.slice.call(arguments, 2)
|
|
1698
|
+
: children;
|
|
1699
|
+
}
|
|
1700
|
+
return (0, _create_element__WEBPACK_IMPORTED_MODULE_1__.createVNode)(
|
|
1701
|
+
vnode.type,
|
|
1702
|
+
normalizedProps,
|
|
1703
|
+
key || vnode.key,
|
|
1704
|
+
ref || vnode.ref,
|
|
1705
|
+
null
|
|
1706
|
+
);
|
|
1707
|
+
}
|
|
1708
|
+
|
|
1709
|
+
/***/
|
|
1710
|
+
},
|
|
1711
|
+
|
|
1712
|
+
/***/ './src/component.js':
|
|
1713
|
+
/*!**************************!*\
|
|
1714
|
+
!*** ./src/component.js ***!
|
|
1715
|
+
\**************************/
|
|
1716
|
+
/***/ (
|
|
1717
|
+
__unused_webpack_module,
|
|
1718
|
+
__webpack_exports__,
|
|
1719
|
+
__webpack_require__
|
|
1720
|
+
) => {
|
|
1721
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1722
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1723
|
+
/* harmony export */ Component: () => /* binding */ Component,
|
|
1724
|
+
/* harmony export */ enqueueRender: () => /* binding */ enqueueRender,
|
|
1725
|
+
/* harmony export */ getDomSibling: () => /* binding */ getDomSibling,
|
|
1726
|
+
/* harmony export */
|
|
1727
|
+
});
|
|
1728
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ =
|
|
1729
|
+
__webpack_require__(/*! ./util */ './src/util.js');
|
|
1730
|
+
/* harmony import */ var _diff_index__WEBPACK_IMPORTED_MODULE_1__ =
|
|
1731
|
+
__webpack_require__(/*! ./diff/index */ './src/diff/index.js');
|
|
1732
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_2__ =
|
|
1733
|
+
__webpack_require__(/*! ./options */ './src/options.js');
|
|
1734
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_3__ =
|
|
1735
|
+
__webpack_require__(/*! ./create-element */ './src/create-element.js');
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Base Component class. Provides `setState()` and `forceUpdate()`, which
|
|
1739
|
+
* trigger rendering
|
|
1740
|
+
* @param {object} props The initial component props
|
|
1741
|
+
* @param {object} context The initial context from parent components'
|
|
1742
|
+
* getChildContext
|
|
1743
|
+
*/
|
|
1744
|
+
function Component(props, context) {
|
|
1745
|
+
this.props = props;
|
|
1746
|
+
this.context = context;
|
|
1747
|
+
}
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Update component state and schedule a re-render.
|
|
1751
|
+
* @this {import('./internal').Component}
|
|
1752
|
+
* @param {object | ((s: object, p: object) => object)} update A hash of state
|
|
1753
|
+
* properties to update with new values or a function that given the current
|
|
1754
|
+
* state and props returns a new partial state
|
|
1755
|
+
* @param {() => void} [callback] A function to be called once component state is
|
|
1756
|
+
* updated
|
|
1757
|
+
*/
|
|
1758
|
+
Component.prototype.setState = function (update, callback) {
|
|
1759
|
+
// only clone state when copying to nextState the first time.
|
|
1760
|
+
var s;
|
|
1761
|
+
if (this.__s != null && this.__s !== this.state) {
|
|
1762
|
+
s = this.__s;
|
|
1763
|
+
}
|
|
1764
|
+
else {
|
|
1765
|
+
s = this.__s = (0, _util__WEBPACK_IMPORTED_MODULE_0__.assign)(
|
|
1766
|
+
{},
|
|
1767
|
+
this.state
|
|
1768
|
+
);
|
|
1769
|
+
}
|
|
1770
|
+
if (typeof update == 'function') {
|
|
1771
|
+
// Some libraries like `immer` mark the current state as readonly,
|
|
1772
|
+
// preventing us from mutating it, so we need to clone it. See #2716
|
|
1773
|
+
update = update(
|
|
1774
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_0__.assign)({}, s),
|
|
1775
|
+
this.props
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
if (update) {
|
|
1779
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_0__.assign)(s, update);
|
|
1780
|
+
}
|
|
1781
|
+
|
|
1782
|
+
// Skip update if updater function returned null
|
|
1783
|
+
if (update == null) return;
|
|
1784
|
+
if (this.__v) {
|
|
1785
|
+
if (callback) {
|
|
1786
|
+
this._sb.push(callback);
|
|
1787
|
+
}
|
|
1788
|
+
enqueueRender(this);
|
|
1789
|
+
}
|
|
1790
|
+
};
|
|
1791
|
+
|
|
1792
|
+
/**
|
|
1793
|
+
* Immediately perform a synchronous re-render of the component
|
|
1794
|
+
* @this {import('./internal').Component}
|
|
1795
|
+
* @param {() => void} [callback] A function to be called after component is
|
|
1796
|
+
* re-rendered
|
|
1797
|
+
*/
|
|
1798
|
+
Component.prototype.forceUpdate = function (callback) {
|
|
1799
|
+
if (this.__v) {
|
|
1800
|
+
// Set render mode so that we can differentiate where the render request
|
|
1801
|
+
// is coming from. We need this because forceUpdate should never call
|
|
1802
|
+
// shouldComponentUpdate
|
|
1803
|
+
this.__e = true;
|
|
1804
|
+
if (callback) this.__h.push(callback);
|
|
1805
|
+
enqueueRender(this);
|
|
1806
|
+
}
|
|
1807
|
+
};
|
|
1808
|
+
|
|
1809
|
+
/**
|
|
1810
|
+
* Accepts `props` and `state`, and returns a new Virtual DOM tree to build.
|
|
1811
|
+
* Virtual DOM is generally constructed via [JSX](http://jasonformat.com/wtf-is-jsx).
|
|
1812
|
+
* @param {object} props Props (eg: JSX attributes) received from parent
|
|
1813
|
+
* element/component
|
|
1814
|
+
* @param {object} state The component's current state
|
|
1815
|
+
* @param {object} context Context object, as returned by the nearest
|
|
1816
|
+
* ancestor's `getChildContext()`
|
|
1817
|
+
* @returns {import('./index').ComponentChildren | void}
|
|
1818
|
+
*/
|
|
1819
|
+
Component.prototype.render =
|
|
1820
|
+
_create_element__WEBPACK_IMPORTED_MODULE_3__.Fragment;
|
|
1821
|
+
|
|
1822
|
+
/**
|
|
1823
|
+
* @param {import('./internal').VNode} vnode
|
|
1824
|
+
* @param {number | null} [childIndex]
|
|
1825
|
+
*/
|
|
1826
|
+
function getDomSibling(vnode, childIndex) {
|
|
1827
|
+
if (childIndex == null) {
|
|
1828
|
+
// Use childIndex==null as a signal to resume the search from the vnode's sibling
|
|
1829
|
+
return vnode.__
|
|
1830
|
+
? getDomSibling(vnode.__, vnode.__.__k.indexOf(vnode) + 1)
|
|
1831
|
+
: null;
|
|
1832
|
+
}
|
|
1833
|
+
var sibling;
|
|
1834
|
+
for (; childIndex < vnode.__k.length; childIndex++) {
|
|
1835
|
+
sibling = vnode.__k[childIndex];
|
|
1836
|
+
if (sibling != null && sibling.__e != null) {
|
|
1837
|
+
// Since updateParentDomPointers keeps _dom pointer correct,
|
|
1838
|
+
// we can rely on _dom to tell us if this subtree contains a
|
|
1839
|
+
// rendered DOM node, and what the first rendered DOM node is
|
|
1840
|
+
return sibling.__e;
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
// If we get here, we have not found a DOM node in this vnode's children.
|
|
1845
|
+
// We must resume from this vnode's sibling (in it's parent _children array)
|
|
1846
|
+
// Only climb up and search the parent if we aren't searching through a DOM
|
|
1847
|
+
// VNode (meaning we reached the DOM parent of the original vnode that began
|
|
1848
|
+
// the search)
|
|
1849
|
+
return typeof vnode.type == 'function' ? getDomSibling(vnode) : null;
|
|
1850
|
+
}
|
|
1851
|
+
|
|
1852
|
+
/**
|
|
1853
|
+
* Trigger in-place re-rendering of a component.
|
|
1854
|
+
* @param {import('./internal').Component} component The component to rerender
|
|
1855
|
+
*/
|
|
1856
|
+
function renderComponent(component) {
|
|
1857
|
+
var vnode = component.__v,
|
|
1858
|
+
oldDom = vnode.__e,
|
|
1859
|
+
parentDom = component.__P;
|
|
1860
|
+
var onRenderComponent =
|
|
1861
|
+
_options__WEBPACK_IMPORTED_MODULE_2__['default'].onRenderComponent;
|
|
1862
|
+
if (onRenderComponent) onRenderComponent(component, 'begin');
|
|
1863
|
+
if (parentDom) {
|
|
1864
|
+
var commitQueue = [];
|
|
1865
|
+
var oldVNode = (0, _util__WEBPACK_IMPORTED_MODULE_0__.assign)(
|
|
1866
|
+
{},
|
|
1867
|
+
vnode
|
|
1868
|
+
);
|
|
1869
|
+
oldVNode.__v = vnode.__v + 1;
|
|
1870
|
+
(0, _diff_index__WEBPACK_IMPORTED_MODULE_1__.diff)(
|
|
1871
|
+
parentDom,
|
|
1872
|
+
vnode,
|
|
1873
|
+
oldVNode,
|
|
1874
|
+
component.__n,
|
|
1875
|
+
parentDom.ownerSVGElement !== undefined,
|
|
1876
|
+
vnode.__h != null ? [oldDom] : null,
|
|
1877
|
+
commitQueue,
|
|
1878
|
+
oldDom == null ? getDomSibling(vnode) : oldDom,
|
|
1879
|
+
vnode.__h
|
|
1880
|
+
);
|
|
1881
|
+
(0, _diff_index__WEBPACK_IMPORTED_MODULE_1__.commitRoot)(
|
|
1882
|
+
commitQueue,
|
|
1883
|
+
vnode
|
|
1884
|
+
);
|
|
1885
|
+
if (vnode.__e != oldDom) {
|
|
1886
|
+
updateParentDomPointers(vnode);
|
|
1887
|
+
}
|
|
1888
|
+
}
|
|
1889
|
+
if (onRenderComponent) onRenderComponent(component, 'end');
|
|
1890
|
+
}
|
|
1891
|
+
|
|
1892
|
+
/**
|
|
1893
|
+
* @param {import('./internal').VNode} vnode
|
|
1894
|
+
*/
|
|
1895
|
+
function updateParentDomPointers(vnode) {
|
|
1896
|
+
if ((vnode = vnode.__) != null && vnode.__c != null) {
|
|
1897
|
+
vnode.__e = vnode.__c.base = null;
|
|
1898
|
+
for (var i = 0; i < vnode.__k.length; i++) {
|
|
1899
|
+
var child = vnode.__k[i];
|
|
1900
|
+
if (child != null && child.__e != null) {
|
|
1901
|
+
vnode.__e = vnode.__c.base = child.__e;
|
|
1902
|
+
break;
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
return updateParentDomPointers(vnode);
|
|
1906
|
+
}
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1909
|
+
/**
|
|
1910
|
+
* The render queue
|
|
1911
|
+
* @type {Array<import('./internal').Component>}
|
|
1912
|
+
*/
|
|
1913
|
+
var rerenderQueue = [];
|
|
1914
|
+
|
|
1915
|
+
/*
|
|
1916
|
+
* The value of `Component.debounce` must asynchronously invoke the passed in callback. It is
|
|
1917
|
+
* important that contributors to Preact can consistently reason about what calls to `setState`, etc.
|
|
1918
|
+
* do, and when their effects will be applied. See the links below for some further reading on designing
|
|
1919
|
+
* asynchronous APIs.
|
|
1920
|
+
* * [Designing APIs for Asynchrony](https://blog.izs.me/2013/08/designing-apis-for-asynchrony)
|
|
1921
|
+
* * [Callbacks synchronous and asynchronous](https://blog.ometer.com/2011/07/24/callbacks-synchronous-and-asynchronous/)
|
|
1922
|
+
*/
|
|
1923
|
+
|
|
1924
|
+
var prevDebounce;
|
|
1925
|
+
|
|
1926
|
+
/**
|
|
1927
|
+
* Enqueue a rerender of a component
|
|
1928
|
+
* @param {import('./internal').Component} c The component to rerender
|
|
1929
|
+
*/
|
|
1930
|
+
function enqueueRender(c) {
|
|
1931
|
+
if (
|
|
1932
|
+
(!c.__d &&
|
|
1933
|
+
(c.__d = true) &&
|
|
1934
|
+
rerenderQueue.push(c) &&
|
|
1935
|
+
!process.__r++) ||
|
|
1936
|
+
prevDebounce !==
|
|
1937
|
+
_options__WEBPACK_IMPORTED_MODULE_2__['default'].debounceRendering
|
|
1938
|
+
) {
|
|
1939
|
+
prevDebounce =
|
|
1940
|
+
_options__WEBPACK_IMPORTED_MODULE_2__['default'].debounceRendering;
|
|
1941
|
+
(prevDebounce || setTimeout)(process);
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
|
|
1945
|
+
/** Flush the render queue by rerendering all queued components */
|
|
1946
|
+
function process() {
|
|
1947
|
+
var queue;
|
|
1948
|
+
while ((process.__r = rerenderQueue.length)) {
|
|
1949
|
+
queue = rerenderQueue.sort(function (a, b) {
|
|
1950
|
+
return a.__v.__b - b.__v.__b;
|
|
1951
|
+
});
|
|
1952
|
+
rerenderQueue = [];
|
|
1953
|
+
// Don't update `renderCount` yet. Keep its value non-zero to prevent unnecessary
|
|
1954
|
+
// process() calls from getting scheduled while `queue` is still being consumed.
|
|
1955
|
+
queue.some(function (c) {
|
|
1956
|
+
if (c.__d) renderComponent(c);
|
|
1957
|
+
});
|
|
1958
|
+
}
|
|
1959
|
+
}
|
|
1960
|
+
process.__r = 0;
|
|
1961
|
+
|
|
1962
|
+
/***/
|
|
1963
|
+
},
|
|
1964
|
+
|
|
1965
|
+
/***/ './src/constants.js':
|
|
1966
|
+
/*!**************************!*\
|
|
1967
|
+
!*** ./src/constants.js ***!
|
|
1968
|
+
\**************************/
|
|
1969
|
+
/***/ (
|
|
1970
|
+
__unused_webpack_module,
|
|
1971
|
+
__webpack_exports__,
|
|
1972
|
+
__webpack_require__
|
|
1973
|
+
) => {
|
|
1974
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1975
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1976
|
+
/* harmony export */ EMPTY_ARR: () => /* binding */ EMPTY_ARR,
|
|
1977
|
+
/* harmony export */ EMPTY_OBJ: () => /* binding */ EMPTY_OBJ,
|
|
1978
|
+
/* harmony export */ IS_NON_DIMENSIONAL: () =>
|
|
1979
|
+
/* binding */ IS_NON_DIMENSIONAL,
|
|
1980
|
+
/* harmony export */
|
|
1981
|
+
});
|
|
1982
|
+
var EMPTY_OBJ = {};
|
|
1983
|
+
var EMPTY_ARR = [];
|
|
1984
|
+
var IS_NON_DIMENSIONAL =
|
|
1985
|
+
/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
1986
|
+
|
|
1987
|
+
/***/
|
|
1988
|
+
},
|
|
1989
|
+
|
|
1990
|
+
/***/ './src/create-context.js':
|
|
1991
|
+
/*!*******************************!*\
|
|
1992
|
+
!*** ./src/create-context.js ***!
|
|
1993
|
+
\*******************************/
|
|
1994
|
+
/***/ (
|
|
1995
|
+
__unused_webpack_module,
|
|
1996
|
+
__webpack_exports__,
|
|
1997
|
+
__webpack_require__
|
|
1998
|
+
) => {
|
|
1999
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2000
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2001
|
+
/* harmony export */ createContext: () => /* binding */ createContext,
|
|
2002
|
+
/* harmony export */ i: () => /* binding */ i,
|
|
2003
|
+
/* harmony export */
|
|
2004
|
+
});
|
|
2005
|
+
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_0__ =
|
|
2006
|
+
__webpack_require__(/*! ./component */ './src/component.js');
|
|
2007
|
+
|
|
2008
|
+
var i = 0;
|
|
2009
|
+
function createContext(defaultValue, contextId) {
|
|
2010
|
+
contextId = '__cC' + i++;
|
|
2011
|
+
var context = {
|
|
2012
|
+
__c: contextId,
|
|
2013
|
+
__: defaultValue,
|
|
2014
|
+
/** @type {import('./internal').FunctionComponent} */ Consumer:
|
|
2015
|
+
function Consumer(props, contextValue) {
|
|
2016
|
+
// return props.children(
|
|
2017
|
+
// context[contextId] ? context[contextId].props.value : defaultValue
|
|
2018
|
+
// );
|
|
2019
|
+
return props.children(contextValue);
|
|
2020
|
+
},
|
|
2021
|
+
/** @type {import('./internal').FunctionComponent} */ Provider:
|
|
2022
|
+
function Provider(props) {
|
|
2023
|
+
if (!this.getChildContext) {
|
|
2024
|
+
var subs = [];
|
|
2025
|
+
var ctx = {};
|
|
2026
|
+
ctx[contextId] = this;
|
|
2027
|
+
this.getChildContext = function () {
|
|
2028
|
+
return ctx;
|
|
2029
|
+
};
|
|
2030
|
+
this.shouldComponentUpdate = function (_props) {
|
|
2031
|
+
if (this.props.value !== _props.value) {
|
|
2032
|
+
// I think the forced value propagation here was only needed when `options.debounceRendering` was being bypassed:
|
|
2033
|
+
// https://github.com/preactjs/preact/commit/4d339fb803bea09e9f198abf38ca1bf8ea4b7771#diff-54682ce380935a717e41b8bfc54737f6R358
|
|
2034
|
+
// In those cases though, even with the value corrected, we're double-rendering all nodes.
|
|
2035
|
+
// It might be better to just tell folks not to use force-sync mode.
|
|
2036
|
+
// Currently, using `useContext()` in a class component will overwrite its `this.context` value.
|
|
2037
|
+
// subs.some(c => {
|
|
2038
|
+
// c.context = _props.value;
|
|
2039
|
+
// enqueueRender(c);
|
|
2040
|
+
// });
|
|
2041
|
+
|
|
2042
|
+
// subs.some(c => {
|
|
2043
|
+
// c.context[contextId] = _props.value;
|
|
2044
|
+
// enqueueRender(c);
|
|
2045
|
+
// });
|
|
2046
|
+
subs.some(
|
|
2047
|
+
_component__WEBPACK_IMPORTED_MODULE_0__.enqueueRender
|
|
2048
|
+
);
|
|
2049
|
+
}
|
|
2050
|
+
};
|
|
2051
|
+
this.sub = function (c) {
|
|
2052
|
+
subs.push(c);
|
|
2053
|
+
var old = c.componentWillUnmount;
|
|
2054
|
+
c.componentWillUnmount = function () {
|
|
2055
|
+
subs.splice(subs.indexOf(c), 1);
|
|
2056
|
+
if (old) old.call(c);
|
|
2057
|
+
};
|
|
2058
|
+
};
|
|
2059
|
+
}
|
|
2060
|
+
return props.children;
|
|
2061
|
+
},
|
|
2062
|
+
};
|
|
2063
|
+
|
|
2064
|
+
// Devtools needs access to the context object when it
|
|
2065
|
+
// encounters a Provider. This is necessary to support
|
|
2066
|
+
// setting `displayName` on the context object instead
|
|
2067
|
+
// of on the component itself. See:
|
|
2068
|
+
// https://reactjs.org/docs/context.html#contextdisplayname
|
|
2069
|
+
|
|
2070
|
+
return (context.Provider.__ = context.Consumer.contextType = context);
|
|
2071
|
+
}
|
|
2072
|
+
|
|
2073
|
+
/***/
|
|
2074
|
+
},
|
|
2075
|
+
|
|
2076
|
+
/***/ './src/create-element.js':
|
|
2077
|
+
/*!*******************************!*\
|
|
2078
|
+
!*** ./src/create-element.js ***!
|
|
2079
|
+
\*******************************/
|
|
2080
|
+
/***/ (
|
|
2081
|
+
__unused_webpack_module,
|
|
2082
|
+
__webpack_exports__,
|
|
2083
|
+
__webpack_require__
|
|
2084
|
+
) => {
|
|
2085
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2086
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2087
|
+
/* harmony export */ Fragment: () => /* binding */ Fragment,
|
|
2088
|
+
/* harmony export */ createElement: () => /* binding */ createElement,
|
|
2089
|
+
/* harmony export */ createRef: () => /* binding */ createRef,
|
|
2090
|
+
/* harmony export */ createVNode: () => /* binding */ createVNode,
|
|
2091
|
+
/* harmony export */ isValidElement: () => /* binding */ isValidElement,
|
|
2092
|
+
/* harmony export */
|
|
2093
|
+
});
|
|
2094
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_0__ =
|
|
2095
|
+
__webpack_require__(/*! ./util */ './src/util.js');
|
|
2096
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_1__ =
|
|
2097
|
+
__webpack_require__(/*! ./options */ './src/options.js');
|
|
2098
|
+
|
|
2099
|
+
var vnodeId = 0;
|
|
2100
|
+
|
|
2101
|
+
/**
|
|
2102
|
+
* Create an virtual node (used for JSX)
|
|
2103
|
+
* @param {import('./internal').VNode["type"]} type The node name or Component
|
|
2104
|
+
* constructor for this virtual node
|
|
2105
|
+
* @param {object | null | undefined} [props] The properties of the virtual node
|
|
2106
|
+
* @param {Array<import('.').ComponentChildren>} [children] The children of the virtual node
|
|
2107
|
+
* @returns {import('./internal').VNode}
|
|
2108
|
+
*/
|
|
2109
|
+
function createElement(type, props, children) {
|
|
2110
|
+
var normalizedProps = {},
|
|
2111
|
+
key,
|
|
2112
|
+
ref,
|
|
2113
|
+
i;
|
|
2114
|
+
for (i in props) {
|
|
2115
|
+
if (i == 'key') key = props[i];
|
|
2116
|
+
else if (i == 'ref') ref = props[i];
|
|
2117
|
+
else normalizedProps[i] = props[i];
|
|
2118
|
+
}
|
|
2119
|
+
if (arguments.length > 2) {
|
|
2120
|
+
normalizedProps.children =
|
|
2121
|
+
arguments.length > 3
|
|
2122
|
+
? _util__WEBPACK_IMPORTED_MODULE_0__.slice.call(arguments, 2)
|
|
2123
|
+
: children;
|
|
2124
|
+
}
|
|
2125
|
+
|
|
2126
|
+
// If a Component VNode, check for and apply defaultProps
|
|
2127
|
+
// Note: type may be undefined in development, must never error here.
|
|
2128
|
+
if (typeof type == 'function' && type.defaultProps != null) {
|
|
2129
|
+
for (i in type.defaultProps) {
|
|
2130
|
+
if (normalizedProps[i] === undefined) {
|
|
2131
|
+
normalizedProps[i] = type.defaultProps[i];
|
|
2132
|
+
}
|
|
2133
|
+
}
|
|
2134
|
+
}
|
|
2135
|
+
return createVNode(type, normalizedProps, key, ref, null);
|
|
2136
|
+
}
|
|
2137
|
+
|
|
2138
|
+
/**
|
|
2139
|
+
* Create a VNode (used internally by Preact)
|
|
2140
|
+
* @param {import('./internal').VNode["type"]} type The node name or Component
|
|
2141
|
+
* Constructor for this virtual node
|
|
2142
|
+
* @param {object | string | number | null} props The properties of this virtual node.
|
|
2143
|
+
* If this virtual node represents a text node, this is the text of the node (string or number).
|
|
2144
|
+
* @param {string | number | null} key The key for this virtual node, used when
|
|
2145
|
+
* diffing it against its children
|
|
2146
|
+
* @param {import('./internal').VNode["ref"]} ref The ref property that will
|
|
2147
|
+
* receive a reference to its created child
|
|
2148
|
+
* @returns {import('./internal').VNode}
|
|
2149
|
+
*/
|
|
2150
|
+
function createVNode(type, props, key, ref, original) {
|
|
2151
|
+
// V8 seems to be better at detecting type shapes if the object is allocated from the same call site
|
|
2152
|
+
// Do not inline into createElement and coerceToVNode!
|
|
2153
|
+
var vnode = {
|
|
2154
|
+
type: type,
|
|
2155
|
+
props: props,
|
|
2156
|
+
key: key,
|
|
2157
|
+
ref: ref,
|
|
2158
|
+
__k: null,
|
|
2159
|
+
__: null,
|
|
2160
|
+
__b: 0,
|
|
2161
|
+
__e: null,
|
|
2162
|
+
// _nextDom must be initialized to undefined b/c it will eventually
|
|
2163
|
+
// be set to dom.nextSibling which can return `null` and it is important
|
|
2164
|
+
// to be able to distinguish between an uninitialized _nextDom and
|
|
2165
|
+
// a _nextDom that has been set to `null`
|
|
2166
|
+
__d: undefined,
|
|
2167
|
+
__c: null,
|
|
2168
|
+
__h: null,
|
|
2169
|
+
constructor: undefined,
|
|
2170
|
+
__v: original == null ? ++vnodeId : original,
|
|
2171
|
+
};
|
|
2172
|
+
|
|
2173
|
+
// Only invoke the vnode hook if this was *not* a direct copy:
|
|
2174
|
+
if (
|
|
2175
|
+
original == null &&
|
|
2176
|
+
_options__WEBPACK_IMPORTED_MODULE_1__['default'].vnode != null
|
|
2177
|
+
)
|
|
2178
|
+
_options__WEBPACK_IMPORTED_MODULE_1__['default'].vnode(vnode);
|
|
2179
|
+
return vnode;
|
|
2180
|
+
}
|
|
2181
|
+
function createRef() {
|
|
2182
|
+
return {
|
|
2183
|
+
current: null,
|
|
2184
|
+
};
|
|
2185
|
+
}
|
|
2186
|
+
function Fragment(props) {
|
|
2187
|
+
return props.children;
|
|
2188
|
+
}
|
|
2189
|
+
|
|
2190
|
+
/**
|
|
2191
|
+
* Check if a the argument is a valid Preact VNode.
|
|
2192
|
+
* @param {*} vnode
|
|
2193
|
+
* @returns {vnode is import('./internal').VNode}
|
|
2194
|
+
*/
|
|
2195
|
+
var isValidElement = function isValidElement(vnode) {
|
|
2196
|
+
return vnode != null && vnode.constructor === undefined;
|
|
2197
|
+
};
|
|
2198
|
+
|
|
2199
|
+
/***/
|
|
2200
|
+
},
|
|
2201
|
+
|
|
2202
|
+
/***/ './src/diff/catch-error.js':
|
|
2203
|
+
/*!*********************************!*\
|
|
2204
|
+
!*** ./src/diff/catch-error.js ***!
|
|
2205
|
+
\*********************************/
|
|
2206
|
+
/***/ (
|
|
2207
|
+
__unused_webpack_module,
|
|
2208
|
+
__webpack_exports__,
|
|
2209
|
+
__webpack_require__
|
|
2210
|
+
) => {
|
|
2211
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2212
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2213
|
+
/* harmony export */ _catchError: () => /* binding */ _catchError,
|
|
2214
|
+
/* harmony export */
|
|
2215
|
+
});
|
|
2216
|
+
/**
|
|
2217
|
+
* Find the closest error boundary to a thrown error and call it
|
|
2218
|
+
* @param {object} error The thrown value
|
|
2219
|
+
* @param {import('../types/internal').VNode} vnode The vnode that threw
|
|
2220
|
+
* the error that was caught (except for unmounting when this parameter
|
|
2221
|
+
* is the highest parent that was being unmounted)
|
|
2222
|
+
* @param {import('../types/internal').VNode} [oldVNode]
|
|
2223
|
+
* @param {import('../types/internal').ErrorInfo} [errorInfo]
|
|
2224
|
+
*/
|
|
2225
|
+
function _catchError(error, vnode, oldVNode, errorInfo) {
|
|
2226
|
+
/** @type {import('../types/internal').Component} */
|
|
2227
|
+
var component, ctor, handled;
|
|
2228
|
+
for (; (vnode = vnode.__); ) {
|
|
2229
|
+
if ((component = vnode.__c) && !component.__) {
|
|
2230
|
+
try {
|
|
2231
|
+
ctor = component.constructor;
|
|
2232
|
+
if (ctor && ctor.getDerivedStateFromError != null) {
|
|
2233
|
+
component.setState(ctor.getDerivedStateFromError(error));
|
|
2234
|
+
handled = component.__d;
|
|
2235
|
+
}
|
|
2236
|
+
if (component.componentDidCatch != null) {
|
|
2237
|
+
component.componentDidCatch(error, errorInfo || {});
|
|
2238
|
+
handled = component.__d;
|
|
2239
|
+
}
|
|
2240
|
+
|
|
2241
|
+
// This is an error boundary. Mark it as having bailed out, and whether it was mid-hydration.
|
|
2242
|
+
if (handled) {
|
|
2243
|
+
return (component.__E = component);
|
|
2244
|
+
}
|
|
2245
|
+
}
|
|
2246
|
+
catch (e) {
|
|
2247
|
+
error = e;
|
|
2248
|
+
}
|
|
2249
|
+
}
|
|
2250
|
+
}
|
|
2251
|
+
throw error;
|
|
2252
|
+
}
|
|
2253
|
+
|
|
2254
|
+
/***/
|
|
2255
|
+
},
|
|
2256
|
+
|
|
2257
|
+
/***/ './src/diff/children.js':
|
|
2258
|
+
/*!******************************!*\
|
|
2259
|
+
!*** ./src/diff/children.js ***!
|
|
2260
|
+
\******************************/
|
|
2261
|
+
/***/ (
|
|
2262
|
+
__unused_webpack_module,
|
|
2263
|
+
__webpack_exports__,
|
|
2264
|
+
__webpack_require__
|
|
2265
|
+
) => {
|
|
2266
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2267
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2268
|
+
/* harmony export */ diffChildren: () => /* binding */ diffChildren,
|
|
2269
|
+
/* harmony export */ toChildArray: () => /* binding */ toChildArray,
|
|
2270
|
+
/* harmony export */
|
|
2271
|
+
});
|
|
2272
|
+
/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ =
|
|
2273
|
+
__webpack_require__(/*! ./index */ './src/diff/index.js');
|
|
2274
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_1__ =
|
|
2275
|
+
__webpack_require__(/*! ../create-element */ './src/create-element.js');
|
|
2276
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_2__ =
|
|
2277
|
+
__webpack_require__(/*! ../constants */ './src/constants.js');
|
|
2278
|
+
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_3__ =
|
|
2279
|
+
__webpack_require__(/*! ../component */ './src/component.js');
|
|
2280
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ =
|
|
2281
|
+
__webpack_require__(/*! ../util */ './src/util.js');
|
|
2282
|
+
|
|
2283
|
+
/**
|
|
2284
|
+
* Diff the children of a virtual node
|
|
2285
|
+
* @param {import('../types/internal').PreactElement} parentDom The DOM element whose
|
|
2286
|
+
* children are being diffed
|
|
2287
|
+
* @param {import('../types/internal').ComponentChildren[]} renderResult
|
|
2288
|
+
* @param {import('../types/internal').VNode} newParentVNode The new virtual
|
|
2289
|
+
* node whose children should be diff'ed against oldParentVNode
|
|
2290
|
+
* @param {import('../types/internal').VNode} oldParentVNode The old virtual
|
|
2291
|
+
* node whose children should be diff'ed against newParentVNode
|
|
2292
|
+
* @param {object} globalContext The current context object - modified by getChildContext
|
|
2293
|
+
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
|
2294
|
+
* @param {Array<import('../types/internal').PreactElement>} excessDomChildren
|
|
2295
|
+
* @param {Array<import('../types/internal').Component>} commitQueue List of components
|
|
2296
|
+
* which have callbacks to invoke in commitRoot
|
|
2297
|
+
* @param {import('../types/internal').PreactElement} oldDom The current attached DOM
|
|
2298
|
+
* element any new dom elements should be placed around. Likely `null` on first
|
|
2299
|
+
* render (except when hydrating). Can be a sibling DOM element when diffing
|
|
2300
|
+
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
|
2301
|
+
* @param {boolean} isHydrating Whether or not we are in hydration
|
|
2302
|
+
*/
|
|
2303
|
+
function diffChildren(
|
|
2304
|
+
parentDom,
|
|
2305
|
+
renderResult,
|
|
2306
|
+
newParentVNode,
|
|
2307
|
+
oldParentVNode,
|
|
2308
|
+
globalContext,
|
|
2309
|
+
isSvg,
|
|
2310
|
+
excessDomChildren,
|
|
2311
|
+
commitQueue,
|
|
2312
|
+
oldDom,
|
|
2313
|
+
isHydrating
|
|
2314
|
+
) {
|
|
2315
|
+
var i, j, oldVNode, childVNode, newDom, firstChildDom, refs;
|
|
2316
|
+
|
|
2317
|
+
// This is a compression of oldParentVNode!=null && oldParentVNode != EMPTY_OBJ && oldParentVNode._children || EMPTY_ARR
|
|
2318
|
+
// as EMPTY_OBJ._children should be `undefined`.
|
|
2319
|
+
var oldChildren =
|
|
2320
|
+
(oldParentVNode && oldParentVNode.__k) ||
|
|
2321
|
+
_constants__WEBPACK_IMPORTED_MODULE_2__.EMPTY_ARR;
|
|
2322
|
+
var oldChildrenLength = oldChildren.length;
|
|
2323
|
+
newParentVNode.__k = [];
|
|
2324
|
+
for (i = 0; i < renderResult.length; i++) {
|
|
2325
|
+
childVNode = renderResult[i];
|
|
2326
|
+
// console.debug(`**${newParentVNode.props.id}-child${i}-${childVNode.props?.id}-start`,JSON.stringify(renderResult));
|
|
2327
|
+
|
|
2328
|
+
if (childVNode == null || typeof childVNode == 'boolean') {
|
|
2329
|
+
childVNode = newParentVNode.__k[i] = null;
|
|
2330
|
+
}
|
|
2331
|
+
// If this newVNode is being reused (e.g. <div>{reuse}{reuse}</div>) in the same diff,
|
|
2332
|
+
// or we are rendering a component (e.g. setState) copy the oldVNodes so it can have
|
|
2333
|
+
// it's own DOM & etc. pointers
|
|
2334
|
+
else if (
|
|
2335
|
+
typeof childVNode == 'string' ||
|
|
2336
|
+
typeof childVNode == 'number' ||
|
|
2337
|
+
// eslint-disable-next-line valid-typeof
|
|
2338
|
+
typeof childVNode == 'bigint'
|
|
2339
|
+
) {
|
|
2340
|
+
childVNode = newParentVNode.__k[i] = (0,
|
|
2341
|
+
_create_element__WEBPACK_IMPORTED_MODULE_1__.createVNode)(
|
|
2342
|
+
null,
|
|
2343
|
+
childVNode,
|
|
2344
|
+
null,
|
|
2345
|
+
null,
|
|
2346
|
+
childVNode
|
|
2347
|
+
);
|
|
2348
|
+
}
|
|
2349
|
+
else if (Array.isArray(childVNode)) {
|
|
2350
|
+
childVNode = newParentVNode.__k[i] = (0,
|
|
2351
|
+
_create_element__WEBPACK_IMPORTED_MODULE_1__.createVNode)(
|
|
2352
|
+
_create_element__WEBPACK_IMPORTED_MODULE_1__.Fragment,
|
|
2353
|
+
{
|
|
2354
|
+
children: childVNode,
|
|
2355
|
+
},
|
|
2356
|
+
null,
|
|
2357
|
+
null,
|
|
2358
|
+
null
|
|
2359
|
+
);
|
|
2360
|
+
}
|
|
2361
|
+
else if (childVNode.__b > 0) {
|
|
2362
|
+
// VNode is already in use, clone it. This can happen in the following
|
|
2363
|
+
// scenario:
|
|
2364
|
+
// const reuse = <div />
|
|
2365
|
+
// <div>{reuse}<span />{reuse}</div>
|
|
2366
|
+
childVNode = newParentVNode.__k[i] = (0,
|
|
2367
|
+
_create_element__WEBPACK_IMPORTED_MODULE_1__.createVNode)(
|
|
2368
|
+
childVNode.type,
|
|
2369
|
+
childVNode.props,
|
|
2370
|
+
childVNode.key,
|
|
2371
|
+
childVNode.ref ? childVNode.ref : null,
|
|
2372
|
+
childVNode.__v
|
|
2373
|
+
);
|
|
2374
|
+
}
|
|
2375
|
+
else {
|
|
2376
|
+
childVNode = newParentVNode.__k[i] = childVNode;
|
|
2377
|
+
}
|
|
2378
|
+
|
|
2379
|
+
// Terser removes the `continue` here and wraps the loop body
|
|
2380
|
+
// in a `if (childVNode) { ... } condition
|
|
2381
|
+
if (childVNode == null) {
|
|
2382
|
+
continue;
|
|
2383
|
+
}
|
|
2384
|
+
childVNode.__ = newParentVNode;
|
|
2385
|
+
childVNode.__b = newParentVNode.__b + 1;
|
|
2386
|
+
|
|
2387
|
+
// Check if we find a corresponding element in oldChildren.
|
|
2388
|
+
// If found, delete the array item by setting to `undefined`.
|
|
2389
|
+
// We use `undefined`, as `null` is reserved for empty placeholders
|
|
2390
|
+
// (holes).
|
|
2391
|
+
oldVNode = oldChildren[i];
|
|
2392
|
+
|
|
2393
|
+
///PLACE1/////////////////////////////////////
|
|
2394
|
+
|
|
2395
|
+
if (
|
|
2396
|
+
oldVNode === null ||
|
|
2397
|
+
(oldVNode &&
|
|
2398
|
+
childVNode.key == oldVNode.key &&
|
|
2399
|
+
childVNode.type === oldVNode.type)
|
|
2400
|
+
) {
|
|
2401
|
+
oldChildren[i] = undefined;
|
|
2402
|
+
}
|
|
2403
|
+
else {
|
|
2404
|
+
// Either oldVNode === undefined or oldChildrenLength > 0,
|
|
2405
|
+
// so after this loop oldVNode == null or oldVNode is a valid value.
|
|
2406
|
+
for (j = 0; j < oldChildrenLength; j++) {
|
|
2407
|
+
oldVNode = oldChildren[j];
|
|
2408
|
+
// If childVNode is unkeyed, we only match similarly unkeyed nodes, otherwise we match by key.
|
|
2409
|
+
// We always match by type (in either case).
|
|
2410
|
+
if (
|
|
2411
|
+
oldVNode &&
|
|
2412
|
+
childVNode.key == oldVNode.key &&
|
|
2413
|
+
childVNode.type === oldVNode.type
|
|
2414
|
+
) {
|
|
2415
|
+
oldChildren[j] = undefined;
|
|
2416
|
+
break;
|
|
2417
|
+
}
|
|
2418
|
+
oldVNode = null;
|
|
2419
|
+
}
|
|
2420
|
+
}
|
|
2421
|
+
oldVNode =
|
|
2422
|
+
oldVNode || _constants__WEBPACK_IMPORTED_MODULE_2__.EMPTY_OBJ;
|
|
2423
|
+
|
|
2424
|
+
///PLACE2/////////////////////////////////////
|
|
2425
|
+
|
|
2426
|
+
// Morph the old element into the new one, but don't append it to the dom yet
|
|
2427
|
+
(0, _index__WEBPACK_IMPORTED_MODULE_0__.diff)(
|
|
2428
|
+
parentDom,
|
|
2429
|
+
childVNode,
|
|
2430
|
+
oldVNode,
|
|
2431
|
+
globalContext,
|
|
2432
|
+
isSvg,
|
|
2433
|
+
excessDomChildren,
|
|
2434
|
+
commitQueue,
|
|
2435
|
+
oldDom,
|
|
2436
|
+
isHydrating
|
|
2437
|
+
);
|
|
2438
|
+
oldVNode =
|
|
2439
|
+
oldVNode || _constants__WEBPACK_IMPORTED_MODULE_2__.EMPTY_OBJ;
|
|
2440
|
+
newDom = childVNode.__e;
|
|
2441
|
+
if ((j = childVNode.ref) && oldVNode.ref != j) {
|
|
2442
|
+
if (!refs) refs = [];
|
|
2443
|
+
if (oldVNode.ref) refs.push(oldVNode.ref, null, childVNode);
|
|
2444
|
+
refs.push(j, childVNode.__c || newDom, childVNode);
|
|
2445
|
+
}
|
|
2446
|
+
if (newDom != null) {
|
|
2447
|
+
if (firstChildDom == null) {
|
|
2448
|
+
firstChildDom = newDom;
|
|
2449
|
+
}
|
|
2450
|
+
if (
|
|
2451
|
+
typeof childVNode.type == 'function' &&
|
|
2452
|
+
childVNode.__k === oldVNode.__k
|
|
2453
|
+
) {
|
|
2454
|
+
childVNode.__d = oldDom = reorderChildren(
|
|
2455
|
+
childVNode,
|
|
2456
|
+
oldDom,
|
|
2457
|
+
parentDom
|
|
2458
|
+
);
|
|
2459
|
+
}
|
|
2460
|
+
else {
|
|
2461
|
+
oldDom = placeChild(
|
|
2462
|
+
parentDom,
|
|
2463
|
+
childVNode,
|
|
2464
|
+
oldVNode,
|
|
2465
|
+
oldChildren,
|
|
2466
|
+
newDom,
|
|
2467
|
+
oldDom
|
|
2468
|
+
);
|
|
2469
|
+
}
|
|
2470
|
+
if (typeof newParentVNode.type == 'function') {
|
|
2471
|
+
// Because the newParentVNode is Fragment-like, we need to set it's
|
|
2472
|
+
// _nextDom property to the nextSibling of its last child DOM node.
|
|
2473
|
+
//
|
|
2474
|
+
// `oldDom` contains the correct value here because if the last child
|
|
2475
|
+
// is a Fragment-like, then oldDom has already been set to that child's _nextDom.
|
|
2476
|
+
// If the last child is a DOM VNode, then oldDom will be set to that DOM
|
|
2477
|
+
// node's nextSibling.
|
|
2478
|
+
newParentVNode.__d = oldDom;
|
|
2479
|
+
}
|
|
2480
|
+
}
|
|
2481
|
+
else if (
|
|
2482
|
+
oldDom &&
|
|
2483
|
+
oldVNode.__e == oldDom &&
|
|
2484
|
+
oldDom.parentNode != parentDom
|
|
2485
|
+
) {
|
|
2486
|
+
// The above condition is to handle null placeholders. See test in placeholder.test.js:
|
|
2487
|
+
// `efficiently replace null placeholders in parent rerenders`
|
|
2488
|
+
oldDom = (0, _component__WEBPACK_IMPORTED_MODULE_3__.getDomSibling)(
|
|
2489
|
+
oldVNode
|
|
2490
|
+
);
|
|
2491
|
+
}
|
|
2492
|
+
}
|
|
2493
|
+
newParentVNode.__e = firstChildDom;
|
|
2494
|
+
|
|
2495
|
+
// Remove remaining oldChildren if there are any.
|
|
2496
|
+
for (i = oldChildrenLength; i--; ) {
|
|
2497
|
+
if (oldChildren[i] != null) {
|
|
2498
|
+
(0, _index__WEBPACK_IMPORTED_MODULE_0__.unmount)(
|
|
2499
|
+
oldChildren[i],
|
|
2500
|
+
oldChildren[i]
|
|
2501
|
+
);
|
|
2502
|
+
}
|
|
2503
|
+
}
|
|
2504
|
+
|
|
2505
|
+
// Set refs only after unmount
|
|
2506
|
+
if (refs) {
|
|
2507
|
+
for (i = 0; i < refs.length; i++) {
|
|
2508
|
+
(0, _index__WEBPACK_IMPORTED_MODULE_0__.applyRef)(
|
|
2509
|
+
refs[i],
|
|
2510
|
+
refs[++i],
|
|
2511
|
+
refs[++i]
|
|
2512
|
+
);
|
|
2513
|
+
}
|
|
2514
|
+
}
|
|
2515
|
+
}
|
|
2516
|
+
function reorderChildren(childVNode, oldDom, parentDom) {
|
|
2517
|
+
// Note: VNodes in nested suspended trees may be missing _children.
|
|
2518
|
+
var c = childVNode.__k;
|
|
2519
|
+
var tmp = 0;
|
|
2520
|
+
for (; c && tmp < c.length; tmp++) {
|
|
2521
|
+
var vnode = c[tmp];
|
|
2522
|
+
if (vnode) {
|
|
2523
|
+
// We typically enter this code path on sCU bailout, where we copy
|
|
2524
|
+
// oldVNode._children to newVNode._children. If that is the case, we need
|
|
2525
|
+
// to update the old children's _parent pointer to point to the newVNode
|
|
2526
|
+
// (childVNode here).
|
|
2527
|
+
vnode.__ = childVNode;
|
|
2528
|
+
if (typeof vnode.type == 'function') {
|
|
2529
|
+
oldDom = reorderChildren(vnode, oldDom, parentDom);
|
|
2530
|
+
}
|
|
2531
|
+
else {
|
|
2532
|
+
oldDom = placeChild(
|
|
2533
|
+
parentDom,
|
|
2534
|
+
vnode,
|
|
2535
|
+
vnode,
|
|
2536
|
+
c,
|
|
2537
|
+
vnode.__e,
|
|
2538
|
+
oldDom
|
|
2539
|
+
);
|
|
2540
|
+
}
|
|
2541
|
+
}
|
|
2542
|
+
}
|
|
2543
|
+
return oldDom;
|
|
2544
|
+
}
|
|
2545
|
+
|
|
2546
|
+
/**
|
|
2547
|
+
* Flatten and loop through the children of a virtual node
|
|
2548
|
+
* @param {import('@wellbye/pxw/lib/preact').ComponentChildren} children The unflattened
|
|
2549
|
+
* children of a virtual node
|
|
2550
|
+
* @returns {import('../types/internal').VNode[]}
|
|
2551
|
+
*/
|
|
2552
|
+
function toChildArray(children, out) {
|
|
2553
|
+
out = out || [];
|
|
2554
|
+
if (children == null || typeof children == 'boolean') {
|
|
2555
|
+
}
|
|
2556
|
+
else if (Array.isArray(children)) {
|
|
2557
|
+
children.some(function (child) {
|
|
2558
|
+
toChildArray(child, out);
|
|
2559
|
+
});
|
|
2560
|
+
}
|
|
2561
|
+
else {
|
|
2562
|
+
out.push(children);
|
|
2563
|
+
}
|
|
2564
|
+
return out;
|
|
2565
|
+
}
|
|
2566
|
+
function placeChild(
|
|
2567
|
+
parentDom,
|
|
2568
|
+
childVNode,
|
|
2569
|
+
oldVNode,
|
|
2570
|
+
oldChildren,
|
|
2571
|
+
newDom,
|
|
2572
|
+
oldDom
|
|
2573
|
+
) {
|
|
2574
|
+
var nextDom;
|
|
2575
|
+
if (childVNode.__d !== undefined) {
|
|
2576
|
+
// Only Fragments or components that return Fragment like VNodes will
|
|
2577
|
+
// have a non-undefined _nextDom. Continue the diff from the sibling
|
|
2578
|
+
// of last DOM child of this child VNode
|
|
2579
|
+
nextDom = childVNode.__d;
|
|
2580
|
+
|
|
2581
|
+
// Eagerly cleanup _nextDom. We don't need to persist the value because
|
|
2582
|
+
// it is only used by `diffChildren` to determine where to resume the diff after
|
|
2583
|
+
// diffing Components and Fragments. Once we store it the nextDOM local var, we
|
|
2584
|
+
// can clean up the property
|
|
2585
|
+
childVNode.__d = undefined;
|
|
2586
|
+
}
|
|
2587
|
+
else if (
|
|
2588
|
+
oldVNode == null ||
|
|
2589
|
+
newDom != oldDom ||
|
|
2590
|
+
newDom.parentNode == null
|
|
2591
|
+
) {
|
|
2592
|
+
outer: if (oldDom == null || oldDom.parentNode !== parentDom) {
|
|
2593
|
+
parentDom.appendChild(newDom);
|
|
2594
|
+
nextDom = null;
|
|
2595
|
+
}
|
|
2596
|
+
else {
|
|
2597
|
+
// `j<oldChildrenLength; j+=2` is an alternative to `j++<oldChildrenLength/2`
|
|
2598
|
+
for (
|
|
2599
|
+
var sibDom = oldDom, j = 0;
|
|
2600
|
+
(sibDom = sibDom.nextSibling) && j < oldChildren.length;
|
|
2601
|
+
j += 1
|
|
2602
|
+
) {
|
|
2603
|
+
if (sibDom == newDom) {
|
|
2604
|
+
break outer;
|
|
2605
|
+
}
|
|
2606
|
+
}
|
|
2607
|
+
parentDom.insertBefore(newDom, oldDom);
|
|
2608
|
+
nextDom = oldDom;
|
|
2609
|
+
}
|
|
2610
|
+
}
|
|
2611
|
+
|
|
2612
|
+
// If we have pre-calculated the nextDOM node, use it. Else calculate it now
|
|
2613
|
+
// Strictly check for `undefined` here cuz `null` is a valid value of `nextDom`.
|
|
2614
|
+
// See more detail in create-element.js:createVNode
|
|
2615
|
+
if (nextDom !== undefined) {
|
|
2616
|
+
oldDom = nextDom;
|
|
2617
|
+
}
|
|
2618
|
+
else {
|
|
2619
|
+
oldDom = newDom.nextSibling;
|
|
2620
|
+
}
|
|
2621
|
+
return oldDom;
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
/***/
|
|
2625
|
+
},
|
|
2626
|
+
|
|
2627
|
+
/***/ './src/diff/index.js':
|
|
2628
|
+
/*!***************************!*\
|
|
2629
|
+
!*** ./src/diff/index.js ***!
|
|
2630
|
+
\***************************/
|
|
2631
|
+
/***/ (
|
|
2632
|
+
__unused_webpack_module,
|
|
2633
|
+
__webpack_exports__,
|
|
2634
|
+
__webpack_require__
|
|
2635
|
+
) => {
|
|
2636
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2637
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2638
|
+
/* harmony export */ applyRef: () => /* binding */ applyRef,
|
|
2639
|
+
/* harmony export */ commitRoot: () => /* binding */ commitRoot,
|
|
2640
|
+
/* harmony export */ diff: () => /* binding */ diff,
|
|
2641
|
+
/* harmony export */ unmount: () => /* binding */ unmount,
|
|
2642
|
+
/* harmony export */
|
|
2643
|
+
});
|
|
2644
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ =
|
|
2645
|
+
__webpack_require__(/*! ../constants */ './src/constants.js');
|
|
2646
|
+
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_1__ =
|
|
2647
|
+
__webpack_require__(/*! ../component */ './src/component.js');
|
|
2648
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_2__ =
|
|
2649
|
+
__webpack_require__(/*! ../create-element */ './src/create-element.js');
|
|
2650
|
+
/* harmony import */ var _children__WEBPACK_IMPORTED_MODULE_3__ =
|
|
2651
|
+
__webpack_require__(/*! ./children */ './src/diff/children.js');
|
|
2652
|
+
/* harmony import */ var _props__WEBPACK_IMPORTED_MODULE_4__ =
|
|
2653
|
+
__webpack_require__(/*! ./props */ './src/diff/props.js');
|
|
2654
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_5__ =
|
|
2655
|
+
__webpack_require__(/*! ../util */ './src/util.js');
|
|
2656
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_6__ =
|
|
2657
|
+
__webpack_require__(/*! ../options */ './src/options.js');
|
|
2658
|
+
|
|
2659
|
+
/**
|
|
2660
|
+
* Diff two virtual nodes and apply proper changes to the DOM
|
|
2661
|
+
* @param {import('../types/internal').PreactElement} parentDom The parent of the DOM element
|
|
2662
|
+
* @param {import('../types/internal').VNode} newVNode The new virtual node
|
|
2663
|
+
* @param {import('../types/internal').VNode} oldVNode The old virtual node
|
|
2664
|
+
* @param {object} globalContext The current context object. Modified by getChildContext
|
|
2665
|
+
* @param {boolean} isSvg Whether or not this element is an SVG node
|
|
2666
|
+
* @param {Array<import('../types/internal').PreactElement>} excessDomChildren
|
|
2667
|
+
* @param {Array<import('../types/internal').Component>} commitQueue List of components
|
|
2668
|
+
* which have callbacks to invoke in commitRoot
|
|
2669
|
+
* @param {import('../types/internal').PreactElement} oldDom The current attached DOM
|
|
2670
|
+
* element any new dom elements should be placed around. Likely `null` on first
|
|
2671
|
+
* render (except when hydrating). Can be a sibling DOM element when diffing
|
|
2672
|
+
* Fragments that have siblings. In most cases, it starts out as `oldChildren[0]._dom`.
|
|
2673
|
+
* @param {boolean} [isHydrating] Whether or not we are in hydration
|
|
2674
|
+
*/
|
|
2675
|
+
function diff(
|
|
2676
|
+
parentDom,
|
|
2677
|
+
newVNode,
|
|
2678
|
+
oldVNode,
|
|
2679
|
+
globalContext,
|
|
2680
|
+
isSvg,
|
|
2681
|
+
excessDomChildren,
|
|
2682
|
+
commitQueue,
|
|
2683
|
+
oldDom,
|
|
2684
|
+
isHydrating
|
|
2685
|
+
) {
|
|
2686
|
+
var tmp,
|
|
2687
|
+
newType = newVNode.type;
|
|
2688
|
+
|
|
2689
|
+
// When passing through createElement it assigns the object
|
|
2690
|
+
// constructor as undefined. This to prevent JSON-injection.
|
|
2691
|
+
if (newVNode.constructor !== undefined) return null;
|
|
2692
|
+
|
|
2693
|
+
// If the previous diff bailed out, resume creating/hydrating.
|
|
2694
|
+
if (oldVNode.__h != null) {
|
|
2695
|
+
isHydrating = oldVNode.__h;
|
|
2696
|
+
oldDom = newVNode.__e = oldVNode.__e;
|
|
2697
|
+
// if we resume, we want the tree to be "unlocked"
|
|
2698
|
+
newVNode.__h = null;
|
|
2699
|
+
excessDomChildren = [oldDom];
|
|
2700
|
+
}
|
|
2701
|
+
if ((tmp = _options__WEBPACK_IMPORTED_MODULE_6__['default'].__b))
|
|
2702
|
+
tmp(newVNode);
|
|
2703
|
+
try {
|
|
2704
|
+
outer: if (typeof newType == 'function') {
|
|
2705
|
+
var _newType$prototype2;
|
|
2706
|
+
var c,
|
|
2707
|
+
isNew,
|
|
2708
|
+
oldProps,
|
|
2709
|
+
oldState,
|
|
2710
|
+
snapshot,
|
|
2711
|
+
clearProcessingException;
|
|
2712
|
+
var newProps = newVNode.props;
|
|
2713
|
+
|
|
2714
|
+
// Necessary for createContext api. Setting this property will pass
|
|
2715
|
+
// the context value as `this.context` just for this component.
|
|
2716
|
+
tmp = newType.contextType;
|
|
2717
|
+
var provider = tmp && globalContext[tmp.__c];
|
|
2718
|
+
var componentContext = tmp
|
|
2719
|
+
? provider
|
|
2720
|
+
? provider.props.value
|
|
2721
|
+
: tmp.__
|
|
2722
|
+
: globalContext;
|
|
2723
|
+
|
|
2724
|
+
// Get component and set it to `c`
|
|
2725
|
+
if (oldVNode.__c) {
|
|
2726
|
+
c = newVNode.__c = oldVNode.__c;
|
|
2727
|
+
clearProcessingException = c.__ = c.__E;
|
|
2728
|
+
}
|
|
2729
|
+
else {
|
|
2730
|
+
var _newType$prototype;
|
|
2731
|
+
// Instantiate the new component
|
|
2732
|
+
if (
|
|
2733
|
+
(_newType$prototype = newType.prototype) !== null &&
|
|
2734
|
+
_newType$prototype !== void 0 &&
|
|
2735
|
+
_newType$prototype.render
|
|
2736
|
+
) {
|
|
2737
|
+
// @ts-ignore The check above verifies that newType is suppose to be constructed
|
|
2738
|
+
newVNode.__c = c = new newType(newProps, componentContext); // eslint-disable-line new-cap
|
|
2739
|
+
}
|
|
2740
|
+
else {
|
|
2741
|
+
// @ts-ignore Trust me, Component implements the interface we want
|
|
2742
|
+
newVNode.__c = c =
|
|
2743
|
+
new _component__WEBPACK_IMPORTED_MODULE_1__.Component(
|
|
2744
|
+
newProps,
|
|
2745
|
+
componentContext
|
|
2746
|
+
);
|
|
2747
|
+
c.constructor = newType;
|
|
2748
|
+
c.render = doRender;
|
|
2749
|
+
}
|
|
2750
|
+
if (provider) provider.sub(c);
|
|
2751
|
+
c.props = newProps;
|
|
2752
|
+
if (!c.state) c.state = {};
|
|
2753
|
+
c.context = componentContext;
|
|
2754
|
+
c.__n = globalContext;
|
|
2755
|
+
isNew = c.__d = true;
|
|
2756
|
+
c.__h = [];
|
|
2757
|
+
c._sb = [];
|
|
2758
|
+
}
|
|
2759
|
+
|
|
2760
|
+
// Invoke getDerivedStateFromProps
|
|
2761
|
+
if (c.__s == null) {
|
|
2762
|
+
c.__s = c.state;
|
|
2763
|
+
}
|
|
2764
|
+
if (newType.getDerivedStateFromProps != null) {
|
|
2765
|
+
if (c.__s == c.state) {
|
|
2766
|
+
c.__s = (0, _util__WEBPACK_IMPORTED_MODULE_5__.assign)(
|
|
2767
|
+
{},
|
|
2768
|
+
c.__s
|
|
2769
|
+
);
|
|
2770
|
+
}
|
|
2771
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_5__.assign)(
|
|
2772
|
+
c.__s,
|
|
2773
|
+
newType.getDerivedStateFromProps(newProps, c.__s)
|
|
2774
|
+
);
|
|
2775
|
+
}
|
|
2776
|
+
oldProps = c.props;
|
|
2777
|
+
oldState = c.state;
|
|
2778
|
+
|
|
2779
|
+
// Invoke pre-render lifecycle methods
|
|
2780
|
+
if (isNew) {
|
|
2781
|
+
if (
|
|
2782
|
+
newType.getDerivedStateFromProps == null &&
|
|
2783
|
+
c.componentWillMount != null
|
|
2784
|
+
) {
|
|
2785
|
+
c.componentWillMount();
|
|
2786
|
+
}
|
|
2787
|
+
if (c.componentDidMount != null) {
|
|
2788
|
+
c.__h.push(c.componentDidMount);
|
|
2789
|
+
}
|
|
2790
|
+
}
|
|
2791
|
+
else {
|
|
2792
|
+
if (
|
|
2793
|
+
newType.getDerivedStateFromProps == null &&
|
|
2794
|
+
newProps !== oldProps &&
|
|
2795
|
+
c.componentWillReceiveProps != null
|
|
2796
|
+
) {
|
|
2797
|
+
c.componentWillReceiveProps(newProps, componentContext);
|
|
2798
|
+
}
|
|
2799
|
+
if (
|
|
2800
|
+
(!c.__e &&
|
|
2801
|
+
c.shouldComponentUpdate != null &&
|
|
2802
|
+
c.shouldComponentUpdate(newProps, c.__s, componentContext) ===
|
|
2803
|
+
false) ||
|
|
2804
|
+
newVNode.__v === oldVNode.__v
|
|
2805
|
+
) {
|
|
2806
|
+
c.props = newProps;
|
|
2807
|
+
c.state = c.__s;
|
|
2808
|
+
// More info about this here: https://gist.github.com/JoviDeCroock/bec5f2ce93544d2e6070ef8e0036e4e8
|
|
2809
|
+
if (newVNode.__v !== oldVNode.__v) c.__d = false;
|
|
2810
|
+
c.__v = newVNode;
|
|
2811
|
+
newVNode.__e = oldVNode.__e;
|
|
2812
|
+
newVNode.__k = oldVNode.__k;
|
|
2813
|
+
newVNode.__k.forEach(function (vnode) {
|
|
2814
|
+
if (vnode) vnode.__ = newVNode;
|
|
2815
|
+
});
|
|
2816
|
+
for (var i = 0; i < c._sb.length; i++) {
|
|
2817
|
+
c.__h.push(c._sb[i]);
|
|
2818
|
+
}
|
|
2819
|
+
c._sb = [];
|
|
2820
|
+
if (c.__h.length) {
|
|
2821
|
+
commitQueue.push(c);
|
|
2822
|
+
}
|
|
2823
|
+
break outer;
|
|
2824
|
+
}
|
|
2825
|
+
if (c.componentWillUpdate != null) {
|
|
2826
|
+
c.componentWillUpdate(newProps, c.__s, componentContext);
|
|
2827
|
+
}
|
|
2828
|
+
if (c.componentDidUpdate != null) {
|
|
2829
|
+
c.__h.push(function () {
|
|
2830
|
+
c.componentDidUpdate(oldProps, oldState, snapshot);
|
|
2831
|
+
});
|
|
2832
|
+
}
|
|
2833
|
+
}
|
|
2834
|
+
c.context = componentContext;
|
|
2835
|
+
c.props = newProps;
|
|
2836
|
+
c.__v = newVNode;
|
|
2837
|
+
c.__P = parentDom;
|
|
2838
|
+
var renderHook =
|
|
2839
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__r,
|
|
2840
|
+
count = 0;
|
|
2841
|
+
if (
|
|
2842
|
+
(_newType$prototype2 = newType.prototype) !== null &&
|
|
2843
|
+
_newType$prototype2 !== void 0 &&
|
|
2844
|
+
_newType$prototype2.render
|
|
2845
|
+
) {
|
|
2846
|
+
c.state = c.__s;
|
|
2847
|
+
c.__d = false;
|
|
2848
|
+
if (renderHook) renderHook(newVNode);
|
|
2849
|
+
tmp = c.render(c.props, c.state, c.context);
|
|
2850
|
+
for (var _i = 0; _i < c._sb.length; _i++) {
|
|
2851
|
+
c.__h.push(c._sb[_i]);
|
|
2852
|
+
}
|
|
2853
|
+
c._sb = [];
|
|
2854
|
+
}
|
|
2855
|
+
else {
|
|
2856
|
+
do {
|
|
2857
|
+
c.__d = false;
|
|
2858
|
+
if (renderHook) renderHook(newVNode);
|
|
2859
|
+
tmp = c.render(c.props, c.state, c.context);
|
|
2860
|
+
|
|
2861
|
+
// Handle setState called in render, see #2553
|
|
2862
|
+
c.state = c.__s;
|
|
2863
|
+
} while (c.__d && ++count < 25);
|
|
2864
|
+
}
|
|
2865
|
+
|
|
2866
|
+
// Handle setState called in render, see #2553
|
|
2867
|
+
c.state = c.__s;
|
|
2868
|
+
if (c.getChildContext != null) {
|
|
2869
|
+
globalContext = (0, _util__WEBPACK_IMPORTED_MODULE_5__.assign)(
|
|
2870
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_5__.assign)(
|
|
2871
|
+
{},
|
|
2872
|
+
globalContext
|
|
2873
|
+
),
|
|
2874
|
+
c.getChildContext()
|
|
2875
|
+
);
|
|
2876
|
+
}
|
|
2877
|
+
if (!isNew && c.getSnapshotBeforeUpdate != null) {
|
|
2878
|
+
snapshot = c.getSnapshotBeforeUpdate(oldProps, oldState);
|
|
2879
|
+
}
|
|
2880
|
+
var isTopLevelFragment =
|
|
2881
|
+
tmp != null &&
|
|
2882
|
+
tmp.type ===
|
|
2883
|
+
_create_element__WEBPACK_IMPORTED_MODULE_2__.Fragment &&
|
|
2884
|
+
tmp.key == null;
|
|
2885
|
+
var renderResult = isTopLevelFragment ? tmp.props.children : tmp;
|
|
2886
|
+
(0, _children__WEBPACK_IMPORTED_MODULE_3__.diffChildren)(
|
|
2887
|
+
parentDom,
|
|
2888
|
+
Array.isArray(renderResult) ? renderResult : [renderResult],
|
|
2889
|
+
newVNode,
|
|
2890
|
+
oldVNode,
|
|
2891
|
+
globalContext,
|
|
2892
|
+
isSvg,
|
|
2893
|
+
excessDomChildren,
|
|
2894
|
+
commitQueue,
|
|
2895
|
+
oldDom,
|
|
2896
|
+
isHydrating
|
|
2897
|
+
);
|
|
2898
|
+
c.base = newVNode.__e;
|
|
2899
|
+
|
|
2900
|
+
// We successfully rendered this VNode, unset any stored hydration/bailout state:
|
|
2901
|
+
newVNode.__h = null;
|
|
2902
|
+
if (c.__h.length) {
|
|
2903
|
+
commitQueue.push(c);
|
|
2904
|
+
}
|
|
2905
|
+
if (clearProcessingException) {
|
|
2906
|
+
c.__E = c.__ = null;
|
|
2907
|
+
}
|
|
2908
|
+
c.__e = false;
|
|
2909
|
+
}
|
|
2910
|
+
else if (
|
|
2911
|
+
excessDomChildren == null &&
|
|
2912
|
+
newVNode.__v === oldVNode.__v
|
|
2913
|
+
) {
|
|
2914
|
+
newVNode.__k = oldVNode.__k;
|
|
2915
|
+
newVNode.__e = oldVNode.__e;
|
|
2916
|
+
}
|
|
2917
|
+
else {
|
|
2918
|
+
var dom;
|
|
2919
|
+
dom = diffElementNodes(
|
|
2920
|
+
oldVNode.__e,
|
|
2921
|
+
newVNode,
|
|
2922
|
+
oldVNode,
|
|
2923
|
+
globalContext,
|
|
2924
|
+
isSvg,
|
|
2925
|
+
excessDomChildren,
|
|
2926
|
+
commitQueue,
|
|
2927
|
+
isHydrating
|
|
2928
|
+
);
|
|
2929
|
+
newVNode.__e = dom;
|
|
2930
|
+
}
|
|
2931
|
+
if ((tmp = _options__WEBPACK_IMPORTED_MODULE_6__['default'].diffed))
|
|
2932
|
+
tmp(newVNode);
|
|
2933
|
+
}
|
|
2934
|
+
catch (e) {
|
|
2935
|
+
newVNode.__v = null;
|
|
2936
|
+
// if hydrating or creating initial tree, bailout preserves DOM:
|
|
2937
|
+
if (isHydrating || excessDomChildren != null) {
|
|
2938
|
+
newVNode.__e = oldDom;
|
|
2939
|
+
newVNode.__h = !!isHydrating;
|
|
2940
|
+
excessDomChildren[excessDomChildren.indexOf(oldDom)] = null;
|
|
2941
|
+
// ^ could possibly be simplified to:
|
|
2942
|
+
// excessDomChildren.length = 0;
|
|
2943
|
+
}
|
|
2944
|
+
|
|
2945
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__e(
|
|
2946
|
+
e,
|
|
2947
|
+
newVNode,
|
|
2948
|
+
oldVNode
|
|
2949
|
+
);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
/**
|
|
2954
|
+
* @param {Array<import('../types/internal').Component>} commitQueue List of components
|
|
2955
|
+
* which have callbacks to invoke in commitRoot
|
|
2956
|
+
* @param {import('../types/internal').VNode} root
|
|
2957
|
+
*/
|
|
2958
|
+
function commitRoot(commitQueue, root) {
|
|
2959
|
+
if (_options__WEBPACK_IMPORTED_MODULE_6__['default'].__c)
|
|
2960
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__c(
|
|
2961
|
+
root,
|
|
2962
|
+
commitQueue
|
|
2963
|
+
);
|
|
2964
|
+
commitQueue.some(function (c) {
|
|
2965
|
+
try {
|
|
2966
|
+
// @ts-ignore Reuse the commitQueue variable here so the type changes
|
|
2967
|
+
commitQueue = c.__h;
|
|
2968
|
+
c.__h = [];
|
|
2969
|
+
commitQueue.some(function (cb) {
|
|
2970
|
+
// @ts-ignore See above ts-ignore on commitQueue
|
|
2971
|
+
cb.call(c);
|
|
2972
|
+
});
|
|
2973
|
+
}
|
|
2974
|
+
catch (e) {
|
|
2975
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__e(e, c.__v);
|
|
2976
|
+
}
|
|
2977
|
+
});
|
|
2978
|
+
}
|
|
2979
|
+
|
|
2980
|
+
/**
|
|
2981
|
+
* Diff two virtual nodes representing DOM element
|
|
2982
|
+
* @param {import('../types/internal').PreactElement} dom The DOM element representing
|
|
2983
|
+
* the virtual nodes being diffed
|
|
2984
|
+
* @param {import('../types/internal').VNode} newVNode The new virtual node
|
|
2985
|
+
* @param {import('../types/internal').VNode} oldVNode The old virtual node
|
|
2986
|
+
* @param {object} globalContext The current context object
|
|
2987
|
+
* @param {boolean} isSvg Whether or not this DOM node is an SVG node
|
|
2988
|
+
* @param {*} excessDomChildren
|
|
2989
|
+
* @param {Array<import('../types/internal').Component>} commitQueue List of components
|
|
2990
|
+
* which have callbacks to invoke in commitRoot
|
|
2991
|
+
* @param {boolean} isHydrating Whether or not we are in hydration
|
|
2992
|
+
* @returns {import('../types/internal').PreactElement}
|
|
2993
|
+
*/
|
|
2994
|
+
function diffElementNodes(
|
|
2995
|
+
dom,
|
|
2996
|
+
newVNode,
|
|
2997
|
+
oldVNode,
|
|
2998
|
+
globalContext,
|
|
2999
|
+
isSvg,
|
|
3000
|
+
excessDomChildren,
|
|
3001
|
+
commitQueue,
|
|
3002
|
+
isHydrating
|
|
3003
|
+
) {
|
|
3004
|
+
var oldProps = oldVNode.props;
|
|
3005
|
+
var newProps = newVNode.props;
|
|
3006
|
+
var nodeType = newVNode.type;
|
|
3007
|
+
var i = 0;
|
|
3008
|
+
|
|
3009
|
+
// Tracks entering and exiting SVG namespace when descending through the tree.
|
|
3010
|
+
if (nodeType === 'svg') isSvg = true;
|
|
3011
|
+
if (excessDomChildren != null) {
|
|
3012
|
+
for (; i < excessDomChildren.length; i++) {
|
|
3013
|
+
var child = excessDomChildren[i];
|
|
3014
|
+
|
|
3015
|
+
// if newVNode matches an element in excessDomChildren or the `dom`
|
|
3016
|
+
// argument matches an element in excessDomChildren, remove it from
|
|
3017
|
+
// excessDomChildren so it isn't later removed in diffChildren
|
|
3018
|
+
if (
|
|
3019
|
+
child &&
|
|
3020
|
+
'setAttribute' in child === !!nodeType &&
|
|
3021
|
+
(nodeType ? child.localName === nodeType : child.nodeType === 3)
|
|
3022
|
+
) {
|
|
3023
|
+
dom = child;
|
|
3024
|
+
excessDomChildren[i] = null;
|
|
3025
|
+
break;
|
|
3026
|
+
}
|
|
3027
|
+
}
|
|
3028
|
+
}
|
|
3029
|
+
if (dom == null) {
|
|
3030
|
+
if (nodeType === null) {
|
|
3031
|
+
// @ts-ignore createTextNode returns Text, we expect PreactElement
|
|
3032
|
+
// console.log('---',newProps);
|
|
3033
|
+
|
|
3034
|
+
return document.createTextNode(newProps);
|
|
3035
|
+
}
|
|
3036
|
+
if (isSvg) {
|
|
3037
|
+
dom = document.createElementNS(
|
|
3038
|
+
'http://www.w3.org/2000/svg',
|
|
3039
|
+
// @ts-ignore We know `newVNode.type` is a string
|
|
3040
|
+
nodeType
|
|
3041
|
+
);
|
|
3042
|
+
}
|
|
3043
|
+
else {
|
|
3044
|
+
dom = document.createElement(
|
|
3045
|
+
// @ts-ignore We know `newVNode.type` is a string
|
|
3046
|
+
nodeType,
|
|
3047
|
+
newProps.is && newProps
|
|
3048
|
+
);
|
|
3049
|
+
}
|
|
3050
|
+
|
|
3051
|
+
// we created a new parent, so none of the previously attached children can be reused:
|
|
3052
|
+
excessDomChildren = null;
|
|
3053
|
+
// we are creating a new node, so we can assume this is a new subtree (in case we are hydrating), this deopts the hydrate
|
|
3054
|
+
isHydrating = false;
|
|
3055
|
+
}
|
|
3056
|
+
dom.__v = newVNode;
|
|
3057
|
+
if (nodeType === null) {
|
|
3058
|
+
// During hydration, we still have to split merged text from SSR'd HTML.
|
|
3059
|
+
if (
|
|
3060
|
+
oldProps !== newProps &&
|
|
3061
|
+
(!isHydrating || dom.data !== newProps)
|
|
3062
|
+
) {
|
|
3063
|
+
dom.data = newProps;
|
|
3064
|
+
}
|
|
3065
|
+
}
|
|
3066
|
+
else {
|
|
3067
|
+
// If excessDomChildren was not null, repopulate it with the current element's children:
|
|
3068
|
+
excessDomChildren =
|
|
3069
|
+
excessDomChildren &&
|
|
3070
|
+
_util__WEBPACK_IMPORTED_MODULE_5__.slice.call(dom.childNodes);
|
|
3071
|
+
oldProps =
|
|
3072
|
+
oldVNode.props || _constants__WEBPACK_IMPORTED_MODULE_0__.EMPTY_OBJ;
|
|
3073
|
+
var oldHtml = oldProps.dangerouslySetInnerHTML;
|
|
3074
|
+
var newHtml = newProps.dangerouslySetInnerHTML;
|
|
3075
|
+
|
|
3076
|
+
// During hydration, props are not diffed at all (including dangerouslySetInnerHTML)
|
|
3077
|
+
// @TODO we should warn in debug mode when props don't match here.
|
|
3078
|
+
if (!isHydrating) {
|
|
3079
|
+
// But, if we are in a situation where we are using existing DOM (e.g. replaceNode)
|
|
3080
|
+
// we should read the existing DOM attributes to diff them
|
|
3081
|
+
if (excessDomChildren != null) {
|
|
3082
|
+
oldProps = {};
|
|
3083
|
+
for (i = 0; i < dom.attributes.length; i++) {
|
|
3084
|
+
oldProps[dom.attributes[i].name] = dom.attributes[i].value;
|
|
3085
|
+
}
|
|
3086
|
+
}
|
|
3087
|
+
if (newHtml || oldHtml) {
|
|
3088
|
+
// Avoid re-applying the same '__html' if it did not changed between re-render
|
|
3089
|
+
if (
|
|
3090
|
+
!newHtml ||
|
|
3091
|
+
((!oldHtml || newHtml.__html != oldHtml.__html) &&
|
|
3092
|
+
newHtml.__html !== dom.innerHTML)
|
|
3093
|
+
) {
|
|
3094
|
+
dom.innerHTML = (newHtml && newHtml.__html) || '';
|
|
3095
|
+
}
|
|
3096
|
+
}
|
|
3097
|
+
}
|
|
3098
|
+
(0, _props__WEBPACK_IMPORTED_MODULE_4__.diffProps)(
|
|
3099
|
+
dom,
|
|
3100
|
+
newProps,
|
|
3101
|
+
oldProps,
|
|
3102
|
+
isSvg,
|
|
3103
|
+
isHydrating
|
|
3104
|
+
);
|
|
3105
|
+
|
|
3106
|
+
// If the new vnode didn't have dangerouslySetInnerHTML, diff its children
|
|
3107
|
+
if (newHtml) {
|
|
3108
|
+
newVNode.__k = [];
|
|
3109
|
+
}
|
|
3110
|
+
else {
|
|
3111
|
+
var _i2 = newVNode.props.children;
|
|
3112
|
+
(0, _children__WEBPACK_IMPORTED_MODULE_3__.diffChildren)(
|
|
3113
|
+
dom,
|
|
3114
|
+
Array.isArray(_i2) ? _i2 : [_i2],
|
|
3115
|
+
newVNode,
|
|
3116
|
+
oldVNode,
|
|
3117
|
+
globalContext,
|
|
3118
|
+
isSvg && nodeType !== 'foreignObject',
|
|
3119
|
+
excessDomChildren,
|
|
3120
|
+
commitQueue,
|
|
3121
|
+
excessDomChildren
|
|
3122
|
+
? excessDomChildren[0]
|
|
3123
|
+
: oldVNode.__k &&
|
|
3124
|
+
(0, _component__WEBPACK_IMPORTED_MODULE_1__.getDomSibling)(
|
|
3125
|
+
oldVNode,
|
|
3126
|
+
0
|
|
3127
|
+
),
|
|
3128
|
+
isHydrating
|
|
3129
|
+
);
|
|
3130
|
+
// Remove children that are not part of any vnode.
|
|
3131
|
+
if (excessDomChildren != null) {
|
|
3132
|
+
for (_i2 = excessDomChildren.length; _i2--; ) {
|
|
3133
|
+
if (excessDomChildren[_i2] != null)
|
|
3134
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_5__.removeNode)(
|
|
3135
|
+
excessDomChildren[_i2]
|
|
3136
|
+
);
|
|
3137
|
+
}
|
|
3138
|
+
}
|
|
3139
|
+
}
|
|
3140
|
+
|
|
3141
|
+
// (as above, don't diff props during hydration)
|
|
3142
|
+
if (!isHydrating) {
|
|
3143
|
+
if (
|
|
3144
|
+
'value' in newProps &&
|
|
3145
|
+
(i = newProps.value) !== undefined &&
|
|
3146
|
+
// #2756 For the <progress>-element the initial value is 0,
|
|
3147
|
+
// despite the attribute not being present. When the attribute
|
|
3148
|
+
// is missing the progress bar is treated as indeterminate.
|
|
3149
|
+
// To fix that we'll always update it when it is 0 for progress elements
|
|
3150
|
+
(i !== dom.value ||
|
|
3151
|
+
(nodeType === 'progress' && !i) ||
|
|
3152
|
+
// This is only for IE 11 to fix <select> value not being updated.
|
|
3153
|
+
// To avoid a stale select value we need to set the option.value
|
|
3154
|
+
// again, which triggers IE11 to re-evaluate the select value
|
|
3155
|
+
(nodeType === 'option' && i !== oldProps.value))
|
|
3156
|
+
) {
|
|
3157
|
+
(0, _props__WEBPACK_IMPORTED_MODULE_4__.setProperty)(
|
|
3158
|
+
dom,
|
|
3159
|
+
'value',
|
|
3160
|
+
i,
|
|
3161
|
+
oldProps.value,
|
|
3162
|
+
false
|
|
3163
|
+
);
|
|
3164
|
+
}
|
|
3165
|
+
if (
|
|
3166
|
+
'checked' in newProps &&
|
|
3167
|
+
(i = newProps.checked) !== undefined &&
|
|
3168
|
+
i !== dom.checked
|
|
3169
|
+
) {
|
|
3170
|
+
(0, _props__WEBPACK_IMPORTED_MODULE_4__.setProperty)(
|
|
3171
|
+
dom,
|
|
3172
|
+
'checked',
|
|
3173
|
+
i,
|
|
3174
|
+
oldProps.checked,
|
|
3175
|
+
false
|
|
3176
|
+
);
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
return dom;
|
|
3181
|
+
}
|
|
3182
|
+
|
|
3183
|
+
/**
|
|
3184
|
+
* Invoke or update a ref, depending on whether it is a function or object ref.
|
|
3185
|
+
* @param {object|function} ref
|
|
3186
|
+
* @param {any} value
|
|
3187
|
+
* @param {import('../types/internal').VNode} vnode
|
|
3188
|
+
*/
|
|
3189
|
+
function applyRef(ref, value, vnode) {
|
|
3190
|
+
try {
|
|
3191
|
+
if (typeof ref == 'function') ref(value);
|
|
3192
|
+
else ref.current = value;
|
|
3193
|
+
}
|
|
3194
|
+
catch (e) {
|
|
3195
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__e(e, vnode);
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
|
|
3199
|
+
/**
|
|
3200
|
+
* Unmount a virtual node from the tree and apply DOM changes
|
|
3201
|
+
* @param {import('../types/internal').VNode} vnode The virtual node to unmount
|
|
3202
|
+
* @param {import('../types/internal').VNode} parentVNode The parent of the VNode that
|
|
3203
|
+
* initiated the unmount
|
|
3204
|
+
* @param {boolean} [skipRemove] Flag that indicates that a parent node of the
|
|
3205
|
+
* current element is already detached from the DOM.
|
|
3206
|
+
*/
|
|
3207
|
+
function unmount(vnode, parentVNode, skipRemove) {
|
|
3208
|
+
var r;
|
|
3209
|
+
if (_options__WEBPACK_IMPORTED_MODULE_6__['default'].unmount)
|
|
3210
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].unmount(vnode);
|
|
3211
|
+
if ((r = vnode.ref)) {
|
|
3212
|
+
if (!r.current || r.current === vnode.__e) {
|
|
3213
|
+
applyRef(r, null, parentVNode);
|
|
3214
|
+
}
|
|
3215
|
+
}
|
|
3216
|
+
if ((r = vnode.__c) != null) {
|
|
3217
|
+
if (r.componentWillUnmount) {
|
|
3218
|
+
try {
|
|
3219
|
+
r.componentWillUnmount();
|
|
3220
|
+
}
|
|
3221
|
+
catch (e) {
|
|
3222
|
+
_options__WEBPACK_IMPORTED_MODULE_6__['default'].__e(
|
|
3223
|
+
e,
|
|
3224
|
+
parentVNode
|
|
3225
|
+
);
|
|
3226
|
+
}
|
|
3227
|
+
}
|
|
3228
|
+
r.base = r.__P = null;
|
|
3229
|
+
vnode.__c = undefined;
|
|
3230
|
+
}
|
|
3231
|
+
if ((r = vnode.__k)) {
|
|
3232
|
+
for (var i = 0; i < r.length; i++) {
|
|
3233
|
+
if (r[i]) {
|
|
3234
|
+
unmount(
|
|
3235
|
+
r[i],
|
|
3236
|
+
parentVNode,
|
|
3237
|
+
skipRemove || typeof vnode.type !== 'function'
|
|
3238
|
+
);
|
|
3239
|
+
}
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
if (!skipRemove && vnode.__e != null) {
|
|
3243
|
+
(0, _util__WEBPACK_IMPORTED_MODULE_5__.removeNode)(vnode.__e);
|
|
3244
|
+
}
|
|
3245
|
+
|
|
3246
|
+
// Must be set to `undefined` to properly clean up `_nextDom`
|
|
3247
|
+
// for which `null` is a valid value. See comment in `create-element.js`
|
|
3248
|
+
vnode.__ = vnode.__e = vnode.__d = undefined;
|
|
3249
|
+
}
|
|
3250
|
+
|
|
3251
|
+
/** The `.render()` method for a PFC backing instance. */
|
|
3252
|
+
function doRender(props, state, context) {
|
|
3253
|
+
return this.constructor(props, context);
|
|
3254
|
+
}
|
|
3255
|
+
|
|
3256
|
+
/***/
|
|
3257
|
+
},
|
|
3258
|
+
|
|
3259
|
+
/***/ './src/diff/props.js':
|
|
3260
|
+
/*!***************************!*\
|
|
3261
|
+
!*** ./src/diff/props.js ***!
|
|
3262
|
+
\***************************/
|
|
3263
|
+
/***/ (
|
|
3264
|
+
__unused_webpack_module,
|
|
3265
|
+
__webpack_exports__,
|
|
3266
|
+
__webpack_require__
|
|
3267
|
+
) => {
|
|
3268
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3269
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3270
|
+
/* harmony export */ diffProps: () => /* binding */ diffProps,
|
|
3271
|
+
/* harmony export */ setProperty: () => /* binding */ setProperty,
|
|
3272
|
+
/* harmony export */
|
|
3273
|
+
});
|
|
3274
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3275
|
+
__webpack_require__(/*! ../constants */ './src/constants.js');
|
|
3276
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_1__ =
|
|
3277
|
+
__webpack_require__(/*! ../options */ './src/options.js');
|
|
3278
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_2__ =
|
|
3279
|
+
__webpack_require__(/*! ../util */ './src/util.js');
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* Diff the old and new properties of a VNode and apply changes to the DOM node
|
|
3283
|
+
* @param {import('../types/internal').PreactElement} dom The DOM node to apply
|
|
3284
|
+
* changes to
|
|
3285
|
+
* @param {object} newProps The new props
|
|
3286
|
+
* @param {object} oldProps The old props
|
|
3287
|
+
* @param {boolean} isSvg Whether or not this node is an SVG node
|
|
3288
|
+
* @param {boolean} hydrate Whether or not we are in hydration mode
|
|
3289
|
+
*/
|
|
3290
|
+
function diffProps(dom, newProps, oldProps, isSvg, hydrate) {
|
|
3291
|
+
var i;
|
|
3292
|
+
for (i in oldProps) {
|
|
3293
|
+
if (i !== 'children' && i !== 'key' && !(i in newProps)) {
|
|
3294
|
+
setProperty(dom, i, null, oldProps[i], isSvg);
|
|
3295
|
+
}
|
|
3296
|
+
}
|
|
3297
|
+
for (i in newProps) {
|
|
3298
|
+
if (
|
|
3299
|
+
(!hydrate || typeof newProps[i] == 'function') &&
|
|
3300
|
+
i !== 'children' &&
|
|
3301
|
+
i !== 'key' &&
|
|
3302
|
+
i !== 'value' &&
|
|
3303
|
+
i !== 'checked' &&
|
|
3304
|
+
oldProps[i] !== newProps[i]
|
|
3305
|
+
) {
|
|
3306
|
+
setProperty(dom, i, newProps[i], oldProps[i], isSvg);
|
|
3307
|
+
}
|
|
3308
|
+
}
|
|
3309
|
+
}
|
|
3310
|
+
function setStyle(style, key, value) {
|
|
3311
|
+
if (key[0] === '-') {
|
|
3312
|
+
style.setProperty(key, value);
|
|
3313
|
+
}
|
|
3314
|
+
else if (value == null) {
|
|
3315
|
+
style[key] = '';
|
|
3316
|
+
}
|
|
3317
|
+
else if (
|
|
3318
|
+
typeof value != 'number' ||
|
|
3319
|
+
_constants__WEBPACK_IMPORTED_MODULE_0__.IS_NON_DIMENSIONAL.test(key)
|
|
3320
|
+
) {
|
|
3321
|
+
style[key] = value;
|
|
3322
|
+
}
|
|
3323
|
+
else {
|
|
3324
|
+
style[key] = value + 'px';
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3328
|
+
/**
|
|
3329
|
+
* Set a property value on a DOM node
|
|
3330
|
+
* @param {import('../types/internal').PreactElement} dom The DOM node to modify
|
|
3331
|
+
* @param {string} name The name of the property to set
|
|
3332
|
+
* @param {*} value The value to set the property to
|
|
3333
|
+
* @param {*} oldValue The old value the property had
|
|
3334
|
+
* @param {boolean} isSvg Whether or not this DOM node is an SVG node or not
|
|
3335
|
+
*/
|
|
3336
|
+
function setProperty(dom, name, value, oldValue, isSvg) {
|
|
3337
|
+
var useCapture;
|
|
3338
|
+
o: if (name === 'style') {
|
|
3339
|
+
if (typeof value == 'string') {
|
|
3340
|
+
dom.style.cssText = value;
|
|
3341
|
+
}
|
|
3342
|
+
else {
|
|
3343
|
+
if (typeof oldValue == 'string') {
|
|
3344
|
+
dom.style.cssText = oldValue = '';
|
|
3345
|
+
}
|
|
3346
|
+
if (oldValue) {
|
|
3347
|
+
for (name in oldValue) {
|
|
3348
|
+
if (!(value && name in value)) {
|
|
3349
|
+
setStyle(dom.style, name, '');
|
|
3350
|
+
}
|
|
3351
|
+
}
|
|
3352
|
+
}
|
|
3353
|
+
if (value) {
|
|
3354
|
+
for (name in value) {
|
|
3355
|
+
if (!oldValue || value[name] !== oldValue[name]) {
|
|
3356
|
+
setStyle(dom.style, name, value[name]);
|
|
3357
|
+
}
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
}
|
|
3362
|
+
// Benchmark for comparison: https://esbench.com/bench/574c954bdb965b9a00965ac6
|
|
3363
|
+
else if (name[0] === 'o' && name[1] === 'n') {
|
|
3364
|
+
useCapture = name !== (name = name.replace(/Capture$/, ''));
|
|
3365
|
+
|
|
3366
|
+
// Infer correct casing for DOM built-in events:
|
|
3367
|
+
if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);
|
|
3368
|
+
else name = name.slice(2);
|
|
3369
|
+
if (!dom.l) dom.l = {};
|
|
3370
|
+
dom.l[name + useCapture] = value;
|
|
3371
|
+
if (value) {
|
|
3372
|
+
if (!oldValue) {
|
|
3373
|
+
var handler = useCapture ? eventProxyCapture : eventProxy;
|
|
3374
|
+
dom.addEventListener(name, handler, useCapture);
|
|
3375
|
+
}
|
|
3376
|
+
}
|
|
3377
|
+
else {
|
|
3378
|
+
var _handler = useCapture ? eventProxyCapture : eventProxy;
|
|
3379
|
+
dom.removeEventListener(name, _handler, useCapture);
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
else if (name !== 'dangerouslySetInnerHTML') {
|
|
3383
|
+
if (isSvg) {
|
|
3384
|
+
// Normalize incorrect prop usage for SVG:
|
|
3385
|
+
// - xlink:href / xlinkHref --> href (xlink:href was removed from SVG and isn't needed)
|
|
3386
|
+
// - className --> class
|
|
3387
|
+
name = name.replace(/xlink(H|:h)/, 'h').replace(/sName$/, 's');
|
|
3388
|
+
}
|
|
3389
|
+
else if (
|
|
3390
|
+
name !== 'href' &&
|
|
3391
|
+
name !== 'list' &&
|
|
3392
|
+
name !== 'form' &&
|
|
3393
|
+
// Default value in browsers is `-1` and an empty string is
|
|
3394
|
+
// cast to `0` instead
|
|
3395
|
+
name !== 'tabIndex' &&
|
|
3396
|
+
name !== 'download' &&
|
|
3397
|
+
name in dom
|
|
3398
|
+
) {
|
|
3399
|
+
try {
|
|
3400
|
+
dom[name] = value == null ? '' : value;
|
|
3401
|
+
// labelled break is 1b smaller here than a return statement (sorry)
|
|
3402
|
+
break o;
|
|
3403
|
+
}
|
|
3404
|
+
catch (e) {}
|
|
3405
|
+
}
|
|
3406
|
+
|
|
3407
|
+
// ARIA-attributes have a different notion of boolean values.
|
|
3408
|
+
// The value `false` is different from the attribute not
|
|
3409
|
+
// existing on the DOM, so we can't remove it. For non-boolean
|
|
3410
|
+
// ARIA-attributes we could treat false as a removal, but the
|
|
3411
|
+
// amount of exceptions would cost us too many bytes. On top of
|
|
3412
|
+
// that other VDOM frameworks also always stringify `false`.
|
|
3413
|
+
|
|
3414
|
+
if (typeof value === 'function') {
|
|
3415
|
+
// never serialize functions as attribute values
|
|
3416
|
+
}
|
|
3417
|
+
else if (
|
|
3418
|
+
value != null &&
|
|
3419
|
+
(value !== false || name.indexOf('-') != -1)
|
|
3420
|
+
) {
|
|
3421
|
+
dom.setAttribute(name, value);
|
|
3422
|
+
}
|
|
3423
|
+
else {
|
|
3424
|
+
dom.removeAttribute(name);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
|
|
3429
|
+
/**
|
|
3430
|
+
* Proxy an event to hooked event handlers
|
|
3431
|
+
* @param {Event} e The event object from the browser
|
|
3432
|
+
* @private
|
|
3433
|
+
*/
|
|
3434
|
+
function eventProxy(e) {
|
|
3435
|
+
this.l[e.type + false](
|
|
3436
|
+
_options__WEBPACK_IMPORTED_MODULE_1__['default'].event
|
|
3437
|
+
? _options__WEBPACK_IMPORTED_MODULE_1__['default'].event(e)
|
|
3438
|
+
: e
|
|
3439
|
+
);
|
|
3440
|
+
}
|
|
3441
|
+
function eventProxyCapture(e) {
|
|
3442
|
+
this.l[e.type + true](
|
|
3443
|
+
_options__WEBPACK_IMPORTED_MODULE_1__['default'].event
|
|
3444
|
+
? _options__WEBPACK_IMPORTED_MODULE_1__['default'].event(e)
|
|
3445
|
+
: e
|
|
3446
|
+
);
|
|
3447
|
+
}
|
|
3448
|
+
|
|
3449
|
+
/***/
|
|
3450
|
+
},
|
|
3451
|
+
|
|
3452
|
+
/***/ './src/index.js':
|
|
3453
|
+
/*!**********************!*\
|
|
3454
|
+
!*** ./src/index.js ***!
|
|
3455
|
+
\**********************/
|
|
3456
|
+
/***/ (
|
|
3457
|
+
__unused_webpack_module,
|
|
3458
|
+
__webpack_exports__,
|
|
3459
|
+
__webpack_require__
|
|
3460
|
+
) => {
|
|
3461
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3462
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3463
|
+
/* harmony export */ Component: () =>
|
|
3464
|
+
/* reexport safe */ _component__WEBPACK_IMPORTED_MODULE_2__.Component,
|
|
3465
|
+
/* harmony export */ Fragment: () =>
|
|
3466
|
+
/* reexport safe */ _create_element__WEBPACK_IMPORTED_MODULE_1__.Fragment,
|
|
3467
|
+
/* harmony export */ cloneElement: () =>
|
|
3468
|
+
/* reexport safe */ _clone_element__WEBPACK_IMPORTED_MODULE_3__.cloneElement,
|
|
3469
|
+
/* harmony export */ createContext: () =>
|
|
3470
|
+
/* reexport safe */ _create_context__WEBPACK_IMPORTED_MODULE_4__.createContext,
|
|
3471
|
+
/* harmony export */ createElement: () =>
|
|
3472
|
+
/* reexport safe */ _create_element__WEBPACK_IMPORTED_MODULE_1__.createElement,
|
|
3473
|
+
/* harmony export */ createRef: () =>
|
|
3474
|
+
/* reexport safe */ _create_element__WEBPACK_IMPORTED_MODULE_1__.createRef,
|
|
3475
|
+
/* harmony export */ h: () =>
|
|
3476
|
+
/* reexport safe */ _create_element__WEBPACK_IMPORTED_MODULE_1__.createElement,
|
|
3477
|
+
/* harmony export */ hydrate: () =>
|
|
3478
|
+
/* reexport safe */ _render__WEBPACK_IMPORTED_MODULE_0__.hydrate,
|
|
3479
|
+
/* harmony export */ isValidElement: () =>
|
|
3480
|
+
/* reexport safe */ _create_element__WEBPACK_IMPORTED_MODULE_1__.isValidElement,
|
|
3481
|
+
/* harmony export */ options: () =>
|
|
3482
|
+
/* reexport safe */ _options__WEBPACK_IMPORTED_MODULE_6__['default'],
|
|
3483
|
+
/* harmony export */ render: () =>
|
|
3484
|
+
/* reexport safe */ _render__WEBPACK_IMPORTED_MODULE_0__.render,
|
|
3485
|
+
/* harmony export */ toChildArray: () =>
|
|
3486
|
+
/* reexport safe */ _diff_children__WEBPACK_IMPORTED_MODULE_5__.toChildArray,
|
|
3487
|
+
/* harmony export */
|
|
3488
|
+
});
|
|
3489
|
+
/* harmony import */ var _render__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3490
|
+
__webpack_require__(/*! ./render */ './src/render.js');
|
|
3491
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_1__ =
|
|
3492
|
+
__webpack_require__(/*! ./create-element */ './src/create-element.js');
|
|
3493
|
+
/* harmony import */ var _component__WEBPACK_IMPORTED_MODULE_2__ =
|
|
3494
|
+
__webpack_require__(/*! ./component */ './src/component.js');
|
|
3495
|
+
/* harmony import */ var _clone_element__WEBPACK_IMPORTED_MODULE_3__ =
|
|
3496
|
+
__webpack_require__(/*! ./clone-element */ './src/clone-element.js');
|
|
3497
|
+
/* harmony import */ var _create_context__WEBPACK_IMPORTED_MODULE_4__ =
|
|
3498
|
+
__webpack_require__(/*! ./create-context */ './src/create-context.js');
|
|
3499
|
+
/* harmony import */ var _diff_children__WEBPACK_IMPORTED_MODULE_5__ =
|
|
3500
|
+
__webpack_require__(/*! ./diff/children */ './src/diff/children.js');
|
|
3501
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_6__ =
|
|
3502
|
+
__webpack_require__(/*! ./options */ './src/options.js');
|
|
3503
|
+
|
|
3504
|
+
/***/
|
|
3505
|
+
},
|
|
3506
|
+
|
|
3507
|
+
/***/ './src/options.js':
|
|
3508
|
+
/*!************************!*\
|
|
3509
|
+
!*** ./src/options.js ***!
|
|
3510
|
+
\************************/
|
|
3511
|
+
/***/ (
|
|
3512
|
+
__unused_webpack_module,
|
|
3513
|
+
__webpack_exports__,
|
|
3514
|
+
__webpack_require__
|
|
3515
|
+
) => {
|
|
3516
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3517
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3518
|
+
/* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
|
|
3519
|
+
/* harmony export */
|
|
3520
|
+
});
|
|
3521
|
+
/* harmony import */ var _diff_catch_error__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3522
|
+
__webpack_require__(
|
|
3523
|
+
/*! ./diff/catch-error */ './src/diff/catch-error.js'
|
|
3524
|
+
);
|
|
3525
|
+
|
|
3526
|
+
/**
|
|
3527
|
+
* The `option` object can potentially contain callback functions
|
|
3528
|
+
* that are called during various stages of our renderer. This is the
|
|
3529
|
+
* foundation on which all our addons like `preact/debug`, `preact/compat`,
|
|
3530
|
+
* and `preact/hooks` are based on. See the `Options` type in `internal.d.ts`
|
|
3531
|
+
* for a full list of available option hooks (most editors/IDEs allow you to
|
|
3532
|
+
* ctrl+click or cmd+click on mac the type definition below).
|
|
3533
|
+
* @type {import('./internal').Options}
|
|
3534
|
+
*/
|
|
3535
|
+
var options = {
|
|
3536
|
+
__e: _diff_catch_error__WEBPACK_IMPORTED_MODULE_0__._catchError,
|
|
3537
|
+
};
|
|
3538
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = options;
|
|
3539
|
+
|
|
3540
|
+
/***/
|
|
3541
|
+
},
|
|
3542
|
+
|
|
3543
|
+
/***/ './src/render.js':
|
|
3544
|
+
/*!***********************!*\
|
|
3545
|
+
!*** ./src/render.js ***!
|
|
3546
|
+
\***********************/
|
|
3547
|
+
/***/ (
|
|
3548
|
+
__unused_webpack_module,
|
|
3549
|
+
__webpack_exports__,
|
|
3550
|
+
__webpack_require__
|
|
3551
|
+
) => {
|
|
3552
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3553
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3554
|
+
/* harmony export */ hydrate: () => /* binding */ hydrate,
|
|
3555
|
+
/* harmony export */ render: () => /* binding */ render,
|
|
3556
|
+
/* harmony export */
|
|
3557
|
+
});
|
|
3558
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3559
|
+
__webpack_require__(/*! ./constants */ './src/constants.js');
|
|
3560
|
+
/* harmony import */ var _diff_index__WEBPACK_IMPORTED_MODULE_1__ =
|
|
3561
|
+
__webpack_require__(/*! ./diff/index */ './src/diff/index.js');
|
|
3562
|
+
/* harmony import */ var _create_element__WEBPACK_IMPORTED_MODULE_2__ =
|
|
3563
|
+
__webpack_require__(/*! ./create-element */ './src/create-element.js');
|
|
3564
|
+
/* harmony import */ var _options__WEBPACK_IMPORTED_MODULE_3__ =
|
|
3565
|
+
__webpack_require__(/*! ./options */ './src/options.js');
|
|
3566
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_4__ =
|
|
3567
|
+
__webpack_require__(/*! ./util */ './src/util.js');
|
|
3568
|
+
|
|
3569
|
+
/**
|
|
3570
|
+
* Render a Preact virtual node into a DOM element
|
|
3571
|
+
* @param {import('./internal').ComponentChild} vnode The virtual node to render
|
|
3572
|
+
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
|
3573
|
+
* render into
|
|
3574
|
+
* @param {import('./internal').PreactElement | object} [replaceNode] Optional: Attempt to re-use an
|
|
3575
|
+
* existing DOM tree rooted at `replaceNode`
|
|
3576
|
+
*/
|
|
3577
|
+
function render(vnode, parentDom, replaceNode) {
|
|
3578
|
+
if (_options__WEBPACK_IMPORTED_MODULE_3__['default'].__)
|
|
3579
|
+
_options__WEBPACK_IMPORTED_MODULE_3__['default'].__(vnode, parentDom);
|
|
3580
|
+
|
|
3581
|
+
// We abuse the `replaceNode` parameter in `hydrate()` to signal if we are in
|
|
3582
|
+
// hydration mode or not by passing the `hydrate` function instead of a DOM
|
|
3583
|
+
// element..
|
|
3584
|
+
var isHydrating = typeof replaceNode === 'function';
|
|
3585
|
+
|
|
3586
|
+
// To be able to support calling `render()` multiple times on the same
|
|
3587
|
+
// DOM node, we need to obtain a reference to the previous tree. We do
|
|
3588
|
+
// this by assigning a new `_children` property to DOM nodes which points
|
|
3589
|
+
// to the last rendered tree. By default this property is not present, which
|
|
3590
|
+
// means that we are mounting a new tree for the first time.
|
|
3591
|
+
var oldVNode = isHydrating
|
|
3592
|
+
? null
|
|
3593
|
+
: (replaceNode && replaceNode.__k) || parentDom.__k;
|
|
3594
|
+
vnode = ((!isHydrating && replaceNode) || parentDom).__k = (0,
|
|
3595
|
+
_create_element__WEBPACK_IMPORTED_MODULE_2__.createElement)(
|
|
3596
|
+
_create_element__WEBPACK_IMPORTED_MODULE_2__.Fragment,
|
|
3597
|
+
null,
|
|
3598
|
+
[vnode]
|
|
3599
|
+
);
|
|
3600
|
+
|
|
3601
|
+
// List of effects that need to be called after diffing.
|
|
3602
|
+
var commitQueue = [];
|
|
3603
|
+
vnode.props.id = 'proot';
|
|
3604
|
+
(0, _diff_index__WEBPACK_IMPORTED_MODULE_1__.diff)(
|
|
3605
|
+
parentDom,
|
|
3606
|
+
// Determine the new vnode tree and store it on the DOM element on
|
|
3607
|
+
// our custom `_children` property.
|
|
3608
|
+
vnode,
|
|
3609
|
+
oldVNode || _constants__WEBPACK_IMPORTED_MODULE_0__.EMPTY_OBJ,
|
|
3610
|
+
_constants__WEBPACK_IMPORTED_MODULE_0__.EMPTY_OBJ,
|
|
3611
|
+
parentDom.ownerSVGElement !== undefined,
|
|
3612
|
+
!isHydrating && replaceNode
|
|
3613
|
+
? [replaceNode]
|
|
3614
|
+
: oldVNode
|
|
3615
|
+
? null
|
|
3616
|
+
: parentDom.firstChild
|
|
3617
|
+
? _util__WEBPACK_IMPORTED_MODULE_4__.slice.call(
|
|
3618
|
+
parentDom.childNodes
|
|
3619
|
+
)
|
|
3620
|
+
: null,
|
|
3621
|
+
commitQueue,
|
|
3622
|
+
!isHydrating && replaceNode
|
|
3623
|
+
? replaceNode
|
|
3624
|
+
: oldVNode
|
|
3625
|
+
? oldVNode.__e
|
|
3626
|
+
: parentDom.firstChild,
|
|
3627
|
+
isHydrating
|
|
3628
|
+
);
|
|
3629
|
+
|
|
3630
|
+
// Flush all queued effects
|
|
3631
|
+
(0, _diff_index__WEBPACK_IMPORTED_MODULE_1__.commitRoot)(
|
|
3632
|
+
commitQueue,
|
|
3633
|
+
vnode
|
|
3634
|
+
);
|
|
3635
|
+
return commitQueue;
|
|
3636
|
+
}
|
|
3637
|
+
|
|
3638
|
+
/**
|
|
3639
|
+
* Update an existing DOM element with data from a Preact virtual node
|
|
3640
|
+
* @param {import('./internal').ComponentChild} vnode The virtual node to render
|
|
3641
|
+
* @param {import('./internal').PreactElement} parentDom The DOM element to
|
|
3642
|
+
* updateimport logger from '../demo/logger';
|
|
3643
|
+
|
|
3644
|
+
*/
|
|
3645
|
+
function hydrate(vnode, parentDom) {
|
|
3646
|
+
render(vnode, parentDom, hydrate);
|
|
3647
|
+
}
|
|
3648
|
+
|
|
3649
|
+
/***/
|
|
3650
|
+
},
|
|
3651
|
+
|
|
3652
|
+
/***/ './src/util.js':
|
|
3653
|
+
/*!*********************!*\
|
|
3654
|
+
!*** ./src/util.js ***!
|
|
3655
|
+
\*********************/
|
|
3656
|
+
/***/ (
|
|
3657
|
+
__unused_webpack_module,
|
|
3658
|
+
__webpack_exports__,
|
|
3659
|
+
__webpack_require__
|
|
3660
|
+
) => {
|
|
3661
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3662
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3663
|
+
/* harmony export */ assign: () => /* binding */ assign,
|
|
3664
|
+
/* harmony export */ makeTaskQueue: () => /* binding */ makeTaskQueue,
|
|
3665
|
+
/* harmony export */ removeNode: () => /* binding */ removeNode,
|
|
3666
|
+
/* harmony export */ slice: () => /* binding */ slice,
|
|
3667
|
+
/* harmony export */ vnName: () => /* binding */ vnName,
|
|
3668
|
+
/* harmony export */
|
|
3669
|
+
});
|
|
3670
|
+
/* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3671
|
+
__webpack_require__(/*! ./constants */ './src/constants.js');
|
|
3672
|
+
|
|
3673
|
+
/**
|
|
3674
|
+
* Assign properties from `props` to `obj`
|
|
3675
|
+
* @template O, P The obj and props types
|
|
3676
|
+
* @param {O} obj The object to copy properties to
|
|
3677
|
+
* @param {P} props The object to copy properties from
|
|
3678
|
+
* @returns {O & P}
|
|
3679
|
+
*/
|
|
3680
|
+
function assign(obj, props) {
|
|
3681
|
+
// @ts-ignore We change the type of `obj` to be `O & P`
|
|
3682
|
+
for (var i in props) {
|
|
3683
|
+
obj[i] = props[i];
|
|
3684
|
+
}
|
|
3685
|
+
return /** @type {O & P} */ obj;
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
/**
|
|
3689
|
+
* Remove a child node from its parent if attached. This is a workaround for
|
|
3690
|
+
* IE11 which doesn't support `Element.prototype.remove()`. Using this function
|
|
3691
|
+
* is smaller than including a dedicated polyfill.
|
|
3692
|
+
* @param {Node} node The node to remove
|
|
3693
|
+
*/
|
|
3694
|
+
function removeNode(node) {
|
|
3695
|
+
var parentNode = node.parentNode;
|
|
3696
|
+
if (parentNode) parentNode.removeChild(node);
|
|
3697
|
+
}
|
|
3698
|
+
var slice = _constants__WEBPACK_IMPORTED_MODULE_0__.EMPTY_ARR.slice;
|
|
3699
|
+
function makeTaskQueue(que) {
|
|
3700
|
+
que.task = {};
|
|
3701
|
+
que.task.pushChild = function (where, f) {
|
|
3702
|
+
if (!que.cur) {
|
|
3703
|
+
que.cur = {
|
|
3704
|
+
children: [],
|
|
3705
|
+
task: f,
|
|
3706
|
+
};
|
|
3707
|
+
que.root = que.cur;
|
|
3708
|
+
}
|
|
3709
|
+
else {
|
|
3710
|
+
que.cur.children.push({
|
|
3711
|
+
children: [],
|
|
3712
|
+
task: f,
|
|
3713
|
+
parent: que.cur,
|
|
3714
|
+
});
|
|
3715
|
+
}
|
|
3716
|
+
};
|
|
3717
|
+
que.task.run = function () {
|
|
3718
|
+
var maxStep = 1000;
|
|
3719
|
+
while (que.cur) {
|
|
3720
|
+
var _que$cur = que.cur,
|
|
3721
|
+
cpos = _que$cur.cpos,
|
|
3722
|
+
children = _que$cur.children,
|
|
3723
|
+
task = _que$cur.task,
|
|
3724
|
+
parent = _que$cur.parent;
|
|
3725
|
+
// console.log('ctask',i);
|
|
3726
|
+
|
|
3727
|
+
if (!cpos) {
|
|
3728
|
+
if (task) {
|
|
3729
|
+
que.cur.ret = task();
|
|
3730
|
+
}
|
|
3731
|
+
cpos = 0;
|
|
3732
|
+
}
|
|
3733
|
+
if (cpos < children.length) {
|
|
3734
|
+
var next = children[cpos];
|
|
3735
|
+
que.cur.cpos = cpos + 1;
|
|
3736
|
+
que.cur = next;
|
|
3737
|
+
}
|
|
3738
|
+
else if (parent) {
|
|
3739
|
+
que.lastRet = que.cur.ret;
|
|
3740
|
+
que.cur = parent;
|
|
3741
|
+
}
|
|
3742
|
+
else {
|
|
3743
|
+
break;
|
|
3744
|
+
}
|
|
3745
|
+
|
|
3746
|
+
// if(--maxStep < 0)break;
|
|
3747
|
+
}
|
|
3748
|
+
};
|
|
3749
|
+
}
|
|
3750
|
+
|
|
3751
|
+
function vnName(vnode, noDepth) {
|
|
3752
|
+
var _vnode$props;
|
|
3753
|
+
var name = vnode.type;
|
|
3754
|
+
if (typeof name == 'function') {
|
|
3755
|
+
name = name.name;
|
|
3756
|
+
}
|
|
3757
|
+
if (
|
|
3758
|
+
(_vnode$props = vnode.props) !== null &&
|
|
3759
|
+
_vnode$props !== void 0 &&
|
|
3760
|
+
_vnode$props.id
|
|
3761
|
+
)
|
|
3762
|
+
name += '#' + vnode.props.id;
|
|
3763
|
+
if (name == null) name = '#text<'.concat(vnode.props, '>');
|
|
3764
|
+
if (!noDepth) {
|
|
3765
|
+
var dp = ' '.repeat(vnode.__b);
|
|
3766
|
+
name = dp + name;
|
|
3767
|
+
}
|
|
3768
|
+
return name;
|
|
3769
|
+
}
|
|
3770
|
+
|
|
3771
|
+
/***/
|
|
3772
|
+
},
|
|
3773
|
+
|
|
3774
|
+
/******/
|
|
3775
|
+
};
|
|
3776
|
+
/************************************************************************/
|
|
3777
|
+
/******/ // The module cache
|
|
3778
|
+
/******/ var __webpack_module_cache__ = {};
|
|
3779
|
+
/******/
|
|
3780
|
+
/******/ // The require function
|
|
3781
|
+
/******/ function __webpack_require__(moduleId) {
|
|
3782
|
+
/******/ // Check if module is in cache
|
|
3783
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
3784
|
+
/******/ if (cachedModule !== undefined) {
|
|
3785
|
+
/******/ return cachedModule.exports;
|
|
3786
|
+
/******/
|
|
3787
|
+
}
|
|
3788
|
+
/******/ // Create a new module (and put it into the cache)
|
|
3789
|
+
/******/ var module = (__webpack_module_cache__[moduleId] = {
|
|
3790
|
+
/******/ // no module.id needed
|
|
3791
|
+
/******/ // no module.loaded needed
|
|
3792
|
+
/******/ exports: {},
|
|
3793
|
+
/******/
|
|
3794
|
+
});
|
|
3795
|
+
/******/
|
|
3796
|
+
/******/ // Execute the module function
|
|
3797
|
+
/******/ __webpack_modules__[moduleId](
|
|
3798
|
+
module,
|
|
3799
|
+
module.exports,
|
|
3800
|
+
__webpack_require__
|
|
3801
|
+
);
|
|
3802
|
+
/******/
|
|
3803
|
+
/******/ // Return the exports of the module
|
|
3804
|
+
/******/ return module.exports;
|
|
3805
|
+
/******/
|
|
3806
|
+
}
|
|
3807
|
+
/******/
|
|
3808
|
+
/************************************************************************/
|
|
3809
|
+
/******/ /* webpack/runtime/define property getters */
|
|
3810
|
+
/******/ (() => {
|
|
3811
|
+
/******/ // define getter functions for harmony exports
|
|
3812
|
+
/******/ __webpack_require__.d = (exports, definition) => {
|
|
3813
|
+
/******/ for (var key in definition) {
|
|
3814
|
+
/******/ if (
|
|
3815
|
+
__webpack_require__.o(definition, key) &&
|
|
3816
|
+
!__webpack_require__.o(exports, key)
|
|
3817
|
+
) {
|
|
3818
|
+
/******/ Object.defineProperty(exports, key, {
|
|
3819
|
+
enumerable: true,
|
|
3820
|
+
get: definition[key],
|
|
3821
|
+
});
|
|
3822
|
+
/******/
|
|
3823
|
+
}
|
|
3824
|
+
/******/
|
|
3825
|
+
}
|
|
3826
|
+
/******/
|
|
3827
|
+
};
|
|
3828
|
+
/******/
|
|
3829
|
+
})();
|
|
3830
|
+
/******/
|
|
3831
|
+
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
3832
|
+
/******/ (() => {
|
|
3833
|
+
/******/ __webpack_require__.o = (obj, prop) =>
|
|
3834
|
+
Object.prototype.hasOwnProperty.call(obj, prop);
|
|
3835
|
+
/******/
|
|
3836
|
+
})();
|
|
3837
|
+
/******/
|
|
3838
|
+
/******/ /* webpack/runtime/make namespace object */
|
|
3839
|
+
/******/ (() => {
|
|
3840
|
+
/******/ // define __esModule on exports
|
|
3841
|
+
/******/ __webpack_require__.r = (exports) => {
|
|
3842
|
+
/******/ if (typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
3843
|
+
/******/ Object.defineProperty(exports, Symbol.toStringTag, {
|
|
3844
|
+
value: 'Module',
|
|
3845
|
+
});
|
|
3846
|
+
/******/
|
|
3847
|
+
}
|
|
3848
|
+
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
3849
|
+
/******/
|
|
3850
|
+
};
|
|
3851
|
+
/******/
|
|
3852
|
+
})();
|
|
3853
|
+
/******/
|
|
3854
|
+
/************************************************************************/
|
|
3855
|
+
var __webpack_exports__ = {};
|
|
3856
|
+
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
|
|
3857
|
+
(() => {
|
|
3858
|
+
/*!*****************************!*\
|
|
3859
|
+
!*** ./compat/src/index.js ***!
|
|
3860
|
+
\*****************************/
|
|
3861
|
+
__webpack_require__.r(__webpack_exports__);
|
|
3862
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
3863
|
+
/* harmony export */ Children: () =>
|
|
3864
|
+
/* reexport safe */ _Children__WEBPACK_IMPORTED_MODULE_5__.Children,
|
|
3865
|
+
/* harmony export */ Component: () =>
|
|
3866
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.Component,
|
|
3867
|
+
/* harmony export */ Fragment: () =>
|
|
3868
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,
|
|
3869
|
+
/* harmony export */ PureComponent: () =>
|
|
3870
|
+
/* reexport safe */ _PureComponent__WEBPACK_IMPORTED_MODULE_2__.PureComponent,
|
|
3871
|
+
/* harmony export */ StrictMode: () => /* binding */ StrictMode,
|
|
3872
|
+
/* harmony export */ Suspense: () =>
|
|
3873
|
+
/* reexport safe */ _suspense__WEBPACK_IMPORTED_MODULE_6__.Suspense,
|
|
3874
|
+
/* harmony export */ SuspenseList: () =>
|
|
3875
|
+
/* reexport safe */ _suspense_list__WEBPACK_IMPORTED_MODULE_7__.SuspenseList,
|
|
3876
|
+
/* harmony export */ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:
|
|
3877
|
+
() =>
|
|
3878
|
+
/* reexport safe */ _render__WEBPACK_IMPORTED_MODULE_10__.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
3879
|
+
/* harmony export */ cloneElement: () => /* binding */ cloneElement,
|
|
3880
|
+
/* harmony export */ createContext: () =>
|
|
3881
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.createContext,
|
|
3882
|
+
/* harmony export */ createElement: () =>
|
|
3883
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.createElement,
|
|
3884
|
+
/* harmony export */ createFactory: () => /* binding */ createFactory,
|
|
3885
|
+
/* harmony export */ createPortal: () =>
|
|
3886
|
+
/* reexport safe */ _portals__WEBPACK_IMPORTED_MODULE_8__.createPortal,
|
|
3887
|
+
/* harmony export */ createRef: () =>
|
|
3888
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.createRef,
|
|
3889
|
+
/* harmony export */ default: () => __WEBPACK_DEFAULT_EXPORT__,
|
|
3890
|
+
/* harmony export */ findDOMNode: () => /* binding */ findDOMNode,
|
|
3891
|
+
/* harmony export */ flushSync: () => /* binding */ flushSync,
|
|
3892
|
+
/* harmony export */ forwardRef: () =>
|
|
3893
|
+
/* reexport safe */ _forwardRef__WEBPACK_IMPORTED_MODULE_4__.forwardRef,
|
|
3894
|
+
/* harmony export */ hydrate: () =>
|
|
3895
|
+
/* reexport safe */ _render__WEBPACK_IMPORTED_MODULE_10__.hydrate,
|
|
3896
|
+
/* harmony export */ isValidElement: () => /* binding */ isValidElement,
|
|
3897
|
+
/* harmony export */ lazy: () =>
|
|
3898
|
+
/* reexport safe */ _suspense__WEBPACK_IMPORTED_MODULE_6__.lazy,
|
|
3899
|
+
/* harmony export */ memo: () =>
|
|
3900
|
+
/* reexport safe */ _memo__WEBPACK_IMPORTED_MODULE_3__.memo,
|
|
3901
|
+
/* harmony export */ options: () =>
|
|
3902
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.options,
|
|
3903
|
+
/* harmony export */ render: () =>
|
|
3904
|
+
/* reexport safe */ _render__WEBPACK_IMPORTED_MODULE_10__.render,
|
|
3905
|
+
/* harmony export */ startTransition: () => /* binding */ startTransition,
|
|
3906
|
+
/* harmony export */ toChildArray: () =>
|
|
3907
|
+
/* reexport safe */ preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray,
|
|
3908
|
+
/* harmony export */ unmountComponentAtNode: () =>
|
|
3909
|
+
/* binding */ unmountComponentAtNode,
|
|
3910
|
+
/* harmony export */ unstable_batchedUpdates: () =>
|
|
3911
|
+
/* binding */ unstable_batchedUpdates,
|
|
3912
|
+
/* harmony export */ useCallback: () =>
|
|
3913
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,
|
|
3914
|
+
/* harmony export */ useContext: () =>
|
|
3915
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,
|
|
3916
|
+
/* harmony export */ useDebugValue: () =>
|
|
3917
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,
|
|
3918
|
+
/* harmony export */ useDeferredValue: () => /* binding */ useDeferredValue,
|
|
3919
|
+
/* harmony export */ useEffect: () =>
|
|
3920
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,
|
|
3921
|
+
/* harmony export */ useErrorBoundary: () =>
|
|
3922
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useErrorBoundary,
|
|
3923
|
+
/* harmony export */ useId: () =>
|
|
3924
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,
|
|
3925
|
+
/* harmony export */ useImperativeHandle: () =>
|
|
3926
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,
|
|
3927
|
+
/* harmony export */ useInsertionEffect: () =>
|
|
3928
|
+
/* binding */ useInsertionEffect,
|
|
3929
|
+
/* harmony export */ useLayoutEffect: () =>
|
|
3930
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,
|
|
3931
|
+
/* harmony export */ useMemo: () =>
|
|
3932
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,
|
|
3933
|
+
/* harmony export */ useReducer: () =>
|
|
3934
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,
|
|
3935
|
+
/* harmony export */ useRef: () =>
|
|
3936
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,
|
|
3937
|
+
/* harmony export */ useState: () =>
|
|
3938
|
+
/* reexport safe */ preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,
|
|
3939
|
+
/* harmony export */ useSyncExternalStore: () =>
|
|
3940
|
+
/* binding */ useSyncExternalStore,
|
|
3941
|
+
/* harmony export */ useTransition: () => /* binding */ useTransition,
|
|
3942
|
+
/* harmony export */ version: () => /* binding */ version,
|
|
3943
|
+
/* harmony export */
|
|
3944
|
+
});
|
|
3945
|
+
/* harmony import */ var preact__WEBPACK_IMPORTED_MODULE_0__ =
|
|
3946
|
+
__webpack_require__(/*! preact */ './src/index.js');
|
|
3947
|
+
/* harmony import */ var preact_hooks__WEBPACK_IMPORTED_MODULE_1__ =
|
|
3948
|
+
__webpack_require__(/*! preact/hooks */ './hooks/src/index.js');
|
|
3949
|
+
/* harmony import */ var _PureComponent__WEBPACK_IMPORTED_MODULE_2__ =
|
|
3950
|
+
__webpack_require__(/*! ./PureComponent */ './compat/src/PureComponent.js');
|
|
3951
|
+
/* harmony import */ var _memo__WEBPACK_IMPORTED_MODULE_3__ =
|
|
3952
|
+
__webpack_require__(/*! ./memo */ './compat/src/memo.js');
|
|
3953
|
+
/* harmony import */ var _forwardRef__WEBPACK_IMPORTED_MODULE_4__ =
|
|
3954
|
+
__webpack_require__(/*! ./forwardRef */ './compat/src/forwardRef.js');
|
|
3955
|
+
/* harmony import */ var _Children__WEBPACK_IMPORTED_MODULE_5__ =
|
|
3956
|
+
__webpack_require__(/*! ./Children */ './compat/src/Children.js');
|
|
3957
|
+
/* harmony import */ var _suspense__WEBPACK_IMPORTED_MODULE_6__ =
|
|
3958
|
+
__webpack_require__(/*! ./suspense */ './compat/src/suspense.js');
|
|
3959
|
+
/* harmony import */ var _suspense_list__WEBPACK_IMPORTED_MODULE_7__ =
|
|
3960
|
+
__webpack_require__(/*! ./suspense-list */ './compat/src/suspense-list.js');
|
|
3961
|
+
/* harmony import */ var _portals__WEBPACK_IMPORTED_MODULE_8__ =
|
|
3962
|
+
__webpack_require__(/*! ./portals */ './compat/src/portals.js');
|
|
3963
|
+
/* harmony import */ var _util__WEBPACK_IMPORTED_MODULE_9__ =
|
|
3964
|
+
__webpack_require__(/*! ./util */ './compat/src/util.js');
|
|
3965
|
+
/* harmony import */ var _render__WEBPACK_IMPORTED_MODULE_10__ =
|
|
3966
|
+
__webpack_require__(/*! ./render */ './compat/src/render.js');
|
|
3967
|
+
function _slicedToArray(arr, i) {
|
|
3968
|
+
return (
|
|
3969
|
+
_arrayWithHoles(arr) ||
|
|
3970
|
+
_iterableToArrayLimit(arr, i) ||
|
|
3971
|
+
_unsupportedIterableToArray(arr, i) ||
|
|
3972
|
+
_nonIterableRest()
|
|
3973
|
+
);
|
|
3974
|
+
}
|
|
3975
|
+
function _nonIterableRest() {
|
|
3976
|
+
throw new TypeError(
|
|
3977
|
+
'Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.'
|
|
3978
|
+
);
|
|
3979
|
+
}
|
|
3980
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
3981
|
+
if (!o) return;
|
|
3982
|
+
if (typeof o === 'string') return _arrayLikeToArray(o, minLen);
|
|
3983
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
3984
|
+
if (n === 'Object' && o.constructor) n = o.constructor.name;
|
|
3985
|
+
if (n === 'Map' || n === 'Set') return Array.from(o);
|
|
3986
|
+
if (n === 'Arguments' || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
3987
|
+
return _arrayLikeToArray(o, minLen);
|
|
3988
|
+
}
|
|
3989
|
+
function _arrayLikeToArray(arr, len) {
|
|
3990
|
+
if (len == null || len > arr.length) len = arr.length;
|
|
3991
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
3992
|
+
arr2[i] = arr[i];
|
|
3993
|
+
}
|
|
3994
|
+
return arr2;
|
|
3995
|
+
}
|
|
3996
|
+
function _iterableToArrayLimit(arr, i) {
|
|
3997
|
+
var _i =
|
|
3998
|
+
arr == null
|
|
3999
|
+
? null
|
|
4000
|
+
: (typeof Symbol !== 'undefined' && arr[Symbol.iterator]) ||
|
|
4001
|
+
arr['@@iterator'];
|
|
4002
|
+
if (_i == null) return;
|
|
4003
|
+
var _arr = [];
|
|
4004
|
+
var _n = true;
|
|
4005
|
+
var _d = false;
|
|
4006
|
+
var _s, _e;
|
|
4007
|
+
try {
|
|
4008
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
4009
|
+
_arr.push(_s.value);
|
|
4010
|
+
if (i && _arr.length === i) break;
|
|
4011
|
+
}
|
|
4012
|
+
}
|
|
4013
|
+
catch (err) {
|
|
4014
|
+
_d = true;
|
|
4015
|
+
_e = err;
|
|
4016
|
+
}
|
|
4017
|
+
finally {
|
|
4018
|
+
try {
|
|
4019
|
+
if (!_n && _i['return'] != null) _i['return']();
|
|
4020
|
+
}
|
|
4021
|
+
finally {
|
|
4022
|
+
if (_d) throw _e;
|
|
4023
|
+
}
|
|
4024
|
+
}
|
|
4025
|
+
return _arr;
|
|
4026
|
+
}
|
|
4027
|
+
function _arrayWithHoles(arr) {
|
|
4028
|
+
if (Array.isArray(arr)) return arr;
|
|
4029
|
+
}
|
|
4030
|
+
|
|
4031
|
+
var version = '17.0.2'; // trick libraries to think we are react
|
|
4032
|
+
|
|
4033
|
+
/**
|
|
4034
|
+
* Legacy version of createElement.
|
|
4035
|
+
* @param {import('./internal').VNode["type"]} type The node name or Component constructor
|
|
4036
|
+
*/
|
|
4037
|
+
function createFactory(type) {
|
|
4038
|
+
return preact__WEBPACK_IMPORTED_MODULE_0__.createElement.bind(null, type);
|
|
4039
|
+
}
|
|
4040
|
+
|
|
4041
|
+
/**
|
|
4042
|
+
* Check if the passed element is a valid (p)react node.
|
|
4043
|
+
* @param {*} element The element to check
|
|
4044
|
+
* @returns {boolean}
|
|
4045
|
+
*/
|
|
4046
|
+
function isValidElement(element) {
|
|
4047
|
+
return (
|
|
4048
|
+
!!element &&
|
|
4049
|
+
element.$$typeof ===
|
|
4050
|
+
_render__WEBPACK_IMPORTED_MODULE_10__.REACT_ELEMENT_TYPE
|
|
4051
|
+
);
|
|
4052
|
+
}
|
|
4053
|
+
|
|
4054
|
+
/**
|
|
4055
|
+
* Wrap `cloneElement` to abort if the passed element is not a valid element and apply
|
|
4056
|
+
* all vnode normalizations.
|
|
4057
|
+
* @param {import('./internal').VNode} element The vnode to clone
|
|
4058
|
+
* @param {object} props Props to add when cloning
|
|
4059
|
+
* @param {Array<import('./internal').ComponentChildren>} rest Optional component children
|
|
4060
|
+
*/
|
|
4061
|
+
function cloneElement(element) {
|
|
4062
|
+
if (!isValidElement(element)) return element;
|
|
4063
|
+
return preact__WEBPACK_IMPORTED_MODULE_0__.cloneElement.apply(
|
|
4064
|
+
null,
|
|
4065
|
+
arguments
|
|
4066
|
+
);
|
|
4067
|
+
}
|
|
4068
|
+
|
|
4069
|
+
/**
|
|
4070
|
+
* Remove a component tree from the DOM, including state and event handlers.
|
|
4071
|
+
* @param {import('./internal').PreactElement} container
|
|
4072
|
+
* @returns {boolean}
|
|
4073
|
+
*/
|
|
4074
|
+
function unmountComponentAtNode(container) {
|
|
4075
|
+
if (container.__k) {
|
|
4076
|
+
(0, preact__WEBPACK_IMPORTED_MODULE_0__.render)(null, container);
|
|
4077
|
+
return true;
|
|
4078
|
+
}
|
|
4079
|
+
return false;
|
|
4080
|
+
}
|
|
4081
|
+
|
|
4082
|
+
/**
|
|
4083
|
+
* Get the matching DOM node for a component
|
|
4084
|
+
* @param {import('./internal').Component} component
|
|
4085
|
+
* @returns {import('./internal').PreactElement | null}
|
|
4086
|
+
*/
|
|
4087
|
+
|
|
4088
|
+
function findDOMNode(component) {
|
|
4089
|
+
return (
|
|
4090
|
+
(component &&
|
|
4091
|
+
(component.base || (component.nodeType === 1 && component))) ||
|
|
4092
|
+
null
|
|
4093
|
+
);
|
|
4094
|
+
}
|
|
4095
|
+
|
|
4096
|
+
/**
|
|
4097
|
+
* Deprecated way to control batched rendering inside the reconciler, but we
|
|
4098
|
+
* already schedule in batches inside our rendering code
|
|
4099
|
+
* @template Arg
|
|
4100
|
+
* @param {(arg: Arg) => void} callback function that triggers the updated
|
|
4101
|
+
* @param {Arg} [arg] Optional argument that can be passed to the callback
|
|
4102
|
+
*/
|
|
4103
|
+
// eslint-disable-next-line camelcase
|
|
4104
|
+
var unstable_batchedUpdates = function unstable_batchedUpdates(
|
|
4105
|
+
callback,
|
|
4106
|
+
arg
|
|
4107
|
+
) {
|
|
4108
|
+
return callback(arg);
|
|
4109
|
+
};
|
|
4110
|
+
|
|
4111
|
+
/**
|
|
4112
|
+
* In React, `flushSync` flushes the entire tree and forces a rerender. It's
|
|
4113
|
+
* implmented here as a no-op.
|
|
4114
|
+
* @template Arg
|
|
4115
|
+
* @template Result
|
|
4116
|
+
* @param {(arg: Arg) => Result} callback function that runs before the flush
|
|
4117
|
+
* @param {Arg} [arg] Optional arugment that can be passed to the callback
|
|
4118
|
+
* @returns
|
|
4119
|
+
*/
|
|
4120
|
+
var flushSync = function flushSync(callback, arg) {
|
|
4121
|
+
return callback(arg);
|
|
4122
|
+
};
|
|
4123
|
+
|
|
4124
|
+
/**
|
|
4125
|
+
* Strict Mode is not implemented in Preact, so we provide a stand-in for it
|
|
4126
|
+
* that just renders its children without imposing any restrictions.
|
|
4127
|
+
*/
|
|
4128
|
+
var StrictMode = preact__WEBPACK_IMPORTED_MODULE_0__.Fragment;
|
|
4129
|
+
function startTransition(cb) {
|
|
4130
|
+
cb();
|
|
4131
|
+
}
|
|
4132
|
+
function useDeferredValue(val) {
|
|
4133
|
+
return val;
|
|
4134
|
+
}
|
|
4135
|
+
function useTransition() {
|
|
4136
|
+
return [false, startTransition];
|
|
4137
|
+
}
|
|
4138
|
+
|
|
4139
|
+
// TODO: in theory this should be done after a VNode is diffed as we want to insert
|
|
4140
|
+
// styles/... before it attaches
|
|
4141
|
+
var useInsertionEffect =
|
|
4142
|
+
preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect;
|
|
4143
|
+
|
|
4144
|
+
/**
|
|
4145
|
+
* This is taken from https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L84
|
|
4146
|
+
* on a high level this cuts out the warnings, ... and attempts a smaller implementation
|
|
4147
|
+
*/
|
|
4148
|
+
function useSyncExternalStore(subscribe, getSnapshot) {
|
|
4149
|
+
var value = getSnapshot();
|
|
4150
|
+
var _useState = (0, preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState)({
|
|
4151
|
+
_instance: {
|
|
4152
|
+
__: value,
|
|
4153
|
+
_getSnapshot: getSnapshot,
|
|
4154
|
+
},
|
|
4155
|
+
}),
|
|
4156
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
4157
|
+
_instance = _useState2[0]._instance,
|
|
4158
|
+
forceUpdate = _useState2[1];
|
|
4159
|
+
(0, preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect)(
|
|
4160
|
+
function () {
|
|
4161
|
+
_instance.__ = value;
|
|
4162
|
+
_instance._getSnapshot = getSnapshot;
|
|
4163
|
+
if (
|
|
4164
|
+
!(0, _util__WEBPACK_IMPORTED_MODULE_9__.is)(
|
|
4165
|
+
_instance.__,
|
|
4166
|
+
getSnapshot()
|
|
4167
|
+
)
|
|
4168
|
+
) {
|
|
4169
|
+
forceUpdate({
|
|
4170
|
+
_instance: _instance,
|
|
4171
|
+
});
|
|
4172
|
+
}
|
|
4173
|
+
},
|
|
4174
|
+
[subscribe, value, getSnapshot]
|
|
4175
|
+
);
|
|
4176
|
+
(0, preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect)(
|
|
4177
|
+
function () {
|
|
4178
|
+
if (
|
|
4179
|
+
!(0, _util__WEBPACK_IMPORTED_MODULE_9__.is)(
|
|
4180
|
+
_instance.__,
|
|
4181
|
+
_instance._getSnapshot()
|
|
4182
|
+
)
|
|
4183
|
+
) {
|
|
4184
|
+
forceUpdate({
|
|
4185
|
+
_instance: _instance,
|
|
4186
|
+
});
|
|
4187
|
+
}
|
|
4188
|
+
return subscribe(function () {
|
|
4189
|
+
if (
|
|
4190
|
+
!(0, _util__WEBPACK_IMPORTED_MODULE_9__.is)(
|
|
4191
|
+
_instance.__,
|
|
4192
|
+
_instance._getSnapshot()
|
|
4193
|
+
)
|
|
4194
|
+
) {
|
|
4195
|
+
forceUpdate({
|
|
4196
|
+
_instance: _instance,
|
|
4197
|
+
});
|
|
4198
|
+
}
|
|
4199
|
+
});
|
|
4200
|
+
},
|
|
4201
|
+
[subscribe]
|
|
4202
|
+
);
|
|
4203
|
+
return value;
|
|
4204
|
+
}
|
|
4205
|
+
|
|
4206
|
+
// React copies the named exports to the default one.
|
|
4207
|
+
/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = {
|
|
4208
|
+
useState: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useState,
|
|
4209
|
+
useId: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useId,
|
|
4210
|
+
useReducer: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useReducer,
|
|
4211
|
+
useEffect: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useEffect,
|
|
4212
|
+
useLayoutEffect: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useLayoutEffect,
|
|
4213
|
+
useInsertionEffect: useInsertionEffect,
|
|
4214
|
+
useTransition: useTransition,
|
|
4215
|
+
useDeferredValue: useDeferredValue,
|
|
4216
|
+
useSyncExternalStore: useSyncExternalStore,
|
|
4217
|
+
startTransition: startTransition,
|
|
4218
|
+
useRef: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useRef,
|
|
4219
|
+
useImperativeHandle:
|
|
4220
|
+
preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useImperativeHandle,
|
|
4221
|
+
useMemo: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useMemo,
|
|
4222
|
+
useCallback: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useCallback,
|
|
4223
|
+
useContext: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useContext,
|
|
4224
|
+
useDebugValue: preact_hooks__WEBPACK_IMPORTED_MODULE_1__.useDebugValue,
|
|
4225
|
+
version: version,
|
|
4226
|
+
Children: _Children__WEBPACK_IMPORTED_MODULE_5__.Children,
|
|
4227
|
+
render: _render__WEBPACK_IMPORTED_MODULE_10__.render,
|
|
4228
|
+
hydrate: _render__WEBPACK_IMPORTED_MODULE_10__.hydrate,
|
|
4229
|
+
unmountComponentAtNode: unmountComponentAtNode,
|
|
4230
|
+
createPortal: _portals__WEBPACK_IMPORTED_MODULE_8__.createPortal,
|
|
4231
|
+
createElement: preact__WEBPACK_IMPORTED_MODULE_0__.createElement,
|
|
4232
|
+
createContext: preact__WEBPACK_IMPORTED_MODULE_0__.createContext,
|
|
4233
|
+
createFactory: createFactory,
|
|
4234
|
+
cloneElement: cloneElement,
|
|
4235
|
+
createRef: preact__WEBPACK_IMPORTED_MODULE_0__.createRef,
|
|
4236
|
+
Fragment: preact__WEBPACK_IMPORTED_MODULE_0__.Fragment,
|
|
4237
|
+
isValidElement: isValidElement,
|
|
4238
|
+
findDOMNode: findDOMNode,
|
|
4239
|
+
Component: preact__WEBPACK_IMPORTED_MODULE_0__.Component,
|
|
4240
|
+
PureComponent: _PureComponent__WEBPACK_IMPORTED_MODULE_2__.PureComponent,
|
|
4241
|
+
memo: _memo__WEBPACK_IMPORTED_MODULE_3__.memo,
|
|
4242
|
+
forwardRef: _forwardRef__WEBPACK_IMPORTED_MODULE_4__.forwardRef,
|
|
4243
|
+
flushSync: flushSync,
|
|
4244
|
+
unstable_batchedUpdates: unstable_batchedUpdates,
|
|
4245
|
+
StrictMode: StrictMode,
|
|
4246
|
+
Suspense: _suspense__WEBPACK_IMPORTED_MODULE_6__.Suspense,
|
|
4247
|
+
SuspenseList: _suspense_list__WEBPACK_IMPORTED_MODULE_7__.SuspenseList,
|
|
4248
|
+
lazy: _suspense__WEBPACK_IMPORTED_MODULE_6__.lazy,
|
|
4249
|
+
toChildArray: preact__WEBPACK_IMPORTED_MODULE_0__.toChildArray,
|
|
4250
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:
|
|
4251
|
+
_render__WEBPACK_IMPORTED_MODULE_10__.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
4252
|
+
};
|
|
4253
|
+
})();
|
|
4254
|
+
|
|
4255
|
+
var __webpack_exports__Children = __webpack_exports__.Children;
|
|
4256
|
+
var __webpack_exports__Component = __webpack_exports__.Component;
|
|
4257
|
+
var __webpack_exports__Fragment = __webpack_exports__.Fragment;
|
|
4258
|
+
var __webpack_exports__PureComponent = __webpack_exports__.PureComponent;
|
|
4259
|
+
var __webpack_exports__StrictMode = __webpack_exports__.StrictMode;
|
|
4260
|
+
var __webpack_exports__Suspense = __webpack_exports__.Suspense;
|
|
4261
|
+
var __webpack_exports__SuspenseList = __webpack_exports__.SuspenseList;
|
|
4262
|
+
var __webpack_exports___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED =
|
|
4263
|
+
__webpack_exports__.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
4264
|
+
var __webpack_exports__cloneElement = __webpack_exports__.cloneElement;
|
|
4265
|
+
var __webpack_exports__createContext = __webpack_exports__.createContext;
|
|
4266
|
+
var __webpack_exports__createElement = __webpack_exports__.createElement;
|
|
4267
|
+
var __webpack_exports__createFactory = __webpack_exports__.createFactory;
|
|
4268
|
+
var __webpack_exports__createPortal = __webpack_exports__.createPortal;
|
|
4269
|
+
var __webpack_exports__createRef = __webpack_exports__.createRef;
|
|
4270
|
+
var __webpack_exports__default = __webpack_exports__['default'];
|
|
4271
|
+
var __webpack_exports__findDOMNode = __webpack_exports__.findDOMNode;
|
|
4272
|
+
var __webpack_exports__flushSync = __webpack_exports__.flushSync;
|
|
4273
|
+
var __webpack_exports__forwardRef = __webpack_exports__.forwardRef;
|
|
4274
|
+
var __webpack_exports__hydrate = __webpack_exports__.hydrate;
|
|
4275
|
+
var __webpack_exports__isValidElement = __webpack_exports__.isValidElement;
|
|
4276
|
+
var __webpack_exports__lazy = __webpack_exports__.lazy;
|
|
4277
|
+
var __webpack_exports__memo = __webpack_exports__.memo;
|
|
4278
|
+
var __webpack_exports__options = __webpack_exports__.options;
|
|
4279
|
+
var __webpack_exports__render = __webpack_exports__.render;
|
|
4280
|
+
var __webpack_exports__startTransition = __webpack_exports__.startTransition;
|
|
4281
|
+
var __webpack_exports__toChildArray = __webpack_exports__.toChildArray;
|
|
4282
|
+
var __webpack_exports__unmountComponentAtNode =
|
|
4283
|
+
__webpack_exports__.unmountComponentAtNode;
|
|
4284
|
+
var __webpack_exports__unstable_batchedUpdates =
|
|
4285
|
+
__webpack_exports__.unstable_batchedUpdates;
|
|
4286
|
+
var __webpack_exports__useCallback = __webpack_exports__.useCallback;
|
|
4287
|
+
var __webpack_exports__useContext = __webpack_exports__.useContext;
|
|
4288
|
+
var __webpack_exports__useDebugValue = __webpack_exports__.useDebugValue;
|
|
4289
|
+
var __webpack_exports__useDeferredValue = __webpack_exports__.useDeferredValue;
|
|
4290
|
+
var __webpack_exports__useEffect = __webpack_exports__.useEffect;
|
|
4291
|
+
var __webpack_exports__useErrorBoundary = __webpack_exports__.useErrorBoundary;
|
|
4292
|
+
var __webpack_exports__useId = __webpack_exports__.useId;
|
|
4293
|
+
var __webpack_exports__useImperativeHandle =
|
|
4294
|
+
__webpack_exports__.useImperativeHandle;
|
|
4295
|
+
var __webpack_exports__useInsertionEffect =
|
|
4296
|
+
__webpack_exports__.useInsertionEffect;
|
|
4297
|
+
var __webpack_exports__useLayoutEffect = __webpack_exports__.useLayoutEffect;
|
|
4298
|
+
var __webpack_exports__useMemo = __webpack_exports__.useMemo;
|
|
4299
|
+
var __webpack_exports__useReducer = __webpack_exports__.useReducer;
|
|
4300
|
+
var __webpack_exports__useRef = __webpack_exports__.useRef;
|
|
4301
|
+
var __webpack_exports__useState = __webpack_exports__.useState;
|
|
4302
|
+
var __webpack_exports__useSyncExternalStore =
|
|
4303
|
+
__webpack_exports__.useSyncExternalStore;
|
|
4304
|
+
var __webpack_exports__useTransition = __webpack_exports__.useTransition;
|
|
4305
|
+
var __webpack_exports__version = __webpack_exports__.version;
|
|
4306
|
+
export {
|
|
4307
|
+
__webpack_exports__Children as Children,
|
|
4308
|
+
__webpack_exports__Component as Component,
|
|
4309
|
+
__webpack_exports__Fragment as Fragment,
|
|
4310
|
+
__webpack_exports__PureComponent as PureComponent,
|
|
4311
|
+
__webpack_exports__StrictMode as StrictMode,
|
|
4312
|
+
__webpack_exports__Suspense as Suspense,
|
|
4313
|
+
__webpack_exports__SuspenseList as SuspenseList,
|
|
4314
|
+
__webpack_exports___SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED as __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,
|
|
4315
|
+
__webpack_exports__cloneElement as cloneElement,
|
|
4316
|
+
__webpack_exports__createContext as createContext,
|
|
4317
|
+
__webpack_exports__createElement as createElement,
|
|
4318
|
+
__webpack_exports__createFactory as createFactory,
|
|
4319
|
+
__webpack_exports__createPortal as createPortal,
|
|
4320
|
+
__webpack_exports__createRef as createRef,
|
|
4321
|
+
__webpack_exports__default as default,
|
|
4322
|
+
__webpack_exports__findDOMNode as findDOMNode,
|
|
4323
|
+
__webpack_exports__flushSync as flushSync,
|
|
4324
|
+
__webpack_exports__forwardRef as forwardRef,
|
|
4325
|
+
__webpack_exports__hydrate as hydrate,
|
|
4326
|
+
__webpack_exports__isValidElement as isValidElement,
|
|
4327
|
+
__webpack_exports__lazy as lazy,
|
|
4328
|
+
__webpack_exports__memo as memo,
|
|
4329
|
+
__webpack_exports__options as options,
|
|
4330
|
+
__webpack_exports__render as render,
|
|
4331
|
+
__webpack_exports__startTransition as startTransition,
|
|
4332
|
+
__webpack_exports__toChildArray as toChildArray,
|
|
4333
|
+
__webpack_exports__unmountComponentAtNode as unmountComponentAtNode,
|
|
4334
|
+
__webpack_exports__unstable_batchedUpdates as unstable_batchedUpdates,
|
|
4335
|
+
__webpack_exports__useCallback as useCallback,
|
|
4336
|
+
__webpack_exports__useContext as useContext,
|
|
4337
|
+
__webpack_exports__useDebugValue as useDebugValue,
|
|
4338
|
+
__webpack_exports__useDeferredValue as useDeferredValue,
|
|
4339
|
+
__webpack_exports__useEffect as useEffect,
|
|
4340
|
+
__webpack_exports__useErrorBoundary as useErrorBoundary,
|
|
4341
|
+
__webpack_exports__useId as useId,
|
|
4342
|
+
__webpack_exports__useImperativeHandle as useImperativeHandle,
|
|
4343
|
+
__webpack_exports__useInsertionEffect as useInsertionEffect,
|
|
4344
|
+
__webpack_exports__useLayoutEffect as useLayoutEffect,
|
|
4345
|
+
__webpack_exports__useMemo as useMemo,
|
|
4346
|
+
__webpack_exports__useReducer as useReducer,
|
|
4347
|
+
__webpack_exports__useRef as useRef,
|
|
4348
|
+
__webpack_exports__useState as useState,
|
|
4349
|
+
__webpack_exports__useSyncExternalStore as useSyncExternalStore,
|
|
4350
|
+
__webpack_exports__useTransition as useTransition,
|
|
4351
|
+
__webpack_exports__version as version,
|
|
4352
|
+
};
|
|
4353
|
+
|
|
4354
|
+
//# sourceMappingURL=preact.js.map
|