tangled
alpha
login
or
join now
notnite.com
/
moonlight
3
fork
atom
this repo has no description
3
fork
atom
overview
issues
pulls
pipelines
Load style.css if it exists
notnite.com
1 year ago
4871f2ab
779b424c
+77
-68
6 changed files
expand all
collapse all
unified
split
build.mjs
packages
core
src
extension
loader.ts
extension.ts
core-extensions
src
moonbase
index.tsx
style.css
types
src
extension.ts
+12
-8
build.mjs
···
205
205
}
206
206
}
207
207
208
208
-
async function buildExt(ext, side, copyManifest, fileExt) {
208
208
+
async function buildExt(ext, side, fileExt) {
209
209
const outdir = path.join("./dist", "core-extensions", ext);
210
210
if (!fs.existsSync(outdir)) {
211
211
fs.mkdirSync(outdir, { recursive: true });
···
246
246
}
247
247
};
248
248
249
249
+
const styleInput = `packages/core-extensions/src/${ext}/style.css`;
250
250
+
const styleOutput = `dist/core-extensions/${ext}/style.css`;
251
251
+
249
252
const esbuildConfig = {
250
253
entryPoints,
251
254
outdir,
···
265
268
},
266
269
logLevel: "silent",
267
270
plugins: [
268
268
-
...(copyManifest
271
271
+
copyStaticFiles({
272
272
+
src: `./packages/core-extensions/src/${ext}/manifest.json`,
273
273
+
dest: `./dist/core-extensions/${ext}/manifest.json`
274
274
+
}),
275
275
+
...(fs.existsSync(styleInput)
269
276
? [
270
277
copyStaticFiles({
271
271
-
src: `./packages/core-extensions/src/${ext}/manifest.json`,
272
272
-
dest: `./dist/core-extensions/${ext}/manifest.json`
278
278
+
src: styleInput,
279
279
+
dest: styleOutput
273
280
})
274
281
]
275
282
: []),
···
298
305
299
306
const coreExtensions = fs.readdirSync("./packages/core-extensions/src");
300
307
for (const ext of coreExtensions) {
301
301
-
let copiedManifest = false;
302
302
-
303
308
for (const fileExt of ["ts", "tsx"]) {
304
309
for (const type of ["index", "node", "host"]) {
305
310
if (fs.existsSync(`./packages/core-extensions/src/${ext}/${type}.${fileExt}`)) {
306
306
-
promises.push(buildExt(ext, type, !copiedManifest, fileExt));
307
307
-
copiedManifest = true;
311
311
+
promises.push(buildExt(ext, type, fileExt));
308
312
}
309
313
}
310
314
}
-58
packages/core-extensions/src/moonbase/index.tsx
···
45
45
dependencies: [{ ext: "moonbase", id: "stores" }]
46
46
}
47
47
};
48
48
-
49
49
-
const bg = "#222034";
50
50
-
const fg = "#FFFBA6";
51
51
-
52
52
-
export const styles = [
53
53
-
`
54
54
-
.moonbase-settings > :first-child {
55
55
-
margin-top: 0px;
56
56
-
}
57
57
-
58
58
-
textarea.moonbase-resizeable {
59
59
-
resize: vertical
60
60
-
}
61
61
-
62
62
-
.moonbase-updates-notice {
63
63
-
background-color: ${bg};
64
64
-
color: ${fg};
65
65
-
line-height: unset;
66
66
-
height: 36px;
67
67
-
}
68
68
-
69
69
-
.moonbase-updates-notice button {
70
70
-
color: ${fg};
71
71
-
border-color: ${fg};
72
72
-
}
73
73
-
74
74
-
.moonbase-updates-notice_text-wrapper {
75
75
-
display: inline-flex;
76
76
-
align-items: center;
77
77
-
line-height: 36px;
78
78
-
gap: 2px;
79
79
-
}
80
80
-
81
81
-
.moonbase-update-section {
82
82
-
background-color: ${bg};
83
83
-
--info-help-foreground: ${fg};
84
84
-
border: none !important;
85
85
-
color: ${fg};
86
86
-
87
87
-
display: flex;
88
88
-
flex-direction: row;
89
89
-
justify-content: space-between;
90
90
-
}
91
91
-
92
92
-
.moonbase-update-section button {
93
93
-
--info-help-foreground: ${fg};
94
94
-
color: ${fg};
95
95
-
background-color: transparent;
96
96
-
border-color: ${fg};
97
97
-
}
98
98
-
99
99
-
.moonbase-update-section-buttons {
100
100
-
display: flex;
101
101
-
flex-direction: row;
102
102
-
gap: 8px;
103
103
-
}
104
104
-
`.trim()
105
105
-
];
+55
packages/core-extensions/src/moonbase/style.css
···
1
1
+
:root {
2
2
+
--moonbase-bg: #222034;
3
3
+
--moonbase-fg: #fffba6;
4
4
+
}
5
5
+
6
6
+
.moonbase-settings > :first-child {
7
7
+
margin-top: 0px;
8
8
+
}
9
9
+
10
10
+
textarea.moonbase-resizeable {
11
11
+
resize: vertical;
12
12
+
}
13
13
+
14
14
+
.moonbase-updates-notice {
15
15
+
background-color: var(--moonbase-bg);
16
16
+
color: var(--moonbase-fg);
17
17
+
line-height: unset;
18
18
+
height: 36px;
19
19
+
}
20
20
+
21
21
+
.moonbase-updates-notice button {
22
22
+
color: var(--moonbase-fg);
23
23
+
border-color: var(--moonbase-fg);
24
24
+
}
25
25
+
26
26
+
.moonbase-updates-notice_text-wrapper {
27
27
+
display: inline-flex;
28
28
+
align-items: center;
29
29
+
line-height: 36px;
30
30
+
gap: 2px;
31
31
+
}
32
32
+
33
33
+
.moonbase-update-section {
34
34
+
background-color: var(--moonbase-bg);
35
35
+
--info-help-foreground: var(--moonbase-fg);
36
36
+
border: none !important;
37
37
+
color: var(--moonbase-fg);
38
38
+
39
39
+
display: flex;
40
40
+
flex-direction: row;
41
41
+
justify-content: space-between;
42
42
+
}
43
43
+
44
44
+
.moonbase-update-section button {
45
45
+
--info-help-foreground: var(--moonbase-fg);
46
46
+
color: var(--moonbase-fg);
47
47
+
background-color: transparent;
48
48
+
border-color: var(--moonbase-fg);
49
49
+
}
50
50
+
51
51
+
.moonbase-update-section-buttons {
52
52
+
display: flex;
53
53
+
flex-direction: row;
54
54
+
gap: 8px;
55
55
+
}
+6
-2
packages/core/src/extension.ts
···
75
75
}
76
76
}
77
77
78
78
+
const stylePath = moonlightFS.join(dir, "style.css");
79
79
+
78
80
ret.push({
79
81
id: manifest.id,
80
82
manifest,
···
87
89
webPath: web != null ? webPath : undefined,
88
90
webpackModules: wpModules,
89
91
nodePath: (await moonlightFS.exists(nodePath)) ? nodePath : undefined,
90
90
-
hostPath: (await moonlightFS.exists(hostPath)) ? hostPath : undefined
92
92
+
hostPath: (await moonlightFS.exists(hostPath)) ? hostPath : undefined,
93
93
+
style: (await moonlightFS.exists(stylePath)) ? await moonlightFS.readFileString(stylePath) : undefined
91
94
}
92
95
});
93
96
} catch (e) {
···
145
148
},
146
149
scripts: {
147
150
web,
148
148
-
webpackModules: wpModules
151
151
+
webpackModules: wpModules,
152
152
+
style: coreExtensionsFs[`${ext}/style.css`]
149
153
}
150
154
});
151
155
seen.add(manifest.id);
+3
packages/core/src/extension/loader.ts
···
71
71
if (exports.styles != null) {
72
72
registerStyles(exports.styles.map((style, i) => `/* ${ext.id}#${i} */ ${style}`));
73
73
}
74
74
+
if (ext.scripts.style != null) {
75
75
+
registerStyles([`/* ${ext.id}#style.css */ ${ext.scripts.style}`]);
76
76
+
}
74
77
}
75
78
}
76
79
+1
packages/types/src/extension.ts
···
75
75
webpackModules?: Record<string, string>;
76
76
nodePath?: string;
77
77
hostPath?: string;
78
78
+
style?: string;
78
79
};
79
80
};
80
81