@forge-kit/plugin-source-map-prase 0.0.3 → 0.0.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.
package/dist/node.js CHANGED
@@ -3,6 +3,11 @@ const node_perf_hooks = require("node:perf_hooks");
3
3
  const promises = require("node:fs/promises");
4
4
  const node_path = require("node:path");
5
5
  const node_os = require("node:os");
6
+ var PluginOriginType;
7
+ (function(PluginOriginType2) {
8
+ PluginOriginType2["Local"] = "local";
9
+ PluginOriginType2["Remote"] = "remote";
10
+ })(PluginOriginType || (PluginOriginType = {}));
6
11
  var InvokeType;
7
12
  (function(InvokeType2) {
8
13
  InvokeType2["invoke"] = "invoke";
@@ -59,7 +64,7 @@ function isFunction(value) {
59
64
  }
60
65
  const defineInvokeMethod = (methods) => methods;
61
66
  const registerInvokeMethod = (methods) => {
62
- if (!process.send)
67
+ if (!process?.send || !process.on)
63
68
  return;
64
69
  const reply = (response) => process.send?.(response);
65
70
  process.on("message", async (message) => {
@@ -77,15 +82,6 @@ const registerInvokeMethod = (methods) => {
77
82
  }
78
83
  });
79
84
  };
80
- typeof SuppressedError === "function" ? SuppressedError : function(error, suppressed, message) {
81
- var e = new Error(message);
82
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
83
- };
84
- var PluginOriginType;
85
- (function(PluginOriginType2) {
86
- PluginOriginType2["Local"] = "local";
87
- PluginOriginType2["Remote"] = "remote";
88
- })(PluginOriginType || (PluginOriginType = {}));
89
85
  const MAX_TRACE_DEPTH = 20;
90
86
  const DEFAULT_CONTEXT_LINE_RADIUS$1 = 3;
91
87
  const normalizePath = (input) => input.replace(/\\/g, "/").trim();
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  ],
12
12
  "author": "yu.pan <panyupy@vip.qq.com>",
13
13
  "license": "MIT",
14
- "version": "0.0.3",
14
+ "version": "0.0.4",
15
15
  "type": "module",
16
16
  "scripts": {
17
17
  "dev": "vite",
@@ -23,10 +23,10 @@
23
23
  "@dnd-kit/core": "^6.3.1",
24
24
  "@dnd-kit/sortable": "^10.0.0",
25
25
  "@dnd-kit/utilities": "^3.2.2",
26
+ "@forge-kit/bridge-client": "workspace:*",
26
27
  "@forge-kit/component": "workspace:*",
27
28
  "@forge-kit/icons": "workspace:*",
28
29
  "@forge-kit/helper": "workspace:*",
29
- "@forge-kit/node-sdk": "workspace:*",
30
30
  "classnames": "^2.5.1",
31
31
  "react": "^19.2.0",
32
32
  "react-dom": "^19.2.0",
package/src/App.tsx CHANGED
@@ -4,8 +4,8 @@ import {CodeHighlight} from "@/components/code-highlight";
4
4
  import {MapInputPanel} from "@/components/map-input-panel";
5
5
  import {PanelCard} from "@/components/panel-card";
6
6
  import {TraceChain} from "@/components/trace-chain";
7
+ import {applyNodeMethod, canIUse} from "@forge-kit/bridge-client";
7
8
  import type {
8
- ForgeKitBridge,
9
9
  MapInputConfig,
10
10
  ResolveTraceMetaOutput,
11
11
  ResolveTraceSnippetOutput,
@@ -92,13 +92,11 @@ export const App: React.FC<AppProps> = (props) => {
92
92
 
93
93
  if (!validated.ok) return setOutputMessage(validated.message)
94
94
 
95
- const applyNodeMethod = (window as Window & { forgeKit?: ForgeKitBridge }).forgeKit?.applyNodeMethod
96
-
97
95
  const mapFilePaths = chainState.chainMapSlots
98
96
  .map((slot) => slot.mapFilePath)
99
97
  .filter((path): path is string => Boolean(path))
100
98
 
101
- if (!applyNodeMethod) return setOutputMessage("Node bridge 不可用,无法执行解析。")
99
+ if (!canIUse('applyNodeMethod')) return setOutputMessage("Node bridge 不可用,无法执行解析。")
102
100
 
103
101
  if (mapFilePaths.length === 0) return setOutputMessage("未提供 map 文件路径,无法在 Node 侧解析。")
104
102
 
@@ -112,7 +110,7 @@ export const App: React.FC<AppProps> = (props) => {
112
110
  }
113
111
 
114
112
  try {
115
- const nextOutput = await applyNodeMethod('resolveTrace', JSON.stringify(payload)) as ResolveTraceMetaOutput
113
+ const nextOutput = await applyNodeMethod<ResolveTraceMetaOutput>('resolveTrace', JSON.stringify(payload))
116
114
  setOutputState((prev) => ({
117
115
  ...prev,
118
116
  traceData: nextOutput.traceData || [],
@@ -122,7 +120,7 @@ export const App: React.FC<AppProps> = (props) => {
122
120
  }))
123
121
  if (nextOutput?.resolvedSourceMeta) {
124
122
  try {
125
- const snippet = await applyNodeMethod('getSourceSnippet', JSON.stringify(payload)) as ResolveTraceSnippetOutput
123
+ const snippet = await applyNodeMethod<ResolveTraceSnippetOutput>('getSourceSnippet', JSON.stringify(payload))
126
124
  setOutputState((prev) => ({...prev, ...snippet}))
127
125
  } catch (error) {
128
126
  const message = error instanceof Error ? error.message : String(error)
@@ -1,7 +1,8 @@
1
1
  import * as React from "react";
2
2
  import {Box, Button, Flex, Text, TextField} from "@forge-kit/component";
3
+ import {canIUse, openFileDialog} from "@forge-kit/bridge-client";
3
4
  import {PanelCard} from "@/components/panel-card";
4
- import type {ForgeKitBridge, MapInputConfig} from "@/types";
5
+ import type {MapInputConfig} from "@/types";
5
6
  import {noop} from "@/utils";
6
7
  import classNames from "classnames";
7
8
  import "./index.less";
@@ -52,8 +53,7 @@ export const MapInputPanel: React.FC<MapInputPanelProps> = (props) => {
52
53
  } = props
53
54
 
54
55
  const openFilePicker = async () => {
55
- const openFileDialog = (window as Window & {forgeKit?: ForgeKitBridge}).forgeKit?.openFileDialog
56
- if (!openFileDialog) return
56
+ if (!canIUse('openFileDialog')) return
57
57
 
58
58
  const selected = await openFileDialog({
59
59
  multiple: true,
package/src/node/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {defineInvokeMethod, registerInvokeMethod} from "@forge-kit/node-sdk";
1
+ import {defineInvokeMethod, registerInvokeMethod} from "@forge-kit/helper";
2
2
  import {getSourceSnippet, profileResolveTracePhases, resolveTrace} from "./trace/resolve";
3
3
 
4
4
  const invokeMethod = defineInvokeMethod({resolveTrace, getSourceSnippet, profileResolveTracePhases})
package/src/types.ts CHANGED
@@ -9,11 +9,3 @@ export interface MapInputConfig {
9
9
  entryColumn: string
10
10
  contextLineRadius: string
11
11
  }
12
-
13
- export interface ForgeKitBridge {
14
- applyNodeMethod?: (method: string, ...args: string[]) => Promise<unknown>
15
- openFileDialog?: (options: {
16
- multiple?: boolean
17
- filters?: {name: string; extensions: string[]}[]
18
- }) => Promise<string | string[] | null>
19
- }