Fix StartOS 0.4 TypeScript packaging to match SDK API

This commit is contained in:
MacPro
2026-04-09 15:10:44 -05:00
parent d5046a0daf
commit 0b70cbb2bf
3436 changed files with 867051 additions and 92 deletions
+2
View File
@@ -0,0 +1,2 @@
export * from './setupInit';
export * from './setupUninit';
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./setupInit"), exports);
__exportStar(require("./setupUninit"), exports);
//# sourceMappingURL=index.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../base/lib/inits/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA2B;AAC3B,gDAA6B"}
+26
View File
@@ -0,0 +1,26 @@
import * as T from '../../../base/lib/types';
/**
* The reason a service's init function is being called:
* - `'install'` — first-time installation
* - `'update'` — after a package update
* - `'restore'` — after restoring from backup
* - `null` — regular startup (no special lifecycle event)
*/
export type InitKind = 'install' | 'update' | 'restore' | null;
/** Function signature for an init handler that runs during service startup. */
export type InitFn<Kind extends InitKind = InitKind> = (effects: T.Effects, kind: Kind) => Promise<void | null | undefined>;
/** Object form of an init handler — implements an `init()` method. */
export interface InitScript<Kind extends InitKind = InitKind> {
init(effects: T.Effects, kind: Kind): Promise<void>;
}
/** Either an {@link InitScript} object or an {@link InitFn} function. */
export type InitScriptOrFn<Kind extends InitKind = InitKind> = InitScript<Kind> | InitFn<Kind>;
/**
* Composes multiple init handlers into a single `ExpectedExports.init`-compatible function.
* Handlers are executed sequentially in the order provided.
*
* @param inits - One or more init handlers to compose
*/
export declare function setupInit(...inits: InitScriptOrFn[]): T.ExpectedExports.init;
/** Normalizes an {@link InitScriptOrFn} into an {@link InitScript} object. */
export declare function setupOnInit(onInit: InitScriptOrFn): InitScript;
+47
View File
@@ -0,0 +1,47 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupInit = setupInit;
exports.setupOnInit = setupOnInit;
const util_1 = require("../util");
/**
* Composes multiple init handlers into a single `ExpectedExports.init`-compatible function.
* Handlers are executed sequentially in the order provided.
*
* @param inits - One or more init handlers to compose
*/
function setupInit(...inits) {
return async (opts) => {
for (const idx in inits) {
const init = inits[idx];
const fn = async () => {
let res = () => { };
const complete = new Promise((resolve) => {
res = resolve;
});
const e = opts.effects.child(`init_${idx}`);
e.constRetry = (0, util_1.once)(() => complete.then(() => fn()).catch(console.error));
try {
if ('init' in init)
await init.init(e, opts.kind);
else
await init(e, opts.kind);
}
finally {
res();
}
};
await fn();
}
};
}
/** Normalizes an {@link InitScriptOrFn} into an {@link InitScript} object. */
function setupOnInit(onInit) {
return 'init' in onInit
? onInit
: {
init: async (effects, kind) => {
await onInit(effects, kind);
},
};
}
//# sourceMappingURL=setupInit.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setupInit.js","sourceRoot":"","sources":["../../../../base/lib/inits/setupInit.ts"],"names":[],"mappings":";;AAmCA,8BAuBC;AAGD,kCAQC;AAnED,kCAA8B;AA2B9B;;;;;GAKG;AACH,SAAgB,SAAS,CAAC,GAAG,KAAuB;IAClD,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;YACxB,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAA;YACvB,MAAM,EAAE,GAAG,KAAK,IAAI,EAAE;gBACpB,IAAI,GAAG,GAAgC,GAAG,EAAE,GAAE,CAAC,CAAA;gBAC/C,MAAM,QAAQ,GAAG,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;oBACvC,GAAG,GAAG,OAAO,CAAA;gBACf,CAAC,CAAC,CAAA;gBACF,MAAM,CAAC,GAAc,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,QAAQ,GAAG,EAAE,CAAC,CAAA;gBACtD,CAAC,CAAC,UAAU,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,CACvB,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAC/C,CAAA;gBACD,IAAI,CAAC;oBACH,IAAI,MAAM,IAAI,IAAI;wBAAE,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;;wBAC5C,MAAM,IAAI,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAA;gBAC/B,CAAC;wBAAS,CAAC;oBACT,GAAG,EAAE,CAAA;gBACP,CAAC;YACH,CAAC,CAAA;YACD,MAAM,EAAE,EAAE,CAAA;QACZ,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,SAAgB,WAAW,CAAC,MAAsB;IAChD,OAAO,MAAM,IAAI,MAAM;QACrB,CAAC,CAAC,MAAM;QACR,CAAC,CAAC;YACE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;gBAC5B,MAAM,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;YAC7B,CAAC;SACF,CAAA;AACP,CAAC"}
+37
View File
@@ -0,0 +1,37 @@
import { ExtendedVersion, VersionRange } from '../../../base/lib/exver';
import * as T from '../../../base/lib/types';
/**
* Function signature for an uninit handler that runs during service shutdown/uninstall.
*/
export type UninitFn = (effects: T.Effects,
/**
* @description the target version to prepare for
*
* on update: the canMigrateFrom of the new package
* on uninstall: null
* on shutdown: the current version
*/
target: VersionRange | ExtendedVersion | null) => Promise<void | null | undefined>;
/** Object form of an uninit handler — implements an `uninit()` method. */
export interface UninitScript {
uninit(effects: T.Effects,
/**
* @description the target version to prepare for
*
* on update: the canMigrateFrom of the new package
* on uninstall: null
* on shutdown: the current version
*/
target: VersionRange | ExtendedVersion | null): Promise<void>;
}
/** Either a {@link UninitScript} object or a {@link UninitFn} function. */
export type UninitScriptOrFn = UninitScript | UninitFn;
/**
* Composes multiple uninit handlers into a single `ExpectedExports.uninit`-compatible function.
* Handlers are executed sequentially in the order provided.
*
* @param uninits - One or more uninit handlers to compose
*/
export declare function setupUninit(...uninits: UninitScriptOrFn[]): T.ExpectedExports.uninit;
/** Normalizes a {@link UninitScriptOrFn} into a {@link UninitScript} object. */
export declare function setupOnUninit(onUninit: UninitScriptOrFn): UninitScript;
+31
View File
@@ -0,0 +1,31 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.setupUninit = setupUninit;
exports.setupOnUninit = setupOnUninit;
/**
* Composes multiple uninit handlers into a single `ExpectedExports.uninit`-compatible function.
* Handlers are executed sequentially in the order provided.
*
* @param uninits - One or more uninit handlers to compose
*/
function setupUninit(...uninits) {
return async (opts) => {
for (const uninit of uninits) {
if ('uninit' in uninit)
await uninit.uninit(opts.effects, opts.target);
else
await uninit(opts.effects, opts.target);
}
};
}
/** Normalizes a {@link UninitScriptOrFn} into a {@link UninitScript} object. */
function setupOnUninit(onUninit) {
return 'uninit' in onUninit
? onUninit
: {
uninit: async (effects, target) => {
await onUninit(effects, target);
},
};
}
//# sourceMappingURL=setupUninit.js.map
+1
View File
@@ -0,0 +1 @@
{"version":3,"file":"setupUninit.js","sourceRoot":"","sources":["../../../../base/lib/inits/setupUninit.ts"],"names":[],"mappings":";;AA0CA,kCASC;AAGD,sCAQC;AA1BD;;;;;GAKG;AACH,SAAgB,WAAW,CACzB,GAAG,OAA2B;IAE9B,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE;QACpB,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,QAAQ,IAAI,MAAM;gBAAE,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;;gBACjE,MAAM,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAED,gFAAgF;AAChF,SAAgB,aAAa,CAAC,QAA0B;IACtD,OAAO,QAAQ,IAAI,QAAQ;QACzB,CAAC,CAAC,QAAQ;QACV,CAAC,CAAC;YACE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;gBAChC,MAAM,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC,CAAA;YACjC,CAAC;SACF,CAAA;AACP,CAAC"}