@michijs/dev-server 0.4.2 → 0.5.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/LICENSE.md +8 -8
- package/README.md +229 -208
- package/bin/actions/build.js +2 -2
- package/bin/actions/dist.js +5 -5
- package/bin/actions/generateAssets.d.ts +4 -0
- package/bin/actions/generateAssets.js +125 -0
- package/bin/actions/start.d.ts +1 -1
- package/bin/actions/start.js +46 -30
- package/bin/cli.js +33 -33
- package/bin/config/config.d.ts +111 -6
- package/bin/config/config.js +40 -31
- package/bin/config/getIPAddress.js +5 -3
- package/bin/config/michi.config.cjs +159 -0
- package/bin/config/public/client.js +1 -1
- package/bin/config/tsconfig.d.ts +1 -1
- package/bin/config/tsconfig.js +3 -3
- package/bin/config/userConfig.d.ts +1 -1
- package/bin/config/userConfig.js +18 -14
- package/bin/constants.d.ts +8 -0
- package/bin/constants.js +12 -0
- package/bin/index.d.ts +1 -1
- package/bin/index.js +1 -1
- package/bin/tsconfig.tsbuildinfo +1 -1
- package/bin/types.d.ts +71 -7
- package/bin/utils/copy.js +4 -4
- package/bin/utils/feature-image-template.svg +62 -0
- package/bin/utils/getAllFiles.js +2 -2
- package/bin/utils/getHostURL.d.ts +1 -0
- package/bin/utils/getHostURL.js +4 -0
- package/bin/utils/getLocalURL.d.ts +1 -0
- package/bin/utils/getLocalURL.js +3 -0
- package/bin/utils/getPath.js +1 -1
- package/bin/utils/minify.js +3 -3
- package/bin/utils/serviceWorkerTransformer.d.ts +1 -1
- package/bin/utils/serviceWorkerTransformer.js +8 -8
- package/bin/utils/transformers.d.ts +1 -1
- package/bin/utils/transformers.js +4 -4
- package/package.json +63 -74
- package/bin/actions/generateIcons.d.ts +0 -1
- package/bin/actions/generateIcons.js +0 -31
package/bin/actions/start.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import http from
|
|
2
|
-
import fs from
|
|
3
|
-
import { config,
|
|
4
|
-
import coloredString from
|
|
5
|
-
import { getPath } from
|
|
6
|
-
import open from
|
|
7
|
-
import { context } from
|
|
8
|
-
import watch from
|
|
9
|
-
import { copyFile } from
|
|
10
|
-
import { sep } from
|
|
11
|
-
import { transformers } from
|
|
1
|
+
import http from "http";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import { config, connections } from "../config/config.js";
|
|
4
|
+
import coloredString from "../utils/coloredString.js";
|
|
5
|
+
import { getPath } from "../utils/getPath.js";
|
|
6
|
+
import open from "open";
|
|
7
|
+
import { context } from "esbuild";
|
|
8
|
+
import watch from "node-watch";
|
|
9
|
+
import { copyFile } from "../utils/copy.js";
|
|
10
|
+
import { sep } from "path";
|
|
11
|
+
import { transformers } from "../utils/transformers.js";
|
|
12
|
+
import { getHostURL } from "../utils/getHostURL.js";
|
|
13
|
+
import { getLocalURL } from "../utils/getLocalURL.js";
|
|
12
14
|
export const start = (callback) => {
|
|
13
15
|
config.esbuildOptions.plugins?.push({
|
|
14
|
-
name:
|
|
16
|
+
name: "michijs-dev-server-watch-public-folder",
|
|
15
17
|
setup(build) {
|
|
16
|
-
if (config.public.path)
|
|
18
|
+
if (config.public.path && config.watch)
|
|
17
19
|
watch.default(config.public.path, {
|
|
18
|
-
encoding:
|
|
20
|
+
encoding: "utf-8",
|
|
19
21
|
persistent: true,
|
|
20
22
|
recursive: true,
|
|
21
23
|
}, (event, fileChangedPath) => {
|
|
@@ -29,7 +31,7 @@ export const start = (callback) => {
|
|
|
29
31
|
fs.rmSync(getPath(`${outDir}/${transformers
|
|
30
32
|
.find((x) => x.fileRegex.test(fileName))
|
|
31
33
|
?.pathTransformer?.(fileName) ?? fileName}`), { force: true, recursive: true });
|
|
32
|
-
if (event ===
|
|
34
|
+
if (event === "remove")
|
|
33
35
|
removed.push(fileChangedPath);
|
|
34
36
|
else {
|
|
35
37
|
updated.push(fileChangedPath);
|
|
@@ -48,9 +50,8 @@ export const start = (callback) => {
|
|
|
48
50
|
const { host: esbuildHost, port: esbuildPort } = await buildContext.serve({
|
|
49
51
|
servedir: config.esbuildOptions.outdir,
|
|
50
52
|
});
|
|
51
|
-
http
|
|
52
|
-
|
|
53
|
-
if (req.url === '/esbuild')
|
|
53
|
+
const server = http.createServer(async (req, res) => {
|
|
54
|
+
if (req.url === "/esbuild")
|
|
54
55
|
connections.push(res);
|
|
55
56
|
const esbuildProxyRequestOptions = {
|
|
56
57
|
hostname: esbuildHost,
|
|
@@ -63,7 +64,7 @@ export const start = (callback) => {
|
|
|
63
64
|
const proxyReq = http.request(esbuildProxyRequestOptions, (proxyRes) => {
|
|
64
65
|
// If esbuild returns "not found", send a custom 404 page
|
|
65
66
|
if (!proxyRes.statusCode || proxyRes.statusCode === 404) {
|
|
66
|
-
res.writeHead(200, {
|
|
67
|
+
res.writeHead(200, { "Content-Type": "text/html" });
|
|
67
68
|
// TODO: Find a better way to do this
|
|
68
69
|
res.end(fs.readFileSync(getPath(`${config.esbuildOptions.outdir}/${config.public.indexName}`)));
|
|
69
70
|
return;
|
|
@@ -74,16 +75,31 @@ export const start = (callback) => {
|
|
|
74
75
|
});
|
|
75
76
|
// Forward the body of the request to esbuild
|
|
76
77
|
req.pipe(proxyReq, { end: true });
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
});
|
|
79
|
+
let selectedPort = config.port;
|
|
80
|
+
server.on("error", (e) => {
|
|
81
|
+
// @ts-ignore
|
|
82
|
+
if (e.code === "EADDRINUSE") {
|
|
83
|
+
selectedPort++;
|
|
84
|
+
server.listen(selectedPort);
|
|
85
|
+
}
|
|
86
|
+
else
|
|
87
|
+
throw e;
|
|
88
|
+
});
|
|
89
|
+
server.on("listening", () => {
|
|
90
|
+
const localURL = getLocalURL(selectedPort);
|
|
91
|
+
console.log(`
|
|
92
|
+
Server running at:
|
|
93
|
+
|
|
94
|
+
> Network: ${coloredString(getHostURL(selectedPort))}
|
|
95
|
+
> Local: ${coloredString(localURL)}`);
|
|
96
|
+
callback(selectedPort);
|
|
97
|
+
if (config.watch)
|
|
98
|
+
buildContext.watch();
|
|
99
|
+
if (config.openBrowser)
|
|
100
|
+
open(localURL);
|
|
101
|
+
});
|
|
102
|
+
// First try
|
|
103
|
+
server.listen(selectedPort);
|
|
88
104
|
});
|
|
89
105
|
};
|
package/bin/cli.js
CHANGED
|
@@ -1,65 +1,65 @@
|
|
|
1
|
-
import coloredString from
|
|
2
|
-
import yargs from
|
|
3
|
-
import { Timer } from
|
|
4
|
-
import { hideBin } from
|
|
1
|
+
import coloredString from "./utils/coloredString.js";
|
|
2
|
+
import yargs from "yargs";
|
|
3
|
+
import { Timer } from "./classes/Timer.js";
|
|
4
|
+
import { hideBin } from "yargs/helpers";
|
|
5
5
|
export async function cli() {
|
|
6
6
|
const timer = new Timer();
|
|
7
|
-
const showReadyMessage = () => console.log(`
|
|
7
|
+
const showReadyMessage = () => console.log(`
|
|
8
8
|
${coloredString(`Ready in ${timer.endTimer()}ms.`)}`);
|
|
9
9
|
timer.startTimer();
|
|
10
10
|
const args = await yargs(hideBin(process.argv))
|
|
11
|
-
.option(
|
|
12
|
-
type:
|
|
11
|
+
.option("start", {
|
|
12
|
+
type: "boolean",
|
|
13
13
|
default: false,
|
|
14
|
-
description:
|
|
14
|
+
description: "Allows to start a dev server as a webpage.",
|
|
15
15
|
})
|
|
16
|
-
.option(
|
|
17
|
-
type:
|
|
16
|
+
.option("build", {
|
|
17
|
+
type: "boolean",
|
|
18
18
|
default: false,
|
|
19
|
-
description:
|
|
19
|
+
description: "Allows to build the src code as a webpage.",
|
|
20
20
|
})
|
|
21
|
-
.option(
|
|
22
|
-
type:
|
|
21
|
+
.option("dist", {
|
|
22
|
+
type: "boolean",
|
|
23
23
|
default: false,
|
|
24
|
-
description:
|
|
24
|
+
description: "Allows to distribute the src code as a package.",
|
|
25
25
|
})
|
|
26
|
-
.option(
|
|
27
|
-
type:
|
|
28
|
-
description:
|
|
26
|
+
.option("generate-assets", {
|
|
27
|
+
type: "string",
|
|
28
|
+
description: "Allows to generate a full set of icons and screenshots from a src icon.",
|
|
29
29
|
})
|
|
30
|
-
.option(
|
|
31
|
-
type:
|
|
30
|
+
.option("watch", {
|
|
31
|
+
type: "boolean",
|
|
32
32
|
default: false,
|
|
33
|
-
alias:
|
|
33
|
+
alias: "w",
|
|
34
34
|
})
|
|
35
|
-
.option(
|
|
36
|
-
type:
|
|
35
|
+
.option("env", {
|
|
36
|
+
type: "string",
|
|
37
37
|
})
|
|
38
|
-
.option(
|
|
39
|
-
type:
|
|
38
|
+
.option("env", {
|
|
39
|
+
type: "string",
|
|
40
40
|
})
|
|
41
41
|
.help()
|
|
42
|
-
.alias(
|
|
42
|
+
.alias("help", "h").argv;
|
|
43
43
|
process.env.NODE_ENV =
|
|
44
44
|
args.env ||
|
|
45
|
-
(args.build ?
|
|
46
|
-
const
|
|
47
|
-
if (
|
|
48
|
-
const action = await import(
|
|
49
|
-
await action.
|
|
45
|
+
(args.build ? "PRODUCTION" : args.dist ? "DISTRIBUTION" : "DEVELOPMENT");
|
|
46
|
+
const generateAssets = args.generateAssets === "" ? "public/assets/icon.svg" : args.generateAssets;
|
|
47
|
+
if (generateAssets) {
|
|
48
|
+
const action = await import("./actions/generateAssets.js");
|
|
49
|
+
await action.generateAssets(showReadyMessage, generateAssets);
|
|
50
50
|
}
|
|
51
51
|
else
|
|
52
52
|
console.log(coloredString(` Running in ${process.env.NODE_ENV} mode`));
|
|
53
53
|
if (args.start) {
|
|
54
|
-
const action = await import(
|
|
54
|
+
const action = await import("./actions/start.js");
|
|
55
55
|
action.start(showReadyMessage);
|
|
56
56
|
}
|
|
57
57
|
if (args.build) {
|
|
58
|
-
const action = await import(
|
|
58
|
+
const action = await import("./actions/build.js");
|
|
59
59
|
action.build(showReadyMessage);
|
|
60
60
|
}
|
|
61
61
|
if (args.dist) {
|
|
62
|
-
const action = await import(
|
|
62
|
+
const action = await import("./actions/dist.js");
|
|
63
63
|
action.dist(showReadyMessage, args.watch);
|
|
64
64
|
}
|
|
65
65
|
}
|
package/bin/config/config.d.ts
CHANGED
|
@@ -1,10 +1,115 @@
|
|
|
1
1
|
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
-
import
|
|
3
|
-
import http from 'http';
|
|
2
|
+
import http from "http";
|
|
4
3
|
export declare const connections: (http.ServerResponse<http.IncomingMessage> & {
|
|
5
4
|
req: http.IncomingMessage;
|
|
6
5
|
})[];
|
|
7
|
-
declare const config:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
declare const config: {
|
|
7
|
+
public: {
|
|
8
|
+
assets: {
|
|
9
|
+
screenshots: {
|
|
10
|
+
paths: string[];
|
|
11
|
+
pageCallbacks: import("../types.js").PageCallback<string | void>[];
|
|
12
|
+
};
|
|
13
|
+
featureImage: {
|
|
14
|
+
path: string;
|
|
15
|
+
pageCallback?: import("../types.js").PageCallback<void> | undefined;
|
|
16
|
+
};
|
|
17
|
+
path: string;
|
|
18
|
+
};
|
|
19
|
+
manifest: {
|
|
20
|
+
name: string;
|
|
21
|
+
options?: import("web-app-manifest").WebAppManifest | undefined;
|
|
22
|
+
};
|
|
23
|
+
wellKnown?: import("../types.js").WellKnown[] | undefined;
|
|
24
|
+
path: string;
|
|
25
|
+
indexName: string;
|
|
26
|
+
minify: boolean;
|
|
27
|
+
};
|
|
28
|
+
esbuildOptions: {
|
|
29
|
+
plugins: import("esbuild").Plugin[];
|
|
30
|
+
define: {
|
|
31
|
+
michiProcess: string;
|
|
32
|
+
};
|
|
33
|
+
inject: string[];
|
|
34
|
+
bundle: boolean;
|
|
35
|
+
splitting: boolean;
|
|
36
|
+
preserveSymlinks?: boolean | undefined;
|
|
37
|
+
outfile?: string | undefined;
|
|
38
|
+
metafile?: boolean | undefined;
|
|
39
|
+
outdir: string;
|
|
40
|
+
outbase?: string | undefined;
|
|
41
|
+
external?: string[] | undefined;
|
|
42
|
+
packages?: "external" | undefined;
|
|
43
|
+
alias?: Record<string, string> | undefined;
|
|
44
|
+
loader?: {
|
|
45
|
+
[ext: string]: import("esbuild").Loader;
|
|
46
|
+
} | undefined;
|
|
47
|
+
resolveExtensions?: string[] | undefined;
|
|
48
|
+
mainFields?: string[] | undefined;
|
|
49
|
+
conditions?: string[] | undefined;
|
|
50
|
+
write?: boolean | undefined;
|
|
51
|
+
allowOverwrite?: boolean | undefined;
|
|
52
|
+
tsconfig: string;
|
|
53
|
+
outExtension?: {
|
|
54
|
+
[ext: string]: string;
|
|
55
|
+
} | undefined;
|
|
56
|
+
publicPath?: string | undefined;
|
|
57
|
+
entryNames?: string | undefined;
|
|
58
|
+
chunkNames?: string | undefined;
|
|
59
|
+
assetNames?: string | undefined;
|
|
60
|
+
banner?: {
|
|
61
|
+
[type: string]: string;
|
|
62
|
+
} | undefined;
|
|
63
|
+
footer?: {
|
|
64
|
+
[type: string]: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
entryPoints: string[] | Record<string, string> | {
|
|
67
|
+
in: string;
|
|
68
|
+
out: string;
|
|
69
|
+
}[];
|
|
70
|
+
stdin?: import("esbuild").StdinOptions | undefined;
|
|
71
|
+
absWorkingDir?: string | undefined;
|
|
72
|
+
nodePaths?: string[] | undefined;
|
|
73
|
+
sourcemap: boolean | "linked" | "inline" | "external" | "both";
|
|
74
|
+
legalComments?: "linked" | "inline" | "external" | "none" | "eof" | undefined;
|
|
75
|
+
sourceRoot?: string | undefined;
|
|
76
|
+
sourcesContent?: boolean | undefined;
|
|
77
|
+
format: import("esbuild").Format;
|
|
78
|
+
globalName?: string | undefined;
|
|
79
|
+
target: string | string[];
|
|
80
|
+
supported?: Record<string, boolean> | undefined;
|
|
81
|
+
platform?: import("esbuild").Platform | undefined;
|
|
82
|
+
mangleProps?: RegExp | undefined;
|
|
83
|
+
reserveProps?: RegExp | undefined;
|
|
84
|
+
mangleQuoted?: boolean | undefined;
|
|
85
|
+
mangleCache?: Record<string, string | false> | undefined;
|
|
86
|
+
drop?: import("esbuild").Drop[] | undefined;
|
|
87
|
+
minify?: boolean | undefined;
|
|
88
|
+
minifyWhitespace: boolean;
|
|
89
|
+
minifyIdentifiers?: boolean | undefined;
|
|
90
|
+
minifySyntax: boolean;
|
|
91
|
+
charset?: import("esbuild").Charset | undefined;
|
|
92
|
+
treeShaking?: boolean | undefined;
|
|
93
|
+
ignoreAnnotations?: boolean | undefined;
|
|
94
|
+
jsx?: "transform" | "preserve" | "automatic" | undefined;
|
|
95
|
+
jsxFactory?: string | undefined;
|
|
96
|
+
jsxFragment?: string | undefined;
|
|
97
|
+
jsxImportSource?: string | undefined;
|
|
98
|
+
jsxDev?: boolean | undefined;
|
|
99
|
+
jsxSideEffects?: boolean | undefined;
|
|
100
|
+
pure?: string[] | undefined;
|
|
101
|
+
keepNames: boolean;
|
|
102
|
+
color?: boolean | undefined;
|
|
103
|
+
logLevel: import("esbuild").LogLevel;
|
|
104
|
+
logLimit?: number | undefined;
|
|
105
|
+
logOverride?: Record<string, import("esbuild").LogLevel> | undefined;
|
|
106
|
+
};
|
|
107
|
+
env?: {
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
} | undefined;
|
|
110
|
+
watch: boolean;
|
|
111
|
+
port: number;
|
|
112
|
+
openBrowser: boolean;
|
|
113
|
+
showLinkedPackages: boolean;
|
|
114
|
+
};
|
|
115
|
+
export { config };
|
package/bin/config/config.js
CHANGED
|
@@ -1,48 +1,61 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import coloredString from
|
|
3
|
-
import { copy } from
|
|
4
|
-
import { getPath } from
|
|
5
|
-
import { Timer } from
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const devServerListener = process.env.NODE_ENV === 'DEVELOPMENT'
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import coloredString from "../utils/coloredString.js";
|
|
3
|
+
import { copy } from "../utils/copy.js";
|
|
4
|
+
import { getPath } from "../utils/getPath.js";
|
|
5
|
+
import { Timer } from "../classes/Timer.js";
|
|
6
|
+
import { userConfig } from "./userConfig.js";
|
|
7
|
+
import { resolve } from "path";
|
|
8
|
+
import { jsAndTsRegex, jsonTransformer, notJsAndTsRegex, } from "../utils/transformers.js";
|
|
9
|
+
import { dirname } from "path";
|
|
10
|
+
import { fileURLToPath } from "url";
|
|
11
|
+
const minify = process.env.NODE_ENV === "PRODUCTION";
|
|
12
|
+
const devServerListener = process.env.NODE_ENV === "DEVELOPMENT"
|
|
14
13
|
? [getPath(`${dirname(fileURLToPath(import.meta.url))}/public/client.js`)]
|
|
15
14
|
: [];
|
|
16
15
|
export const connections = [];
|
|
17
16
|
const config = {
|
|
18
17
|
port: 3000,
|
|
19
|
-
openBrowser: process.env.NODE_ENV ===
|
|
18
|
+
openBrowser: process.env.NODE_ENV === "DEVELOPMENT",
|
|
20
19
|
showLinkedPackages: true,
|
|
20
|
+
watch: true,
|
|
21
21
|
...userConfig,
|
|
22
22
|
// protocol: 'http',
|
|
23
23
|
public: {
|
|
24
|
-
path:
|
|
25
|
-
indexName:
|
|
24
|
+
path: "public",
|
|
25
|
+
indexName: "index.html",
|
|
26
26
|
minify: minify,
|
|
27
27
|
...(userConfig.public ?? {}),
|
|
28
|
+
assets: {
|
|
29
|
+
path: "assets",
|
|
30
|
+
...(userConfig.public?.assets ?? {}),
|
|
31
|
+
screenshots: {
|
|
32
|
+
paths: ["/"],
|
|
33
|
+
pageCallbacks: [() => { }],
|
|
34
|
+
...(userConfig.public?.assets?.screenshots ?? {}),
|
|
35
|
+
},
|
|
36
|
+
featureImage: {
|
|
37
|
+
path: "/",
|
|
38
|
+
...(userConfig.public?.assets?.featureImage ?? {}),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
28
41
|
manifest: {
|
|
29
|
-
name:
|
|
42
|
+
name: "manifest.json",
|
|
30
43
|
...(userConfig.public?.manifest ?? {}),
|
|
31
44
|
},
|
|
32
45
|
},
|
|
33
46
|
esbuildOptions: {
|
|
34
|
-
outdir:
|
|
35
|
-
tsconfig:
|
|
47
|
+
outdir: "build",
|
|
48
|
+
tsconfig: "tsconfig.json",
|
|
36
49
|
minifySyntax: minify,
|
|
37
50
|
minifyWhitespace: minify,
|
|
38
|
-
sourcemap: process.env.NODE_ENV !==
|
|
51
|
+
sourcemap: process.env.NODE_ENV !== "PRODUCTION",
|
|
39
52
|
splitting: true,
|
|
40
53
|
bundle: true,
|
|
41
54
|
keepNames: minify,
|
|
42
|
-
entryPoints: [
|
|
43
|
-
format:
|
|
44
|
-
target:
|
|
45
|
-
logLevel:
|
|
55
|
+
entryPoints: ["src/index.ts"],
|
|
56
|
+
format: "esm",
|
|
57
|
+
target: "esnext",
|
|
58
|
+
logLevel: "error",
|
|
46
59
|
...(userConfig.esbuildOptions ?? {}),
|
|
47
60
|
// Still not supported
|
|
48
61
|
// bug .css.ts
|
|
@@ -68,7 +81,7 @@ const config = {
|
|
|
68
81
|
plugins: [
|
|
69
82
|
...(userConfig.esbuildOptions?.plugins ?? []),
|
|
70
83
|
{
|
|
71
|
-
name:
|
|
84
|
+
name: "michijs-dev-server",
|
|
72
85
|
setup(build) {
|
|
73
86
|
// Clean outdir
|
|
74
87
|
if (build.initialOptions.outdir) {
|
|
@@ -124,10 +137,6 @@ const config = {
|
|
|
124
137
|
...(userConfig.esbuildOptions?.define ?? {}),
|
|
125
138
|
},
|
|
126
139
|
};
|
|
127
|
-
const hostURL = `http://${getIPAddress()}:${config.port}`;
|
|
128
|
-
const localURL = `http://localhost:${config.port}`;
|
|
129
|
-
// const hostURL = `${config.protocol}://${config.hostname}:${config.port}`;
|
|
130
|
-
// const localURL = `${config.protocol}://localhost:${config.port}`;
|
|
131
140
|
function findSymbolickLinkRealPath(packagePath) {
|
|
132
141
|
if (fs.lstatSync(packagePath).isSymbolicLink()) {
|
|
133
142
|
// Getting absolute path for the simbolic link
|
|
@@ -136,7 +145,7 @@ function findSymbolickLinkRealPath(packagePath) {
|
|
|
136
145
|
return packagePath;
|
|
137
146
|
}
|
|
138
147
|
if (config.showLinkedPackages) {
|
|
139
|
-
const packageJson = JSON.parse(fs.readFileSync(
|
|
148
|
+
const packageJson = JSON.parse(fs.readFileSync("package.json", "utf8"));
|
|
140
149
|
const dependencies = Object.keys(packageJson.dependencies || {});
|
|
141
150
|
const devDependencies = Object.keys(packageJson.devDependencies || {});
|
|
142
151
|
dependencies.concat(devDependencies).forEach((packagePath) => {
|
|
@@ -147,4 +156,4 @@ if (config.showLinkedPackages) {
|
|
|
147
156
|
}
|
|
148
157
|
});
|
|
149
158
|
}
|
|
150
|
-
export { config
|
|
159
|
+
export { config };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { networkInterfaces } from
|
|
1
|
+
import { networkInterfaces } from "os";
|
|
2
2
|
export function getIPAddress() {
|
|
3
3
|
const interfaces = networkInterfaces();
|
|
4
4
|
for (const devName in interfaces) {
|
|
@@ -6,9 +6,11 @@ export function getIPAddress() {
|
|
|
6
6
|
if (iface)
|
|
7
7
|
for (let i = 0; i < iface.length; i++) {
|
|
8
8
|
const alias = iface[i];
|
|
9
|
-
if (alias.family ===
|
|
9
|
+
if (alias.family === "IPv4" &&
|
|
10
|
+
alias.address !== "127.0.0.1" &&
|
|
11
|
+
!alias.internal)
|
|
10
12
|
return alias.address;
|
|
11
13
|
}
|
|
12
14
|
}
|
|
13
|
-
return
|
|
15
|
+
return "0.0.0.0";
|
|
14
16
|
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// michi.config.ts
|
|
20
|
+
var michi_config_exports = {};
|
|
21
|
+
__export(michi_config_exports, {
|
|
22
|
+
androidTarget: () => androidTarget,
|
|
23
|
+
config: () => config,
|
|
24
|
+
default: () => michi_config_default
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(michi_config_exports);
|
|
27
|
+
var package_name = "app.netlify.michi_notepad.twa";
|
|
28
|
+
var androidTarget = {
|
|
29
|
+
namespace: "android_app",
|
|
30
|
+
package_name,
|
|
31
|
+
sha256_cert_fingerprints: [
|
|
32
|
+
"5B:79:54:BA:A1:D8:8E:A9:C8:DE:E2:8A:AD:5B:09:B2:29:DF:57:15:54:67:11:30:61:AA:32:2D:1E:A0:2D:4E"
|
|
33
|
+
]
|
|
34
|
+
};
|
|
35
|
+
var config = ({ assetsSizes }) => {
|
|
36
|
+
const icons = [
|
|
37
|
+
...assetsSizes.webp.map((x) => ({
|
|
38
|
+
src: `/assets/generated/icon-${x}.webp`,
|
|
39
|
+
sizes: `${x}x${x}`,
|
|
40
|
+
type: "image/webp",
|
|
41
|
+
purpose: "any"
|
|
42
|
+
})),
|
|
43
|
+
...assetsSizes.png.map((x) => ({
|
|
44
|
+
src: `/assets/generated/icon-${x}.png`,
|
|
45
|
+
sizes: `${x}x${x}`,
|
|
46
|
+
type: "image/png",
|
|
47
|
+
purpose: "any"
|
|
48
|
+
}))
|
|
49
|
+
];
|
|
50
|
+
return {
|
|
51
|
+
public: {
|
|
52
|
+
assets: {
|
|
53
|
+
screenshots: {
|
|
54
|
+
paths: ["/", "/#navigation-drawer-opened", "/privacy-policy"],
|
|
55
|
+
pageCallbacks: [
|
|
56
|
+
async (page) => {
|
|
57
|
+
await page.emulateMediaFeatures([{ name: "prefers-color-scheme", value: "light" }]);
|
|
58
|
+
return "light";
|
|
59
|
+
},
|
|
60
|
+
async (page) => {
|
|
61
|
+
await page.emulateMediaFeatures([{ name: "prefers-color-scheme", value: "dark" }]);
|
|
62
|
+
return "dark";
|
|
63
|
+
}
|
|
64
|
+
]
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
wellKnown: [
|
|
68
|
+
{
|
|
69
|
+
relation: ["delegate_permission/common.handle_all_urls"],
|
|
70
|
+
target: androidTarget
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
manifest: {
|
|
74
|
+
options: {
|
|
75
|
+
prefer_related_applications: true,
|
|
76
|
+
related_applications: [
|
|
77
|
+
{
|
|
78
|
+
platform: "play",
|
|
79
|
+
url: `https://play.google.com/store/apps/details?id=${package_name}`,
|
|
80
|
+
id: package_name
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
platform: "windows",
|
|
84
|
+
url: "https://www.microsoft.com/store/apps/9N3RTBWQB529",
|
|
85
|
+
id: "9N3RTBWQB529"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
iarc_rating_id: "2975cb9a-7360-433d-8f1c-2e91b8c69dc8",
|
|
89
|
+
name: "Michi Notepad",
|
|
90
|
+
short_name: "Notepad",
|
|
91
|
+
description: "Simple notepad written in web languages",
|
|
92
|
+
lang: "en",
|
|
93
|
+
categories: ["business", "utilities", "productivity"],
|
|
94
|
+
theme_color: "#ffb05c",
|
|
95
|
+
background_color: "#767579",
|
|
96
|
+
display: "standalone",
|
|
97
|
+
orientation: "portrait",
|
|
98
|
+
start_url: "/",
|
|
99
|
+
scope: ".",
|
|
100
|
+
icons,
|
|
101
|
+
screenshots: assetsSizes.screenshots.map(({ width, height }) => ({
|
|
102
|
+
"src": `/assets/generated/screenshots/screenshot-${width}x${height}.png`,
|
|
103
|
+
"sizes": `${width}x${height}`,
|
|
104
|
+
"type": "image/png"
|
|
105
|
+
})),
|
|
106
|
+
file_handlers: [
|
|
107
|
+
{
|
|
108
|
+
action: "/",
|
|
109
|
+
name: "Text files",
|
|
110
|
+
icons,
|
|
111
|
+
accept: {
|
|
112
|
+
"text/*": [
|
|
113
|
+
".vtt",
|
|
114
|
+
".srt",
|
|
115
|
+
".sub",
|
|
116
|
+
".xml",
|
|
117
|
+
".yml",
|
|
118
|
+
".yaml",
|
|
119
|
+
".rtf",
|
|
120
|
+
".asc",
|
|
121
|
+
".cfg",
|
|
122
|
+
".conf",
|
|
123
|
+
".cpp",
|
|
124
|
+
".css",
|
|
125
|
+
".h",
|
|
126
|
+
".html",
|
|
127
|
+
".ini",
|
|
128
|
+
".java",
|
|
129
|
+
".js",
|
|
130
|
+
".json",
|
|
131
|
+
".log",
|
|
132
|
+
".md",
|
|
133
|
+
".php",
|
|
134
|
+
".py",
|
|
135
|
+
".rb",
|
|
136
|
+
".ts",
|
|
137
|
+
".tsx",
|
|
138
|
+
".jsx",
|
|
139
|
+
".txt",
|
|
140
|
+
".csv",
|
|
141
|
+
".dat",
|
|
142
|
+
".msg",
|
|
143
|
+
".pages",
|
|
144
|
+
".tex"
|
|
145
|
+
]
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
]
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
var michi_config_default = config;
|
|
155
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
156
|
+
0 && (module.exports = {
|
|
157
|
+
androidTarget,
|
|
158
|
+
config
|
|
159
|
+
});
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
new EventSource(
|
|
1
|
+
new EventSource("/esbuild").addEventListener("change", () => location.reload());
|
|
2
2
|
export {};
|
package/bin/config/tsconfig.d.ts
CHANGED
package/bin/config/tsconfig.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { config } from
|
|
2
|
-
import fs from
|
|
1
|
+
import { config } from "./config.js";
|
|
2
|
+
import fs from "fs";
|
|
3
3
|
let tsconfig;
|
|
4
4
|
if (config.esbuildOptions.tsconfig &&
|
|
5
5
|
fs.existsSync(config.esbuildOptions?.tsconfig)) {
|
|
6
|
-
tsconfig = JSON.parse(fs.readFileSync(config.esbuildOptions.tsconfig,
|
|
6
|
+
tsconfig = JSON.parse(fs.readFileSync(config.esbuildOptions.tsconfig, "utf-8"));
|
|
7
7
|
}
|
|
8
8
|
else {
|
|
9
9
|
throw `Unable to find tsconfig at ${config.esbuildOptions.tsconfig}`;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ServerConfig } from
|
|
1
|
+
import { ServerConfig } from "../types.js";
|
|
2
2
|
export declare const userConfig: ServerConfig;
|