@k37z3r/jbase 2.0.2 → 2.0.3

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.
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * @file src/modules/http/get.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
@@ -17,20 +17,24 @@
17
17
  * * The expected type of the response data (Generic).
18
18
  * @param url
19
19
  * * The target URL for the request.
20
+ * @param option
21
+ * * Optional RequestInit object to customize the fetch request.
20
22
  * @returns
21
23
  * * A Promise resolving with the typed JSON data.
22
24
  * @throws
23
25
  * * Error if HTTP status is not in success range (200-299) or a timeout occurs.
24
26
  */
25
- export declare function get<T>(url: string): Promise<T>;
27
+ export declare function get<T>(url: string, option?: RequestInit): Promise<T>;
26
28
  /**
27
29
  * * Performs an asynchronous HTTP GET request and returns the raw text content. Ideal for loading HTML fragments (Server-Side Rendering Partials) or plain text.
28
30
  * @param url
29
31
  * * The target URL for the request.
32
+ * @param option
33
+ * * Optional RequestInit object to customize the fetch request.
30
34
  * @returns
31
35
  * * A Promise containing the response body as a string.
32
36
  * @throws
33
37
  * * Error if HTTP status is not in success range (200-299).
34
38
  */
35
- export declare function getText<T>(url: string): Promise<T>;
39
+ export declare function getText<T>(url: string, option?: RequestInit): Promise<T>;
36
40
  //# sourceMappingURL=get.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;GAUG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CASpD;AAED;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAOxD"}
1
+ {"version":3,"file":"get.d.ts","sourceRoot":"","sources":["../../../src/modules/http/get.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB1E;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAgB9E"}
@@ -26,8 +26,8 @@
26
26
  * const html = await http.getText('/templates/modal.html');
27
27
  */
28
28
  export declare const http: {
29
- post<T>(url: string, body?: any): Promise<T>;
30
- get<T>(url: string): Promise<T>;
31
- getText<T>(url: string): Promise<T>;
29
+ post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
30
+ get<T>(url: string, option?: RequestInit): Promise<T>;
31
+ getText<T>(url: string, option?: RequestInit): Promise<T>;
32
32
  };
33
33
  //# sourceMappingURL=index.d.ts.map
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @file src/modules/http/post.ts
3
- * @version 2.0.2
4
- * @since 2.0.0
3
+ * @version 2.0.3
4
+ * @since 2.0.2
5
5
  * @license GPL-3.0-or-later
6
6
  * @copyright Sven Minio 2026
7
7
  * @author Sven Minio <https://sven-minio.de>
@@ -19,10 +19,12 @@
19
19
  * * The target URL for the request.
20
20
  * @param body
21
21
  * * The data to send (automatically JSON serialized). Default is {}.
22
+ * @param option
23
+ * * Optional RequestInit object to customize the fetch request.
22
24
  * @returns
23
25
  * * A Promise resolving with the deserialized JSON response of type T.
24
26
  * @throws
25
27
  * * Error if the HTTP status code is not in the range 200-299.
26
28
  */
27
- export declare function post<T>(url: string, body?: any): Promise<T>;
29
+ export declare function post<T>(url: string, body?: any, option?: RequestInit): Promise<T>;
28
30
  //# sourceMappingURL=post.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;GAYG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,GAAG,OAAO,CAAC,CAAC,CAAC,CAkBrE"}
1
+ {"version":3,"file":"post.d.ts","sourceRoot":"","sources":["../../../src/modules/http/post.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,IAAI,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE,GAAQ,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAyB3F"}
package/dist/server.js CHANGED
@@ -1,6 +1,6 @@
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.2
3
+ * @version 2.0.3
4
4
  * @homepage https://github.com/k37z3r/jBase-2.0
5
5
  * @author Sven Minio (https://github.com/k37z3r/jBase-2.0)
6
6
  * @license GPL-3.0-or-later
@@ -1248,9 +1248,16 @@ __export(get_exports, {
1248
1248
  get: () => get,
1249
1249
  getText: () => getText
1250
1250
  });
1251
- async function get(url) {
1251
+ async function get(url, option) {
1252
+ const fetchOptions = { ...option };
1253
+ if (fetchOptions.method?.toLowerCase() === "post") {
1254
+ fetchOptions.method = "GET";
1255
+ }
1256
+ if (!fetchOptions.signal) {
1257
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1258
+ }
1252
1259
  const response = await fetch(url, {
1253
- signal: AbortSignal.timeout(5e3)
1260
+ ...fetchOptions
1254
1261
  });
1255
1262
  if (!response.ok) {
1256
1263
  throw new Error(`HTTP Error: ${response.status}`);
@@ -1258,8 +1265,17 @@ async function get(url) {
1258
1265
  const text2 = await response.text();
1259
1266
  return text2 ? JSON.parse(text2) : {};
1260
1267
  }
1261
- async function getText(url) {
1262
- const response = await fetch(url);
1268
+ async function getText(url, option) {
1269
+ const fetchOptions = { ...option };
1270
+ if (fetchOptions.method?.toLowerCase() !== "get") {
1271
+ fetchOptions.method = "GET";
1272
+ }
1273
+ if (!fetchOptions.signal) {
1274
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1275
+ }
1276
+ const response = await fetch(url, {
1277
+ ...fetchOptions
1278
+ });
1263
1279
  if (!response.ok) {
1264
1280
  throw new Error(`HTTP Error: ${response.status}`);
1265
1281
  }
@@ -1272,9 +1288,16 @@ var post_exports = {};
1272
1288
  __export(post_exports, {
1273
1289
  post: () => post
1274
1290
  });
1275
- async function post(url, body = {}) {
1291
+ async function post(url, body = {}, option) {
1292
+ const fetchOptions = { ...option };
1293
+ if (fetchOptions.method?.toLowerCase() !== "post") {
1294
+ fetchOptions.method = "post";
1295
+ }
1296
+ if (!fetchOptions.signal) {
1297
+ fetchOptions.signal = AbortSignal.timeout(5e3);
1298
+ }
1276
1299
  const response = await fetch(url, {
1277
- method: "POST",
1300
+ ...fetchOptions,
1278
1301
  headers: { "Content-Type": "application/json" },
1279
1302
  body: JSON.stringify(body)
1280
1303
  });
@@ -2100,7 +2123,7 @@ function parseHTML2(html2) {
2100
2123
  */
2101
2124
  /**
2102
2125
  * @file src/modules/http/get.ts
2103
- * @version 2.0.2
2126
+ * @version 2.0.3
2104
2127
  * @since 2.0.0
2105
2128
  * @license GPL-3.0-or-later
2106
2129
  * @copyright Sven Minio 2026
@@ -2113,8 +2136,8 @@ function parseHTML2(html2) {
2113
2136
  */
2114
2137
  /**
2115
2138
  * @file src/modules/http/post.ts
2116
- * @version 2.0.2
2117
- * @since 2.0.0
2139
+ * @version 2.0.3
2140
+ * @since 2.0.2
2118
2141
  * @license GPL-3.0-or-later
2119
2142
  * @copyright Sven Minio 2026
2120
2143
  * @author Sven Minio <https://sven-minio.de>