mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-30 12:11:56 +00:00
sideload wip, websockets, styling, multiple todos (#2865)
* sideload wip, websockets, styling, multiple todos * sideload * misc backend updates * chore: comments * prep for license and instructions display * comment for Matt * s9pk updates and 040 sdk * fix dependency error for actions * 0.4.0-beta.1 * beta.2 --------- Co-authored-by: Aiden McClelland <me@drbonez.dev> Co-authored-by: waterplea <alexander@inkin.ru> Co-authored-by: Aiden McClelland <3732071+dr-bonez@users.noreply.github.com>
This commit is contained in:
@@ -4,34 +4,57 @@ export type InstallFn<Manifest extends T.SDKManifest, Store> = (opts: {
|
||||
effects: T.Effects
|
||||
}) => Promise<null | void | undefined>
|
||||
export class Install<Manifest extends T.SDKManifest, Store> {
|
||||
private constructor(
|
||||
readonly fn: InstallFn<Manifest, Store>,
|
||||
readonly preFn?: InstallFn<Manifest, Store>,
|
||||
) {}
|
||||
protected constructor(readonly fn: InstallFn<Manifest, Store>) {}
|
||||
}
|
||||
|
||||
export class PreInstall<Manifest extends T.SDKManifest, Store> extends Install<
|
||||
Manifest,
|
||||
Store
|
||||
> {
|
||||
private constructor(fn: InstallFn<Manifest, Store>) {
|
||||
super(fn)
|
||||
}
|
||||
static of<Manifest extends T.SDKManifest, Store>(
|
||||
fn: InstallFn<Manifest, Store>,
|
||||
preFn?: InstallFn<Manifest, Store>,
|
||||
) {
|
||||
return new Install(fn, preFn)
|
||||
return new PreInstall(fn)
|
||||
}
|
||||
|
||||
async install({ effects }: Parameters<T.ExpectedExports.packageInit>[0]) {
|
||||
async preInstall({ effects }: Parameters<T.ExpectedExports.packageInit>[0]) {
|
||||
await this.fn({
|
||||
effects,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
async preInstall({ effects }: Parameters<T.ExpectedExports.packageInit>[0]) {
|
||||
this.preFn &&
|
||||
(await this.preFn({
|
||||
effects,
|
||||
}))
|
||||
export function setupPreInstall<Manifest extends T.SDKManifest, Store>(
|
||||
fn: InstallFn<Manifest, Store>,
|
||||
) {
|
||||
return PreInstall.of(fn)
|
||||
}
|
||||
|
||||
export class PostInstall<Manifest extends T.SDKManifest, Store> extends Install<
|
||||
Manifest,
|
||||
Store
|
||||
> {
|
||||
private constructor(fn: InstallFn<Manifest, Store>) {
|
||||
super(fn)
|
||||
}
|
||||
static of<Manifest extends T.SDKManifest, Store>(
|
||||
fn: InstallFn<Manifest, Store>,
|
||||
) {
|
||||
return new PostInstall(fn)
|
||||
}
|
||||
|
||||
async postInstall({ effects }: Parameters<T.ExpectedExports.packageInit>[0]) {
|
||||
await this.fn({
|
||||
effects,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
export function setupInstall<Manifest extends T.SDKManifest, Store>(
|
||||
export function setupPostInstall<Manifest extends T.SDKManifest, Store>(
|
||||
fn: InstallFn<Manifest, Store>,
|
||||
preFn?: InstallFn<Manifest, Store>,
|
||||
) {
|
||||
return Install.of(fn, preFn)
|
||||
return PostInstall.of(fn)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user