@whitesev/pops 3.1.2 → 3.1.3
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/dist/index.amd.js +108 -118
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +108 -118
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +108 -118
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +108 -118
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +108 -118
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +108 -118
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/package.json +8 -8
- package/src/components/tooltip/index.ts +12 -6
package/dist/index.esm.js
CHANGED
|
@@ -259,47 +259,7 @@ const LAST_NUMBER_WEAK_MAP = new WeakMap();
|
|
|
259
259
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
260
260
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
261
261
|
|
|
262
|
-
const
|
|
263
|
-
return typeof sender.start === 'function';
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const PORT_MAP = new WeakMap();
|
|
267
|
-
|
|
268
|
-
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
269
|
-
...partialBrokerImplementation,
|
|
270
|
-
connect: ({ call }) => {
|
|
271
|
-
return async () => {
|
|
272
|
-
const { port1, port2 } = new MessageChannel();
|
|
273
|
-
const portId = await call('connect', { port: port1 }, [port1]);
|
|
274
|
-
PORT_MAP.set(port2, portId);
|
|
275
|
-
return port2;
|
|
276
|
-
};
|
|
277
|
-
},
|
|
278
|
-
disconnect: ({ call }) => {
|
|
279
|
-
return async (port) => {
|
|
280
|
-
const portId = PORT_MAP.get(port);
|
|
281
|
-
if (portId === undefined) {
|
|
282
|
-
throw new Error('The given port is not connected.');
|
|
283
|
-
}
|
|
284
|
-
await call('disconnect', { portId });
|
|
285
|
-
};
|
|
286
|
-
},
|
|
287
|
-
isSupported: ({ call }) => {
|
|
288
|
-
return () => call('isSupported');
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
const ONGOING_REQUESTS = new WeakMap();
|
|
293
|
-
const createOrGetOngoingRequests = (sender) => {
|
|
294
|
-
if (ONGOING_REQUESTS.has(sender)) {
|
|
295
|
-
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
296
|
-
return ONGOING_REQUESTS.get(sender);
|
|
297
|
-
}
|
|
298
|
-
const ongoingRequests = new Map();
|
|
299
|
-
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
300
|
-
return ongoingRequests;
|
|
301
|
-
};
|
|
302
|
-
const createBroker = (brokerImplementation) => {
|
|
262
|
+
const createBrokerFactory = (createOrGetOngoingRequests, extendBrokerImplementation, generateUniqueNumber, isMessagePort) => (brokerImplementation) => {
|
|
303
263
|
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
304
264
|
return (sender) => {
|
|
305
265
|
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
@@ -342,81 +302,115 @@ const createBroker = (brokerImplementation) => {
|
|
|
342
302
|
};
|
|
343
303
|
};
|
|
344
304
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
305
|
+
const createCreateOrGetOngoingRequests = (ongoingRequestsMap) => (sender) => {
|
|
306
|
+
if (ongoingRequestsMap.has(sender)) {
|
|
307
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
308
|
+
return ongoingRequestsMap.get(sender);
|
|
309
|
+
}
|
|
310
|
+
const ongoingRequests = new Map();
|
|
311
|
+
ongoingRequestsMap.set(sender, ongoingRequests);
|
|
312
|
+
return ongoingRequests;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const createExtendBrokerImplementation = (portMap) => (partialBrokerImplementation) => ({
|
|
316
|
+
...partialBrokerImplementation,
|
|
317
|
+
connect: ({ call }) => {
|
|
318
|
+
return async () => {
|
|
319
|
+
const { port1, port2 } = new MessageChannel();
|
|
320
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
321
|
+
portMap.set(port2, portId);
|
|
322
|
+
return port2;
|
|
357
323
|
};
|
|
358
324
|
},
|
|
359
|
-
|
|
360
|
-
return (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
scheduledTimeoutsState.delete(timerId);
|
|
365
|
-
});
|
|
325
|
+
disconnect: ({ call }) => {
|
|
326
|
+
return async (port) => {
|
|
327
|
+
const portId = portMap.get(port);
|
|
328
|
+
if (portId === undefined) {
|
|
329
|
+
throw new Error('The given port is not connected.');
|
|
366
330
|
}
|
|
331
|
+
await call('disconnect', { portId });
|
|
367
332
|
};
|
|
368
333
|
},
|
|
369
|
-
|
|
370
|
-
return (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
};
|
|
395
|
-
},
|
|
396
|
-
setTimeout: ({ call }) => {
|
|
397
|
-
return (func, delay = 0, ...args) => {
|
|
398
|
-
const symbol = Symbol();
|
|
399
|
-
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
400
|
-
scheduledTimeoutsState.set(timerId, symbol);
|
|
401
|
-
call('set', {
|
|
402
|
-
delay,
|
|
403
|
-
now: performance.timeOrigin + performance.now(),
|
|
404
|
-
timerId,
|
|
405
|
-
timerType: 'timeout'
|
|
406
|
-
}).then(() => {
|
|
407
|
-
const state = scheduledTimeoutsState.get(timerId);
|
|
408
|
-
if (state === undefined) {
|
|
409
|
-
throw new Error('The timer is in an undefined state.');
|
|
410
|
-
}
|
|
411
|
-
if (state === symbol) {
|
|
412
|
-
// A timeout can be savely deleted because it is only called once.
|
|
413
|
-
scheduledTimeoutsState.delete(timerId);
|
|
414
|
-
func(...args);
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
return timerId;
|
|
418
|
-
};
|
|
334
|
+
isSupported: ({ call }) => {
|
|
335
|
+
return () => call('isSupported');
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const isMessagePort = (sender) => {
|
|
340
|
+
return typeof sender.start === 'function';
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const createBroker = createBrokerFactory(createCreateOrGetOngoingRequests(new WeakMap()), createExtendBrokerImplementation(new WeakMap()), generateUniqueNumber, isMessagePort);
|
|
344
|
+
|
|
345
|
+
const createClearIntervalFactory = (scheduledIntervalsState) => (clear) => (timerId) => {
|
|
346
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
347
|
+
scheduledIntervalsState.set(timerId, null);
|
|
348
|
+
clear(timerId).then(() => {
|
|
349
|
+
scheduledIntervalsState.delete(timerId);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const createClearTimeoutFactory = (scheduledTimeoutsState) => (clear) => (timerId) => {
|
|
355
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
356
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
357
|
+
clear(timerId).then(() => {
|
|
358
|
+
scheduledTimeoutsState.delete(timerId);
|
|
359
|
+
});
|
|
419
360
|
}
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const createSetIntervalFactory = (generateUniqueNumber, scheduledIntervalsState) => (set) => (func, delay = 0, ...args) => {
|
|
364
|
+
const symbol = Symbol();
|
|
365
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
366
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
367
|
+
const schedule = () => set(delay, timerId).then(() => {
|
|
368
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
369
|
+
if (state === undefined) {
|
|
370
|
+
throw new Error('The timer is in an undefined state.');
|
|
371
|
+
}
|
|
372
|
+
if (state === symbol) {
|
|
373
|
+
func(...args);
|
|
374
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
375
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
376
|
+
schedule();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
schedule();
|
|
381
|
+
return timerId;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
const createSetTimeoutFactory = (generateUniqueNumber, scheduledTimeoutsState) => (set) => (func, delay = 0, ...args) => {
|
|
385
|
+
const symbol = Symbol();
|
|
386
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
387
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
388
|
+
set(delay, timerId).then(() => {
|
|
389
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
390
|
+
if (state === undefined) {
|
|
391
|
+
throw new Error('The timer is in an undefined state.');
|
|
392
|
+
}
|
|
393
|
+
if (state === symbol) {
|
|
394
|
+
// A timeout can be savely deleted because it is only called once.
|
|
395
|
+
scheduledTimeoutsState.delete(timerId);
|
|
396
|
+
func(...args);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return timerId;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
403
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
404
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
405
|
+
const createClearInterval = createClearIntervalFactory(scheduledIntervalsState);
|
|
406
|
+
const createClearTimeout = createClearTimeoutFactory(scheduledTimeoutsState);
|
|
407
|
+
const createSetInterval = createSetIntervalFactory(generateUniqueNumber, scheduledIntervalsState);
|
|
408
|
+
const createSetTimeout = createSetTimeoutFactory(generateUniqueNumber, scheduledTimeoutsState);
|
|
409
|
+
const wrap = createBroker({
|
|
410
|
+
clearInterval: ({ call }) => createClearInterval((timerId) => call('clear', { timerId, timerType: 'interval' })),
|
|
411
|
+
clearTimeout: ({ call }) => createClearTimeout((timerId) => call('clear', { timerId, timerType: 'timeout' })),
|
|
412
|
+
setInterval: ({ call }) => createSetInterval((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'interval' })),
|
|
413
|
+
setTimeout: ({ call }) => createSetTimeout((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'timeout' }))
|
|
420
414
|
});
|
|
421
415
|
const load = (url) => {
|
|
422
416
|
const worker = new Worker(url);
|
|
@@ -439,7 +433,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
|
439
433
|
};
|
|
440
434
|
|
|
441
435
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
442
|
-
const worker = `(()=>{var e={455
|
|
436
|
+
const worker = `(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,()=>{n(),t.close(),u.delete(o)}),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},m=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise(t=>{e.set(a,[r(n,u,i,e,t,a),t])})},f=new Map,h=d(globalThis.clearTimeout,f),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=m(f,performance,globalThis.setTimeout,w),T=m(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
443
437
|
|
|
444
438
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
445
439
|
const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -7387,9 +7381,7 @@ class ToolTip {
|
|
|
7387
7381
|
* 取消绑定 显示事件
|
|
7388
7382
|
*/
|
|
7389
7383
|
offShowEvent() {
|
|
7390
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show,
|
|
7391
|
-
capture: true,
|
|
7392
|
-
});
|
|
7384
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show, this.$data.config.eventOption);
|
|
7393
7385
|
}
|
|
7394
7386
|
/**
|
|
7395
7387
|
* 关闭提示框
|
|
@@ -7448,9 +7440,7 @@ class ToolTip {
|
|
|
7448
7440
|
* 取消绑定 关闭事件
|
|
7449
7441
|
*/
|
|
7450
7442
|
offCloseEvent() {
|
|
7451
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close,
|
|
7452
|
-
capture: true,
|
|
7453
|
-
});
|
|
7443
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close, this.$data.config.eventOption);
|
|
7454
7444
|
}
|
|
7455
7445
|
/**
|
|
7456
7446
|
* 销毁元素
|
|
@@ -13337,7 +13327,7 @@ const PopsSearchSuggestion = {
|
|
|
13337
13327
|
},
|
|
13338
13328
|
};
|
|
13339
13329
|
|
|
13340
|
-
const version = "3.1.
|
|
13330
|
+
const version = "3.1.3";
|
|
13341
13331
|
|
|
13342
13332
|
class Pops {
|
|
13343
13333
|
/** 配置 */
|