@quietsapa/qsl 0.1.2 → 0.1.4
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/CHANGELOG.md +46 -3
- package/README.md +5 -13
- package/dist/qsl.min.js +1 -1
- package/dist/qsl.min.js.map +1 -1
- package/dist/qsl.mjs +15 -15
- package/dist/qsl.mjs.map +1 -1
- package/dist/qsl.slim.min.js +1 -1
- package/dist/qsl.slim.min.js.map +1 -1
- package/package.json +1 -1
- package/src/core.js +7 -1
- package/src/plugins/events.js +36 -14
- package/src/presets/full.js +2 -0
package/dist/qsl.mjs
CHANGED
|
@@ -2,7 +2,7 @@ const core = {
|
|
|
2
2
|
/**
|
|
3
3
|
* Constants
|
|
4
4
|
*/
|
|
5
|
-
VERSION: "0.1.
|
|
5
|
+
VERSION: "0.1.4",
|
|
6
6
|
PREFIX: "qsl-",
|
|
7
7
|
FLOW_TYPE: {
|
|
8
8
|
DEFAULT: "default",
|
|
@@ -1527,6 +1527,7 @@ function logger(QSL) {
|
|
|
1527
1527
|
function events(QSL) {
|
|
1528
1528
|
const customEvents = /* @__PURE__ */ new Map();
|
|
1529
1529
|
const processElementMap = /* @__PURE__ */ new WeakMap();
|
|
1530
|
+
let processCounter = 0;
|
|
1530
1531
|
let documentListener = null;
|
|
1531
1532
|
let windowListener = null;
|
|
1532
1533
|
let isIntercepting = false;
|
|
@@ -1538,6 +1539,12 @@ function events(QSL) {
|
|
|
1538
1539
|
return u.split("?")[0].split("#")[0];
|
|
1539
1540
|
}
|
|
1540
1541
|
};
|
|
1542
|
+
const processKey = (process) => {
|
|
1543
|
+
if (!process._eventKey) {
|
|
1544
|
+
process._eventKey = process.id + "#" + ++processCounter;
|
|
1545
|
+
}
|
|
1546
|
+
return process._eventKey;
|
|
1547
|
+
};
|
|
1541
1548
|
QSL.loadActions.add(function() {
|
|
1542
1549
|
if (isIntercepting) return;
|
|
1543
1550
|
documentListener = document.addEventListener;
|
|
@@ -1613,9 +1620,10 @@ function events(QSL) {
|
|
|
1613
1620
|
if (process) {
|
|
1614
1621
|
const shouldFireEvents = process.fireEvents !== false && ((_a = this.flowOptions.get(targetFlowId)) == null ? void 0 : _a.fireEvents) !== false;
|
|
1615
1622
|
if (shouldFireEvents) {
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
|
|
1623
|
+
const key = processKey(process);
|
|
1624
|
+
const eventName = `${type}:${key}`;
|
|
1625
|
+
if (!customEvents.has(key)) customEvents.set(key, []);
|
|
1626
|
+
const events2 = customEvents.get(key);
|
|
1619
1627
|
if (!events2.some((e) => e.name === eventName)) events2.push({ type: eventType, name: eventName });
|
|
1620
1628
|
if (changeEventName) type = eventName;
|
|
1621
1629
|
}
|
|
@@ -1625,21 +1633,13 @@ function events(QSL) {
|
|
|
1625
1633
|
};
|
|
1626
1634
|
document.addEventListener = (type, listener, opts) => {
|
|
1627
1635
|
if (type === "DOMContentLoaded" && this.LIFECYCLE.DOMREADY) {
|
|
1628
|
-
|
|
1629
|
-
if (trackedType !== type) {
|
|
1630
|
-
type = trackedType;
|
|
1631
|
-
queueMicrotask(() => document.dispatchEvent(new Event(trackedType)));
|
|
1632
|
-
}
|
|
1636
|
+
type = iterator.call(this, type, this.EVENTS.DOMREADY, true);
|
|
1633
1637
|
}
|
|
1634
1638
|
return documentListener.call(document, type, listener, opts);
|
|
1635
1639
|
};
|
|
1636
1640
|
window.addEventListener = (type, listener, opts) => {
|
|
1637
1641
|
if (type === "load" && this.LIFECYCLE.LOADED) {
|
|
1638
|
-
|
|
1639
|
-
if (trackedType !== type) {
|
|
1640
|
-
type = trackedType;
|
|
1641
|
-
queueMicrotask(() => window.dispatchEvent(new Event(trackedType)));
|
|
1642
|
-
}
|
|
1642
|
+
type = iterator.call(this, type, this.EVENTS.LOADED, true);
|
|
1643
1643
|
}
|
|
1644
1644
|
return windowListener.call(window, type, listener, opts);
|
|
1645
1645
|
};
|
|
@@ -1652,7 +1652,7 @@ function events(QSL) {
|
|
|
1652
1652
|
};
|
|
1653
1653
|
});
|
|
1654
1654
|
QSL.processCompleteActions.add(function(process) {
|
|
1655
|
-
const events2 = customEvents.get(process.
|
|
1655
|
+
const events2 = customEvents.get(process._eventKey);
|
|
1656
1656
|
if (events2 && Array.isArray(events2)) {
|
|
1657
1657
|
for (const event of events2) {
|
|
1658
1658
|
if (event.type === this.EVENTS.DOMREADY) {
|