@shijiu/jsview 2.3.151-test.0 → 3.0.0-test.0

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.
Files changed (78) hide show
  1. package/dom/bin/jsview-dom-browser-engine-core.min.js +1 -1
  2. package/dom/bin/jsview-dom-browser-engine-modules.min.js +1 -1
  3. package/dom/bin/{jsview-dom-browser-forge.1493.9a36.wasm → jsview-dom-browser-forge.1760.0e35.wasm} +0 -0
  4. package/dom/bin/jsview-dom-browser-forge.min.js +1 -1
  5. package/dom/bin/jsview-dom-browser-forge.worker.min.js +1 -1
  6. package/dom/bin/jsview-dom-browser.min.js +1 -1
  7. package/dom/bin/jsview-dom-native.min.js +1 -1
  8. package/dom/bin/jsview-engine-js-native.min.js +1 -1
  9. package/dom/target_core_revision.mjs +2 -2
  10. package/loader/jsv-core-api/jsview-core-api-glue.js +10 -1
  11. package/loader/jsv-core-api/wasm/core-api.js +87 -2
  12. package/loader/jsv-core-api/wasm/wasm-extension.js +5 -0
  13. package/loader/jsview-loader.js +7 -0
  14. package/loader/jsview-main.mjs +2 -1
  15. package/loader/jsview.config.default.js +4 -0
  16. package/package.json +7 -5
  17. package/patches/@vitejs+plugin-vue+4.0.0.patch +51 -0
  18. package/patches/@vitejs+plugin-vue+6.0.6.patch +54 -0
  19. package/patches/@vue+compiler-dom+3.2.45.patch +22 -0
  20. package/patches/@vue+compiler-dom+3.6.0-beta.10.patch +22 -0
  21. package/patches/@vue+compiler-sfc+3.2.45.patch +1986 -0
  22. package/patches/@vue+compiler-sfc+3.6.0-beta.10.patch +69 -0
  23. package/patches/@vue+runtime-core+3.2.45.patch +353 -0
  24. package/patches/@vue+runtime-core+3.6.0-beta.10.patch +198 -0
  25. package/patches/@vue+runtime-dom+3.2.45.patch +81 -0
  26. package/patches/@vue+runtime-dom+3.6.0-beta.10.patch +47 -0
  27. package/patches/postcss-js+5.1.0.patch +20 -0
  28. package/patches/vite+4.0.0.patch +117 -0
  29. package/patches/vite+8.0.9.patch +77 -0
  30. package/patches/vue-router+4.1.6.patch +17 -0
  31. package/patches/vue-router+5.0.6.patch +0 -0
  32. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js → thirdparty/@vue/compiler-sfc/jsview-css-to-js.cjs} +15 -10
  33. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-checker.js → thirdparty/@vue/compiler-sfc/jsview-style-checker.cjs} +6 -1
  34. package/{patches/node_modules/@vue/compiler-sfc/dist/jsview-style-formator.cjs.js → thirdparty/@vue/compiler-sfc/jsview-style-formator.cjs} +3 -0
  35. package/thirdparty/@vue/runtime-core/jsview-render-break.mjs +201 -0
  36. package/thirdparty/vite/jsview-vite-extension.mjs +336 -0
  37. package/tools/jsview-build-zip.mjs +7 -2
  38. package/tools/jsview-common.mjs +17 -4
  39. package/tools/{jsview-logger.js → jsview-logger.cjs} +1 -1
  40. package/tools/jsview-post-build.mjs +55 -0
  41. package/tools/jsview-post-install.mjs +98 -110
  42. package/tools/jsview-run-tool.mjs +3 -6
  43. package/tools/jsview-vue-devtools.mjs +1 -1
  44. package/loader/jsview-react-main.js +0 -37
  45. package/loader/jsview-react-script-loader.js +0 -134
  46. package/patches/node_modules/@vitejs/plugin-react/dist/index.cjs +0 -520
  47. package/patches/node_modules/@vitejs/plugin-react/package.json +0 -55
  48. package/patches/node_modules/@vitejs/plugin-vue/dist/index.mjs +0 -2756
  49. package/patches/node_modules/@vitejs/plugin-vue/package.json +0 -51
  50. package/patches/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +0 -3152
  51. package/patches/node_modules/@vue/compiler-dom/package.json +0 -43
  52. package/patches/node_modules/@vue/compiler-sfc/dist/compiler-sfc.cjs.js +0 -17730
  53. package/patches/node_modules/@vue/compiler-sfc/package.json +0 -59
  54. package/patches/node_modules/@vue/runtime-core/dist/runtime-core.esm-bundler.js +0 -8154
  55. package/patches/node_modules/@vue/runtime-core/package.json +0 -38
  56. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.d.ts +0 -1531
  57. package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +0 -1740
  58. package/patches/node_modules/@vue/runtime-dom/package.json +0 -42
  59. package/patches/node_modules/postcss-js/objectifier.js +0 -94
  60. package/patches/node_modules/postcss-js/package.json +0 -42
  61. package/patches/node_modules/react-dev-utils/WebpackDevServerUtils.js +0 -450
  62. package/patches/node_modules/react-dev-utils/package.json +0 -88
  63. package/patches/node_modules/react-dom/cjs/react-dom.development.js +0 -29868
  64. package/patches/node_modules/react-dom/cjs/react-dom.production.min.js +0 -323
  65. package/patches/node_modules/react-dom/package.json +0 -62
  66. package/patches/node_modules/react-scripts/config/paths.js +0 -179
  67. package/patches/node_modules/react-scripts/config/webpack.config.js +0 -858
  68. package/patches/node_modules/react-scripts/package.json +0 -108
  69. package/patches/node_modules/vite/dist/node/chunks/dep-ed9cb113.js +0 -63182
  70. package/patches/node_modules/vite/dist/node/constants.js +0 -125
  71. package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +0 -245
  72. package/patches/node_modules/vite/package.json +0 -153
  73. package/patches/node_modules/vue-router/dist/vue-router.mjs +0 -3613
  74. package/patches/node_modules/vue-router/package.json +0 -114
  75. package/patches/node_modules/webpack-dev-server/client/utils/reloadApp.js +0 -76
  76. package/patches/node_modules/webpack-dev-server/client/utils/sendMessage.js +0 -21
  77. package/patches/node_modules/webpack-dev-server/package.json +0 -141
  78. /package/patches/{node_modules/@originjs/vite-plugin-federation/1.3.4/@originjs+vite-plugin-federation+1.3.4.patch → @originjs+vite-plugin-federation+1.3.4.patch} +0 -0
@@ -1,1740 +0,0 @@
1
- import { warn, camelize, callWithAsyncErrorHandling, defineComponent, nextTick, createVNode, getCurrentInstance, watchPostEffect, onMounted, onUnmounted, Fragment, Static, h, BaseTransition, useTransitionState, onUpdated, toRaw, getTransitionRawChildren, setTransitionHooks, resolveTransitionHooks, createRenderer, isRuntimeOnly, createHydrationRenderer } from '@vue/runtime-core';
2
- export * from '@vue/runtime-core';
3
- import { isString, isArray, hyphenate, capitalize, isSpecialBooleanAttr, includeBooleanAttr, isOn, isModelListener, isFunction, camelize as camelize$1, toNumber, extend, EMPTY_OBJ, isObject, invokeArrayFns, looseIndexOf, isSet, looseEqual, isHTMLTag, isSVGTag } from '@vue/shared';
4
-
5
- const svgNS = 'http://www.w3.org/2000/svg';
6
- const doc = (typeof document !== 'undefined' ? document : null);
7
- const templateContainer = doc && /*#__PURE__*/ doc.createElement('template');
8
- const nodeOps = {
9
- insert: (child, parent, anchor) => {
10
- parent.insertBefore(child, anchor || null);
11
- },
12
- remove: child => {
13
- const parent = child.parentNode;
14
- if (parent) {
15
- parent.removeChild(child);
16
- }
17
- },
18
- createElement: (tag, isSVG, is, props) => {
19
- const el = isSVG
20
- ? doc.createElementNS(svgNS, tag)
21
- : doc.createElement(tag, is ? { is } : undefined);
22
- if (tag === 'select' && props && props.multiple != null) {
23
- el.setAttribute('multiple', props.multiple);
24
- }
25
- return el;
26
- },
27
- createText: text => doc.createTextNode(text),
28
- createComment: text => doc.createComment(text),
29
- setText: (node, text) => {
30
- node.nodeValue = text;
31
- },
32
- setElementText: (el, text) => {
33
- el.textContent = text;
34
- },
35
- parentNode: node => node.parentNode,
36
- nextSibling: node => node.nextSibling,
37
- querySelector: selector => doc.querySelector(selector),
38
- setScopeId(el, id) {
39
- el.setAttribute(id, '');
40
- },
41
- // JsView Removed >>>
42
- // 删除盒子不支持的cloneNode函数,Vue会自动转为重新创建。
43
- /* cloneNode(el) {
44
- const cloned = el.cloneNode(true);
45
- // #3072
46
- // - in `patchDOMProp`, we store the actual value in the `el._value` property.
47
- // - normally, elements using `:value` bindings will not be hoisted, but if
48
- // the bound value is a constant, e.g. `:value="true"` - they do get
49
- // hoisted.
50
- // - in production, hoisted nodes are cloned when subsequent inserts, but
51
- // cloneNode() does not copy the custom property we attached.
52
- // - This may need to account for other custom DOM properties we attach to
53
- // elements in addition to `_value` in the future.
54
- if (`_value` in el) {
55
- cloned._value = el._value;
56
- }
57
- return cloned;
58
- }, */
59
- // JsView Removed <<<
60
- // __UNSAFE__
61
- // Reason: innerHTML.
62
- // Static content here can only come from compiled templates.
63
- // As long as the user only uses trusted templates, this is safe.
64
- insertStaticContent(content, parent, anchor, isSVG, start, end) {
65
- // <parent> before | first ... last | anchor </parent>
66
- const before = anchor ? anchor.previousSibling : parent.lastChild;
67
- // #5308 can only take cached path if:
68
- // - has a single root node
69
- // - nextSibling info is still available
70
- if (start && (start === end || start.nextSibling)) {
71
- // cached
72
- while (true) {
73
- parent.insertBefore(start.cloneNode(true), anchor);
74
- if (start === end || !(start = start.nextSibling))
75
- break;
76
- }
77
- }
78
- else {
79
- // fresh insert
80
- templateContainer.innerHTML = isSVG ? `<svg>${content}</svg>` : content;
81
- const template = templateContainer.content;
82
- if (isSVG) {
83
- // remove outer svg wrapper
84
- const wrapper = template.firstChild;
85
- while (wrapper.firstChild) {
86
- template.appendChild(wrapper.firstChild);
87
- }
88
- template.removeChild(wrapper);
89
- }
90
- parent.insertBefore(template, anchor);
91
- }
92
- return [
93
- // first
94
- before ? before.nextSibling : parent.firstChild,
95
- // last
96
- anchor ? anchor.previousSibling : parent.lastChild
97
- ];
98
- }
99
- };
100
-
101
- // compiler should normalize class + :class bindings on the same element
102
- // into a single binding ['staticClass', dynamic]
103
- function patchClass(el, value, isSVG) {
104
- // directly setting className should be faster than setAttribute in theory
105
- // if this is an element during a transition, take the temporary transition
106
- // classes into account.
107
- const transitionClasses = el._vtc;
108
- if (transitionClasses) {
109
- value = (value ? [value, ...transitionClasses] : [...transitionClasses]).join(' ');
110
- }
111
- if (value == null) {
112
- el.removeAttribute('class');
113
- }
114
- else if (isSVG) {
115
- el.setAttribute('class', value);
116
- }
117
- else {
118
- el.className = value;
119
- }
120
- }
121
-
122
- function patchStyle(el, prev, next) {
123
- const style = el.style;
124
- const isCssString = isString(next);
125
- if (next && !isCssString) {
126
- for (const key in next) {
127
- setStyle(style, key, next[key]);
128
- }
129
- if (prev && !isString(prev)) {
130
- for (const key in prev) {
131
- if (next[key] == null) {
132
- setStyle(style, key, '');
133
- }
134
- }
135
- }
136
- }
137
- else {
138
- const currentDisplay = style.display;
139
- if (isCssString) {
140
- if (prev !== next) {
141
- style.cssText = next;
142
- }
143
- }
144
- else if (prev) {
145
- el.removeAttribute('style');
146
- }
147
- // indicates that the `display` of the element is controlled by `v-show`,
148
- // so we always keep the current `display` value regardless of the `style`
149
- // value, thus handing over control to `v-show`.
150
- if ('_vod' in el) {
151
- style.display = currentDisplay;
152
- }
153
- }
154
- }
155
- const semicolonRE = /[^\\];\s*$/;
156
- const importantRE = /\s*!important$/;
157
- function setStyle(style, name, val) {
158
- if (isArray(val)) {
159
- val.forEach(v => setStyle(style, name, v));
160
- }
161
- else {
162
- if (val == null)
163
- val = '';
164
- if ((process.env.NODE_ENV !== 'production')) {
165
- if (semicolonRE.test(val)) {
166
- warn(`Unexpected semicolon at the end of '${name}' style value: '${val}'`);
167
- }
168
- }
169
- if (name.startsWith('--')) {
170
- // custom property definition
171
- style.setProperty(name, val);
172
- }
173
- else {
174
- const prefixed = autoPrefix(style, name);
175
- if (importantRE.test(val)) {
176
- // !important
177
- style.setProperty(hyphenate(prefixed), val.replace(importantRE, ''), 'important');
178
- }
179
- else {
180
- style[prefixed] = val;
181
- }
182
- }
183
- }
184
- }
185
- const prefixes = ['Webkit', 'Moz', 'ms'];
186
- const prefixCache = {};
187
- function autoPrefix(style, rawName) {
188
- const cached = prefixCache[rawName];
189
- if (cached) {
190
- return cached;
191
- }
192
- let name = camelize(rawName);
193
- if (name !== 'filter' && name in style) {
194
- return (prefixCache[rawName] = name);
195
- }
196
- name = capitalize(name);
197
- for (let i = 0; i < prefixes.length; i++) {
198
- const prefixed = prefixes[i] + name;
199
- if (prefixed in style) {
200
- return (prefixCache[rawName] = prefixed);
201
- }
202
- }
203
- return rawName;
204
- }
205
-
206
- const xlinkNS = 'http://www.w3.org/1999/xlink';
207
- function patchAttr(el, key, value, isSVG, instance) {
208
- if (isSVG && key.startsWith('xlink:')) {
209
- if (value == null) {
210
- el.removeAttributeNS(xlinkNS, key.slice(6, key.length));
211
- }
212
- else {
213
- el.setAttributeNS(xlinkNS, key, value);
214
- }
215
- }
216
- else {
217
- // note we are only checking boolean attributes that don't have a
218
- // corresponding dom prop of the same name here.
219
- const isBoolean = isSpecialBooleanAttr(key);
220
- if (value == null || (isBoolean && !includeBooleanAttr(value))) {
221
- el.removeAttribute(key);
222
- }
223
- else {
224
- el.setAttribute(key, isBoolean ? '' : value);
225
- }
226
- }
227
- }
228
-
229
- // __UNSAFE__
230
- // functions. The user is responsible for using them with only trusted content.
231
- function patchDOMProp(el, key, value,
232
- // the following args are passed only due to potential innerHTML/textContent
233
- // overriding existing VNodes, in which case the old tree must be properly
234
- // unmounted.
235
- prevChildren, parentComponent, parentSuspense, unmountChildren) {
236
- if (key === 'innerHTML' || key === 'textContent') {
237
- if (prevChildren) {
238
- unmountChildren(prevChildren, parentComponent, parentSuspense);
239
- }
240
- el[key] = value == null ? '' : value;
241
- return;
242
- }
243
- if (key === 'value' &&
244
- el.tagName !== 'PROGRESS' &&
245
- // custom elements may use _value internally
246
- !el.tagName.includes('-')) {
247
- // store value as _value as well since
248
- // non-string values will be stringified.
249
- el._value = value;
250
- const newValue = value == null ? '' : value;
251
- if (el.value !== newValue ||
252
- // #4956: always set for OPTION elements because its value falls back to
253
- // textContent if no value attribute is present. And setting .value for
254
- // OPTION has no side effect
255
- el.tagName === 'OPTION') {
256
- el.value = newValue;
257
- }
258
- if (value == null) {
259
- el.removeAttribute(key);
260
- }
261
- return;
262
- }
263
- let needRemove = false;
264
- if (value === '' || value == null) {
265
- const type = typeof el[key];
266
- if (type === 'boolean') {
267
- // e.g. <select multiple> compiles to { multiple: '' }
268
- value = includeBooleanAttr(value);
269
- }
270
- else if (value == null && type === 'string') {
271
- // e.g. <div :id="null">
272
- value = '';
273
- needRemove = true;
274
- }
275
- else if (type === 'number') {
276
- // e.g. <img :width="null">
277
- value = 0;
278
- needRemove = true;
279
- }
280
- }
281
- // some properties perform value validation and throw,
282
- // some properties has getter, no setter, will error in 'use strict'
283
- // eg. <select :type="null"></select> <select :willValidate="null"></select>
284
- try {
285
- el[key] = value;
286
- }
287
- catch (e) {
288
- // do not warn if value is auto-coerced from nullish values
289
- if ((process.env.NODE_ENV !== 'production') && !needRemove) {
290
- warn(`Failed setting prop "${key}" on <${el.tagName.toLowerCase()}>: ` +
291
- `value ${value} is invalid.`, e);
292
- }
293
- }
294
- needRemove && el.removeAttribute(key);
295
- }
296
-
297
- function addEventListener(el, event, handler, options) {
298
- el.addEventListener(event, handler, options);
299
- }
300
- function removeEventListener(el, event, handler, options) {
301
- el.removeEventListener(event, handler, options);
302
- }
303
- function patchEvent(el, rawName, prevValue, nextValue, instance = null) {
304
- // vei = vue event invokers
305
- const invokers = el._vei || (el._vei = {});
306
- const existingInvoker = invokers[rawName];
307
- if (nextValue && existingInvoker) {
308
- // patch
309
- existingInvoker.value = nextValue;
310
- }
311
- else {
312
- const [name, options] = parseName(rawName);
313
- if (nextValue) {
314
- // add
315
- const invoker = (invokers[rawName] = createInvoker(nextValue, instance));
316
- addEventListener(el, name, invoker, options);
317
- }
318
- else if (existingInvoker) {
319
- // remove
320
- removeEventListener(el, name, existingInvoker, options);
321
- invokers[rawName] = undefined;
322
- }
323
- }
324
- }
325
- const optionsModifierRE = /(?:Once|Passive|Capture)$/;
326
- function parseName(name) {
327
- let options;
328
- if (optionsModifierRE.test(name)) {
329
- options = {};
330
- let m;
331
- while ((m = name.match(optionsModifierRE))) {
332
- name = name.slice(0, name.length - m[0].length);
333
- options[m[0].toLowerCase()] = true;
334
- }
335
- }
336
- // JsView Added >>>
337
- // 处理自定义的 addEventListener() options, 前缀为jsv
338
- // onJsvXxx留给自定义Event,这样判断防止出现下面写法
339
- // :jsvevent.jsvoption1.jsvoption2 => onJsvEventJsvOption1JsvOption2
340
- if (name.lastIndexOf('Jsv') > 2) {
341
- options = options ?? {};
342
-
343
- const optNames = name.substring(3); // 过滤掉jsvEvent
344
- const optArray = optNames.split('Jsv');
345
- // optArray[0] 为EventName部分内容
346
- for (let idx = optArray.length - 1; idx > 0; idx--) {
347
- const optName = 'jsv' + optArray[idx];
348
- options[optName] = true;
349
- name = name.slice(0, name.length - optName.length);
350
- }
351
- }
352
- // JsView Added <<<
353
- const event = name[2] === ':' ? name.slice(3) : hyphenate(name.slice(2));
354
- return [event, options];
355
- }
356
- // To avoid the overhead of repeatedly calling Date.now(), we cache
357
- // and use the same timestamp for all event listeners attached in the same tick.
358
- let cachedNow = 0;
359
- const p = /*#__PURE__*/ Promise.resolve();
360
- const getNow = () => cachedNow || (p.then(() => (cachedNow = 0)), (cachedNow = Date.now()));
361
- function createInvoker(initialValue, instance) {
362
- const invoker = (e) => {
363
- // async edge case vuejs/vue#6566
364
- // inner click event triggers patch, event handler
365
- // attached to outer element during patch, and triggered again. This
366
- // happens because browsers fire microtask ticks between event propagation.
367
- // this no longer happens for templates in Vue 3, but could still be
368
- // theoretically possible for hand-written render functions.
369
- // the solution: we save the timestamp when a handler is attached,
370
- // and also attach the timestamp to any event that was handled by vue
371
- // for the first time (to avoid inconsistent event timestamp implementations
372
- // or events fired from iframes, e.g. #2513)
373
- // The handler would only fire if the event passed to it was fired
374
- // AFTER it was attached.
375
- if (!e._vts) {
376
- e._vts = Date.now();
377
- }
378
- else if (e._vts <= invoker.attached) {
379
- return;
380
- }
381
- callWithAsyncErrorHandling(patchStopImmediatePropagation(e, invoker.value), instance, 5 /* ErrorCodes.NATIVE_EVENT_HANDLER */, [e]);
382
- };
383
- invoker.value = initialValue;
384
- invoker.attached = getNow();
385
- return invoker;
386
- }
387
- function patchStopImmediatePropagation(e, value) {
388
- if (isArray(value)) {
389
- const originalStop = e.stopImmediatePropagation;
390
- e.stopImmediatePropagation = () => {
391
- originalStop.call(e);
392
- e._stopped = true;
393
- };
394
- return value.map(fn => (e) => !e._stopped && fn && fn(e));
395
- }
396
- else {
397
- return value;
398
- }
399
- }
400
-
401
- const nativeOnRE = /^on[a-z]/;
402
- const patchProp = (el, key, prevValue, nextValue, isSVG = false, prevChildren, parentComponent, parentSuspense, unmountChildren) => {
403
- if (key === 'class') {
404
- patchClass(el, nextValue, isSVG);
405
- }
406
- else if (key === 'style') {
407
- patchStyle(el, prevValue, nextValue);
408
- }
409
- else if (isOn(key)) {
410
- // ignore v-model listeners
411
- if (!isModelListener(key)) {
412
- patchEvent(el, key, prevValue, nextValue, parentComponent);
413
- }
414
- }
415
- else if (key[0] === '.'
416
- ? ((key = key.slice(1)), true)
417
- : key[0] === '^'
418
- ? ((key = key.slice(1)), false)
419
- : shouldSetAsProp(el, key, nextValue, isSVG)) {
420
- patchDOMProp(el, key, nextValue, prevChildren, parentComponent, parentSuspense, unmountChildren);
421
- }
422
- else {
423
- // special case for <input v-model type="checkbox"> with
424
- // :true-value & :false-value
425
- // store value as dom properties since non-string values will be
426
- // stringified.
427
- if (key === 'true-value') {
428
- el._trueValue = nextValue;
429
- }
430
- else if (key === 'false-value') {
431
- el._falseValue = nextValue;
432
- }
433
- patchAttr(el, key, nextValue, isSVG);
434
- }
435
- };
436
- function shouldSetAsProp(el, key, value, isSVG) {
437
- if (isSVG) {
438
- // most keys must be set as attribute on svg elements to work
439
- // ...except innerHTML & textContent
440
- if (key === 'innerHTML' || key === 'textContent') {
441
- return true;
442
- }
443
- // or native onclick with function values
444
- if (key in el && nativeOnRE.test(key) && isFunction(value)) {
445
- return true;
446
- }
447
- return false;
448
- }
449
- // these are enumerated attrs, however their corresponding DOM properties
450
- // are actually booleans - this leads to setting it with a string "false"
451
- // value leading it to be coerced to `true`, so we need to always treat
452
- // them as attributes.
453
- // Note that `contentEditable` doesn't have this problem: its DOM
454
- // property is also enumerated string values.
455
- if (key === 'spellcheck' || key === 'draggable' || key === 'translate') {
456
- return false;
457
- }
458
- // #1787, #2840 form property on form elements is readonly and must be set as
459
- // attribute.
460
- if (key === 'form') {
461
- return false;
462
- }
463
- // #1526 <input list> must be set as attribute
464
- if (key === 'list' && el.tagName === 'INPUT') {
465
- return false;
466
- }
467
- // #2766 <textarea type> must be set as attribute
468
- if (key === 'type' && el.tagName === 'TEXTAREA') {
469
- return false;
470
- }
471
- // native onclick with string value, must be set as attribute
472
- if (nativeOnRE.test(key) && isString(value)) {
473
- return false;
474
- }
475
- return key in el;
476
- }
477
-
478
- function defineCustomElement(options, hydrate) {
479
- const Comp = defineComponent(options);
480
- class VueCustomElement extends VueElement {
481
- constructor(initialProps) {
482
- super(Comp, initialProps, hydrate);
483
- }
484
- }
485
- VueCustomElement.def = Comp;
486
- return VueCustomElement;
487
- }
488
- const defineSSRCustomElement = ((options) => {
489
- // @ts-ignore
490
- return defineCustomElement(options, hydrate);
491
- });
492
- const BaseClass = (typeof HTMLElement !== 'undefined' ? HTMLElement : class {
493
- });
494
- class VueElement extends BaseClass {
495
- constructor(_def, _props = {}, hydrate) {
496
- super();
497
- this._def = _def;
498
- this._props = _props;
499
- /**
500
- * @internal
501
- */
502
- this._instance = null;
503
- this._connected = false;
504
- this._resolved = false;
505
- this._numberProps = null;
506
- if (this.shadowRoot && hydrate) {
507
- hydrate(this._createVNode(), this.shadowRoot);
508
- }
509
- else {
510
- if ((process.env.NODE_ENV !== 'production') && this.shadowRoot) {
511
- warn(`Custom element has pre-rendered declarative shadow root but is not ` +
512
- `defined as hydratable. Use \`defineSSRCustomElement\`.`);
513
- }
514
- this.attachShadow({ mode: 'open' });
515
- if (!this._def.__asyncLoader) {
516
- // for sync component defs we can immediately resolve props
517
- this._resolveProps(this._def);
518
- }
519
- }
520
- }
521
- connectedCallback() {
522
- this._connected = true;
523
- if (!this._instance) {
524
- if (this._resolved) {
525
- this._update();
526
- }
527
- else {
528
- this._resolveDef();
529
- }
530
- }
531
- }
532
- disconnectedCallback() {
533
- this._connected = false;
534
- nextTick(() => {
535
- if (!this._connected) {
536
- render(null, this.shadowRoot);
537
- this._instance = null;
538
- }
539
- });
540
- }
541
- /**
542
- * resolve inner component definition (handle possible async component)
543
- */
544
- _resolveDef() {
545
- this._resolved = true;
546
- // set initial attrs
547
- for (let i = 0; i < this.attributes.length; i++) {
548
- this._setAttr(this.attributes[i].name);
549
- }
550
- // watch future attr changes
551
- new MutationObserver(mutations => {
552
- for (const m of mutations) {
553
- this._setAttr(m.attributeName);
554
- }
555
- }).observe(this, { attributes: true });
556
- const resolve = (def, isAsync = false) => {
557
- const { props, styles } = def;
558
- // cast Number-type props set before resolve
559
- let numberProps;
560
- if (props && !isArray(props)) {
561
- for (const key in props) {
562
- const opt = props[key];
563
- if (opt === Number || (opt && opt.type === Number)) {
564
- if (key in this._props) {
565
- this._props[key] = toNumber(this._props[key]);
566
- }
567
- (numberProps || (numberProps = Object.create(null)))[camelize$1(key)] = true;
568
- }
569
- }
570
- }
571
- this._numberProps = numberProps;
572
- if (isAsync) {
573
- // defining getter/setters on prototype
574
- // for sync defs, this already happened in the constructor
575
- this._resolveProps(def);
576
- }
577
- // apply CSS
578
- this._applyStyles(styles);
579
- // initial render
580
- this._update();
581
- };
582
- const asyncDef = this._def.__asyncLoader;
583
- if (asyncDef) {
584
- asyncDef().then(def => resolve(def, true));
585
- }
586
- else {
587
- resolve(this._def);
588
- }
589
- }
590
- _resolveProps(def) {
591
- const { props } = def;
592
- const declaredPropKeys = isArray(props) ? props : Object.keys(props || {});
593
- // check if there are props set pre-upgrade or connect
594
- for (const key of Object.keys(this)) {
595
- if (key[0] !== '_' && declaredPropKeys.includes(key)) {
596
- this._setProp(key, this[key], true, false);
597
- }
598
- }
599
- // defining getter/setters on prototype
600
- for (const key of declaredPropKeys.map(camelize$1)) {
601
- Object.defineProperty(this, key, {
602
- get() {
603
- return this._getProp(key);
604
- },
605
- set(val) {
606
- this._setProp(key, val);
607
- }
608
- });
609
- }
610
- }
611
- _setAttr(key) {
612
- let value = this.getAttribute(key);
613
- const camelKey = camelize$1(key);
614
- if (this._numberProps && this._numberProps[camelKey]) {
615
- value = toNumber(value);
616
- }
617
- this._setProp(camelKey, value, false);
618
- }
619
- /**
620
- * @internal
621
- */
622
- _getProp(key) {
623
- return this._props[key];
624
- }
625
- /**
626
- * @internal
627
- */
628
- _setProp(key, val, shouldReflect = true, shouldUpdate = true) {
629
- if (val !== this._props[key]) {
630
- this._props[key] = val;
631
- if (shouldUpdate && this._instance) {
632
- this._update();
633
- }
634
- // reflect
635
- if (shouldReflect) {
636
- if (val === true) {
637
- this.setAttribute(hyphenate(key), '');
638
- }
639
- else if (typeof val === 'string' || typeof val === 'number') {
640
- this.setAttribute(hyphenate(key), val + '');
641
- }
642
- else if (!val) {
643
- this.removeAttribute(hyphenate(key));
644
- }
645
- }
646
- }
647
- }
648
- _update() {
649
- render(this._createVNode(), this.shadowRoot);
650
- }
651
- _createVNode() {
652
- const vnode = createVNode(this._def, extend({}, this._props));
653
- if (!this._instance) {
654
- vnode.ce = instance => {
655
- this._instance = instance;
656
- instance.isCE = true;
657
- // HMR
658
- if ((process.env.NODE_ENV !== 'production')) {
659
- instance.ceReload = newStyles => {
660
- // always reset styles
661
- if (this._styles) {
662
- this._styles.forEach(s => this.shadowRoot.removeChild(s));
663
- this._styles.length = 0;
664
- }
665
- this._applyStyles(newStyles);
666
- this._instance = null;
667
- this._update();
668
- };
669
- }
670
- const dispatch = (event, args) => {
671
- this.dispatchEvent(new CustomEvent(event, {
672
- detail: args
673
- }));
674
- };
675
- // intercept emit
676
- instance.emit = (event, ...args) => {
677
- // dispatch both the raw and hyphenated versions of an event
678
- // to match Vue behavior
679
- dispatch(event, args);
680
- if (hyphenate(event) !== event) {
681
- dispatch(hyphenate(event), args);
682
- }
683
- };
684
- // locate nearest Vue custom element parent for provide/inject
685
- let parent = this;
686
- while ((parent =
687
- parent && (parent.parentNode || parent.host))) {
688
- if (parent instanceof VueElement) {
689
- instance.parent = parent._instance;
690
- instance.provides = parent._instance.provides;
691
- break;
692
- }
693
- }
694
- };
695
- }
696
- return vnode;
697
- }
698
- _applyStyles(styles) {
699
- if (styles) {
700
- styles.forEach(css => {
701
- const s = document.createElement('style');
702
- s.textContent = css;
703
- this.shadowRoot.appendChild(s);
704
- // record for HMR
705
- if ((process.env.NODE_ENV !== 'production')) {
706
- (this._styles || (this._styles = [])).push(s);
707
- }
708
- });
709
- }
710
- }
711
- }
712
-
713
- function useCssModule(name = '$style') {
714
- /* istanbul ignore else */
715
- {
716
- const instance = getCurrentInstance();
717
- if (!instance) {
718
- (process.env.NODE_ENV !== 'production') && warn(`useCssModule must be called inside setup()`);
719
- return EMPTY_OBJ;
720
- }
721
- const modules = instance.type.__cssModules;
722
- if (!modules) {
723
- (process.env.NODE_ENV !== 'production') && warn(`Current instance does not have CSS modules injected.`);
724
- return EMPTY_OBJ;
725
- }
726
- const mod = modules[name];
727
- if (!mod) {
728
- (process.env.NODE_ENV !== 'production') &&
729
- warn(`Current instance does not have CSS module named "${name}".`);
730
- return EMPTY_OBJ;
731
- }
732
- return mod;
733
- }
734
- }
735
-
736
- /**
737
- * Runtime helper for SFC's CSS variable injection feature.
738
- * @private
739
- */
740
- function useCssVars(getter) {
741
- const instance = getCurrentInstance();
742
- /* istanbul ignore next */
743
- if (!instance) {
744
- (process.env.NODE_ENV !== 'production') &&
745
- warn(`useCssVars is called without current active component instance.`);
746
- return;
747
- }
748
- const updateTeleports = (instance.ut = (vars = getter(instance.proxy)) => {
749
- Array.from(document.querySelectorAll(`[data-v-owner="${instance.uid}"]`)).forEach(node => setVarsOnNode(node, vars));
750
- });
751
- const setVars = () => {
752
- const vars = getter(instance.proxy);
753
- setVarsOnVNode(instance.subTree, vars);
754
- updateTeleports(vars);
755
- };
756
- watchPostEffect(setVars);
757
- onMounted(() => {
758
- const ob = new MutationObserver(setVars);
759
- ob.observe(instance.subTree.el.parentNode, { childList: true });
760
- onUnmounted(() => ob.disconnect());
761
- });
762
- }
763
- function setVarsOnVNode(vnode, vars) {
764
- if (vnode.shapeFlag & 128 /* ShapeFlags.SUSPENSE */) {
765
- const suspense = vnode.suspense;
766
- vnode = suspense.activeBranch;
767
- if (suspense.pendingBranch && !suspense.isHydrating) {
768
- suspense.effects.push(() => {
769
- setVarsOnVNode(suspense.activeBranch, vars);
770
- });
771
- }
772
- }
773
- // drill down HOCs until it's a non-component vnode
774
- while (vnode.component) {
775
- vnode = vnode.component.subTree;
776
- }
777
- if (vnode.shapeFlag & 1 /* ShapeFlags.ELEMENT */ && vnode.el) {
778
- setVarsOnNode(vnode.el, vars);
779
- }
780
- else if (vnode.type === Fragment) {
781
- vnode.children.forEach(c => setVarsOnVNode(c, vars));
782
- }
783
- else if (vnode.type === Static) {
784
- let { el, anchor } = vnode;
785
- while (el) {
786
- setVarsOnNode(el, vars);
787
- if (el === anchor)
788
- break;
789
- el = el.nextSibling;
790
- }
791
- }
792
- }
793
- function setVarsOnNode(el, vars) {
794
- if (el.nodeType === 1) {
795
- const style = el.style;
796
- for (const key in vars) {
797
- style.setProperty(`--${key}`, vars[key]);
798
- }
799
- }
800
- }
801
-
802
- const TRANSITION = 'transition';
803
- const ANIMATION = 'animation';
804
- // DOM Transition is a higher-order-component based on the platform-agnostic
805
- // base Transition component, with DOM-specific logic.
806
- const Transition = (props, { slots }) => h(BaseTransition, resolveTransitionProps(props), slots);
807
- Transition.displayName = 'Transition';
808
- const DOMTransitionPropsValidators = {
809
- name: String,
810
- type: String,
811
- css: {
812
- type: Boolean,
813
- default: true
814
- },
815
- duration: [String, Number, Object],
816
- enterFromClass: String,
817
- enterActiveClass: String,
818
- enterToClass: String,
819
- appearFromClass: String,
820
- appearActiveClass: String,
821
- appearToClass: String,
822
- leaveFromClass: String,
823
- leaveActiveClass: String,
824
- leaveToClass: String
825
- };
826
- const TransitionPropsValidators = (Transition.props =
827
- /*#__PURE__*/ extend({}, BaseTransition.props, DOMTransitionPropsValidators));
828
- /**
829
- * #3227 Incoming hooks may be merged into arrays when wrapping Transition
830
- * with custom HOCs.
831
- */
832
- const callHook = (hook, args = []) => {
833
- if (isArray(hook)) {
834
- hook.forEach(h => h(...args));
835
- }
836
- else if (hook) {
837
- hook(...args);
838
- }
839
- };
840
- /**
841
- * Check if a hook expects a callback (2nd arg), which means the user
842
- * intends to explicitly control the end of the transition.
843
- */
844
- const hasExplicitCallback = (hook) => {
845
- return hook
846
- ? isArray(hook)
847
- ? hook.some(h => h.length > 1)
848
- : hook.length > 1
849
- : false;
850
- };
851
- function resolveTransitionProps(rawProps) {
852
- const baseProps = {};
853
- for (const key in rawProps) {
854
- if (!(key in DOMTransitionPropsValidators)) {
855
- baseProps[key] = rawProps[key];
856
- }
857
- }
858
- if (rawProps.css === false) {
859
- return baseProps;
860
- }
861
- const { name = 'v', type, duration, enterFromClass = `${name}-enter-from`, enterActiveClass = `${name}-enter-active`, enterToClass = `${name}-enter-to`, appearFromClass = enterFromClass, appearActiveClass = enterActiveClass, appearToClass = enterToClass, leaveFromClass = `${name}-leave-from`, leaveActiveClass = `${name}-leave-active`, leaveToClass = `${name}-leave-to` } = rawProps;
862
- const durations = normalizeDuration(duration);
863
- const enterDuration = durations && durations[0];
864
- const leaveDuration = durations && durations[1];
865
- const { onBeforeEnter, onEnter, onEnterCancelled, onLeave, onLeaveCancelled, onBeforeAppear = onBeforeEnter, onAppear = onEnter, onAppearCancelled = onEnterCancelled } = baseProps;
866
- const finishEnter = (el, isAppear, done) => {
867
- removeTransitionClass(el, isAppear ? appearToClass : enterToClass);
868
- removeTransitionClass(el, isAppear ? appearActiveClass : enterActiveClass);
869
- done && done();
870
- };
871
- const finishLeave = (el, done) => {
872
- el._isLeaving = false;
873
- removeTransitionClass(el, leaveFromClass);
874
- removeTransitionClass(el, leaveToClass);
875
- removeTransitionClass(el, leaveActiveClass);
876
- done && done();
877
- };
878
- const makeEnterHook = (isAppear) => {
879
- return (el, done) => {
880
- const hook = isAppear ? onAppear : onEnter;
881
- const resolve = () => finishEnter(el, isAppear, done);
882
- callHook(hook, [el, resolve]);
883
- nextFrame(() => {
884
- removeTransitionClass(el, isAppear ? appearFromClass : enterFromClass);
885
- addTransitionClass(el, isAppear ? appearToClass : enterToClass);
886
- if (!hasExplicitCallback(hook)) {
887
- whenTransitionEnds(el, type, enterDuration, resolve);
888
- }
889
- });
890
- };
891
- };
892
- return extend(baseProps, {
893
- onBeforeEnter(el) {
894
- callHook(onBeforeEnter, [el]);
895
- addTransitionClass(el, enterFromClass);
896
- addTransitionClass(el, enterActiveClass);
897
- },
898
- onBeforeAppear(el) {
899
- callHook(onBeforeAppear, [el]);
900
- addTransitionClass(el, appearFromClass);
901
- addTransitionClass(el, appearActiveClass);
902
- },
903
- onEnter: makeEnterHook(false),
904
- onAppear: makeEnterHook(true),
905
- onLeave(el, done) {
906
- el._isLeaving = true;
907
- const resolve = () => finishLeave(el, done);
908
- addTransitionClass(el, leaveFromClass);
909
- // force reflow so *-leave-from classes immediately take effect (#2593)
910
- forceReflow();
911
- addTransitionClass(el, leaveActiveClass);
912
- nextFrame(() => {
913
- if (!el._isLeaving) {
914
- // cancelled
915
- return;
916
- }
917
- removeTransitionClass(el, leaveFromClass);
918
- addTransitionClass(el, leaveToClass);
919
- if (!hasExplicitCallback(onLeave)) {
920
- whenTransitionEnds(el, type, leaveDuration, resolve);
921
- }
922
- });
923
- callHook(onLeave, [el, resolve]);
924
- },
925
- onEnterCancelled(el) {
926
- finishEnter(el, false);
927
- callHook(onEnterCancelled, [el]);
928
- },
929
- onAppearCancelled(el) {
930
- finishEnter(el, true);
931
- callHook(onAppearCancelled, [el]);
932
- },
933
- onLeaveCancelled(el) {
934
- finishLeave(el);
935
- callHook(onLeaveCancelled, [el]);
936
- }
937
- });
938
- }
939
- function normalizeDuration(duration) {
940
- if (duration == null) {
941
- return null;
942
- }
943
- else if (isObject(duration)) {
944
- return [NumberOf(duration.enter), NumberOf(duration.leave)];
945
- }
946
- else {
947
- const n = NumberOf(duration);
948
- return [n, n];
949
- }
950
- }
951
- function NumberOf(val) {
952
- const res = toNumber(val);
953
- if ((process.env.NODE_ENV !== 'production'))
954
- validateDuration(res);
955
- return res;
956
- }
957
- function validateDuration(val) {
958
- if (typeof val !== 'number') {
959
- warn(`<transition> explicit duration is not a valid number - ` +
960
- `got ${JSON.stringify(val)}.`);
961
- }
962
- else if (isNaN(val)) {
963
- warn(`<transition> explicit duration is NaN - ` +
964
- 'the duration expression might be incorrect.');
965
- }
966
- }
967
- function addTransitionClass(el, cls) {
968
- cls.split(/\s+/).forEach(c => c && el.classList.add(c));
969
- (el._vtc ||
970
- (el._vtc = new Set())).add(cls);
971
- }
972
- function removeTransitionClass(el, cls) {
973
- cls.split(/\s+/).forEach(c => c && el.classList.remove(c));
974
- const { _vtc } = el;
975
- if (_vtc) {
976
- _vtc.delete(cls);
977
- if (!_vtc.size) {
978
- el._vtc = undefined;
979
- }
980
- }
981
- }
982
- function nextFrame(cb) {
983
- requestAnimationFrame(() => {
984
- requestAnimationFrame(cb);
985
- });
986
- }
987
- let endId = 0;
988
- function whenTransitionEnds(el, expectedType, explicitTimeout, resolve) {
989
- const id = (el._endId = ++endId);
990
- const resolveIfNotStale = () => {
991
- if (id === el._endId) {
992
- resolve();
993
- }
994
- };
995
- if (explicitTimeout) {
996
- return setTimeout(resolveIfNotStale, explicitTimeout);
997
- }
998
- const { type, timeout, propCount } = getTransitionInfo(el, expectedType);
999
- if (!type) {
1000
- return resolve();
1001
- }
1002
- const endEvent = type + 'end';
1003
- let ended = 0;
1004
- const end = () => {
1005
- el.removeEventListener(endEvent, onEnd);
1006
- resolveIfNotStale();
1007
- };
1008
- const onEnd = (e) => {
1009
- if (e.target === el && ++ended >= propCount) {
1010
- end();
1011
- }
1012
- };
1013
- setTimeout(() => {
1014
- if (ended < propCount) {
1015
- end();
1016
- }
1017
- }, timeout + 1);
1018
- el.addEventListener(endEvent, onEnd);
1019
- }
1020
- function getTransitionInfo(el, expectedType) {
1021
- const styles = window.getComputedStyle(el);
1022
- // JSDOM may return undefined for transition properties
1023
- const getStyleProperties = (key) => (styles[key] || '').split(', ');
1024
- const transitionDelays = getStyleProperties(`${TRANSITION}Delay`);
1025
- const transitionDurations = getStyleProperties(`${TRANSITION}Duration`);
1026
- const transitionTimeout = getTimeout(transitionDelays, transitionDurations);
1027
- const animationDelays = getStyleProperties(`${ANIMATION}Delay`);
1028
- const animationDurations = getStyleProperties(`${ANIMATION}Duration`);
1029
- const animationTimeout = getTimeout(animationDelays, animationDurations);
1030
- let type = null;
1031
- let timeout = 0;
1032
- let propCount = 0;
1033
- /* istanbul ignore if */
1034
- if (expectedType === TRANSITION) {
1035
- if (transitionTimeout > 0) {
1036
- type = TRANSITION;
1037
- timeout = transitionTimeout;
1038
- propCount = transitionDurations.length;
1039
- }
1040
- }
1041
- else if (expectedType === ANIMATION) {
1042
- if (animationTimeout > 0) {
1043
- type = ANIMATION;
1044
- timeout = animationTimeout;
1045
- propCount = animationDurations.length;
1046
- }
1047
- }
1048
- else {
1049
- timeout = Math.max(transitionTimeout, animationTimeout);
1050
- type =
1051
- timeout > 0
1052
- ? transitionTimeout > animationTimeout
1053
- ? TRANSITION
1054
- : ANIMATION
1055
- : null;
1056
- propCount = type
1057
- ? type === TRANSITION
1058
- ? transitionDurations.length
1059
- : animationDurations.length
1060
- : 0;
1061
- }
1062
- const hasTransform = type === TRANSITION &&
1063
- /\b(transform|all)(,|$)/.test(getStyleProperties(`${TRANSITION}Property`).toString());
1064
- return {
1065
- type,
1066
- timeout,
1067
- propCount,
1068
- hasTransform
1069
- };
1070
- }
1071
- function getTimeout(delays, durations) {
1072
- while (delays.length < durations.length) {
1073
- delays = delays.concat(delays);
1074
- }
1075
- return Math.max(...durations.map((d, i) => toMs(d) + toMs(delays[i])));
1076
- }
1077
- // Old versions of Chromium (below 61.0.3163.100) formats floating pointer
1078
- // numbers in a locale-dependent way, using a comma instead of a dot.
1079
- // If comma is not replaced with a dot, the input will be rounded down
1080
- // (i.e. acting as a floor function) causing unexpected behaviors
1081
- function toMs(s) {
1082
- return Number(s.slice(0, -1).replace(',', '.')) * 1000;
1083
- }
1084
- // synchronously force layout to put elements into a certain state
1085
- function forceReflow() {
1086
- return document.body.offsetHeight;
1087
- }
1088
-
1089
- const positionMap = new WeakMap();
1090
- const newPositionMap = new WeakMap();
1091
- const TransitionGroupImpl = {
1092
- name: 'TransitionGroup',
1093
- props: /*#__PURE__*/ extend({}, TransitionPropsValidators, {
1094
- tag: String,
1095
- moveClass: String
1096
- }),
1097
- setup(props, { slots }) {
1098
- const instance = getCurrentInstance();
1099
- const state = useTransitionState();
1100
- let prevChildren;
1101
- let children;
1102
- onUpdated(() => {
1103
- // children is guaranteed to exist after initial render
1104
- if (!prevChildren.length) {
1105
- return;
1106
- }
1107
- const moveClass = props.moveClass || `${props.name || 'v'}-move`;
1108
- if (!hasCSSTransform(prevChildren[0].el, instance.vnode.el, moveClass)) {
1109
- return;
1110
- }
1111
- // we divide the work into three loops to avoid mixing DOM reads and writes
1112
- // in each iteration - which helps prevent layout thrashing.
1113
- prevChildren.forEach(callPendingCbs);
1114
- prevChildren.forEach(recordPosition);
1115
- const movedChildren = prevChildren.filter(applyTranslation);
1116
- // force reflow to put everything in position
1117
- forceReflow();
1118
- movedChildren.forEach(c => {
1119
- const el = c.el;
1120
- const style = el.style;
1121
- addTransitionClass(el, moveClass);
1122
- style.transform = style.webkitTransform = style.transitionDuration = '';
1123
- const cb = (el._moveCb = (e) => {
1124
- if (e && e.target !== el) {
1125
- return;
1126
- }
1127
- if (!e || /transform$/.test(e.propertyName)) {
1128
- el.removeEventListener('transitionend', cb);
1129
- el._moveCb = null;
1130
- removeTransitionClass(el, moveClass);
1131
- }
1132
- });
1133
- el.addEventListener('transitionend', cb);
1134
- });
1135
- });
1136
- return () => {
1137
- const rawProps = toRaw(props);
1138
- const cssTransitionProps = resolveTransitionProps(rawProps);
1139
- let tag = rawProps.tag || Fragment;
1140
- prevChildren = children;
1141
- children = slots.default ? getTransitionRawChildren(slots.default()) : [];
1142
- for (let i = 0; i < children.length; i++) {
1143
- const child = children[i];
1144
- if (child.key != null) {
1145
- setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
1146
- }
1147
- else if ((process.env.NODE_ENV !== 'production')) {
1148
- warn(`<TransitionGroup> children must be keyed.`);
1149
- }
1150
- }
1151
- if (prevChildren) {
1152
- for (let i = 0; i < prevChildren.length; i++) {
1153
- const child = prevChildren[i];
1154
- setTransitionHooks(child, resolveTransitionHooks(child, cssTransitionProps, state, instance));
1155
- positionMap.set(child, child.el.getBoundingClientRect());
1156
- }
1157
- }
1158
- return createVNode(tag, null, children);
1159
- };
1160
- }
1161
- };
1162
- const TransitionGroup = TransitionGroupImpl;
1163
- function callPendingCbs(c) {
1164
- const el = c.el;
1165
- if (el._moveCb) {
1166
- el._moveCb();
1167
- }
1168
- if (el._enterCb) {
1169
- el._enterCb();
1170
- }
1171
- }
1172
- function recordPosition(c) {
1173
- newPositionMap.set(c, c.el.getBoundingClientRect());
1174
- }
1175
- function applyTranslation(c) {
1176
- const oldPos = positionMap.get(c);
1177
- const newPos = newPositionMap.get(c);
1178
- const dx = oldPos.left - newPos.left;
1179
- const dy = oldPos.top - newPos.top;
1180
- if (dx || dy) {
1181
- const s = c.el.style;
1182
- s.transform = s.webkitTransform = `translate(${dx}px,${dy}px)`;
1183
- s.transitionDuration = '0s';
1184
- return c;
1185
- }
1186
- }
1187
- function hasCSSTransform(el, root, moveClass) {
1188
- // Detect whether an element with the move class applied has
1189
- // CSS transitions. Since the element may be inside an entering
1190
- // transition at this very moment, we make a clone of it and remove
1191
- // all other transition classes applied to ensure only the move class
1192
- // is applied.
1193
- const clone = el.cloneNode();
1194
- if (el._vtc) {
1195
- el._vtc.forEach(cls => {
1196
- cls.split(/\s+/).forEach(c => c && clone.classList.remove(c));
1197
- });
1198
- }
1199
- moveClass.split(/\s+/).forEach(c => c && clone.classList.add(c));
1200
- clone.style.display = 'none';
1201
- const container = (root.nodeType === 1 ? root : root.parentNode);
1202
- container.appendChild(clone);
1203
- const { hasTransform } = getTransitionInfo(clone);
1204
- container.removeChild(clone);
1205
- return hasTransform;
1206
- }
1207
-
1208
- const getModelAssigner = (vnode) => {
1209
- const fn = vnode.props['onUpdate:modelValue'] ||
1210
- (false );
1211
- return isArray(fn) ? value => invokeArrayFns(fn, value) : fn;
1212
- };
1213
- function onCompositionStart(e) {
1214
- e.target.composing = true;
1215
- }
1216
- function onCompositionEnd(e) {
1217
- const target = e.target;
1218
- if (target.composing) {
1219
- target.composing = false;
1220
- target.dispatchEvent(new Event('input'));
1221
- }
1222
- }
1223
- // We are exporting the v-model runtime directly as vnode hooks so that it can
1224
- // be tree-shaken in case v-model is never used.
1225
- const vModelText = {
1226
- created(el, { modifiers: { lazy, trim, number } }, vnode) {
1227
- el._assign = getModelAssigner(vnode);
1228
- const castToNumber = number || (vnode.props && vnode.props.type === 'number');
1229
- addEventListener(el, lazy ? 'change' : 'input', e => {
1230
- if (e.target.composing)
1231
- return;
1232
- let domValue = el.value;
1233
- if (trim) {
1234
- domValue = domValue.trim();
1235
- }
1236
- if (castToNumber) {
1237
- domValue = toNumber(domValue);
1238
- }
1239
- el._assign(domValue);
1240
- });
1241
- if (trim) {
1242
- addEventListener(el, 'change', () => {
1243
- el.value = el.value.trim();
1244
- });
1245
- }
1246
- if (!lazy) {
1247
- addEventListener(el, 'compositionstart', onCompositionStart);
1248
- addEventListener(el, 'compositionend', onCompositionEnd);
1249
- // Safari < 10.2 & UIWebView doesn't fire compositionend when
1250
- // switching focus before confirming composition choice
1251
- // this also fixes the issue where some browsers e.g. iOS Chrome
1252
- // fires "change" instead of "input" on autocomplete.
1253
- addEventListener(el, 'change', onCompositionEnd);
1254
- }
1255
- },
1256
- // set value on mounted so it's after min/max for type="range"
1257
- mounted(el, { value }) {
1258
- el.value = value == null ? '' : value;
1259
- },
1260
- beforeUpdate(el, { value, modifiers: { lazy, trim, number } }, vnode) {
1261
- el._assign = getModelAssigner(vnode);
1262
- // avoid clearing unresolved text. #2302
1263
- if (el.composing)
1264
- return;
1265
- if (document.activeElement === el && el.type !== 'range') {
1266
- if (lazy) {
1267
- return;
1268
- }
1269
- if (trim && el.value.trim() === value) {
1270
- return;
1271
- }
1272
- if ((number || el.type === 'number') && toNumber(el.value) === value) {
1273
- return;
1274
- }
1275
- }
1276
- const newValue = value == null ? '' : value;
1277
- if (el.value !== newValue) {
1278
- el.value = newValue;
1279
- }
1280
- }
1281
- };
1282
- const vModelCheckbox = {
1283
- // #4096 array checkboxes need to be deep traversed
1284
- deep: true,
1285
- created(el, _, vnode) {
1286
- el._assign = getModelAssigner(vnode);
1287
- addEventListener(el, 'change', () => {
1288
- const modelValue = el._modelValue;
1289
- const elementValue = getValue(el);
1290
- const checked = el.checked;
1291
- const assign = el._assign;
1292
- if (isArray(modelValue)) {
1293
- const index = looseIndexOf(modelValue, elementValue);
1294
- const found = index !== -1;
1295
- if (checked && !found) {
1296
- assign(modelValue.concat(elementValue));
1297
- }
1298
- else if (!checked && found) {
1299
- const filtered = [...modelValue];
1300
- filtered.splice(index, 1);
1301
- assign(filtered);
1302
- }
1303
- }
1304
- else if (isSet(modelValue)) {
1305
- const cloned = new Set(modelValue);
1306
- if (checked) {
1307
- cloned.add(elementValue);
1308
- }
1309
- else {
1310
- cloned.delete(elementValue);
1311
- }
1312
- assign(cloned);
1313
- }
1314
- else {
1315
- assign(getCheckboxValue(el, checked));
1316
- }
1317
- });
1318
- },
1319
- // set initial checked on mount to wait for true-value/false-value
1320
- mounted: setChecked,
1321
- beforeUpdate(el, binding, vnode) {
1322
- el._assign = getModelAssigner(vnode);
1323
- setChecked(el, binding, vnode);
1324
- }
1325
- };
1326
- function setChecked(el, { value, oldValue }, vnode) {
1327
- el._modelValue = value;
1328
- if (isArray(value)) {
1329
- el.checked = looseIndexOf(value, vnode.props.value) > -1;
1330
- }
1331
- else if (isSet(value)) {
1332
- el.checked = value.has(vnode.props.value);
1333
- }
1334
- else if (value !== oldValue) {
1335
- el.checked = looseEqual(value, getCheckboxValue(el, true));
1336
- }
1337
- }
1338
- const vModelRadio = {
1339
- created(el, { value }, vnode) {
1340
- el.checked = looseEqual(value, vnode.props.value);
1341
- el._assign = getModelAssigner(vnode);
1342
- addEventListener(el, 'change', () => {
1343
- el._assign(getValue(el));
1344
- });
1345
- },
1346
- beforeUpdate(el, { value, oldValue }, vnode) {
1347
- el._assign = getModelAssigner(vnode);
1348
- if (value !== oldValue) {
1349
- el.checked = looseEqual(value, vnode.props.value);
1350
- }
1351
- }
1352
- };
1353
- const vModelSelect = {
1354
- // <select multiple> value need to be deep traversed
1355
- deep: true,
1356
- created(el, { value, modifiers: { number } }, vnode) {
1357
- const isSetModel = isSet(value);
1358
- addEventListener(el, 'change', () => {
1359
- const selectedVal = Array.prototype.filter
1360
- .call(el.options, (o) => o.selected)
1361
- .map((o) => number ? toNumber(getValue(o)) : getValue(o));
1362
- el._assign(el.multiple
1363
- ? isSetModel
1364
- ? new Set(selectedVal)
1365
- : selectedVal
1366
- : selectedVal[0]);
1367
- });
1368
- el._assign = getModelAssigner(vnode);
1369
- },
1370
- // set value in mounted & updated because <select> relies on its children
1371
- // <option>s.
1372
- mounted(el, { value }) {
1373
- setSelected(el, value);
1374
- },
1375
- beforeUpdate(el, _binding, vnode) {
1376
- el._assign = getModelAssigner(vnode);
1377
- },
1378
- updated(el, { value }) {
1379
- setSelected(el, value);
1380
- }
1381
- };
1382
- function setSelected(el, value) {
1383
- const isMultiple = el.multiple;
1384
- if (isMultiple && !isArray(value) && !isSet(value)) {
1385
- (process.env.NODE_ENV !== 'production') &&
1386
- warn(`<select multiple v-model> expects an Array or Set value for its binding, ` +
1387
- `but got ${Object.prototype.toString.call(value).slice(8, -1)}.`);
1388
- return;
1389
- }
1390
- for (let i = 0, l = el.options.length; i < l; i++) {
1391
- const option = el.options[i];
1392
- const optionValue = getValue(option);
1393
- if (isMultiple) {
1394
- if (isArray(value)) {
1395
- option.selected = looseIndexOf(value, optionValue) > -1;
1396
- }
1397
- else {
1398
- option.selected = value.has(optionValue);
1399
- }
1400
- }
1401
- else {
1402
- if (looseEqual(getValue(option), value)) {
1403
- if (el.selectedIndex !== i)
1404
- el.selectedIndex = i;
1405
- return;
1406
- }
1407
- }
1408
- }
1409
- if (!isMultiple && el.selectedIndex !== -1) {
1410
- el.selectedIndex = -1;
1411
- }
1412
- }
1413
- // retrieve raw value set via :value bindings
1414
- function getValue(el) {
1415
- return '_value' in el ? el._value : el.value;
1416
- }
1417
- // retrieve raw value for true-value and false-value set via :true-value or :false-value bindings
1418
- function getCheckboxValue(el, checked) {
1419
- const key = checked ? '_trueValue' : '_falseValue';
1420
- return key in el ? el[key] : checked;
1421
- }
1422
- const vModelDynamic = {
1423
- created(el, binding, vnode) {
1424
- callModelHook(el, binding, vnode, null, 'created');
1425
- },
1426
- mounted(el, binding, vnode) {
1427
- callModelHook(el, binding, vnode, null, 'mounted');
1428
- },
1429
- beforeUpdate(el, binding, vnode, prevVNode) {
1430
- callModelHook(el, binding, vnode, prevVNode, 'beforeUpdate');
1431
- },
1432
- updated(el, binding, vnode, prevVNode) {
1433
- callModelHook(el, binding, vnode, prevVNode, 'updated');
1434
- }
1435
- };
1436
- function resolveDynamicModel(tagName, type) {
1437
- switch (tagName) {
1438
- case 'SELECT':
1439
- return vModelSelect;
1440
- case 'TEXTAREA':
1441
- return vModelText;
1442
- default:
1443
- switch (type) {
1444
- case 'checkbox':
1445
- return vModelCheckbox;
1446
- case 'radio':
1447
- return vModelRadio;
1448
- default:
1449
- return vModelText;
1450
- }
1451
- }
1452
- }
1453
- function callModelHook(el, binding, vnode, prevVNode, hook) {
1454
- const modelToUse = resolveDynamicModel(el.tagName, vnode.props && vnode.props.type);
1455
- const fn = modelToUse[hook];
1456
- fn && fn(el, binding, vnode, prevVNode);
1457
- }
1458
- // SSR vnode transforms, only used when user includes client-oriented render
1459
- // function in SSR
1460
- function initVModelForSSR() {
1461
- vModelText.getSSRProps = ({ value }) => ({ value });
1462
- vModelRadio.getSSRProps = ({ value }, vnode) => {
1463
- if (vnode.props && looseEqual(vnode.props.value, value)) {
1464
- return { checked: true };
1465
- }
1466
- };
1467
- vModelCheckbox.getSSRProps = ({ value }, vnode) => {
1468
- if (isArray(value)) {
1469
- if (vnode.props && looseIndexOf(value, vnode.props.value) > -1) {
1470
- return { checked: true };
1471
- }
1472
- }
1473
- else if (isSet(value)) {
1474
- if (vnode.props && value.has(vnode.props.value)) {
1475
- return { checked: true };
1476
- }
1477
- }
1478
- else if (value) {
1479
- return { checked: true };
1480
- }
1481
- };
1482
- vModelDynamic.getSSRProps = (binding, vnode) => {
1483
- if (typeof vnode.type !== 'string') {
1484
- return;
1485
- }
1486
- const modelToUse = resolveDynamicModel(
1487
- // resolveDynamicModel expects an uppercase tag name, but vnode.type is lowercase
1488
- vnode.type.toUpperCase(), vnode.props && vnode.props.type);
1489
- if (modelToUse.getSSRProps) {
1490
- return modelToUse.getSSRProps(binding, vnode);
1491
- }
1492
- };
1493
- }
1494
-
1495
- const systemModifiers = ['ctrl', 'shift', 'alt', 'meta'];
1496
- const modifierGuards = {
1497
- stop: e => e.stopPropagation(),
1498
- prevent: e => e.preventDefault(),
1499
- self: e => e.target !== e.currentTarget,
1500
- ctrl: e => !e.ctrlKey,
1501
- shift: e => !e.shiftKey,
1502
- alt: e => !e.altKey,
1503
- meta: e => !e.metaKey,
1504
- left: e => 'button' in e && e.button !== 0,
1505
- middle: e => 'button' in e && e.button !== 1,
1506
- right: e => 'button' in e && e.button !== 2,
1507
- exact: (e, modifiers) => systemModifiers.some(m => e[`${m}Key`] && !modifiers.includes(m))
1508
- };
1509
- /**
1510
- * @private
1511
- */
1512
- const withModifiers = (fn, modifiers) => {
1513
- return (event, ...args) => {
1514
- for (let i = 0; i < modifiers.length; i++) {
1515
- const guard = modifierGuards[modifiers[i]];
1516
- if (guard && guard(event, modifiers))
1517
- return;
1518
- }
1519
- return fn(event, ...args);
1520
- };
1521
- };
1522
- // Kept for 2.x compat.
1523
- // Note: IE11 compat for `spacebar` and `del` is removed for now.
1524
- const keyNames = {
1525
- esc: 'escape',
1526
- space: ' ',
1527
- up: 'arrow-up',
1528
- left: 'arrow-left',
1529
- right: 'arrow-right',
1530
- down: 'arrow-down',
1531
- delete: 'backspace'
1532
- };
1533
- /**
1534
- * @private
1535
- */
1536
- const withKeys = (fn, modifiers) => {
1537
- return (event) => {
1538
- if (!('key' in event)) {
1539
- return;
1540
- }
1541
- const eventKey = hyphenate(event.key);
1542
- if (modifiers.some(k => k === eventKey || keyNames[k] === eventKey)) {
1543
- return fn(event);
1544
- }
1545
- };
1546
- };
1547
-
1548
- const vShow = {
1549
- beforeMount(el, { value }, { transition }) {
1550
- el._vod = el.style.display === 'none' ? '' : el.style.display;
1551
- if (transition && value) {
1552
- transition.beforeEnter(el);
1553
- }
1554
- else {
1555
- setDisplay(el, value);
1556
- }
1557
- },
1558
- mounted(el, { value }, { transition }) {
1559
- if (transition && value) {
1560
- transition.enter(el);
1561
- }
1562
- },
1563
- updated(el, { value, oldValue }, { transition }) {
1564
- if (!value === !oldValue)
1565
- return;
1566
- if (transition) {
1567
- if (value) {
1568
- transition.beforeEnter(el);
1569
- setDisplay(el, true);
1570
- transition.enter(el);
1571
- }
1572
- else {
1573
- transition.leave(el, () => {
1574
- setDisplay(el, false);
1575
- });
1576
- }
1577
- }
1578
- else {
1579
- setDisplay(el, value);
1580
- }
1581
- },
1582
- beforeUnmount(el, { value }) {
1583
- setDisplay(el, value);
1584
- }
1585
- };
1586
- function setDisplay(el, value) {
1587
- el.style.display = value ? el._vod : 'none';
1588
- }
1589
- // SSR vnode transforms, only used when user includes client-oriented render
1590
- // function in SSR
1591
- function initVShowForSSR() {
1592
- vShow.getSSRProps = ({ value }) => {
1593
- if (!value) {
1594
- return { style: { display: 'none' } };
1595
- }
1596
- };
1597
- }
1598
-
1599
- const rendererOptions = /*#__PURE__*/ extend({ patchProp }, nodeOps);
1600
- // lazy create the renderer - this makes core renderer logic tree-shakable
1601
- // in case the user only imports reactivity utilities from Vue.
1602
- let renderer;
1603
- let enabledHydration = false;
1604
- function ensureRenderer() {
1605
- return (renderer ||
1606
- (renderer = createRenderer(rendererOptions)));
1607
- }
1608
- function ensureHydrationRenderer() {
1609
- renderer = enabledHydration
1610
- ? renderer
1611
- : createHydrationRenderer(rendererOptions);
1612
- enabledHydration = true;
1613
- return renderer;
1614
- }
1615
- // use explicit type casts here to avoid import() calls in rolled-up d.ts
1616
- const render = ((...args) => {
1617
- ensureRenderer().render(...args);
1618
- });
1619
- const hydrate = ((...args) => {
1620
- ensureHydrationRenderer().hydrate(...args);
1621
- });
1622
- const createApp = ((...args) => {
1623
- const app = ensureRenderer().createApp(...args);
1624
- if ((process.env.NODE_ENV !== 'production')) {
1625
- injectNativeTagCheck(app);
1626
- injectCompilerOptionsCheck(app);
1627
- }
1628
- const { mount } = app;
1629
- app.mount = (containerOrSelector) => {
1630
- const container = normalizeContainer(containerOrSelector);
1631
- if (!container)
1632
- return;
1633
- const component = app._component;
1634
- if (!isFunction(component) && !component.render && !component.template) {
1635
- // __UNSAFE__
1636
- // Reason: potential execution of JS expressions in in-DOM template.
1637
- // The user must make sure the in-DOM template is trusted. If it's
1638
- // rendered by the server, the template should not contain any user data.
1639
- component.template = container.innerHTML;
1640
- }
1641
- // clear content before mounting
1642
- container.innerHTML = '';
1643
- const proxy = mount(container, false, container instanceof SVGElement);
1644
- if (container instanceof Element) {
1645
- container.removeAttribute('v-cloak');
1646
- container.setAttribute('data-v-app', '');
1647
- }
1648
- return proxy;
1649
- };
1650
- return app;
1651
- });
1652
- const createSSRApp = ((...args) => {
1653
- const app = ensureHydrationRenderer().createApp(...args);
1654
- if ((process.env.NODE_ENV !== 'production')) {
1655
- injectNativeTagCheck(app);
1656
- injectCompilerOptionsCheck(app);
1657
- }
1658
- const { mount } = app;
1659
- app.mount = (containerOrSelector) => {
1660
- const container = normalizeContainer(containerOrSelector);
1661
- if (container) {
1662
- return mount(container, true, container instanceof SVGElement);
1663
- }
1664
- };
1665
- return app;
1666
- });
1667
- function injectNativeTagCheck(app) {
1668
- // Inject `isNativeTag`
1669
- // this is used for component name validation (dev only)
1670
- Object.defineProperty(app.config, 'isNativeTag', {
1671
- value: (tag) => isHTMLTag(tag) || isSVGTag(tag),
1672
- writable: false
1673
- });
1674
- }
1675
- // dev only
1676
- function injectCompilerOptionsCheck(app) {
1677
- if (isRuntimeOnly()) {
1678
- const isCustomElement = app.config.isCustomElement;
1679
- Object.defineProperty(app.config, 'isCustomElement', {
1680
- get() {
1681
- return isCustomElement;
1682
- },
1683
- set() {
1684
- warn(`The \`isCustomElement\` config option is deprecated. Use ` +
1685
- `\`compilerOptions.isCustomElement\` instead.`);
1686
- }
1687
- });
1688
- const compilerOptions = app.config.compilerOptions;
1689
- const msg = `The \`compilerOptions\` config option is only respected when using ` +
1690
- `a build of Vue.js that includes the runtime compiler (aka "full build"). ` +
1691
- `Since you are using the runtime-only build, \`compilerOptions\` ` +
1692
- `must be passed to \`@vue/compiler-dom\` in the build setup instead.\n` +
1693
- `- For vue-loader: pass it via vue-loader's \`compilerOptions\` loader option.\n` +
1694
- `- For vue-cli: see https://cli.vuejs.org/guide/webpack.html#modifying-options-of-a-loader\n` +
1695
- `- For vite: pass it via @vitejs/plugin-vue options. See https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom`;
1696
- Object.defineProperty(app.config, 'compilerOptions', {
1697
- get() {
1698
- // JsView Added >>>
1699
- // 解决连接vuejs-devtools后的大量报警问题
1700
- if(!this.jsvVuejsDevtools)
1701
- // JsView Added <<<
1702
- warn(msg);
1703
- return compilerOptions;
1704
- },
1705
- set() {
1706
- warn(msg);
1707
- }
1708
- });
1709
- }
1710
- }
1711
- function normalizeContainer(container) {
1712
- if (isString(container)) {
1713
- const res = document.querySelector(container);
1714
- if ((process.env.NODE_ENV !== 'production') && !res) {
1715
- warn(`Failed to mount app: mount target selector "${container}" returned null.`);
1716
- }
1717
- return res;
1718
- }
1719
- if ((process.env.NODE_ENV !== 'production') &&
1720
- window.ShadowRoot &&
1721
- container instanceof window.ShadowRoot &&
1722
- container.mode === 'closed') {
1723
- warn(`mounting on a ShadowRoot with \`{mode: "closed"}\` may lead to unpredictable bugs`);
1724
- }
1725
- return container;
1726
- }
1727
- let ssrDirectiveInitialized = false;
1728
- /**
1729
- * @internal
1730
- */
1731
- const initDirectivesForSSR = () => {
1732
- if (!ssrDirectiveInitialized) {
1733
- ssrDirectiveInitialized = true;
1734
- initVModelForSSR();
1735
- initVShowForSSR();
1736
- }
1737
- }
1738
- ;
1739
-
1740
- export { Transition, TransitionGroup, VueElement, createApp, createSSRApp, defineCustomElement, defineSSRCustomElement, hydrate, initDirectivesForSSR, render, useCssModule, useCssVars, vModelCheckbox, vModelDynamic, vModelRadio, vModelSelect, vModelText, vShow, withKeys, withModifiers };