sliftutils 0.6.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/builders/electronBuild.ts +101 -0
- package/builders/electronBuildRun.js +4 -0
- package/builders/extensionBuild.ts +15 -9
- package/builders/hotReload.ts +96 -0
- package/builders/nodeJSBuild.ts +1 -1
- package/builders/setup.ts +192 -0
- package/builders/setupRun.js +4 -0
- package/builders/watch.ts +182 -0
- package/builders/watchRun.js +4 -0
- package/builders/webBuild.ts +2 -2
- package/builders/webBuildRun.js +1 -1
- package/builders/webRun.js +4 -0
- package/bundler/bundleEntry.ts +17 -9
- package/bundler/bundleEntryCaller.ts +1 -1
- package/bundler/bundleRequire.ts +21 -3
- package/electron/electronIndex.html +12 -0
- package/electron/electronMain.ts +29 -0
- package/electron/electronRenderer.tsx +33 -0
- package/extension/extBackground.ts +22 -0
- package/extension/extContentScript.ts +19 -0
- package/extension/manifest.json +29 -0
- package/misc/environment.ts +28 -0
- package/nodejs/server.ts +16 -0
- package/package.json +20 -3
- package/render-utils/browser.tsx +31 -0
- package/render-utils/index.html +12 -0
- package/spec.txt +32 -46
- package/storage/FileFolderAPI.tsx +1 -1
- package/storage/PendingManager.tsx +1 -1
- package/web/browser.tsx +37 -0
- package/web/index.html +32 -0
- /package/{web → render-utils}/DropdownCustom.tsx +0 -0
- /package/{web → render-utils}/FullscreenModal.tsx +0 -0
- /package/{web → render-utils}/GenericFormat.tsx +0 -0
- /package/{web → render-utils}/Input.tsx +0 -0
- /package/{web → render-utils}/InputLabel.tsx +0 -0
- /package/{web → render-utils}/InputPicker.tsx +0 -0
- /package/{web → render-utils}/LocalStorageParam.ts +0 -0
- /package/{web → render-utils}/SyncedController.ts +0 -0
- /package/{web → render-utils}/SyncedLoadingIndicator.tsx +0 -0
- /package/{web → render-utils}/Table.tsx +0 -0
- /package/{web → render-utils}/URLParam.ts +0 -0
- /package/{web → render-utils}/asyncObservable.ts +0 -0
- /package/{web → render-utils}/colors.tsx +0 -0
- /package/{web → render-utils}/mobxTyped.ts +0 -0
- /package/{web → render-utils}/modal.tsx +0 -0
- /package/{web → render-utils}/observer.tsx +0 -0
package/bundler/bundleEntry.ts
CHANGED
|
@@ -1,22 +1,19 @@
|
|
|
1
1
|
import path from "path";
|
|
2
2
|
import { bundle } from "./bundler";
|
|
3
3
|
import fs from "fs";
|
|
4
|
-
import yargs from "yargs";
|
|
5
4
|
|
|
6
5
|
async function main() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
.argv || {}
|
|
11
|
-
;
|
|
12
|
-
let entryPoint = yargObj.entryPoint;
|
|
13
|
-
let outputFolder = yargObj.outputFolder;
|
|
6
|
+
// NOTE: Using yargs added ~0.5s to the time to run this, and considering we run in ~1s... that's just too much
|
|
7
|
+
let entryPoint = process.argv[2];
|
|
8
|
+
let outputFolder = process.argv[3];
|
|
14
9
|
if (!entryPoint) {
|
|
15
10
|
throw new Error("No entry point provided. Please use the --entryPoint option.");
|
|
16
11
|
}
|
|
17
12
|
if (!outputFolder) {
|
|
18
13
|
throw new Error("No output folder provided. Please use the --outputFolder option.");
|
|
19
14
|
}
|
|
15
|
+
// We prefer production, as this is what the bundler uses internally. This ensures that in the build and when run, we will have the same environment, which will result in the same requires being called.
|
|
16
|
+
process.env.NODE_ENV = process.env.NODE_ENV || "production";
|
|
20
17
|
require(entryPoint);
|
|
21
18
|
|
|
22
19
|
let name = path.basename(entryPoint);
|
|
@@ -32,6 +29,17 @@ async function main() {
|
|
|
32
29
|
rootPath: path.resolve("."),
|
|
33
30
|
entryPoints: [entryPoint],
|
|
34
31
|
});
|
|
35
|
-
|
|
32
|
+
|
|
33
|
+
let finalPath = `${outputFolder}/${name}`;
|
|
34
|
+
let tempPath = `${finalPath}.tmp`;
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
await fs.promises.writeFile(tempPath, bundled.bundle);
|
|
38
|
+
await fs.promises.rename(tempPath, finalPath);
|
|
39
|
+
} finally {
|
|
40
|
+
try {
|
|
41
|
+
await fs.promises.unlink(tempPath);
|
|
42
|
+
} catch { }
|
|
43
|
+
}
|
|
36
44
|
}
|
|
37
45
|
main().catch(console.error).finally(() => process.exit());
|
|
@@ -10,5 +10,5 @@ export async function bundleEntryCaller(config: {
|
|
|
10
10
|
entryPoint = path.resolve(entryPoint).replace(/\\/g, "/");
|
|
11
11
|
outputFolder = path.resolve(outputFolder).replace(/\\/g, "/");
|
|
12
12
|
let bundleEntryPath = path.resolve(__dirname, "bundleEntry.ts").replace(/\\/g, "/");
|
|
13
|
-
await runPromise(`
|
|
13
|
+
await runPromise(`node -r ./node_modules/typenode/index.js ${JSON.stringify(bundleEntryPath)} ${JSON.stringify(entryPoint)} ${JSON.stringify(outputFolder)}`);
|
|
14
14
|
}
|
package/bundler/bundleRequire.ts
CHANGED
|
@@ -16,11 +16,9 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
16
16
|
(globalThis as any).global = (globalThis as any).global || globalThis;
|
|
17
17
|
(globalThis as any).setImmediate = (globalThis as any).setImmediate || globalThis.setTimeout;
|
|
18
18
|
|
|
19
|
-
// Set document, so isNode checks return false.
|
|
20
|
-
(globalThis as any).document = (globalThis as any).document || {};
|
|
21
19
|
(globalThis as any).BOOTED_EDGE_NODE = undefined;
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
let builtInModuleExports: { [key: string]: unknown } = {
|
|
24
22
|
worker_threads: {
|
|
25
23
|
isMainThread: true,
|
|
26
24
|
},
|
|
@@ -47,6 +45,26 @@ export function bundleRequire(config: BundleRequireConfig) {
|
|
|
47
45
|
child_process: {},
|
|
48
46
|
events: class EventEmitter { },
|
|
49
47
|
};
|
|
48
|
+
// If is nodeJs
|
|
49
|
+
let allBuiltInModules = new Set<string>();
|
|
50
|
+
// Electron
|
|
51
|
+
allBuiltInModules.add("electron");
|
|
52
|
+
allBuiltInModules.add("original-fs");
|
|
53
|
+
allBuiltInModules.add("vscode");
|
|
54
|
+
if (typeof document === "undefined" && typeof require !== "undefined") {
|
|
55
|
+
// Change the builts ins to use the actual built ins!
|
|
56
|
+
let { builtinModules } = require("node:module");
|
|
57
|
+
for (let key of builtinModules) {
|
|
58
|
+
allBuiltInModules.add(key);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
for (let key of allBuiltInModules) {
|
|
62
|
+
Object.defineProperty(builtInModuleExports, key, {
|
|
63
|
+
get() {
|
|
64
|
+
return require(key);
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
50
68
|
|
|
51
69
|
// Just path.resolve (but needs to be reimplemented, because we can't use imports)
|
|
52
70
|
function pathResolve(...paths: string[]): string {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { app, BrowserWindow } from "electron";
|
|
2
|
+
import { isInElectron } from "../misc/environment";
|
|
3
|
+
|
|
4
|
+
function main() {
|
|
5
|
+
if (!isInElectron()) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
app.whenReady().then(() => {
|
|
10
|
+
const mainWindow = new BrowserWindow({
|
|
11
|
+
width: 800,
|
|
12
|
+
height: 600,
|
|
13
|
+
webPreferences: {
|
|
14
|
+
nodeIntegration: false,
|
|
15
|
+
contextIsolation: true,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
mainWindow.loadFile("./electronIndex.html");
|
|
20
|
+
mainWindow.webContents.openDevTools();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
app.on("window-all-closed", () => {
|
|
24
|
+
app.quit();
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
main();
|
|
29
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as preact from "preact";
|
|
2
|
+
import { observable } from "mobx";
|
|
3
|
+
import { observer } from "../render-utils/observer";
|
|
4
|
+
import { isNode } from "typesafecss";
|
|
5
|
+
import { enableHotReloading } from "../builders/hotReload";
|
|
6
|
+
|
|
7
|
+
@observer
|
|
8
|
+
class App extends preact.Component {
|
|
9
|
+
synced = observable({
|
|
10
|
+
count: 0,
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
render() {
|
|
14
|
+
return (
|
|
15
|
+
<div>
|
|
16
|
+
<h1>Hello from Electron!</h1>
|
|
17
|
+
<p>Count: {this.synced.count}</p>
|
|
18
|
+
<button onClick={() => this.synced.count++}>
|
|
19
|
+
Increment
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function main() {
|
|
27
|
+
if (isNode()) return;
|
|
28
|
+
await enableHotReloading({ port: 9879 });
|
|
29
|
+
preact.render(<App />, document.getElementById("app")!);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
main().catch(console.error);
|
|
33
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { enableHotReloading } from "../builders/hotReload";
|
|
2
|
+
import { isInChromeExtension } from "../misc/environment";
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
if (!isInChromeExtension()) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
await enableHotReloading({ port: 9878 });
|
|
10
|
+
|
|
11
|
+
chrome.runtime.onInstalled.addListener(() => {
|
|
12
|
+
console.log("Extension installed!");
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
|
|
16
|
+
console.log("Message received:", message, sender);
|
|
17
|
+
sendResponse({ status: "ok 26" });
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
main().catch(console.error);
|
|
22
|
+
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { enableHotReloading } from "../builders/hotReload";
|
|
2
|
+
import { isInChromeExtension } from "../misc/environment";
|
|
3
|
+
|
|
4
|
+
async function main() {
|
|
5
|
+
if (!isInChromeExtension()) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
await enableHotReloading({ port: 9878 });
|
|
10
|
+
|
|
11
|
+
console.log("Content script loaded! new");
|
|
12
|
+
|
|
13
|
+
chrome.runtime.sendMessage({ type: "contentScriptLoaded" }, (response) => {
|
|
14
|
+
console.log("Response from background:", response);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
main().catch(console.error);
|
|
19
|
+
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"manifest_version": 3,
|
|
3
|
+
"name": "Example Extension",
|
|
4
|
+
"version": "1.0.0",
|
|
5
|
+
"description": "Example Chrome extension",
|
|
6
|
+
"background": {
|
|
7
|
+
"service_worker": "extBackground.js"
|
|
8
|
+
},
|
|
9
|
+
"content_scripts": [
|
|
10
|
+
{
|
|
11
|
+
"matches": [
|
|
12
|
+
"*://*.wikipedia.org/*"
|
|
13
|
+
],
|
|
14
|
+
"js": [
|
|
15
|
+
"extContentScript.js"
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"permissions": [
|
|
20
|
+
"tabs",
|
|
21
|
+
"storage"
|
|
22
|
+
],
|
|
23
|
+
"host_permissions": [
|
|
24
|
+
"*://*.wikipedia.org/*"
|
|
25
|
+
],
|
|
26
|
+
"icons": {
|
|
27
|
+
"16": "assets/icon16.png"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/misc/environment.ts
CHANGED
|
@@ -2,10 +2,38 @@
|
|
|
2
2
|
export function isInChromeExtension() {
|
|
3
3
|
return typeof chrome !== "undefined" && chrome.runtime && chrome.runtime.id;
|
|
4
4
|
}
|
|
5
|
+
export function isInChromeExtensionBackground() {
|
|
6
|
+
if (!isInChromeExtension()) return false;
|
|
7
|
+
|
|
8
|
+
// Manifest V3: Service Worker context (has importScripts but no document)
|
|
9
|
+
if (typeof (globalThis as any).importScripts === "function" && typeof document === "undefined") {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Manifest V2: Background page
|
|
14
|
+
if (typeof chrome.extension !== "undefined" && typeof chrome.extension.getBackgroundPage === "function") {
|
|
15
|
+
try {
|
|
16
|
+
return chrome.extension.getBackgroundPage() === window;
|
|
17
|
+
} catch (e) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
export function isInChromeExtensionContentScript() {
|
|
25
|
+
return isInChromeExtension() && !isInChromeExtensionBackground();
|
|
26
|
+
}
|
|
27
|
+
export function isInElectron() {
|
|
28
|
+
return typeof process !== "undefined" && process.versions && process.versions.electron;
|
|
29
|
+
}
|
|
5
30
|
let isInBuildFlag = false;
|
|
6
31
|
export function triggerIsInBuild() {
|
|
7
32
|
isInBuildFlag = true;
|
|
8
33
|
}
|
|
9
34
|
export function isInBuild() {
|
|
10
35
|
return isInBuildFlag;
|
|
36
|
+
}
|
|
37
|
+
export function isInBrowser() {
|
|
38
|
+
return typeof document !== "undefined";
|
|
11
39
|
}
|
package/nodejs/server.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import http from "http";
|
|
2
|
+
|
|
3
|
+
async function main() {
|
|
4
|
+
const server = http.createServer((req, res) => {
|
|
5
|
+
res.writeHead(200, { "Content-Type": "text/plain" });
|
|
6
|
+
res.end("Hello from Node.js!\n");
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
const port = 3000;
|
|
10
|
+
server.listen(port, () => {
|
|
11
|
+
console.log(`Server running at http://localhost:${port}/`);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
main().catch(console.error);
|
|
16
|
+
|
package/package.json
CHANGED
|
@@ -1,17 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sliftutils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"type": "yarn tsc --noEmit",
|
|
8
|
-
"
|
|
8
|
+
"run-nodejs": "node ./build-nodejs/server.js",
|
|
9
|
+
"run-nodejs-dev": "typenode ./nodejs/server.ts",
|
|
10
|
+
"run-web": "node ./builders/webRun.js",
|
|
11
|
+
"run-electron": "node ./node_modules/electron/cli.js ./build-electron/electronMain.js",
|
|
12
|
+
"build-nodejs": "node ./builders/nodeJSBuildRun.js",
|
|
13
|
+
"build-web": "node ./builders/webBuildRun.js",
|
|
14
|
+
"build-extension": "node ./builders/extensionBuildRun.js",
|
|
15
|
+
"build-electron": "node ./builders/electronBuildRun.js",
|
|
16
|
+
"watch-nodejs": "node ./builders/watchRun.js --port 9876 \"nodejs/*.ts\" \"nodejs/*.tsx\" \"yarn build-nodejs\"",
|
|
17
|
+
"watch-web": "node ./builders/watchRun.js --port 9877 \"web/*.ts\" \"web/*.tsx\" \"yarn build-web\"",
|
|
18
|
+
"watch-extension": "node ./builders/watchRun.js --port 9878 \"extension/*.ts\" \"extension/*.tsx\" \"yarn build-extension\"",
|
|
19
|
+
"watch-electron": "node ./builders/watchRun.js --port 9879 \"electron/*.ts\" \"electron/*.tsx\" \"yarn build-electron\"",
|
|
9
20
|
"notes": "mobx, preact, socket-function, typenode SHOULD be peerDependencies. But we want to use yarn (better dependency deduplication), so we can't use peerDependencies (as they aren't installed by default, which makes them a nightmare to use). If you want to override the versions, feel free to use overrides/resolutions."
|
|
10
21
|
},
|
|
11
22
|
"bin": {
|
|
12
23
|
"build-nodejs": "./builders/nodeJSBuildRun.js",
|
|
13
24
|
"build-extension": "./builders/extensionBuildRun.js",
|
|
14
|
-
"build-web": "./builders/webBuildRun.js"
|
|
25
|
+
"build-web": "./builders/webBuildRun.js",
|
|
26
|
+
"build-electron": "./builders/electronBuildRun.js",
|
|
27
|
+
"slift-watch": "./builders/watchRun.js",
|
|
28
|
+
"slift-setup": "./builders/setupRun.js"
|
|
15
29
|
},
|
|
16
30
|
"dependencies": {
|
|
17
31
|
"@types/shell-quote": "^1.7.5",
|
|
@@ -22,12 +36,15 @@
|
|
|
22
36
|
"socket-function": "^0.155.0",
|
|
23
37
|
"typenode": "^6.0.0",
|
|
24
38
|
"typesafecss": "^0.26.0",
|
|
39
|
+
"ws": "^8.18.3",
|
|
25
40
|
"yargs": "15.4.1"
|
|
26
41
|
},
|
|
27
42
|
"devDependencies": {
|
|
28
43
|
"@types/chrome": "^0.0.237",
|
|
29
44
|
"@types/yargs": "15.0.19",
|
|
30
45
|
"debugbreak": "^0.9.9",
|
|
46
|
+
"electron": "^33.2.1",
|
|
47
|
+
"open": "^8.4.0",
|
|
31
48
|
"typedev": "^0.1.1"
|
|
32
49
|
}
|
|
33
50
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import * as preact from "preact";
|
|
2
|
+
import { observable } from "mobx";
|
|
3
|
+
import { observer } from "./observer";
|
|
4
|
+
import { isNode } from "typesafecss";
|
|
5
|
+
|
|
6
|
+
@observer
|
|
7
|
+
class App extends preact.Component {
|
|
8
|
+
synced = observable({
|
|
9
|
+
count: 0,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
render() {
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<h1>Hello from Web!</h1>
|
|
16
|
+
<p>Count: {this.synced.count}</p>
|
|
17
|
+
<button onClick={() => this.synced.count++}>
|
|
18
|
+
Increment
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function main() {
|
|
26
|
+
if (isNode()) return;
|
|
27
|
+
preact.render(<App />, document.getElementById("app")!);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
main().catch(console.error);
|
|
31
|
+
|
package/spec.txt
CHANGED
|
@@ -1,52 +1,38 @@
|
|
|
1
|
-
TODO:
|
|
2
|
-
|
|
3
1
|
|
|
4
|
-
|
|
2
|
+
1) Copy command (setup-proj?, copy-proj?), to copy all default files
|
|
3
|
+
- I think we will have to do some renaming so that when it references our lib files, it actually references our package instead of relative.
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
- HELPER bin to setup the project with:
|
|
6
|
+
(Only if the files don't exist)
|
|
7
|
+
tsconfig.json
|
|
8
|
+
.gitignore
|
|
9
|
+
.vscode (for format on save)
|
|
10
|
+
.eslintrc.js
|
|
11
|
+
.cursorrules
|
|
12
|
+
Add dependencies to package.json
|
|
13
|
+
(Any dependencies our helper project has should be dev dependencies)
|
|
14
|
+
- typenode
|
|
15
|
+
- socket-function
|
|
16
|
+
- typesafecss
|
|
17
|
+
- typedev
|
|
18
|
+
add the basic entry points for Node.js, the browser, the browser HTML file, and even some files for a Chrome extension, and even for an Electron app.
|
|
19
|
+
- We'll make Electron optional though, and so they'll have to manually install Electron if they want to make an Electron app. We can check for this and warn if they try to build electron without having electron installed.
|
|
20
|
+
Add build and type commands to package.json
|
|
21
|
+
- We have the binaries for the build commands, but adding them to packs.json makes it a lot more discoverable.
|
|
22
|
+
- And it's just very good practice to add the type command to package.json. That way you could just say, what does this command do to the AI? and it'll tell you exactly what it does, instead of nesting
|
|
17
23
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
24
|
+
EXPOSE our helpers in our main export, in an index.ts file?
|
|
25
|
+
- Will this let us just import them? Hmm...
|
|
26
|
+
5) Test it in a new test repo
|
|
27
|
+
- Test it with:
|
|
28
|
+
single html browser site
|
|
29
|
+
nodejs bundled running
|
|
30
|
+
electron
|
|
31
|
+
chrome extension
|
|
32
|
+
- Make sure sourcemaps are preserved and work
|
|
33
|
+
5.1) Use the new project and bundler in voice-cloner
|
|
22
34
|
|
|
23
|
-
watch helper script in bin
|
|
24
|
-
- And have it automatically ignore .gitignored files
|
|
25
|
-
- And have it also watch .watchignore
|
|
26
35
|
|
|
27
|
-
- HELPER bin to setup the project with:
|
|
28
|
-
(Only if the files don't exist)
|
|
29
|
-
tsconfig.json
|
|
30
|
-
.gitignore
|
|
31
|
-
.vscode (for format on save)
|
|
32
|
-
.eslintrc.js
|
|
33
|
-
.cursorrules
|
|
34
|
-
Add dependencies to package.json
|
|
35
|
-
(Any dependencies our helper project has should be dev dependencies)
|
|
36
|
-
- typenode
|
|
37
|
-
- socket-function
|
|
38
|
-
- typesafecss
|
|
39
|
-
- typedev
|
|
40
|
-
index.ts and index.html
|
|
41
|
-
Add build and type commands to package.json
|
|
42
36
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
5) Test it in a new test repo
|
|
46
|
-
- Test it with:
|
|
47
|
-
single html browser site
|
|
48
|
-
nodejs bundled running
|
|
49
|
-
electron
|
|
50
|
-
chrome extension
|
|
51
|
-
- Make sure sourcemaps are preserved and work
|
|
52
|
-
5.1) Use the new project and bundler in voice-cloner
|
|
37
|
+
TODO:
|
|
38
|
+
- vscode extension as well
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import preact from "preact";
|
|
2
2
|
import { getFileSystemPointer, storeFileSystemPointer } from "./fileSystemPointer";
|
|
3
3
|
import { observable } from "mobx";
|
|
4
|
-
import { observer } from "../
|
|
4
|
+
import { observer } from "../render-utils/observer";
|
|
5
5
|
import { cache, lazy } from "socket-function/src/caching";
|
|
6
6
|
import { css, isNode } from "typesafecss";
|
|
7
7
|
import { IStorageRaw } from "./IStorage";
|
|
@@ -2,7 +2,7 @@ import { throttleFunction } from "socket-function/src/misc";
|
|
|
2
2
|
import { observable } from "mobx";
|
|
3
3
|
import preact from "preact";
|
|
4
4
|
import { css } from "typesafecss";
|
|
5
|
-
import { observer } from "../
|
|
5
|
+
import { observer } from "../render-utils/observer";
|
|
6
6
|
import { formatTime } from "socket-function/src/formatting/format";
|
|
7
7
|
|
|
8
8
|
let watchState = observable({
|
package/web/browser.tsx
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as preact from "preact";
|
|
2
|
+
import { observable } from "mobx";
|
|
3
|
+
import { observer } from "../render-utils/observer";
|
|
4
|
+
import { css, isNode } from "typesafecss";
|
|
5
|
+
import { list } from "socket-function/src/misc";
|
|
6
|
+
import { enableHotReloading } from "../builders/hotReload";
|
|
7
|
+
|
|
8
|
+
@observer
|
|
9
|
+
class App extends preact.Component {
|
|
10
|
+
synced = observable({
|
|
11
|
+
count: 0,
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
render() {
|
|
15
|
+
return (
|
|
16
|
+
<div className={css.pad2(20)}>
|
|
17
|
+
<h1>Hello from Web! 3</h1>
|
|
18
|
+
<p>Count: {this.synced.count}</p>
|
|
19
|
+
<button onClick={() => this.synced.count++}>
|
|
20
|
+
Increment
|
|
21
|
+
</button>
|
|
22
|
+
<div>
|
|
23
|
+
{list(1000).map(x => <div key={x}>{x}</div>)}
|
|
24
|
+
</div>
|
|
25
|
+
</div>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async function main() {
|
|
31
|
+
if (isNode()) return;
|
|
32
|
+
await enableHotReloading({ port: 9877 });
|
|
33
|
+
preact.render(<App />, document.getElementById("app")!);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
main().catch(console.error);
|
|
37
|
+
|
package/web/index.html
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<title>Web App</title>
|
|
6
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
7
|
+
<style>
|
|
8
|
+
* {
|
|
9
|
+
box-sizing: border-box;
|
|
10
|
+
overflow-wrap: break-word;
|
|
11
|
+
word-wrap: break-word;
|
|
12
|
+
word-break: break-word;
|
|
13
|
+
}
|
|
14
|
+
body {
|
|
15
|
+
margin: 0px;
|
|
16
|
+
padding: 0px;
|
|
17
|
+
background: hsl(0, 0%, 7%);
|
|
18
|
+
color: hsl(0, 0%, 100%);
|
|
19
|
+
font-family: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', sans-serif;
|
|
20
|
+
}
|
|
21
|
+
body, button, textarea {
|
|
22
|
+
font-family: Inter;
|
|
23
|
+
font-size: 12px;
|
|
24
|
+
}
|
|
25
|
+
</style>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<div id="app"></div>
|
|
29
|
+
<script src="../browser.js"></script>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
|
32
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|