@k37z3r/jbase 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +621 -0
- package/README.md +124 -0
- package/dist/browser.d.ts +30 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +29 -0
- package/dist/browser.js.map +1 -0
- package/dist/core.d.ts +42 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +78 -0
- package/dist/core.js.map +1 -0
- package/dist/index.cjs +2150 -0
- package/dist/index.d.ts +1158 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +100 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2118 -0
- package/dist/jbase.browser.js +1906 -0
- package/dist/jbase.js +1898 -0
- package/dist/jbase.min.js +9 -0
- package/dist/modules/css/classes.d.ts +61 -0
- package/dist/modules/css/classes.d.ts.map +1 -0
- package/dist/modules/css/classes.js +88 -0
- package/dist/modules/css/classes.js.map +1 -0
- package/dist/modules/css/index.d.ts +30 -0
- package/dist/modules/css/index.d.ts.map +1 -0
- package/dist/modules/css/index.js +33 -0
- package/dist/modules/css/index.js.map +1 -0
- package/dist/modules/css/styles.d.ts +31 -0
- package/dist/modules/css/styles.d.ts.map +1 -0
- package/dist/modules/css/styles.js +49 -0
- package/dist/modules/css/styles.js.map +1 -0
- package/dist/modules/data/arrays.d.ts +131 -0
- package/dist/modules/data/arrays.d.ts.map +1 -0
- package/dist/modules/data/arrays.js +177 -0
- package/dist/modules/data/arrays.js.map +1 -0
- package/dist/modules/data/index.d.ts +29 -0
- package/dist/modules/data/index.d.ts.map +1 -0
- package/dist/modules/data/index.js +33 -0
- package/dist/modules/data/index.js.map +1 -0
- package/dist/modules/data/objects.d.ts +108 -0
- package/dist/modules/data/objects.d.ts.map +1 -0
- package/dist/modules/data/objects.js +168 -0
- package/dist/modules/data/objects.js.map +1 -0
- package/dist/modules/data/types.d.ts +35 -0
- package/dist/modules/data/types.d.ts.map +1 -0
- package/dist/modules/data/types.js +43 -0
- package/dist/modules/data/types.js.map +1 -0
- package/dist/modules/dom/attributes.d.ts +42 -0
- package/dist/modules/dom/attributes.d.ts.map +1 -0
- package/dist/modules/dom/attributes.js +69 -0
- package/dist/modules/dom/attributes.js.map +1 -0
- package/dist/modules/dom/content.d.ts +39 -0
- package/dist/modules/dom/content.d.ts.map +1 -0
- package/dist/modules/dom/content.js +63 -0
- package/dist/modules/dom/content.js.map +1 -0
- package/dist/modules/dom/index.d.ts +78 -0
- package/dist/modules/dom/index.d.ts.map +1 -0
- package/dist/modules/dom/index.js +48 -0
- package/dist/modules/dom/index.js.map +1 -0
- package/dist/modules/dom/manipulation.d.ts +159 -0
- package/dist/modules/dom/manipulation.d.ts.map +1 -0
- package/dist/modules/dom/manipulation.js +343 -0
- package/dist/modules/dom/manipulation.js.map +1 -0
- package/dist/modules/dom/states.d.ts +50 -0
- package/dist/modules/dom/states.d.ts.map +1 -0
- package/dist/modules/dom/states.js +89 -0
- package/dist/modules/dom/states.js.map +1 -0
- package/dist/modules/dom/traversal.d.ts +246 -0
- package/dist/modules/dom/traversal.d.ts.map +1 -0
- package/dist/modules/dom/traversal.js +527 -0
- package/dist/modules/dom/traversal.js.map +1 -0
- package/dist/modules/effects/fade.d.ts +58 -0
- package/dist/modules/effects/fade.d.ts.map +1 -0
- package/dist/modules/effects/fade.js +104 -0
- package/dist/modules/effects/fade.js.map +1 -0
- package/dist/modules/effects/index.d.ts +40 -0
- package/dist/modules/effects/index.d.ts.map +1 -0
- package/dist/modules/effects/index.js +38 -0
- package/dist/modules/effects/index.js.map +1 -0
- package/dist/modules/effects/slide.d.ts +58 -0
- package/dist/modules/effects/slide.d.ts.map +1 -0
- package/dist/modules/effects/slide.js +103 -0
- package/dist/modules/effects/slide.js.map +1 -0
- package/dist/modules/effects/vertical.d.ts +58 -0
- package/dist/modules/effects/vertical.d.ts.map +1 -0
- package/dist/modules/effects/vertical.js +118 -0
- package/dist/modules/effects/vertical.js.map +1 -0
- package/dist/modules/events/binding.d.ts +47 -0
- package/dist/modules/events/binding.d.ts.map +1 -0
- package/dist/modules/events/binding.js +60 -0
- package/dist/modules/events/binding.js.map +1 -0
- package/dist/modules/events/form.d.ts +72 -0
- package/dist/modules/events/form.d.ts.map +1 -0
- package/dist/modules/events/form.js +106 -0
- package/dist/modules/events/form.js.map +1 -0
- package/dist/modules/events/index.d.ts +62 -0
- package/dist/modules/events/index.d.ts.map +1 -0
- package/dist/modules/events/index.js +53 -0
- package/dist/modules/events/index.js.map +1 -0
- package/dist/modules/events/keyboard.d.ts +65 -0
- package/dist/modules/events/keyboard.d.ts.map +1 -0
- package/dist/modules/events/keyboard.js +83 -0
- package/dist/modules/events/keyboard.js.map +1 -0
- package/dist/modules/events/lifecycle.d.ts +28 -0
- package/dist/modules/events/lifecycle.d.ts.map +1 -0
- package/dist/modules/events/lifecycle.js +40 -0
- package/dist/modules/events/lifecycle.js.map +1 -0
- package/dist/modules/events/mouse.d.ts +120 -0
- package/dist/modules/events/mouse.d.ts.map +1 -0
- package/dist/modules/events/mouse.js +172 -0
- package/dist/modules/events/mouse.js.map +1 -0
- package/dist/modules/events/touch.d.ts +61 -0
- package/dist/modules/events/touch.d.ts.map +1 -0
- package/dist/modules/events/touch.js +74 -0
- package/dist/modules/events/touch.js.map +1 -0
- package/dist/modules/http/get.d.ts +47 -0
- package/dist/modules/http/get.d.ts.map +1 -0
- package/dist/modules/http/get.js +65 -0
- package/dist/modules/http/get.js.map +1 -0
- package/dist/modules/http/index.d.ts +37 -0
- package/dist/modules/http/index.d.ts.map +1 -0
- package/dist/modules/http/index.js +42 -0
- package/dist/modules/http/index.js.map +1 -0
- package/dist/modules/http/post.d.ts +36 -0
- package/dist/modules/http/post.d.ts.map +1 -0
- package/dist/modules/http/post.js +54 -0
- package/dist/modules/http/post.js.map +1 -0
- package/dist/types.d.ts +61 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +15 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +51 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +71 -0
- package/dist/utils.js.map +1 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# jBase
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+

|
|
7
|
+
|
|
8
|
+
**A modern, lightweight, and modular JavaScript framework for high-performance DOM manipulation, event handling, and data management.**
|
|
9
|
+
|
|
10
|
+
jBase offers a familiar chainable API (similar to jQuery) but is built on modern ES6+ standards. It goes beyond UI logic by including a robust set of immutable data utilities for handling complex arrays and objects.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
## 📥 Installation
|
|
15
|
+
|
|
16
|
+
### via NPM / Yarn (coming soon)
|
|
17
|
+
Ideal for modern web apps using bundlers like Webpack, Vite, or Rollup.
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install jbase
|
|
21
|
+
# or
|
|
22
|
+
yarn add jbase
|
|
23
|
+
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### via Script Tag (CDN)
|
|
27
|
+
|
|
28
|
+
Simply download the minified file and include it in your HTML.
|
|
29
|
+
|
|
30
|
+
```html
|
|
31
|
+
<script src="dist/jbase.min.js"></script>
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Start
|
|
38
|
+
|
|
39
|
+
jBase exposes itself globally as `jBase` and the shorthand `$`.
|
|
40
|
+
|
|
41
|
+
### 1. DOM Manipulation & Events
|
|
42
|
+
|
|
43
|
+
```javascript
|
|
44
|
+
import { $ } from 'jbase';
|
|
45
|
+
|
|
46
|
+
$(document).ready(() => {
|
|
47
|
+
// Select elements and modify CSS
|
|
48
|
+
$('.card').css({
|
|
49
|
+
'background-color': '#f8f9fa',
|
|
50
|
+
'border-radius': '8px'
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
// Handle events
|
|
54
|
+
$('#save-btn').on('click', (e) => {
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
$('.status').text('Saved successfully!').fadeIn(300);
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### 2. Powerful Data Utilities
|
|
63
|
+
|
|
64
|
+
jBase includes a unique `$.data` module for **immutable** array and object manipulation.
|
|
65
|
+
|
|
66
|
+
```javascript
|
|
67
|
+
const users = [
|
|
68
|
+
{ id: 1, name: 'Alice', role: 'admin' },
|
|
69
|
+
{ id: 2, name: 'Bob', role: 'user' }
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
// Find specific data efficiently
|
|
73
|
+
const admin = $.data.find.first(users, 'admin', 'exact', 'role');
|
|
74
|
+
|
|
75
|
+
// Remove data immutably (returns a new array)
|
|
76
|
+
const nonAdmins = $.data.remove.byMatch(users, 'admin', 'exact', 'role');
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### 3. HTTP Requests
|
|
81
|
+
|
|
82
|
+
Simple, Promise-based AJAX wrappers.
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
$.http.get('https://api.example.com/items')
|
|
86
|
+
.then(data => console.log('Items loaded:', data))
|
|
87
|
+
.catch(err => console.error('Error:', err));
|
|
88
|
+
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## 📚 Documentation
|
|
94
|
+
|
|
95
|
+
Detailed documentation for all methods is available in the **[GitHub Wiki](../../wiki)**.
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 🛠 Usage in Node.js
|
|
101
|
+
|
|
102
|
+
jBase can be used in Node.js environments. Note that DOM-related methods require a window context (like jsdom), but **Data** and **HTTP** utilities work natively.
|
|
103
|
+
|
|
104
|
+
```javascript
|
|
105
|
+
const { $ } = require('jbase');
|
|
106
|
+
|
|
107
|
+
// Use Data Utils on the server side
|
|
108
|
+
const merged = $.data.mergeObjects({ a: 1 }, { b: 2 });
|
|
109
|
+
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
|
|
114
|
+
## ©️ License & Author
|
|
115
|
+
|
|
116
|
+
**jBase** is open-source software licensed under the **[GPL-3.0-or-later](LICENSE)**.
|
|
117
|
+
|
|
118
|
+
**Author:** Sven Minio
|
|
119
|
+
|
|
120
|
+
**Website:** [sven-minio.de](https://sven-minio.de)
|
|
121
|
+
|
|
122
|
+
**Copyright:** © 2026 Sven Minio
|
|
123
|
+
|
|
124
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/browser.ts
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category Browser
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: Browser Entry Point. Attaches the jBase library and utilities to the global window object so they can be accessed via `$` or `jBase` in inline scripts.
|
|
11
|
+
* * 🇩🇪: Browser-Einstiegspunkt. Hängt die jBase-Bibliothek und Utilities an das globale Window-Objekt an, damit sie über `$` oder `jBase` in Inline-Skripten verfügbar sind.
|
|
12
|
+
*/
|
|
13
|
+
import { $, jBase, http, jB, _jB, __jB, _jBase, __jBase } from './index';
|
|
14
|
+
/**
|
|
15
|
+
* * 🇬🇧: TypeScript declaration merging to extend the global Window interface.
|
|
16
|
+
* * 🇩🇪: TypeScript Declaration Merging zur Erweiterung des globalen Window-Interfaces.
|
|
17
|
+
*/
|
|
18
|
+
declare global {
|
|
19
|
+
interface Window {
|
|
20
|
+
$: typeof $;
|
|
21
|
+
jBase: typeof jBase;
|
|
22
|
+
jB: typeof jB;
|
|
23
|
+
_jB: typeof _jB;
|
|
24
|
+
__jB: typeof __jB;
|
|
25
|
+
_jBase: typeof _jBase;
|
|
26
|
+
__jBase: typeof __jBase;
|
|
27
|
+
http: typeof http;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAEzE;;;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,IAAI,EAAE,OAAO,IAAI,CAAC;KACrB;CACJ"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/browser.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Browser
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: Browser Entry Point. Attaches the jBase library and utilities to the global window object so they can be accessed via `$` or `jBase` in inline scripts.
|
|
12
|
+
* * 🇩🇪: Browser-Einstiegspunkt. Hängt die jBase-Bibliothek und Utilities an das globale Window-Objekt an, damit sie über `$` oder `jBase` in Inline-Skripten verfügbar sind.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const index_1 = require("./index");
|
|
16
|
+
/**
|
|
17
|
+
* * 🇬🇧: Expose globals to the window object.
|
|
18
|
+
* * 🇩🇪: Globale Variablen auf dem Window-Objekt setzen.
|
|
19
|
+
*/
|
|
20
|
+
window.$ = index_1.$;
|
|
21
|
+
window.jBase = index_1.jBase;
|
|
22
|
+
window.jB = index_1.jB;
|
|
23
|
+
window._jB = index_1._jB;
|
|
24
|
+
window.__jB = index_1.__jB;
|
|
25
|
+
window._jBase = index_1._jBase;
|
|
26
|
+
window.__jBase = index_1.__jBase;
|
|
27
|
+
window.http = index_1.http;
|
|
28
|
+
console.log("jBase initialized and ready!");
|
|
29
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;AAEH,mCAAyE;AAmBzE;;;GAGG;AACF,MAAc,CAAC,CAAC,GAAG,SAAC,CAAC;AACrB,MAAc,CAAC,KAAK,GAAG,aAAK,CAAC;AAC7B,MAAc,CAAC,EAAE,GAAG,UAAE,CAAC;AACvB,MAAc,CAAC,GAAG,GAAG,WAAG,CAAC;AACzB,MAAc,CAAC,IAAI,GAAG,YAAI,CAAC;AAC3B,MAAc,CAAC,MAAM,GAAG,cAAM,CAAC;AAC/B,MAAc,CAAC,OAAO,GAAG,eAAO,CAAC;AACjC,MAAc,CAAC,IAAI,GAAG,YAAI,CAAC;AAE5B,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC"}
|
package/dist/core.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file src/core.ts
|
|
3
|
+
* @version 2.0.0
|
|
4
|
+
* @since 2.0.0
|
|
5
|
+
* @license GPL-3.0-or-later
|
|
6
|
+
* @copyright Sven Minio 2026
|
|
7
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
8
|
+
* @category Core
|
|
9
|
+
* @description
|
|
10
|
+
* * 🇬🇧: The main jBase class. Handles the selection engine, initialization, and plugin architecture.
|
|
11
|
+
* * 🇩🇪: Die Haupt-jBase-Klasse. Behandelt die Selektions-Engine, Initialisierung und Plugin-Architektur.
|
|
12
|
+
*/
|
|
13
|
+
import { JBaseElement, JBaseInput } from './types';
|
|
14
|
+
/**
|
|
15
|
+
* * 🇬🇧: 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).
|
|
16
|
+
* * 🇩🇪: Die Kern-Klasse des Frameworks, die von der nativen Array-Klasse erbt. Dient als Wrapper um DOM-Elemente und ermöglicht verkettbare Methoden (Fluent Interface).
|
|
17
|
+
*/
|
|
18
|
+
export declare class jBase extends Array<JBaseElement> {
|
|
19
|
+
selectorSource: string;
|
|
20
|
+
/**
|
|
21
|
+
* * 🇬🇧: Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements.
|
|
22
|
+
* * 🇩🇪: Initialisiert eine neue jBase-Instanz. Analysiert den übergebenen Selektor und füllt das interne Array mit den gefundenen oder erstellten DOM-Elementen.
|
|
23
|
+
* @param selector
|
|
24
|
+
* * 🇬🇧: The input selector (CSS selector, HTML string, DOM element, or collection).
|
|
25
|
+
* * 🇩🇪: Der Eingabe-Selektor (CSS-Selektor, HTML-String, DOM-Element oder Sammlung).
|
|
26
|
+
*/
|
|
27
|
+
constructor(selector?: JBaseInput);
|
|
28
|
+
/**
|
|
29
|
+
* * 🇬🇧: Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview.
|
|
30
|
+
* * 🇩🇪: Benutzerdefinierte Serialisierung für JSON.stringify. Verhindert Zirkelbezüge und riesige Ausgaben durch Rückgabe einer vereinfachten Vorschau.
|
|
31
|
+
* @returns
|
|
32
|
+
* * 🇬🇧: A simplified object representation for debugging.
|
|
33
|
+
* * 🇩🇪: Eine vereinfachte Objektrepräsentation für das Debugging.
|
|
34
|
+
*/
|
|
35
|
+
toJSON(): {
|
|
36
|
+
meta: string;
|
|
37
|
+
query: string;
|
|
38
|
+
count: number;
|
|
39
|
+
preview: string[];
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEnD;;;GAGG;AACH,qBAAa,KAAM,SAAQ,KAAK,CAAC,YAAY,CAAC;IACnC,cAAc,EAAE,MAAM,CAAM;IAEnC;;;;;;OAMG;gBACS,QAAQ,CAAC,EAAE,UAAU;IAgCjC;;;;;;OAMG;IACH,MAAM;;;;;;CAYT"}
|
package/dist/core.js
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @file src/core.ts
|
|
4
|
+
* @version 2.0.0
|
|
5
|
+
* @since 2.0.0
|
|
6
|
+
* @license GPL-3.0-or-later
|
|
7
|
+
* @copyright Sven Minio 2026
|
|
8
|
+
* @author Sven Minio <https://sven-minio.de>
|
|
9
|
+
* @category Core
|
|
10
|
+
* @description
|
|
11
|
+
* * 🇬🇧: The main jBase class. Handles the selection engine, initialization, and plugin architecture.
|
|
12
|
+
* * 🇩🇪: Die Haupt-jBase-Klasse. Behandelt die Selektions-Engine, Initialisierung und Plugin-Architektur.
|
|
13
|
+
*/
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.jBase = void 0;
|
|
16
|
+
/**
|
|
17
|
+
* * 🇬🇧: 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).
|
|
18
|
+
* * 🇩🇪: Die Kern-Klasse des Frameworks, die von der nativen Array-Klasse erbt. Dient als Wrapper um DOM-Elemente und ermöglicht verkettbare Methoden (Fluent Interface).
|
|
19
|
+
*/
|
|
20
|
+
class jBase extends Array {
|
|
21
|
+
/**
|
|
22
|
+
* * 🇬🇧: Initializes a new jBase instance. Analyzes the provided selector and populates the internal array with found or created DOM elements.
|
|
23
|
+
* * 🇩🇪: Initialisiert eine neue jBase-Instanz. Analysiert den übergebenen Selektor und füllt das interne Array mit den gefundenen oder erstellten DOM-Elementen.
|
|
24
|
+
* @param selector
|
|
25
|
+
* * 🇬🇧: The input selector (CSS selector, HTML string, DOM element, or collection).
|
|
26
|
+
* * 🇩🇪: Der Eingabe-Selektor (CSS-Selektor, HTML-String, DOM-Element oder Sammlung).
|
|
27
|
+
*/
|
|
28
|
+
constructor(selector) {
|
|
29
|
+
super();
|
|
30
|
+
this.selectorSource = '';
|
|
31
|
+
this.selectorSource = typeof selector === 'string' ? selector : '<DOM Object/Array>';
|
|
32
|
+
if (!selector)
|
|
33
|
+
return;
|
|
34
|
+
// 1. Single DOM Element / Window / Document
|
|
35
|
+
if (selector instanceof HTMLElement || selector === document || selector === window || selector instanceof Element) {
|
|
36
|
+
this.push(selector);
|
|
37
|
+
}
|
|
38
|
+
// 2. String (HTML Creation or CSS Selector)
|
|
39
|
+
else if (typeof selector === 'string') {
|
|
40
|
+
const trimmed = selector.trim();
|
|
41
|
+
if (trimmed.startsWith('<') && trimmed.endsWith('>')) {
|
|
42
|
+
// HTML Creation
|
|
43
|
+
const tempDiv = document.createElement('div');
|
|
44
|
+
tempDiv.innerHTML = trimmed;
|
|
45
|
+
this.push(...Array.from(tempDiv.children));
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
// CSS Selector
|
|
49
|
+
this.push(...Array.from(document.querySelectorAll(selector)));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
// 3. Collections (NodeList, Array)
|
|
53
|
+
else if (selector instanceof NodeList || Array.isArray(selector)) {
|
|
54
|
+
this.push(...Array.from(selector));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* * 🇬🇧: Custom serializer for JSON.stringify. Prevents circular references and huge outputs by returning a simplified preview.
|
|
59
|
+
* * 🇩🇪: Benutzerdefinierte Serialisierung für JSON.stringify. Verhindert Zirkelbezüge und riesige Ausgaben durch Rückgabe einer vereinfachten Vorschau.
|
|
60
|
+
* @returns
|
|
61
|
+
* * 🇬🇧: A simplified object representation for debugging.
|
|
62
|
+
* * 🇩🇪: Eine vereinfachte Objektrepräsentation für das Debugging.
|
|
63
|
+
*/
|
|
64
|
+
toJSON() {
|
|
65
|
+
return {
|
|
66
|
+
meta: 'jBase Wrapper',
|
|
67
|
+
query: this.selectorSource,
|
|
68
|
+
count: this.length,
|
|
69
|
+
preview: this.slice(0, 10).map(el => {
|
|
70
|
+
if (el instanceof Element)
|
|
71
|
+
return el.tagName.toLowerCase();
|
|
72
|
+
return typeof el;
|
|
73
|
+
})
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.jBase = jBase;
|
|
78
|
+
//# sourceMappingURL=core.js.map
|
package/dist/core.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../src/core.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;GAWG;;;AAIH;;;GAGG;AACH,MAAa,KAAM,SAAQ,KAAmB;IAG1C;;;;;;OAMG;IACH,YAAY,QAAqB;QAC7B,KAAK,EAAE,CAAC;QAVL,mBAAc,GAAW,EAAE,CAAC;QAY/B,IAAI,CAAC,cAAc,GAAG,OAAO,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,oBAAoB,CAAC;QAErF,IAAI,CAAC,QAAQ;YACT,OAAO;QAEX,4CAA4C;QAC5C,IAAI,QAAQ,YAAY,WAAW,IAAI,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,MAAM,IAAI,QAAQ,YAAY,OAAO,EAAE,CAAC;YACjH,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QACxB,CAAC;QACD,4CAA4C;aACvC,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC;YAEhC,IAAI,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACnD,gBAAgB;gBAChB,MAAM,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;gBAC9C,OAAO,CAAC,SAAS,GAAG,OAAO,CAAC;gBAC5B,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;YAC/C,CAAC;iBAAM,CAAC;gBACJ,eAAe;gBACf,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAClE,CAAC;QACL,CAAC;QACD,mCAAmC;aAC9B,IAAI,QAAQ,YAAY,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/D,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,QAAmC,CAAC,CAAC,CAAC;QAClE,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,MAAM;QACF,OAAO;YACH,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,IAAI,CAAC,cAAc;YAC1B,KAAK,EAAE,IAAI,CAAC,MAAM;YAClB,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE;gBAChC,IAAI,EAAE,YAAY,OAAO;oBACrB,OAAO,EAAE,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;gBACpC,OAAO,OAAO,EAAE,CAAC;YACrB,CAAC,CAAC;SACL,CAAC;IACN,CAAC;CACJ;AA7DD,sBA6DC"}
|