@oxyhq/services 5.8.4 → 5.8.6
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/README.md +2 -50
- package/lib/commonjs/core/index.js +4 -5
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/ui/context/OxyContext.js +10 -2
- package/lib/commonjs/ui/context/OxyContext.js.map +1 -1
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js +0 -1
- package/lib/commonjs/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/module/core/index.js +4 -5
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/ui/context/OxyContext.js +10 -2
- package/lib/module/ui/context/OxyContext.js.map +1 -1
- package/lib/module/ui/screens/internal/SignInPasswordStep.js +0 -1
- package/lib/module/ui/screens/internal/SignInPasswordStep.js.map +1 -1
- package/lib/typescript/core/index.d.ts.map +1 -1
- package/lib/typescript/ui/context/OxyContext.d.ts.map +1 -1
- package/lib/typescript/ui/screens/internal/SignInPasswordStep.d.ts.map +1 -1
- package/package.json +2 -3
- package/src/core/index.ts +6 -6
- package/src/ui/context/OxyContext.tsx +4 -1
- package/src/ui/screens/internal/SignInPasswordStep.tsx +0 -1
- package/lib/commonjs/utils/hermesPolyfill.js +0 -114
- package/lib/commonjs/utils/hermesPolyfill.js.map +0 -1
- package/lib/module/utils/hermesPolyfill.js +0 -106
- package/lib/module/utils/hermesPolyfill.js.map +0 -1
- package/lib/typescript/utils/hermesPolyfill.d.ts +0 -11
- package/lib/typescript/utils/hermesPolyfill.d.ts.map +0 -1
- package/src/utils/hermesPolyfill.ts +0 -104
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.safeToString = exports.safeObjectIdToString = exports.isHermes = exports.checkHermesPolyfills = void 0;
|
|
7
|
-
/**
|
|
8
|
-
* Hermes JavaScript Engine Polyfill Helper
|
|
9
|
-
*
|
|
10
|
-
* This module provides polyfills and compatibility checks for React Native apps
|
|
11
|
-
* using the Hermes JavaScript engine.
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
// Detect if we're running in Hermes
|
|
15
|
-
const isHermes = () => {
|
|
16
|
-
return typeof global !== 'undefined' && global.HermesInternal;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Check for required polyfills
|
|
20
|
-
exports.isHermes = isHermes;
|
|
21
|
-
const checkHermesPolyfills = () => {
|
|
22
|
-
if (!isHermes()) {
|
|
23
|
-
return; // Not running in Hermes, no polyfills needed
|
|
24
|
-
}
|
|
25
|
-
const missingPolyfills = [];
|
|
26
|
-
|
|
27
|
-
// Check for FormData
|
|
28
|
-
if (typeof FormData === 'undefined') {
|
|
29
|
-
missingPolyfills.push('FormData');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check for URLSearchParams
|
|
33
|
-
if (typeof URLSearchParams === 'undefined') {
|
|
34
|
-
missingPolyfills.push('URLSearchParams');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Check for URL
|
|
38
|
-
if (typeof URL === 'undefined') {
|
|
39
|
-
missingPolyfills.push('URL');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Check for Object.prototype.toString
|
|
43
|
-
if (typeof Object.prototype.toString !== 'function') {
|
|
44
|
-
missingPolyfills.push('Object.prototype.toString');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Report missing polyfills
|
|
48
|
-
if (missingPolyfills.length > 0) {
|
|
49
|
-
console.error('[OxyHQ/Services] CRITICAL: Missing polyfills in Hermes engine:', missingPolyfills.join(', '));
|
|
50
|
-
console.error('[OxyHQ/Services] Add "import \'react-native-url-polyfill/auto\'" as the VERY FIRST line of your app entry file.');
|
|
51
|
-
console.error('[OxyHQ/Services] This is required for proper functionality in React Native with Hermes.');
|
|
52
|
-
|
|
53
|
-
// Throw a more descriptive error for debugging
|
|
54
|
-
throw new Error(`Missing required polyfills in Hermes engine: ${missingPolyfills.join(', ')}. Please add "import 'react-native-url-polyfill/auto'" at the top of your app entry file.`);
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
// Safe toString wrapper for MongoDB ObjectIds and other objects
|
|
59
|
-
exports.checkHermesPolyfills = checkHermesPolyfills;
|
|
60
|
-
const safeToString = obj => {
|
|
61
|
-
if (obj == null) {
|
|
62
|
-
return '';
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Handle MongoDB ObjectId
|
|
66
|
-
if (obj && typeof obj.toString === 'function') {
|
|
67
|
-
try {
|
|
68
|
-
return obj.toString();
|
|
69
|
-
} catch (error) {
|
|
70
|
-
console.warn('[OxyHQ/Services] toString() failed on object:', obj, error);
|
|
71
|
-
return String(obj);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// Fallback to String constructor
|
|
76
|
-
return String(obj);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// Safe ObjectId conversion
|
|
80
|
-
exports.safeToString = safeToString;
|
|
81
|
-
const safeObjectIdToString = obj => {
|
|
82
|
-
if (!obj) {
|
|
83
|
-
return '';
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// If it's already a string, return it
|
|
87
|
-
if (typeof obj === 'string') {
|
|
88
|
-
return obj;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// If it has a toString method, use it
|
|
92
|
-
if (obj && typeof obj.toString === 'function') {
|
|
93
|
-
try {
|
|
94
|
-
return obj.toString();
|
|
95
|
-
} catch (error) {
|
|
96
|
-
console.warn('[OxyHQ/Services] ObjectId toString() failed:', error);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// If it has an _id property, try to convert that
|
|
101
|
-
if (obj && obj._id) {
|
|
102
|
-
return safeObjectIdToString(obj._id);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Last resort: convert to string
|
|
106
|
-
return String(obj);
|
|
107
|
-
};
|
|
108
|
-
|
|
109
|
-
// Initialize polyfills on module load
|
|
110
|
-
exports.safeObjectIdToString = safeObjectIdToString;
|
|
111
|
-
if (typeof window !== 'undefined' || typeof global !== 'undefined') {
|
|
112
|
-
checkHermesPolyfills();
|
|
113
|
-
}
|
|
114
|
-
//# sourceMappingURL=hermesPolyfill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isHermes","global","HermesInternal","exports","checkHermesPolyfills","missingPolyfills","FormData","push","URLSearchParams","URL","Object","prototype","toString","length","console","error","join","Error","safeToString","obj","warn","String","safeObjectIdToString","_id","window"],"sourceRoot":"../../../src","sources":["utils/hermesPolyfill.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACO,MAAMA,QAAQ,GAAGA,CAAA,KAAe;EACrC,OAAO,OAAOC,MAAM,KAAK,WAAW,IAAKA,MAAM,CAASC,cAAc;AACxE,CAAC;;AAED;AAAAC,OAAA,CAAAH,QAAA,GAAAA,QAAA;AACO,MAAMI,oBAAoB,GAAGA,CAAA,KAAY;EAC9C,IAAI,CAACJ,QAAQ,CAAC,CAAC,EAAE;IACf,OAAO,CAAC;EACV;EAEA,MAAMK,gBAA0B,GAAG,EAAE;;EAErC;EACA,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACnCD,gBAAgB,CAACE,IAAI,CAAC,UAAU,CAAC;EACnC;;EAEA;EACA,IAAI,OAAOC,eAAe,KAAK,WAAW,EAAE;IAC1CH,gBAAgB,CAACE,IAAI,CAAC,iBAAiB,CAAC;EAC1C;;EAEA;EACA,IAAI,OAAOE,GAAG,KAAK,WAAW,EAAE;IAC9BJ,gBAAgB,CAACE,IAAI,CAAC,KAAK,CAAC;EAC9B;;EAEA;EACA,IAAI,OAAOG,MAAM,CAACC,SAAS,CAACC,QAAQ,KAAK,UAAU,EAAE;IACnDP,gBAAgB,CAAC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C;IACvB,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdD,OAAO,CAACM,IAAI,CAAC,8CAA8C,EAAEL,KAAK,CAAC;IACrE;EACF;;EAEA;EACA,IAAII,GAAG,IAAIA,GAAG,CAACI,GAAG,EAAE;IAClB,OAAOD,oBAAoB,CAACH,GAAG,CAACI,GAAG,CAAC;EACtC;;EAEA;EACA,OAAOF,MAAM,CAACF,GAAG,CAAC;AACpB,CAAC;;AAED;AAAAhB,OAAA,CAAAmB,oBAAA,GAAAA,oBAAA;AACA,IAAI,OAAOE,MAAM,KAAK,WAAW,IAAI,OAAOvB,MAAM,KAAK,WAAW,EAAE;EAClEG,oBAAoB,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Hermes JavaScript Engine Polyfill Helper
|
|
5
|
-
*
|
|
6
|
-
* This module provides polyfills and compatibility checks for React Native apps
|
|
7
|
-
* using the Hermes JavaScript engine.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
// Detect if we're running in Hermes
|
|
11
|
-
export const isHermes = () => {
|
|
12
|
-
return typeof global !== 'undefined' && global.HermesInternal;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// Check for required polyfills
|
|
16
|
-
export const checkHermesPolyfills = () => {
|
|
17
|
-
if (!isHermes()) {
|
|
18
|
-
return; // Not running in Hermes, no polyfills needed
|
|
19
|
-
}
|
|
20
|
-
const missingPolyfills = [];
|
|
21
|
-
|
|
22
|
-
// Check for FormData
|
|
23
|
-
if (typeof FormData === 'undefined') {
|
|
24
|
-
missingPolyfills.push('FormData');
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Check for URLSearchParams
|
|
28
|
-
if (typeof URLSearchParams === 'undefined') {
|
|
29
|
-
missingPolyfills.push('URLSearchParams');
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Check for URL
|
|
33
|
-
if (typeof URL === 'undefined') {
|
|
34
|
-
missingPolyfills.push('URL');
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Check for Object.prototype.toString
|
|
38
|
-
if (typeof Object.prototype.toString !== 'function') {
|
|
39
|
-
missingPolyfills.push('Object.prototype.toString');
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Report missing polyfills
|
|
43
|
-
if (missingPolyfills.length > 0) {
|
|
44
|
-
console.error('[OxyHQ/Services] CRITICAL: Missing polyfills in Hermes engine:', missingPolyfills.join(', '));
|
|
45
|
-
console.error('[OxyHQ/Services] Add "import \'react-native-url-polyfill/auto\'" as the VERY FIRST line of your app entry file.');
|
|
46
|
-
console.error('[OxyHQ/Services] This is required for proper functionality in React Native with Hermes.');
|
|
47
|
-
|
|
48
|
-
// Throw a more descriptive error for debugging
|
|
49
|
-
throw new Error(`Missing required polyfills in Hermes engine: ${missingPolyfills.join(', ')}. Please add "import 'react-native-url-polyfill/auto'" at the top of your app entry file.`);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
// Safe toString wrapper for MongoDB ObjectIds and other objects
|
|
54
|
-
export const safeToString = obj => {
|
|
55
|
-
if (obj == null) {
|
|
56
|
-
return '';
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Handle MongoDB ObjectId
|
|
60
|
-
if (obj && typeof obj.toString === 'function') {
|
|
61
|
-
try {
|
|
62
|
-
return obj.toString();
|
|
63
|
-
} catch (error) {
|
|
64
|
-
console.warn('[OxyHQ/Services] toString() failed on object:', obj, error);
|
|
65
|
-
return String(obj);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// Fallback to String constructor
|
|
70
|
-
return String(obj);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
// Safe ObjectId conversion
|
|
74
|
-
export const safeObjectIdToString = obj => {
|
|
75
|
-
if (!obj) {
|
|
76
|
-
return '';
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// If it's already a string, return it
|
|
80
|
-
if (typeof obj === 'string') {
|
|
81
|
-
return obj;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// If it has a toString method, use it
|
|
85
|
-
if (obj && typeof obj.toString === 'function') {
|
|
86
|
-
try {
|
|
87
|
-
return obj.toString();
|
|
88
|
-
} catch (error) {
|
|
89
|
-
console.warn('[OxyHQ/Services] ObjectId toString() failed:', error);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// If it has an _id property, try to convert that
|
|
94
|
-
if (obj && obj._id) {
|
|
95
|
-
return safeObjectIdToString(obj._id);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// Last resort: convert to string
|
|
99
|
-
return String(obj);
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// Initialize polyfills on module load
|
|
103
|
-
if (typeof window !== 'undefined' || typeof global !== 'undefined') {
|
|
104
|
-
checkHermesPolyfills();
|
|
105
|
-
}
|
|
106
|
-
//# sourceMappingURL=hermesPolyfill.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["isHermes","global","HermesInternal","checkHermesPolyfills","missingPolyfills","FormData","push","URLSearchParams","URL","Object","prototype","toString","length","console","error","join","Error","safeToString","obj","warn","String","safeObjectIdToString","_id","window"],"sourceRoot":"../../../src","sources":["utils/hermesPolyfill.ts"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA,OAAO,MAAMA,QAAQ,GAAGA,CAAA,KAAe;EACrC,OAAO,OAAOC,MAAM,KAAK,WAAW,IAAKA,MAAM,CAASC,cAAc;AACxE,CAAC;;AAED;AACA,OAAO,MAAMC,oBAAoB,GAAGA,CAAA,KAAY;EAC9C,IAAI,CAACH,QAAQ,CAAC,CAAC,EAAE;IACf,OAAO,CAAC;EACV;EAEA,MAAMI,gBAA0B,GAAG,EAAE;;EAErC;EACA,IAAI,OAAOC,QAAQ,KAAK,WAAW,EAAE;IACn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,GAAIH,GAAQ,IAAa;EACxD,IAAI,CAACA,GAAG,EAAE;IACR,OAAO,EAAE;EACX;;EAEA;EACA,IAAI,OAAOA,GAAG,KAAK,QAAQ,EAAE;IAC3B,OAAOA,GAAG;EACZ;;EAEA;EACA,IAAIA,GAAG,IAAI,OAAOA,GAAG,CAACP,QAAQ,KAAK,UAAU,EAAE;IAC7C,IAAI;MACF,OAAOO,GAAG,CAACP,QAAQ,CAAC,CAAC;IACvB,CAAC,CAAC,OAAOG,KAAK,EAAE;MACdD,OAAO,CAACM,IAAI,CAAC,8CAA8C,EAAEL,KAAK,CAAC;IACrE;EACF;;EAEA;EACA,IAAII,GAAG,IAAIA,GAAG,CAACI,GAAG,EAAE;IAClB,OAAOD,oBAAoB,CAACH,GAAG,CAACI,GAAG,CAAC;EACtC;;EAEA;EACA,OAAOF,MAAM,CAACF,GAAG,CAAC;AACpB,CAAC;;AAED;AACA,IAAI,OAAOK,MAAM,KAAK,WAAW,IAAI,OAAOtB,MAAM,KAAK,WAAW,EAAE;EAClEE,oBAAoB,CAAC,CAAC;AACxB","ignoreList":[]}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hermes JavaScript Engine Polyfill Helper
|
|
3
|
-
*
|
|
4
|
-
* This module provides polyfills and compatibility checks for React Native apps
|
|
5
|
-
* using the Hermes JavaScript engine.
|
|
6
|
-
*/
|
|
7
|
-
export declare const isHermes: () => boolean;
|
|
8
|
-
export declare const checkHermesPolyfills: () => void;
|
|
9
|
-
export declare const safeToString: (obj: any) => string;
|
|
10
|
-
export declare const safeObjectIdToString: (obj: any) => string;
|
|
11
|
-
//# sourceMappingURL=hermesPolyfill.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hermesPolyfill.d.ts","sourceRoot":"","sources":["../../../src/utils/hermesPolyfill.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,eAAO,MAAM,QAAQ,QAAO,OAE3B,CAAC;AAGF,eAAO,MAAM,oBAAoB,QAAO,IAoCvC,CAAC;AAGF,eAAO,MAAM,YAAY,GAAI,KAAK,GAAG,KAAG,MAiBvC,CAAC;AAGF,eAAO,MAAM,oBAAoB,GAAI,KAAK,GAAG,KAAG,MA0B/C,CAAC"}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hermes JavaScript Engine Polyfill Helper
|
|
3
|
-
*
|
|
4
|
-
* This module provides polyfills and compatibility checks for React Native apps
|
|
5
|
-
* using the Hermes JavaScript engine.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
// Detect if we're running in Hermes
|
|
9
|
-
export const isHermes = (): boolean => {
|
|
10
|
-
return typeof global !== 'undefined' && (global as any).HermesInternal;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// Check for required polyfills
|
|
14
|
-
export const checkHermesPolyfills = (): void => {
|
|
15
|
-
if (!isHermes()) {
|
|
16
|
-
return; // Not running in Hermes, no polyfills needed
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const missingPolyfills: string[] = [];
|
|
20
|
-
|
|
21
|
-
// Check for FormData
|
|
22
|
-
if (typeof FormData === 'undefined') {
|
|
23
|
-
missingPolyfills.push('FormData');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// Check for URLSearchParams
|
|
27
|
-
if (typeof URLSearchParams === 'undefined') {
|
|
28
|
-
missingPolyfills.push('URLSearchParams');
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Check for URL
|
|
32
|
-
if (typeof URL === 'undefined') {
|
|
33
|
-
missingPolyfills.push('URL');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Check for Object.prototype.toString
|
|
37
|
-
if (typeof Object.prototype.toString !== 'function') {
|
|
38
|
-
missingPolyfills.push('Object.prototype.toString');
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Report missing polyfills
|
|
42
|
-
if (missingPolyfills.length > 0) {
|
|
43
|
-
console.error('[OxyHQ/Services] CRITICAL: Missing polyfills in Hermes engine:', missingPolyfills.join(', '));
|
|
44
|
-
console.error('[OxyHQ/Services] Add "import \'react-native-url-polyfill/auto\'" as the VERY FIRST line of your app entry file.');
|
|
45
|
-
console.error('[OxyHQ/Services] This is required for proper functionality in React Native with Hermes.');
|
|
46
|
-
|
|
47
|
-
// Throw a more descriptive error for debugging
|
|
48
|
-
throw new Error(`Missing required polyfills in Hermes engine: ${missingPolyfills.join(', ')}. Please add "import 'react-native-url-polyfill/auto'" at the top of your app entry file.`);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
// Safe toString wrapper for MongoDB ObjectIds and other objects
|
|
53
|
-
export const safeToString = (obj: any): string => {
|
|
54
|
-
if (obj == null) {
|
|
55
|
-
return '';
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Handle MongoDB ObjectId
|
|
59
|
-
if (obj && typeof obj.toString === 'function') {
|
|
60
|
-
try {
|
|
61
|
-
return obj.toString();
|
|
62
|
-
} catch (error) {
|
|
63
|
-
console.warn('[OxyHQ/Services] toString() failed on object:', obj, error);
|
|
64
|
-
return String(obj);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Fallback to String constructor
|
|
69
|
-
return String(obj);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
// Safe ObjectId conversion
|
|
73
|
-
export const safeObjectIdToString = (obj: any): string => {
|
|
74
|
-
if (!obj) {
|
|
75
|
-
return '';
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// If it's already a string, return it
|
|
79
|
-
if (typeof obj === 'string') {
|
|
80
|
-
return obj;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// If it has a toString method, use it
|
|
84
|
-
if (obj && typeof obj.toString === 'function') {
|
|
85
|
-
try {
|
|
86
|
-
return obj.toString();
|
|
87
|
-
} catch (error) {
|
|
88
|
-
console.warn('[OxyHQ/Services] ObjectId toString() failed:', error);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// If it has an _id property, try to convert that
|
|
93
|
-
if (obj && obj._id) {
|
|
94
|
-
return safeObjectIdToString(obj._id);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Last resort: convert to string
|
|
98
|
-
return String(obj);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
// Initialize polyfills on module load
|
|
102
|
-
if (typeof window !== 'undefined' || typeof global !== 'undefined') {
|
|
103
|
-
checkHermesPolyfills();
|
|
104
|
-
}
|