@cossackframework/node-adapter 0.8.3 → 0.9.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.
@@ -0,0 +1,4 @@
1
+ import { type EmailDeliveryProvider } from '@cossackframework/core/notifications';
2
+ import type { NodeEmailSender } from './email.js';
3
+ /** Adapt createNodeEmailSender() or another explicit structural SMTP sender. */
4
+ export declare function createSmtpNotificationEmailProvider(sender: NodeEmailSender): EmailDeliveryProvider;
@@ -0,0 +1,40 @@
1
+ import { NotificationDeliveryError as e } from "@cossackframework/core/notifications";
2
+ //#region src/notifications.ts
3
+ function t(t) {
4
+ return Object.freeze({
5
+ idempotency: "none",
6
+ async send(n) {
7
+ let { to: r, from: i, subject: a, html: o, text: s } = n;
8
+ if (![
9
+ r,
10
+ i,
11
+ a,
12
+ o,
13
+ s
14
+ ].every((e) => typeof e == "string") || !r || !i || !a || /[\r\n]/.test(r + i + a) || new TextEncoder().encode(r + i + a + o + s).byteLength > 256 * 1024) throw new e("rejected");
15
+ try {
16
+ let n = await t.send({
17
+ to: r,
18
+ from: i,
19
+ subject: a,
20
+ html: o,
21
+ text: s
22
+ }), c = n && typeof n == "object" ? Object.getOwnPropertyDescriptor(n, "messageId") : void 0, l = c && "value" in c ? c.value : void 0;
23
+ if (typeof l != "string" || !/^[\x21-\x7e]{1,255}$/.test(l)) throw new e("unknown");
24
+ return Object.freeze({
25
+ status: "provider-accepted",
26
+ messageId: l
27
+ });
28
+ } catch (t) {
29
+ let n;
30
+ try {
31
+ let e = t && typeof t == "object" ? Object.getOwnPropertyDescriptor(t, "responseCode") : void 0;
32
+ n = e && "value" in e ? e.value : void 0;
33
+ } catch {}
34
+ throw typeof n == "number" && Number.isInteger(n) && n >= 400 && n <= 599 ? new e("rejected", { retryable: n < 500 }) : new e("unknown");
35
+ }
36
+ }
37
+ });
38
+ }
39
+ //#endregion
40
+ export { t as createSmtpNotificationEmailProvider };
@@ -0,0 +1,24 @@
1
+ import type { EventEmitter } from 'node:events';
2
+ /** Operations shared by Node HTTP, HTTPS and HTTP/2 compatibility servers. */
3
+ export interface NodeShutdownServer extends Pick<EventEmitter, 'on' | 'off'> {
4
+ close(callback: () => void): unknown;
5
+ closeIdleConnections?(): void;
6
+ closeAllConnections?(): void;
7
+ }
8
+ export interface NodeShutdownOptions {
9
+ /** Deadline for HTTP requests and runtime cleanup together. Default: 10 seconds. */
10
+ timeoutMs?: number;
11
+ dispose(): Promise<void>;
12
+ /** Called once after draining or the deadline. Signal handlers do not call process.exit. */
13
+ onComplete?: (result: NodeShutdownResult) => void;
14
+ }
15
+ export interface NodeShutdownResult {
16
+ forced: boolean;
17
+ cleanupCompleted: boolean;
18
+ cleanupFailed: boolean;
19
+ }
20
+ /** Explicit process ownership: stop accepting HTTP, dispose the runtime, and bound draining. */
21
+ export declare function installNodeShutdown(server: NodeShutdownServer, options: NodeShutdownOptions): {
22
+ shutdown: () => Promise<NodeShutdownResult>;
23
+ uninstall: () => void;
24
+ };
@@ -16,7 +16,16 @@ export interface StaticServeOptions {
16
16
  * Create a middleware that serves static files from a directory.
17
17
  * This is for Node.js runtime only - uses fs to read files.
18
18
  *
19
+ * Files are streamed. Responses carry a weak `ETag`, `Last-Modified` and
20
+ * `Accept-Ranges: bytes`; `If-None-Match`/`If-Modified-Since` return 304, and a
21
+ * single `Range` on GET returns 206 (416 when unsatisfiable). Several ranges
22
+ * receive the whole file with 200.
23
+ *
19
24
  * @param options - Static serving options
20
25
  * @returns Hono middleware
21
26
  */
22
27
  export declare function serveStatic(options: StaticServeOptions): (c: Context, next: Next) => Promise<void | Response>;
28
+ /** Filesystem-backed ASSETS binding for SSR manifest and CSS reads. */
29
+ export declare function createStaticAssets(options: StaticServeOptions): {
30
+ fetch(request: Request): Promise<Response>;
31
+ };
@@ -0,0 +1,26 @@
1
+ import { StorageError } from '@cossackframework/core/storage';
2
+ import type { StorageProvider, StorageMetadata, StorageObject, StoragePutOptions, StorageReadOptions } from '@cossackframework/core/storage';
3
+ export declare class LocalStorageError extends StorageError {
4
+ constructor();
5
+ }
6
+ /** Persistent filesystem storage for a root exclusively owned by one Node process.
7
+ * Objects use immutable generations; atomic manifest rename publishes complete bytes. */
8
+ export declare class LocalStorageProvider implements StorageProvider {
9
+ readonly name = "local-filesystem";
10
+ readonly root: string;
11
+ constructor(options: {
12
+ root: string;
13
+ });
14
+ /** Shared by concurrent callers; cleared on failure and when the root disappears. */
15
+ private initialized;
16
+ private ready;
17
+ private initialize;
18
+ private prefix;
19
+ private own;
20
+ private safeOpen;
21
+ private manifest;
22
+ put(key: string, body: ReadableStream<Uint8Array>, options: StoragePutOptions): Promise<StorageMetadata>;
23
+ head(key: string, options?: StorageReadOptions): Promise<StorageMetadata | null>;
24
+ get(key: string, options?: StorageReadOptions): Promise<StorageObject | null>;
25
+ delete(key: string, options?: StorageReadOptions): Promise<void>;
26
+ }
@@ -0,0 +1,241 @@
1
+ import { constants as e } from "node:fs";
2
+ import { mkdir as t, open as n, realpath as r, rename as i, unlink as a } from "node:fs/promises";
3
+ import o from "node:path";
4
+ import { createHash as s, randomUUID as c } from "node:crypto";
5
+ import { StorageError as l } from "@cossackframework/core/storage";
6
+ //#region src/storage.ts
7
+ var u = class extends l {
8
+ constructor() {
9
+ super("COSSACK_STORAGE_PROVIDER_FAILED", "Local storage failed. Check the isolated root, object metadata, and filesystem permissions."), this.name = "LocalStorageError";
10
+ }
11
+ }, d = /* @__PURE__ */ new Map();
12
+ function f(e) {
13
+ if (e?.aborted) throw new DOMException("Storage operation was cancelled.", "AbortError");
14
+ }
15
+ function p(e) {
16
+ if (typeof e != "string" || e.length > 1024 || !e || e.split("/").some((e) => !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(e) || e === "." || e === "..")) throw new u();
17
+ }
18
+ function m(e) {
19
+ if (!Number.isSafeInteger(e.size) || e.size < 0 || e.contentType !== void 0 && (typeof e.contentType != "string" || e.contentType.length > 256 || /[\x00-\x1f\x7f]/.test(e.contentType))) throw new u();
20
+ let t;
21
+ if (e.customMetadata !== void 0) {
22
+ if (!e.customMetadata || ![Object.prototype, null].includes(Object.getPrototypeOf(e.customMetadata))) throw new u();
23
+ t = Object.create(null);
24
+ for (let n of Reflect.ownKeys(e.customMetadata)) {
25
+ let r = Object.getOwnPropertyDescriptor(e.customMetadata, n);
26
+ if (typeof n != "string" || !/^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/.test(n) || !("value" in r) || typeof r.value != "string" || r.value.length > 2048) throw new u();
27
+ t[n] = r.value;
28
+ }
29
+ if (Object.keys(t).length > 64 || Buffer.byteLength(JSON.stringify(t)) > 8192) throw new u();
30
+ }
31
+ return {
32
+ size: e.size,
33
+ ...e.contentType === void 0 ? {} : { contentType: e.contentType },
34
+ ...t ? { customMetadata: t } : {}
35
+ };
36
+ }
37
+ function h(e) {
38
+ return e?.code === "ENOENT";
39
+ }
40
+ function g(e) {
41
+ return {
42
+ key: e.key,
43
+ size: e.size,
44
+ etag: e.etag,
45
+ uploaded: new Date(e.uploaded),
46
+ ...e.contentType === void 0 ? {} : { contentType: e.contentType },
47
+ ...e.customMetadata ? { customMetadata: { ...e.customMetadata } } : {}
48
+ };
49
+ }
50
+ async function _(e, t) {
51
+ if (f(t), !t) return e;
52
+ let n, r = new Promise((e, r) => {
53
+ n = () => r(new DOMException("Storage operation was cancelled.", "AbortError")), t.addEventListener("abort", n, { once: !0 });
54
+ });
55
+ try {
56
+ f(t), await Promise.race([e, r]);
57
+ } finally {
58
+ t.removeEventListener("abort", n);
59
+ }
60
+ }
61
+ async function v(e, t) {
62
+ if (f(t), !t) return e.read();
63
+ let n, r = new Promise((e, r) => {
64
+ n = () => r(new DOMException("Storage operation was cancelled.", "AbortError")), t.addEventListener("abort", n, { once: !0 });
65
+ });
66
+ try {
67
+ return f(t), await Promise.race([e.read(), r]);
68
+ } finally {
69
+ t.removeEventListener("abort", n);
70
+ }
71
+ }
72
+ var y = class {
73
+ name = "local-filesystem";
74
+ root;
75
+ constructor(e) {
76
+ if (!e?.root || typeof e.root != "string") throw new u();
77
+ this.root = o.resolve(e.root);
78
+ }
79
+ initialized;
80
+ ready() {
81
+ let e = this.initialized ??= this.initialize().catch((t) => {
82
+ throw this.initialized === e && (this.initialized = void 0), t;
83
+ });
84
+ return e;
85
+ }
86
+ async initialize() {
87
+ let e = this.root;
88
+ for (;;) try {
89
+ if (await r(e) !== e) throw new u();
90
+ break;
91
+ } catch (t) {
92
+ if (!h(t)) throw t;
93
+ let n = o.dirname(e);
94
+ if (n === e) throw t;
95
+ e = n;
96
+ }
97
+ if (await t(this.root, {
98
+ recursive: !0,
99
+ mode: 448
100
+ }), await r(this.root) !== this.root) throw new u();
101
+ }
102
+ prefix(e) {
103
+ return p(e), s("sha256").update(e).digest("hex");
104
+ }
105
+ async own(e, t, n) {
106
+ let r = this.prefix(e);
107
+ f(t);
108
+ let i = this.root + "/" + r, a = d.get(i) ?? Promise.resolve(), o, s = new Promise((e) => {
109
+ o = e;
110
+ }), c = a.then(() => s);
111
+ d.set(i, c);
112
+ try {
113
+ await _(a, t), f(t);
114
+ let e = this.ready();
115
+ await e;
116
+ try {
117
+ return await n(r);
118
+ } catch (i) {
119
+ if (!h(i)) throw i;
120
+ return this.initialized === e && (this.initialized = void 0), f(t), await this.ready(), await n(r);
121
+ }
122
+ } catch (e) {
123
+ throw e?.name === "AbortError" || e instanceof u ? e : new u();
124
+ } finally {
125
+ o(), c.then(() => {
126
+ d.get(i) === c && d.delete(i);
127
+ });
128
+ }
129
+ }
130
+ async safeOpen(t, i, a) {
131
+ let s = o.join(this.root, t), c = await n(s, i | e.O_NOFOLLOW | e.O_NONBLOCK, a);
132
+ try {
133
+ let e = await c.stat();
134
+ if (await r(s) !== s || !e.isFile() || e.nlink !== 1) throw new u();
135
+ return c;
136
+ } catch (e) {
137
+ throw await c.close(), e;
138
+ }
139
+ }
140
+ async manifest(t, n) {
141
+ let r;
142
+ try {
143
+ r = await this.safeOpen(n + ".json", e.O_RDONLY);
144
+ } catch (e) {
145
+ if (h(e)) return null;
146
+ throw e;
147
+ }
148
+ try {
149
+ if ((await r.stat()).size > 16384) throw new u();
150
+ let e = JSON.parse(await r.readFile("utf8"));
151
+ if (e.key !== t || !RegExp(`^${n}\\.[a-f0-9-]{36}\\.blob$`).test(e.file) || !/^"[a-f0-9]{64}"$/.test(e.etag) || !Number.isSafeInteger(e.uploaded) || e.uploaded < 0) throw new u();
152
+ return m(e), e;
153
+ } finally {
154
+ await r.close();
155
+ }
156
+ }
157
+ async put(t, n, r) {
158
+ let l = m(r);
159
+ return this.own(t, r.signal, async (d) => {
160
+ let p = await this.manifest(t, d), m = c(), h = `${d}.${m}.blob`, _ = `${d}.${m}.json.tmp`, y, b, x, S = !1;
161
+ try {
162
+ y = await this.safeOpen(h, e.O_WRONLY | e.O_CREAT | e.O_EXCL, 384), x = n.getReader();
163
+ let c = s("sha256"), m = 0;
164
+ for (;;) {
165
+ let e = await v(x, r.signal);
166
+ if (e.done) break;
167
+ if (!(e.value instanceof Uint8Array) || m + e.value.byteLength > l.size) throw new u();
168
+ let t = 0;
169
+ for (; t < e.value.byteLength;) {
170
+ f(r.signal);
171
+ let n = await y.write(e.value, t, e.value.byteLength - t);
172
+ if (!n.bytesWritten) throw new u();
173
+ t += n.bytesWritten;
174
+ }
175
+ c.update(e.value), m += e.value.byteLength;
176
+ }
177
+ if (f(r.signal), m !== l.size) throw new u();
178
+ await y.sync(), await y.close(), y = void 0;
179
+ let C = {
180
+ key: t,
181
+ ...l,
182
+ etag: `"${c.digest("hex")}"`,
183
+ uploaded: Date.now(),
184
+ file: h
185
+ };
186
+ return b = await this.safeOpen(_, e.O_WRONLY | e.O_CREAT | e.O_EXCL, 384), await b.writeFile(JSON.stringify(C)), await b.sync(), await b.close(), b = void 0, f(r.signal), await i(o.join(this.root, _), o.join(this.root, d + ".json")), S = !0, p && await a(o.join(this.root, p.file)).catch(() => {}), g(C);
187
+ } finally {
188
+ x && (S || x.cancel(new DOMException("Storage operation was cancelled.", "AbortError")).catch(() => {}), x.releaseLock()), await y?.close(), await b?.close(), await a(o.join(this.root, _)).catch(() => {}), S || await a(o.join(this.root, h)).catch(() => {});
189
+ }
190
+ });
191
+ }
192
+ async head(e, t = {}) {
193
+ return this.own(e, t.signal, async (n) => {
194
+ let r = await this.manifest(e, n);
195
+ return f(t.signal), r ? g(r) : null;
196
+ });
197
+ }
198
+ async get(t, n = {}) {
199
+ return this.own(t, n.signal, async (r) => {
200
+ let i = await this.manifest(t, r);
201
+ if (!i) return null;
202
+ let a = await this.safeOpen(i.file, e.O_RDONLY);
203
+ try {
204
+ if ((await a.stat()).size !== i.size) throw new u();
205
+ } catch (e) {
206
+ throw await a.close(), e;
207
+ }
208
+ let o, s, c = () => (n.signal?.removeEventListener("abort", s), o ??= a.close()), l = new ReadableStream({
209
+ start(e) {
210
+ s = () => {
211
+ e.error(new DOMException("Storage operation was cancelled.", "AbortError")), c().catch(() => {});
212
+ }, n.signal?.addEventListener("abort", s, { once: !0 }), n.signal?.aborted && s();
213
+ },
214
+ async pull(e) {
215
+ try {
216
+ f(n.signal);
217
+ let t = new Uint8Array(64 * 1024), { bytesRead: r } = await a.read(t);
218
+ r ? e.enqueue(t.subarray(0, r)) : (await c(), e.close());
219
+ } catch {
220
+ await c(), e.error(n.signal?.aborted ? new DOMException("Storage operation was cancelled.", "AbortError") : new u());
221
+ }
222
+ },
223
+ async cancel() {
224
+ await c();
225
+ }
226
+ }, { highWaterMark: 0 });
227
+ return {
228
+ ...g(i),
229
+ body: l
230
+ };
231
+ });
232
+ }
233
+ async delete(e, t = {}) {
234
+ return this.own(e, t.signal, async (n) => {
235
+ let r = await this.manifest(e, n);
236
+ f(t.signal), r && (await a(o.join(this.root, n + ".json")), await a(o.join(this.root, r.file)).catch(() => {}));
237
+ });
238
+ }
239
+ };
240
+ //#endregion
241
+ export { u as LocalStorageError, y as LocalStorageProvider };
@@ -0,0 +1,32 @@
1
+ //#region ../core/dist/shared/transport-routes.js
2
+ var e = Object.freeze({
3
+ rpc: "/crpc",
4
+ upload: "/upload",
5
+ sse: "/sse/:componentRouteId",
6
+ websocket: "/ws/:id"
7
+ }), t = {
8
+ rpc: "RPC calls",
9
+ upload: "RPC calls with file uploads",
10
+ sse: "server-sent event streams",
11
+ websocket: "component WebSocket connections"
12
+ };
13
+ function n(n) {
14
+ let r = e[n], i = r.split("/"), a = i.findIndex((e) => e.startsWith(":") || e.includes("*"));
15
+ return a === -1 ? {
16
+ path: r,
17
+ match: "exact",
18
+ route: r,
19
+ purpose: t[n]
20
+ } : {
21
+ path: i.slice(0, a).join("/"),
22
+ match: "namespace",
23
+ route: r,
24
+ purpose: t[n]
25
+ };
26
+ }
27
+ var r = Object.freeze(Object.keys(e).map((e) => Object.freeze(n(e))));
28
+ function i(t, ...n) {
29
+ return (n.length ? r.filter((t) => n.some((n) => e[n] === t.route)) : r).some((e) => e.match === "exact" ? t === e.path : t.startsWith(`${e.path}/`));
30
+ }
31
+ //#endregion
32
+ export { i as t };
package/dist/vite.d.ts ADDED
@@ -0,0 +1,23 @@
1
+ import { type Plugin } from 'vite';
2
+ import type { NodeUpgradeServer } from './adapter.js';
3
+ /** Structural application entry; this tooling never imports the framework. */
4
+ export interface NodeDevelopmentEntry {
5
+ app: {
6
+ fetch(request: Request, env?: Record<string, unknown>): Response | Promise<Response>;
7
+ };
8
+ env?: Record<string, unknown>;
9
+ /** Build server bindings from Vite's environment files and process overrides. */
10
+ createEnv?(variables: Record<string, string | undefined>): Record<string, unknown> | Promise<Record<string, unknown>>;
11
+ runtime?: {
12
+ attach?(server: NodeUpgradeServer, fetch: (request: Request) => Response | Promise<Response>): () => void;
13
+ dispose(): void | Promise<void>;
14
+ };
15
+ }
16
+ export interface NodeDevelopmentOptions {
17
+ /** Vite server entry, relative to the project root. */
18
+ entry?: string;
19
+ /** Maximum time to wait for application cleanup when closing Vite. */
20
+ shutdownTimeoutMs?: number;
21
+ }
22
+ /** Serve generated Node applications through Vite's SSR environment. */
23
+ export declare function cossackNode(options?: NodeDevelopmentOptions): Plugin;
package/dist/vite.js ADDED
@@ -0,0 +1,128 @@
1
+ import { t as e } from "./transport-routes-CjDWcC93.js";
2
+ import { relative as t } from "node:path";
3
+ import { getRequestListener as n } from "@hono/node-server";
4
+ import { isRunnableDevEnvironment as r, loadEnv as i } from "vite";
5
+ import { EventEmitter as a } from "node:events";
6
+ //#region src/vite.ts
7
+ function o(e) {
8
+ if (r(e)) return !0;
9
+ let t = e.runner;
10
+ return typeof t?.import == "function" && typeof t.clearCache == "function" && typeof e.moduleGraph?.invalidateAll == "function";
11
+ }
12
+ function s(r = {}) {
13
+ let s = r.shutdownTimeoutMs ?? 5e3;
14
+ if (!Number.isFinite(s) || s <= 0) throw TypeError("shutdownTimeoutMs must be positive and finite");
15
+ let c, l;
16
+ return {
17
+ name: "cossack-node-development",
18
+ apply: "serve",
19
+ config: () => ({
20
+ appType: "custom",
21
+ environments: { ssr: { resolve: { noExternal: ["@cossackframework/node-adapter", "@cossackframework/core"] } } }
22
+ }),
23
+ configureServer(t) {
24
+ if (t.config.server.middlewareMode) return;
25
+ let u = t.environments.ssr;
26
+ if (!o(u)) throw Error("Cossack Node development requires a runnable Vite SSR environment");
27
+ let d = {
28
+ ...i(t.config.mode, t.config.envDir, ""),
29
+ ...process.env
30
+ }, f, p = !1, m = 0, h = !1, g, _ = /* @__PURE__ */ new Set(), v = /* @__PURE__ */ new Set(), y = /* @__PURE__ */ new WeakSet(), b = (e) => {
31
+ if (!e.runtime || y.has(e.runtime)) return;
32
+ y.add(e.runtime);
33
+ let n = Promise.resolve().then(() => e.runtime?.dispose()).then(() => {});
34
+ v.add(n), n.catch((e) => t.config.logger.error(`[cossack node] cleanup failed: ${e}`)).finally(() => v.delete(n));
35
+ }, x = () => {
36
+ f &&= (f.detach?.(), b(f.entry), void 0);
37
+ }, S = () => p ? Promise.reject(/* @__PURE__ */ Error("Cossack Node development server is closing")) : f ? Promise.resolve(f) : g ??= (async () => {
38
+ for (; !p;) {
39
+ let e = m;
40
+ h &&= (u.moduleGraph.invalidateAll(), u.runner.clearCache(), !1);
41
+ let t = await u.runner.import(r.entry ?? "/src/index.ts");
42
+ if (typeof t.app?.fetch != "function") throw b(t), TypeError("Cossack Node entry must export app.fetch");
43
+ let n;
44
+ try {
45
+ n = t.createEnv ? await t.createEnv(d) : t.env;
46
+ } catch (e) {
47
+ throw b(t), e;
48
+ }
49
+ if (p || e !== m) {
50
+ b(t);
51
+ continue;
52
+ }
53
+ let i = {
54
+ entry: t,
55
+ env: n,
56
+ upgrades: new a()
57
+ };
58
+ try {
59
+ i.detach = t.runtime?.attach?.(i.upgrades, (e) => t.app.fetch(e, n));
60
+ } catch (e) {
61
+ throw b(t), e;
62
+ }
63
+ return f = i, i;
64
+ }
65
+ throw Error("Cossack Node development server is closing");
66
+ })().catch((e) => {
67
+ throw h = !0, e;
68
+ }).finally(() => {
69
+ g = void 0;
70
+ });
71
+ l = () => (m++, h = !0, x(), S());
72
+ let C = (n, r, i) => {
73
+ if (!e(n.url?.split("?", 1)[0] ?? "", "websocket")) return;
74
+ _.add(r);
75
+ let a = () => _.delete(r);
76
+ r.once("close", a), r.on("error", () => r.destroy()), S().then((e) => {
77
+ p || r.destroyed || e.upgrades.emit("upgrade", n, r, i) || r.end("HTTP/1.1 503 Unavailable\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
78
+ }).catch((e) => {
79
+ t.config.logger.error(`[cossack node] upgrade failed: ${e}`), r.destroy();
80
+ }).finally(() => {
81
+ a(), r.off("close", a);
82
+ });
83
+ };
84
+ t.httpServer?.on("upgrade", C);
85
+ let w;
86
+ return c = () => w ??= (async () => {
87
+ p = !0, l = void 0, t.httpServer?.off("upgrade", C);
88
+ for (let e of _) e.destroy();
89
+ _.clear(), x();
90
+ let e = (async () => {
91
+ await g?.catch(() => {}), await Promise.allSettled([...v]);
92
+ })(), n;
93
+ try {
94
+ await Promise.race([e, new Promise((e) => {
95
+ n = setTimeout(() => {
96
+ t.config.logger.warn("[cossack node] application cleanup exceeded the shutdown deadline"), e();
97
+ }, s);
98
+ })]);
99
+ } finally {
100
+ clearTimeout(n);
101
+ }
102
+ })(), () => t.middlewares.use((e, t, r) => {
103
+ S().then(({ entry: r, env: i }) => n((e) => r.app.fetch(e, i))(e, t)).catch(r);
104
+ });
105
+ },
106
+ hotUpdate: {
107
+ order: "post",
108
+ async handler({ file: e, modules: n, read: r, type: i, server: a }) {
109
+ if (this.environment.name !== "ssr" || !l) return;
110
+ let o = t(a.config.root, e).replaceAll("\\", "/");
111
+ if (!(!n.length && !(o.startsWith("src/") && !o.startsWith("src/client/") && /\.[cm]?[jt]sx?$|\.mdx?$/.test(o)))) {
112
+ i !== "delete" && await r();
113
+ try {
114
+ await l();
115
+ } catch (e) {
116
+ a.config.logger.error(`[cossack node] reload failed: ${e}`);
117
+ }
118
+ return [];
119
+ }
120
+ }
121
+ },
122
+ async closeBundle() {
123
+ await c?.();
124
+ }
125
+ };
126
+ }
127
+ //#endregion
128
+ export { s as cossackNode };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cossackframework/node-adapter",
3
- "version": "0.8.3",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "description": "Node.js runtime adapter for the Cossack Framework",
6
6
  "license": "MIT",
@@ -16,32 +16,52 @@
16
16
  ".": {
17
17
  "import": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts"
19
+ },
20
+ "./vite": {
21
+ "types": "./dist/vite.d.ts",
22
+ "import": "./dist/vite.js"
23
+ },
24
+ "./notifications": {
25
+ "types": "./dist/notifications.d.ts",
26
+ "import": "./dist/notifications.js"
27
+ },
28
+ "./storage": {
29
+ "types": "./dist/storage.d.ts",
30
+ "import": "./dist/storage.js"
19
31
  }
20
32
  },
21
33
  "files": [
22
- "dist"
34
+ "dist",
35
+ "agent-docs.json"
23
36
  ],
24
37
  "publishConfig": {
25
38
  "access": "public"
26
39
  },
27
40
  "dependencies": {
28
- "nodemailer": "^10.0.6",
41
+ "@hono/node-server": "^2.1.6",
42
+ "nodemailer": "^10.4.0",
29
43
  "ws": ">=8.21.0",
30
- "@cossackframework/core": "0.8.3"
44
+ "@cossackframework/core": "0.9.1"
31
45
  },
32
46
  "devDependencies": {
33
47
  "@types/nodemailer": "^8.0.1",
34
48
  "@types/ws": "^8.18.0",
35
49
  "hono": "^4.13.7",
36
50
  "typescript": "^7.0.2",
37
- "vite": "^8.1.4",
38
- "vitest": "^4.1.11"
51
+ "vite": "^8.1.6",
52
+ "vitest": "^4.1.12"
39
53
  },
40
54
  "peerDependencies": {
41
- "hono": "^4.13.7"
55
+ "hono": "^4.13.7",
56
+ "vite": "^8.1.6"
57
+ },
58
+ "peerDependenciesMeta": {
59
+ "vite": {
60
+ "optional": true
61
+ }
42
62
  },
43
63
  "scripts": {
44
- "build": "vite build && tsc -p tsconfig.declarations.json",
64
+ "build": "vite build && tsc -p tsconfig.declarations.json && node ../../scripts/rewrite-declaration-imports.mjs dist",
45
65
  "test": "vitest --run"
46
66
  }
47
67
  }
package/dist/runtime.d.ts DELETED
@@ -1,6 +0,0 @@
1
- import { WebSocket } from 'ws';
2
- import { InMemoryWebSocketRuntime, type Cossack } from '@cossackframework/core';
3
- export declare class NodeWebSocketRuntime extends InMemoryWebSocketRuntime<WebSocket> {
4
- constructor(component: Cossack);
5
- addClient(ws: WebSocket, user?: unknown): void;
6
- }