@kylincloud/flamegraph 0.36.3 → 0.36.4

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 +1 @@
1
- {"version":3,"file":"createFlamegraphRenderWorker.d.ts","sourceRoot":"","sources":["../../src/workers/createFlamegraphRenderWorker.ts"],"names":[],"mappings":"AAAA,wBAAgB,4BAA4B,IAAI,MAAM,CAsCrD"}
1
+ {"version":3,"file":"createFlamegraphRenderWorker.d.ts","sourceRoot":"","sources":["../../src/workers/createFlamegraphRenderWorker.ts"],"names":[],"mappings":"AAEA,wBAAgB,4BAA4B,IAAI,MAAM,CAiDrD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kylincloud/flamegraph",
3
- "version": "0.36.3",
3
+ "version": "0.36.4",
4
4
  "description": "KylinCloud flamegraph renderer (Pyroscope-based)",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/index.node.cjs.js",
package/src/globals.d.ts CHANGED
@@ -11,3 +11,7 @@ declare module '*.svg' {
11
11
  >;
12
12
  export default ReactComponent;
13
13
  }
14
+
15
+ declare module 'virtual:flamegraph-worker' {
16
+ export const inlineWorkerCode: string;
17
+ }
@@ -1,4 +1,17 @@
1
+ import { inlineWorkerCode } from 'virtual:flamegraph-worker'
2
+
1
3
  export function createFlamegraphRenderWorker(): Worker {
4
+ if (inlineWorkerCode && inlineWorkerCode.trim().length > 0) {
5
+ try {
6
+ const blob = new Blob([inlineWorkerCode], { type: 'text/javascript' })
7
+ const url = URL.createObjectURL(blob)
8
+ const worker = new Worker(url, { type: 'module' })
9
+ URL.revokeObjectURL(url)
10
+ return worker
11
+ } catch (err) {
12
+ console.warn('[flamegraph] inline worker failed, fallback to URL worker', err)
13
+ }
14
+ }
2
15
  const metaUrl = new URL(import.meta.url);
3
16
  const pathname = metaUrl.pathname;
4
17
  const isFromSrc = pathname.includes('/src/');