diff --git a/.gitignore b/.gitignore
index 7412003..005d2f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@
/.vscode
.DS_Store
*.nupkg
+/build
+/node_modules
\ No newline at end of file
diff --git a/.npmignore b/.npmignore
new file mode 100644
index 0000000..d4c31df
--- /dev/null
+++ b/.npmignore
@@ -0,0 +1,19 @@
+/.github
+/.vscode
+/test
+/build
+CODE_OF_CONDUCT.md
+CONTRIBUTING.md
+observe.js.nuspec
+PACK.sh
+PUBLISH.sh
+README_NUGET.md
+SECURITY.md
+SERVE.sh
+package-lock.json
+tsconfig.json
+tsup.build.config.ts
+tsup.build.esm.config.ts
+tsup.build.min.config.ts
+BUILD_INSTRUCTIONS.md
+*.nupkg
\ No newline at end of file
diff --git a/BUILD_INSTRUCTIONS.md b/BUILD_INSTRUCTIONS.md
new file mode 100644
index 0000000..4259868
--- /dev/null
+++ b/BUILD_INSTRUCTIONS.md
@@ -0,0 +1,83 @@
+# Building Observe.js
+
+Before getting started with Observe.js, please read through the following instructions:
+
+
+## Step 1: Install Packages:
+
+Install the packages using the following NPM commands:
+
+### 1. Install TypeScript:
+
+```markdown
+npm install -g typescript
+```
+
+### 2. Install tsup:
+
+```markdown
+npm i tsup -D
+```
+
+### 3. Install terser:
+
+```markdown
+npm install terser -D
+```
+
+### 4. Install swc/core (if ES5 is required):
+
+```markdown
+npm install @swc/core -D
+```
+
+
+## Step 2: Build Project:
+
+### 1. Full Build:
+
+To build the TypeScript, run the following command:
+
+```markdown
+npm run build-typescript
+```
+
+To build the SASS, run the following command:
+
+```markdown
+npm run build-sass
+```
+
+To build the everything, run the following command:
+
+```markdown
+npm run build
+```
+
+### 2. Minimized Build:
+
+To build the TypeScript, run the following command:
+
+```markdown
+npm run build-minimized-typescript
+```
+
+To build the SASS, run the following command:
+
+```markdown
+npm run build-minimized-sass
+```
+
+To build the everything, run the following command:
+
+```markdown
+npm run build-minimized
+```
+
+### 3. ESM Build:
+
+To build the TypeScript, run the following command:
+
+```markdown
+npm run build-typescript-esm
+```
\ No newline at end of file
diff --git a/README.md b/README.md
index 772f481..def900d 100644
--- a/README.md
+++ b/README.md
@@ -2,22 +2,22 @@
Observe.js
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
-[![npm](https://img.shields.io/badge/npmjs-v0.8.2-blue)](https://www.npmjs.com/package/jobserve.js)
-[![nuget](https://img.shields.io/badge/nuget-v0.8.2-purple)](https://www.nuget.org/packages/jObserve.js/)
+[![npm](https://img.shields.io/badge/npmjs-v1.0.0-blue)](https://www.npmjs.com/package/jobserve.js)
+[![nuget](https://img.shields.io/badge/nuget-v1.0.0-purple)](https://www.nuget.org/packages/jObserve.js/)
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://www.william-troup.com/)
>
A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.
->
v0.8.2
+>
v1.0.0
What features does Observe.js have?
- Zero-dependencies and extremely lightweight!
-- Exportable for use in other frameworks!
+- Written in TypeScript, allowing greater support for React, Angular, and other libraries!
- JS Object and HTML DOM Element watching!
- Watch for specific property changes!
- Cancel, Pause, and Resume support!
diff --git a/README_NUGET.md b/README_NUGET.md
index b1cf847..2b5685f 100644
--- a/README_NUGET.md
+++ b/README_NUGET.md
@@ -1,8 +1,8 @@
-# Observe.js v0.8.2
+# Observe.js v1.0.0
[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Observe.js%2C%20a%20free%20JavaScript%observe%builder&url=https://github.com/williamtroup/Observe.js&hashtags=javascript,html,observe)
-[![npm](https://img.shields.io/badge/npmjs-v0.8.2-blue)](https://www.npmjs.com/package/jobserve.js)
-[![nuget](https://img.shields.io/badge/nuget-v0.8.2-purple)](https://www.nuget.org/packages/jObserve.js/)
+[![npm](https://img.shields.io/badge/npmjs-v1.0.0-blue)](https://www.npmjs.com/package/jobserve.js)
+[![nuget](https://img.shields.io/badge/nuget-v1.0.0-purple)](https://www.nuget.org/packages/jObserve.js/)
[![license](https://img.shields.io/badge/license-MIT-green)](https://github.com/williamtroup/Observe.js/blob/main/LICENSE.txt)
[![discussions Welcome](https://img.shields.io/badge/discussions-Welcome-red)](https://github.com/williamtroup/Observe.js/discussions)
[![coded by William Troup](https://img.shields.io/badge/coded_by-William_Troup-yellow)](https://www.william-troup.com/)
@@ -13,7 +13,7 @@
## What features does Observe.js have?
- Zero-dependencies and extremely lightweight!
-- Exportable for use in other frameworks!
+- Written in TypeScript, allowing greater support for React, Angular, and other libraries!
- JS Object and HTML DOM Element watching!
- Watch for specific property changes!
- Cancel, Pause, and Resume support!
diff --git a/dist/observe.d.mts b/dist/observe.d.mts
new file mode 100644
index 0000000..223e65e
--- /dev/null
+++ b/dist/observe.d.mts
@@ -0,0 +1,2 @@
+
+export { }
diff --git a/dist/observe.d.ts b/dist/observe.d.ts
new file mode 100644
index 0000000..223e65e
--- /dev/null
+++ b/dist/observe.d.ts
@@ -0,0 +1,2 @@
+
+export { }
diff --git a/dist/observe.esm.js b/dist/observe.esm.js
new file mode 100644
index 0000000..a015d3b
--- /dev/null
+++ b/dist/observe.esm.js
@@ -0,0 +1,568 @@
+var __getOwnPropNames = Object.getOwnPropertyNames;
+
+var __esm = (e, t) => function n() {
+ return e && (t = (0, e[__getOwnPropNames(e)[0]])(e = 0)), t;
+};
+
+var __commonJS = (e, t) => function n() {
+ return t || (0, e[__getOwnPropNames(e)[0]])((t = {
+ exports: {}
+ }).exports, t), t.exports;
+};
+
+var Constant;
+
+var init_constant = __esm({
+ "src/ts/constant.ts"() {
+ "use strict";
+ (e => {
+ e.OBSERVE_JS_ATTRIBUTE_NAME = "data-observe-js";
+ })(Constant || (Constant = {}));
+ }
+});
+
+var init_enum = __esm({
+ "src/ts/enum.ts"() {
+ "use strict";
+ }
+});
+
+var Is;
+
+var init_is = __esm({
+ "src/ts/is.ts"() {
+ "use strict";
+ init_enum();
+ (e => {
+ function t(e) {
+ return e !== null && e !== void 0 && e.toString() !== "";
+ }
+ e.defined = t;
+ function n(e) {
+ return t(e) && typeof e === "object";
+ }
+ e.definedObject = n;
+ function r(e) {
+ return t(e) && typeof e === "boolean";
+ }
+ e.definedBoolean = r;
+ function a(e) {
+ return t(e) && typeof e === "string";
+ }
+ e.definedString = a;
+ function o(e) {
+ return t(e) && typeof e === "function";
+ }
+ e.definedFunction = o;
+ function i(e) {
+ return t(e) && typeof e === "number";
+ }
+ e.definedNumber = i;
+ function s(e) {
+ return n(e) && e instanceof Array;
+ }
+ e.definedArray = s;
+ function c(e) {
+ return n(e) && e instanceof Date;
+ }
+ e.definedDate = c;
+ })(Is || (Is = {}));
+ }
+});
+
+var Data;
+
+var init_data = __esm({
+ "src/ts/data.ts"() {
+ "use strict";
+ init_enum();
+ init_is();
+ (e => {
+ let t;
+ (e => {
+ function t() {
+ const e = [];
+ for (let t = 0; t < 32; t++) {
+ if (t === 8 || t === 12 || t === 16 || t === 20) {
+ e.push("-");
+ }
+ const n = Math.floor(Math.random() * 16).toString(16);
+ e.push(n);
+ }
+ return e.join("");
+ }
+ e.newGuid = t;
+ })(t = e.String || (e.String = {}));
+ function n(e, t) {
+ return typeof e === "string" ? e : t;
+ }
+ e.getDefaultAnyString = n;
+ function r(e, t) {
+ return Is.definedString(e) ? e : t;
+ }
+ e.getDefaultString = r;
+ function a(e, t) {
+ return Is.definedBoolean(e) ? e : t;
+ }
+ e.getDefaultBoolean = a;
+ function o(e, t) {
+ return Is.definedNumber(e) ? e : t;
+ }
+ e.getDefaultNumber = o;
+ function i(e, t) {
+ return Is.definedFunction(e) ? e : t;
+ }
+ e.getDefaultFunction = i;
+ function s(e, t) {
+ return Is.definedArray(e) ? e : t;
+ }
+ e.getDefaultArray = s;
+ function c(e, t) {
+ return Is.definedObject(e) ? e : t;
+ }
+ e.getDefaultObject = c;
+ function u(e, t) {
+ return Is.definedDate(e) ? e : t;
+ }
+ e.getDefaultDate = u;
+ function f(e, t) {
+ let n = t;
+ if (Is.definedString(e)) {
+ const r = e.toString().split("space");
+ if (r.length === 0) {
+ e = t;
+ } else {
+ n = r;
+ }
+ } else {
+ n = s(e, t);
+ }
+ return n;
+ }
+ e.getDefaultStringOrArray = f;
+ })(Data || (Data = {}));
+ }
+});
+
+var require_observe = __commonJS({
+ "src/observe.ts"(exports, module) {
+ init_constant();
+ init_data();
+ init_enum();
+ init_is();
+ (() => {
+ let _configuration = {};
+ const _watches = {};
+ let _watches_Cancel = false;
+ function collectDOMObjects() {
+ const e = _configuration.domElementTypes;
+ const t = e.length;
+ for (let n = 0; n < t; n++) {
+ const t = document.getElementsByTagName(e[n]);
+ const r = [].slice.call(t);
+ const a = r.length;
+ for (let e = 0; e < a; e++) {
+ if (!collectDOMObject(r[e])) {
+ break;
+ }
+ }
+ }
+ }
+ function collectDOMObject(e) {
+ let t = true;
+ if (Is.defined(e) && e.hasAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME)) {
+ const n = e.getAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME);
+ if (Is.definedString(n)) {
+ const r = getObjectFromString(n);
+ if (r.parsed && Is.definedObject(r.object)) {
+ const t = getWatchOptions(r.object);
+ if (!Is.definedString(e.id)) {
+ e.id = Data.String.newGuid();
+ }
+ if (t.removeAttribute) {
+ e.removeAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME);
+ }
+ createWatch(e, t, e.id);
+ } else {
+ logError(_configuration.text.attributeNotValidErrorText.replace("{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME));
+ t = false;
+ }
+ } else {
+ logError(_configuration.text.attributeNotSetErrorText.replace("{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME));
+ t = false;
+ }
+ }
+ return t;
+ }
+ function createWatch(e, t, n = null) {
+ let r = null;
+ if (Is.definedObject(e)) {
+ r = Data.String.newGuid();
+ const a = getWatchOptions(t);
+ const o = {};
+ let i = null;
+ o.options = a;
+ o.totalChanges = 0;
+ if (Is.definedString(n)) {
+ const e = document.getElementById(n);
+ if (Is.defined(e)) {
+ o.domElementId = n;
+ o.cachedObject = e.outerHTML;
+ o.originalObject = e.outerHTML;
+ i = e.outerHTML;
+ }
+ } else {
+ o.cachedObject = JSON.stringify(e);
+ o.originalObject = e;
+ i = e;
+ }
+ if (Is.defined(o.cachedObject)) {
+ fireCustomTriggerEvent(o.options.events.onStart, i);
+ o.timer = setInterval((function() {
+ watchTimer(a, r);
+ }), a.timeout);
+ _watches[r] = o;
+ }
+ }
+ return r;
+ }
+ function watchTimer(e, t) {
+ const n = new Date;
+ if (!Is.definedDate(e.starts) || n >= e.starts) {
+ watchObjectForChanges(t);
+ if (Is.definedDate(e.expires) && n >= e.expires) {
+ cancelWatchObject(t);
+ }
+ }
+ }
+ function watchObjectForChanges(e) {
+ if (_watches.hasOwnProperty(e)) {
+ const t = _watches[e];
+ const n = Is.definedString(t.domElementId);
+ let r = null;
+ if (n) {
+ r = document.getElementById(t.domElementId);
+ if (Is.defined(r)) {
+ t.originalObject = r.outerHTML;
+ } else {
+ t.originalObject = "";
+ fireCustomTriggerEvent(t.options.events.onRemove, t.domElementId);
+ }
+ }
+ const a = t.cachedObject;
+ const o = t.originalObject;
+ const i = !n ? JSON.stringify(o) : o;
+ if (a !== i) {
+ if (t.options.reset) {
+ if (n) {
+ r.outerHTML = t.cachedObject;
+ } else {
+ t.originalObject = getObjectFromString(a).object;
+ }
+ } else {
+ t.cachedObject = i;
+ }
+ if (n) {
+ fireCustomTriggerEvent(t.options.events.onChange, a, i);
+ } else {
+ const e = getObjectFromString(a).object;
+ const n = getObjectFromString(i).object;
+ if (!Is.definedArray(e) && !Is.definedArray(n)) {
+ compareWatchObject(e, n, t);
+ if (Is.definedFunction(t.options.events.onPropertyChange)) {
+ compareWatchObjectProperties(e, n, t);
+ }
+ } else {
+ fireCustomTriggerEvent(t.options.events.onChange, e, n);
+ }
+ }
+ t.totalChanges++;
+ if (t.options.pauseTimeoutOnChange > 0) {
+ pauseWatchObject(e, t.options.pauseTimeoutOnChange);
+ }
+ if (t.options.cancelOnChange) {
+ cancelWatchObject(e);
+ }
+ if (t.options.maximumChangesBeforeCanceling > 0 && t.totalChanges >= t.options.maximumChangesBeforeCanceling) {
+ cancelWatchObject(e);
+ }
+ }
+ }
+ }
+ function compareWatchObject(e, t, n) {
+ if (Is.definedArray(n.options.propertyNames)) {
+ const r = n.options.propertyNames.length;
+ for (let a = 0; a < r; a++) {
+ const r = n.options.propertyNames[a];
+ if (e[r] !== t[r]) {
+ fireCustomTriggerEvent(n.options.events.onChange, e, t);
+ break;
+ }
+ }
+ } else {
+ fireCustomTriggerEvent(n.options.events.onChange, e, t);
+ }
+ }
+ function compareWatchObjectProperties(e, t, n) {
+ for (let r in e) {
+ if (e.hasOwnProperty(r)) {
+ const a = e[r];
+ let o = null;
+ if (t.hasOwnProperty(r)) {
+ o = t[r];
+ }
+ if (Is.definedObject(a) && Is.definedObject(o)) {
+ compareWatchObjectProperties(a, o, n);
+ } else {
+ if (!Is.definedArray(n.options.propertyNames) || n.options.propertyNames.indexOf(r) > -1) {
+ if (JSON.stringify(a) !== JSON.stringify(o)) {
+ fireCustomTriggerEvent(n.options.events.onPropertyChange, r, a, o);
+ }
+ }
+ }
+ }
+ }
+ }
+ function cancelWatchesForObjects() {
+ for (let e in _watches) {
+ if (_watches.hasOwnProperty(e)) {
+ cancelWatchObject(e);
+ }
+ }
+ }
+ function cancelWatchObject(e) {
+ if (_watches.hasOwnProperty(e)) {
+ const t = _watches[e].options;
+ if (t.allowCanceling || _watches_Cancel) {
+ fireCustomTriggerEvent(t.events.onCancel, e);
+ clearInterval(_watches[e].timer);
+ delete _watches[e];
+ }
+ }
+ }
+ function pauseWatchObject(e, t) {
+ let n = false;
+ if (_watches.hasOwnProperty(e)) {
+ const r = _watches[e].options;
+ if (r.allowPausing) {
+ r.starts = new Date;
+ r.starts.setMilliseconds(r.starts.getMilliseconds() + t);
+ n = true;
+ }
+ }
+ return n;
+ }
+ function getWatchOptions(e) {
+ let t = Data.getDefaultObject(e, {});
+ t.timeout = Data.getDefaultNumber(t.timeout, 250);
+ t.starts = Data.getDefaultDate(t.starts, null);
+ t.expires = Data.getDefaultDate(t.expires, null);
+ t.reset = Data.getDefaultBoolean(t.reset, false);
+ t.cancelOnChange = Data.getDefaultBoolean(t.cancelOnChange, false);
+ t.maximumChangesBeforeCanceling = Data.getDefaultNumber(t.maximumChangesBeforeCanceling, 0);
+ t.pauseTimeoutOnChange = Data.getDefaultNumber(t.pauseTimeoutOnChange, 0);
+ t.propertyNames = Data.getDefaultArray(t.propertyNames, null);
+ t.allowCanceling = Data.getDefaultBoolean(t.allowCanceling, true);
+ t.allowPausing = Data.getDefaultBoolean(t.allowPausing, true);
+ t.removeAttribute = Data.getDefaultBoolean(t.removeAttribute, true);
+ t = getWatchOptionsCustomTriggers(t);
+ return t;
+ }
+ function getWatchOptionsCustomTriggers(e) {
+ e.events = Data.getDefaultObject(e.events, {});
+ e.events.onChange = Data.getDefaultFunction(e.events.onChange, null);
+ e.events.onPropertyChange = Data.getDefaultFunction(e.events.onPropertyChange, null);
+ e.events.onCancel = Data.getDefaultFunction(e.events.onCancel, null);
+ e.events.onRemove = Data.getDefaultFunction(e.events.onRemove, null);
+ e.events.onStart = Data.getDefaultFunction(e.events.onStart, null);
+ return e;
+ }
+ function fireCustomTriggerEvent(e, ...t) {
+ if (Is.definedFunction(e)) {
+ e.apply(null, [].slice.call(t, 0));
+ }
+ }
+ function getObjectFromString(objectString) {
+ const result = {
+ parsed: true,
+ object: null
+ };
+ try {
+ if (Is.definedString(objectString)) {
+ result.object = JSON.parse(objectString);
+ }
+ } catch (e1) {
+ try {
+ result.object = eval(`(${objectString})`);
+ if (Is.definedFunction(result.object)) {
+ result.object = result.object();
+ }
+ } catch (e) {
+ if (!_configuration.safeMode) {
+ logError(_configuration.text.objectErrorText.replace("{{error_1}}", e1.message).replace("{{error_2}}", e.message));
+ result.parsed = false;
+ }
+ result.object = null;
+ }
+ }
+ return result;
+ }
+ function logError(e) {
+ let t = true;
+ if (!_configuration.safeMode) {
+ console.error(e);
+ t = false;
+ }
+ return t;
+ }
+ function buildDefaultConfiguration(e = null) {
+ _configuration = Data.getDefaultObject(e, {});
+ _configuration.safeMode = Data.getDefaultBoolean(_configuration.safeMode, true);
+ _configuration.domElementTypes = Data.getDefaultStringOrArray(_configuration.domElementTypes, [ "*" ]);
+ buildDefaultConfigurationStrings();
+ }
+ function buildDefaultConfigurationStrings() {
+ _configuration.text = Data.getDefaultObject(_configuration.text, {});
+ _configuration.text.objectErrorText = Data.getDefaultString(_configuration.text.objectErrorText, "Errors in object: {{error_1}}, {{error_2}}");
+ _configuration.text.attributeNotValidErrorText = Data.getDefaultString(_configuration.text.attributeNotValidErrorText, "The attribute '{{attribute_name}}' is not a valid object.");
+ _configuration.text.attributeNotSetErrorText = Data.getDefaultString(_configuration.text.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly.");
+ }
+ const _public = {
+ watch: function(e, t) {
+ return createWatch(e, t);
+ },
+ cancelWatch: function(e) {
+ let t = false;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ cancelWatchObject(e);
+ t = true;
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ cancelWatchObject(n);
+ t = true;
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ cancelWatches: function() {
+ cancelWatchesForObjects();
+ return _public;
+ },
+ getWatch: function(e) {
+ let t = null;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ t = _watches[e];
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ t = _watches[n];
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ getWatches: function() {
+ return _watches;
+ },
+ pauseWatch: function(e, t) {
+ let n = false;
+ if (Is.definedString(e) && Is.definedNumber(t)) {
+ if (_watches.hasOwnProperty(e)) {
+ n = pauseWatchObject(e, t);
+ } else {
+ for (let r in _watches) {
+ if (_watches.hasOwnProperty(r) && Is.definedString(_watches[r].domElementId) && _watches[r].domElementId === e) {
+ n = pauseWatchObject(r, t);
+ break;
+ }
+ }
+ }
+ }
+ return n;
+ },
+ pauseWatches: function(e) {
+ if (Is.definedNumber(e)) {
+ for (let t in _watches) {
+ if (_watches.hasOwnProperty(t)) {
+ pauseWatchObject(t, e);
+ }
+ }
+ }
+ return _public;
+ },
+ resumeWatch: function(e) {
+ let t = false;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ _watches[e].options.starts = null;
+ t = true;
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ _watches[n].options.starts = null;
+ t = true;
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ resumeWatches: function() {
+ for (let e in _watches) {
+ if (_watches.hasOwnProperty(e)) {
+ _watches[e].options.starts = null;
+ }
+ }
+ return _public;
+ },
+ searchDomForNewWatches: function() {
+ collectDOMObjects();
+ return _public;
+ },
+ setConfiguration: function(e) {
+ if (Is.definedObject(e)) {
+ let t = false;
+ const n = _configuration;
+ for (let r in e) {
+ if (e.hasOwnProperty(r) && _configuration.hasOwnProperty(r) && n[r] !== e[r]) {
+ n[r] = e[r];
+ t = true;
+ }
+ }
+ if (t) {
+ buildDefaultConfiguration(n);
+ }
+ }
+ return _public;
+ },
+ getVersion: function() {
+ return "1.0.0";
+ }
+ };
+ (() => {
+ buildDefaultConfiguration();
+ document.addEventListener("DOMContentLoaded", (function() {
+ collectDOMObjects();
+ }));
+ window.addEventListener("pagehide", (function() {
+ _watches_Cancel = true;
+ cancelWatchesForObjects();
+ }));
+ if (!Is.defined(window.$observe)) {
+ window.$observe = _public;
+ }
+ })();
+ })();
+ }
+});
+
+export default require_observe();//# sourceMappingURL=observe.esm.js.map
\ No newline at end of file
diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map
new file mode 100644
index 0000000..ecd886c
--- /dev/null
+++ b/dist/observe.esm.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../src/ts/constant.ts","../src/ts/enum.ts","../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Constant","Is","Data","String","result"],"mappings":";;;;;;;;;AAAA,IAaiB;AAbjB;AAAA;AAAA;AAaO,MAAUA,cAAV;AACI,MAAMA,UAAA,4BAA4B;AAAA,OAD5B;AAAA;AAAA;;;ACbjB;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAgBiB;AAhBjB;AAAA;AAAA;AAaA;AAGO,MAAUC,QAAV;AACI,eAAS,QAAS,OAAuB;AAC5C,eAAO,UAAU,QAAQ,UAAU,UAAa,MAAM,SAAS;AAAA,MACnE;AAFO,MAAAA,IAAS;AAIT,eAAS,cAAe,QAAwB;AACnD,eAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,eAAgB,QAAwB;AACpD,eAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,cAAe,QAAwB;AACnD,eAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,gBAAiB,QAAwB;AACrD,eAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,cAAe,QAAwB;AACnD,eAAO,QAAS,MAAO,KAAK,OAA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YAAa;AAC1E,0CAA0B;AAAA,cAC9B;AAAA,YACJ;AAEA,gBAAK,yBAA0B;AAC3B,wCAA2B,wBAAyB;AAAA,YACxD;AAAA,UACJ;AAEA,iBAAO;AAAA,QACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASA,YAAY,WAAqB;AAC7B,iBAAO;AAAA,QACX;AAAA,MACJ;AASA,OAAE,MAAM;AACJ,kCAA0B;AAE1B,iBAAS,iBAAkB,oBAAoB,WAAW;AACtD,4BAAkB;AAAA,QACtB,CAAE;AAEF,eAAO,iBAAkB,YAAY,WAAW;AAC5C,4BAAkB;AAElB,kCAAwB;AAAA,QAC5B,CAAE;AAEF,YAAK,CAAC,GAAG,QAAS,OAAO,QAAS,GAAI;AAClC,iBAAO,WAAW;AAAA,QACtB;AAAA,MACJ,GAAI;AAAA,IACR,GAAI;AAAA;AAAA","sourcesContent":["/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file constant.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nexport namespace Constant {\n export const OBSERVE_JS_ATTRIBUTE_NAME = \"data-observe-js\";\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file enum.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nexport const enum Char {\n empty = \"\",\n space = \"space\",\n dash = \"-\",\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file is.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport { Char } from \"./enum\"\n\n\nexport namespace Is {\n export function defined( value: any ) : boolean {\n return value !== null && value !== undefined && value.toString() !== Char.empty;\n }\n\n export function definedObject( object: any ) : boolean {\n return defined( object ) && typeof object === \"object\";\n }\n\n export function definedBoolean( object: any ) : boolean {\n return defined( object ) && typeof object === \"boolean\";\n }\n\n export function definedString( object: any ) : boolean {\n return defined( object ) && typeof object === \"string\";\n }\n\n export function definedFunction( object: any ) : boolean {\n return defined( object ) && typeof object === \"function\";\n }\n\n export function definedNumber( object: any ) : boolean {\n return defined( object ) && typeof object === \"number\";\n }\n\n export function definedArray( object: any ) : boolean {\n return definedObject( object ) && object instanceof Array;\n }\n\n export function definedDate( object: any ) : boolean {\n return definedObject( object ) && object instanceof Date;\n }\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file data.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport { Char } from \"./enum\";\nimport { Is } from \"./is\";\n\n\nexport namespace Data {\n export namespace String {\n export function newGuid() : string {\n const result: string[] = [];\n \n for ( let charIndex: number = 0; charIndex < 32; charIndex++ ) {\n if ( charIndex === 8 || charIndex === 12 || charIndex === 16 || charIndex === 20 ) {\n result.push( Char.dash );\n }\n \n const character: string = Math.floor( Math.random() * 16 ).toString( 16 );\n result.push( character );\n }\n \n return result.join( Char.empty );\n }\n }\n\n export function getDefaultAnyString( value: any, defaultValue: string ) : string {\n return typeof value === \"string\" ? value : defaultValue;\n }\n\n export function getDefaultString( value: any, defaultValue: string ) : string {\n return Is.definedString( value ) ? value : defaultValue;\n }\n\n export function getDefaultBoolean( value: any, defaultValue: boolean ) : boolean {\n return Is.definedBoolean( value ) ? value : defaultValue;\n }\n\n export function getDefaultNumber( value: any, defaultValue: number ) : number {\n return Is.definedNumber( value ) ? value : defaultValue;\n }\n\n export function getDefaultFunction( value: any, defaultValue: object ) : any {\n return Is.definedFunction( value ) ? value : defaultValue;\n }\n\n export function getDefaultArray( value: any, defaultValue: any[] ) : any[] {\n return Is.definedArray( value ) ? value : defaultValue;\n }\n\n export function getDefaultObject( value: any, defaultValue: object ) : any {\n return Is.definedObject( value ) ? value : defaultValue;\n }\n\n export function getDefaultDate( value: any, defaultValue: Date ) : Date {\n return Is.definedDate( value ) ? value : defaultValue;\n }\n\n export function getDefaultStringOrArray( value: any, defaultValue: string[] ) : string[] {\n let result: string[] = defaultValue;\n\n if ( Is.definedString( value ) ) {\n const values: string[] = value.toString().split( Char.space );\n\n if ( values.length === 0 ) {\n value = defaultValue;\n } else {\n result = values;\n }\n\n } else {\n result = getDefaultArray( value, defaultValue );\n }\n\n return result;\n }\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file observe.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport {\n type WatchOptionEvents,\n type WatchOptions,\n type Configuration,\n type ObserveWatch, \n type ConfigurationText } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type PublicApi } from \"./ts/api\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\n\n( () => {\n // Variables: Configuration\n let _configuration: Configuration = {} as Configuration;\n\n // Variables: Watches\n const _watches: Record = {} as Record;\n let _watches_Cancel: boolean = false;\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Observable DOM Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function collectDOMObjects() : void {\n const tagTypes: string[] = _configuration.domElementTypes as string[];\n const tagTypesLength: number = tagTypes.length;\n\n for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) {\n const domElements: HTMLCollectionOf = document.getElementsByTagName( tagTypes[ tagTypeIndex ] );\n const elements: HTMLElement[] = [].slice.call( domElements );\n const elementsLength: number = elements.length;\n\n for ( let elementIndex: number = 0; elementIndex < elementsLength; elementIndex++ ) {\n if ( !collectDOMObject( elements[ elementIndex ] ) ) {\n break;\n }\n }\n }\n }\n\n function collectDOMObject( element: HTMLElement ) : boolean {\n let result: boolean = true;\n\n if ( Is.defined( element ) && element.hasAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME ) ) {\n const bindingOptionsData: string = element.getAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME )!;\n\n if ( Is.definedString( bindingOptionsData ) ) {\n const watchOptionsJson: StringToJson = getObjectFromString( bindingOptionsData );\n\n if ( watchOptionsJson.parsed && Is.definedObject( watchOptionsJson.object ) ) {\n const watchOptions: WatchOptions = getWatchOptions( watchOptionsJson.object );\n\n if ( !Is.definedString( element.id ) ) {\n element.id = Data.String.newGuid();\n }\n\n if ( watchOptions.removeAttribute ) {\n element.removeAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME );\n }\n\n createWatch( element, watchOptions, element.id );\n\n } else {\n logError( _configuration.text!.attributeNotValidErrorText!.replace( \"{{attribute_name}}\", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) );\n result = false;\n }\n\n } else {\n logError( _configuration.text!.attributeNotSetErrorText!.replace( \"{{attribute_name}}\", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) );\n result = false;\n }\n }\n\n return result;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string = null! ) : string {\n let storageId: string = null!;\n\n if ( Is.definedObject( object ) ) {\n storageId = Data.String.newGuid();\n\n const watchOptions: WatchOptions = getWatchOptions( options );\n const watch: ObserveWatch = {} as ObserveWatch;\n let startWatchObject: any = null;\n\n watch.options = watchOptions;\n watch.totalChanges = 0;\n\n if ( Is.definedString( domElementId ) ) {\n const domElement: HTMLElement = document.getElementById( domElementId )!;\n\n if ( Is.defined( domElement ) ) {\n watch.domElementId = domElementId;\n watch.cachedObject = domElement.outerHTML;\n watch.originalObject = domElement.outerHTML;\n\n startWatchObject = domElement.outerHTML;\n }\n\n } else {\n watch.cachedObject = JSON.stringify( object );\n watch.originalObject = object;\n\n startWatchObject = object;\n }\n\n if ( Is.defined( watch.cachedObject ) ) {\n fireCustomTriggerEvent( watch.options.events!.onStart!, startWatchObject );\n\n watch.timer = setInterval( function() {\n watchTimer( watchOptions, storageId );\n }, watchOptions.timeout );\n \n _watches[ storageId ] = watch;\n }\n }\n\n return storageId;\n }\n\n function watchTimer( watchOptions: WatchOptions, storageId: string ) : void {\n const currentDateTime: Date = new Date();\n\n if ( !Is.definedDate( watchOptions.starts ) || currentDateTime >= watchOptions.starts! ) {\n watchObjectForChanges( storageId );\n\n if ( Is.definedDate( watchOptions.expires ) && currentDateTime >= watchOptions.expires! ) {\n cancelWatchObject( storageId );\n }\n }\n }\n\n function watchObjectForChanges( storageId: string ) : void {\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watch: ObserveWatch = _watches[ storageId ];\n const isDomElement: boolean = Is.definedString( watch.domElementId );\n let domElement: HTMLElement = null!;\n\n if ( isDomElement ) {\n domElement = document.getElementById( watch.domElementId )!;\n\n if ( Is.defined( domElement ) ) {\n watch.originalObject = domElement.outerHTML;\n } else {\n watch.originalObject = Char.empty;\n\n fireCustomTriggerEvent( watch.options.events!.onRemove!, watch.domElementId );\n }\n }\n\n const cachedObject: any = watch.cachedObject;\n const originalObject: any = watch.originalObject;\n const originalObjectJson: any = !isDomElement ? JSON.stringify( originalObject ) : originalObject;\n\n if ( cachedObject !== originalObjectJson ) {\n if ( watch.options.reset ) {\n if ( isDomElement ) {\n domElement.outerHTML = watch.cachedObject;\n } else {\n watch.originalObject = getObjectFromString( cachedObject ).object;\n }\n\n } else {\n watch.cachedObject = originalObjectJson;\n }\n\n if ( isDomElement ) {\n fireCustomTriggerEvent( watch.options.events!.onChange!, cachedObject, originalObjectJson );\n } else {\n\n const oldValue: any = getObjectFromString( cachedObject ).object;\n const newValue: any = getObjectFromString( originalObjectJson ).object;\n\n if ( !Is.definedArray( oldValue ) && !Is.definedArray( newValue ) ) {\n compareWatchObject( oldValue, newValue, watch );\n\n if ( Is.definedFunction( watch.options.events!.onPropertyChange ) ) {\n compareWatchObjectProperties( oldValue, newValue, watch );\n }\n \n } else {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldValue, newValue );\n }\n }\n\n watch.totalChanges++;\n\n if ( watch.options.pauseTimeoutOnChange! > 0 ) {\n pauseWatchObject( storageId, watch.options.pauseTimeoutOnChange! );\n }\n\n if ( watch.options.cancelOnChange ) {\n cancelWatchObject( storageId );\n }\n\n if ( watch.options.maximumChangesBeforeCanceling! > 0 && watch.totalChanges >= watch.options.maximumChangesBeforeCanceling! ) {\n cancelWatchObject( storageId );\n }\n }\n }\n }\n\n function compareWatchObject( oldObject: any, newObject: any, watch: ObserveWatch ) : void {\n if ( Is.definedArray( watch.options.propertyNames ) ) {\n const propertyNamesLength: number = watch.options.propertyNames!.length;\n\n for ( let propertyNameIndex: number = 0; propertyNameIndex < propertyNamesLength; propertyNameIndex++ ) {\n const propertyName: string = watch.options.propertyNames![ propertyNameIndex ];\n\n if ( oldObject[ propertyName ] !== newObject[ propertyName ] ) {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject );\n break;\n }\n }\n\n } else {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject );\n }\n }\n\n function compareWatchObjectProperties( oldObject: any, newObject: any, watch: ObserveWatch ) : void {\n for ( let propertyName in oldObject ) {\n if ( oldObject.hasOwnProperty( propertyName ) ) {\n const propertyOldValue: any = oldObject[ propertyName ];\n let propertyNewValue: any = null;\n\n if ( newObject.hasOwnProperty( propertyName ) ) {\n propertyNewValue = newObject[ propertyName ];\n }\n\n if ( Is.definedObject( propertyOldValue ) && Is.definedObject( propertyNewValue ) ) {\n compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch );\n } else {\n\n if ( !Is.definedArray( watch.options.propertyNames ) || watch.options.propertyNames!.indexOf( propertyName ) > -1 ) {\n if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) {\n fireCustomTriggerEvent( watch.options.events!.onPropertyChange!, propertyName, propertyOldValue, propertyNewValue );\n }\n }\n }\n }\n }\n }\n\n function cancelWatchesForObjects() : void {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n cancelWatchObject( storageId );\n }\n }\n }\n\n function cancelWatchObject( storageId: string ) : void {\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watchOptions: WatchOptions = _watches[ storageId ].options;\n\n if ( watchOptions.allowCanceling || _watches_Cancel ) {\n fireCustomTriggerEvent( watchOptions.events!.onCancel!, storageId );\n clearInterval( _watches[ storageId ].timer );\n \n delete _watches[ storageId ];\n }\n }\n }\n\n function pauseWatchObject( storageId: string, milliseconds: number ) : boolean {\n let result: boolean = false;\n\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watchOptions: WatchOptions = _watches[ storageId ].options;\n\n if ( watchOptions.allowPausing ) {\n watchOptions.starts = new Date();\n watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds );\n \n result = true;\n }\n }\n\n return result;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Watch Options\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function getWatchOptions( newOptions: any ) : WatchOptions {\n let options: WatchOptions = Data.getDefaultObject( newOptions, {} as WatchOptions );\n\n options.timeout = Data.getDefaultNumber( options.timeout, 250 );\n options.starts = Data.getDefaultDate( options.starts, null! );\n options.expires = Data.getDefaultDate( options.expires, null! );\n options.reset = Data.getDefaultBoolean( options.reset, false );\n options.cancelOnChange = Data.getDefaultBoolean( options.cancelOnChange, false );\n options.maximumChangesBeforeCanceling = Data.getDefaultNumber( options.maximumChangesBeforeCanceling, 0 );\n options.pauseTimeoutOnChange = Data.getDefaultNumber( options.pauseTimeoutOnChange, 0 );\n options.propertyNames = Data.getDefaultArray( options.propertyNames, null! );\n options.allowCanceling = Data.getDefaultBoolean( options.allowCanceling, true );\n options.allowPausing = Data.getDefaultBoolean( options.allowPausing, true );\n options.removeAttribute = Data.getDefaultBoolean( options.removeAttribute, true );\n\n options = getWatchOptionsCustomTriggers( options );\n\n return options;\n }\n\n function getWatchOptionsCustomTriggers( options: WatchOptions ) : WatchOptions {\n options.events = Data.getDefaultObject( options.events, {} as WatchOptionEvents );\n options.events!.onChange = Data.getDefaultFunction( options.events!.onChange, null! );\n options.events!.onPropertyChange = Data.getDefaultFunction( options.events!.onPropertyChange, null! );\n options.events!.onCancel = Data.getDefaultFunction( options.events!.onCancel, null! );\n options.events!.onRemove = Data.getDefaultFunction( options.events!.onRemove, null! );\n options.events!.onStart = Data.getDefaultFunction( options.events!.onStart, null! );\n\n return options;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Triggering Custom Events\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function fireCustomTriggerEvent( triggerFunction: Function, ...args : any[] ) : void {\n if ( Is.definedFunction( triggerFunction ) ) {\n triggerFunction.apply( null, [].slice.call( args, 0 ) );\n }\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Default Parameter/Option Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function getObjectFromString( objectString: any ) : StringToJson {\n const result: StringToJson = {\n parsed: true,\n object: null\n } as StringToJson;\n\n try {\n if ( Is.definedString( objectString ) ) {\n result.object = JSON.parse( objectString );\n }\n\n } catch ( e1: any ) {\n try {\n result.object = eval( `(${objectString})` );\n\n if ( Is.definedFunction( result.object ) ) {\n result.object = result.object();\n }\n \n } catch ( e2: any ) {\n if ( !_configuration.safeMode ) {\n logError( _configuration.text!.objectErrorText!.replace( \"{{error_1}}\", e1.message ).replace( \"{{error_2}}\", e2.message ) );\n result.parsed = false;\n }\n \n result.object = null;\n }\n }\n\n return result;\n }\n\n function logError( error: string ) : boolean {\n let result: boolean = true;\n\n if ( !_configuration.safeMode ) {\n console.error( error );\n result = false;\n }\n\n return result;\n }\n\n\n\t/*\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t * Public API Functions: Helpers: Configuration\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t */\n\n function buildDefaultConfiguration( newConfiguration: any = null ) : void {\n _configuration = Data.getDefaultObject( newConfiguration, {} as Configuration );\n _configuration.safeMode = Data.getDefaultBoolean( _configuration.safeMode, true );\n _configuration.domElementTypes = Data.getDefaultStringOrArray( _configuration.domElementTypes, [ \"*\" ] );\n\n buildDefaultConfigurationStrings();\n }\n\n function buildDefaultConfigurationStrings() : void {\n _configuration.text = Data.getDefaultObject( _configuration.text, {} as ConfigurationText );\n _configuration.text!.objectErrorText = Data.getDefaultString( _configuration.text!.objectErrorText, \"Errors in object: {{error_1}}, {{error_2}}\" );\n _configuration.text!.attributeNotValidErrorText = Data.getDefaultString( _configuration.text!.attributeNotValidErrorText, \"The attribute '{{attribute_name}}' is not a valid object.\" );\n _configuration.text!.attributeNotSetErrorText = Data.getDefaultString( _configuration.text!.attributeNotSetErrorText, \"The attribute '{{attribute_name}}' has not been set correctly.\" ); \n }\n\n\n\t/*\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t * Public API Functions:\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t */\n\n const _public: PublicApi = {\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Watching Objects\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n watch: function ( object: any, options: WatchOptions ) : string {\n return createWatch( object, options );\n },\n\n cancelWatch: function ( id: string ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n cancelWatchObject( id );\n \n result = true;\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n cancelWatchObject( storageId );\n \n result = true;\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n cancelWatches: function () : PublicApi {\n cancelWatchesForObjects();\n\n return _public;\n },\n\n getWatch: function ( id: string ) : ObserveWatch {\n let result: ObserveWatch = null!;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n result = _watches[ id ];\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n result = _watches[ storageId ];\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n getWatches: function () : Record {\n return _watches;\n },\n\n pauseWatch: function ( id: string, milliseconds: number ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) && Is.definedNumber( milliseconds ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n result = pauseWatchObject( id, milliseconds );\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n result = pauseWatchObject( storageId, milliseconds );\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n pauseWatches: function ( milliseconds: number ) : PublicApi {\n if ( Is.definedNumber( milliseconds ) ) {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n pauseWatchObject( storageId, milliseconds );\n }\n }\n }\n \n return _public;\n },\n\n resumeWatch: function ( id: string ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n _watches[ id ].options.starts = null!;\n result = true;\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n _watches[ storageId ].options.starts = null!;\n result = true;\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n resumeWatches: function () : PublicApi {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n _watches[ storageId ].options.starts = null!;\n }\n }\n \n return _public;\n },\n\n searchDomForNewWatches: function () : PublicApi {\n collectDOMObjects();\n\n return _public;\n },\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Configuration\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n setConfiguration: function ( newConfiguration: any ) : PublicApi {\n if ( Is.definedObject( newConfiguration ) ) {\n let configurationHasChanged: boolean = false;\n const newInternalConfiguration: any = _configuration;\n \n for ( let propertyName in newConfiguration ) {\n if ( newConfiguration.hasOwnProperty( propertyName ) && _configuration.hasOwnProperty( propertyName ) && newInternalConfiguration[ propertyName ] !== newConfiguration[ propertyName ] ) {\n newInternalConfiguration[ propertyName ] = newConfiguration[ propertyName ];\n configurationHasChanged = true;\n }\n }\n \n if ( configurationHasChanged ) {\n buildDefaultConfiguration( newInternalConfiguration );\n }\n }\n \n return _public;\n },\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Additional Data\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n getVersion: function () : string {\n return \"1.0.0\";\n }\n };\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n buildDefaultConfiguration();\n\n document.addEventListener( \"DOMContentLoaded\", function() {\n collectDOMObjects();\n } );\n\n window.addEventListener( \"pagehide\", function() {\n _watches_Cancel = true;\n\n cancelWatchesForObjects();\n } );\n\n if ( !Is.defined( window.$observe ) ) {\n window.$observe = _public;\n }\n } )();\n} )();"]}
\ No newline at end of file
diff --git a/dist/observe.export.js b/dist/observe.export.js
deleted file mode 100644
index e5f874e..0000000
--- a/dist/observe.export.js
+++ /dev/null
@@ -1,6 +0,0 @@
-/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */
-var observe = {js:function() {
- return window.$observe;
-}};
-Object.assign(window, {observe});
-export{observe};
\ No newline at end of file
diff --git a/dist/observe.export.min.js b/dist/observe.export.min.js
deleted file mode 100644
index ee28274..0000000
--- a/dist/observe.export.min.js
+++ /dev/null
@@ -1,2 +0,0 @@
-/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */
-var observe={js:function(){return window.$observe}};Object.assign(window,{observe});export{observe};
\ No newline at end of file
diff --git a/dist/observe.js b/dist/observe.js
index 5da177b..31a8f70 100644
--- a/dist/observe.js
+++ b/dist/observe.js
@@ -1,460 +1,524 @@
-/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */
-(function() {
- var _parameter_Document = null, _parameter_Window = null, _parameter_Math = null, _parameter_Json = null, _public = {}, _string = {empty:""}, _watches = {}, _watches_Cancel = false, _configuration = {}, _attribute_Name_Watch_Options = "data-observe-js";
- function collectDOMObjects() {
- var tagTypes = _configuration.domElementTypes, tagTypesLength = tagTypes.length;
- for (var tagTypeIndex = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++) {
- var domElements = _parameter_Document.getElementsByTagName(tagTypes[tagTypeIndex]), elements = [].slice.call(domElements), elementsLength = elements.length;
- for (var elementIndex = 0; elementIndex < elementsLength; elementIndex++) {
- if (!collectDOMObject(elements[elementIndex])) {
- break;
- }
- }
- }
- }
- function collectDOMObject(element) {
- var result = true;
- if (isDefined(element) && element.hasAttribute(_attribute_Name_Watch_Options)) {
- var bindingOptionsData = element.getAttribute(_attribute_Name_Watch_Options);
- if (isDefinedString(bindingOptionsData)) {
- var bindingOptions = getObjectFromString(bindingOptionsData);
- if (bindingOptions.parsed && isDefinedObject(bindingOptions.result)) {
- bindingOptions = getWatchOptions(bindingOptions.result);
- if (!isDefinedString(element.id)) {
- element.id = newGuid();
- }
- if (bindingOptions.removeAttribute) {
- element.removeAttribute(_attribute_Name_Watch_Options);
- }
- createWatch(element, bindingOptions, element.id);
- } else {
- logError(_configuration.attributeNotValidErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
- result = false;
- }
- } else {
- logError(_configuration.attributeNotSetErrorText.replace("{{attribute_name}}", _attribute_Name_Watch_Options));
- result = false;
- }
- }
- return result;
- }
- function createWatch(object, options, domElementId) {
- var storageId = null;
- if (isDefinedObject(object)) {
- storageId = newGuid();
- var watchOptions = getWatchOptions(options), watch = {}, startWatchObject;
- watch.options = watchOptions;
- watch.totalChanges = 0;
- if (isDefinedString(domElementId)) {
- var domElement = _parameter_Document.getElementById(domElementId);
- if (isDefined(domElement)) {
- watch.domElementId = domElementId;
- watch.cachedObject = domElement.outerHTML;
- watch.originalObject = domElement.outerHTML;
- startWatchObject = domElement.outerHTML;
+"use strict";
+
+var Constant;
+
+(e => {
+ e.OBSERVE_JS_ATTRIBUTE_NAME = "data-observe-js";
+})(Constant || (Constant = {}));
+
+var Is;
+
+(e => {
+ function t(e) {
+ return e !== null && e !== void 0 && e.toString() !== "";
+ }
+ e.defined = t;
+ function n(e) {
+ return t(e) && typeof e === "object";
+ }
+ e.definedObject = n;
+ function r(e) {
+ return t(e) && typeof e === "boolean";
+ }
+ e.definedBoolean = r;
+ function a(e) {
+ return t(e) && typeof e === "string";
+ }
+ e.definedString = a;
+ function o(e) {
+ return t(e) && typeof e === "function";
+ }
+ e.definedFunction = o;
+ function i(e) {
+ return t(e) && typeof e === "number";
+ }
+ e.definedNumber = i;
+ function c(e) {
+ return n(e) && e instanceof Array;
+ }
+ e.definedArray = c;
+ function s(e) {
+ return n(e) && e instanceof Date;
+ }
+ e.definedDate = s;
+})(Is || (Is = {}));
+
+var Data;
+
+(e => {
+ let t;
+ (e => {
+ function t() {
+ const e = [];
+ for (let t = 0; t < 32; t++) {
+ if (t === 8 || t === 12 || t === 16 || t === 20) {
+ e.push("-");
+ }
+ const n = Math.floor(Math.random() * 16).toString(16);
+ e.push(n);
+ }
+ return e.join("");
}
- } else {
- watch.cachedObject = _parameter_Json.stringify(object);
- watch.originalObject = object;
- startWatchObject = object;
- }
- if (isDefined(watch.cachedObject)) {
- fireCustomTrigger(watch.options.onStart, startWatchObject);
- watch.timer = setInterval(function() {
- watchTimer(watchOptions, storageId);
- }, watchOptions.timeout);
- _watches[storageId] = watch;
- }
- }
- return storageId;
- }
- function watchTimer(watchOptions, storageId) {
- var currentDateTime = new Date();
- if (!isDefinedDate(watchOptions.starts) || currentDateTime >= watchOptions.starts) {
- watchObjectForChanges(storageId);
- if (isDefinedDate(watchOptions.expires) && currentDateTime >= watchOptions.expires) {
- cancelWatchObject(storageId);
- }
- }
- }
- function watchObjectForChanges(storageId) {
- if (_watches.hasOwnProperty(storageId)) {
- var watch = _watches[storageId], isDomElement = isDefinedString(watch.domElementId), domElement = null;
- if (isDomElement) {
- domElement = _parameter_Document.getElementById(watch.domElementId);
- if (isDefined(domElement)) {
- watch.originalObject = domElement.outerHTML;
+ e.newGuid = t;
+ })(t = e.String || (e.String = {}));
+ function n(e, t) {
+ return typeof e === "string" ? e : t;
+ }
+ e.getDefaultAnyString = n;
+ function r(e, t) {
+ return Is.definedString(e) ? e : t;
+ }
+ e.getDefaultString = r;
+ function a(e, t) {
+ return Is.definedBoolean(e) ? e : t;
+ }
+ e.getDefaultBoolean = a;
+ function o(e, t) {
+ return Is.definedNumber(e) ? e : t;
+ }
+ e.getDefaultNumber = o;
+ function i(e, t) {
+ return Is.definedFunction(e) ? e : t;
+ }
+ e.getDefaultFunction = i;
+ function c(e, t) {
+ return Is.definedArray(e) ? e : t;
+ }
+ e.getDefaultArray = c;
+ function s(e, t) {
+ return Is.definedObject(e) ? e : t;
+ }
+ e.getDefaultObject = s;
+ function u(e, t) {
+ return Is.definedDate(e) ? e : t;
+ }
+ e.getDefaultDate = u;
+ function f(e, t) {
+ let n = t;
+ if (Is.definedString(e)) {
+ const r = e.toString().split("space");
+ if (r.length === 0) {
+ e = t;
+ } else {
+ n = r;
+ }
} else {
- watch.originalObject = _string.empty;
- fireCustomTrigger(watch.options.onRemove, watch.domElementId);
+ n = c(e, t);
}
- }
- var cachedObject = watch.cachedObject, originalObject = watch.originalObject, originalObjectJson = !isDomElement ? _parameter_Json.stringify(originalObject) : originalObject;
- if (cachedObject !== originalObjectJson) {
- if (watch.options.reset) {
- if (isDomElement) {
- domElement.outerHTML = watch.cachedObject;
- } else {
- watch.originalObject = getObjectFromString(cachedObject).result;
- }
- } else {
- watch.cachedObject = originalObjectJson;
+ return n;
+ }
+ e.getDefaultStringOrArray = f;
+})(Data || (Data = {}));
+
+(() => {
+ let _configuration = {};
+ const _watches = {};
+ let _watches_Cancel = false;
+ function collectDOMObjects() {
+ const e = _configuration.domElementTypes;
+ const t = e.length;
+ for (let n = 0; n < t; n++) {
+ const t = document.getElementsByTagName(e[n]);
+ const r = [].slice.call(t);
+ const a = r.length;
+ for (let e = 0; e < a; e++) {
+ if (!collectDOMObject(r[e])) {
+ break;
+ }
+ }
}
- if (isDomElement) {
- fireCustomTrigger(watch.options.onChange, cachedObject, originalObjectJson);
- } else {
- var oldValue = getObjectFromString(cachedObject).result, newValue = getObjectFromString(originalObjectJson).result;
- if (!isDefinedArray(oldValue) && !isDefinedArray(newValue)) {
- compareWatchObject(oldValue, newValue, watch);
- if (isDefinedFunction(watch.options.onPropertyChange)) {
- compareWatchObjectProperties(oldValue, newValue, watch);
+ }
+ function collectDOMObject(e) {
+ let t = true;
+ if (Is.defined(e) && e.hasAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME)) {
+ const n = e.getAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME);
+ if (Is.definedString(n)) {
+ const r = getObjectFromString(n);
+ if (r.parsed && Is.definedObject(r.object)) {
+ const t = getWatchOptions(r.object);
+ if (!Is.definedString(e.id)) {
+ e.id = Data.String.newGuid();
+ }
+ if (t.removeAttribute) {
+ e.removeAttribute(Constant.OBSERVE_JS_ATTRIBUTE_NAME);
+ }
+ createWatch(e, t, e.id);
+ } else {
+ logError(_configuration.text.attributeNotValidErrorText.replace("{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME));
+ t = false;
+ }
+ } else {
+ logError(_configuration.text.attributeNotSetErrorText.replace("{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME));
+ t = false;
}
- } else {
- fireCustomTrigger(watch.options.onChange, oldValue, newValue);
- }
}
- watch.totalChanges++;
- if (watch.options.pauseTimeoutOnChange > 0) {
- pauseWatchObject(storageId, watch.options.pauseTimeoutOnChange);
+ return t;
+ }
+ function createWatch(e, t, n = null) {
+ let r = null;
+ if (Is.definedObject(e)) {
+ r = Data.String.newGuid();
+ const a = getWatchOptions(t);
+ const o = {};
+ let i = null;
+ o.options = a;
+ o.totalChanges = 0;
+ if (Is.definedString(n)) {
+ const e = document.getElementById(n);
+ if (Is.defined(e)) {
+ o.domElementId = n;
+ o.cachedObject = e.outerHTML;
+ o.originalObject = e.outerHTML;
+ i = e.outerHTML;
+ }
+ } else {
+ o.cachedObject = JSON.stringify(e);
+ o.originalObject = e;
+ i = e;
+ }
+ if (Is.defined(o.cachedObject)) {
+ fireCustomTriggerEvent(o.options.events.onStart, i);
+ o.timer = setInterval((function() {
+ watchTimer(a, r);
+ }), a.timeout);
+ _watches[r] = o;
+ }
}
- if (watch.options.cancelOnChange) {
- cancelWatchObject(storageId);
+ return r;
+ }
+ function watchTimer(e, t) {
+ const n = new Date;
+ if (!Is.definedDate(e.starts) || n >= e.starts) {
+ watchObjectForChanges(t);
+ if (Is.definedDate(e.expires) && n >= e.expires) {
+ cancelWatchObject(t);
+ }
}
- if (watch.options.maximumChangesBeforeCanceling > 0 && watch.totalChanges >= watch.options.maximumChangesBeforeCanceling) {
- cancelWatchObject(storageId);
+ }
+ function watchObjectForChanges(e) {
+ if (_watches.hasOwnProperty(e)) {
+ const t = _watches[e];
+ const n = Is.definedString(t.domElementId);
+ let r = null;
+ if (n) {
+ r = document.getElementById(t.domElementId);
+ if (Is.defined(r)) {
+ t.originalObject = r.outerHTML;
+ } else {
+ t.originalObject = "";
+ fireCustomTriggerEvent(t.options.events.onRemove, t.domElementId);
+ }
+ }
+ const a = t.cachedObject;
+ const o = t.originalObject;
+ const i = !n ? JSON.stringify(o) : o;
+ if (a !== i) {
+ if (t.options.reset) {
+ if (n) {
+ r.outerHTML = t.cachedObject;
+ } else {
+ t.originalObject = getObjectFromString(a).object;
+ }
+ } else {
+ t.cachedObject = i;
+ }
+ if (n) {
+ fireCustomTriggerEvent(t.options.events.onChange, a, i);
+ } else {
+ const e = getObjectFromString(a).object;
+ const n = getObjectFromString(i).object;
+ if (!Is.definedArray(e) && !Is.definedArray(n)) {
+ compareWatchObject(e, n, t);
+ if (Is.definedFunction(t.options.events.onPropertyChange)) {
+ compareWatchObjectProperties(e, n, t);
+ }
+ } else {
+ fireCustomTriggerEvent(t.options.events.onChange, e, n);
+ }
+ }
+ t.totalChanges++;
+ if (t.options.pauseTimeoutOnChange > 0) {
+ pauseWatchObject(e, t.options.pauseTimeoutOnChange);
+ }
+ if (t.options.cancelOnChange) {
+ cancelWatchObject(e);
+ }
+ if (t.options.maximumChangesBeforeCanceling > 0 && t.totalChanges >= t.options.maximumChangesBeforeCanceling) {
+ cancelWatchObject(e);
+ }
+ }
}
- }
- }
- }
- function compareWatchObject(oldObject, newObject, watch) {
- if (isDefinedArray(watch.options.propertyNames)) {
- var propertyNamesLength = watch.options.propertyNames.length;
- for (var propertyNameIndex = 0; propertyNameIndex < propertyNamesLength; propertyNameIndex++) {
- var propertyName = watch.options.propertyNames[propertyNameIndex];
- if (oldObject[propertyName] !== newObject[propertyName]) {
- fireCustomTrigger(watch.options.onChange, oldObject, newObject);
- break;
+ }
+ function compareWatchObject(e, t, n) {
+ if (Is.definedArray(n.options.propertyNames)) {
+ const r = n.options.propertyNames.length;
+ for (let a = 0; a < r; a++) {
+ const r = n.options.propertyNames[a];
+ if (e[r] !== t[r]) {
+ fireCustomTriggerEvent(n.options.events.onChange, e, t);
+ break;
+ }
+ }
+ } else {
+ fireCustomTriggerEvent(n.options.events.onChange, e, t);
}
- }
- } else {
- fireCustomTrigger(watch.options.onChange, oldObject, newObject);
- }
- }
- function compareWatchObjectProperties(oldObject, newObject, watch) {
- for (var propertyName in oldObject) {
- if (oldObject.hasOwnProperty(propertyName)) {
- var propertyOldValue = oldObject[propertyName], propertyNewValue = null;
- if (newObject.hasOwnProperty(propertyName)) {
- propertyNewValue = newObject[propertyName];
+ }
+ function compareWatchObjectProperties(e, t, n) {
+ for (let r in e) {
+ if (e.hasOwnProperty(r)) {
+ const a = e[r];
+ let o = null;
+ if (t.hasOwnProperty(r)) {
+ o = t[r];
+ }
+ if (Is.definedObject(a) && Is.definedObject(o)) {
+ compareWatchObjectProperties(a, o, n);
+ } else {
+ if (!Is.definedArray(n.options.propertyNames) || n.options.propertyNames.indexOf(r) > -1) {
+ if (JSON.stringify(a) !== JSON.stringify(o)) {
+ fireCustomTriggerEvent(n.options.events.onPropertyChange, r, a, o);
+ }
+ }
+ }
+ }
}
- if (isDefinedObject(propertyOldValue) && isDefinedObject(propertyNewValue)) {
- compareWatchObjectProperties(propertyOldValue, propertyNewValue, watch.options);
- } else {
- if (!isDefinedArray(watch.options.propertyNames) || watch.options.propertyNames.indexOf(propertyName) > -1) {
- if (_parameter_Json.stringify(propertyOldValue) !== _parameter_Json.stringify(propertyNewValue)) {
- fireCustomTrigger(watch.options.onPropertyChange, propertyName, propertyOldValue, propertyNewValue);
+ }
+ function cancelWatchesForObjects() {
+ for (let e in _watches) {
+ if (_watches.hasOwnProperty(e)) {
+ cancelWatchObject(e);
}
- }
}
- }
- }
- }
- function cancelWatchesForObjects() {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId)) {
- cancelWatchObject(storageId);
- }
- }
- }
- function cancelWatchObject(storageId) {
- if (_watches.hasOwnProperty(storageId)) {
- var watchOptions = _watches[storageId].options;
- if (watchOptions.allowCanceling || _watches_Cancel) {
- fireCustomTrigger(watchOptions.onCancel, storageId);
- clearInterval(_watches[storageId].timer);
- delete _watches[storageId];
- }
- }
- }
- function pauseWatchObject(storageId, milliseconds) {
- var result = false;
- if (_watches.hasOwnProperty(storageId)) {
- var watchOptions = _watches[storageId].options;
- if (watchOptions.allowPausing) {
- watchOptions.starts = new Date();
- watchOptions.starts.setMilliseconds(watchOptions.starts.getMilliseconds() + milliseconds);
- result = true;
- }
- }
- return result;
- }
- function getWatchOptions(newOptions) {
- var options = getDefaultObject(newOptions, {});
- options.timeout = getDefaultNumber(options.timeout, 250);
- options.starts = getDefaultDate(options.starts, null);
- options.expires = getDefaultDate(options.expires, null);
- options.reset = getDefaultBoolean(options.reset, false);
- options.cancelOnChange = getDefaultBoolean(options.cancelOnChange, false);
- options.maximumChangesBeforeCanceling = getDefaultNumber(options.maximumChangesBeforeCanceling, 0);
- options.pauseTimeoutOnChange = getDefaultNumber(options.pauseTimeoutOnChange, 0);
- options.propertyNames = getDefaultArray(options.propertyNames, null);
- options.allowCanceling = getDefaultBoolean(options.allowCanceling, true);
- options.allowPausing = getDefaultBoolean(options.allowPausing, true);
- options.removeAttribute = getDefaultBoolean(options.removeAttribute, true);
- options = getWatchOptionsCustomTriggers(options);
- return options;
- }
- function getWatchOptionsCustomTriggers(options) {
- options.onChange = getDefaultFunction(options.onChange, null);
- options.onPropertyChange = getDefaultFunction(options.onPropertyChange, null);
- options.onCancel = getDefaultFunction(options.onCancel, null);
- options.onRemove = getDefaultFunction(options.onRemove, null);
- options.onStart = getDefaultFunction(options.onStart, null);
- return options;
- }
- function fireCustomTrigger(triggerFunction) {
- if (isDefinedFunction(triggerFunction)) {
- triggerFunction.apply(null, [].slice.call(arguments, 1));
- }
- }
- function newGuid() {
- var result = [];
- for (var charIndex = 0; charIndex < 32; charIndex++) {
- if (charIndex === 8 || charIndex === 12 || charIndex === 16 || charIndex === 20) {
- result.push("-");
- }
- var character = _parameter_Math.floor(_parameter_Math.random() * 16).toString(16);
- result.push(character);
- }
- return result.join(_string.empty);
- }
- function isDefined(value) {
- return value !== null && value !== undefined && value !== _string.empty;
- }
- function isDefinedObject(object) {
- return isDefined(object) && typeof object === "object";
- }
- function isDefinedBoolean(object) {
- return isDefined(object) && typeof object === "boolean";
- }
- function isDefinedString(object) {
- return isDefined(object) && typeof object === "string";
- }
- function isDefinedFunction(object) {
- return isDefined(object) && typeof object === "function";
- }
- function isDefinedNumber(object) {
- return isDefined(object) && typeof object === "number";
- }
- function isDefinedArray(object) {
- return isDefinedObject(object) && object instanceof Array;
- }
- function isDefinedDate(object) {
- return isDefinedObject(object) && object instanceof Date;
- }
- function getDefaultBoolean(value, defaultValue) {
- return isDefinedBoolean(value) ? value : defaultValue;
- }
- function getDefaultFunction(value, defaultValue) {
- return isDefinedFunction(value) ? value : defaultValue;
- }
- function getDefaultNumber(value, defaultValue) {
- return isDefinedNumber(value) ? value : defaultValue;
- }
- function getDefaultString(value, defaultValue) {
- return isDefinedString(value) ? value : defaultValue;
- }
- function getDefaultDate(value, defaultValue) {
- return isDefinedDate(value) ? value : defaultValue;
- }
- function getDefaultArray(value, defaultValue) {
- return isDefinedArray(value) ? value : defaultValue;
- }
- function getDefaultObject(value, defaultValue) {
- return isDefinedObject(value) ? value : defaultValue;
- }
- function getDefaultStringOrArray(value, defaultValue) {
- if (isDefinedString(value)) {
- value = value.split(_string.space);
- if (value.length === 0) {
- value = defaultValue;
- }
- } else {
- value = getDefaultArray(value, defaultValue);
- }
- return value;
- }
- function getObjectFromString(objectString) {
- var parsed = true, result = null;
- try {
- if (isDefinedString(objectString)) {
- result = _parameter_Json.parse(objectString);
- }
- } catch (e1) {
- try {
- result = eval("(" + objectString + ")");
- if (isDefinedFunction(result)) {
- result = result();
+ }
+ function cancelWatchObject(e) {
+ if (_watches.hasOwnProperty(e)) {
+ const t = _watches[e].options;
+ if (t.allowCanceling || _watches_Cancel) {
+ fireCustomTriggerEvent(t.events.onCancel, e);
+ clearInterval(_watches[e].timer);
+ delete _watches[e];
+ }
}
- } catch (e2) {
- parsed = logError(_configuration.objectErrorText.replace("{{error_1}}", e1.message).replace("{{error_2}}", e2.message));
- result = null;
- }
- }
- return {parsed:parsed, result:result};
- }
- function logError(error) {
- var result = true;
- if (!_configuration.safeMode) {
- console.error(error);
- result = false;
- }
- return result;
- }
- _public.watch = function(object, options) {
- return createWatch(object, options);
- };
- _public.cancelWatch = function(id) {
- var result = false;
- if (isDefinedString(id)) {
- if (_watches.hasOwnProperty(id)) {
- cancelWatchObject(id);
- result = true;
- } else {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId) && isDefinedString(_watches[storageId].domElementId) && _watches[storageId].domElementId === id) {
- cancelWatchObject(storageId);
- result = true;
- break;
- }
+ }
+ function pauseWatchObject(e, t) {
+ let n = false;
+ if (_watches.hasOwnProperty(e)) {
+ const r = _watches[e].options;
+ if (r.allowPausing) {
+ r.starts = new Date;
+ r.starts.setMilliseconds(r.starts.getMilliseconds() + t);
+ n = true;
+ }
}
- }
- }
- return result;
- };
- _public.cancelWatches = function() {
- cancelWatchesForObjects();
- return _public;
- };
- _public.getWatch = function(id) {
- var result = null;
- if (isDefinedString(id)) {
- if (_watches.hasOwnProperty(id)) {
- result = _watches[id];
- } else {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId) && isDefinedString(_watches[storageId].domElementId) && _watches[storageId].domElementId === id) {
- result = _watches[storageId];
- break;
- }
+ return n;
+ }
+ function getWatchOptions(e) {
+ let t = Data.getDefaultObject(e, {});
+ t.timeout = Data.getDefaultNumber(t.timeout, 250);
+ t.starts = Data.getDefaultDate(t.starts, null);
+ t.expires = Data.getDefaultDate(t.expires, null);
+ t.reset = Data.getDefaultBoolean(t.reset, false);
+ t.cancelOnChange = Data.getDefaultBoolean(t.cancelOnChange, false);
+ t.maximumChangesBeforeCanceling = Data.getDefaultNumber(t.maximumChangesBeforeCanceling, 0);
+ t.pauseTimeoutOnChange = Data.getDefaultNumber(t.pauseTimeoutOnChange, 0);
+ t.propertyNames = Data.getDefaultArray(t.propertyNames, null);
+ t.allowCanceling = Data.getDefaultBoolean(t.allowCanceling, true);
+ t.allowPausing = Data.getDefaultBoolean(t.allowPausing, true);
+ t.removeAttribute = Data.getDefaultBoolean(t.removeAttribute, true);
+ t = getWatchOptionsCustomTriggers(t);
+ return t;
+ }
+ function getWatchOptionsCustomTriggers(e) {
+ e.events = Data.getDefaultObject(e.events, {});
+ e.events.onChange = Data.getDefaultFunction(e.events.onChange, null);
+ e.events.onPropertyChange = Data.getDefaultFunction(e.events.onPropertyChange, null);
+ e.events.onCancel = Data.getDefaultFunction(e.events.onCancel, null);
+ e.events.onRemove = Data.getDefaultFunction(e.events.onRemove, null);
+ e.events.onStart = Data.getDefaultFunction(e.events.onStart, null);
+ return e;
+ }
+ function fireCustomTriggerEvent(e, ...t) {
+ if (Is.definedFunction(e)) {
+ e.apply(null, [].slice.call(t, 0));
}
- }
- }
- return result;
- };
- _public.getWatches = function() {
- return _watches;
- };
- _public.pauseWatch = function(id, milliseconds) {
- var result = false;
- if (isDefinedString(id) && isDefinedNumber(milliseconds)) {
- if (_watches.hasOwnProperty(id)) {
- result = pauseWatchObject(id, milliseconds);
- } else {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId) && isDefinedString(_watches[storageId].domElementId) && _watches[storageId].domElementId === id) {
- result = pauseWatchObject(storageId, milliseconds);
- break;
- }
+ }
+ function getObjectFromString(objectString) {
+ const result = {
+ parsed: true,
+ object: null
+ };
+ try {
+ if (Is.definedString(objectString)) {
+ result.object = JSON.parse(objectString);
+ }
+ } catch (e1) {
+ try {
+ result.object = eval(`(${objectString})`);
+ if (Is.definedFunction(result.object)) {
+ result.object = result.object();
+ }
+ } catch (e) {
+ if (!_configuration.safeMode) {
+ logError(_configuration.text.objectErrorText.replace("{{error_1}}", e1.message).replace("{{error_2}}", e.message));
+ result.parsed = false;
+ }
+ result.object = null;
+ }
}
- }
- }
- return result;
- };
- _public.pauseWatches = function(milliseconds) {
- if (isDefinedNumber(milliseconds)) {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId)) {
- pauseWatchObject(storageId, milliseconds);
+ return result;
+ }
+ function logError(e) {
+ let t = true;
+ if (!_configuration.safeMode) {
+ console.error(e);
+ t = false;
}
- }
- }
- return _public;
- };
- _public.resumeWatch = function(id) {
- var result = false;
- if (isDefinedString(id)) {
- if (_watches.hasOwnProperty(id)) {
- _watches[id].options.starts = null;
- result = true;
- } else {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId) && isDefinedString(_watches[storageId].domElementId) && _watches[storageId].domElementId === id) {
- _watches[storageId].options.starts = null;
- result = true;
- break;
- }
+ return t;
+ }
+ function buildDefaultConfiguration(e = null) {
+ _configuration = Data.getDefaultObject(e, {});
+ _configuration.safeMode = Data.getDefaultBoolean(_configuration.safeMode, true);
+ _configuration.domElementTypes = Data.getDefaultStringOrArray(_configuration.domElementTypes, [ "*" ]);
+ buildDefaultConfigurationStrings();
+ }
+ function buildDefaultConfigurationStrings() {
+ _configuration.text = Data.getDefaultObject(_configuration.text, {});
+ _configuration.text.objectErrorText = Data.getDefaultString(_configuration.text.objectErrorText, "Errors in object: {{error_1}}, {{error_2}}");
+ _configuration.text.attributeNotValidErrorText = Data.getDefaultString(_configuration.text.attributeNotValidErrorText, "The attribute '{{attribute_name}}' is not a valid object.");
+ _configuration.text.attributeNotSetErrorText = Data.getDefaultString(_configuration.text.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly.");
+ }
+ const _public = {
+ watch: function(e, t) {
+ return createWatch(e, t);
+ },
+ cancelWatch: function(e) {
+ let t = false;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ cancelWatchObject(e);
+ t = true;
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ cancelWatchObject(n);
+ t = true;
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ cancelWatches: function() {
+ cancelWatchesForObjects();
+ return _public;
+ },
+ getWatch: function(e) {
+ let t = null;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ t = _watches[e];
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ t = _watches[n];
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ getWatches: function() {
+ return _watches;
+ },
+ pauseWatch: function(e, t) {
+ let n = false;
+ if (Is.definedString(e) && Is.definedNumber(t)) {
+ if (_watches.hasOwnProperty(e)) {
+ n = pauseWatchObject(e, t);
+ } else {
+ for (let r in _watches) {
+ if (_watches.hasOwnProperty(r) && Is.definedString(_watches[r].domElementId) && _watches[r].domElementId === e) {
+ n = pauseWatchObject(r, t);
+ break;
+ }
+ }
+ }
+ }
+ return n;
+ },
+ pauseWatches: function(e) {
+ if (Is.definedNumber(e)) {
+ for (let t in _watches) {
+ if (_watches.hasOwnProperty(t)) {
+ pauseWatchObject(t, e);
+ }
+ }
+ }
+ return _public;
+ },
+ resumeWatch: function(e) {
+ let t = false;
+ if (Is.definedString(e)) {
+ if (_watches.hasOwnProperty(e)) {
+ _watches[e].options.starts = null;
+ t = true;
+ } else {
+ for (let n in _watches) {
+ if (_watches.hasOwnProperty(n) && Is.definedString(_watches[n].domElementId) && _watches[n].domElementId === e) {
+ _watches[n].options.starts = null;
+ t = true;
+ break;
+ }
+ }
+ }
+ }
+ return t;
+ },
+ resumeWatches: function() {
+ for (let e in _watches) {
+ if (_watches.hasOwnProperty(e)) {
+ _watches[e].options.starts = null;
+ }
+ }
+ return _public;
+ },
+ searchDomForNewWatches: function() {
+ collectDOMObjects();
+ return _public;
+ },
+ setConfiguration: function(e) {
+ if (Is.definedObject(e)) {
+ let t = false;
+ const n = _configuration;
+ for (let r in e) {
+ if (e.hasOwnProperty(r) && _configuration.hasOwnProperty(r) && n[r] !== e[r]) {
+ n[r] = e[r];
+ t = true;
+ }
+ }
+ if (t) {
+ buildDefaultConfiguration(n);
+ }
+ }
+ return _public;
+ },
+ getVersion: function() {
+ return "1.0.0";
}
- }
- }
- return result;
- };
- _public.resumeWatches = function() {
- for (var storageId in _watches) {
- if (_watches.hasOwnProperty(storageId)) {
- _watches[storageId].options.starts = null;
- }
- }
- return _public;
- };
- _public.searchDomForNewWatches = function() {
- collectDOMObjects();
- return _public;
- };
- _public.setConfiguration = function(newConfiguration) {
- if (isDefinedObject(newConfiguration)) {
- var configurationHasChanged = false;
- for (var propertyName in newConfiguration) {
- if (newConfiguration.hasOwnProperty(propertyName) && _configuration.hasOwnProperty(propertyName) && _configuration[propertyName] !== newConfiguration[propertyName]) {
- _configuration[propertyName] = newConfiguration[propertyName];
- configurationHasChanged = true;
+ };
+ (() => {
+ buildDefaultConfiguration();
+ document.addEventListener("DOMContentLoaded", (function() {
+ collectDOMObjects();
+ }));
+ window.addEventListener("pagehide", (function() {
+ _watches_Cancel = true;
+ cancelWatchesForObjects();
+ }));
+ if (!Is.defined(window.$observe)) {
+ window.$observe = _public;
}
- }
- if (configurationHasChanged) {
- buildDefaultConfiguration(_configuration);
- }
- }
- return _public;
- };
- function buildDefaultConfiguration(newConfiguration) {
- _configuration = !isDefinedObject(newConfiguration) ? {} : newConfiguration;
- _configuration.safeMode = getDefaultBoolean(_configuration.safeMode, true);
- _configuration.domElementTypes = getDefaultStringOrArray(_configuration.domElementTypes, ["*"]);
- buildDefaultConfigurationStrings();
- }
- function buildDefaultConfigurationStrings() {
- _configuration.objectErrorText = getDefaultString(_configuration.objectErrorText, "Errors in object: {{error_1}}, {{error_2}}");
- _configuration.attributeNotValidErrorText = getDefaultString(_configuration.attributeNotValidErrorText, "The attribute '{{attribute_name}}' is not a valid object.");
- _configuration.attributeNotSetErrorText = getDefaultString(_configuration.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly.");
- }
- _public.getVersion = function() {
- return "0.8.2";
- };
- (function(documentObject, windowObject, mathObject, jsonObject) {
- _parameter_Document = documentObject;
- _parameter_Window = windowObject;
- _parameter_Math = mathObject;
- _parameter_Json = jsonObject;
- buildDefaultConfiguration();
- _parameter_Document.addEventListener("DOMContentLoaded", function() {
- collectDOMObjects();
- });
- _parameter_Window.addEventListener("pagehide", function() {
- _watches_Cancel = true;
- cancelWatchesForObjects();
- });
- if (!isDefined(_parameter_Window.$observe)) {
- _parameter_Window.$observe = _public;
- }
- })(document, window, Math, JSON);
-})();
\ No newline at end of file
+ })();
+})();//# sourceMappingURL=observe.js.map
\ No newline at end of file
diff --git a/dist/observe.js.map b/dist/observe.js.map
new file mode 100644
index 0000000..a9ed779
--- /dev/null
+++ b/dist/observe.js.map
@@ -0,0 +1 @@
+{"version":3,"sources":["../src/ts/constant.ts","../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Constant","Is","Data","String","result"],"mappings":";;;AAaO,IAAU;AAAA,CAAV,CAAUA,cAAV;AACI,EAAMA,UAAA,4BAA4B;AAAA,GAD5B;;;ACGV,IAAU;AAAA,CAAV,CAAUC,QAAV;AACI,WAAS,QAAS,OAAuB;AAC5C,WAAO,UAAU,QAAQ,UAAU,UAAa,MAAM,SAAS;AAAA,EACnE;AAFO,EAAAA,IAAS;AAIT,WAAS,cAAe,QAAwB;AACnD,WAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,eAAgB,QAAwB;AACpD,WAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,cAAe,QAAwB;AACnD,WAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,gBAAiB,QAAwB;AACrD,WAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,cAAe,QAAwB;AACnD,WAAO,QAAS,MAAO,KAAK,OAAO,WAAW;AAAA,EA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AM;AACJ,8BAA0B;AAE1B,aAAS,iBAAkB,oBAAoB,WAAW;AACtD,wBAAkB;AAAA,IACtB,CAAE;AAEF,WAAO,iBAAkB,YAAY,WAAW;AAC5C,wBAAkB;AAElB,8BAAwB;AAAA,IAC5B,CAAE;AAEF,QAAK,CAAC,GAAG,QAAS,OAAO,QAAS,GAAI;AAClC,aAAO,WAAW;AAAA,IACtB;AAAA,EACJ,GAAI;AACR,GAAI","sourcesContent":["/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file constant.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nexport namespace Constant {\n export const OBSERVE_JS_ATTRIBUTE_NAME = \"data-observe-js\";\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file is.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport { Char } from \"./enum\"\n\n\nexport namespace Is {\n export function defined( value: any ) : boolean {\n return value !== null && value !== undefined && value.toString() !== Char.empty;\n }\n\n export function definedObject( object: any ) : boolean {\n return defined( object ) && typeof object === \"object\";\n }\n\n export function definedBoolean( object: any ) : boolean {\n return defined( object ) && typeof object === \"boolean\";\n }\n\n export function definedString( object: any ) : boolean {\n return defined( object ) && typeof object === \"string\";\n }\n\n export function definedFunction( object: any ) : boolean {\n return defined( object ) && typeof object === \"function\";\n }\n\n export function definedNumber( object: any ) : boolean {\n return defined( object ) && typeof object === \"number\";\n }\n\n export function definedArray( object: any ) : boolean {\n return definedObject( object ) && object instanceof Array;\n }\n\n export function definedDate( object: any ) : boolean {\n return definedObject( object ) && object instanceof Date;\n }\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file data.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport { Char } from \"./enum\";\nimport { Is } from \"./is\";\n\n\nexport namespace Data {\n export namespace String {\n export function newGuid() : string {\n const result: string[] = [];\n \n for ( let charIndex: number = 0; charIndex < 32; charIndex++ ) {\n if ( charIndex === 8 || charIndex === 12 || charIndex === 16 || charIndex === 20 ) {\n result.push( Char.dash );\n }\n \n const character: string = Math.floor( Math.random() * 16 ).toString( 16 );\n result.push( character );\n }\n \n return result.join( Char.empty );\n }\n }\n\n export function getDefaultAnyString( value: any, defaultValue: string ) : string {\n return typeof value === \"string\" ? value : defaultValue;\n }\n\n export function getDefaultString( value: any, defaultValue: string ) : string {\n return Is.definedString( value ) ? value : defaultValue;\n }\n\n export function getDefaultBoolean( value: any, defaultValue: boolean ) : boolean {\n return Is.definedBoolean( value ) ? value : defaultValue;\n }\n\n export function getDefaultNumber( value: any, defaultValue: number ) : number {\n return Is.definedNumber( value ) ? value : defaultValue;\n }\n\n export function getDefaultFunction( value: any, defaultValue: object ) : any {\n return Is.definedFunction( value ) ? value : defaultValue;\n }\n\n export function getDefaultArray( value: any, defaultValue: any[] ) : any[] {\n return Is.definedArray( value ) ? value : defaultValue;\n }\n\n export function getDefaultObject( value: any, defaultValue: object ) : any {\n return Is.definedObject( value ) ? value : defaultValue;\n }\n\n export function getDefaultDate( value: any, defaultValue: Date ) : Date {\n return Is.definedDate( value ) ? value : defaultValue;\n }\n\n export function getDefaultStringOrArray( value: any, defaultValue: string[] ) : string[] {\n let result: string[] = defaultValue;\n\n if ( Is.definedString( value ) ) {\n const values: string[] = value.toString().split( Char.space );\n\n if ( values.length === 0 ) {\n value = defaultValue;\n } else {\n result = values;\n }\n\n } else {\n result = getDefaultArray( value, defaultValue );\n }\n\n return result;\n }\n}","/**\n * Observe.js\n * \n * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.\n * \n * @file observe.ts\n * @version v1.0.0\n * @author Bunoon\n * @license MIT License\n * @copyright Bunoon 2024\n */\n\n\nimport {\n type WatchOptionEvents,\n type WatchOptions,\n type Configuration,\n type ObserveWatch, \n type ConfigurationText } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type PublicApi } from \"./ts/api\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\n\n( () => {\n // Variables: Configuration\n let _configuration: Configuration = {} as Configuration;\n\n // Variables: Watches\n const _watches: Record = {} as Record;\n let _watches_Cancel: boolean = false;\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Observable DOM Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function collectDOMObjects() : void {\n const tagTypes: string[] = _configuration.domElementTypes as string[];\n const tagTypesLength: number = tagTypes.length;\n\n for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) {\n const domElements: HTMLCollectionOf = document.getElementsByTagName( tagTypes[ tagTypeIndex ] );\n const elements: HTMLElement[] = [].slice.call( domElements );\n const elementsLength: number = elements.length;\n\n for ( let elementIndex: number = 0; elementIndex < elementsLength; elementIndex++ ) {\n if ( !collectDOMObject( elements[ elementIndex ] ) ) {\n break;\n }\n }\n }\n }\n\n function collectDOMObject( element: HTMLElement ) : boolean {\n let result: boolean = true;\n\n if ( Is.defined( element ) && element.hasAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME ) ) {\n const bindingOptionsData: string = element.getAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME )!;\n\n if ( Is.definedString( bindingOptionsData ) ) {\n const watchOptionsJson: StringToJson = getObjectFromString( bindingOptionsData );\n\n if ( watchOptionsJson.parsed && Is.definedObject( watchOptionsJson.object ) ) {\n const watchOptions: WatchOptions = getWatchOptions( watchOptionsJson.object );\n\n if ( !Is.definedString( element.id ) ) {\n element.id = Data.String.newGuid();\n }\n\n if ( watchOptions.removeAttribute ) {\n element.removeAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME );\n }\n\n createWatch( element, watchOptions, element.id );\n\n } else {\n logError( _configuration.text!.attributeNotValidErrorText!.replace( \"{{attribute_name}}\", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) );\n result = false;\n }\n\n } else {\n logError( _configuration.text!.attributeNotSetErrorText!.replace( \"{{attribute_name}}\", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) );\n result = false;\n }\n }\n\n return result;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string = null! ) : string {\n let storageId: string = null!;\n\n if ( Is.definedObject( object ) ) {\n storageId = Data.String.newGuid();\n\n const watchOptions: WatchOptions = getWatchOptions( options );\n const watch: ObserveWatch = {} as ObserveWatch;\n let startWatchObject: any = null;\n\n watch.options = watchOptions;\n watch.totalChanges = 0;\n\n if ( Is.definedString( domElementId ) ) {\n const domElement: HTMLElement = document.getElementById( domElementId )!;\n\n if ( Is.defined( domElement ) ) {\n watch.domElementId = domElementId;\n watch.cachedObject = domElement.outerHTML;\n watch.originalObject = domElement.outerHTML;\n\n startWatchObject = domElement.outerHTML;\n }\n\n } else {\n watch.cachedObject = JSON.stringify( object );\n watch.originalObject = object;\n\n startWatchObject = object;\n }\n\n if ( Is.defined( watch.cachedObject ) ) {\n fireCustomTriggerEvent( watch.options.events!.onStart!, startWatchObject );\n\n watch.timer = setInterval( function() {\n watchTimer( watchOptions, storageId );\n }, watchOptions.timeout );\n \n _watches[ storageId ] = watch;\n }\n }\n\n return storageId;\n }\n\n function watchTimer( watchOptions: WatchOptions, storageId: string ) : void {\n const currentDateTime: Date = new Date();\n\n if ( !Is.definedDate( watchOptions.starts ) || currentDateTime >= watchOptions.starts! ) {\n watchObjectForChanges( storageId );\n\n if ( Is.definedDate( watchOptions.expires ) && currentDateTime >= watchOptions.expires! ) {\n cancelWatchObject( storageId );\n }\n }\n }\n\n function watchObjectForChanges( storageId: string ) : void {\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watch: ObserveWatch = _watches[ storageId ];\n const isDomElement: boolean = Is.definedString( watch.domElementId );\n let domElement: HTMLElement = null!;\n\n if ( isDomElement ) {\n domElement = document.getElementById( watch.domElementId )!;\n\n if ( Is.defined( domElement ) ) {\n watch.originalObject = domElement.outerHTML;\n } else {\n watch.originalObject = Char.empty;\n\n fireCustomTriggerEvent( watch.options.events!.onRemove!, watch.domElementId );\n }\n }\n\n const cachedObject: any = watch.cachedObject;\n const originalObject: any = watch.originalObject;\n const originalObjectJson: any = !isDomElement ? JSON.stringify( originalObject ) : originalObject;\n\n if ( cachedObject !== originalObjectJson ) {\n if ( watch.options.reset ) {\n if ( isDomElement ) {\n domElement.outerHTML = watch.cachedObject;\n } else {\n watch.originalObject = getObjectFromString( cachedObject ).object;\n }\n\n } else {\n watch.cachedObject = originalObjectJson;\n }\n\n if ( isDomElement ) {\n fireCustomTriggerEvent( watch.options.events!.onChange!, cachedObject, originalObjectJson );\n } else {\n\n const oldValue: any = getObjectFromString( cachedObject ).object;\n const newValue: any = getObjectFromString( originalObjectJson ).object;\n\n if ( !Is.definedArray( oldValue ) && !Is.definedArray( newValue ) ) {\n compareWatchObject( oldValue, newValue, watch );\n\n if ( Is.definedFunction( watch.options.events!.onPropertyChange ) ) {\n compareWatchObjectProperties( oldValue, newValue, watch );\n }\n \n } else {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldValue, newValue );\n }\n }\n\n watch.totalChanges++;\n\n if ( watch.options.pauseTimeoutOnChange! > 0 ) {\n pauseWatchObject( storageId, watch.options.pauseTimeoutOnChange! );\n }\n\n if ( watch.options.cancelOnChange ) {\n cancelWatchObject( storageId );\n }\n\n if ( watch.options.maximumChangesBeforeCanceling! > 0 && watch.totalChanges >= watch.options.maximumChangesBeforeCanceling! ) {\n cancelWatchObject( storageId );\n }\n }\n }\n }\n\n function compareWatchObject( oldObject: any, newObject: any, watch: ObserveWatch ) : void {\n if ( Is.definedArray( watch.options.propertyNames ) ) {\n const propertyNamesLength: number = watch.options.propertyNames!.length;\n\n for ( let propertyNameIndex: number = 0; propertyNameIndex < propertyNamesLength; propertyNameIndex++ ) {\n const propertyName: string = watch.options.propertyNames![ propertyNameIndex ];\n\n if ( oldObject[ propertyName ] !== newObject[ propertyName ] ) {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject );\n break;\n }\n }\n\n } else {\n fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject );\n }\n }\n\n function compareWatchObjectProperties( oldObject: any, newObject: any, watch: ObserveWatch ) : void {\n for ( let propertyName in oldObject ) {\n if ( oldObject.hasOwnProperty( propertyName ) ) {\n const propertyOldValue: any = oldObject[ propertyName ];\n let propertyNewValue: any = null;\n\n if ( newObject.hasOwnProperty( propertyName ) ) {\n propertyNewValue = newObject[ propertyName ];\n }\n\n if ( Is.definedObject( propertyOldValue ) && Is.definedObject( propertyNewValue ) ) {\n compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch );\n } else {\n\n if ( !Is.definedArray( watch.options.propertyNames ) || watch.options.propertyNames!.indexOf( propertyName ) > -1 ) {\n if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) {\n fireCustomTriggerEvent( watch.options.events!.onPropertyChange!, propertyName, propertyOldValue, propertyNewValue );\n }\n }\n }\n }\n }\n }\n\n function cancelWatchesForObjects() : void {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n cancelWatchObject( storageId );\n }\n }\n }\n\n function cancelWatchObject( storageId: string ) : void {\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watchOptions: WatchOptions = _watches[ storageId ].options;\n\n if ( watchOptions.allowCanceling || _watches_Cancel ) {\n fireCustomTriggerEvent( watchOptions.events!.onCancel!, storageId );\n clearInterval( _watches[ storageId ].timer );\n \n delete _watches[ storageId ];\n }\n }\n }\n\n function pauseWatchObject( storageId: string, milliseconds: number ) : boolean {\n let result: boolean = false;\n\n if ( _watches.hasOwnProperty( storageId ) ) {\n const watchOptions: WatchOptions = _watches[ storageId ].options;\n\n if ( watchOptions.allowPausing ) {\n watchOptions.starts = new Date();\n watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds );\n \n result = true;\n }\n }\n\n return result;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Watch Options\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function getWatchOptions( newOptions: any ) : WatchOptions {\n let options: WatchOptions = Data.getDefaultObject( newOptions, {} as WatchOptions );\n\n options.timeout = Data.getDefaultNumber( options.timeout, 250 );\n options.starts = Data.getDefaultDate( options.starts, null! );\n options.expires = Data.getDefaultDate( options.expires, null! );\n options.reset = Data.getDefaultBoolean( options.reset, false );\n options.cancelOnChange = Data.getDefaultBoolean( options.cancelOnChange, false );\n options.maximumChangesBeforeCanceling = Data.getDefaultNumber( options.maximumChangesBeforeCanceling, 0 );\n options.pauseTimeoutOnChange = Data.getDefaultNumber( options.pauseTimeoutOnChange, 0 );\n options.propertyNames = Data.getDefaultArray( options.propertyNames, null! );\n options.allowCanceling = Data.getDefaultBoolean( options.allowCanceling, true );\n options.allowPausing = Data.getDefaultBoolean( options.allowPausing, true );\n options.removeAttribute = Data.getDefaultBoolean( options.removeAttribute, true );\n\n options = getWatchOptionsCustomTriggers( options );\n\n return options;\n }\n\n function getWatchOptionsCustomTriggers( options: WatchOptions ) : WatchOptions {\n options.events = Data.getDefaultObject( options.events, {} as WatchOptionEvents );\n options.events!.onChange = Data.getDefaultFunction( options.events!.onChange, null! );\n options.events!.onPropertyChange = Data.getDefaultFunction( options.events!.onPropertyChange, null! );\n options.events!.onCancel = Data.getDefaultFunction( options.events!.onCancel, null! );\n options.events!.onRemove = Data.getDefaultFunction( options.events!.onRemove, null! );\n options.events!.onStart = Data.getDefaultFunction( options.events!.onStart, null! );\n\n return options;\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Triggering Custom Events\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function fireCustomTriggerEvent( triggerFunction: Function, ...args : any[] ) : void {\n if ( Is.definedFunction( triggerFunction ) ) {\n triggerFunction.apply( null, [].slice.call( args, 0 ) );\n }\n }\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Default Parameter/Option Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function getObjectFromString( objectString: any ) : StringToJson {\n const result: StringToJson = {\n parsed: true,\n object: null\n } as StringToJson;\n\n try {\n if ( Is.definedString( objectString ) ) {\n result.object = JSON.parse( objectString );\n }\n\n } catch ( e1: any ) {\n try {\n result.object = eval( `(${objectString})` );\n\n if ( Is.definedFunction( result.object ) ) {\n result.object = result.object();\n }\n \n } catch ( e2: any ) {\n if ( !_configuration.safeMode ) {\n logError( _configuration.text!.objectErrorText!.replace( \"{{error_1}}\", e1.message ).replace( \"{{error_2}}\", e2.message ) );\n result.parsed = false;\n }\n \n result.object = null;\n }\n }\n\n return result;\n }\n\n function logError( error: string ) : boolean {\n let result: boolean = true;\n\n if ( !_configuration.safeMode ) {\n console.error( error );\n result = false;\n }\n\n return result;\n }\n\n\n\t/*\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t * Public API Functions: Helpers: Configuration\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t */\n\n function buildDefaultConfiguration( newConfiguration: any = null ) : void {\n _configuration = Data.getDefaultObject( newConfiguration, {} as Configuration );\n _configuration.safeMode = Data.getDefaultBoolean( _configuration.safeMode, true );\n _configuration.domElementTypes = Data.getDefaultStringOrArray( _configuration.domElementTypes, [ \"*\" ] );\n\n buildDefaultConfigurationStrings();\n }\n\n function buildDefaultConfigurationStrings() : void {\n _configuration.text = Data.getDefaultObject( _configuration.text, {} as ConfigurationText );\n _configuration.text!.objectErrorText = Data.getDefaultString( _configuration.text!.objectErrorText, \"Errors in object: {{error_1}}, {{error_2}}\" );\n _configuration.text!.attributeNotValidErrorText = Data.getDefaultString( _configuration.text!.attributeNotValidErrorText, \"The attribute '{{attribute_name}}' is not a valid object.\" );\n _configuration.text!.attributeNotSetErrorText = Data.getDefaultString( _configuration.text!.attributeNotSetErrorText, \"The attribute '{{attribute_name}}' has not been set correctly.\" ); \n }\n\n\n\t/*\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t * Public API Functions:\n\t * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n\t */\n\n const _public: PublicApi = {\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Watching Objects\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n watch: function ( object: any, options: WatchOptions ) : string {\n return createWatch( object, options );\n },\n\n cancelWatch: function ( id: string ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n cancelWatchObject( id );\n \n result = true;\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n cancelWatchObject( storageId );\n \n result = true;\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n cancelWatches: function () : PublicApi {\n cancelWatchesForObjects();\n\n return _public;\n },\n\n getWatch: function ( id: string ) : ObserveWatch {\n let result: ObserveWatch = null!;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n result = _watches[ id ];\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n result = _watches[ storageId ];\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n getWatches: function () : Record {\n return _watches;\n },\n\n pauseWatch: function ( id: string, milliseconds: number ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) && Is.definedNumber( milliseconds ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n result = pauseWatchObject( id, milliseconds );\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n result = pauseWatchObject( storageId, milliseconds );\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n pauseWatches: function ( milliseconds: number ) : PublicApi {\n if ( Is.definedNumber( milliseconds ) ) {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n pauseWatchObject( storageId, milliseconds );\n }\n }\n }\n \n return _public;\n },\n\n resumeWatch: function ( id: string ) : boolean {\n let result: boolean = false;\n\n if ( Is.definedString( id ) ) {\n if ( _watches.hasOwnProperty( id ) ) {\n _watches[ id ].options.starts = null!;\n result = true;\n } else {\n \n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) {\n _watches[ storageId ].options.starts = null!;\n result = true;\n break;\n }\n }\n }\n }\n \n return result;\n },\n\n resumeWatches: function () : PublicApi {\n for ( let storageId in _watches ) {\n if ( _watches.hasOwnProperty( storageId ) ) {\n _watches[ storageId ].options.starts = null!;\n }\n }\n \n return _public;\n },\n\n searchDomForNewWatches: function () : PublicApi {\n collectDOMObjects();\n\n return _public;\n },\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Configuration\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n setConfiguration: function ( newConfiguration: any ) : PublicApi {\n if ( Is.definedObject( newConfiguration ) ) {\n let configurationHasChanged: boolean = false;\n const newInternalConfiguration: any = _configuration;\n \n for ( let propertyName in newConfiguration ) {\n if ( newConfiguration.hasOwnProperty( propertyName ) && _configuration.hasOwnProperty( propertyName ) && newInternalConfiguration[ propertyName ] !== newConfiguration[ propertyName ] ) {\n newInternalConfiguration[ propertyName ] = newConfiguration[ propertyName ];\n configurationHasChanged = true;\n }\n }\n \n if ( configurationHasChanged ) {\n buildDefaultConfiguration( newInternalConfiguration );\n }\n }\n \n return _public;\n },\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Public API Functions: Additional Data\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n getVersion: function () : string {\n return \"1.0.0\";\n }\n };\n\n\n /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n buildDefaultConfiguration();\n\n document.addEventListener( \"DOMContentLoaded\", function() {\n collectDOMObjects();\n } );\n\n window.addEventListener( \"pagehide\", function() {\n _watches_Cancel = true;\n\n cancelWatchesForObjects();\n } );\n\n if ( !Is.defined( window.$observe ) ) {\n window.$observe = _public;\n }\n } )();\n} )();"]}
\ No newline at end of file
diff --git a/dist/observe.min.js b/dist/observe.min.js
index 0156756..6fd0afe 100644
--- a/dist/observe.min.js
+++ b/dist/observe.min.js
@@ -1,14 +1 @@
-/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */
-(function(){function P(){for(var a=g.domElementTypes,b=a.length,c=0;c=k.starts){if(d.hasOwnProperty(l)){var e=d[l],p=m(e.domElementId),q=null;p&&(q=C.getElementById(e.domElementId),t(q)?e.originalObject=q.outerHTML:(e.originalObject=G.empty,v(e.options.onRemove,e.domElementId)));var y=e.cachedObject,r=e.originalObject;r=p?r:x.stringify(r);if(y!==r){e.options.reset?p?q.outerHTML=e.cachedObject:e.originalObject=E(y).result:e.cachedObject=r;if(p)v(e.options.onChange,y,r);else if(p=E(y).result,q=E(r).result,z(p)||z(q))v(e.options.onChange,p,q);else{if(z(e.options.propertyNames))for(y=
-e.options.propertyNames.length,r=0;r=e.options.maximumChangesBeforeCanceling&&A(l)}}F(k.expires)&&w>=k.expires&&A(l)}},k.timeout),d[f]=b)}return f}function U(a,b,c){for(var f in a)if(a.hasOwnProperty(f)){var k=
-a[f],n=null;b.hasOwnProperty(f)&&(n=b[f]);u(k)&&u(n)?U(k,n,c.options):(!z(c.options.propertyNames)||-1b;b++){8!==b&&12!==b&&16!==b&&20!==b||a.push("-");var c=M.floor(16*M.random()).toString(16);a.push(c)}return a.join(G.empty)}function t(a){return null!==a&&void 0!==a&&a!==G.empty}function u(a){return t(a)&&"object"===typeof a}function m(a){return t(a)&&
-"string"===typeof a}function H(a){return t(a)&&"function"===typeof a}function N(a){return t(a)&&"number"===typeof a}function z(a){return u(a)&&a instanceof Array}function F(a){return u(a)&&a instanceof Date}function B(a,b){return t(a)&&"boolean"===typeof a?a:b}function D(a,b){return H(a)?a:b}function L(a,b){return N(a)?a:b}function O(a,b){return m(a)?a:b}function E(a){var b=!0,c=null;try{m(a)&&(c=x.parse(a))}catch(f){try{c=eval("("+a+")"),H(c)&&(c=c())}catch(k){b=K(g.objectErrorText.replace("{{error_1}}",
-f.message).replace("{{error_2}}",k.message)),c=null}}return{parsed:b,result:c}}function K(a){var b=!0;g.safeMode||(console.error(a),b=!1);return b}function X(a){g=u(a)?a:{};g.safeMode=B(g.safeMode,!0);a=g;var b=g.domElementTypes,c=["*"];m(b)?(b=b.split(G.space),0===b.length&&(b=c)):b=z(b)?b:c;a.domElementTypes=b;g.objectErrorText=O(g.objectErrorText,"Errors in object: {{error_1}}, {{error_2}}");g.attributeNotValidErrorText=O(g.attributeNotValidErrorText,"The attribute '{{attribute_name}}' is not a valid object.");
-g.attributeNotSetErrorText=O(g.attributeNotSetErrorText,"The attribute '{{attribute_name}}' has not been set correctly.")}var C=null,J=null,M=null,x=null,h={},G={empty:""},d={},W=!1,g={};h.watch=function(a,b){return S(a,b)};h.cancelWatch=function(a){var b=!1;if(m(a))if(d.hasOwnProperty(a))A(a),b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&m(d[c].domElementId)&&d[c].domElementId===a){A(c);b=!0;break}return b};h.cancelWatches=function(){V();return h};h.getWatch=function(a){var b=null;if(m(a))if(d.hasOwnProperty(a))b=
-d[a];else for(var c in d)if(d.hasOwnProperty(c)&&m(d[c].domElementId)&&d[c].domElementId===a){b=d[c];break}return b};h.getWatches=function(){return d};h.pauseWatch=function(a,b){var c=!1;if(m(a)&&N(b))if(d.hasOwnProperty(a))c=I(a,b);else for(var f in d)if(d.hasOwnProperty(f)&&m(d[f].domElementId)&&d[f].domElementId===a){c=I(f,b);break}return c};h.pauseWatches=function(a){if(N(a))for(var b in d)d.hasOwnProperty(b)&&I(b,a);return h};h.resumeWatch=function(a){var b=!1;if(m(a))if(d.hasOwnProperty(a))d[a].options.starts=
-null,b=!0;else for(var c in d)if(d.hasOwnProperty(c)&&m(d[c].domElementId)&&d[c].domElementId===a){d[c].options.starts=null;b=!0;break}return b};h.resumeWatches=function(){for(var a in d)d.hasOwnProperty(a)&&(d[a].options.starts=null);return h};h.searchDomForNewWatches=function(){P();return h};h.setConfiguration=function(a){if(u(a)){var b=!1,c;for(c in a)a.hasOwnProperty(c)&&g.hasOwnProperty(c)&&g[c]!==a[c]&&(g[c]=a[c],b=!0);b&&X(g)}return h};h.getVersion=function(){return"0.8.2"};(function(a,b,c,
-f){C=a;J=b;M=c;x=f;X();C.addEventListener("DOMContentLoaded",function(){P()});J.addEventListener("pagehide",function(){W=!0;V()});t(J.$observe)||(J.$observe=h)})(document,window,Math,JSON)})();
\ No newline at end of file
+"use strict";var Constant,Is,Data;(Constant||(Constant={})).OBSERVE_JS_ATTRIBUTE_NAME="data-observe-js",(e=>{function t(e){return null!=e&&""!==e.toString()}function n(e){return t(e)&&"object"==typeof e}e.defined=t,e.definedObject=n,e.definedBoolean=function(e){return t(e)&&"boolean"==typeof e},e.definedString=function(e){return t(e)&&"string"==typeof e},e.definedFunction=function(e){return t(e)&&"function"==typeof e},e.definedNumber=function(e){return t(e)&&"number"==typeof e},e.definedArray=function(e){return n(e)&&e instanceof Array},e.definedDate=function(e){return n(e)&&e instanceof Date}})(Is||(Is={})),(e=>{let t;function n(e,t){return Is.definedArray(e)?e:t}(t=e.String||(e.String={})).newGuid=function(){const e=[];for(let t=0;t<32;t++){8!==t&&12!==t&&16!==t&&20!==t||e.push("-");const n=Math.floor(16*Math.random()).toString(16);e.push(n)}return e.join("")},e.getDefaultAnyString=function(e,t){return"string"==typeof e?e:t},e.getDefaultString=function(e,t){return Is.definedString(e)?e:t},e.getDefaultBoolean=function(e,t){return Is.definedBoolean(e)?e:t},e.getDefaultNumber=function(e,t){return Is.definedNumber(e)?e:t},e.getDefaultFunction=function(e,t){return Is.definedFunction(e)?e:t},e.getDefaultArray=n,e.getDefaultObject=function(e,t){return Is.definedObject(e)?e:t},e.getDefaultDate=function(e,t){return Is.definedDate(e)?e:t},e.getDefaultStringOrArray=function(e,t){let r=t;if(Is.definedString(e)){const n=e.toString().split("space");0===n.length?e=t:r=n}else r=n(e,t);return r}})(Data||(Data={})),(()=>{let _configuration={};const _watches={};let _watches_Cancel=!1;function collectDOMObjects(){const e=_configuration.domElementTypes,t=e.length;for(let n=0;n=e.starts)&&(watchObjectForChanges(t),Is.definedDate(e.expires)&&n>=e.expires&&cancelWatchObject(t))}function watchObjectForChanges(e){if(_watches.hasOwnProperty(e)){const t=_watches[e],n=Is.definedString(t.domElementId);let r=null;n&&(r=document.getElementById(t.domElementId),Is.defined(r)?t.originalObject=r.outerHTML:(t.originalObject="",fireCustomTriggerEvent(t.options.events.onRemove,t.domElementId)));const o=t.cachedObject,a=t.originalObject,i=n?a:JSON.stringify(a);if(o!==i){if(t.options.reset?n?r.outerHTML=t.cachedObject:t.originalObject=getObjectFromString(o).object:t.cachedObject=i,n)fireCustomTriggerEvent(t.options.events.onChange,o,i);else{const e=getObjectFromString(o).object,n=getObjectFromString(i).object;Is.definedArray(e)||Is.definedArray(n)?fireCustomTriggerEvent(t.options.events.onChange,e,n):(compareWatchObject(e,n,t),Is.definedFunction(t.options.events.onPropertyChange)&&compareWatchObjectProperties(e,n,t))}t.totalChanges++,t.options.pauseTimeoutOnChange>0&&pauseWatchObject(e,t.options.pauseTimeoutOnChange),t.options.cancelOnChange&&cancelWatchObject(e),t.options.maximumChangesBeforeCanceling>0&&t.totalChanges>=t.options.maximumChangesBeforeCanceling&&cancelWatchObject(e)}}}function compareWatchObject(e,t,n){if(Is.definedArray(n.options.propertyNames)){const r=n.options.propertyNames.length;for(let o=0;o-1)&&JSON.stringify(o)!==JSON.stringify(a)&&fireCustomTriggerEvent(n.options.events.onPropertyChange,r,o,a)}}function cancelWatchesForObjects(){for(let e in _watches)_watches.hasOwnProperty(e)&&cancelWatchObject(e)}function cancelWatchObject(e){if(_watches.hasOwnProperty(e)){const t=_watches[e].options;(t.allowCanceling||_watches_Cancel)&&(fireCustomTriggerEvent(t.events.onCancel,e),clearInterval(_watches[e].timer),delete _watches[e])}}function pauseWatchObject(e,t){let n=!1;if(_watches.hasOwnProperty(e)){const r=_watches[e].options;r.allowPausing&&(r.starts=new Date,r.starts.setMilliseconds(r.starts.getMilliseconds()+t),n=!0)}return n}function getWatchOptions(e){let t=Data.getDefaultObject(e,{});return t.timeout=Data.getDefaultNumber(t.timeout,250),t.starts=Data.getDefaultDate(t.starts,null),t.expires=Data.getDefaultDate(t.expires,null),t.reset=Data.getDefaultBoolean(t.reset,!1),t.cancelOnChange=Data.getDefaultBoolean(t.cancelOnChange,!1),t.maximumChangesBeforeCanceling=Data.getDefaultNumber(t.maximumChangesBeforeCanceling,0),t.pauseTimeoutOnChange=Data.getDefaultNumber(t.pauseTimeoutOnChange,0),t.propertyNames=Data.getDefaultArray(t.propertyNames,null),t.allowCanceling=Data.getDefaultBoolean(t.allowCanceling,!0),t.allowPausing=Data.getDefaultBoolean(t.allowPausing,!0),t.removeAttribute=Data.getDefaultBoolean(t.removeAttribute,!0),t=getWatchOptionsCustomTriggers(t),t}function getWatchOptionsCustomTriggers(e){return e.events=Data.getDefaultObject(e.events,{}),e.events.onChange=Data.getDefaultFunction(e.events.onChange,null),e.events.onPropertyChange=Data.getDefaultFunction(e.events.onPropertyChange,null),e.events.onCancel=Data.getDefaultFunction(e.events.onCancel,null),e.events.onRemove=Data.getDefaultFunction(e.events.onRemove,null),e.events.onStart=Data.getDefaultFunction(e.events.onStart,null),e}function fireCustomTriggerEvent(e,...t){Is.definedFunction(e)&&e.apply(null,[].slice.call(t,0))}function getObjectFromString(objectString){const result={parsed:!0,object:null};try{Is.definedString(objectString)&&(result.object=JSON.parse(objectString))}catch(e1){try{result.object=eval(`(${objectString})`),Is.definedFunction(result.object)&&(result.object=result.object())}catch(e){_configuration.safeMode||(logError(_configuration.text.objectErrorText.replace("{{error_1}}",e1.message).replace("{{error_2}}",e.message)),result.parsed=!1),result.object=null}}return result}function logError(e){let t=!0;return _configuration.safeMode||(console.error(e),t=!1),t}function buildDefaultConfiguration(e=null){_configuration=Data.getDefaultObject(e,{}),_configuration.safeMode=Data.getDefaultBoolean(_configuration.safeMode,!0),_configuration.domElementTypes=Data.getDefaultStringOrArray(_configuration.domElementTypes,["*"]),buildDefaultConfigurationStrings()}function buildDefaultConfigurationStrings(){_configuration.text=Data.getDefaultObject(_configuration.text,{}),_configuration.text.objectErrorText=Data.getDefaultString(_configuration.text.objectErrorText,"Errors in object: {{error_1}}, {{error_2}}"),_configuration.text.attributeNotValidErrorText=Data.getDefaultString(_configuration.text.attributeNotValidErrorText,"The attribute '{{attribute_name}}' is not a valid object."),_configuration.text.attributeNotSetErrorText=Data.getDefaultString(_configuration.text.attributeNotSetErrorText,"The attribute '{{attribute_name}}' has not been set correctly.")}const _public={watch:function(e,t){return createWatch(e,t)},cancelWatch:function(e){let t=!1;if(Is.definedString(e))if(_watches.hasOwnProperty(e))cancelWatchObject(e),t=!0;else for(let n in _watches)if(_watches.hasOwnProperty(n)&&Is.definedString(_watches[n].domElementId)&&_watches[n].domElementId===e){cancelWatchObject(n),t=!0;break}return t},cancelWatches:function(){return cancelWatchesForObjects(),_public},getWatch:function(e){let t=null;if(Is.definedString(e))if(_watches.hasOwnProperty(e))t=_watches[e];else for(let n in _watches)if(_watches.hasOwnProperty(n)&&Is.definedString(_watches[n].domElementId)&&_watches[n].domElementId===e){t=_watches[n];break}return t},getWatches:function(){return _watches},pauseWatch:function(e,t){let n=!1;if(Is.definedString(e)&&Is.definedNumber(t))if(_watches.hasOwnProperty(e))n=pauseWatchObject(e,t);else for(let r in _watches)if(_watches.hasOwnProperty(r)&&Is.definedString(_watches[r].domElementId)&&_watches[r].domElementId===e){n=pauseWatchObject(r,t);break}return n},pauseWatches:function(e){if(Is.definedNumber(e))for(let t in _watches)_watches.hasOwnProperty(t)&&pauseWatchObject(t,e);return _public},resumeWatch:function(e){let t=!1;if(Is.definedString(e))if(_watches.hasOwnProperty(e))_watches[e].options.starts=null,t=!0;else for(let n in _watches)if(_watches.hasOwnProperty(n)&&Is.definedString(_watches[n].domElementId)&&_watches[n].domElementId===e){_watches[n].options.starts=null,t=!0;break}return t},resumeWatches:function(){for(let e in _watches)_watches.hasOwnProperty(e)&&(_watches[e].options.starts=null);return _public},searchDomForNewWatches:function(){return collectDOMObjects(),_public},setConfiguration:function(e){if(Is.definedObject(e)){let t=!1;const n=_configuration;for(let r in e)e.hasOwnProperty(r)&&_configuration.hasOwnProperty(r)&&n[r]!==e[r]&&(n[r]=e[r],t=!0);t&&buildDefaultConfiguration(n)}return _public},getVersion:function(){return"1.0.0"}};buildDefaultConfiguration(),document.addEventListener("DOMContentLoaded",(function(){collectDOMObjects()})),window.addEventListener("pagehide",(function(){_watches_Cancel=!0,cancelWatchesForObjects()})),Is.defined(window.$observe)||(window.$observe=_public)})();
\ No newline at end of file
diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md
index 23e99ef..24ed495 100644
--- a/docs/CHANGE_LOG.md
+++ b/docs/CHANGE_LOG.md
@@ -1,5 +1,29 @@
# Observe.js - Change Log:
+## Version 1.0.0:
+
+#### **Language Shift:**
+- The entire project has been rewritten in TypeScript, allowing all components to be exported, which allows better support for libraries such as React, Angular, etc.
+- Added CDN links for the minimized version of the files.
+- The TypeScript code is compiled to ES2016 instead of ES5 (older browsers, such as IE, are no longer supported).
+
+#### **Building:**
+- You can now run separate builds to produce CJS, ESM, and Minimized project versions.
+- All files not required for the NPM packages have now been excluded.
+
+#### **Watch Options:**
+- BREAKING: All the event custom triggers are now under a new section called "events".
+
+#### **Configuration Options:**
+- BREAKING: All the text options are now under a new section called "text".
+
+#### **Testing:**
+- Removed the "src" and "dist" folders under "test". Only the dist versions remain, removing duplication.
+- Added "BUILD_INSTRUCTIONS.md" to help first-time users set up their dev environments.
+
+
+
+
## Version 0.8.2:
- Added export support for the global "$observe" object, which can now be imported as "observe.js".
- BREAKING: Renamed the binding attribute "data-observe-watch-options" to "data-observe-js".
diff --git a/docs/binding/options/CUSTOM_TRIGGERS.md b/docs/binding/options/CUSTOM_TRIGGERS.md
index b722d31..1f9ba04 100644
--- a/docs/binding/options/CUSTOM_TRIGGERS.md
+++ b/docs/binding/options/CUSTOM_TRIGGERS.md
@@ -7,7 +7,7 @@ Below is a list of all the custom triggers supported in the "data-observe-js" bi
## When Changes Are Detected:
-### options.onChange( *oldValue*, *newValue* ):
+### options.events.onChange( *oldValue*, *newValue* ):
Fires when a change has been detected in an object.
***Parameter:*** oldValue: '*object*' - The old value for the object.
@@ -15,7 +15,7 @@ Fires when a change has been detected in an object.
***Parameter:*** newValue: '*object*' - The new value for the object.
-### options.onPropertyChange( *propertyName*, *oldValue*, *newValue* ):
+### options.events.onPropertyChange( *propertyName*, *oldValue*, *newValue* ):
Fires when a change has been detected in an object (states which property changed).
***Parameter:*** propertyName: '*string*' - The name of the property that has been changed.
@@ -25,19 +25,19 @@ Fires when a change has been detected in an object (states which property change
***Parameter:*** newValue: '*object*' - The new value.
-### options.onCancel( *id* ):
+### options.events.onCancel( *id* ):
Fires when a watch has been cancelled.
***Parameter:*** id: '*string*' - The ID of the watch that has been cancelled.
-### options.onRemove( *id* ):
+### options.events.onRemove( *id* ):
Fires when a DOM element is no longer available in the DOM.
***Parameter:*** id: '*string*' - The ID of the DOM element.
-### options.onStart( *originalValue* ):
+### options.events.onStart( *originalValue* ):
Fires when a watch is started.
***Parameter:*** id: '*object*' - The object that the watch as started for.
@@ -48,7 +48,7 @@ Fires when a watch is started.
## Binding Example:
```markdown
-