From 8d63a9875a58c1e0608c486f907e4b6106bcece6 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:02:46 +0100 Subject: [PATCH 01/28] Updated to v1.0.0. --- README.md | 6 +++--- README_NUGET.md | 6 +++--- dist/observe.export.js | 2 +- dist/observe.export.min.js | 2 +- dist/observe.js | 4 ++-- dist/observe.min.js | 4 ++-- docs/CHANGE_LOG.md | 6 ++++++ observe.js.nuspec | 2 +- package.json | 2 +- src/observe.export.js | 2 +- src/observe.js | 4 ++-- 11 files changed, 23 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index 772f481..f074ed6 100644 --- a/README.md +++ b/README.md @@ -2,15 +2,15 @@ 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



diff --git a/README_NUGET.md b/README_NUGET.md index b1cf847..a637031 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/) diff --git a/dist/observe.export.js b/dist/observe.export.js index e5f874e..80ef507 100644 --- a/dist/observe.export.js +++ b/dist/observe.export.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */ +/*! Observe.js v1.0.0 | (c) Bunoon 2024 | MIT License */ var observe = {js:function() { return window.$observe; }}; diff --git a/dist/observe.export.min.js b/dist/observe.export.min.js index ee28274..6ed273c 100644 --- a/dist/observe.export.min.js +++ b/dist/observe.export.min.js @@ -1,2 +1,2 @@ -/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */ +/*! Observe.js v1.0.0 | (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..aec4ae8 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */ +/*! Observe.js v1.0.0 | (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() { @@ -438,7 +438,7 @@ _configuration.attributeNotSetErrorText = getDefaultString(_configuration.attributeNotSetErrorText, "The attribute '{{attribute_name}}' has not been set correctly."); } _public.getVersion = function() { - return "0.8.2"; + return "1.0.0"; }; (function(documentObject, windowObject, mathObject, jsonObject) { _parameter_Document = documentObject; diff --git a/dist/observe.min.js b/dist/observe.min.js index 0156756..a985ffc 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,4 +1,4 @@ -/*! Observe.js v0.8.2 | (c) Bunoon 2024 | MIT License */ +/*! Observe.js v1.0.0 | (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= @@ -10,5 +10,5 @@ b),c=!0));return c}function Q(a){var b={};a=u(a)?a:b;a.timeout=L(a.timeout,250); 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, +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"1.0.0"};(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 diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 23e99ef..5d598a6 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -1,5 +1,11 @@ # Observe.js - Change Log: +## Version 1.0.0: +- + +
+ + ## 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/observe.js.nuspec b/observe.js.nuspec index d0fabfb..542ed79 100644 --- a/observe.js.nuspec +++ b/observe.js.nuspec @@ -2,7 +2,7 @@ jObserve.js - 0.8.2 + 1.0.0 Observe.js A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. William Troup diff --git a/package.json b/package.json index 92bde17..6a35265 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "jobserve.js", "title": "Observe.js", "description": "A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.", - "version": "0.8.2", + "version": "1.0.0", "main": "dist/observe.js", "homepage": "https://www.william-troup.com/observe-js/", "author": { diff --git a/src/observe.export.js b/src/observe.export.js index dc8cb93..ae0517b 100644 --- a/src/observe.export.js +++ b/src/observe.export.js @@ -4,7 +4,7 @@ * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. * * @file observe.js - * @version v0.8.2 + * @version v1.0.0 * @author Bunoon * @license MIT License * @copyright Bunoon 2024 diff --git a/src/observe.js b/src/observe.js index 9cffe3d..df5bda1 100644 --- a/src/observe.js +++ b/src/observe.js @@ -4,7 +4,7 @@ * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. * * @file observe.js - * @version v0.8.2 + * @version v1.0.0 * @author Bunoon * @license MIT License * @copyright Bunoon 2024 @@ -821,7 +821,7 @@ * @returns {string} The version number. */ _public.getVersion = function() { - return "0.8.2"; + return "1.0.0"; }; From 9b346de2b3398196df999ffc81e390c1d883fd54 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:03:02 +0100 Subject: [PATCH 02/28] Deleted export files. --- dist/observe.export.js | 6 ------ dist/observe.export.min.js | 2 -- src/observe.export.js | 22 ---------------------- 3 files changed, 30 deletions(-) delete mode 100644 dist/observe.export.js delete mode 100644 dist/observe.export.min.js delete mode 100644 src/observe.export.js diff --git a/dist/observe.export.js b/dist/observe.export.js deleted file mode 100644 index 80ef507..0000000 --- a/dist/observe.export.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! Observe.js v1.0.0 | (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 6ed273c..0000000 --- a/dist/observe.export.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! Observe.js v1.0.0 | (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/src/observe.export.js b/src/observe.export.js deleted file mode 100644 index ae0517b..0000000 --- a/src/observe.export.js +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Observe.js - * - * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. - * - * @file observe.js - * @version v1.0.0 - * @author Bunoon - * @license MIT License - * @copyright Bunoon 2024 - */ - - -var observe = { - js: function() { - return window.$observe; - } -}; - -Object.assign( window, { observe } ); - -export { observe }; \ No newline at end of file From 32c412f2c1255aac455832cc58e62c386520b0be Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:03:52 +0100 Subject: [PATCH 03/28] Removed src testing files, and moved dist back a level. --- test/dist/observe.js.basic.html | 147 --------------------------- test/{src => }/observe.js.basic.html | 4 +- test/{dist => }/observe.js.min.html | 4 +- 3 files changed, 4 insertions(+), 151 deletions(-) delete mode 100644 test/dist/observe.js.basic.html rename test/{src => }/observe.js.basic.html (98%) rename test/{dist => }/observe.js.min.html (97%) diff --git a/test/dist/observe.js.basic.html b/test/dist/observe.js.basic.html deleted file mode 100644 index 0ca7803..0000000 --- a/test/dist/observe.js.basic.html +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - Observe.js - Basic - - - - - -
-

Observe.js - Basic

-

This is a basic example of how to use Observe.js to watch HTML DOM elements, and JS objects.

-
- -
-
- When changed, this element should fire a custom trigger. -
- -
- When changed, this element should fire a custom trigger (and reset its value back to the original). -
-
- -
-

Watch:

- -
- -

Cancel Watch:

- - -
- -

Cancel Watches:

- -
- -

Pause Watch:

- - -
- -

Pause Watches:

- -
- -

Resume Watch:

- - -
- -

Resume Watches:

- -
- -

Get Watch:

- - -
- -

Get Watches:

- -
- -

Change Object Values:

- - - -
- -
- - -
- -

Configuration:

- -
- -

Additional Data:

- -
- - - - \ No newline at end of file diff --git a/test/src/observe.js.basic.html b/test/observe.js.basic.html similarity index 98% rename from test/src/observe.js.basic.html rename to test/observe.js.basic.html index 05a1808..d8cb180 100644 --- a/test/src/observe.js.basic.html +++ b/test/observe.js.basic.html @@ -4,8 +4,8 @@ Observe.js - Basic - - + + diff --git a/test/dist/observe.js.min.html b/test/observe.js.min.html similarity index 97% rename from test/dist/observe.js.min.html rename to test/observe.js.min.html index 0ffed75..43d6002 100644 --- a/test/dist/observe.js.min.html +++ b/test/observe.js.min.html @@ -4,8 +4,8 @@ Observe.js - Minimized - - + + From ef1c0d7f6cb295347ac5e865d8ed66bb8cc3abcf Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:39:20 +0100 Subject: [PATCH 04/28] Updated gitignore and NuGet pack nuspec file. --- .gitignore | 2 ++ observe.js.nuspec | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) 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/observe.js.nuspec b/observe.js.nuspec index 542ed79..fe6502c 100644 --- a/observe.js.nuspec +++ b/observe.js.nuspec @@ -15,6 +15,6 @@ William Troup
- +
\ No newline at end of file From 3ecc0b1a8d1ae5a2b6ffe0fa7f3aa313c260d566 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:40:26 +0100 Subject: [PATCH 05/28] Added TypeScript support and config files. --- .npmignore | 19 +++++++++ BUILD_INSTRUCTIONS.md | 83 ++++++++++++++++++++++++++++++++++++++++ tsconfig.json | 23 +++++++++++ tsup.build.config.ts | 28 ++++++++++++++ tsup.build.esm.config.ts | 33 ++++++++++++++++ tsup.build.min.config.ts | 33 ++++++++++++++++ 6 files changed, 219 insertions(+) create mode 100644 .npmignore create mode 100644 BUILD_INSTRUCTIONS.md create mode 100644 tsconfig.json create mode 100644 tsup.build.config.ts create mode 100644 tsup.build.esm.config.ts create mode 100644 tsup.build.min.config.ts 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/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..363f865 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "target": "ES2016", + "module": "ESNext", + "moduleResolution": "node", + "declaration": true, + "outDir": "./build", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "skipLibCheck": true, + "removeComments": true, + "sourceMap": true, + "strict": true + }, + "include": [ + "src/**/*.ts" + ], + "exclude": [ + "node_modules", + "dist", + "**/*.test.ts" + ] +} \ No newline at end of file diff --git a/tsup.build.config.ts b/tsup.build.config.ts new file mode 100644 index 0000000..e4d70ff --- /dev/null +++ b/tsup.build.config.ts @@ -0,0 +1,28 @@ +import { defineConfig } from "tsup"; + + +export default defineConfig( [ + { + entry: [ + "src/observe.ts" + ], + platform: "neutral", + format: [ + "cjs" + ], + outDir: "./dist", + dts: true, + splitting: false, + sourcemap: true, + clean: false, + minify: "terser", + terserOptions: { + compress: false, + sourceMap: true, + format: { + beautify: true, + comments: false + } + } + } +] ); \ No newline at end of file diff --git a/tsup.build.esm.config.ts b/tsup.build.esm.config.ts new file mode 100644 index 0000000..c554c16 --- /dev/null +++ b/tsup.build.esm.config.ts @@ -0,0 +1,33 @@ +import { defineConfig } from "tsup"; + + +export default defineConfig( [ + { + entry: [ + "src/observe.ts" + ], + platform: "neutral", + outExtension({ format }) { + return { + js: `.${format}.js`, + }; + }, + format: [ + "esm" + ], + outDir: "./dist", + dts: true, + splitting: false, + sourcemap: true, + clean: false, + minify: "terser", + terserOptions: { + compress: false, + sourceMap: true, + format: { + beautify: true, + comments: false + } + } + } +] ); \ No newline at end of file diff --git a/tsup.build.min.config.ts b/tsup.build.min.config.ts new file mode 100644 index 0000000..94890e2 --- /dev/null +++ b/tsup.build.min.config.ts @@ -0,0 +1,33 @@ +import { defineConfig } from "tsup"; + + +export default defineConfig( [ + { + entry: [ + "src/observe.ts" + ], + outExtension({ }) { + return { + js: ".min.js", + }; + }, + platform: "neutral", + format: [ + "cjs" + ], + outDir: "./dist", + dts: false, + splitting: false, + sourcemap: false, + clean: false, + minify: "terser", + terserOptions: { + compress: true, + sourceMap: false, + format: { + comments: false, + shorthand: true + } + } + } +] ); \ No newline at end of file From fd4fee929ea7b75ddd2b4c759a6fe31d728aa6a6 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:43:12 +0100 Subject: [PATCH 06/28] Added packages. --- package-lock.json | 2515 +++++++++++++++++++++++++++++++++++++++++++++ package.json | 22 +- 2 files changed, 2534 insertions(+), 3 deletions(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..b2e66a2 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2515 @@ +{ + "name": "jobserve.js", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "jobserve.js", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "typescript": "^5.5.3" + }, + "devDependencies": { + "@swc/core": "^1.6.13", + "terser": "^5.31.2", + "tsup": "^8.1.0" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.21.5.tgz", + "integrity": "sha512-1SDgH6ZSPTlggy1yI6+Dbkiz8xzpHJEVAlF/AM1tHPLsf5STom9rwtjE4hKAF20FfXXNTFqEYXyJNWh1GiZedQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.21.5.tgz", + "integrity": "sha512-vCPvzSjpPHEi1siZdlvAlsPxXl7WbOVUBBAowWug4rJHb68Ox8KualB+1ocNvT5fjv6wpkX6o/iEpbDrf68zcg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.21.5.tgz", + "integrity": "sha512-c0uX9VAUBQ7dTDCjq+wdyGLowMdtR/GoC2U5IYk/7D1H1JYC0qseD7+11iMP2mRLN9RcCMRcjC4YMclCzGwS/A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.21.5.tgz", + "integrity": "sha512-D7aPRUUNHRBwHxzxRvp856rjUHRFW1SdQATKXH2hqA0kAZb1hKmi02OpYRacl0TxIGz/ZmXWlbZgjwWYaCakTA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.21.5.tgz", + "integrity": "sha512-DwqXqZyuk5AiWWf3UfLiRDJ5EDd49zg6O9wclZ7kUMv2WRFr4HKjXp/5t8JZ11QbQfUS6/cRCKGwYhtNAY88kQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.21.5.tgz", + "integrity": "sha512-se/JjF8NlmKVG4kNIuyWMV/22ZaerB+qaSi5MdrXtd6R08kvs2qCN4C09miupktDitvh8jRFflwGFBQcxZRjbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.21.5.tgz", + "integrity": "sha512-5JcRxxRDUJLX8JXp/wcBCy3pENnCgBR9bN6JsY4OmhfUtIHe3ZW0mawA7+RDAcMLrMIZaf03NlQiX9DGyB8h4g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.21.5.tgz", + "integrity": "sha512-J95kNBj1zkbMXtHVH29bBriQygMXqoVQOQYA+ISs0/2l3T9/kj42ow2mpqerRBxDJnmkUDCaQT/dfNXWX/ZZCQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.21.5.tgz", + "integrity": "sha512-bPb5AHZtbeNGjCKVZ9UGqGwo8EUu4cLq68E95A53KlxAPRmUyYv2D6F0uUI65XisGOL1hBP5mTronbgo+0bFcA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.21.5.tgz", + "integrity": "sha512-ibKvmyYzKsBeX8d8I7MH/TMfWDXBF3db4qM6sy+7re0YXya+K1cem3on9XgdT2EQGMu4hQyZhan7TeQ8XkGp4Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.21.5.tgz", + "integrity": "sha512-YvjXDqLRqPDl2dvRODYmmhz4rPeVKYvppfGYKSNGdyZkA01046pLWyRKKI3ax8fbJoK5QbxblURkwK/MWY18Tg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.21.5.tgz", + "integrity": "sha512-uHf1BmMG8qEvzdrzAqg2SIG/02+4/DHB6a9Kbya0XDvwDEKCoC8ZRWI5JJvNdUjtciBGFQ5PuBlpEOXQj+JQSg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.21.5.tgz", + "integrity": "sha512-IajOmO+KJK23bj52dFSNCMsz1QP1DqM6cwLUv3W1QwyxkyIWecfafnI555fvSGqEKwjMXVLokcV5ygHW5b3Jbg==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.21.5.tgz", + "integrity": "sha512-1hHV/Z4OEfMwpLO8rp7CvlhBDnjsC3CttJXIhBi+5Aj5r+MBvy4egg7wCbe//hSsT+RvDAG7s81tAvpL2XAE4w==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.21.5.tgz", + "integrity": "sha512-2HdXDMd9GMgTGrPWnJzP2ALSokE/0O5HhTUvWIbD3YdjME8JwvSCnNGBnTThKGEB91OZhzrJ4qIIxk/SBmyDDA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.21.5.tgz", + "integrity": "sha512-zus5sxzqBJD3eXxwvjN1yQkRepANgxE9lgOW2qLnmr8ikMTphkjgXu1HR01K4FJg8h1kEEDAqDcZQtbrRnB41A==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.21.5.tgz", + "integrity": "sha512-1rYdTpyv03iycF1+BhzrzQJCdOuAOtaqHTWJZCWvijKD2N5Xu0TtVC8/+1faWqcP9iBCWOmjmhoH94dH82BxPQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.21.5.tgz", + "integrity": "sha512-Woi2MXzXjMULccIwMnLciyZH4nCIMpWQAs049KEeMvOcNADVxo0UBIQPfSmxB3CWKedngg7sWZdLvLczpe0tLg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.21.5.tgz", + "integrity": "sha512-HLNNw99xsvx12lFBUwoT8EVCsSvRNDVxNpjZ7bPn947b8gJPzeHWyNVhFsaerc0n3TsbOINvRP2byTZ5LKezow==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.21.5.tgz", + "integrity": "sha512-6+gjmFpfy0BHU5Tpptkuh8+uw3mnrvgs+dSPQXQOv3ekbordwnzTVEb4qnIvQcYXq6gzkyTnoZ9dZG+D4garKg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.21.5.tgz", + "integrity": "sha512-Z0gOTd75VvXqyq7nsl93zwahcTROgqvuAcYDUr+vOv8uHhNSKROyU961kgtCD1e95IqPKSQKH7tBTslnS3tA8A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.21.5.tgz", + "integrity": "sha512-SWXFF1CL2RVNMaVs+BBClwtfZSvDgtL//G/smwAc5oVK/UPu2Gu9tIaRgFmYFFKrmg3SyAjSrElf0TiJ1v8fYA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.21.5.tgz", + "integrity": "sha512-tQd/1efJuzPC6rCFwEvLtci/xNFcTZknmXs98FYDfGE4wP9ClFV98nyKrzJKVPMhdDnjzLhdUyMX4PsQAPjwIw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=12" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.5.tgz", + "integrity": "sha512-IzL8ZoEDIBRWEzlCcRhOaCupYyN5gdIK+Q6fbFdPDg6HqX6jpkItn7DFIpW9LQzXG6Df9sA7+OKnq0qlz/GaQg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/source-map": { + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@jridgewell/source-map/-/source-map-0.3.6.tgz", + "integrity": "sha512-1ZJTZebgqllO79ue2bm3rIGud/bOe0pP5BjSRCRxxYkEZS8STV7zN84UBbiYu7jy+eCKSnVIUgoWWE/tt+shMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.25" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.18.1.tgz", + "integrity": "sha512-lncuC4aHicncmbORnx+dUaAgzee9cm/PbIqgWz1PpXuwc+sa1Ct83tnqUDy/GFKleLiN7ZIeytM6KJ4cAn1SxA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.18.1.tgz", + "integrity": "sha512-F/tkdw0WSs4ojqz5Ovrw5r9odqzFjb5LIgHdHZG65dFI1lWTWRVy32KDJLKRISHgJvqUeUhdIvy43fX41znyDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.18.1.tgz", + "integrity": "sha512-vk+ma8iC1ebje/ahpxpnrfVQJibTMyHdWpOGZ3JpQ7Mgn/3QNHmPq7YwjZbIE7km73dH5M1e6MRRsnEBW7v5CQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.18.1.tgz", + "integrity": "sha512-IgpzXKauRe1Tafcej9STjSSuG0Ghu/xGYH+qG6JwsAUxXrnkvNHcq/NL6nz1+jzvWAnQkuAJ4uIwGB48K9OCGA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.18.1.tgz", + "integrity": "sha512-P9bSiAUnSSM7EmyRK+e5wgpqai86QOSv8BwvkGjLwYuOpaeomiZWifEos517CwbG+aZl1T4clSE1YqqH2JRs+g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.18.1.tgz", + "integrity": "sha512-5RnjpACoxtS+aWOI1dURKno11d7krfpGDEn19jI8BuWmSBbUC4ytIADfROM1FZrFhQPSoP+KEa3NlEScznBTyQ==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.1.tgz", + "integrity": "sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.18.1.tgz", + "integrity": "sha512-dJX9u4r4bqInMGOAQoGYdwDP8lQiisWb9et+T84l2WXk41yEej8v2iGKodmdKimT8cTAYt0jFb+UEBxnPkbXEQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.18.1.tgz", + "integrity": "sha512-V72cXdTl4EI0x6FNmho4D502sy7ed+LuVW6Ym8aI6DRQ9hQZdp5sj0a2usYOlqvFBNKQnLQGwmYnujo2HvjCxQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.18.1.tgz", + "integrity": "sha512-f+pJih7sxoKmbjghrM2RkWo2WHUW8UbfxIQiWo5yeCaCM0TveMEuAzKJte4QskBp1TIinpnRcxkquY+4WuY/tg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.18.1.tgz", + "integrity": "sha512-qb1hMMT3Fr/Qz1OKovCuUM11MUNLUuHeBC2DPPAWUYYUAOFWaxInaTwTQmc7Fl5La7DShTEpmYwgdt2hG+4TEg==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.18.1.tgz", + "integrity": "sha512-7O5u/p6oKUFYjRbZkL2FLbwsyoJAjyeXHCU3O4ndvzg2OFO2GinFPSJFGbiwFDaCFc+k7gs9CF243PwdPQFh5g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.18.1.tgz", + "integrity": "sha512-pDLkYITdYrH/9Cv/Vlj8HppDuLMDUBmgsM0+N+xLtFd18aXgM9Nyqupb/Uw+HeidhfYg2lD6CXvz6CjoVOaKjQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.1.tgz", + "integrity": "sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.18.1.tgz", + "integrity": "sha512-ELfEX1/+eGZYMaCIbK4jqLxO1gyTSOIlZr6pbC4SRYFaSIDVKOnZNMdoZ+ON0mrFDp4+H5MhwNC1H/AhE3zQLg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.1.tgz", + "integrity": "sha512-yjk2MAkQmoaPYCSu35RLJ62+dz358nE83VfTePJRp8CG7aMg25mEJYpXFiD+NcevhX8LxD5OP5tktPXnXN7GDw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@swc/core": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.6.13.tgz", + "integrity": "sha512-eailUYex6fkfaQTev4Oa3mwn0/e3mQU4H8y1WPuImYQESOQDtVrowwUGDSc19evpBbHpKtwM+hw8nLlhIsF+Tw==", + "dev": true, + "hasInstallScript": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3", + "@swc/types": "^0.1.9" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/swc" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "1.6.13", + "@swc/core-darwin-x64": "1.6.13", + "@swc/core-linux-arm-gnueabihf": "1.6.13", + "@swc/core-linux-arm64-gnu": "1.6.13", + "@swc/core-linux-arm64-musl": "1.6.13", + "@swc/core-linux-x64-gnu": "1.6.13", + "@swc/core-linux-x64-musl": "1.6.13", + "@swc/core-win32-arm64-msvc": "1.6.13", + "@swc/core-win32-ia32-msvc": "1.6.13", + "@swc/core-win32-x64-msvc": "1.6.13" + }, + "peerDependencies": { + "@swc/helpers": "*" + }, + "peerDependenciesMeta": { + "@swc/helpers": { + "optional": true + } + } + }, + "node_modules/@swc/core-darwin-arm64": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.6.13.tgz", + "integrity": "sha512-SOF4buAis72K22BGJ3N8y88mLNfxLNprTuJUpzikyMGrvkuBFNcxYtMhmomO0XHsgLDzOJ+hWzcgjRNzjMsUcQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.6.13.tgz", + "integrity": "sha512-AW8akFSC+tmPE6YQQvK9S2A1B8pjnXEINg+gGgw0KRUUXunvu1/OEOeC5L2Co1wAwhD7bhnaefi06Qi9AiwOag==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.6.13.tgz", + "integrity": "sha512-f4gxxvDXVUm2HLYXRd311mSrmbpQF2MZ4Ja6XCQz1hWAxXdhRl1gpnZ+LH/xIfGSwQChrtLLVrkxdYUCVuIjFg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.6.13.tgz", + "integrity": "sha512-Nf/eoW2CbG8s+9JoLtjl9FByBXyQ5cjdBsA4efO7Zw4p+YSuXDgc8HRPC+E2+ns0praDpKNZtLvDtmF2lL+2Gg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.6.13.tgz", + "integrity": "sha512-2OysYSYtdw79prJYuKIiux/Gj0iaGEbpS2QZWCIY4X9sGoETJ5iMg+lY+YCrIxdkkNYd7OhIbXdYFyGs/w5LDg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.6.13.tgz", + "integrity": "sha512-PkR4CZYJNk5hcd2+tMWBpnisnmYsUzazI1O5X7VkIGFcGePTqJ/bWlfUIVVExWxvAI33PQFzLbzmN5scyIUyGQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.6.13.tgz", + "integrity": "sha512-OdsY7wryTxCKwGQcwW9jwWg3cxaHBkTTHi91+5nm7hFPpmZMz1HivJrWAMwVE7iXFw+M4l6ugB/wCvpYrUAAjA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.6.13.tgz", + "integrity": "sha512-ap6uNmYjwk9M/+bFEuWRNl3hq4VqgQ/Lk+ID/F5WGqczNr0L7vEf+pOsRAn0F6EV+o/nyb3ePt8rLhE/wjHpPg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.6.13.tgz", + "integrity": "sha512-IJ8KH4yIUHTnS/U1jwQmtbfQals7zWPG0a9hbEfIr4zI0yKzjd83lmtS09lm2Q24QBWOCFGEEbuZxR4tIlvfzA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.6.13", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.6.13.tgz", + "integrity": "sha512-f6/sx6LMuEnbuxtiSL/EkR0Y6qUHFw1XVrh6rwzKXptTipUdOY+nXpKoh+1UsBm/r7H0/5DtOdrn3q5ZHbFZjQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "Apache-2.0 AND MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/counter": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@swc/counter/-/counter-0.1.3.tgz", + "integrity": "sha512-e2BR4lsJkkRlKZ/qCHPw9ZaSxc0MVUd7gtbtaB7aMvHeJVYe8sOB8DBZkP2DtISHGSku9sCK6T6cnY0CtXrOCQ==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/@swc/types": { + "version": "0.1.9", + "resolved": "https://registry.npmjs.org/@swc/types/-/types-0.1.9.tgz", + "integrity": "sha512-qKnCno++jzcJ4lM4NTfYifm1EFSCeIfKiAHAfkENZAV5Kl9PjJIyd2yeeVv6c/2CckuLyv2NmRC5pv6pm2WQBg==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@swc/counter": "^0.1.3" + } + }, + "node_modules/@types/estree": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", + "dev": true, + "license": "MIT" + }, + "node_modules/acorn": { + "version": "8.12.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.12.1.tgz", + "integrity": "sha512-tcpGyI9zbizT9JbV6oYE477V6mTlXvvi0T0G3SNIYE2apm/G5huBa1+K89VGeovbg+jycCrfhl3ADxErOuO6Jg==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/any-promise": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/any-promise/-/any-promise-1.3.0.tgz", + "integrity": "sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==", + "dev": true, + "license": "MIT" + }, + "node_modules/anymatch": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", + "integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==", + "dev": true, + "license": "ISC", + "dependencies": { + "normalize-path": "^3.0.0", + "picomatch": "^2.0.4" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/array-union": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", + "integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/binary-extensions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz", + "integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/braces": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz", + "integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==", + "dev": true, + "license": "MIT", + "dependencies": { + "fill-range": "^7.1.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/buffer-from": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz", + "integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/bundle-require": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/bundle-require/-/bundle-require-4.2.1.tgz", + "integrity": "sha512-7Q/6vkyYAwOmQNRw75x+4yRtZCZJXUDmHHlFdkiV0wgv/reNjtJwpu1jPJ0w2kbEpIM0uoKI3S4/f39dU7AjSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "load-tsconfig": "^0.2.3" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "peerDependencies": { + "esbuild": ">=0.17" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/chokidar": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", + "integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "anymatch": "~3.1.2", + "braces": "~3.0.2", + "glob-parent": "~5.1.2", + "is-binary-path": "~2.1.0", + "is-glob": "~4.0.1", + "normalize-path": "~3.0.0", + "readdirp": "~3.6.0" + }, + "engines": { + "node": ">= 8.10.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + }, + "optionalDependencies": { + "fsevents": "~2.3.2" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/commander": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/commander/-/commander-4.1.1.tgz", + "integrity": "sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.5", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", + "integrity": "sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/dir-glob": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz", + "integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.21.5", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", + "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=12" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.21.5", + "@esbuild/android-arm": "0.21.5", + "@esbuild/android-arm64": "0.21.5", + "@esbuild/android-x64": "0.21.5", + "@esbuild/darwin-arm64": "0.21.5", + "@esbuild/darwin-x64": "0.21.5", + "@esbuild/freebsd-arm64": "0.21.5", + "@esbuild/freebsd-x64": "0.21.5", + "@esbuild/linux-arm": "0.21.5", + "@esbuild/linux-arm64": "0.21.5", + "@esbuild/linux-ia32": "0.21.5", + "@esbuild/linux-loong64": "0.21.5", + "@esbuild/linux-mips64el": "0.21.5", + "@esbuild/linux-ppc64": "0.21.5", + "@esbuild/linux-riscv64": "0.21.5", + "@esbuild/linux-s390x": "0.21.5", + "@esbuild/linux-x64": "0.21.5", + "@esbuild/netbsd-x64": "0.21.5", + "@esbuild/openbsd-x64": "0.21.5", + "@esbuild/sunos-x64": "0.21.5", + "@esbuild/win32-arm64": "0.21.5", + "@esbuild/win32-ia32": "0.21.5", + "@esbuild/win32-x64": "0.21.5" + } + }, + "node_modules/execa": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", + "integrity": "sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.3", + "get-stream": "^6.0.0", + "human-signals": "^2.1.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^4.0.1", + "onetime": "^5.1.2", + "signal-exit": "^3.0.3", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sindresorhus/execa?sponsor=1" + } + }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, + "node_modules/fill-range": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz", + "integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==", + "dev": true, + "license": "MIT", + "dependencies": { + "to-regex-range": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/foreground-child": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.2.1.tgz", + "integrity": "sha512-PXUUyLqrR2XCWICfv6ukppP96sdFwWbNEnfEMt7jNsISjMsvaLNinAHNDYyvkyU+SZG2BTSbT5NjG+vZslfGTA==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/foreground-child/node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/get-stream": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-6.0.1.tgz", + "integrity": "sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/globby": { + "version": "11.1.0", + "resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz", + "integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^2.1.0", + "dir-glob": "^3.0.1", + "fast-glob": "^3.2.9", + "ignore": "^5.2.0", + "merge2": "^1.4.1", + "slash": "^3.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/human-signals": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/human-signals/-/human-signals-2.1.0.tgz", + "integrity": "sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=10.17.0" + } + }, + "node_modules/ignore": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.1.tgz", + "integrity": "sha512-5Fytz/IraMjqpwfd34ke28PTVMjZjJG2MPn5t7OE4eUCUNf8BAa7b5WUS9/Qvr6mwOQS7Mk6vdsMno5he+T8Xw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/is-binary-path": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", + "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "dev": true, + "license": "MIT", + "dependencies": { + "binary-extensions": "^2.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/joycon": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/joycon/-/joycon-3.1.1.tgz", + "integrity": "sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + } + }, + "node_modules/lilconfig": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/lilconfig/-/lilconfig-3.1.2.tgz", + "integrity": "sha512-eop+wDAvpItUys0FWkHIKeC9ybYrTGbU41U5K7+bttZZeohvnY7M9dZ5kB21GNWiFT2q1OoPTvncPCgSOVO5ow==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antonk52" + } + }, + "node_modules/lines-and-columns": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", + "integrity": "sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==", + "dev": true, + "license": "MIT" + }, + "node_modules/load-tsconfig": { + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/load-tsconfig/-/load-tsconfig-0.2.5.tgz", + "integrity": "sha512-IXO6OCs9yg8tMKzfPZ1YmheJbZCiEsnBdcB03l0OcfK9prKnJb96siuHCr5Fl37/yo9DnKU+TLpxzTUspw9shg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + } + }, + "node_modules/lodash.sortby": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", + "integrity": "sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/merge-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true, + "license": "MIT" + }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/micromatch": { + "version": "4.0.7", + "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.7.tgz", + "integrity": "sha512-LPP/3KorzCwBxfeUuZmaR6bG2kdeHSbe0P2tY3FLRU4vYrjYz5hI4QZwV0njUx3jeuKe67YukQ1LSPZBKDqO/Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "braces": "^3.0.3", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=8.6" + } + }, + "node_modules/mimic-fn": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-2.1.0.tgz", + "integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true, + "license": "MIT" + }, + "node_modules/mz": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/mz/-/mz-2.7.0.tgz", + "integrity": "sha512-z81GNO7nnYMEhrGh9LeymoE4+Yr0Wn5McHIZMK5cfQCl+NDX08sCZgUc9/6MHni9IWuFLm1Z3HTCXu2z9fN62Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0", + "object-assign": "^4.0.1", + "thenify-all": "^1.0.0" + } + }, + "node_modules/normalize-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/npm-run-path": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-4.0.1.tgz", + "integrity": "sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz", + "integrity": "sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/path-type": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz", + "integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/picomatch": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz", + "integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8.6" + }, + "funding": { + "url": "https://github.com/sponsors/jonschlinkert" + } + }, + "node_modules/pirates": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.6.tgz", + "integrity": "sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 6" + } + }, + "node_modules/postcss-load-config": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/postcss-load-config/-/postcss-load-config-4.0.2.tgz", + "integrity": "sha512-bSVhyJGL00wMVoPUzAVAnbEoWyqRxkjv64tUl427SKnPrENtq6hJwUojroMz2VB+Q1edmi4IfrAPpami5VVgMQ==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "lilconfig": "^3.0.0", + "yaml": "^2.3.4" + }, + "engines": { + "node": ">= 14" + }, + "peerDependencies": { + "postcss": ">=8.0.9", + "ts-node": ">=9.0.0" + }, + "peerDependenciesMeta": { + "postcss": { + "optional": true + }, + "ts-node": { + "optional": true + } + } + }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, + "node_modules/readdirp": { + "version": "3.6.0", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", + "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "dev": true, + "license": "MIT", + "dependencies": { + "picomatch": "^2.2.1" + }, + "engines": { + "node": ">=8.10.0" + } + }, + "node_modules/resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, + "node_modules/rollup": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.1.tgz", + "integrity": "sha512-Elx2UT8lzxxOXMpy5HWQGZqkrQOtrVDDa/bm9l10+U4rQnVzbL/LgZ4NOM1MPIDyHk69W4InuYDF5dzRh4Kw1A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.5" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.18.1", + "@rollup/rollup-android-arm64": "4.18.1", + "@rollup/rollup-darwin-arm64": "4.18.1", + "@rollup/rollup-darwin-x64": "4.18.1", + "@rollup/rollup-linux-arm-gnueabihf": "4.18.1", + "@rollup/rollup-linux-arm-musleabihf": "4.18.1", + "@rollup/rollup-linux-arm64-gnu": "4.18.1", + "@rollup/rollup-linux-arm64-musl": "4.18.1", + "@rollup/rollup-linux-powerpc64le-gnu": "4.18.1", + "@rollup/rollup-linux-riscv64-gnu": "4.18.1", + "@rollup/rollup-linux-s390x-gnu": "4.18.1", + "@rollup/rollup-linux-x64-gnu": "4.18.1", + "@rollup/rollup-linux-x64-musl": "4.18.1", + "@rollup/rollup-win32-arm64-msvc": "4.18.1", + "@rollup/rollup-win32-ia32-msvc": "4.18.1", + "@rollup/rollup-win32-x64-msvc": "4.18.1", + "fsevents": "~2.3.2" + } + }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/slash": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", + "integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/source-map": { + "version": "0.8.0-beta.0", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.8.0-beta.0.tgz", + "integrity": "sha512-2ymg6oRBpebeZi9UUNsgQ89bhx01TcTkmNTGnNO88imTmbSgy4nfujrgVEFKWpMTEGA11EDkTt7mqObTPdigIA==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "whatwg-url": "^7.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/source-map-support": { + "version": "0.5.21", + "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", + "integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-from": "^1.0.0", + "source-map": "^0.6.0" + } + }, + "node_modules/source-map-support/node_modules/source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-final-newline": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", + "integrity": "sha512-BrpvfNAE3dcvq7ll3xVumzjKjZQ5tI1sEUIKr3Uoks0XUl45St3FlatVqef9prk4jRDzhW6WZg+3bk93y6pLjA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/sucrase": { + "version": "3.35.0", + "resolved": "https://registry.npmjs.org/sucrase/-/sucrase-3.35.0.tgz", + "integrity": "sha512-8EbVDiu9iN/nESwxeSxDKe0dunta1GOlHufmSSXxMD2z2/tMZpDMpvXQGsc+ajGo8y2uYUmixaSRUc/QPoQ0GA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.2", + "commander": "^4.0.0", + "glob": "^10.3.10", + "lines-and-columns": "^1.1.6", + "mz": "^2.7.0", + "pirates": "^4.0.1", + "ts-interface-checker": "^0.1.9" + }, + "bin": { + "sucrase": "bin/sucrase", + "sucrase-node": "bin/sucrase-node" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/terser": { + "version": "5.31.2", + "resolved": "https://registry.npmjs.org/terser/-/terser-5.31.2.tgz", + "integrity": "sha512-LGyRZVFm/QElZHy/CPr/O4eNZOZIzsrQ92y4v9UJe/pFJjypje2yI3C2FmPtvUEnhadlSbmG2nXtdcjHOjCfxw==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@jridgewell/source-map": "^0.3.3", + "acorn": "^8.8.2", + "commander": "^2.20.0", + "source-map-support": "~0.5.20" + }, + "bin": { + "terser": "bin/terser" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/terser/node_modules/commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/thenify": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/thenify/-/thenify-3.3.1.tgz", + "integrity": "sha512-RVZSIV5IG10Hk3enotrhvz0T9em6cyHBLkH/YAZuKqd8hRkKhSfCGIcP2KUY0EPxndzANBmNllzWPwak+bheSw==", + "dev": true, + "license": "MIT", + "dependencies": { + "any-promise": "^1.0.0" + } + }, + "node_modules/thenify-all": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/thenify-all/-/thenify-all-1.6.0.tgz", + "integrity": "sha512-RNxQH/qI8/t3thXJDwcstUO4zeqo64+Uy/+sNVRBx4Xn2OX+OZ9oP+iJnNFqplFra2ZUVeKCSa2oVWi3T4uVmA==", + "dev": true, + "license": "MIT", + "dependencies": { + "thenify": ">= 3.1.0 < 4" + }, + "engines": { + "node": ">=0.8" + } + }, + "node_modules/to-regex-range": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", + "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-number": "^7.0.0" + }, + "engines": { + "node": ">=8.0" + } + }, + "node_modules/tr46": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-1.0.1.tgz", + "integrity": "sha512-dTpowEjclQ7Kgx5SdBkqRzVhERQXov8/l9Ft9dVM9fmg0W0KQSVaXX9T4i6twCPNtYiZM53lpSSUAwJbFPOHxA==", + "dev": true, + "license": "MIT", + "dependencies": { + "punycode": "^2.1.0" + } + }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "license": "MIT", + "bin": { + "tree-kill": "cli.js" + } + }, + "node_modules/ts-interface-checker": { + "version": "0.1.13", + "resolved": "https://registry.npmjs.org/ts-interface-checker/-/ts-interface-checker-0.1.13.tgz", + "integrity": "sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==", + "dev": true, + "license": "Apache-2.0" + }, + "node_modules/tsup": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/tsup/-/tsup-8.1.0.tgz", + "integrity": "sha512-UFdfCAXukax+U6KzeTNO2kAARHcWxmKsnvSPXUcfA1D+kU05XDccCrkffCQpFaWDsZfV0jMyTsxU39VfCp6EOg==", + "dev": true, + "license": "MIT", + "dependencies": { + "bundle-require": "^4.0.0", + "cac": "^6.7.12", + "chokidar": "^3.5.1", + "debug": "^4.3.1", + "esbuild": "^0.21.4", + "execa": "^5.0.0", + "globby": "^11.0.3", + "joycon": "^3.0.1", + "postcss-load-config": "^4.0.1", + "resolve-from": "^5.0.0", + "rollup": "^4.0.2", + "source-map": "0.8.0-beta.0", + "sucrase": "^3.20.3", + "tree-kill": "^1.2.2" + }, + "bin": { + "tsup": "dist/cli-default.js", + "tsup-node": "dist/cli-node.js" + }, + "engines": { + "node": ">=18" + }, + "peerDependencies": { + "@microsoft/api-extractor": "^7.36.0", + "@swc/core": "^1", + "postcss": "^8.4.12", + "typescript": ">=4.5.0" + }, + "peerDependenciesMeta": { + "@microsoft/api-extractor": { + "optional": true + }, + "@swc/core": { + "optional": true + }, + "postcss": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/typescript": { + "version": "5.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.3.tgz", + "integrity": "sha512-/hreyEujaB0w76zKo6717l3L0o/qEUtRgdvUBvlkhoWeOVMjMuHNHk0BRBzikzuGDqNmPQbg5ifMEqsHLiIUcQ==", + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/webidl-conversions": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz", + "integrity": "sha512-YQ+BmxuTgd6UXZW3+ICGfyqRyHXVlD5GtQr5+qjiNW7bF0cqrzX500HVXPBOvgXb5YnzDd+h0zqyv61KUD7+Sg==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/whatwg-url": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-7.1.0.tgz", + "integrity": "sha512-WUu7Rg1DroM7oQvGWfOiAK21n74Gg+T4elXEQYkOhtyLeWiJFoOGLXPKI/9gzIie9CtwVLm8wtw6YJdKyxSjeg==", + "dev": true, + "license": "MIT", + "dependencies": { + "lodash.sortby": "^4.7.0", + "tr46": "^1.0.1", + "webidl-conversions": "^4.0.2" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yaml": { + "version": "2.4.5", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.4.5.tgz", + "integrity": "sha512-aBx2bnqDzVOyNKfsysjA2ms5ZlnjSAW2eG3/L5G/CSujfjLJTJsEw1bGw8kCf04KodQWk1pxlGnZ56CRxiawmg==", + "dev": true, + "license": "ISC", + "bin": { + "yaml": "bin.mjs" + }, + "engines": { + "node": ">= 14" + } + } + } +} diff --git a/package.json b/package.json index 6a35265..e6ac120 100644 --- a/package.json +++ b/package.json @@ -3,11 +3,11 @@ "title": "Observe.js", "description": "A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements.", "version": "1.0.0", - "main": "dist/observe.js", "homepage": "https://www.william-troup.com/observe-js/", "author": { "name": "Bunoon" }, + "license": "MIT", "repository": { "type": "git", "url": "https://github.com/williamtroup/Observe.js" @@ -31,5 +31,21 @@ "bugs": { "url": "https://github.com/williamtroup/Observe.js/issues" }, - "license": "MIT" -} \ No newline at end of file + "main": "dist/observe.js", + "types": "dist/observe.d.ts", + "scripts": { + "build-all": "npm run build && npm run build-minimized", + "build": "tsup --config tsup.build.config.ts && tsup --config tsup.build.esm.config.ts", + "build-minimized": "tsup --config tsup.build.min.config.ts", + "build-typescript": "tsup --config tsup.build.config.ts", + "build-typescript-esm": "tsup --config tsup.build.esm.config.ts", + "build-typescript-minimized": "tsup --config tsup.build.min.config.ts" + }, + "devDependencies": { + "@swc/core": "^1.6.13", + "sass": "^1.77.8", + "terser": "^5.31.2", + "tsup": "^8.1.0", + "typescript": "^5.5.3" + } +} From 0d01e241341c3dd809389800eef99d32336b2eb0 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:43:36 +0100 Subject: [PATCH 07/28] Moved old Js files. --- src/{ => _old}/observe.js | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/{ => _old}/observe.js (100%) diff --git a/src/observe.js b/src/_old/observe.js similarity index 100% rename from src/observe.js rename to src/_old/observe.js From 6df14d1d4dc12656d1aa4e8446ebcdb46f227c90 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:47:13 +0100 Subject: [PATCH 08/28] Added constant.ts and start of observe.ts. --- src/observe.ts | 20 ++++++++++++++++++++ src/ts/constant.ts | 16 ++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/observe.ts create mode 100644 src/ts/constant.ts diff --git a/src/observe.ts b/src/observe.ts new file mode 100644 index 0000000..8620107 --- /dev/null +++ b/src/observe.ts @@ -0,0 +1,20 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file observe.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +( () => { + + + ( () => { + + } )(); +} )(); \ No newline at end of file diff --git a/src/ts/constant.ts b/src/ts/constant.ts new file mode 100644 index 0000000..e0db072 --- /dev/null +++ b/src/ts/constant.ts @@ -0,0 +1,16 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file constant.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +export namespace Constant { + export const OBSERVE_JS_ATTRIBUTE_NAME = "data-observe-js"; +} \ No newline at end of file From bb91a7f7d6d5a4cb0a1a992d484d204cc288051a Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:53:19 +0100 Subject: [PATCH 09/28] Added type.ts. --- src/ts/type.ts | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/ts/type.ts diff --git a/src/ts/type.ts b/src/ts/type.ts new file mode 100644 index 0000000..2bae3f8 --- /dev/null +++ b/src/ts/type.ts @@ -0,0 +1,46 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file type.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +export type Configuration = { + safeMode?: boolean; + domElementTypes?: string[] | string; +}; + +export type ConfigurationText = { + objectErrorText?: string; + attributeNotValidErrorText?: string; + attributeNotSetErrorText?: string; +}; + +export type BindingOptions = { + timeout?: number; + starts?: Date; + expires?: Date; + reset?: boolean; + cancelOnChange?: boolean; + maximumChangesBeforeCanceling?: number; + pauseTimeoutOnChange?: number; + propertyNames?: string[]; + allowCanceling?: boolean; + allowPausing?: boolean; + removeAttribute?: boolean; + events?: BindingOptionEvents; +}; + +export type BindingOptionEvents = { + onChange?: Function; + onPropertyChange?: Function; + onCancel?: Function; + onRemove?: Function; + onStart?: Function; +} \ No newline at end of file From d9079e8faff7407f403f0fecc914389724814548 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 10:56:23 +0100 Subject: [PATCH 10/28] Added enum.ts and is.ts. --- src/ts/enum.ts | 16 ++++++++++++++++ src/ts/is.ts | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 src/ts/enum.ts create mode 100644 src/ts/is.ts diff --git a/src/ts/enum.ts b/src/ts/enum.ts new file mode 100644 index 0000000..57fd60a --- /dev/null +++ b/src/ts/enum.ts @@ -0,0 +1,16 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file enum.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +export const enum Char { + empty = "", +} \ No newline at end of file diff --git a/src/ts/is.ts b/src/ts/is.ts new file mode 100644 index 0000000..2a8abe7 --- /dev/null +++ b/src/ts/is.ts @@ -0,0 +1,49 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file is.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +import { Char } from "./enum" + + +export namespace Is { + export function defined( value: any ) : boolean { + return value !== null && value !== undefined && value.toString() !== Char.empty; + } + + export function definedObject( object: any ) : boolean { + return defined( object ) && typeof object === "object"; + } + + export function definedBoolean( object: any ) : boolean { + return defined( object ) && typeof object === "boolean"; + } + + export function definedString( object: any ) : boolean { + return defined( object ) && typeof object === "string"; + } + + export function definedFunction( object: any ) : boolean { + return defined( object ) && typeof object === "function"; + } + + export function definedNumber( object: any ) : boolean { + return defined( object ) && typeof object === "number"; + } + + export function definedArray( object: any ) : boolean { + return definedObject( object ) && object instanceof Array; + } + + export function definedDate( object: any ) : boolean { + return definedObject( object ) && object instanceof Date; + } +} \ No newline at end of file From 2936dfab33e209f7537c66631af649eb576143df Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 11:00:07 +0100 Subject: [PATCH 11/28] Added data.ts. --- src/ts/data.ts | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/ts/enum.ts | 2 ++ 2 files changed, 84 insertions(+) create mode 100644 src/ts/data.ts diff --git a/src/ts/data.ts b/src/ts/data.ts new file mode 100644 index 0000000..50c0a7f --- /dev/null +++ b/src/ts/data.ts @@ -0,0 +1,82 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file data.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +import { Char } from "./enum"; +import { Is } from "./is"; + + +export namespace Data { + export namespace String { + export function newGuid() : string { + const result: string[] = []; + + for ( let charIndex: number = 0; charIndex < 32; charIndex++ ) { + if ( charIndex === 8 || charIndex === 12 || charIndex === 16 || charIndex === 20 ) { + result.push( Char.dash ); + } + + const character: string = Math.floor( Math.random() * 16 ).toString( 16 ); + result.push( character ); + } + + return result.join( Char.empty ); + } + } + + export function getDefaultAnyString( value: any, defaultValue: string ) : string { + return typeof value === "string" ? value : defaultValue; + } + + export function getDefaultString( value: any, defaultValue: string ) : string { + return Is.definedString( value ) ? value : defaultValue; + } + + export function getDefaultBoolean( value: any, defaultValue: boolean ) : boolean { + return Is.definedBoolean( value ) ? value : defaultValue; + } + + export function getDefaultNumber( value: any, defaultValue: number ) : number { + return Is.definedNumber( value ) ? value : defaultValue; + } + + export function getDefaultFunction( value: any, defaultValue: object ) : any { + return Is.definedFunction( value ) ? value : defaultValue; + } + + export function getDefaultArray( value: any, defaultValue: any[] ) : any[] { + return Is.definedArray( value ) ? value : defaultValue; + } + + export function getDefaultObject( value: any, defaultValue: object ) : any { + return Is.definedObject( value ) ? value : defaultValue; + } + + export function getDefaultStringOrArray( value: any, defaultValue: string[] ) : string[] { + let result: string[] = defaultValue; + + if ( Is.definedString( value ) ) { + const values: string[] = value.toString().split( Char.space ); + + if ( values.length === 0 ) { + value = defaultValue; + } else { + result = values; + } + + } else { + result = getDefaultArray( value, defaultValue ); + } + + return result; + } +} \ No newline at end of file diff --git a/src/ts/enum.ts b/src/ts/enum.ts index 57fd60a..ca83b1b 100644 --- a/src/ts/enum.ts +++ b/src/ts/enum.ts @@ -13,4 +13,6 @@ export const enum Char { empty = "", + space = "space", + dash = "-", } \ No newline at end of file From 8c11b3e146eea6834a53a651a2753a8c282740a7 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 11:01:22 +0100 Subject: [PATCH 12/28] Minor rename. --- src/ts/type.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ts/type.ts b/src/ts/type.ts index 2bae3f8..c4802e5 100644 --- a/src/ts/type.ts +++ b/src/ts/type.ts @@ -22,7 +22,7 @@ export type ConfigurationText = { attributeNotSetErrorText?: string; }; -export type BindingOptions = { +export type WatchOptions = { timeout?: number; starts?: Date; expires?: Date; @@ -34,10 +34,10 @@ export type BindingOptions = { allowCanceling?: boolean; allowPausing?: boolean; removeAttribute?: boolean; - events?: BindingOptionEvents; + events?: WatchOptionEvents; }; -export type BindingOptionEvents = { +export type WatchOptionEvents = { onChange?: Function; onPropertyChange?: Function; onCancel?: Function; From 1e43eaa97f8ba0054ecdd805a1dafab9052be08b Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 11:04:59 +0100 Subject: [PATCH 13/28] Added start of private functions. --- src/observe.ts | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/ts/type.ts | 1 + 2 files changed, 82 insertions(+) diff --git a/src/observe.ts b/src/observe.ts index 8620107..7d0600a 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -10,9 +10,90 @@ * @copyright Bunoon 2024 */ +import { Is } from "./ts/is"; +import { type Configuration } from "./ts/type"; + + +type StringToJson = { + parsed: boolean; + object: any; +}; + ( () => { + // Variables: Configuration + let _configuration: Configuration = {} as Configuration; + + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Triggering Custom Events + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function fireCustomTriggerEvent( triggerFunction: Function, ...args : any[] ) : void { + if ( Is.definedFunction( triggerFunction ) ) { + triggerFunction.apply( null, [].slice.call( args, 0 ) ); + } + } + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Default Parameter/Option Handling + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function getObjectFromString( objectString: any ) : StringToJson { + const result: StringToJson = { + parsed: true, + object: null + } as StringToJson; + + try { + if ( Is.definedString( objectString ) ) { + result.object = JSON.parse( objectString ); + } + + } catch ( e1: any ) { + try { + result.object = eval( `(${objectString})` ); + + if ( Is.definedFunction( result.object ) ) { + result.object = result.object(); + } + + } catch ( e2: any ) { + if ( !_configuration.safeMode ) { + logError( _configuration.text!.objectErrorText!.replace( "{{error_1}}", e1.message ).replace( "{{error_2}}", e2.message ) ); + result.parsed = false; + } + + result.object = null; + } + } + + return result; + } + + function logError( error: string ) : boolean { + let result: boolean = true; + + if ( !_configuration.safeMode ) { + console.error( error ); + result = false; + } + + return result; + } + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Initialize Observe.js + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ ( () => { diff --git a/src/ts/type.ts b/src/ts/type.ts index c4802e5..64c0436 100644 --- a/src/ts/type.ts +++ b/src/ts/type.ts @@ -14,6 +14,7 @@ export type Configuration = { safeMode?: boolean; domElementTypes?: string[] | string; + text?: ConfigurationText; }; export type ConfigurationText = { From 0e4dd6ca30ceab8e07d92abcba280d036377f3ae Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 11:09:02 +0100 Subject: [PATCH 14/28] Added watch options private functions, and added missing method. --- src/observe.ts | 44 +++++++++++++++++++++++++++++++++++++++++--- src/ts/data.ts | 4 ++++ 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/src/observe.ts b/src/observe.ts index 7d0600a..f60066c 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -10,8 +10,9 @@ * @copyright Bunoon 2024 */ +import { Data } from "./ts/data"; import { Is } from "./ts/is"; -import { type Configuration } from "./ts/type"; +import { type WatchOptionEvents, type WatchOptions, type Configuration } from "./ts/type"; type StringToJson = { @@ -25,7 +26,44 @@ type StringToJson = { let _configuration: Configuration = {} as Configuration; - + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Watch Options + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function getWatchOptions( newOptions: any ) : WatchOptions { + let options: WatchOptions = Data.getDefaultObject( newOptions, {} as WatchOptions ); + + options.timeout = Data.getDefaultNumber( options.timeout, 250 ); + options.starts = Data.getDefaultDate( options.starts, null! ); + options.expires = Data.getDefaultDate( options.expires, null! ); + options.reset = Data.getDefaultBoolean( options.reset, false ); + options.cancelOnChange = Data.getDefaultBoolean( options.cancelOnChange, false ); + options.maximumChangesBeforeCanceling = Data.getDefaultNumber( options.maximumChangesBeforeCanceling, 0 ); + options.pauseTimeoutOnChange = Data.getDefaultNumber( options.pauseTimeoutOnChange, 0 ); + options.propertyNames = Data.getDefaultArray( options.propertyNames, null! ); + options.allowCanceling = Data.getDefaultBoolean( options.allowCanceling, true ); + options.allowPausing = Data.getDefaultBoolean( options.allowPausing, true ); + options.removeAttribute = Data.getDefaultBoolean( options.removeAttribute, true ); + + options = getWatchOptionsCustomTriggers( options ); + + return options; + } + + function getWatchOptionsCustomTriggers( options: WatchOptions ) : WatchOptions { + options.events = Data.getDefaultObject( options.events, {} as WatchOptionEvents ); + options.events!.onChange = Data.getDefaultFunction( options.events!.onChange, null! ); + options.events!.onPropertyChange = Data.getDefaultFunction( options.events!.onPropertyChange, null! ); + options.events!.onCancel = Data.getDefaultFunction( options.events!.onCancel, null! ); + options.events!.onRemove = Data.getDefaultFunction( options.events!.onRemove, null! ); + options.events!.onStart = Data.getDefaultFunction( options.events!.onStart, null! ); + + return options; + } + + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Triggering Custom Events @@ -88,7 +126,7 @@ type StringToJson = { return result; } - + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Initialize Observe.js diff --git a/src/ts/data.ts b/src/ts/data.ts index 50c0a7f..6db366f 100644 --- a/src/ts/data.ts +++ b/src/ts/data.ts @@ -61,6 +61,10 @@ export namespace Data { return Is.definedObject( value ) ? value : defaultValue; } + export function getDefaultDate( value: any, defaultValue: Date ) : Date { + return Is.definedDate( value ) ? value : defaultValue; + } + export function getDefaultStringOrArray( value: any, defaultValue: string[] ) : string[] { let result: string[] = defaultValue; From ce3857754ade92c1bb7a5b4c024c8fe617a16565 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 11:14:28 +0100 Subject: [PATCH 15/28] Added class variables and new types. --- src/observe.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/observe.ts b/src/observe.ts index f60066c..6161268 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -20,11 +20,23 @@ type StringToJson = { object: any; }; +type ObserveWatch = { + options: WatchOptions; + totalChanges: number; + domElementId: string; + cachedObject: any; + originalObject: any; +}; + ( () => { // Variables: Configuration let _configuration: Configuration = {} as Configuration; + // Variables: Watches + const _watches: Record = {} as Record; + let _watches_Cancel: boolean = false; + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- From c3c1f8237e79a6fb68a103f23b2f1cbe1c91d66b Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:03:15 +0100 Subject: [PATCH 16/28] Added create watch private functions. --- dist/observe.d.mts | 2 + dist/observe.d.ts | 2 + dist/observe.esm.js | 371 ++++++++++++++++++++ dist/observe.esm.js.map | 1 + dist/observe.js | 729 +++++++++++++++++----------------------- dist/observe.js.map | 1 + dist/observe.min.js | 15 +- src/observe.ts | 216 ++++++++++++ 8 files changed, 895 insertions(+), 442 deletions(-) create mode 100644 dist/observe.d.mts create mode 100644 dist/observe.d.ts create mode 100644 dist/observe.esm.js create mode 100644 dist/observe.esm.js.map create mode 100644 dist/observe.js.map 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..1d47ebd --- /dev/null +++ b/dist/observe.esm.js @@ -0,0 +1,371 @@ +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 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 o(e) { + return t(e) && typeof e === "string"; + } + e.definedString = o; + function a(e) { + return t(e) && typeof e === "function"; + } + e.definedFunction = a; + 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 o(e, t) { + return Is.definedBoolean(e) ? e : t; + } + e.getDefaultBoolean = o; + function a(e, t) { + return Is.definedNumber(e) ? e : t; + } + e.getDefaultNumber = a; + 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 l(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 = l; + })(Data || (Data = {})); + } +}); + +var require_observe = __commonJS({ + "src/observe.ts"(exports, module) { + init_data(); + init_enum(); + init_is(); + (() => { + let _configuration = {}; + const _watches = {}; + let _watches_Cancel = false; + function createWatch(e, t, n) { + let r = null; + if (Is.definedObject(e)) { + r = Data.String.newGuid(); + const o = getWatchOptions(t); + const a = {}; + let i = null; + a.options = o; + a.totalChanges = 0; + if (Is.definedString(n)) { + const e = document.getElementById(n); + if (Is.defined(e)) { + a.domElementId = n; + a.cachedObject = e.outerHTML; + a.originalObject = e.outerHTML; + i = e.outerHTML; + } + } else { + a.cachedObject = JSON.stringify(e); + a.originalObject = e; + i = e; + } + if (Is.defined(a.cachedObject)) { + fireCustomTriggerEvent(a.options.events.onStart, i); + a.timer = setInterval((function() { + watchTimer(o, r); + }), o.timeout); + _watches[r] = a; + } + } + 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 o = t.cachedObject; + const a = t.originalObject; + const i = !n ? JSON.stringify(a) : a; + if (o !== i) { + if (t.options.reset) { + if (n) { + r.outerHTML = t.cachedObject; + } else { + t.originalObject = getObjectFromString(o).object; + } + } else { + t.cachedObject = i; + } + if (n) { + fireCustomTriggerEvent(t.options.events.onChange, o, i); + } else { + const e = getObjectFromString(o).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 o = 0; o < r; o++) { + const r = n.options.propertyNames[o]; + 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 (var r in e) { + if (e.hasOwnProperty(r)) { + const o = e[r]; + let a = null; + if (t.hasOwnProperty(r)) { + a = t[r]; + } + if (Is.definedObject(o) && Is.definedObject(a)) { + compareWatchObjectProperties(o, a, n); + } else { + if (!Is.definedArray(n.options.propertyNames) || n.options.propertyNames.indexOf(r) > -1) { + if (JSON.stringify(o) !== JSON.stringify(a)) { + fireCustomTriggerEvent(n.options.events.onPropertyChange, r, o, a); + } + } + } + } + } + } + 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; + } + (() => {})(); + })(); + } +}); + +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..0f69545 --- /dev/null +++ b/dist/observe.esm.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/ts/enum.ts","../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Is","Data","String","result"],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAgBiB;AAhBjB;AAAA;AAAA;AAaA;AAGO,MAAUA,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,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,aAAc,QAAwB;AAClD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAIT,eAAS,YAAa,QAAwB;AACjD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAAA,OA7BH;AAAA;AAAA;;;AChBjB,IAiBiB;AAjBjB;AAAA;AAAA;AAaA;AACA;AAGO,MAAUC,UAAV;AACI,UAAU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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\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.js b/dist/observe.js index aec4ae8..d53e8a5 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -1,460 +1,333 @@ -/*! Observe.js v1.0.0 | (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; - } - } +"use strict"; + +var Is; + +(e => { + function t(e) { + return e !== null && e !== void 0 && e.toString() !== ""; } - } - 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; - } + e.defined = t; + function n(e) { + return t(e) && typeof e === "object"; } - 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; - } - } 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; - } + e.definedObject = n; + function o(e) { + return t(e) && typeof e === "boolean"; } - 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); - } + e.definedBoolean = o; + function r(e) { + return t(e) && typeof e === "string"; } - } - 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; - } else { - watch.originalObject = _string.empty; - fireCustomTrigger(watch.options.onRemove, watch.domElementId); - } - } - 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; - } - 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); - } - } else { - fireCustomTrigger(watch.options.onChange, oldValue, newValue); - } - } - watch.totalChanges++; - if (watch.options.pauseTimeoutOnChange > 0) { - pauseWatchObject(storageId, watch.options.pauseTimeoutOnChange); - } - if (watch.options.cancelOnChange) { - cancelWatchObject(storageId); - } - if (watch.options.maximumChangesBeforeCanceling > 0 && watch.totalChanges >= watch.options.maximumChangesBeforeCanceling) { - cancelWatchObject(storageId); - } - } + e.definedString = r; + function a(e) { + return t(e) && typeof e === "function"; } - } - 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; - } - } - } else { - fireCustomTrigger(watch.options.onChange, oldObject, newObject); + e.definedFunction = a; + function i(e) { + return t(e) && typeof e === "number"; } - } - 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]; - } - 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); + 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; + +(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 o(e, t) { + return Is.definedString(e) ? e : t; + } + e.getDefaultString = o; + function r(e, t) { + return Is.definedBoolean(e) ? e : t; + } + e.getDefaultBoolean = r; + function a(e, t) { + return Is.definedNumber(e) ? e : t; } - } - function cancelWatchesForObjects() { - for (var storageId in _watches) { - if (_watches.hasOwnProperty(storageId)) { - cancelWatchObject(storageId); - } + e.getDefaultNumber = a; + function i(e, t) { + return Is.definedFunction(e) ? e : t; } - } - 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]; - } + e.getDefaultFunction = i; + function s(e, t) { + return Is.definedArray(e) ? e : t; } - } - 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; - } + e.getDefaultArray = s; + function c(e, t) { + return Is.definedObject(e) ? e : t; } - 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)); + e.getDefaultObject = c; + function u(e, t) { + return Is.definedDate(e) ? e : t; } - } - 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); + e.getDefaultDate = u; + function l(e, t) { + let n = t; + if (Is.definedString(e)) { + const o = e.toString().split("space"); + if (o.length === 0) { + e = t; + } else { + n = o; + } + } else { + n = s(e, t); + } + return n; } - 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); + e.getDefaultStringOrArray = l; +})(Data || (Data = {})); + +(() => { + let _configuration = {}; + const _watches = {}; + let _watches_Cancel = false; + function createWatch(e, t, n) { + let o = null; + if (Is.definedObject(e)) { + o = Data.String.newGuid(); + const r = getWatchOptions(t); + const a = {}; + let i = null; + a.options = r; + a.totalChanges = 0; + if (Is.definedString(n)) { + const e = document.getElementById(n); + if (Is.defined(e)) { + a.domElementId = n; + a.cachedObject = e.outerHTML; + a.originalObject = e.outerHTML; + i = e.outerHTML; + } + } else { + a.cachedObject = JSON.stringify(e); + a.originalObject = e; + i = e; + } + if (Is.defined(a.cachedObject)) { + fireCustomTriggerEvent(a.options.events.onStart, i); + a.timer = setInterval((function() { + watchTimer(r, o); + }), r.timeout); + _watches[o] = a; + } + } + return o; } - 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 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); + } } - } 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; + function watchObjectForChanges(e) { + if (_watches.hasOwnProperty(e)) { + const t = _watches[e]; + const n = Is.definedString(t.domElementId); + let o = null; + if (n) { + o = document.getElementById(t.domElementId); + if (Is.defined(o)) { + t.originalObject = o.outerHTML; + } else { + t.originalObject = ""; + fireCustomTriggerEvent(t.options.events.onRemove, t.domElementId); + } + } + const r = t.cachedObject; + const a = t.originalObject; + const i = !n ? JSON.stringify(a) : a; + if (r !== i) { + if (t.options.reset) { + if (n) { + o.outerHTML = t.cachedObject; + } else { + t.originalObject = getObjectFromString(r).object; + } + } else { + t.cachedObject = i; + } + if (n) { + fireCustomTriggerEvent(t.options.events.onChange, r, i); + } else { + const e = getObjectFromString(r).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); + } + } + } } - 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 compareWatchObject(e, t, n) { + if (Is.definedArray(n.options.propertyNames)) { + const o = n.options.propertyNames.length; + for (let r = 0; r < o; r++) { + const o = n.options.propertyNames[r]; + if (e[o] !== t[o]) { + fireCustomTriggerEvent(n.options.events.onChange, e, t); + break; + } + } + } else { + fireCustomTriggerEvent(n.options.events.onChange, e, t); } - } } - 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; - } + function compareWatchObjectProperties(e, t, n) { + for (var o in e) { + if (e.hasOwnProperty(o)) { + const r = e[o]; + let a = null; + if (t.hasOwnProperty(o)) { + a = t[o]; + } + if (Is.definedObject(r) && Is.definedObject(a)) { + compareWatchObjectProperties(r, a, n); + } else { + if (!Is.definedArray(n.options.propertyNames) || n.options.propertyNames.indexOf(o) > -1) { + if (JSON.stringify(r) !== JSON.stringify(a)) { + fireCustomTriggerEvent(n.options.events.onPropertyChange, o, r, a); + } + } + } + } } - } } - 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 cancelWatchesForObjects() { + for (let e in _watches) { + if (_watches.hasOwnProperty(e)) { + cancelWatchObject(e); + } } - } } - return result; - }; - _public.pauseWatches = function(milliseconds) { - if (isDefinedNumber(milliseconds)) { - for (var storageId in _watches) { - if (_watches.hasOwnProperty(storageId)) { - pauseWatchObject(storageId, milliseconds); + 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]; + } } - } } - 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; - } + function pauseWatchObject(e, t) { + let n = false; + if (_watches.hasOwnProperty(e)) { + const o = _watches[e].options; + if (o.allowPausing) { + o.starts = new Date; + o.starts.setMilliseconds(o.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; } - return result; - }; - _public.resumeWatches = function() { - for (var storageId in _watches) { - if (_watches.hasOwnProperty(storageId)) { - _watches[storageId].options.starts = null; - } + 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; } - 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; + function fireCustomTriggerEvent(e, ...t) { + if (Is.definedFunction(e)) { + e.apply(null, [].slice.call(t, 0)); } - } - 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 "1.0.0"; - }; - (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; + 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; } - })(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..5601b74 --- /dev/null +++ b/dist/observe.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Is","Data","String","result"],"mappings":";;;AAgBO,IAAU;AAAA,CAAV,CAAUA,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,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,aAAc,QAAwB;AAClD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,EACxD;AAFO,EAAAA,IAAS;AAIT,WAAS,YAAa,QAAwB;AACjD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,EACxD;AAFO,EAAAA,IAAS;AAAA,GA7BH;;;ACCV,IAAU;AAAA,CAAV,CAAUC,UAAV;AACI,MAAU;AAAV,IAAUC,YAAV;AACI,aAAS,UAAmB;AAC/B,YAAMC,UAAmB,CAAC;AAE1B,eAAU,YAAoB,GAAG,YAAY,IAAI,aAAc;AAC3D,YAAK,cAAc,KAAK,cAAc,MAAM,cAAc,MAAM,cAAc,IAAK;AAC/E,UAAAA,QAAO,mBAAgB;AAAA,QAC3B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AAA,IAC1D;AAAA,EACJ;AASA,WAAS,oBAAqB,cAAmC;AAC7D,UAAM,SAAuB;AAAA,MACzB,QAAQ;AAAA,MACR,QAAQ;AAAA,IACZ;AAEA,QAAI;AACA,UAAK,GAAG,cAAe,YAAa,GAAI;AACpC,eAAO,SAAS,KAAK,MAAO,YAAa;AAAA,MAC7C;AAAA,IAEJ,SAAU,IAAU;AAChB,UAAI;AACA,eAAO,SAAS,KAAM,IAAI,YAAY,GAAI;AAE1C,YAAK,GAAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,iBAAO,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MAEJ,SAAU,IAAU;AAChB,YAAK,CAAC,eAAe,UAAW;AAC5B,mBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,iBAAO,SAAS;AAAA,QACpB;AAEA,eAAO,SAAS;AAAA,MACpB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,WAAS,SAAU,OAA0B;AACzC,QAAIA,UAAkB;AAEtB,QAAK,CAAC,eAAe,UAAW;AAC5B,cAAQ,MAAO,KAAM;AACrB,MAAAA,UAAS;AAAA,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 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\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.min.js b/dist/observe.min.js index a985ffc..d78b2d4 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1,14 +1 @@ -/*! Observe.js v1.0.0 | (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"1.0.0"};(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 n,t;(n=>{function t(n){return null!=n&&""!==n.toString()}function e(n){return t(n)&&"object"==typeof n}n.defined=t,n.definedObject=e,n.definedBoolean=function(n){return t(n)&&"boolean"==typeof n},n.definedString=function(n){return t(n)&&"string"==typeof n},n.definedFunction=function(n){return t(n)&&"function"==typeof n},n.definedNumber=function(n){return t(n)&&"number"==typeof n},n.definedArray=function(n){return e(n)&&n instanceof Array},n.definedDate=function(n){return e(n)&&n instanceof Date}})(n||(n={})),(t=>{let e;function r(t,e){return n.definedArray(t)?t:e}(e=t.String||(t.String={})).newGuid=function(){const n=[];for(let t=0;t<32;t++){8!==t&&12!==t&&16!==t&&20!==t||n.push("-");const e=Math.floor(16*Math.random()).toString(16);n.push(e)}return n.join("")},t.getDefaultAnyString=function(n,t){return"string"==typeof n?n:t},t.getDefaultString=function(t,e){return n.definedString(t)?t:e},t.getDefaultBoolean=function(t,e){return n.definedBoolean(t)?t:e},t.getDefaultNumber=function(t,e){return n.definedNumber(t)?t:e},t.getDefaultFunction=function(t,e){return n.definedFunction(t)?t:e},t.getDefaultArray=r,t.getDefaultObject=function(t,e){return n.definedObject(t)?t:e},t.getDefaultDate=function(t,e){return n.definedDate(t)?t:e},t.getDefaultStringOrArray=function(t,e){let i=e;if(n.definedString(t)){const n=t.toString().split("space");0===n.length?t=e:i=n}else i=r(t,e);return i}})(t||(t={})); \ No newline at end of file diff --git a/src/observe.ts b/src/observe.ts index 6161268..edbb9b7 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -11,6 +11,7 @@ */ import { Data } from "./ts/data"; +import { Char } from "./ts/enum"; import { Is } from "./ts/is"; import { type WatchOptionEvents, type WatchOptions, type Configuration } from "./ts/type"; @@ -26,6 +27,7 @@ type ObserveWatch = { domElementId: string; cachedObject: any; originalObject: any; + timer: number; }; @@ -38,6 +40,220 @@ type ObserveWatch = { let _watches_Cancel: boolean = false; + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Watch Object Creation / Handling + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function createWatch( object: any, options: any, domElementId: string ) : string { + let storageId: string = null!; + + if ( Is.definedObject( object ) ) { + storageId = Data.String.newGuid(); + + const watchOptions: WatchOptions = getWatchOptions( options ); + const watch: ObserveWatch = {} as ObserveWatch; + let startWatchObject: any = null; + + watch.options = watchOptions; + watch.totalChanges = 0; + + if ( Is.definedString( domElementId ) ) { + const domElement: HTMLElement = document.getElementById( domElementId )!; + + if ( Is.defined( domElement ) ) { + watch.domElementId = domElementId; + watch.cachedObject = domElement.outerHTML; + watch.originalObject = domElement.outerHTML; + + startWatchObject = domElement.outerHTML; + } + + } else { + watch.cachedObject = JSON.stringify( object ); + watch.originalObject = object; + + startWatchObject = object; + } + + if ( Is.defined( watch.cachedObject ) ) { + fireCustomTriggerEvent( watch.options.events!.onStart!, startWatchObject ); + + watch.timer = setInterval( function() { + watchTimer( watchOptions, storageId ); + }, watchOptions.timeout ); + + _watches[ storageId ] = watch; + } + } + + return storageId; + } + + function watchTimer( watchOptions: WatchOptions, storageId: string ) : void { + const currentDateTime: Date = new Date(); + + if ( !Is.definedDate( watchOptions.starts ) || currentDateTime >= watchOptions.starts! ) { + watchObjectForChanges( storageId ); + + if ( Is.definedDate( watchOptions.expires ) && currentDateTime >= watchOptions.expires! ) { + cancelWatchObject( storageId ); + } + } + } + + function watchObjectForChanges( storageId: string ) : void { + if ( _watches.hasOwnProperty( storageId ) ) { + const watch: ObserveWatch = _watches[ storageId ]; + const isDomElement: boolean = Is.definedString( watch.domElementId ); + let domElement: HTMLElement = null!; + + if ( isDomElement ) { + domElement = document.getElementById( watch.domElementId )!; + + if ( Is.defined( domElement ) ) { + watch.originalObject = domElement.outerHTML; + } else { + watch.originalObject = Char.empty; + + fireCustomTriggerEvent( watch.options.events!.onRemove!, watch.domElementId ); + } + } + + const cachedObject: any = watch.cachedObject; + const originalObject: any = watch.originalObject; + const originalObjectJson: any = !isDomElement ? JSON.stringify( originalObject ) : originalObject; + + if ( cachedObject !== originalObjectJson ) { + if ( watch.options.reset ) { + if ( isDomElement ) { + domElement.outerHTML = watch.cachedObject; + } else { + watch.originalObject = getObjectFromString( cachedObject ).object; + } + + } else { + watch.cachedObject = originalObjectJson; + } + + if ( isDomElement ) { + fireCustomTriggerEvent( watch.options.events!.onChange!, cachedObject, originalObjectJson ); + } else { + + const oldValue: any = getObjectFromString( cachedObject ).object; + const newValue: any = getObjectFromString( originalObjectJson ).object; + + if ( !Is.definedArray( oldValue ) && !Is.definedArray( newValue ) ) { + compareWatchObject( oldValue, newValue, watch ); + + if ( Is.definedFunction( watch.options.events!.onPropertyChange ) ) { + compareWatchObjectProperties( oldValue, newValue, watch ); + } + + } else { + fireCustomTriggerEvent( watch.options.events!.onChange!, oldValue, newValue ); + } + } + + watch.totalChanges++; + + if ( watch.options.pauseTimeoutOnChange! > 0 ) { + pauseWatchObject( storageId, watch.options.pauseTimeoutOnChange! ); + } + + if ( watch.options.cancelOnChange ) { + cancelWatchObject( storageId ); + } + + if ( watch.options.maximumChangesBeforeCanceling! > 0 && watch.totalChanges >= watch.options.maximumChangesBeforeCanceling! ) { + cancelWatchObject( storageId ); + } + } + } + } + + function compareWatchObject( oldObject: any, newObject: any, watch: ObserveWatch ) : void { + if ( Is.definedArray( watch.options.propertyNames ) ) { + const propertyNamesLength: number = watch.options.propertyNames!.length; + + for ( let propertyNameIndex: number = 0; propertyNameIndex < propertyNamesLength; propertyNameIndex++ ) { + const propertyName: string = watch.options.propertyNames![ propertyNameIndex ]; + + if ( oldObject[ propertyName ] !== newObject[ propertyName ] ) { + fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject ); + break; + } + } + + } else { + fireCustomTriggerEvent( watch.options.events!.onChange!, oldObject, newObject ); + } + } + + function compareWatchObjectProperties( oldObject: any, newObject: any, watch: ObserveWatch ) : void { + for ( var propertyName in oldObject ) { + if ( oldObject.hasOwnProperty( propertyName ) ) { + const propertyOldValue: any = oldObject[ propertyName ]; + let propertyNewValue: any = null; + + if ( newObject.hasOwnProperty( propertyName ) ) { + propertyNewValue = newObject[ propertyName ]; + } + + if ( Is.definedObject( propertyOldValue ) && Is.definedObject( propertyNewValue ) ) { + compareWatchObjectProperties( propertyOldValue, propertyNewValue, watch ); + } else { + + if ( !Is.definedArray( watch.options.propertyNames ) || watch.options.propertyNames!.indexOf( propertyName ) > -1 ) { + if ( JSON.stringify( propertyOldValue ) !== JSON.stringify( propertyNewValue ) ) { + fireCustomTriggerEvent( watch.options.events!.onPropertyChange!, propertyName, propertyOldValue, propertyNewValue ); + } + } + } + } + } + } + + function cancelWatchesForObjects() : void { + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) ) { + cancelWatchObject( storageId ); + } + } + } + + function cancelWatchObject( storageId: string ) : void { + if ( _watches.hasOwnProperty( storageId ) ) { + const watchOptions: WatchOptions = _watches[ storageId ].options; + + if ( watchOptions.allowCanceling || _watches_Cancel ) { + fireCustomTriggerEvent( watchOptions.events!.onCancel!, storageId ); + clearInterval( _watches[ storageId ].timer ); + + delete _watches[ storageId ]; + } + } + } + + function pauseWatchObject( storageId: string, milliseconds: number ) : boolean { + let result: boolean = false; + + if ( _watches.hasOwnProperty( storageId ) ) { + const watchOptions: WatchOptions = _watches[ storageId ].options; + + if ( watchOptions.allowPausing ) { + watchOptions.starts = new Date(); + watchOptions.starts.setMilliseconds( watchOptions.starts.getMilliseconds() + milliseconds ); + + result = true; + } + } + + return result; + } + + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Watch Options From e89895349e33425c4d6283a8b1f185ff88f3bca8 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:07:02 +0100 Subject: [PATCH 17/28] Added final private functions. --- dist/observe.esm.js | 52 +++++++++++++++++++++++++++++++++ dist/observe.esm.js.map | 2 +- dist/observe.js | 54 +++++++++++++++++++++++++++++++--- dist/observe.js.map | 2 +- dist/observe.min.js | 2 +- src/observe.ts | 64 ++++++++++++++++++++++++++++++++++++++++- 6 files changed, 168 insertions(+), 8 deletions(-) diff --git a/dist/observe.esm.js b/dist/observe.esm.js index 1d47ebd..d3054c6 100644 --- a/dist/observe.esm.js +++ b/dist/observe.esm.js @@ -10,6 +10,17 @@ var __commonJS = (e, t) => function n() { }).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"; @@ -135,6 +146,7 @@ var init_data = __esm({ var require_observe = __commonJS({ "src/observe.ts"(exports, module) { + init_constant(); init_data(); init_enum(); init_is(); @@ -142,6 +154,46 @@ var require_observe = __commonJS({ 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 o = r.length; + for (let e = 0; e < o; 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) { let r = null; if (Is.definedObject(e)) { diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map index 0f69545..20a31e5 100644 --- a/dist/observe.esm.js.map +++ b/dist/observe.esm.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/ts/enum.ts","../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Is","Data","String","result"],"mappings":";;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAgBiB;AAhBjB;AAAA;AAAA;AAaA;AAGO,MAAUA,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,WAA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M,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,qBAAO,SAAS;AAAA,YACpB;AAEA,mBAAO,SAAS;AAAA,UACpB;AAAA,QACJ;AAEA,eAAO;AAAA,MACX;AAEA,eAAS,SAAU,OAA0B;AACzC,YAAIA,UAAkB;AAEtB,YAAK,CAAC,eAAe,UAAW;AAC5B,kBAAQ,MAAO,KAAM;AACrB,UAAAA,UAAS;AAAA,QACb;AAEA,eAAOA;AAAA,MACX;AASA,MAAE,uBAAM;AAAA,MAER,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 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\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"version":3,"sources":["../src/ts/constant.ts","../src/ts/enum.ts","../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"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mBAAoB,QAAQ,OAAQ,UAAU,IAAM;AACpF,gBAAQ,OAAQ,UAAU,KAAK,mBAAoB,QAAQ,OAAQ,SAAS,IAAM;AAElF,eAAO;AAAA,MACX;AASA,eAAS,uBAAwB,oBAA8B,MAAsB;AACjF,YAAK,GAAG,gBAAiB,eAAgB,GAAI;AACzC,0BAAgB,MAAO,MAAM,CAAC,EAAE,MAAM,KAAM,MAAM,CAAE,CAAE;AAAA,QAC1D;AAAA,MACJ;AASA,eAAS,oBAAqB,cAAmC;AAC7D,cAAM,SAAuB;AAAA,UACzB,QAAQ;AAAA,UACR,QAAQ;AAAA,QACZ;AAEA,YAAI;AACA,cAAK,GAAG,cAAe,YAAa,GAAI;AACpC,mBAAO,SAAS,KAAK,MAAO,YAAa;AAAA,UAC7C;AAAA,QAEJ,SAAU,IAAU;AAChB,cAAI;AACA,mBAAO,SAAS,KAAM,IAAI,YAAY,GAAI;AAE1C,gBAAK,GAAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,qBAAO,SAAS,OAAO,OAAO;AAAA,YAClC;AAAA,UAEJ,SAAU,IAAU;AAChB,gBAAK,CAAC,eAAe,UAAW;AAC5B,uBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,qBAAO,SAAS;AAAA,YACpB;AAEA,mBAAO,SAAS;AAAA,UACpB;AAAA,QACJ;AAEA,eAAO;AAAA,MACX;AAEA,eAAS,SAAU,OAA0B;AACzC,YAAIA,UAAkB;AAEtB,YAAK,CAAC,eAAe,UAAW;AAC5B,kBAAQ,MAAO,KAAM;AACrB,UAAAA,UAAS;AAAA,QACb;AAEA,eAAOA;AAAA,MACX;AASA,MAAE,uBAAM;AAAA,MAER,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 { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.js b/dist/observe.js index d53e8a5..9e0169a 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -1,5 +1,11 @@ "use strict"; +var Constant; + +(e => { + e.OBSERVE_JS_ATTRIBUTE_NAME = "data-observe-js"; +})(Constant || (Constant = {})); + var Is; (e => { @@ -83,11 +89,11 @@ var Data; return Is.definedObject(e) ? e : t; } e.getDefaultObject = c; - function u(e, t) { + function l(e, t) { return Is.definedDate(e) ? e : t; } - e.getDefaultDate = u; - function l(e, t) { + e.getDefaultDate = l; + function u(e, t) { let n = t; if (Is.definedString(e)) { const o = e.toString().split("space"); @@ -101,13 +107,53 @@ var Data; } return n; } - e.getDefaultStringOrArray = l; + e.getDefaultStringOrArray = u; })(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 o = [].slice.call(t); + const r = o.length; + for (let e = 0; e < r; e++) { + if (!collectDOMObject(o[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 o = getObjectFromString(n); + if (o.parsed && Is.definedObject(o.object)) { + const t = getWatchOptions(o.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) { let o = null; if (Is.definedObject(e)) { diff --git a/dist/observe.js.map b/dist/observe.js.map index 5601b74..ebc9ec3 100644 --- a/dist/observe.js.map +++ b/dist/observe.js.map @@ -1 +1 @@ -{"version":3,"sources":["../src/ts/is.ts","../src/ts/data.ts","../src/observe.ts"],"names":["Is","Data","String","result"],"mappings":";;;AAgBO,IAAU;AAAA,CAAV,CAAUA,QAAV;AACI,WAAS,QAAS,OAAuB;AAC5C,WAAO,UAAU,QAAQ,UAAU,UAAa,MAAM,SAAS;AAAA,EACnE;AAFO,EAAAA,IAAS;AAIT,WAAS,cAAe,QAAwB;AACnD,WAAO,QA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AAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,iBAAO,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MAEJ,SAAU,IAAU;AAChB,YAAK,CAAC,eAAe,UAAW;AAC5B,mBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,iBAAO,SAAS;AAAA,QACpB;AAEA,eAAO,SAAS;AAAA,MACpB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,WAAS,SAAU,OAA0B;AACzC,QAAIA,UAAkB;AAEtB,QAAK,CAAC,eAAe,UAAW;AAC5B,cAAQ,MAAO,KAAM;AACrB,MAAAA,UAAS;AAAA,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 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\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\nimport { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 * Watch Object Creation / Handling\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n function createWatch( object: any, options: any, domElementId: string ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"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,E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B,QAAQ;AAAA,MACR,QAAQ;AAAA,IACZ;AAEA,QAAI;AACA,UAAK,GAAG,cAAe,YAAa,GAAI;AACpC,eAAO,SAAS,KAAK,MAAO,YAAa;AAAA,MAC7C;AAAA,IAEJ,SAAU,IAAU;AAChB,UAAI;AACA,eAAO,SAAS,KAAM,IAAI,YAAY,GAAI;AAE1C,YAAK,GAAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,iBAAO,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MAEJ,SAAU,IAAU;AAChB,YAAK,CAAC,eAAe,UAAW;AAC5B,mBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,iBAAO,SAAS;AAAA,QACpB;AAEA,eAAO,SAAS;AAAA,MACpB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,WAAS,SAAU,OAA0B;AACzC,QAAIA,UAAkB;AAEtB,QAAK,CAAC,eAAe,UAAW;AAC5B,cAAQ,MAAO,KAAM;AACrB,MAAAA,UAAS;AAAA,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.min.js b/dist/observe.min.js index d78b2d4..0044e99 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1 +1 @@ -"use strict";var n,t;(n=>{function t(n){return null!=n&&""!==n.toString()}function e(n){return t(n)&&"object"==typeof n}n.defined=t,n.definedObject=e,n.definedBoolean=function(n){return t(n)&&"boolean"==typeof n},n.definedString=function(n){return t(n)&&"string"==typeof n},n.definedFunction=function(n){return t(n)&&"function"==typeof n},n.definedNumber=function(n){return t(n)&&"number"==typeof n},n.definedArray=function(n){return e(n)&&n instanceof Array},n.definedDate=function(n){return e(n)&&n instanceof Date}})(n||(n={})),(t=>{let e;function r(t,e){return n.definedArray(t)?t:e}(e=t.String||(t.String={})).newGuid=function(){const n=[];for(let t=0;t<32;t++){8!==t&&12!==t&&16!==t&&20!==t||n.push("-");const e=Math.floor(16*Math.random()).toString(16);n.push(e)}return n.join("")},t.getDefaultAnyString=function(n,t){return"string"==typeof n?n:t},t.getDefaultString=function(t,e){return n.definedString(t)?t:e},t.getDefaultBoolean=function(t,e){return n.definedBoolean(t)?t:e},t.getDefaultNumber=function(t,e){return n.definedNumber(t)?t:e},t.getDefaultFunction=function(t,e){return n.definedFunction(t)?t:e},t.getDefaultArray=r,t.getDefaultObject=function(t,e){return n.definedObject(t)?t:e},t.getDefaultDate=function(t,e){return n.definedDate(t)?t:e},t.getDefaultStringOrArray=function(t,e){let i=e;if(n.definedString(t)){const n=t.toString().split("space");0===n.length?t=e:i=n}else i=r(t,e);return i}})(t||(t={})); \ No newline at end of file +"use strict";var n,e,t;(n||(n={})).OBSERVE_JS_ATTRIBUTE_NAME="data-observe-js",(n=>{function e(n){return null!=n&&""!==n.toString()}function t(n){return e(n)&&"object"==typeof n}n.defined=e,n.definedObject=t,n.definedBoolean=function(n){return e(n)&&"boolean"==typeof n},n.definedString=function(n){return e(n)&&"string"==typeof n},n.definedFunction=function(n){return e(n)&&"function"==typeof n},n.definedNumber=function(n){return e(n)&&"number"==typeof n},n.definedArray=function(n){return t(n)&&n instanceof Array},n.definedDate=function(n){return t(n)&&n instanceof Date}})(e||(e={})),(n=>{let t;function r(n,t){return e.definedArray(n)?n:t}(t=n.String||(n.String={})).newGuid=function(){const n=[];for(let e=0;e<32;e++){8!==e&&12!==e&&16!==e&&20!==e||n.push("-");const t=Math.floor(16*Math.random()).toString(16);n.push(t)}return n.join("")},n.getDefaultAnyString=function(n,e){return"string"==typeof n?n:e},n.getDefaultString=function(n,t){return e.definedString(n)?n:t},n.getDefaultBoolean=function(n,t){return e.definedBoolean(n)?n:t},n.getDefaultNumber=function(n,t){return e.definedNumber(n)?n:t},n.getDefaultFunction=function(n,t){return e.definedFunction(n)?n:t},n.getDefaultArray=r,n.getDefaultObject=function(n,t){return e.definedObject(n)?n:t},n.getDefaultDate=function(n,t){return e.definedDate(n)?n:t},n.getDefaultStringOrArray=function(n,t){let i=t;if(e.definedString(n)){const e=n.toString().split("space");0===e.length?n=t:i=e}else i=r(n,t);return i}})(t||(t={})); \ No newline at end of file diff --git a/src/observe.ts b/src/observe.ts index edbb9b7..890a8d7 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -10,10 +10,12 @@ * @copyright Bunoon 2024 */ + +import { type WatchOptionEvents, type WatchOptions, type Configuration } from "./ts/type"; +import { Constant } from "./ts/constant"; import { Data } from "./ts/data"; import { Char } from "./ts/enum"; import { Is } from "./ts/is"; -import { type WatchOptionEvents, type WatchOptions, type Configuration } from "./ts/type"; type StringToJson = { @@ -40,6 +42,66 @@ type ObserveWatch = { let _watches_Cancel: boolean = false; + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Observable DOM Object Creation / Handling + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function collectDOMObjects() : void { + const tagTypes: string[] = _configuration.domElementTypes as string[]; + const tagTypesLength: number = tagTypes.length; + + for ( let tagTypeIndex: number = 0; tagTypeIndex < tagTypesLength; tagTypeIndex++ ) { + const domElements: HTMLCollectionOf = document.getElementsByTagName( tagTypes[ tagTypeIndex ] ); + const elements: HTMLElement[] = [].slice.call( domElements ); + const elementsLength: number = elements.length; + + for ( let elementIndex: number = 0; elementIndex < elementsLength; elementIndex++ ) { + if ( !collectDOMObject( elements[ elementIndex ] ) ) { + break; + } + } + } + } + + function collectDOMObject( element: HTMLElement ) : boolean { + let result: boolean = true; + + if ( Is.defined( element ) && element.hasAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME ) ) { + const bindingOptionsData: string = element.getAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME )!; + + if ( Is.definedString( bindingOptionsData ) ) { + const watchOptionsJson: StringToJson = getObjectFromString( bindingOptionsData ); + + if ( watchOptionsJson.parsed && Is.definedObject( watchOptionsJson.object ) ) { + const watchOptions: WatchOptions = getWatchOptions( watchOptionsJson.object ); + + if ( !Is.definedString( element.id ) ) { + element.id = Data.String.newGuid(); + } + + if ( watchOptions.removeAttribute ) { + element.removeAttribute( Constant.OBSERVE_JS_ATTRIBUTE_NAME ); + } + + createWatch( element, watchOptions, element.id ); + + } else { + logError( _configuration.text!.attributeNotValidErrorText!.replace( "{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) ); + result = false; + } + + } else { + logError( _configuration.text!.attributeNotSetErrorText!.replace( "{{attribute_name}}", Constant.OBSERVE_JS_ATTRIBUTE_NAME ) ); + result = false; + } + } + + return result; + } + + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Watch Object Creation / Handling From a841d75d6acd0468ba31b49cd498dd5712935815 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:14:43 +0100 Subject: [PATCH 18/28] Added api.ts. --- dist/observe.esm.js.map | 2 +- dist/observe.js.map | 2 +- src/observe.ts | 16 ++-- src/ts/api.ts | 191 ++++++++++++++++++++++++++++++++++++++++ src/ts/type.ts | 11 ++- 5 files changed, 209 insertions(+), 13 deletions(-) create mode 100644 src/ts/api.ts diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map index 20a31e5..aac88d7 100644 --- a/dist/observe.esm.js.map +++ b/dist/observe.esm.js.map @@ -1 +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;AACn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,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,qBAAO,SAAS;AAAA,YACpB;AAEA,mBAAO,SAAS;AAAA,UACpB;AAAA,QACJ;AAEA,eAAO;AAAA,MACX;AAEA,eAAS,SAAU,OAA0B;AACzC,YAAIA,UAAkB;AAEtB,YAAK,CAAC,eAAe,UAAW;AAC5B,kBAAQ,MAAO,KAAM;AACrB,UAAAA,UAAS;AAAA,QACb;AAEA,eAAOA;AAAA,MACX;AASA,MAAE,uBAAM;AAAA,MAER,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 { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"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,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,aAAc,QAAwB;AAClD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAIT,eAAS,YAAa,QAAwB;AACjD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAAA,OA7BH;AAAA;AAAA;;;AChBjB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ACX;AASA,MAAE,uBAAM;AAAA,MAER,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 } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.js.map b/dist/observe.js.map index ebc9ec3..660796c 100644 --- a/dist/observe.js.map +++ b/dist/observe.js.map @@ -1 +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;;;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Z;AAEA,QAAI;AACA,UAAK,GAAG,cAAe,YAAa,GAAI;AACpC,eAAO,SAAS,KAAK,MAAO,YAAa;AAAA,MAC7C;AAAA,IAEJ,SAAU,IAAU;AAChB,UAAI;AACA,eAAO,SAAS,KAAM,IAAI,YAAY,GAAI;AAE1C,YAAK,GAAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,iBAAO,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MAEJ,SAAU,IAAU;AAChB,YAAK,CAAC,eAAe,UAAW;AAC5B,mBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,iBAAO,SAAS;AAAA,QACpB;AAEA,eAAO,SAAS;AAAA,MACpB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,WAAS,SAAU,OAA0B;AACzC,QAAIA,UAAkB;AAEtB,QAAK,CAAC,eAAe,UAAW;AAC5B,cAAQ,MAAO,KAAM;AACrB,MAAAA,UAAS;AAAA,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 { type WatchOptionEvents, type WatchOptions, type Configuration } from \"./ts/type\";\nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\n\n\ntype StringToJson = {\n parsed: boolean;\n object: any;\n};\n\ntype ObserveWatch = {\n options: WatchOptions;\n totalChanges: number;\n domElementId: string;\n cachedObject: any;\n originalObject: any;\n timer: number;\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"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,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,aAAc,QAAwB;AAClD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,EACxD;AAFO,EAAAA,IAAS;AAIT,WAAS,YAAa,QAAwB;AACjD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA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U,IAAM;AACpF,YAAQ,OAAQ,WAAW,KAAK,mBAAoB,QAAQ,OAAQ,UAAU,IAAM;AACpF,YAAQ,OAAQ,UAAU,KAAK,mBAAoB,QAAQ,OAAQ,SAAS,IAAM;AAElF,WAAO;AAAA,EACX;AASA,WAAS,uBAAwB,oBAA8B,MAAsB;AACjF,QAAK,GAAG,gBAAiB,eAAgB,GAAI;AACzC,sBAAgB,MAAO,MAAM,CAAC,EAAE,MAAM,KAAM,MAAM,CAAE,CAAE;AAAA,IAC1D;AAAA,EACJ;AASA,WAAS,oBAAqB,cAAmC;AAC7D,UAAM,SAAuB;AAAA,MACzB,QAAQ;AAAA,MACR,QAAQ;AAAA,IACZ;AAEA,QAAI;AACA,UAAK,GAAG,cAAe,YAAa,GAAI;AACpC,eAAO,SAAS,KAAK,MAAO,YAAa;AAAA,MAC7C;AAAA,IAEJ,SAAU,IAAU;AAChB,UAAI;AACA,eAAO,SAAS,KAAM,IAAI,YAAY,GAAI;AAE1C,YAAK,GAAG,gBAAiB,OAAO,MAAO,GAAI;AACvC,iBAAO,SAAS,OAAO,OAAO;AAAA,QAClC;AAAA,MAEJ,SAAU,IAAU;AAChB,YAAK,CAAC,eAAe,UAAW;AAC5B,mBAAU,eAAe,KAAM,gBAAiB,QAAS,eAAgB,GAAG,OAAQ,EAAE,QAAS,eAAgB,GAAG,OAAQ,CAAE;AAC5H,iBAAO,SAAS;AAAA,QACpB;AAEA,eAAO,SAAS;AAAA,MACpB;AAAA,IACJ;AAEA,WAAO;AAAA,EACX;AAEA,WAAS,SAAU,OAA0B;AACzC,QAAIA,UAAkB;AAEtB,QAAK,CAAC,eAAe,UAAW;AAC5B,cAAQ,MAAO,KAAM;AACrB,MAAAA,UAAS;AAAA,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file diff --git a/src/observe.ts b/src/observe.ts index 890a8d7..e25786d 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -11,7 +11,12 @@ */ -import { type WatchOptionEvents, type WatchOptions, type Configuration } from "./ts/type"; +import { + type WatchOptionEvents, + type WatchOptions, + type Configuration, + type ObserveWatch } from "./ts/type"; + import { Constant } from "./ts/constant"; import { Data } from "./ts/data"; import { Char } from "./ts/enum"; @@ -23,15 +28,6 @@ type StringToJson = { object: any; }; -type ObserveWatch = { - options: WatchOptions; - totalChanges: number; - domElementId: string; - cachedObject: any; - originalObject: any; - timer: number; -}; - ( () => { // Variables: Configuration diff --git a/src/ts/api.ts b/src/ts/api.ts new file mode 100644 index 0000000..467d9e8 --- /dev/null +++ b/src/ts/api.ts @@ -0,0 +1,191 @@ +/** + * Observe.js + * + * A lightweight JavaScript library that allows developers to keep track of changes to JavaScript objects and/or DOM elements. + * + * @file api.ts + * @version v1.0.0 + * @author Bunoon + * @license MIT License + * @copyright Bunoon 2024 + */ + + +import { type ObserveWatch, type WatchOptions } from "./type"; + + +export type PublicApi = { + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Watching Objects + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + /** + * watch(). + * + * Adds an object that should be watched for changes. + * + * @public + * + * @param {Object} object The object that should be watched. + * @param {Object} options All the options that should be used. + * + * @returns {string} The ID that object watch is stored under. + */ + watch: ( object: any, options: WatchOptions ) => string; + + /** + * cancelWatch(). + * + * Cancels the watching of an object for changes. + * + * @public + * + * @param {string} id The Id of the object being watched, or DOM element ID being watched. + * + * @returns {boolean} States if the object being watched has been cancelled. + */ + cancelWatch: ( id: string ) => boolean; + + /** + * cancelWatches(). + * + * Cancels all the watches currently running, or paused. + * + * @public + * + * @returns {Object} The Observe.js class instance. + */ + cancelWatches: () => PublicApi; + + /** + * getWatch(). + * + * Returns the properties for a running, or paused, watch. + * + * @public + * + * @param {string} id The Id of the object being watched, or DOM element ID being watched. + * + * @returns {Object} The watch properties for an object (null if not found). + */ + getWatch: ( id: string ) => ObserveWatch; + + /** + * getWatches(). + * + * Returns all the watches currently running, or paused. + * + * @public + * + * @returns {Object} The object of watches currently running, or paused. + */ + getWatches: () => Record; + + /** + * pauseWatch(). + * + * Pauses the watching of an object for changes for a specific number of milliseconds. + * + * @public + * + * @param {string} id The Id of the object being watched, or DOM element ID being watched. + * @param {number} milliseconds The milliseconds to pause the watch for. + * + * @returns {boolean} States if the object being watched has been paused. + */ + pauseWatch: ( id: string, milliseconds: number ) => boolean; + + /** + * pauseWatches(). + * + * Pauses all the watches for a specific number of milliseconds. + * + * @public + * + * @param {number} milliseconds The milliseconds to pause the watches for. + * + * @returns {Object} The Observe.js class instance. + */ + pauseWatches: ( milliseconds: number ) => PublicApi; + + /** + * resumeWatch(). + * + * Resumes the watching of an object for changes after it was paused. + * + * @public + * + * @param {string} id The Id of the object being watched, or DOM element ID being watched. + * + * @returns {boolean} States if the watching of an object has been resumed + */ + resumeWatch: ( id: string ) => boolean; + + /** + * resumeWatches(). + * + * Resumes all the watches that are currently paused. + * + * @public + * + * @returns {Object} The Observe.js class instance. + */ + resumeWatches: () => PublicApi; + + /** + * searchDomForNewWatches(). + * + * Searches the DOM for new elements to watch, and adds them. + * + * @public + * + * @returns {Object} The Observe.js class instance. + */ + searchDomForNewWatches: () => PublicApi; + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Configuration + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + /** + * setConfiguration(). + * + * Sets the specific configuration options that should be used. + * + * @public + * + * @param {Options} newConfiguration All the configuration options that should be set (refer to "Options" documentation for properties). + * + * @returns {Object} The Observe.js class instance. + */ + setConfiguration: ( configuration: any ) => PublicApi; + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Additional Data + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + /** + * getVersion(). + * + * Returns the version of Observe.js. + * + * @public + * + * @returns {string} The version number. + */ + getVersion: () => string; +}; + +declare global { + interface Window { + $observe: PublicApi; + } +} \ No newline at end of file diff --git a/src/ts/type.ts b/src/ts/type.ts index 64c0436..eccd37a 100644 --- a/src/ts/type.ts +++ b/src/ts/type.ts @@ -44,4 +44,13 @@ export type WatchOptionEvents = { onCancel?: Function; onRemove?: Function; onStart?: Function; -} \ No newline at end of file +} + +export type ObserveWatch = { + options: WatchOptions; + totalChanges: number; + domElementId: string; + cachedObject: any; + originalObject: any; + timer: number; +}; \ No newline at end of file From 0ed3649cc3eb2468f25505f46b0a8bdf79567244 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:18:13 +0100 Subject: [PATCH 19/28] Added API structure. --- src/observe.ts | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/observe.ts b/src/observe.ts index e25786d..1bb6963 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -21,6 +21,7 @@ import { Constant } from "./ts/constant"; import { Data } from "./ts/data"; import { Char } from "./ts/enum"; import { Is } from "./ts/is"; +import { type PublicApi } from "./ts/api"; type StringToJson = { @@ -413,6 +414,83 @@ type StringToJson = { } + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + const _public: PublicApi = { + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Watching Objects + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + watch: function ( object: any, options: WatchOptions ) : string { + throw new Error("Function not implemented."); + }, + + cancelWatch: function ( id: string ) : boolean { + throw new Error("Function not implemented."); + }, + + cancelWatches: function () : PublicApi { + throw new Error("Function not implemented."); + }, + + getWatch: function ( id: string ) : ObserveWatch { + throw new Error("Function not implemented."); + }, + + getWatches: function () : Record { + throw new Error("Function not implemented."); + }, + + pauseWatch: function ( id: string, milliseconds: number ) : boolean { + throw new Error("Function not implemented."); + }, + + pauseWatches: function ( milliseconds: number ) : PublicApi { + throw new Error("Function not implemented."); + }, + + resumeWatch: function ( id: string ) : boolean { + throw new Error("Function not implemented."); + }, + + resumeWatches: function () : PublicApi { + throw new Error("Function not implemented."); + }, + + searchDomForNewWatches: function () : PublicApi { + throw new Error("Function not implemented."); + }, + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Configuration + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + setConfiguration: function ( configuration: any ) : PublicApi { + throw new Error("Function not implemented."); + }, + + + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Additional Data + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + getVersion: function () : string { + throw new Error("Function not implemented."); + } + }; + + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Initialize Observe.js From 62e1b5aab717d3e0b8d0d4e4ffefee43cedeb031 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:25:23 +0100 Subject: [PATCH 20/28] Added public function implementations. --- dist/observe.esm.js | 221 +++++++++++++++++++++++------ dist/observe.esm.js.map | 2 +- dist/observe.js | 303 +++++++++++++++++++++++++++++----------- dist/observe.js.map | 2 +- src/observe.ts | 157 +++++++++++++++++++-- src/ts/api.ts | 2 +- 6 files changed, 540 insertions(+), 147 deletions(-) diff --git a/dist/observe.esm.js b/dist/observe.esm.js index d3054c6..095ada8 100644 --- a/dist/observe.esm.js +++ b/dist/observe.esm.js @@ -46,14 +46,14 @@ var init_is = __esm({ return t(e) && typeof e === "boolean"; } e.definedBoolean = r; - function o(e) { + function a(e) { return t(e) && typeof e === "string"; } - e.definedString = o; - function a(e) { + e.definedString = a; + function o(e) { return t(e) && typeof e === "function"; } - e.definedFunction = a; + e.definedFunction = o; function i(e) { return t(e) && typeof e === "number"; } @@ -101,14 +101,14 @@ var init_data = __esm({ return Is.definedString(e) ? e : t; } e.getDefaultString = r; - function o(e, t) { + function a(e, t) { return Is.definedBoolean(e) ? e : t; } - e.getDefaultBoolean = o; - function a(e, t) { + e.getDefaultBoolean = a; + function o(e, t) { return Is.definedNumber(e) ? e : t; } - e.getDefaultNumber = a; + e.getDefaultNumber = o; function i(e, t) { return Is.definedFunction(e) ? e : t; } @@ -125,7 +125,7 @@ var init_data = __esm({ return Is.definedDate(e) ? e : t; } e.getDefaultDate = u; - function l(e, t) { + function f(e, t) { let n = t; if (Is.definedString(e)) { const r = e.toString().split("space"); @@ -139,7 +139,7 @@ var init_data = __esm({ } return n; } - e.getDefaultStringOrArray = l; + e.getDefaultStringOrArray = f; })(Data || (Data = {})); } }); @@ -160,8 +160,8 @@ var require_observe = __commonJS({ for (let n = 0; n < t; n++) { const t = document.getElementsByTagName(e[n]); const r = [].slice.call(t); - const o = r.length; - for (let e = 0; e < o; e++) { + const a = r.length; + for (let e = 0; e < a; e++) { if (!collectDOMObject(r[e])) { break; } @@ -194,34 +194,34 @@ var require_observe = __commonJS({ } return t; } - function createWatch(e, t, n) { + function createWatch(e, t, n = null) { let r = null; if (Is.definedObject(e)) { r = Data.String.newGuid(); - const o = getWatchOptions(t); - const a = {}; + const a = getWatchOptions(t); + const o = {}; let i = null; - a.options = o; - a.totalChanges = 0; + o.options = a; + o.totalChanges = 0; if (Is.definedString(n)) { const e = document.getElementById(n); if (Is.defined(e)) { - a.domElementId = n; - a.cachedObject = e.outerHTML; - a.originalObject = e.outerHTML; + o.domElementId = n; + o.cachedObject = e.outerHTML; + o.originalObject = e.outerHTML; i = e.outerHTML; } } else { - a.cachedObject = JSON.stringify(e); - a.originalObject = e; + o.cachedObject = JSON.stringify(e); + o.originalObject = e; i = e; } - if (Is.defined(a.cachedObject)) { - fireCustomTriggerEvent(a.options.events.onStart, i); - a.timer = setInterval((function() { - watchTimer(o, r); - }), o.timeout); - _watches[r] = a; + 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; @@ -249,23 +249,23 @@ var require_observe = __commonJS({ fireCustomTriggerEvent(t.options.events.onRemove, t.domElementId); } } - const o = t.cachedObject; - const a = t.originalObject; - const i = !n ? JSON.stringify(a) : a; - if (o !== i) { + 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(o).object; + t.originalObject = getObjectFromString(a).object; } } else { t.cachedObject = i; } if (n) { - fireCustomTriggerEvent(t.options.events.onChange, o, i); + fireCustomTriggerEvent(t.options.events.onChange, a, i); } else { - const e = getObjectFromString(o).object; + const e = getObjectFromString(a).object; const n = getObjectFromString(i).object; if (!Is.definedArray(e) && !Is.definedArray(n)) { compareWatchObject(e, n, t); @@ -292,8 +292,8 @@ var require_observe = __commonJS({ function compareWatchObject(e, t, n) { if (Is.definedArray(n.options.propertyNames)) { const r = n.options.propertyNames.length; - for (let o = 0; o < r; o++) { - const r = n.options.propertyNames[o]; + 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; @@ -306,17 +306,17 @@ var require_observe = __commonJS({ function compareWatchObjectProperties(e, t, n) { for (var r in e) { if (e.hasOwnProperty(r)) { - const o = e[r]; - let a = null; + const a = e[r]; + let o = null; if (t.hasOwnProperty(r)) { - a = t[r]; + o = t[r]; } - if (Is.definedObject(o) && Is.definedObject(a)) { - compareWatchObjectProperties(o, a, n); + 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(o) !== JSON.stringify(a)) { - fireCustomTriggerEvent(n.options.events.onPropertyChange, r, o, a); + if (JSON.stringify(a) !== JSON.stringify(o)) { + fireCustomTriggerEvent(n.options.events.onPropertyChange, r, a, o); } } } @@ -415,6 +415,139 @@ var require_observe = __commonJS({ } return t; } + function buildDefaultConfiguration(e) { + _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"; + } + }; (() => {})(); })(); } diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map index aac88d7..4186ed7 100644 --- a/dist/observe.esm.js.map +++ b/dist/observe.esm.js.map @@ -1 +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,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,aAAc,QAAwB;AAClD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;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ACzC,YAAIA,UAAkB;AAEtB,YAAK,CAAC,eAAe,UAAW;AAC5B,kBAAQ,MAAO,KAAM;AACrB,UAAAA,UAAS;AAAA,QACb;AAEA,eAAOA;AAAA,MACX;AASA,MAAE,uBAAM;AAAA,MAER,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 } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"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;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,SAAU,EAAE,iBAAiB,IAAK;AAC/I,2BAAU,SAAU,EAAE,QAAQ,SAAS;AACvC,kBAAAA,UAAS;AACT;AAAA,gBACJ;AAAA,cACJ;AAAA,YACJ;AAAA,UACJ;AAEA,iBAAOA;AAAA,QACX;AAAA,QAEA,eAAe,WAAwB;AACnC,mBAAU,aAAa,UAAW;AAC9B,gBAAK,SAAS,eAAgB,SAAU,GAAI;AACxC,uBAAU,SAAU,EAAE,QAAQ,SAAS;AAAA,YAC3C;AAAA,UACJ;AAEA,iBAAO;AAAA,QACX;AAAA,QAEA,wBAAwB,WAAwB;AAC5C,4BAAkB;AAElB,iBAAO;AAAA,QACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,QASA,kBAAkB,SAAW,kBAAoC;AAC7D,cAAK,GAAG,cAAe,gBAAiB,GAAI;AACxC,gBAAI,0BAAmC;AACvC,kBAAM,2BAAgC;AAEtC,qBAAU,gBAAgB,kBAAmB;AACzC,kBAAK,iBAAiB,eAAgB,YAAa,KAAK,eAAe,eAAgB,YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,yCAA0B,YAAa,IAAI,iBAAkB,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,MAAE,uBAAM;AAAA,MAER,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 ( var 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 ) : 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\n } )();\n} )();"]} \ No newline at end of file diff --git a/dist/observe.js b/dist/observe.js index 9e0169a..a746b74 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -17,30 +17,30 @@ var Is; return t(e) && typeof e === "object"; } e.definedObject = n; - function o(e) { + function r(e) { return t(e) && typeof e === "boolean"; } - e.definedBoolean = o; - function r(e) { + e.definedBoolean = r; + function a(e) { return t(e) && typeof e === "string"; } - e.definedString = r; - function a(e) { + e.definedString = a; + function o(e) { return t(e) && typeof e === "function"; } - e.definedFunction = a; + e.definedFunction = o; function i(e) { return t(e) && typeof e === "number"; } e.definedNumber = i; - function s(e) { + function c(e) { return n(e) && e instanceof Array; } - e.definedArray = s; - function c(e) { + e.definedArray = c; + function s(e) { return n(e) && e instanceof Date; } - e.definedDate = c; + e.definedDate = s; })(Is || (Is = {})); var Data; @@ -65,49 +65,49 @@ var Data; return typeof e === "string" ? e : t; } e.getDefaultAnyString = n; - function o(e, t) { + function r(e, t) { return Is.definedString(e) ? e : t; } - e.getDefaultString = o; - function r(e, t) { + e.getDefaultString = r; + function a(e, t) { return Is.definedBoolean(e) ? e : t; } - e.getDefaultBoolean = r; - function a(e, t) { + e.getDefaultBoolean = a; + function o(e, t) { return Is.definedNumber(e) ? e : t; } - e.getDefaultNumber = a; + e.getDefaultNumber = o; function i(e, t) { return Is.definedFunction(e) ? e : t; } e.getDefaultFunction = i; - function s(e, t) { + function c(e, t) { return Is.definedArray(e) ? e : t; } - e.getDefaultArray = s; - function c(e, t) { + e.getDefaultArray = c; + function s(e, t) { return Is.definedObject(e) ? e : t; } - e.getDefaultObject = c; - function l(e, t) { + e.getDefaultObject = s; + function u(e, t) { return Is.definedDate(e) ? e : t; } - e.getDefaultDate = l; - function u(e, t) { + e.getDefaultDate = u; + function f(e, t) { let n = t; if (Is.definedString(e)) { - const o = e.toString().split("space"); - if (o.length === 0) { + const r = e.toString().split("space"); + if (r.length === 0) { e = t; } else { - n = o; + n = r; } } else { - n = s(e, t); + n = c(e, t); } return n; } - e.getDefaultStringOrArray = u; + e.getDefaultStringOrArray = f; })(Data || (Data = {})); (() => { @@ -119,10 +119,10 @@ var Data; const t = e.length; for (let n = 0; n < t; n++) { const t = document.getElementsByTagName(e[n]); - const o = [].slice.call(t); - const r = o.length; - for (let e = 0; e < r; e++) { - if (!collectDOMObject(o[e])) { + const r = [].slice.call(t); + const a = r.length; + for (let e = 0; e < a; e++) { + if (!collectDOMObject(r[e])) { break; } } @@ -133,9 +133,9 @@ var Data; 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 o = getObjectFromString(n); - if (o.parsed && Is.definedObject(o.object)) { - const t = getWatchOptions(o.object); + 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(); } @@ -154,37 +154,37 @@ var Data; } return t; } - function createWatch(e, t, n) { - let o = null; + function createWatch(e, t, n = null) { + let r = null; if (Is.definedObject(e)) { - o = Data.String.newGuid(); - const r = getWatchOptions(t); - const a = {}; + r = Data.String.newGuid(); + const a = getWatchOptions(t); + const o = {}; let i = null; - a.options = r; - a.totalChanges = 0; + o.options = a; + o.totalChanges = 0; if (Is.definedString(n)) { const e = document.getElementById(n); if (Is.defined(e)) { - a.domElementId = n; - a.cachedObject = e.outerHTML; - a.originalObject = e.outerHTML; + o.domElementId = n; + o.cachedObject = e.outerHTML; + o.originalObject = e.outerHTML; i = e.outerHTML; } } else { - a.cachedObject = JSON.stringify(e); - a.originalObject = e; + o.cachedObject = JSON.stringify(e); + o.originalObject = e; i = e; } - if (Is.defined(a.cachedObject)) { - fireCustomTriggerEvent(a.options.events.onStart, i); - a.timer = setInterval((function() { - watchTimer(r, o); - }), r.timeout); - _watches[o] = a; + if (Is.defined(o.cachedObject)) { + fireCustomTriggerEvent(o.options.events.onStart, i); + o.timer = setInterval((function() { + watchTimer(a, r); + }), a.timeout); + _watches[r] = o; } } - return o; + return r; } function watchTimer(e, t) { const n = new Date; @@ -199,33 +199,33 @@ var Data; if (_watches.hasOwnProperty(e)) { const t = _watches[e]; const n = Is.definedString(t.domElementId); - let o = null; + let r = null; if (n) { - o = document.getElementById(t.domElementId); - if (Is.defined(o)) { - t.originalObject = o.outerHTML; + r = document.getElementById(t.domElementId); + if (Is.defined(r)) { + t.originalObject = r.outerHTML; } else { t.originalObject = ""; fireCustomTriggerEvent(t.options.events.onRemove, t.domElementId); } } - const r = t.cachedObject; - const a = t.originalObject; - const i = !n ? JSON.stringify(a) : a; - if (r !== i) { + const a = t.cachedObject; + const o = t.originalObject; + const i = !n ? JSON.stringify(o) : o; + if (a !== i) { if (t.options.reset) { if (n) { - o.outerHTML = t.cachedObject; + r.outerHTML = t.cachedObject; } else { - t.originalObject = getObjectFromString(r).object; + t.originalObject = getObjectFromString(a).object; } } else { t.cachedObject = i; } if (n) { - fireCustomTriggerEvent(t.options.events.onChange, r, i); + fireCustomTriggerEvent(t.options.events.onChange, a, i); } else { - const e = getObjectFromString(r).object; + const e = getObjectFromString(a).object; const n = getObjectFromString(i).object; if (!Is.definedArray(e) && !Is.definedArray(n)) { compareWatchObject(e, n, t); @@ -251,10 +251,10 @@ var Data; } function compareWatchObject(e, t, n) { if (Is.definedArray(n.options.propertyNames)) { - const o = n.options.propertyNames.length; - for (let r = 0; r < o; r++) { - const o = n.options.propertyNames[r]; - if (e[o] !== t[o]) { + 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; } @@ -264,19 +264,19 @@ var Data; } } function compareWatchObjectProperties(e, t, n) { - for (var o in e) { - if (e.hasOwnProperty(o)) { - const r = e[o]; - let a = null; - if (t.hasOwnProperty(o)) { - a = t[o]; + for (var r in e) { + if (e.hasOwnProperty(r)) { + const a = e[r]; + let o = null; + if (t.hasOwnProperty(r)) { + o = t[r]; } - if (Is.definedObject(r) && Is.definedObject(a)) { - compareWatchObjectProperties(r, a, n); + if (Is.definedObject(a) && Is.definedObject(o)) { + compareWatchObjectProperties(a, o, n); } else { - if (!Is.definedArray(n.options.propertyNames) || n.options.propertyNames.indexOf(o) > -1) { - if (JSON.stringify(r) !== JSON.stringify(a)) { - fireCustomTriggerEvent(n.options.events.onPropertyChange, o, r, a); + 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); } } } @@ -303,10 +303,10 @@ var Data; function pauseWatchObject(e, t) { let n = false; if (_watches.hasOwnProperty(e)) { - const o = _watches[e].options; - if (o.allowPausing) { - o.starts = new Date; - o.starts.setMilliseconds(o.starts.getMilliseconds() + t); + const r = _watches[e].options; + if (r.allowPausing) { + r.starts = new Date; + r.starts.setMilliseconds(r.starts.getMilliseconds() + t); n = true; } } @@ -375,5 +375,138 @@ var Data; } return t; } + function buildDefaultConfiguration(e) { + _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"; + } + }; (() => {})(); })();//# sourceMappingURL=observe.js.map \ No newline at end of file diff --git a/dist/observe.js.map b/dist/observe.js.map index 660796c..911a9dd 100644 --- a/dist/observe.js.map +++ b/dist/observe.js.map @@ -1 +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,EAClD;AAFO,EAAAA,IAAS;AAIT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A,IACb;AAEA,WAAOA;AAAA,EACX;AASA,EAAE,uBAAM;AAAA,EAER,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 } from \"./ts/type\";\n \nimport { Constant } from \"./ts/constant\";\nimport { Data } from \"./ts/data\";\nimport { Char } from \"./ts/enum\";\nimport { Is } from \"./ts/is\";\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 ) : 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 ( var 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 /*\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n * Initialize Observe.js\n * ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------\n */\n\n ( () => {\n\n } )();\n} )();"]} \ No newline at end of file +{"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,QAA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YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,qCAA0B,YAAa,IAAI,iBAAkB,YAAa;AAC1E,sCAA0B;AAAA,UAC9B;AAAA,QACJ;AAEA,YAAK,yBAA0B;AAC3B,oCAA2B,wBAAyB;AAAA,QACxD;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,YAAY,WAAqB;AAC7B,aAAO;AAAA,IACX;AAAA,EACJ;AASA,EAAE,uBAAM;AAAA,EAER,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 ( var 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 ) : 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\n } )();\n} )();"]} \ No newline at end of file diff --git a/src/observe.ts b/src/observe.ts index 1bb6963..59aade0 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -15,7 +15,8 @@ import { type WatchOptionEvents, type WatchOptions, type Configuration, - type ObserveWatch } from "./ts/type"; + type ObserveWatch, + type ConfigurationText } from "./ts/type"; import { Constant } from "./ts/constant"; import { Data } from "./ts/data"; @@ -105,7 +106,7 @@ type StringToJson = { * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - function createWatch( object: any, options: any, domElementId: string ) : string { + function createWatch( object: any, options: any, domElementId: string = null! ) : string { let storageId: string = null!; if ( Is.definedObject( object ) ) { @@ -414,6 +415,28 @@ type StringToJson = { } + /* + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + * Public API Functions: Helpers: Configuration + * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + */ + + function buildDefaultConfiguration( newConfiguration: any ) : void { + _configuration = Data.getDefaultObject( newConfiguration, {} as Configuration ); + _configuration.safeMode = Data.getDefaultBoolean( _configuration.safeMode, true ); + _configuration.domElementTypes = Data.getDefaultStringOrArray( _configuration.domElementTypes, [ "*" ] ); + + buildDefaultConfigurationStrings(); + } + + function buildDefaultConfigurationStrings() : void { + _configuration.text = Data.getDefaultObject( _configuration.text, {} as ConfigurationText ); + _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." ); + } + + /* * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- * Public API Functions: @@ -428,43 +451,131 @@ type StringToJson = { */ watch: function ( object: any, options: WatchOptions ) : string { - throw new Error("Function not implemented."); + return createWatch( object, options ); }, cancelWatch: function ( id: string ) : boolean { - throw new Error("Function not implemented."); + let result: boolean = false; + + if ( Is.definedString( id ) ) { + if ( _watches.hasOwnProperty( id ) ) { + cancelWatchObject( id ); + + result = true; + } else { + + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) { + cancelWatchObject( storageId ); + + result = true; + break; + } + } + } + } + + return result; }, cancelWatches: function () : PublicApi { - throw new Error("Function not implemented."); + cancelWatchesForObjects(); + + return _public; }, getWatch: function ( id: string ) : ObserveWatch { - throw new Error("Function not implemented."); + let result: ObserveWatch = null!; + + if ( Is.definedString( id ) ) { + if ( _watches.hasOwnProperty( id ) ) { + result = _watches[ id ]; + } else { + + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) { + result = _watches[ storageId ]; + break; + } + } + } + } + + return result; }, getWatches: function () : Record { - throw new Error("Function not implemented."); + return _watches; }, pauseWatch: function ( id: string, milliseconds: number ) : boolean { - throw new Error("Function not implemented."); + let result: boolean = false; + + if ( Is.definedString( id ) && Is.definedNumber( milliseconds ) ) { + if ( _watches.hasOwnProperty( id ) ) { + result = pauseWatchObject( id, milliseconds ); + } else { + + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) { + result = pauseWatchObject( storageId, milliseconds ); + break; + } + } + } + } + + return result; }, pauseWatches: function ( milliseconds: number ) : PublicApi { - throw new Error("Function not implemented."); + if ( Is.definedNumber( milliseconds ) ) { + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) ) { + pauseWatchObject( storageId, milliseconds ); + } + } + } + + return _public; }, resumeWatch: function ( id: string ) : boolean { - throw new Error("Function not implemented."); + let result: boolean = false; + + if ( Is.definedString( id ) ) { + if ( _watches.hasOwnProperty( id ) ) { + _watches[ id ].options.starts = null!; + result = true; + } else { + + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) && Is.definedString( _watches[ storageId ].domElementId ) && _watches[ storageId ].domElementId === id ) { + _watches[ storageId ].options.starts = null!; + result = true; + break; + } + } + } + } + + return result; }, resumeWatches: function () : PublicApi { - throw new Error("Function not implemented."); + for ( let storageId in _watches ) { + if ( _watches.hasOwnProperty( storageId ) ) { + _watches[ storageId ].options.starts = null!; + } + } + + return _public; }, searchDomForNewWatches: function () : PublicApi { - throw new Error("Function not implemented."); + collectDOMObjects(); + + return _public; }, @@ -474,8 +585,24 @@ type StringToJson = { * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - setConfiguration: function ( configuration: any ) : PublicApi { - throw new Error("Function not implemented."); + setConfiguration: function ( newConfiguration: any ) : PublicApi { + if ( Is.definedObject( newConfiguration ) ) { + let configurationHasChanged: boolean = false; + const newInternalConfiguration: any = _configuration; + + for ( let propertyName in newConfiguration ) { + if ( newConfiguration.hasOwnProperty( propertyName ) && _configuration.hasOwnProperty( propertyName ) && newInternalConfiguration[ propertyName ] !== newConfiguration[ propertyName ] ) { + newInternalConfiguration[ propertyName ] = newConfiguration[ propertyName ]; + configurationHasChanged = true; + } + } + + if ( configurationHasChanged ) { + buildDefaultConfiguration( newInternalConfiguration ); + } + } + + return _public; }, @@ -486,7 +613,7 @@ type StringToJson = { */ getVersion: function () : string { - throw new Error("Function not implemented."); + return "1.0.0"; } }; diff --git a/src/ts/api.ts b/src/ts/api.ts index 467d9e8..0d79bf4 100644 --- a/src/ts/api.ts +++ b/src/ts/api.ts @@ -163,7 +163,7 @@ export type PublicApi = { * * @returns {Object} The Observe.js class instance. */ - setConfiguration: ( configuration: any ) => PublicApi; + setConfiguration: ( newConfiguration: any ) => PublicApi; /* From 1cb9a954d168c00eaf5bcd5629024347b3a6a420 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:27:09 +0100 Subject: [PATCH 21/28] Added initializer. --- dist/observe.esm.js | 16 ++++++++++++++-- dist/observe.esm.js.map | 2 +- dist/observe.js | 16 ++++++++++++++-- dist/observe.js.map | 2 +- dist/observe.min.js | 2 +- src/observe.ts | 16 +++++++++++++++- 6 files changed, 46 insertions(+), 8 deletions(-) diff --git a/dist/observe.esm.js b/dist/observe.esm.js index 095ada8..4db7a91 100644 --- a/dist/observe.esm.js +++ b/dist/observe.esm.js @@ -415,7 +415,7 @@ var require_observe = __commonJS({ } return t; } - function buildDefaultConfiguration(e) { + function buildDefaultConfiguration(e = null) { _configuration = Data.getDefaultObject(e, {}); _configuration.safeMode = Data.getDefaultBoolean(_configuration.safeMode, true); _configuration.domElementTypes = Data.getDefaultStringOrArray(_configuration.domElementTypes, [ "*" ]); @@ -548,7 +548,19 @@ var require_observe = __commonJS({ 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; + } + })(); })(); } }); diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map index 4186ed7..a3dd932 100644 --- a/dist/observe.esm.js.map +++ b/dist/observe.esm.js.map @@ -1 +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,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,aAAc,QAAwB;AAClD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAIT,eAAS,YAAa,QAAwB;AACjD,eAAO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A,QASA,YAAY,WAAqB;AAC7B,iBAAO;AAAA,QACX;AAAA,MACJ;AASA,MAAE,uBAAM;AAAA,MAER,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 ( var 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 ) : 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\n } )();\n} )();"]} \ No newline at end of file +{"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,Q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AI;AACxC,gBAAI,0BAAmC;AACvC,kBAAM,2BAAgC;AAEtC,qBAAU,gBAAgB,kBAAmB;AACzC,kBAAK,iBAAiB,eAAgB,YAAa,KAAK,eAAe,eAAgB,YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,yCAA0B,YAAa,IAAI,iBAAkB,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 ( var 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.js b/dist/observe.js index a746b74..c8c17e2 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -375,7 +375,7 @@ var Data; } return t; } - function buildDefaultConfiguration(e) { + function buildDefaultConfiguration(e = null) { _configuration = Data.getDefaultObject(e, {}); _configuration.safeMode = Data.getDefaultBoolean(_configuration.safeMode, true); _configuration.domElementTypes = Data.getDefaultStringOrArray(_configuration.domElementTypes, [ "*" ]); @@ -508,5 +508,17 @@ var Data; 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; + } + })(); })();//# sourceMappingURL=observe.js.map \ No newline at end of file diff --git a/dist/observe.js.map b/dist/observe.js.map index 911a9dd..574c804 100644 --- a/dist/observe.js.map +++ b/dist/observe.js.map @@ -1 +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,Q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B,YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,qCAA0B,YAAa,IAAI,iBAAkB,YAAa;AAC1E,sCAA0B;AAAA,UAC9B;AAAA,QACJ;AAEA,YAAK,yBAA0B;AAC3B,oCAA2B,wBAAyB;AAAA,QACxD;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,YAAY,WAAqB;AAC7B,aAAO;AAAA,IACX;AAAA,EACJ;AASA,EAAE,uBAAM;AAAA,EAER,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 ( var 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 ) : 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\n } )();\n} )();"]} \ No newline at end of file +{"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,IAA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A0B;AAC3B,oCAA2B,wBAAyB;AAAA,QACxD;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,YAAY,WAAqB;AAC7B,aAAO;AAAA,IACX;AAAA,EACJ;AASA,GAAE,MAAM;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 ( var 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 0044e99..80ad123 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1 +1 @@ -"use strict";var n,e,t;(n||(n={})).OBSERVE_JS_ATTRIBUTE_NAME="data-observe-js",(n=>{function e(n){return null!=n&&""!==n.toString()}function t(n){return e(n)&&"object"==typeof n}n.defined=e,n.definedObject=t,n.definedBoolean=function(n){return e(n)&&"boolean"==typeof n},n.definedString=function(n){return e(n)&&"string"==typeof n},n.definedFunction=function(n){return e(n)&&"function"==typeof n},n.definedNumber=function(n){return e(n)&&"number"==typeof n},n.definedArray=function(n){return t(n)&&n instanceof Array},n.definedDate=function(n){return t(n)&&n instanceof Date}})(e||(e={})),(n=>{let t;function r(n,t){return e.definedArray(n)?n:t}(t=n.String||(n.String={})).newGuid=function(){const n=[];for(let e=0;e<32;e++){8!==e&&12!==e&&16!==e&&20!==e||n.push("-");const t=Math.floor(16*Math.random()).toString(16);n.push(t)}return n.join("")},n.getDefaultAnyString=function(n,e){return"string"==typeof n?n:e},n.getDefaultString=function(n,t){return e.definedString(n)?n:t},n.getDefaultBoolean=function(n,t){return e.definedBoolean(n)?n:t},n.getDefaultNumber=function(n,t){return e.definedNumber(n)?n:t},n.getDefaultFunction=function(n,t){return e.definedFunction(n)?n:t},n.getDefaultArray=r,n.getDefaultObject=function(n,t){return e.definedObject(n)?n:t},n.getDefaultDate=function(n,t){return e.definedDate(n)?n:t},n.getDefaultStringOrArray=function(n,t){let i=t;if(e.definedString(n)){const e=n.toString().split("space");0===e.length?n=t:i=e}else i=r(n,t);return i}})(t||(t={})); \ 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/src/observe.ts b/src/observe.ts index 59aade0..6a64935 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -421,7 +421,7 @@ type StringToJson = { * ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- */ - function buildDefaultConfiguration( newConfiguration: any ) : void { + function buildDefaultConfiguration( newConfiguration: any = null ) : void { _configuration = Data.getDefaultObject( newConfiguration, {} as Configuration ); _configuration.safeMode = Data.getDefaultBoolean( _configuration.safeMode, true ); _configuration.domElementTypes = Data.getDefaultStringOrArray( _configuration.domElementTypes, [ "*" ] ); @@ -625,6 +625,20 @@ type StringToJson = { */ ( () => { + buildDefaultConfiguration(); + document.addEventListener( "DOMContentLoaded", function() { + collectDOMObjects(); + } ); + + window.addEventListener( "pagehide", function() { + _watches_Cancel = true; + + cancelWatchesForObjects(); + } ); + + if ( !Is.defined( window.$observe ) ) { + window.$observe = _public; + } } )(); } )(); \ No newline at end of file From c5f87c6cc5c077ca4ff9808e976af068986d30d8 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:29:42 +0100 Subject: [PATCH 22/28] Updated HTML. --- test/observe.js.basic.html | 4 ++-- test/observe.js.min.html | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/test/observe.js.basic.html b/test/observe.js.basic.html index d8cb180..df9deff 100644 --- a/test/observe.js.basic.html +++ b/test/observe.js.basic.html @@ -15,11 +15,11 @@

Observe.js - Basic

-
+
When changed, this element should fire a custom trigger.
-
+
When changed, this element should fire a custom trigger (and reset its value back to the original).
diff --git a/test/observe.js.min.html b/test/observe.js.min.html index 43d6002..6153334 100644 --- a/test/observe.js.min.html +++ b/test/observe.js.min.html @@ -15,11 +15,11 @@

Observe.js - Basic

-
+
When changed, this element should fire a custom trigger.
-
+
When changed, this element should fire a custom trigger (and reset its value back to the original).
From c73a4f4aa7332ac9702c23d399a0142006c76af2 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:31:21 +0100 Subject: [PATCH 23/28] Updated documentation. --- docs/binding/options/CUSTOM_TRIGGERS.md | 16 +++++++++------- docs/configuration/OPTIONS.md | 10 +++++----- 2 files changed, 14 insertions(+), 12 deletions(-) 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 -
+
Your HTML.
``` @@ -61,7 +61,9 @@ Fires when a watch is started. ```markdown ``` \ No newline at end of file diff --git a/docs/configuration/OPTIONS.md b/docs/configuration/OPTIONS.md index 6752d85..54365c6 100644 --- a/docs/configuration/OPTIONS.md +++ b/docs/configuration/OPTIONS.md @@ -15,11 +15,11 @@ Below are all the configuration options that can be passed to the "setConfigurat ### Options - Strings: -| Type: | Name: | Description: | -| --- | --- | --- | -| *string* | objectErrorText | The error text that should be shown when an object error is detected (defaults to "Errors in object: {{error_1}}, {{error_2}}"). | -| *string* | attributeNotValidErrorText | The error text that should be shown when a binding object isn't valid (defaults to "The attribute '{{attribute_name}}' is not a valid object."). | -| *string* | attributeNotSetErrorText | The error text that should be shown when a binding attribute isn't set (defaults to "The attribute '{{attribute_name}}' has not been set correctly."). | +| Category: | Type: | Name: | Description: | +| --- | --- | --- | --- | +| text | *string* | objectErrorText | The error text that should be shown when an object error is detected (defaults to "Errors in object: {{error_1}}, {{error_2}}"). | +| text | *string* | attributeNotValidErrorText | The error text that should be shown when a binding object isn't valid (defaults to "The attribute '{{attribute_name}}' is not a valid object."). | +| text | *string* | attributeNotSetErrorText | The error text that should be shown when a binding attribute isn't set (defaults to "The attribute '{{attribute_name}}' has not been set correctly."). |
From fbdb3097391cc329ef692e17fa342660f23fcb59 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:32:13 +0100 Subject: [PATCH 24/28] Updated README files. --- README.md | 2 +- README_NUGET.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f074ed6..def900d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Observe.js

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 a637031..2b5685f 100644 --- a/README_NUGET.md +++ b/README_NUGET.md @@ -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! From 935fe79e2fadbe841d60ddc2ffb7b011b1beb06f Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:32:35 +0100 Subject: [PATCH 25/28] Updated keywords. --- observe.js.nuspec | 2 +- package.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/observe.js.nuspec b/observe.js.nuspec index fe6502c..df55605 100644 --- a/observe.js.nuspec +++ b/observe.js.nuspec @@ -10,7 +10,7 @@ README_NUGET.md MIT - javascript css observe.js observe observable watcher object changes watch event events trigger triggers handler + typescript javascript css observe.js observe observable watcher object changes watch event events trigger triggers handler docs\images\icon.png William Troup diff --git a/package.json b/package.json index e6ac120..76deff4 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ "url": "https://github.com/williamtroup/Observe.js" }, "keywords": [ + "typescript", "javascript", "css", "observe.js", From a7b4560c3dffc9641d612f716f931e42e4a30078 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:37:11 +0100 Subject: [PATCH 26/28] More HTML updates. --- test/observe.js.basic.html | 20 ++++++++++++-------- test/observe.js.min.html | 10 ++++++---- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/test/observe.js.basic.html b/test/observe.js.basic.html index df9deff..ca9d252 100644 --- a/test/observe.js.basic.html +++ b/test/observe.js.basic.html @@ -100,18 +100,22 @@

Additional Data:

function watchNewObject() { watchId = $observe.watch( window.observeObject, { - onChange: onObservableObjectChange, - onPropertyChange: onObservableObjectPropertyChange, - onCancel: onCancelWatch, propertyNames: [ "bool", "num" ], - onStart: onStartWatch + events: { + onChange: onObservableObjectChange, + onPropertyChange: onObservableObjectPropertyChange, + onCancel: onCancelWatch, + onStart: onStartWatch + } } ); $observe.watch( window.observeArray, { - onChange: onObservableObjectChange, - onPropertyChange: onObservableObjectPropertyChange, - onCancel: onCancelWatch, - onStart: onStartWatch + events: { + onChange: onObservableObjectChange, + onPropertyChange: onObservableObjectPropertyChange, + onCancel: onCancelWatch, + onStart: onStartWatch + } } ); } diff --git a/test/observe.js.min.html b/test/observe.js.min.html index 6153334..c721cfd 100644 --- a/test/observe.js.min.html +++ b/test/observe.js.min.html @@ -96,11 +96,13 @@

Additional Data:

function watchNewObject() { watchId = $observe.watch( window.observeObject, { - onChange: onObservableObjectChange, - onPropertyChange: onObservableObjectPropertyChange, - onCancel: onCancelWatch, propertyNames: [ "bool", "num" ], - onStart: onStartWatch + events: { + onChange: onObservableObjectChange, + onPropertyChange: onObservableObjectPropertyChange, + onCancel: onCancelWatch, + onStart: onStartWatch + } } ); } From 418444aec007071d51a426a78e9aa9931ed130c1 Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:38:05 +0100 Subject: [PATCH 27/28] Minor clean up. --- dist/observe.esm.js | 2 +- dist/observe.esm.js.map | 2 +- dist/observe.js | 2 +- dist/observe.js.map | 2 +- dist/observe.min.js | 2 +- src/observe.ts | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/observe.esm.js b/dist/observe.esm.js index 4db7a91..a015d3b 100644 --- a/dist/observe.esm.js +++ b/dist/observe.esm.js @@ -304,7 +304,7 @@ var require_observe = __commonJS({ } } function compareWatchObjectProperties(e, t, n) { - for (var r in e) { + for (let r in e) { if (e.hasOwnProperty(r)) { const a = e[r]; let o = null; diff --git a/dist/observe.esm.js.map b/dist/observe.esm.js.map index a3dd932..ecd886c 100644 --- a/dist/observe.esm.js.map +++ b/dist/observe.esm.js.map @@ -1 +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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K,eAAe,eAAgB,YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,yCAA0B,YAAa,IAAI,iBAAkB,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 ( var 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 +{"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,OAAO,WAAW;AAAA,MAClD;AAFO,MAAAA,IAAS;AAIT,eAAS,aAAc,QAAwB;AAClD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAIT,eAAS,YAAa,QAAwB;AACjD,eAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,MACxD;AAFO,MAAAA,IAAS;AAAA,OA7BH;AAAA;AAAA;;;AChBjB,IAiBiB;AAjBjB;AAAA;AAAA;AAaA;AACA;AA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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.js b/dist/observe.js index c8c17e2..31a8f70 100644 --- a/dist/observe.js +++ b/dist/observe.js @@ -264,7 +264,7 @@ var Data; } } function compareWatchObjectProperties(e, t, n) { - for (var r in e) { + for (let r in e) { if (e.hasOwnProperty(r)) { const a = e[r]; let o = null; diff --git a/dist/observe.js.map b/dist/observe.js.map index 574c804..a9ed779 100644 --- a/dist/observe.js.map +++ b/dist/observe.js.map @@ -1 +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"],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,mBAAU,SAAU,EAAE,QAAQ,SAAS;AAAA,QAC3C;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA,IAEA,wBAAwB,WAAwB;AAC5C,wBAAkB;AAElB,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,kBAAkB,SAAW,kBAAoC;AAC7D,UAAK,GAAG,cAAe,gBAAiB,GAAI;AACxC,YAAI,0BAAmC;AACvC,cAAM,2BAAgC;AAEtC,iBAAU,gBAAgB,kBAAmB;AACzC,cAAK,iBAAiB,eAAgB,YAAa,KAAK,eAAe,eAAgB,YAAa,KAAK,yBAA0B,YAAa,MAAM,iBAAkB,YAAa,GAAI;AACrL,qCAA0B,YAAa,IAAI,iBAAkB,YAAa;AAC1E,sCAA0B;AAAA,UAC9B;AAAA,QACJ;AAEA,YAAK,yBAA0B;AAC3B,oCAA2B,wBAAyB;AAAA,QACxD;AAAA,MACJ;AAEA,aAAO;AAAA,IACX;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,IASA,YAAY,WAAqB;AAC7B,aAAO;AAAA,IACX;AAAA,EACJ;AASA,GAAE,MAAM;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 ( var 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 +{"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,EAClD;AAFO,EAAAA,IAAS;AAIT,WAAS,aAAc,QAAwB;AAClD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,EACxD;AAFO,EAAAA,IAAS;AAIT,WAAS,YAAa,QAAwB;AACjD,WAAO,cAAe,MAAO,KAAK,kBAAkB;AAAA,EACxD;AAFO,EAAAA,IAAS;AAAA,GA7BH;;;ACCV,IAAU;AAAA,CAAV,C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ACJ,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 80ad123..6fd0afe 100644 --- a/dist/observe.min.js +++ b/dist/observe.min.js @@ -1 +1 @@ -"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 +"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/src/observe.ts b/src/observe.ts index 6a64935..1574103 100644 --- a/src/observe.ts +++ b/src/observe.ts @@ -252,7 +252,7 @@ type StringToJson = { } function compareWatchObjectProperties( oldObject: any, newObject: any, watch: ObserveWatch ) : void { - for ( var propertyName in oldObject ) { + for ( let propertyName in oldObject ) { if ( oldObject.hasOwnProperty( propertyName ) ) { const propertyOldValue: any = oldObject[ propertyName ]; let propertyNewValue: any = null; From cbcf5f072ffdfa21912aff269b6c20e59f09a0aa Mon Sep 17 00:00:00 2001 From: William Troup Date: Tue, 16 Jul 2024 12:42:11 +0100 Subject: [PATCH 28/28] Updated change log. --- docs/CHANGE_LOG.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/docs/CHANGE_LOG.md b/docs/CHANGE_LOG.md index 5d598a6..24ed495 100644 --- a/docs/CHANGE_LOG.md +++ b/docs/CHANGE_LOG.md @@ -1,7 +1,25 @@ # 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.