@develia/commons 0.4.6 → 0.4.8
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/dist/cjs/browser/form-utilities.js +129 -0
- package/dist/cjs/browser/form-utilities.js.map +1 -0
- package/dist/cjs/browser/{gps.js → geo-location.js} +2 -2
- package/dist/cjs/browser/geo-location.js.map +1 -0
- package/dist/cjs/browser/index.js +9 -127
- package/dist/cjs/browser/index.js.map +1 -1
- package/dist/cjs/browser/native-bridge.js +70 -0
- package/dist/cjs/browser/native-bridge.js.map +1 -0
- package/dist/cjs/index.js +6 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/browser/form-utilities.js +122 -0
- package/dist/esm/browser/form-utilities.js.map +1 -0
- package/dist/{web/browser/gps.js → esm/browser/geo-location.js} +2 -2
- package/dist/esm/browser/geo-location.js.map +1 -0
- package/dist/esm/browser/index.js +3 -122
- package/dist/esm/browser/index.js.map +1 -1
- package/dist/esm/browser/native-bridge.js +67 -0
- package/dist/esm/browser/native-bridge.js.map +1 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/types/browser/form-utilities.d.ts +7 -0
- package/dist/types/browser/form-utilities.d.ts.map +1 -0
- package/dist/types/browser/{gps.d.ts → geo-location.d.ts} +2 -2
- package/dist/types/browser/geo-location.d.ts.map +1 -0
- package/dist/types/browser/index.d.ts +3 -7
- package/dist/types/browser/index.d.ts.map +1 -1
- package/dist/types/browser/native-bridge.d.ts +22 -0
- package/dist/types/browser/native-bridge.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/web/browser/form-utilities.js +123 -0
- package/dist/web/browser/form-utilities.js.map +1 -0
- package/dist/{esm/browser/gps.js → web/browser/geo-location.js} +2 -2
- package/dist/web/browser/geo-location.js.map +1 -0
- package/dist/web/browser/index.js +3 -123
- package/dist/web/browser/index.js.map +1 -1
- package/dist/web/browser/native-bridge.js +67 -0
- package/dist/web/browser/native-bridge.js.map +1 -0
- package/dist/web/index.js +1 -1
- package/dist/web/index.js.map +1 -1
- package/package.json +7 -1
- package/src/browser/form-utilities.ts +174 -0
- package/src/browser/{gps.ts → geo-location.ts} +1 -1
- package/src/browser/index.ts +3 -174
- package/src/browser/native-bridge.ts +117 -0
- package/src/index.ts +1 -1
- package/dist/cjs/browser/gps.js.map +0 -1
- package/dist/esm/browser/gps.js.map +0 -1
- package/dist/types/browser/gps.d.ts.map +0 -1
- package/dist/web/browser/gps.js.map +0 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export default class NativeBridge {
|
|
2
|
+
constructor({ channel, timeout = 3000, callbackName = '__nativeResponseHandler' }) {
|
|
3
|
+
this._pending = new Map();
|
|
4
|
+
this._callId = 0;
|
|
5
|
+
this._defaultTimeout = timeout;
|
|
6
|
+
this._channel = channel;
|
|
7
|
+
if (!this._channel) {
|
|
8
|
+
throw new Error('Channel not found');
|
|
9
|
+
}
|
|
10
|
+
window[callbackName] = this._callback;
|
|
11
|
+
return new Proxy(this, {
|
|
12
|
+
get(target, prop) {
|
|
13
|
+
if (prop in target) {
|
|
14
|
+
return target[prop];
|
|
15
|
+
}
|
|
16
|
+
return (data, timeout) => target.call(String(prop), data, timeout);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
_callback(id, error, result) {
|
|
21
|
+
const pending = this._pending.get(id);
|
|
22
|
+
if (!pending) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (pending.timer !== null) {
|
|
26
|
+
clearTimeout(pending.timer);
|
|
27
|
+
}
|
|
28
|
+
this._pending.delete(id);
|
|
29
|
+
if (error) {
|
|
30
|
+
pending.reject(error instanceof Error ? error : new Error(String(error)));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
pending.resolve(result);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
call(method, data = null, timeout) {
|
|
37
|
+
const effectiveTimeout = timeout !== undefined ? timeout : this._defaultTimeout;
|
|
38
|
+
return new Promise((resolve, reject) => {
|
|
39
|
+
const id = this._callId++;
|
|
40
|
+
let timer = null;
|
|
41
|
+
if (effectiveTimeout !== null && effectiveTimeout > 0) {
|
|
42
|
+
timer = setTimeout(() => {
|
|
43
|
+
this._pending.delete(id);
|
|
44
|
+
reject(new Error(`Timeout (${effectiveTimeout}ms): ${method}`));
|
|
45
|
+
}, effectiveTimeout);
|
|
46
|
+
}
|
|
47
|
+
this._pending.set(id, { resolve, reject, timer });
|
|
48
|
+
this._channel.postMessage(JSON.stringify({ id, method, data }));
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
send(method, data = null) {
|
|
52
|
+
this._channel.postMessage(JSON.stringify({ method, data }));
|
|
53
|
+
}
|
|
54
|
+
get pendingCount() {
|
|
55
|
+
return this._pending.size;
|
|
56
|
+
}
|
|
57
|
+
cancelAll() {
|
|
58
|
+
for (const [, { reject, timer }] of this._pending) {
|
|
59
|
+
if (timer !== null) {
|
|
60
|
+
clearTimeout(timer);
|
|
61
|
+
}
|
|
62
|
+
reject(new Error('Cancelled'));
|
|
63
|
+
}
|
|
64
|
+
this._pending.clear();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=native-bridge.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-bridge.js","sourceRoot":"","sources":["../../../src/browser/native-bridge.ts"],"names":[],"mappings":"AAoBA,MAAM,CAAC,OAAO,OAAO,YAAY;IAO7B,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,EAAE,YAAY,GAAG,yBAAyB,EAAiB;QANxF,aAAQ,GAAG,IAAI,GAAG,EAAuB,CAAC;QAC1C,YAAO,GAAG,CAAC,CAAC;QAMhB,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QAExB,IAAI,CAAC,IAAI,C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AAE,CAAC;gBACjB,YAAY,CAAC,KAAK,CAAC,CAAC;YACxB,CAAC;YACD,MAAM,CAAC,IAAI,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;QACnC,CAAC;QACD,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;IAC1B,CAAC;CACJ"}
|
package/dist/web/index.js
CHANGED
|
@@ -13,7 +13,7 @@ export { default as AsyncPoolExecutor } from './async-pool-executor.js';
|
|
|
13
13
|
export { default as Lazy } from './lazy.js';
|
|
14
14
|
export { default as from, From } from './from.js';
|
|
15
15
|
export { default as CleanURLSearchParams } from './clean-url-search-params.js';
|
|
16
|
-
export
|
|
16
|
+
export { ajaxSubmit, ajaxSubmission, submitForm, formToObject } from './browser/index.js';
|
|
17
17
|
export * from './array.js';
|
|
18
18
|
export * from './collections/index.js';
|
|
19
19
|
//# sourceMappingURL=index.js.map
|
package/dist/web/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAC,OAAO,IAAI,IAAI,EAAC,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAGnD,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAG1B,OAAO,EAAC,OAAO,IAAI,YAAY,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AAG5C,OAAO,EAAC,OAAO,IAAI,KAAK,EAAC,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAC,OAAO,IAAI,QAAQ,EAAC,MAAM,eAAe,CAAC;AAClD,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAC,OAAO,IAA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AI1F,cAAc,YAAY,CAAC;AAE3B,cAAc,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@develia/commons",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.8",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Antonio Gil Espinosa",
|
|
6
6
|
"email": "antonio.gil.espinosa@gmail.com",
|
|
@@ -28,6 +28,12 @@
|
|
|
28
28
|
"import": "./dist/esm/collections/index.js",
|
|
29
29
|
"require": "./dist/cjs/collections/index.js",
|
|
30
30
|
"browser": "./dist/web/collections/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./browser": {
|
|
33
|
+
"types": "./dist/types/browser/index.d.ts",
|
|
34
|
+
"import": "./dist/esm/browser/index.js",
|
|
35
|
+
"require": "./dist/cjs/browser/index.js",
|
|
36
|
+
"browser": "./dist/web/browser/index.js"
|
|
31
37
|
}
|
|
32
38
|
},
|
|
33
39
|
"license": "proprietary",
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import {type Optional, type Supplier} from "../types.js";
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Submits a form via AJAX and returns a Promise that resolves to the Response object.
|
|
6
|
+
*
|
|
7
|
+
* @param {HTMLFormElement | string} selectorOrElement - The form element or selector.
|
|
8
|
+
* @return {Promise<Response>} A Promise that resolves to the Response object.
|
|
9
|
+
* @throws {Error} If the element is invalid.
|
|
10
|
+
*/
|
|
11
|
+
export async function ajaxSubmit(selectorOrElement: HTMLFormElement | string): Promise<Response> {
|
|
12
|
+
|
|
13
|
+
const form = typeof selectorOrElement === 'string'
|
|
14
|
+
? document.querySelector(selectorOrElement)
|
|
15
|
+
: selectorOrElement;
|
|
16
|
+
|
|
17
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
18
|
+
throw new Error("Invalid element.");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Crear un objeto FormData a partir del formulario
|
|
22
|
+
return await fetch(form.action, {
|
|
23
|
+
method: form.method,
|
|
24
|
+
body: new FormData(form),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
export function submitForm(
|
|
30
|
+
url: string,
|
|
31
|
+
data: Record<string, any>,
|
|
32
|
+
method: 'POST' | 'GET' = 'POST',
|
|
33
|
+
target?: '_blank' | '_self' | '_parent' | '_top'
|
|
34
|
+
): void {
|
|
35
|
+
|
|
36
|
+
const form = document.createElement('form');
|
|
37
|
+
form.method = method.toUpperCase();
|
|
38
|
+
form.action = url;
|
|
39
|
+
form.style.display = 'none';
|
|
40
|
+
|
|
41
|
+
if (target) {
|
|
42
|
+
form.target = target;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Recursively appends inputs to the form, supporting nested keys and arrays.
|
|
47
|
+
* @param keyPrefix - Key path, e.g., 'user[name]' or 'tags[]'
|
|
48
|
+
* @param value - The value to append (can be nested)
|
|
49
|
+
*/
|
|
50
|
+
const appendInputs = (keyPrefix: string, value: any) => {
|
|
51
|
+
if (Array.isArray(value)) {
|
|
52
|
+
value.forEach(val => {
|
|
53
|
+
appendInputs(`${keyPrefix}[]`, val);
|
|
54
|
+
});
|
|
55
|
+
} else if (typeof value === 'object' && value !== null) {
|
|
56
|
+
for (const subKey in value) {
|
|
57
|
+
if (value.hasOwnProperty(subKey)) {
|
|
58
|
+
appendInputs(`${keyPrefix}[${subKey}]`, value[subKey]);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else {
|
|
62
|
+
const input = document.createElement('input');
|
|
63
|
+
input.type = 'hidden';
|
|
64
|
+
input.name = keyPrefix;
|
|
65
|
+
input.value = String(value);
|
|
66
|
+
form.appendChild(input);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
for (const key in data) {
|
|
71
|
+
if (data.hasOwnProperty(key)) {
|
|
72
|
+
appendInputs(key, data[key]);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
document.body.appendChild(form);
|
|
77
|
+
form.submit();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export function formToObject(form: HTMLFormElement): Record<string, FormDataEntryValue | FormDataEntryValue[]> {
|
|
81
|
+
const fd = new FormData(form);
|
|
82
|
+
const out: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};
|
|
83
|
+
|
|
84
|
+
for (const [key, value] of fd.entries()) {
|
|
85
|
+
if (key in out) {
|
|
86
|
+
const current = out[key];
|
|
87
|
+
if (Array.isArray(current)) {
|
|
88
|
+
current.push(value);
|
|
89
|
+
} else {
|
|
90
|
+
out[key] = [current, value];
|
|
91
|
+
}
|
|
92
|
+
} else {
|
|
93
|
+
out[key] = value;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Converts an object to `FormData` format recursively.
|
|
102
|
+
*
|
|
103
|
+
* @param {Record<string, any>} data - The object data to convert.
|
|
104
|
+
* @param {FormData} formData - The `FormData` instance to append data to.
|
|
105
|
+
* @param {string} parentKey - The parent key to append to child keys in the `FormData`.
|
|
106
|
+
* @returns {FormData} - The `FormData` instance with the converted data.
|
|
107
|
+
*/
|
|
108
|
+
function _objectToFormData(data: Record<string, any>, formData: FormData, parentKey: string = ''): FormData {
|
|
109
|
+
|
|
110
|
+
for (const key in data) {
|
|
111
|
+
if (data.hasOwnProperty(key)) {
|
|
112
|
+
const value = data[key];
|
|
113
|
+
|
|
114
|
+
if (value instanceof Date) {
|
|
115
|
+
formData.append(parentKey ? `${parentKey}[${key}]` : key, value.toISOString());
|
|
116
|
+
} else if (value instanceof File) {
|
|
117
|
+
formData.append(parentKey ? `${parentKey}[${key}]` : key, value);
|
|
118
|
+
} else if (typeof value === 'object' && !Array.isArray(value)) {
|
|
119
|
+
_objectToFormData(value, formData, parentKey ? `${parentKey}[${key}]` : key);
|
|
120
|
+
} else if (Array.isArray(value)) {
|
|
121
|
+
value.forEach((item, index) => {
|
|
122
|
+
const arrayKey = `${parentKey ? `${parentKey}[${key}]` : key}[${index}]`;
|
|
123
|
+
if (typeof item === 'object' && !Array.isArray(item)) {
|
|
124
|
+
_objectToFormData(item, formData, arrayKey);
|
|
125
|
+
} else {
|
|
126
|
+
formData.append(arrayKey, item);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
} else {
|
|
130
|
+
formData.append(parentKey ? `${parentKey}[${key}]` : key, value);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
return formData;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Converts an object into FormData.
|
|
140
|
+
*
|
|
141
|
+
* @param {Record<string, any>} data - The object to be converted into FormData.
|
|
142
|
+
* @return {FormData} - The FormData object representing the converted data.
|
|
143
|
+
*/
|
|
144
|
+
export function objectToFormData(data: Record<string, any>): FormData {
|
|
145
|
+
let formData = new FormData();
|
|
146
|
+
return _objectToFormData(data, formData);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export function ajaxSubmission(selectorOrElement: HTMLFormElement | string,
|
|
150
|
+
onSuccess: Optional<Supplier<any>> = undefined,
|
|
151
|
+
onFailure: Optional<Supplier<any>> = undefined): void {
|
|
152
|
+
|
|
153
|
+
const form = typeof selectorOrElement === 'string'
|
|
154
|
+
? document.querySelector(selectorOrElement)
|
|
155
|
+
: selectorOrElement;
|
|
156
|
+
|
|
157
|
+
if (!(form instanceof HTMLFormElement)) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
form.addEventListener('submit', async (event) => {
|
|
162
|
+
event.preventDefault();
|
|
163
|
+
let promise = ajaxSubmit(form);
|
|
164
|
+
if (promise) {
|
|
165
|
+
if (onSuccess)
|
|
166
|
+
promise = promise.then(onSuccess);
|
|
167
|
+
if (onFailure)
|
|
168
|
+
promise.catch(onFailure);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
}
|
|
@@ -19,7 +19,7 @@ export interface GeoLocationOptions {
|
|
|
19
19
|
|
|
20
20
|
// ─── Función ─────────────────────────────────────────────
|
|
21
21
|
|
|
22
|
-
export async function getGeoLocation(options: GeoLocationOptions = {}): Promise<GeoLocation> {
|
|
22
|
+
export default async function getGeoLocation(options: GeoLocationOptions = {}): Promise<GeoLocation> {
|
|
23
23
|
|
|
24
24
|
// ── Soporte del navegador ────────────────────────────
|
|
25
25
|
if (!navigator.geolocation) {
|
package/src/browser/index.ts
CHANGED
|
@@ -1,176 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './form-utilities.js'
|
|
2
2
|
|
|
3
|
+
export {default as NativeBridge} from "./native-bridge.js"
|
|
3
4
|
|
|
4
|
-
|
|
5
|
-
export function submitForm(
|
|
6
|
-
url: string,
|
|
7
|
-
data: Record<string, any>,
|
|
8
|
-
method: 'POST' | 'GET' = 'POST',
|
|
9
|
-
target?: '_blank' | '_self' | '_parent' | '_top'
|
|
10
|
-
): void {
|
|
11
|
-
|
|
12
|
-
const form = document.createElement('form');
|
|
13
|
-
form.method = method.toUpperCase();
|
|
14
|
-
form.action = url;
|
|
15
|
-
form.style.display = 'none';
|
|
16
|
-
|
|
17
|
-
if (target) {
|
|
18
|
-
form.target = target;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Recursively appends inputs to the form, supporting nested keys and arrays.
|
|
23
|
-
* @param keyPrefix - Key path, e.g., 'user[name]' or 'tags[]'
|
|
24
|
-
* @param value - The value to append (can be nested)
|
|
25
|
-
*/
|
|
26
|
-
const appendInputs = (keyPrefix: string, value: any) => {
|
|
27
|
-
if (Array.isArray(value)) {
|
|
28
|
-
value.forEach(val => {
|
|
29
|
-
appendInputs(`${keyPrefix}[]`, val);
|
|
30
|
-
});
|
|
31
|
-
} else if (typeof value === 'object' && value !== null) {
|
|
32
|
-
for (const subKey in value) {
|
|
33
|
-
if (value.hasOwnProperty(subKey)) {
|
|
34
|
-
appendInputs(`${keyPrefix}[${subKey}]`, value[subKey]);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
const input = document.createElement('input');
|
|
39
|
-
input.type = 'hidden';
|
|
40
|
-
input.name = keyPrefix;
|
|
41
|
-
input.value = String(value);
|
|
42
|
-
form.appendChild(input);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
for (const key in data) {
|
|
47
|
-
if (data.hasOwnProperty(key)) {
|
|
48
|
-
appendInputs(key, data[key]);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
document.body.appendChild(form);
|
|
53
|
-
form.submit();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function formToObject(form: HTMLFormElement): Record<string, FormDataEntryValue | FormDataEntryValue[]> {
|
|
57
|
-
const fd = new FormData(form);
|
|
58
|
-
const out: Record<string, FormDataEntryValue | FormDataEntryValue[]> = {};
|
|
59
|
-
|
|
60
|
-
for (const [key, value] of fd.entries()) {
|
|
61
|
-
if (key in out) {
|
|
62
|
-
const current = out[key];
|
|
63
|
-
if (Array.isArray(current)) {
|
|
64
|
-
current.push(value);
|
|
65
|
-
} else {
|
|
66
|
-
out[key] = [current, value];
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
out[key] = value;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return out;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Converts an object to `FormData` format recursively.
|
|
78
|
-
*
|
|
79
|
-
* @param {Record<string, any>} data - The object data to convert.
|
|
80
|
-
* @param {FormData} formData - The `FormData` instance to append data to.
|
|
81
|
-
* @param {string} parentKey - The parent key to append to child keys in the `FormData`.
|
|
82
|
-
* @returns {FormData} - The `FormData` instance with the converted data.
|
|
83
|
-
*/
|
|
84
|
-
function _objectToFormData(data: Record<string, any>, formData: FormData, parentKey: string = ''): FormData {
|
|
85
|
-
|
|
86
|
-
for (const key in data) {
|
|
87
|
-
if (data.hasOwnProperty(key)) {
|
|
88
|
-
const value = data[key];
|
|
89
|
-
|
|
90
|
-
if (value instanceof Date) {
|
|
91
|
-
formData.append(parentKey ? `${parentKey}[${key}]` : key, value.toISOString());
|
|
92
|
-
} else if (value instanceof File) {
|
|
93
|
-
formData.append(parentKey ? `${parentKey}[${key}]` : key, value);
|
|
94
|
-
} else if (typeof value === 'object' && !Array.isArray(value)) {
|
|
95
|
-
_objectToFormData(value, formData, parentKey ? `${parentKey}[${key}]` : key);
|
|
96
|
-
} else if (Array.isArray(value)) {
|
|
97
|
-
value.forEach((item, index) => {
|
|
98
|
-
const arrayKey = `${parentKey ? `${parentKey}[${key}]` : key}[${index}]`;
|
|
99
|
-
if (typeof item === 'object' && !Array.isArray(item)) {
|
|
100
|
-
_objectToFormData(item, formData, arrayKey);
|
|
101
|
-
} else {
|
|
102
|
-
formData.append(arrayKey, item);
|
|
103
|
-
}
|
|
104
|
-
});
|
|
105
|
-
} else {
|
|
106
|
-
formData.append(parentKey ? `${parentKey}[${key}]` : key, value);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return formData;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Converts an object into FormData.
|
|
116
|
-
*
|
|
117
|
-
* @param {Record<string, any>} data - The object to be converted into FormData.
|
|
118
|
-
* @return {FormData} - The FormData object representing the converted data.
|
|
119
|
-
*/
|
|
120
|
-
export function objectToFormData(data: Record<string, any>): FormData {
|
|
121
|
-
let formData = new FormData();
|
|
122
|
-
return _objectToFormData(data, formData);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export function ajaxSubmission(selectorOrElement: HTMLFormElement | string,
|
|
126
|
-
onSuccess: Optional<Supplier<any>> = undefined,
|
|
127
|
-
onFailure: Optional<Supplier<any>> = undefined): void {
|
|
128
|
-
|
|
129
|
-
const form = typeof selectorOrElement === 'string'
|
|
130
|
-
? document.querySelector(selectorOrElement)
|
|
131
|
-
: selectorOrElement;
|
|
132
|
-
|
|
133
|
-
if (!(form instanceof HTMLFormElement)) {
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
form.addEventListener('submit', async (event) => {
|
|
138
|
-
event.preventDefault();
|
|
139
|
-
let promise = ajaxSubmit(form);
|
|
140
|
-
if (promise) {
|
|
141
|
-
if (onSuccess)
|
|
142
|
-
promise = promise.then(onSuccess);
|
|
143
|
-
if (onFailure)
|
|
144
|
-
promise.catch(onFailure);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Submits a form via AJAX and returns a Promise that resolves to the Response object.
|
|
154
|
-
*
|
|
155
|
-
* @param {HTMLFormElement | string} selectorOrElement - The form element or selector.
|
|
156
|
-
* @return {Promise<Response>} A Promise that resolves to the Response object.
|
|
157
|
-
* @throws {Error} If the element is invalid.
|
|
158
|
-
*/
|
|
159
|
-
export async function ajaxSubmit(selectorOrElement: HTMLFormElement | string): Promise<Response> {
|
|
160
|
-
|
|
161
|
-
const form = typeof selectorOrElement === 'string'
|
|
162
|
-
? document.querySelector(selectorOrElement)
|
|
163
|
-
: selectorOrElement;
|
|
164
|
-
|
|
165
|
-
if (!(form instanceof HTMLFormElement)) {
|
|
166
|
-
throw new Error("Invalid element.");
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
// Crear un objeto FormData a partir del formulario
|
|
170
|
-
return await fetch(form.action, {
|
|
171
|
-
method: form.method,
|
|
172
|
-
body: new FormData(form),
|
|
173
|
-
});
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
export * from './gps.js';
|
|
5
|
+
export {default as getGeoLocation} from './geo-location.js';
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// ─── Tipos ───────────────────────────────────────────────
|
|
2
|
+
interface BridgeOptions {
|
|
3
|
+
channel: Channel;
|
|
4
|
+
timeout?: number | null;
|
|
5
|
+
callbackName?: string; // ← nuevo
|
|
6
|
+
}
|
|
7
|
+
interface PendingCall {
|
|
8
|
+
resolve: (value: unknown) => void;
|
|
9
|
+
reject: (reason: Error) => void;
|
|
10
|
+
timer: ReturnType<typeof setTimeout> | null;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
interface Channel {
|
|
14
|
+
postMessage: (message: string) => void;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
// ─── Clase ──────────────────────────────────────────────
|
|
20
|
+
|
|
21
|
+
export default class NativeBridge {
|
|
22
|
+
private _pending = new Map<number, PendingCall>();
|
|
23
|
+
private _callId = 0;
|
|
24
|
+
private readonly _defaultTimeout: number | null;
|
|
25
|
+
private readonly _channel: Channel;
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
constructor({ channel, timeout = 3000, callbackName = '__nativeResponseHandler' }: BridgeOptions) {
|
|
29
|
+
this._defaultTimeout = timeout;
|
|
30
|
+
this._channel = channel;
|
|
31
|
+
|
|
32
|
+
if (!this._channel) {
|
|
33
|
+
throw new Error('Channel not found');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
(window as any)[callbackName] = this._callback;
|
|
37
|
+
|
|
38
|
+
// Proxy: cualquier propiedad no existente se convierte en call()
|
|
39
|
+
return new Proxy(this, {
|
|
40
|
+
get(target: NativeBridge, prop: string | symbol) {
|
|
41
|
+
if (prop in target) {
|
|
42
|
+
return (target as any)[prop];
|
|
43
|
+
}
|
|
44
|
+
return (data?: unknown, timeout?: number | null) => target.call(String(prop), data, timeout);
|
|
45
|
+
},
|
|
46
|
+
}) as unknown as NativeBridge;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
private _callback(id: number, error: any, result: any) {
|
|
51
|
+
|
|
52
|
+
const pending = this._pending.get(id);
|
|
53
|
+
if (!pending) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (pending.timer !== null) {
|
|
58
|
+
clearTimeout(pending.timer);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
this._pending.delete(id);
|
|
62
|
+
|
|
63
|
+
if (error) {
|
|
64
|
+
pending.reject(error instanceof Error? error : new Error(String(error)));
|
|
65
|
+
} else {
|
|
66
|
+
pending.resolve(result);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
call(method: string, data: unknown = null, timeout?: number | null): Promise<unknown> {
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
const effectiveTimeout = timeout !== undefined ? timeout : this._defaultTimeout;
|
|
74
|
+
|
|
75
|
+
return new Promise<unknown>((resolve, reject) => {
|
|
76
|
+
const id = this._callId++;
|
|
77
|
+
|
|
78
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
79
|
+
|
|
80
|
+
// Solo crear timer si hay timeout
|
|
81
|
+
if (effectiveTimeout !== null && effectiveTimeout > 0) {
|
|
82
|
+
timer = setTimeout(() => {
|
|
83
|
+
this._pending.delete(id);
|
|
84
|
+
reject(new Error(`Timeout (${effectiveTimeout}ms): ${method}`));
|
|
85
|
+
}, effectiveTimeout);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
this._pending.set(id, { resolve, reject, timer });
|
|
89
|
+
this._channel!.postMessage(JSON.stringify({ id, method, data }));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
send(method: string, data: unknown = null): void {
|
|
95
|
+
this._channel!.postMessage(JSON.stringify({ method, data }));
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Número de llamadas pendientes
|
|
100
|
+
*/
|
|
101
|
+
get pendingCount(): number {
|
|
102
|
+
return this._pending.size;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Cancela todas las llamadas pendientes
|
|
107
|
+
*/
|
|
108
|
+
cancelAll(): void {
|
|
109
|
+
for (const [, { reject, timer }] of this._pending) {
|
|
110
|
+
if (timer !== null) {
|
|
111
|
+
clearTimeout(timer);
|
|
112
|
+
}
|
|
113
|
+
reject(new Error('Cancelled'));
|
|
114
|
+
}
|
|
115
|
+
this._pending.clear();
|
|
116
|
+
}
|
|
117
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -27,7 +27,7 @@ export {default as from, From} from './from.js';
|
|
|
27
27
|
// ─── Web ─────────────────────────────────────────────
|
|
28
28
|
export {default as CleanURLSearchParams} from './clean-url-search-params.js';
|
|
29
29
|
/** @deprecated */
|
|
30
|
-
export
|
|
30
|
+
export { ajaxSubmit, ajaxSubmission, submitForm , formToObject} from './browser/index.js';
|
|
31
31
|
|
|
32
32
|
// ─── Deprecated ──────────────────────────────────────
|
|
33
33
|
/** @deprecated */
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"gps.js","sourceRoot":"","sources":["../../../src/browser/gps.ts"],"names":[],"mappings":";;AAqBA,wCA0DC;AA1DM,KAAK,UAAU,cAAc,CAAC,UAA8B,EAAE;IAGjE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;IAChE,CAAC;IAGD,IAAI,SAAS,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,UAAU,GAAG,MAAM,SAAS,CAAC,WAAW,CAAC,KAAK,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;QAE9E,IAAI,UAAU,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;YAChC,MAAM,IAAI,KAAK,CACX,4EAA4E,CAC/E,CAAC;QACN,CAAC;IACL,CAAC;IAGD,M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