@hybridly/core 0.0.1-alpha.21 → 0.0.1-alpha.22
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 +5 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +5 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -356,7 +356,7 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
356
356
|
const definition = getRouteDefinition(routeName);
|
|
357
357
|
const parameters = routeParameters || {};
|
|
358
358
|
const missing = Object.keys(parameters);
|
|
359
|
-
const
|
|
359
|
+
const replaceParameter = (match, parameterName) => {
|
|
360
360
|
const optional = /\?}$/.test(match);
|
|
361
361
|
const value = (() => {
|
|
362
362
|
const value2 = parameters[parameterName];
|
|
@@ -384,12 +384,15 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
384
384
|
return "";
|
|
385
385
|
}
|
|
386
386
|
throw new MissingRouteParameter(parameterName, routeName);
|
|
387
|
-
}
|
|
387
|
+
};
|
|
388
|
+
const path = definition.uri.replace(/{([^}?]+)\??}/g, replaceParameter);
|
|
389
|
+
const domain = definition.domain?.replace(/{([^}?]+)\??}/g, replaceParameter);
|
|
388
390
|
const remaining = Object.keys(parameters).filter((key) => missing.includes(key)).reduce((obj, key) => ({
|
|
389
391
|
...obj,
|
|
390
392
|
[key]: parameters[key]
|
|
391
393
|
}), {});
|
|
392
394
|
return {
|
|
395
|
+
...domain && { hostname: domain },
|
|
393
396
|
pathname: path,
|
|
394
397
|
search: qs__default.stringify(remaining, {
|
|
395
398
|
encodeValuesOnly: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -35,29 +35,29 @@ interface RequestHooks {
|
|
|
35
35
|
/**
|
|
36
36
|
* Called when a response to a request is not a valid hybrid response.
|
|
37
37
|
*/
|
|
38
|
-
invalid: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<
|
|
38
|
+
invalid: (response: AxiosResponse, context: InternalRouterContext) => MaybePromise<any>;
|
|
39
39
|
/**
|
|
40
40
|
* Called when an unknowne exception was triggered.
|
|
41
41
|
*/
|
|
42
|
-
exception: (error: Error, context: InternalRouterContext) => MaybePromise<
|
|
42
|
+
exception: (error: Error, context: InternalRouterContext) => MaybePromise<any>;
|
|
43
43
|
/**
|
|
44
44
|
* Called whenever the request failed, for any reason, in addition to other hooks.
|
|
45
45
|
*/
|
|
46
|
-
fail: (context: InternalRouterContext) => MaybePromise<
|
|
46
|
+
fail: (context: InternalRouterContext) => MaybePromise<any>;
|
|
47
47
|
/**
|
|
48
48
|
* Called after a request has been made, even if it didn't succeed.
|
|
49
49
|
*/
|
|
50
|
-
after: (context: InternalRouterContext) => MaybePromise<
|
|
50
|
+
after: (context: InternalRouterContext) => MaybePromise<any>;
|
|
51
51
|
}
|
|
52
52
|
interface Hooks extends RequestHooks {
|
|
53
53
|
/**
|
|
54
54
|
* Called when Hybridly's context is initialized.
|
|
55
55
|
*/
|
|
56
|
-
initialized: (context: InternalRouterContext) => MaybePromise<
|
|
56
|
+
initialized: (context: InternalRouterContext) => MaybePromise<any>;
|
|
57
57
|
/**
|
|
58
58
|
* Called after Hybridly's initial page load.
|
|
59
59
|
*/
|
|
60
|
-
ready: (context: InternalRouterContext) => MaybePromise<
|
|
60
|
+
ready: (context: InternalRouterContext) => MaybePromise<any>;
|
|
61
61
|
/**
|
|
62
62
|
* Called when a back-forward navigation occurs.
|
|
63
63
|
*/
|
|
@@ -65,11 +65,11 @@ interface Hooks extends RequestHooks {
|
|
|
65
65
|
/**
|
|
66
66
|
* Called when a component navigation is being made.
|
|
67
67
|
*/
|
|
68
|
-
navigating: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<
|
|
68
|
+
navigating: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
|
|
69
69
|
/**
|
|
70
70
|
* Called when a component has been navigated to.
|
|
71
71
|
*/
|
|
72
|
-
navigated: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<
|
|
72
|
+
navigated: (options: NavigationOptions, context: InternalRouterContext) => MaybePromise<any>;
|
|
73
73
|
}
|
|
74
74
|
interface HookOptions {
|
|
75
75
|
/** Executes the hook only once. */
|
package/dist/index.mjs
CHANGED
|
@@ -347,7 +347,7 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
347
347
|
const definition = getRouteDefinition(routeName);
|
|
348
348
|
const parameters = routeParameters || {};
|
|
349
349
|
const missing = Object.keys(parameters);
|
|
350
|
-
const
|
|
350
|
+
const replaceParameter = (match, parameterName) => {
|
|
351
351
|
const optional = /\?}$/.test(match);
|
|
352
352
|
const value = (() => {
|
|
353
353
|
const value2 = parameters[parameterName];
|
|
@@ -375,12 +375,15 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
|
|
|
375
375
|
return "";
|
|
376
376
|
}
|
|
377
377
|
throw new MissingRouteParameter(parameterName, routeName);
|
|
378
|
-
}
|
|
378
|
+
};
|
|
379
|
+
const path = definition.uri.replace(/{([^}?]+)\??}/g, replaceParameter);
|
|
380
|
+
const domain = definition.domain?.replace(/{([^}?]+)\??}/g, replaceParameter);
|
|
379
381
|
const remaining = Object.keys(parameters).filter((key) => missing.includes(key)).reduce((obj, key) => ({
|
|
380
382
|
...obj,
|
|
381
383
|
[key]: parameters[key]
|
|
382
384
|
}), {});
|
|
383
385
|
return {
|
|
386
|
+
...domain && { hostname: domain },
|
|
384
387
|
pathname: path,
|
|
385
388
|
search: qs.stringify(remaining, {
|
|
386
389
|
encodeValuesOnly: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hybridly/core",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.22",
|
|
4
4
|
"description": "A solution to develop server-driven, client-rendered applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"hybridly",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"qs": "^6.11.0",
|
|
40
|
-
"@hybridly/utils": "0.0.1-alpha.
|
|
40
|
+
"@hybridly/utils": "0.0.1-alpha.22"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"defu": "^6.1.1"
|