plotboilerplate 1.23.0 → 1.23.1

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 (38) hide show
  1. package/dist/index.esm.js +19 -4
  2. package/dist/index.esm.js.map +1 -1
  3. package/dist/index.esm.min.js +1 -1
  4. package/dist/index.esm.min.js.map +1 -1
  5. package/dist/plotboilerplate.browser.min.js +1 -1
  6. package/dist/plotboilerplate.browser.min.js.map +1 -1
  7. package/dist/plotboilerplate.js +19 -4
  8. package/dist/plotboilerplate.min.js +1 -1
  9. package/package.json +3 -1
  10. package/src/cjs/PlotBoilerplate.d.ts +16 -3
  11. package/src/cjs/PlotBoilerplate.js +19 -4
  12. package/src/cjs/PlotBoilerplate.js.map +1 -1
  13. package/src/cjs/interfaces/externals.d.ts +12 -0
  14. package/src/cjs/utils/InitializationObserver.d.ts +18 -0
  15. package/src/cjs/utils/InitializationObserver.js +56 -0
  16. package/src/cjs/utils/InitializationObserver.js.map +1 -0
  17. package/src/cjs/utils/creategui.js +319 -251
  18. package/src/cjs/utils/dat.gui.arrowbounce.polyfill.js +74 -73
  19. package/src/cjs/utils/dat.gui.title.polyfill.js +9 -7
  20. package/src/cjs/utils/dom/guiSizeToggler.d.ts +17 -0
  21. package/src/cjs/utils/dom/guiSizeToggler.js +42 -0
  22. package/src/cjs/utils/dom/guiSizeToggler.js.map +1 -0
  23. package/src/cjs/utils/lil.gui.arrowbounce.polyfill.js +133 -0
  24. package/src/cjs/utils/lil.gui.title.polyfill.js +32 -0
  25. package/src/esm/PlotBoilerplate.d.ts +16 -3
  26. package/src/esm/PlotBoilerplate.js +19 -4
  27. package/src/esm/PlotBoilerplate.js.map +1 -1
  28. package/src/esm/interfaces/externals.d.ts +12 -0
  29. package/src/esm/utils/InitializationObserver.d.ts +18 -0
  30. package/src/esm/utils/InitializationObserver.js +50 -0
  31. package/src/esm/utils/InitializationObserver.js.map +1 -0
  32. package/src/esm/utils/dom/guiSizeToggler.d.ts +17 -0
  33. package/src/esm/utils/dom/guiSizeToggler.js +38 -0
  34. package/src/esm/utils/dom/guiSizeToggler.js.map +1 -0
  35. package/src/ts/PlotBoilerplate.ts +38 -10
  36. package/src/ts/interfaces/externals.ts +16 -0
  37. package/src/ts/utils/InitializationObserver.ts +63 -0
  38. package/src/ts/utils/dom/guiSizeToggler.ts +45 -0
@@ -8,72 +8,73 @@
8
8
  * @author Ikaros Kappler
9
9
  * @date 2020-02-13
10
10
  * @modified 2020-10-14 Changed 'window' to 'globalthis'.
11
- * version 1.0.1
11
+ * @version 1.0.1
12
+ * @DEPRECATED dat.gui was replaced by lil-gui.
12
13
  **/
13
14
 
14
-
15
- (function() {
16
-
17
- /* dat.GUI copies the prototype of superclass Controller to all other controllers, so it is not enough to add it only to
15
+ (function () {
16
+ /* dat.GUI copies the prototype of superclass Controller to all other controllers, so it is not enough to add it only to
18
17
  the super class as the reference is not maintained */
19
- var eachController = function(fnc) {
20
- for (var controllerName in dat.controllers) {
21
- if (dat.controllers.hasOwnProperty(controllerName)) {
22
- fnc(dat.controllers[controllerName]);
23
- }
24
- }
18
+ var eachController = function (fnc) {
19
+ for (var controllerName in dat.controllers) {
20
+ if (dat.controllers.hasOwnProperty(controllerName)) {
21
+ fnc(dat.controllers[controllerName]);
22
+ }
25
23
  }
24
+ };
26
25
 
27
- var setArrowBounce = function(v,options) {
28
- options = options || {};
29
- if( typeof options.fadeDelay == "undefined" )
30
- options.fadeDelay = 5000;
31
- options.fadeDelay = options.fadeDelay/1000;
26
+ var setArrowBounce = function (v, options) {
27
+ options = options || {};
28
+ if (typeof options.fadeDelay == "undefined") options.fadeDelay = 5000;
29
+ options.fadeDelay = options.fadeDelay / 1000;
32
30
 
33
- var randomkey = 'arrowbounce-'+Math.round(Math.random()*Math.pow(2,16));
31
+ var randomkey = "arrowbounce-" + Math.round(Math.random() * Math.pow(2, 16));
34
32
 
35
- var _self = this;
36
- removeElement = function() {
37
- _self.__li.querySelectorAll('.arrowBounce').forEach( function(elem) {
38
- elem.parentElement.removeChild(elem);
39
- } );
40
- _self.__li.style.overflow = 'hidden'; // Restore old overflow
41
- _self.__li.style.position = 'static';
42
- };
43
-
44
- // __li is the root dom element of each controller
45
- if (v) {
46
- this.__li.style.position = 'relative';
47
- this.__li.style.overflow = 'visible';
48
- //this.__li.style.overflowX = 'visible';
49
- //this.__li.style.overflowY = 'hidden';
50
- var node = document.createElement('div');
51
- node.style.position = 'absolute';
52
- // node.style.lineHeight = '24px';
53
- node.style.left = 0;
54
- node.style.top = 0;
55
- node.style.transform = 'translateX(-100%)';
56
- node.classList = randomkey + " arrowBounce hideAfterNs" + (typeof options.className != 'undefined' ? ' '+options.className : '');
57
- // BEGIN custom Styling
58
- node.style.paddingRight = '1em';
59
- // node.style.paddingTop = node.style.paddingBottom = '0em';
60
- node.style.color = 'rgb(0,0,0)';
61
- // END custom Styling
62
-
63
- node.innerHTML = '<div class="bounce">' + v + '&nbsp;<span style="margin-left: 3em;">➤</span></div>';
64
- this.__li.prepend(node);
65
- if( typeof options.detachAfter == 'number' )
66
- globalThis.setTimeout( function() { removeElement(); }, options.detachAfter );
67
- } else {
68
- removeElement();
69
- }
33
+ var _self = this;
34
+ removeElement = function () {
35
+ _self.__li.querySelectorAll(".arrowBounce").forEach(function (elem) {
36
+ elem.parentElement.removeChild(elem);
37
+ });
38
+ _self.__li.style.overflow = "hidden"; // Restore old overflow
39
+ _self.__li.style.position = "static";
40
+ };
70
41
 
71
- // --- Unfortunately IE does not support ES6 Template Literals ---
72
- // --- So use '§' instead '$' here plus string.replace(...) ---
73
- // Define a dynamic and local CSS class
74
- var style = document.createElement('style');
75
- style.type = 'text/css';
76
- style.innerHTML = `.§{randomkey}.hideAfterNs {
42
+ // __li is the root dom element of each controller
43
+ if (v) {
44
+ this.__li.style.position = "relative";
45
+ this.__li.style.overflow = "visible";
46
+ //this.__li.style.overflowX = 'visible';
47
+ //this.__li.style.overflowY = 'hidden';
48
+ var node = document.createElement("div");
49
+ node.style.position = "absolute";
50
+ // node.style.lineHeight = '24px';
51
+ node.style.left = 0;
52
+ node.style.top = 0;
53
+ node.style.transform = "translateX(-100%)";
54
+ node.classList =
55
+ randomkey + " arrowBounce hideAfterNs" + (typeof options.className != "undefined" ? " " + options.className : "");
56
+ // BEGIN custom Styling
57
+ node.style.paddingRight = "1em";
58
+ // node.style.paddingTop = node.style.paddingBottom = '0em';
59
+ node.style.color = "rgb(0,0,0)";
60
+ // END custom Styling
61
+
62
+ node.innerHTML = '<div class="bounce">' + v + '&nbsp;<span style="margin-left: 3em;">➤</span></div>';
63
+ this.__li.prepend(node);
64
+ if (typeof options.detachAfter == "number")
65
+ globalThis.setTimeout(function () {
66
+ removeElement();
67
+ }, options.detachAfter);
68
+ } else {
69
+ removeElement();
70
+ }
71
+
72
+ // --- Unfortunately IE does not support ES6 Template Literals ---
73
+ // --- So use '§' instead '$' here plus string.replace(...) ---
74
+ // Define a dynamic and local CSS class
75
+ var style = document.createElement("style");
76
+ style.type = "text/css";
77
+ style.innerHTML = `.§{randomkey}.hideAfterNs {
77
78
  animation: fadeout 0.5s 1;
78
79
  -webkit-animation: fadeout 0.5s 1;
79
80
  animation-fill-mode: forwards;
@@ -81,15 +82,15 @@
81
82
  animation-delay: ${options.fadeDelay}s;
82
83
  -webkit-animation-delay:§{options.fadeDelay}s; /* Safari and Chrome */
83
84
  -webkit-animation-fill-mode: forwards;
84
- }` .replace(/§\{fadeTime\}/g, (options.fadeDelay/1000).toString());
85
- document.getElementsByTagName('head')[0].appendChild(style);
86
- return this;
87
- };
85
+ }`.replace(/§\{fadeTime\}/g, (options.fadeDelay / 1000).toString());
86
+ document.getElementsByTagName("head")[0].appendChild(style);
87
+ return this;
88
+ };
88
89
 
89
- // Define a global CSS class
90
- var style = document.createElement('style');
91
- style.type = 'text/css';
92
- style.innerHTML = `.bounce {
90
+ // Define a global CSS class
91
+ var style = document.createElement("style");
92
+ style.type = "text/css";
93
+ style.innerHTML = `.bounce {
93
94
  animation: bounce 2s infinite;
94
95
  background: rgba(255,255,255,0.7);
95
96
  border-radius: 8px;
@@ -116,12 +117,12 @@
116
117
  from {opacity :1;}
117
118
  to {opacity :0;display:none;}
118
119
  }`;
119
- document.getElementsByTagName('head')[0].appendChild(style);
120
+ document.getElementsByTagName("head")[0].appendChild(style);
120
121
 
121
- // Install the new feature
122
- eachController(function(controller) {
123
- if (!controller.prototype.hasOwnProperty('arrowBounce')) {
124
- controller.prototype.arrowBounce = setArrowBounce;
125
- }
126
- });
122
+ // Install the new feature
123
+ eachController(function (controller) {
124
+ if (!controller.prototype.hasOwnProperty("arrowBounce")) {
125
+ controller.prototype.arrowBounce = setArrowBounce;
126
+ }
127
+ });
127
128
  })();
@@ -4,30 +4,32 @@
4
4
  * Found at
5
5
  * https://stackoverflow.com/questions/27362914/how-to-add-tooltips-to-dat-gui
6
6
  * Thanks to greginvm
7
+ *
8
+ * @DEPRECATED dat.gui was replaced by lil-gui.
7
9
  **/
8
10
 
9
11
  /* dat.GUI copies the prototype of superclass Controller to all other controllers, so it is not enough to add it only to
10
12
  the super class as the reference is not maintained */
11
- var eachController = function(fnc) {
13
+ var eachController = function (fnc) {
12
14
  for (var controllerName in dat.controllers) {
13
15
  if (dat.controllers.hasOwnProperty(controllerName)) {
14
16
  fnc(dat.controllers[controllerName]);
15
17
  }
16
18
  }
17
- }
19
+ };
18
20
 
19
- var setTitle = function(v) {
21
+ var setTitle = function (v) {
20
22
  // __li is the root dom element of each controller
21
23
  if (v) {
22
- this.__li.setAttribute('title', v);
24
+ this.__li.setAttribute("title", v);
23
25
  } else {
24
- this.__li.removeAttribute('title')
26
+ this.__li.removeAttribute("title");
25
27
  }
26
28
  return this;
27
29
  };
28
30
 
29
- eachController(function(controller) {
30
- if (!controller.prototype.hasOwnProperty('title')) {
31
+ eachController(function (controller) {
32
+ if (!controller.prototype.hasOwnProperty("title")) {
31
33
  controller.prototype.title = setTitle;
32
34
  }
33
35
  });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @requires lil-gui
3
+ *
4
+ * @author Ikaros Kappler
5
+ * @date 2021-12-13
6
+ * @modified 2022-01-10
7
+ * @modified 2024-06-25 Ported to typescript and moved to utils/dom (was located inside demos before).
8
+ * @version 1.1.0
9
+ */
10
+ import { GUI } from "../../interfaces/externals";
11
+ interface ITogglerConfig {
12
+ guiDoubleSize?: boolean;
13
+ }
14
+ export declare const guiSizeToggler: (gui: GUI, config: ITogglerConfig, cssProps: Record<string, string>) => {
15
+ update: () => void;
16
+ };
17
+ export {};
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ /**
3
+ * @requires lil-gui
4
+ *
5
+ * @author Ikaros Kappler
6
+ * @date 2021-12-13
7
+ * @modified 2022-01-10
8
+ * @modified 2024-06-25 Ported to typescript and moved to utils/dom (was located inside demos before).
9
+ * @version 1.1.0
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.guiSizeToggler = void 0;
13
+ /**
14
+ * @param {GUI} gui - The GUI (compatible with dat.gui and lil-gui).
15
+ * @param {boolean} guiDoubleSize - True or false.
16
+ * @param {Record<string,string>} cssProps - The CSS props to use.
17
+ */
18
+ var applyGuiSize = function (gui, guiDoubleSize, cssProps) {
19
+ if (cssProps && cssProps.hasOwnProperty("transformOrigin")) {
20
+ gui.domElement.style["transform-origin"] = cssProps["transformOrigin"];
21
+ }
22
+ else {
23
+ gui.domElement.style["transform-origin"] = "100% 0%";
24
+ }
25
+ var transform = cssProps && cssProps.hasOwnProperty("transform") ? cssProps["transform"] + " " : "";
26
+ console.log("transform", transform);
27
+ if (guiDoubleSize) {
28
+ gui.domElement.style["transform"] = transform + "scale(2.0)";
29
+ }
30
+ else {
31
+ gui.domElement.style["transform"] = transform + "scale(1.0)";
32
+ }
33
+ };
34
+ var guiSizeToggler /* gst */ = function (gui, config, cssProps) {
35
+ return {
36
+ update: function () {
37
+ applyGuiSize(gui, Boolean(config.guiDoubleSize), cssProps);
38
+ }
39
+ };
40
+ };
41
+ exports.guiSizeToggler /* gst */ = guiSizeToggler;
42
+ //# sourceMappingURL=guiSizeToggler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guiSizeToggler.js","sourceRoot":"","sources":["../../../ts/utils/dom/guiSizeToggler.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;AAQH;;;;GAIG;AACH,IAAM,YAAY,GAAG,UAAC,GAAQ,EAAE,aAAsB,EAAE,QAAgC;IACtF,IAAI,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IACzE,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,kBAAkB,CAAC,GAAG,SAAS,CAAC;IACvD,CAAC;IAED,IAAM,SAAS,GAAG,QAAQ,IAAI,QAAQ,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IAEtG,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;IACpC,IAAI,aAAa,EAAE,CAAC;QAClB,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;SAAM,CAAC;QACN,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,GAAG,YAAY,CAAC;IAC/D,CAAC;AACH,CAAC,CAAC;AAEK,IAAM,cAAc,CAAC,SAAS,GAAG,UAAC,GAAQ,EAAE,MAAsB,EAAE,QAAgC;IACzG,OAAO;QACL,MAAM,EAAE;YACN,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,EAAE,QAAQ,CAAC,CAAC;QAC7D,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AANW,QAAA,cAAc,CAAC,SAAS,kBAMnC"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * This snippet adds an 'arrowBounce' prototype function to all dat.GUI components.
3
+ *
4
+ * It's an adaption of the 'title' polyfill found at
5
+ * https://stackoverflow.com/questions/27362914/how-to-add-tooltips-to-dat-gui
6
+ * by greginvm
7
+ *
8
+ * @author Ikaros Kappler
9
+ * @date 2024-06-25 Copied from dat.gui and adapted for lil-gui
10
+ * version 1.0.0
11
+ **/
12
+
13
+ (function () {
14
+ /* lil.GUI copies the prototype of superclass Controller to all other controllers, so it is not enough to add it only to
15
+ the super class as the reference is not maintained */
16
+ var eachController = function (fnc) {
17
+ fnc(lil.Controller);
18
+ };
19
+
20
+ var setArrowBounce = function (v, options) {
21
+ options = options || {};
22
+ if (typeof options.fadeDelay == "undefined") {
23
+ options.fadeDelay = 5000;
24
+ }
25
+ options.fadeDelay = options.fadeDelay / 1000;
26
+ var randomkey = "arrowbounce-" + Math.round(Math.random() * Math.pow(2, 16));
27
+
28
+ var _self = this;
29
+ removeElement = function () {
30
+ _self.domElement.querySelectorAll(".arrowBounce").forEach(function (elem) {
31
+ elem.parentElement.removeChild(elem);
32
+ });
33
+ _self.domElement.style.overflow = "hidden"; // Restore old overflow
34
+ _self.domElement.style.position = "static";
35
+ };
36
+
37
+ // domElement is the root dom element of each controller
38
+ if (v) {
39
+ this.domElement.style.position = "relative";
40
+ this.domElement.style.overflow = "visible";
41
+ //this.domElement.style.overflowX = 'visible';
42
+ //this.domElement.style.overflowY = 'hidden';
43
+ var node = document.createElement("div");
44
+ node.style.position = "absolute";
45
+ // node.style.lineHeight = '24px';
46
+ node.style.left = 0;
47
+ node.style.top = 0;
48
+ node.style.transform = "translateX(-100%)";
49
+ node.style.height = "100%";
50
+ node.classList =
51
+ randomkey + " arrowBounce hideAfterNs" + (typeof options.className != "undefined" ? " " + options.className : "");
52
+ // BEGIN custom Styling
53
+ node.style.paddingRight = "1em";
54
+ // node.style.paddingTop = node.style.paddingBottom = '0em';
55
+ node.style.color = "rgb(0,0,0)";
56
+ // END custom Styling
57
+
58
+ node.innerHTML = '<div class="bounce">' + v + '&nbsp;<span style="margin-left: 3em;">➤</span></div>';
59
+ this.domElement.prepend(node);
60
+ if (typeof options.detachAfter == "number")
61
+ globalThis.setTimeout(function () {
62
+ removeElement();
63
+ }, options.detachAfter);
64
+ } else {
65
+ removeElement();
66
+ }
67
+
68
+ // --- Unfortunately IE does not support ES6 Template Literals ---
69
+ // --- So use '§' instead '$' here plus string.replace(...) ---
70
+ // Define a dynamic and local CSS class
71
+ var style = document.createElement("style");
72
+ style.innerHTML = `.§{randomkey}.hideAfterNs {
73
+ animation: fadeout 0.5s 1;
74
+ -webkit-animation: fadeout 0.5s 1;
75
+ animation-fill-mode: forwards;
76
+
77
+ animation-delay: ${options.fadeDelay}s;
78
+ -webkit-animation-delay:§{options.fadeDelay}s; /* Safari and Chrome */
79
+ -webkit-animation-fill-mode: forwards;
80
+ }`.replace(/§\{fadeTime\}/g, (options.fadeDelay / 1000).toString());
81
+ document.getElementsByTagName("head")[0].appendChild(style);
82
+ return this;
83
+ };
84
+
85
+ // Define a global CSS class
86
+ var style = document.createElement("style");
87
+ // style.type = "text/css";
88
+ style.innerHTML = `.bounce {
89
+ animation: bounce 2s infinite;
90
+ background: rgba(255,255,255,0.7);
91
+ border-radius: 8px;
92
+ padding-left: 1em;
93
+ padding-right: 1em;
94
+ display: flex;
95
+ align-items: center;
96
+ height: 100%;
97
+ }
98
+
99
+ @keyframes bounce {
100
+ 0%, 20%, 50%, 80%, 100% {
101
+ transform: translateX(0);
102
+ }
103
+ 40% {
104
+ transform: translateX(-30px);
105
+ }
106
+ 60% {
107
+ transform: translateX(-15px);
108
+ }
109
+ }
110
+ @keyframes fadeout {
111
+ from {opacity :1;}
112
+ to {opacity :0; display:none;}
113
+ }
114
+ @-webkit-keyframes fadeout {
115
+ from {opacity :1;}
116
+ to {opacity :0;display:none;}
117
+ }
118
+
119
+ /* override lil.gui style to make arrowbounce work */
120
+ .lil-gui .children {
121
+ overflow-x: visible !important;
122
+ overflow-y: visible !important;
123
+ }
124
+ `;
125
+ document.getElementsByTagName("head")[0].appendChild(style);
126
+
127
+ // Install the new feature
128
+ eachController(function (controller) {
129
+ if (!controller.prototype.hasOwnProperty("arrowBounce")) {
130
+ controller.prototype.arrowBounce = setArrowBounce;
131
+ }
132
+ });
133
+ })();
@@ -0,0 +1,32 @@
1
+ /* lil.GUI copies the prototype of superclass Controller to all other controllers, so it is not enough to add it only to
2
+ the super class as the reference is not maintained */
3
+
4
+ (function () {
5
+ var eachController = function (fnc) {
6
+ // Only in super controller required (?)
7
+ fnc(lil.Controller);
8
+ fnc(lil.BooleanController);
9
+ fnc(lil.ColorController);
10
+ fnc(lil.FunctionController);
11
+ fnc(lil.OptionController);
12
+ fnc(lil.NumberController);
13
+ fnc(lil.StringController);
14
+ };
15
+
16
+ var setTitle = function (v) {
17
+ // __li is the root dom element of each controller
18
+ // console.log("Controller", v, this);
19
+ if (v) {
20
+ this.domElement.setAttribute("title", v);
21
+ } else {
22
+ this.domElement.removeAttribute("title");
23
+ }
24
+ return this;
25
+ };
26
+
27
+ eachController(function (controller) {
28
+ if (!controller.prototype.hasOwnProperty("title")) {
29
+ controller.prototype.title = setTitle;
30
+ }
31
+ });
32
+ })();
@@ -83,7 +83,9 @@
83
83
  * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
84
84
  * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
85
85
  * @modified 2023-09-29 Adding proper dicionary key and value types to the params of `PlotBoilerplate.utils.safeMergeByKeys` (was `object` before).
86
- * @version 1.17.3
86
+ * @modified 2024-07-08 Adding `PlotBoilerplate.getGUI()` to retrieve the GUI instance.
87
+ *
88
+ * @version 1.18.0
87
89
  *
88
90
  * @file PlotBoilerplate
89
91
  * @fileoverview The main class.
@@ -95,7 +97,8 @@ import { Bounds } from "./Bounds";
95
97
  import { Grid } from "./Grid";
96
98
  import { Polygon } from "./Polygon";
97
99
  import { Vertex } from "./Vertex";
98
- import { IDraggable, Config, DrawLib, Drawable, DrawConfig, IHooks, PBParams, XYCoords, XYDimension, DatGuiProps } from "./interfaces";
100
+ import { IDraggable, Config, DrawLib, Drawable, DrawConfig, IHooks, PBParams, XYCoords, XYDimension, DatGuiProps, // DEPRECATED. Please do not use any more.
101
+ LilGuiProps } from "./interfaces";
99
102
  /**
100
103
  * @classdesc The main class of the PlotBoilerplate.
101
104
  *
@@ -263,6 +266,10 @@ export declare class PlotBoilerplate {
263
266
  * @private
264
267
  */
265
268
  private renderTime;
269
+ /**
270
+ * A storage variable for retrieving the GUI instance once it was created.
271
+ */
272
+ private _gui;
266
273
  /**
267
274
  * The constructor.
268
275
  *
@@ -784,7 +791,13 @@ export declare class PlotBoilerplate {
784
791
  * @memberof PlotBoilerplate
785
792
  * @return {dat.gui.GUI}
786
793
  **/
787
- createGUI(props?: DatGuiProps): GUI;
794
+ createGUI(props?: DatGuiProps | LilGuiProps): GUI;
795
+ /**
796
+ * Retriebe the GUI once it was created. If the `createGUI` method was not called or failed to create any
797
+ * GUI then null is returned.
798
+ * @returns {GUI | null}
799
+ */
800
+ getGUI(): GUI | null;
788
801
  /**
789
802
  * A set of helper functions.
790
803
  **/
@@ -83,7 +83,9 @@
83
83
  * @modified 2023-02-10 Cleaning up most type errors in the main class (mostly null checks).
84
84
  * @modified 2023-02-10 Adding `enableZoom` and `enablePan` (both default true) to have the option to disable these functions.
85
85
  * @modified 2023-09-29 Adding proper dicionary key and value types to the params of `PlotBoilerplate.utils.safeMergeByKeys` (was `object` before).
86
- * @version 1.17.3
86
+ * @modified 2024-07-08 Adding `PlotBoilerplate.getGUI()` to retrieve the GUI instance.
87
+ *
88
+ * @version 1.18.0
87
89
  *
88
90
  * @file PlotBoilerplate
89
91
  * @fileoverview The main class.
@@ -217,6 +219,10 @@ export class PlotBoilerplate {
217
219
  * @private
218
220
  */
219
221
  this.renderTime = 0;
222
+ /**
223
+ * A storage variable for retrieving the GUI instance once it was created.
224
+ */
225
+ this._gui = null;
220
226
  // This should be in some static block ...
221
227
  VertexAttr.model = {
222
228
  bezierAutoAdjust: false,
@@ -1759,7 +1765,8 @@ export class PlotBoilerplate {
1759
1765
  return { x: pos.x - bounds.left, y: pos.y - bounds.top };
1760
1766
  };
1761
1767
  // Make PB work together with both, AlloyFinger as a esm module or a commonjs function.
1762
- if (typeof globalThis["AlloyFinger"] === "function" || typeof globalThis["createAlloyFinger"] === "function") {
1768
+ if (typeof globalThis["AlloyFinger"] === "function" ||
1769
+ typeof globalThis["createAlloyFinger"] === "function") {
1763
1770
  try {
1764
1771
  var touchMovePos = null;
1765
1772
  var touchDownPos = null;
@@ -1958,12 +1965,20 @@ export class PlotBoilerplate {
1958
1965
  // if (globalThis["utils"] && typeof globalThis["utils"].createGUI == "function") {
1959
1966
  // return (globalThis["utils" as keyof Object] as any as ({createGUI : (pb:PlotBoilerplate,props:DatGuiProps|undefined)=>GUI })).createGUI(this, props);
1960
1967
  if (utils && typeof utils.createGUI === "function") {
1961
- return utils.createGUI(this, props);
1968
+ return (this._gui = utils.createGUI(this, props));
1962
1969
  }
1963
1970
  else {
1964
- throw "Cannot create dat.GUI instance; did you load the ./utils/creategui helper function an the dat.GUI library?";
1971
+ throw "Cannot create dat.GUI or lil-gui instance; did you load the ./utils/creategui helper function an the dat.GUI/lil-gui library?";
1965
1972
  }
1966
1973
  }
1974
+ /**
1975
+ * Retriebe the GUI once it was created. If the `createGUI` method was not called or failed to create any
1976
+ * GUI then null is returned.
1977
+ * @returns {GUI | null}
1978
+ */
1979
+ getGUI() {
1980
+ return this._gui;
1981
+ }
1967
1982
  } // END class PlotBoilerplate
1968
1983
  /** @constant {number} */
1969
1984
  PlotBoilerplate.DEFAULT_CANVAS_WIDTH = 1024;