peakflow-api 0.0.5 → 0.0.7
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/AGENTS.md +1 -0
- package/CHANGELOG.md +5 -0
- package/package.json +1 -1
- package/src/bug-reporting/index.js +16 -5
package/AGENTS.md
CHANGED
|
@@ -24,6 +24,7 @@ This repo hosts the Peakflow JavaScript client for error reporting across browse
|
|
|
24
24
|
- Avoid adding global browser dependencies unless guarded by runtime checks.
|
|
25
25
|
- When changing API exports, update `README.md` examples.
|
|
26
26
|
- `.js` files should always have JSDoc comments to keep TypeScript checks happy.
|
|
27
|
+
- Keep single-line JSDoc comments on a single line.
|
|
27
28
|
- Use `gh` to open pull requests when requested.
|
|
28
29
|
- Keep JSDoc accurate; TypeScript checks JS via `checkJs`.
|
|
29
30
|
- Ensure new browser-only logic is opt-in and documented.
|
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
- Fix: avoid bundlers resolving Node-only modules in bug-reporting node transport by using runtime-only imports.
|
|
3
|
+
- Chore: keep single-line JSDoc comments on a single line and document the convention.
|
|
4
|
+
- Fix: defer runtime import helper creation to avoid CSP unsafe-eval during browser module load.
|
|
5
|
+
- Fix: build Node module specifiers dynamically to avoid Expo bundler resolution errors.
|
package/package.json
CHANGED
|
@@ -229,9 +229,7 @@ export default class BugReporting {
|
|
|
229
229
|
return true
|
|
230
230
|
}
|
|
231
231
|
|
|
232
|
-
/**
|
|
233
|
-
* Wire Node.js uncaught error handlers.
|
|
234
|
-
*/
|
|
232
|
+
/** Wire Node.js uncaught error handlers. */
|
|
235
233
|
connectNodeUncaughtException() {
|
|
236
234
|
globalThis.process.on("uncaughtException", async (error) => {
|
|
237
235
|
debuggerInstance.debug(`Uncaught exception: ${error?.message || error}`)
|
|
@@ -440,8 +438,21 @@ export default class BugReporting {
|
|
|
440
438
|
* @returns {Promise<string|null>}
|
|
441
439
|
*/
|
|
442
440
|
async sendNodeRequest(postUrl, body) {
|
|
443
|
-
|
|
444
|
-
const
|
|
441
|
+
/** @type {(specifier: string) => Promise<unknown>} */
|
|
442
|
+
const runtimeImport = (specifier) => {
|
|
443
|
+
const loader = new Function("specifier", "return import(specifier)")
|
|
444
|
+
return loader(specifier)
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
const httpsSpecifier = ["node", "https"].join(":")
|
|
448
|
+
const urlSpecifier = ["node", "url"].join(":")
|
|
449
|
+
|
|
450
|
+
const {request} = /** @type {{request: typeof import("node:https").request}} */ (
|
|
451
|
+
await runtimeImport(httpsSpecifier)
|
|
452
|
+
)
|
|
453
|
+
const {URL} = /** @type {{URL: typeof import("node:url").URL}} */ (
|
|
454
|
+
await runtimeImport(urlSpecifier)
|
|
455
|
+
)
|
|
445
456
|
|
|
446
457
|
return await new Promise((resolve) => {
|
|
447
458
|
const url = new URL(postUrl)
|