@hybridly/core 0.10.0-beta.15 → 0.10.0-beta.16

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.mts CHANGED
@@ -109,7 +109,7 @@ interface RequestHooks {
109
109
  */
110
110
  fail: (error: Error, request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
111
111
  /**
112
- * Called after a request has been made, even if it didn't succeed.
112
+ * Called after a response has been received, even if it didn't succeed in a navigation.
113
113
  */
114
114
  after: (request: PendingHybridRequest, context: InternalRouterContext) => MaybePromise<any>;
115
115
  }
@@ -553,7 +553,7 @@ type Validation = Record<string, Errors>;
553
553
  declare const router: {
554
554
  abort: () => void;
555
555
  navigate: (options: HybridRequestOptions) => Promise<NavigationResponse>;
556
- reload: (options: HybridRequestOptions | undefined) => Promise<NavigationResponse>;
556
+ reload: (options?: HybridRequestOptions | undefined) => Promise<NavigationResponse>;
557
557
  get: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
558
558
  post: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
559
559
  put: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
@@ -561,8 +561,8 @@ declare const router: {
561
561
  delete: (url: UrlResolvable, options?: Omit<HybridRequestOptions, "method" | "url"> | undefined) => Promise<NavigationResponse>;
562
562
  local: (url: UrlResolvable, options?: ComponentNavigationOptions) => Promise<void>;
563
563
  external: (url: UrlResolvable, data?: _hybridly_utils0.RequestData) => void;
564
- to: <T extends RouteName>(name: T, parameters: Record<string, any> | undefined, options: Omit<HybridRequestOptions, "url"> | undefined) => Promise<NavigationResponse>;
565
- matches: <T extends RouteName>(name: T, parameters: Record<string, any> | undefined) => boolean;
564
+ to: <T extends RouteName>(name: T, parameters?: Record<string, any> | undefined, options?: Omit<HybridRequestOptions, "url"> | undefined) => Promise<NavigationResponse>;
565
+ matches: <T extends RouteName>(name: T, parameters?: Record<string, any> | undefined) => boolean;
566
566
  current: () => string | undefined;
567
567
  dialog: {
568
568
  close: (options?: CloseDialogOptions | undefined) => Promise<void | NavigationResponse>;
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "./_chunks/chunk.mjs";
2
- import { debug, getByPath, hasFiles, merge, mergeObject, objectToFormData, random, showResponseErrorModal, wrap } from "@hybridly/utils";
2
+ import { debug, hasFiles, merge, mergeObject, objectToFormData, random, showResponseErrorModal, wrap } from "@hybridly/utils";
3
3
  import { trimEnd } from "es-toolkit/string";
4
4
  import { parse, stringify } from "picoquery";
5
5
  import { debounce } from "es-toolkit/function";
@@ -949,8 +949,8 @@ function isPartial(options) {
949
949
  function resolveProperties(original, payload) {
950
950
  const mergedPayloadProperties = merge(original, payload.properties);
951
951
  (payload.mergeable ?? []).forEach(([mergeableProperty, prepends, uniqueBy]) => {
952
- const originalValue = getByPath(original, mergeableProperty);
953
- const newValue = getByPath(payload.properties, mergeableProperty);
952
+ const originalValue = get(original, mergeableProperty);
953
+ const newValue = get(payload.properties, mergeableProperty);
954
954
  const mergeArrays = (current, incoming) => {
955
955
  const merged = prepends === true ? [...incoming, ...current] : [...current, ...incoming];
956
956
  if (typeof uniqueBy !== "string") return merged;
@@ -1014,7 +1014,12 @@ async function processNextResponse() {
1014
1014
  return;
1015
1015
  }
1016
1016
  debug.queue("Processing response", response);
1017
- response.request.resolve(await handleHybridRequestResponse(response));
1017
+ try {
1018
+ response.request.resolve(await handleHybridRequestResponse(response));
1019
+ } finally {
1020
+ debug.router("Ended navigation.", response.request);
1021
+ await runHooks("after", response.request.options.hooks, response.request, getInternalRouterContext());
1022
+ }
1018
1023
  return await processNextResponse();
1019
1024
  }
1020
1025
  //#endregion
@@ -1071,8 +1076,6 @@ async function processRequest(request, onFinally) {
1071
1076
  await handleTransportError(request, error);
1072
1077
  } finally {
1073
1078
  request.completed = true;
1074
- debug.router("Ended navigation.", request);
1075
- await runHooks("after", request.options.hooks, request, getRouterContext());
1076
1079
  onFinally();
1077
1080
  }
1078
1081
  }
@@ -1535,7 +1538,7 @@ async function closeDialog(options) {
1535
1538
  const router = {
1536
1539
  abort: () => cancelNavigationRequest(),
1537
1540
  navigate: async (options) => await performHybridNavigation(options),
1538
- reload: async (options) => await performHybridNavigation({
1541
+ reload: async (options = {}) => await performHybridNavigation({
1539
1542
  preserveScroll: true,
1540
1543
  preserveState: true,
1541
1544
  replace: true,
@@ -1573,7 +1576,7 @@ const router = {
1573
1576
  }),
1574
1577
  local: async (url, options = {}) => await performLocalNavigation(url, options),
1575
1578
  external: (url, data = {}) => navigateToExternalUrl(url, data),
1576
- to: async (name, parameters, options) => {
1579
+ to: async (name, parameters = void 0, options = {}) => {
1577
1580
  const url = generateRouteFromName(name, parameters);
1578
1581
  const method = getRouteDefinition(name).method.at(0);
1579
1582
  return await performHybridNavigation({
@@ -1582,7 +1585,7 @@ const router = {
1582
1585
  method
1583
1586
  });
1584
1587
  },
1585
- matches: (name, parameters) => currentRouteMatches(name, parameters),
1588
+ matches: (name, parameters = void 0) => currentRouteMatches(name, parameters),
1586
1589
  current: () => getCurrentRouteName(),
1587
1590
  dialog: { close: (options = {}) => closeDialog(options) },
1588
1591
  history: {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hybridly/core",
3
3
  "type": "module",
4
- "version": "0.10.0-beta.15",
4
+ "version": "0.10.0-beta.16",
5
5
  "description": "Core functionality of Hybridly",
6
6
  "author": "Enzo Innocenzi <enzo@innocenzi.dev>",
7
7
  "license": "MIT",
@@ -40,7 +40,7 @@
40
40
  "build:stub": "obuild --stub"
41
41
  },
42
42
  "dependencies": {
43
- "@hybridly/utils": "0.10.0-beta.15",
43
+ "@hybridly/utils": "0.10.0-beta.16",
44
44
  "picoquery": "^2.5.0",
45
45
  "superjson": "^2.2.2",
46
46
  "es-toolkit": "^1.45.1"