@k37z3r/jbase 2.0.3 → 2.1.2

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 CHANGED
@@ -21,19 +21,19 @@ 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
 
@@ -47,4 +47,25 @@ All notable changes to this project will be documented in this file.
47
47
  ### 🛡️ Fixed (http)
48
48
 
49
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.
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.
65
+
66
+ ## [2.1.2] - 2026-02-22
67
+
68
+ ### 🛡️ Fixed (Core & Browser Scope)
69
+
70
+ * **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()`.
71
+ * **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`).
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jBase
2
2
 
3
- ![Version](https://img.shields.io/badge/version-2.0.2-blue.svg?style=flat-square)
3
+ ![Version](https://img.shields.io/badge/version-2.1.2-blue.svg?style=flat-square)
4
4
  ![License](https://img.shields.io/badge/license-GPL--3.0-green.svg?style=flat-square)
5
5
  ![Size](https://img.shields.io/badge/size-lightweight-orange.svg?style=flat-square)
6
6
  ![Build](https://img.shields.io/badge/build-passing-brightgreen.svg?style=flat-square)
package/dist/browser.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file src/browser.ts
3
- * @version 2.0.2
3
+ * @version 2.0.3
4
4
  * @since 2.0.0
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
@@ -9,7 +9,7 @@
9
9
  * @description
10
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
11
  */
12
- import { $, jBase, http, jB, _jB, __jB, _jBase, __jBase, __ } from './index';
12
+ import { $, jBase, jB, _jB, __jB, _jBase, __jBase, __ } from './index';
13
13
  /**
14
14
  * * TypeScript declaration merging to extend the global Window interface.
15
15
  */
@@ -23,7 +23,6 @@ declare global {
23
23
  _jBase: typeof _jBase;
24
24
  __jBase: typeof __jBase;
25
25
  __: typeof __;
26
- http: typeof http;
27
26
  }
28
27
  }
29
28
  //# sourceMappingURL=browser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAE7E;;GAEG;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;QACd,IAAI,EAAE,OAAO,IAAI,CAAC;KACrB;CACJ"}
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAC;AAEvE;;GAEG;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"}
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.0.3
4
- * @homepage https://github.com/k37z3r/jBase-2.0
5
- * @author Sven Minio (https://github.com/k37z3r/jBase-2.0)
3
+ * @version 2.1.2
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.0)
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 (value === void 0) {
163
- const el = this[0];
164
- if (el instanceof HTMLElement || el instanceof SVGElement) {
165
- const doc = el.ownerDocument;
166
- const win = doc ? doc.defaultView : null;
167
- if (win) {
168
- return win.getComputedStyle(el)[property];
169
- } else {
170
- return el.style[property] || "";
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
- this.forEach((el) => {
176
- if (el instanceof HTMLElement || el instanceof SVGElement) {
177
- el.style[property] = value;
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 = {};
@@ -1310,7 +1352,7 @@ async function getText(url, option) {
1310
1352
  throw new Error(`HTTP Error: ${response.status}`);
1311
1353
  }
1312
1354
  const text2 = await response.text();
1313
- return text2 ? JSON.parse(text2) : {};
1355
+ return text2;
1314
1356
  }
1315
1357
 
1316
1358
  // src/modules/http/post.ts
@@ -1817,9 +1859,14 @@ Object.assign(jBase.prototype, cssMethods);
1817
1859
  Object.assign(jBase.prototype, eventMethods);
1818
1860
  Object.assign(jBase.prototype, domMethods);
1819
1861
  Object.assign(jBase.prototype, effectMethods);
1820
- var init = (selector) => {
1862
+ var initFn = (selector) => {
1821
1863
  return new jBase(selector);
1822
1864
  };
1865
+ var init = Object.assign(initFn, {
1866
+ http,
1867
+ data,
1868
+ fn: jBase.prototype
1869
+ });
1823
1870
  var bind = (window2) => {
1824
1871
  const doc = window2.document;
1825
1872
  const boundInit = (selector) => new jBase(selector, doc);
@@ -1881,7 +1928,7 @@ var __ = init;
1881
1928
  */
1882
1929
  /**
1883
1930
  * @file src/modules/css/styles.ts
1884
- * @version 2.0.2
1931
+ * @version 2.0.3
1885
1932
  * @since 2.0.0
1886
1933
  * @license GPL-3.0-or-later
1887
1934
  * @copyright Sven Minio 2026
@@ -2010,7 +2057,7 @@ var __ = init;
2010
2057
  */
2011
2058
  /**
2012
2059
  * @file src/modules/dom/attributes.ts
2013
- * @version 2.0.2
2060
+ * @version 2.1.0
2014
2061
  * @since 2.0.0
2015
2062
  * @license GPL-3.0-or-later
2016
2063
  * @copyright Sven Minio 2026
@@ -2163,7 +2210,7 @@ var __ = init;
2163
2210
  */
2164
2211
  /**
2165
2212
  * @file src/modules/http/get.ts
2166
- * @version 2.0.3
2213
+ * @version 2.0.4
2167
2214
  * @since 2.0.0
2168
2215
  * @license GPL-3.0-or-later
2169
2216
  * @copyright Sven Minio 2026
@@ -2245,7 +2292,7 @@ var __ = init;
2245
2292
  */
2246
2293
  /**
2247
2294
  * @file src/index.ts
2248
- * @version 2.0.2
2295
+ * @version 2.1.2
2249
2296
  * @since 2.0.0
2250
2297
  * @license GPL-3.0-or-later
2251
2298
  * @copyright Sven Minio 2026