peakflow-api 0.0.5 → 0.0.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/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,4 @@
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "peakflow-api",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "type": "module",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -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,18 @@ export default class BugReporting {
440
438
  * @returns {Promise<string|null>}
441
439
  */
442
440
  async sendNodeRequest(postUrl, body) {
443
- const {request} = await import("node:https")
444
- const {URL} = await import("node:url")
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 {request} = /** @type {{request: typeof import("node:https").request}} */ (
448
+ await runtimeImport("node:https")
449
+ )
450
+ const {URL} = /** @type {{URL: typeof import("node:url").URL}} */ (
451
+ await runtimeImport("node:url")
452
+ )
445
453
 
446
454
  return await new Promise((resolve) => {
447
455
  const url = new URL(postUrl)