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.
- package/README.md +1 -1
- package/dist/emulators/emulators.js +2 -0
- package/dist/emulators/emulators.js.map +1 -0
- package/dist/emulators/types/build.d.ts +28 -0
- package/dist/emulators/types/dos/bundle/dos-bundle.d.ts +20 -0
- package/dist/emulators/types/dos/dosbox/ts/direct.d.ts +3 -0
- package/dist/emulators/types/dos/dosbox/ts/worker.d.ts +3 -0
- package/dist/emulators/types/emulators.d.ts +76 -0
- package/dist/emulators/types/http.d.ts +9 -0
- package/dist/emulators/types/impl/ci-impl.d.ts +29 -0
- package/dist/emulators/types/impl/emulators-impl.d.ts +26 -0
- package/dist/emulators/types/impl/modules.d.ts +38 -0
- package/dist/emulators/types/libzip/libzip.d.ts +16 -0
- package/dist/emulators/types/protocol/messages-queue.d.ts +8 -0
- package/dist/emulators/types/protocol/protocol.d.ts +128 -0
- package/dist/emulators/wdosbox-x.js +55 -0
- package/dist/emulators/wdosbox-x.js.symbols +8760 -0
- package/dist/emulators/wdosbox-x.wasm +0 -0
- package/dist/emulators/wdosbox.js +55 -0
- package/dist/emulators/wdosbox.js.symbols +3001 -0
- package/dist/emulators/wdosbox.wasm +0 -0
- package/dist/emulators/wlibzip.js +21 -0
- package/dist/emulators/wlibzip.js.symbols +268 -0
- package/dist/emulators/wlibzip.wasm +0 -0
- package/dist/js-dos.css +1 -0
- package/dist/js-dos.js +22 -0
- package/dist/js-dos.js.map +1 -0
- package/package.json +1 -1
- package/release.zip +0 -0
- package/.eslintrc.json +0 -43
- package/.github/workflows/build.yml +0 -51
- package/.gitmodules +0 -4
- package/index.html +0 -110
- package/postcss.config.cjs +0 -8
- package/src/app.css +0 -14
- package/src/base.css +0 -10
- package/src/components/checkbox.tsx +0 -41
- package/src/components/close-button.tsx +0 -17
- package/src/components/components.css +0 -28
- package/src/components/dos-option-checkbox.tsx +0 -94
- package/src/components/dos-option-select.tsx +0 -108
- package/src/components/dos-option-slider.tsx +0 -35
- package/src/components/error.tsx +0 -16
- package/src/components/loading.tsx +0 -26
- package/src/components/lock.tsx +0 -10
- package/src/components/select.tsx +0 -33
- package/src/components/slider.tsx +0 -69
- package/src/download-file.ts +0 -18
- package/src/frame/account-frame.tsx +0 -156
- package/src/frame/editor/defaults.ts +0 -419
- package/src/frame/editor/editor-conf-frame.tsx +0 -227
- package/src/frame/editor/editor-frame.css +0 -55
- package/src/frame/editor/editor-fs-frame.tsx +0 -314
- package/src/frame/fat-drives-frame.tsx +0 -199
- package/src/frame/frame.css +0 -119
- package/src/frame/frame.tsx +0 -34
- package/src/frame/image-rendering-frame.tsx +0 -8
- package/src/frame/network-frame.tsx +0 -157
- package/src/frame/quick-save-frame.tsx +0 -98
- package/src/frame/settings-frame.tsx +0 -14
- package/src/frame/stats-frame.tsx +0 -87
- package/src/host/bundle-storage.ts +0 -91
- package/src/host/fullscreen.ts +0 -35
- package/src/host/lcache.ts +0 -203
- package/src/host/lstorage.ts +0 -156
- package/src/i18n.ts +0 -185
- package/src/index.css +0 -7
- package/src/load.ts +0 -132
- package/src/login/login.css +0 -9
- package/src/login/login.tsx +0 -77
- package/src/main.tsx +0 -197
- package/src/public/types.ts +0 -45
- package/src/sidebar/account-button.tsx +0 -33
- package/src/sidebar/cloud-save-button.tsx +0 -89
- package/src/sidebar/diskette-icon.tsx +0 -14
- package/src/sidebar/fullscreen-button.tsx +0 -44
- package/src/sidebar/network-button.tsx +0 -39
- package/src/sidebar/sidebar-button.tsx +0 -244
- package/src/sidebar/sidebar.css +0 -47
- package/src/sidebar/sidebar.tsx +0 -30
- package/src/sockdrive/LICENSE +0 -674
- package/src/sockdrive/README.md +0 -45
- package/src/sockdrive/include/sockdrive.h +0 -23
- package/src/sockdrive/js/.eslintrc.json +0 -43
- package/src/sockdrive/js/package.json +0 -29
- package/src/sockdrive/js/src/fatfs/chains.js +0 -318
- package/src/sockdrive/js/src/fatfs/dir.js +0 -385
- package/src/sockdrive/js/src/fatfs/helpers.js +0 -210
- package/src/sockdrive/js/src/fatfs/index.js +0 -606
- package/src/sockdrive/js/src/fatfs/structs.js +0 -255
- package/src/sockdrive/js/src/fatfs/vol.js +0 -166
- package/src/sockdrive/js/src/sockdrive/cache.ts +0 -56
- package/src/sockdrive/js/src/sockdrive/drive.ts +0 -471
- package/src/sockdrive/js/src/sockdrive/lru.ts +0 -221
- package/src/sockdrive/js/src/sockdrive/types.ts +0 -14
- package/src/sockdrive/js/src/sockdrive-fat.d.ts +0 -64
- package/src/sockdrive/js/src/sockdrive-fat.ts +0 -226
- package/src/sockdrive/js/src/sockdrive-native.ts +0 -100
- package/src/sockdrive/js/src/test/test.ts +0 -289
- package/src/sockdrive/js/tsconfig.json +0 -11
- package/src/sockdrive/js/webpack.config.js +0 -68
- package/src/sockdrive/js/yarn.lock +0 -1808
- package/src/store/auth.ts +0 -115
- package/src/store/dos.ts +0 -305
- package/src/store/editor.ts +0 -61
- package/src/store/init.ts +0 -48
- package/src/store/storage.ts +0 -32
- package/src/store/ui.ts +0 -191
- package/src/store.tsx +0 -116
- package/src/ui.tsx +0 -140
- package/src/v8/changes.ts +0 -56
- package/src/v8/config.ts +0 -20
- package/src/v8/subscriptions.ts +0 -62
- package/src/vite-env.d.ts +0 -5
- package/src/window/dos/controls/keyboard.ts +0 -32
- package/src/window/dos/controls/keys.ts +0 -331
- package/src/window/dos/controls/mouse/mount.ts +0 -99
- package/src/window/dos/controls/mouse/mouse-locked.ts +0 -51
- package/src/window/dos/controls/mouse/mouse-not-locked.ts +0 -84
- package/src/window/dos/controls/mouse/mouse-swipe.ts +0 -57
- package/src/window/dos/controls/mouse/pointer.ts +0 -85
- package/src/window/dos/controls/mouse.ts +0 -21
- package/src/window/dos/dos-dhry2.tsx +0 -191
- package/src/window/dos/dos-runtime.tsx +0 -216
- package/src/window/dos/dos-window.tsx +0 -91
- package/src/window/dos/render/canvas.ts +0 -65
- package/src/window/dos/render/resize.ts +0 -31
- package/src/window/dos/render/webgl.ts +0 -173
- package/src/window/dos/sound/audio-node.ts +0 -148
- package/src/window/error-window.tsx +0 -9
- package/src/window/loading-window.tsx +0 -54
- package/src/window/prerun-window.tsx +0 -121
- package/src/window/select-window.tsx +0 -118
- package/src/window/window.css +0 -78
- package/src/window/window.tsx +0 -49
- package/src/ws/ws-sockdrive.ts +0 -123
- package/src/ws/ws-transport-layer.ts +0 -468
- package/tailwind.config.cjs +0 -48
- package/tsconfig.json +0 -32
- package/tsconfig.node.json +0 -9
- package/vite.config.ts +0 -25
package/src/store/ui.ts
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
import { Dispatch, createAction, createSlice } from "@reduxjs/toolkit";
|
|
2
|
-
import { lStorage } from "../host/lstorage";
|
|
3
|
-
import { Account } from "./auth";
|
|
4
|
-
import { DosAction } from "../store";
|
|
5
|
-
|
|
6
|
-
export const ThemeValues = <const>["light", "dark", "cupcake", "bumblebee", "emerald", "corporate",
|
|
7
|
-
"synthwave", "retro", "cyberpunk", "valentine", "halloween", "garden", "forest", "aqua", "lofi",
|
|
8
|
-
"pastel", "fantasy", "wireframe", "black", "luxury", "dracula", "cmyk", "autumn", "business",
|
|
9
|
-
"acid", "lemonade", "night", "coffee", "winter"];
|
|
10
|
-
export type Theme = typeof ThemeValues[number];
|
|
11
|
-
|
|
12
|
-
export type Frame = "none" | "account" | "settings" |
|
|
13
|
-
"editor-conf" | "editor-fs" | "network" |
|
|
14
|
-
"stats" | "fat-drives" | "quick-save" | "image-rendering";
|
|
15
|
-
|
|
16
|
-
const initialState: {
|
|
17
|
-
modal: "none" | "login",
|
|
18
|
-
frame: Frame,
|
|
19
|
-
frameXs: boolean,
|
|
20
|
-
window: "none" | "error" | "loading" | "prerun" | "run" | "select",
|
|
21
|
-
theme: Theme,
|
|
22
|
-
editor: boolean,
|
|
23
|
-
wideScreen: boolean,
|
|
24
|
-
fullScreen: boolean,
|
|
25
|
-
toast: string | null,
|
|
26
|
-
toastIntent: "none" | "error" | "success" | "panic",
|
|
27
|
-
toastTimeoutId: number,
|
|
28
|
-
background: string | null,
|
|
29
|
-
readOnlyWarning: boolean,
|
|
30
|
-
updateWsWarning: boolean,
|
|
31
|
-
cloudSaves: boolean,
|
|
32
|
-
} = {
|
|
33
|
-
modal: "none",
|
|
34
|
-
frame: "none",
|
|
35
|
-
frameXs: false,
|
|
36
|
-
window: "none",
|
|
37
|
-
theme: (lStorage.getItem("theme") ?? "dark") as Theme,
|
|
38
|
-
editor: false,
|
|
39
|
-
wideScreen: true,
|
|
40
|
-
fullScreen: false,
|
|
41
|
-
toast: null,
|
|
42
|
-
toastIntent: "none",
|
|
43
|
-
toastTimeoutId: 0,
|
|
44
|
-
background: null,
|
|
45
|
-
readOnlyWarning: false,
|
|
46
|
-
updateWsWarning: false,
|
|
47
|
-
cloudSaves: true,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export type UiState = typeof initialState;
|
|
51
|
-
|
|
52
|
-
export const uiSlice = createSlice({
|
|
53
|
-
name: "js-dos v8s",
|
|
54
|
-
initialState,
|
|
55
|
-
reducers: {
|
|
56
|
-
theme: (state, a: { payload: Theme }) => {
|
|
57
|
-
lStorage.setItem("theme", a.payload);
|
|
58
|
-
state.theme = a.payload;
|
|
59
|
-
},
|
|
60
|
-
modalLogin: (state) => {
|
|
61
|
-
state.modal = "login";
|
|
62
|
-
},
|
|
63
|
-
modalNone: (state) => {
|
|
64
|
-
state.modal = "none";
|
|
65
|
-
},
|
|
66
|
-
frameNone: (state) => {
|
|
67
|
-
state.frame = "none";
|
|
68
|
-
state.frameXs = false;
|
|
69
|
-
},
|
|
70
|
-
frameAccount: (state) => {
|
|
71
|
-
toggleFrameIfNeeded(state, "account");
|
|
72
|
-
state.frameXs = false;
|
|
73
|
-
},
|
|
74
|
-
frameSettings: (state) => {
|
|
75
|
-
state.frame = "settings";
|
|
76
|
-
state.frameXs = false;
|
|
77
|
-
},
|
|
78
|
-
frameNetwork: (state) => {
|
|
79
|
-
state.frame = "network";
|
|
80
|
-
state.frameXs = false;
|
|
81
|
-
},
|
|
82
|
-
frameStats: (state) => {
|
|
83
|
-
state.frame = "stats";
|
|
84
|
-
state.frameXs = false;
|
|
85
|
-
},
|
|
86
|
-
frameConf: (state) => {
|
|
87
|
-
state.frame = "editor-conf";
|
|
88
|
-
state.frameXs = false;
|
|
89
|
-
},
|
|
90
|
-
frameFs: (state) => {
|
|
91
|
-
state.frame = "editor-fs";
|
|
92
|
-
state.frameXs = false;
|
|
93
|
-
},
|
|
94
|
-
frameFatDrives: (state) => {
|
|
95
|
-
state.frame = "fat-drives";
|
|
96
|
-
state.frameXs = false;
|
|
97
|
-
},
|
|
98
|
-
frameQuickSave: (state) => {
|
|
99
|
-
state.frame = "quick-save";
|
|
100
|
-
state.frameXs = true;
|
|
101
|
-
},
|
|
102
|
-
frameImageRendering: (state) => {
|
|
103
|
-
state.frame = "image-rendering";
|
|
104
|
-
state.frameXs = false;
|
|
105
|
-
},
|
|
106
|
-
windowSelect: (state) => {
|
|
107
|
-
state.window = "select";
|
|
108
|
-
},
|
|
109
|
-
background: (state, a: { payload: string }) => {
|
|
110
|
-
state.background = a.payload;
|
|
111
|
-
},
|
|
112
|
-
setEditor: (state, a: { payload: boolean }) => {
|
|
113
|
-
state.editor = a.payload;
|
|
114
|
-
},
|
|
115
|
-
setWideScreen: (state, a: { payload: boolean }) => {
|
|
116
|
-
state.wideScreen = a.payload;
|
|
117
|
-
},
|
|
118
|
-
setFullScreen: (state, a: { payload: boolean }) => {
|
|
119
|
-
state.fullScreen = a.payload;
|
|
120
|
-
},
|
|
121
|
-
showToast: (state, a: { payload: { message: string, intent?: typeof initialState.toastIntent,
|
|
122
|
-
long?: boolean } }) => {
|
|
123
|
-
if (state.toastTimeoutId !== 0) {
|
|
124
|
-
clearInterval(state.toastTimeoutId);
|
|
125
|
-
}
|
|
126
|
-
state.toast = a.payload.message;
|
|
127
|
-
state.toastIntent = a.payload.intent ?? "none";
|
|
128
|
-
if (a.payload.intent !== "panic") {
|
|
129
|
-
state.toastTimeoutId = setTimeout(() => {
|
|
130
|
-
(a as unknown as DosAction).asyncStore((store) => store.dispatch(uiSlice.actions.hideToast()));
|
|
131
|
-
}, a.payload.long ? 5000 : 1500);
|
|
132
|
-
}
|
|
133
|
-
},
|
|
134
|
-
hideToast: (state) => {
|
|
135
|
-
state.toast = null;
|
|
136
|
-
state.toastTimeoutId = 0;
|
|
137
|
-
},
|
|
138
|
-
readOnlyWarning: (state, a: { payload: boolean }) => {
|
|
139
|
-
state.readOnlyWarning = a.payload;
|
|
140
|
-
},
|
|
141
|
-
updateWsWarning: (state, a: { payload: boolean }) => {
|
|
142
|
-
state.updateWsWarning = a.payload;
|
|
143
|
-
},
|
|
144
|
-
cloudSaves: (state, a: { payload: boolean }) => {
|
|
145
|
-
state.cloudSaves = a.payload;
|
|
146
|
-
},
|
|
147
|
-
},
|
|
148
|
-
extraReducers: (builder) => {
|
|
149
|
-
builder
|
|
150
|
-
.addCase(createAction<string>("dos/bndLoad"), (s, a) => {
|
|
151
|
-
s.window = "loading";
|
|
152
|
-
})
|
|
153
|
-
.addCase(createAction<string>("editor/extract"), (s, a) => {
|
|
154
|
-
s.window = "loading";
|
|
155
|
-
})
|
|
156
|
-
.addCase(createAction<string>("editor/ready"), (s, a) => {
|
|
157
|
-
s.window = "prerun";
|
|
158
|
-
})
|
|
159
|
-
.addCase(createAction<string>("dos/bndReady"), (s, a) => {
|
|
160
|
-
s.window = "prerun";
|
|
161
|
-
})
|
|
162
|
-
.addCase(createAction<string>("dos/bndPlay"), (s, a) => {
|
|
163
|
-
s.window = "run";
|
|
164
|
-
s.frame = "none";
|
|
165
|
-
})
|
|
166
|
-
.addMatcher((action: { type: string }) => {
|
|
167
|
-
return action.type.startsWith("dos/") &&
|
|
168
|
-
action.type.endsWith("Error");
|
|
169
|
-
}, (s, a) => {
|
|
170
|
-
s.window = "error";
|
|
171
|
-
});
|
|
172
|
-
},
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
function toggleFrameIfNeeded(
|
|
176
|
-
state: typeof initialState,
|
|
177
|
-
newFrame: typeof initialState.frame) {
|
|
178
|
-
if (state.frame === newFrame) {
|
|
179
|
-
state.frame = "none";
|
|
180
|
-
} else {
|
|
181
|
-
state.frame = newFrame;
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
export function dispatchLoginAction(account: Account | null, dispatch: Dispatch) {
|
|
186
|
-
if (account === null) {
|
|
187
|
-
dispatch(uiSlice.actions.modalLogin());
|
|
188
|
-
} else {
|
|
189
|
-
dispatch(uiSlice.actions.frameAccount());
|
|
190
|
-
}
|
|
191
|
-
}
|
package/src/store.tsx
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { ThunkMiddleware, configureStore } from "@reduxjs/toolkit";
|
|
2
|
-
import { UiState, uiSlice } from "./store/ui";
|
|
3
|
-
import { AuthState, authSlice } from "./store/auth";
|
|
4
|
-
import { DosState, dosSlice } from "./store/dos";
|
|
5
|
-
import { I18NState, i18nSlice } from "./i18n";
|
|
6
|
-
import { StorageState, storageSlice } from "./store/storage";
|
|
7
|
-
import { EditorState, editorSlice } from "./store/editor";
|
|
8
|
-
import { DosEvent, DosOptions } from "./public/types";
|
|
9
|
-
import { CommandInterface, InitFs } from "emulators";
|
|
10
|
-
import { useStore } from "react-redux";
|
|
11
|
-
import { Cache, CacheNoop } from "./host/lcache";
|
|
12
|
-
import { InitState, createInitSlice, initSlice, sockdriveBackend, sockdriveBackendNames } from "./store/init";
|
|
13
|
-
|
|
14
|
-
export interface LoadedBundle {
|
|
15
|
-
bundleUrl: string | null,
|
|
16
|
-
bundleChangesUrl: string | null,
|
|
17
|
-
bundle: InitFs | null,
|
|
18
|
-
bundleChanges: Uint8Array | null,
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export interface NonSerializableStore {
|
|
22
|
-
root: HTMLDivElement,
|
|
23
|
-
loadedBundle: LoadedBundle | null,
|
|
24
|
-
ci: CommandInterface | null,
|
|
25
|
-
cache: Cache,
|
|
26
|
-
options: Partial<DosOptions>,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export interface DosAction {
|
|
30
|
-
asyncStore: (cakkback: (store: Store) => void) => void,
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const dosMiddleware: ThunkMiddleware<any> = (store) => (next) => (action) => {
|
|
34
|
-
function asyncStore(callback: (store: any) => void) {
|
|
35
|
-
setTimeout(() => callback(store), 4);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const actionWithAsyncDispatch =
|
|
39
|
-
Object.assign({}, action, { asyncStore });
|
|
40
|
-
|
|
41
|
-
next(actionWithAsyncDispatch);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const nonSerializableStoreMap: { [uid: string]: NonSerializableStore } = {};
|
|
45
|
-
|
|
46
|
-
export function makeNonSerializableStore(options: Partial<DosOptions>): NonSerializableStore {
|
|
47
|
-
return {
|
|
48
|
-
root: null as any,
|
|
49
|
-
loadedBundle: null,
|
|
50
|
-
ci: null,
|
|
51
|
-
cache: new CacheNoop(),
|
|
52
|
-
options,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function makeStore(nonSerializableStore: NonSerializableStore, options: Partial<DosOptions>) {
|
|
57
|
-
const { storeUid, slice } = createInitSlice();
|
|
58
|
-
const store = configureStore({
|
|
59
|
-
reducer: {
|
|
60
|
-
init: slice.reducer,
|
|
61
|
-
i18n: i18nSlice.reducer,
|
|
62
|
-
auth: authSlice.reducer,
|
|
63
|
-
ui: uiSlice.reducer,
|
|
64
|
-
dos: dosSlice.reducer,
|
|
65
|
-
storage: storageSlice.reducer,
|
|
66
|
-
editor: editorSlice.reducer,
|
|
67
|
-
},
|
|
68
|
-
middleware: (getDefault) => {
|
|
69
|
-
const all = getDefault();
|
|
70
|
-
all.push(dosMiddleware);
|
|
71
|
-
return all;
|
|
72
|
-
},
|
|
73
|
-
});
|
|
74
|
-
nonSerializableStoreMap[storeUid] = nonSerializableStore;
|
|
75
|
-
if (options.sockdriveBackend && sockdriveBackendNames.indexOf(options.sockdriveBackend.name) === -1) {
|
|
76
|
-
sockdriveBackendNames.push(options.sockdriveBackend.name);
|
|
77
|
-
sockdriveBackend[options.sockdriveBackend.name] = {
|
|
78
|
-
sockdriveEndpoint: "https://" + options.sockdriveBackend.host,
|
|
79
|
-
sockdriveWssEndpoint: "wss://" + options.sockdriveBackend.host,
|
|
80
|
-
};
|
|
81
|
-
store.dispatch(initSlice.actions.setSockdriveBackendName(options.sockdriveBackend.name));
|
|
82
|
-
}
|
|
83
|
-
return store;
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
export interface State {
|
|
87
|
-
init: InitState,
|
|
88
|
-
ui: UiState,
|
|
89
|
-
auth: AuthState,
|
|
90
|
-
dos: DosState,
|
|
91
|
-
i18n: I18NState,
|
|
92
|
-
editor: EditorState,
|
|
93
|
-
storage: StorageState,
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export type Store = ReturnType<typeof makeStore>;
|
|
97
|
-
|
|
98
|
-
export function getNonSerializableStore(storeOrState: any): NonSerializableStore {
|
|
99
|
-
if (typeof storeOrState.getState === "function") {
|
|
100
|
-
return nonSerializableStoreMap[storeOrState.getState().init.uid];
|
|
101
|
-
} else {
|
|
102
|
-
return nonSerializableStoreMap[storeOrState.init.uid];
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function useNonSerializableStore() {
|
|
107
|
-
return getNonSerializableStore(useStore());
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export function postJsDosEvent(nonSerializableStore: NonSerializableStore, event: DosEvent, ci?: CommandInterface) {
|
|
111
|
-
if (nonSerializableStore.options.onEvent) {
|
|
112
|
-
setTimeout(() => {
|
|
113
|
-
nonSerializableStore.options.onEvent?.(event, ci);
|
|
114
|
-
}, 4);
|
|
115
|
-
}
|
|
116
|
-
};
|
package/src/ui.tsx
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef } from "preact/hooks";
|
|
2
|
-
import { useDispatch, useSelector } from "react-redux";
|
|
3
|
-
import { Login } from "./login/login";
|
|
4
|
-
import { Frame } from "./frame/frame";
|
|
5
|
-
import { SideBar } from "./sidebar/sidebar";
|
|
6
|
-
import { State } from "./store";
|
|
7
|
-
import { dispatchLoginAction, uiSlice } from "./store/ui";
|
|
8
|
-
import { Window } from "./window/window";
|
|
9
|
-
import { useT } from "./i18n";
|
|
10
|
-
|
|
11
|
-
let currentWideScreen = uiSlice.getInitialState().wideScreen;
|
|
12
|
-
export function Ui() {
|
|
13
|
-
const rootRef = useRef<HTMLDivElement>(null);
|
|
14
|
-
const theme = useSelector((state: State) => state.ui.theme);
|
|
15
|
-
const dispatch = useDispatch();
|
|
16
|
-
|
|
17
|
-
useEffect(() => {
|
|
18
|
-
if (rootRef === null || rootRef.current === null) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const root = rootRef.current;
|
|
23
|
-
function onResize() {
|
|
24
|
-
const size = root.getBoundingClientRect().width;
|
|
25
|
-
const wide = size > 640;
|
|
26
|
-
if (wide !== currentWideScreen) {
|
|
27
|
-
currentWideScreen = wide;
|
|
28
|
-
dispatch(uiSlice.actions.setWideScreen(currentWideScreen));
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const resizeObserver = new ResizeObserver(onResize);
|
|
33
|
-
resizeObserver.observe(root);
|
|
34
|
-
window.addEventListener("resize", onResize);
|
|
35
|
-
|
|
36
|
-
return () => {
|
|
37
|
-
resizeObserver.disconnect();
|
|
38
|
-
window.removeEventListener("resize", onResize);
|
|
39
|
-
};
|
|
40
|
-
}, [rootRef, dispatch]);
|
|
41
|
-
|
|
42
|
-
return <div
|
|
43
|
-
ref={rootRef}
|
|
44
|
-
class="w-full h-full relative"
|
|
45
|
-
data-theme={theme}>
|
|
46
|
-
<Window />
|
|
47
|
-
<Frame />
|
|
48
|
-
<SideBar />
|
|
49
|
-
<Login />
|
|
50
|
-
<Toast />
|
|
51
|
-
<ReadOnlyWarning />
|
|
52
|
-
<UpdateWsWarning />
|
|
53
|
-
</div>;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function Toast() {
|
|
57
|
-
const toast = useSelector((state: State) => state.ui.toast);
|
|
58
|
-
const intent = useSelector((state: State) => state.ui.toastIntent);
|
|
59
|
-
const readOnlyWarning = useSelector((state: State) => state.ui.readOnlyWarning);
|
|
60
|
-
|
|
61
|
-
if (toast === null) {
|
|
62
|
-
return null;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return <div class={"absolute right-10 " + (readOnlyWarning ? "bottom-32" : "bottom-10")}>
|
|
66
|
-
<div class={"alert alert-" + (intent === "panic" ? "error" : intent)} >
|
|
67
|
-
{toast}
|
|
68
|
-
</div>
|
|
69
|
-
</div>;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function ReadOnlyWarning() {
|
|
73
|
-
const readOnlyWarning = useSelector((state: State) => state.ui.readOnlyWarning);
|
|
74
|
-
const account = useSelector((state: State) => state.auth.account);
|
|
75
|
-
const t = useT();
|
|
76
|
-
const dispatch = useDispatch();
|
|
77
|
-
|
|
78
|
-
if (!readOnlyWarning) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function fix() {
|
|
83
|
-
dispatch(uiSlice.actions.readOnlyWarning(false));
|
|
84
|
-
dispatchLoginAction(account, dispatch);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
function close() {
|
|
88
|
-
dispatch(uiSlice.actions.readOnlyWarning(false));
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
return <div class="absolute right-10 bottom-10">
|
|
92
|
-
<div class="alert">
|
|
93
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
|
94
|
-
class="stroke-info shrink-0 w-6 h-6">
|
|
95
|
-
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
|
96
|
-
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
|
|
97
|
-
</svg>
|
|
98
|
-
<span>{t("read_only_access")}</span>
|
|
99
|
-
<div>
|
|
100
|
-
<button class="btn btn-sm btn-primary mr-2" onClick={fix}>{t("fix")}</button>
|
|
101
|
-
<button class="btn btn-sm" onClick={close}>{t("close")}</button>
|
|
102
|
-
</div>
|
|
103
|
-
</div>
|
|
104
|
-
</div>;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function UpdateWsWarning() {
|
|
108
|
-
const updateWsWarning = useSelector((state: State) => state.ui.updateWsWarning);
|
|
109
|
-
const t = useT();
|
|
110
|
-
const dispatch = useDispatch();
|
|
111
|
-
|
|
112
|
-
if (!updateWsWarning) {
|
|
113
|
-
return null;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
function fix() {
|
|
117
|
-
window.open("https://dos.zone/download/", "_blank");
|
|
118
|
-
dispatch(uiSlice.actions.updateWsWarning(false));
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function close() {
|
|
122
|
-
dispatch(uiSlice.actions.updateWsWarning(false));
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return <div class="absolute left-20 right-10 top-10 flex justify-center">
|
|
126
|
-
<div class="alert w-auto">
|
|
127
|
-
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
|
|
128
|
-
stroke-width="1.5" stroke="currentColor" class="size-6 text-error">
|
|
129
|
-
<path stroke-linecap="round" stroke-linejoin="round" d="M12 9v3.75m-9.303 3.376c-.866 1.5.217
|
|
130
|
-
3.374 1.948 3.374h14.71c1.73 0 2.813-1.874 1.948-3.374L13.949 3.378c-.866-1.5-3.032-1.5-3.898
|
|
131
|
-
0L2.697 16.126ZM12 15.75h.007v.008H12v-.008Z" />
|
|
132
|
-
</svg>
|
|
133
|
-
<span>{t("ws_outdated")}</span>
|
|
134
|
-
<div>
|
|
135
|
-
<button class="btn btn-sm btn-primary mr-2" onClick={fix}>{t("update")}</button>
|
|
136
|
-
<button class="btn btn-sm" onClick={close}>{t("close")}</button>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
</div>;
|
|
140
|
-
}
|
package/src/v8/changes.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { uploadsS3Url, uploadsS3Bucket, uploadNamspace, presignPut } from "./config";
|
|
2
|
-
|
|
3
|
-
function getPersonalBundleKey(id: string,
|
|
4
|
-
bundleUrl: string): string {
|
|
5
|
-
const index = bundleUrl.lastIndexOf("/");
|
|
6
|
-
const basename = bundleUrl.substring(index + 1);
|
|
7
|
-
return "personal-v2/" + uploadNamspace + "/" + id + "/" + basename;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function getChangesUrlPrefix(id: string): string {
|
|
11
|
-
return uploadsS3Url + "/" + uploadsS3Bucket + "/" + "personal-v2" + "/" + uploadNamspace + "/" + id + "/";
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export function getChangesUrl(id: string, bundleUrl: string): string {
|
|
15
|
-
const personalBundleKey = getPersonalBundleKey(id, bundleUrl);
|
|
16
|
-
return uploadsS3Url + "/" + uploadsS3Bucket + "/" + personalBundleKey;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export async function putChanges(bundleUrl: string,
|
|
20
|
-
data: Uint8Array): Promise<void> {
|
|
21
|
-
let response = await fetch(presignPut + "?bundleUrl=" + encodeURIComponent(bundleUrl));
|
|
22
|
-
const result = await response.json();
|
|
23
|
-
|
|
24
|
-
if (!result.success) {
|
|
25
|
-
throw new Error("Unable to put personal bundle");
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const post = result.post as {
|
|
29
|
-
url: string,
|
|
30
|
-
fields: {
|
|
31
|
-
Policy: string,
|
|
32
|
-
"X-Amz-Algorithm": string,
|
|
33
|
-
"X-Amz-Credential": string,
|
|
34
|
-
"X-Amz-Date": string,
|
|
35
|
-
"X-Amz-Signature": string,
|
|
36
|
-
bucket: string,
|
|
37
|
-
key: string,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
const formData = new FormData();
|
|
42
|
-
Object.entries(post.fields).forEach(([k, v]) => {
|
|
43
|
-
formData.append(k, v);
|
|
44
|
-
});
|
|
45
|
-
formData.append("acl", "public-read");
|
|
46
|
-
formData.append("file", new Blob([data]));
|
|
47
|
-
|
|
48
|
-
response = await fetch(post.url, {
|
|
49
|
-
method: "post",
|
|
50
|
-
body: formData,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
if (response.status !== 200 && response.status !== 204) {
|
|
54
|
-
throw new Error("Unable to put changes: " + response.statusText);
|
|
55
|
-
}
|
|
56
|
-
}
|
package/src/v8/config.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const endpoint = "https://v8.js-dos.com";
|
|
2
|
-
export const authentificator = endpoint + "/auth/";
|
|
3
|
-
export const uploadsS3Bucket = "doszone-uploads";
|
|
4
|
-
export const uploadsS3Url = "https://storage.yandexcloud.net";
|
|
5
|
-
export const uploadNamspace = "dzapi";
|
|
6
|
-
|
|
7
|
-
export const apiEndpoint = "https://d5dn8hh4ivlobv6682ep.apigw.yandexcloud.net";
|
|
8
|
-
export const presignPut = apiEndpoint + "/presign-put";
|
|
9
|
-
|
|
10
|
-
export const xsollaSubscriptons = "https://subscriptions.xsolla.com/api/user/v1/projects/184012/subscriptions";
|
|
11
|
-
export const xsollaPremiumId = "sumOxNVr";
|
|
12
|
-
|
|
13
|
-
export const brCdn = "https://br.cdn.dos.zone";
|
|
14
|
-
|
|
15
|
-
export const cancelSubscriptionPage = {
|
|
16
|
-
en: "https://v8.js-dos.com/cancel-your-subscription/",
|
|
17
|
-
ru: "https://v8.js-dos.com/ru/cancel-your-subscription/",
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export const actualWsVersion = 2;
|
package/src/v8/subscriptions.ts
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { xsollaPremiumId, xsollaSubscriptons } from "../v8/config";
|
|
2
|
-
|
|
3
|
-
export async function linkToBuy(token: string): Promise<string | null> {
|
|
4
|
-
const response = await fetch(xsollaSubscriptons + "/buy", {
|
|
5
|
-
method: "POST",
|
|
6
|
-
cache: "no-cache",
|
|
7
|
-
headers: {
|
|
8
|
-
"Authorization": "Bearer " + token,
|
|
9
|
-
"Content-Type": "application/json",
|
|
10
|
-
},
|
|
11
|
-
body: JSON.stringify({
|
|
12
|
-
plan_external_id: xsollaPremiumId,
|
|
13
|
-
}),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
const json = await response.json();
|
|
17
|
-
|
|
18
|
-
if (json.link_to_ps === undefined) {
|
|
19
|
-
console.error("Unexpected subscriptions response:", json);
|
|
20
|
-
return null;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
return json.link_to_ps;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function havePremium(token: string): Promise<boolean> {
|
|
27
|
-
const response = await fetch(xsollaSubscriptons, {
|
|
28
|
-
method: "GET",
|
|
29
|
-
cache: "no-cache",
|
|
30
|
-
headers: {
|
|
31
|
-
"Authorization": "Bearer " + token,
|
|
32
|
-
},
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
const json = await response.json();
|
|
36
|
-
if (json.items === undefined) {
|
|
37
|
-
console.error("Unexpected subscriptions response:", json);
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
return json.items.length > 0 && json.items[0].plan_external_id === xsollaPremiumId;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export async function cancle(token: string): Promise<boolean> {
|
|
45
|
-
// eslint-disable-next-line
|
|
46
|
-
// https://subscriptions.xsolla.com/api/doc/user#/Subscriptions/put_xsolla_subscription_apiuser_cancelusersubscription
|
|
47
|
-
const response = await fetch(xsollaSubscriptons + "/" + xsollaPremiumId + "/cancel", {
|
|
48
|
-
method: "PUT",
|
|
49
|
-
cache: "no-cache",
|
|
50
|
-
headers: {
|
|
51
|
-
"Authorization": "Bearer " + token,
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
const json = await response.json();
|
|
56
|
-
if (json.error) {
|
|
57
|
-
console.error("Unexpected subscriptions response:", json);
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return true;
|
|
62
|
-
}
|
package/src/vite-env.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { CommandInterface } from "emulators";
|
|
2
|
-
import { domToKeyCode } from "./keys";
|
|
3
|
-
|
|
4
|
-
export function keyboard(el: HTMLElement, ci: CommandInterface) {
|
|
5
|
-
function onKeyDown(e: KeyboardEvent) {
|
|
6
|
-
if ((e.target as any).type === "text") {
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
const keyCode = domToKeyCode(e.keyCode);
|
|
10
|
-
ci.sendKeyEvent(keyCode, true);
|
|
11
|
-
e.stopPropagation();
|
|
12
|
-
e.preventDefault();
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
function onKeyUp(e: KeyboardEvent) {
|
|
16
|
-
if ((e.target as any).type === "text") {
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
const keyCode = domToKeyCode(e.keyCode);
|
|
20
|
-
ci.sendKeyEvent(keyCode, false);
|
|
21
|
-
e.stopPropagation();
|
|
22
|
-
e.preventDefault();
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
el.addEventListener("keydown", onKeyDown);
|
|
26
|
-
el.addEventListener("keyup", onKeyUp);
|
|
27
|
-
|
|
28
|
-
return () => {
|
|
29
|
-
el.removeEventListener("keydown", onKeyDown);
|
|
30
|
-
el.removeEventListener("keyup", onKeyUp);
|
|
31
|
-
};
|
|
32
|
-
}
|