@hybridly/core 0.10.0-beta.1 → 0.10.0-beta.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.mts CHANGED
@@ -129,7 +129,6 @@ type BaseUrlTransformable = Partial<Omit<URL, 'searchParams' | 'toJSON' | 'toStr
129
129
  trailingSlash?: boolean;
130
130
  };
131
131
  /** Normalizes the given input to an URL. */
132
-
133
132
  /**
134
133
  * Converts an input to an URL, optionally changing its properties after initialization.
135
134
  */
@@ -280,9 +279,7 @@ interface Router {
280
279
  dialog: DialogRouter;
281
280
  /** Access the history state. */
282
281
  history: {
283
- /** Remembers a value for the given route. */
284
- remember: (key: string, value: any) => void;
285
- /** Gets a remembered value. */
282
+ /** Remembers a value for the given route. */remember: (key: string, value: any) => void; /** Gets a remembered value. */
286
283
  get: <T = any>(key: string) => T | undefined;
287
284
  };
288
285
  }
package/dist/index.mjs CHANGED
@@ -274,8 +274,8 @@ function getHistoryState() {
274
274
  }
275
275
  /** Gets the current history state if it exists. */
276
276
  function getHistoryMemo(key) {
277
- const state$1 = getHistoryState();
278
- return key ? state$1?.memo?.[key] : state$1?.memo;
277
+ const state = getHistoryState();
278
+ return key ? state?.memo?.[key] : state?.memo;
279
279
  }
280
280
  /** Register history-related event listeneners. */
281
281
  async function registerEventListeners() {
@@ -287,9 +287,9 @@ async function registerEventListeners() {
287
287
  debug.router("Aborting current navigation.", context.pendingNavigation);
288
288
  context.pendingNavigation?.controller?.abort();
289
289
  }
290
- const state$1 = context.serializer.unserialize(event.state);
291
- await runHooks("backForward", {}, state$1, context);
292
- if (!state$1) {
290
+ const state = context.serializer.unserialize(event.state);
291
+ await runHooks("backForward", {}, state, context);
292
+ if (!state) {
293
293
  debug.history("There is no state. Adding hash if any and restoring scroll positions.");
294
294
  return await navigate({
295
295
  type: "initial",
@@ -304,9 +304,9 @@ async function registerEventListeners() {
304
304
  }
305
305
  await navigate({
306
306
  type: "back-forward",
307
- payload: state$1,
307
+ payload: state,
308
308
  preserveScroll: true,
309
- preserveState: !!getInternalRouterContext().dialog || !!state$1.dialog,
309
+ preserveState: !!getInternalRouterContext().dialog || !!state.dialog,
310
310
  updateHistoryState: false
311
311
  });
312
312
  });
@@ -323,12 +323,12 @@ function isBackForwardNavigation() {
323
323
  async function handleBackForwardNavigation() {
324
324
  debug.router("Handling a back/forward navigation from an external URL.");
325
325
  const context = getRouterContext();
326
- const state$1 = getHistoryState();
327
- if (!state$1) throw new Error("Tried to handling a back/forward navigation, but there was no state in the history. This should not happen.");
326
+ const state = getHistoryState();
327
+ if (!state) throw new Error("Tried to handling a back/forward navigation, but there was no state in the history. This should not happen.");
328
328
  await navigate({
329
329
  type: "back-forward",
330
330
  payload: {
331
- ...state$1,
331
+ ...state,
332
332
  version: context.version
333
333
  },
334
334
  preserveScroll: true,
@@ -442,10 +442,10 @@ function getRouteParameterValue(routeName, parameterName, routeParameters) {
442
442
  const definition = getRouteDefinition(routeName);
443
443
  const parameters = routeParameters || {};
444
444
  const value = (() => {
445
- const value$1 = parameters[parameterName];
445
+ const value = parameters[parameterName];
446
446
  const bindingProperty = definition.bindings?.[parameterName];
447
- if (bindingProperty && value$1 != null && typeof value$1 === "object") return value$1[bindingProperty];
448
- return value$1;
447
+ if (bindingProperty && value != null && typeof value === "object") return value[bindingProperty];
448
+ return value;
449
449
  })();
450
450
  if (value) {
451
451
  const where = definition.wheres?.[parameterName];
@@ -461,7 +461,7 @@ function getRouteTransformable(routeName, routeParameters, shouldThrow) {
461
461
  const definition = getRouteDefinition(routeName);
462
462
  const parameters = routeParameters || {};
463
463
  const missing = Object.keys(parameters);
464
- const replaceParameter = (match$1, parameterName, optional) => {
464
+ const replaceParameter = (match, parameterName, optional) => {
465
465
  const value = getRouteParameterValue(routeName, parameterName, parameters);
466
466
  const found = missing.indexOf(parameterName);
467
467
  if (found >= 0) missing.splice(found, 1);
@@ -610,8 +610,8 @@ async function initializeContext(options) {
610
610
  * Registers an interceptor that assumes `arraybuffer`
611
611
  * responses and converts responses to JSON or text.
612
612
  */
613
- function registerAxios(axios$1) {
614
- axios$1.interceptors.response.use((response) => {
613
+ function registerAxios(axios) {
614
+ axios.interceptors.response.use((response) => {
615
615
  if (!isDownloadResponse(response)) {
616
616
  const text = new TextDecoder().decode(response.data);
617
617
  try {
@@ -622,19 +622,19 @@ function registerAxios(axios$1) {
622
622
  }
623
623
  return response;
624
624
  }, (error) => Promise.reject(error));
625
- return axios$1;
625
+ return axios;
626
626
  }
627
627
  /**
628
628
  * Mutates properties at the top-level of the context.
629
629
  */
630
- function setContext(merge$1 = {}, options = {}) {
631
- Object.keys(merge$1).forEach((key) => {
632
- Reflect.set(state.context, key, merge$1[key]);
630
+ function setContext(merge = {}, options = {}) {
631
+ Object.keys(merge).forEach((key) => {
632
+ Reflect.set(state.context, key, merge[key]);
633
633
  });
634
634
  if (options.propagate !== false) state.context.adapter.onContextUpdate?.(state.context);
635
635
  debug.context("Updated context:", {
636
636
  context: state.context,
637
- added: merge$1
637
+ added: merge
638
638
  });
639
639
  }
640
640
  /** Gets a payload from the current context. */
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.1",
4
+ "version": "0.10.0-beta.3",
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
  "axios": "^1.7.2"
44
44
  },
45
45
  "dependencies": {
46
- "@hybridly/utils": "0.10.0-beta.1",
46
+ "@hybridly/utils": "0.10.0-beta.3",
47
47
  "qs": "^6.14.0",
48
48
  "superjson": "^2.2.2"
49
49
  },