key-screen-framework 1.3.1 → 1.4.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.
package/installer.nsh CHANGED
@@ -19,7 +19,7 @@
19
19
  Abort
20
20
  ${EndIf}
21
21
 
22
- ${NSD_CreateLabel} 0 0 100% 36u "기본값은 기존 파일 보존입니다. 덮어쓰기를 선택하면 같은 이름의 파일을 인스톨러에 포함된 media 파일로 교체합니다."
22
+ ${NSD_CreateLabel} 0 0 100% 36u "기본값은 기존 파일 보존입니다. 덮어쓰기를 선택하면 사용자 추가 파일을 포함한 기존 media 폴더의 모든 파일을 삭제한 뒤 리소스를 설치합니다."
23
23
  Pop $0
24
24
  ${NSD_CreateCheckbox} 0 44u 100% 20u "기존 리소스 덮어쓰기"
25
25
  Pop $keyScreenMediaOverwriteCheckbox
package/main/index.js CHANGED
@@ -298,8 +298,8 @@ 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 = 1e4;
302
- const HEARTBEAT_TIMEOUT_MS = 22e3;
301
+ const HEARTBEAT_INTERVAL_MS = 2e3;
302
+ const HEARTBEAT_TIMEOUT_MS = 6e3;
303
303
  const knownErrorCodes = /* @__PURE__ */ new Set([
304
304
  "UNKNOWN_COMMAND",
305
305
  "INVALID_TARGET",
@@ -1170,6 +1170,12 @@ class MediaManager {
1170
1170
  if (!sourceRoot.isDirectory()) {
1171
1171
  throw new Error("Media source root must be a directory.");
1172
1172
  }
1173
+ if (options.overwrite) {
1174
+ if (isInsideDirectory(this.rootPath, sourceRootPath)) {
1175
+ throw new Error("Media source root must be outside of the media cleanup directory.");
1176
+ }
1177
+ await rm(this.rootPath, { recursive: true, force: true });
1178
+ }
1173
1179
  await this.ensureDirectories();
1174
1180
  await Promise.all(
1175
1181
  MEDIA_TYPES.map(async (type) => {
@@ -1461,8 +1467,16 @@ function resolveMainRuntimePaths(overrides, context) {
1461
1467
  defaultMediaRoot: overrides?.defaultMediaRoot ?? defaultMediaRoot
1462
1468
  };
1463
1469
  }
1470
+ async function getMediaInstallationId(executablePath) {
1471
+ const file = await stat(executablePath, { bigint: true });
1472
+ return ["v1", file.dev, file.ino, file.birthtimeNs, file.mtimeNs, file.size].join(":");
1473
+ }
1464
1474
  async function installMediaOnFirstLaunch(options) {
1465
- if (options.platform !== "darwin" || !options.isPackaged || options.isDev || options.completed) {
1475
+ if (options.platform !== "darwin" || !options.isPackaged || options.isDev) {
1476
+ return true;
1477
+ }
1478
+ const installationId = await options.getInstallationId();
1479
+ if (options.completedInstallationId === installationId) {
1466
1480
  return true;
1467
1481
  }
1468
1482
  const overwrite = await options.askOverwrite();
@@ -1470,7 +1484,7 @@ async function installMediaOnFirstLaunch(options) {
1470
1484
  return false;
1471
1485
  }
1472
1486
  await options.install(overwrite);
1473
- options.markCompleted();
1487
+ options.markCompleted(installationId);
1474
1488
  return true;
1475
1489
  }
1476
1490
  const requireMainDependency = createRequire(import.meta.url);
@@ -1956,13 +1970,14 @@ function startKeyScreenMain(options) {
1956
1970
  platform: process.platform,
1957
1971
  isPackaged: app.isPackaged,
1958
1972
  isDev,
1959
- completed: store.get("mediaInstallationCompleted", false),
1973
+ completedInstallationId: store.get("mediaInstallationId"),
1974
+ getInstallationId: () => getMediaInstallationId(app.getPath("exe")),
1960
1975
  askOverwrite: async () => {
1961
1976
  const result = await dialog.showMessageBox({
1962
1977
  type: "question",
1963
1978
  title: "리소스 설치 옵션",
1964
1979
  message: "최초 실행에 필요한 media 리소스를 설치합니다.",
1965
- detail: "기본값은 기존 파일 보존입니다. 덮어쓰기를 선택하면 같은 이름의 파일을 앱에 포함된 media 파일로 교체합니다. 사용자 추가 파일은 유지됩니다.",
1980
+ detail: "기본값은 기존 파일 보존입니다. 덮어쓰기를 선택하면 사용자 추가 파일을 포함한 기존 media 폴더의 모든 파일을 삭제한 뒤 앱에 포함된 리소스를 설치합니다.",
1966
1981
  checkboxLabel: "기존 리소스 덮어쓰기",
1967
1982
  checkboxChecked: false,
1968
1983
  buttons: ["리소스 설치", "종료"],
@@ -1972,7 +1987,7 @@ function startKeyScreenMain(options) {
1972
1987
  return result.response === 0 ? result.checkboxChecked : null;
1973
1988
  },
1974
1989
  install: (overwrite) => mediaManager.seedFrom(runtimePaths.defaultMediaRoot, { overwrite }),
1975
- markCompleted: () => store.set("mediaInstallationCompleted", true)
1990
+ markCompleted: (installationId) => store.set("mediaInstallationId", installationId)
1976
1991
  });
1977
1992
  if (!ready) {
1978
1993
  app.quit();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "key-screen-framework",
3
- "version": "1.3.1",
3
+ "version": "1.4.1",
4
4
  "description": "Screen framework for Keyescape desktop projects.",
5
5
  "repository": {
6
6
  "type": "git",
package/renderer/index.js CHANGED
@@ -2508,7 +2508,7 @@ function AdminScreen({ gameState }) {
2508
2508
  value: arduinoDraft.serialHealthyTimeoutMs
2509
2509
  }
2510
2510
  ),
2511
- /* @__PURE__ */ jsx("span", { className: "text-[11px] leading-5 text-text-dim", children: "해당 시간동안 Serial 통신 실패시 키보드 제어 방식으로 변경됩니다." })
2511
+ /* @__PURE__ */ jsx("span", { className: "text-[11px] leading-5 text-text-dim", children: "해당 시간동안 Serial 통신 실패시 키보드 제어 방식으로 변경됩니다. 앱은 2초마다 연결을 확인하므로 4000 이상으로 두세요." })
2512
2512
  ] })
2513
2513
  ] }),
2514
2514
  /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-border-soft bg-surface px-3 py-3", children: [
@@ -1,9 +1,11 @@
1
+ export declare function getMediaInstallationId(executablePath: string): Promise<string>;
1
2
  export declare function installMediaOnFirstLaunch(options: {
2
3
  platform: string;
3
4
  isPackaged: boolean;
4
5
  isDev: boolean;
5
- completed: boolean;
6
+ completedInstallationId?: string;
7
+ getInstallationId: () => Promise<string>;
6
8
  askOverwrite: () => Promise<boolean | null>;
7
9
  install: (overwrite: boolean) => Promise<void>;
8
- markCompleted: () => void;
10
+ markCompleted: (installationId: string) => void;
9
11
  }): Promise<boolean>;
@@ -22,8 +22,8 @@ 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 = 10000;
26
- export declare const HEARTBEAT_TIMEOUT_MS = 22000;
25
+ export declare const HEARTBEAT_INTERVAL_MS = 2000;
26
+ export declare const HEARTBEAT_TIMEOUT_MS = 6000;
27
27
  export declare function buildOutgoingLine(command: ArduinoCommand): string;
28
28
  export declare function buildResponseLine(response: Pick<ArduinoResponse, 'ok' | 'target' | 'code'>): string;
29
29
  export declare function parseIncomingLine(rawLine: string): IncomingSerialMessage | null;