@absolutejs/absolute 0.19.0-beta.121 → 0.19.0-beta.122
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/.absolutejs/cert.pem +11 -0
- package/.absolutejs/key.pem +5 -0
- package/.absolutejs/prettier.cache.json +45 -27
- package/.absolutejs/tsconfig.tsbuildinfo +1 -1
- package/.claude/projects/-home-alexkahn-abs-absolutejs/memory/feedback_http2_naming.md +10 -0
- package/.claude/settings.local.json +6 -1
- package/dist/build.js +9 -2
- package/dist/build.js.map +7 -7
- package/dist/dev/client/reactRefreshSetup.ts +2 -3
- package/dist/index.js +258 -38
- package/dist/index.js.map +14 -13
- package/dist/react/index.js.map +2 -2
- package/dist/src/core/prepare.d.ts +2 -16
- package/dist/src/dev/http2Bridge.d.ts +3 -0
- package/dist/src/plugins/hmr.d.ts +2 -16
- package/package.json +1 -1
- package/scripts/use-combined-bun.sh +27 -0
- package/scripts/use-http2-bun.sh +26 -0
- package/types/globals.d.ts +6 -0
|
@@ -28,8 +28,7 @@ if (!window.$RefreshRuntime$) {
|
|
|
28
28
|
for (const [type, id] of buffer) {
|
|
29
29
|
RefreshRuntime.register(type, id);
|
|
30
30
|
}
|
|
31
|
-
(
|
|
32
|
-
|
|
33
|
-
).__REFRESH_BUFFER__ = undefined;
|
|
31
|
+
(window as unknown as Record<string, unknown>).__REFRESH_BUFFER__ =
|
|
32
|
+
undefined;
|
|
34
33
|
}
|
|
35
34
|
}
|
package/dist/index.js
CHANGED
|
@@ -1169,7 +1169,14 @@ var colors, MONTHS, formatTimestamp = () => {
|
|
|
1169
1169
|
hours = hours % HOURS_IN_HALF_DAY || HOURS_IN_HALF_DAY;
|
|
1170
1170
|
return `${month} ${day} ${hours}:${minutes}:${seconds} ${ampm}`;
|
|
1171
1171
|
}, startupBanner = (options) => {
|
|
1172
|
-
const {
|
|
1172
|
+
const {
|
|
1173
|
+
version,
|
|
1174
|
+
duration,
|
|
1175
|
+
port,
|
|
1176
|
+
host,
|
|
1177
|
+
networkUrl,
|
|
1178
|
+
protocol = "http"
|
|
1179
|
+
} = options;
|
|
1173
1180
|
const name = `${colors.cyan}${colors.bold}ABSOLUTEJS${colors.reset}`;
|
|
1174
1181
|
const ver = `${colors.dim}v${version}${colors.reset}`;
|
|
1175
1182
|
const time = `${colors.dim}ready in${colors.reset} ${colors.bold}${getDurationString(duration)}${colors.reset}`;
|
|
@@ -204980,7 +204987,8 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
|
|
|
204980
204987
|
Reflect.set(globalThis, STORE_KEY, app.store);
|
|
204981
204988
|
}, hmr = (hmrState2, manifest, moduleServerHandler) => (app) => {
|
|
204982
204989
|
restoreStore(app);
|
|
204983
|
-
|
|
204990
|
+
const http2Mode = Boolean(globalThis.__http2Config);
|
|
204991
|
+
app.onBeforeHandle(async ({ request }) => {
|
|
204984
204992
|
if (globalThis.__reactModuleRef) {
|
|
204985
204993
|
await bridgeReactInternals();
|
|
204986
204994
|
}
|
|
@@ -205015,11 +205023,15 @@ var STORE_KEY = "__elysiaStore", getGlobalValue = (key) => Reflect.get(globalThi
|
|
|
205015
205023
|
"Content-Type": getMimeType(pathname)
|
|
205016
205024
|
}
|
|
205017
205025
|
});
|
|
205018
|
-
})
|
|
205019
|
-
|
|
205020
|
-
|
|
205021
|
-
|
|
205022
|
-
|
|
205026
|
+
});
|
|
205027
|
+
if (!http2Mode) {
|
|
205028
|
+
app.ws("/hmr", {
|
|
205029
|
+
close: (ws) => handleClientDisconnect(hmrState2, ws),
|
|
205030
|
+
message: (ws, msg) => handleHMRMessage(hmrState2, ws, msg),
|
|
205031
|
+
open: (ws) => handleClientConnect(hmrState2, ws, manifest)
|
|
205032
|
+
});
|
|
205033
|
+
}
|
|
205034
|
+
return app.get("/hmr-status", () => ({
|
|
205023
205035
|
connectedClients: hmrState2.connectedClients.size,
|
|
205024
205036
|
isRebuilding: hmrState2.isRebuilding,
|
|
205025
205037
|
manifestKeys: Object.keys(manifest),
|
|
@@ -205035,6 +205047,188 @@ var init_hmr = __esm(() => {
|
|
|
205035
205047
|
init_webSocket();
|
|
205036
205048
|
});
|
|
205037
205049
|
|
|
205050
|
+
// src/dev/http2Bridge.ts
|
|
205051
|
+
var exports_http2Bridge = {};
|
|
205052
|
+
__export(exports_http2Bridge, {
|
|
205053
|
+
bridgeHttp2Stream: () => bridgeHttp2Stream
|
|
205054
|
+
});
|
|
205055
|
+
var WS_OPCODE_TEXT = 1, WS_OPCODE_CLOSE = 8, WS_OPCODE_PING = 9, WS_OPCODE_PONG = 10, parseWsFrame = (buf) => {
|
|
205056
|
+
if (buf.length < 2)
|
|
205057
|
+
return null;
|
|
205058
|
+
const byte0 = buf[0];
|
|
205059
|
+
const byte1 = buf[1];
|
|
205060
|
+
const opcode = byte0 & 15;
|
|
205061
|
+
const masked = (byte1 & 128) !== 0;
|
|
205062
|
+
let payloadLen = byte1 & 127;
|
|
205063
|
+
let offset = 2;
|
|
205064
|
+
if (payloadLen === 126) {
|
|
205065
|
+
if (buf.length < 4)
|
|
205066
|
+
return null;
|
|
205067
|
+
payloadLen = buf.readUInt16BE(2);
|
|
205068
|
+
offset = 4;
|
|
205069
|
+
} else if (payloadLen === 127) {
|
|
205070
|
+
if (buf.length < 10)
|
|
205071
|
+
return null;
|
|
205072
|
+
payloadLen = Number(buf.readBigUInt64BE(2));
|
|
205073
|
+
offset = 10;
|
|
205074
|
+
}
|
|
205075
|
+
if (masked) {
|
|
205076
|
+
if (buf.length < offset + 4 + payloadLen)
|
|
205077
|
+
return null;
|
|
205078
|
+
const maskKey = buf.subarray(offset, offset + 4);
|
|
205079
|
+
offset += 4;
|
|
205080
|
+
const payload = Buffer.allocUnsafe(payloadLen);
|
|
205081
|
+
for (let i = 0;i < payloadLen; i++) {
|
|
205082
|
+
payload[i] = buf[offset + i] ^ maskKey[i & 3];
|
|
205083
|
+
}
|
|
205084
|
+
return { opcode, payload, totalLen: offset + payloadLen };
|
|
205085
|
+
}
|
|
205086
|
+
if (buf.length < offset + payloadLen)
|
|
205087
|
+
return null;
|
|
205088
|
+
return {
|
|
205089
|
+
opcode,
|
|
205090
|
+
payload: buf.subarray(offset, offset + payloadLen),
|
|
205091
|
+
totalLen: offset + payloadLen
|
|
205092
|
+
};
|
|
205093
|
+
}, writeWsFrame = (opcode, payload) => {
|
|
205094
|
+
const len = payload.length;
|
|
205095
|
+
let header;
|
|
205096
|
+
if (len < 126) {
|
|
205097
|
+
header = Buffer.allocUnsafe(2);
|
|
205098
|
+
header[0] = 128 | opcode;
|
|
205099
|
+
header[1] = len;
|
|
205100
|
+
} else if (len < 65536) {
|
|
205101
|
+
header = Buffer.allocUnsafe(4);
|
|
205102
|
+
header[0] = 128 | opcode;
|
|
205103
|
+
header[1] = 126;
|
|
205104
|
+
header.writeUInt16BE(len, 2);
|
|
205105
|
+
} else {
|
|
205106
|
+
header = Buffer.allocUnsafe(10);
|
|
205107
|
+
header[0] = 128 | opcode;
|
|
205108
|
+
header[1] = 127;
|
|
205109
|
+
header.writeBigUInt64BE(BigInt(len), 2);
|
|
205110
|
+
}
|
|
205111
|
+
return Buffer.concat([header, payload]);
|
|
205112
|
+
}, createHttp2WebSocket = (stream) => {
|
|
205113
|
+
let state = WS_READY_STATE_OPEN;
|
|
205114
|
+
let buffer = Buffer.alloc(0);
|
|
205115
|
+
let onMessage = null;
|
|
205116
|
+
let onClose = null;
|
|
205117
|
+
stream.on("data", (chunk) => {
|
|
205118
|
+
buffer = Buffer.concat([buffer, chunk]);
|
|
205119
|
+
while (buffer.length > 0) {
|
|
205120
|
+
const frame = parseWsFrame(buffer);
|
|
205121
|
+
if (!frame)
|
|
205122
|
+
break;
|
|
205123
|
+
buffer = buffer.subarray(frame.totalLen);
|
|
205124
|
+
if (frame.opcode === WS_OPCODE_TEXT && onMessage) {
|
|
205125
|
+
onMessage(frame.payload.toString("utf-8"));
|
|
205126
|
+
} else if (frame.opcode === WS_OPCODE_PING) {
|
|
205127
|
+
if (!stream.destroyed) {
|
|
205128
|
+
stream.write(writeWsFrame(WS_OPCODE_PONG, frame.payload));
|
|
205129
|
+
}
|
|
205130
|
+
} else if (frame.opcode === WS_OPCODE_CLOSE) {
|
|
205131
|
+
if (!stream.destroyed) {
|
|
205132
|
+
stream.write(writeWsFrame(WS_OPCODE_CLOSE, Buffer.alloc(0)));
|
|
205133
|
+
stream.end();
|
|
205134
|
+
}
|
|
205135
|
+
state = 3;
|
|
205136
|
+
if (onClose)
|
|
205137
|
+
onClose();
|
|
205138
|
+
}
|
|
205139
|
+
}
|
|
205140
|
+
});
|
|
205141
|
+
stream.on("close", () => {
|
|
205142
|
+
if (state === WS_READY_STATE_OPEN) {
|
|
205143
|
+
state = 3;
|
|
205144
|
+
if (onClose)
|
|
205145
|
+
onClose();
|
|
205146
|
+
}
|
|
205147
|
+
});
|
|
205148
|
+
stream.on("error", () => {
|
|
205149
|
+
state = 3;
|
|
205150
|
+
});
|
|
205151
|
+
const ws = {
|
|
205152
|
+
get readyState() {
|
|
205153
|
+
return state;
|
|
205154
|
+
},
|
|
205155
|
+
send(data) {
|
|
205156
|
+
if (state !== WS_READY_STATE_OPEN || stream.destroyed)
|
|
205157
|
+
return;
|
|
205158
|
+
stream.write(writeWsFrame(WS_OPCODE_TEXT, Buffer.from(data)));
|
|
205159
|
+
},
|
|
205160
|
+
close() {
|
|
205161
|
+
if (state !== WS_READY_STATE_OPEN || stream.destroyed)
|
|
205162
|
+
return;
|
|
205163
|
+
stream.write(writeWsFrame(WS_OPCODE_CLOSE, Buffer.alloc(0)));
|
|
205164
|
+
stream.end();
|
|
205165
|
+
state = 2;
|
|
205166
|
+
},
|
|
205167
|
+
onMessage: null,
|
|
205168
|
+
onClose: null
|
|
205169
|
+
};
|
|
205170
|
+
onMessage = (data) => ws.onMessage?.(data);
|
|
205171
|
+
onClose = () => ws.onClose?.();
|
|
205172
|
+
return ws;
|
|
205173
|
+
}, bridgeHttp2Stream = async (stream, headers, fetchHandler, hmrState2, manifest) => {
|
|
205174
|
+
const method = headers[":method"] ?? "GET";
|
|
205175
|
+
const path = headers[":path"] ?? "/";
|
|
205176
|
+
if (method === "CONNECT" && headers[":protocol"] === "websocket" && hmrState2 && manifest) {
|
|
205177
|
+
stream.respond({ ":status": 200 });
|
|
205178
|
+
const ws = createHttp2WebSocket(stream);
|
|
205179
|
+
ws.onMessage = (data) => handleHMRMessage(hmrState2, ws, data);
|
|
205180
|
+
ws.onClose = () => handleClientDisconnect(hmrState2, ws);
|
|
205181
|
+
handleClientConnect(hmrState2, ws, manifest);
|
|
205182
|
+
return;
|
|
205183
|
+
}
|
|
205184
|
+
const authority = headers[":authority"] ?? "localhost";
|
|
205185
|
+
const scheme = headers[":scheme"] ?? "https";
|
|
205186
|
+
const url = `${scheme}://${authority}${path}`;
|
|
205187
|
+
const requestHeaders = new Headers;
|
|
205188
|
+
for (const [key, value] of Object.entries(headers)) {
|
|
205189
|
+
if (key.startsWith(":") || value === undefined)
|
|
205190
|
+
continue;
|
|
205191
|
+
const headerValue = Array.isArray(value) ? value.join(", ") : value;
|
|
205192
|
+
requestHeaders.set(key, headerValue);
|
|
205193
|
+
}
|
|
205194
|
+
const hasBody = method !== "GET" && method !== "HEAD";
|
|
205195
|
+
const bodyBlob = hasBody ? await new Promise((resolve24) => {
|
|
205196
|
+
const chunks = [];
|
|
205197
|
+
stream.on("data", (chunk) => chunks.push(chunk));
|
|
205198
|
+
stream.on("end", () => {
|
|
205199
|
+
resolve24(new Blob([Buffer.concat(chunks)]));
|
|
205200
|
+
});
|
|
205201
|
+
}) : null;
|
|
205202
|
+
const request = new Request(url, {
|
|
205203
|
+
body: bodyBlob,
|
|
205204
|
+
headers: requestHeaders,
|
|
205205
|
+
method
|
|
205206
|
+
});
|
|
205207
|
+
try {
|
|
205208
|
+
const response = await fetchHandler(request);
|
|
205209
|
+
const responseHeaders = {
|
|
205210
|
+
":status": response.status
|
|
205211
|
+
};
|
|
205212
|
+
response.headers.forEach((value, key) => {
|
|
205213
|
+
responseHeaders[key] = value;
|
|
205214
|
+
});
|
|
205215
|
+
if (!response.body) {
|
|
205216
|
+
stream.respond(responseHeaders);
|
|
205217
|
+
stream.end();
|
|
205218
|
+
return;
|
|
205219
|
+
}
|
|
205220
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
205221
|
+
stream.respond(responseHeaders);
|
|
205222
|
+
stream.end(Buffer.from(arrayBuffer));
|
|
205223
|
+
} catch {
|
|
205224
|
+
stream.respond({ ":status": 500, "content-type": "text/plain" });
|
|
205225
|
+
stream.end("Internal Server Error");
|
|
205226
|
+
}
|
|
205227
|
+
};
|
|
205228
|
+
var init_http2Bridge = __esm(() => {
|
|
205229
|
+
init_webSocket();
|
|
205230
|
+
});
|
|
205231
|
+
|
|
205038
205232
|
// src/dev/devCert.ts
|
|
205039
205233
|
var exports_devCert = {};
|
|
205040
205234
|
__export(exports_devCert, {
|
|
@@ -205386,6 +205580,10 @@ var prepare = async (configOrPath) => {
|
|
|
205386
205580
|
warmCache2(`${SRC_URL_PREFIX2}${rel}`);
|
|
205387
205581
|
}
|
|
205388
205582
|
}
|
|
205583
|
+
globalThis.__http2Config = {
|
|
205584
|
+
hmrState: result.hmrState,
|
|
205585
|
+
manifest: result.manifest
|
|
205586
|
+
};
|
|
205389
205587
|
const hmrPlugin = hmr2(result.hmrState, result.manifest, moduleHandler);
|
|
205390
205588
|
const devIndexDir = resolve23(buildDir, "_src_indexes");
|
|
205391
205589
|
for (const key of Object.keys(result.manifest)) {
|
|
@@ -205412,6 +205610,8 @@ var pageRouterPlugin = () => {
|
|
|
205412
205610
|
};
|
|
205413
205611
|
// src/plugins/networking.ts
|
|
205414
205612
|
init_constants();
|
|
205613
|
+
import { readFileSync as readFileSync12 } from "fs";
|
|
205614
|
+
import { join as join18 } from "path";
|
|
205415
205615
|
import { argv } from "process";
|
|
205416
205616
|
var {env: env3 } = globalThis.Bun;
|
|
205417
205617
|
|
|
@@ -205444,45 +205644,65 @@ if (hostFlag) {
|
|
|
205444
205644
|
localIP = getLocalIPAddress();
|
|
205445
205645
|
host = "0.0.0.0";
|
|
205446
205646
|
}
|
|
205447
|
-
var
|
|
205448
|
-
|
|
205449
|
-
|
|
205450
|
-
if (env3.ABSOLUTE_HTTPS !== "true")
|
|
205451
|
-
return;
|
|
205452
|
-
try {
|
|
205453
|
-
const { loadDevCert: loadDevCert2 } = (init_devCert(), __toCommonJS(exports_devCert));
|
|
205454
|
-
return loadDevCert2();
|
|
205455
|
-
} catch {
|
|
205456
|
-
return;
|
|
205457
|
-
}
|
|
205458
|
-
})();
|
|
205459
|
-
var protocol = tls ? "https" : "http";
|
|
205460
|
-
var networking = (app) => app.listen({
|
|
205461
|
-
hostname: host,
|
|
205462
|
-
port,
|
|
205463
|
-
...tls ? {
|
|
205464
|
-
tls: {
|
|
205465
|
-
cert: tls.cert,
|
|
205466
|
-
key: tls.key
|
|
205467
|
-
}
|
|
205468
|
-
} : {}
|
|
205469
|
-
}, () => {
|
|
205647
|
+
var isHttpsDev = env3.NODE_ENV === "development" && env3.ABSOLUTE_HTTPS === "true";
|
|
205648
|
+
var protocol = isHttpsDev ? "https" : "http";
|
|
205649
|
+
var showBanner = () => {
|
|
205470
205650
|
const isHotReload = Boolean(globalThis.__hmrServerStartup);
|
|
205471
205651
|
globalThis.__hmrServerStartup = true;
|
|
205472
|
-
if (isHotReload)
|
|
205652
|
+
if (isHotReload)
|
|
205473
205653
|
return;
|
|
205474
|
-
}
|
|
205475
|
-
const buildDuration = globalThis.__hmrBuildDuration ?? Number(env3.ABSOLUTE_BUILD_DURATION || 0);
|
|
205476
|
-
const version = globalThis.__absoluteVersion || env3.ABSOLUTE_VERSION || "";
|
|
205477
205654
|
startupBanner({
|
|
205478
|
-
duration:
|
|
205655
|
+
duration: globalThis.__hmrBuildDuration ?? Number(env3.ABSOLUTE_BUILD_DURATION || 0),
|
|
205479
205656
|
host,
|
|
205480
205657
|
networkUrl: hostFlag ? `${protocol}://${localIP}:${port}/` : undefined,
|
|
205481
205658
|
port,
|
|
205482
205659
|
protocol,
|
|
205483
|
-
version
|
|
205660
|
+
version: globalThis.__absoluteVersion || env3.ABSOLUTE_VERSION || ""
|
|
205484
205661
|
});
|
|
205485
|
-
}
|
|
205662
|
+
};
|
|
205663
|
+
var networking = (app) => {
|
|
205664
|
+
if (isHttpsDev) {
|
|
205665
|
+
const certDir = join18(process.cwd(), ".absolutejs");
|
|
205666
|
+
const cert = readFileSync12(join18(certDir, "cert.pem"), "utf-8");
|
|
205667
|
+
const key = readFileSync12(join18(certDir, "key.pem"), "utf-8");
|
|
205668
|
+
app.compile();
|
|
205669
|
+
const http2 = __require("http2");
|
|
205670
|
+
const server2 = http2.createSecureServer({
|
|
205671
|
+
cert,
|
|
205672
|
+
key,
|
|
205673
|
+
settings: { enableConnectProtocol: true }
|
|
205674
|
+
});
|
|
205675
|
+
server2.on("session", (session) => {
|
|
205676
|
+
session.settings({ enableConnectProtocol: true });
|
|
205677
|
+
});
|
|
205678
|
+
const { bridgeHttp2Stream: bridgeHttp2Stream2 } = (init_http2Bridge(), __toCommonJS(exports_http2Bridge));
|
|
205679
|
+
const http2Config = globalThis.__http2Config;
|
|
205680
|
+
server2.on("stream", (stream, headers) => {
|
|
205681
|
+
bridgeHttp2Stream2(stream, headers, app.fetch.bind(app), http2Config?.hmrState, http2Config?.manifest);
|
|
205682
|
+
});
|
|
205683
|
+
server2.listen(Number(port), () => {
|
|
205684
|
+
showBanner();
|
|
205685
|
+
});
|
|
205686
|
+
return app;
|
|
205687
|
+
}
|
|
205688
|
+
const tls = (() => {
|
|
205689
|
+
if (!isHttpsDev)
|
|
205690
|
+
return;
|
|
205691
|
+
try {
|
|
205692
|
+
const { loadDevCert: loadDevCert2 } = (init_devCert(), __toCommonJS(exports_devCert));
|
|
205693
|
+
return loadDevCert2();
|
|
205694
|
+
} catch {
|
|
205695
|
+
return;
|
|
205696
|
+
}
|
|
205697
|
+
})();
|
|
205698
|
+
return app.listen({
|
|
205699
|
+
hostname: host,
|
|
205700
|
+
port,
|
|
205701
|
+
...tls ? { tls: { cert: tls.cert, key: tls.key } } : {}
|
|
205702
|
+
}, () => {
|
|
205703
|
+
showBanner();
|
|
205704
|
+
});
|
|
205705
|
+
};
|
|
205486
205706
|
// src/utils/defineConfig.ts
|
|
205487
205707
|
var defineConfig = (config) => config;
|
|
205488
205708
|
// src/utils/generateHeadElement.ts
|
|
@@ -205582,5 +205802,5 @@ export {
|
|
|
205582
205802
|
ANGULAR_INIT_TIMEOUT_MS
|
|
205583
205803
|
};
|
|
205584
205804
|
|
|
205585
|
-
//# debugId=
|
|
205805
|
+
//# debugId=781BD03FD0AB276C64756E2164756E21
|
|
205586
205806
|
//# sourceMappingURL=index.js.map
|