-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstuff.ts
More file actions
93 lines (83 loc) · 2.23 KB
/
stuff.ts
File metadata and controls
93 lines (83 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { isAbsolute, join, resolve, normalize } from "./deps.ts";
import denoJson from "./deno.json" with { type: "json" };
export const DSBUILD_VERSION = denoJson.version;
export const IS_DEV = Deno.env.get("DENO_ENV") === "development";
export const DEFAULT_IN_FILES = [
"src/app.ts",
"src/app.tsx",
"src/index.ts",
"src/index.tsx",
"src/main.ts",
"src/main.tsx",
"src/mod.ts",
"src/mod.tsx",
];
export const DEFAULT_IN_FOLDER = "src";
export const DEFAULT_OUT_FILE = join("public", "app.js");
export const DEFAULT_CSS_FILE = join("public", "app.css");
export const DEFAULT_STATIC_FILE = join("public", "index.html");
export const DEFAULT_SERVE_DIR = "public";
export const REACT_TS_CONFIG = {
compilerOptions: {
target: "es6",
lib: ["dom", "dom.iterable", "esnext", "deno.ns"],
jsx: "react-jsxdev",
jsxImportSource: "react",
},
// "include": ["src"]
};
export const REACT_STATIC_TS_CONFIG = {
compilerOptions: {
lib: ["dom", "dom.iterable", "dom.asynciterable", "esnext", "deno.ns"],
jsx: "react-jsxdev",
jsxImportSource: "react",
},
"imports": {
"react": "npm:react@^18.3.0",
"react-dom/client": "npm:react-dom@^18.3.0/client",
"react-dom": "npm:react-dom@^18.3.0",
}
};
export const REACT_STATIC_TS_CONFIG_DEV = {
compilerOptions: {
lib: ["dom", "dom.iterable", "dom.asynciterable", "esnext", "deno.ns"],
jsx: "react-jsxdev",
jsxImportSource: "react",
},
"imports": {
"react": "npm:react@^18.3.0",
"react-dom/client": "npm:react-dom@^18.3.0/client",
"react-dom": "npm:react-dom@^18.3.0",
}
};
export function omitKeys<T, TKey extends keyof T>(
obj: T,
keys: TKey[]
): Omit<T, TKey> {
const result = { ...obj };
for (const key of keys) {
delete result[key];
}
return result;
}
/**
* A temporary file that is automatically deleted when the object is disposed.
*/
export class DenoTempFile {
private path: string;
private disposed = false;
[Symbol.dispose]() {
if (this.disposed) {
return;
}
this.disposed = true;
return Deno.remove(this.path);
}
constructor(text: string) {
this.path = Deno.makeTempFileSync();
Deno.writeTextFileSync(this.path, text);
}
getPath() {
return this.path;
}
}