@mac-bug-screenshot/native-host 1.0.11 → 1.0.13

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 CHANGED
@@ -11,7 +11,7 @@ npm install -g @mac-bug-screenshot/native-host
11
11
  ## 등록
12
12
 
13
13
  ```bash
14
- mac-bug-screenshot-install <확장_프로그램_ID>
14
+ mac-bug-screenshot-install
15
15
  ```
16
16
 
17
17
  ## 동작
@@ -22,13 +22,13 @@ mac-bug-screenshot-install <확장_프로그램_ID>
22
22
  ## 게시 정보
23
23
 
24
24
  - npm 패키지: https://www.npmjs.com/package/@mac-bug-screenshot/native-host
25
- - 현재 버전: 1.0.10
25
+ - 현재 버전: 1.0.11
26
26
 
27
27
  ## 문제 해결
28
28
 
29
29
  - `Native host has exited` 오류가 뜨면 최신 버전으로 업데이트 후 재등록하세요.
30
30
  ```bash
31
31
  npm install -g @mac-bug-screenshot/native-host@latest
32
- mac-bug-screenshot-install <확장_프로그램_ID>
32
+ mac-bug-screenshot-install
33
33
  ```
34
34
  - nvm 사용 시에도 `npm root -g` 기준 경로로 자동 설정됩니다.
package/bin/install.js CHANGED
@@ -19,21 +19,9 @@ const TARGET_DIR = path.join(
19
19
  );
20
20
  const TARGET_PATH = path.join(TARGET_DIR, `${HOST_NAME}.json`);
21
21
 
22
- function printUsage() {
23
- console.log("사용법: mac-bug-screenshot-install <확장_프로그램_ID>");
24
- }
25
-
26
22
  function main() {
27
- const extensionId = process.argv[2];
28
- if (!extensionId) {
29
- printUsage();
30
- process.exit(1);
31
- }
32
-
33
23
  const template = fs.readFileSync(TEMPLATE_PATH, "utf8");
34
- const manifest = template
35
- .replace(/__HOST_PATH__/g, WRAPPER_PATH)
36
- .replace(/__EXTENSION_ID__/g, extensionId);
24
+ const manifest = template.replace(/__HOST_PATH__/g, WRAPPER_PATH);
37
25
 
38
26
  if (!fs.existsSync(HOST_PATH)) {
39
27
  console.error("host.js를 찾을 수 없습니다:", HOST_PATH);
package/host.js CHANGED
@@ -68,6 +68,29 @@ function runAppleScript(script) {
68
68
  });
69
69
  }
70
70
 
71
+ async function openInPreview(filePath) {
72
+ const script = [
73
+ 'tell application "Preview"',
74
+ "activate",
75
+ `open POSIX file "${filePath}"`,
76
+ "end tell"
77
+ ].join("\n");
78
+
79
+ try {
80
+ await runAppleScript(script);
81
+ return;
82
+ } catch (error) {
83
+ // fallback to open command below
84
+ }
85
+
86
+ try {
87
+ await runCommandDetailed("open", ["-a", "Preview", filePath]);
88
+ } catch (error) {
89
+ await sleep(300);
90
+ await runCommandDetailed("open", ["-n", "-a", "Preview", filePath]);
91
+ }
92
+ }
93
+
71
94
  async function setPreviewActualSize() {
72
95
  const script = [
73
96
  'tell application "Preview"',
@@ -105,29 +128,27 @@ async function readImageSize(filePath) {
105
128
  }
106
129
  }
107
130
 
108
- async function capture(outputDir) {
131
+ async function capture(outputDir, mode = "region") {
109
132
  const resolvedDir = expandHome(outputDir || DEFAULT_OUTPUT_DIR);
110
133
  const timestamp = new Date().toISOString().replace(/[:.]/g, "-");
111
134
  const outputPath = path.join(resolvedDir, `screenshot-${timestamp}.png`);
112
135
 
113
136
  await fs.promises.mkdir(resolvedDir, { recursive: true });
114
137
  await sleep(300);
138
+ const captureArgs = mode === "full"
139
+ ? ["-x", "-t", "png", outputPath]
140
+ : ["-i", "-s", "-t", "png", outputPath];
115
141
  try {
116
- await runCommandDetailed("screencapture", ["-i", "-s", "-t", "png", outputPath]);
142
+ await runCommandDetailed("screencapture", captureArgs);
117
143
  } catch (error) {
118
144
  await sleep(300);
119
- await runCommandDetailed("screencapture", ["-i", "-s", "-t", "png", outputPath]);
145
+ await runCommandDetailed("screencapture", captureArgs);
120
146
  }
121
147
  if (!fs.existsSync(outputPath)) {
122
148
  throw new Error("캡처가 취소되었습니다.");
123
149
  }
124
150
  const dimensions = await readImageSize(outputPath);
125
- try {
126
- await runCommandDetailed("open", ["-a", "Preview", outputPath]);
127
- } catch (error) {
128
- await sleep(300);
129
- await runCommandDetailed("open", ["-a", "Preview", outputPath]);
130
- }
151
+ await openInPreview(outputPath);
131
152
  await sleep(200);
132
153
  await setPreviewActualSize();
133
154
 
@@ -179,7 +200,7 @@ async function main() {
179
200
  return;
180
201
  }
181
202
 
182
- const result = await capture(message.outputDir);
203
+ const result = await capture(message.outputDir, message.mode);
183
204
  writeMessage({ ok: true, outputPath: result.outputPath, dimensions: result.dimensions });
184
205
  } catch (error) {
185
206
  writeMessage({ ok: false, error: error.message });
@@ -3,5 +3,5 @@
3
3
  "description": "Native host for mac-bug-screenshot.",
4
4
  "path": "__HOST_PATH__",
5
5
  "type": "stdio",
6
- "allowed_origins": ["chrome-extension://__EXTENSION_ID__/"]
6
+ "allowed_origins": ["chrome-extension://jmdcdaafmahlbhncekhfhlncfgkjoogb/"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mac-bug-screenshot/native-host",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Native messaging host for Mac Bug Screenshot.",
5
5
  "bin": {
6
6
  "mac-bug-screenshot-install": "bin/install.js"