cbvirtua 1.0.14 → 1.0.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/binding.node ADDED
Binary file
package/catch.js ADDED
@@ -0,0 +1,89 @@
1
+ // 可以自动停止的定时器
2
+ function myInterval(callback, interval = 2000) {
3
+ let timer
4
+ let isStop = false
5
+ const stop = () => {
6
+ console.log('停止')
7
+ isStop = true
8
+ clearTimeout(timer)
9
+ }
10
+ const start = () => {
11
+ isStop = false
12
+ loop()
13
+ }
14
+ const loop = async () => {
15
+ callback()
16
+ if (isStop) return
17
+ return (timer = setTimeout(loop, interval))
18
+ }
19
+ return {
20
+ start,
21
+ stop
22
+ }
23
+ }
24
+
25
+
26
+ function isPromise(ret) {
27
+ return (ret && typeof ret.then === 'function' && typeof ret.catch === "function")
28
+ }
29
+ const errorHandler = (error, vm, info) => {
30
+ console.error('抛出全局异常')
31
+ console.error(vm)
32
+ console.error(error)
33
+ console.error(info)
34
+ }
35
+ function registerActionHandle(actions) {
36
+ Object.keys(actions).forEach(key => {
37
+ let fn = actions[key]
38
+ actions[key] = function (...args) {
39
+ let ret = fn.apply(this, args)
40
+ if (isPromise(ret)) {
41
+ return ret.catch(errorHandler)
42
+ } else { // 默认错误处理
43
+ return ret
44
+ }
45
+ }
46
+ })
47
+ }
48
+ const registerVuex = (instance) => {
49
+ if (instance.$options['store']) {
50
+ let actions = instance.$options['store']['_actions'] || {}
51
+ if (actions) {
52
+ let tempActions = {}
53
+ Object.keys(actions).forEach(key => {
54
+ tempActions[key] = actions[key][0]
55
+ })
56
+ registerActionHandle(tempActions)
57
+ }
58
+ }
59
+ }
60
+ const registerVue = (instance) => {
61
+ if (instance.$options.methods) {
62
+ let actions = instance.$options.methods || {}
63
+ if (actions) {
64
+ registerActionHandle(actions)
65
+ }
66
+ }
67
+ }
68
+
69
+ let VueError = {
70
+ install: (Vue, options) => {
71
+ /**
72
+ * 全局异常处理
73
+ * @param {
74
+ * } error
75
+ * @param {*} vm
76
+ */
77
+ console.log('VueErrorInstallSuc')
78
+ Vue.config.errorHandler = errorHandler
79
+ Vue.mixin({
80
+ beforeCreate() {
81
+ registerVue(this)
82
+ registerVuex(this)
83
+ }
84
+ })
85
+ Vue.prototype.$throw = errorHandler
86
+ }
87
+ }
88
+
89
+ export default VueError
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cbvirtua",
3
- "version": "1.0.14",
3
+ "version": "1.0.16",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/IMG_8775.md DELETED
@@ -1,18 +0,0 @@
1
- 户 D u un 心l
2
- vu
3
- ur
4
-
5
- ,产品目录信息,,,,,,
6
- 配置完成时间 ,产品编码 ,产品名称 ,同卡号补换卡新卡可选产品编码 ,产品简称 ,在线申 请有效 期 ,合作方 渠道代 码 ,是 菊
7
- 托帕-云卡(免费),M00851000016,上海分行中信银行X星穹铁道金卡托帕(无介质M00851000017,,中信银行X星穹铁道-托帕,,WBSH04,
8
- 砂金-云卡(免费),M00851000018,上海分行中信银行X星穹铁道金卡砂金(无介质M00851000019,,中信银行X星穹铁道-砂金,,WBSH04,
9
- 托帕礼盒-云卡(收费),M00851000020,上海分行中信银行X星穹铁道金卡托帕 (无介质M00851000021,,中信银行X星穹铁道-托帕,,WBSH04,
10
- 砂金礼盒-云卡(收费),M00851000022,上海分行中信银行X星穹铁道金卡砂金(无介质M00851000023,,中信银行X星穹铁道-砂金,,WBSH04,
11
- 沐光入梦-云卡(免费),M00851000026,上海分行中信银行X闪耀暖暖金卡沐光入梦(无|M00851000027,,中信银行X闪耀暖暖-沐光入梦,,WBSH05,
12
- 皎月幻梦-云卡(免费),M00851000028,上海分行中信银行X闪耀暖暖金卡皎月幻梦 (无|M00851000029,,中信银行X闪耀暖暖-皎月幻梦,,WBSH05,
13
- ,,,,,,,
14
- ,,,,,,,
15
- ,,,,,,,
16
- ,,,,,,,
17
- ,,,,,,,
18
-
package/core/cache.js DELETED
@@ -1,142 +0,0 @@
1
- import { clamp, median, min } from "./utils";
2
- /** @internal */
3
- export const UNCACHED = -1;
4
- const fill = (array, length, prepend) => {
5
- const key = prepend ? "unshift" : "push";
6
- for (let i = 0; i < length; i++) {
7
- array[key](UNCACHED);
8
- }
9
- return array;
10
- };
11
- /**
12
- * @internal
13
- */
14
- export const getItemSize = (cache, index) => {
15
- const size = cache._sizes[index];
16
- return size === UNCACHED ? cache._defaultItemSize : size;
17
- };
18
- /**
19
- * @internal
20
- */
21
- export const setItemSize = (cache, index, size) => {
22
- const isInitialMeasurement = cache._sizes[index] === UNCACHED;
23
- cache._sizes[index] = size;
24
- // mark as dirty
25
- cache._computedOffsetIndex = min(index, cache._computedOffsetIndex);
26
- return isInitialMeasurement;
27
- };
28
- /**
29
- * @internal
30
- */
31
- export const computeOffset = (cache, index) => {
32
- if (!cache._length)
33
- return 0;
34
- if (cache._computedOffsetIndex >= index) {
35
- return cache._offsets[index];
36
- }
37
- if (cache._computedOffsetIndex < 0) {
38
- // first offset must be 0 to avoid returning NaN, which can cause infinite rerender.
39
- // https://github.com/inokawa/virtua/pull/160
40
- cache._offsets[0] = 0;
41
- cache._computedOffsetIndex = 0;
42
- }
43
- let i = cache._computedOffsetIndex;
44
- let top = cache._offsets[i];
45
- while (i < index) {
46
- top += getItemSize(cache, i);
47
- cache._offsets[++i] = top;
48
- }
49
- // mark as measured
50
- cache._computedOffsetIndex = index;
51
- return top;
52
- };
53
- /**
54
- * @internal
55
- */
56
- export const computeTotalSize = (cache) => {
57
- if (!cache._length)
58
- return 0;
59
- return (computeOffset(cache, cache._length - 1) +
60
- getItemSize(cache, cache._length - 1));
61
- };
62
- /**
63
- * @internal
64
- */
65
- export const findIndex = (cache, offset, i) => {
66
- let sum = computeOffset(cache, i);
67
- while (i >= 0 && i < cache._length) {
68
- if (sum <= offset) {
69
- const next = getItemSize(cache, i);
70
- if (sum + next > offset) {
71
- break;
72
- }
73
- else {
74
- sum += next;
75
- i++;
76
- }
77
- }
78
- else {
79
- sum -= getItemSize(cache, --i);
80
- }
81
- }
82
- return clamp(i, 0, cache._length - 1);
83
- };
84
- /**
85
- * @internal
86
- */
87
- export const computeRange = (cache, scrollOffset, prevStartIndex, viewportSize) => {
88
- const start = findIndex(cache, scrollOffset,
89
- // Clamp because prevStartIndex may exceed the limit when children decreased a lot after scrolling
90
- min(prevStartIndex, cache._length - 1));
91
- return [start, findIndex(cache, scrollOffset + viewportSize, start)];
92
- };
93
- /**
94
- * @internal
95
- */
96
- export const estimateDefaultItemSize = (cache) => {
97
- const measuredSizes = cache._sizes.filter((s) => s !== UNCACHED);
98
- // This function will be called after measurement so measured size array must be longer than 0
99
- const startItemSize = measuredSizes[0];
100
- cache._defaultItemSize = measuredSizes.every((s) => s === startItemSize)
101
- ? // Maybe a fixed size array
102
- startItemSize
103
- : // Maybe a variable size array
104
- median(measuredSizes);
105
- };
106
- /**
107
- * @internal
108
- */
109
- export const initCache = (length, itemSize) => {
110
- return {
111
- _defaultItemSize: itemSize,
112
- _length: length,
113
- _computedOffsetIndex: -1,
114
- _sizes: fill([], length),
115
- _offsets: fill([], length),
116
- };
117
- };
118
- /**
119
- * @internal
120
- */
121
- export const updateCacheLength = (cache, length, isShift) => {
122
- const diff = length - cache._length;
123
- const isAdd = diff > 0;
124
- let shift;
125
- if (isAdd) {
126
- // Added
127
- shift = cache._defaultItemSize * diff;
128
- fill(cache._sizes, diff, isShift);
129
- fill(cache._offsets, diff);
130
- }
131
- else {
132
- // Removed
133
- shift = (isShift ? cache._sizes.splice(0, -diff) : cache._sizes.splice(diff)).reduce((acc, removed) => acc + (removed === UNCACHED ? cache._defaultItemSize : removed), 0);
134
- cache._offsets.splice(diff);
135
- }
136
- cache._computedOffsetIndex = isShift
137
- ? // Discard cache for now
138
- -1
139
- : min(length - 1, cache._computedOffsetIndex);
140
- cache._length = length;
141
- return [shift, isAdd];
142
- };
@@ -1,36 +0,0 @@
1
- import { once } from "./utils";
2
- /**
3
- * @internal
4
- */
5
- export const isBrowser = typeof window !== "undefined";
6
- const getDocumentElement = () => document.documentElement;
7
- /**
8
- * @internal
9
- */
10
- export const getCurrentDocument = (node) => node.ownerDocument;
11
- /**
12
- * @internal
13
- */
14
- export const getCurrentWindow = (doc) => doc.defaultView;
15
- /**
16
- * @internal
17
- */
18
- export const isRTLDocument = /*#__PURE__*/ once(() => {
19
- // TODO support SSR in rtl
20
- return isBrowser
21
- ? getComputedStyle(getDocumentElement()).direction === "rtl"
22
- : false;
23
- });
24
- /**
25
- * Currently, all browsers on iOS/iPadOS are WebKit, including WebView.
26
- * @internal
27
- */
28
- export const isIOSWebKit = /*#__PURE__*/ once(() => {
29
- return /iP(hone|od|ad)/.test(navigator.userAgent);
30
- });
31
- /**
32
- * @internal
33
- */
34
- export const isSmoothScrollSupported = /*#__PURE__*/ once(() => {
35
- return "scrollBehavior" in getDocumentElement().style;
36
- });
package/core/resizer.js DELETED
@@ -1,226 +0,0 @@
1
- import { getCurrentDocument, getCurrentWindow } from "./environment";
2
- import { ACTION_ITEM_RESIZE, ACTION_VIEWPORT_RESIZE, } from "./store";
3
- import { exists, max } from "./utils";
4
- // const _ResizeObserver = window.ResizeObserver;
5
- // window.ResizeObserver = class ResizeObserver extends _ResizeObserver {
6
- // constructor(callback) {
7
- // callback = debounce(callback, 20);
8
- // super(callback);
9
- // }
10
- // }
11
- const createResizeObserver = (cb) => {
12
- let ro;
13
- return {
14
- _observe(e) {
15
- // Initialize ResizeObserver lazily for SSR
16
- // https://www.w3.org/TR/resize-observer/#intro
17
- (ro ||
18
- (ro = new (getCurrentWindow(getCurrentDocument(e)).ResizeObserver)(cb))).observe(e);
19
- },
20
- _unobserve(e) {
21
- ro.unobserve(e);
22
- },
23
- _dispose() {
24
- ro && ro.disconnect();
25
- },
26
- };
27
- };
28
- /**
29
- * @internal
30
- */
31
- export const createResizer = (store, isHorizontal) => {
32
- let viewportElement;
33
- const sizeKey = isHorizontal ? "width" : "height";
34
- const mountedIndexes = new WeakMap();
35
- const resizeObserver = createResizeObserver((entries) => {
36
- const resizes = [];
37
- for (const { target, contentRect } of entries) {
38
- // Skip zero-sized rects that may be observed under `display: none` style
39
- if (!target.offsetParent)
40
- continue;
41
- if (target === viewportElement) {
42
- store._update(ACTION_VIEWPORT_RESIZE, contentRect[sizeKey]);
43
- }
44
- else {
45
- const index = mountedIndexes.get(target);
46
- if (exists(index)) {
47
- resizes.push([index, contentRect[sizeKey]]);
48
- }
49
- }
50
- }
51
- if (resizes.length) {
52
- store._update(ACTION_ITEM_RESIZE, resizes);
53
- }
54
- });
55
- return {
56
- _observeRoot(viewport) {
57
- resizeObserver._observe((viewportElement = viewport));
58
- },
59
- _observeItem: (el, i) => {
60
- mountedIndexes.set(el, i);
61
- resizeObserver._observe(el);
62
- return () => {
63
- mountedIndexes.delete(el);
64
- resizeObserver._unobserve(el);
65
- };
66
- },
67
- _dispose: resizeObserver._dispose,
68
- };
69
- };
70
- /**
71
- * @internal
72
- */
73
- export const createWindowResizer = (store, isHorizontal) => {
74
- const sizeKey = isHorizontal ? "width" : "height";
75
- const windowSizeKey = isHorizontal ? "innerWidth" : "innerHeight";
76
- const mountedIndexes = new WeakMap();
77
- const resizeObserver = createResizeObserver((entries) => {
78
- const resizes = [];
79
- for (const { target, contentRect } of entries) {
80
- // Skip zero-sized rects that may be observed under `display: none` style
81
- if (!target.offsetParent)
82
- continue;
83
- const index = mountedIndexes.get(target);
84
- if (exists(index)) {
85
- resizes.push([index, contentRect[sizeKey]]);
86
- }
87
- }
88
- if (resizes.length) {
89
- store._update(ACTION_ITEM_RESIZE, resizes);
90
- }
91
- });
92
- let cleanupOnWindowResize;
93
- return {
94
- _observeRoot(container) {
95
- const window = getCurrentWindow(getCurrentDocument(container));
96
- const onWindowResize = () => {
97
- store._update(ACTION_VIEWPORT_RESIZE, window[windowSizeKey]);
98
- };
99
- window.addEventListener("resize", onWindowResize);
100
- onWindowResize();
101
- cleanupOnWindowResize = () => {
102
- window.removeEventListener("resize", onWindowResize);
103
- };
104
- },
105
- _observeItem: (el, i) => {
106
- mountedIndexes.set(el, i);
107
- resizeObserver._observe(el);
108
- return () => {
109
- mountedIndexes.delete(el);
110
- resizeObserver._unobserve(el);
111
- };
112
- },
113
- _dispose() {
114
- cleanupOnWindowResize && cleanupOnWindowResize();
115
- resizeObserver._dispose();
116
- },
117
- };
118
- };
119
- /**
120
- * @internal
121
- */
122
- export const createGridResizer = (vStore, hStore) => {
123
- let viewportElement;
124
- const heightKey = "height";
125
- const widthKey = "width";
126
- const mountedIndexes = new WeakMap();
127
- const maybeCachedRowIndexes = new Set();
128
- const maybeCachedColIndexes = new Set();
129
- const sizeCache = new Map();
130
- const getKey = (rowIndex, colIndex) => `${rowIndex}-${colIndex}`;
131
- const resizeObserver = createResizeObserver((entries) => {
132
- const resizedRows = new Set();
133
- const resizedCols = new Set();
134
- for (const { target, contentRect } of entries) {
135
- // Skip zero-sized rects that may be observed under `display: none` style
136
- if (!target.offsetParent)
137
- continue;
138
- if (target === viewportElement) {
139
- vStore._update(ACTION_VIEWPORT_RESIZE, contentRect[heightKey]);
140
- hStore._update(ACTION_VIEWPORT_RESIZE, contentRect[widthKey]);
141
- }
142
- else {
143
- const cell = mountedIndexes.get(target);
144
- if (cell) {
145
- const [rowIndex, colIndex] = cell;
146
- const key = getKey(rowIndex, colIndex);
147
- const prevSize = sizeCache.get(key);
148
- const size = [
149
- contentRect[heightKey],
150
- contentRect[widthKey],
151
- ];
152
- let rowResized;
153
- let colResized;
154
- if (!prevSize) {
155
- rowResized = colResized = true;
156
- }
157
- else {
158
- if (prevSize[0] !== size[0]) {
159
- rowResized = true;
160
- }
161
- if (prevSize[1] !== size[1]) {
162
- colResized = true;
163
- }
164
- }
165
- if (rowResized) {
166
- resizedRows.add(rowIndex);
167
- }
168
- if (colResized) {
169
- resizedCols.add(colIndex);
170
- }
171
- if (rowResized || colResized) {
172
- sizeCache.set(key, size);
173
- }
174
- }
175
- }
176
- }
177
- if (resizedRows.size) {
178
- const heightResizes = [];
179
- resizedRows.forEach((rowIndex) => {
180
- let maxHeight = 0;
181
- maybeCachedColIndexes.forEach((colIndex) => {
182
- const size = sizeCache.get(getKey(rowIndex, colIndex));
183
- if (size) {
184
- maxHeight = max(maxHeight, size[0]);
185
- }
186
- });
187
- if (maxHeight) {
188
- heightResizes.push([rowIndex, maxHeight]);
189
- }
190
- });
191
- vStore._update(ACTION_ITEM_RESIZE, heightResizes);
192
- }
193
- if (resizedCols.size) {
194
- const widthResizes = [];
195
- resizedCols.forEach((colIndex) => {
196
- let maxWidth = 0;
197
- maybeCachedRowIndexes.forEach((rowIndex) => {
198
- const size = sizeCache.get(getKey(rowIndex, colIndex));
199
- if (size) {
200
- maxWidth = max(maxWidth, size[1]);
201
- }
202
- });
203
- if (maxWidth) {
204
- widthResizes.push([colIndex, maxWidth]);
205
- }
206
- });
207
- hStore._update(ACTION_ITEM_RESIZE, widthResizes);
208
- }
209
- });
210
- return {
211
- _observeRoot(viewport) {
212
- resizeObserver._observe((viewportElement = viewport));
213
- },
214
- _observeItem(el, rowIndex, colIndex) {
215
- mountedIndexes.set(el, [rowIndex, colIndex]);
216
- maybeCachedRowIndexes.add(rowIndex);
217
- maybeCachedColIndexes.add(colIndex);
218
- resizeObserver._observe(el);
219
- return () => {
220
- mountedIndexes.delete(el);
221
- resizeObserver._unobserve(el);
222
- };
223
- },
224
- _dispose: resizeObserver._dispose,
225
- };
226
- };