@ubean/routes 0.3.1 → 0.3.3
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.d.ts +2 -10
- package/dist/index.js +15 -9
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -234,15 +234,7 @@ interface RegisterOptions {
|
|
|
234
234
|
*/
|
|
235
235
|
colorModeScript?: string;
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
* Sort page routes so catch-all routes (`/**:slug`, converted to Hono `*`)
|
|
239
|
-
* are registered last. Hono's RegExpRouter matches in registration order,
|
|
240
|
-
* so a catch-all registered before a specific path (e.g. `/`) would swallow
|
|
241
|
-
* it. File-system sort order puts `[...slug].vue` before `index.vue`
|
|
242
|
-
* (`[` < `i`), which is wrong for Hono — this sort corrects it.
|
|
243
|
-
*
|
|
244
|
-
* Stable: non-catch-all pages keep their original relative order.
|
|
245
|
-
*/
|
|
237
|
+
declare function convertUbeanRoutePath(path: string): string;
|
|
246
238
|
declare function sortPagesForRegistration<T extends {
|
|
247
239
|
route: string;
|
|
248
240
|
}>(pages: readonly T[]): T[];
|
|
@@ -710,4 +702,4 @@ declare function registerOpenAPIRoutes(app: Hono<UbeanEnv$1>, options?: OpenAPIG
|
|
|
710
702
|
openAPIPath?: string;
|
|
711
703
|
}): void;
|
|
712
704
|
//#endregion
|
|
713
|
-
export { ACTIONS_ENDPOINT, ACTION_BRAND, ACTION_RESPONSE_HEADER, type ActionContext, type ActionContextStorage, ActionError, type ActionFailure, type ActionHandler, type ActionId, type ActionResult, type ActionSchema, type CompiledLayout, type CompiledMiddleware, type CompiledPage, type CompiledRoute, type CompiledRouteRule, type ComposedHandler, type DefineActionOptions, type GenericSchema, type Input, type InternalFetchOptions, type IsrCacheEntry, type IsrCacheEntryInternal, type IsrCacheStore, type IsrRule, type IsrServeOptions, type OpenAPIGenerationOptions, type RegisterOptions, type ResolveSelectSsrInput, type ResolvedSelectSsr, type RouteMeta, type RouteRegistrar, type RouteRule, type RouteRulesMiddlewareOptions, type SelectSsrMode, type SelectSsrValue, type ServerAction, type Span, type SpanAttributes, type SpanContext, type SpanEndOptions, type SpanEvent, type SpanOptions, type SpanStatus, type UbeanBindings, type UbeanContext, type UbeanEnv, type UbeanHandler, type UbeanMiddleware, UbeanRouter, type UbeanVariables, applyPathTransform, bindActionContextStorage, buildActionContext, buildFormActionUrl, buildIsrCacheKey, clearActions, clearInternalFetcher, compileRouteRules, createActionId, createActionsMiddleware, createDetachedActionContext, createInternalAdapter, createRouteLoader, createRouteRulesMiddleware, createServerRouter, defineAction, defineHandler, defineHandlerMeta, defineMiddleware, defineServerFn, describeActionsOpenApi, dispatchAction, extractRouteMeta, fail, getAction, getActionContext, getInternalFetcher, getIsrCache, getIsrRuleFromContext, getStaleIsrCache, hasAction, hasFormAction, invalidateIsrCache, invalidateIsrCachePattern, invokeServerFn, isActionFailure, isActionResponse, isActionsRequest, isBotUserAgent, isHandlerChain, isIsrEntryStale, isServerAction, isValidActionId, listActions, matchRouteRules, normalizeActionResult, normalizeIsrRule, parseActionInput, parseFormActionName, registerAction, registerActions, registerApiRoutes, registerOpenAPIRoutes, registerPageRoutes, registerRoutes, resolveSelectSsr, runAction, runPageAction, runWithActionContext, serveIsr, setInternalFetcher, setIsrCache, sortPagesForRegistration, ssrModeHeader, unwrapActionResult, unwrapServerFnResult, useRouter, validateActionInput };
|
|
705
|
+
export { ACTIONS_ENDPOINT, ACTION_BRAND, ACTION_RESPONSE_HEADER, type ActionContext, type ActionContextStorage, ActionError, type ActionFailure, type ActionHandler, type ActionId, type ActionResult, type ActionSchema, type CompiledLayout, type CompiledMiddleware, type CompiledPage, type CompiledRoute, type CompiledRouteRule, type ComposedHandler, type DefineActionOptions, type GenericSchema, type Input, type InternalFetchOptions, type IsrCacheEntry, type IsrCacheEntryInternal, type IsrCacheStore, type IsrRule, type IsrServeOptions, type OpenAPIGenerationOptions, type RegisterOptions, type ResolveSelectSsrInput, type ResolvedSelectSsr, type RouteMeta, type RouteRegistrar, type RouteRule, type RouteRulesMiddlewareOptions, type SelectSsrMode, type SelectSsrValue, type ServerAction, type Span, type SpanAttributes, type SpanContext, type SpanEndOptions, type SpanEvent, type SpanOptions, type SpanStatus, type UbeanBindings, type UbeanContext, type UbeanEnv, type UbeanHandler, type UbeanMiddleware, UbeanRouter, type UbeanVariables, applyPathTransform, bindActionContextStorage, buildActionContext, buildFormActionUrl, buildIsrCacheKey, clearActions, clearInternalFetcher, compileRouteRules, convertUbeanRoutePath, createActionId, createActionsMiddleware, createDetachedActionContext, createInternalAdapter, createRouteLoader, createRouteRulesMiddleware, createServerRouter, defineAction, defineHandler, defineHandlerMeta, defineMiddleware, defineServerFn, describeActionsOpenApi, dispatchAction, extractRouteMeta, fail, getAction, getActionContext, getInternalFetcher, getIsrCache, getIsrRuleFromContext, getStaleIsrCache, hasAction, hasFormAction, invalidateIsrCache, invalidateIsrCachePattern, invokeServerFn, isActionFailure, isActionResponse, isActionsRequest, isBotUserAgent, isHandlerChain, isIsrEntryStale, isServerAction, isValidActionId, listActions, matchRouteRules, normalizeActionResult, normalizeIsrRule, parseActionInput, parseFormActionName, registerAction, registerActions, registerApiRoutes, registerOpenAPIRoutes, registerPageRoutes, registerRoutes, resolveSelectSsr, runAction, runPageAction, runWithActionContext, serveIsr, setInternalFetcher, setIsrCache, sortPagesForRegistration, ssrModeHeader, unwrapActionResult, unwrapServerFnResult, useRouter, validateActionInput };
|
package/dist/index.js
CHANGED
|
@@ -874,21 +874,27 @@ function convertUbeanRoutePath(path) {
|
|
|
874
874
|
if (rest) return `*${name}`;
|
|
875
875
|
return `:${name}`;
|
|
876
876
|
});
|
|
877
|
+
honoPath = honoPath.replace(/:([A-Za-z_][\w-]*)\(([^()]*)\)[*+?]?/g, (_m, name, regex) => `:${name}{${regex}}`);
|
|
877
878
|
return honoPath;
|
|
878
879
|
}
|
|
879
880
|
/**
|
|
880
|
-
* Sort page routes so catch-all routes
|
|
881
|
-
*
|
|
882
|
-
*
|
|
883
|
-
*
|
|
884
|
-
*
|
|
881
|
+
* Sort page routes so catch-all routes are registered last. Hono's
|
|
882
|
+
* RegExpRouter matches in registration order, so a catch-all registered
|
|
883
|
+
* before a specific path (e.g. `/`) would swallow it. File-system sort
|
|
884
|
+
* order puts `[...slug].vue` before `index.vue` (`[` < `i`), which is
|
|
885
|
+
* wrong for Hono — this sort corrects it.
|
|
886
|
+
*
|
|
887
|
+
* Detects both catch-all spellings: the scan-default `/**:slug` form and
|
|
888
|
+
* the vue-router regex form `:slug(.*)*` / `:slug(.*)` used by custom
|
|
889
|
+
* `definePage({ path })` values.
|
|
885
890
|
*
|
|
886
891
|
* Stable: non-catch-all pages keep their original relative order.
|
|
887
892
|
*/
|
|
893
|
+
const CATCH_ALL_ROUTE_REGEX = /\/\*\*:|\(\.\*\)/;
|
|
888
894
|
function sortPagesForRegistration(pages) {
|
|
889
895
|
return [...pages].sort((a, b) => {
|
|
890
|
-
const aCatchall =
|
|
891
|
-
const bCatchall =
|
|
896
|
+
const aCatchall = CATCH_ALL_ROUTE_REGEX.test(a.route);
|
|
897
|
+
const bCatchall = CATCH_ALL_ROUTE_REGEX.test(b.route);
|
|
892
898
|
if (aCatchall && !bCatchall) return 1;
|
|
893
899
|
if (!aCatchall && bCatchall) return -1;
|
|
894
900
|
return 0;
|
|
@@ -1185,7 +1191,7 @@ async function registerPageRoutes(app, options) {
|
|
|
1185
1191
|
component: page.reuseTarget || page.name,
|
|
1186
1192
|
props,
|
|
1187
1193
|
params: c.req.param(),
|
|
1188
|
-
url:
|
|
1194
|
+
url: c.req.path + (c.req.url.includes("?") ? new URL(c.req.url).search : ""),
|
|
1189
1195
|
layout: page.layout === false ? false : page.layout || page.pageMeta?.layout || (hasDefaultLayout ? "default" : false),
|
|
1190
1196
|
errors: actionErrors,
|
|
1191
1197
|
head: page.pageMeta?.head
|
|
@@ -1479,4 +1485,4 @@ function registerOpenAPIRoutes(app, options = {}) {
|
|
|
1479
1485
|
});
|
|
1480
1486
|
}
|
|
1481
1487
|
//#endregion
|
|
1482
|
-
export { ACTIONS_ENDPOINT, ACTION_BRAND, ACTION_RESPONSE_HEADER, ActionError, UbeanRouter, applyPathTransform, bindActionContextStorage, buildActionContext, buildFormActionUrl, buildIsrCacheKey, clearActions, clearInternalFetcher, compileRouteRules, createActionId, createActionsMiddleware, createDetachedActionContext, createInternalAdapter, createRouteLoader, createRouteRulesMiddleware, createServerRouter, defineAction, defineHandler, defineHandlerMeta, defineMiddleware, defineServerFn, describeActionsOpenApi, dispatchAction, extractRouteMeta, fail, getAction, getActionContext, getInternalFetcher, getIsrCache, getIsrRuleFromContext, getStaleIsrCache, hasAction, hasFormAction, invalidateIsrCache, invalidateIsrCachePattern, invokeServerFn, isActionFailure, isActionResponse, isActionsRequest, isBotUserAgent, isHandlerChain, isIsrEntryStale, isServerAction, isValidActionId, listActions, matchRouteRules, normalizeActionResult, normalizeIsrRule, parseActionInput, parseFormActionName, registerAction, registerActions, registerApiRoutes, registerOpenAPIRoutes, registerPageRoutes, registerRoutes, resolveSelectSsr, runAction, runPageAction, runWithActionContext, serveIsr, setInternalFetcher, setIsrCache, sortPagesForRegistration, ssrModeHeader, unwrapActionResult, unwrapServerFnResult, useRouter, validateActionInput };
|
|
1488
|
+
export { ACTIONS_ENDPOINT, ACTION_BRAND, ACTION_RESPONSE_HEADER, ActionError, UbeanRouter, applyPathTransform, bindActionContextStorage, buildActionContext, buildFormActionUrl, buildIsrCacheKey, clearActions, clearInternalFetcher, compileRouteRules, convertUbeanRoutePath, createActionId, createActionsMiddleware, createDetachedActionContext, createInternalAdapter, createRouteLoader, createRouteRulesMiddleware, createServerRouter, defineAction, defineHandler, defineHandlerMeta, defineMiddleware, defineServerFn, describeActionsOpenApi, dispatchAction, extractRouteMeta, fail, getAction, getActionContext, getInternalFetcher, getIsrCache, getIsrRuleFromContext, getStaleIsrCache, hasAction, hasFormAction, invalidateIsrCache, invalidateIsrCachePattern, invokeServerFn, isActionFailure, isActionResponse, isActionsRequest, isBotUserAgent, isHandlerChain, isIsrEntryStale, isServerAction, isValidActionId, listActions, matchRouteRules, normalizeActionResult, normalizeIsrRule, parseActionInput, parseFormActionName, registerAction, registerActions, registerApiRoutes, registerOpenAPIRoutes, registerPageRoutes, registerRoutes, resolveSelectSsr, runAction, runPageAction, runWithActionContext, serveIsr, setInternalFetcher, setIsrCache, sortPagesForRegistration, ssrModeHeader, unwrapActionResult, unwrapServerFnResult, useRouter, validateActionInput };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ubean/routes",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.3",
|
|
4
4
|
"description": "Server routes runtime for ubean (defineHandler, defineMiddleware, registerRoutes, Server Actions, rou3 server router, route rules, ISR, internal-fetch, OpenAPI)",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -24,23 +24,23 @@
|
|
|
24
24
|
"@soybeanjs/fetch": "^0.1.0",
|
|
25
25
|
"@standard-community/standard-json": "^0.3.5",
|
|
26
26
|
"@standard-community/standard-openapi": "^0.2.9",
|
|
27
|
-
"@ubean/i18n": "0.3.
|
|
28
|
-
"@ubean/shared": "0.3.
|
|
27
|
+
"@ubean/i18n": "0.3.3",
|
|
28
|
+
"@ubean/shared": "0.3.3",
|
|
29
29
|
"hono": "4.13.5",
|
|
30
30
|
"hono-openapi": "^1.3.1",
|
|
31
31
|
"rou3": "^0.9.2"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^26.4.0",
|
|
35
|
-
"@ubean/pages": "0.3.
|
|
36
|
-
"@ubean/scan": "0.3.
|
|
35
|
+
"@ubean/pages": "0.3.3",
|
|
36
|
+
"@ubean/scan": "0.3.3",
|
|
37
37
|
"typescript": "7.0.2",
|
|
38
38
|
"vite-plus": "0.3.0",
|
|
39
39
|
"vue": "^3.5.42"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
|
-
"@ubean/pages": "0.3.
|
|
43
|
-
"@ubean/scan": "0.3.
|
|
42
|
+
"@ubean/pages": "0.3.3",
|
|
43
|
+
"@ubean/scan": "0.3.3",
|
|
44
44
|
"vue": "^3.0.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependenciesMeta": {
|