key-screen-framework 1.4.1 → 1.5.1

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.
@@ -11,7 +11,8 @@ const commands = {
11
11
  remove: ['key-screen-remove', 'remove-screen.mjs'],
12
12
  sync: ['key-screen-sync', 'sync-screens.mjs'],
13
13
  'setup-arduino': ['key-screen-setup-arduino', 'setup-arduino-cli.mjs'],
14
- 'check-arduino-bundle': ['key-screen-check-arduino-bundle', 'check-arduino-bundle.mjs']
14
+ 'check-arduino-bundle': ['key-screen-check-arduino-bundle', 'check-arduino-bundle.mjs'],
15
+ 'publish-release': ['key-screen-publish-release', 'publish-release.mjs']
15
16
  }
16
17
 
17
18
  const [command, ...args] = process.argv.slice(2)
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env node
2
+ import process from 'node:process'
3
+ import { spawnSync } from 'node:child_process'
4
+ import { existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
5
+ import { tmpdir } from 'node:os'
6
+ import { basename, join, resolve } from 'node:path'
7
+ import { isDirectExecution } from './screen-script-utils.mjs'
8
+
9
+ // 빌드한 설치 파일을 설치 파일 보관소(기본 key-escape/key-installers)의 GitHub Release에 올린다.
10
+ // 태그는 `<패키지 이름>-v<버전>`이고, 같은 태그가 있으면 첨부 파일만 덮어써 Windows·Mac 빌드를 한 릴리스에 모은다.
11
+ export const DEFAULT_INSTALLERS_REPO = 'key-escape/key-installers'
12
+
13
+ const TARGET_EXTENSIONS = {
14
+ win: ['.exe'],
15
+ mac: ['.dmg']
16
+ }
17
+
18
+ function printUsage() {
19
+ console.log(`Usage: key-screen-publish-release [--target win|mac] [--prompt] [--repo <owner/name>] [--project-root <path>] [--dry-run]
20
+
21
+ 빌드 결과 폴더(build.directories.output, 기본 release/)의 설치 파일을 GitHub Release에 올립니다.
22
+ --target win이면 .exe, mac이면 .dmg만 올립니다. 생략하면 둘 다 올립니다.
23
+ --prompt 올리기 전에 게시할지 묻습니다. 터미널이 아니거나 CI에서는 묻지 않고 건너뜁니다.
24
+ --repo 올릴 저장소. 생략하면 package.json의 keyInstallers.repo, 그다음 ${DEFAULT_INSTALLERS_REPO}입니다.
25
+ --dry-run 실제로 올리지 않고 할 일만 출력합니다.
26
+
27
+ GitHub CLI(gh)가 설치되어 있고 gh auth login으로 로그인되어 있어야 합니다.`)
28
+ }
29
+
30
+ export function parsePublishArgs(argv) {
31
+ const options = { target: undefined, prompt: false, repo: undefined, projectRoot: '.', dryRun: false, help: false }
32
+ for (let index = 0; index < argv.length; index += 1) {
33
+ const token = argv[index]
34
+ const [key, inlineValue] = token.split(/=(.*)/s, 2)
35
+ const takeValue = () => {
36
+ const value = inlineValue ?? argv[++index]
37
+ if (!value || value.startsWith('--')) throw new Error(`Option ${key} requires a value.`)
38
+ return value
39
+ }
40
+ switch (key) {
41
+ case '--target':
42
+ options.target = takeValue()
43
+ if (!Object.hasOwn(TARGET_EXTENSIONS, options.target)) {
44
+ throw new Error(`--target must be one of: ${Object.keys(TARGET_EXTENSIONS).join(', ')}`)
45
+ }
46
+ break
47
+ case '--repo':
48
+ options.repo = takeValue()
49
+ break
50
+ case '--project-root':
51
+ options.projectRoot = takeValue()
52
+ break
53
+ case '--prompt':
54
+ options.prompt = true
55
+ break
56
+ case '--dry-run':
57
+ options.dryRun = true
58
+ break
59
+ case '--help':
60
+ case '-h':
61
+ options.help = true
62
+ break
63
+ default:
64
+ throw new Error(`Unknown option: ${token}`)
65
+ }
66
+ }
67
+ return options
68
+ }
69
+
70
+ export function releaseTag(manifest) {
71
+ return `${manifest.name}-v${manifest.version}`
72
+ }
73
+
74
+ export function releaseTitle(manifest) {
75
+ return `${manifest.name} ${manifest.version}`
76
+ }
77
+
78
+ /** GitHub는 첨부 파일 이름의 공백을 '.'으로 바꿔 저장한다. */
79
+ export function githubAssetName(fileName) {
80
+ return fileName.replace(/ /g, '.')
81
+ }
82
+
83
+ /** 결과 폴더에서 이번 버전의 설치 파일만 고른다. blockmap·latest.yml·이전 버전 파일은 제외한다. */
84
+ export function findInstallers(fileNames, { version, target }) {
85
+ const extensions = target ? TARGET_EXTENSIONS[target] : Object.values(TARGET_EXTENSIONS).flat()
86
+ return fileNames
87
+ .filter((name) => extensions.some((extension) => name.toLowerCase().endsWith(extension)))
88
+ .filter((name) => name.includes(version))
89
+ .sort()
90
+ }
91
+
92
+ /** git remote URL(https·ssh)에서 owner/name을 뽑는다. GitHub가 아니면 undefined. */
93
+ export function parseGitHubRepo(remoteUrl) {
94
+ const match = /github\.com[:/]([^/]+)\/([^/]+?)(?:\.git)?\/?$/.exec(remoteUrl?.trim() ?? '')
95
+ return match ? `${match[1]}/${match[2]}` : undefined
96
+ }
97
+
98
+ export function buildReleaseNotes({ manifest, sourceRepo, commit, branch, dirty, frameworkVersion, date }) {
99
+ const lines = [`${manifest.productName ?? manifest.build?.productName ?? manifest.name} ${manifest.version}`, '']
100
+ if (sourceRepo && commit) {
101
+ lines.push(`- 원본: [${sourceRepo}@${commit.slice(0, 7)}](https://github.com/${sourceRepo}/tree/${commit})${branch ? ` (${branch})` : ''}`)
102
+ } else {
103
+ lines.push(`- 원본: ${manifest.name}${branch ? ` (${branch})` : ''}`)
104
+ }
105
+ if (commit) lines.push(`- 커밋: \`${commit}\``)
106
+ if (dirty) lines.push('- ⚠️ 커밋되지 않은 변경이 있는 상태에서 빌드했습니다.')
107
+ if (frameworkVersion) lines.push(`- key-screen-framework: ${frameworkVersion}`)
108
+ lines.push(`- 빌드: ${date}`)
109
+ return `${lines.join('\n')}\n`
110
+ }
111
+
112
+ function run(command, args, cwd, { capture = true } = {}) {
113
+ const result = spawnSync(command, args, {
114
+ cwd,
115
+ encoding: 'utf8',
116
+ stdio: capture ? ['ignore', 'pipe', 'pipe'] : 'inherit'
117
+ })
118
+ return { ok: result.status === 0 && !result.error, stdout: (result.stdout ?? '').trim(), stderr: (result.stderr ?? '').trim() }
119
+ }
120
+
121
+ function readGitInfo(projectRoot) {
122
+ const commit = run('git', ['rev-parse', 'HEAD'], projectRoot)
123
+ if (!commit.ok) return {}
124
+ const branch = run('git', ['rev-parse', '--abbrev-ref', 'HEAD'], projectRoot)
125
+ const status = run('git', ['status', '--porcelain', '--untracked-files=no'], projectRoot)
126
+ const remote = run('git', ['remote', 'get-url', 'origin'], projectRoot)
127
+ return {
128
+ commit: commit.stdout,
129
+ branch: branch.ok && branch.stdout !== 'HEAD' ? branch.stdout : undefined,
130
+ dirty: status.ok && status.stdout.length > 0,
131
+ sourceRepo: remote.ok ? parseGitHubRepo(remote.stdout) : undefined
132
+ }
133
+ }
134
+
135
+ function readFrameworkVersion(projectRoot) {
136
+ const path = join(projectRoot, 'node_modules', 'key-screen-framework', 'package.json')
137
+ if (!existsSync(path)) return undefined
138
+ return JSON.parse(readFileSync(path, 'utf8')).version
139
+ }
140
+
141
+ function todayInSeoul() {
142
+ return new Intl.DateTimeFormat('en-CA', { timeZone: 'Asia/Seoul' }).format(new Date())
143
+ }
144
+
145
+ async function askToPublish(message) {
146
+ if (!process.stdin.isTTY || !process.stdout.isTTY || process.env.CI) {
147
+ console.log('터미널이 아니어서 Release 게시를 건너뜁니다. 나중에 npm run release:publish 로 올릴 수 있습니다.')
148
+ return false
149
+ }
150
+ const { confirm } = await import('@inquirer/prompts')
151
+ try {
152
+ return await confirm({ message, default: false })
153
+ } catch (error) {
154
+ // Ctrl+C 등으로 프롬프트를 닫으면 게시하지 않은 것으로 본다. 빌드는 이미 끝났으므로 실패로 처리하지 않는다.
155
+ if (error instanceof Error && error.name === 'ExitPromptError') return false
156
+ throw error
157
+ }
158
+ }
159
+
160
+ export async function main(argv = process.argv.slice(2)) {
161
+ const options = parsePublishArgs(argv)
162
+ if (options.help) {
163
+ printUsage()
164
+ return
165
+ }
166
+
167
+ const projectRoot = resolve(options.projectRoot)
168
+ const manifest = JSON.parse(readFileSync(join(projectRoot, 'package.json'), 'utf8'))
169
+ const repo = options.repo ?? manifest.keyInstallers?.repo ?? DEFAULT_INSTALLERS_REPO
170
+ const outputDir = join(projectRoot, manifest.build?.directories?.output ?? 'release')
171
+ const installers = existsSync(outputDir)
172
+ ? findInstallers(readdirSync(outputDir), { version: manifest.version, target: options.target })
173
+ : []
174
+ if (installers.length === 0) {
175
+ throw new Error(`${outputDir}에 ${manifest.version} 버전 설치 파일이 없습니다. 먼저 build:win 또는 build:mac을 실행하세요.`)
176
+ }
177
+
178
+ const tag = releaseTag(manifest)
179
+ const git = readGitInfo(projectRoot)
180
+ console.log(`\n설치 파일: ${installers.join(', ')}`)
181
+ console.log(`게시 위치: ${repo} Release ${tag}`)
182
+ if (git.dirty) console.log('⚠️ 커밋되지 않은 변경이 있습니다. 현장에 배포할 설치 파일이면 커밋한 뒤 다시 빌드하세요.')
183
+
184
+ if (options.prompt && !(await askToPublish(`${repo} Release(${tag})에 게시할까요?`))) {
185
+ console.log('Release 게시를 건너뜁니다.')
186
+ return
187
+ }
188
+
189
+ const files = installers.map((name) => join(outputDir, name))
190
+ const notes = buildReleaseNotes({
191
+ manifest,
192
+ ...git,
193
+ frameworkVersion: readFrameworkVersion(projectRoot),
194
+ date: todayInSeoul()
195
+ })
196
+
197
+ if (options.dryRun) {
198
+ console.log(`[dry-run] ${tag} 에 올릴 파일: ${installers.map(githubAssetName).join(', ')}\n${notes}`)
199
+ return
200
+ }
201
+
202
+ if (!run('gh', ['auth', 'status'], projectRoot).ok) {
203
+ throw new Error('GitHub CLI(gh)가 없거나 로그인되어 있지 않습니다. gh auth login 후 npm run release:publish 로 다시 올리세요.')
204
+ }
205
+
206
+ const exists = run('gh', ['release', 'view', tag, '--repo', repo], projectRoot).ok
207
+ let result
208
+ if (exists) {
209
+ console.log(`${tag} 릴리스가 이미 있어 첨부 파일만 올립니다(같은 이름은 덮어씁니다).`)
210
+ result = run('gh', ['release', 'upload', tag, ...files, '--repo', repo, '--clobber'], projectRoot, { capture: false })
211
+ } else {
212
+ const notesDir = mkdtempSync(join(tmpdir(), 'key-screen-release-'))
213
+ const notesFile = join(notesDir, 'notes.md')
214
+ writeFileSync(notesFile, notes)
215
+ try {
216
+ result = run(
217
+ 'gh',
218
+ ['release', 'create', tag, ...files, '--repo', repo, '--title', releaseTitle(manifest), '--notes-file', notesFile, '--latest=false'],
219
+ projectRoot,
220
+ { capture: false }
221
+ )
222
+ } finally {
223
+ rmSync(notesDir, { recursive: true, force: true })
224
+ }
225
+ }
226
+ if (!result.ok) throw new Error(`Release 게시에 실패했습니다: ${tag}`)
227
+
228
+ console.log(`게시 완료: https://github.com/${repo}/releases/tag/${tag}`)
229
+ console.log(`첨부 파일 이름: ${files.map((file) => githubAssetName(basename(file))).join(', ')}`)
230
+ console.log('보관소 README의 프로젝트별 최신 버전 표도 함께 갱신하세요.')
231
+ }
232
+
233
+ if (isDirectExecution(import.meta.url, process.argv[1])) {
234
+ main().catch((error) => {
235
+ process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`)
236
+ process.exitCode = 1
237
+ })
238
+ }
package/main/index.js CHANGED
@@ -4,9 +4,9 @@ import { createRequire } from "node:module";
4
4
  import { join, dirname, extname, relative, sep, normalize } from "node:path";
5
5
  import { Readable } from "node:stream";
6
6
  import { fileURLToPath } from "node:url";
7
- import { app, protocol, dialog, ipcMain, shell, BrowserWindow, screen } from "electron";
7
+ import { app, protocol, dialog, screen, ipcMain, shell, BrowserWindow } from "electron";
8
8
  import Store from "electron-store";
9
- import { validateArduinoBoardConfig, defaultArduinoBoardConfig } from "../shared/arduino-board.js";
9
+ import { validateArduinoBoardConfig, suggestArduinoBoardPreset, defaultArduinoBoardConfig } from "../shared/arduino-board.js";
10
10
  import { createScreenCatalog } from "../shared/screen-catalog.js";
11
11
  import { RESET_SCREEN_TARGET, buildDefaultGlobalShortcuts, mergeGlobalShortcuts, normalizeShortcutAccelerator } from "../shared/screen-shortcuts.js";
12
12
  import { b as normalizeScreenOverrides, m as mergeScreenOverrides, a as normalizeDisplayFit, n as normalizeAdminZoom, c as normalizeStoredScreenOverrides } from "../chunks/screen-overrides-0d_pEdnM.js";
@@ -70,6 +70,7 @@ function buildArduinoUploadArgs(options) {
70
70
  return [
71
71
  "compile",
72
72
  "--upload",
73
+ "--verbose",
73
74
  "-p",
74
75
  options.portPath,
75
76
  "--fqbn",
@@ -295,11 +296,23 @@ function isReloadShortcut(input, platform = process.platform) {
295
296
  }
296
297
  return Boolean(input.key?.toLowerCase() === "f5" || hasPrimaryModifier$1(input, platform) && isKey$1(input, "r"));
297
298
  }
299
+ const FUNCTION_KEY_PATTERN = /^f([1-9]|1[0-9]|2[0-4])$/;
300
+ function isBlockedFunctionKey(input) {
301
+ const key = input.key?.toLowerCase() ?? "";
302
+ if (!FUNCTION_KEY_PATTERN.test(key)) {
303
+ return false;
304
+ }
305
+ return !(input.alt && key === "f4");
306
+ }
298
307
  const SERIAL_BAUD_RATE = 115200;
299
308
  const REQUEST_TIMEOUT_MS = 500;
300
309
  const REQUEST_RETRY_LIMIT = 3;
301
310
  const HEARTBEAT_INTERVAL_MS = 2e3;
302
311
  const HEARTBEAT_TIMEOUT_MS = 6e3;
312
+ const HEARTBEAT_SLOW_INTERVAL_MS = 1e4;
313
+ const UNRECOGNIZED_LINE_LOG_LIMIT = 3;
314
+ const UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS = 1e4;
315
+ const UNRECOGNIZED_LINE_PREVIEW_LENGTH = 80;
303
316
  const knownErrorCodes = /* @__PURE__ */ new Set([
304
317
  "UNKNOWN_COMMAND",
305
318
  "INVALID_TARGET",
@@ -358,12 +371,18 @@ function parseIncomingLine(rawLine) {
358
371
  }
359
372
  }
360
373
  const now$3 = () => (/* @__PURE__ */ new Date()).toISOString();
374
+ const previewLine = (line) => line.length > UNRECOGNIZED_LINE_PREVIEW_LENGTH ? `${line.slice(0, UNRECOGNIZED_LINE_PREVIEW_LENGTH)}…` : line;
361
375
  class DeviceController extends EventEmitter {
362
376
  port = null;
363
377
  options;
364
378
  readBuffer = "";
365
379
  heartbeatInterval = null;
366
380
  heartbeatTimeout = null;
381
+ heartbeatIntervalMs = HEARTBEAT_INTERVAL_MS;
382
+ handshakeReceived = false;
383
+ ignoredLineCount = 0;
384
+ ignoredSinceSummary = 0;
385
+ lastIgnoredSummaryAt = 0;
367
386
  writeQueue = Promise.resolve();
368
387
  pendingRequest = null;
369
388
  state = {
@@ -385,7 +404,8 @@ class DeviceController extends EventEmitter {
385
404
  manufacturer: port.manufacturer ?? void 0,
386
405
  serialNumber: port.serialNumber ?? void 0,
387
406
  vendorId: port.vendorId ?? void 0,
388
- productId: port.productId ?? void 0
407
+ productId: port.productId ?? void 0,
408
+ suggestedBoardPreset: suggestArduinoBoardPreset(port.vendorId, port.productId)
389
409
  })),
390
410
  updatedAt: now$3()
391
411
  };
@@ -395,6 +415,10 @@ class DeviceController extends EventEmitter {
395
415
  getState() {
396
416
  return this.state;
397
417
  }
418
+ // 핸드셰이크 실패로 status가 error여도 포트는 열려 있을 수 있다. 업로드 전 포트 해제 판단에 쓴다.
419
+ isPortOpen() {
420
+ return Boolean(this.port?.isOpen);
421
+ }
398
422
  logSystemEvent(message) {
399
423
  this.state = {
400
424
  ...this.state,
@@ -423,6 +447,9 @@ class DeviceController extends EventEmitter {
423
447
  status: "connecting",
424
448
  selectedPortPath: selectedPort,
425
449
  lastError: void 0,
450
+ firmwareStatus: "unknown",
451
+ firmwareIssue: void 0,
452
+ ignoredLineCount: 0,
426
453
  updatedAt: now$3()
427
454
  };
428
455
  this.emitState();
@@ -468,6 +495,7 @@ class DeviceController extends EventEmitter {
468
495
  this.stopHeartbeat();
469
496
  this.pendingRequest = null;
470
497
  this.readBuffer = "";
498
+ this.resetFirmwareDetection();
471
499
  if (this.port?.isOpen) {
472
500
  await new Promise((resolve) => {
473
501
  this.port?.close(() => resolve());
@@ -479,6 +507,9 @@ class DeviceController extends EventEmitter {
479
507
  status: "disconnected",
480
508
  selectedPortPath,
481
509
  lastMessage: "Disconnected from device.",
510
+ firmwareStatus: void 0,
511
+ firmwareIssue: void 0,
512
+ ignoredLineCount: void 0,
482
513
  updatedAt: now$3()
483
514
  };
484
515
  this.pushLog("system", this.state.lastMessage);
@@ -570,6 +601,10 @@ class DeviceController extends EventEmitter {
570
601
  async handleIncomingLine(rawLine) {
571
602
  const parsed = parseIncomingLine(rawLine);
572
603
  const trimmed = rawLine.trim();
604
+ if (!parsed && !this.handshakeReceived) {
605
+ this.recordUnrecognizedLine(trimmed);
606
+ return;
607
+ }
573
608
  const logDirection = parsed?.type === "err" ? "error" : "in";
574
609
  const shouldSkip = this.shouldSkipMessageLog("in", trimmed);
575
610
  this.state = {
@@ -604,15 +639,21 @@ class DeviceController extends EventEmitter {
604
639
  }
605
640
  }
606
641
  markHandshake(message) {
642
+ this.handshakeReceived = true;
607
643
  this.state = {
608
644
  ...this.state,
609
645
  status: "connected",
646
+ firmwareStatus: "detected",
647
+ firmwareIssue: void 0,
610
648
  lastMessage: this.shouldKeepAsLastMessage(message) ? message : this.state.lastMessage,
611
649
  lastHandshakeAt: now$3(),
612
650
  updatedAt: now$3()
613
651
  };
614
652
  this.emitState();
615
653
  this.refreshHeartbeatTimeout();
654
+ if (this.heartbeatIntervalMs !== HEARTBEAT_INTERVAL_MS) {
655
+ this.scheduleHeartbeat(HEARTBEAT_INTERVAL_MS);
656
+ }
616
657
  if (message === "READY") {
617
658
  void this.sendHeartbeatPing();
618
659
  }
@@ -620,10 +661,56 @@ class DeviceController extends EventEmitter {
620
661
  startHeartbeat() {
621
662
  this.stopHeartbeat();
622
663
  void this.sendHeartbeatPing();
664
+ this.scheduleHeartbeat(HEARTBEAT_INTERVAL_MS);
665
+ this.refreshHeartbeatTimeout();
666
+ }
667
+ scheduleHeartbeat(intervalMs) {
668
+ if (this.heartbeatInterval) {
669
+ clearInterval(this.heartbeatInterval);
670
+ }
671
+ this.heartbeatIntervalMs = intervalMs;
623
672
  this.heartbeatInterval = setInterval(() => {
624
673
  void this.sendHeartbeatPing();
625
- }, HEARTBEAT_INTERVAL_MS);
626
- this.refreshHeartbeatTimeout();
674
+ }, intervalMs);
675
+ }
676
+ resetFirmwareDetection() {
677
+ this.handshakeReceived = false;
678
+ this.ignoredLineCount = 0;
679
+ this.ignoredSinceSummary = 0;
680
+ this.lastIgnoredSummaryAt = 0;
681
+ }
682
+ recordUnrecognizedLine(line) {
683
+ if (!line) {
684
+ return;
685
+ }
686
+ this.ignoredLineCount += 1;
687
+ if (this.ignoredLineCount <= UNRECOGNIZED_LINE_LOG_LIMIT) {
688
+ this.pushLog("in", line, "in");
689
+ if (this.ignoredLineCount === UNRECOGNIZED_LINE_LOG_LIMIT) {
690
+ this.lastIgnoredSummaryAt = Date.now();
691
+ this.pushLog(
692
+ "system",
693
+ `Unrecognized serial data is ignored until READY/PONG arrives. Further lines are summarized every ${UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS / 1e3}s.`,
694
+ "system"
695
+ );
696
+ }
697
+ this.state = { ...this.state, ignoredLineCount: this.ignoredLineCount, updatedAt: now$3() };
698
+ this.emitState();
699
+ return;
700
+ }
701
+ this.ignoredSinceSummary += 1;
702
+ if (Date.now() - this.lastIgnoredSummaryAt < UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS) {
703
+ return;
704
+ }
705
+ this.pushLog(
706
+ "system",
707
+ `Ignored ${this.ignoredSinceSummary} unrecognized serial lines (latest: ${previewLine(line)}).`,
708
+ "system"
709
+ );
710
+ this.ignoredSinceSummary = 0;
711
+ this.lastIgnoredSummaryAt = Date.now();
712
+ this.state = { ...this.state, ignoredLineCount: this.ignoredLineCount, updatedAt: now$3() };
713
+ this.emitState();
627
714
  }
628
715
  async sendHeartbeatPing() {
629
716
  if (!this.port?.isOpen) {
@@ -648,6 +735,7 @@ class DeviceController extends EventEmitter {
648
735
  clearInterval(this.heartbeatInterval);
649
736
  this.heartbeatInterval = null;
650
737
  }
738
+ this.heartbeatIntervalMs = HEARTBEAT_INTERVAL_MS;
651
739
  if (this.heartbeatTimeout) {
652
740
  clearTimeout(this.heartbeatTimeout);
653
741
  this.heartbeatTimeout = null;
@@ -661,6 +749,22 @@ class DeviceController extends EventEmitter {
661
749
  if (!this.port?.isOpen) {
662
750
  return;
663
751
  }
752
+ if (!this.handshakeReceived) {
753
+ this.state = {
754
+ ...this.state,
755
+ status: "error",
756
+ lastError: "No READY/PONG since connecting: the framework firmware is probably not uploaded to this board.",
757
+ lastHandshakeAt: void 0,
758
+ firmwareStatus: "missing",
759
+ firmwareIssue: this.ignoredLineCount > 0 ? "unrecognized-data" : "silent",
760
+ ignoredLineCount: this.ignoredLineCount,
761
+ updatedAt: now$3()
762
+ };
763
+ this.pushLog("error", this.state.lastError, "system");
764
+ this.emitState();
765
+ this.scheduleHeartbeat(HEARTBEAT_SLOW_INTERVAL_MS);
766
+ return;
767
+ }
664
768
  this.state = {
665
769
  ...this.state,
666
770
  status: "error",
@@ -1294,6 +1398,10 @@ function parseByteRange(rangeHeader, sizeBytes) {
1294
1398
  end: Math.min(requestedEnd, sizeBytes - 1)
1295
1399
  };
1296
1400
  }
1401
+ const COVERING_TOLERANCE_PX = 2;
1402
+ function isWindowCoveringDisplay(windowBounds, displayBounds) {
1403
+ return windowBounds.x <= displayBounds.x + COVERING_TOLERANCE_PX && windowBounds.y <= displayBounds.y + COVERING_TOLERANCE_PX && windowBounds.x + windowBounds.width >= displayBounds.x + displayBounds.width - COVERING_TOLERANCE_PX && windowBounds.y + windowBounds.height >= displayBounds.y + displayBounds.height - COVERING_TOLERANCE_PX;
1404
+ }
1297
1405
  function getEnvWindowModeOverride(env) {
1298
1406
  if (env.KEYESCAPE_KIOSK === "1") {
1299
1407
  return "kiosk";
@@ -1324,6 +1432,10 @@ function applyWindowMode(window, mode, options = {}) {
1324
1432
  window.setMovable(isWindowed);
1325
1433
  window.setFullScreenable(true);
1326
1434
  if (isKiosk) {
1435
+ if (options.forceKioskReentry) {
1436
+ window.setKiosk(false);
1437
+ window.setFullScreen(false);
1438
+ }
1327
1439
  if (canUnmaximize) {
1328
1440
  window.unmaximize();
1329
1441
  }
@@ -1374,6 +1486,10 @@ public static class KioskWindowsKeyBlocker {
1374
1486
  private const int WM_SYSKEYUP = 0x0105;
1375
1487
  private const int VK_LWIN = 0x5B;
1376
1488
  private const int VK_RWIN = 0x5C;
1489
+ private const int VK_TAB = 0x09;
1490
+ private const int VK_ESCAPE = 0x1B;
1491
+ private const int VK_CONTROL = 0x11;
1492
+ private const int LLKHF_ALTDOWN = 0x20;
1377
1493
 
1378
1494
  private static LowLevelKeyboardProc proc = HookCallback;
1379
1495
  private static IntPtr hookId = IntPtr.Zero;
@@ -1396,7 +1512,8 @@ public static class KioskWindowsKeyBlocker {
1396
1512
  private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) {
1397
1513
  if (nCode >= 0 && IsKeyboardMessage(wParam)) {
1398
1514
  int vkCode = Marshal.ReadInt32(lParam);
1399
- if (vkCode == VK_LWIN || vkCode == VK_RWIN) {
1515
+ int flags = Marshal.ReadInt32(lParam, 8);
1516
+ if (IsBlockedKey(vkCode, (flags & LLKHF_ALTDOWN) != 0)) {
1400
1517
  return (IntPtr)1;
1401
1518
  }
1402
1519
  }
@@ -1404,6 +1521,21 @@ public static class KioskWindowsKeyBlocker {
1404
1521
  return CallNextHookEx(hookId, nCode, wParam, lParam);
1405
1522
  }
1406
1523
 
1524
+ // Ctrl+Esc and Ctrl+Shift+Esc open Start and Task Manager; Alt+Tab and Alt+Esc switch windows.
1525
+ // Ctrl+Alt+Del cannot be intercepted here; see docs/windows-store-pc-lockdown.md.
1526
+ private static bool IsBlockedKey(int vkCode, bool altDown) {
1527
+ if (vkCode == VK_LWIN || vkCode == VK_RWIN) {
1528
+ return true;
1529
+ }
1530
+
1531
+ bool controlDown = (GetAsyncKeyState(VK_CONTROL) & 0x8000) != 0;
1532
+ if (vkCode == VK_ESCAPE) {
1533
+ return controlDown || altDown;
1534
+ }
1535
+
1536
+ return vkCode == VK_TAB && altDown;
1537
+ }
1538
+
1407
1539
  private static bool IsKeyboardMessage(IntPtr wParam) {
1408
1540
  int message = wParam.ToInt32();
1409
1541
  return message == WM_KEYDOWN || message == WM_KEYUP || message == WM_SYSKEYDOWN || message == WM_SYSKEYUP;
@@ -1419,6 +1551,9 @@ public static class KioskWindowsKeyBlocker {
1419
1551
  [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
1420
1552
  private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, IntPtr wParam, IntPtr lParam);
1421
1553
 
1554
+ [DllImport("user32.dll")]
1555
+ private static extern short GetAsyncKeyState(int vKey);
1556
+
1422
1557
  [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
1423
1558
  private static extern IntPtr GetModuleHandle(string lpModuleName);
1424
1559
  }
@@ -1507,6 +1642,7 @@ function startKeyScreenMain(options) {
1507
1642
  let mainWindow = null;
1508
1643
  let currentWindowMode = "windowed";
1509
1644
  let allowKioskQuit = false;
1645
+ let kioskEnforcementTimers = [];
1510
1646
  let activeArduinoBuild = null;
1511
1647
  let arduinoLogSequence = 0;
1512
1648
  let arduinoBuildStatus = {
@@ -1728,7 +1864,7 @@ function startKeyScreenMain(options) {
1728
1864
  const sketchDir = await writeGeneratedArduinoSketch(preview.source);
1729
1865
  if (action === "upload") {
1730
1866
  const deviceState = deviceController.getState();
1731
- previousPortPath = deviceState.status === "connected" ? deviceState.selectedPortPath : void 0;
1867
+ previousPortPath = deviceController.isPortOpen() ? deviceState.selectedPortPath : void 0;
1732
1868
  shouldReconnect = Boolean(previousPortPath);
1733
1869
  const uploadPortPath = portPath ?? previousPortPath;
1734
1870
  if (!uploadPortPath) {
@@ -1814,19 +1950,40 @@ function startKeyScreenMain(options) {
1814
1950
  activeArduinoBuild = null;
1815
1951
  }
1816
1952
  }
1817
- function applyCurrentWindowMode() {
1953
+ function getKioskBounds(window) {
1954
+ return screen.getDisplayMatching(window.getBounds()).bounds;
1955
+ }
1956
+ function applyCurrentWindowMode(options2 = {}) {
1818
1957
  if (!mainWindow) {
1819
1958
  return;
1820
1959
  }
1821
1960
  applyWindowMode(mainWindow, currentWindowMode, {
1822
- kioskBounds: screen.getDisplayMatching(mainWindow.getBounds()).bounds
1961
+ kioskBounds: getKioskBounds(mainWindow),
1962
+ forceKioskReentry: options2.forceKioskReentry
1963
+ });
1964
+ }
1965
+ function logWindowState(reason) {
1966
+ if (!mainWindow || mainWindow.isDestroyed()) {
1967
+ return;
1968
+ }
1969
+ log.info("[window]", reason, {
1970
+ mode: currentWindowMode,
1971
+ bounds: mainWindow.getBounds(),
1972
+ displayBounds: getKioskBounds(mainWindow),
1973
+ isFullScreen: mainWindow.isFullScreen(),
1974
+ isKiosk: mainWindow.isKiosk(),
1975
+ isVisible: mainWindow.isVisible()
1823
1976
  });
1824
1977
  }
1825
1978
  function enforceKioskWindowMode() {
1826
- if (!mainWindow || currentWindowMode !== "kiosk") {
1979
+ if (!mainWindow || mainWindow.isDestroyed() || currentWindowMode !== "kiosk") {
1827
1980
  return;
1828
1981
  }
1829
- applyCurrentWindowMode();
1982
+ const isCovering = isWindowCoveringDisplay(mainWindow.getBounds(), getKioskBounds(mainWindow));
1983
+ if (!isCovering) {
1984
+ logWindowState("kiosk window does not cover display, re-entering kiosk");
1985
+ }
1986
+ applyCurrentWindowMode({ forceKioskReentry: !isCovering });
1830
1987
  mainWindow.show();
1831
1988
  mainWindow.focus();
1832
1989
  }
@@ -1834,9 +1991,11 @@ function startKeyScreenMain(options) {
1834
1991
  if (currentWindowMode !== "kiosk") {
1835
1992
  return;
1836
1993
  }
1837
- for (const delayMs of [50, 250, 1e3, 2500]) {
1838
- setTimeout(enforceKioskWindowMode, delayMs);
1994
+ for (const timer of kioskEnforcementTimers) {
1995
+ clearTimeout(timer);
1839
1996
  }
1997
+ kioskEnforcementTimers = [50, 250, 1e3, 2500, 5e3].map((delayMs) => setTimeout(enforceKioskWindowMode, delayMs));
1998
+ kioskEnforcementTimers.push(setTimeout(() => logWindowState("kiosk enforcement finished"), 5500));
1840
1999
  }
1841
2000
  function syncWindowsKeyLockToWindowMode() {
1842
2001
  if (currentWindowMode === "kiosk") {
@@ -1894,8 +2053,9 @@ function startKeyScreenMain(options) {
1894
2053
  minHeight: 760,
1895
2054
  show: false,
1896
2055
  autoHideMenuBar: true,
1897
- fullscreen: initialWindowMode !== "windowed",
1898
- kiosk: initialWindowMode === "kiosk",
2056
+ // 키오스크는 숨긴 창을 처음부터 전체화면으로 만들면 작은 창으로 남을 수 있어, 창을 보인 뒤 관리자 화면에서 켤 때와 같은 경로로 적용한다.
2057
+ fullscreen: initialWindowMode === "fullscreen",
2058
+ kiosk: false,
1899
2059
  resizable: initialWindowMode === "windowed",
1900
2060
  minimizable: initialWindowMode === "windowed",
1901
2061
  maximizable: initialWindowMode === "windowed",
@@ -1913,8 +2073,14 @@ function startKeyScreenMain(options) {
1913
2073
  mainWindow.setMenuBarVisibility(false);
1914
2074
  }
1915
2075
  mainWindow.on("ready-to-show", () => {
1916
- applyCurrentWindowMode();
1917
- mainWindow?.show();
2076
+ if (currentWindowMode === "kiosk") {
2077
+ mainWindow?.show();
2078
+ applyCurrentWindowMode();
2079
+ } else {
2080
+ applyCurrentWindowMode();
2081
+ mainWindow?.show();
2082
+ }
2083
+ logWindowState("ready-to-show");
1918
2084
  scheduleKioskWindowModeEnforcement();
1919
2085
  });
1920
2086
  mainWindow.on("close", (event) => {
@@ -1923,7 +2089,7 @@ function startKeyScreenMain(options) {
1923
2089
  }
1924
2090
  });
1925
2091
  mainWindow.webContents.on("before-input-event", (event, input) => {
1926
- if (!isDev && isReloadShortcut(input)) {
2092
+ if (!isDev && (isReloadShortcut(input) || isBlockedFunctionKey(input))) {
1927
2093
  event.preventDefault();
1928
2094
  return;
1929
2095
  }
@@ -2012,8 +2178,16 @@ function startKeyScreenMain(options) {
2012
2178
  });
2013
2179
  createWindow();
2014
2180
  syncWindowsKeyLockToWindowMode();
2181
+ const handleDisplayChange = (reason) => () => {
2182
+ logWindowState(reason);
2183
+ scheduleKioskWindowModeEnforcement();
2184
+ };
2185
+ screen.on("display-added", handleDisplayChange("display-added"));
2186
+ screen.on("display-removed", handleDisplayChange("display-removed"));
2187
+ screen.on("display-metrics-changed", handleDisplayChange("display-metrics-changed"));
2015
2188
  arduinoCliRunner = new ArduinoCliRunner(resolveArduinoCliPaths(app));
2016
2189
  arduinoCliRunner.on("log", (entry) => {
2190
+ log.info(`[arduino:${entry.stream}]`, entry.line);
2017
2191
  broadcastArduinoLog(entry);
2018
2192
  });
2019
2193
  const deviceLogWriter = new DeviceLogWriter(app.getPath("logs"), {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "key-screen-framework",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "Screen framework for Keyescape desktop projects.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -89,7 +89,8 @@
89
89
  "key-screen-remove": "./cli/remove-screen.mjs",
90
90
  "key-screen-sync": "./cli/sync-screens.mjs",
91
91
  "key-screen-setup-arduino": "./cli/setup-arduino-cli.mjs",
92
- "key-screen-check-arduino-bundle": "./cli/check-arduino-bundle.mjs"
92
+ "key-screen-check-arduino-bundle": "./cli/check-arduino-bundle.mjs",
93
+ "key-screen-publish-release": "./cli/publish-release.mjs"
93
94
  },
94
95
  "engines": {
95
96
  "node": "^20.19.0 || ^22.13.0 || >=23.5.0"
package/renderer/index.js CHANGED
@@ -693,7 +693,7 @@ const arduinoPhaseLabel = {
693
693
  };
694
694
  const arduinoLogTone = {
695
695
  stdout: "border-border-soft bg-surface-subtle text-text-muted",
696
- stderr: "border-log-error-label-text/40 bg-log-error-bg text-text",
696
+ stderr: "border-log-error-label-text bg-log-error-bg text-text",
697
697
  system: "border-aqua_signal/30 bg-aqua_signal/10 text-text"
698
698
  };
699
699
  const ARDUINO_AUTO_SAVE_DEBOUNCE_MS = 1500;
@@ -1767,12 +1767,16 @@ function AdminScreen({ gameState }) {
1767
1767
  ]
1768
1768
  });
1769
1769
  };
1770
- const saveArduinoDraft = async () => {
1770
+ const firmwareSuggestedPreset = ports.find(
1771
+ (port) => port.path === deviceState.selectedPortPath
1772
+ )?.suggestedBoardPreset;
1773
+ const firmwareBoardPresetChange = Boolean(firmwareSuggestedPreset) && !arduinoAdvancedFqbn && firmwareSuggestedPreset !== arduinoDraft.boardPreset;
1774
+ const saveArduinoDraft = async (draft = arduinoDraft) => {
1771
1775
  const saveSequence = arduinoSaveSequenceRef.current + 1;
1772
1776
  const editSequenceAtStart = arduinoEditSequenceRef.current;
1773
1777
  arduinoSaveSequenceRef.current = saveSequence;
1774
1778
  try {
1775
- await updateArduinoBoardConfig(arduinoDraft);
1779
+ await updateArduinoBoardConfig(draft);
1776
1780
  if (arduinoSaveSequenceRef.current === saveSequence && arduinoEditSequenceRef.current === editSequenceAtStart) {
1777
1781
  setArduinoSyncState("saved");
1778
1782
  setArduinoError("");
@@ -1819,6 +1823,24 @@ function AdminScreen({ gameState }) {
1819
1823
  setArduinoError("Arduino 업로드 요청에 실패했습니다.");
1820
1824
  }
1821
1825
  };
1826
+ const uploadDefaultFirmware = async () => {
1827
+ const nextDraft = firmwareBoardPresetChange && firmwareSuggestedPreset ? {
1828
+ ...arduinoDraft,
1829
+ boardPreset: firmwareSuggestedPreset,
1830
+ fqbn: resolveArduinoBoardFqbn(firmwareSuggestedPreset)
1831
+ } : arduinoDraft;
1832
+ arduinoEditSequenceRef.current += 1;
1833
+ setArduinoDraft(nextDraft);
1834
+ setArduinoFirmwareOpen(true);
1835
+ if (!await saveArduinoDraft(nextDraft)) {
1836
+ return;
1837
+ }
1838
+ try {
1839
+ await arduinoBuild.upload(deviceState.selectedPortPath);
1840
+ } catch {
1841
+ setArduinoError("Arduino 업로드 요청에 실패했습니다.");
1842
+ }
1843
+ };
1822
1844
  const buildCurrentOverrides = () => {
1823
1845
  const result = {};
1824
1846
  for (const current of screens.filter((screen) => screen.kind === "scene")) {
@@ -2139,7 +2161,44 @@ function AdminScreen({ gameState }) {
2139
2161
  children: "연결 해제"
2140
2162
  }
2141
2163
  )
2142
- ] })
2164
+ ] }),
2165
+ deviceState.firmwareStatus === "missing" ? /* @__PURE__ */ jsxs(
2166
+ "div",
2167
+ {
2168
+ className: "rounded-lg border border-log-error-label-text bg-log-error-bg p-4",
2169
+ role: "alert",
2170
+ children: [
2171
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-semibold text-text", children: "프레임워크 펌웨어가 없는 보드로 보입니다" }),
2172
+ /* @__PURE__ */ jsx("p", { className: "mt-2 text-xs leading-5 text-text-muted", children: deviceState.firmwareIssue === "unrecognized-data" ? `연결 후 응답(READY/PONG) 대신 프로토콜이 아닌 데이터 ${deviceState.ignoredLineCount ?? 0}줄이 들어왔습니다. 다른 스케치가 올라가 있거나 통신 속도가 다를 수 있습니다. 이 데이터에는 응답하지 않고 로그는 요약해서 남깁니다.` : "연결 후 6초 동안 응답(READY/PONG)이 없었습니다. 빈 보드이거나 시리얼을 쓰지 않는 다른 스케치가 올라가 있을 수 있습니다." }),
2173
+ /* @__PURE__ */ jsxs("p", { className: "mt-2 text-xs leading-5 text-text-muted", children: [
2174
+ arduinoAdvancedFqbn ? `직접 지정한 FQBN(${arduinoDraft.fqbn})으로 업로드합니다.` : firmwareSuggestedPreset ? firmwareBoardPresetChange ? `USB 정보로 보면 ${firmwareSuggestedPreset} 보드입니다. 업로드하면 보드 설정을 ${arduinoDraft.boardPreset}에서 ${firmwareSuggestedPreset}(으)로 바꿉니다.` : `USB 정보로 보면 ${firmwareSuggestedPreset} 보드이며, 현재 보드 설정과 같습니다.` : `USB 정보로 보드 종류를 알 수 없어 현재 보드 설정(${arduinoDraft.boardPreset})으로 업로드합니다. 다르면 펌웨어 화면에서 보드를 먼저 고르세요.`,
2175
+ " ",
2176
+ "업로드하면 보드에 있던 기존 스케치는 지워집니다."
2177
+ ] }),
2178
+ /* @__PURE__ */ jsxs("div", { className: "mt-3 grid gap-2 sm:grid-cols-2", children: [
2179
+ /* @__PURE__ */ jsx(
2180
+ "button",
2181
+ {
2182
+ className: "rounded-lg bg-button-primary-bg px-4 py-2.5 text-sm font-semibold text-button-primary-text transition hover:bg-button-primary-hover disabled:cursor-not-allowed disabled:opacity-60",
2183
+ disabled: loading || arduinoBuild.compiling || arduinoBuild.uploading || !deviceState.selectedPortPath,
2184
+ onClick: () => void uploadDefaultFirmware(),
2185
+ type: "button",
2186
+ children: "기본 펌웨어 업로드"
2187
+ }
2188
+ ),
2189
+ /* @__PURE__ */ jsx(
2190
+ "button",
2191
+ {
2192
+ className: "rounded-lg border border-border px-4 py-2.5 text-sm font-semibold text-text transition hover:border-border-strong hover:bg-surface-hover",
2193
+ onClick: () => setArduinoFirmwareOpen(true),
2194
+ type: "button",
2195
+ children: "펌웨어 화면 열기"
2196
+ }
2197
+ )
2198
+ ] })
2199
+ ]
2200
+ }
2201
+ ) : null
2143
2202
  ] }),
2144
2203
  /* @__PURE__ */ jsx("div", { className: "flex min-h-0 flex-col gap-3", children: /* @__PURE__ */ jsxs("div", { className: "flex min-h-0 flex-1 flex-col rounded-lg border border-border-soft bg-surface-strong p-4", children: [
2145
2204
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex shrink-0 items-center justify-between", children: [
@@ -914,6 +914,9 @@ video {
914
914
  .border-log-error-bg {
915
915
  border-color: var(--color-log-error-bg);
916
916
  }
917
+ .border-log-error-label-text {
918
+ border-color: var(--color-log-error-label-text);
919
+ }
917
920
  .border-transparent {
918
921
  border-color: transparent;
919
922
  }
@@ -21,6 +21,34 @@ function defaultArduinoBoardConfig() {
21
21
  outputs: []
22
22
  };
23
23
  }
24
+ const BOARD_PRESET_BY_USB_ID = {
25
+ "2341:0036": "Leonardo",
26
+ "2341:8036": "Leonardo",
27
+ "2a03:0036": "Leonardo",
28
+ "2a03:8036": "Leonardo",
29
+ "2341:0037": "Micro",
30
+ "2341:8037": "Micro",
31
+ "2a03:0037": "Micro",
32
+ "2a03:8037": "Micro",
33
+ "1b4f:9205": "ProMicro",
34
+ "1b4f:9206": "ProMicro",
35
+ "2341:0001": "Uno",
36
+ "2341:0043": "Uno",
37
+ "2341:0243": "Uno",
38
+ "2a03:0043": "Uno"
39
+ };
40
+ function normalizeUsbId(value) {
41
+ const normalized = value?.trim().toLowerCase().replace(/^0x/, "");
42
+ return normalized ? normalized.padStart(4, "0") : void 0;
43
+ }
44
+ function suggestArduinoBoardPreset(vendorId, productId) {
45
+ const vendor = normalizeUsbId(vendorId);
46
+ const product = normalizeUsbId(productId);
47
+ if (!vendor || !product) {
48
+ return void 0;
49
+ }
50
+ return BOARD_PRESET_BY_USB_ID[`${vendor}:${product}`];
51
+ }
24
52
  function resolveArduinoBoardFqbn(preset, override) {
25
53
  const trimmedOverride = override?.trim();
26
54
  return trimmedOverride || BOARD_PRESET_FQBN[preset];
@@ -132,5 +160,6 @@ export {
132
160
  DEFAULT_ARDUINO_SERIAL_HEALTHY_TIMEOUT_MS,
133
161
  defaultArduinoBoardConfig,
134
162
  resolveArduinoBoardFqbn,
163
+ suggestArduinoBoardPreset,
135
164
  validateArduinoBoardConfig
136
165
  };
package/shared/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ADMIN_ZOOM_LEVELS } from "./types.js";
2
2
  import { createScreenCatalog } from "./screen-catalog.js";
3
3
  import { DEBUG_DEVICE_LOG_SHORTCUT, KIOSK_QUIT_SHORTCUT, RESET_SCREEN_TARGET, buildDefaultGlobalShortcuts, matchesShortcut, mergeGlobalShortcuts, normalizeShortcutAccelerator } from "./screen-shortcuts.js";
4
- import { ARDUINO_BOARD_PRESETS, ARDUINO_MAX_INPUTS, ARDUINO_MAX_OUTPUTS, ARDUINO_MAX_PIN, ARDUINO_MAX_TARGET_LENGTH, BOARD_PRESET_FQBN, DEFAULT_ARDUINO_SERIAL_HEALTHY_TIMEOUT_MS, defaultArduinoBoardConfig, resolveArduinoBoardFqbn, validateArduinoBoardConfig } from "./arduino-board.js";
4
+ import { ARDUINO_BOARD_PRESETS, ARDUINO_MAX_INPUTS, ARDUINO_MAX_OUTPUTS, ARDUINO_MAX_PIN, ARDUINO_MAX_TARGET_LENGTH, BOARD_PRESET_FQBN, DEFAULT_ARDUINO_SERIAL_HEALTHY_TIMEOUT_MS, defaultArduinoBoardConfig, resolveArduinoBoardFqbn, suggestArduinoBoardPreset, validateArduinoBoardConfig } from "./arduino-board.js";
5
5
  import { acceleratorToArduinoKeyboardShortcut } from "./arduino-keyboard-shortcut.js";
6
6
  export {
7
7
  ADMIN_ZOOM_LEVELS,
@@ -23,5 +23,6 @@ export {
23
23
  mergeGlobalShortcuts,
24
24
  normalizeShortcutAccelerator,
25
25
  resolveArduinoBoardFqbn,
26
+ suggestArduinoBoardPreset,
26
27
  validateArduinoBoardConfig
27
28
  };
@@ -85,6 +85,17 @@ npm run generate:screen -- --id puzzle-1 --title "퍼즐 1"
85
85
 
86
86
  패키징 결과는 `release/` 아래에 생성됩니다. Windows 폴더형 앱은 `release/win-unpacked` 디렉토리 전체를 배포하세요.
87
87
 
88
+ ### 설치 파일 보관소에 게시
89
+
90
+ `build:win`, `build:mac`이 끝나면 설치 파일을 [key-escape/key-installers](https://github.com/key-escape/key-installers) Release에 올릴지 묻습니다. 기본값은 "아니요"이고, 터미널이 아니거나 CI에서는 묻지 않고 건너뜁니다.
91
+
92
+ - 태그는 `<package.json name>-v<version>`입니다. Windows와 Mac을 따로 빌드해도 같은 릴리스에 첨부 파일이 모입니다. 같은 이름의 파일은 덮어씁니다.
93
+ - 릴리스 노트에는 원본 저장소, 커밋 해시, key-screen-framework 버전이 들어갑니다. 커밋하지 않은 변경이 있으면 경고가 함께 표시됩니다.
94
+ - 나중에 올리려면 `npm run release:publish`를 실행합니다. `-- --target win` 또는 `-- --target mac`으로 한쪽만 올릴 수 있고, `-- --dry-run`으로 올릴 내용만 확인할 수 있습니다.
95
+ - 다른 저장소에 올리려면 `package.json`에 `"keyInstallers": { "repo": "owner/name" }`을 추가합니다.
96
+ - [GitHub CLI](https://cli.github.com/)를 설치하고 `gh auth login`으로 로그인해야 합니다.
97
+ - 게시한 뒤에는 보관소 README의 프로젝트별 최신 버전 표를 갱신하세요.
98
+
88
99
  ## 선택 기능: Arduino
89
100
 
90
101
  Arduino를 사용하지 않는 `npm run dev`와 `npm run build`에는 별도 번들이 필요하지 않습니다. Windows 또는 macOS 실행 파일을 패키징할 때는 해당 플랫폼의 Arduino CLI 번들 검사가 먼저 실행됩니다.
@@ -11,9 +11,9 @@
11
11
  "pretest": "npm run sync:screens",
12
12
  "dev": "electron-vite dev",
13
13
  "build": "electron-vite build",
14
- "build:win": "npm run check:arduino-bundle:win && npm run build && electron-builder --win nsis --x64",
14
+ "build:win": "npm run check:arduino-bundle:win && npm run build && electron-builder --win nsis --x64 && key-screen-publish-release --target win --prompt",
15
15
  "build:win:dir": "npm run check:arduino-bundle:win && npm run build && electron-builder --win dir --x64",
16
- "build:mac": "npm run check:arduino-bundle:mac && npm run build && electron-builder --mac dmg",
16
+ "build:mac": "npm run check:arduino-bundle:mac && npm run build && electron-builder --mac dmg && key-screen-publish-release --target mac --prompt",
17
17
  "build:mac:dir": "npm run check:arduino-bundle:mac && npm run build && electron-builder --mac dir",
18
18
  "preview": "electron-vite preview",
19
19
  "doctor:framework": "key-screen-doctor",
@@ -24,6 +24,7 @@
24
24
  "check:arduino-bundle": "key-screen-check-arduino-bundle",
25
25
  "check:arduino-bundle:win": "key-screen-check-arduino-bundle --target win32-x64",
26
26
  "check:arduino-bundle:mac": "key-screen-check-arduino-bundle --target darwin-arm64",
27
+ "release:publish": "key-screen-publish-release",
27
28
  "lint": "eslint .",
28
29
  "test": "vitest run",
29
30
  "test:watch": "vitest",
@@ -1,4 +1,5 @@
1
1
  import type { Input } from 'electron';
2
2
  type Platform = NodeJS.Platform;
3
3
  export declare function isReloadShortcut(input: Input, platform?: Platform): boolean;
4
+ export declare function isBlockedFunctionKey(input: Pick<Input, 'key' | 'alt'>): boolean;
4
5
  export {};
@@ -9,12 +9,18 @@ export declare class DeviceController extends EventEmitter {
9
9
  private readBuffer;
10
10
  private heartbeatInterval;
11
11
  private heartbeatTimeout;
12
+ private heartbeatIntervalMs;
13
+ private handshakeReceived;
14
+ private ignoredLineCount;
15
+ private ignoredSinceSummary;
16
+ private lastIgnoredSummaryAt;
12
17
  private writeQueue;
13
18
  private pendingRequest;
14
19
  private state;
15
20
  constructor(options: DeviceControllerOptions);
16
21
  listPorts(): Promise<DevicePortInfo[]>;
17
22
  getState(): DeviceConnectionState;
23
+ isPortOpen(): boolean;
18
24
  logSystemEvent(message: string): void;
19
25
  connect(portPath?: string): Promise<DeviceConnectionState>;
20
26
  disconnect(emit?: boolean): Promise<DeviceConnectionState>;
@@ -26,6 +32,9 @@ export declare class DeviceController extends EventEmitter {
26
32
  private handleIncomingLine;
27
33
  private markHandshake;
28
34
  private startHeartbeat;
35
+ private scheduleHeartbeat;
36
+ private resetFirmwareDetection;
37
+ private recordUnrecognizedLine;
29
38
  private sendHeartbeatPing;
30
39
  private stopHeartbeat;
31
40
  private refreshHeartbeatTimeout;
@@ -24,6 +24,10 @@ export declare const REQUEST_TIMEOUT_MS = 500;
24
24
  export declare const REQUEST_RETRY_LIMIT = 3;
25
25
  export declare const HEARTBEAT_INTERVAL_MS = 2000;
26
26
  export declare const HEARTBEAT_TIMEOUT_MS = 6000;
27
+ export declare const HEARTBEAT_SLOW_INTERVAL_MS = 10000;
28
+ export declare const UNRECOGNIZED_LINE_LOG_LIMIT = 3;
29
+ export declare const UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS = 10000;
30
+ export declare const UNRECOGNIZED_LINE_PREVIEW_LENGTH = 80;
27
31
  export declare function buildOutgoingLine(command: ArduinoCommand): string;
28
32
  export declare function buildResponseLine(response: Pick<ArduinoResponse, 'ok' | 'target' | 'code'>): string;
29
33
  export declare function parseIncomingLine(rawLine: string): IncomingSerialMessage | null;
@@ -8,7 +8,9 @@ export type WindowBounds = {
8
8
  };
9
9
  export type ApplyWindowModeOptions = {
10
10
  kioskBounds?: WindowBounds;
11
+ forceKioskReentry?: boolean;
11
12
  };
13
+ export declare function isWindowCoveringDisplay(windowBounds: WindowBounds, displayBounds: WindowBounds): boolean;
12
14
  export declare function getEnvWindowModeOverride(env: NodeJS.ProcessEnv): WindowMode | undefined;
13
15
  export declare function resolveInitialWindowMode(options: {
14
16
  env: NodeJS.ProcessEnv;
@@ -7,5 +7,6 @@ export declare const ARDUINO_MAX_TARGET_LENGTH = 64;
7
7
  export declare const ARDUINO_MAX_PIN = 255;
8
8
  export declare const DEFAULT_ARDUINO_SERIAL_HEALTHY_TIMEOUT_MS = 6000;
9
9
  export declare function defaultArduinoBoardConfig(): ArduinoBoardConfig;
10
+ export declare function suggestArduinoBoardPreset(vendorId?: string, productId?: string): ArduinoBoardPreset | undefined;
10
11
  export declare function resolveArduinoBoardFqbn(preset: ArduinoBoardPreset, override?: string): string;
11
12
  export declare function validateArduinoBoardConfig(config: ArduinoBoardConfig): ArduinoBoardConfig;
@@ -1,10 +1,13 @@
1
1
  export type DeviceConnectionStatus = 'disconnected' | 'connecting' | 'connected' | 'error';
2
+ export type DeviceFirmwareStatus = 'unknown' | 'detected' | 'missing';
3
+ export type DeviceFirmwareIssue = 'silent' | 'unrecognized-data';
2
4
  export interface DevicePortInfo {
3
5
  path: string;
4
6
  manufacturer?: string;
5
7
  serialNumber?: string;
6
8
  vendorId?: string;
7
9
  productId?: string;
10
+ suggestedBoardPreset?: ArduinoBoardPreset;
8
11
  }
9
12
  export interface DeviceConnectionState {
10
13
  status: DeviceConnectionStatus;
@@ -13,6 +16,9 @@ export interface DeviceConnectionState {
13
16
  lastMessage?: string;
14
17
  lastError?: string;
15
18
  lastHandshakeAt?: string;
19
+ firmwareStatus?: DeviceFirmwareStatus;
20
+ firmwareIssue?: DeviceFirmwareIssue;
21
+ ignoredLineCount?: number;
16
22
  messageLog: DeviceLogEntry[];
17
23
  updatedAt: string;
18
24
  }