@zeltjs/adapter-bun 0.8.1 → 0.8.2-canary.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/dist/index.cjs ADDED
@@ -0,0 +1,124 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
+ let _zeltjs_core = require("@zeltjs/core");
3
+ //#region src/bun-cli.config.ts
4
+ function _ts_decorate$1(decorators, target, key, desc) {
5
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
6
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
7
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
8
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
9
+ }
10
+ var BunCliConfig = class extends _zeltjs_core.CliConfig {
11
+ cwd() {
12
+ return process.cwd();
13
+ }
14
+ argv() {
15
+ return Bun.argv;
16
+ }
17
+ exit(code) {
18
+ process.exit(code);
19
+ }
20
+ setExitCode(code) {
21
+ process.exitCode = code;
22
+ }
23
+ onSignal(signal, handler) {
24
+ process.on(signal, handler);
25
+ }
26
+ offSignal(signal, handler) {
27
+ process.off(signal, handler);
28
+ }
29
+ };
30
+ BunCliConfig = _ts_decorate$1([_zeltjs_core.Config], BunCliConfig);
31
+ //#endregion
32
+ //#region src/bun-env.adaptor.ts
33
+ function _ts_decorate(decorators, target, key, desc) {
34
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
35
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
36
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
37
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
38
+ }
39
+ var BunEnvAdaptor = class extends _zeltjs_core.EnvAdaptor {
40
+ get(key) {
41
+ return Bun.env[key];
42
+ }
43
+ };
44
+ BunEnvAdaptor = _ts_decorate([_zeltjs_core.Config], BunEnvAdaptor);
45
+ //#endregion
46
+ //#region src/on-bun.ts
47
+ const createServeForHttp = (appFetch, appShutdown) => {
48
+ return (options) => {
49
+ const port = options?.port ?? 3e3;
50
+ const hostname = options?.hostname ?? "0.0.0.0";
51
+ const server = Bun.serve({
52
+ fetch: appFetch,
53
+ port,
54
+ hostname
55
+ });
56
+ const shutdown = async () => {
57
+ await server.stop();
58
+ await appShutdown();
59
+ };
60
+ return {
61
+ address: {
62
+ port: server.port ?? port,
63
+ hostname: server.hostname ?? hostname
64
+ },
65
+ shutdown
66
+ };
67
+ };
68
+ };
69
+ const getArgs = () => Bun.argv.slice(2);
70
+ const createBunApp = (readyApp, shutdown, args) => {
71
+ const base = {
72
+ ...readyApp,
73
+ args,
74
+ shutdown
75
+ };
76
+ const httpCaps = readyApp.getFeatureCapabilities(_zeltjs_core.HttpFeature);
77
+ if (!httpCaps) return base;
78
+ return {
79
+ ...base,
80
+ serve: createServeForHttp(httpCaps.fetch, shutdown)
81
+ };
82
+ };
83
+ /** @throws {ZeltLifecycleStateError} */ async function onBun(app, options = {}) {
84
+ const readyApp = await app.createRuntime({
85
+ fallbackConfigs: [BunCliConfig, BunEnvAdaptor],
86
+ warmup: options.warmup ?? true
87
+ });
88
+ const cliConfig = await readyApp.get(BunCliConfig);
89
+ const runtimeShutdown = readyApp.shutdown;
90
+ let shuttingDown = false;
91
+ const detachSignals = () => {
92
+ cliConfig.offSignal("SIGINT", gracefulShutdown);
93
+ cliConfig.offSignal("SIGTERM", gracefulShutdown);
94
+ };
95
+ const shutdown = async () => {
96
+ if (shuttingDown) return;
97
+ shuttingDown = true;
98
+ try {
99
+ await runtimeShutdown();
100
+ } finally {
101
+ detachSignals();
102
+ }
103
+ };
104
+ const gracefulShutdown = () => {
105
+ shutdown().catch(() => {});
106
+ };
107
+ cliConfig.onSignal("SIGINT", gracefulShutdown);
108
+ cliConfig.onSignal("SIGTERM", gracefulShutdown);
109
+ return createBunApp(readyApp, shutdown, getArgs());
110
+ }
111
+ //#endregion
112
+ Object.defineProperty(exports, "BunCliConfig", {
113
+ enumerable: true,
114
+ get: function() {
115
+ return BunCliConfig;
116
+ }
117
+ });
118
+ Object.defineProperty(exports, "BunEnvAdaptor", {
119
+ enumerable: true,
120
+ get: function() {
121
+ return BunEnvAdaptor;
122
+ }
123
+ });
124
+ exports.onBun = onBun;
@@ -0,0 +1,57 @@
1
+ import { CliConfig, CommandCapabilities, ConfiguredFeature, EnvAdaptor, ExecResult, FeatureApp, HttpFeature, RuntimeApp, Signal, SignalHandler } from "@zeltjs/core";
2
+
3
+ //#region src/bun-cli.config.d.ts
4
+ declare class BunCliConfig extends CliConfig {
5
+ cwd(): string;
6
+ argv(): readonly string[];
7
+ exit(code: number): never;
8
+ setExitCode(code: number): void;
9
+ onSignal(signal: Signal, handler: SignalHandler): void;
10
+ offSignal(signal: Signal, handler: SignalHandler): void;
11
+ }
12
+ //#endregion
13
+ //#region src/bun-env.adaptor.d.ts
14
+ declare class BunEnvAdaptor extends EnvAdaptor {
15
+ get(key: string): string | undefined;
16
+ }
17
+ //#endregion
18
+ //#region src/on-bun.d.ts
19
+ type ServeOptions = {
20
+ readonly port?: number;
21
+ readonly hostname?: string;
22
+ };
23
+ type ServerHandle = {
24
+ readonly address: {
25
+ port: number;
26
+ hostname: string;
27
+ };
28
+ readonly shutdown: () => Promise<void>;
29
+ };
30
+ type BunAppOptions = {
31
+ readonly warmup?: boolean;
32
+ };
33
+ type BunAppBase = {
34
+ readonly get: <T extends object>(cls: new (...args: never[]) => T) => Promise<T>;
35
+ readonly args: readonly string[];
36
+ readonly shutdown: () => Promise<void>;
37
+ };
38
+ type EnvironmentBunAppPart = {
39
+ readonly args: readonly string[];
40
+ readonly shutdown: () => Promise<void>;
41
+ };
42
+ type HttpBunAppPart = {
43
+ readonly serve: (options?: ServeOptions) => ServerHandle;
44
+ };
45
+ type HttpBunApp = BunAppBase & RuntimeApp<readonly [HttpFeature]> & HttpBunAppPart;
46
+ type CommandBunApp = BunAppBase & {
47
+ readonly commands: CommandCapabilities;
48
+ };
49
+ type FullBunApp = HttpBunApp & CommandBunApp;
50
+ type BunApp = (RuntimeApp<readonly ConfiguredFeature[]> & EnvironmentBunAppPart) & Partial<HttpBunAppPart>;
51
+ type HasFeatureClass<F extends readonly ConfiguredFeature[], TFeature extends ConfiguredFeature> = Extract<F[number], TFeature> extends never ? false : true;
52
+ type WithFeatureClass<F extends readonly ConfiguredFeature[], TFeature extends ConfiguredFeature, TPart extends object> = HasFeatureClass<F, TFeature> extends true ? TPart : unknown;
53
+ type BunAppForFeatures<F extends readonly ConfiguredFeature[]> = RuntimeApp<F> & EnvironmentBunAppPart & (number extends F['length'] ? Partial<HttpBunAppPart> : WithFeatureClass<F, HttpFeature, HttpBunAppPart>);
54
+ declare function onBun<const F extends readonly ConfiguredFeature[]>(app: FeatureApp<F>, options?: BunAppOptions): Promise<BunAppForFeatures<F>>;
55
+ //#endregion
56
+ export { type BunApp, type BunAppOptions, BunCliConfig, BunEnvAdaptor, type CommandBunApp, type ExecResult, type FullBunApp, type HttpBunApp, type ServerHandle, onBun };
57
+ //# sourceMappingURL=index.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/bun-cli.config.ts","../src/bun-env.adaptor.ts","../src/on-bun.ts"],"mappings":";;;cAIa,YAAA,SAAqB,SAAA;EACvB,GAAA,CAAA;EAIA,IAAA,CAAA;EAIA,IAAA,CAAK,IAAA;EAIL,WAAA,CAAY,IAAA;EAIZ,QAAA,CAAS,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,aAAA;EAIlC,SAAA,CAAU,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,aAAA;AAAA;;;cCtBjC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A,EAAK,UAAA,CAAW,CAAA,GAChB,OAAA,GAAU,aAAA,GACT,OAAA,CAAQ,iBAAA,CAAkB,CAAA"}
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CliConfig, CommandApp, EnvAdaptor, ExecResult, ExecResult as ExecResult$1, HttpApp, ReadyResult, Signal, SignalHandler } from "@zeltjs/core";
1
+ import { CliConfig, CommandCapabilities, ConfiguredFeature, EnvAdaptor, ExecResult, FeatureApp, HttpFeature, RuntimeApp, Signal, SignalHandler } from "@zeltjs/core";
2
2
 
3
3
  //#region src/bun-cli.config.d.ts
4
4
  declare class BunCliConfig extends CliConfig {
@@ -31,24 +31,27 @@ type BunAppOptions = {
31
31
  readonly warmup?: boolean;
32
32
  };
33
33
  type BunAppBase = {
34
+ readonly get: <T extends object>(cls: new (...args: never[]) => T) => Promise<T>;
34
35
  readonly args: readonly string[];
35
- };
36
- type HttpBunApp = ReadyResult & BunAppBase & {
37
- readonly serve: (options?: ServeOptions) => ServerHandle;
38
36
  readonly shutdown: () => Promise<void>;
39
37
  };
40
- type CommandBunApp = ReadyResult & BunAppBase & {
41
- readonly execCommand: (argv: readonly string[]) => Promise<ExecResult$1>;
38
+ type EnvironmentBunAppPart = {
39
+ readonly args: readonly string[];
42
40
  readonly shutdown: () => Promise<void>;
43
41
  };
42
+ type HttpBunAppPart = {
43
+ readonly serve: (options?: ServeOptions) => ServerHandle;
44
+ };
45
+ type HttpBunApp = BunAppBase & RuntimeApp<readonly [HttpFeature]> & HttpBunAppPart;
46
+ type CommandBunApp = BunAppBase & {
47
+ readonly commands: CommandCapabilities;
48
+ };
44
49
  type FullBunApp = HttpBunApp & CommandBunApp;
45
- type BunApp = HttpBunApp | CommandBunApp | FullBunApp;
46
- /** @throws {ZeltLifecycleStateError} */
47
- declare function onBun(app: HttpApp & CommandApp, options?: BunAppOptions): Promise<FullBunApp>;
48
- /** @throws {ZeltLifecycleStateError} */
49
- declare function onBun(app: HttpApp, options?: BunAppOptions): Promise<HttpBunApp>;
50
- /** @throws {ZeltLifecycleStateError} */
51
- declare function onBun(app: CommandApp, options?: BunAppOptions): Promise<CommandBunApp>;
50
+ type BunApp = (RuntimeApp<readonly ConfiguredFeature[]> & EnvironmentBunAppPart) & Partial<HttpBunAppPart>;
51
+ type HasFeatureClass<F extends readonly ConfiguredFeature[], TFeature extends ConfiguredFeature> = Extract<F[number], TFeature> extends never ? false : true;
52
+ type WithFeatureClass<F extends readonly ConfiguredFeature[], TFeature extends ConfiguredFeature, TPart extends object> = HasFeatureClass<F, TFeature> extends true ? TPart : unknown;
53
+ type BunAppForFeatures<F extends readonly ConfiguredFeature[]> = RuntimeApp<F> & EnvironmentBunAppPart & (number extends F['length'] ? Partial<HttpBunAppPart> : WithFeatureClass<F, HttpFeature, HttpBunAppPart>);
54
+ declare function onBun<const F extends readonly ConfiguredFeature[]>(app: FeatureApp<F>, options?: BunAppOptions): Promise<BunAppForFeatures<F>>;
52
55
  //#endregion
53
56
  export { type BunApp, type BunAppOptions, BunCliConfig, BunEnvAdaptor, type CommandBunApp, type ExecResult, type FullBunApp, type HttpBunApp, type ServerHandle, onBun };
54
57
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/bun-cli.config.ts","../src/bun-env.adaptor.ts","../src/on-bun.ts"],"mappings":";;;cAIa,YAAA,SAAqB,SAAA;EACvB,GAAA,CAAA;EAIA,IAAA,CAAA;EAIA,IAAA,CAAK,IAAA;EAIL,WAAA,CAAY,IAAA;EAIZ,QAAA,CAAS,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,aAAA;EAIlC,SAAA,CAAU,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,aAAA;AAAA;;;cCtBjC,aAAA,SAAsB,UAAA;EACxB,GAAA,CAAI,GAAA;AAAA;;;KCCV,YAAA;EAAA,SACM,IAAA;EAAA,SACA,QAAA;AAAA;AAAA,KAGC,YAAA;EAAA,SACD,O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iBAAA,CAAkB,CAAA"}
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { CliConfig, Config, EnvAdaptor } from "@zeltjs/core";
1
+ import { CliConfig, Config, EnvAdaptor, HttpFeature } from "@zeltjs/core";
2
2
  //#region src/bun-cli.config.ts
3
3
  function _ts_decorate$1(decorators, target, key, desc) {
4
4
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -65,64 +65,27 @@ const createServeForHttp = (appFetch, appShutdown) => {
65
65
  };
66
66
  };
67
67
  };
68
- const getStderr = () => globalThis.process.stderr;
69
68
  const getArgs = () => Bun.argv.slice(2);
70
- const extractCapabilities = (app) => app;
71
- const buildHttpBunApp = (caps, resolver, shutdown, args) => {
72
- if (typeof caps.fetch !== "function") return void 0;
73
- return {
74
- ...resolver,
69
+ const createBunApp = (readyApp, shutdown, args) => {
70
+ const base = {
71
+ ...readyApp,
75
72
  args,
76
- serve: createServeForHttp(caps.fetch, shutdown),
77
73
  shutdown
78
74
  };
79
- };
80
- const buildCommandBunApp = (caps, resolver, shutdown, stderr, args) => {
81
- if (typeof caps.execCommand !== "function") return void 0;
82
- const coreExecCommand = caps.execCommand;
83
- const execCommand = async (argv) => {
84
- const result = await coreExecCommand(argv);
85
- if (result.exitCode === 1) stderr.write(`${result.reason.message}\n`);
86
- return result;
87
- };
75
+ const httpCaps = readyApp.getFeatureCapabilities(HttpFeature);
76
+ if (!httpCaps) return base;
88
77
  return {
89
- ...resolver,
90
- args,
91
- execCommand,
92
- shutdown
93
- };
94
- };
95
- const buildBunApps = (caps, resolver, shutdown, stderr, args) => ({
96
- httpResult: buildHttpBunApp(caps, resolver, shutdown, args),
97
- commandResult: buildCommandBunApp(caps, resolver, shutdown, stderr, args)
98
- });
99
- const mergeBunApps = (result, resolver, shutdown, args) => {
100
- const { httpResult, commandResult } = result;
101
- if (httpResult && commandResult) return {
102
- ...httpResult,
103
- execCommand: commandResult.execCommand
104
- };
105
- if (httpResult) return httpResult;
106
- if (commandResult) return commandResult;
107
- return {
108
- ...resolver,
109
- args,
110
- shutdown,
111
- serve: () => ({
112
- address: {
113
- port: 0,
114
- hostname: ""
115
- },
116
- shutdown
117
- })
78
+ ...base,
79
+ serve: createServeForHttp(httpCaps.fetch, shutdown)
118
80
  };
119
81
  };
120
82
  /** @throws {ZeltLifecycleStateError} */ async function onBun(app, options = {}) {
121
- app.addFallbackConfig(BunCliConfig);
122
- app.addFallbackConfig(BunEnvAdaptor);
123
- const readyOptions = { warmup: options.warmup ?? true };
124
- const resolver = await app.ready(readyOptions);
125
- const cliConfig = resolver.get(BunCliConfig);
83
+ const readyApp = await app.createRuntime({
84
+ fallbackConfigs: [BunCliConfig, BunEnvAdaptor],
85
+ warmup: options.warmup ?? true
86
+ });
87
+ const cliConfig = await readyApp.get(BunCliConfig);
88
+ const runtimeShutdown = readyApp.shutdown;
126
89
  let shuttingDown = false;
127
90
  const detachSignals = () => {
128
91
  cliConfig.offSignal("SIGINT", gracefulShutdown);
@@ -132,7 +95,7 @@ const mergeBunApps = (result, resolver, shutdown, args) => {
132
95
  if (shuttingDown) return;
133
96
  shuttingDown = true;
134
97
  try {
135
- await app.shutdown();
98
+ await runtimeShutdown();
136
99
  } finally {
137
100
  detachSignals();
138
101
  }
@@ -142,10 +105,7 @@ const mergeBunApps = (result, resolver, shutdown, args) => {
142
105
  };
143
106
  cliConfig.onSignal("SIGINT", gracefulShutdown);
144
107
  cliConfig.onSignal("SIGTERM", gracefulShutdown);
145
- const caps = extractCapabilities(app);
146
- const stderr = getStderr();
147
- const args = getArgs();
148
- return mergeBunApps(buildBunApps(caps, resolver, shutdown, stderr, args), resolver, shutdown, args);
108
+ return createBunApp(readyApp, shutdown, getArgs());
149
109
  }
150
110
  //#endregion
151
111
  export { BunCliConfig, BunEnvAdaptor, onBun };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["CliConfig","Config","BunCliConfig","cwd","process","argv","Bun","exit","code","setExitCode","exitCode","onSignal","signal","handler","on","offSignal","off","Config","EnvAdaptor","BunEnvAdaptor","get","key","Bun","env","BunCliConfig","BunEnvAdaptor","createServeForHttp","appFetch","appShutdown","options","port","hostname","server","Bun","serve","fetch","shutdown","stop","address","getStderr","globalThis","process","stderr","getArgs","argv","slice","extractCapabilities","app","buildHttpBunApp","caps","resolver","args","undefined","buildCommandBunApp","execCommand","coreExecCommand","result","exitCode","write","reason","message","buildBunApps","httpResult","commandResult","mergeBunApps","fullApp","onBun","addFallbackConfig","readyOptions","warmup","ready","cliConfig","get","shuttingDown","detachSignals","offSignal","gracefulShutdown","catch","onSignal"],"sources":["../src/bun-cli.config.ts","../src/bun-env.adaptor.ts","../src/on-bun.ts"],"sourcesContent":["import type { Signal, SignalHandler } from '@zeltjs/core';\nimport { CliConfig, Config } from '@zeltjs/core';\n\n@Config\nexport class BunCliConfig extends CliConfig {\n override cwd(): string {\n return process.cwd();\n }\n\n override argv(): readonly string[] {\n return Bun.argv;\n }\n\n override exit(code: number): never {\n process.exit(code);\n }\n\n override setExitCode(code: number): void {\n process.exitCode = code;\n }\n\n override onSignal(signal: Signal, handler: SignalHandler): void {\n process.on(signal, handler);\n }\n\n override offSignal(signal: Signal, handler: SignalHandler): void {\n process.off(signal, handler);\n }\n}\n","import { Config, EnvAdaptor } from '@zeltjs/core';\n\n@Config\nexport class BunEnvAdaptor extends EnvAdaptor {\n override get(key: string): string | undefined {\n return Bun.env[key];\n }\n}\n","import type { CommandApp, ExecResult, HttpApp, ReadyOptions, ReadyResult } from '@zeltjs/core';\n\nimport { BunCliConfig } from './bun-cli.config';\nimport { BunEnvAdaptor } from './bun-env.adaptor';\n\ntype ServeOptions = {\n readonly port?: number;\n readonly hostname?: string;\n};\n\nexport type ServerHandle = {\n readonly address: { port: number; hostname: string };\n readonly shutdown: () => Promise<void>;\n};\n\nexport type BunAppOptions = {\n readonly warmup?: boolean;\n};\n\nexport type { ExecResult } from '@zeltjs/core';\n\ntype BunAppBase = {\n readonly args: readonly string[];\n};\n\nexport type HttpBunApp = ReadyResult &\n BunAppBase & {\n readonly serve: (options?: ServeOptions) => ServerHandle;\n readonly shutdown: () => Promise<void>;\n };\n\nexport type CommandBunApp = ReadyResult &\n BunAppBase & {\n readonly execCommand: (argv: readonly string[]) => Promise<ExecResult>;\n readonly shutdown: () => Promise<void>;\n };\n\nexport type FullBunApp = HttpBunApp & CommandBunApp;\n\nexport type BunApp = HttpBunApp | CommandBunApp | FullBunApp;\n\ntype Stderr = { write: (s: string) => void };\n\nconst createServeForHttp = (\n appFetch: (request: Request) => Promise<Response>,\n appShutdown: () => Promise<void>,\n): ((options?: ServeOptions) => ServerHandle) => {\n return (options?: ServeOptions): ServerHandle => {\n const port = options?.port ?? 3000;\n const hostname = options?.hostname ?? '0.0.0.0';\n\n const server = Bun.serve({\n fetch: appFetch,\n port,\n hostname,\n });\n\n const shutdown = async (): Promise<void> => {\n await server.stop();\n await appShutdown();\n };\n\n return {\n address: { port: server.port ?? port, hostname: server.hostname ?? hostname },\n shutdown,\n };\n };\n};\n\nconst getStderr = (): Stderr => globalThis.process.stderr;\n\nconst getArgs = (): readonly string[] => Bun.argv.slice(2);\n\ntype AppCapabilities = {\n fetch?: (request: Request) => Promise<Response>;\n execCommand?: (argv: readonly string[]) => Promise<ExecResult>;\n};\n\nconst extractCapabilities = (app: HttpApp | CommandApp | (HttpApp & CommandApp)): AppCapabilities =>\n app;\n\ntype BuildResult = {\n httpResult: HttpBunApp | undefined;\n commandResult: CommandBunApp | undefined;\n};\n\nconst buildHttpBunApp = (\n caps: AppCapabilities,\n resolver: ReadyResult,\n shutdown: () => Promise<void>,\n args: readonly string[],\n): HttpBunApp | undefined => {\n if (typeof caps.fetch !== 'function') return undefined;\n return { ...resolver, args, serve: createServeForHttp(caps.fetch, shutdown), shutdown };\n};\n\nconst buildCommandBunApp = (\n caps: AppCapabilities,\n resolver: ReadyResult,\n shutdown: () => Promise<void>,\n stderr: Stderr,\n args: readonly string[],\n): CommandBunApp | undefined => {\n if (typeof caps.execCommand !== 'function') return undefined;\n\n const coreExecCommand = caps.execCommand;\n const execCommand = async (argv: readonly string[]): Promise<ExecResult> => {\n const result = await coreExecCommand(argv);\n if (result.exitCode === 1) {\n stderr.write(`${result.reason.message}\\n`);\n }\n return result;\n };\n\n return { ...resolver, args, execCommand, shutdown };\n};\n\nconst buildBunApps = (\n caps: AppCapabilities,\n resolver: ReadyResult,\n shutdown: () => Promise<void>,\n stderr: Stderr,\n args: readonly string[],\n): BuildResult => ({\n httpResult: buildHttpBunApp(caps, resolver, shutdown, args),\n commandResult: buildCommandBunApp(caps, resolver, shutdown, stderr, args),\n});\n\nconst mergeBunApps = (\n result: BuildResult,\n resolver: ReadyResult,\n shutdown: () => Promise<void>,\n args: readonly string[],\n): BunApp => {\n const { httpResult, commandResult } = result;\n if (httpResult && commandResult) {\n const fullApp: FullBunApp = { ...httpResult, execCommand: commandResult.execCommand };\n return fullApp;\n }\n if (httpResult) return httpResult;\n if (commandResult) return commandResult;\n return {\n ...resolver,\n args,\n shutdown,\n serve: () => ({ address: { port: 0, hostname: '' }, shutdown }),\n };\n};\n\n/** @throws {ZeltLifecycleStateError} */\nexport function onBun(app: HttpApp & CommandApp, options?: BunAppOptions): Promise<FullBunApp>;\n/** @throws {ZeltLifecycleStateError} */\nexport function onBun(app: HttpApp, options?: BunAppOptions): Promise<HttpBunApp>;\n/** @throws {ZeltLifecycleStateError} */\nexport function onBun(app: CommandApp, options?: BunAppOptions): Promise<CommandBunApp>;\n/** @throws {ZeltLifecycleStateError} */\nexport async function onBun(\n app: HttpApp | CommandApp | (HttpApp & CommandApp),\n options: BunAppOptions = {},\n): Promise<BunApp> {\n app.addFallbackConfig(BunCliConfig);\n app.addFallbackConfig(BunEnvAdaptor);\n\n const readyOptions: ReadyOptions = { warmup: options.warmup ?? true };\n const resolver = await app.ready(readyOptions);\n\n const cliConfig = resolver.get(BunCliConfig);\n\n let shuttingDown = false;\n const detachSignals = (): void => {\n cliConfig.offSignal('SIGINT', gracefulShutdown);\n cliConfig.offSignal('SIGTERM', gracefulShutdown);\n };\n\n const shutdown = async (): Promise<void> => {\n if (shuttingDown) return;\n shuttingDown = true;\n try {\n await app.shutdown();\n } finally {\n detachSignals();\n }\n };\n\n const gracefulShutdown = (): void => {\n void shutdown().catch(() => {});\n };\n\n cliConfig.onSignal('SIGINT', gracefulShutdown);\n cliConfig.onSignal('SIGTERM', gracefulShutdown);\n\n const caps = extractCapabilities(app);\n const stderr = getStderr();\n const args = getArgs();\n const result = buildBunApps(caps, resolver, shutdown, stderr, args);\n\n return mergeBunApps(result, resolver, shutdown, args);\n}\n"],"mappings":";;;;;;;;AAIA,IAAaE,eAAb,cAAkCF,UAAAA;CACvBG,MAAc;AACrB,SAAOC,QAAQD,KAAG;;CAGXE,OAA0B;AACjC,SAAOC,IAAID;;CAGJE,KAAKC,MAAqB;AACjCJ,UAAQG,KAAKC,KAAAA;;CAGNC,YAAYD,MAAoB;AACvCJ,UAAQM,WAAWF;;CAGZG,SAASC,QAAgBC,SAA8B;AAC9DT,UAAQU,GAAGF,QAAQC,QAAAA;;CAGZE,UAAUH,QAAgBC,SAA8B;AAC/DT,UAAQY,IAAIJ,QAAQC,QAAAA;;;;;;;;;;;;ACvBxB,IAAaM,gBAAb,cAAmCD,WAAAA;CACxBE,IAAIC,KAAiC;AAC5C,SAAOC,IAAIC,IAAIF;;;;;;ACsCnB,MAAMK,sBACJC,UACAC,gBAAAA;AAEA,SAAQC,YAAAA;EACN,MAAMC,OAAOD,SAASC,QAAQ;EAC9B,MAAMC,WAAWF,SAASE,YAAY;EAEtC,MAAMC,SAASC,IAAIC,MAAM;GACvBC,OAAOR;GACPG;GACAC;GACF,CAAA;EAEA,MAAMK,WAAW,YAAA;AACf,SAAMJ,OAAOK,MAAI;AACjB,SAAMT,aAAAA;;AAGR,SAAO;GACLU,SAAS;IAAER,MAAME,OAAOF,QAAQA;IAAMC,UAAUC,OAAOD,YAAYA;IA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BnB,KACAlB,UAAyB,EAAE,EAAA;AAE3BkB,KAAIoB,kBAAkB3C,aAAAA;AACtBuB,KAAIoB,kBAAkB1C,cAAAA;CAEtB,MAAM2C,eAA6B,EAAEC,QAAQxC,QAAQwC,UAAU,MAAK;CACpE,MAAMnB,WAAW,MAAMH,IAAIuB,MAAMF,aAAAA;CAEjC,MAAMG,YAAYrB,SAASsB,IAAIhD,aAAAA;CAE/B,IAAIiD,eAAe;CACnB,MAAMC,sBAAgB;AACpBH,YAAUI,UAAU,UAAUC,iBAAAA;AAC9BL,YAAUI,UAAU,WAAWC,iBAAAA;;CAGjC,MAAMxC,WAAW,YAAA;AACf,MAAIqC,aAAc;AAClBA,iBAAe;AACf,MAAI;AACF,SAAM1B,IAAIX,UAAQ;YACV;AACRsC,kBAAAA;;;CAIJ,MAAME,yBAAmB;AAClBxC,YAAAA,CAAWyC,YAAM,GAAO;;AAG/BN,WAAUO,SAAS,UAAUF,iBAAAA;AAC7BL,WAAUO,SAAS,WAAWF,iBAAAA;CAE9B,MAAM3B,OAAOH,oBAAoBC,IAAAA;CACjC,MAAML,SAASH,WAAAA;CACf,MAAMY,OAAOR,SAAAA;AAGb,QAAOqB,aAFQH,aAAaZ,MAAMC,UAAUd,UAAUM,QAAQS,KAE1CK,EAAQN,UAAUd,UAAUe,KAAAA"}
1
+ {"version":3,"file":"index.js","names":["CliConfig","Config","BunCliConfig","cwd","process","argv","Bun","exit","code","setExitCode","exitCode","onSignal","signal","handler","on","offSignal","off","Config","EnvAdaptor","BunEnvAdaptor","get","key","Bun","env","HttpFeature","BunCliConfig","BunEnvAdaptor","createServeForHttp","appFetch","appShutdown","options","port","hostname","server","Bun","serve","fetch","shutdown","stop","address","getArgs","argv","slice","createBunApp","readyApp","args","base","httpCaps","getFeatureCapabilities","onBun","app","createRuntime","fallbackConfigs","warmup","cliConfig","get","runtimeShutdown","shuttingDown","detachSignals","offSignal","gracefulShutdown","catch","onSignal"],"sources":["../src/bun-cli.config.ts","../src/bun-env.adaptor.ts","../src/on-bun.ts"],"sourcesContent":["import type { Signal, SignalHandler } from '@zeltjs/core';\nimport { CliConfig, Config } from '@zeltjs/core';\n\n@Config\nexport class BunCliConfig extends CliConfig {\n override cwd(): string {\n return process.cwd();\n }\n\n override argv(): readonly string[] {\n return Bun.argv;\n }\n\n override exit(code: number): never {\n process.exit(code);\n }\n\n override setExitCode(code: number): void {\n process.exitCode = code;\n }\n\n override onSignal(signal: Signal, handler: SignalHandler): void {\n process.on(signal, handler);\n }\n\n override offSignal(signal: Signal, handler: SignalHandler): void {\n process.off(signal, handler);\n }\n}\n","import { Config, EnvAdaptor } from '@zeltjs/core';\n\n@Config\nexport class BunEnvAdaptor extends EnvAdaptor {\n override get(key: string): string | undefined {\n return Bun.env[key];\n }\n}\n","import type { CommandCapabilities, ConfiguredFeature, FeatureApp, RuntimeApp } from '@zeltjs/core';\nimport { HttpFeature } from '@zeltjs/core';\n\nimport { BunCliConfig } from './bun-cli.config';\nimport { BunEnvAdaptor } from './bun-env.adaptor';\n\ntype ServeOptions = {\n readonly port?: number;\n readonly hostname?: string;\n};\n\nexport type ServerHandle = {\n readonly address: { port: number; hostname: string };\n readonly shutdown: () => Promise<void>;\n};\n\nexport type BunAppOptions = {\n readonly warmup?: boolean;\n};\n\nexport type { ExecResult } from '@zeltjs/core';\n\ntype BunAppBase = {\n readonly get: <T extends object>(cls: new (...args: never[]) => T) => Promise<T>;\n readonly args: readonly string[];\n readonly shutdown: () => Promise<void>;\n};\n\ntype EnvironmentBunAppPart = {\n readonly args: readonly string[];\n readonly shutdown: () => Promise<void>;\n};\n\ntype HttpBunAppPart = {\n readonly serve: (options?: ServeOptions) => ServerHandle;\n};\n\nexport type HttpBunApp = BunAppBase & RuntimeApp<readonly [HttpFeature]> & HttpBunAppPart;\n\nexport type CommandBunApp = BunAppBase & { readonly commands: CommandCapabilities };\n\nexport type FullBunApp = HttpBunApp & CommandBunApp;\n\nexport type BunApp = (RuntimeApp<readonly ConfiguredFeature[]> & EnvironmentBunAppPart) &\n Partial<HttpBunAppPart>;\n\ntype HasFeatureClass<F extends readonly ConfiguredFeature[], TFeature extends ConfiguredFeature> =\n Extract<F[number], TFeature> extends never ? false : true;\n\ntype WithFeatureClass<\n F extends readonly ConfiguredFeature[],\n TFeature extends ConfiguredFeature,\n TPart extends object,\n> = HasFeatureClass<F, TFeature> extends true ? TPart : unknown;\n\ntype BunAppForFeatures<F extends readonly ConfiguredFeature[]> = RuntimeApp<F> &\n EnvironmentBunAppPart &\n (number extends F['length']\n ? Partial<HttpBunAppPart>\n : WithFeatureClass<F, HttpFeature, HttpBunAppPart>);\n\nconst createServeForHttp = (\n appFetch: (request: Request) => Promise<Response>,\n appShutdown: () => Promise<void>,\n): ((options?: ServeOptions) => ServerHandle) => {\n return (options?: ServeOptions): ServerHandle => {\n const port = options?.port ?? 3000;\n const hostname = options?.hostname ?? '0.0.0.0';\n\n const server = Bun.serve({\n fetch: appFetch,\n port,\n hostname,\n });\n\n const shutdown = async (): Promise<void> => {\n await server.stop();\n await appShutdown();\n };\n\n return {\n address: { port: server.port ?? port, hostname: server.hostname ?? hostname },\n shutdown,\n };\n };\n};\n\nconst getArgs = (): readonly string[] => Bun.argv.slice(2);\n\nconst createBunApp = (\n readyApp: RuntimeApp<readonly ConfiguredFeature[]>,\n shutdown: () => Promise<void>,\n args: readonly string[],\n): BunApp => {\n const base: RuntimeApp<readonly ConfiguredFeature[]> & EnvironmentBunAppPart = {\n ...readyApp,\n args,\n shutdown,\n };\n\n const httpCaps = readyApp.getFeatureCapabilities(HttpFeature);\n if (!httpCaps) return base;\n return {\n ...base,\n serve: createServeForHttp(httpCaps.fetch, shutdown),\n };\n};\n\nexport function onBun<const F extends readonly ConfiguredFeature[]>(\n app: FeatureApp<F>,\n options?: BunAppOptions,\n): Promise<BunAppForFeatures<F>>;\n\n/** @throws {ZeltLifecycleStateError} */\nexport async function onBun<const F extends readonly ConfiguredFeature[]>(\n app: FeatureApp<F>,\n options: BunAppOptions = {},\n): Promise<BunApp> {\n const readyApp = await app.createRuntime({\n fallbackConfigs: [BunCliConfig, BunEnvAdaptor],\n warmup: options.warmup ?? true,\n });\n\n const cliConfig = await readyApp.get(BunCliConfig);\n const runtimeShutdown = readyApp.shutdown;\n\n let shuttingDown = false;\n const detachSignals = (): void => {\n cliConfig.offSignal('SIGINT', gracefulShutdown);\n cliConfig.offSignal('SIGTERM', gracefulShutdown);\n };\n\n const shutdown = async (): Promise<void> => {\n if (shuttingDown) return;\n shuttingDown = true;\n try {\n await runtimeShutdown();\n } finally {\n detachSignals();\n }\n };\n\n const gracefulShutdown = (): void => {\n void shutdown().catch(() => {});\n };\n\n cliConfig.onSignal('SIGINT', gracefulShutdown);\n cliConfig.onSignal('SIGTERM', gracefulShutdown);\n\n const args = getArgs();\n\n return createBunApp(readyApp, shutdown, args);\n}\n"],"mappings":";;;;;;;;AAIA,IAAaE,eAAb,cAAkCF,UAAAA;CACvBG,MAAc;AACrB,SAAOC,QAAQD,KAAG;;CAGXE,OAA0B;AACjC,SAAOC,IAAID;;CAGJE,KAAKC,MAAqB;AACjCJ,UAAQG,KAAKC,KAAAA;;CAGNC,YAAYD,MAAoB;AACvCJ,UAAQM,WAAWF;;CAGZG,SAASC,QAAgBC,SAA8B;AAC9DT,UAAQU,GAAGF,QAAQC,QAAAA;;CAGZE,UAAUH,QAAgBC,SAA8B;AAC/DT,UAAQY,IAAIJ,QAAQC,QAAAA;;;;;;;;;;;;ACvBxB,IAAaM,gBAAb,cAAmCD,WAAAA;CACxBE,IAAIC,KAAiC;AAC5C,SAAOC,IAAIC,IAAIF;;;;;;ACwDnB,MAAMM,sBACJC,UACAC,gBAAAA;AAEA,SAAQC,YAAAA;EACN,MAAMC,OAAOD,SAASC,QAAQ;EAC9B,MAAMC,WAAWF,SAASE,YAAY;EAEtC,MAAMC,SAASC,IAAIC,MAAM;GACvBC,OAAOR;GACPG;GACAC;GACF,CAAA;EAEA,MAAMK,WAAW,YAAA;AACf,SAAMJ,OAA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
5
  "license": "MIT",
6
6
  "repository": {
@@ -13,22 +13,30 @@
13
13
  },
14
14
  "exports": {
15
15
  ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.js"
16
+ "import": {
17
+ "types": "./dist/index.d.ts",
18
+ "default": "./dist/index.js"
19
+ },
20
+ "require": {
21
+ "types": "./dist/index.d.cts",
22
+ "default": "./dist/index.cjs"
23
+ }
18
24
  }
19
25
  },
20
26
  "files": [
21
27
  "dist"
22
28
  ],
23
- "dependencies": {
24
- "@zeltjs/core": "0.8.1"
29
+ "peerDependencies": {
30
+ "@zeltjs/core": "0.8.2-canary.1"
25
31
  },
26
32
  "devDependencies": {
27
- "@types/bun": "1.2.17"
33
+ "@types/bun": "1.2.17",
34
+ "@zeltjs/core": "0.8.2-canary.1"
28
35
  },
29
36
  "volta": {
30
37
  "extends": "../../package.json"
31
38
  },
39
+ "main": "./dist/index.cjs",
32
40
  "scripts": {
33
41
  "build": "tsdown",
34
42
  "test": "vitest run",