@hybridly/core 0.7.19 → 0.8.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 +7 -11
- package/dist/index.d.cts +17 -3
- package/dist/index.d.mts +17 -3
- package/dist/index.d.ts +17 -3
- package/dist/index.mjs +8 -12
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -77,7 +77,7 @@ async function runPluginHooks(hook, ...args) {
|
|
|
77
77
|
await forEachPlugin(async (plugin) => {
|
|
78
78
|
if (plugin[hook]) {
|
|
79
79
|
utils.debug.plugin(plugin.name, `Calling "${hook}" hook.`);
|
|
80
|
-
result
|
|
80
|
+
result &&= await plugin[hook]?.(...args) !== false;
|
|
81
81
|
}
|
|
82
82
|
});
|
|
83
83
|
return result;
|
|
@@ -404,7 +404,7 @@ function urlMatchesRoute(fullUrl, name, routeParameters) {
|
|
|
404
404
|
});
|
|
405
405
|
}
|
|
406
406
|
function generateRouteFromName(name, parameters, absolute, shouldThrow) {
|
|
407
|
-
const url = getUrlFromName(name, parameters
|
|
407
|
+
const url = getUrlFromName(name, parameters);
|
|
408
408
|
return absolute === false ? url.toString().replace(url.origin, "") : url.toString();
|
|
409
409
|
}
|
|
410
410
|
function getNameFromUrl(url, parameters) {
|
|
@@ -417,7 +417,7 @@ function getNameFromUrl(url, parameters) {
|
|
|
417
417
|
function getUrlFromName(name, parameters, shouldThrow) {
|
|
418
418
|
const routing = getRouting();
|
|
419
419
|
const definition = getRouteDefinition(name);
|
|
420
|
-
const transforms = getRouteTransformable(name, parameters
|
|
420
|
+
const transforms = getRouteTransformable(name, parameters);
|
|
421
421
|
const url = makeUrl(routing.url, (url2) => ({
|
|
422
422
|
hostname: definition.domain || url2.hostname,
|
|
423
423
|
port: routing.port?.toString() || url2.port,
|
|
@@ -465,9 +465,6 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
465
465
|
if (optional) {
|
|
466
466
|
return "";
|
|
467
467
|
}
|
|
468
|
-
if (shouldThrow === false) {
|
|
469
|
-
return "";
|
|
470
|
-
}
|
|
471
468
|
throw new MissingRouteParameter(parameterName, routeName);
|
|
472
469
|
};
|
|
473
470
|
const path = definition.uri.replace(/{([^}?]+)(\??)}/g, replaceParameter);
|
|
@@ -950,13 +947,12 @@ function isHybridResponse(response) {
|
|
|
950
947
|
return !!response?.headers[HYBRIDLY_HEADER];
|
|
951
948
|
}
|
|
952
949
|
async function navigate(options) {
|
|
953
|
-
var _a;
|
|
954
950
|
const context = getRouterContext();
|
|
955
|
-
options.hasDialog
|
|
951
|
+
options.hasDialog ??= !!options.payload?.dialog;
|
|
956
952
|
utils.debug.router("Making an internal navigation:", { context, options });
|
|
957
953
|
await runHooks("navigating", {}, options, context);
|
|
958
|
-
options.payload
|
|
959
|
-
|
|
954
|
+
options.payload ??= payloadFromContext();
|
|
955
|
+
options.payload.view ??= payloadFromContext().view;
|
|
960
956
|
function evaluateConditionalOption(option) {
|
|
961
957
|
return typeof option === "function" ? option(options) : option;
|
|
962
958
|
}
|
|
@@ -1089,7 +1085,7 @@ async function performLocalNavigation(targetUrl, options) {
|
|
|
1089
1085
|
url,
|
|
1090
1086
|
view: {
|
|
1091
1087
|
component: options?.component ?? context.view.component,
|
|
1092
|
-
properties: options?.properties ??
|
|
1088
|
+
properties: options?.properties ?? context.view.properties,
|
|
1093
1089
|
deferred: []
|
|
1094
1090
|
}
|
|
1095
1091
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -277,7 +277,7 @@ interface Router {
|
|
|
277
277
|
/** Determines if the given route name and parameters matches the current route. */
|
|
278
278
|
matches: <T extends RouteName>(name: T, parameters?: RouteParameters<T>) => boolean;
|
|
279
279
|
/** Gets the current route name. Returns `undefined` is unknown. */
|
|
280
|
-
current: () =>
|
|
280
|
+
current: () => RouteName | undefined;
|
|
281
281
|
/** Access the dialog router. */
|
|
282
282
|
dialog: DialogRouter;
|
|
283
283
|
/** Access the history state. */
|
|
@@ -523,7 +523,21 @@ declare const constants_SCROLL_REGION_ATTRIBUTE: typeof SCROLL_REGION_ATTRIBUTE;
|
|
|
523
523
|
declare const constants_STORAGE_EXTERNAL_KEY: typeof STORAGE_EXTERNAL_KEY;
|
|
524
524
|
declare const constants_VERSION_HEADER: typeof VERSION_HEADER;
|
|
525
525
|
declare namespace constants {
|
|
526
|
-
export {
|
|
526
|
+
export {
|
|
527
|
+
constants_DIALOG_KEY_HEADER as DIALOG_KEY_HEADER,
|
|
528
|
+
constants_DIALOG_REDIRECT_HEADER as DIALOG_REDIRECT_HEADER,
|
|
529
|
+
constants_ERROR_BAG_HEADER as ERROR_BAG_HEADER,
|
|
530
|
+
constants_EXCEPT_DATA_HEADER as EXCEPT_DATA_HEADER,
|
|
531
|
+
constants_EXTERNAL_NAVIGATION_HEADER as EXTERNAL_NAVIGATION_HEADER,
|
|
532
|
+
constants_EXTERNAL_NAVIGATION_TARGET_HEADER as EXTERNAL_NAVIGATION_TARGET_HEADER,
|
|
533
|
+
constants_HYBRIDLY_HEADER as HYBRIDLY_HEADER,
|
|
534
|
+
constants_ONLY_DATA_HEADER as ONLY_DATA_HEADER,
|
|
535
|
+
constants_PARTIAL_COMPONENT_HEADER as PARTIAL_COMPONENT_HEADER,
|
|
536
|
+
constants_SCROLL_REGION_ATTRIBUTE as SCROLL_REGION_ATTRIBUTE,
|
|
537
|
+
constants_STORAGE_EXTERNAL_KEY as STORAGE_EXTERNAL_KEY,
|
|
538
|
+
constants_VERSION_HEADER as VERSION_HEADER,
|
|
539
|
+
};
|
|
527
540
|
}
|
|
528
541
|
|
|
529
|
-
export {
|
|
542
|
+
export { can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls };
|
|
543
|
+
export type { Authorizable, DynamicConfiguration, GlobalRouteCollection, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, RouteDefinition, RouteName, RouteParameters, Router, RouterContext, RouterContextOptions, RoutingConfiguration, UrlResolvable };
|
package/dist/index.d.mts
CHANGED
|
@@ -277,7 +277,7 @@ interface Router {
|
|
|
277
277
|
/** Determines if the given route name and parameters matches the current route. */
|
|
278
278
|
matches: <T extends RouteName>(name: T, parameters?: RouteParameters<T>) => boolean;
|
|
279
279
|
/** Gets the current route name. Returns `undefined` is unknown. */
|
|
280
|
-
current: () =>
|
|
280
|
+
current: () => RouteName | undefined;
|
|
281
281
|
/** Access the dialog router. */
|
|
282
282
|
dialog: DialogRouter;
|
|
283
283
|
/** Access the history state. */
|
|
@@ -523,7 +523,21 @@ declare const constants_SCROLL_REGION_ATTRIBUTE: typeof SCROLL_REGION_ATTRIBUTE;
|
|
|
523
523
|
declare const constants_STORAGE_EXTERNAL_KEY: typeof STORAGE_EXTERNAL_KEY;
|
|
524
524
|
declare const constants_VERSION_HEADER: typeof VERSION_HEADER;
|
|
525
525
|
declare namespace constants {
|
|
526
|
-
export {
|
|
526
|
+
export {
|
|
527
|
+
constants_DIALOG_KEY_HEADER as DIALOG_KEY_HEADER,
|
|
528
|
+
constants_DIALOG_REDIRECT_HEADER as DIALOG_REDIRECT_HEADER,
|
|
529
|
+
constants_ERROR_BAG_HEADER as ERROR_BAG_HEADER,
|
|
530
|
+
constants_EXCEPT_DATA_HEADER as EXCEPT_DATA_HEADER,
|
|
531
|
+
constants_EXTERNAL_NAVIGATION_HEADER as EXTERNAL_NAVIGATION_HEADER,
|
|
532
|
+
constants_EXTERNAL_NAVIGATION_TARGET_HEADER as EXTERNAL_NAVIGATION_TARGET_HEADER,
|
|
533
|
+
constants_HYBRIDLY_HEADER as HYBRIDLY_HEADER,
|
|
534
|
+
constants_ONLY_DATA_HEADER as ONLY_DATA_HEADER,
|
|
535
|
+
constants_PARTIAL_COMPONENT_HEADER as PARTIAL_COMPONENT_HEADER,
|
|
536
|
+
constants_SCROLL_REGION_ATTRIBUTE as SCROLL_REGION_ATTRIBUTE,
|
|
537
|
+
constants_STORAGE_EXTERNAL_KEY as STORAGE_EXTERNAL_KEY,
|
|
538
|
+
constants_VERSION_HEADER as VERSION_HEADER,
|
|
539
|
+
};
|
|
527
540
|
}
|
|
528
541
|
|
|
529
|
-
export {
|
|
542
|
+
export { can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls };
|
|
543
|
+
export type { Authorizable, DynamicConfiguration, GlobalRouteCollection, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, RouteDefinition, RouteName, RouteParameters, Router, RouterContext, RouterContextOptions, RoutingConfiguration, UrlResolvable };
|
package/dist/index.d.ts
CHANGED
|
@@ -277,7 +277,7 @@ interface Router {
|
|
|
277
277
|
/** Determines if the given route name and parameters matches the current route. */
|
|
278
278
|
matches: <T extends RouteName>(name: T, parameters?: RouteParameters<T>) => boolean;
|
|
279
279
|
/** Gets the current route name. Returns `undefined` is unknown. */
|
|
280
|
-
current: () =>
|
|
280
|
+
current: () => RouteName | undefined;
|
|
281
281
|
/** Access the dialog router. */
|
|
282
282
|
dialog: DialogRouter;
|
|
283
283
|
/** Access the history state. */
|
|
@@ -523,7 +523,21 @@ declare const constants_SCROLL_REGION_ATTRIBUTE: typeof SCROLL_REGION_ATTRIBUTE;
|
|
|
523
523
|
declare const constants_STORAGE_EXTERNAL_KEY: typeof STORAGE_EXTERNAL_KEY;
|
|
524
524
|
declare const constants_VERSION_HEADER: typeof VERSION_HEADER;
|
|
525
525
|
declare namespace constants {
|
|
526
|
-
export {
|
|
526
|
+
export {
|
|
527
|
+
constants_DIALOG_KEY_HEADER as DIALOG_KEY_HEADER,
|
|
528
|
+
constants_DIALOG_REDIRECT_HEADER as DIALOG_REDIRECT_HEADER,
|
|
529
|
+
constants_ERROR_BAG_HEADER as ERROR_BAG_HEADER,
|
|
530
|
+
constants_EXCEPT_DATA_HEADER as EXCEPT_DATA_HEADER,
|
|
531
|
+
constants_EXTERNAL_NAVIGATION_HEADER as EXTERNAL_NAVIGATION_HEADER,
|
|
532
|
+
constants_EXTERNAL_NAVIGATION_TARGET_HEADER as EXTERNAL_NAVIGATION_TARGET_HEADER,
|
|
533
|
+
constants_HYBRIDLY_HEADER as HYBRIDLY_HEADER,
|
|
534
|
+
constants_ONLY_DATA_HEADER as ONLY_DATA_HEADER,
|
|
535
|
+
constants_PARTIAL_COMPONENT_HEADER as PARTIAL_COMPONENT_HEADER,
|
|
536
|
+
constants_SCROLL_REGION_ATTRIBUTE as SCROLL_REGION_ATTRIBUTE,
|
|
537
|
+
constants_STORAGE_EXTERNAL_KEY as STORAGE_EXTERNAL_KEY,
|
|
538
|
+
constants_VERSION_HEADER as VERSION_HEADER,
|
|
539
|
+
};
|
|
527
540
|
}
|
|
528
541
|
|
|
529
|
-
export {
|
|
542
|
+
export { can, constants, createRouter, definePlugin, getRouterContext, makeUrl, registerHook, route, router, sameUrls };
|
|
543
|
+
export type { Authorizable, DynamicConfiguration, GlobalRouteCollection, HybridPayload, HybridRequestOptions, MaybePromise, Method, NavigationResponse, Plugin, Progress, ResolveComponent, RouteDefinition, RouteName, RouteParameters, Router, RouterContext, RouterContextOptions, RoutingConfiguration, UrlResolvable };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { debug, merge, removeTrailingSlash, debounce, random, hasFiles, objectToFormData, match, showResponseErrorModal, when } from '@hybridly/utils';
|
|
2
2
|
import qs from 'qs';
|
|
3
3
|
import axios from 'axios';
|
|
4
|
-
import {
|
|
4
|
+
import { parse, stringify } from 'superjson';
|
|
5
5
|
|
|
6
6
|
const STORAGE_EXTERNAL_KEY = "hybridly:external";
|
|
7
7
|
const HYBRIDLY_HEADER = "x-hybrid";
|
|
@@ -70,7 +70,7 @@ async function runPluginHooks(hook, ...args) {
|
|
|
70
70
|
await forEachPlugin(async (plugin) => {
|
|
71
71
|
if (plugin[hook]) {
|
|
72
72
|
debug.plugin(plugin.name, `Calling "${hook}" hook.`);
|
|
73
|
-
result
|
|
73
|
+
result &&= await plugin[hook]?.(...args) !== false;
|
|
74
74
|
}
|
|
75
75
|
});
|
|
76
76
|
return result;
|
|
@@ -397,7 +397,7 @@ function urlMatchesRoute(fullUrl, name, routeParameters) {
|
|
|
397
397
|
});
|
|
398
398
|
}
|
|
399
399
|
function generateRouteFromName(name, parameters, absolute, shouldThrow) {
|
|
400
|
-
const url = getUrlFromName(name, parameters
|
|
400
|
+
const url = getUrlFromName(name, parameters);
|
|
401
401
|
return absolute === false ? url.toString().replace(url.origin, "") : url.toString();
|
|
402
402
|
}
|
|
403
403
|
function getNameFromUrl(url, parameters) {
|
|
@@ -410,7 +410,7 @@ function getNameFromUrl(url, parameters) {
|
|
|
410
410
|
function getUrlFromName(name, parameters, shouldThrow) {
|
|
411
411
|
const routing = getRouting();
|
|
412
412
|
const definition = getRouteDefinition(name);
|
|
413
|
-
const transforms = getRouteTransformable(name, parameters
|
|
413
|
+
const transforms = getRouteTransformable(name, parameters);
|
|
414
414
|
const url = makeUrl(routing.url, (url2) => ({
|
|
415
415
|
hostname: definition.domain || url2.hostname,
|
|
416
416
|
port: routing.port?.toString() || url2.port,
|
|
@@ -458,9 +458,6 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
458
458
|
if (optional) {
|
|
459
459
|
return "";
|
|
460
460
|
}
|
|
461
|
-
if (shouldThrow === false) {
|
|
462
|
-
return "";
|
|
463
|
-
}
|
|
464
461
|
throw new MissingRouteParameter(parameterName, routeName);
|
|
465
462
|
};
|
|
466
463
|
const path = definition.uri.replace(/{([^}?]+)(\??)}/g, replaceParameter);
|
|
@@ -943,13 +940,12 @@ function isHybridResponse(response) {
|
|
|
943
940
|
return !!response?.headers[HYBRIDLY_HEADER];
|
|
944
941
|
}
|
|
945
942
|
async function navigate(options) {
|
|
946
|
-
var _a;
|
|
947
943
|
const context = getRouterContext();
|
|
948
|
-
options.hasDialog
|
|
944
|
+
options.hasDialog ??= !!options.payload?.dialog;
|
|
949
945
|
debug.router("Making an internal navigation:", { context, options });
|
|
950
946
|
await runHooks("navigating", {}, options, context);
|
|
951
|
-
options.payload
|
|
952
|
-
|
|
947
|
+
options.payload ??= payloadFromContext();
|
|
948
|
+
options.payload.view ??= payloadFromContext().view;
|
|
953
949
|
function evaluateConditionalOption(option) {
|
|
954
950
|
return typeof option === "function" ? option(options) : option;
|
|
955
951
|
}
|
|
@@ -1082,7 +1078,7 @@ async function performLocalNavigation(targetUrl, options) {
|
|
|
1082
1078
|
url,
|
|
1083
1079
|
view: {
|
|
1084
1080
|
component: options?.component ?? context.view.component,
|
|
1085
|
-
properties: options?.properties ??
|
|
1081
|
+
properties: options?.properties ?? context.view.properties,
|
|
1086
1082
|
deferred: []
|
|
1087
1083
|
}
|
|
1088
1084
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/core",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.1",
|
|
5
5
|
"description": "Core functionality of Hybridly",
|
|
6
6
|
"author": "Enzo Innocenzi <enzo@innocenzi.dev>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"qs": "^6.14.0",
|
|
45
45
|
"superjson": "^2.2.2",
|
|
46
|
-
"@hybridly/utils": "0.
|
|
46
|
+
"@hybridly/utils": "0.8.1"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"defu": "^6.1.4"
|