@soleil-se/app-util 5.7.0 → 5.7.2

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/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ All notable changes to this project will be documented in this file.
7
7
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
8
8
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
9
 
10
+ ## [5.7.2] - 2024-08-21
11
+
12
+ - Add `?version=0` properly to `getRouteUri` when called in offline mode.
13
+
14
+ ## [5.7.1] - 2024-08-07
15
+
16
+ - Change widget detection to use `window.sv.PageContext.dashboardId`.
17
+ - Options in `fetchJson` is now optional.
18
+
10
19
  ## [5.7.0] - 2024-05-23
11
20
 
12
21
  - Add widget support for `fetchJson`.
@@ -38,7 +38,7 @@ async function handleResponse(response) {
38
38
  }
39
39
 
40
40
  function isWidget() {
41
- return window.document.location.pathname.startsWith('/edit-dashboard');
41
+ return !!window?.sv?.PageContext?.dashboardId;
42
42
  }
43
43
 
44
44
  function getWidgetOptions(options) {
@@ -71,7 +71,7 @@ function getWidgetOptions(options) {
71
71
  * @returns {Promise<object>} A promise that resolves to the JSON response.
72
72
  * @throws {Error} If the response is not successful or cannot be parsed as JSON.
73
73
  */
74
- export default function fetchJson(uri, options) {
74
+ export default function fetchJson(uri, options = {}) {
75
75
  const { params = {}, retries = 0, ...rest } = isWidget() ? getWidgetOptions(options) : options;
76
76
 
77
77
  return fetch(getUrl(uri, params), rest)
package/common/index.js CHANGED
@@ -129,9 +129,13 @@ export function parseParams(url = '') {
129
129
  */
130
130
  export function getRouteUri(route = '', params = undefined) {
131
131
  const path = route.replace(leadingSlashes, '');
132
- const qs = stringifyParams(params, { addQueryPrefix: true });
132
+ const qs = stringifyParams({
133
+ version: isOffline ? '0' : undefined,
134
+ ...params,
135
+ }, { addQueryPrefix: true });
133
136
  if (router?.getStandaloneUrl) {
134
- return router.getStandaloneUrl((path !== '' ? `/${path}` : path).replace(trailingSlashes, '')) + qs;
137
+ return router.getStandaloneUrl((path !== '' ? `/${path}` : path).replace(trailingSlashes, ''))
138
+ .replace('?version=0', '') + qs;
135
139
  }
136
140
  /* Import of @sitevision/api/common/router is not avaliable in hooks, need to build the route URI
137
141
  * manually instead of using router.getStandaloneUri */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleil-se/app-util",
3
- "version": "5.7.0",
3
+ "version": "5.7.2",
4
4
  "description": "Utility and rendering functions for WebApps.",
5
5
  "main": "./common/index.js",
6
6
  "author": "Soleil AB",
@@ -14,6 +14,6 @@
14
14
  "peerDependencies": {
15
15
  "@sitevision/api": "*"
16
16
  },
17
- "gitHead": "d555d9d6df015ae9876ff6d7d9c127a14b39a132",
17
+ "gitHead": "128dfdd05bb4d36206cc0314de147fcd10b31155",
18
18
  "dependencies": {}
19
19
  }