aboutsummaryrefslogtreecommitdiff
path: root/.ci/ci.cjs
diff options
context:
space:
mode:
Diffstat (limited to '.ci/ci.cjs')
-rwxr-xr-x.ci/ci.cjs558
1 files changed, 462 insertions, 96 deletions
diff --git a/.ci/ci.cjs b/.ci/ci.cjs
index 5574ede..ee058dd 100755
--- a/.ci/ci.cjs
+++ b/.ci/ci.cjs
@@ -1806,6 +1806,7 @@ var require_dist = __commonJS({
});
module2.exports = __toCommonJS(src_exports);
var import_node_http = require("http");
+ var import_node_http22 = require("http2");
var import_node_http2 = require("http2");
var import_node_stream = require("stream");
var RequestError = class extends Error {
@@ -1833,7 +1834,7 @@ var require_dist = __commonJS({
super(input, options);
}
};
- var newRequestFromIncoming = (method, url, incoming, abortController) => {
+ var newHeadersFromIncoming = (incoming) => {
const headerRecord = [];
const rawHeaders = incoming.rawHeaders;
for (let i = 0; i < rawHeaders.length; i += 2) {
@@ -1843,9 +1844,13 @@ var require_dist = __commonJS({
headerRecord.push([key, value]);
}
}
+ return new Headers(headerRecord);
+ };
+ var wrapBodyStream = Symbol("wrapBodyStream");
+ var newRequestFromIncoming = (method, url, headers, incoming, abortController) => {
const init = {
method,
- headers: headerRecord,
+ headers,
signal: abortController.signal
};
if (method === "TRACE") {
@@ -1866,6 +1871,23 @@ var require_dist = __commonJS({
controller.close();
}
});
+ } else if (incoming[wrapBodyStream]) {
+ let reader;
+ init.body = new ReadableStream({
+ async pull(controller) {
+ try {
+ reader ||= import_node_stream.Readable.toWeb(incoming).getReader();
+ const { done, value } = await reader.read();
+ if (done) {
+ controller.close();
+ } else {
+ controller.enqueue(value);
+ }
+ } catch (error) {
+ controller.error(error);
+ }
+ }
+ });
} else {
init.body = import_node_stream.Readable.toWeb(incoming);
}
@@ -1876,6 +1898,7 @@ var require_dist = __commonJS({
var requestCache = Symbol("requestCache");
var incomingKey = Symbol("incomingKey");
var urlKey = Symbol("urlKey");
+ var headersKey = Symbol("headersKey");
var abortControllerKey = Symbol("abortControllerKey");
var getAbortController = Symbol("getAbortController");
var requestPrototype = {
@@ -1885,6 +1908,9 @@ var require_dist = __commonJS({
get url() {
return this[urlKey];
},
+ get headers() {
+ return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
+ },
[getAbortController]() {
this[getRequestCache]();
return this[abortControllerKey];
@@ -1894,6 +1920,7 @@ var require_dist = __commonJS({
return this[requestCache] ||= newRequestFromIncoming(
this.method,
this[urlKey],
+ this.headers,
this[incomingKey],
this[abortControllerKey]
);
@@ -1905,7 +1932,6 @@ var require_dist = __commonJS({
"cache",
"credentials",
"destination",
- "headers",
"integrity",
"mode",
"redirect",
@@ -2031,30 +2057,28 @@ var require_dist = __commonJS({
});
Object.setPrototypeOf(Response2, GlobalResponse);
Object.setPrototypeOf(Response2.prototype, GlobalResponse.prototype);
- function writeFromReadableStream(stream, writable) {
- if (stream.locked) {
- throw new TypeError("ReadableStream is locked.");
- } else if (writable.destroyed) {
- stream.cancel();
- return;
- }
- const reader = stream.getReader();
+ async function readWithoutBlocking(readPromise) {
+ return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(void 0))]);
+ }
+ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromise) {
+ const cancel = (error) => {
+ reader.cancel(error).catch(() => {
+ });
+ };
writable.on("close", cancel);
writable.on("error", cancel);
- reader.read().then(flow, cancel);
+ (currentReadPromise ?? reader.read()).then(flow, handleStreamError);
return reader.closed.finally(() => {
writable.off("close", cancel);
writable.off("error", cancel);
});
- function cancel(error) {
- reader.cancel(error).catch(() => {
- });
+ function handleStreamError(error) {
if (error) {
writable.destroy(error);
}
}
function onDrain() {
- reader.read().then(flow, cancel);
+ reader.read().then(flow, handleStreamError);
}
function flow({ done, value }) {
try {
@@ -2063,13 +2087,21 @@ var require_dist = __commonJS({
} else if (!writable.write(value)) {
writable.once("drain", onDrain);
} else {
- return reader.read().then(flow, cancel);
+ return reader.read().then(flow, handleStreamError);
}
} catch (e) {
- cancel(e);
+ handleStreamError(e);
}
}
}
+ function writeFromReadableStream(stream, writable) {
+ if (stream.locked) {
+ throw new TypeError("ReadableStream is locked.");
+ } else if (writable.destroyed) {
+ return;
+ }
+ return writeFromReadableStreamDefaultReader(stream.getReader(), writable);
+ }
var buildOutgoingHttpHeaders = (headers) => {
const res = {};
if (!(headers instanceof Headers)) {
@@ -2104,8 +2136,7 @@ var require_dist = __commonJS({
};
return webFetch(info, init);
};
- var regBuffer = /^no$/i;
- var regContentType = /^(application\/json\b|text\/(?!event-stream\b))/i;
+ var outgoingEnded = Symbol("outgoingEnded");
var handleRequestError = () => new Response(null, {
status: 400
});
@@ -2149,13 +2180,16 @@ var require_dist = __commonJS({
outgoing.end(new Uint8Array(await body.arrayBuffer()));
} else {
flushHeaders(outgoing);
- return writeFromReadableStream(body, outgoing)?.catch(
+ await writeFromReadableStream(body, outgoing)?.catch(
(e) => handleResponseError(e, outgoing)
);
}
+ ;
+ outgoing[outgoingEnded]?.();
};
+ var isPromise = (res) => typeof res.then === "function";
var responseViaResponseObject = async (res, outgoing, options = {}) => {
- if (res instanceof Promise) {
+ if (isPromise(res)) {
if (options.errorHandler) {
try {
res = await res;
@@ -2175,31 +2209,62 @@ var require_dist = __commonJS({
}
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
if (res.body) {
- const {
- "transfer-encoding": transferEncoding,
- "content-encoding": contentEncoding,
- "content-length": contentLength,
- "x-accel-buffering": accelBuffering,
- "content-type": contentType
- } = resHeaderRecord;
- if (transferEncoding || contentEncoding || contentLength || // nginx buffering variant
- accelBuffering && regBuffer.test(accelBuffering) || !regContentType.test(contentType)) {
- outgoing.writeHead(res.status, resHeaderRecord);
- flushHeaders(outgoing);
- await writeFromReadableStream(res.body, outgoing);
+ const reader = res.body.getReader();
+ const values = [];
+ let done = false;
+ let currentReadPromise = void 0;
+ if (resHeaderRecord["transfer-encoding"] !== "chunked") {
+ let maxReadCount = 2;
+ for (let i = 0; i < maxReadCount; i++) {
+ currentReadPromise ||= reader.read();
+ const chunk = await readWithoutBlocking(currentReadPromise).catch((e) => {
+ console.error(e);
+ done = true;
+ });
+ if (!chunk) {
+ if (i === 1) {
+ await new Promise((resolve) => setTimeout(resolve));
+ maxReadCount = 3;
+ continue;
+ }
+ break;
+ }
+ currentReadPromise = void 0;
+ if (chunk.value) {
+ values.push(chunk.value);
+ }
+ if (chunk.done) {
+ done = true;
+ break;
+ }
+ }
+ if (done && !("content-length" in resHeaderRecord)) {
+ resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
+ }
+ }
+ outgoing.writeHead(res.status, resHeaderRecord);
+ values.forEach((value) => {
+ ;
+ outgoing.write(value);
+ });
+ if (done) {
+ outgoing.end();
} else {
- const buffer = await res.arrayBuffer();
- resHeaderRecord["content-length"] = buffer.byteLength;
- outgoing.writeHead(res.status, resHeaderRecord);
- outgoing.end(new Uint8Array(buffer));
+ if (values.length === 0) {
+ flushHeaders(outgoing);
+ }
+ await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
}
} else if (resHeaderRecord[X_ALREADY_SENT]) {
} else {
outgoing.writeHead(res.status, resHeaderRecord);
outgoing.end();
}
+ ;
+ outgoing[outgoingEnded]?.();
};
var getRequestListener = (fetchCallback, options = {}) => {
+ const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
if (options.overrideGlobalObjects !== false && global.Request !== Request2) {
Object.defineProperty(global, "Request", {
value: Request2
@@ -2212,15 +2277,46 @@ var require_dist = __commonJS({
let res, req;
try {
req = newRequest(incoming, options.hostname);
+ let incomingEnded = !autoCleanupIncoming || incoming.method === "GET" || incoming.method === "HEAD";
+ if (!incomingEnded) {
+ ;
+ incoming[wrapBodyStream] = true;
+ incoming.on("end", () => {
+ incomingEnded = true;
+ });
+ if (incoming instanceof import_node_http22.Http2ServerRequest) {
+ ;
+ outgoing[outgoingEnded] = () => {
+ if (!incomingEnded) {
+ setTimeout(() => {
+ if (!incomingEnded) {
+ setTimeout(() => {
+ incoming.destroy();
+ outgoing.destroy();
+ });
+ }
+ });
+ }
+ };
+ }
+ }
outgoing.on("close", () => {
const abortController = req[abortControllerKey];
- if (!abortController) {
- return;
+ if (abortController) {
+ if (incoming.errored) {
+ req[abortControllerKey].abort(incoming.errored.toString());
+ } else if (!outgoing.writableFinished) {
+ req[abortControllerKey].abort("Client connection prematurely closed.");
+ }
}
- if (incoming.errored) {
- req[abortControllerKey].abort(incoming.errored.toString());
- } else if (!outgoing.writableFinished) {
- req[abortControllerKey].abort("Client connection prematurely closed.");
+ if (!incomingEnded) {
+ setTimeout(() => {
+ if (!incomingEnded) {
+ setTimeout(() => {
+ incoming.destroy();
+ });
+ }
+ });
}
});
res = fetchCallback(req, { incoming, outgoing });
@@ -2254,7 +2350,8 @@ var require_dist = __commonJS({
const fetchCallback = options.fetch;
const requestListener = getRequestListener(fetchCallback, {
hostname: options.hostname,
- overrideGlobalObjects: options.overrideGlobalObjects
+ overrideGlobalObjects: options.overrideGlobalObjects,
+ autoCleanupIncoming: options.autoCleanupIncoming
});
const createServer = options.createServer || import_node_http.createServer;
const server = createServer(options.serverOptions || {}, requestListener);
@@ -2342,6 +2439,56 @@ var require_compose = __commonJS({
}
});
+// ../node_modules/hono/dist/cjs/http-exception.js
+var require_http_exception = __commonJS({
+ "../node_modules/hono/dist/cjs/http-exception.js"(exports2, module2) {
+ "use strict";
+ var __defProp2 = Object.defineProperty;
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp2(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps2 = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames2(from))
+ if (!__hasOwnProp2.call(to, key) && key !== except)
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
+ var http_exception_exports = {};
+ __export(http_exception_exports, {
+ HTTPException: () => HTTPException
+ });
+ module2.exports = __toCommonJS(http_exception_exports);
+ var HTTPException = class extends Error {
+ res;
+ status;
+ constructor(status = 500, options) {
+ super(options?.message, { cause: options?.cause });
+ this.res = options?.res;
+ this.status = status;
+ }
+ getResponse() {
+ if (this.res) {
+ const newResponse = new Response(this.res.body, {
+ status: this.status,
+ headers: this.res.headers
+ });
+ return newResponse;
+ }
+ return new Response(this.message, {
+ status: this.status
+ });
+ }
+ };
+ }
+});
+
// ../node_modules/hono/dist/cjs/request/constants.js
var require_constants = __commonJS({
"../node_modules/hono/dist/cjs/request/constants.js"(exports2, module2) {
@@ -2574,10 +2721,7 @@ var require_url = __commonJS({
var tryDecodeURI = (str) => tryDecode(str, decodeURI);
var getPath = (request) => {
const url = request.url;
- const start = url.indexOf(
- "/",
- url.charCodeAt(9) === 58 ? 13 : 8
- );
+ const start = url.indexOf("/", url.indexOf(":") + 4);
let i = start;
for (; i < url.length; i++) {
const charCode = url.charCodeAt(i);
@@ -2644,9 +2788,12 @@ var require_url = __commonJS({
var _getQueryParam = (url, key, multiple) => {
let encoded;
if (!multiple && key && !/[%+]/.test(key)) {
- let keyIndex2 = url.indexOf(`?${key}`, 8);
+ let keyIndex2 = url.indexOf("?", 8);
if (keyIndex2 === -1) {
- keyIndex2 = url.indexOf(`&${key}`, 8);
+ return void 0;
+ }
+ if (!url.startsWith(key, keyIndex2 + 1)) {
+ keyIndex2 = url.indexOf(`&${key}`, keyIndex2 + 1);
}
while (keyIndex2 !== -1) {
const trailingKeyCode = url.charCodeAt(keyIndex2 + key.length + 1);
@@ -2736,9 +2883,11 @@ var require_request2 = __commonJS({
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var request_exports = {};
__export(request_exports, {
- HonoRequest: () => HonoRequest
+ HonoRequest: () => HonoRequest,
+ cloneRawRequest: () => cloneRawRequest
});
module2.exports = __toCommonJS(request_exports);
+ var import_http_exception = require_http_exception();
var import_constants = require_constants();
var import_body = require_body2();
var import_url = require_url();
@@ -2762,14 +2911,14 @@ var require_request2 = __commonJS({
#getDecodedParam(key) {
const paramKey = this.#matchResult[0][this.routeIndex][1][key];
const param = this.#getParamValue(paramKey);
- return param ? /\%/.test(param) ? tryDecodeURIComponent(param) : param : void 0;
+ return param && /\%/.test(param) ? tryDecodeURIComponent(param) : param;
}
#getAllDecodedParams() {
const decoded = {};
const keys = Object.keys(this.#matchResult[0][this.routeIndex][1]);
for (const key of keys) {
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
- if (value && typeof value === "string") {
+ if (value !== void 0) {
decoded[key] = /\%/.test(value) ? tryDecodeURIComponent(value) : value;
}
}
@@ -2851,6 +3000,32 @@ var require_request2 = __commonJS({
return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
}
};
+ var cloneRawRequest = async (req) => {
+ if (!req.raw.bodyUsed) {
+ return req.raw.clone();
+ }
+ const cacheKey = Object.keys(req.bodyCache)[0];
+ if (!cacheKey) {
+ throw new import_http_exception.HTTPException(500, {
+ message: "Cannot clone request: body was already consumed and not cached. Please use HonoRequest methods (e.g., req.json(), req.text()) instead of consuming req.raw directly."
+ });
+ }
+ const requestInit = {
+ body: await req[cacheKey](),
+ cache: req.raw.cache,
+ credentials: req.raw.credentials,
+ headers: req.header(),
+ integrity: req.raw.integrity,
+ keepalive: req.raw.keepalive,
+ method: req.method,
+ mode: req.raw.mode,
+ redirect: req.raw.redirect,
+ referrer: req.raw.referrer,
+ referrerPolicy: req.raw.referrerPolicy,
+ signal: req.raw.signal
+ };
+ return new Request(req.url, requestInit);
+ };
}
});
@@ -3541,6 +3716,56 @@ var require_hono_base = __commonJS({
}
});
+// ../node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js
+var require_matcher = __commonJS({
+ "../node_modules/hono/dist/cjs/router/reg-exp-router/matcher.js"(exports2, module2) {
+ "use strict";
+ var __defProp2 = Object.defineProperty;
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp2(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps2 = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames2(from))
+ if (!__hasOwnProp2.call(to, key) && key !== except)
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
+ var matcher_exports = {};
+ __export(matcher_exports, {
+ emptyParam: () => emptyParam,
+ match: () => match
+ });
+ module2.exports = __toCommonJS(matcher_exports);
+ var import_router = require_router();
+ var emptyParam = [];
+ function match(method, path) {
+ const matchers = this.buildAllMatchers();
+ const match2 = (method2, path2) => {
+ const matcher = matchers[method2] || matchers[import_router.METHOD_NAME_ALL];
+ const staticMatch = matcher[2][path2];
+ if (staticMatch) {
+ return staticMatch;
+ }
+ const match3 = path2.match(matcher[0]);
+ if (!match3) {
+ return [[], emptyParam];
+ }
+ const index = match3.indexOf("", 1);
+ return [matcher[1][index], match3];
+ };
+ this.match = match2;
+ return match2(method, path);
+ }
+ }
+});
+
// ../node_modules/hono/dist/cjs/router/reg-exp-router/node.js
var require_node = __commonJS({
"../node_modules/hono/dist/cjs/router/reg-exp-router/node.js"(exports2, module2) {
@@ -3614,6 +3839,9 @@ var require_node = __commonJS({
const name = pattern[1];
let regexpStr = pattern[2] || LABEL_REG_EXP_STR;
if (name && pattern[2]) {
+ if (regexpStr === ".*") {
+ throw PATH_ERROR;
+ }
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
if (/\((?!\?:)/.test(regexpStr)) {
throw PATH_ERROR;
@@ -3786,9 +4014,9 @@ var require_router2 = __commonJS({
module2.exports = __toCommonJS(router_exports);
var import_router = require_router();
var import_url = require_url();
+ var import_matcher = require_matcher();
var import_node = require_node();
var import_trie = require_trie();
- var emptyParam = [];
var nullMatcher = [/^$/, [], /* @__PURE__ */ Object.create(null)];
var wildcardRegExpCache = /* @__PURE__ */ Object.create(null);
function buildWildcardRegExp(path) {
@@ -3817,7 +4045,7 @@ var require_router2 = __commonJS({
for (let i = 0, j = -1, len = routesWithStaticPathFlag.length; i < len; i++) {
const [pathErrorCheckOnly, path, handlers] = routesWithStaticPathFlag[i];
if (pathErrorCheckOnly) {
- staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), emptyParam];
+ staticMap[path] = [handlers.map(([h]) => [h, /* @__PURE__ */ Object.create(null)]), import_matcher.emptyParam];
} else {
j++;
}
@@ -3935,30 +4163,14 @@ var require_router2 = __commonJS({
});
}
}
- match(method, path) {
- clearWildcardRegExpCache();
- const matchers = this.#buildAllMatchers();
- this.match = (method2, path2) => {
- const matcher = matchers[method2] || matchers[import_router.METHOD_NAME_ALL];
- const staticMatch = matcher[2][path2];
- if (staticMatch) {
- return staticMatch;
- }
- const match = path2.match(matcher[0]);
- if (!match) {
- return [[], emptyParam];
- }
- const index = match.indexOf("", 1);
- return [matcher[1][index], match];
- };
- return this.match(method, path);
- }
- #buildAllMatchers() {
+ match = import_matcher.match;
+ buildAllMatchers() {
const matchers = /* @__PURE__ */ Object.create(null);
Object.keys(this.#routes).concat(Object.keys(this.#middleware)).forEach((method) => {
matchers[method] ||= this.#buildMatcher(method);
});
this.#middleware = this.#routes = void 0;
+ clearWildcardRegExpCache();
return matchers;
}
#buildMatcher(method) {
@@ -3985,6 +4197,173 @@ var require_router2 = __commonJS({
}
});
+// ../node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js
+var require_prepared_router = __commonJS({
+ "../node_modules/hono/dist/cjs/router/reg-exp-router/prepared-router.js"(exports2, module2) {
+ "use strict";
+ var __defProp2 = Object.defineProperty;
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
+ var __export = (target, all) => {
+ for (var name in all)
+ __defProp2(target, name, { get: all[name], enumerable: true });
+ };
+ var __copyProps2 = (to, from, except, desc) => {
+ if (from && typeof from === "object" || typeof from === "function") {
+ for (let key of __getOwnPropNames2(from))
+ if (!__hasOwnProp2.call(to, key) && key !== except)
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
+ }
+ return to;
+ };
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
+ var prepared_router_exports = {};
+ __export(prepared_router_exports, {
+ PreparedRegExpRouter: () => PreparedRegExpRouter2,
+ buildInitParams: () => buildInitParams2,
+ serializeInitParams: () => serializeInitParams2
+ });
+ module2.exports = __toCommonJS(prepared_router_exports);
+ var import_router = require_router();
+ var import_matcher = require_matcher();
+ var import_router2 = require_router2();
+ var PreparedRegExpRouter2 = class {
+ name = "PreparedRegExpRouter";
+ #matchers;
+ #relocateMap;
+ constructor(matchers, relocateMap) {
+ this.#matchers = matchers;
+ this.#relocateMap = relocateMap;
+ }
+ #addWildcard(method, handlerData) {
+ const matcher = this.#matchers[method];
+ matcher[1].forEach((list) => list && list.push(handlerData));
+ Object.values(matcher[2]).forEach((list) => list[0].push(handlerData));
+ }
+ #addPath(method, path, handler, indexes, map) {
+ const matcher = this.#matchers[method];
+ if (!map) {
+ matcher[2][path][0].push([handler, {}]);
+ } else {
+ indexes.forEach((index) => {
+ if (typeof index === "number") {
+ matcher[1][index].push([handler, map]);
+ } else {
+ ;
+ matcher[2][index || path][0].push([handler, map]);
+ }
+ });
+ }
+ }
+ add(method, path, handler) {
+ if (!this.#matchers[method]) {
+ const all = this.#matchers[import_router.METHOD_NAME_ALL];
+ const staticMap = {};
+ for (const key in all[2]) {
+ staticMap[key] = [all[2][key][0].slice(), import_matcher.emptyParam];
+ }
+ this.#matchers[method] = [
+ all[0],
+ all[1].map((list) => Array.isArray(list) ? list.slice() : 0),
+ staticMap
+ ];
+ }
+ if (path === "/*" || path === "*") {
+ const handlerData = [handler, {}];
+ if (method === import_router.METHOD_NAME_ALL) {
+ for (const m in this.#matchers) {
+ this.#addWildcard(m, handlerData);
+ }
+ } else {
+ this.#addWildcard(method, handlerData);
+ }
+ return;
+ }
+ const data = this.#relocateMap[path];
+ if (!data) {
+ throw new Error(`Path ${path} is not registered`);
+ }
+ for (const [indexes, map] of data) {
+ if (method === import_router.METHOD_NAME_ALL) {
+ for (const m in this.#matchers) {
+ this.#addPath(m, path, handler, indexes, map);
+ }
+ } else {
+ this.#addPath(method, path, handler, indexes, map);
+ }
+ }
+ }
+ buildAllMatchers() {
+ return this.#matchers;
+ }
+ match = import_matcher.match;
+ };
+ var buildInitParams2 = ({ paths }) => {
+ const RegExpRouterWithMatcherExport = class extends import_router2.RegExpRouter {
+ buildAndExportAllMatchers() {
+ return this.buildAllMatchers();
+ }
+ };
+ const router = new RegExpRouterWithMatcherExport();
+ for (const path of paths) {
+ router.add(import_router.METHOD_NAME_ALL, path, path);
+ }
+ const matchers = router.buildAndExportAllMatchers();
+ const all = matchers[import_router.METHOD_NAME_ALL];
+ const relocateMap = {};
+ for (const path of paths) {
+ if (path === "/*" || path === "*") {
+ continue;
+ }
+ all[1].forEach((list, i) => {
+ list.forEach(([p, map]) => {
+ if (p === path) {
+ if (relocateMap[path]) {
+ relocateMap[path][0][1] = {
+ ...relocateMap[path][0][1],
+ ...map
+ };
+ } else {
+ relocateMap[path] = [[[], map]];
+ }
+ if (relocateMap[path][0][0].findIndex((j) => j === i) === -1) {
+ relocateMap[path][0][0].push(i);
+ }
+ }
+ });
+ });
+ for (const path2 in all[2]) {
+ all[2][path2][0].forEach(([p]) => {
+ if (p === path) {
+ relocateMap[path] ||= [[[]]];
+ const value = path2 === path ? "" : path2;
+ if (relocateMap[path][0][0].findIndex((v) => v === value) === -1) {
+ relocateMap[path][0][0].push(value);
+ }
+ }
+ });
+ }
+ }
+ for (let i = 0, len = all[1].length; i < len; i++) {
+ all[1][i] = all[1][i] ? [] : 0;
+ }
+ for (const path in all[2]) {
+ all[2][path][0] = [];
+ }
+ return [matchers, relocateMap];
+ };
+ var serializeInitParams2 = ([matchers, relocateMap]) => {
+ const matchersStr = JSON.stringify(
+ matchers,
+ (_, value) => value instanceof RegExp ? `##${value.toString()}##` : value
+ ).replace(/"##(.+?)##"/g, (_, str) => str.replace(/\\\\/g, "\\"));
+ const relocateMapStr = JSON.stringify(relocateMap);
+ return `[${matchersStr},${relocateMapStr}]`;
+ };
+ }
+});
+
// ../node_modules/hono/dist/cjs/router/reg-exp-router/index.js
var require_reg_exp_router = __commonJS({
"../node_modules/hono/dist/cjs/router/reg-exp-router/index.js"(exports2, module2) {
@@ -4008,10 +4387,14 @@ var require_reg_exp_router = __commonJS({
var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
var reg_exp_router_exports = {};
__export(reg_exp_router_exports, {
- RegExpRouter: () => import_router.RegExpRouter
+ PreparedRegExpRouter: () => import_prepared_router.PreparedRegExpRouter,
+ RegExpRouter: () => import_router.RegExpRouter,
+ buildInitParams: () => import_prepared_router.buildInitParams,
+ serializeInitParams: () => import_prepared_router.serializeInitParams
});
module2.exports = __toCommonJS(reg_exp_router_exports);
var import_router = require_router2();
+ var import_prepared_router = require_prepared_router();
}
});
@@ -4266,10 +4649,10 @@ var require_node2 = __commonJS({
}
continue;
}
- if (!part) {
+ const [key, name, matcher] = pattern;
+ if (!part && !(matcher instanceof RegExp)) {
continue;
}
- const [key, name, matcher] = pattern;
const child = node.#children[key];
const restPathString = parts.slice(i).join("/");
if (matcher instanceof RegExp) {
@@ -4663,10 +5046,9 @@ var isPipeline = (t) => (0, import_pengueno3.isObject)(t) && "serialJobs" in t &
// dist/ci.js
var import_path = require("path");
-var REGISTRY = "oci.liz.coffee";
+var REGISTRY = "img.liz.coffee";
var NAMESPACE = "emprespresso";
var IMG = "ci";
-var REMOTE = "ssh://src.liz.coffee:2222";
var getPipeline = () => {
const gitHookPipeline = new DefaultGitHookPipelineBuilder();
const branch = gitHookPipeline.getBranch();
@@ -4716,22 +5098,6 @@ var getPipeline = () => {
if (!isRelease) {
return gitHookPipeline.build();
}
- const fetchAnsibleCode = {
- type: "fetch_code",
- arguments: {
- remoteUrl: `${REMOTE}/infra`,
- checkout: "main",
- path: "infra"
- }
- };
- const thenDeploy = {
- type: "ansible_playbook.js",
- arguments: {
- path: "infra",
- playbooks: "playbooks/ci.yml"
- }
- };
- [fetchAnsibleCode, thenDeploy].forEach((deploymentStage) => gitHookPipeline.addStage({ parallelJobs: [deploymentStage] }));
return gitHookPipeline.build();
};
var main = () => {