@difizen/libro-common 0.1.1 → 0.1.2
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/es/dom.d.ts +3 -0
- package/es/dom.d.ts.map +1 -0
- package/es/dom.js +97 -0
- package/es/index.d.ts +1 -0
- package/es/index.d.ts.map +1 -1
- package/es/index.js +2 -1
- package/es/iter.d.ts +2 -2
- package/es/iter.d.ts.map +1 -1
- package/es/polling/poll.d.ts +2 -2
- package/es/polling/poll.d.ts.map +1 -1
- package/es/polling/poll.js +1 -1
- package/es/polling/protocol.d.ts +1 -1
- package/es/polling/protocol.d.ts.map +1 -1
- package/es/sanitizer.d.ts +2 -1
- package/es/sanitizer.d.ts.map +1 -1
- package/es/url.js +1 -1
- package/package.json +2 -2
- package/src/dom.ts +71 -0
- package/src/index.ts +1 -0
- package/src/iter.ts +2 -2
- package/src/polling/poll.ts +2 -2
- package/src/polling/protocol.ts +1 -1
- package/src/sanitizer.ts +15 -15
- package/src/url.ts +1 -1
package/es/dom.d.ts
ADDED
package/es/dom.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,cAAc,WAAY,MAAM,SA0B5C,CAAC;AAgBF,eAAO,MAAM,iBAAiB,uBAgB7B,CAAC"}
|
package/es/dom.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
+
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
+
function copyFallback(string) {
|
|
6
|
+
function handler(event) {
|
|
7
|
+
var clipboardData = event.clipboardData || window.clipboardData;
|
|
8
|
+
clipboardData.setData('text/plain', string);
|
|
9
|
+
event.preventDefault();
|
|
10
|
+
document.removeEventListener('copy', handler, true);
|
|
11
|
+
}
|
|
12
|
+
document.addEventListener('copy', handler, true);
|
|
13
|
+
document.execCommand('copy');
|
|
14
|
+
}
|
|
15
|
+
// 复制到剪贴板
|
|
16
|
+
export var copy2clipboard = function copy2clipboard(string) {
|
|
17
|
+
navigator.permissions.query({
|
|
18
|
+
name: 'clipboard-write'
|
|
19
|
+
}).then(function (result) {
|
|
20
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
21
|
+
if (window.navigator && window.navigator.clipboard) {
|
|
22
|
+
window.navigator.clipboard.writeText(string).then(function () {
|
|
23
|
+
return;
|
|
24
|
+
}).catch(function (err) {
|
|
25
|
+
console.error('Could not copy text: ', err);
|
|
26
|
+
});
|
|
27
|
+
} else {
|
|
28
|
+
console.warn('navigator is not exist');
|
|
29
|
+
}
|
|
30
|
+
} else {
|
|
31
|
+
console.warn('浏览器权限不允许复制');
|
|
32
|
+
copyFallback(string);
|
|
33
|
+
}
|
|
34
|
+
return;
|
|
35
|
+
}).catch(console.error);
|
|
36
|
+
};
|
|
37
|
+
function readFallback() {
|
|
38
|
+
function handler(event) {
|
|
39
|
+
// 获取剪贴板数据
|
|
40
|
+
var clipboardData = event.clipboardData || window.clipboardData;
|
|
41
|
+
// 读取文本内容
|
|
42
|
+
var pastedData = clipboardData.getData('text/plain');
|
|
43
|
+
event.preventDefault();
|
|
44
|
+
document.removeEventListener('paste', handler, true);
|
|
45
|
+
return pastedData;
|
|
46
|
+
}
|
|
47
|
+
document.addEventListener('paste', handler, true);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// 从剪贴板读取
|
|
51
|
+
export var readFromClipboard = /*#__PURE__*/function () {
|
|
52
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
53
|
+
var clipboardValue, result;
|
|
54
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
55
|
+
while (1) switch (_context.prev = _context.next) {
|
|
56
|
+
case 0:
|
|
57
|
+
clipboardValue = '';
|
|
58
|
+
_context.next = 3;
|
|
59
|
+
return navigator.permissions.query({
|
|
60
|
+
name: 'clipboard-read'
|
|
61
|
+
});
|
|
62
|
+
case 3:
|
|
63
|
+
result = _context.sent;
|
|
64
|
+
if (!(result.state === 'granted' || result.state === 'prompt')) {
|
|
65
|
+
_context.next = 14;
|
|
66
|
+
break;
|
|
67
|
+
}
|
|
68
|
+
if (!(window.navigator && window.navigator.clipboard)) {
|
|
69
|
+
_context.next = 11;
|
|
70
|
+
break;
|
|
71
|
+
}
|
|
72
|
+
_context.next = 8;
|
|
73
|
+
return window.navigator.clipboard.readText();
|
|
74
|
+
case 8:
|
|
75
|
+
clipboardValue = _context.sent;
|
|
76
|
+
_context.next = 12;
|
|
77
|
+
break;
|
|
78
|
+
case 11:
|
|
79
|
+
console.warn('navigator is not exist');
|
|
80
|
+
case 12:
|
|
81
|
+
_context.next = 16;
|
|
82
|
+
break;
|
|
83
|
+
case 14:
|
|
84
|
+
console.warn('浏览器权限不允许粘贴');
|
|
85
|
+
readFallback();
|
|
86
|
+
case 16:
|
|
87
|
+
return _context.abrupt("return", clipboardValue);
|
|
88
|
+
case 17:
|
|
89
|
+
case "end":
|
|
90
|
+
return _context.stop();
|
|
91
|
+
}
|
|
92
|
+
}, _callee);
|
|
93
|
+
}));
|
|
94
|
+
return function readFromClipboard() {
|
|
95
|
+
return _ref.apply(this, arguments);
|
|
96
|
+
};
|
|
97
|
+
}();
|
package/es/index.d.ts
CHANGED
package/es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,qBAAqB,CAAC;AACpC,cAAc,UAAU,CAAC"}
|
package/es/index.js
CHANGED
package/es/iter.d.ts
CHANGED
|
@@ -88,8 +88,8 @@ export declare class ArrayIterator<T> implements IIterator<T> {
|
|
|
88
88
|
* @returns The next value from the iterator, or `undefined`.
|
|
89
89
|
*/
|
|
90
90
|
next(): T | undefined;
|
|
91
|
-
|
|
92
|
-
|
|
91
|
+
protected _index: number;
|
|
92
|
+
protected _source: ArrayLike<T>;
|
|
93
93
|
}
|
|
94
94
|
/**
|
|
95
95
|
* Create an iterator for an iterable object.
|
package/es/iter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iter.d.ts","sourceRoot":"","sources":["../src/iter.ts"],"names":[],"mappings":"AAAA;;GAEG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,GAAG,SAAS,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;AAEjE;;;;;GAKG;AACH,qBAAa,aAAa,CAAC,CAAC,CAAE,YAAW,SAAS,CAAC,CAAC,CAAC;IACnD;;;;OAIG;gBACS,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IAIhC;;;;OAIG;IACH,IAAI,IAAI,SAAS,CAAC,CAAC,CAAC;IAIpB;;;;OAIG;IACH,KAAK,IAAI,SAAS,CAAC,CAAC,CAAC;IAMrB;;;;OAIG;IACH,IAAI,IAAI,CAAC,GAAG,SAAS;IAOrB,SAAS,CAAC,MAAM,SAAK;IACrB,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACjC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAQpE;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,IAAI,CAAC,CAAC,EACpB,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,EAC9B,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,GAAG,IAAI,GAC9C,IAAI,CASN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,CAAC,EAAE,CAS9D"}
|
package/es/polling/poll.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import type { Event } from '@difizen/mana-
|
|
3
|
-
import { Emitter, Deferred } from '@difizen/mana-
|
|
2
|
+
import type { Event } from '@difizen/mana-app';
|
|
3
|
+
import { Emitter, Deferred } from '@difizen/mana-app';
|
|
4
4
|
import type { IPoll } from './protocol.js';
|
|
5
5
|
/**
|
|
6
6
|
* A class that wraps an asynchronous function to poll at a regular interval
|
package/es/polling/poll.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../src/polling/poll.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"poll.d.ts","sourceRoot":"","sources":["../../src/polling/poll.ts"],"names":[],"mappings":";AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAItD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAE3C;;;;;;;;;;;;GAYG;AACH,qBAAa,IAAI,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,SAAS,MAAM,GAAG,SAAS,CAC9D,YAAW,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAEzB,SAAS,CAAC,cAAc,gBAAuB;IAC/C,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC1C,SAAS,CAAC,UAAU,EAAE,KAAK,CAAC,SAAS,CAAC;IACtC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,CAAC;IAClE,SAAS,CAAC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IACvC,SAAS,CAAC,KAAK,iBAAwB;IACvC,SAAS,CAAC,aAAa,gCAAuC;IAC9D,SAAS,CAAC,QAAQ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I,CAAC;IAE3B;;;;;OAKG;IACI,MAAM,YAAY,aAAa,CAAC;IAEvC;;OAEG;IACI,MAAM,KAAK,QAAW,CAAC;CAC/B"}
|
package/es/polling/poll.js
CHANGED
|
@@ -18,7 +18,7 @@ _AsyncGenerator.prototype["function" == typeof Symbol && Symbol.asyncIterator ||
|
|
|
18
18
|
function _OverloadYield(t, e) { this.v = t, this.k = e; }
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
20
|
|
|
21
|
-
import { Emitter, Deferred } from '@difizen/mana-
|
|
21
|
+
import { Emitter, Deferred } from '@difizen/mana-app';
|
|
22
22
|
import { deepEqual } from "../json.js";
|
|
23
23
|
_Symbol$asyncIterator = Symbol.asyncIterator;
|
|
24
24
|
/**
|
package/es/polling/protocol.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/polling/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../src/polling/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;;;;;;;GAQG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,MAAM,CAC3C,SAAQ,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;IAC3C;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;IAEhC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;I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CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import sanitize from 'sanitize-html';
|
|
1
2
|
export interface ISanitizerOptions {
|
|
2
3
|
/**
|
|
3
4
|
* The allowed tags.
|
|
@@ -38,7 +39,7 @@ export declare class Sanitizer implements ISanitizer {
|
|
|
38
39
|
* @returns The sanitized string.
|
|
39
40
|
*/
|
|
40
41
|
sanitize(dirty: string, options?: ISanitizerOptions): string;
|
|
41
|
-
|
|
42
|
+
protected _options: sanitize.IOptions;
|
|
42
43
|
}
|
|
43
44
|
export declare const defaultSanitizer: ISanitizer;
|
|
44
45
|
//# sourceMappingURL=sanitizer.d.ts.map
|
package/es/sanitizer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sanitizer.d.ts","sourceRoot":"","sources":["../src/sanitizer.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,eAAe,CAAC;AA4ZrC,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IAEvB;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAE7C;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CAC1D;AACD,MAAM,WAAW,UAAU;IACzB;;;;;;;;OAQG;IACH,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,KAAK,MAAM,CAAC;CAClE;AAED;;GAEG;AACH,qBAAa,SAAU,YAAW,UAAU;IAC1C;;;;;;;;OAQG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,iBAAiB,GAAG,MAAM;IAI5D,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAmenC;CACH;AACD,eAAO,MAAM,gBAAgB,EAAE,UAA4B,CAAC"}
|
package/es/url.js
CHANGED
|
@@ -10,7 +10,7 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
|
|
|
10
10
|
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
11
11
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
12
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
-
import { isWeb } from '@difizen/mana-
|
|
13
|
+
import { isWeb } from '@difizen/mana-app';
|
|
14
14
|
import { posix } from 'path-browserify';
|
|
15
15
|
import urlparse from 'url-parse';
|
|
16
16
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@difizen/libro-common",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"libro",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"src"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@difizen/mana-
|
|
35
|
+
"@difizen/mana-app": "latest",
|
|
36
36
|
"path-browserify": "^1.0.0",
|
|
37
37
|
"sanitize-html": "^2.7.2",
|
|
38
38
|
"url-parse": "^1.5.10"
|
package/src/dom.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function copyFallback(string: string) {
|
|
2
|
+
function handler(event: ClipboardEvent) {
|
|
3
|
+
const clipboardData = event.clipboardData || (window as any).clipboardData;
|
|
4
|
+
clipboardData.setData('text/plain', string);
|
|
5
|
+
event.preventDefault();
|
|
6
|
+
document.removeEventListener('copy', handler, true);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
document.addEventListener('copy', handler, true);
|
|
10
|
+
document.execCommand('copy');
|
|
11
|
+
}
|
|
12
|
+
// 复制到剪贴板
|
|
13
|
+
export const copy2clipboard = (string: string) => {
|
|
14
|
+
navigator.permissions
|
|
15
|
+
.query({
|
|
16
|
+
name: 'clipboard-write' as any,
|
|
17
|
+
})
|
|
18
|
+
.then((result) => {
|
|
19
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
20
|
+
if (window.navigator && window.navigator.clipboard) {
|
|
21
|
+
window.navigator.clipboard
|
|
22
|
+
.writeText(string)
|
|
23
|
+
.then(() => {
|
|
24
|
+
return;
|
|
25
|
+
})
|
|
26
|
+
.catch((err) => {
|
|
27
|
+
console.error('Could not copy text: ', err);
|
|
28
|
+
});
|
|
29
|
+
} else {
|
|
30
|
+
console.warn('navigator is not exist');
|
|
31
|
+
}
|
|
32
|
+
} else {
|
|
33
|
+
console.warn('浏览器权限不允许复制');
|
|
34
|
+
copyFallback(string);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
})
|
|
38
|
+
.catch(console.error);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function readFallback() {
|
|
42
|
+
function handler(event: ClipboardEvent) {
|
|
43
|
+
// 获取剪贴板数据
|
|
44
|
+
const clipboardData = event.clipboardData || (window as any).clipboardData;
|
|
45
|
+
// 读取文本内容
|
|
46
|
+
const pastedData = clipboardData.getData('text/plain');
|
|
47
|
+
event.preventDefault();
|
|
48
|
+
document.removeEventListener('paste', handler, true);
|
|
49
|
+
return pastedData;
|
|
50
|
+
}
|
|
51
|
+
document.addEventListener('paste', handler, true);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// 从剪贴板读取
|
|
55
|
+
export const readFromClipboard = async () => {
|
|
56
|
+
let clipboardValue = '';
|
|
57
|
+
const result = await navigator.permissions.query({
|
|
58
|
+
name: 'clipboard-read' as any,
|
|
59
|
+
});
|
|
60
|
+
if (result.state === 'granted' || result.state === 'prompt') {
|
|
61
|
+
if (window.navigator && window.navigator.clipboard) {
|
|
62
|
+
clipboardValue = await window.navigator.clipboard.readText();
|
|
63
|
+
} else {
|
|
64
|
+
console.warn('navigator is not exist');
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
console.warn('浏览器权限不允许粘贴');
|
|
68
|
+
readFallback();
|
|
69
|
+
}
|
|
70
|
+
return clipboardValue;
|
|
71
|
+
};
|
package/src/index.ts
CHANGED
package/src/iter.ts
CHANGED
package/src/polling/poll.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
import type { Event } from '@difizen/mana-
|
|
3
|
-
import { Emitter, Deferred } from '@difizen/mana-
|
|
2
|
+
import type { Event } from '@difizen/mana-app';
|
|
3
|
+
import { Emitter, Deferred } from '@difizen/mana-app';
|
|
4
4
|
|
|
5
5
|
import { deepEqual } from '../json.js';
|
|
6
6
|
|
package/src/polling/protocol.ts
CHANGED
package/src/sanitizer.ts
CHANGED
|
@@ -8,7 +8,7 @@ class CssProp {
|
|
|
8
8
|
/*
|
|
9
9
|
* Numeric base expressions used to help build more complex regular expressions
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
protected static readonly N = {
|
|
12
12
|
integer: `[+-]?[0-9]+`,
|
|
13
13
|
integer_pos: `[+]?[0-9]+`,
|
|
14
14
|
integer_zero_ff: `([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])`,
|
|
@@ -21,7 +21,7 @@ class CssProp {
|
|
|
21
21
|
/*
|
|
22
22
|
* Base expressions of common CSS syntax elements
|
|
23
23
|
*/
|
|
24
|
-
|
|
24
|
+
protected static readonly B = {
|
|
25
25
|
angle: `(${CssProp.N.number}(deg|rad|grad|turn)|0)`,
|
|
26
26
|
frequency: `${CssProp.N.number}(Hz|kHz)`,
|
|
27
27
|
ident: String.raw`-?([_a-z]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])([_a-z0-9-]|[\xA0-\xFF]|\\[0-9a-f]{1,6}(\r\n|[ \t\r\n\f])?|\\[^\r\n\f0-9a-f])*`,
|
|
@@ -40,7 +40,7 @@ class CssProp {
|
|
|
40
40
|
/*
|
|
41
41
|
* Atomic (i.e. not dependant on other regular expressions) sub RegEx segments
|
|
42
42
|
*/
|
|
43
|
-
|
|
43
|
+
protected static readonly A = {
|
|
44
44
|
absolute_size: `xx-small|x-small|small|medium|large|x-large|xx-large`,
|
|
45
45
|
attachment: `scroll|fixed|local`,
|
|
46
46
|
bg_origin: `border-box|padding-box|content-box`,
|
|
@@ -62,7 +62,7 @@ class CssProp {
|
|
|
62
62
|
/*
|
|
63
63
|
* Color definition sub expressions
|
|
64
64
|
*/
|
|
65
|
-
|
|
65
|
+
protected static readonly _COLOR = {
|
|
66
66
|
hex: `\\#(0x)?[0-9a-f]+`,
|
|
67
67
|
name: `aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|transparent|violet|wheat|white|whitesmoke|yellow|yellowgreen`,
|
|
68
68
|
rgb: String.raw`rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)`,
|
|
@@ -72,7 +72,7 @@ class CssProp {
|
|
|
72
72
|
/*
|
|
73
73
|
* Compound (i.e. dependant on other (sub) regular expressions) sub RegEx segments
|
|
74
74
|
*/
|
|
75
|
-
|
|
75
|
+
protected static readonly _C = {
|
|
76
76
|
alpha: `${CssProp.N.integer_zero_ff}|${CssProp.N.number_zero_one}|${CssProp.B.percentage_zero_hundred}`,
|
|
77
77
|
alphavalue: CssProp.N.number_zero_one,
|
|
78
78
|
bg_position: `((${CssProp.B.len_or_perc}|left|center|right|top|bottom)\\s*){1,4}`,
|
|
@@ -96,29 +96,29 @@ class CssProp {
|
|
|
96
96
|
top: `${CssProp.B.length}|auto`,
|
|
97
97
|
};
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
protected static readonly _C1 = {
|
|
100
100
|
image_list: `image\\(\\s*(${CssProp.B.url})*\\s*(${CssProp.B.url}|${CssProp._C.color})\\s*\\)`,
|
|
101
101
|
linear_color_stop: `(${CssProp._C.color})(\\s*${CssProp._C.color_stop_length})?`,
|
|
102
102
|
// eslint-disable-next-line no-useless-escape
|
|
103
103
|
shadow: `((${CssProp._C.color})\\s+((${CssProp.B.length})\\s*){2,4}(\s+inset)?)|((inset\\s+)?((${CssProp.B.length})\\s*){2,4}\\s*(${CssProp._C.color})?)`,
|
|
104
104
|
};
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
protected static readonly _C2 = {
|
|
107
107
|
color_stop_list: `((${CssProp._C1.linear_color_stop})(\\s*(${CssProp._C.linear_color_hint}))?\\s*,\\s*)+(${CssProp._C1.linear_color_stop})`,
|
|
108
108
|
shape: `rect\\(\\s*(${CssProp._C.top})\\s*,\\s*(${CssProp._C.right})\\s*,\\s*(${CssProp._C.bottom})\\s*,\\s*(${CssProp._C.left})\\s*\\)`,
|
|
109
109
|
};
|
|
110
110
|
|
|
111
|
-
|
|
111
|
+
protected static readonly _C3 = {
|
|
112
112
|
linear_gradient: `linear-gradient\\((((${CssProp.B.angle})|to\\s+(${CssProp.A.side_or_corner}))\\s*,\\s*)?\\s*(${CssProp._C2.color_stop_list})\\s*\\)`,
|
|
113
113
|
radial_gradient: `radial-gradient\\(((((${CssProp.A.ending_shape})|(${CssProp._C.size}))\\s*)*\\s*(at\\s+${CssProp._C.position})?\\s*,\\s*)?\\s*(${CssProp._C2.color_stop_list})\\s*\\)`,
|
|
114
114
|
};
|
|
115
115
|
|
|
116
|
-
|
|
116
|
+
protected static readonly _C4 = {
|
|
117
117
|
image: `${CssProp.B.url}|${CssProp._C3.linear_gradient}|${CssProp._C3.radial_gradient}|${CssProp._C1.image_list}`,
|
|
118
118
|
bg_image: `(${CssProp.B.url}|${CssProp._C3.linear_gradient}|${CssProp._C3.radial_gradient}|${CssProp._C1.image_list})|none`,
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
|
|
121
|
+
protected static readonly C = {
|
|
122
122
|
...CssProp._C,
|
|
123
123
|
...CssProp._C1,
|
|
124
124
|
...CssProp._C2,
|
|
@@ -129,7 +129,7 @@ class CssProp {
|
|
|
129
129
|
/*
|
|
130
130
|
* Property value regular expressions not dependant on other sub expressions
|
|
131
131
|
*/
|
|
132
|
-
|
|
132
|
+
protected static readonly AP = {
|
|
133
133
|
border_collapse: `collapse|separate`,
|
|
134
134
|
box: `normal|none|contents`,
|
|
135
135
|
box_sizing: `content-box|padding-box|border-box`,
|
|
@@ -170,7 +170,7 @@ class CssProp {
|
|
|
170
170
|
/*
|
|
171
171
|
* Compound propertiy value regular expressions (i.e. dependant on other sub expressions)
|
|
172
172
|
*/
|
|
173
|
-
|
|
173
|
+
protected static readonly _CP = {
|
|
174
174
|
background_attachment: `${CssProp.A.attachment}(,\\s*${CssProp.A.attachment})*`,
|
|
175
175
|
background_color: CssProp.C.color,
|
|
176
176
|
background_origin: `${CssProp.A.box}(,\\s*${CssProp.A.box})*`,
|
|
@@ -268,11 +268,11 @@ class CssProp {
|
|
|
268
268
|
min_width: `${CssProp.B.length_pos}|${CssProp.B.percentage_pos}|auto`,
|
|
269
269
|
};
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
protected static readonly _CP1 = {
|
|
272
272
|
font: `(((((${CssProp.AP.font_style}|${CssProp.AP.font_variant}|${CssProp.AP.font_weight})\\s*){1,3})?\\s*(${CssProp._CP.font_size})\\s*(\\/\\s*(${CssProp._CP.line_height}))?\\s+(${CssProp._CP.font_family}))|caption|icon|menu|message-box|small-caption|status-bar)`,
|
|
273
273
|
};
|
|
274
274
|
|
|
275
|
-
|
|
275
|
+
protected static readonly CP = { ...CssProp._CP, ...CssProp._CP1 };
|
|
276
276
|
|
|
277
277
|
// CSS Property value validation regular expressions for use with sanitize-html
|
|
278
278
|
|
|
@@ -456,7 +456,7 @@ export class Sanitizer implements ISanitizer {
|
|
|
456
456
|
return sanitize(dirty, { ...this._options, ...(options || {}) });
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
-
|
|
459
|
+
protected _options: sanitize.IOptions = {
|
|
460
460
|
// HTML tags that are allowed to be used. Tags were extracted from Google Caja
|
|
461
461
|
allowedTags: [
|
|
462
462
|
'a',
|
package/src/url.ts
CHANGED