js-dos 8.1.4 → 8.1.6

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 (141) hide show
  1. package/README.md +1 -1
  2. package/dist/emulators/emulators.js +2 -0
  3. package/dist/emulators/emulators.js.map +1 -0
  4. package/dist/emulators/types/build.d.ts +28 -0
  5. package/dist/emulators/types/dos/bundle/dos-bundle.d.ts +20 -0
  6. package/dist/emulators/types/dos/dosbox/ts/direct.d.ts +3 -0
  7. package/dist/emulators/types/dos/dosbox/ts/worker.d.ts +3 -0
  8. package/dist/emulators/types/emulators.d.ts +76 -0
  9. package/dist/emulators/types/http.d.ts +9 -0
  10. package/dist/emulators/types/impl/ci-impl.d.ts +29 -0
  11. package/dist/emulators/types/impl/emulators-impl.d.ts +26 -0
  12. package/dist/emulators/types/impl/modules.d.ts +38 -0
  13. package/dist/emulators/types/libzip/libzip.d.ts +16 -0
  14. package/dist/emulators/types/protocol/messages-queue.d.ts +8 -0
  15. package/dist/emulators/types/protocol/protocol.d.ts +128 -0
  16. package/dist/emulators/wdosbox-x.js +55 -0
  17. package/dist/emulators/wdosbox-x.js.symbols +8760 -0
  18. package/dist/emulators/wdosbox-x.wasm +0 -0
  19. package/dist/emulators/wdosbox.js +55 -0
  20. package/dist/emulators/wdosbox.js.symbols +3001 -0
  21. package/dist/emulators/wdosbox.wasm +0 -0
  22. package/dist/emulators/wlibzip.js +21 -0
  23. package/dist/emulators/wlibzip.js.symbols +268 -0
  24. package/dist/emulators/wlibzip.wasm +0 -0
  25. package/dist/js-dos.css +1 -0
  26. package/dist/js-dos.js +22 -0
  27. package/dist/js-dos.js.map +1 -0
  28. package/package.json +1 -1
  29. package/release.zip +0 -0
  30. package/.eslintrc.json +0 -43
  31. package/.github/workflows/build.yml +0 -51
  32. package/.gitmodules +0 -4
  33. package/index.html +0 -110
  34. package/postcss.config.cjs +0 -8
  35. package/src/app.css +0 -14
  36. package/src/base.css +0 -10
  37. package/src/components/checkbox.tsx +0 -41
  38. package/src/components/close-button.tsx +0 -17
  39. package/src/components/components.css +0 -28
  40. package/src/components/dos-option-checkbox.tsx +0 -94
  41. package/src/components/dos-option-select.tsx +0 -108
  42. package/src/components/dos-option-slider.tsx +0 -35
  43. package/src/components/error.tsx +0 -16
  44. package/src/components/loading.tsx +0 -26
  45. package/src/components/lock.tsx +0 -10
  46. package/src/components/select.tsx +0 -33
  47. package/src/components/slider.tsx +0 -69
  48. package/src/download-file.ts +0 -18
  49. package/src/frame/account-frame.tsx +0 -156
  50. package/src/frame/editor/defaults.ts +0 -419
  51. package/src/frame/editor/editor-conf-frame.tsx +0 -227
  52. package/src/frame/editor/editor-frame.css +0 -55
  53. package/src/frame/editor/editor-fs-frame.tsx +0 -314
  54. package/src/frame/fat-drives-frame.tsx +0 -199
  55. package/src/frame/frame.css +0 -119
  56. package/src/frame/frame.tsx +0 -34
  57. package/src/frame/image-rendering-frame.tsx +0 -8
  58. package/src/frame/network-frame.tsx +0 -157
  59. package/src/frame/quick-save-frame.tsx +0 -98
  60. package/src/frame/settings-frame.tsx +0 -14
  61. package/src/frame/stats-frame.tsx +0 -87
  62. package/src/host/bundle-storage.ts +0 -91
  63. package/src/host/fullscreen.ts +0 -35
  64. package/src/host/lcache.ts +0 -203
  65. package/src/host/lstorage.ts +0 -156
  66. package/src/i18n.ts +0 -185
  67. package/src/index.css +0 -7
  68. package/src/load.ts +0 -132
  69. package/src/login/login.css +0 -9
  70. package/src/login/login.tsx +0 -77
  71. package/src/main.tsx +0 -197
  72. package/src/public/types.ts +0 -45
  73. package/src/sidebar/account-button.tsx +0 -33
  74. package/src/sidebar/cloud-save-button.tsx +0 -89
  75. package/src/sidebar/diskette-icon.tsx +0 -14
  76. package/src/sidebar/fullscreen-button.tsx +0 -44
  77. package/src/sidebar/network-button.tsx +0 -39
  78. package/src/sidebar/sidebar-button.tsx +0 -244
  79. package/src/sidebar/sidebar.css +0 -47
  80. package/src/sidebar/sidebar.tsx +0 -30
  81. package/src/sockdrive/LICENSE +0 -674
  82. package/src/sockdrive/README.md +0 -45
  83. package/src/sockdrive/include/sockdrive.h +0 -23
  84. package/src/sockdrive/js/.eslintrc.json +0 -43
  85. package/src/sockdrive/js/package.json +0 -29
  86. package/src/sockdrive/js/src/fatfs/chains.js +0 -318
  87. package/src/sockdrive/js/src/fatfs/dir.js +0 -385
  88. package/src/sockdrive/js/src/fatfs/helpers.js +0 -210
  89. package/src/sockdrive/js/src/fatfs/index.js +0 -606
  90. package/src/sockdrive/js/src/fatfs/structs.js +0 -255
  91. package/src/sockdrive/js/src/fatfs/vol.js +0 -166
  92. package/src/sockdrive/js/src/sockdrive/cache.ts +0 -56
  93. package/src/sockdrive/js/src/sockdrive/drive.ts +0 -471
  94. package/src/sockdrive/js/src/sockdrive/lru.ts +0 -221
  95. package/src/sockdrive/js/src/sockdrive/types.ts +0 -14
  96. package/src/sockdrive/js/src/sockdrive-fat.d.ts +0 -64
  97. package/src/sockdrive/js/src/sockdrive-fat.ts +0 -226
  98. package/src/sockdrive/js/src/sockdrive-native.ts +0 -100
  99. package/src/sockdrive/js/src/test/test.ts +0 -289
  100. package/src/sockdrive/js/tsconfig.json +0 -11
  101. package/src/sockdrive/js/webpack.config.js +0 -68
  102. package/src/sockdrive/js/yarn.lock +0 -1808
  103. package/src/store/auth.ts +0 -115
  104. package/src/store/dos.ts +0 -305
  105. package/src/store/editor.ts +0 -61
  106. package/src/store/init.ts +0 -48
  107. package/src/store/storage.ts +0 -32
  108. package/src/store/ui.ts +0 -191
  109. package/src/store.tsx +0 -116
  110. package/src/ui.tsx +0 -140
  111. package/src/v8/changes.ts +0 -56
  112. package/src/v8/config.ts +0 -20
  113. package/src/v8/subscriptions.ts +0 -62
  114. package/src/vite-env.d.ts +0 -5
  115. package/src/window/dos/controls/keyboard.ts +0 -32
  116. package/src/window/dos/controls/keys.ts +0 -331
  117. package/src/window/dos/controls/mouse/mount.ts +0 -99
  118. package/src/window/dos/controls/mouse/mouse-locked.ts +0 -51
  119. package/src/window/dos/controls/mouse/mouse-not-locked.ts +0 -84
  120. package/src/window/dos/controls/mouse/mouse-swipe.ts +0 -57
  121. package/src/window/dos/controls/mouse/pointer.ts +0 -85
  122. package/src/window/dos/controls/mouse.ts +0 -21
  123. package/src/window/dos/dos-dhry2.tsx +0 -191
  124. package/src/window/dos/dos-runtime.tsx +0 -216
  125. package/src/window/dos/dos-window.tsx +0 -91
  126. package/src/window/dos/render/canvas.ts +0 -65
  127. package/src/window/dos/render/resize.ts +0 -31
  128. package/src/window/dos/render/webgl.ts +0 -173
  129. package/src/window/dos/sound/audio-node.ts +0 -148
  130. package/src/window/error-window.tsx +0 -9
  131. package/src/window/loading-window.tsx +0 -54
  132. package/src/window/prerun-window.tsx +0 -121
  133. package/src/window/select-window.tsx +0 -118
  134. package/src/window/window.css +0 -78
  135. package/src/window/window.tsx +0 -49
  136. package/src/ws/ws-sockdrive.ts +0 -123
  137. package/src/ws/ws-transport-layer.ts +0 -468
  138. package/tailwind.config.cjs +0 -48
  139. package/tsconfig.json +0 -32
  140. package/tsconfig.node.json +0 -9
  141. package/vite.config.ts +0 -25
package/src/i18n.ts DELETED
@@ -1,185 +0,0 @@
1
- import { createSlice } from "@reduxjs/toolkit";
2
- import { useSelector } from "react-redux";
3
- import { State } from "./store";
4
-
5
- const translations: {[lang: string]: {[key: string]: string} } = {
6
- ru: {
7
- enter_name_of_drive: "Введите название диска",
8
- ws_outdated: "Необходимо обновить DOS Браузер",
9
- update: "Обновить",
10
- preloading_sockdrive: "Загрузка FAT",
11
- filter: "Фильтр",
12
- add: "Добавить",
13
- logout: "Выйти",
14
- please_login: "Войдите в аккаунт",
15
- features: "Функции",
16
- premium: "Премиум",
17
- buy: "Купить",
18
- experimental_features: "Доступ к экспериентальным функциям",
19
- cloud_saves: "Облачные сохранения",
20
- writeable_fat32: "FAT32 диски",
21
- net_no_limits: "Выбор сервера для стевой игры",
22
- unlock_options: "Доступ ко всем настройкам",
23
- error: "Упс... Что-то пошло не так...",
24
- consult_logs: "Проверьте логи браузера",
25
- bundle_loading: "Загрузка бандла",
26
- bundle_config: "Чтение конфигурации",
27
- try_free: "дней бесплатно",
28
- upload_file: "Выбирите архив jsdos/zip что бы начать...",
29
- emulation_backend: "Эмуляция",
30
- render_backend: "Рендер",
31
- render_aspect: "Соотношение сторон",
32
- worker: "Фоновый поток",
33
- mouse_sensitivity: "Чувст. мыши",
34
- mouse_lock: "Захват мыши",
35
- volume: "Громкость",
36
- pause: "Пауза",
37
- dosboxconf_template: "dosbox.conf шаблон:",
38
- preview: "Превью",
39
- continue: "Продолжить",
40
- skip: "Пропустить",
41
- loading: "Загрузка",
42
- extract_loading: "Распаковка архива",
43
- extract_long_time: "Может занять длительное время, пожалуйста ждите...",
44
- theme: "Тема",
45
- create_empty: "Создать пустой бандл",
46
- uploading_file: "Загрузка файла",
47
- fs_restart: "Вы хотите пересобрать бандл используя эту FS?",
48
- please_wait: "Пожалуйста подождите",
49
- making_bundle: "Создаем бандл",
50
- size: "Размер",
51
- room: "Команта",
52
- server: "Сервер",
53
- load_by_url: "Загрузить по ссылке",
54
- enter_url: "Введите ссылку",
55
- load: "Загрузить",
56
- stored: "Сохраненные",
57
- delete: "Удалить",
58
- editor: "Редактор",
59
- download: "Скачать",
60
- changes: "Сохранения",
61
- account_not_ready: "Пропустить загрузку сохранений",
62
- loading_saves: "Загрузка сохранений",
63
- success: "Успешно",
64
- unable_to_save: "Ошибка записи",
65
- not_premium: "Подключить премиум",
66
- copy_net_link: "Отправьте ссылку на подключение",
67
- copied: "Скопировано",
68
- image_rendering: "Обработка изображения",
69
- read_only_access: "Диск FAT32 открыт только для чтения",
70
- fix: "Исправить",
71
- close: "Закрыть",
72
- cancle: "Отказаться",
73
- manage: "Управлять",
74
- unable_to_cancle_subscription: "Не удалось отменить подписку",
75
- subscription_cancelled: "Подписка отменена",
76
- hardware: "Аппаратное ускорение",
77
- net_drives: "Сетевые диски",
78
- fat_write: "FAT запись",
79
- },
80
- en: {
81
- enter_name_of_drive: "Enter name of drive",
82
- ws_outdated: "Must update DOS Browser App",
83
- update: "Update",
84
- preloading_sockdrive: "Preloading FAT",
85
- filter: "Filter",
86
- add: "Add",
87
- logout: "Logout",
88
- please_login: "Please login",
89
- features: "Features",
90
- premium: "Premium",
91
- buy: "Buy",
92
- experimental_features: "Access to all experimental features",
93
- cloud_saves: "Cloud saves",
94
- writeable_fat32: "Writable FAT32",
95
- net_no_limits: "Change the network region",
96
- unlock_options: "Unlock all configuration options",
97
- error: "Oops... Something went wrong...",
98
- consult_logs: "Please check browser logs",
99
- bundle_loading: "Bundle loading",
100
- bundle_config: "Reading config",
101
- try_free: "days for free",
102
- upload_file: "Select jsdos/zip file to start...",
103
- emulation_backend: "Emulation",
104
- render_backend: "Render",
105
- render_aspect: "Aspect",
106
- worker: "Worker thread",
107
- mouse_sensitivity: "Mouse sens...",
108
- mouse_lock: "Capture mouse",
109
- volume: "Volume",
110
- pause: "Pause",
111
- dosboxconf_template: "dosbox.conf template:",
112
- preview: "Preview",
113
- continue: "Continue",
114
- skip: "Skip",
115
- loading: "Loading",
116
- extract_loading: "Unpacking archive",
117
- extract_long_time: "Can take long time, please be patient...",
118
- theme: "Theme",
119
- create_empty: "Create empty bundle",
120
- uploading_file: "Uploading file",
121
- fs_restart: "Do you want to rebuild the bundle using this fs?",
122
- please_wait: "Please wait",
123
- making_bundle: "Creating bundle",
124
- size: "Size",
125
- room: "Room",
126
- server: "Server",
127
- load_by_url: "Load by url",
128
- enter_url: "Enter url",
129
- load: "Load",
130
- stored: "Stored",
131
- delete: "Delete",
132
- editor: "Editor",
133
- download: "Download",
134
- changes: "Saves",
135
- account_not_ready: "Skip loading saves",
136
- loading_saves: "Loading saves",
137
- success: "Success",
138
- unable_to_save: "Unable to save",
139
- not_premium: "Subscribe to premium",
140
- copy_net_link: "Share this link to connect",
141
- copied: "Copied",
142
- image_rendering: "Image rendering",
143
- read_only_access: "The FAT32 drive is open in read-only mode",
144
- fix: "Fix",
145
- close: "Close",
146
- cancle: "Cancle",
147
- manage: "Manage",
148
- unable_to_cancle_subscription: "Unable to cancle subscription",
149
- subscription_cancelled: "Subscription cancelled",
150
- hardware: "Hardware acceleration",
151
- net_drives: "Net drives",
152
- fat_write: "Writeable FAT",
153
- },
154
- };
155
-
156
- const initialLang = navigator.language.startsWith("ru") ? "ru" : "en";
157
-
158
- const initialState: {
159
- lang: "ru" | "en",
160
- keys: {[key: string]: string},
161
- } = {
162
- lang: initialLang,
163
- keys: translations[initialLang],
164
- };
165
-
166
- export type I18NState = typeof initialState;
167
-
168
- export const i18nSlice = createSlice({
169
- name: "i18n",
170
- initialState,
171
- reducers: {
172
- setLang: (state, action: { payload: "ru" | "en" }) => {
173
- state.lang = action.payload;
174
- state.keys = translations[action.payload];
175
- },
176
- },
177
- });
178
-
179
- export function useT() {
180
- const keys = useSelector((state: State) => state.i18n.keys);
181
- return (key: string) => {
182
- return keys[key] ?? key;
183
- };
184
- };
185
-
package/src/index.css DELETED
@@ -1,7 +0,0 @@
1
- @import "./base.css";
2
- @import "./app.css";
3
- @import "./components/components.css";
4
- @import "./sidebar/sidebar.css";
5
- @import "./login/login.css";
6
- @import "./window/window.css";
7
- @import "./frame/frame.css";
package/src/load.ts DELETED
@@ -1,132 +0,0 @@
1
- import { Dispatch, Store, Unsubscribe } from "@reduxjs/toolkit";
2
- import { DosConfig, Emulators } from "emulators";
3
- import { dosSlice } from "./store/dos";
4
- import { bundleFromChanges, bundleFromFile, bundleFromUrl } from "./host/bundle-storage";
5
- import { uiSlice } from "./store/ui";
6
- import { editorSlice } from "./store/editor";
7
- import { getChangesUrl } from "./v8/changes";
8
- import { storageSlice } from "./store/storage";
9
- import { getNonSerializableStore } from "./store";
10
-
11
- declare const emulators: Emulators;
12
-
13
- export async function loadEmptyBundle(store: Store) {
14
- await doLoadBundle("empty.jsdos",
15
- (async () => {
16
- const bundle = await emulators.bundle();
17
- return bundle.toUint8Array();
18
- })(), null, null, store);
19
-
20
- store.dispatch(uiSlice.actions.frameConf());
21
- store.dispatch(uiSlice.actions.setEditor(true));
22
- }
23
-
24
- export async function loadBundle(bundle: Uint8Array, openConfig: boolean, store: Store) {
25
- await doLoadBundle("bundle.jsdos", Promise.resolve(bundle),
26
- null, null, store);
27
- if (openConfig) {
28
- store.dispatch(uiSlice.actions.frameConf());
29
- }
30
- }
31
-
32
- export function loadBundleFromFile(file: File, store: Store) {
33
- return doLoadBundle(file.name,
34
- bundleFromFile(file, store),
35
- null, null, store);
36
- }
37
-
38
- export async function loadBundleFromConfg(config: DosConfig, store: Store) {
39
- const nonSerializableStore = getNonSerializableStore(store);
40
- const dispatch = store.dispatch;
41
- nonSerializableStore.loadedBundle = null;
42
-
43
- dispatch(editorSlice.actions.init(config));
44
- syncWithConfig(config, dispatch);
45
-
46
- nonSerializableStore.loadedBundle = {
47
- bundleUrl: null,
48
- bundleChangesUrl: null,
49
- bundle: config,
50
- bundleChanges: null,
51
- };
52
- dispatch(dosSlice.actions.bndReady({}));
53
- }
54
-
55
- export async function loadBundleFromUrl(url: string, store: Store) {
56
- const owner = store.getState().auth.account?.email ?? "guest";
57
- const changesUrl = await getChangesUrl(owner, url);
58
- return doLoadBundle(url,
59
- bundleFromUrl(url, store),
60
- changesProducer(changesUrl, store),
61
- url,
62
- store);
63
- }
64
-
65
- async function doLoadBundle(bundleName: string,
66
- bundlePromise: Promise<Uint8Array>,
67
- bundleChangesPromise: (ReturnType<typeof changesProducer>) | null,
68
- bundleUrl: string | null,
69
- store: Store) {
70
- const nonSerializableStore = getNonSerializableStore(store);
71
- const dispatch = store.dispatch;
72
- nonSerializableStore.loadedBundle = null;
73
-
74
-
75
- dispatch(dosSlice.actions.bndLoad(bundleName));
76
-
77
- const bundle = await bundlePromise;
78
- dispatch(storageSlice.actions.ready());
79
- const bundleChanges = await bundleChangesPromise;
80
- dispatch(dosSlice.actions.bndConfig());
81
-
82
- const config = await emulators.bundleConfig(bundle);
83
- dispatch(editorSlice.actions.init(config));
84
- if (config === null) {
85
- dispatch(uiSlice.actions.frameConf());
86
- } else {
87
- syncWithConfig(config, dispatch);
88
- }
89
-
90
- nonSerializableStore.loadedBundle = {
91
- bundleUrl,
92
- bundleChangesUrl: bundleChanges?.url ?? null,
93
- bundle,
94
- bundleChanges: bundleChanges?.bundle ?? null,
95
- };
96
- dispatch(dosSlice.actions.bndReady({}));
97
- }
98
-
99
- async function changesProducer(bundleUrl: string, store: Store): Promise<{
100
- url: string,
101
- bundle: Uint8Array | null,
102
- }> {
103
- if (!store.getState().auth.ready) {
104
- await new Promise<void>((resolve) => {
105
- let unsubscirbe: Unsubscribe | null = null;
106
- const updateFn = () => {
107
- if (store.getState().auth.ready) {
108
- unsubscirbe!();
109
- resolve();
110
- }
111
- };
112
- unsubscirbe = store.subscribe(updateFn);
113
- });
114
- }
115
-
116
- const account = store.getState().auth.account;
117
- const owner = account?.email ?? "guest";
118
- const url = getChangesUrl(owner, bundleUrl);
119
- const bundle = await bundleFromChanges(url, account, store);
120
- return {
121
- url,
122
- bundle,
123
- };
124
- }
125
-
126
- function syncWithConfig(config: DosConfig, dispatch: Dispatch) {
127
- if (config.dosboxConf.indexOf("sockdrive") >= 0) {
128
- dispatch(dosSlice.actions.dosBackendLocked(true));
129
- dispatch(dosSlice.actions.dosBackend("dosboxX"));
130
- }
131
- dispatch(dosSlice.actions.mouseCapture(config.dosboxConf.indexOf("autolock=true") >= 0));
132
- }
@@ -1,9 +0,0 @@
1
- .jsdos-rso {
2
- .login-widget {
3
- @apply absolute z-40 left-12 top-0 bottom-0 right-0 bg-white;
4
-
5
- iframe {
6
- @apply w-full h-full p-0 m-0 border-0;
7
- }
8
- }
9
- }
@@ -1,77 +0,0 @@
1
- import { useEffect, useRef } from "preact/hooks";
2
- import { useDispatch, useSelector } from "react-redux";
3
- import { State } from "../store";
4
- import { uiSlice } from "../store/ui";
5
- import { CloseButton } from "../components/close-button";
6
- import { authentificator } from "../v8/config";
7
- import { Account, authSlice, postAuthMessage } from "../store/auth";
8
- import { havePremium } from "../v8/subscriptions";
9
-
10
- export function Login() {
11
- const iframeRef = useRef<HTMLIFrameElement>(null);
12
- const activeAccount = useSelector((state: State) => state.auth.account);
13
- const visible = useSelector((state: State) => state.ui.modal) === "login";
14
- const dispatch = useDispatch();
15
-
16
- useEffect(() => {
17
- if (activeAccount != null) {
18
- return;
19
- }
20
-
21
- const iframe = iframeRef.current;
22
- if (iframe === null) {
23
- dispatch(authSlice.actions.logout({}));
24
- dispatch(authSlice.actions.ready());
25
- console.error("Unable to inialize authentificator!");
26
- return;
27
- }
28
-
29
- async function onAuthMessage(e: any) {
30
- if (e.data.action === "auth/ready") {
31
- postAuthMessage("auth/authenicate");
32
- } else if (e.data.action === "auth/authenicate") {
33
- const account = e.data.account as Account | null;
34
- if (account !== null) {
35
- try {
36
- account.premium = await havePremium(account.token.access_token);
37
- } catch (e: any) {
38
- console.error(e);
39
- account.premium = false;
40
- }
41
- dispatch(authSlice.actions.login(e.data.account));
42
- } else {
43
- dispatch(authSlice.actions.logout({}));
44
- dispatch(authSlice.actions.ready());
45
- }
46
- }
47
- }
48
-
49
- window.addEventListener("message", onAuthMessage);
50
- iframe.src = authentificator;
51
-
52
- return () => {
53
- window.removeEventListener("message", onAuthMessage);
54
- };
55
- }, []);
56
-
57
- useEffect(() => {
58
- const iframe = iframeRef.current;
59
- if (iframe === null) {
60
- return;
61
- }
62
-
63
- postAuthMessage("auth/login");
64
- }, [visible]);
65
-
66
- return <div
67
- id={"login"}
68
- class={
69
- "login-widget " + (visible ? "block" : "hidden")
70
- }>
71
- <iframe id="authentificator" ref={iframeRef} />
72
- <CloseButton
73
- class="absolute z-40 right-24 top-10"
74
- onClose={() => dispatch(uiSlice.actions.modalNone()) }
75
- />
76
- </div>;
77
- }
package/src/main.tsx DELETED
@@ -1,197 +0,0 @@
1
- import { render } from "preact";
2
- import "./index.css";
3
-
4
- import { Provider } from "react-redux";
5
- import { Ui } from "./ui";
6
- import { dosSlice } from "./store/dos";
7
- import { initEmulators } from "./store/dos";
8
- // eslint-disable-next-line
9
- import { uiSlice } from "./store/ui";
10
- import { i18nSlice } from "./i18n";
11
- import { getCache } from "./host/lcache";
12
- import { loadBundleFromConfg, loadBundleFromUrl } from "./load";
13
-
14
- import { DosOptions, DosProps, DosFn } from "./public/types";
15
- import { browserSetFullScreen } from "./host/fullscreen";
16
- import { NonSerializableStore, Store, makeNonSerializableStore, makeStore, postJsDosEvent } from "./store";
17
-
18
- export const Dos: DosFn = (element: HTMLDivElement,
19
- options: Partial<DosOptions> = {}): DosProps => {
20
- const nonSerializableStore = makeNonSerializableStore(options);
21
- const store = makeStore(nonSerializableStore, options);
22
-
23
-
24
- if (store.getState().auth.account?.email === "dz.caiiiycuk@gmail.com" ||
25
- store.getState().auth.account?.email === "caiiiycuk@gmail.com") {
26
- store.dispatch(dosSlice.actions.setSockdriveWrite(false));
27
- }
28
-
29
- setupRootElement(element, nonSerializableStore, store);
30
-
31
- let pollStep = "none";
32
- function pollEvents() {
33
- (async () => {
34
- const state = store.getState();
35
- const step = state.dos.step;
36
-
37
- if (step === pollStep) {
38
- return;
39
- }
40
- pollStep = step;
41
-
42
- switch (state.dos.step) {
43
- case "emu-ready": {
44
- const cachedEmail = state.auth.account?.email;
45
- nonSerializableStore.cache = await getCache(cachedEmail ?? "guest");
46
-
47
- if (nonSerializableStore.options.url) {
48
- try {
49
- await loadBundleFromUrl(nonSerializableStore.options.url, store);
50
- } catch (e: any) {
51
- store.dispatch(dosSlice.actions.bndError(e.message));
52
- }
53
- } else if (nonSerializableStore.options.dosboxConf) {
54
- loadBundleFromConfg({
55
- dosboxConf: nonSerializableStore.options.dosboxConf,
56
- jsdosConf: {
57
- version: "8",
58
- },
59
- }, store);
60
- } else {
61
- store.dispatch(uiSlice.actions.windowSelect());
62
- }
63
-
64
- postJsDosEvent(nonSerializableStore, "emu-ready");
65
- } break;
66
- };
67
- })().catch(console.error);
68
- }
69
- store.subscribe(pollEvents);
70
-
71
- initEmulators(store, options.pathPrefix ?? "https://v8.js-dos.com/latest/emulators/");
72
-
73
- function setTheme(theme: DosOptions["theme"]) {
74
- store.dispatch(uiSlice.actions.theme(theme));
75
- }
76
-
77
- function setLang(lang: DosOptions["lang"]) {
78
- store.dispatch(i18nSlice.actions.setLang(lang));
79
- }
80
-
81
- function setBackend(backend: DosOptions["backend"]) {
82
- store.dispatch(dosSlice.actions.dosBackend(backend));
83
- }
84
-
85
- function setBackendLocked(locked: boolean) {
86
- store.dispatch(dosSlice.actions.dosBackendLocked(locked));
87
- }
88
-
89
- function setWorkerThread(workerThread: DosOptions["workerThread"]) {
90
- store.dispatch(dosSlice.actions.dosWorker(workerThread));
91
- }
92
-
93
- function setMouseCapture(capture: DosOptions["mouseCapture"]) {
94
- store.dispatch(dosSlice.actions.mouseCapture(capture));
95
- }
96
-
97
- function setServer(server: DosOptions["server"]) {
98
- store.dispatch(dosSlice.actions.setServer(server));
99
- }
100
-
101
- function setRoom(room: DosOptions["room"]) {
102
- store.dispatch(dosSlice.actions.setRoom(room));
103
- }
104
-
105
- function setFrame(frame: "network") {
106
- store.dispatch(uiSlice.actions.frameNetwork());
107
- }
108
-
109
- function setBackground(background: string) {
110
- store.dispatch(uiSlice.actions.background(background));
111
- }
112
-
113
- function setFullScreen(fullScreen: boolean) {
114
- browserSetFullScreen(fullScreen, store);
115
- }
116
-
117
- if (options.theme) {
118
- setTheme(options.theme);
119
- }
120
-
121
- if (options.lang) {
122
- setLang(options.lang);
123
- }
124
-
125
- if (options.backend) {
126
- setBackend(options.backend);
127
- }
128
-
129
- if (options.backendLocked) {
130
- setBackendLocked(options.backendLocked);
131
- }
132
-
133
- if (options.workerThread !== undefined) {
134
- setWorkerThread(options.workerThread);
135
- }
136
-
137
- if (options.mouseCapture !== undefined) {
138
- setMouseCapture(options.mouseCapture);
139
- }
140
-
141
- if (options.server) {
142
- setServer(options.server);
143
- }
144
-
145
- if (options.room) {
146
- setRoom(options.room);
147
- }
148
-
149
- if (options.background) {
150
- setBackground(options.background);
151
- }
152
-
153
- if (options.fullScreen !== undefined) {
154
- setFullScreen(options.fullScreen);
155
- }
156
-
157
- render(
158
- <Provider store={store}>
159
- {<Ui /> as any}
160
- </Provider>,
161
- element,
162
- );
163
-
164
- return {
165
- setTheme,
166
- setLang,
167
- setBackend,
168
- setBackendLocked,
169
- setWorkerThread,
170
- setMouseCapture,
171
- setServer,
172
- setRoom,
173
- setFrame,
174
- setBackground,
175
- setFullScreen,
176
- };
177
- };
178
-
179
- function setupRootElement(root: HTMLDivElement, nonSerializableStore: NonSerializableStore, store: Store) {
180
- nonSerializableStore.root = root;
181
- root.classList.add("jsdos-rso");
182
- root.addEventListener("contextmenu", (e) => {
183
- if (e.target !== null &&
184
- (e.target as HTMLElement).classList?.contains("contextmenu")) {
185
- return;
186
- }
187
- e.stopPropagation();
188
- e.preventDefault();
189
- return false;
190
- });
191
- document.addEventListener("fullscreenchange", () => {
192
- const fullscreen = document.fullscreenElement === root;
193
- store.dispatch(uiSlice.actions.setFullScreen(fullscreen));
194
- });
195
- }
196
-
197
- (window as any).Dos = Dos;
@@ -1,45 +0,0 @@
1
- export type DosEvent = "emu-ready" | "ci-ready" | "bnd-play";
2
-
3
- export interface DosOptions {
4
- url: string,
5
- dosboxConf: string,
6
- background: string,
7
- pathPrefix: string,
8
- theme: "light" | "dark" | "cupcake" | "bumblebee" | "emerald" | "corporate" |
9
- "synthwave" | "retro" | "cyberpunk" | "valentine" | "halloween" | "garden" |
10
- "forest" | "aqua" | "lofi" | "pastel" | "fantasy" | "wireframe" | "black" |
11
- "luxury" | "dracula" | "cmyk" | "autumn" | "business" | "acid" | "lemonade" |
12
- "night" | "coffee" | "winter",
13
- lang: "ru" | "en",
14
- backend: "dosbox" | "dosboxX",
15
- backendLocked: boolean,
16
- backendHardware: ((backend: "dosbox" | "dosboxX") => Promise<string | null>),
17
- workerThread: boolean,
18
- mouseCapture: boolean,
19
- onEvent: (event: DosEvent, ci?: any /* CommandInterface */) => void,
20
- server: "netherlands" | "newyork" | "singapore",
21
- room: string,
22
- fullScreen: boolean,
23
- sockdriveBackend: {
24
- name: string,
25
- host: string,
26
- }
27
- }
28
-
29
- export interface DosProps {
30
- setTheme(theme: DosOptions["theme"]): void;
31
- setLang(lang: DosOptions["lang"]): void;
32
- setBackend(backend: DosOptions["backend"]): void;
33
- setBackendLocked(locked: boolean): void;
34
- setWorkerThread(capture: DosOptions["workerThread"]): void;
35
- setMouseCapture(capture: DosOptions["mouseCapture"]): void;
36
- setServer(server: DosOptions["server"]): void;
37
- setRoom(room: DosOptions["room"]): void;
38
- setFrame(frame: "network"): void;
39
- setBackground(background: string | null): void;
40
- setFullScreen(fullScreen: boolean): void;
41
- }
42
-
43
- export type DosFn = (element: HTMLDivElement, options: Partial<DosOptions>) => DosProps;
44
-
45
- // declare const Dos: DosFn;
@@ -1,33 +0,0 @@
1
- import { useDispatch, useSelector } from "react-redux";
2
- import { dispatchLoginAction } from "../store/ui";
3
- import { State } from "../store";
4
-
5
- export function AccountButton(props: {
6
- class?: string,
7
- }) {
8
- const account = useSelector((state: State) => state.auth.account);
9
- const loggedIn = account !== null;
10
- const hightlight = useSelector((state: State) => state.ui.frame) === "account";
11
- const dispatch = useDispatch();
12
-
13
- function onClick() {
14
- dispatchLoginAction(account, dispatch);
15
- }
16
-
17
- return <div class={"sidebar-button " + (hightlight ? "sidebar-highlight " : "") +
18
- (account?.email === "dz.caiiiycuk@gmail.com" ? "bg-accent " : "") +
19
- props.class} onClick={onClick}>
20
-
21
- <svg xmlns="http://www.w3.org/2000/svg" fill="none"
22
- viewBox="0 0 24 24" stroke-width="1.5"
23
- stroke="currentColor" class="w-full h-full">
24
- <path stroke-linecap="round"
25
- stroke-linejoin="round"
26
- d="M17.982 18.725A7.488 7.488 0 0012 15.75a7.488 7.488 0 00-5.982 2.975m11.963 0a9 9 0 10-11.963
27
- 0m11.963 0A8.966 8.966 0 0112 21a8.966
28
- 8.966 0 01-5.982-2.275M15 9.75a3 3 0 11-6 0 3 3 0 016 0z" />
29
- </svg>
30
-
31
- {loggedIn === false && <div class="sidebar-badge" />}
32
- </div>;
33
- }