Skip to content

Commit 36df582

Browse files
committed
fix: Update all clients from backend after enabling or disabling extension
feat: Expose setExtensionEnabled util to ext feat: Expose SimpleButton and CheckBox components to ext feat: Add removeCustomRoute action and use it to remove components in extensions after the initialiser component unloads fix: Weird casing on ext actions feat: Basics of the Manager extension
1 parent d58184b commit 36df582

File tree

21 files changed

+10092
-27
lines changed

21 files changed

+10092
-27
lines changed
Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
import { AddGameSidebarComponent } from 'flashpoint-launcher-renderer-ext/actions/main';
1+
import { addGameSidebarComponent, removeGameSidebarComponent } from 'flashpoint-launcher-renderer-ext/actions/main';
22
import { useAppDispatch } from 'flashpoint-launcher-renderer-ext/hooks';
3-
import { useState } from 'react';
3+
import { useEffect } from 'react';
44

55
export default function Initializer() {
6-
const [initialized, setInitialized] = useState(false);
76
const dispatch = useAppDispatch();
87

9-
// Perform frontend init functions
10-
if (!initialized) {
11-
setInitialized(true);
12-
13-
dispatch(AddGameSidebarComponent({
8+
useEffect(() => {
9+
dispatch(addGameSidebarComponent({
1410
section: 'bottom',
1511
name: 'core_controller/ControllerSupport'
1612
}));
17-
}
13+
14+
return () => {
15+
dispatch(removeGameSidebarComponent({
16+
section: 'bottom',
17+
name: 'core_controller/ControllerSupport'
18+
}));
19+
};
20+
});
1821

1922
return <></>;
2023
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*.js
2+
*.mjs

extensions/core-manager/.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dist/
2+
static/*.js
3+
static/mf*.json
4+
static/*mf-types*
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import { loadConfig, build as rslibBuild } from '@rslib/core';
2+
import esbuild from 'esbuild';
3+
import fs from 'fs';
4+
import gulp, { series } from 'gulp';
5+
import zip from 'gulp-zip';
6+
import merge from 'merge-stream';
7+
8+
const filesToCopy = [
9+
'extension.js',
10+
'package.json',
11+
'icon.png',
12+
'LICENSE.md',
13+
'README.md'
14+
];
15+
16+
async function buildTask(done) {
17+
// Build main extension (Node.js)
18+
const nodeBuild = esbuild.build({
19+
bundle: true,
20+
entryPoints: ['./src/extension.ts'],
21+
outfile: './dist/extension.js',
22+
platform: 'node',
23+
external: ['flashpoint-launcher'],
24+
});
25+
26+
const config = await loadConfig('./rslib.config.ts');
27+
28+
Promise.all([nodeBuild, rslibBuild({
29+
...config.content,
30+
mode: 'development'
31+
})])
32+
.catch(console.error)
33+
.finally(done);
34+
}
35+
36+
async function watchTask(done) {
37+
const ctx = await esbuild.context({
38+
bundle: true,
39+
entryPoints: ['./src/extension.ts'],
40+
outfile: './dist/extension.js',
41+
platform: 'node',
42+
external: ['flashpoint-launcher', '*.css'],
43+
});
44+
45+
const config = await loadConfig('./rslib.config.ts');
46+
const renderer = rslibBuild({
47+
...config.content,
48+
mode: 'development',
49+
watch: true
50+
});
51+
52+
return Promise.all([ctx.watch(), renderer])
53+
.catch(console.error)
54+
.finally(done);
55+
}
56+
57+
function clean(cb) {
58+
fs.rm('./package', { recursive: true }, (err) => {
59+
if (err) { console.log('Clean', err); }
60+
cb();
61+
});
62+
}
63+
64+
function stage() {
65+
const streams = filesToCopy.map(file => {
66+
if (fs.existsSync(file)) {
67+
return gulp.src(file).pipe(gulp.dest('package/core-manager'));
68+
}
69+
}).filter(s => s !== undefined);
70+
return merge([
71+
...streams,
72+
gulp.src('out/**/*').pipe(gulp.dest('package/core-manager/out')),
73+
gulp.src('dist/**/*').pipe(gulp.dest('package/core-manager/dist')),
74+
gulp.src('static/**/*').pipe(gulp.dest('package/core-manager/static')),
75+
]);
76+
}
77+
78+
function packageExtTask() {
79+
return gulp.src('package/**/*').pipe(zip('core-manager.fplx')).pipe(gulp.dest('.'));
80+
}
81+
82+
export const build = series(buildTask);
83+
export const watch = series(watchTask);
84+
export const packageExt = series(clean, stage, packageExtTask);

0 commit comments

Comments
 (0)