From 1fa6d558c7ae491d927b13d77e87fa0bf55df23c Mon Sep 17 00:00:00 2001 From: svenMinio Date: Sun, 17 May 2026 12:39:25 +0200 Subject: [PATCH] Upload files to "/" --- .editorconfig | 18 + CHANGELOG.md | 157 ++ CODE_OF_CONDUCT.md | 69 + CONTRIBUTING.md | 96 + LICENSE | 621 +++++ README.md | 179 ++ SECURITY.md | 36 + build.js | 113 + dist/browser.d.ts | 32 + dist/browser.d.ts.map | 1 + dist/core.d.ts | 45 + dist/core.d.ts.map | 1 + dist/index.cjs | 3037 ++++++++++++++++++++++ dist/index.cjs.map | 7 + dist/index.d.ts | 1914 ++++++++++++++ dist/index.d.ts.map | 1 + dist/index.mjs | 3002 ++++++++++++++++++++++ dist/index.mjs.map | 7 + dist/jbase.browser.js | 3219 ++++++++++++++++++++++++ dist/jbase.browser.js.map | 7 + dist/jbase.min.js | 10 + dist/jbase.min.js.map | 7 + dist/modules/css/classes.d.ts | 43 + dist/modules/css/classes.d.ts.map | 1 + dist/modules/css/index.d.ts | 26 + dist/modules/css/index.d.ts.map | 1 + dist/modules/css/styles.d.ts | 25 + dist/modules/css/styles.d.ts.map | 1 + dist/modules/data/arrays.d.ts | 238 ++ dist/modules/data/arrays.d.ts.map | 1 + dist/modules/data/index.d.ts | 227 ++ dist/modules/data/index.d.ts.map | 1 + dist/modules/data/objects.d.ts | 223 ++ dist/modules/data/objects.d.ts.map | 1 + dist/modules/data/types.d.ts | 16 + dist/modules/data/types.d.ts.map | 1 + dist/modules/dom/attributes.d.ts | 50 + dist/modules/dom/attributes.d.ts.map | 1 + dist/modules/dom/content.d.ts | 46 + dist/modules/dom/content.d.ts.map | 1 + dist/modules/dom/index.d.ts | 83 + dist/modules/dom/index.d.ts.map | 1 + dist/modules/dom/manipulation.d.ts | 111 + dist/modules/dom/manipulation.d.ts.map | 1 + dist/modules/dom/states.d.ts | 69 + dist/modules/dom/states.d.ts.map | 1 + dist/modules/dom/traversal.d.ts | 184 ++ dist/modules/dom/traversal.d.ts.map | 1 + dist/modules/effects/fade.d.ts | 60 + dist/modules/effects/fade.d.ts.map | 1 + dist/modules/effects/index.d.ts | 36 + dist/modules/effects/index.d.ts.map | 1 + dist/modules/effects/slide.d.ts | 44 + dist/modules/effects/slide.d.ts.map | 1 + dist/modules/effects/types.d.ts | 33 + dist/modules/effects/types.d.ts.map | 1 + dist/modules/effects/vertical.d.ts | 44 + dist/modules/effects/vertical.d.ts.map | 1 + dist/modules/events/binding.d.ts | 66 + dist/modules/events/binding.d.ts.map | 1 + dist/modules/events/form.d.ts | 52 + dist/modules/events/form.d.ts.map | 1 + dist/modules/events/index.d.ts | 61 + dist/modules/events/index.d.ts.map | 1 + dist/modules/events/keyboard.d.ts | 44 + dist/modules/events/keyboard.d.ts.map | 1 + dist/modules/events/lifecycle.d.ts | 22 + dist/modules/events/lifecycle.d.ts.map | 1 + dist/modules/events/mouse.d.ts | 89 + dist/modules/events/mouse.d.ts.map | 1 + dist/modules/events/touch.d.ts | 75 + dist/modules/events/touch.d.ts.map | 1 + dist/modules/http/get.d.ts | 35 + dist/modules/http/get.d.ts.map | 1 + dist/modules/http/index.d.ts | 27 + dist/modules/http/index.d.ts.map | 1 + dist/modules/http/post.d.ts | 23 + dist/modules/http/post.d.ts.map | 1 + dist/modules/http/upload.d.ts | 30 + dist/modules/http/upload.d.ts.map | 1 + dist/server.d.ts | 13 + dist/server.d.ts.map | 1 + dist/server.js | 3027 ++++++++++++++++++++++ dist/server.js.map | 7 + dist/types.d.ts | 51 + dist/types.d.ts.map | 1 + dist/utils.d.ts | 59 + dist/utils.d.ts.map | 1 + package.json | 85 + src/browser.ts | 47 + src/core.ts | 128 + src/index.ts | 1172 +++++++++ src/modules/css/classes.ts | 66 + src/modules/css/index.ts | 26 + src/modules/css/styles.ts | 69 + src/modules/data/arrays.ts | 399 +++ src/modules/data/index.ts | 315 +++ src/modules/data/objects.ts | 445 ++++ src/modules/data/types.ts | 16 + src/modules/dom/attributes.ts | 96 + src/modules/dom/content.ts | 121 + src/modules/dom/index.ts | 38 + src/modules/dom/manipulation.ts | 389 +++ src/modules/dom/states.ts | 122 + src/modules/dom/traversal.ts | 463 ++++ src/modules/effects/fade.ts | 149 ++ src/modules/effects/index.ts | 30 + src/modules/effects/slide.ts | 126 + src/modules/effects/types.ts | 41 + src/modules/effects/vertical.ts | 145 ++ src/modules/events/binding.ts | 185 ++ src/modules/events/form.ts | 81 + src/modules/events/index.ts | 42 + src/modules/events/keyboard.ts | 61 + src/modules/events/lifecycle.ts | 31 + src/modules/events/mouse.ts | 139 + src/modules/events/touch.ts | 136 + src/modules/http/get.ts | 76 + src/modules/http/index.ts | 30 + src/modules/http/post.ts | 52 + src/modules/http/upload.ts | 66 + src/server.ts | 31 + src/types.ts | 57 + src/utils.ts | 105 + tsconfig.json | 38 + wiki/A-Z.md | 292 +++ wiki/CSS-Classes-&-Styles.md | 128 + wiki/DATA-Utilities-(Arrays).md | 560 +++++ wiki/DATA-Utilities-(Objects).md | 543 ++++ wiki/DOM-Attributes.md | 110 + wiki/DOM-Content.md | 90 + wiki/DOM-Manipulation.md | 312 +++ wiki/DOM-States.md | 165 ++ wiki/DOM-Traversal.md | 529 ++++ wiki/EFFECTS-Fade.md | 114 + wiki/EFFECTS-Slide-(horizontal).md | 101 + wiki/EFFECTS-Slide-(vertical).md | 91 + wiki/EVENTS-Bindings.md | 130 + wiki/EVENTS-Form.md | 122 + wiki/EVENTS-Keyboard.md | 97 + wiki/EVENTS-Lifecycle.md | 25 + wiki/EVENTS-Mouse.md | 234 ++ wiki/EVENTS-Touch.md | 185 ++ wiki/HTTP-Requests.md | 159 ++ wiki/Home.md | 142 ++ wiki/Installation.md | 70 + wiki/Quick-Start.md | 138 + wiki/RECIPE-Advanced-Chaining.md | 84 + wiki/UTILITIES.md | 98 + 149 files changed, 27987 insertions(+) create mode 100644 .editorconfig create mode 100644 CHANGELOG.md create mode 100644 CODE_OF_CONDUCT.md create mode 100644 CONTRIBUTING.md create mode 100644 LICENSE create mode 100644 README.md create mode 100644 SECURITY.md create mode 100644 build.js create mode 100644 dist/browser.d.ts create mode 100644 dist/browser.d.ts.map create mode 100644 dist/core.d.ts create mode 100644 dist/core.d.ts.map create mode 100644 dist/index.cjs create mode 100644 dist/index.cjs.map create mode 100644 dist/index.d.ts create mode 100644 dist/index.d.ts.map create mode 100644 dist/index.mjs create mode 100644 dist/index.mjs.map create mode 100644 dist/jbase.browser.js create mode 100644 dist/jbase.browser.js.map create mode 100644 dist/jbase.min.js create mode 100644 dist/jbase.min.js.map create mode 100644 dist/modules/css/classes.d.ts create mode 100644 dist/modules/css/classes.d.ts.map create mode 100644 dist/modules/css/index.d.ts create mode 100644 dist/modules/css/index.d.ts.map create mode 100644 dist/modules/css/styles.d.ts create mode 100644 dist/modules/css/styles.d.ts.map create mode 100644 dist/modules/data/arrays.d.ts create mode 100644 dist/modules/data/arrays.d.ts.map create mode 100644 dist/modules/data/index.d.ts create mode 100644 dist/modules/data/index.d.ts.map create mode 100644 dist/modules/data/objects.d.ts create mode 100644 dist/modules/data/objects.d.ts.map create mode 100644 dist/modules/data/types.d.ts create mode 100644 dist/modules/data/types.d.ts.map create mode 100644 dist/modules/dom/attributes.d.ts create mode 100644 dist/modules/dom/attributes.d.ts.map create mode 100644 dist/modules/dom/content.d.ts create mode 100644 dist/modules/dom/content.d.ts.map create mode 100644 dist/modules/dom/index.d.ts create mode 100644 dist/modules/dom/index.d.ts.map create mode 100644 dist/modules/dom/manipulation.d.ts create mode 100644 dist/modules/dom/manipulation.d.ts.map create mode 100644 dist/modules/dom/states.d.ts create mode 100644 dist/modules/dom/states.d.ts.map create mode 100644 dist/modules/dom/traversal.d.ts create mode 100644 dist/modules/dom/traversal.d.ts.map create mode 100644 dist/modules/effects/fade.d.ts create mode 100644 dist/modules/effects/fade.d.ts.map create mode 100644 dist/modules/effects/index.d.ts create mode 100644 dist/modules/effects/index.d.ts.map create mode 100644 dist/modules/effects/slide.d.ts create mode 100644 dist/modules/effects/slide.d.ts.map create mode 100644 dist/modules/effects/types.d.ts create mode 100644 dist/modules/effects/types.d.ts.map create mode 100644 dist/modules/effects/vertical.d.ts create mode 100644 dist/modules/effects/vertical.d.ts.map create mode 100644 dist/modules/events/binding.d.ts create mode 100644 dist/modules/events/binding.d.ts.map create mode 100644 dist/modules/events/form.d.ts create mode 100644 dist/modules/events/form.d.ts.map create mode 100644 dist/modules/events/index.d.ts create mode 100644 dist/modules/events/index.d.ts.map create mode 100644 dist/modules/events/keyboard.d.ts create mode 100644 dist/modules/events/keyboard.d.ts.map create mode 100644 dist/modules/events/lifecycle.d.ts create mode 100644 dist/modules/events/lifecycle.d.ts.map create mode 100644 dist/modules/events/mouse.d.ts create mode 100644 dist/modules/events/mouse.d.ts.map create mode 100644 dist/modules/events/touch.d.ts create mode 100644 dist/modules/events/touch.d.ts.map create mode 100644 dist/modules/http/get.d.ts create mode 100644 dist/modules/http/get.d.ts.map create mode 100644 dist/modules/http/index.d.ts create mode 100644 dist/modules/http/index.d.ts.map create mode 100644 dist/modules/http/post.d.ts create mode 100644 dist/modules/http/post.d.ts.map create mode 100644 dist/modules/http/upload.d.ts create mode 100644 dist/modules/http/upload.d.ts.map create mode 100644 dist/server.d.ts create mode 100644 dist/server.d.ts.map create mode 100644 dist/server.js create mode 100644 dist/server.js.map create mode 100644 dist/types.d.ts create mode 100644 dist/types.d.ts.map create mode 100644 dist/utils.d.ts create mode 100644 dist/utils.d.ts.map create mode 100644 package.json create mode 100644 src/browser.ts create mode 100644 src/core.ts create mode 100644 src/index.ts create mode 100644 src/modules/css/classes.ts create mode 100644 src/modules/css/index.ts create mode 100644 src/modules/css/styles.ts create mode 100644 src/modules/data/arrays.ts create mode 100644 src/modules/data/index.ts create mode 100644 src/modules/data/objects.ts create mode 100644 src/modules/data/types.ts create mode 100644 src/modules/dom/attributes.ts create mode 100644 src/modules/dom/content.ts create mode 100644 src/modules/dom/index.ts create mode 100644 src/modules/dom/manipulation.ts create mode 100644 src/modules/dom/states.ts create mode 100644 src/modules/dom/traversal.ts create mode 100644 src/modules/effects/fade.ts create mode 100644 src/modules/effects/index.ts create mode 100644 src/modules/effects/slide.ts create mode 100644 src/modules/effects/types.ts create mode 100644 src/modules/effects/vertical.ts create mode 100644 src/modules/events/binding.ts create mode 100644 src/modules/events/form.ts create mode 100644 src/modules/events/index.ts create mode 100644 src/modules/events/keyboard.ts create mode 100644 src/modules/events/lifecycle.ts create mode 100644 src/modules/events/mouse.ts create mode 100644 src/modules/events/touch.ts create mode 100644 src/modules/http/get.ts create mode 100644 src/modules/http/index.ts create mode 100644 src/modules/http/post.ts create mode 100644 src/modules/http/upload.ts create mode 100644 src/server.ts create mode 100644 src/types.ts create mode 100644 src/utils.ts create mode 100644 tsconfig.json create mode 100644 wiki/A-Z.md create mode 100644 wiki/CSS-Classes-&-Styles.md create mode 100644 wiki/DATA-Utilities-(Arrays).md create mode 100644 wiki/DATA-Utilities-(Objects).md create mode 100644 wiki/DOM-Attributes.md create mode 100644 wiki/DOM-Content.md create mode 100644 wiki/DOM-Manipulation.md create mode 100644 wiki/DOM-States.md create mode 100644 wiki/DOM-Traversal.md create mode 100644 wiki/EFFECTS-Fade.md create mode 100644 wiki/EFFECTS-Slide-(horizontal).md create mode 100644 wiki/EFFECTS-Slide-(vertical).md create mode 100644 wiki/EVENTS-Bindings.md create mode 100644 wiki/EVENTS-Form.md create mode 100644 wiki/EVENTS-Keyboard.md create mode 100644 wiki/EVENTS-Lifecycle.md create mode 100644 wiki/EVENTS-Mouse.md create mode 100644 wiki/EVENTS-Touch.md create mode 100644 wiki/HTTP-Requests.md create mode 100644 wiki/Home.md create mode 100644 wiki/Installation.md create mode 100644 wiki/Quick-Start.md create mode 100644 wiki/RECIPE-Advanced-Chaining.md create mode 100644 wiki/UTILITIES.md diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..8c3432c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 4 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.{yml,yaml}] +indent_size = 2 + +[*.json] +indent_size = 4 diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..a1a94a9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,157 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## [2.0.1] - 2026-02-04 + +* **ReadMe (`README.md`):** Updated ReadMe for better understanding + + +## [2.0.2] - 2026-02-08 + +### πŸš€ Added (SSR & Architecture) + +* **Server-Side Rendering (SSR):** Full support for Node.js environments via `jsdom`. +* Added `src/server.ts` with `parseHTML` utility. +* Added `bind(window)` factory in `src/index.ts` to create isolated jBase instances per request. + + +* **Context Awareness:** The core `jBase` class now accepts an optional `context` (Window/Document) in the constructor to support isolated environments. +* **Environment Detection:** Added `isBrowser()` utility in `src/utils.ts` to safely distinguish between browser and server environments. + +### ⚑ Performance + +* **Data Module (`data/objects.ts`):** Optimized search algorithms in `find.first`, `find.last`, `find.key`, and `find.value`. moved query normalization (`toLowerCase()`) outside of loops to significantly reduce CPU overhead. +* **Effects Module:** Added server-guards (`if (!isBrowser())`) to `fade.ts`, `slide.ts`, and `vertical.ts`. Animation logic is now skipped on the server to save resources. + +### πŸ›‘οΈ Fixed (Stability & Logic) + +* **Core (`core.ts`):** Added crash protection for invalid CSS selectors. `$(...)` now catches `DOMException` errors internally and logs a warning instead of crashing. +* **DOM Manipulation (`dom/manipulation.ts`):** +* Rewrote `unwrap()` using a `Set` to safely handle parent removal without conflicts on sibling elements. +* Replaced global `window.document` usage with a `getDoc(this)` helper to prevent `ReferenceError` crashes in Node.js. + + +* **HTTP Module (`http/*.ts`):** Fixed potential crash when parsing JSON from `200 OK` responses that contain an empty body. +* **CSS Module (`css/styles.ts`):** Updated `css()` getter to access `getComputedStyle` via `el.ownerDocument` instead of global `window`. + +### πŸ”§ Changed & Cleaned + +* **Documentation:** Removed localized German JSDoc comments to reduce source code size and maintain a consistent English-only documentation standard. +* **Config:** Fixed invalid JSON syntax in `tsconfig.json`. +* **Type Safety:** Upgraded `isObject` utility to a TypeScript Type Guard for better type inference. + + +## [2.0.3] - 2026-02-13 + +### πŸ›‘οΈ Fixed (http) + +* **HTTP Module (`http/get.ts`):** Enforce GET method in get() and getText() utility. Overrides method to 'GET' if 'POST' is passed in options. +* **HTTP Module (`http/post.ts`):** Enforce POST method in post() utility. Overrides method to 'POST' if 'GET' is passed in options. + + +## [2.1.1] - 2026-02-22 + +### πŸš€ Added (DOM Attributes) + +* **Attributes Module (`dom/attributes.ts`):** Added `removeAttr()` method to safely remove HTML attributes from all elements in a selection. +* **Attributes Module (`dom/attributes.ts`):** Added `prop()` method for getting and setting underlying DOM properties (e.g., `checked`, `disabled`, `selectedIndex`) that don't directly map to standard HTML attributes. + +### πŸ›‘οΈ Fixed (CSS & HTTP) + +* **CSS Module (`css/styles.ts`):** Enhanced the `css()` method to support passing an object (`Record`) for setting multiple CSS properties simultaneously (e.g., `css({'background-color': 'blue', 'font-size': '14px'})`). +* **CSS Module (`css/styles.ts`):** Improved handling of kebab-case property names inside the `css()` method by utilizing `style.setProperty()` for greater robustness. +* **HTTP Module (`http/get.ts`):** Fixed a critical bug in `getText()` where it incorrectly attempted to parse the response with `JSON.parse()` instead of returning the raw text. It now safely returns the raw string/HTML as intended. + +## [2.1.2] - 2026-02-22 + +### πŸ›‘οΈ Fixed (Core & Browser Scope) + +* **Core (`src/index.ts`):** Fixed an architectural bug where the `http` and `data` modules were not accessible via the main `$` wrapper (e.g., `$.http` or `$.data`) as documented in the wiki. They are now properly attached to the `init` factory function using `Object.assign()`. +* **Browser Module (`src/browser.ts`):** Removed the unintended global `window.http` export to prevent global namespace pollution. The HTTP module must now be accessed exclusively through the framework instance (e.g., `$.http` or `jBase.http`). + +## [2.2.0] - 2026-04-12 + +### πŸš€ Added (New Features) +* **Event System (`events/binding.ts`):** * Massive upgrade to the `.on()` and `.off()` methods. They now fully support **Event Delegation** (e.g., `$('table').on('click', 'tr', handler)`) and passing custom data to the event object (`event.data`). + * Added `.once()` method to execute a handler at most once per element and event type. Supports delegation and data. + * Added `.trigger()` method to programmatically execute native or custom events and pass optional data via `event.detail`. +* **Touch Events (`events/touch.ts`):** Added `.swipeLeft()`, `.swipeUp()` `.swipeDown()` and `.swipeRight()` helpers for robust mobile gesture detection. +* **Mouse Events (`events/mouse.ts`):** Added `.hover()` as a convenient shorthand for binding both `mouseenter` and `mouseleave` handlers. +* **Core Utilities (`utils.ts` & `index.ts`):** * Introduced `$.each()`, a highly performant, breakable iteration utility for arrays, NodeLists, and plain objects. + * `$.throttle` and `$.debounce` are now globally exposed on the main `$` object for easy access. + +### ⚑ Performance +* **Core (`core.ts`):** Implemented a high-performance, native `for`-loop iteration method (`.each()`) inside the core class. Replaced standard `forEach` calls across the entire framework (DOM, CSS, Attributes, etc.) to significantly reduce CPU overhead and allow early loop termination. + +### πŸ›‘οΈ Fixed (Stability & Architecture) +* **SSR Safety (`core.ts`):** Fixed a critical bug in the constructor where string selectors would fall back to the global `document` instead of the passed isolated `context` (`this.doc`). Node.js environments are now completely safe. +* **Event Delegation (`events/binding.ts`):** Fixed a potential `TypeError` crash during event delegation when a user clicks on a pure `TextNode` (which lacks the `.closest()` method). +* **Typings (`index.ts`):** Fixed signature mismatch for `.prop()` to correctly handle getter (`any`) and setter (`jBase`) overloads. +* **Dependencies (`package.json`):** Moved `jsdom` and `tslib` from standard `dependencies` to `peerDependencies` / `devDependencies`. This drastically reduces the installation size for browser-only users via npm. + +## [2.3.0] - 2026-04-20 + +### πŸš€ Added (Upload Method) +* **HTTP Module:** Added `$.http.upload()` method. This introduces a modern, Promise-based wrapper around `XMLHttpRequest` specifically designed for file uploads. It solves the native limitation of the `fetch` API by allowing real-time upload progress tracking via an `onProgress` callback, while maintaining the same elegant `async/await` syntax as the rest of the HTTP module. + +## [2.4.0] - 2026-05-03 + +### πŸš€ Added (Dynamic Routing & API Symmetry) +* **Data Module (`data/index.ts`):** Introduced a smart, dynamic API router (Facade). You no longer need to explicitly specify `.arr` or `.obj` when calling data utilities. + * Methods can now be called directly on the main data namespace (e.g., `$.data.chunk()`, `$.data.remove.at()`). + * The framework automatically detects the input type under the hood (`Array.isArray()`) and routes the request to the correct underlying module. + * Full TypeScript overloads guarantee perfect IntelliSense and type safety depending on whether you pass an array or an object. + * *Note: Explicit calls via `.arr` and `.obj` remain fully supported for 100% backward compatibility.* +* **Data Module (`data/objects.ts`):** Massive expansion of object utilities to mirror the array API. + * Added `chunk()` for objects to split a large object into an array of smaller objects (batched processing). + * Added `add()` for safely injecting a key-value pair at a specific index position. + * Added `remove.at()`, `remove.first()`, `remove.last()`, `remove.byKey()`, `remove.byValue()`, and `remove.byMatch()` to immutably remove properties from an object based on complex queries or exact matches. + * Added `find.all()` to return a partial object containing only the properties that match a specific query. + * Aliased `merge` to `mergeObjects` to ensure naming consistency across the data module. +* **Data Module (`data/arrays.ts`):** Expanded array utilities to mirror the object API. + * Added `get()` and `set()` for safe, deep navigation and assignment within nested arrays. + * Added `find.key()` and `find.value()` to provide identical method signatures between arrays and objects. + * Added `pick()` and `omit()` to immutably extract or remove array elements based on a list of specific indices. + * Added `remove.byKey()` and `remove.byValue()` for strict API parity with object removals. + +### πŸš€ Added (DOM Content) +* **DOM Module (`dom/content.ts`):** Added `.load(url)` method. This provides a highly requested, classic shortcut to asynchronously fetch HTML from a server and inject it directly into the matched DOM elements. Under the hood, it seamlessly utilizes the robust `$.http.getText()` utility. + +### ⚑ Performance & Logic +* **Data Module (`data/arrays.ts` & `data/objects.ts`):** + * All search queries within `find` and `remove` methods are now executed in a case-insensitive manner by default. + * Both modules are now completely symmetrical, utilizing the same internal `MatchMode` logic (`'exact'`, `'contains'`, `'startsWith'`, `'endsWith'`) for predictable data extraction. + +### 🧹 Cleaned & Utility +* **Data Module (`data/arrays.ts` & `data/objects.ts`):** + * Added `clear()` (along with aliases `empty()` and `remove.all()`) to both modules. These methods provide a fast, standardized way to return a new, empty element of the respective type (`[]` or `{}`) without mutating the original data structure, adhering to the framework's functional design principles. +* **Effects Module (`effects/fade.ts`):** Added `show()`, `hide()` and `toggle()`, as semantic aliases for `fadeIn()`, `fadeOut()` and `fadeToggle()`. This provides a more intuitive, classic API for developers used to standard DOM visibility toggling, while maintaining the smooth CSS transition logic under the hood. +* **DOM Module (`dom/states.ts`):** Added semantic action aliases for state manipulation. You can now use `.check()`, `.uncheck()`, `.select()`, `.disable()`, and `.enable()` as highly readable, chainable alternatives to passing boolean values into `.checked()`, `.selected()`, and `.disabled()`. + +### πŸ›‘οΈ Secured (XSS Protection & Architecture) +* **Core Utilities (`utils.ts`):** Introduced a centralized, high-performance XSS sanitizer (`sanitizeDangerousAttributes`). This internal utility aggressively strips dangerous inline event handlers (like `onerror`) and malicious protocols (like `href="javascript:..."`) from raw HTML strings. +* **Core (`core.ts`):** Hardened the main `jBase` constructor. Creating new DOM elements via `$('')` now passes the string through the central sanitizer, ensuring "secure-by-default" behavior even when handling untrusted user input. +* **DOM Manipulation (`dom/manipulation.ts`):** Secured all structural insertion methods (`append`, `prepend`, `before`, `after`, `wrap`, and `replaceWith`). Any raw HTML strings passed into these methods are now automatically sanitized before being injected into the DOM, closing the backdoor for XSS injections. +* **DOM Content (`dom/content.ts`):** Completely overhauled the injection logic for `.html()` and `.load()`. They now inherit the strict XSS sanitization by default. To maintain full framework flexibility for trusted sources, we introduced the `{ executeScripts: true }` bypass, which safely extracts, injects, and evaluates embedded ` +``` + +-- OR -- + +### via CDN +```html + + + + + + + + + + + + + +``` + +--- + +## πŸ–₯️ Server-Side Rendering (SSR) & Node.js + +jBase is **isomorphic**. You can use the exact same code on the client and the server. +To use DOM manipulation in Node.js, simply bind jBase to a `jsdom` window instance. + +### 1. Install JSDOM (Optional Peer Dependency) + +```bash +npm install jsdom +``` + +### 2. Bind to a Virtual Window + +Use the `bind` factory to create a jBase instance scoped to a specific request or document. + +```javascript +import { JSDOM } from 'jsdom'; +import { bind } from '@k37z3r/jbase'; // Adjust to your package name + +// 1. Create a virtual DOM environment +const dom = new JSDOM('
'); +const window = dom.window; + +// 2. Create a scoped instance of jBase +const $ = bind(window); + +// 3. Manipulate the DOM exactly like in the browser +$('#app') + .addClass('ssr-rendered') + .html('

Hello from Node.js!

') + .append('

This HTML was generated on the server.

'); + +// 4. Output the final HTML string +console.log(dom.serialize()); +``` + +> [!NOTE] +> Browser-only features like animations (`fadeIn`, `slideUp`) or Event Bindings (`click`) are **safely ignored** in Node.js environments to prevent crashes and save resources. + +--- + +## πŸš€ Client-Side Features + +jBase exposes itself globally as `jBase` and the shorthand `$`. + +### 1. DOM & Effects + +```javascript +$(document).ready(() => { + // Event Handling + $('button.save').on('click', (e) => { + e.preventDefault(); + + // Chained manipulation & Animation + $('.notification') + .addClass('success') + .text('Saved successfully!') + .fadeIn(300); + }); +}); +``` + +### 2. Powerful Data Utilities + +jBase includes a unique `$.data` module for **immutable** array and object manipulation. Optimized for high performance. + +```javascript +const users = [ + { id: 1, name: 'Alice', role: 'admin' }, + { id: 2, name: 'Bob', role: 'user' } +]; + +// Find specific data efficiently (Optimized Search) +const admin = $.data.find.first(users, 'admin', 'exact', 'role'); + +// Remove data immutably (returns a new array) +const nonAdmins = $.data.remove.byMatch(users, 'admin', 'exact', 'role'); +``` + +### 3. HTTP Requests + +Simple, robust AJAX wrappers that handle JSON automatically. + +```javascript +$.http.get('https://api.example.com/items') + .then(data => console.log('Items loaded:', data)) + .catch(err => console.error('Error:', err)); +``` + +--- + +## πŸ“š Documentation + +Detailed documentation for all methods is available in the **[GitHub Wiki](../../wiki)** or offline **[Documentation](./wiki)**. + +--- + +## πŸ“„ License + +**jBase** is open-source software licensed under the **[GPL-3.0-or-later](LICENSE)**. + +**Author:** Sven Minio + +**Website:** [sven-minio.de](https://sven-minio.de) + +**Copyright:** Β© 2026 Sven Minio + +[available-badge-npm]: https://img.shields.io/badge/available%20on-npm-CB3837?style=flat-square&logo=npm +[available-badge-github]: https://img.shields.io/badge/available%20on-GitHub-181717CB3837?style=flat-square&logo=github +[cdn-badge-jsdelivr]: https://img.shields.io/badge/CDN-jsDelivr-E84D3D?style=flat-square&logo=jsdelivr +[cdn-badge-statically]: https://img.shields.io/badge/CDN-Statically-ea6545?style=flat-square&logo=data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYuNjc1bW0iIGhlaWdodD0iMTYuNjc1bW0iIGNsaXAtcnVsZT0iZXZlbm9kZCIgZmlsbC1ydWxlPSJldmVub2RkIiBpbWFnZS1yZW5kZXJpbmc9Im9wdGltaXplUXVhbGl0eSIgc2hhcGUtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iIHRleHQtcmVuZGVyaW5nPSJnZW9tZXRyaWNQcmVjaXNpb24iIHZpZXdCb3g9IjAgMCA0NDUuNjcgNDQ1LjMzIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxsaW5lYXJHcmFkaWVudCBpZD0iYSIgeDE9IjExMC42NyIgeDI9IjMzNC4zMiIgeTE9IjQxNC44IiB5Mj0iMzAuMTkiIGdyYWRpZW50VHJhbnNmb3JtPSJ0cmFuc2xhdGUoMCwxNTU1LjcpIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSI+PHN0b3Agc3RvcC1jb2xvcj0iI2Q3MjQzMCIgb2Zmc2V0PSIwIi8+PHN0b3Agc3RvcC1jb2xvcj0iI2ZkYTI1OSIgb2Zmc2V0PSIxIi8+PC9saW5lYXJHcmFkaWVudD48L2RlZnM+PGcgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLjMzNDI3IC0xNTU2KSI+PHBhdGggZD0ibTMwIDE2NjYuN2M2Mi0xMDcgMTk4LTE0MyAzMDQtODEgMTA3IDYyIDE0MyAxOTggODEgMzA0LTYyIDEwNy0xOTggMTQzLTMwNCA4MS0xMDctNjItMTQzLTE5OC04MS0zMDR6IiBmaWxsPSJ1cmwoI2EpIi8+PGcgdHJhbnNmb3JtPSJtYXRyaXgoMS4yMTk0IC4xMTIzNiAtLjExMjkyIDEuMjI1NSAtMjIuMjUxIDE0NzguNCkiIHN0cm9rZT0iI2ZlZmVmZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyMy4wNDEiPjxnIHN0cm9rZT0iI2ZlZmVmZSIgc3Ryb2tlLWxpbmVqb2luPSJyb3VuZCIgc3Ryb2tlLXdpZHRoPSIyMy4wNDEiPjxwYXRoIGQ9Ik0yODMgMjI2bC00Ny0xOSA3NC0xMDVMMTU2IDIyMmw1MiAxOC03MyAxMDZ6IiBmaWxsPSIjZmVmZWZlIiBzdHJva2U9IiNmZWZlZmUiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIHN0cm9rZS13aWR0aD0iMjMuMDQxIi8+PC9nPjwvZz48L2c+PC9zdmc+ +[package-version-badge]: https://img.shields.io/github/package-json/v/k37z3r/jBase-2/main?style=flat-square&label=version +[ssr-ready-badge]: https://img.shields.io/badge/SSR-Ready-brightgreen?style=flat-square +[browser-ready-badge]: https://img.shields.io/badge/Browser-Ready-4CAF50?style=flat-square +[exports-badge]: https://img.shields.io/badge/exports-.js%20%7C%20.mjs%20%7C%20.cjs%20%7C%20.d.ts-007ec6?style=flat-square +[license-badge]: https://img.shields.io/badge/license-GPL--3.0-green.svg?style=flat-square +[size-badge]: https://img.shields.io/badge/size-lightweight-orange.svg?style=flat-square +[build-badge]: https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000..045b79e --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,36 @@ +# Security Policy + +## Supported Versions + +We are currently supporting the following versions of jBase with security updates: + +| Version | Supported | Notes | +| ------- | ------------------ | ----- | +| 2.x | :white_check_mark: | Current major version | +| 1.x | :x: | End of Life | + +## Reporting a Vulnerability + +We take the security of jBase seriously. If you believe you have found a security vulnerability in this framework, please report it to us as described below. + +**Please do not report security vulnerabilities through public GitHub issues.** + +### How to Report + +Please email the lead developer directly at: **[jbase@sven-minio.de]** + +Please include the following details in your report: +* The version of jBase you are using. +* A description of the vulnerability. +* Steps to reproduce the issue (code snippets or a proof-of-concept are highly appreciated). +* Any potential impact you foresee. + +### Our Response Policy + +1. **Acknowledgment:** We will make every effort to acknowledge your report within 48 hours. +2. **Investigation:** We will investigate the issue and verify the vulnerability. +3. **Fix:** Once confirmed, we will work on a patch. +4. **Release:** We will release a new version (e.g., v2.0.3) containing the security fix. +5. **Disclosure:** After the fix is released and users have had time to update, we will publicly acknowledge your contribution (unless you wish to remain anonymous). + +Thank you for helping keep jBase safe for everyone! diff --git a/build.js b/build.js new file mode 100644 index 0000000..942fce7 --- /dev/null +++ b/build.js @@ -0,0 +1,113 @@ +/** + * @file build.js + * @version 2.0.2 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Build + * @description + * * Build automation script using esbuild. Handles bundling, minification, and output generation. + * @requires esbuild + * * High-performance JavaScript bundler. + * @requires ./package.json + * * Project configuration and versioning. + * @requires child_process + * * For executing shell commands to generate TypeScript definitions. + */ + +const esbuild = require('esbuild'); +const pkg = require('./package.json'); +const { exec } = require('child_process'); +const banner = `/** + * ${pkg.name} - ${pkg.description} + * @version ${pkg.version} + * @homepage ${pkg.homepage} + * @author ${pkg.author} + * @license ${pkg.license} + * @copyright ${new Date().getFullYear()} ${pkg.author} + */`; + +const baseConfig = { + entryPoints: ['src/index.ts'], + bundle: true, + banner: { js: banner }, + logLevel: 'info', + platform: 'neutral', + sourcemap: true, +}; + +const browserBuild = { + ...baseConfig, + entryPoints: ['src/browser.ts'], + format: 'iife', + outfile: 'dist/jbase.browser.js', + legalComments: 'inline', + platform: 'browser', +}; + +const browserMinBuild = { + ...browserBuild, + outfile: 'dist/jbase.min.js', + minify: true, + legalComments: 'none', +}; + +const esmBuild = { + ...baseConfig, + format: 'esm', + outfile: 'dist/index.mjs', +}; + +const cjsBuild = { + ...baseConfig, + format: 'cjs', + outfile: 'dist/index.cjs', + platform: 'node', +}; + +const serverBuild = { + ...baseConfig, + entryPoints: ['src/server.ts'], + platform: 'node', + format: 'cjs', + outfile: 'dist/server.js', + external: ['jsdom', 'canvas', 'bufferutil', 'utf-8-validate'], +}; + +function generateTypes() { + return new Promise((resolve, reject) => { + console.log('\x1b[36m%s\x1b[0m', 'πŸ”¨: Generating TypeScript Definitions...'); + exec('npx tsc --emitDeclarationOnly --outDir dist', (error, stdout, stderr) => { + if (error) { + console.error(`Error generating types: ${error.message}`); + reject(error); + return; + } + if (stderr) console.error(`TSC Stderr: ${stderr}`); + console.log('\x1b[32m%s\x1b[0m', 'βœ…: TypeScript Definitions generated.'); + resolve(); + }); + }); +} + +Promise.all([ + esbuild.build(browserBuild), + esbuild.build(browserMinBuild), + esbuild.build(esmBuild), + esbuild.build(cjsBuild), + esbuild.build(serverBuild), + generateTypes() +]).then(() => { + console.log('\x1b[32m%s\x1b[0m', `*********************************************************************`); + console.log('\x1b[32m%s\x1b[0m', `πŸ—Š: jBase v${pkg.version}: A modern micro-framework for the web.`); + console.log('\x1b[32m%s\x1b[0m', `πŸ—Š: A modern micro-framework for the web: jBase offers the familiar`); + console.log('\x1b[32m%s\x1b[0m', `πŸ—Š: syntax of classic DOM libraries, but without their baggage. Fully`); + console.log('\x1b[32m%s\x1b[0m', `πŸ—Š: typed, modular, and optimized for modern browser engines.`); + console.log('\x1b[32m%s\x1b[0m', `β’Έ: Copyright (C) ${new Date().getFullYear()} ${pkg.author}`); + console.log('\x1b[32m%s\x1b[0m', `Β§: Released under the ${pkg.license} License.`); + console.log('\x1b[32m%s\x1b[0m', `*********************************************************************`); +}).catch((error) => { + console.error('\x1b[31m%s\x1b[0m', '❌ Build failed:', error); + process.exit(1); +}); \ No newline at end of file diff --git a/dist/browser.d.ts b/dist/browser.d.ts new file mode 100644 index 0000000..0a1fc22 --- /dev/null +++ b/dist/browser.d.ts @@ -0,0 +1,32 @@ +/** + * @file src/browser.ts + * @version 2.2.1 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Browser + * @description + * * Browser Entry Point. Attaches the jBase library and utilities to the global window object + * * so they can be accessed via `$` or `jBase` (and other aliases) in inline scripts. + * @requires ./index + * * The core jBase class and its aliases are imported to be attached to the window object. + */ +import { $, jBase, jB, _jB, __jB, _jBase, __jBase, __ } from './index'; +/** + * * TypeScript declaration merging to extend the global Window interface. + * * Ensures strict typing when accessing jBase aliases on the window object. + */ +declare global { + interface Window { + $: typeof $; + jBase: typeof jBase; + jB: typeof jB; + _jB: typeof _jB; + __jB: typeof __jB; + _jBase: typeof _jBase; + __jBase: typeof __jBase; + __: typeof __; + } +} +//# sourceMappingURL=browser.d.ts.map \ No newline at end of file diff --git a/dist/browser.d.ts.map b/dist/browser.d.ts.map new file mode 100644 index 0000000..71d43d6 --- /dev/null +++ b/dist/browser.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAEvE;;;GAGG;AACH,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,CAAC,EAAE,OAAO,CAAC,CAAC;QACZ,KAAK,EAAE,OAAO,KAAK,CAAC;QACpB,EAAE,EAAE,OAAO,EAAE,CAAC;QACd,GAAG,EAAE,OAAO,GAAG,CAAC;QAChB,IAAI,EAAE,OAAO,IAAI,CAAC;QAClB,MAAM,EAAE,OAAO,MAAM,CAAC;QACtB,OAAO,EAAE,OAAO,OAAO,CAAC;QACxB,EAAE,EAAE,OAAO,EAAE,CAAC;KACjB;CACJ"} \ No newline at end of file diff --git a/dist/core.d.ts b/dist/core.d.ts new file mode 100644 index 0000000..d5bc8ac --- /dev/null +++ b/dist/core.d.ts @@ -0,0 +1,45 @@ +/** + * @file src/core.ts + * @version 2.2.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Core + * @description + * * The main jBase class. Handles the selection engine, initialization, and plugin architecture. + * @requires ./types + * * Type definitions for the core class and its methods. + */ +import { JBaseElement, JBaseInput } from './types'; +/** + * * The core class of the framework, inheriting from the native Array class. Acts as a wrapper around DOM elements and enables chainable methods (Fluent Interface). + */ +export declare class jBase extends Array { + /** + * * The original selector string or input type used to create this instance. + */ + selectorSource: string; + /** + * * The document context this instance is bound to (supports SSR via jsdom). + */ + doc: Document; + /** + * * Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements. + * @param selector The input selector (CSS selector, HTML string, DOM element, or collection). + * @param context An optional specific Document or Window context (essential for SSR). + */ + constructor(selector?: JBaseInput, context?: Document | Window); + /** + * * Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview. + * @example toJson() => { meta: 'jBase Wrapper', query: '#myId', count: 1, preview: ['div'] } + * @returns A simplified object representation for debugging. + */ + toJSON(): { + meta: string; + query: string; + count: number; + preview: string[]; + }; +} +//# sourceMappingURL=core.d.ts.map \ No newline at end of file diff --git a/dist/core.d.ts.map b/dist/core.d.ts.map new file mode 100644 index 0000000..aeba384 --- /dev/null +++ b/dist/core.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGnD;;GAEG;AACH,qBAAa,KAAM,SAAQ,KAAK,CAAC,YAAY,CAAC;IAC1C;;OAEG;IACI,cAAc,EAAE,MAAM,CAAM;IAEnC;;OAEG;IACI,GAAG,EAAE,QAAQ,CAAC;IAErB;;;;OAIG;gBACS,QAAQ,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,QAAQ,GAAG,MAAM;IA0D9D;;;;OAIG;IACH,MAAM;;;;;;CA4BT"} \ No newline at end of file diff --git a/dist/index.cjs b/dist/index.cjs new file mode 100644 index 0000000..e3314f3 --- /dev/null +++ b/dist/index.cjs @@ -0,0 +1,3037 @@ +/** + * @k37z3r/jbase - Ditch the legacy bloat. jBase is a blazing-fast, SSR-ready micro-framework combining an elegant DOM chaining API with powerful, immutable data utilities. Fully typed, modular, and built for modern web & Node.js environments. + * @version 2.4.0 + * @homepage https://github.com/k37z3r/jBase-2 + * @author Sven Minio (https://github.com/k37z3r/jBase-2) + * @license GPL-3.0-or-later + * @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2) + */ +"use strict"; +var __defProp = Object.defineProperty; +var __getOwnPropDesc = Object.getOwnPropertyDescriptor; +var __getOwnPropNames = Object.getOwnPropertyNames; +var __hasOwnProp = Object.prototype.hasOwnProperty; +var __export = (target, all) => { + for (var name in all) + __defProp(target, name, { get: all[name], enumerable: true }); +}; +var __copyProps = (to, from, except, desc) => { + if (from && typeof from === "object" || typeof from === "function") { + for (let key of __getOwnPropNames(from)) + if (!__hasOwnProp.call(to, key) && key !== except) + __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); + } + return to; +}; +var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); + +// src/index.ts +var index_exports = {}; +__export(index_exports, { + $: () => $, + JBaseClass: () => jBase, + __: () => __, + __jB: () => __jB, + __jBase: () => __jBase, + _jB: () => _jB, + _jBase: () => _jBase, + bind: () => bind, + data: () => data, + debounce: () => debounce, + each: () => each, + http: () => http, + jB: () => jB, + jBase: () => jBase2, + throttle: () => throttle +}); +module.exports = __toCommonJS(index_exports); + +// src/utils.ts +function throttle(func, limit) { + let inThrottle; + return function(...args) { + const context = this; + if (!inThrottle) { + func.apply(context, args); + inThrottle = true; + setTimeout(() => inThrottle = false, limit); + } + }; +} +function debounce(func, delay) { + let timer; + return function(...args) { + clearTimeout(timer); + timer = setTimeout(() => func.apply(this, args), delay); + }; +} +function isBrowser() { + return typeof window !== "undefined" && typeof window.requestAnimationFrame !== "undefined"; +} +function each(collection, callback) { + const isArrayLike = Array.isArray(collection) || collection && typeof collection === "object" && "length" in collection && typeof collection.length === "number"; + if (isArrayLike) { + const arr = collection; + for (let i = 0, len = arr.length; i < len; i++) { + if (callback.call(arr[i], i, arr[i]) === false) { + break; + } + } + } else { + const obj = collection; + for (const key in obj) { + if (Object.prototype.hasOwnProperty.call(obj, key)) { + if (callback.call(obj[key], key, obj[key]) === false) { + break; + } + } + } + } + return collection; +} +function sanitizeDangerousAttributes(htmlStr) { + let cleanStr = htmlStr.replace(/on\w+\s*=\s*(['"])(?:(?!\1).)*\1/gi, ""); + cleanStr = cleanStr.replace(/(href|action)\s*=\s*(['"])\s*javascript\s*:[\s\S]*?\2/gi, ""); + return cleanStr; +} + +// src/core.ts +var jBase = class extends Array { + /** + * * The original selector string or input type used to create this instance. + */ + selectorSource = ""; + /** + * * The document context this instance is bound to (supports SSR via jsdom). + */ + doc; + /** + * * Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements. + * @param selector The input selector (CSS selector, HTML string, DOM element, or collection). + * @param context An optional specific Document or Window context (essential for SSR). + */ + constructor(selector, context) { + super(); + if (context instanceof Document) { + this.doc = context; + } else if (context && context.document) { + this.doc = context.document; + } else { + this.doc = typeof document !== "undefined" ? document : null; + } + if (typeof document === "undefined") { + return; + } + this.selectorSource = typeof selector === "string" ? selector : ""; + if (!selector) + return; + if (selector instanceof HTMLElement || selector === document || selector === window || selector instanceof Element) { + this.push(selector); + } else if (typeof selector === "string") { + const trimmed = selector.trim(); + if (trimmed.startsWith("<") && trimmed.endsWith(">")) { + const tempDiv = this.doc.createElement("div"); + tempDiv.innerHTML = sanitizeDangerousAttributes(trimmed); + this.push(...Array.from(tempDiv.children)); + } else if (trimmed.startsWith("#") && !trimmed.includes(" ") && !trimmed.includes(".")) { + const el = this.doc.getElementById(trimmed.slice(1)); + if (el) + this.push(el); + } else if (trimmed.startsWith(".") && !trimmed.includes(" ") && !/[:\[#]/.test(trimmed)) { + const els = this.doc.getElementsByClassName(trimmed.slice(1)); + for (let i = 0; i < els.length; i++) { + this.push(els[i]); + } + } else if (/^[a-zA-Z0-9]+$/.test(trimmed)) { + const els = this.doc.getElementsByTagName(trimmed); + for (let i = 0; i < els.length; i++) { + this.push(els[i]); + } + } else { + try { + this.push(...Array.from(this.doc.querySelectorAll(selector))); + } catch (e) { + console.warn(`jBase: Invalid selector "${selector}"`, e); + } + } + } else if (selector instanceof NodeList || Array.isArray(selector)) { + this.push(...Array.from(selector)); + } + } + /** + * * Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview. + * @example toJson() => { meta: 'jBase Wrapper', query: '#myId', count: 1, preview: ['div'] } + * @returns A simplified object representation for debugging. + */ + toJSON() { + return { + meta: "jBase Wrapper", + query: this.selectorSource, + count: this.length, + preview: this.slice(0, 10).map((el) => { + if (el instanceof Element) + return el.tagName.toLowerCase(); + return typeof el; + }) + }; + } + /** + * * High-performance iteration over matched elements. + * * Returning 'false' in the callback breaks the loop early. + * @example each((el, index) => { console.log(el); if (index === 5) return false; }) => Logs the first 6 matched elements to the console. + * @param callback The function to execute for each element. Context (`this`) is set to the current element. + * @returns The current jBase instance for chaining. + */ + each(callback) { + for (let i = 0, len = this.length; i < len; i++) { + if (callback.call(this[i], this[i], i) === false) { + break; + } + } + return this; + } +}; + +// src/modules/css/classes.ts +var classes_exports = {}; +__export(classes_exports, { + addClass: () => addClass, + hasClass: () => hasClass, + removeClass: () => removeClass, + toggleClass: () => toggleClass +}); +function addClass(...classNames) { + this.each(function(el) { + if (el instanceof Element) el.classList.add(...classNames); + }); + return this; +} +function removeClass(...classNames) { + this.each(function(el) { + if (el instanceof Element) el.classList.remove(...classNames); + }); + return this; +} +function toggleClass(className) { + this.each(function(el) { + if (el instanceof Element) el.classList.toggle(className); + }); + return this; +} +function hasClass(className) { + return this.some((el) => { + return el instanceof Element && el.classList.contains(className); + }); +} + +// src/modules/css/styles.ts +var styles_exports = {}; +__export(styles_exports, { + css: () => css +}); +function css(property, value) { + if (typeof property === "object" && property !== null) { + this.each(function(el) { + if (el instanceof HTMLElement || el instanceof SVGElement) { + for (const key in property) { + if (Object.prototype.hasOwnProperty.call(property, key)) { + if (key.includes("-")) { + el.style.setProperty(key, String(property[key])); + } else { + el.style[key] = property[key]; + } + } + } + } + }); + return this; + } + if (typeof property === "string") { + if (value === void 0) { + const el = this[0]; + if (el instanceof HTMLElement || el instanceof SVGElement) { + const doc = el.ownerDocument; + const win = doc ? doc.defaultView : null; + if (win) { + return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property] || ""; + } else { + return el.style[property] || ""; + } + } + return ""; + } + this.each(function(el) { + if (el instanceof HTMLElement || el instanceof SVGElement) { + if (property.includes("-")) { + el.style.setProperty(property, String(value)); + } else { + el.style[property] = value; + } + } + }); + } + return this; +} + +// src/modules/css/index.ts +var cssMethods = { + ...classes_exports, + ...styles_exports +}; + +// src/modules/events/binding.ts +var binding_exports = {}; +__export(binding_exports, { + off: () => off, + on: () => on, + once: () => once, + trigger: () => trigger +}); +var JB_EVENTS = "__jb_events"; +function on(events, selectorOrDataOrHandler, dataOrHandler, handlerOrUndefined) { + let selector; + let data2; + let handler; + if (typeof selectorOrDataOrHandler === "string") { + selector = selectorOrDataOrHandler; + if (typeof dataOrHandler === "function") { + handler = dataOrHandler; + } else { + data2 = dataOrHandler; + handler = handlerOrUndefined; + } + } else if (typeof selectorOrDataOrHandler === "function") { + handler = selectorOrDataOrHandler; + } else { + data2 = selectorOrDataOrHandler; + handler = dataOrHandler; + } + if (!handler) return this; + const eventTypes = events.split(" "); + this.each(function(el) { + if (!(el instanceof EventTarget)) return; + const registry = el[JB_EVENTS] || (el[JB_EVENTS] = []); + each(eventTypes, function(_index, eventType) { + const wrappedHandler = function(e) { + let targetContext = el; + if (selector) { + const target = e.target instanceof Element ? e.target : e.target?.parentElement; + const match = target instanceof Element && target.closest ? target.closest(selector) : null; + if (!match || !el.contains(match)) { + return; + } + targetContext = match; + } + if (data2 !== void 0) { + e.data = data2; + } + handler.call(targetContext, e); + }; + registry.push({ + type: eventType, + original: handler, + wrapped: wrappedHandler, + selector + }); + el.addEventListener(eventType, wrappedHandler); + }); + }); + return this; +} +function off(events, selectorOrHandler, handlerOrUndefined) { + let selector; + let handler; + if (typeof selectorOrHandler === "string") { + selector = selectorOrHandler; + handler = handlerOrUndefined; + } else if (typeof selectorOrHandler === "function") { + handler = selectorOrHandler; + } + const eventTypes = events.split(" "); + this.each(function(el) { + if (!(el instanceof EventTarget)) return; + const registry = el[JB_EVENTS]; + if (!registry) return; + each(eventTypes, function(_index, eventType) { + for (let i = registry.length - 1; i >= 0; i--) { + const record = registry[i]; + const matchType = record.type === eventType; + const matchSelector = selector ? record.selector === selector : true; + const matchHandler = handler ? record.original === handler : true; + if (matchType && matchSelector && matchHandler) { + el.removeEventListener(eventType, record.wrapped); + registry.splice(i, 1); + } + } + }); + }); + return this; +} +function once(events, selectorOrDataOrHandler, dataOrHandler, handlerOrUndefined) { + const self = this; + const handleOnce = function(e) { + self.off(events, selectorOrDataOrHandler, handleOnce); + let realHandler; + if (typeof selectorOrDataOrHandler === "function") { + realHandler = selectorOrDataOrHandler; + } else if (typeof dataOrHandler === "function") { + realHandler = dataOrHandler; + } else { + realHandler = handlerOrUndefined; + } + return realHandler.apply(this, arguments); + }; + if (typeof selectorOrDataOrHandler === "string") { + if (typeof dataOrHandler === "function") { + return this.on(events, selectorOrDataOrHandler, handleOnce); + } else { + return this.on(events, selectorOrDataOrHandler, dataOrHandler, handleOnce); + } + } else if (typeof selectorOrDataOrHandler === "function") { + return this.on(events, handleOnce); + } else { + return this.on(events, selectorOrDataOrHandler, handleOnce); + } +} +function trigger(eventName, data2) { + return this.each(function(el) { + if (!(el instanceof EventTarget)) return; + const event = new CustomEvent(eventName, { + bubbles: true, + cancelable: true, + detail: data2 + }); + el.dispatchEvent(event); + }); +} + +// src/modules/events/mouse.ts +var mouse_exports = {}; +__export(mouse_exports, { + click: () => click, + dblclick: () => dblclick, + hover: () => hover, + mousedown: () => mousedown, + mouseenter: () => mouseenter, + mouseleave: () => mouseleave, + mousemove: () => mousemove, + mouseout: () => mouseout, + mouseover: () => mouseover, + mouseup: () => mouseup +}); +function click(handler) { + if (handler) { + return this.on("click", handler); + } else { + this.each(function(el) { + if (el instanceof HTMLElement) el.click(); + }); + return this; + } +} +function mousemove(handler) { + return this.on("mousemove", handler); +} +function mouseleave(handler) { + return this.on("mouseleave", handler); +} +function mouseenter(handler) { + return this.on("mouseenter", handler); +} +function mousedown(handler) { + return this.on("mousedown", handler); +} +function mouseup(handler) { + return this.on("mouseup", handler); +} +function dblclick(handler) { + if (handler) { + return this.on("dblclick", handler); + } else { + this.each(function(el) { + if (el instanceof HTMLElement) { + el.dispatchEvent(new MouseEvent("dblclick", { + bubbles: true, + cancelable: true, + view: window + })); + } + }); + return this; + } +} +function mouseout(handler) { + return this.on("mouseout", handler); +} +function mouseover(handler) { + return this.on("mouseover", handler); +} +function hover(handlerIn, handlerOut) { + return this.mouseenter(handlerIn).mouseleave(handlerOut); +} + +// src/modules/events/lifecycle.ts +var lifecycle_exports = {}; +__export(lifecycle_exports, { + ready: () => ready +}); +function ready(handler) { + const doc = window.document; + if (doc.readyState === "complete" || doc.readyState === "interactive") { + handler(); + } else { + this.on("DOMContentLoaded", handler); + } + return this; +} + +// src/modules/events/keyboard.ts +var keyboard_exports = {}; +__export(keyboard_exports, { + keydown: () => keydown, + keypress: () => keypress, + keyup: () => keyup, + pressedKey: () => pressedKey +}); +function keydown(handler) { + return this.on("keydown", handler); +} +function keyup(handler) { + return this.on("keyup", handler); +} +function keypress(handler) { + return this.on("keypress", handler); +} +function pressedKey(targetKey, handler) { + return this.on("keydown", (e) => { + const event = e; + if (event.key.toLowerCase() === targetKey.toLowerCase()) { + handler(event); + } + }); +} + +// src/modules/events/form.ts +var form_exports = {}; +__export(form_exports, { + blur: () => blur, + change: () => change, + focus: () => focus, + input: () => input, + submit: () => submit +}); +function submit(handler) { + return this.on("submit", handler); +} +function change(handler) { + return this.on("change", handler); +} +function input(handler) { + return this.on("input", handler); +} +function focus(handler) { + if (handler) { + return this.on("focus", handler); + } else { + this.each(function(el) { + if (el instanceof HTMLElement) el.focus(); + }); + return this; + } +} +function blur(handler) { + if (handler) { + return this.on("blur", handler); + } else { + this.each(function(el) { + if (el instanceof HTMLElement) el.blur(); + }); + return this; + } +} + +// src/modules/events/touch.ts +var touch_exports = {}; +__export(touch_exports, { + swipeDown: () => swipeDown, + swipeLeft: () => swipeLeft, + swipeRight: () => swipeRight, + swipeUp: () => swipeUp, + touchcancel: () => touchcancel, + touchend: () => touchend, + touchmove: () => touchmove, + touchstart: () => touchstart +}); +function touchstart(handler) { + return this.on("touchstart", handler); +} +function touchend(handler) { + return this.on("touchend", handler); +} +function touchmove(handler) { + return this.on("touchmove", handler); +} +function touchcancel(handler) { + return this.on("touchcancel", handler); +} +function swipeLeft(handler) { + return this.each(function(el) { + if (el instanceof Element) handleSwipe.call(this, el, "left", handler); + }); +} +function swipeRight(handler) { + return this.each(function(el) { + if (el instanceof Element) handleSwipe.call(this, el, "right", handler); + }); +} +function swipeUp(handler) { + return this.each(function(el) { + if (el instanceof Element) handleSwipe.call(this, el, "up", handler); + }); +} +function swipeDown(handler) { + return this.each(function(el) { + if (el instanceof Element) handleSwipe.call(this, el, "down", handler); + }); +} +function handleSwipe(el, direction, handler) { + let startX = 0, startY = 0; + el.addEventListener("touchstart", (e) => { + startX = e.touches[0].clientX; + startY = e.touches[0].clientY; + }, { passive: true }); + el.addEventListener("touchend", (e) => { + const diffX = e.changedTouches[0].clientX - startX; + const diffY = e.changedTouches[0].clientY - startY; + const threshold = 50; + if (Math.abs(diffX) > Math.abs(diffY)) { + if (Math.abs(diffX) > threshold) { + if (diffX > 0 && direction === "right") handler.call(el, e); + if (diffX < 0 && direction === "left") handler.call(el, e); + } + } else { + if (Math.abs(diffY) > threshold) { + if (diffY > 0 && direction === "down") handler.call(el, e); + if (diffY < 0 && direction === "up") handler.call(el, e); + } + } + }, { passive: true }); +} + +// src/modules/events/index.ts +var eventMethods = { + ...binding_exports, + ...mouse_exports, + ...lifecycle_exports, + ...keyboard_exports, + ...form_exports, + ...touch_exports +}; + +// src/modules/dom/attributes.ts +var attributes_exports = {}; +__export(attributes_exports, { + attr: () => attr, + prop: () => prop, + removeAttr: () => removeAttr, + val: () => val +}); +function attr(name, value) { + if (value === void 0) { + const el = this[0]; + return el instanceof Element ? el.getAttribute(name) : null; + } + this.each(function(el) { + if (el instanceof Element) el.setAttribute(name, value); + }); + return this; +} +function val(value) { + if (value === void 0) { + const el = this[0]; + if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) { + return el.value; + } + return ""; + } + this.each(function(el) { + if (el instanceof HTMLInputElement || el instanceof HTMLTextAreaElement || el instanceof HTMLSelectElement) { + el.value = value; + } + }); + return this; +} +function removeAttr(name) { + this.each(function(el) { + if (el instanceof Element) el.removeAttribute(name); + }); + return this; +} +function prop(name, value) { + if (value === void 0) { + const el = this[0]; + return el instanceof Element ? el[name] : void 0; + } + this.each(function(el) { + if (el instanceof Element) { + el[name] = value; + } + }); + return this; +} + +// src/modules/dom/content.ts +var content_exports = {}; +__export(content_exports, { + html: () => html, + load: () => load, + text: () => text +}); + +// src/modules/http/get.ts +var get_exports = {}; +__export(get_exports, { + get: () => get, + getText: () => getText +}); +async function get(url, option) { + const fetchOptions = { ...option }; + if (fetchOptions.method?.toLowerCase() === "post") { + fetchOptions.method = "GET"; + } + if (!fetchOptions.signal) { + fetchOptions.signal = AbortSignal.timeout(5e3); + } + const response = await fetch(url, { + ...fetchOptions + }); + if (!response.ok) { + throw new Error(`HTTP Error: ${response.status}`); + } + const text2 = await response.text(); + try { + return text2 ? JSON.parse(text2) : {}; + } catch (e) { + return text2; + } +} +async function getText(url, option) { + const fetchOptions = { ...option }; + if (fetchOptions.method?.toLowerCase() !== "get") { + fetchOptions.method = "GET"; + } + if (!fetchOptions.signal) { + fetchOptions.signal = AbortSignal.timeout(5e3); + } + const response = await fetch(url, { + ...fetchOptions + }); + if (!response.ok) { + throw new Error(`HTTP Error: ${response.status}`); + } + const text2 = await response.text(); + return text2; +} + +// src/modules/dom/content.ts +function extractAndExecuteScripts(htmlStr, doc) { + const tempDiv = doc.createElement("div"); + tempDiv.innerHTML = htmlStr; + const scripts = tempDiv.querySelectorAll("script"); + scripts.forEach((oldScript) => { + const newScript = doc.createElement("script"); + Array.from(oldScript.attributes).forEach((attr2) => { + newScript.setAttribute(attr2.name, attr2.value); + }); + if (oldScript.textContent) { + newScript.textContent = oldScript.textContent; + } + doc.head.appendChild(newScript); + doc.head.removeChild(newScript); + oldScript.remove(); + }); + return tempDiv.innerHTML; +} +function html(content, options) { + if (content === void 0) { + const el = this[0]; + return el instanceof Element ? el.innerHTML : ""; + } + let finalHtml = content; + const execute = options?.executeScripts === true; + this.each(function(el) { + if (el instanceof Element) { + const doc = el.ownerDocument || document; + const processedHtml = execute ? extractAndExecuteScripts(finalHtml, doc) : sanitizeDangerousAttributes(finalHtml); + el.innerHTML = processedHtml; + } + }); + return this; +} +function text(content) { + if (content === void 0) { + const el = this[0]; + return el instanceof Node ? el.textContent || "" : ""; + } + this.each(function(el) { + if (el instanceof HTMLElement) { + el.textContent = content; + } + }); + return this; +} +async function load(url, options) { + try { + const fetchOptions = { ...options }; + delete fetchOptions.executeScripts; + const htmlStr = await getText(url, fetchOptions); + this.html(htmlStr, { executeScripts: options?.executeScripts }); + } catch (error) { + console.error(`jBase .load() failed to fetch: ${url}`, error); + throw error; + } + return this; +} + +// src/modules/dom/manipulation.ts +var manipulation_exports = {}; +__export(manipulation_exports, { + after: () => after, + append: () => append, + appendTo: () => appendTo, + before: () => before, + empty: () => empty, + insertAfter: () => insertAfter, + insertBefore: () => insertBefore, + prepend: () => prepend, + prependTo: () => prependTo, + remove: () => remove, + replaceWith: () => replaceWith, + replaceWithClone: () => replaceWithClone, + unwrap: () => unwrap, + wrap: () => wrap +}); +function parseHTML(html2, doc) { + const tmp = doc.createElement("div"); + tmp.innerHTML = sanitizeDangerousAttributes(html2.trim()); + return tmp.firstElementChild; +} +function getDoc(collection) { + if (collection.length > 0 && collection[0] instanceof Element) { + return collection[0].ownerDocument; + } + return typeof document !== "undefined" ? document : null; +} +function normalizeToFragment(content, doc) { + const fragment = doc.createDocumentFragment(); + const add4 = (item) => { + if (typeof item === "string") { + const temp = doc.createElement("div"); + temp.innerHTML = sanitizeDangerousAttributes(item.trim()); + while (temp.firstChild) { + fragment.appendChild(temp.firstChild); + } + } else if (item instanceof Node) { + fragment.appendChild(item); + } else if (item instanceof jBase || Array.isArray(item) || item instanceof NodeList) { + each(item, function(_index, child) { + add4(child); + }); + } + }; + add4(content); + return fragment; +} +function remove() { + this.each(function(el) { + if (el instanceof Element) el.remove(); + }); + return this; +} +function empty() { + this.each(function(el) { + if (el instanceof Element) el.innerHTML = ""; + }); + return this; +} +function replaceWithClone() { + const newElements = []; + this.each(function(el) { + if (el instanceof Element) { + const clone = el.cloneNode(true); + el.replaceWith(clone); + newElements.push(clone); + } + }); + return new this.constructor(newElements); +} +function append(content) { + if (typeof content === "string") { + const safeContent = sanitizeDangerousAttributes(content); + this.each(function(el) { + if (el instanceof Element) { + el.insertAdjacentHTML("beforeend", safeContent); + } + }); + return this; + } + const doc = getDoc(this); + if (!doc) + return this; + const fragment = normalizeToFragment(content, doc); + const len = this.length; + this.each(function(el, i) { + if (el instanceof Element) { + const contentToInsert = i < len - 1 ? fragment.cloneNode(true) : fragment; + el.appendChild(contentToInsert); + } + }); + return this; +} +function prepend(content) { + if (typeof content === "string") { + const safeContent = sanitizeDangerousAttributes(content); + this.each(function(el) { + if (el instanceof Element) { + el.insertAdjacentHTML("afterbegin", safeContent); + } + }); + return this; + } + const doc = getDoc(this); + if (!doc) + return this; + const fragment = normalizeToFragment(content, doc); + const len = this.length; + this.each(function(el, i) { + if (el instanceof Element) { + const contentToInsert = i < len - 1 ? fragment.cloneNode(true) : fragment; + el.prepend(contentToInsert); + } + }); + return this; +} +function before(content) { + if (typeof content === "string") { + const safeContent = sanitizeDangerousAttributes(content); + this.each(function(el) { + if (el instanceof Element) { + el.insertAdjacentHTML("beforebegin", safeContent); + } + }); + return this; + } + const doc = getDoc(this); + if (!doc) + return this; + const fragment = normalizeToFragment(content, doc); + const len = this.length; + this.each(function(el, i) { + if (el instanceof Element) { + const contentToInsert = i < len - 1 ? fragment.cloneNode(true) : fragment; + el.before(contentToInsert); + } + }); + return this; +} +function after(content) { + if (typeof content === "string") { + const safeContent = sanitizeDangerousAttributes(content); + this.each(function(el) { + if (el instanceof Element) { + el.insertAdjacentHTML("afterend", safeContent); + } + }); + return this; + } + const doc = getDoc(this); + if (!doc) + return this; + const fragment = normalizeToFragment(content, doc); + const len = this.length; + this.each(function(el, i) { + if (el instanceof Element) { + const contentToInsert = i < len - 1 ? fragment.cloneNode(true) : fragment; + el.after(contentToInsert); + } + }); + return this; +} +function replaceWith(content) { + const doc = getDoc(this); + if (!doc) + return this; + const fragment = normalizeToFragment(content, doc); + const len = this.length; + this.each(function(el, i) { + if (el instanceof Element) { + const contentToInsert = i < len - 1 ? fragment.cloneNode(true) : fragment; + el.replaceWith(contentToInsert); + } + }); + return this; +} +function appendTo(target) { + const doc = getDoc(this); + if (!doc) + return this; + const parent2 = typeof target === "string" ? doc.querySelector(target) : target; + if (parent2 instanceof Element) { + const fragment = doc.createDocumentFragment(); + this.each(function(el) { + if (el instanceof Node) fragment.appendChild(el); + }); + parent2.appendChild(fragment); + } + return this; +} +function prependTo(target) { + const doc = getDoc(this); + if (!doc) + return this; + const parent2 = typeof target === "string" ? doc.querySelector(target) : target; + if (parent2 instanceof Element) { + const fragment = doc.createDocumentFragment(); + this.each(function(el) { + if (el instanceof Node) fragment.appendChild(el); + }); + parent2.prepend(fragment); + } + return this; +} +function insertBefore(target) { + const doc = getDoc(this); + if (!doc) + return this; + const targetEl = typeof target === "string" ? doc.querySelector(target) : target; + if (targetEl instanceof Element) { + const fragment = doc.createDocumentFragment(); + this.each(function(el) { + if (el instanceof Node) fragment.appendChild(el); + }); + targetEl.before(fragment); + } + return this; +} +function insertAfter(target) { + const doc = getDoc(this); + if (!doc) + return this; + const targetEl = typeof target === "string" ? doc.querySelector(target) : target; + if (targetEl instanceof Element) { + const fragment = doc.createDocumentFragment(); + this.each(function(el) { + if (el instanceof Node) fragment.appendChild(el); + }); + targetEl.after(fragment); + } + return this; +} +function wrap(wrapperHtml) { + const doc = getDoc(this); + if (!doc) + return this; + this.each(function(el) { + if (el instanceof Element) { + const wrapper = parseHTML(wrapperHtml, doc); + if (el.parentNode) { + el.parentNode.insertBefore(wrapper, el); + } + wrapper.appendChild(el); + } + }); + return this; +} +function unwrap() { + const doc = getDoc(this); + if (!doc) return this; + const parents2 = /* @__PURE__ */ new Set(); + this.each(function(el) { + if (el instanceof Element && el.parentElement) { + parents2.add(el.parentElement); + } + }); + each(Array.from(parents2), function(_index, parent2) { + const fragment = doc.createDocumentFragment(); + while (parent2.firstChild) { + fragment.appendChild(parent2.firstChild); + } + parent2.replaceWith(fragment); + }); + return this; +} + +// src/modules/dom/traversal.ts +var traversal_exports = {}; +__export(traversal_exports, { + children: () => children, + closest: () => closest, + descendants: () => descendants, + descendantsUntil: () => descendantsUntil, + eq: () => eq, + filterBy: () => filterBy, + findAll: () => findAll, + first: () => first, + last: () => last, + next: () => next, + nextAll: () => nextAll, + nextSibling: () => nextSibling, + nextUntil: () => nextUntil, + not: () => not, + parent: () => parent, + parents: () => parents, + parentsUntil: () => parentsUntil, + prev: () => prev, + prevAll: () => prevAll, + prevSibling: () => prevSibling, + prevUntil: () => prevUntil, + sibling: () => sibling, + siblings: () => siblings +}); +function closest(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element) { + const match = el.closest(selector); + if (match) { + found.push(match); + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function parent() { + const parents2 = []; + this.each(function(el) { + if (el instanceof Element && el.parentElement) { + parents2.push(el.parentElement); + } + }); + const Construction = this.constructor; + return new Construction([...new Set(parents2)]); +} +function children(selector) { + let allChildren = []; + this.each(function(el) { + if (el instanceof Element) { + const kids = Array.from(el.children); + allChildren = allChildren.concat(kids); + } + }); + if (selector) { + allChildren = allChildren.filter((child) => child.matches(selector)); + } + const Construction = this.constructor; + return new Construction(allChildren); +} +function findAll(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element || el instanceof Document) { + const matches = el.querySelectorAll(selector); + each(matches, function(_index, m) { + found.push(m); + }); + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function descendants() { + return this.findAll("*"); +} +function parents(selector) { + const ancestors = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.parentElement; + while (curr) { + if (!selector || curr.matches(selector)) { + ancestors.push(curr); + } + curr = curr.parentElement; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(ancestors)]); +} +function parentsUntil(selector, filter) { + const ancestors = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.parentElement; + while (curr && !curr.matches(selector)) { + if (!filter || curr.matches(filter)) { + ancestors.push(curr); + } + curr = curr.parentElement; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(ancestors)]); +} +function descendantsUntil(untilSelector, filter) { + const found = []; + const traverse = (parent2) => { + const kids = parent2.children; + for (let i = 0; i < kids.length; i++) { + const child = kids[i]; + if (child.matches(untilSelector)) { + continue; + } + if (!filter || child.matches(filter)) { + found.push(child); + } + traverse(child); + } + }; + this.each(function(el) { + if (el instanceof Element) traverse(el); + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function next(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element && el.nextElementSibling) { + const nextEl = el.nextElementSibling; + if (!selector || nextEl.matches(selector)) { + found.push(nextEl); + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function prev(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element && el.previousElementSibling) { + const prevEl = el.previousElementSibling; + if (!selector || prevEl.matches(selector)) { + found.push(prevEl); + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function nextSibling(selector) { + return this.next(selector); +} +function prevSibling(selector) { + return this.prev(selector); +} +function sibling(selector) { + return this.next(selector); +} +function nextAll(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.nextElementSibling; + while (curr) { + if (!selector || curr.matches(selector)) { + found.push(curr); + } + curr = curr.nextElementSibling; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function prevAll(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.previousElementSibling; + while (curr) { + if (!selector || curr.matches(selector)) { + found.push(curr); + } + curr = curr.previousElementSibling; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function siblings(selector) { + const found = []; + this.each(function(el) { + if (el instanceof Element && el.parentElement) { + const children2 = Array.from(el.parentElement.children); + each(children2, function(_index, child) { + if (child !== el) { + if (!selector || child.matches(selector)) { + found.push(child); + } + } + }); + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function nextUntil(untilSelector, filter) { + const found = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.nextElementSibling; + while (curr && !curr.matches(untilSelector)) { + if (!filter || curr.matches(filter)) { + found.push(curr); + } + curr = curr.nextElementSibling; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function prevUntil(untilSelector, filter) { + const found = []; + this.each(function(el) { + if (el instanceof Element) { + let curr = el.previousElementSibling; + while (curr && !curr.matches(untilSelector)) { + if (!filter || curr.matches(filter)) { + found.push(curr); + } + curr = curr.previousElementSibling; + } + } + }); + const Construction = this.constructor; + return new Construction([...new Set(found)]); +} +function eq(index) { + const len = this.length; + const idx = index < 0 ? len + index : index; + const el = this[idx]; + const Construction = this.constructor; + return new Construction(el ? [el] : []); +} +function first() { + return this.eq(0); +} +function last() { + return this.eq(-1); +} +function filterBy(selectorOrFn) { + const found = []; + this.each(function(el, index) { + if (el instanceof Element) { + if (typeof selectorOrFn === "string") { + if (el.matches(selectorOrFn)) { + found.push(el); + } + } else if (typeof selectorOrFn === "function") { + if (selectorOrFn.call(el, index, el)) { + found.push(el); + } + } + } + }); + const Construction = this.constructor; + return new Construction(found); +} +function not(selectorOrFn) { + const found = []; + this.each(function(el, index) { + if (el instanceof Element) { + if (typeof selectorOrFn === "string") { + if (!el.matches(selectorOrFn)) { + found.push(el); + } + } else if (typeof selectorOrFn === "function") { + if (!selectorOrFn.call(el, index, el)) { + found.push(el); + } + } + } + }); + const Construction = this.constructor; + return new Construction(found); +} + +// src/modules/dom/states.ts +var states_exports = {}; +__export(states_exports, { + check: () => check, + checked: () => checked, + disable: () => disable, + disabled: () => disabled, + enable: () => enable, + select: () => select, + selected: () => selected, + uncheck: () => uncheck +}); +function checked(state) { + if (state === void 0) { + const el = this[0]; + return el instanceof HTMLInputElement ? el.checked : false; + } + this.each(function(el) { + if (el instanceof HTMLInputElement) + el.checked = state; + }); + return this; +} +function selected(state) { + if (state === void 0) { + const el = this[0]; + return el instanceof HTMLOptionElement ? el.selected : false; + } + this.each(function(el) { + if (el instanceof HTMLOptionElement) + el.selected = state; + }); + return this; +} +function disabled(state) { + if (state === void 0) { + const el = this[0]; + return el instanceof HTMLElement && "disabled" in el ? el.disabled : false; + } + this.each(function(el) { + if (el instanceof HTMLElement && "disabled" in el) { + el.disabled = state; + if (state) + el.classList.add("disabled"); + else + el.classList.remove("disabled"); + } + }); + return this; +} +function check() { + return checked.call(this, true); +} +function uncheck() { + return checked.call(this, false); +} +function select() { + return selected.call(this, true); +} +function disable() { + return disabled.call(this, true); +} +function enable() { + return disabled.call(this, false); +} + +// src/modules/dom/index.ts +var domMethods = { + ...attributes_exports, + ...content_exports, + ...manipulation_exports, + ...traversal_exports, + ...states_exports +}; + +// src/modules/effects/slide.ts +var slide_exports = {}; +__export(slide_exports, { + slideIn: () => slideIn, + slideOut: () => slideOut, + slideToggle: () => slideToggle +}); +function slideIn(options = {}) { + if (!isBrowser()) + return this; + const { duration = 300 } = options; + this.each(function(el) { + if (el instanceof HTMLElement) { + el.style.willChange = "transform"; + el.style.transition = `transform ${duration}ms cubic-bezier(0.4, 0.0, 0.2, 1)`; + requestAnimationFrame(() => { + el.style.transform = "translateX(0%)"; + }); + el.setAttribute("data-slide-state", "open"); + } + }); + return this; +} +function slideOut(options = {}) { + if (!isBrowser()) + return this; + const { direction = "left", duration = 300 } = options; + const translateValue = direction === "left" ? "-100%" : "100%"; + this.each(function(el) { + if (el instanceof HTMLElement) { + el.style.willChange = "transform"; + el.style.transition = `transform ${duration}ms cubic-bezier(0.4, 0.0, 0.2, 1)`; + requestAnimationFrame(() => { + el.style.transform = `translateX(${translateValue})`; + }); + el.setAttribute("data-slide-state", "closed"); + } + }); + return this; +} +function slideToggle(options = {}) { + if (!isBrowser()) + return this; + this.each(function(el) { + if (el instanceof HTMLElement) { + const state = el.getAttribute("data-slide-state"); + const currentTransform = el.style.transform; + if (state === "open" || currentTransform === "translateX(0%)") { + const wrapper = new this.constructor(el); + wrapper.slideOut(options); + } else { + const wrapper = new this.constructor(el); + wrapper.slideIn(options); + } + } + }); + return this; +} + +// src/modules/effects/vertical.ts +var vertical_exports = {}; +__export(vertical_exports, { + slideDown: () => slideDown, + slideToggleBox: () => slideToggleBox, + slideUp: () => slideUp +}); +function slideDown(options = {}) { + if (!isBrowser()) + return this; + const { duration = 300, displayType = "block" } = options; + this.each(function(el) { + if (el instanceof HTMLElement) { + if (window.getComputedStyle(el).display !== "none") + return; + el.style.display = displayType; + const height = el.scrollHeight; + el.style.height = "0px"; + el.style.overflow = "hidden"; + el.style.transition = `height ${duration}ms ease-in-out`; + void el.offsetHeight; + el.style.height = `${height}px`; + setTimeout(() => { + el.style.height = "auto"; + el.style.overflow = "visible"; + el.style.transition = ""; + }, duration); + } + }); + return this; +} +function slideUp(options = {}) { + if (!isBrowser()) + return this; + const { duration = 300 } = options; + this.each(function(el) { + if (el instanceof HTMLElement) { + el.style.height = `${el.scrollHeight}px`; + el.style.overflow = "hidden"; + el.style.transition = `height ${duration}ms ease-in-out`; + void el.offsetHeight; + el.style.height = "0px"; + setTimeout(() => { + el.style.display = "none"; + el.style.height = ""; + el.style.overflow = ""; + el.style.transition = ""; + }, duration); + } + }); + return this; +} +function slideToggleBox(options = {}) { + if (!isBrowser()) + return this; + this.each(function(el) { + if (el instanceof HTMLElement) { + const display = window.getComputedStyle(el).display; + const wrapper = new this.constructor(el); + if (display === "none") { + wrapper.slideDown(options); + } else { + wrapper.slideUp(options); + } + } + }); + return this; +} + +// src/modules/effects/fade.ts +var fade_exports = {}; +__export(fade_exports, { + fadeIn: () => fadeIn, + fadeOut: () => fadeOut, + fadeToggle: () => fadeToggle, + hide: () => hide, + show: () => show, + toggle: () => toggle +}); +function fadeIn(options = {}) { + if (!isBrowser()) return this; + const duration = typeof options === "number" ? options : options.duration || 300; + const displayType = typeof options === "object" && options.displayType ? options.displayType : "block"; + this.each(function(el) { + if (el instanceof HTMLElement) { + if (el._jbaseFadeTimer) { + clearTimeout(el._jbaseFadeTimer); + } + el.style.opacity = "0"; + el.style.display = displayType; + el.style.transition = `opacity ${duration}ms ease-in-out`; + void el.offsetHeight; + requestAnimationFrame(() => { + el.style.opacity = "1"; + }); + el._jbaseFadeTimer = setTimeout(() => { + el.style.transition = ""; + delete el._jbaseFadeTimer; + }, duration); + } + }); + return this; +} +function fadeOut(options = {}) { + if (!isBrowser()) return this; + const duration = typeof options === "number" ? options : options.duration || 300; + this.each(function(el) { + if (el instanceof HTMLElement) { + if (el._jbaseFadeTimer) { + clearTimeout(el._jbaseFadeTimer); + } + el.style.opacity = "1"; + el.style.transition = `opacity ${duration}ms ease-in-out`; + void el.offsetHeight; + requestAnimationFrame(() => { + el.style.opacity = "0"; + }); + el._jbaseFadeTimer = setTimeout(() => { + el.style.display = "none"; + el.style.transition = ""; + delete el._jbaseFadeTimer; + }, duration); + } + }); + return this; +} +function fadeToggle(options = {}) { + if (!isBrowser()) return this; + this.each((el) => { + if (el instanceof HTMLElement) { + const display = window.getComputedStyle(el).display; + const wrapper = new this.constructor(el); + if (display === "none") { + wrapper.fadeIn(options); + } else { + wrapper.fadeOut(options); + } + } + }); + return this; +} +var show = fadeIn; +var hide = fadeOut; +var toggle = fadeToggle; + +// src/modules/effects/index.ts +var effectMethods = { + ...slide_exports, + ...vertical_exports, + ...fade_exports +}; + +// src/modules/http/post.ts +var post_exports = {}; +__export(post_exports, { + post: () => post +}); +async function post(url, body = {}, option) { + const fetchOptions = { ...option }; + if (fetchOptions.method?.toLowerCase() !== "post") { + fetchOptions.method = "post"; + } + if (!fetchOptions.signal) { + fetchOptions.signal = AbortSignal.timeout(5e3); + } + const response = await fetch(url, { + ...fetchOptions, + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(body) + }); + if (response.status === 204) { + const text3 = await response.text(); + return text3 ? JSON.parse(text3) : {}; + } + if (!response.ok) { + throw new Error(`HTTP Error: ${response.status}`); + } + const text2 = await response.text(); + try { + return text2 ? JSON.parse(text2) : {}; + } catch (e) { + return text2; + } +} + +// src/modules/http/upload.ts +var upload_exports = {}; +__export(upload_exports, { + upload: () => upload +}); +async function upload(url, data2, onProgress) { + return new Promise((resolve, reject) => { + const xhr = new XMLHttpRequest(); + xhr.open("POST", url); + if (onProgress) { + xhr.upload.onprogress = (event) => { + if (event.lengthComputable) { + const percentage = Math.round(event.loaded / event.total * 100); + onProgress(percentage, event.loaded, event.total); + } + }; + } + xhr.onload = () => { + if (xhr.status >= 200 && xhr.status < 300) { + const text2 = xhr.responseText; + try { + resolve(text2 ? JSON.parse(text2) : {}); + } catch (e) { + resolve(text2); + } + } else { + reject(new Error(`HTTP Error: ${xhr.status}`)); + } + }; + xhr.onerror = () => { + reject(new Error("Network Error during upload")); + }; + let payload; + if (data2 instanceof File) { + payload = new FormData(); + payload.append("file", data2); + } else { + payload = data2; + } + xhr.send(payload); + }); +} + +// src/modules/http/index.ts +var http = { + ...get_exports, + ...post_exports, + ...upload_exports +}; + +// src/modules/data/arrays.ts +var arrays_exports = {}; +__export(arrays_exports, { + add: () => add, + chunk: () => chunk, + clear: () => clear, + empty: () => empty2, + find: () => find, + get: () => get2, + merge: () => merge, + mergeArray: () => mergeArray, + omit: () => omit, + pick: () => pick, + remove: () => remove2, + set: () => set +}); +function chunk(array, size) { + const chunks = []; + for (let i = 0; i < array.length; i += size) { + chunks.push(array.slice(i, i + size)); + } + return chunks; +} +function mergeArray(...arrays) { + return [].concat(...arrays); +} +var merge = mergeArray; +function add(array, item, index = array.length) { + const copy = [...array]; + const idx = index < 0 ? array.length + index + 1 : index; + copy.splice(idx, 0, item); + return copy; +} +function clear(array) { + return []; +} +var empty2 = clear; +function pick(array, indices) { + return array.filter((_, index) => indices.includes(index)); +} +function omit(array, indices) { + return array.filter((_, index) => !indices.includes(index)); +} +function get2(array, path) { + return path.split(".").reduce((acc, part) => acc && acc[part], array); +} +function set(array, path, value) { + const parts = path.split("."); + let current = array; + for (let i = 0; i < parts.length - 1; i++) { + const part = parts[i]; + if (!current[part]) { + current[part] = isNaN(Number(parts[i + 1])) ? {} : []; + } + current = current[part]; + } + current[parts[parts.length - 1]] = value; +} +var remove2 = { + /** + * * Removes an element at a specific index. + * @example remove.at([1, 2, 3, 4], -2) => [1, 2, 4] + * @template T The type of the items in the array. + * @param array The array. + * @param index The index (negative values allowed). + * @returns A new array with the element removed. + */ + at(array, index) { + const copy = [...array]; + const idx = index < 0 ? array.length + index : index; + if (idx >= 0 && idx < copy.length) { + copy.splice(idx, 1); + } + return copy; + }, + /** + * * Removes the first element. + * @example remove.first([1, 2, 3]) => [2, 3] + * @template T The type of the items in the array. + * @param array The array. + */ + first(array) { + return array.slice(1); + }, + /** + * * Removes the last element. + * @example remove.last([1, 2, 3]) => [1, 2] + * @template T The type of the items in the array. + * @param array The array. + */ + last(array) { + return array.slice(0, -1); + }, + /** + * * Removes all elements matching a query condition. + * @example remove.byMatch(users, 'Admin', 'exact', 'role') + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + */ + byMatch(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return array.filter((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Removes the element at a specific index. + * * Mirrors object.remove.byKey. + * @example remove.byKey(['a', 'b', 'c'], 1) => ['a', 'c'] + * @template T The type of the items in the array. + * @param array The source array. + * @param index The index (key) to remove. + * @returns A new array without the specified index. + */ + byKey(array, index) { + return this.at(array, index); + }, + /** + * * Removes all elements that match a specific value exactly (Strict Equality). + * * Mirrors object.remove.byValue. + * @example remove.byValue([1, 2, 1, 3], 1) => [2, 3] + * @template T The type of the items in the array. + * @param array The source array. + * @param value The value to remove. + * @returns A new array without the matching values. + */ + byValue(array, value) { + return array.filter((item) => item !== value); + }, + /** + * * ALIAS for clear. Removes all elements. + * @param array The source array. + * @returns A new, empty array. + */ + all(array) { + return clear(array); + } +}; +var find = { + /** + * * Finds the index of the first match. + * @example find.at(['apple', 'banana', 'cherry'], 'an', 'contains') => 1 + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + * @returns Index or -1. + */ + at(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return array.findIndex((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Returns all elements matching the condition (Filter). + * @example find.all(['apple', 'banana', 'cherry'], 'a', 'contains') => ['apple', 'banana'] + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + * @returns All matching elements or -1. + */ + all(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return array.filter((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Returns the first matching element (or undefined). + * @example find.first(['apple', 'banana', 'cherry'], 'a', 'contains') => 'apple' + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + * @returns Index or -1. + */ + first(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return array.find((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Returns the last matching element (or undefined). + * @example find.last(['apple', 'banana', 'cherry'], 'a', 'contains') => 'banana' + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + * @returns Index or -1. + */ + last(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return [...array].reverse().find((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds all indices (keys) matching the query. + * * Mirrors object.find.key(). For arrays, keys are the indices. + * @param array The array to search. + * @param query The search query. + * @param mode The comparison mode. + * @returns An array of matching indices as strings. + */ + key(array, query, mode = "exact") { + const queryStr = String(query).toLowerCase(); + return Object.keys(array).filter((indexKey) => { + const valStr = String(indexKey).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds all values matching the query. + * * Mirrors object.find.value(). Identical to find.all() for flat arrays. + * @param array The array to search. + * @param query The search query. + * @param mode The comparison mode. + * @returns An array of matching values. + */ + value(array, query, mode = "exact") { + return this.all(array, query, mode); + }, + /** + * * Finds the key of the first match based on the query condition. + * @example find.byMatch(users, 'Admin', 'exact', 'role') => 0 + * @template T The type of the items in the array. + * @param array The array. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param key (Optional) The object key if it is an array of objects. + * @returns Index or -1. + */ + byMatch(array, query, mode = "exact", key) { + const queryStr = String(query).toLowerCase(); + return array.findIndex((item) => { + const val2 = key ? item[key] : item; + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + } +}; + +// src/modules/data/objects.ts +var objects_exports = {}; +__export(objects_exports, { + add: () => add2, + chunk: () => chunk2, + clear: () => clear2, + empty: () => empty3, + find: () => find2, + get: () => get3, + merge: () => merge2, + mergeObjects: () => mergeObjects, + omit: () => omit2, + pick: () => pick2, + remove: () => remove3, + set: () => set2 +}); +function isObject(item) { + return item && typeof item === "object" && !Array.isArray(item); +} +function mergeObjects(target, ...sources) { + if (!sources.length) + return target; + const source = sources.shift(); + if (isObject(target) && isObject(source)) { + for (const key in source) { + if (key === "__proto__" || key === "constructor") + continue; + if (isObject(source[key])) { + if (!target[key]) target[key] = {}; + mergeObjects(target[key], source[key]); + } else { + target[key] = source[key]; + } + } + } + return mergeObjects(target, ...sources); +} +var merge2 = mergeObjects; +function chunk2(obj, size) { + const entries = Object.entries(obj); + const chunks = []; + for (let i = 0; i < entries.length; i += size) { + const slice = entries.slice(i, i + size); + chunks.push(Object.fromEntries(slice)); + } + return chunks; +} +function add2(obj, key, value, index = Object.keys(obj).length) { + const entries = Object.entries(obj); + const idx = index < 0 ? entries.length + index + 1 : index; + entries.splice(idx, 0, [key, value]); + return Object.fromEntries(entries); +} +function clear2(obj) { + return {}; +} +var empty3 = clear2; +function pick2(obj, keys) { + const ret = {}; + each(keys, function(_index, key) { + if (key in obj) ret[key] = obj[key]; + }); + return ret; +} +function omit2(obj, keys) { + const ret = { ...obj }; + each(keys, function(_index, key) { + delete ret[key]; + }); + return ret; +} +function get3(obj, path) { + return path.split(".").reduce((acc, part) => acc && acc[part], obj); +} +function set2(obj, path, value) { + const parts = path.split("."); + let current = obj; + for (let i = 0; i < parts.length - 1; i++) { + const part = parts[i]; + if (!current[part]) current[part] = {}; + current = current[part]; + } + current[parts[parts.length - 1]] = value; +} +var remove3 = { + /** + * * Removes an entry at a specific index. + * @example remove.at({a: 1, b: 2, c: 3}, -1) => {a: 1, b: 2} + * @param obj The source object. + * @param index The index (negative values allowed). + * @returns A new object with the element removed. + */ + at(obj, index) { + const entries = Object.entries(obj); + const idx = index < 0 ? entries.length + index : index; + if (idx >= 0 && idx < entries.length) { + entries.splice(idx, 1); + } + return Object.fromEntries(entries); + }, + /** + * * Removes the first entry from the object. + * @param obj The source object. + * @returns A new object without the first entry. + */ + first(obj) { + const entries = Object.entries(obj).slice(1); + return Object.fromEntries(entries); + }, + /** + * * Removes the last entry from the object. + * @param obj The source object. + * @returns A new object without the last entry. + */ + last(obj) { + const entries = Object.entries(obj).slice(0, -1); + return Object.fromEntries(entries); + }, + /** + * * Removes all entries matching a query condition. + * @example remove.byMatch(config, 'hidden', 'exact', 'key') + * @param obj The source object. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param searchBy Whether to search by 'key' or 'value' (default: 'key'). + * @returns A new object without the matching elements. + */ + byMatch(obj, query, mode = "exact", searchBy = "key") { + const queryStr = String(query).toLowerCase(); + const filteredEntries = Object.entries(obj).filter(([key, val2]) => { + const target = searchBy === "key" ? key : val2; + const valStr = String(target).toLowerCase(); + switch (mode) { + case "exact": + return valStr !== queryStr; + case "startsWith": + return !valStr.startsWith(queryStr); + case "endsWith": + return !valStr.endsWith(queryStr); + case "contains": + return !valStr.includes(queryStr); + default: + return true; + } + }); + return Object.fromEntries(filteredEntries); + }, + /** + * * Removes all entries that have a specific key. + * @example remove.byKey({ a: 1, b: 2, c: 3 }, 'b') => { a: 1, c: 3 } + * @param obj The source object. + * @param key The key to remove. + * @returns A new object without the specified key. + */ + byKey(obj, key) { + const ret = { ...obj }; + delete ret[key]; + return ret; + }, + /** + * * Removes all entries that match a specific value exactly (Strict Equality). + * @example remove.byValue({ a: 1, b: 2, c: 1 }, 1) => { b: 2 } + * @param obj The source object. + * @param value The value to remove. + * @returns A new object without the matching values. + */ + byValue(obj, value) { + const filteredEntries = Object.entries(obj).filter(([_key, val2]) => val2 !== value); + return Object.fromEntries(filteredEntries); + }, + /** + * * ALIAS for clear. Removes all entries. + * @param obj The source object. + * @returns A new, empty object. + */ + all(obj) { + return clear2(obj); + } +}; +var find2 = { + /** + * * Returns the n-th entry of an object as a [key, value] pair. Supports negative indices. + * @example find.at({ a: 1, b: 2 }, 1) => ['b', 2] + * @param obj The object to search. + * @param index The index (0-based, negative counts from the back). + * @returns A [key, value] tuple or undefined. + */ + at(obj, index) { + const entries = Object.entries(obj); + const idx = index < 0 ? entries.length + index : index; + return entries[idx]; + }, + /** + * * Returns a NEW OBJECT containing ALL elements matching the condition. + * * Mirrors array.find.all() but returns a partial object. + * @example find.all({a: 1, b: 2, c: 1}, 1, 'exact', 'value') => {a: 1, c: 1} + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param searchBy Whether to search by 'key' or 'value' (default: 'key'). + * @returns A new object with only the matching elements. + */ + all(obj, query, mode = "exact", searchBy = "key") { + const queryStr = String(query).toLowerCase(); + const filteredEntries = Object.entries(obj).filter(([key, val2]) => { + const target = searchBy === "key" ? key : val2; + const valStr = String(target).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + return Object.fromEntries(filteredEntries); + }, + /** + * * Finds the first entry where the key or value matches the query. + * @example find.first(config, 'admin', 'exact', 'key') + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param searchBy Whether to search by 'key' or 'value'. + * @returns The first matching [key, value] pair or undefined. + */ + first(obj, query, mode = "exact", searchBy = "key") { + const entries = Object.entries(obj); + const queryStr = String(query).toLowerCase(); + return entries.find(([key, val2]) => { + const target = searchBy === "key" ? key : val2; + const valStr = String(target).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds the last entry where the key or value matches the query. + * @example find.last(config, '.php', 'endsWith', 'key') + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param searchBy Whether to search by 'key' or 'value'. + * @returns The last matching [key, value] pair or undefined. + */ + last(obj, query, mode = "exact", searchBy = "key") { + const entries = Object.entries(obj); + const queryStr = String(query).toLowerCase(); + return [...entries].reverse().find(([key, val2]) => { + const target = searchBy === "key" ? key : val2; + const valStr = String(target).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds all keys matching the query. + * @example find.key(config, 'api_', 'startsWith') + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @returns An array of matching keys. + */ + key(obj, query, mode = "exact") { + const queryStr = String(query).toLowerCase(); + return Object.keys(obj).filter((key) => { + const valStr = String(key).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds all values matching the query. + * @example find.value(config, 'enabled', 'exact') + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @returns An array of matching values. + */ + value(obj, query, mode = "exact") { + const queryStr = String(query).toLowerCase(); + return Object.values(obj).filter((val2) => { + const valStr = String(val2).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + }, + /** + * * Finds the key of the first match based on the query condition. + * * Mirrors array.find.byMatch(). For objects, it returns the key instead of a numeric index. + * @example find.byMatch(config, 'admin', 'exact', 'value') => 'role' + * @param obj The object to search. + * @param query The search query. + * @param mode The comparison mode ('exact', 'contains', 'startsWith', 'endsWith'). + * @param searchBy Whether to search by 'key' or 'value' (default: 'key'). + * @returns The matched key as a string, or undefined if no match is found. + */ + byMatch(obj, query, mode = "exact", searchBy = "key") { + const queryStr = String(query).toLowerCase(); + const entries = Object.entries(obj); + const found = entries.find(([key, val2]) => { + const target = searchBy === "key" ? key : val2; + const valStr = String(target).toLowerCase(); + switch (mode) { + case "exact": + return valStr === queryStr; + case "startsWith": + return valStr.startsWith(queryStr); + case "endsWith": + return valStr.endsWith(queryStr); + case "contains": + return valStr.includes(queryStr); + default: + return false; + } + }); + return found ? found[0] : void 0; + } +}; + +// src/modules/data/index.ts +function chunk3(data2, size) { + return Array.isArray(data2) ? chunk(data2, size) : chunk2(data2, size); +} +function merge3(data2, ...args) { + return Array.isArray(data2) ? merge(data2, ...args) : merge2(data2, ...args); +} +function add3(data2, arg1, arg2, arg3) { + return Array.isArray(data2) ? add(data2, arg1, arg2) : add2(data2, arg1, arg2, arg3); +} +function clear3(data2) { + return Array.isArray(data2) ? clear(data2) : clear2(data2); +} +function pick3(data2, keysOrIndices) { + return Array.isArray(data2) ? pick(data2, keysOrIndices) : pick2(data2, keysOrIndices); +} +function omit3(data2, keysOrIndices) { + return Array.isArray(data2) ? omit(data2, keysOrIndices) : omit2(data2, keysOrIndices); +} +function get4(data2, path) { + return Array.isArray(data2) ? get2(data2, path) : get3(data2, path); +} +function set3(data2, path, value) { + return Array.isArray(data2) ? set(data2, path, value) : set2(data2, path, value); +} +function removeAt(data2, index) { + return Array.isArray(data2) ? remove2.at(data2, index) : remove3.at(data2, index); +} +function removeFirst(data2) { + return Array.isArray(data2) ? remove2.first(data2) : remove3.first(data2); +} +function removeLast(data2) { + return Array.isArray(data2) ? remove2.last(data2) : remove3.last(data2); +} +function removeByMatch(data2, query, mode, keyOrSearchBy) { + return Array.isArray(data2) ? remove2.byMatch(data2, query, mode, keyOrSearchBy) : remove3.byMatch(data2, query, mode, keyOrSearchBy); +} +function removeByKey(data2, keyOrIndex) { + return Array.isArray(data2) ? remove2.byKey(data2, keyOrIndex) : remove3.byKey(data2, keyOrIndex); +} +function removeByValue(data2, value) { + return Array.isArray(data2) ? remove2.byValue(data2, value) : remove3.byValue(data2, value); +} +function findAt(data2, arg1, arg2, arg3) { + return Array.isArray(data2) ? find.at(data2, arg1, arg2, arg3) : find2.at(data2, arg1); +} +function findAll2(data2, query, mode, keyOrSearchBy) { + return Array.isArray(data2) ? find.all(data2, query, mode, keyOrSearchBy) : find2.all(data2, query, mode, keyOrSearchBy); +} +function findFirst(data2, query, mode, keyOrSearchBy) { + return Array.isArray(data2) ? find.first(data2, query, mode, keyOrSearchBy) : find2.first(data2, query, mode, keyOrSearchBy); +} +function findLast(data2, query, mode, keyOrSearchBy) { + return Array.isArray(data2) ? find.last(data2, query, mode, keyOrSearchBy) : find2.last(data2, query, mode, keyOrSearchBy); +} +function findKey(data2, query, mode) { + return Array.isArray(data2) ? find.key(data2, query, mode) : find2.key(data2, query, mode); +} +function findValue(data2, query, mode) { + return Array.isArray(data2) ? find.value(data2, query, mode) : find2.value(data2, query, mode); +} +function findByMatch(data2, query, mode, keyOrSearchBy) { + return Array.isArray(data2) ? find.byMatch(data2, query, mode, keyOrSearchBy) : find2.byMatch(data2, query, mode, keyOrSearchBy); +} +var data = { + arr: arrays_exports, + obj: objects_exports, + chunk: chunk3, + merge: merge3, + add: add3, + clear: clear3, + empty: clear3, + pick: pick3, + omit: omit3, + get: get4, + set: set3, + remove: { + at: removeAt, + first: removeFirst, + last: removeLast, + byKey: removeByKey, + byValue: removeByValue, + byMatch: removeByMatch, + all: clear3 + }, + find: { + at: findAt, + all: findAll2, + first: findFirst, + last: findLast, + key: findKey, + value: findValue, + byMatch: findByMatch + } +}; + +// src/index.ts +Object.assign(jBase.prototype, cssMethods); +Object.assign(jBase.prototype, eventMethods); +Object.assign(jBase.prototype, domMethods); +Object.assign(jBase.prototype, effectMethods); +var initFn = (selector) => { + return new jBase(selector); +}; +var init = Object.assign(initFn, { + http, + data, + each, + throttle, + debounce, + fn: jBase.prototype +}); +var bind = (window2) => { + const doc = window2.document; + const boundInit = (selector) => new jBase(selector, doc); + Object.assign(boundInit, { + fn: jBase.prototype, + http, + data, + each, + throttle, + debounce + }); + return boundInit; +}; +var $ = init; +var jB = init; +var _jB = init; +var __jB = init; +var _jBase = init; +var __jBase = init; +var jBase2 = init; +var __ = init; +// Annotate the CommonJS export names for ESM import in node: +0 && (module.exports = { + $, + JBaseClass, + __, + __jB, + __jBase, + _jB, + _jBase, + bind, + data, + debounce, + each, + http, + jB, + jBase, + throttle +}); +/** + * @file src/utils.ts + * @version 2.2.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Utilities + * @description + * * General utility functions and helpers (e.g., debounce, throttle, type checks). + */ +/** + * @file src/core.ts + * @version 2.2.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Core + * @description + * * The main jBase class. Handles the selection engine, initialization, and plugin architecture. + * @requires ./types + * * Type definitions for the core class and its methods. + */ +/** + * @file src/modules/css/classes.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category CSS + * @description + * * Methods for manipulating CSS classes (add, remove, toggle, has). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/css/styles.ts + * @version 2.0.4 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category CSS + * @description + * * Methods for getting and setting inline CSS styles. + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/css/index.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category CSS + * @description + * * Central entry point for CSS operations. Aggregates class and style manipulation methods. + * @requires ./classes + * * Class manipulation methods (addClass, removeClass, etc.). + * @requires ./styles + * * Style manipulation methods (css). + */ +/** + * @file src/modules/events/binding.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Core event binding methods (on, off, trigger). Handles event registration and removal. + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires ../../utils + * * Uses utility functions for iteration and environment checks. + */ +/** + * @file src/modules/events/mouse.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Methods for handling mouse events (click, dblclick, hover, mouseenter, mouseleave). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/events/lifecycle.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Methods for handling DOM lifecycle events (e.g., ready). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/events/keyboard.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Methods for handling keyboard events (keydown, keyup, keypress). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/events/form.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Methods for handling form events (submit, change, focus, blur, input). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/events/touch.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Methods for handling touch events (touchstart, touchend, touchmove). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/events/index.ts + * @version 2.0.2 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Events + * @description + * * Central entry point for event handling. Aggregates binding, mouse, lifecycle, keyboard, form, and touch events. + * @requires ./binding + * * General event binding (on, off). + * @requires ./mouse + * * Mouse interaction events (click, hover, etc.). + * @requires ./lifecycle + * * DOM lifecycle events (ready). + * @requires ./keyboard + * * Keyboard interaction events (keydown, keyup). + * @requires ./form + * * Form handling events (submit, change, input). + * @requires ./touch + * * Touch interaction events. + */ +/** + * @file src/modules/dom/attributes.ts + * @version 2.1.1 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Methods for getting and setting HTML attributes and properties (attr, data, val). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/http/get.ts + * @version 2.0.6 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category HTTP + * @description + * * Abstraction for HTTP GET requests. + */ +/** + * @file src/modules/dom/content.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Methods for getting and setting element content (html, text, empty, replaceWith). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/dom/manipulation.ts + * @version 2.0.4 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Methods for inserting, moving, and removing elements (append, prepend, remove). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires src/utils + * * Depends on utility functions (e.g., each). + */ +/** + * @file src/modules/dom/traversal.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Methods for navigating the DOM tree (find, parent, children, siblings). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires ../../utils + * * Utility functions (e.g., `each` for iteration). + */ +/** + * @file src/modules/dom/states.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Methods for checking element states (e.g., visibility, checked, disabled). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + */ +/** + * @file src/modules/dom/index.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category DOM + * @description + * * Central entry point for DOM operations. Aggregates methods for attributes, content, manipulation, traversal, and states. + * @requires ./attributes + * * Attribute and value manipulation. + * @requires ./content + * * Content handling (html, text). + * @requires ./manipulation + * * DOM manipulation (append, remove, etc.). + * @requires ./traversal + * * Tree traversal (find, parent, children). + * @requires ./states + * * State checks (checked, disabled). + */ +/** + * @file src/modules/effects/slide.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Effects + * @description + * * Methods for horizontal sliding effects (slideIn, slideOut, slideToggle). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires ../../utils + * * Uses utility functions for environment checks. + * @requires ./types + * * Type definitions for slide options. + */ +/** + * @file src/modules/effects/vertical.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Effects + * @description + * * Methods for vertical sliding effects (slideDown, slideUp, slideToggle). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires ../../utils + * * Utility function to check for browser environment. + * @requires ./types + * * Type definitions for effect options. + */ +/** + * @file src/modules/effects/fade.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Effects + * @description + * * Methods for fading elements in and out (fadeIn, fadeOut, fadeToggle). + * @requires ../../core + * * Depends on the core jBase class for type definitions. + * @requires ../../utils + * * Uses utility functions for environment checks. + * @requires ./types + * * Type definitions for fade options. + */ +/** + * @file src/modules/effects/index.ts + * @version 2.0.3 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Effects + * @description + * * Central entry point for visual effects. Aggregates slide, fade, and vertical animation modules. + * @requires ./slide + * * Horizontal slide effects (slideIn, slideOut). + * @requires ./vertical + * * Vertical slide effects / Accordion (slideDown, slideUp). + * @requires ./fade + * * Opacity fade effects (fadeIn, fadeOut). + */ +/** + * @file src/modules/http/post.ts + * @version 2.0.5 + * @since 2.0.2 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category HTTP + * * @description + * * Abstraction for HTTP POST requests. + */ +/** + * @file src/modules/http/upload.ts + * @version 2.0.0 + * @since 2.3.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category HTTP + * * @description + * * Abstraction for HTTP POST requests. + */ +/** + * @file src/modules/http/index.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category HTTP + * @description + * * Central entry point for HTTP requests. Aggregates GET and POST methods. + * @requires ./get + * * HTTP GET methods (get, getText). + * @requires ./post + * * HTTP POST methods. + * @requires ./upload + * * HTTP file upload method with progress tracking. + */ +/** + * @file src/modules/data/arrays.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Data + * @description + * * Utility functions for array manipulation and data processing. + * @requires ./types + * * Depends on types. + */ +/** + * @file src/modules/data/objects.ts + * @version 2.1.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Data + * @description + * * Utility functions for object manipulation (e.g., deep merging, extension). + * @requires ./types + * * Depends on types. + * @requires src/utils + * * Depends on utility functions (e.g., each). + */ +/** + * @file src/modules/data/index.ts + * @version 2.1.0 + * @since 2.0.0 + * * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Data + * @description + * * Central entry point for data manipulation. + * * Features a dynamic, overloaded API router that automatically delegates + * * to array or object utilities based on the input type. + * @requires ./arrays + * * Array manipulation methods. + * @requires ./objects + * * Object manipulation methods. + */ +/** + * @file src/index.ts + * @version 2.3.0 + * @since 2.0.0 + * @license GPL-3.0-or-later + * @copyright Sven Minio 2026 + * @author Sven Minio + * @category Entry Point + * @description + * * Main library entry point. Aggregates Core, Types, Utils, and all functional modules into a single export. + * @requires ./core + * * Core class logic and inheritance. + * @requires ./types + * * TypeScript type definitions and interfaces. + * @requires ./utils + * * Helper functions (throttle, debounce). + * @requires ./modules/css + * * Style manipulation methods. + * @requires ./modules/events + * * Event handling logic. + * @requires ./modules/dom + * * DOM traversal and manipulation. + * @requires ./modules/effects + * * Visual effects and animations. + * @requires ./modules/http + * * HTTP client for AJAX requests. + * @requires ./modules/data + * * Data structure utilities. + */ +//# sourceMappingURL=index.cjs.map diff --git a/dist/index.cjs.map b/dist/index.cjs.map new file mode 100644 index 0000000..c2ae9f0 --- /dev/null +++ b/dist/index.cjs.map @@ -0,0 +1,7 @@ +{ + "version": 3, + "sources": ["../src/index.ts", "../src/utils.ts", "../src/core.ts", "../src/modules/css/classes.ts", "../src/modules/css/styles.ts", "../src/modules/css/index.ts", "../src/modules/events/binding.ts", "../src/modules/events/mouse.ts", "../src/modules/events/lifecycle.ts", "../src/modules/events/keyboard.ts", "../src/modules/events/form.ts", "../src/modules/events/touch.ts", "../src/modules/events/index.ts", "../src/modules/dom/attributes.ts", "../src/modules/dom/content.ts", "../src/modules/http/get.ts", "../src/modules/dom/manipulation.ts", "../src/modules/dom/traversal.ts", "../src/modules/dom/states.ts", "../src/modules/dom/index.ts", "../src/modules/effects/slide.ts", "../src/modules/effects/vertical.ts", "../src/modules/effects/fade.ts", "../src/modules/effects/index.ts", "../src/modules/http/post.ts", "../src/modules/http/upload.ts", "../src/modules/http/index.ts", "../src/modules/data/arrays.ts", "../src/modules/data/objects.ts", "../src/modules/data/index.ts"], + "sourcesContent": ["/**\r\n * @file src/index.ts\r\n * @version 2.3.0\r\n * @since 2.0.0\r\n * @license GPL-3.0-or-later\r\n * @copyright Sven Minio 2026\r\n * @author Sven Minio \r\n * @category Entry Point\r\n * @description\r\n * * Main library entry point. Aggregates Core, Types, Utils, and all functional modules into a single export.\r\n * @requires ./core\r\n * * Core class logic and inheritance.\r\n * @requires ./types\r\n * * TypeScript type definitions and interfaces.\r\n * @requires ./utils\r\n * * Helper functions (throttle, debounce).\r\n * @requires ./modules/css\r\n * * Style manipulation methods.\r\n * @requires ./modules/events\r\n * * Event handling logic.\r\n * @requires ./modules/dom\r\n * * DOM traversal and manipulation.\r\n * @requires ./modules/effects\r\n * * Visual effects and animations.\r\n * @requires ./modules/http\r\n * * HTTP client for AJAX requests.\r\n * @requires ./modules/data\r\n * * Data structure utilities.\r\n */\r\n\r\nimport { jBase as JBaseClass } from './core';\r\nimport { JBaseInput, JBaseCSSProperty, JBaseEventMap, JBaseElement } from './types';\r\nimport { cssMethods } from './modules/css';\r\nimport { eventMethods } from './modules/events';\r\nimport { domMethods } from './modules/dom';\r\nimport { effectMethods } from './modules/effects';\r\nimport { http } from './modules/http';\r\nimport { data } from './modules/data';\r\nimport { debounce, each, throttle } from './utils';\r\n\r\nObject.assign(JBaseClass.prototype, cssMethods);\r\nObject.assign(JBaseClass.prototype, eventMethods);\r\nObject.assign(JBaseClass.prototype, domMethods);\r\nObject.assign(JBaseClass.prototype, effectMethods);\r\n\r\n/**\r\n * * TypeScript Declaration Merging.\r\n */\r\ndeclare module './core' {\r\n interface jBase {\r\n /**\r\n * * Adds one or more CSS classes to the selected elements.\r\n * @example addClass('active', 'highlight'); => Adds the 'active' and 'highlight' classes to all selected elements.\r\n * @param classNames One or more class names to be added.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n addClass(...classNames: string[]): jBase;\r\n\r\n /**\r\n * * Removes one or more CSS classes from the selected elements.\r\n * @example removeClass('active', 'highlight'); => Removes the 'active' and 'highlight' classes from all selected elements.\r\n * @param classNames One or more class names to be removed.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n removeClass(...classNames: string[]): jBase;\r\n\r\n /**\r\n * * Toggles a CSS class (adds if missing, removes if present).\r\n * @example toggleClass('active'); => Toggles the 'active' class on all selected elements.\r\n * @param className The class name to toggle.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n toggleClass(className: string): jBase;\r\n\r\n /**\r\n * * Checks if at least one of the selected elements has the specified class.\r\n * @example hasClass('active'); => Checks if at least one selected element has the 'active' class.\r\n * @param className The class name to check for.\r\n * @returns True if the class exists on at least one element, otherwise false.\r\n */\r\n hasClass(className: string): boolean;\r\n\r\n /**\r\n * * Sets a CSS property for all selected elements.\r\n * @example css('color', 'red'); => Sets the 'color' style to 'red' for all selected elements.\r\n * @param property The CSS property name (camelCase).\r\n * @param value The value to set.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n css(property: JBaseCSSProperty, value: string | number): jBase;\r\n\r\n /**\r\n * * Gets the computed CSS value of the first element.\r\n * @example css('color'); => Returns the computed 'color' value of the first selected element.\r\n * @param property The CSS property name (camelCase).\r\n * @returns The computed value as a string.\r\n */\r\n css(property: JBaseCSSProperty): string;\r\n\r\n /**\r\n * * Sets multiple CSS properties for all selected elements using an object.\r\n * @example css({ color: 'red', backgroundColor: 'blue' }); => Sets the 'color' to 'red' and 'background-color' to 'blue' for all selected elements.\r\n * @param properties An object containing CSS property-value pairs.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n css(properties: Record): jBase;\r\n\r\n /**\r\n * Iterates over the jBase collection in a highly performant manner.\r\n * Returning `false` within the callback breaks the loop early.\r\n * @example each((el, index) => { console.log(el); if (index === 5) return false; }); => Logs the first 6 matched elements to the console.\r\n * @param callback The function to execute for each element.\r\n * The context (`this`)\r\n * The first argument (`el`) are set to the current DOM element.\r\n * The second argument (`index`) provides the current loop index.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n each(callback: (this: JBaseElement, el: JBaseElement, index: number) => boolean | void): jBase;\r\n\r\n /**\r\n * * Registers a typed event listener.\r\n * @example on('click', event => { console.log(event); }); => Attaches a click event listener that logs the event object.\r\n * @param event The event name (e.g., 'click').\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n on(event: K, handler: (event: JBaseEventMap[K]) => void): jBase;\r\n\r\n /**\r\n * * Attaches an event handler function for one or more events to the selected elements.\r\n * @example on('click', handler) => Binds a click event handler to all matched elements.\r\n * @param events One or more space-separated event types (e.g., 'click', 'mouseenter mouseleave').\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n on(events: string, handler: (event: any) => void): jBase;\r\n \r\n /**\r\n * * Attaches an event handler to the selected elements, passing custom data to the event object.\r\n * @example on('click', { key: 'value' }, handler) => Binds a click event handler and passes custom data to the event object.\r\n * @param events One or more space-separated event types.\r\n * @param data Custom data to be passed to the handler via `event.data`.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n on(events: string, data: any, handler: (event: any) => void): jBase;\r\n \r\n /**\r\n * * Attaches a delegated event handler. The handler is only executed if the event target matches the given selector.\r\n * * Highly performant for observing dynamically added child elements.\r\n * @example on('click', '.btn', handler) => Binds a click event handler to all current and future elements matching '.btn' within the matched elements.\r\n * @param events One or more space-separated event types.\r\n * @param selector A CSS selector string to filter the descendants of the selected elements.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n on(events: string, selector: string, handler: (event: any) => void): jBase;\r\n \r\n /**\r\n * * Attaches a delegated event handler and passes custom data to the event object.\r\n * @example on('click', '.btn', { key: 'value' }, handler) => Binds a click event handler to all current and future elements matching '.btn' and passes custom data to the event object.\r\n * @param events One or more space-separated event types.\r\n * @param selector A CSS selector string to filter the descendants of the selected elements.\r\n * @param data Custom data to be passed to the handler via `event.data`.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n on(events: string, selector: string, data: any, handler: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Removes a typed event listener.\r\n * @example off('click', handler) => Removes a click event handler from all matched elements.\r\n * @param event The event name.\r\n * @param handler The exact reference of the handler to remove.\r\n * @returns The current jBase instance.\r\n */\r\n off(event: K, handler: (event: JBaseEventMap[K]) => void): jBase;\r\n\r\n /**\r\n * * Removes all or a specific event listener.\r\n * @example off('click') => Removes all click event handlers from all matched elements.\r\n * @param events One or more space-separated event types.\r\n * @param handler (Optional) The specific handler to remove.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n off(events: string, handler?: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Removes a delegated event listener.\r\n * @example off('click', '.btn', handler) => Removes a delegated click event handler from all matched elements for the specified selector.\r\n * @param events One or more space-separated event types.\r\n * @param selector The CSS selector string originally used for delegation.\r\n * @param handler (Optional) The specific handler to remove.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n off(events: string, selector: string, handler?: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Registers a typed event listener that executes only once.\r\n * @example once('click', event => { console.log(event); }); => Attaches a click event listener that executes only once and logs the event object.\r\n * @param event The event name.\r\n * @param handler The exact reference of the handler.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n once(event: K, handler: (event: JBaseEventMap[K]) => void): jBase;\r\n\r\n /**\r\n * * Registers an event listener that executes only once.\r\n * @example once('click', handler) => Binds a click event handler that executes only once for all matched elements.\r\n * @param events One or more space-separated event types.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n once(events: string, handler: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Registers a one-time listener with custom data.\r\n * @example once('click', { key: 'value' }, handler) => Binds a click event handler that executes only once and passes custom data to the event object.\r\n * @param events One or more space-separated event types.\r\n * @param data Custom data to be passed to the handler via `event.data`.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n once(events: string, data: any, handler: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Registers a one-time listener with event delegation.\r\n * @example once('click', '.btn', handler) => Binds a click event handler that executes only once for all current and future elements matching '.btn' within the matched elements.\r\n * @param events One or more space-separated event types.\r\n * @param selector A CSS selector string for event delegation.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n once(events: string, selector: string, handler: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Registers a one-time listener with event delegation and custom data.\r\n * @example once('click', '.btn', { key: 'value' }, handler) => Binds a click event handler that executes only once for all current and future elements matching '.btn' and passes custom data to the event object.\r\n * @example once('click', { key: 'value' }, handler) => Binds a click event handler that executes only once and passes custom data to the event object.\r\n * @param events One or more space-separated event types.\r\n * @param selector A CSS selector string for event delegation.\r\n * @param data Custom data to be passed to the handler via `event.data`.\r\n * @param handler A function to execute when the event is triggered.\r\n * @returns The current jBase instance for method chaining.\r\n */\r\n once(events: string, selector: string, data: any, handler: (event: any) => void): jBase;\r\n\r\n /**\r\n * * Triggers an event on each element in the collection.\r\n * @example trigger('customEvent') => Triggers 'customEvent' on all matched elements.\r\n * @example trigger('customEvent', { key: 'value' }) => Triggers 'customEvent' on all matched elements and passes custom data to the event object.\r\n * @example trigger('click') => Programmatically triggers a click event on all matched elements.\r\n * @example trigger('click', { key: 'value' }) => Programmatically triggers a click event on all matched elements and passes custom data to the event object.\r\n * @param eventName The name of the event to trigger.\r\n * @param data Optional data to pass to the event (accessible via event.detail).\r\n * @returns The current jBase instance.\r\n */\r\n trigger(eventName: string, data?: any): jBase;\r\n\r\n /**\r\n * * Triggers the 'click' event or binds a handler.\r\n * @example click() => Triggers the 'click' event on all matched elements.\r\n * @example click(handler) => Binds a click event handler to all matched elements.\r\n * @param handler (Optional) The function to execute on click.\r\n * @returns The current jBase instance.\r\n */\r\n click(handler?: (event: Event) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mousemove' event.\r\n * @example mousemove(handler) => Binds a mousemove event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mousemove(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mouseleave' event.\r\n * @example mouseleave(handler) => Binds a mouseleave event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mouseleave(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mouseenter' event.\r\n * @example mouseenter(handler) => Binds a mouseenter event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mouseenter(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mousedown' event.\r\n * @example mousedown(handler) => Binds a mousedown event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mousedown(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mouseup' event.\r\n * @example mouseup(handler) => Binds a mouseup event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mouseup(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Triggers the 'dblclick' event or binds a handler.\r\n * @example dblclick() => Triggers the 'dblclick' event on all matched elements.\r\n * @example dblclick(handler) => Binds a dblclick event handler to all matched elements.\r\n * @param handler (Optional) The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n dblclick(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mouseout' event.\r\n * @example mouseout(handler) => Binds a mouseout event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mouseout(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'mouseover' event.\r\n * @example mouseover(handler) => Binds a mouseover event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n mouseover(handler: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds handlers to both 'mouseenter' and 'mouseleave' events.\r\n * @example hover(handlerIn, handlerOut) => Binds handlerIn to mouseenter and handlerOut to mouseleave for all matched elements.\r\n * @param handlerIn Executed on mouseenter.\r\n * @param handlerOut Executed on mouseleave.\r\n * @returns The current jBase instance.\r\n */\r\n hover(handlerIn: (event: MouseEvent) => void, handlerOut: (event: MouseEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'keydown' event\r\n * @example keydown(handler) => Binds a keydown event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n keydown(handler: (event: KeyboardEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'keyup' event.\r\n * @example keyup(handler) => Binds a keyup event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n keyup(handler: (event: KeyboardEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'keypress' event (Deprecated).\r\n * @deprecated Use keydown instead.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n keypress(handler: (event: KeyboardEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler that fires only when a specific key is pressed.\r\n * @example pressedKey(handler) => Binds a handler that executes only when a specific key is pressed.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n pressedKey(handler: (event: KeyboardEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'submit' event.\r\n * @example submit(handler) => Binds a submit event handler to all matched forms.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n submit(handler: (event: SubmitEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'change' event.\r\n * @example change(handler) => Binds a change event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n change(handler: (event: Event) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'input' event (real-time).\r\n * @example input(handler) => Binds an input event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n input(handler: (event: Event) => void): jBase;\r\n\r\n /**\r\n * * Sets focus on the element.\r\n * @example focus() => Sets focus on the element.\r\n * @returns The current jBase instance.\r\n */\r\n focus(): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'focus' event.\r\n * @example focus(handler) => Binds a focus event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n focus(handler: (event: FocusEvent) => void): jBase;\r\n\r\n /**\r\n * * Removes focus from the element.\r\n * @example blur() => Removes focus from the element.\r\n * @returns The current jBase instance.\r\n */\r\n blur(): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'blur' event.\r\n * @example blur(handler) => Binds a blur event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n blur(handler: (event: FocusEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'touchstart' event.\r\n * @example touchstart(handler) => Binds a touchstart event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n touchstart(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'touchend' event.\r\n * @example touchend(handler) => Binds a touchend event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n touchend(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'touchmove' event.\r\n * @example touchmove(handler) => Binds a touchmove event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n touchmove(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'touchcancel' event.\r\n * @example touchcancel(handler) => Binds a touchcancel event handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n touchcancel(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'swipeLeft' gesture.\r\n * @example swipeLeft(handler) => Binds a swipeLeft gesture handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n swipeLeft(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'swipeRight' gesture.\r\n * @example swipeRight(handler) => Binds a swipeRight gesture handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n swipeRight(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'swipeDown' gesture.\r\n * @example swipeDown(handler) => Binds a swipeDown gesture handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n swipeDown(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Binds a handler to the 'swipeUp' gesture.\r\n * @example swipeUp(handler) => Binds a swipeUp gesture handler to all matched elements.\r\n * @param handler The callback function.\r\n * @returns The current jBase instance.\r\n */\r\n swipeUp(handler: (event: TouchEvent) => void): jBase;\r\n\r\n /**\r\n * * Gets the HTML content of the first element.\r\n * @example html() => Returns the HTML content of the first matched element as a string.\r\n * @returns The HTML content as a string.\r\n */\r\n html(): string;\r\n \r\n /**\r\n * * Gets the HTML content of the first element, or sets the HTML content of all matched elements.\r\n * @example html() => Returns the innerHTML of the first element.\r\n * @example html('
New
') => Sets safe HTML for all matched elements.\r\n * @example html('', { executeScripts: true }) => Injects and executes scripts.\r\n * @param content The HTML string to set. If undefined, acts as a getter.\r\n * @param options Security and execution options.\r\n * @returns HTML string (getter) or the current jBase instance (setter).\r\n */\r\n html(content: string, options?: { executeScripts?: boolean }): jBase;\r\n\r\n /**\r\n * * Gets the text content of the first element.\r\n * @example text() => Returns the text content of the first matched element as a string.\r\n * @returns The text content as a string.\r\n */\r\n text(): string;\r\n /**\r\n * * Sets the text content of all selected elements (safe against XSS).\r\n * @example text('New text content') => Sets the text content of all matched elements to 'New text content'.\r\n * @param content The new text content.\r\n * @returns The current jBase instance.\r\n */\r\n text(content: string): jBase;\r\n\r\n /**\r\n * * Loads HTML from a server and injects it into the matched elements.\r\n * @example $('#content').load('/pages/about.html')\r\n * @example $('#content').load('/pages/widget.html', { executeScripts: true })\r\n * @param url The URL to fetch the HTML from.\r\n * @param options Fetch options extended with jBase specific settings (e.g., executeScripts).\r\n * @returns A Promise resolving to the current jBase instance.\r\n */\r\n load(url: string, options?: RequestInit & { executeScripts?: boolean }): Promise;\r\n\r\n /**\r\n * * Gets an attribute value from the first element.\r\n * @example attr('href') => Returns the value of the 'href' attribute from the first matched element or null if it doesn't exist.\r\n * @param name The name of the attribute.\r\n * @returns The attribute value or null.\r\n */\r\n attr(name: string): string | null;\r\n\r\n /**\r\n * * Sets an attribute for all selected elements.\r\n * @example attr('data-id', '123') => Sets the 'data-id' attribute to '123' for all matched elements.\r\n * @param name The name of the attribute.\r\n * @param value The value to set.\r\n * @returns The current jBase instance.\r\n */\r\n attr(name: string, value: string): jBase;\r\n\r\n /**\r\n * * Gets the value of the first form element.\r\n * @example val() => Returns the current value of the first matched form element as a string.\r\n * @returns The value as a string.\r\n */\r\n val(): string;\r\n\r\n /**\r\n * * Sets the value for all selected form elements.\r\n * @example val('New value') => Sets the value of all matched form elements to 'New value'.\r\n * @param value The value to set.\r\n * @returns The current jBase instance.\r\n */\r\n val(value: string | number): jBase;\r\n\r\n /**\r\n * * Gets a property from the first element.\r\n * * Useful for DOM properties that don't directly map to HTML attributes.\r\n * @example prop('checked') => Returns the checked property of the first matched element (true or false).\r\n * @param name The name of the property (e.g., 'checked', 'disabled').\r\n * @returns The property value.\r\n */\r\n prop(name: string): any;\r\n\r\n /**\r\n * * Sets a property for all selected elements.\r\n * @example prop('checked', true) => Sets the checked property to true for all matched elements.\r\n * @param name The name of the property.\r\n * @param value The value to set.\r\n * @returns The current jBase instance.\r\n */\r\n prop(name: string, value: any): jBase;\r\n\r\n /**\r\n * * Removes an attribute from all selected elements.\r\n * @example removeAttr('data-id') => Removes the 'data-id' attribute from all matched elements.\r\n * @param name The name of the attribute to remove.\r\n * @returns The current jBase instance.\r\n */\r\n removeAttr(name: string): jBase;\r\n\r\n /**\r\n * * Replaces elements with a deep clone of themselves (removes listeners).\r\n * @example replaceWithClone() => Replaces each matched element with a deep clone of itself, effectively removing all event listeners and data.\r\n * @returns The current jBase instance.\r\n */\r\n replaceWithClone(): jBase;\r\n\r\n /**\r\n * * Removes all selected elements from the DOM.\r\n * @example remove() => Removes all matched elements from the DOM.\r\n * @returns The current jBase instance.\r\n */\r\n remove(): jBase;\r\n\r\n /**\r\n * * Removes all child nodes from the selected elements.\r\n * @example empty() => Removes all child nodes from each matched element, leaving the elements themselves intact.\r\n * @returns The current jBase instance.\r\n */\r\n empty(): jBase;\r\n\r\n /**\r\n * * Finds the closest ancestor matching the selector.\r\n * @example closest('.container') => For each matched element, returns the closest ancestor that matches the '.container' selector.\r\n * @param selector The CSS selector to match.\r\n * @returns A new jBase instance containing the ancestor.\r\n */\r\n closest(selector: string): jBase;\r\n\r\n /**\r\n * * Executes the handler when the DOM is fully loaded.\r\n * @example ready(() => { console.log('DOM is ready'); }); => Executes the provided function when the DOM is fully loaded.\r\n * @param handler The function to execute.\r\n * @returns The current jBase instance.\r\n */\r\n ready(handler: () => void): jBase;\r\n\r\n /**\r\n * * Inserts content at the end of the selected elements (inside).\r\n * @example append('New content') => Appends a new element with 'New content' inside each matched element.\r\n * @param content Content to insert (String, Node, or jBase).\r\n * @returns The current jBase instance.\r\n */\r\n append(content: string | Node | jBase): jBase;\r\n\r\n /**\r\n * * Inserts content at the beginning of the selected elements (inside).\r\n * @example prepend('New content') => Prepends a new element with 'New content' inside each matched element.\r\n * @param content Content to insert (String, Node, or jBase).\r\n * @returns The current jBase instance.\r\n */\r\n prepend(content: string | Node | jBase): jBase;\r\n\r\n /**\r\n * * Inserts content before the selected elements (outside).\r\n * @example before('New content') => Inserts a new element with 'New content' before each matched element.\r\n * @param content Content to insert (String, Node, or jBase).\r\n * @returns The current jBase instance.\r\n */\r\n before(content: string | Node | jBase): jBase;\r\n\r\n /**\r\n * * Inserts content after the selected elements (outside).\r\n * @example after('New content') => Inserts a new element with 'New content' after each matched element.\r\n * @param content Content to insert (String, Node, or jBase).\r\n * @returns The current jBase instance.\r\n */\r\n after(content: string | Node | jBase): jBase;\r\n\r\n /**\r\n * * Replaces the selected elements with new content.\r\n * @example replaceWith('New content') => Replaces each matched element with a new element containing 'New content'.\r\n * @param content Content to insert (String, Node, or jBase).\r\n * @returns The current jBase instance.\r\n */\r\n replaceWith(content: string | Node | jBase): jBase;\r\n\r\n /**\r\n * * Appends the selected elements to a target.\r\n * @example appendTo('#container') => Appends all matched elements to the element with id 'container'.\r\n * @param target Target element or selector.\r\n * @returns The current jBase instance.\r\n */\r\n appendTo(target: string | Element): jBase;\r\n\r\n /**\r\n * * Prepends the selected elements to a target.\r\n * @example prependTo('#container') => Prepends all matched elements to the element with id 'container'.\r\n * @param target Target element or selector.\r\n * @returns The current jBase instance.\r\n */\r\n prependTo(target: string | Element): jBase;\r\n\r\n /**\r\n * * Inserts the selected elements before a target.\r\n * @example insertBefore('#target') => Inserts all matched elements before the element with id 'target'.\r\n * @param target Target element or selector.\r\n * @returns The current jBase instance.\r\n */\r\n insertBefore(target: string | Element): jBase;\r\n\r\n /**\r\n * * Inserts the selected elements after a target.\r\n * @example insertAfter('#target') => Inserts all matched elements after the element with id 'target'.\r\n * @param target Target element or selector.\r\n * @returns The current jBase instance.\r\n */\r\n insertAfter(target: string | Element): jBase;\r\n\r\n /**\r\n * * Wraps each selected element with the specified HTML structure.\r\n * @example wrap('
') => Wraps each matched element with a
element having the class 'wrapper'.\r\n * @param wrapperHtml The HTML string for the wrapper.\r\n * @returns The current jBase instance.\r\n */\r\n wrap(wrapperHtml: string): jBase;\r\n\r\n /**\r\n * * Removes the direct parent of the selected elements.\r\n * @example unwrap() => Removes the direct parent of each matched element, effectively unwrapping it from its parent.\r\n * @returns The current jBase instance.\r\n */\r\n unwrap(): jBase;\r\n\r\n /**\r\n * * Gets the direct parents.\r\n * @example parent() => Gets the direct parent of each matched element.\r\n * @returns A new jBase instance with parents.\r\n */\r\n parent(): jBase;\r\n\r\n /**\r\n * * Gets the direct children.\r\n * @example children() => Gets the direct children of each matched element.\r\n * @example children('.filter') => Gets the direct children of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance with children.\r\n */\r\n children(selector?: string): jBase;\r\n\r\n /**\r\n * * Finds descendants matching the selector (deep).\r\n * @example find('.item') => Finds all descendant elements matching the '.item' selector for each matched element.\r\n * @param selector CSS selector to find.\r\n * @returns A new jBase instance.\r\n */\r\n findAll(selector: string): jBase;\r\n\r\n /**\r\n * * Gets all descendants recursively.\r\n * @example descendants() => Gets all descendant elements of each matched element, regardless of depth.\r\n * @returns A new jBase instance.\r\n */\r\n descendants(): jBase;\r\n\r\n /**\r\n * * Gets descendants recursively until a selector is met.\r\n * @example descendantsUntil('.stop') => Gets all descendant elements of each matched element until an element matching the '.stop' selector is encountered in the hierarchy.\r\n * @example descendantsUntil('.stop', '.filter') => Gets all descendant elements of each matched element until an element matching the '.stop' selector is encountered in the hierarchy, filtered by '.filter'.\r\n * @param untilSelector Selector to stop at.\r\n * @param filter (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n descendantsUntil(untilSelector: string, filter?: string): jBase;\r\n\r\n /**\r\n * * Gets all ancestors up to the root.\r\n * @example parents() => Gets all ancestor elements of each matched element, up to the document root.\r\n * @example parents('.filter') => Gets all ancestor elements of each matched element, up to the document root, filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n parents(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets all ancestors until a selector is met.\r\n * @example parentsUntil('.stop') => Gets all ancestor elements of each matched element until an element matching the '.stop' selector is encountered in the hierarchy.\r\n * @example parentsUntil('.stop', '.filter') => Gets all ancestor elements of each matched element until an element matching the '.stop' selector is encountered in the hierarchy, filtered by '.filter'.\r\n * @param selector Selector to stop at.\r\n * @param filter (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n parentsUntil(selector: string, filter?: string): jBase;\r\n\r\n /**\r\n * * Gets the immediately following sibling.\r\n * @example next() => Gets the immediately following sibling of each matched element.\r\n * @example next('.filter') => Gets the immediately following sibling of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n next(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets the immediately preceding sibling.\r\n * @example prev() => Gets the immediately preceding sibling of each matched element.\r\n * @example prev('.filter') => Gets the immediately preceding sibling of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n prev(selector?: string): jBase;\r\n\r\n /**\r\n * * Alias for `next()`.\r\n * @example sibling() => Gets the immediately following sibling of each matched element.\r\n * @example sibling('.filter') => Gets the immediately following sibling of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n sibling(selector?: string): jBase;\r\n\r\n /**\r\n * * Alias for `next()`.\r\n * @example nextSibling() => Gets the immediately following sibling of each matched element.\r\n * @example nextSibling('.filter') => Gets the immediately following sibling of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n nextSibling(selector?: string): jBase;\r\n\r\n /**\r\n * * Alias for `prev()`.\r\n * @example prevSibling() => Gets the immediately preceding sibling of each matched element.\r\n * @example prevSibling('.filter') => Gets the immediately preceding sibling of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n prevSibling(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets all following siblings.\r\n * @example nextAll() => Gets all following siblings of each matched element.\r\n * @example nextAll('.filter') => Gets all following siblings of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n nextAll(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets all preceding siblings.\r\n * @example prevAll() => Gets all preceding siblings of each matched element.\r\n * @example prevAll('.filter') => Gets all preceding siblings of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n prevAll(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets all siblings (prev and next).\r\n * @example siblings() => Gets all siblings (both previous and next) of each matched element.\r\n * @example siblings('.filter') => Gets all siblings of each matched element filtered by '.filter'.\r\n * @param selector (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n siblings(selector?: string): jBase;\r\n\r\n /**\r\n * * Gets following siblings until a selector is met.\r\n * @example nextUntil('.stop') => Gets all following siblings of each matched element until an element matching the '.stop' selector is encountered in the hierarchy.\r\n * @example nextUntil('.stop', '.filter') => Gets all following siblings of each matched element until an element matching the '.stop' selector is encountered in the hierarchy, filtered by '.filter'.\r\n * @param untilSelector Selector to stop at.\r\n * @param filter (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n nextUntil(untilSelector: string, filter?: string): jBase;\r\n\r\n /**\r\n * * Gets preceding siblings until a selector is met.\r\n * @example prevUntil('.stop') => Gets all preceding siblings of each matched element until an element matching the '.stop' selector is encountered in the hierarchy.\r\n * @example prevUntil('.stop', '.filter') => Gets all preceding siblings of each matched element until an element matching the '.stop' selector is encountered in the hierarchy, filtered by '.filter'.\r\n * @param untilSelector Selector to stop at.\r\n * @param filter (Optional) Filter selector.\r\n * @returns A new jBase instance.\r\n */\r\n prevUntil(untilSelector: string, filter?: string): jBase;\r\n\r\n /**\r\n * * Reduces the set to the element at the index.\r\n * @example eq(0) => Reduces the set to the first element.\r\n * @example eq(-1) => Reduces the set to the last element.\r\n * @param index Index (negative values count from the end).\r\n * @returns A new jBase instance.\r\n */\r\n eq(index: number): jBase;\r\n\r\n /**\r\n * * Reduces the set to the first element.\r\n * @example first() => Reduces the set to the first element.\r\n * @returns A new jBase instance.\r\n */\r\n first(): jBase;\r\n\r\n /**\r\n * * Reduces the set to the last element.\r\n * @example last() => Reduces the set to the last element.\r\n * @returns A new jBase instance.\r\n */\r\n last(): jBase;\r\n\r\n /**\r\n * * Filters elements by selector.\r\n * @example filterBy('.active') => Reduces the set to elements that match the '.active' selector.\r\n * @param selector CSS selector to filter by.\r\n * @returns A new jBase instance.\r\n */\r\n filterBy(selector: string): jBase;\r\n\r\n /**\r\n * * Filters the collection based on a custom callback function.\r\n * * Elements for which the callback returns `true` are kept in the new collection.\r\n * @example filterBy((index, element) => element.classList.contains('active')) => Reduces the set to elements for which the callback returns true (e.g., elements with the 'active' class).\r\n * @param predicate A function executed for each element in the current collection. \r\n * Receives the current `index` and the DOM `element` as arguments. \r\n * Return `true` to keep the element, or `false` to exclude it.\r\n * @returns A new jBase instance containing only the elements that passed the test.\r\n */\r\n filterBy(predicate: (index: number, element: Element) => boolean): jBase;\r\n\r\n /**\r\n * * Removes elements matching the selector.\r\n * @example not('.active') => Removes elements that match the '.active' selector from the set.\r\n * @param selector CSS selector to remove.\r\n * @returns A new jBase instance.\r\n */\r\n not(selector: string): jBase;\r\n\r\n /**\r\n * * Removes elements matching the callback function.\r\n * @example not((index, element) => element.classList.contains('active')) => Removes elements for which the callback returns true (e.g., elements with the 'active' class) from the set.\r\n * @param predicate Function that returns true to remove the element.\r\n * @returns A new jBase instance.\r\n */\r\n not(predicate: (index: number, element: Element) => boolean): jBase;\r\n\r\n /**\r\n * * Slides the element into view (horizontal).\r\n * @example slideIn() => Slides the element into view from the left with default duration.\r\n * @example slideIn({ direction: 'right', duration: 500 }) => Slides the element into view from the right over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideIn(options?: { direction?: 'left' | 'right', duration?: number }): jBase;\r\n\r\n /**\r\n * * Slides the element out of view (horizontal).\r\n * @example slideOut() => Slides the element out of view to the left with default duration.\r\n * @example slideOut({ direction: 'right', duration: 500 }) => Slides the element out of view to the right over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideOut(options?: { direction?: 'left' | 'right', duration?: number }): jBase;\r\n\r\n /**\r\n * * Toggles between slideIn and slideOut.\r\n * @example slideToggle() => Toggles between sliding the element into and out of view from the left with default duration.\r\n * @example slideToggle({ direction: 'right', duration: 500 }) => Toggles between sliding the element into and out of view from the right over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideToggle(options?: { direction?: 'left' | 'right', duration?: number }): jBase;\r\n\r\n /**\r\n * * Slides the element down (Accordion).\r\n * @example slideDown() => Slides the element down into view with default duration.\r\n * @example slideDown({ duration: 500, displayType: 'block' }) => Slides the element down into view over 500 milliseconds and sets display to 'block' when shown.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideDown(options?: { duration?: number, displayType?: string }): jBase;\r\n\r\n /**\r\n * * Slides the element up.\r\n * @example slideUp() => Slides the element up out of view with default duration.\r\n * @example slideUp({ duration: 500 }) => Slides the element up out of view over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideUp(options?: { duration?: number }): jBase;\r\n\r\n /**\r\n * * Toggles between slideDown and slideUp.\r\n * @example slideToggleBox() => Toggles between sliding the element down into view and up out of view with default duration.\r\n * @example slideToggleBox({ duration: 500, displayType: 'block' }) => Toggles between sliding the element down into view and up out of view over 500 milliseconds, and sets display to 'block' when shown.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n slideToggleBox(options?: { duration?: number }): jBase;\r\n\r\n /**\r\n * * Fades the element in (Opacity).\r\n * @example fadeIn() => Fades the element in with default duration.\r\n * @example fadeIn({ duration: 500, displayType: 'block' }) => Fades the element in over 500 milliseconds and sets display to 'block' when shown.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n fadeIn(options?: { duration?: number, displayType?: string }): jBase;\r\n\r\n /**\r\n * * Fades the element out (Opacity).\r\n * @example fadeOut() => Fades the element out with default duration.\r\n * @example fadeOut({ duration: 500 }) => Fades the element out over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n fadeOut(options?: { duration?: number }): jBase;\r\n\r\n /**\r\n * * Toggles between fadeIn and fadeOut.\r\n * @example fadeToggle() => Toggles between fading the element in and out with default duration.\r\n * @example fadeToggle({ duration: 500 }) => Toggles between fading the element in and out over 500 milliseconds.\r\n * @param options Animation options.\r\n * @returns The current jBase instance.\r\n */\r\n fadeToggle(options?: { duration?: number }): jBase;\r\n\r\n /**\r\n * * Checks the 'checked' state (Getter).\r\n * @example checked() => Returns true if the first matched element is checked (for checkboxes/radio buttons).\r\n * @returns True if checked.\r\n */\r\n checked(): boolean;\r\n\r\n /**\r\n * * Sets the 'checked' state (Setter).\r\n * @example checked(true) => Sets the checked state to true for all matched checkboxes/radio buttons.\r\n * @param state The new state.\r\n * @returns The current jBase instance.\r\n */\r\n checked(state: boolean): jBase;\r\n\r\n /**\r\n * * ALIAS for .checked(true). Checks the matched elements.\r\n * @example check() => Checks all matched checkboxes/radio buttons.\r\n * @returns The current jBase instance.\r\n */\r\n check(): jBase;\r\n\r\n /**\r\n * * ALIAS for .checked(false). Unchecks the matched elements.\r\n * @example uncheck() => Unchecks all matched checkboxes/radio buttons.\r\n * @returns The current jBase instance.\r\n */\r\n uncheck(): jBase;\r\n\r\n /**\r\n * * Checks the 'selected' state (Getter).\r\n * @example selected() => Returns true if the first matched element is selected (for options in a select element).\r\n * @returns True if selected.\r\n */\r\n selected(): boolean;\r\n\r\n /**\r\n * * Sets the 'selected' state (Setter).\r\n * @example selected(true) => Sets the selected state to true for all matched options in a select element.\r\n * @param state The new state.\r\n * @returns The current jBase instance.\r\n */\r\n selected(state: boolean): jBase;\r\n\r\n /**\r\n * * ALIAS for .selected(true). Selects the matched