tsondb 0.5.0 → 0.5.1
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/lib/node/server/index.js
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
1
|
import Debug from "debug";
|
|
2
2
|
import express from "express";
|
|
3
|
-
import {
|
|
3
|
+
import { findPackageJSON } from "node:module";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
4
5
|
import { api } from "./api/index.js";
|
|
5
6
|
import { init } from "./init.js";
|
|
6
7
|
const debug = Debug("tsondb:server");
|
|
7
8
|
const defaultOptions = {
|
|
8
9
|
port: 3000,
|
|
9
10
|
};
|
|
11
|
+
const staticNodeModule = (moduleName) => {
|
|
12
|
+
const pathToPackageJson = findPackageJSON(moduleName, import.meta.url);
|
|
13
|
+
if (!pathToPackageJson) {
|
|
14
|
+
throw new Error(`Could not find module "${moduleName}"`);
|
|
15
|
+
}
|
|
16
|
+
return express.static(dirname(pathToPackageJson));
|
|
17
|
+
};
|
|
10
18
|
export const createServer = async (schema, dataRootPath, instancesByEntityName, options) => {
|
|
11
19
|
const { port } = { ...defaultOptions, ...options };
|
|
12
20
|
const app = express();
|
|
13
21
|
app.use(express.static(join(import.meta.dirname, "../../../public")));
|
|
14
|
-
app.use("/js/node_modules",
|
|
22
|
+
app.use("/js/node_modules/preact", staticNodeModule("preact"));
|
|
23
|
+
app.use("/js/node_modules/preact-iso", staticNodeModule("preact-iso"));
|
|
15
24
|
app.use("/js/client", express.static(join(import.meta.dirname, "../../../lib/web")));
|
|
16
25
|
app.use("/js/shared", express.static(join(import.meta.dirname, "../../../lib/shared")));
|
|
17
26
|
app.use(express.json());
|
|
@@ -12,6 +12,7 @@ export const useInstanceNamesByEntity = (locales = []) => {
|
|
|
12
12
|
console.error("Error fetching data:", error.toString());
|
|
13
13
|
}
|
|
14
14
|
});
|
|
15
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
15
16
|
}, [locales.toString()]);
|
|
16
17
|
useEffect(() => {
|
|
17
18
|
updateInstanceNamesByEntity();
|
package/package.json
CHANGED
package/public/css/styles.css
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
--separator-color: #e9e5eb;
|
|
16
16
|
--secondary-color: #7e7f87;
|
|
17
17
|
--tertiary-color: #bcbdc2;
|
|
18
|
+
--input-border-color: #black;
|
|
18
19
|
--button-background: #c7cad0;
|
|
19
20
|
--button-background-hover: #dedfe4;
|
|
20
21
|
--button-background-primary: black;
|
|
@@ -32,10 +33,51 @@
|
|
|
32
33
|
--highlight-color: #a08500;
|
|
33
34
|
--highlight-background: #fdfab9;
|
|
34
35
|
--disabled-color: #cdced2;
|
|
36
|
+
--git-status-untracked-color: rgb(13, 149, 101);
|
|
37
|
+
--git-status-untracked-background: rgba(13, 149, 101, 0.15);
|
|
38
|
+
--git-status-added-color: rgb(20, 148, 29);
|
|
39
|
+
--git-status-added-background: rgba(20, 148, 29, 0.15);
|
|
40
|
+
--git-status-modified-color: rgb(196, 155, 18);
|
|
41
|
+
--git-status-modified-background: rgba(196, 155, 18, 0.15);
|
|
42
|
+
--git-status-deleted-color: rgb(135, 22, 11);
|
|
43
|
+
--git-status-deleted-background: rgba(135, 22, 11, 0.15);
|
|
44
|
+
--git-status-renamed-color: rgb(20, 97, 148);
|
|
45
|
+
--git-status-renamed-background: rgba(20, 97, 148, 0.15);
|
|
46
|
+
--shadow-color: rgba(160, 163, 165, 0.5);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@media (prefers-color-scheme: dark) {
|
|
50
|
+
:root {
|
|
51
|
+
--background: hsl(260, 6%, 10%);
|
|
52
|
+
--markdown-background: hsl(260, 6%, 17%);
|
|
53
|
+
--color: hsl(260, 6%, 88%);
|
|
54
|
+
--error-color: #ff6b6b;
|
|
55
|
+
--separator-color: hsl(260, 6%, 24%);
|
|
56
|
+
--secondary-color: hsl(260, 6%, 69%);
|
|
57
|
+
--tertiary-color: hsl(260, 6%, 49%);
|
|
58
|
+
--input-border-color: hsl(260, 6%, 40%);
|
|
59
|
+
--button-background: hsl(260, 6%, 24%);
|
|
60
|
+
--button-background-hover: hsl(260, 6%, 30%);
|
|
61
|
+
--button-background-primary: hsl(260, 6%, 80%);
|
|
62
|
+
--button-background-primary-hover: hsl(260, 6%, 60%);
|
|
63
|
+
--button-background-destructive: #922727;
|
|
64
|
+
--button-background-destructive-hover: #ff8080;
|
|
65
|
+
--button-background-disabled: hsl(260, 6%, 35%);
|
|
66
|
+
--button-color: #fff;
|
|
67
|
+
--button-color-hover: #fff;
|
|
68
|
+
--button-color-primary: #000;
|
|
69
|
+
--button-color-primary-hover: #000;
|
|
70
|
+
--button-color-destructive: #fff;
|
|
71
|
+
--button-color-destructive-hover: #fff;
|
|
72
|
+
--button-color-disabled: hsl(260, 6%, 54%);
|
|
73
|
+
--highlight-color: #f2d600;
|
|
74
|
+
--highlight-background: #333300;
|
|
75
|
+
}
|
|
35
76
|
}
|
|
36
77
|
|
|
37
78
|
body {
|
|
38
79
|
font-family: var(--font-sans);
|
|
80
|
+
color: var(--color);
|
|
39
81
|
margin: 0;
|
|
40
82
|
padding: 1.5rem;
|
|
41
83
|
line-height: 1.4;
|
|
@@ -143,6 +185,13 @@ button.primary {
|
|
|
143
185
|
border: none;
|
|
144
186
|
}
|
|
145
187
|
|
|
188
|
+
@media (prefers-color-scheme: dark) {
|
|
189
|
+
a.btn--primary,
|
|
190
|
+
button.primary {
|
|
191
|
+
font-weight: 700;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
146
195
|
a.btn--primary:hover,
|
|
147
196
|
button.primary:hover {
|
|
148
197
|
background: var(--button-background-primary-hover);
|
|
@@ -179,8 +228,10 @@ button.destructive:disabled {
|
|
|
179
228
|
input,
|
|
180
229
|
textarea,
|
|
181
230
|
select {
|
|
231
|
+
background: var(--background);
|
|
232
|
+
color: var(--color);
|
|
182
233
|
font-family: var(--font-sans);
|
|
183
|
-
border: 1px solid var(--color);
|
|
234
|
+
border: 1px solid var(--input-border-color);
|
|
184
235
|
padding: 0.5rem;
|
|
185
236
|
display: block;
|
|
186
237
|
width: 100%;
|
|
@@ -301,7 +352,7 @@ select {
|
|
|
301
352
|
font-size: 1rem;
|
|
302
353
|
margin: 0;
|
|
303
354
|
flex: 1 1 auto;
|
|
304
|
-
padding: 0.
|
|
355
|
+
padding: 0.65rem 0;
|
|
305
356
|
}
|
|
306
357
|
|
|
307
358
|
.entity-item .title {
|
|
@@ -507,28 +558,28 @@ button[type="submit"] {
|
|
|
507
558
|
}
|
|
508
559
|
|
|
509
560
|
.git-status.git-status--U {
|
|
510
|
-
color:
|
|
511
|
-
background:
|
|
561
|
+
color: var(--git-status-untracked-color);
|
|
562
|
+
background: var(--git-status-untracked-background);
|
|
512
563
|
}
|
|
513
564
|
|
|
514
565
|
.git-status.git-status--A {
|
|
515
|
-
color:
|
|
516
|
-
background:
|
|
566
|
+
color: var(--git-status-added-color);
|
|
567
|
+
background: var(--git-status-added-background);
|
|
517
568
|
}
|
|
518
569
|
|
|
519
570
|
.git-status.git-status--M {
|
|
520
|
-
color:
|
|
521
|
-
background:
|
|
571
|
+
color: var(--git-status-modified-color);
|
|
572
|
+
background: var(--git-status-modified-background);
|
|
522
573
|
}
|
|
523
574
|
|
|
524
575
|
.git-status.git-status--D {
|
|
525
|
-
color:
|
|
526
|
-
background:
|
|
576
|
+
color: var(--git-status-deleted-color);
|
|
577
|
+
background: var(--git-status-deleted-background);
|
|
527
578
|
}
|
|
528
579
|
|
|
529
580
|
.git-status.git-status--R {
|
|
530
|
-
color:
|
|
531
|
-
background:
|
|
581
|
+
color: var(--git-status-renamed-color);
|
|
582
|
+
background: var(--git-status-renamed-background);
|
|
532
583
|
}
|
|
533
584
|
|
|
534
585
|
aside.git {
|
|
@@ -632,7 +683,7 @@ aside.git .branch .select-wrapper {
|
|
|
632
683
|
display: none;
|
|
633
684
|
position: absolute;
|
|
634
685
|
right: 1.5rem;
|
|
635
|
-
box-shadow: 0 0.5rem 2rem
|
|
686
|
+
box-shadow: 0 0.5rem 2rem var(--shadow-color);
|
|
636
687
|
z-index: 1000;
|
|
637
688
|
padding: 1rem;
|
|
638
689
|
background: var(--background);
|