@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.iife.js
CHANGED
|
@@ -262,47 +262,7 @@ var pops = (function () {
|
|
|
262
262
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
263
263
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
264
264
|
|
|
265
|
-
const
|
|
266
|
-
return typeof sender.start === 'function';
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const PORT_MAP = new WeakMap();
|
|
270
|
-
|
|
271
|
-
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
272
|
-
...partialBrokerImplementation,
|
|
273
|
-
connect: ({ call }) => {
|
|
274
|
-
return async () => {
|
|
275
|
-
const { port1, port2 } = new MessageChannel();
|
|
276
|
-
const portId = await call('connect', { port: port1 }, [port1]);
|
|
277
|
-
PORT_MAP.set(port2, portId);
|
|
278
|
-
return port2;
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
disconnect: ({ call }) => {
|
|
282
|
-
return async (port) => {
|
|
283
|
-
const portId = PORT_MAP.get(port);
|
|
284
|
-
if (portId === undefined) {
|
|
285
|
-
throw new Error('The given port is not connected.');
|
|
286
|
-
}
|
|
287
|
-
await call('disconnect', { portId });
|
|
288
|
-
};
|
|
289
|
-
},
|
|
290
|
-
isSupported: ({ call }) => {
|
|
291
|
-
return () => call('isSupported');
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
const ONGOING_REQUESTS = new WeakMap();
|
|
296
|
-
const createOrGetOngoingRequests = (sender) => {
|
|
297
|
-
if (ONGOING_REQUESTS.has(sender)) {
|
|
298
|
-
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
299
|
-
return ONGOING_REQUESTS.get(sender);
|
|
300
|
-
}
|
|
301
|
-
const ongoingRequests = new Map();
|
|
302
|
-
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
303
|
-
return ongoingRequests;
|
|
304
|
-
};
|
|
305
|
-
const createBroker = (brokerImplementation) => {
|
|
265
|
+
const createBrokerFactory = (createOrGetOngoingRequests, extendBrokerImplementation, generateUniqueNumber, isMessagePort) => (brokerImplementation) => {
|
|
306
266
|
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
307
267
|
return (sender) => {
|
|
308
268
|
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
@@ -345,81 +305,115 @@ var pops = (function () {
|
|
|
345
305
|
};
|
|
346
306
|
};
|
|
347
307
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
308
|
+
const createCreateOrGetOngoingRequests = (ongoingRequestsMap) => (sender) => {
|
|
309
|
+
if (ongoingRequestsMap.has(sender)) {
|
|
310
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
311
|
+
return ongoingRequestsMap.get(sender);
|
|
312
|
+
}
|
|
313
|
+
const ongoingRequests = new Map();
|
|
314
|
+
ongoingRequestsMap.set(sender, ongoingRequests);
|
|
315
|
+
return ongoingRequests;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const createExtendBrokerImplementation = (portMap) => (partialBrokerImplementation) => ({
|
|
319
|
+
...partialBrokerImplementation,
|
|
320
|
+
connect: ({ call }) => {
|
|
321
|
+
return async () => {
|
|
322
|
+
const { port1, port2 } = new MessageChannel();
|
|
323
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
324
|
+
portMap.set(port2, portId);
|
|
325
|
+
return port2;
|
|
360
326
|
};
|
|
361
327
|
},
|
|
362
|
-
|
|
363
|
-
return (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
scheduledTimeoutsState.delete(timerId);
|
|
368
|
-
});
|
|
328
|
+
disconnect: ({ call }) => {
|
|
329
|
+
return async (port) => {
|
|
330
|
+
const portId = portMap.get(port);
|
|
331
|
+
if (portId === undefined) {
|
|
332
|
+
throw new Error('The given port is not connected.');
|
|
369
333
|
}
|
|
334
|
+
await call('disconnect', { portId });
|
|
370
335
|
};
|
|
371
336
|
},
|
|
372
|
-
|
|
373
|
-
return (
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
};
|
|
398
|
-
},
|
|
399
|
-
setTimeout: ({ call }) => {
|
|
400
|
-
return (func, delay = 0, ...args) => {
|
|
401
|
-
const symbol = Symbol();
|
|
402
|
-
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
403
|
-
scheduledTimeoutsState.set(timerId, symbol);
|
|
404
|
-
call('set', {
|
|
405
|
-
delay,
|
|
406
|
-
now: performance.timeOrigin + performance.now(),
|
|
407
|
-
timerId,
|
|
408
|
-
timerType: 'timeout'
|
|
409
|
-
}).then(() => {
|
|
410
|
-
const state = scheduledTimeoutsState.get(timerId);
|
|
411
|
-
if (state === undefined) {
|
|
412
|
-
throw new Error('The timer is in an undefined state.');
|
|
413
|
-
}
|
|
414
|
-
if (state === symbol) {
|
|
415
|
-
// A timeout can be savely deleted because it is only called once.
|
|
416
|
-
scheduledTimeoutsState.delete(timerId);
|
|
417
|
-
func(...args);
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
return timerId;
|
|
421
|
-
};
|
|
337
|
+
isSupported: ({ call }) => {
|
|
338
|
+
return () => call('isSupported');
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const isMessagePort = (sender) => {
|
|
343
|
+
return typeof sender.start === 'function';
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const createBroker = createBrokerFactory(createCreateOrGetOngoingRequests(new WeakMap()), createExtendBrokerImplementation(new WeakMap()), generateUniqueNumber, isMessagePort);
|
|
347
|
+
|
|
348
|
+
const createClearIntervalFactory = (scheduledIntervalsState) => (clear) => (timerId) => {
|
|
349
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
350
|
+
scheduledIntervalsState.set(timerId, null);
|
|
351
|
+
clear(timerId).then(() => {
|
|
352
|
+
scheduledIntervalsState.delete(timerId);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const createClearTimeoutFactory = (scheduledTimeoutsState) => (clear) => (timerId) => {
|
|
358
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
359
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
360
|
+
clear(timerId).then(() => {
|
|
361
|
+
scheduledTimeoutsState.delete(timerId);
|
|
362
|
+
});
|
|
422
363
|
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const createSetIntervalFactory = (generateUniqueNumber, scheduledIntervalsState) => (set) => (func, delay = 0, ...args) => {
|
|
367
|
+
const symbol = Symbol();
|
|
368
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
369
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
370
|
+
const schedule = () => set(delay, timerId).then(() => {
|
|
371
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
372
|
+
if (state === undefined) {
|
|
373
|
+
throw new Error('The timer is in an undefined state.');
|
|
374
|
+
}
|
|
375
|
+
if (state === symbol) {
|
|
376
|
+
func(...args);
|
|
377
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
378
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
379
|
+
schedule();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
schedule();
|
|
384
|
+
return timerId;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const createSetTimeoutFactory = (generateUniqueNumber, scheduledTimeoutsState) => (set) => (func, delay = 0, ...args) => {
|
|
388
|
+
const symbol = Symbol();
|
|
389
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
390
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
391
|
+
set(delay, timerId).then(() => {
|
|
392
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
393
|
+
if (state === undefined) {
|
|
394
|
+
throw new Error('The timer is in an undefined state.');
|
|
395
|
+
}
|
|
396
|
+
if (state === symbol) {
|
|
397
|
+
// A timeout can be savely deleted because it is only called once.
|
|
398
|
+
scheduledTimeoutsState.delete(timerId);
|
|
399
|
+
func(...args);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return timerId;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
406
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
407
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
408
|
+
const createClearInterval = createClearIntervalFactory(scheduledIntervalsState);
|
|
409
|
+
const createClearTimeout = createClearTimeoutFactory(scheduledTimeoutsState);
|
|
410
|
+
const createSetInterval = createSetIntervalFactory(generateUniqueNumber, scheduledIntervalsState);
|
|
411
|
+
const createSetTimeout = createSetTimeoutFactory(generateUniqueNumber, scheduledTimeoutsState);
|
|
412
|
+
const wrap = createBroker({
|
|
413
|
+
clearInterval: ({ call }) => createClearInterval((timerId) => call('clear', { timerId, timerType: 'interval' })),
|
|
414
|
+
clearTimeout: ({ call }) => createClearTimeout((timerId) => call('clear', { timerId, timerType: 'timeout' })),
|
|
415
|
+
setInterval: ({ call }) => createSetInterval((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'interval' })),
|
|
416
|
+
setTimeout: ({ call }) => createSetTimeout((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'timeout' }))
|
|
423
417
|
});
|
|
424
418
|
const load = (url) => {
|
|
425
419
|
const worker = new Worker(url);
|
|
@@ -442,7 +436,7 @@ var pops = (function () {
|
|
|
442
436
|
};
|
|
443
437
|
|
|
444
438
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
445
|
-
const worker = `(()=>{var e={455
|
|
439
|
+
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
|
|
446
440
|
|
|
447
441
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
448
442
|
const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -7390,9 +7384,7 @@ var pops = (function () {
|
|
|
7390
7384
|
* 取消绑定 显示事件
|
|
7391
7385
|
*/
|
|
7392
7386
|
offShowEvent() {
|
|
7393
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show,
|
|
7394
|
-
capture: true,
|
|
7395
|
-
});
|
|
7387
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show, this.$data.config.eventOption);
|
|
7396
7388
|
}
|
|
7397
7389
|
/**
|
|
7398
7390
|
* 关闭提示框
|
|
@@ -7451,9 +7443,7 @@ var pops = (function () {
|
|
|
7451
7443
|
* 取消绑定 关闭事件
|
|
7452
7444
|
*/
|
|
7453
7445
|
offCloseEvent() {
|
|
7454
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close,
|
|
7455
|
-
capture: true,
|
|
7456
|
-
});
|
|
7446
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close, this.$data.config.eventOption);
|
|
7457
7447
|
}
|
|
7458
7448
|
/**
|
|
7459
7449
|
* 销毁元素
|
|
@@ -13340,7 +13330,7 @@ var pops = (function () {
|
|
|
13340
13330
|
},
|
|
13341
13331
|
};
|
|
13342
13332
|
|
|
13343
|
-
const version = "3.1.
|
|
13333
|
+
const version = "3.1.3";
|
|
13344
13334
|
|
|
13345
13335
|
class Pops {
|
|
13346
13336
|
/** 配置 */
|