@k37z3r/jbase 2.0.2 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +26 -4
- package/README.md +1 -1
- package/dist/index.cjs +97 -32
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +36 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +97 -32
- package/dist/index.mjs.map +2 -2
- package/dist/jbase.browser.js +97 -32
- package/dist/jbase.browser.js.map +2 -2
- package/dist/jbase.min.js +5 -5
- package/dist/jbase.min.js.map +3 -3
- package/dist/modules/css/index.d.ts +1 -1
- package/dist/modules/css/styles.d.ts +6 -6
- package/dist/modules/css/styles.d.ts.map +1 -1
- package/dist/modules/dom/attributes.d.ts +20 -1
- package/dist/modules/dom/attributes.d.ts.map +1 -1
- package/dist/modules/dom/index.d.ts +2 -0
- package/dist/modules/dom/index.d.ts.map +1 -1
- package/dist/modules/http/get.d.ts +7 -3
- package/dist/modules/http/get.d.ts.map +1 -1
- package/dist/modules/http/index.d.ts +3 -3
- package/dist/modules/http/post.d.ts +5 -3
- package/dist/modules/http/post.d.ts.map +1 -1
- package/dist/server.js +97 -32
- package/dist/server.js.map +2 -2
- package/package.json +5 -5
- package/wiki/DOM-Attributes.md +56 -2
- package/wiki/HTTP-Requests.md +11 -14
- package/wiki/Home.md +1 -1
- package/wiki/Quick-Start.md +3 -4
package/CHANGELOG.md
CHANGED
|
@@ -21,22 +21,44 @@ All notable changes to this project will be documented in this file.
|
|
|
21
21
|
|
|
22
22
|
### ⚡ Performance
|
|
23
23
|
|
|
24
|
-
* **Data Module (`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.
|
|
24
|
+
* **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.
|
|
25
25
|
* **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.
|
|
26
26
|
|
|
27
27
|
### 🛡️ Fixed (Stability & Logic)
|
|
28
28
|
|
|
29
29
|
* **Core (`core.ts`):** Added crash protection for invalid CSS selectors. `$(...)` now catches `DOMException` errors internally and logs a warning instead of crashing.
|
|
30
|
-
* **DOM Manipulation (`manipulation.ts`):**
|
|
30
|
+
* **DOM Manipulation (`dom/manipulation.ts`):**
|
|
31
31
|
* Rewrote `unwrap()` using a `Set` to safely handle parent removal without conflicts on sibling elements.
|
|
32
32
|
* Replaced global `window.document` usage with a `getDoc(this)` helper to prevent `ReferenceError` crashes in Node.js.
|
|
33
33
|
|
|
34
34
|
|
|
35
35
|
* **HTTP Module (`http/*.ts`):** Fixed potential crash when parsing JSON from `200 OK` responses that contain an empty body.
|
|
36
|
-
* **CSS Module (`styles.ts`):** Updated `css()` getter to access `getComputedStyle` via `el.ownerDocument` instead of global `window`.
|
|
36
|
+
* **CSS Module (`css/styles.ts`):** Updated `css()` getter to access `getComputedStyle` via `el.ownerDocument` instead of global `window`.
|
|
37
37
|
|
|
38
38
|
### 🔧 Changed & Cleaned
|
|
39
39
|
|
|
40
40
|
* **Documentation:** Removed localized German JSDoc comments to reduce source code size and maintain a consistent English-only documentation standard.
|
|
41
41
|
* **Config:** Fixed invalid JSON syntax in `tsconfig.json`.
|
|
42
|
-
* **Type Safety:** Upgraded `isObject` utility to a TypeScript Type Guard for better type inference.
|
|
42
|
+
* **Type Safety:** Upgraded `isObject` utility to a TypeScript Type Guard for better type inference.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## [2.0.3] - 2026-02-13
|
|
46
|
+
|
|
47
|
+
### 🛡️ Fixed (http)
|
|
48
|
+
|
|
49
|
+
* **HTTP Module (`http/get.ts`):** Enforce GET method in get() and getText() utility. Overrides method to 'GET' if 'POST' is passed in options.
|
|
50
|
+
* **HTTP Module (`http/post.ts`):** Enforce POST method in post() utility. Overrides method to 'POST' if 'GET' is passed in options.
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## [2.1.1] - 2026-02-22
|
|
54
|
+
|
|
55
|
+
### 🚀 Added (DOM Attributes)
|
|
56
|
+
|
|
57
|
+
* **Attributes Module (`dom/attributes.ts`):** Added `removeAttr()` method to safely remove HTML attributes from all elements in a selection.
|
|
58
|
+
* **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.
|
|
59
|
+
|
|
60
|
+
### 🛡️ Fixed (CSS & HTTP)
|
|
61
|
+
|
|
62
|
+
* **CSS Module (`css/styles.ts`):** Enhanced the `css()` method to support passing an object (`Record<string, string | number>`) for setting multiple CSS properties simultaneously (e.g., `css({'background-color': 'blue', 'font-size': '14px'})`).
|
|
63
|
+
* **CSS Module (`css/styles.ts`):** Improved handling of kebab-case property names inside the `css()` method by utilizing `style.setProperty()` for greater robustness.
|
|
64
|
+
* **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.
|
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# jBase
|
|
2
2
|
|
|
3
|
-

|
|
4
4
|

|
|
5
5
|

|
|
6
6
|

|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @k37z3r/jbase - A modern micro-framework for the web: jBase offers the familiar syntax of classic DOM libraries, but without their baggage. Fully typed, modular, and optimized for modern browser engines.
|
|
3
|
-
* @version 2.
|
|
4
|
-
* @homepage https://github.com/k37z3r/jBase-2
|
|
5
|
-
* @author Sven Minio (https://github.com/k37z3r/jBase-2
|
|
3
|
+
* @version 2.1.1
|
|
4
|
+
* @homepage https://github.com/k37z3r/jBase-2
|
|
5
|
+
* @author Sven Minio (https://github.com/k37z3r/jBase-2)
|
|
6
6
|
* @license GPL-3.0-or-later
|
|
7
|
-
* @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2
|
|
7
|
+
* @copyright 2026 Sven Minio (https://github.com/k37z3r/jBase-2)
|
|
8
8
|
*/
|
|
9
9
|
"use strict";
|
|
10
10
|
var __defProp = Object.defineProperty;
|
|
@@ -159,24 +159,46 @@ __export(styles_exports, {
|
|
|
159
159
|
css: () => css
|
|
160
160
|
});
|
|
161
161
|
function css(property, value) {
|
|
162
|
-
if (
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
162
|
+
if (typeof property === "object" && property !== null) {
|
|
163
|
+
this.forEach((el) => {
|
|
164
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
165
|
+
for (const key in property) {
|
|
166
|
+
if (Object.prototype.hasOwnProperty.call(property, key)) {
|
|
167
|
+
if (key.includes("-")) {
|
|
168
|
+
el.style.setProperty(key, String(property[key]));
|
|
169
|
+
} else {
|
|
170
|
+
el.style[key] = property[key];
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
171
174
|
}
|
|
172
|
-
}
|
|
173
|
-
return
|
|
175
|
+
});
|
|
176
|
+
return this;
|
|
174
177
|
}
|
|
175
|
-
|
|
176
|
-
if (
|
|
177
|
-
el
|
|
178
|
+
if (typeof property === "string") {
|
|
179
|
+
if (value === void 0) {
|
|
180
|
+
const el = this[0];
|
|
181
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
182
|
+
const doc = el.ownerDocument;
|
|
183
|
+
const win = doc ? doc.defaultView : null;
|
|
184
|
+
if (win) {
|
|
185
|
+
return win.getComputedStyle(el).getPropertyValue(property) || win.getComputedStyle(el)[property] || "";
|
|
186
|
+
} else {
|
|
187
|
+
return el.style[property] || "";
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
return "";
|
|
178
191
|
}
|
|
179
|
-
|
|
192
|
+
this.forEach((el) => {
|
|
193
|
+
if (el instanceof HTMLElement || el instanceof SVGElement) {
|
|
194
|
+
if (property.includes("-")) {
|
|
195
|
+
el.style.setProperty(property, String(value));
|
|
196
|
+
} else {
|
|
197
|
+
el.style[property] = value;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
}
|
|
180
202
|
return this;
|
|
181
203
|
}
|
|
182
204
|
|
|
@@ -381,6 +403,8 @@ var eventMethods = {
|
|
|
381
403
|
var attributes_exports = {};
|
|
382
404
|
__export(attributes_exports, {
|
|
383
405
|
attr: () => attr,
|
|
406
|
+
prop: () => prop,
|
|
407
|
+
removeAttr: () => removeAttr,
|
|
384
408
|
val: () => val
|
|
385
409
|
});
|
|
386
410
|
function attr(name, value) {
|
|
@@ -408,6 +432,24 @@ function val(value) {
|
|
|
408
432
|
});
|
|
409
433
|
return this;
|
|
410
434
|
}
|
|
435
|
+
function removeAttr(name) {
|
|
436
|
+
this.forEach((el) => {
|
|
437
|
+
if (el instanceof Element) el.removeAttribute(name);
|
|
438
|
+
});
|
|
439
|
+
return this;
|
|
440
|
+
}
|
|
441
|
+
function prop(name, value) {
|
|
442
|
+
if (value === void 0) {
|
|
443
|
+
const el = this[0];
|
|
444
|
+
return el instanceof Element ? el[name] : void 0;
|
|
445
|
+
}
|
|
446
|
+
this.forEach((el) => {
|
|
447
|
+
if (el instanceof Element) {
|
|
448
|
+
el[name] = value;
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
return this;
|
|
452
|
+
}
|
|
411
453
|
|
|
412
454
|
// src/modules/dom/content.ts
|
|
413
455
|
var content_exports = {};
|
|
@@ -1278,9 +1320,16 @@ __export(get_exports, {
|
|
|
1278
1320
|
get: () => get,
|
|
1279
1321
|
getText: () => getText
|
|
1280
1322
|
});
|
|
1281
|
-
async function get(url) {
|
|
1323
|
+
async function get(url, option) {
|
|
1324
|
+
const fetchOptions = { ...option };
|
|
1325
|
+
if (fetchOptions.method?.toLowerCase() === "post") {
|
|
1326
|
+
fetchOptions.method = "GET";
|
|
1327
|
+
}
|
|
1328
|
+
if (!fetchOptions.signal) {
|
|
1329
|
+
fetchOptions.signal = AbortSignal.timeout(5e3);
|
|
1330
|
+
}
|
|
1282
1331
|
const response = await fetch(url, {
|
|
1283
|
-
|
|
1332
|
+
...fetchOptions
|
|
1284
1333
|
});
|
|
1285
1334
|
if (!response.ok) {
|
|
1286
1335
|
throw new Error(`HTTP Error: ${response.status}`);
|
|
@@ -1288,13 +1337,22 @@ async function get(url) {
|
|
|
1288
1337
|
const text2 = await response.text();
|
|
1289
1338
|
return text2 ? JSON.parse(text2) : {};
|
|
1290
1339
|
}
|
|
1291
|
-
async function getText(url) {
|
|
1292
|
-
const
|
|
1340
|
+
async function getText(url, option) {
|
|
1341
|
+
const fetchOptions = { ...option };
|
|
1342
|
+
if (fetchOptions.method?.toLowerCase() !== "get") {
|
|
1343
|
+
fetchOptions.method = "GET";
|
|
1344
|
+
}
|
|
1345
|
+
if (!fetchOptions.signal) {
|
|
1346
|
+
fetchOptions.signal = AbortSignal.timeout(5e3);
|
|
1347
|
+
}
|
|
1348
|
+
const response = await fetch(url, {
|
|
1349
|
+
...fetchOptions
|
|
1350
|
+
});
|
|
1293
1351
|
if (!response.ok) {
|
|
1294
1352
|
throw new Error(`HTTP Error: ${response.status}`);
|
|
1295
1353
|
}
|
|
1296
1354
|
const text2 = await response.text();
|
|
1297
|
-
return text2
|
|
1355
|
+
return text2;
|
|
1298
1356
|
}
|
|
1299
1357
|
|
|
1300
1358
|
// src/modules/http/post.ts
|
|
@@ -1302,9 +1360,16 @@ var post_exports = {};
|
|
|
1302
1360
|
__export(post_exports, {
|
|
1303
1361
|
post: () => post
|
|
1304
1362
|
});
|
|
1305
|
-
async function post(url, body = {}) {
|
|
1363
|
+
async function post(url, body = {}, option) {
|
|
1364
|
+
const fetchOptions = { ...option };
|
|
1365
|
+
if (fetchOptions.method?.toLowerCase() !== "post") {
|
|
1366
|
+
fetchOptions.method = "post";
|
|
1367
|
+
}
|
|
1368
|
+
if (!fetchOptions.signal) {
|
|
1369
|
+
fetchOptions.signal = AbortSignal.timeout(5e3);
|
|
1370
|
+
}
|
|
1306
1371
|
const response = await fetch(url, {
|
|
1307
|
-
|
|
1372
|
+
...fetchOptions,
|
|
1308
1373
|
headers: { "Content-Type": "application/json" },
|
|
1309
1374
|
body: JSON.stringify(body)
|
|
1310
1375
|
});
|
|
@@ -1858,7 +1923,7 @@ var __ = init;
|
|
|
1858
1923
|
*/
|
|
1859
1924
|
/**
|
|
1860
1925
|
* @file src/modules/css/styles.ts
|
|
1861
|
-
* @version 2.0.
|
|
1926
|
+
* @version 2.0.3
|
|
1862
1927
|
* @since 2.0.0
|
|
1863
1928
|
* @license GPL-3.0-or-later
|
|
1864
1929
|
* @copyright Sven Minio 2026
|
|
@@ -1987,7 +2052,7 @@ var __ = init;
|
|
|
1987
2052
|
*/
|
|
1988
2053
|
/**
|
|
1989
2054
|
* @file src/modules/dom/attributes.ts
|
|
1990
|
-
* @version 2.0
|
|
2055
|
+
* @version 2.1.0
|
|
1991
2056
|
* @since 2.0.0
|
|
1992
2057
|
* @license GPL-3.0-or-later
|
|
1993
2058
|
* @copyright Sven Minio 2026
|
|
@@ -2140,7 +2205,7 @@ var __ = init;
|
|
|
2140
2205
|
*/
|
|
2141
2206
|
/**
|
|
2142
2207
|
* @file src/modules/http/get.ts
|
|
2143
|
-
* @version 2.0.
|
|
2208
|
+
* @version 2.0.4
|
|
2144
2209
|
* @since 2.0.0
|
|
2145
2210
|
* @license GPL-3.0-or-later
|
|
2146
2211
|
* @copyright Sven Minio 2026
|
|
@@ -2153,8 +2218,8 @@ var __ = init;
|
|
|
2153
2218
|
*/
|
|
2154
2219
|
/**
|
|
2155
2220
|
* @file src/modules/http/post.ts
|
|
2156
|
-
* @version 2.0.
|
|
2157
|
-
* @since 2.0.
|
|
2221
|
+
* @version 2.0.3
|
|
2222
|
+
* @since 2.0.2
|
|
2158
2223
|
* @license GPL-3.0-or-later
|
|
2159
2224
|
* @copyright Sven Minio 2026
|
|
2160
2225
|
* @author Sven Minio <https://sven-minio.de>
|
|
@@ -2222,7 +2287,7 @@ var __ = init;
|
|
|
2222
2287
|
*/
|
|
2223
2288
|
/**
|
|
2224
2289
|
* @file src/index.ts
|
|
2225
|
-
* @version 2.
|
|
2290
|
+
* @version 2.1.1
|
|
2226
2291
|
* @since 2.0.0
|
|
2227
2292
|
* @license GPL-3.0-or-later
|
|
2228
2293
|
* @copyright Sven Minio 2026
|