From 66661d5953f83a1906ebb496f54543bcd022935b Mon Sep 17 00:00:00 2001 From: e780671166-netizen <289332946+e780671166-netizen@users.noreply.github.com> Date: Sat, 7 Nov 2026 15:58:26 +0800 Subject: [PATCH] fix(build): restore green builds under the current stable toolchain --- cors/pkg.generated.mbti | 4 ++-- error_wbtest.mbt | 3 ++- examples/static_assets/moon.pkg | 2 +- multipart/pkg.generated.mbti | 16 ++++++++------ multipart/reader.mbt | 3 ++- native/mongoose/pkg.generated.mbti | 2 +- path_match.mbt | 4 ++-- pkg.generated.mbti | 35 +++++++++++++++--------------- static.mbt | 6 ++--- static_file/moon.pkg | 2 +- static_file/static_file.mbt | 10 +++++---- status_code.mbt | 3 ++- uri/pkg.generated.mbti | 11 ++++++---- uri/uri.mbt | 9 +++++--- 14 files changed, 62 insertions(+), 48 deletions(-) diff --git a/cors/pkg.generated.mbti b/cors/pkg.generated.mbti index 9930930..589f1e0 100644 --- a/cors/pkg.generated.mbti +++ b/cors/pkg.generated.mbti @@ -8,9 +8,9 @@ import { // Values pub fn append_cors_headers(@mocket.MocketEvent, origin? : String, methods? : String, allow_headers? : String, expose_headers? : String, credentials? : Bool) -> Unit -pub fn append_cors_preflight_headers(@mocket.MocketEvent, origin? : String, methods? : String, allow_headers? : String, credentials? : Bool, max_age? : Int) -> Unit +pub fn append_cors_preflight_headers(@mocket.MocketEvent, origin? : String, methods? : String, allow_headers? : String, credentials? : Bool, max_age? : Int32) -> Unit -pub fn handle_cors(origin? : String, methods? : String, allow_headers? : String, expose_headers? : String, credentials? : Bool, max_age? : Int) -> async (@mocket.MocketEvent, async () -> &@mocket.Responder) -> &@mocket.Responder +pub fn handle_cors(origin? : String, methods? : String, allow_headers? : String, expose_headers? : String, credentials? : Bool, max_age? : Int32) -> async (@mocket.MocketEvent, async () -> &@mocket.Responder) -> &@mocket.Responder pub fn is_preflight_request(@mocket.MocketEvent) -> Bool diff --git a/error_wbtest.mbt b/error_wbtest.mbt index c801e7e..3931f69 100644 --- a/error_wbtest.mbt +++ b/error_wbtest.mbt @@ -1,7 +1,8 @@ ///| +#derive(Debug) suberror TestRequestError { TestRequestError(String) -} derive(Debug) +} ///| pub extend TestRequestError with Debug::{to_repr} diff --git a/examples/static_assets/moon.pkg b/examples/static_assets/moon.pkg index 3809da1..b32957a 100644 --- a/examples/static_assets/moon.pkg +++ b/examples/static_assets/moon.pkg @@ -7,6 +7,6 @@ import { warnings = "-67" -supported_targets = "+native+wasm+js" +supported_targets = "+native+js" pkgtype(kind: "executable") diff --git a/multipart/pkg.generated.mbti b/multipart/pkg.generated.mbti index 5e0feb4..9245506 100644 --- a/multipart/pkg.generated.mbti +++ b/multipart/pkg.generated.mbti @@ -5,15 +5,17 @@ import { "moonbitlang/async/http", "moonbitlang/async/io", "moonbitlang/core/debug", + "moonbitlang/core/json", } // Values pub fn parse_header_value(String) -> (String, Map[@http.CaseInsensitiveString, String]) raise MultipartError // Errors +#derive(@debug.Debug) pub suberror MultipartError { MultipartError(String) -} derive(@debug.Debug) +} pub fn MultipartError::to_repr(Self) -> @debug.Repr // Types and methods @@ -22,17 +24,17 @@ pub fn Form::Form(&@io.Reader, boundary~ : String) -> Self raise MultipartError pub async fn Form::next_part(Self) -> FormPart? type FormPart -pub async fn FormPart::_direct_read(Self, FixedArray[Byte], offset~ : Int, max_len~ : Int) -> Int +pub async fn FormPart::_direct_read(Self, FixedArray[Byte], offset~ : Int32, max_len~ : Int32) -> Int32 pub fn FormPart::_get_internal_buffer(Self) -> @io.ReaderBuffer pub fn FormPart::content_type(Self) -> String -pub async fn FormPart::drop(Self, Int) -> Int +pub async fn FormPart::drop(Self, Int32) -> Int32 pub fn FormPart::filename(Self) -> String? pub fn FormPart::headers(Self) -> Map[@http.CaseInsensitiveString, String] pub fn FormPart::name(Self) -> String -pub async fn FormPart::read(Self, FixedArray[Byte], offset? : Int, max_len? : Int) -> Int +pub async fn FormPart::read(Self, FixedArray[Byte], offset? : Int32, max_len? : Int32) -> Int32 pub async fn FormPart::read_all(Self) -> &@io.Data -pub async fn FormPart::read_exactly(Self, Int) -> Bytes -pub async fn FormPart::read_some(Self, max_len? : Int) -> Bytes? +pub async fn FormPart::read_exactly(Self, Int32) -> Bytes +pub async fn FormPart::read_some(Self, max_len? : Int32) -> Bytes? pub async fn FormPart::read_until(Self, StringView) -> String? pub impl @io.Reader for FormPart @@ -43,7 +45,7 @@ pub fn FormWriter::content_type(Self) -> String pub async fn FormWriter::finish(Self) -> Unit pub async fn FormWriter::write_field(Self, String, String) -> Unit pub async fn FormWriter::write_file(Self, String, filename? : String, content_type? : String, &@io.Reader) -> Unit -pub async fn FormWriter::write_json(Self, String, Json) -> Unit +pub async fn FormWriter::write_json(Self, String, @json.Json) -> Unit pub async fn FormWriter::write_part(Self, headers~ : Map[@http.CaseInsensitiveString, String], async (&@io.Writer) -> Unit) -> Unit type Reader diff --git a/multipart/reader.mbt b/multipart/reader.mbt index 4b5e981..bbd90c9 100644 --- a/multipart/reader.mbt +++ b/multipart/reader.mbt @@ -1,7 +1,8 @@ ///| +#derive(Debug) pub suberror MultipartError { MultipartError(String) -} derive(Debug) +} ///| pub extend MultipartError with Debug::{to_repr} diff --git a/native/mongoose/pkg.generated.mbti b/native/mongoose/pkg.generated.mbti index e74f8ed..f7c6a99 100644 --- a/native/mongoose/pkg.generated.mbti +++ b/native/mongoose/pkg.generated.mbti @@ -11,7 +11,7 @@ pub fn __ws_emit(Bytes, Bytes, Bytes) -> Unit pub fn listen(@mocket.App, String) -> Unit #deprecated -pub fn serve(@mocket.App, port~ : Int) -> Unit +pub fn serve(@mocket.App, port~ : Int32) -> Unit // Errors diff --git a/path_match.mbt b/path_match.mbt index 76c829a..602e04c 100644 --- a/path_match.mbt +++ b/path_match.mbt @@ -52,7 +52,7 @@ fn match_path_segments( let path_part = path_parts[path_idx] // 使用正则匹配参数模式 - if template_part.view() =~ (re"^:", after=param_name) { + if template_part.clamped_view() =~ (re"^:", after=param_name) { // 命名参数::param_name params.set(param_name.to_owned(), path_part) match_path_segments( @@ -260,7 +260,7 @@ fn DynamicRouteTrieNode::insert( child } } - } else if part.view() =~ (re"^:", after=param_name) { + } else if part.clamped_view() =~ (re"^:", after=param_name) { let param_name = param_name.to_owned() node = match node.param_child(param_name) { Some(child) => child diff --git a/pkg.generated.mbti b/pkg.generated.mbti index f25e9e1..f4de72b 100644 --- a/pkg.generated.mbti +++ b/pkg.generated.mbti @@ -28,7 +28,7 @@ pub fn html(&Show) -> &Responder pub async fn listen_ffi(App, String) -> Unit noraise #deprecated -pub fn new(base_path? : String, max_body_size? : Int) -> App +pub fn new(base_path? : String, max_body_size? : Int32) -> App pub fn parse_form_data(BytesView) -> Map[String, String] @@ -38,11 +38,11 @@ pub fn parse_request_cookie(StringView) -> Map[String, @http.Cookie] pub fn register_ws_connection(String, (String) -> Unit, (Bytes) -> Unit, () -> Unit) -> Unit -pub fn register_ws_handler(App, Int) -> Unit +pub fn register_ws_handler(App, Int32) -> Unit pub fn serialize_cookie(@http.Cookie) -> String -pub async fn serve_ffi(App, port~ : Int) -> Unit noraise +pub async fn serve_ffi(App, port~ : Int32) -> Unit noraise pub async fn[T, E : Error] suspend(((T) -> Unit, (E) -> Unit) -> Unit) -> T raise E @@ -93,13 +93,13 @@ pub(all) struct App { ws_dynamic_routes : Array[(String, (WebSocketEvent) -> Unit)] ws_clients : Map[String, Unit] ws_channels : Map[String, Map[String, Unit]] - ws_client_port : Map[String, Int] - max_body_size : Int + ws_client_port : Map[String, Int32] + max_body_size : Int32 mut error_handler : (MocketEvent, Error) -> &Responder // private fields } #alias(new, deprecated) -pub fn App::App(base_path? : String, max_body_size? : Int) -> Self +pub fn App::App(base_path? : String, max_body_size? : Int32) -> Self pub fn App::acl(Self, String, async (MocketEvent) -> &Responder) -> Unit pub fn App::all(Self, String, async (MocketEvent) -> &Responder) -> Unit pub fn App::bind(Self, String, async (MocketEvent) -> &Responder) -> Unit @@ -137,7 +137,7 @@ pub fn App::rebind(Self, String, async (MocketEvent) -> &Responder) -> Unit pub fn App::report(Self, String, async (MocketEvent) -> &Responder) -> Unit pub fn App::search(Self, String, async (MocketEvent) -> &Responder) -> Unit #deprecated -pub async fn App::serve(Self, port~ : Int) -> Unit noraise +pub async fn App::serve(Self, port~ : Int32) -> Unit noraise pub fn App::static_assets(Self, String, &ServeStaticProvider) -> Unit pub fn App::trace(Self, String, async (MocketEvent) -> &Responder) -> Unit pub fn App::unbind(Self, String, async (MocketEvent) -> &Responder) -> Unit @@ -190,7 +190,7 @@ pub(all) struct HttpResponse { pub fn HttpResponse::HttpResponse(StatusCode, headers? : Map[@http.CaseInsensitiveString, StringView], cookies? : Array[@http.Cookie], body? : &Responder) -> Self pub fn HttpResponse::body(Self, &Responder) -> Self pub fn HttpResponse::delete_cookie(Self, String) -> Unit -pub fn HttpResponse::json(Self, &ToJson) -> Self +pub fn HttpResponse::json(Self, &@json.ToJson) -> Self pub fn HttpResponse::options(Self, Self) -> Unit pub async fn HttpResponse::output(Self, &@io.Writer) -> Unit pub async fn[T : BodyReader] HttpResponse::read_body(Self) -> T @@ -217,7 +217,7 @@ pub(all) struct ResponseBuffer { pub fn ResponseBuffer::bytes(Self) -> Bytes pub fn ResponseBuffer::new() -> Self pub async fn ResponseBuffer::write(Self, &@io.Data) -> Unit -pub async fn ResponseBuffer::write_once(Self, Bytes, offset~ : Int, len~ : Int) -> Int +pub async fn ResponseBuffer::write_once(Self, Bytes, offset~ : Int32, len~ : Int32) -> Int32 pub async fn ResponseBuffer::write_reader(Self, &@io.Reader) -> Unit pub impl @io.Writer for ResponseBuffer @@ -231,6 +231,7 @@ pub(all) struct StaticAssetMeta { } pub fn StaticAssetMeta::new(asset_type? : String, etag? : String, mtime? : Int64, path? : String, size? : Int64, encoding? : String) -> Self +#derive(Eq, @json.ToJson) pub(all) enum StatusCode { Continue SwitchingProtocols @@ -294,13 +295,13 @@ pub(all) enum StatusCode { LoopDetected NotExtended NetworkAuthenticationRequired - Custom(Int) -} derive(Eq, ToJson) + Custom(Int32) +} pub fn StatusCode::equal(Self, Self) -> Bool -pub fn StatusCode::from_int(Int) -> Self +pub fn StatusCode::from_int(Int32) -> Self pub fn StatusCode::not_equal(Self, Self) -> Bool -pub fn StatusCode::to_int(Self) -> Int -pub fn StatusCode::to_json(Self) -> Json +pub fn StatusCode::to_int(Self) -> Int32 +pub fn StatusCode::to_json(Self) -> @json.Json pub(all) enum WebSocketAggregatedMessage { Text(String) @@ -345,7 +346,7 @@ pub impl BodyReader for String pub impl BodyReader for FixedArray[Byte] pub impl BodyReader for Bytes pub impl BodyReader for Array[Byte] -pub impl BodyReader for Json +pub impl BodyReader for @json.Json pub(open) trait Responder { fn options(Self, HttpResponse) -> Unit @@ -353,8 +354,8 @@ pub(open) trait Responder { } pub impl Responder for String pub impl Responder for Bytes -pub impl Responder for Json -pub impl Responder for &ToJson +pub impl Responder for @json.Json +pub impl Responder for &@json.ToJson pub impl Responder for StringView pub(open) trait ServeStaticProvider { diff --git a/static.mbt b/static.mbt index 939a129..e31d848 100644 --- a/static.mbt +++ b/static.mbt @@ -87,7 +87,7 @@ fn join_asset_id(id : String, suffix : String) -> String { if suffix == "" { return id } - let suffix = if suffix.has_prefix("/") { suffix[1:] } else { suffix.view() } + let suffix = if suffix.has_prefix("/") { suffix[1:] } else { suffix.clamped_view() } if id.has_suffix("/") { "\{id}\{suffix}" } else { @@ -141,12 +141,12 @@ pub fn App::static_assets( } // Safe to slice now: `url` equals the mount or starts with "mount/". - let raw_id = if mount == "/" { url.view() } else { url[mount.length():] } + let raw_id = if mount == "/" { url.clamped_view() } else { url[mount.length():] } // Resolve under a virtual root so ".." segments can never escape it; // the normalized id is an absolute path confined to the mount root. let resolved_id = Show::to_string( @posix.Path::normalize( - (if raw_id == "" { "/".view() } else { raw_id }).to_owned(), + (if raw_id == "" { "/".clamped_view() } else { raw_id }).to_owned(), ), ) // Parse Accept-Encoding diff --git a/static_file/moon.pkg b/static_file/moon.pkg index 7a3916f..64f1817 100644 --- a/static_file/moon.pkg +++ b/static_file/moon.pkg @@ -17,7 +17,7 @@ import { warnings = "-20-29" -supported_targets = "+native+wasm+js" +supported_targets = "+native+js" options( targets: { diff --git a/static_file/static_file.mbt b/static_file/static_file.mbt index f2cf1dc..b48a5ae 100644 --- a/static_file/static_file.mbt +++ b/static_file/static_file.mbt @@ -1,5 +1,7 @@ // ///| + + ///| /// Serves static assets from a directory on the local filesystem. /// @@ -63,7 +65,7 @@ test "file_extension" { } ///| -pub impl ServeStaticProvider for StaticFileProvider with fn get_type( +pub impl @mocket.ServeStaticProvider for StaticFileProvider with fn get_type( _, ext : String, ) -> String? { @@ -110,7 +112,7 @@ test "mime_type_of" { } ///| -pub impl ServeStaticProvider for StaticFileProvider with fn get_encodings(_) -> Map[ +pub impl @mocket.ServeStaticProvider for StaticFileProvider with fn get_encodings(_) -> Map[ String, String, ] { @@ -118,14 +120,14 @@ pub impl ServeStaticProvider for StaticFileProvider with fn get_encodings(_) -> } ///| -pub impl ServeStaticProvider for StaticFileProvider with fn get_index_names( +pub impl @mocket.ServeStaticProvider for StaticFileProvider with fn get_index_names( self, ) -> Array[String] { self.index_names } ///| -pub impl ServeStaticProvider for StaticFileProvider with fn get_fallthrough( +pub impl @mocket.ServeStaticProvider for StaticFileProvider with fn get_fallthrough( self, ) -> Bool { self.fallthrough diff --git a/status_code.mbt b/status_code.mbt index 2d5a0b4..053fef2 100644 --- a/status_code.mbt +++ b/status_code.mbt @@ -1,6 +1,7 @@ ///| /// HTTP status codes as registered with IANA. /// See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml +#derive(ToJson, Eq) pub(all) enum StatusCode { /// RFC 9110, 15.2.1 Continue @@ -127,7 +128,7 @@ pub(all) enum StatusCode { /// RFC 6585, 6 NetworkAuthenticationRequired Custom(Int32) -} derive(ToJson, Eq) +} ///| pub extend StatusCode with ToJson::{to_json} diff --git a/uri/pkg.generated.mbti b/uri/pkg.generated.mbti index 01bbb3b..cd088aa 100644 --- a/uri/pkg.generated.mbti +++ b/uri/pkg.generated.mbti @@ -20,30 +20,33 @@ pub suberror ParseError { } // Types and methods +#derive(Eq, @debug.Debug) pub struct Authority { mut userinfo : BytesView? mut host : Host - mut port : Int? -} derive(Eq, @debug.Debug) + mut port : Int32? +} pub fn Authority::equal(Self, Self) -> Bool pub fn Authority::not_equal(Self, Self) -> Bool pub fn Authority::to_repr(Self) -> @debug.Repr +#derive(Eq, @debug.Debug) pub enum Host { IPv6Address(BytesView) RegName(BytesView) -} derive(Eq, @debug.Debug) +} pub fn Host::equal(Self, Self) -> Bool pub fn Host::not_equal(Self, Self) -> Bool pub fn Host::to_repr(Self) -> @debug.Repr +#derive(Eq, @debug.Debug) pub struct Uri { mut scheme : BytesView? mut authority : Authority? path : Array[BytesView] mut query : BytesView? mut fragment : BytesView? -} derive(Eq, @debug.Debug) +} pub fn Uri::equal(Self, Self) -> Bool pub fn Uri::not_equal(Self, Self) -> Bool pub fn Uri::parse(BytesView) -> Self raise ParseError diff --git a/uri/uri.mbt b/uri/uri.mbt index 1ebbe9d..fd38077 100644 --- a/uri/uri.mbt +++ b/uri/uri.mbt @@ -1,10 +1,11 @@ // URI parser implementation following RFC 3986 ///| +#derive(Eq, Debug) pub enum Host { IPv6Address(BytesView) RegName(BytesView) -} derive(Eq, Debug) +} ///| pub extend Host with Eq::{not_equal, equal} @@ -13,11 +14,12 @@ pub extend Host with Eq::{not_equal, equal} pub extend Host with Debug::{to_repr} ///| +#derive(Eq, Debug) pub struct Authority { mut userinfo : BytesView? mut host : Host mut port : Int32? -} derive(Eq, Debug) +} ///| pub extend Authority with Eq::{not_equal, equal} @@ -26,13 +28,14 @@ pub extend Authority with Eq::{not_equal, equal} pub extend Authority with Debug::{to_repr} ///| +#derive(Eq, Debug) pub struct Uri { mut scheme : BytesView? mut authority : Authority? path : Array[BytesView] mut query : BytesView? mut fragment : BytesView? -} derive(Eq, Debug) +} ///| pub extend Uri with Eq::{not_equal, equal}