key-screen-framework 1.4.0 → 1.5.0
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/cli/key-screen-framework.mjs +2 -1
- package/cli/publish-release.mjs +238 -0
- package/main/index.js +102 -7
- package/package.json +3 -2
- package/renderer/index.js +64 -5
- package/renderer/styles.css +3 -0
- package/shared/arduino-board.js +29 -0
- package/shared/index.js +2 -1
- package/templates/project/README.md +11 -0
- package/templates/project/package.json +3 -2
- package/types/main/device-controller.d.ts +9 -0
- package/types/main/serial-protocol.d.ts +6 -2
- package/types/shared/arduino-board.d.ts +1 -0
- package/types/shared/types.d.ts +6 -0
|
@@ -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
|
@@ -6,7 +6,7 @@ import { Readable } from "node:stream";
|
|
|
6
6
|
import { fileURLToPath } from "node:url";
|
|
7
7
|
import { app, protocol, dialog, ipcMain, shell, BrowserWindow, screen } 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";
|
|
@@ -298,8 +298,12 @@ function isReloadShortcut(input, platform = process.platform) {
|
|
|
298
298
|
const SERIAL_BAUD_RATE = 115200;
|
|
299
299
|
const REQUEST_TIMEOUT_MS = 500;
|
|
300
300
|
const REQUEST_RETRY_LIMIT = 3;
|
|
301
|
-
const HEARTBEAT_INTERVAL_MS =
|
|
302
|
-
const HEARTBEAT_TIMEOUT_MS =
|
|
301
|
+
const HEARTBEAT_INTERVAL_MS = 2e3;
|
|
302
|
+
const HEARTBEAT_TIMEOUT_MS = 6e3;
|
|
303
|
+
const HEARTBEAT_SLOW_INTERVAL_MS = 1e4;
|
|
304
|
+
const UNRECOGNIZED_LINE_LOG_LIMIT = 3;
|
|
305
|
+
const UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS = 1e4;
|
|
306
|
+
const UNRECOGNIZED_LINE_PREVIEW_LENGTH = 80;
|
|
303
307
|
const knownErrorCodes = /* @__PURE__ */ new Set([
|
|
304
308
|
"UNKNOWN_COMMAND",
|
|
305
309
|
"INVALID_TARGET",
|
|
@@ -358,12 +362,18 @@ function parseIncomingLine(rawLine) {
|
|
|
358
362
|
}
|
|
359
363
|
}
|
|
360
364
|
const now$3 = () => (/* @__PURE__ */ new Date()).toISOString();
|
|
365
|
+
const previewLine = (line) => line.length > UNRECOGNIZED_LINE_PREVIEW_LENGTH ? `${line.slice(0, UNRECOGNIZED_LINE_PREVIEW_LENGTH)}…` : line;
|
|
361
366
|
class DeviceController extends EventEmitter {
|
|
362
367
|
port = null;
|
|
363
368
|
options;
|
|
364
369
|
readBuffer = "";
|
|
365
370
|
heartbeatInterval = null;
|
|
366
371
|
heartbeatTimeout = null;
|
|
372
|
+
heartbeatIntervalMs = HEARTBEAT_INTERVAL_MS;
|
|
373
|
+
handshakeReceived = false;
|
|
374
|
+
ignoredLineCount = 0;
|
|
375
|
+
ignoredSinceSummary = 0;
|
|
376
|
+
lastIgnoredSummaryAt = 0;
|
|
367
377
|
writeQueue = Promise.resolve();
|
|
368
378
|
pendingRequest = null;
|
|
369
379
|
state = {
|
|
@@ -385,7 +395,8 @@ class DeviceController extends EventEmitter {
|
|
|
385
395
|
manufacturer: port.manufacturer ?? void 0,
|
|
386
396
|
serialNumber: port.serialNumber ?? void 0,
|
|
387
397
|
vendorId: port.vendorId ?? void 0,
|
|
388
|
-
productId: port.productId ?? void 0
|
|
398
|
+
productId: port.productId ?? void 0,
|
|
399
|
+
suggestedBoardPreset: suggestArduinoBoardPreset(port.vendorId, port.productId)
|
|
389
400
|
})),
|
|
390
401
|
updatedAt: now$3()
|
|
391
402
|
};
|
|
@@ -395,6 +406,10 @@ class DeviceController extends EventEmitter {
|
|
|
395
406
|
getState() {
|
|
396
407
|
return this.state;
|
|
397
408
|
}
|
|
409
|
+
// 핸드셰이크 실패로 status가 error여도 포트는 열려 있을 수 있다. 업로드 전 포트 해제 판단에 쓴다.
|
|
410
|
+
isPortOpen() {
|
|
411
|
+
return Boolean(this.port?.isOpen);
|
|
412
|
+
}
|
|
398
413
|
logSystemEvent(message) {
|
|
399
414
|
this.state = {
|
|
400
415
|
...this.state,
|
|
@@ -423,6 +438,9 @@ class DeviceController extends EventEmitter {
|
|
|
423
438
|
status: "connecting",
|
|
424
439
|
selectedPortPath: selectedPort,
|
|
425
440
|
lastError: void 0,
|
|
441
|
+
firmwareStatus: "unknown",
|
|
442
|
+
firmwareIssue: void 0,
|
|
443
|
+
ignoredLineCount: 0,
|
|
426
444
|
updatedAt: now$3()
|
|
427
445
|
};
|
|
428
446
|
this.emitState();
|
|
@@ -468,6 +486,7 @@ class DeviceController extends EventEmitter {
|
|
|
468
486
|
this.stopHeartbeat();
|
|
469
487
|
this.pendingRequest = null;
|
|
470
488
|
this.readBuffer = "";
|
|
489
|
+
this.resetFirmwareDetection();
|
|
471
490
|
if (this.port?.isOpen) {
|
|
472
491
|
await new Promise((resolve) => {
|
|
473
492
|
this.port?.close(() => resolve());
|
|
@@ -479,6 +498,9 @@ class DeviceController extends EventEmitter {
|
|
|
479
498
|
status: "disconnected",
|
|
480
499
|
selectedPortPath,
|
|
481
500
|
lastMessage: "Disconnected from device.",
|
|
501
|
+
firmwareStatus: void 0,
|
|
502
|
+
firmwareIssue: void 0,
|
|
503
|
+
ignoredLineCount: void 0,
|
|
482
504
|
updatedAt: now$3()
|
|
483
505
|
};
|
|
484
506
|
this.pushLog("system", this.state.lastMessage);
|
|
@@ -570,6 +592,10 @@ class DeviceController extends EventEmitter {
|
|
|
570
592
|
async handleIncomingLine(rawLine) {
|
|
571
593
|
const parsed = parseIncomingLine(rawLine);
|
|
572
594
|
const trimmed = rawLine.trim();
|
|
595
|
+
if (!parsed && !this.handshakeReceived) {
|
|
596
|
+
this.recordUnrecognizedLine(trimmed);
|
|
597
|
+
return;
|
|
598
|
+
}
|
|
573
599
|
const logDirection = parsed?.type === "err" ? "error" : "in";
|
|
574
600
|
const shouldSkip = this.shouldSkipMessageLog("in", trimmed);
|
|
575
601
|
this.state = {
|
|
@@ -604,15 +630,21 @@ class DeviceController extends EventEmitter {
|
|
|
604
630
|
}
|
|
605
631
|
}
|
|
606
632
|
markHandshake(message) {
|
|
633
|
+
this.handshakeReceived = true;
|
|
607
634
|
this.state = {
|
|
608
635
|
...this.state,
|
|
609
636
|
status: "connected",
|
|
637
|
+
firmwareStatus: "detected",
|
|
638
|
+
firmwareIssue: void 0,
|
|
610
639
|
lastMessage: this.shouldKeepAsLastMessage(message) ? message : this.state.lastMessage,
|
|
611
640
|
lastHandshakeAt: now$3(),
|
|
612
641
|
updatedAt: now$3()
|
|
613
642
|
};
|
|
614
643
|
this.emitState();
|
|
615
644
|
this.refreshHeartbeatTimeout();
|
|
645
|
+
if (this.heartbeatIntervalMs !== HEARTBEAT_INTERVAL_MS) {
|
|
646
|
+
this.scheduleHeartbeat(HEARTBEAT_INTERVAL_MS);
|
|
647
|
+
}
|
|
616
648
|
if (message === "READY") {
|
|
617
649
|
void this.sendHeartbeatPing();
|
|
618
650
|
}
|
|
@@ -620,10 +652,56 @@ class DeviceController extends EventEmitter {
|
|
|
620
652
|
startHeartbeat() {
|
|
621
653
|
this.stopHeartbeat();
|
|
622
654
|
void this.sendHeartbeatPing();
|
|
655
|
+
this.scheduleHeartbeat(HEARTBEAT_INTERVAL_MS);
|
|
656
|
+
this.refreshHeartbeatTimeout();
|
|
657
|
+
}
|
|
658
|
+
scheduleHeartbeat(intervalMs) {
|
|
659
|
+
if (this.heartbeatInterval) {
|
|
660
|
+
clearInterval(this.heartbeatInterval);
|
|
661
|
+
}
|
|
662
|
+
this.heartbeatIntervalMs = intervalMs;
|
|
623
663
|
this.heartbeatInterval = setInterval(() => {
|
|
624
664
|
void this.sendHeartbeatPing();
|
|
625
|
-
},
|
|
626
|
-
|
|
665
|
+
}, intervalMs);
|
|
666
|
+
}
|
|
667
|
+
resetFirmwareDetection() {
|
|
668
|
+
this.handshakeReceived = false;
|
|
669
|
+
this.ignoredLineCount = 0;
|
|
670
|
+
this.ignoredSinceSummary = 0;
|
|
671
|
+
this.lastIgnoredSummaryAt = 0;
|
|
672
|
+
}
|
|
673
|
+
recordUnrecognizedLine(line) {
|
|
674
|
+
if (!line) {
|
|
675
|
+
return;
|
|
676
|
+
}
|
|
677
|
+
this.ignoredLineCount += 1;
|
|
678
|
+
if (this.ignoredLineCount <= UNRECOGNIZED_LINE_LOG_LIMIT) {
|
|
679
|
+
this.pushLog("in", line, "in");
|
|
680
|
+
if (this.ignoredLineCount === UNRECOGNIZED_LINE_LOG_LIMIT) {
|
|
681
|
+
this.lastIgnoredSummaryAt = Date.now();
|
|
682
|
+
this.pushLog(
|
|
683
|
+
"system",
|
|
684
|
+
`Unrecognized serial data is ignored until READY/PONG arrives. Further lines are summarized every ${UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS / 1e3}s.`,
|
|
685
|
+
"system"
|
|
686
|
+
);
|
|
687
|
+
}
|
|
688
|
+
this.state = { ...this.state, ignoredLineCount: this.ignoredLineCount, updatedAt: now$3() };
|
|
689
|
+
this.emitState();
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
this.ignoredSinceSummary += 1;
|
|
693
|
+
if (Date.now() - this.lastIgnoredSummaryAt < UNRECOGNIZED_LINE_SUMMARY_INTERVAL_MS) {
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
this.pushLog(
|
|
697
|
+
"system",
|
|
698
|
+
`Ignored ${this.ignoredSinceSummary} unrecognized serial lines (latest: ${previewLine(line)}).`,
|
|
699
|
+
"system"
|
|
700
|
+
);
|
|
701
|
+
this.ignoredSinceSummary = 0;
|
|
702
|
+
this.lastIgnoredSummaryAt = Date.now();
|
|
703
|
+
this.state = { ...this.state, ignoredLineCount: this.ignoredLineCount, updatedAt: now$3() };
|
|
704
|
+
this.emitState();
|
|
627
705
|
}
|
|
628
706
|
async sendHeartbeatPing() {
|
|
629
707
|
if (!this.port?.isOpen) {
|
|
@@ -648,6 +726,7 @@ class DeviceController extends EventEmitter {
|
|
|
648
726
|
clearInterval(this.heartbeatInterval);
|
|
649
727
|
this.heartbeatInterval = null;
|
|
650
728
|
}
|
|
729
|
+
this.heartbeatIntervalMs = HEARTBEAT_INTERVAL_MS;
|
|
651
730
|
if (this.heartbeatTimeout) {
|
|
652
731
|
clearTimeout(this.heartbeatTimeout);
|
|
653
732
|
this.heartbeatTimeout = null;
|
|
@@ -661,6 +740,22 @@ class DeviceController extends EventEmitter {
|
|
|
661
740
|
if (!this.port?.isOpen) {
|
|
662
741
|
return;
|
|
663
742
|
}
|
|
743
|
+
if (!this.handshakeReceived) {
|
|
744
|
+
this.state = {
|
|
745
|
+
...this.state,
|
|
746
|
+
status: "error",
|
|
747
|
+
lastError: "No READY/PONG since connecting: the framework firmware is probably not uploaded to this board.",
|
|
748
|
+
lastHandshakeAt: void 0,
|
|
749
|
+
firmwareStatus: "missing",
|
|
750
|
+
firmwareIssue: this.ignoredLineCount > 0 ? "unrecognized-data" : "silent",
|
|
751
|
+
ignoredLineCount: this.ignoredLineCount,
|
|
752
|
+
updatedAt: now$3()
|
|
753
|
+
};
|
|
754
|
+
this.pushLog("error", this.state.lastError, "system");
|
|
755
|
+
this.emitState();
|
|
756
|
+
this.scheduleHeartbeat(HEARTBEAT_SLOW_INTERVAL_MS);
|
|
757
|
+
return;
|
|
758
|
+
}
|
|
664
759
|
this.state = {
|
|
665
760
|
...this.state,
|
|
666
761
|
status: "error",
|
|
@@ -1728,7 +1823,7 @@ function startKeyScreenMain(options) {
|
|
|
1728
1823
|
const sketchDir = await writeGeneratedArduinoSketch(preview.source);
|
|
1729
1824
|
if (action === "upload") {
|
|
1730
1825
|
const deviceState = deviceController.getState();
|
|
1731
|
-
previousPortPath =
|
|
1826
|
+
previousPortPath = deviceController.isPortOpen() ? deviceState.selectedPortPath : void 0;
|
|
1732
1827
|
shouldReconnect = Boolean(previousPortPath);
|
|
1733
1828
|
const uploadPortPath = portPath ?? previousPortPath;
|
|
1734
1829
|
if (!uploadPortPath) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "key-screen-framework",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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
|
|
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
|
|
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(
|
|
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: [
|
|
@@ -2508,7 +2567,7 @@ function AdminScreen({ gameState }) {
|
|
|
2508
2567
|
value: arduinoDraft.serialHealthyTimeoutMs
|
|
2509
2568
|
}
|
|
2510
2569
|
),
|
|
2511
|
-
/* @__PURE__ */ jsx("span", { className: "text-[11px] leading-5 text-text-dim", children: "해당 시간동안 Serial 통신 실패시 키보드 제어 방식으로 변경됩니다." })
|
|
2570
|
+
/* @__PURE__ */ jsx("span", { className: "text-[11px] leading-5 text-text-dim", children: "해당 시간동안 Serial 통신 실패시 키보드 제어 방식으로 변경됩니다. 앱은 2초마다 연결을 확인하므로 4000 이상으로 두세요." })
|
|
2512
2571
|
] })
|
|
2513
2572
|
] }),
|
|
2514
2573
|
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border-soft bg-surface px-3 py-3", children: [
|
package/renderer/styles.css
CHANGED
package/shared/arduino-board.js
CHANGED
|
@@ -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",
|
|
@@ -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;
|
|
@@ -22,8 +22,12 @@ export type IncomingSerialMessage = {
|
|
|
22
22
|
export declare const SERIAL_BAUD_RATE = 115200;
|
|
23
23
|
export declare const REQUEST_TIMEOUT_MS = 500;
|
|
24
24
|
export declare const REQUEST_RETRY_LIMIT = 3;
|
|
25
|
-
export declare const HEARTBEAT_INTERVAL_MS =
|
|
26
|
-
export declare const HEARTBEAT_TIMEOUT_MS =
|
|
25
|
+
export declare const HEARTBEAT_INTERVAL_MS = 2000;
|
|
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;
|
|
@@ -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;
|
package/types/shared/types.d.ts
CHANGED
|
@@ -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
|
}
|