@wolfstar/vite-server 0.2.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/LICENSE +201 -0
- package/README.md +33 -0
- package/dist/esm/context-VAAA2m2X.d.ts +44 -0
- package/dist/esm/context-VAAA2m2X.d.ts.map +1 -0
- package/dist/esm/index.d.ts +26 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +157 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/internal.d.ts +22 -0
- package/dist/esm/internal.d.ts.map +1 -0
- package/dist/esm/internal.js +3 -0
- package/dist/esm/logger-DbLG6z_o.js +263 -0
- package/dist/esm/logger-DbLG6z_o.js.map +1 -0
- package/package.json +83 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2022 Wolfstar Project
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# @wolfstar/vite-server
|
|
2
|
+
|
|
3
|
+
Vite build and watch integration for Stars projects.
|
|
4
|
+
|
|
5
|
+
The Stars CLI loads this integration on demand when `build.tool` resolves to `'vite'`. Existing `stars.config` options and the CLI commands are unchanged.
|
|
6
|
+
Install `vite` in the consuming project; the integration uses the project's own versions and Vite configuration.
|
|
7
|
+
|
|
8
|
+
## Programmatic usage
|
|
9
|
+
|
|
10
|
+
The package exports `ViteBuilder`. Pass a resolved `StarsConfig` and a `BuilderContext` from `@wolfstar/schema`:
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { ViteBuilder } from '@wolfstar/vite-server';
|
|
14
|
+
import type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';
|
|
15
|
+
|
|
16
|
+
export async function build(config: ResolvedStarsConfig, context: BuilderContext) {
|
|
17
|
+
const builder = new ViteBuilder(config, context);
|
|
18
|
+
try {
|
|
19
|
+
return await builder.build();
|
|
20
|
+
} finally {
|
|
21
|
+
await builder.close();
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The host supplies `importFromProject` (project-relative dependency loading with diagnostics) and
|
|
27
|
+
`pluginRegistrations` (the entry transform that activates installed plugins). This explicit boundary keeps the
|
|
28
|
+
integration independent of the CLI and framework runtimes. `watch()` and `close()` implement the shared builder
|
|
29
|
+
lifecycle; `start`, `success`, `failure`, and `log` events expose build status.
|
|
30
|
+
|
|
31
|
+
Vite builds the application and uses its build watcher for rebuilds. Process supervision remains the responsibility of the host CLI.
|
|
32
|
+
|
|
33
|
+
Integration coverage lives in `packages/cli/test/vite-builder.test.ts`, including real builds through the CLI host.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EventEmitter } from "node:events";
|
|
2
|
+
import { BuildOutcome, Builder, BuilderContext, BuilderEvents, ResolvedStarsConfig } from "@wolfstar/schema";
|
|
3
|
+
import { InlineConfig } from "vite";
|
|
4
|
+
//#region src/config.d.ts
|
|
5
|
+
type ViteModule = typeof import('vite');
|
|
6
|
+
interface ViteHooks {
|
|
7
|
+
configure?(options: InlineConfig, command: 'build' | 'serve'): void | Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/** Defaults are applied after Vite loads its config, so explicit project options win. */
|
|
10
|
+
declare function createViteConfig(config: ResolvedStarsConfig, context?: BuilderContext): InlineConfig;
|
|
11
|
+
declare function toArray<T>(value: T | T[] | undefined): T[];
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/lifecycle.d.ts
|
|
14
|
+
interface ServerHooks {
|
|
15
|
+
beforeBuild?(config: ResolvedStarsConfig): void | Promise<void>;
|
|
16
|
+
afterBuild?(outcome: BuildOutcome): void | Promise<void>;
|
|
17
|
+
close?(): void | Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
/** Shared lifecycle: coalesce concurrent builds, report failures and drain work before close. */
|
|
20
|
+
declare abstract class ServerBuilder extends EventEmitter<BuilderEvents> implements Builder {
|
|
21
|
+
#private;
|
|
22
|
+
protected readonly config: ResolvedStarsConfig;
|
|
23
|
+
protected readonly context: BuilderContext;
|
|
24
|
+
protected readonly hooks: ServerHooks;
|
|
25
|
+
readonly tool: 'vite';
|
|
26
|
+
protected closed: boolean;
|
|
27
|
+
protected active: Promise<BuildOutcome> | null;
|
|
28
|
+
protected watching: Promise<void> | null;
|
|
29
|
+
protected stopWatching: (() => Promise<void>) | null;
|
|
30
|
+
protected constructor(config: ResolvedStarsConfig, context?: BuilderContext, hooks?: ServerHooks);
|
|
31
|
+
build(): Promise<BuildOutcome>;
|
|
32
|
+
private runBuild;
|
|
33
|
+
protected abstract compile(): Promise<void>;
|
|
34
|
+
protected abstract startWatching(): Promise<void>;
|
|
35
|
+
watch(): Promise<void>;
|
|
36
|
+
close(): Promise<void>;
|
|
37
|
+
}
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/context.d.ts
|
|
40
|
+
/** Default host for standalone use. Dependencies always resolve from the application. */
|
|
41
|
+
declare const defaultBuilderContext: BuilderContext;
|
|
42
|
+
//#endregion
|
|
43
|
+
export { ViteModule as a, ViteHooks as i, ServerBuilder as n, createViteConfig as o, ServerHooks as r, toArray as s, defaultBuilderContext as t };
|
|
44
|
+
//# sourceMappingURL=context-VAAA2m2X.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-VAAA2m2X.d.ts","names":[],"sources":["../../src/config.ts","../../src/lifecycle.ts","../../src/context.ts"],"mappings":";;;;KAKY;UACK;EAChB,WAAW,SAAS,cAAc,oCAAoC;;;iBAIvD,iBAAiB,QAAQ,qBAAqB,UAAS,iBAAyC;iBAyBhG,QAAQ,GAAG,OAAO,IAAI,kBAAkB;;;UChCvC;EAChB,aAAa,QAAQ,6BAA6B;EAClD,YAAY,SAAS,sBAAsB;EAC3C,iBAAiB;;;uBAII,sBAAsB,aAAa,0BAA0B;;qBAQ9D,QAAQ;qBACR,SAAS;qBACT,OAAO;WATX;YACN;YACA,QAAQ,QAAQ;YAChB,UAAU;YACV,qBAAqB;YAEtB,YACW,QAAQ,qBACR,UAAS,gBACT,QAAO;EAIpB,SAAS,QAAQ;UAQV;qBAoBK,WAAW;qBACX,iBAAiB;EAC7B,SAAS;EAWT,SAAS;;;;;cC3DJ,uBAAuB"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { i as ViteHooks, n as ServerBuilder, o as createViteConfig, r as ServerHooks, t as defaultBuilderContext } from "./context-VAAA2m2X.js";
|
|
2
|
+
import { BuilderContext, ResolvedStarsConfig } from "@wolfstar/schema";
|
|
3
|
+
import { ViteDevServer } from "vite";
|
|
4
|
+
//#region src/build.d.ts
|
|
5
|
+
interface ViteBuilderHooks extends ServerHooks, ViteHooks {}
|
|
6
|
+
export declare class ViteBuilder extends ServerBuilder {
|
|
7
|
+
#private;
|
|
8
|
+
protected readonly hooks: ViteBuilderHooks;
|
|
9
|
+
constructor(config: ResolvedStarsConfig, context?: BuilderContext, hooks?: ViteBuilderHooks);
|
|
10
|
+
protected compile(): Promise<void>;
|
|
11
|
+
protected startWatching(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
//#region src/dev.d.ts
|
|
15
|
+
interface StarsViteServer {
|
|
16
|
+
readonly vite: ViteDevServer;
|
|
17
|
+
/** Dispatch through Vite's SSR graph; changed modules are reloaded by Vite. */
|
|
18
|
+
fetch(request: Request): Promise<Response>;
|
|
19
|
+
listen(port?: number): Promise<void>;
|
|
20
|
+
close(): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
/** A native Vite development server for an entry exporting a loaded Client (or any Fetch handler). */
|
|
23
|
+
export declare function createViteServer(config: ResolvedStarsConfig, context?: BuilderContext, hooks?: ViteHooks): Promise<StarsViteServer>;
|
|
24
|
+
//#endregion
|
|
25
|
+
export { type ServerHooks, type StarsViteServer, type ViteBuilderHooks, type ViteHooks, createViteConfig, defaultBuilderContext };
|
|
26
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/build.ts","../../src/dev.ts"],"mappings":";;;;UAMiB,yBAAyB,aAAa;qBAC1C,oBAAoB;;qBAIH,OAAO;EAHpC,YACC,QAAQ,qBACR,UAAU,gBACkB,QAAO;YAapB,WAAW;YAOX,iBAAiB;;;;UCxBjB;WACP,MAAM;;EAEf,MAAM,SAAS,UAAU,QAAQ;EACjC,OAAO,gBAAgB;EACvB,SAAS;;;wBAIY,iBACrB,QAAQ,qBACR,UAAS,gBACT,QAAO,YACL,QAAQ"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { a as createViteConfig, i as _checkPrivateRedeclaration, n as ServerBuilder, r as _assertClassBrand, s as defaultBuilderContext, t as createBuildLogger } from "./logger-DbLG6z_o.js";
|
|
2
|
+
import { toNodeHandler } from "srvx/node";
|
|
3
|
+
|
|
4
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
5
|
+
function _classPrivateMethodInitSpec(e, a) {
|
|
6
|
+
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/build.ts
|
|
11
|
+
var _ViteBuilder_brand = /* @__PURE__ */ new WeakSet();
|
|
12
|
+
var ViteBuilder = class extends ServerBuilder {
|
|
13
|
+
constructor(config, context, hooks = {}) {
|
|
14
|
+
super(config, context, hooks);
|
|
15
|
+
this.hooks = hooks;
|
|
16
|
+
_classPrivateMethodInitSpec(this, _ViteBuilder_brand);
|
|
17
|
+
}
|
|
18
|
+
async compile() {
|
|
19
|
+
const { vite, options } = await _assertClassBrand(_ViteBuilder_brand, this, _options).call(this);
|
|
20
|
+
options.build = {
|
|
21
|
+
...options.build,
|
|
22
|
+
watch: null
|
|
23
|
+
};
|
|
24
|
+
this.emit("progress", .2, "building server with Vite");
|
|
25
|
+
await vite.build(options);
|
|
26
|
+
}
|
|
27
|
+
async startWatching() {
|
|
28
|
+
const { vite, options } = await _assertClassBrand(_ViteBuilder_brand, this, _options).call(this);
|
|
29
|
+
if (this.closed) return;
|
|
30
|
+
options.plugins ??= [];
|
|
31
|
+
options.plugins.push({
|
|
32
|
+
name: "stars:watch-hooks",
|
|
33
|
+
buildStart: () => this.hooks.beforeBuild?.(this.config)
|
|
34
|
+
});
|
|
35
|
+
let started = performance.now();
|
|
36
|
+
let queue = Promise.resolve();
|
|
37
|
+
const watcher = await vite.build({
|
|
38
|
+
...options,
|
|
39
|
+
build: {
|
|
40
|
+
...options.build,
|
|
41
|
+
watch: options.build?.watch ?? {}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
this.stopWatching = async () => {
|
|
45
|
+
await watcher.close();
|
|
46
|
+
await queue;
|
|
47
|
+
};
|
|
48
|
+
watcher.on("event", (event) => {
|
|
49
|
+
if (this.closed) return;
|
|
50
|
+
if (event.code === "START") {
|
|
51
|
+
started = performance.now();
|
|
52
|
+
this.emit("start");
|
|
53
|
+
}
|
|
54
|
+
if (event.code === "BUNDLE_END") event.result.close().catch((error) => this.emit("log", "error", String(error)));
|
|
55
|
+
if (event.code !== "END" && event.code !== "ERROR") return;
|
|
56
|
+
const outcome = {
|
|
57
|
+
ok: event.code === "END",
|
|
58
|
+
durationMs: Math.round(performance.now() - started),
|
|
59
|
+
message: event.code === "ERROR" ? event.error.message : null
|
|
60
|
+
};
|
|
61
|
+
queue = queue.then(async () => {
|
|
62
|
+
try {
|
|
63
|
+
await this.hooks.afterBuild?.(outcome);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
outcome.ok = false;
|
|
66
|
+
outcome.message = String(error);
|
|
67
|
+
}
|
|
68
|
+
if (!this.closed) this.emit(outcome.ok ? "success" : "failure", outcome);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
async function _options(command = "build") {
|
|
74
|
+
const vite = await this.context.importFromProject(this.config.root, "vite", "Install it with `pnpm add -D vite`.");
|
|
75
|
+
const options = createViteConfig(this.config, this.context);
|
|
76
|
+
options.customLogger = createBuildLogger(vite, (level, text) => {
|
|
77
|
+
this.emit("log", level, text);
|
|
78
|
+
});
|
|
79
|
+
await this.hooks.configure?.(options, command);
|
|
80
|
+
return {
|
|
81
|
+
vite,
|
|
82
|
+
options
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/dev.ts
|
|
88
|
+
/** A native Vite development server for an entry exporting a loaded Client (or any Fetch handler). */
|
|
89
|
+
async function createViteServer(config, context = defaultBuilderContext, hooks = {}) {
|
|
90
|
+
const viteModule = await context.importFromProject(config.root, "vite", "Install it with `pnpm add -D vite`.");
|
|
91
|
+
const options = createViteConfig(config, context);
|
|
92
|
+
const url = new URL(config.dev.url ?? "http://localhost:3000");
|
|
93
|
+
options.appType = "custom";
|
|
94
|
+
options.mode ??= "development";
|
|
95
|
+
options.server = {
|
|
96
|
+
host: url.hostname,
|
|
97
|
+
port: Number(url.port || 3e3),
|
|
98
|
+
...options.server
|
|
99
|
+
};
|
|
100
|
+
await hooks.configure?.(options, "serve");
|
|
101
|
+
let vite;
|
|
102
|
+
let closed = false;
|
|
103
|
+
let closing;
|
|
104
|
+
const pending = /* @__PURE__ */ new Set();
|
|
105
|
+
const fetchRequest = async (request) => {
|
|
106
|
+
if (closed) return new Response("Server closed", { status: 503 });
|
|
107
|
+
try {
|
|
108
|
+
const app = (await vite.ssrLoadModule(config.entry)).default;
|
|
109
|
+
if (typeof app?.fetch !== "function") throw new TypeError("The Stars server entry must default-export an object with fetch(request). Use client.load(), not client.listen().");
|
|
110
|
+
return await app.fetch(request);
|
|
111
|
+
} catch (error) {
|
|
112
|
+
if (error instanceof Error) vite.ssrFixStacktrace(error);
|
|
113
|
+
vite.config.logger.error(error instanceof Error ? error.stack ?? error.message : String(error));
|
|
114
|
+
return new Response("Internal Server Error", { status: 500 });
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const fetch = (request) => {
|
|
118
|
+
const task = fetchRequest(request);
|
|
119
|
+
pending.add(task);
|
|
120
|
+
task.then(() => pending.delete(task), () => pending.delete(task));
|
|
121
|
+
return task;
|
|
122
|
+
};
|
|
123
|
+
options.plugins ??= [];
|
|
124
|
+
const nodeHandler = toNodeHandler(fetch);
|
|
125
|
+
options.plugins.push({
|
|
126
|
+
name: "stars:fetch-server",
|
|
127
|
+
configureServer(server) {
|
|
128
|
+
vite = server;
|
|
129
|
+
return () => {
|
|
130
|
+
server.middlewares.use((req, res, next) => {
|
|
131
|
+
Promise.resolve(nodeHandler(req, res)).catch(next);
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
vite = await viteModule.createServer(options);
|
|
137
|
+
return {
|
|
138
|
+
vite,
|
|
139
|
+
fetch,
|
|
140
|
+
async listen(port) {
|
|
141
|
+
if (closed) throw new Error("The server is closed.");
|
|
142
|
+
await vite.listen(port);
|
|
143
|
+
},
|
|
144
|
+
close() {
|
|
145
|
+
closed = true;
|
|
146
|
+
closing ??= (async () => {
|
|
147
|
+
await Promise.allSettled(pending);
|
|
148
|
+
await vite.close();
|
|
149
|
+
})();
|
|
150
|
+
return closing;
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
//#endregion
|
|
156
|
+
export { ViteBuilder, createViteConfig, createViteServer, defaultBuilderContext };
|
|
157
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/build.ts","../../src/dev.ts"],"sourcesContent":["import type { BuilderContext, BuildOutcome, ResolvedStarsConfig } from '@wolfstar/schema';\ntype ViteWatcher = Extract<Awaited<ReturnType<ViteModule['build']>>, { on: unknown }>;\nimport { createViteConfig, type ViteHooks, type ViteModule } from './config.js';\nimport { ServerBuilder, type ServerHooks } from './lifecycle.js';\nimport { createBuildLogger } from './logger.js';\n\nexport interface ViteBuilderHooks extends ServerHooks, ViteHooks {}\nexport class ViteBuilder extends ServerBuilder {\n\tpublic constructor(\n\t\tconfig: ResolvedStarsConfig,\n\t\tcontext?: BuilderContext,\n\t\tprotected override readonly hooks: ViteBuilderHooks = {}\n\t) {\n\t\tsuper(config, context, hooks);\n\t}\n\tasync #options(command: 'build' | 'serve' = 'build') {\n\t\tconst vite = await this.context.importFromProject<ViteModule>(this.config.root, 'vite', 'Install it with `pnpm add -D vite`.');\n\t\tconst options = createViteConfig(this.config, this.context);\n\t\toptions.customLogger = createBuildLogger(vite, (level, text) => {\n\t\t\tthis.emit('log', level, text);\n\t\t});\n\t\tawait this.hooks.configure?.(options, command);\n\t\treturn { vite, options };\n\t}\n\tprotected async compile(): Promise<void> {\n\t\tconst { vite, options } = await this.#options();\n\t\t// A one-shot build must not accidentally create a persistent watcher.\n\t\toptions.build = { ...options.build, watch: null };\n\t\tthis.emit('progress', 0.2, 'building server with Vite');\n\t\tawait vite.build(options);\n\t}\n\tprotected async startWatching(): Promise<void> {\n\t\tconst { vite, options } = await this.#options();\n\t\tif (this.closed) return;\n\t\toptions.plugins ??= [];\n\t\toptions.plugins.push({ name: 'stars:watch-hooks', buildStart: () => this.hooks.beforeBuild?.(this.config) });\n\t\tlet started = performance.now();\n\t\tlet queue = Promise.resolve();\n\t\tconst watcher = (await vite.build({ ...options, build: { ...options.build, watch: options.build?.watch ?? {} } })) as ViteWatcher;\n\t\tthis.stopWatching = async () => {\n\t\t\tawait watcher.close();\n\t\t\tawait queue;\n\t\t};\n\t\twatcher.on('event', (event) => {\n\t\t\tif (this.closed) return;\n\t\t\tif (event.code === 'START') {\n\t\t\t\tstarted = performance.now();\n\t\t\t\tthis.emit('start');\n\t\t\t}\n\t\t\tif (event.code === 'BUNDLE_END') void event.result.close().catch((error) => this.emit('log', 'error', String(error)));\n\t\t\tif (event.code !== 'END' && event.code !== 'ERROR') return;\n\t\t\tconst outcome: BuildOutcome = {\n\t\t\t\tok: event.code === 'END',\n\t\t\t\tdurationMs: Math.round(performance.now() - started),\n\t\t\t\tmessage: event.code === 'ERROR' ? event.error.message : null\n\t\t\t};\n\t\t\tqueue = queue.then(async () => {\n\t\t\t\ttry {\n\t\t\t\t\tawait this.hooks.afterBuild?.(outcome);\n\t\t\t\t} catch (error) {\n\t\t\t\t\toutcome.ok = false;\n\t\t\t\t\toutcome.message = String(error);\n\t\t\t\t}\n\t\t\t\tif (!this.closed) this.emit(outcome.ok ? 'success' : 'failure', outcome);\n\t\t\t});\n\t\t});\n\t}\n}\n","import type { IncomingMessage, ServerResponse } from 'node:http';\nimport type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { ViteDevServer } from 'vite';\nimport { toNodeHandler } from 'srvx/node';\nimport { createViteConfig, type ViteHooks, type ViteModule } from './config.js';\nimport { defaultBuilderContext } from './context.js';\n\nexport interface StarsViteServer {\n\treadonly vite: ViteDevServer;\n\t/** Dispatch through Vite's SSR graph; changed modules are reloaded by Vite. */\n\tfetch(request: Request): Promise<Response>;\n\tlisten(port?: number): Promise<void>;\n\tclose(): Promise<void>;\n}\n\n/** A native Vite development server for an entry exporting a loaded Client (or any Fetch handler). */\nexport async function createViteServer(\n\tconfig: ResolvedStarsConfig,\n\tcontext: BuilderContext = defaultBuilderContext,\n\thooks: ViteHooks = {}\n): Promise<StarsViteServer> {\n\tconst viteModule = await context.importFromProject<ViteModule>(config.root, 'vite', 'Install it with `pnpm add -D vite`.');\n\tconst options = createViteConfig(config, context);\n\tconst url = new URL(config.dev.url ?? 'http://localhost:3000');\n\toptions.appType = 'custom';\n\toptions.mode ??= 'development';\n\toptions.server = { host: url.hostname, port: Number(url.port || 3000), ...options.server };\n\tawait hooks.configure?.(options, 'serve');\n\tlet vite: ViteDevServer;\n\tlet closed = false;\n\tlet closing: Promise<void> | undefined;\n\tconst pending = new Set<Promise<Response>>();\n\tconst fetchRequest = async (request: Request): Promise<Response> => {\n\t\tif (closed) return new Response('Server closed', { status: 503 });\n\t\ttry {\n\t\t\tconst entry = await vite.ssrLoadModule(config.entry);\n\t\t\tconst app = entry.default as { fetch?: (request: Request) => Response | Promise<Response> } | undefined;\n\t\t\tif (typeof app?.fetch !== 'function')\n\t\t\t\tthrow new TypeError(\n\t\t\t\t\t'The Stars server entry must default-export an object with fetch(request). Use client.load(), not client.listen().'\n\t\t\t\t);\n\t\t\treturn await app.fetch(request);\n\t\t} catch (error) {\n\t\t\tif (error instanceof Error) vite.ssrFixStacktrace(error);\n\t\t\tvite.config.logger.error(error instanceof Error ? (error.stack ?? error.message) : String(error));\n\t\t\treturn new Response('Internal Server Error', { status: 500 });\n\t\t}\n\t};\n\tconst fetch = (request: Request): Promise<Response> => {\n\t\tconst task = fetchRequest(request);\n\t\tpending.add(task);\n\t\tvoid task.then(\n\t\t\t() => pending.delete(task),\n\t\t\t() => pending.delete(task)\n\t\t);\n\t\treturn task;\n\t};\n\toptions.plugins ??= [];\n\t// Vite's dev server only ever runs over plain HTTP/1, so the HTTP/2 branch of srvx's\n\t// NodeHttpHandler union is unreachable here; narrow to keep Connect's HandleFunction happy.\n\tconst nodeHandler = toNodeHandler(fetch) as (req: IncomingMessage, res: ServerResponse) => void | Promise<void>;\n\t// configureServer runs before createServer resolves.\n\toptions.plugins.push({\n\t\tname: 'stars:fetch-server',\n\t\tconfigureServer(server) {\n\t\t\tvite = server;\n\t\t\treturn () => {\n\t\t\t\tserver.middlewares.use((req, res, next) => {\n\t\t\t\t\tvoid Promise.resolve(nodeHandler(req, res)).catch(next);\n\t\t\t\t});\n\t\t\t};\n\t\t}\n\t});\n\tvite = await viteModule.createServer(options);\n\treturn {\n\t\tvite,\n\t\tfetch,\n\t\tasync listen(port) {\n\t\t\tif (closed) throw new Error('The server is closed.');\n\t\t\tawait vite.listen(port);\n\t\t},\n\t\tclose() {\n\t\t\tclosed = true;\n\t\t\tclosing ??= (async () => {\n\t\t\t\tawait Promise.allSettled(pending);\n\t\t\t\tawait vite.close();\n\t\t\t})();\n\t\t\treturn closing;\n\t\t}\n\t};\n}\n"],"mappings":";;;;;;;;;;;AAOA,IAAa,cAAb,cAAiC,cAAc;CAC9C,AAAO,YACN,QACA,SACA,AAA4B,QAA0B,CAAC,GACtD;EACD,MAAM,QAAQ,SAAS,KAAK;EAFA;;CAG7B;CAUA,MAAgB,UAAyB;EACxC,MAAM,EAAE,MAAM,YAAY,4CAAM,yBAAc;EAE9C,QAAQ,QAAQ;GAAE,GAAG,QAAQ;GAAO,OAAO;EAAK;EAChD,KAAK,KAAK,YAAY,IAAK,2BAA2B;EACtD,MAAM,KAAK,MAAM,OAAO;CACzB;CACA,MAAgB,gBAA+B;EAC9C,MAAM,EAAE,MAAM,YAAY,4CAAM,yBAAc;EAC9C,IAAI,KAAK,QAAQ;EACjB,QAAQ,YAAY,CAAC;EACrB,QAAQ,QAAQ,KAAK;GAAE,MAAM;GAAqB,kBAAkB,KAAK,MAAM,cAAc,KAAK,MAAM;EAAE,CAAC;EAC3G,IAAI,UAAU,YAAY,IAAI;EAC9B,IAAI,QAAQ,QAAQ,QAAQ;EAC5B,MAAM,UAAW,MAAM,KAAK,MAAM;GAAE,GAAG;GAAS,OAAO;IAAE,GAAG,QAAQ;IAAO,OAAO,QAAQ,OAAO,SAAS,CAAC;GAAE;EAAE,CAAC;EAChH,KAAK,eAAe,YAAY;GAC/B,MAAM,QAAQ,MAAM;GACpB,MAAM;EACP;EACA,QAAQ,GAAG,UAAU,UAAU;GAC9B,IAAI,KAAK,QAAQ;GACjB,IAAI,MAAM,SAAS,SAAS;IAC3B,UAAU,YAAY,IAAI;IAC1B,KAAK,KA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AI,MAAM,uBAAuB;GACnD,MAAM,KAAK,OAAO,IAAI;EACvB;EACA,QAAQ;GACP,SAAS;GACT,aAAa,YAAY;IACxB,MAAM,QAAQ,WAAW,OAAO;IAChC,MAAM,KAAK,MAAM;GAClB,EAAC,CAAE;GACH,OAAO;EACR;CACD;AACD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { a as ViteModule, i as ViteHooks, n as ServerBuilder, r as ServerHooks, s as toArray, t as defaultBuilderContext } from "./context-VAAA2m2X.js";
|
|
2
|
+
import { BuilderLogLevel, ResolvedStarsConfig } from "@wolfstar/schema";
|
|
3
|
+
//#region src/plugins.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Activates installed WolfStar plugins without making applications maintain a list
|
|
6
|
+
* of side-effect-only plugin registration imports in their entry point.
|
|
7
|
+
*/
|
|
8
|
+
export declare function pluginRegistrations(config: ResolvedStarsConfig): object;
|
|
9
|
+
//#endregion
|
|
10
|
+
//#region src/logger.d.ts
|
|
11
|
+
export declare function createBuildLogger(vite: ViteModule, log: (level: BuilderLogLevel, text: string) => void): {
|
|
12
|
+
clearScreen(type: import("vite").LogType): void;
|
|
13
|
+
hasErrorLogged(error: Error | import("rolldown").RolldownError): boolean;
|
|
14
|
+
hasWarned: boolean;
|
|
15
|
+
info: (text: string) => void;
|
|
16
|
+
warn: (text: string) => void;
|
|
17
|
+
warnOnce(text: string): void;
|
|
18
|
+
error: (text: string) => void;
|
|
19
|
+
};
|
|
20
|
+
//#endregion
|
|
21
|
+
export { ServerBuilder, type ServerHooks, type ViteHooks, type ViteModule, defaultBuilderContext, toArray };
|
|
22
|
+
//# sourceMappingURL=internal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"internal.d.ts","names":[],"sources":["../../src/plugins.ts","../../src/logger.ts"],"mappings":";;;;;;;wBAegB,oBAAoB,QAAQ;;;wBCb5B,kBAAkB,MAAM,YAAY,MAAM,OAAO,iBAAiB;;;;EAKnE,OAAA;EACA,OAAA;EACE,SAAA;EAMD,QAAA"}
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import { basename, join, resolve } from "node:path";
|
|
3
|
+
import { pathToFileURL } from "node:url";
|
|
4
|
+
import { readFileSync } from "node:fs";
|
|
5
|
+
import { EventEmitter } from "node:events";
|
|
6
|
+
|
|
7
|
+
//#region src/plugins.ts
|
|
8
|
+
const PLUGIN_PACKAGE = /^@wolfstar\/plugin-[^/]+$/;
|
|
9
|
+
/**
|
|
10
|
+
* Activates installed WolfStar plugins without making applications maintain a list
|
|
11
|
+
* of side-effect-only plugin registration imports in their entry point.
|
|
12
|
+
*/
|
|
13
|
+
function pluginRegistrations(config) {
|
|
14
|
+
const plugins = findPluginDependencies(config.root);
|
|
15
|
+
const entry = resolve(config.entry);
|
|
16
|
+
return {
|
|
17
|
+
name: "stars:plugin-registrations",
|
|
18
|
+
transform(code, id) {
|
|
19
|
+
if (plugins.length === 0 || cleanId(id) !== entry) return null;
|
|
20
|
+
return {
|
|
21
|
+
code: `${plugins.map((name) => `import ${JSON.stringify(`${name}/register`)};`).join("\n")}\n${code}`,
|
|
22
|
+
map: null
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
function findPluginDependencies(root) {
|
|
28
|
+
const packageJson = JSON.parse(readFileSync(join(root, "package.json"), "utf8"));
|
|
29
|
+
return [.../* @__PURE__ */ new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.optionalDependencies ?? {})])].filter((name) => PLUGIN_PACKAGE.test(name)).sort();
|
|
30
|
+
}
|
|
31
|
+
function cleanId(id) {
|
|
32
|
+
return resolve(id.replace(/^\0/, "").split("?", 1)[0]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
//#endregion
|
|
36
|
+
//#region src/context.ts
|
|
37
|
+
/** Default host for standalone use. Dependencies always resolve from the application. */
|
|
38
|
+
const defaultBuilderContext = {
|
|
39
|
+
pluginRegistrations,
|
|
40
|
+
async importFromProject(root, id, hint) {
|
|
41
|
+
let entry;
|
|
42
|
+
try {
|
|
43
|
+
entry = createRequire(join(root, "package.json")).resolve(id);
|
|
44
|
+
} catch (cause) {
|
|
45
|
+
throw new Error(`Cannot resolve ${id} from ${root}. ${hint}`, { cause });
|
|
46
|
+
}
|
|
47
|
+
return await import(pathToFileURL(entry).href);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/config.ts
|
|
53
|
+
/** Defaults are applied after Vite loads its config, so explicit project options win. */
|
|
54
|
+
function createViteConfig(config, context = defaultBuilderContext) {
|
|
55
|
+
const defaults = {
|
|
56
|
+
name: "stars:server-defaults",
|
|
57
|
+
enforce: "pre",
|
|
58
|
+
config(options) {
|
|
59
|
+
options.build ??= {};
|
|
60
|
+
options.build.ssr ??= config.entry;
|
|
61
|
+
options.build.outDir ??= config.build.outDir;
|
|
62
|
+
options.build.sourcemap ??= true;
|
|
63
|
+
options.build.rollupOptions ??= {};
|
|
64
|
+
const output = options.build.rollupOptions.output;
|
|
65
|
+
if (!Array.isArray(output)) options.build.rollupOptions.output = {
|
|
66
|
+
entryFileNames: basename(config.build.output),
|
|
67
|
+
...output
|
|
68
|
+
};
|
|
69
|
+
options.resolve ??= {};
|
|
70
|
+
options.resolve.tsconfigPaths ??= true;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
const inline = config.vite;
|
|
74
|
+
return {
|
|
75
|
+
...inline,
|
|
76
|
+
root: config.root,
|
|
77
|
+
configFile: config.build.configFile ?? false,
|
|
78
|
+
plugins: [
|
|
79
|
+
defaults,
|
|
80
|
+
context.pluginRegistrations(config),
|
|
81
|
+
...toArray(inline.plugins)
|
|
82
|
+
]
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function toArray(value) {
|
|
86
|
+
return value === void 0 ? [] : Array.isArray(value) ? value : [value];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/typeof.js
|
|
91
|
+
function _typeof(o) {
|
|
92
|
+
"@babel/helpers - typeof";
|
|
93
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
94
|
+
return typeof o;
|
|
95
|
+
} : function(o) {
|
|
96
|
+
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
97
|
+
}, _typeof(o);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/toPrimitive.js
|
|
102
|
+
function toPrimitive(t, r) {
|
|
103
|
+
if ("object" != _typeof(t) || !t) return t;
|
|
104
|
+
var e = t[Symbol.toPrimitive];
|
|
105
|
+
if (void 0 !== e) {
|
|
106
|
+
var i = e.call(t, r || "default");
|
|
107
|
+
if ("object" != _typeof(i)) return i;
|
|
108
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
109
|
+
}
|
|
110
|
+
return ("string" === r ? String : Number)(t);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
//#endregion
|
|
114
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/toPropertyKey.js
|
|
115
|
+
function toPropertyKey(t) {
|
|
116
|
+
var i = toPrimitive(t, "string");
|
|
117
|
+
return "symbol" == _typeof(i) ? i : i + "";
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/defineProperty.js
|
|
122
|
+
function _defineProperty(e, r, t) {
|
|
123
|
+
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
124
|
+
value: t,
|
|
125
|
+
enumerable: !0,
|
|
126
|
+
configurable: !0,
|
|
127
|
+
writable: !0
|
|
128
|
+
}) : e[r] = t, e;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
//#endregion
|
|
132
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/checkPrivateRedeclaration.js
|
|
133
|
+
function _checkPrivateRedeclaration(e, t) {
|
|
134
|
+
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
//#endregion
|
|
138
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
139
|
+
function _classPrivateFieldInitSpec(e, t, a) {
|
|
140
|
+
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/assertClassBrand.js
|
|
145
|
+
function _assertClassBrand(e, t, n) {
|
|
146
|
+
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
147
|
+
throw new TypeError("Private element is not present on this object");
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
//#endregion
|
|
151
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/classPrivateFieldGet2.js
|
|
152
|
+
function _classPrivateFieldGet2(s, a) {
|
|
153
|
+
return s.get(_assertClassBrand(s, a));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
//#endregion
|
|
157
|
+
//#region \0@oxc-project+runtime@0.150.0/helpers/esm/classPrivateFieldSet2.js
|
|
158
|
+
function _classPrivateFieldSet2(s, a, r) {
|
|
159
|
+
return s.set(_assertClassBrand(s, a), r), r;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
163
|
+
//#region src/lifecycle.ts
|
|
164
|
+
var _closing = /* @__PURE__ */ new WeakMap();
|
|
165
|
+
/** Shared lifecycle: coalesce concurrent builds, report failures and drain work before close. */
|
|
166
|
+
var ServerBuilder = class extends EventEmitter {
|
|
167
|
+
constructor(config, context = defaultBuilderContext, hooks = {}) {
|
|
168
|
+
super();
|
|
169
|
+
this.config = config;
|
|
170
|
+
this.context = context;
|
|
171
|
+
this.hooks = hooks;
|
|
172
|
+
_defineProperty(this, "tool", "vite");
|
|
173
|
+
_defineProperty(this, "closed", false);
|
|
174
|
+
_defineProperty(this, "active", null);
|
|
175
|
+
_defineProperty(this, "watching", null);
|
|
176
|
+
_defineProperty(this, "stopWatching", null);
|
|
177
|
+
_classPrivateFieldInitSpec(this, _closing, null);
|
|
178
|
+
}
|
|
179
|
+
build() {
|
|
180
|
+
if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("The server builder is closed. Create a new builder to restart."));
|
|
181
|
+
if (this.active) return this.active;
|
|
182
|
+
this.active = this.runBuild().finally(() => {
|
|
183
|
+
this.active = null;
|
|
184
|
+
});
|
|
185
|
+
return this.active;
|
|
186
|
+
}
|
|
187
|
+
async runBuild() {
|
|
188
|
+
const started = performance.now();
|
|
189
|
+
this.emit("start");
|
|
190
|
+
let message = null;
|
|
191
|
+
try {
|
|
192
|
+
await this.hooks.beforeBuild?.(this.config);
|
|
193
|
+
await this.compile();
|
|
194
|
+
} catch (error) {
|
|
195
|
+
message = error instanceof Error ? error.message : String(error);
|
|
196
|
+
}
|
|
197
|
+
const outcome = {
|
|
198
|
+
ok: message === null,
|
|
199
|
+
durationMs: Math.round(performance.now() - started),
|
|
200
|
+
message
|
|
201
|
+
};
|
|
202
|
+
try {
|
|
203
|
+
await this.hooks.afterBuild?.(outcome);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
outcome.ok = false;
|
|
206
|
+
outcome.message = error instanceof Error ? error.message : String(error);
|
|
207
|
+
}
|
|
208
|
+
if (!this.closed) this.emit(outcome.ok ? "success" : "failure", outcome);
|
|
209
|
+
return outcome;
|
|
210
|
+
}
|
|
211
|
+
watch() {
|
|
212
|
+
if (this.closed) return Promise.reject(/* @__PURE__ */ new Error("The server builder is closed."));
|
|
213
|
+
this.watching ??= this.startWatching().catch(async (error) => {
|
|
214
|
+
const stop = this.stopWatching;
|
|
215
|
+
this.stopWatching = null;
|
|
216
|
+
await stop?.();
|
|
217
|
+
this.watching = null;
|
|
218
|
+
throw error;
|
|
219
|
+
});
|
|
220
|
+
return this.watching;
|
|
221
|
+
}
|
|
222
|
+
close() {
|
|
223
|
+
this.closed = true;
|
|
224
|
+
_classPrivateFieldGet2(_closing, this) ?? _classPrivateFieldSet2(_closing, this, (async () => {
|
|
225
|
+
try {
|
|
226
|
+
await this.watching?.catch(() => {});
|
|
227
|
+
const stop = this.stopWatching;
|
|
228
|
+
this.stopWatching = null;
|
|
229
|
+
try {
|
|
230
|
+
await stop?.();
|
|
231
|
+
} finally {
|
|
232
|
+
await this.active;
|
|
233
|
+
}
|
|
234
|
+
} finally {
|
|
235
|
+
await this.hooks.close?.();
|
|
236
|
+
}
|
|
237
|
+
})());
|
|
238
|
+
return _classPrivateFieldGet2(_closing, this);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region src/logger.ts
|
|
244
|
+
function createBuildLogger(vite, log) {
|
|
245
|
+
const logger = vite.createLogger("warn", { allowClearScreen: false });
|
|
246
|
+
const warned = /* @__PURE__ */ new Set();
|
|
247
|
+
return {
|
|
248
|
+
...logger,
|
|
249
|
+
info: (text) => log("info", text),
|
|
250
|
+
warn: (text) => log("warn", text),
|
|
251
|
+
warnOnce(text) {
|
|
252
|
+
if (!warned.has(text)) {
|
|
253
|
+
warned.add(text);
|
|
254
|
+
log("warn", text);
|
|
255
|
+
}
|
|
256
|
+
},
|
|
257
|
+
error: (text) => log("error", text)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
export { createViteConfig as a, pluginRegistrations as c, _checkPrivateRedeclaration as i, ServerBuilder as n, toArray as o, _assertClassBrand as r, defaultBuilderContext as s, createBuildLogger as t };
|
|
263
|
+
//# sourceMappingURL=logger-DbLG6z_o.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-DbLG6z_o.js","names":[],"sources":["../../src/plugins.ts","../../src/context.ts","../../src/config.ts","../../src/lifecycle.ts","../../src/logger.ts"],"sourcesContent":["import { readFileSync } from 'node:fs';\nimport { join, resolve } from 'node:path';\nimport type { ResolvedStarsConfig } from '@wolfstar/schema';\n\ninterface PackageJson {\n\tdependencies?: Record<string, string>;\n\toptionalDependencies?: Record<string, string>;\n}\n\nconst PLUGIN_PACKAGE = /^@wolfstar\\/plugin-[^/]+$/;\n\n/**\n * Activates installed WolfStar plugins without making applications maintain a list\n * of side-effect-only plugin registration imports in their entry point.\n */\nexport function pluginRegistrations(config: ResolvedStarsConfig): object {\n\tconst plugins = findPluginDependencies(config.root);\n\tconst entry = resolve(config.entry);\n\n\treturn {\n\t\tname: 'stars:plugin-registrations',\n\t\ttransform(code: string, id: string) {\n\t\t\tif (plugins.length === 0 || cleanId(id) !== entry) return null;\n\n\t\t\tconst registrations = plugins.map((name) => `import ${JSON.stringify(`${name}/register`)};`).join('\\n');\n\t\t\treturn { code: `${registrations}\\n${code}`, map: null };\n\t\t}\n\t};\n}\n\nfunction findPluginDependencies(root: string): string[] {\n\tconst packageJson = JSON.parse(readFileSync(join(root, 'package.json'), 'utf8')) as PackageJson;\n\treturn [...new Set([...Object.keys(packageJson.dependencies ?? {}), ...Object.keys(packageJson.optionalDependencies ?? {})])]\n\t\t.filter((name) => PLUGIN_PACKAGE.test(name))\n\t\t.sort();\n}\n\nfunction cleanId(id: string): string {\n\treturn resolve(id.replace(/^\\0/, '').split('?', 1)[0]!);\n}\n","import { createRequire } from 'node:module';\nimport { join } from 'node:path';\nimport { pathToFileURL } from 'node:url';\nimport type { BuilderContext } from '@wolfstar/schema';\nimport { pluginRegistrations } from './plugins.js';\n\n/** Default host for standalone use. Dependencies always resolve from the application. */\nexport const defaultBuilderContext: BuilderContext = {\n\tpluginRegistrations,\n\tasync importFromProject<T>(root: string, id: string, hint: string): Promise<T> {\n\t\tlet entry: string;\n\t\ttry {\n\t\t\tentry = createRequire(join(root, 'package.json')).resolve(id);\n\t\t} catch (cause) {\n\t\t\tthrow new Error(`Cannot resolve ${id} from ${root}. ${hint}`, { cause });\n\t\t}\n\t\treturn (await import(pathToFileURL(entry).href)) as T;\n\t}\n};\n","import { basename } from 'node:path';\nimport type { BuilderContext, ResolvedStarsConfig } from '@wolfstar/schema';\nimport type { InlineConfig, Plugin, UserConfig } from 'vite';\nimport { defaultBuilderContext } from './context.js';\n\nexport type ViteModule = typeof import('vite');\nexport interface ViteHooks {\n\tconfigure?(options: InlineConfig, command: 'build' | 'serve'): void | Promise<void>;\n}\n\n/** Defaults are applied after Vite loads its config, so explicit project options win. */\nexport function createViteConfig(config: ResolvedStarsConfig, context: BuilderContext = defaultBuilderContext): InlineConfig {\n\tconst defaults: Plugin = {\n\t\tname: 'stars:server-defaults',\n\t\tenforce: 'pre',\n\t\tconfig(options) {\n\t\t\toptions.build ??= {};\n\t\t\toptions.build.ssr ??= config.entry;\n\t\t\toptions.build.outDir ??= config.build.outDir;\n\t\t\toptions.build.sourcemap ??= true;\n\t\t\toptions.build.rollupOptions ??= {};\n\t\t\tconst output = options.build.rollupOptions.output;\n\t\t\tif (!Array.isArray(output)) options.build.rollupOptions.output = { entryFileNames: basename(config.build.output), ...output };\n\t\t\toptions.resolve ??= {};\n\t\t\toptions.resolve.tsconfigPaths ??= true;\n\t\t}\n\t};\n\tconst inline = config.vite as UserConfig;\n\treturn {\n\t\t...inline,\n\t\troot: config.root,\n\t\tconfigFile: config.build.configFile ?? false,\n\t\tplugins: [defaults, context.pluginRegistrations(config) as Plugin, ...toArray(inline.plugins)]\n\t};\n}\n\nexport function toArray<T>(value: T | T[] | undefined): T[] {\n\treturn value === undefined ? [] : Array.isArray(value) ? value : [value];\n}\n","import { EventEmitter } from 'node:events';\nimport type { Builder, BuilderContext, BuilderEvents, BuildOutcome, ResolvedStarsConfig } from '@wolfstar/schema';\nimport { defaultBuilderContext } from './context.js';\n\nexport interface ServerHooks {\n\tbeforeBuild?(config: ResolvedStarsConfig): void | Promise<void>;\n\tafterBuild?(outcome: BuildOutcome): void | Promise<void>;\n\tclose?(): void | Promise<void>;\n}\n\n/** Shared lifecycle: coalesce concurrent builds, report failures and drain work before close. */\nexport abstract class ServerBuilder extends EventEmitter<BuilderEvents> implements Builder {\n\tpublic readonly tool = 'vite' as const;\n\tprotected closed = false;\n\tprotected active: Promise<BuildOutcome> | null = null;\n\tprotected watching: Promise<void> | null = null;\n\tprotected stopWatching: (() => Promise<void>) | null = null;\n\t#closing: Promise<void> | null = null;\n\tprotected constructor(\n\t\tprotected readonly config: ResolvedStarsConfig,\n\t\tprotected readonly context: BuilderContext = defaultBuilderContext,\n\t\tprotected readonly hooks: ServerHooks = {}\n\t) {\n\t\tsuper();\n\t}\n\tpublic build(): Promise<BuildOutcome> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed. Create a new builder to restart.'));\n\t\tif (this.active) return this.active;\n\t\tthis.active = this.runBuild().finally(() => {\n\t\t\tthis.active = null;\n\t\t});\n\t\treturn this.active;\n\t}\n\tprivate async runBuild(): Promise<BuildOutcome> {\n\t\tconst started = performance.now();\n\t\tthis.emit('start');\n\t\tlet message: string | null = null;\n\t\ttry {\n\t\t\tawait this.hooks.beforeBuild?.(this.config);\n\t\t\tawait this.compile();\n\t\t} catch (error) {\n\t\t\tmessage = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tconst outcome = { ok: message === null, durationMs: Math.round(performance.now() - started), message };\n\t\ttry {\n\t\t\tawait this.hooks.afterBuild?.(outcome);\n\t\t} catch (error) {\n\t\t\toutcome.ok = false;\n\t\t\toutcome.message = error instanceof Error ? error.message : String(error);\n\t\t}\n\t\tif (!this.closed) this.emit(outcome.ok ? 'success' : 'failure', outcome);\n\t\treturn outcome;\n\t}\n\tprotected abstract compile(): Promise<void>;\n\tprotected abstract startWatching(): Promise<void>;\n\tpublic watch(): Promise<void> {\n\t\tif (this.closed) return Promise.reject(new Error('The server builder is closed.'));\n\t\tthis.watching ??= this.startWatching().catch(async (error: unknown) => {\n\t\t\tconst stop = this.stopWatching;\n\t\t\tthis.stopWatching = null;\n\t\t\tawait stop?.();\n\t\t\tthis.watching = null;\n\t\t\tthrow error;\n\t\t});\n\t\treturn this.watching;\n\t}\n\tpublic close(): Promise<void> {\n\t\tthis.closed = true;\n\t\tthis.#closing ??= (async () => {\n\t\t\ttry {\n\t\t\t\tawait this.watching?.catch(() => {});\n\t\t\t\tconst stop = this.stopWatching;\n\t\t\t\tthis.stopWatching = null;\n\t\t\t\ttry {\n\t\t\t\t\tawait stop?.();\n\t\t\t\t} finally {\n\t\t\t\t\tawait this.active;\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tawait this.hooks.close?.();\n\t\t\t}\n\t\t})();\n\t\treturn this.#closing;\n\t}\n}\n","import type { BuilderLogLevel } from '@wolfstar/schema';\nimport type { ViteModule } from './config.js';\nexport function createBuildLogger(vite: ViteModule, log: (level: BuilderLogLevel, text: string) => void) {\n\tconst logger = vite.createLogger('warn', { allowClearScreen: false });\n\tconst warned = new Set<string>();\n\treturn {\n\t\t...logger,\n\t\tinfo: (text: string) => log('info', text),\n\t\twarn: (text: string) => log('warn', text),\n\t\twarnOnce(text: string) {\n\t\t\tif (!warned.has(text)) {\n\t\t\t\twarned.add(text);\n\t\t\t\tlog('warn', text);\n\t\t\t}\n\t\t},\n\t\terror: (text: string) => log('error', text)\n\t};\n}\n"],"mappings":";;;;;;;AASA,MAAM,iBAAiB;;;;;AAMvB,SAAgB,oBAAoB,QAAqC;CACxE,MAAM,UAAU,uBAAuB,OAAO,IAAI;CAClD,MAAM,QAAQ,QAAQ,OAAO,KAAK;CAElC,OAAO;EACN,MAAM;EACN,UAAU,MAAc,IAAY;GACnC,IAAI,QAAQ,WAAW,KAAK,QAAQ,EAAE,MAAM,OAAO,OAAO;GAG1D,OAAO;IAAE,MAAM,GADO,QAAQ,KAAK,SAAS,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I,GAAG;IACtB,OAAO,IAAI,IAAI;IACf,IAAI,QAAQ,IAAI;GACjB;EACD;EACA,QAAQ,SAAiB,IAAI,SAAS,IAAI;CAC3C;AACD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wolfstar/vite-server",
|
|
3
|
+
"version": "0.2.1",
|
|
4
|
+
"description": "Vite build and watch integration for Stars projects",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"api",
|
|
7
|
+
"discord",
|
|
8
|
+
"http",
|
|
9
|
+
"pnpm",
|
|
10
|
+
"stars",
|
|
11
|
+
"ts",
|
|
12
|
+
"typescript",
|
|
13
|
+
"wolfstar"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/wolfstar-project/stars-components/tree/main/packages/vite-server",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/wolfstar-project/stars-components/issues"
|
|
18
|
+
},
|
|
19
|
+
"license": "Apache-2.0",
|
|
20
|
+
"author": "@wolfstar",
|
|
21
|
+
"repository": {
|
|
22
|
+
"type": "git",
|
|
23
|
+
"url": "git+https://github.com/wolfstar-project/stars-components.git",
|
|
24
|
+
"directory": "packages/vite-server"
|
|
25
|
+
},
|
|
26
|
+
"files": [
|
|
27
|
+
"dist/"
|
|
28
|
+
],
|
|
29
|
+
"type": "module",
|
|
30
|
+
"sideEffects": false,
|
|
31
|
+
"main": "dist/esm/index.js",
|
|
32
|
+
"module": "dist/esm/index.js",
|
|
33
|
+
"types": "dist/esm/index.d.ts",
|
|
34
|
+
"exports": {
|
|
35
|
+
".": {
|
|
36
|
+
"import": {
|
|
37
|
+
"types": "./dist/esm/index.d.ts",
|
|
38
|
+
"default": "./dist/esm/index.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json",
|
|
42
|
+
"./internal": {
|
|
43
|
+
"import": {
|
|
44
|
+
"types": "./dist/esm/internal.d.ts",
|
|
45
|
+
"default": "./dist/esm/internal.js"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"provenance": true
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"@wolfstar/schema": "^0.2.0",
|
|
55
|
+
"srvx": "^1.0.5"
|
|
56
|
+
},
|
|
57
|
+
"devDependencies": {
|
|
58
|
+
"@vitest/coverage-v8": "^4.1.11",
|
|
59
|
+
"golar": "^0.1.10",
|
|
60
|
+
"tsdown": "^0.23.0",
|
|
61
|
+
"typescript": "~7.0.2",
|
|
62
|
+
"vite": "^8.3.0",
|
|
63
|
+
"vitest": "^4.1.11"
|
|
64
|
+
},
|
|
65
|
+
"peerDependencies": {
|
|
66
|
+
"vite": ">=6.0.0"
|
|
67
|
+
},
|
|
68
|
+
"peerDependenciesMeta": {
|
|
69
|
+
"vite": {
|
|
70
|
+
"optional": true
|
|
71
|
+
}
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=22"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "tsdown --config-loader unrun",
|
|
78
|
+
"watch": "tsdown --config-loader unrun --watch",
|
|
79
|
+
"typecheck": "golar tsc -p ../../tsconfig.json",
|
|
80
|
+
"lint": "oxlint src --fix",
|
|
81
|
+
"test": "vitest run"
|
|
82
|
+
}
|
|
83
|
+
}
|