@kirill.konshin/utils 0.0.19 → 0.0.21

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.
Files changed (352) hide show
  1. package/README.md +6 -0
  2. package/dist/bootstrap/index.d.ts +1 -12
  3. package/dist/bootstrap/index.d.ts.map +1 -1
  4. package/dist/bootstrap/index.js +2 -35
  5. package/dist/browser/index.d.ts +2 -0
  6. package/dist/browser/index.d.ts.map +1 -0
  7. package/dist/browser/index.js +2 -0
  8. package/dist/core/index.d.ts +1 -9
  9. package/dist/core/index.d.ts.map +1 -1
  10. package/dist/core/index.js +2 -35
  11. package/dist/electron/index.d.ts +1 -2
  12. package/dist/electron/index.d.ts.map +1 -1
  13. package/dist/electron/index.js +2 -9
  14. package/dist/electron-builder/index.d.ts +1 -2
  15. package/dist/electron-builder/index.d.ts.map +1 -1
  16. package/dist/electron-builder/index.js +2 -7
  17. package/dist/index.d.ts +13 -0
  18. package/dist/index.d.ts.map +1 -0
  19. package/dist/index.js +13 -0
  20. package/dist/mui/index.d.ts +1 -4
  21. package/dist/mui/index.d.ts.map +1 -1
  22. package/dist/mui/index.js +2 -11
  23. package/dist/next/index.d.ts +1 -5
  24. package/dist/next/index.d.ts.map +1 -1
  25. package/dist/next/index.js +2 -15
  26. package/dist/node/index.d.ts +2 -0
  27. package/dist/node/index.d.ts.map +1 -0
  28. package/dist/node/index.js +2 -0
  29. package/dist/react/index.d.ts +1 -5
  30. package/dist/react/index.d.ts.map +1 -1
  31. package/dist/react/index.js +2 -26
  32. package/dist/react-native/index.d.ts +1 -3
  33. package/dist/react-native/index.d.ts.map +1 -1
  34. package/dist/react-native/index.js +2 -9
  35. package/dist/tailwind/index.d.ts +1 -2
  36. package/dist/tailwind/index.d.ts.map +1 -1
  37. package/dist/tailwind/index.js +2 -7
  38. package/dist/worker/index.d.ts +2 -0
  39. package/dist/worker/index.d.ts.map +1 -0
  40. package/dist/worker/index.js +2 -0
  41. package/package.json +51 -99
  42. package/.ctirc +0 -11
  43. package/.storybook/main.ts +0 -21
  44. package/.storybook/preview.ts +0 -17
  45. package/.turbo/turbo-build.log +0 -72
  46. package/.turbo/turbo-test.log +0 -171
  47. package/CHANGELOG.md +0 -116
  48. package/builders/.swcrc +0 -18
  49. package/builders/build.config.ts +0 -11
  50. package/builders/bun.build.js +0 -23
  51. package/builders/package.json +0 -209
  52. package/builders/perf.mjs +0 -63
  53. package/builders/rollup.config.mjs +0 -50
  54. package/builders/rslib.config.ts +0 -26
  55. package/builders/tsconfig.json +0 -21
  56. package/builders/tsup.config.ts +0 -20
  57. package/builders/turbo.json +0 -24
  58. package/builders/vite.config.ts +0 -37
  59. package/demo/worker-demo.ts +0 -73
  60. package/dist/bootstrap/adaptiveContainer.d.ts +0 -4
  61. package/dist/bootstrap/adaptiveContainer.d.ts.map +0 -1
  62. package/dist/bootstrap/adaptiveContainer.js +0 -11
  63. package/dist/bootstrap/adaptiveContainer.js.map +0 -1
  64. package/dist/bootstrap/controls.d.ts +0 -38
  65. package/dist/bootstrap/controls.d.ts.map +0 -1
  66. package/dist/bootstrap/controls.js +0 -78
  67. package/dist/bootstrap/controls.js.map +0 -1
  68. package/dist/bootstrap/controls.stories.d.ts +0 -9
  69. package/dist/bootstrap/controls.stories.d.ts.map +0 -1
  70. package/dist/bootstrap/error.d.ts +0 -9
  71. package/dist/bootstrap/error.d.ts.map +0 -1
  72. package/dist/bootstrap/error.js +0 -27
  73. package/dist/bootstrap/error.js.map +0 -1
  74. package/dist/bootstrap/error.stories.d.ts +0 -8
  75. package/dist/bootstrap/error.stories.d.ts.map +0 -1
  76. package/dist/bootstrap/field.d.ts +0 -11
  77. package/dist/bootstrap/field.d.ts.map +0 -1
  78. package/dist/bootstrap/field.js +0 -29
  79. package/dist/bootstrap/field.js.map +0 -1
  80. package/dist/bootstrap/field.stories.d.ts +0 -8
  81. package/dist/bootstrap/field.stories.d.ts.map +0 -1
  82. package/dist/bootstrap/footer.d.ts +0 -10
  83. package/dist/bootstrap/footer.d.ts.map +0 -1
  84. package/dist/bootstrap/footer.js +0 -45
  85. package/dist/bootstrap/footer.js.map +0 -1
  86. package/dist/bootstrap/globalLoading.d.ts +0 -6
  87. package/dist/bootstrap/globalLoading.d.ts.map +0 -1
  88. package/dist/bootstrap/globalLoading.js +0 -10
  89. package/dist/bootstrap/globalLoading.js.map +0 -1
  90. package/dist/bootstrap/globalLoading.stories.d.ts +0 -7
  91. package/dist/bootstrap/globalLoading.stories.d.ts.map +0 -1
  92. package/dist/bootstrap/index.js.map +0 -1
  93. package/dist/bootstrap/loading.d.ts +0 -10
  94. package/dist/bootstrap/loading.d.ts.map +0 -1
  95. package/dist/bootstrap/loading.js +0 -19
  96. package/dist/bootstrap/loading.js.map +0 -1
  97. package/dist/bootstrap/loading.stories.d.ts +0 -9
  98. package/dist/bootstrap/loading.stories.d.ts.map +0 -1
  99. package/dist/bootstrap/responsiveHelper.d.ts +0 -8
  100. package/dist/bootstrap/responsiveHelper.d.ts.map +0 -1
  101. package/dist/bootstrap/responsiveHelper.js +0 -46
  102. package/dist/bootstrap/responsiveHelper.js.map +0 -1
  103. package/dist/bootstrap/screen.d.ts +0 -22
  104. package/dist/bootstrap/screen.d.ts.map +0 -1
  105. package/dist/bootstrap/screen.js +0 -80
  106. package/dist/bootstrap/screen.js.map +0 -1
  107. package/dist/bootstrap/screen.stories.d.ts +0 -14
  108. package/dist/bootstrap/screen.stories.d.ts.map +0 -1
  109. package/dist/bootstrap/toaster.d.ts +0 -11
  110. package/dist/bootstrap/toaster.d.ts.map +0 -1
  111. package/dist/bootstrap/toaster.js +0 -34
  112. package/dist/bootstrap/toaster.js.map +0 -1
  113. package/dist/bootstrap/toaster.stories.d.ts +0 -8
  114. package/dist/bootstrap/toaster.stories.d.ts.map +0 -1
  115. package/dist/bootstrap/useModal.d.ts +0 -23
  116. package/dist/bootstrap/useModal.d.ts.map +0 -1
  117. package/dist/bootstrap/useModal.js +0 -50
  118. package/dist/bootstrap/useModal.js.map +0 -1
  119. package/dist/bootstrap/useModal.stories.d.ts +0 -9
  120. package/dist/bootstrap/useModal.stories.d.ts.map +0 -1
  121. package/dist/bootstrap/useWrappedForm.d.ts +0 -14
  122. package/dist/bootstrap/useWrappedForm.d.ts.map +0 -1
  123. package/dist/bootstrap/useWrappedForm.js +0 -32
  124. package/dist/bootstrap/useWrappedForm.js.map +0 -1
  125. package/dist/core/cache.d.ts +0 -120
  126. package/dist/core/cache.d.ts.map +0 -1
  127. package/dist/core/cache.js +0 -107
  128. package/dist/core/cache.js.map +0 -1
  129. package/dist/core/cache.test.d.ts +0 -2
  130. package/dist/core/cache.test.d.ts.map +0 -1
  131. package/dist/core/errors.d.ts +0 -2
  132. package/dist/core/errors.d.ts.map +0 -1
  133. package/dist/core/errors.js +0 -15
  134. package/dist/core/errors.js.map +0 -1
  135. package/dist/core/files.d.ts +0 -4
  136. package/dist/core/files.d.ts.map +0 -1
  137. package/dist/core/files.js +0 -31
  138. package/dist/core/files.js.map +0 -1
  139. package/dist/core/index.js.map +0 -1
  140. package/dist/core/ls.d.ts +0 -6
  141. package/dist/core/ls.d.ts.map +0 -1
  142. package/dist/core/ls.js +0 -12
  143. package/dist/core/ls.js.map +0 -1
  144. package/dist/core/measure.d.ts +0 -35
  145. package/dist/core/measure.d.ts.map +0 -1
  146. package/dist/core/measure.js +0 -60
  147. package/dist/core/measure.js.map +0 -1
  148. package/dist/core/mutex.d.ts +0 -6
  149. package/dist/core/mutex.d.ts.map +0 -1
  150. package/dist/core/mutex.js +0 -26
  151. package/dist/core/mutex.js.map +0 -1
  152. package/dist/core/worker.d.ts +0 -98
  153. package/dist/core/worker.d.ts.map +0 -1
  154. package/dist/core/worker.js +0 -240
  155. package/dist/core/worker.js.map +0 -1
  156. package/dist/core/worker.test.d.ts +0 -2
  157. package/dist/core/worker.test.d.ts.map +0 -1
  158. package/dist/core/workerUtils.d.ts +0 -3
  159. package/dist/core/workerUtils.d.ts.map +0 -1
  160. package/dist/core/workerUtils.js +0 -31
  161. package/dist/core/workerUtils.js.map +0 -1
  162. package/dist/core/wrpc.d.ts +0 -45
  163. package/dist/core/wrpc.d.ts.map +0 -1
  164. package/dist/core/wrpc.fixture.d.ts +0 -26
  165. package/dist/core/wrpc.fixture.d.ts.map +0 -1
  166. package/dist/core/wrpc.js +0 -242
  167. package/dist/core/wrpc.js.map +0 -1
  168. package/dist/core/wrpc.test.d.ts +0 -1
  169. package/dist/core/wrpc.test.d.ts.map +0 -1
  170. package/dist/electron/createWindow.d.ts +0 -23
  171. package/dist/electron/createWindow.d.ts.map +0 -1
  172. package/dist/electron/createWindow.js +0 -160
  173. package/dist/electron/createWindow.js.map +0 -1
  174. package/dist/electron/index.js.map +0 -1
  175. package/dist/electron/updater.d.ts +0 -2
  176. package/dist/electron/updater.d.ts.map +0 -1
  177. package/dist/electron/updater.js +0 -47
  178. package/dist/electron/updater.js.map +0 -1
  179. package/dist/electron-builder/builder.d.ts +0 -8
  180. package/dist/electron-builder/builder.d.ts.map +0 -1
  181. package/dist/electron-builder/builder.js +0 -130
  182. package/dist/electron-builder/builder.js.map +0 -1
  183. package/dist/electron-builder/images.d.ts +0 -7
  184. package/dist/electron-builder/images.d.ts.map +0 -1
  185. package/dist/electron-builder/images.js +0 -25
  186. package/dist/electron-builder/images.js.map +0 -1
  187. package/dist/electron-builder/index.js.map +0 -1
  188. package/dist/mui/formControlFieldset.d.ts +0 -5
  189. package/dist/mui/formControlFieldset.d.ts.map +0 -1
  190. package/dist/mui/formControlFieldset.js +0 -28
  191. package/dist/mui/formControlFieldset.js.map +0 -1
  192. package/dist/mui/formControlFieldset.stories.d.ts +0 -7
  193. package/dist/mui/formControlFieldset.stories.d.ts.map +0 -1
  194. package/dist/mui/formLabelLegend.d.ts +0 -4
  195. package/dist/mui/formLabelLegend.d.ts.map +0 -1
  196. package/dist/mui/formLabelLegend.js +0 -12
  197. package/dist/mui/formLabelLegend.js.map +0 -1
  198. package/dist/mui/genericControl.d.ts +0 -7
  199. package/dist/mui/genericControl.d.ts.map +0 -1
  200. package/dist/mui/genericControl.js +0 -21
  201. package/dist/mui/genericControl.js.map +0 -1
  202. package/dist/mui/index.js.map +0 -1
  203. package/dist/mui/readOnly.d.ts +0 -6
  204. package/dist/mui/readOnly.d.ts.map +0 -1
  205. package/dist/mui/readOnly.js +0 -7
  206. package/dist/mui/readOnly.js.map +0 -1
  207. package/dist/next/appLink.d.ts +0 -8
  208. package/dist/next/appLink.d.ts.map +0 -1
  209. package/dist/next/appLink.js +0 -34
  210. package/dist/next/appLink.js.map +0 -1
  211. package/dist/next/index.js.map +0 -1
  212. package/dist/next/measure.d.ts +0 -15
  213. package/dist/next/measure.d.ts.map +0 -1
  214. package/dist/next/measure.js +0 -9
  215. package/dist/next/measure.js.map +0 -1
  216. package/dist/next/noSSR.d.ts +0 -29
  217. package/dist/next/noSSR.d.ts.map +0 -1
  218. package/dist/next/noSSR.js +0 -13
  219. package/dist/next/noSSR.js.map +0 -1
  220. package/dist/next/redirect.d.ts +0 -6
  221. package/dist/next/redirect.d.ts.map +0 -1
  222. package/dist/next/useIsInner.d.ts +0 -3
  223. package/dist/next/useIsInner.d.ts.map +0 -1
  224. package/dist/next/useIsInner.js +0 -15
  225. package/dist/next/useIsInner.js.map +0 -1
  226. package/dist/react/apiCall.d.ts +0 -6
  227. package/dist/react/apiCall.d.ts.map +0 -1
  228. package/dist/react/apiCall.js +0 -24
  229. package/dist/react/apiCall.js.map +0 -1
  230. package/dist/react/form/client.d.ts +0 -7
  231. package/dist/react/form/client.d.ts.map +0 -1
  232. package/dist/react/form/client.js +0 -46
  233. package/dist/react/form/client.js.map +0 -1
  234. package/dist/react/form/form.d.ts +0 -59
  235. package/dist/react/form/form.d.ts.map +0 -1
  236. package/dist/react/form/form.js +0 -89
  237. package/dist/react/form/form.js.map +0 -1
  238. package/dist/react/form/index.d.ts +0 -3
  239. package/dist/react/form/index.d.ts.map +0 -1
  240. package/dist/react/index.js.map +0 -1
  241. package/dist/react/keyboard.d.ts +0 -10
  242. package/dist/react/keyboard.d.ts.map +0 -1
  243. package/dist/react/keyboard.js +0 -38
  244. package/dist/react/keyboard.js.map +0 -1
  245. package/dist/react/useFetch.d.ts +0 -2
  246. package/dist/react/useFetch.d.ts.map +0 -1
  247. package/dist/react/useFetch.js +0 -20
  248. package/dist/react/useFetch.js.map +0 -1
  249. package/dist/react/useFetcher.d.ts +0 -10
  250. package/dist/react/useFetcher.d.ts.map +0 -1
  251. package/dist/react/useFetcher.js +0 -43
  252. package/dist/react/useFetcher.js.map +0 -1
  253. package/dist/react-native/index.js.map +0 -1
  254. package/dist/react-native/share.d.ts +0 -9
  255. package/dist/react-native/share.d.ts.map +0 -1
  256. package/dist/react-native/share.js +0 -23
  257. package/dist/react-native/share.js.map +0 -1
  258. package/dist/react-native/update.d.ts +0 -3
  259. package/dist/react-native/update.d.ts.map +0 -1
  260. package/dist/react-native/update.js +0 -40
  261. package/dist/react-native/update.js.map +0 -1
  262. package/dist/react-native/useAppState.d.ts +0 -2
  263. package/dist/react-native/useAppState.d.ts.map +0 -1
  264. package/dist/react-native/useAppState.js +0 -18
  265. package/dist/react-native/useAppState.js.map +0 -1
  266. package/dist/tailwind/fullpage.d.ts +0 -3
  267. package/dist/tailwind/fullpage.d.ts.map +0 -1
  268. package/dist/tailwind/fullpage.js +0 -14
  269. package/dist/tailwind/fullpage.js.map +0 -1
  270. package/dist/tailwind/index.js.map +0 -1
  271. package/dist/tailwind/responsiveHelper.d.ts +0 -3
  272. package/dist/tailwind/responsiveHelper.d.ts.map +0 -1
  273. package/dist/tailwind/responsiveHelper.js +0 -16
  274. package/dist/tailwind/responsiveHelper.js.map +0 -1
  275. package/src/bootstrap/adaptiveContainer.tsx +0 -12
  276. package/src/bootstrap/controls.stories.tsx +0 -62
  277. package/src/bootstrap/controls.tsx +0 -119
  278. package/src/bootstrap/error.stories.tsx +0 -34
  279. package/src/bootstrap/error.tsx +0 -37
  280. package/src/bootstrap/field.stories.tsx +0 -42
  281. package/src/bootstrap/field.tsx +0 -37
  282. package/src/bootstrap/footer.tsx +0 -61
  283. package/src/bootstrap/globalLoading.stories.tsx +0 -25
  284. package/src/bootstrap/globalLoading.tsx +0 -19
  285. package/src/bootstrap/index.ts +0 -12
  286. package/src/bootstrap/loading.stories.tsx +0 -35
  287. package/src/bootstrap/loading.tsx +0 -24
  288. package/src/bootstrap/main.scss +0 -86
  289. package/src/bootstrap/responsiveHelper.tsx +0 -55
  290. package/src/bootstrap/screen.stories.tsx +0 -160
  291. package/src/bootstrap/screen.tsx +0 -146
  292. package/src/bootstrap/toaster.stories.tsx +0 -32
  293. package/src/bootstrap/toaster.tsx +0 -40
  294. package/src/bootstrap/useModal.stories.tsx +0 -51
  295. package/src/bootstrap/useModal.tsx +0 -93
  296. package/src/bootstrap/useWrappedForm.ts +0 -42
  297. package/src/core/README.md +0 -91
  298. package/src/core/cache.test.ts +0 -121
  299. package/src/core/cache.ts +0 -246
  300. package/src/core/errors.ts +0 -17
  301. package/src/core/files.ts +0 -29
  302. package/src/core/index.ts +0 -9
  303. package/src/core/ls.ts +0 -15
  304. package/src/core/measure.ts +0 -109
  305. package/src/core/mutex.ts +0 -22
  306. package/src/core/worker.test.ts +0 -197
  307. package/src/core/worker.ts +0 -347
  308. package/src/core/workerUtils.ts +0 -32
  309. package/src/core/wrpc.fixture.ts +0 -106
  310. package/src/core/wrpc.test.ts +0 -225
  311. package/src/core/wrpc.ts +0 -377
  312. package/src/electron/README.md +0 -13
  313. package/src/electron/createWindow.ts +0 -234
  314. package/src/electron/index.ts +0 -2
  315. package/src/electron/updater.ts +0 -54
  316. package/src/electron-builder/builder.ts +0 -150
  317. package/src/electron-builder/images.ts +0 -33
  318. package/src/electron-builder/index.ts +0 -2
  319. package/src/mui/README.md +0 -3
  320. package/src/mui/formControlFieldset.stories.tsx +0 -71
  321. package/src/mui/formControlFieldset.tsx +0 -26
  322. package/src/mui/formLabelLegend.tsx +0 -11
  323. package/src/mui/genericControl.tsx +0 -20
  324. package/src/mui/index.ts +0 -4
  325. package/src/mui/readOnly.tsx +0 -6
  326. package/src/next/appLink.tsx +0 -40
  327. package/src/next/index.ts +0 -5
  328. package/src/next/measure.ts +0 -24
  329. package/src/next/noSSR.tsx +0 -36
  330. package/src/next/redirect.tsx +0 -13
  331. package/src/next/useIsInner.ts +0 -13
  332. package/src/react/apiCall.ts +0 -25
  333. package/src/react/form/client.tsx +0 -73
  334. package/src/react/form/form.tsx +0 -178
  335. package/src/react/form/index.ts +0 -2
  336. package/src/react/index.ts +0 -5
  337. package/src/react/keyboard.tsx +0 -54
  338. package/src/react/useFetch.ts +0 -29
  339. package/src/react/useFetcher.ts +0 -54
  340. package/src/react-native/index.ts +0 -3
  341. package/src/react-native/share.ts +0 -31
  342. package/src/react-native/update.tsx +0 -40
  343. package/src/react-native/useAppState.ts +0 -18
  344. package/src/tailwind/README.md +0 -8
  345. package/src/tailwind/fullpage.tsx +0 -11
  346. package/src/tailwind/index.ts +0 -2
  347. package/src/tailwind/responsiveHelper.tsx +0 -16
  348. package/src-todo/auth0.tsx +0 -177
  349. package/tsconfig.json +0 -23
  350. package/turbo.json +0 -10
  351. package/vite.config.ts +0 -56
  352. package/vite.exports.ts +0 -121
@@ -1,234 +0,0 @@
1
- import path from 'node:path';
2
- import https from 'node:https';
3
- import http from 'node:http';
4
- import fs from 'node:fs';
5
- import fsp from 'node:fs/promises';
6
- import url from 'node:url';
7
- import { Menu, app, BrowserWindow, shell, protocol, Rectangle } from 'electron';
8
- import defaultMenu from 'electron-default-menu';
9
- import Store from 'electron-store';
10
- import { checkForUpdates } from './updater.js';
11
-
12
- export const isDev: boolean = process.env['NODE_ENV'] === 'development';
13
- export const appPath: string = app.getAppPath();
14
-
15
- // See https://cs.chromium.org/chromium/src/net/base/net_error_list.h
16
- const FILE_NOT_FOUND = -6;
17
-
18
- const getPath = async (path_, file = '') => {
19
- try {
20
- const result = await fsp.stat(path_);
21
-
22
- if (result.isFile()) return path_;
23
-
24
- if (result.isDirectory()) return getPath(path.join(path_, `${file}.html`));
25
- } catch {
26
- /* empty */
27
- }
28
- };
29
-
30
- export function createWindow({
31
- width = 1000,
32
- height = 1000,
33
- disableSecurity = true,
34
- disableSecurityWarnings = true,
35
- quitOnClose = true,
36
- onOpen,
37
- onClose,
38
- localhostUrl = 'http://localhost:3000',
39
- productionUrl = '', // in this mode Electron acts as a browser for remote app
40
- webPath = path.resolve(appPath, 'web'), // must conform to what is in electron-builder.js files section
41
- useStaticInDev = false,
42
- updater = false,
43
- rememberBounds = true,
44
- }: {
45
- width?: number;
46
- height?: number;
47
- disableSecurity?: boolean;
48
- disableSecurityWarnings?: boolean;
49
- quitOnClose?: boolean;
50
- onOpen?: (win: BrowserWindow) => void;
51
- onClose?: (win: BrowserWindow) => void;
52
- localhostUrl?: string;
53
- productionUrl?: string;
54
- webPath?: string;
55
- useStaticInDev?: boolean;
56
- updater?: boolean;
57
- rememberBounds?: boolean;
58
- } = {}) {
59
- let mainWindow: BrowserWindow | null = null;
60
-
61
- console.log('[APP] Starting Electron', {
62
- isDev,
63
- appPath,
64
- useStaticInDev,
65
- localhostUrl,
66
- productionUrl,
67
- webPath,
68
- updater,
69
- rememberBounds,
70
- quitOnClose,
71
- disableSecurity,
72
- disableSecurityWarnings,
73
- });
74
-
75
- if (!productionUrl && !webPath) {
76
- throw new Error('productionUrl or webPath must be defined');
77
- }
78
-
79
- if (productionUrl && webPath) {
80
- throw new Error('productionUrl and webPath cannot be used together');
81
- }
82
-
83
- if (!localhostUrl) {
84
- throw new Error('localhostUrl must be defined');
85
- }
86
-
87
- const store = new Store<{ bounds: Rectangle }>({
88
- schema: {
89
- bounds: {
90
- type: 'object',
91
- properties: {
92
- // Docs: https://electronjs.org/docs/api/structures/rectangle
93
- height: { type: 'number' },
94
- width: { type: 'number' },
95
- x: { type: 'number' },
96
- y: { type: 'number' },
97
- },
98
- },
99
- },
100
- });
101
-
102
- if (disableSecurityWarnings) process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
103
- process.env['ELECTRON_ENABLE_LOGGING'] = 'true';
104
-
105
- process.on('SIGTERM', () => process.exit(0));
106
- process.on('SIGINT', () => process.exit(0));
107
-
108
- const openDevTools = () => {
109
- if (!mainWindow) return;
110
- mainWindow.setSize(width + 800, height);
111
- mainWindow.center();
112
- mainWindow.webContents.openDevTools();
113
- };
114
-
115
- const createWindow = async () => {
116
- mainWindow = new BrowserWindow({
117
- width,
118
- height,
119
- icon: path.resolve(appPath, 'assets/icon.png'),
120
- webPreferences: {
121
- nodeIntegration: false, // is default value after Electron v5
122
- contextIsolation: true, // protect against prototype pollution
123
- webSecurity: !disableSecurity,
124
- devTools: true,
125
- },
126
- ...(rememberBounds ? store.get('bounds') : {}),
127
- });
128
-
129
- mainWindow.on('move', () => rememberBounds && mainWindow && store.set('bounds', mainWindow.getBounds()));
130
-
131
- mainWindow.once('ready-to-show', () => isDev && openDevTools());
132
-
133
- // Static interceptor
134
-
135
- let interceptor: (() => void) | null = null;
136
-
137
- if (webPath && (!isDev || useStaticInDev)) {
138
- console.log(`[APP] Static Server Enabled, ${localhostUrl} will be intercepted to ${webPath}`);
139
-
140
- //TODO https://localhost:3000
141
- // @see https://github.com/sindresorhus/electron-serve/blob/main/index.js
142
- protocol.interceptStreamProtocol('http', (request, callback) => {
143
- if (request.url.startsWith(localhostUrl)) {
144
- let fileUrl = url.parse(request.url, false).pathname;
145
-
146
- if (!fileUrl) return callback({ error: FILE_NOT_FOUND });
147
-
148
- if (fileUrl === '/') fileUrl = 'index.html';
149
-
150
- const filePath = path.join(webPath, fileUrl);
151
-
152
- const relativePath = path.relative(webPath, fileUrl);
153
-
154
- const isSafe = !relativePath.startsWith('..') && !path.isAbsolute(relativePath);
155
-
156
- if (!isSafe && !isDev) return callback({ error: FILE_NOT_FOUND });
157
-
158
- // const finalPath = await getPath(filePath, options.file);
159
- // const fileExtension = path.extname(filePath);
160
-
161
- console.log('[APP] Static Server', fileUrl, '->', filePath);
162
-
163
- // return {path: path.join(webPath, fileUrl)};
164
- callback(fs.createReadStream(filePath));
165
-
166
- return true;
167
- }
168
-
169
- // return {url: request.url};
170
- (request.url.startsWith('https') ? https : http).get(request.url, callback);
171
-
172
- return true;
173
- });
174
-
175
- interceptor = () => protocol.uninterceptProtocol('http');
176
- }
177
-
178
- mainWindow.on('closed', () => {
179
- interceptor?.();
180
- onClose?.(mainWindow as never);
181
- mainWindow = null;
182
- interceptor = null;
183
- });
184
-
185
- // External URLs
186
-
187
- mainWindow.webContents.setWindowOpenHandler(({ url }) => {
188
- shell.openExternal(url).catch((e) => console.error(e));
189
- return { action: 'deny' };
190
- });
191
-
192
- // Menu
193
-
194
- const menu = defaultMenu(app, shell);
195
-
196
- if (updater) {
197
- (menu.at(-1)!.submenu as any).push(
198
- { type: 'separator' },
199
- {
200
- label: 'Check For Updates',
201
- click: checkForUpdates,
202
- },
203
- );
204
- }
205
-
206
- Menu.setApplicationMenu(Menu.buildFromTemplate(menu)); //TODO onMenu
207
-
208
- // Should be last, after all listeners and menu
209
-
210
- await app.whenReady();
211
-
212
- onOpen?.(mainWindow);
213
-
214
- if (!onOpen && localhostUrl) {
215
- await mainWindow.loadURL(productionUrl && !isDev ? productionUrl : `${localhostUrl}/`);
216
- }
217
-
218
- console.log('[APP] Main Window Open');
219
- };
220
-
221
- app.on('ready', createWindow);
222
-
223
- app.on('window-all-closed', () => {
224
- if (process.platform !== 'darwin' || quitOnClose) app.quit();
225
- });
226
-
227
- app.on('activate', () => BrowserWindow.getAllWindows().length === 0 && !mainWindow && createWindow());
228
-
229
- return {
230
- get mainWindow(): BrowserWindow | null {
231
- return mainWindow;
232
- },
233
- };
234
- }
@@ -1,2 +0,0 @@
1
- export * from './createWindow';
2
- export * from './updater';
@@ -1,54 +0,0 @@
1
- // https://github.com/electron-userland/electron-builder/blob/docs-deprecated/encapsulated%20manual%20update%20via%20menu.js
2
- import { dialog } from 'electron';
3
- import updater from 'electron-updater';
4
- const { autoUpdater } = updater;
5
-
6
- let updateButton;
7
-
8
- autoUpdater.autoDownload = false;
9
-
10
- autoUpdater.on('error', (error) => {
11
- dialog.showErrorBox('Error: ', !error ? 'unknown' : (error.stack || error).toString());
12
- });
13
-
14
- autoUpdater.on('update-available', async () => {
15
- const { response } = await dialog.showMessageBox({
16
- type: 'info',
17
- title: 'Found Updates',
18
- message: 'Found updates, do you want update now?',
19
- buttons: ['Yes', 'No'],
20
- });
21
-
22
- updateButton.enabled = true;
23
- updateButton = null;
24
-
25
- if (response === 0) await autoUpdater.downloadUpdate();
26
- });
27
-
28
- autoUpdater.on('update-not-available', async () => {
29
- try {
30
- await dialog.showMessageBox({
31
- title: 'No Updates',
32
- message: 'Current version is up-to-date.',
33
- });
34
- } catch (e) {
35
- dialog.showErrorBox('Error: ', e.toString());
36
- }
37
- updateButton.enabled = true;
38
- updateButton = null;
39
- });
40
-
41
- autoUpdater.on('update-downloaded', async () => {
42
- await dialog.showMessageBox({
43
- title: 'Install Update',
44
- message: 'Update downloaded, application will quit for update...',
45
- });
46
-
47
- autoUpdater.quitAndInstall();
48
- });
49
-
50
- export function checkForUpdates(menuItem: any): void {
51
- updateButton = menuItem;
52
- updateButton.enabled = false;
53
- autoUpdater.checkForUpdates().catch((e) => console.error('Update error', e));
54
- }
@@ -1,150 +0,0 @@
1
- import type { Configuration, MacConfiguration } from 'electron-builder';
2
- import type { GithubOptions, S3Options } from 'builder-util-runtime';
3
-
4
- const {
5
- GITHUB_REF_TYPE,
6
- GITHUB_REF_NAME,
7
- GITHUB_RUN_ID,
8
- GITHUB_REF,
9
- AWS_URL,
10
- AWS_ACCESS_KEY_ID,
11
- AWS_SECRET_ACCESS_KEY,
12
- GH_TOKEN,
13
- CSC_IDENTITY_AUTO_DISCOVERY,
14
- } = process.env;
15
-
16
- const isGithubTag = GITHUB_REF_TYPE === 'tag';
17
- const isGithubMaster = GITHUB_REF_TYPE === 'branch' && GITHUB_REF_NAME === 'master';
18
- const isDevPublish = AWS_URL?.includes(':9000');
19
- const isNoAutoDiscovery = CSC_IDENTITY_AUTO_DISCOVERY === 'false';
20
- const isSkipPublish = !isDevPublish && !isGithubMaster && !isGithubTag;
21
-
22
- //FIXME Refine logic, tags should be versions, not channels, use branches? See how Changesets does it
23
- const channel = isGithubTag ? 'latest' : GITHUB_REF_NAME; // https://www.electron.build/tutorials/release-using-channels.html
24
-
25
- function getVersion() {
26
- if (isGithubMaster) {
27
- return `0.0.${GITHUB_RUN_ID}`; //TODO Figure out last normal in master and bump it
28
- }
29
- if (isGithubTag) {
30
- return GITHUB_REF!.split('/').pop();
31
- }
32
- return `0.0.${Date.now()}`; //TODO Read from package.json?
33
- }
34
-
35
- function getTarget() {
36
- const arch = ['arm64', isNoAutoDiscovery ? '' : 'x64'].filter(Boolean) as any;
37
-
38
- const target: MacConfiguration['target'] = [
39
- {
40
- target: 'dmg',
41
- arch,
42
- },
43
- {
44
- target: 'zip',
45
- arch,
46
- },
47
- ];
48
-
49
- // Leave only DMG if no signing
50
- if (isNoAutoDiscovery) {
51
- console.log('Skipping signing...');
52
- delete process.env.CSC_LINK;
53
- return [target[0]]; // only keep DMG
54
- }
55
-
56
- return target;
57
- }
58
-
59
- export function builerConfig(options: {
60
- config: Configuration;
61
- s3?: Pick<S3Options, 'bucket'> & Partial<S3Options>; //TODO Omit?
62
- githubReleases: Pick<GithubOptions, 'owner' | 'repo'> & Partial<GithubOptions>;
63
- }): Configuration {
64
- if (options.s3 && (!AWS_URL || !AWS_ACCESS_KEY_ID || !AWS_SECRET_ACCESS_KEY)) {
65
- throw new Error('Missing AWS configuration');
66
- }
67
-
68
- if (options.githubReleases && !GH_TOKEN) {
69
- throw new Error('Missing AWS configuration');
70
- }
71
-
72
- const config: Configuration = {
73
- files: [
74
- '**/*',
75
- '!electron-builder.js',
76
- '!electron-builder.yml',
77
- '!package.json',
78
- 'assets',
79
- ...(options.config.files as never),
80
- ],
81
- directories: {
82
- buildResources: 'assets',
83
- },
84
- mac: {
85
- category: options.config.mac?.category ?? 'public.app-category.utils',
86
- target: getTarget(),
87
- },
88
- //TODO Windows target
89
- dmg: {
90
- contents: [
91
- {
92
- x: 130,
93
- y: 130,
94
- },
95
- {
96
- x: 370,
97
- y: 130,
98
- type: 'link',
99
- path: '/Applications',
100
- },
101
- ],
102
- },
103
- publish: [
104
- options.s3 &&
105
- ({
106
- provider: 's3',
107
- endpoint: AWS_URL,
108
- channel,
109
- ...options.s3, // bucket
110
- } as S3Options),
111
- options.githubReleases &&
112
- GH_TOKEN &&
113
- (isGithubTag || isGithubMaster) &&
114
- ({
115
- provider: 'github',
116
- private: true,
117
- token: GH_TOKEN,
118
- releaseType: isGithubTag ? 'release' : 'draft',
119
- channel,
120
- ...options.githubReleases, // repo, owner
121
- } as GithubOptions),
122
- ].filter(Boolean) as never,
123
- extraMetadata: {
124
- version: getVersion(),
125
- },
126
- };
127
-
128
- if (isSkipPublish) {
129
- delete config.publish;
130
- delete (config as never as any).extraMetadata;
131
- }
132
-
133
- console.log('Electron Builder context', {
134
- isDevPublish,
135
- isGithubMaster,
136
- isGithubTag,
137
- isSkipPublish,
138
- isNoAutoDiscovery,
139
- channel,
140
- GITHUB_RUN_ID: GITHUB_RUN_ID,
141
- GITHUB_REF_TYPE: GITHUB_REF_TYPE,
142
- GITHUB_REF_NAME: GITHUB_REF_NAME,
143
- CSC_IDENTITY_AUTO_DISCOVERY: CSC_IDENTITY_AUTO_DISCOVERY,
144
- AWS_URL: AWS_URL,
145
- });
146
-
147
- console.log('Electron Builder configuration', JSON.stringify(config, null, 2));
148
-
149
- return config;
150
- }
@@ -1,33 +0,0 @@
1
- import psd from 'psd';
2
- import sharp from 'sharp';
3
- import path from 'node:path';
4
-
5
- export async function generateImages({
6
- iconPsdPath,
7
- dmgBackgroundPsdPath,
8
- electronAssetsPath,
9
- webPublicPath,
10
- }: {
11
- iconPsdPath: string;
12
- dmgBackgroundPsdPath: string;
13
- electronAssetsPath: string;
14
- webPublicPath: string;
15
- }): Promise<void> {
16
- const iconPsd = await psd.open(iconPsdPath);
17
- await iconPsd.image!.saveAsPng(path.join(electronAssetsPath, 'icon.png'));
18
-
19
- const bgPsd = await psd.open(dmgBackgroundPsdPath);
20
- await bgPsd.image!.saveAsPng(path.join(electronAssetsPath, 'background@2x.png'));
21
-
22
- const iconPng = sharp(path.join(electronAssetsPath, 'icon.png'));
23
- const bgPng = sharp(path.join(electronAssetsPath, 'background@2x.png'));
24
-
25
- await bgPng.resize(500).toFile(path.join(electronAssetsPath, 'background.png'));
26
-
27
- await iconPng.toFile(path.join(electronAssetsPath, 'splash.webp'));
28
- await iconPng.toFile(path.join(electronAssetsPath, 'icon.icns'));
29
-
30
- //TODO Crop without icon BG
31
- await iconPng.toFile(path.join(webPublicPath, 'icon.png'));
32
- await iconPng.resize(32).toFile(path.join(webPublicPath, 'favicon.ico'));
33
- }
@@ -1,2 +0,0 @@
1
- export * from './builder';
2
- export * from './images';
package/src/mui/README.md DELETED
@@ -1,3 +0,0 @@
1
- ## Prior Art
2
-
3
- https://codesandbox.io/p/sandbox/l7vykxl57q MUI v4
@@ -1,71 +0,0 @@
1
- import React from 'react';
2
- import type { Meta, StoryObj } from '@storybook/react';
3
-
4
- import { TextField, Stack, InputLabel, RadioGroup, Radio, FormControlLabel, Box } from '@mui/material';
5
-
6
- import { GenericControl } from './genericControl';
7
- import { ReadOnly } from './readOnly';
8
- import { FormControlFieldset } from './formControlFieldset';
9
- import { FormLabelLegend } from './formLabelLegend';
10
-
11
- // More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
12
- const meta: Meta<typeof GenericControl> = {
13
- title: 'MUI / FormControlFieldset',
14
- parameters: {
15
- layout: 'centered',
16
- },
17
- tags: ['autodocs'],
18
- argTypes: {},
19
- render: function Render() {
20
- return (
21
- <Box sx={{ position: 'relative' }}>
22
- <Rule top={12} />
23
- <Rule top={37} />
24
- <Rule top={48} />
25
- <Stack direction="row" gap={3} sx={{ alignItems: 'flex-start' }}>
26
- <FormControlFieldset>
27
- <FormLabelLegend>Radios</FormLabelLegend>
28
- <ReadOnly>
29
- {/* TODO The size of the component. small is equivalent to the dense radio styling. */}
30
- <RadioGroup row defaultValue="female" name="radio-buttons-group" sx={{ mt: -1 }}>
31
- <FormControlLabel value="female" label="Female" control={<Radio size="small" />} />
32
- <FormControlLabel value="male" label="Male" control={<Radio size="small" />} />
33
- <FormControlLabel value="other" label="Other" control={<Radio size="small" />} />
34
- </RadioGroup>
35
- </ReadOnly>
36
- </FormControlFieldset>
37
-
38
- <GenericControl>
39
- <InputLabel shrink>GenericControl</InputLabel>
40
- <ReadOnly>
41
- This is a <code>div</code>, not an input with <code>readOnly</code>
42
- </ReadOnly>
43
- </GenericControl>
44
-
45
- <FormControlFieldset>
46
- <FormLabelLegend>FormLabelLegend</FormLabelLegend>
47
- <ReadOnly>
48
- This is a <code>div</code>, not an input with <code>readOnly</code>
49
- </ReadOnly>
50
- </FormControlFieldset>
51
-
52
- <TextField label="TextField" defaultValue="Bar" variant="standard" />
53
- </Stack>
54
- </Box>
55
- );
56
- },
57
- } satisfies Meta<typeof GenericControl>;
58
-
59
- export default meta;
60
-
61
- type Story = StoryObj<typeof meta>;
62
-
63
- function Rule({ top }) {
64
- return (
65
- <Box sx={{ background: 'red', position: 'absolute', left: 0, top: `${top}px`, width: '100%', height: '1px' }} />
66
- );
67
- }
68
-
69
- export const Default: Story = {
70
- args: {},
71
- };
@@ -1,26 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { GenericControl, GenericControlProps } from './genericControl';
3
- import { inputClasses } from '@mui/material/Input';
4
-
5
- export type FormControlFieldsetProps = GenericControlProps;
6
-
7
- export const FormControlFieldset: FC<FormControlFieldsetProps> = function FormControlFieldset({
8
- children,
9
- sx,
10
- ...props
11
- }) {
12
- return (
13
- <GenericControl
14
- {...props}
15
- component="fieldset"
16
- sx={{
17
- ...sx,
18
- [`legend + .${inputClasses.root}`]: {
19
- marginTop: 2, //FIXME 16px, hardcoded from @mui/material/Input/Input.js @ 59
20
- },
21
- }}
22
- >
23
- {children}
24
- </GenericControl>
25
- );
26
- };
@@ -1,11 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { default as InputLabel, InputLabelProps } from '@mui/material/InputLabel';
3
-
4
- export const FormLabelLegend: FC<InputLabelProps> = ({ children, ...props }) => {
5
- return (
6
- // sx={(theme) => theme.typography.caption}
7
- <InputLabel {...props} shrink={true} component={'legend' as any}>
8
- {children}
9
- </InputLabel>
10
- );
11
- };
@@ -1,20 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { FormControlProps, default as FormControl } from '@mui/material/FormControl';
3
- import { inputClasses } from '@mui/material/Input';
4
-
5
- export type GenericControlProps = FormControlProps & { children: any };
6
-
7
- export const GenericControl: FC<GenericControlProps> = ({ children, sx, ...props }) => (
8
- <FormControl
9
- variant="standard"
10
- sx={{
11
- ...sx,
12
- [`& .${inputClasses.root}`]: {
13
- '&:before, &:after': { display: 'none' },
14
- },
15
- }}
16
- {...props}
17
- >
18
- {children}
19
- </FormControl>
20
- );
package/src/mui/index.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './formControlFieldset';
2
- export * from './formLabelLegend';
3
- export * from './genericControl';
4
- export * from './readOnly';
@@ -1,6 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { default as Input, InputProps } from '@mui/material/Input';
3
-
4
- export const ReadOnly: FC<InputProps & { children: any }> = ({ children, inputProps, ...props }) => (
5
- <Input {...props} inputComponent={'div' as any} inputProps={{ ...inputProps, children }}></Input>
6
- );
@@ -1,40 +0,0 @@
1
- 'use client';
2
-
3
- import React, { ComponentProps, FC } from 'react';
4
- import { usePathname } from 'next/navigation';
5
- import Link, { LinkProps } from 'next/link';
6
- import clsx from 'clsx';
7
-
8
- //TODO Test this
9
- export const AppLink: FC<
10
- {
11
- children: any;
12
- exact?: boolean;
13
- activeClassName?: any;
14
- } & LinkProps &
15
- ComponentProps<typeof Link>
16
- > = function AppLink({
17
- href,
18
- children,
19
- className = '',
20
- activeClassName = '',
21
- prefetch = false, // set explicit default
22
- exact = false,
23
- ...props
24
- }) {
25
- const pathname = usePathname();
26
- const hrefPath = typeof href === 'string' ? href : href.pathname || '/';
27
-
28
- return (
29
- <Link
30
- {...props}
31
- href={href}
32
- className={clsx(className, {
33
- [activeClassName]: (!exact && pathname.startsWith(hrefPath)) || (exact && pathname === hrefPath),
34
- })}
35
- prefetch={prefetch}
36
- >
37
- {children}
38
- </Link>
39
- );
40
- };
package/src/next/index.ts DELETED
@@ -1,5 +0,0 @@
1
- export * from './appLink';
2
- export * from './measure';
3
- export * from './noSSR';
4
- export * from './redirect';
5
- export * from './useIsInner';