@quietsapa/qsl 0.1.0 → 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/dist/qsl.mjs CHANGED
@@ -2,7 +2,7 @@ const core = {
2
2
  /**
3
3
  * Constants
4
4
  */
5
- VERSION: "0.1.0",
5
+ VERSION: "0.1.2",
6
6
  PREFIX: "qsl-",
7
7
  FLOW_TYPE: {
8
8
  DEFAULT: "default",
@@ -108,6 +108,7 @@ const core = {
108
108
  */
109
109
  async init() {
110
110
  if (this.initialized) return this;
111
+ const loaderScript = document.currentScript;
111
112
  window.__QSL__ = window.__QSL__ || this;
112
113
  if (document.readyState === "interactive" || document.readyState === "complete") {
113
114
  this.LIFECYCLE.DOMREADY = true;
@@ -139,7 +140,7 @@ const core = {
139
140
  }
140
141
  }
141
142
  this.initialized = true;
142
- const url = document.currentScript ? new URL(document.currentScript.src, document.baseURI) : null;
143
+ const url = loaderScript && loaderScript.src ? new URL(loaderScript.src, document.baseURI) : null;
143
144
  if (!url || url.searchParams.get("async") !== "true") return this;
144
145
  const callback = url.searchParams.get("callback") || this.CALLBACK;
145
146
  if (typeof window[callback] === "function") window[callback]();
@@ -503,8 +504,7 @@ const core = {
503
504
  }
504
505
  }
505
506
  let flowsDone = this.flowOptions.size ? Array.from(this.flowOptions.values()).every((opt) => opt.status === this.FLOW_STATE.COMPLETED) : false;
506
- if (!flowsDone) return;
507
- let maybeComplete = true;
507
+ let maybeComplete = flowsDone;
508
508
  if (this.flows.size && this.completedFlowsActions.size) {
509
509
  for (const cb of this.completedFlowsActions) {
510
510
  maybeComplete = cb.call(this, flowsDone, this.flows, this.flowOptions);
@@ -1402,7 +1402,7 @@ function hoverTrigger(QSL) {
1402
1402
  cb();
1403
1403
  return;
1404
1404
  }
1405
- el.addEventListener("mouseenter", () => cb(), { once: true, passive: true });
1405
+ el.addEventListener("mouseover", () => cb(), { once: true, passive: true });
1406
1406
  });
1407
1407
  };
1408
1408
  });
@@ -1739,19 +1739,19 @@ function dynamic(QSL) {
1739
1739
  return [flowId, config];
1740
1740
  });
1741
1741
  QSL.flowIdFilters.add(function(flowIds) {
1742
+ if (flowIds.length === 1 && flowIds[0].includes("dynamic")) return flowIds;
1742
1743
  return flowIds.filter((fid) => !fid.includes("dynamic"));
1743
1744
  });
1744
1745
  QSL.completedFlowsActions.add(function(flowsDone, flows, flowOptions) {
1745
- if (!flowsDone || !flows || !flowOptions) return true;
1746
+ if (!flows || !flowOptions) return flowsDone;
1746
1747
  const nonDynamicFlowsDone = [...flowOptions.entries()].filter(([fid]) => !fid.includes("dynamic")).every(([, opt]) => opt.status === this.FLOW_STATE.COMPLETED);
1747
1748
  if (!nonDynamicFlowsDone) return false;
1748
1749
  const dynamicFlowIds = [...flows.keys()].filter((fid) => fid.includes("dynamic"));
1749
- if (dynamicFlowIds.length === 0) return true;
1750
+ if (dynamicFlowIds.length === 0) return flowsDone;
1750
1751
  for (const dynamicFlowId of dynamicFlowIds) {
1751
1752
  const dynamicOptions = flowOptions.get(dynamicFlowId);
1752
1753
  if (dynamicOptions && dynamicOptions.status !== this.FLOW_STATE.COMPLETED) {
1753
1754
  if (dynamicOptions.status === this.FLOW_STATE.READY) {
1754
- this.setFlowOptions({ status: this.FLOW_STATE.RUNNING }, dynamicFlowId);
1755
1755
  this.runFlow(dynamicFlowId);
1756
1756
  }
1757
1757
  return false;