@astroscope/boot 0.3.0 → 0.3.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 +2 -12
- package/dist/index.js +2 -12
- package/dist/setup.cjs +3 -4
- package/dist/setup.d.cts +4 -1
- package/dist/setup.d.ts +4 -1
- package/dist/setup.js +1 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -202,8 +202,6 @@ function resolveEntry(entry) {
|
|
|
202
202
|
if (import_node_fs2.default.existsSync("src/boot/index.ts")) return "src/boot/index.ts";
|
|
203
203
|
return "src/boot.ts";
|
|
204
204
|
}
|
|
205
|
-
var VIRTUAL_MODULE_ID = "virtual:@astroscope/boot/config";
|
|
206
|
-
var RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
207
205
|
function getServerDefaults(config) {
|
|
208
206
|
return {
|
|
209
207
|
host: typeof config?.server?.host === "string" ? config.server.host : config?.server?.host === true ? "0.0.0.0" : "localhost",
|
|
@@ -230,15 +228,6 @@ function boot(options = {}) {
|
|
|
230
228
|
{
|
|
231
229
|
name: "@astroscope/boot",
|
|
232
230
|
enforce: "pre",
|
|
233
|
-
resolveId(id) {
|
|
234
|
-
if (id === VIRTUAL_MODULE_ID) return RESOLVED_VIRTUAL_MODULE_ID;
|
|
235
|
-
},
|
|
236
|
-
load(id) {
|
|
237
|
-
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
238
|
-
const { host, port } = getServerDefaults(astroConfig);
|
|
239
|
-
return `export const config = ${JSON.stringify({ host, port })};`;
|
|
240
|
-
}
|
|
241
|
-
},
|
|
242
231
|
async configureServer(server) {
|
|
243
232
|
if (isBuild) return;
|
|
244
233
|
const getBootContext = () => {
|
|
@@ -293,10 +282,11 @@ function boot(options = {}) {
|
|
|
293
282
|
return;
|
|
294
283
|
}
|
|
295
284
|
warmupModules = collectWarmupModules(bundle);
|
|
285
|
+
const { host, port } = getServerDefaults(astroConfig);
|
|
296
286
|
const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
|
|
297
287
|
import * as __astroscope_boot from './${bootChunkName}';
|
|
298
288
|
import { setup as __astroscope_bootSetup } from '@astroscope/boot/setup';
|
|
299
|
-
await __astroscope_bootSetup(__astroscope_boot);
|
|
289
|
+
await __astroscope_bootSetup(__astroscope_boot, ${JSON.stringify({ host, port })});
|
|
300
290
|
`;
|
|
301
291
|
const s = new import_magic_string.default(entryChunk.code);
|
|
302
292
|
s.prepend(bootImport);
|
package/dist/index.js
CHANGED
|
@@ -138,8 +138,6 @@ function resolveEntry(entry) {
|
|
|
138
138
|
if (fs2.existsSync("src/boot/index.ts")) return "src/boot/index.ts";
|
|
139
139
|
return "src/boot.ts";
|
|
140
140
|
}
|
|
141
|
-
var VIRTUAL_MODULE_ID = "virtual:@astroscope/boot/config";
|
|
142
|
-
var RESOLVED_VIRTUAL_MODULE_ID = `\0${VIRTUAL_MODULE_ID}`;
|
|
143
141
|
function getServerDefaults(config) {
|
|
144
142
|
return {
|
|
145
143
|
host: typeof config?.server?.host === "string" ? config.server.host : config?.server?.host === true ? "0.0.0.0" : "localhost",
|
|
@@ -166,15 +164,6 @@ function boot(options = {}) {
|
|
|
166
164
|
{
|
|
167
165
|
name: "@astroscope/boot",
|
|
168
166
|
enforce: "pre",
|
|
169
|
-
resolveId(id) {
|
|
170
|
-
if (id === VIRTUAL_MODULE_ID) return RESOLVED_VIRTUAL_MODULE_ID;
|
|
171
|
-
},
|
|
172
|
-
load(id) {
|
|
173
|
-
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
174
|
-
const { host, port } = getServerDefaults(astroConfig);
|
|
175
|
-
return `export const config = ${JSON.stringify({ host, port })};`;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
167
|
async configureServer(server) {
|
|
179
168
|
if (isBuild) return;
|
|
180
169
|
const getBootContext = () => {
|
|
@@ -229,10 +218,11 @@ function boot(options = {}) {
|
|
|
229
218
|
return;
|
|
230
219
|
}
|
|
231
220
|
warmupModules = collectWarmupModules(bundle);
|
|
221
|
+
const { host, port } = getServerDefaults(astroConfig);
|
|
232
222
|
const bootImport = `globalThis.__astroscope_server_url = import.meta.url;
|
|
233
223
|
import * as __astroscope_boot from './${bootChunkName}';
|
|
234
224
|
import { setup as __astroscope_bootSetup } from '@astroscope/boot/setup';
|
|
235
|
-
await __astroscope_bootSetup(__astroscope_boot);
|
|
225
|
+
await __astroscope_bootSetup(__astroscope_boot, ${JSON.stringify({ host, port })});
|
|
236
226
|
`;
|
|
237
227
|
const s = new MagicString(entryChunk.code);
|
|
238
228
|
s.prepend(bootImport);
|
package/dist/setup.cjs
CHANGED
|
@@ -23,7 +23,6 @@ __export(setup_exports, {
|
|
|
23
23
|
setup: () => setup
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(setup_exports);
|
|
26
|
-
var import_config = require("virtual:@astroscope/boot/config");
|
|
27
26
|
|
|
28
27
|
// src/events.ts
|
|
29
28
|
var STORE_KEY = /* @__PURE__ */ Symbol.for("@astroscope/boot/events");
|
|
@@ -59,11 +58,11 @@ async function runShutdown(boot, context) {
|
|
|
59
58
|
}
|
|
60
59
|
|
|
61
60
|
// src/setup.ts
|
|
62
|
-
async function setup(boot) {
|
|
61
|
+
async function setup(boot, config) {
|
|
63
62
|
const context = {
|
|
64
63
|
dev: false,
|
|
65
|
-
host: process.env["HOST"] ??
|
|
66
|
-
port: process.env["PORT"] ? Number(process.env["PORT"]) :
|
|
64
|
+
host: process.env["HOST"] ?? config.host,
|
|
65
|
+
port: process.env["PORT"] ? Number(process.env["PORT"]) : config.port
|
|
67
66
|
};
|
|
68
67
|
try {
|
|
69
68
|
await runStartup(boot, context);
|
package/dist/setup.d.cts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BootModule } from './lifecycle.cjs';
|
|
2
2
|
import './types-CxpusND2.cjs';
|
|
3
3
|
|
|
4
|
-
declare function setup(boot: BootModule
|
|
4
|
+
declare function setup(boot: BootModule, config: {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
}): Promise<void>;
|
|
5
8
|
|
|
6
9
|
export { setup };
|
package/dist/setup.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { BootModule } from './lifecycle.js';
|
|
2
2
|
import './types-CxpusND2.js';
|
|
3
3
|
|
|
4
|
-
declare function setup(boot: BootModule
|
|
4
|
+
declare function setup(boot: BootModule, config: {
|
|
5
|
+
host: string;
|
|
6
|
+
port: number;
|
|
7
|
+
}): Promise<void>;
|
|
5
8
|
|
|
6
9
|
export { setup };
|
package/dist/setup.js
CHANGED
|
@@ -5,8 +5,7 @@ import {
|
|
|
5
5
|
import "./chunk-I62ZQYTP.js";
|
|
6
6
|
|
|
7
7
|
// src/setup.ts
|
|
8
|
-
|
|
9
|
-
async function setup(boot) {
|
|
8
|
+
async function setup(boot, config) {
|
|
10
9
|
const context = {
|
|
11
10
|
dev: false,
|
|
12
11
|
host: process.env["HOST"] ?? config.host,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@astroscope/boot",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Startup and graceful shutdown hooks for Astro SSR",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
},
|
|
50
50
|
"homepage": "https://github.com/smnbbrv/astroscope/tree/main/packages/boot#readme",
|
|
51
51
|
"scripts": {
|
|
52
|
-
"build": "tsup src/index.ts src/warmup.ts src/events.ts src/lifecycle.ts src/setup.ts --format esm,cjs --dts
|
|
52
|
+
"build": "tsup src/index.ts src/warmup.ts src/events.ts src/lifecycle.ts src/setup.ts --format esm,cjs --dts",
|
|
53
53
|
"typecheck": "tsc --noEmit",
|
|
54
54
|
"lint": "eslint 'src/**/*.{ts,tsx}'",
|
|
55
55
|
"lint:fix": "eslint 'src/**/*.{ts,tsx}' --fix"
|