@soleil-se/app-util 4.1.2 → 4.1.4
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 +67 -5
- package/client/.eslintrc.js +4 -0
- package/common/index.js +1 -1
- package/docs/2.svelte.md +26 -0
- package/package.json +3 -6
- package/server/svelte/index.js +10 -6
- package/client/.eslintrc +0 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,100 +1,162 @@
|
|
|
1
1
|
# Changelog
|
|
2
|
+
|
|
2
3
|
All notable changes to this project will be documented in this file.
|
|
3
4
|
|
|
4
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
7
|
|
|
8
|
+
## [4.1.4] - 2021-05-25
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- Return empty object instead of undefined when app data isn't set.
|
|
13
|
+
|
|
14
|
+
### Removed
|
|
15
|
+
|
|
16
|
+
- Remove `vue` as optional dependency.
|
|
17
|
+
|
|
18
|
+
## [4.1.3] - 2021-03-31
|
|
19
|
+
|
|
20
|
+
### Fixed
|
|
21
|
+
|
|
22
|
+
- Consistent rendering when using `serverServer` and `render` for Svelte.
|
|
23
|
+
|
|
24
|
+
### Added
|
|
25
|
+
|
|
26
|
+
- Docs for Svelte `renderServer` function.
|
|
27
|
+
|
|
7
28
|
## [4.1.2] - 2021-02-24
|
|
29
|
+
|
|
8
30
|
### Fixed
|
|
31
|
+
|
|
9
32
|
- Escape tags when parsing data to prevent closure of script tags.
|
|
10
33
|
|
|
11
34
|
## [4.1.1] - 2021-02-17
|
|
35
|
+
|
|
12
36
|
### Fixed
|
|
37
|
+
|
|
13
38
|
- Validation error for `id` on script tags, even though it's allowed.
|
|
14
39
|
|
|
15
40
|
## [4.1.0] - 2021-02-17
|
|
41
|
+
|
|
16
42
|
### Changed
|
|
43
|
+
|
|
17
44
|
- Put app data and metadata in script elements instead of data attributes.
|
|
18
45
|
|
|
19
46
|
## [4.0.1] - 2021-01-28
|
|
47
|
+
|
|
20
48
|
### Fixed
|
|
49
|
+
|
|
21
50
|
- Crashes when no data is passed to app and then trying to call `getAppData`.
|
|
22
51
|
|
|
23
52
|
## [4.0.0] - 2021-01-27
|
|
24
|
-
|
|
53
|
+
|
|
54
|
+
A much needed major overhaul of the package.
|
|
25
55
|
See [MIGRATION](./MIGRATION.md).
|
|
26
56
|
|
|
27
57
|
### Changed
|
|
58
|
+
|
|
28
59
|
- Major refactoring of package.
|
|
29
|
-
- Exports for render functions are moved.
|
|
60
|
+
- Exports for render functions are moved.
|
|
30
61
|
- All documented constants and functions from base import (`@soleil-api/webapp-util`) now works both in a server and client context.
|
|
31
62
|
- Settings for selector is moved from server to client rendering functions.
|
|
32
63
|
|
|
33
64
|
### Removed
|
|
65
|
+
|
|
34
66
|
- `noScript` option in `render` (formerly `renderApp`) has been removed. If a no script message is needed use the `html` option wrapped in `<noscript>`.
|
|
35
67
|
- `@soleil-api/webapp-util/app-data` has been removed, use [getAppData](./README.md#getAppData) from `@soleil-api/webapp-util`.
|
|
36
68
|
|
|
37
69
|
## [3.0.3] - 2020-11-03
|
|
70
|
+
|
|
38
71
|
- Nothing, Lerna wanted to publish...
|
|
39
72
|
|
|
40
73
|
## [3.0.2] - 2020-10-19
|
|
74
|
+
|
|
41
75
|
- Nothing, Lerna wanted to publish...
|
|
42
76
|
|
|
43
77
|
## [3.0.1] - 2020-09-28
|
|
78
|
+
|
|
44
79
|
### Added
|
|
80
|
+
|
|
45
81
|
- Homepage link
|
|
46
82
|
|
|
47
83
|
## [3.0.0] - 2020-09-28
|
|
84
|
+
|
|
48
85
|
### Added
|
|
86
|
+
|
|
49
87
|
- Svelte support.
|
|
50
88
|
- New exports:
|
|
51
89
|
- `uniqueId` - A unique id for the app instance.
|
|
52
90
|
|
|
53
91
|
## [2.4.1] - 2020-09-01
|
|
92
|
+
|
|
54
93
|
### Fixed
|
|
94
|
+
|
|
55
95
|
- App data with single quotes crashes app in edit mode, use double quotes instead.
|
|
56
96
|
|
|
57
97
|
## [2.4.0] - 2020-05-26
|
|
98
|
+
|
|
58
99
|
### Fixed
|
|
100
|
+
|
|
59
101
|
- `getViewUri` returns correct URI when in offline mode and in the Addons view.
|
|
60
102
|
|
|
61
103
|
## [2.3.0] - 2020-05-22
|
|
104
|
+
|
|
62
105
|
### Added
|
|
63
|
-
|
|
106
|
+
|
|
107
|
+
- `renderApp` now accepts `req` as a setting to opimize script loading when multiple instances of the app exists. If `req` is present the script will only be loaded once in all browsers except IE11 that needs a unique script src for the currentScript polyfill to work.
|
|
64
108
|
|
|
65
109
|
### Fixed
|
|
110
|
+
|
|
66
111
|
- `noScript` in `renderApp` was not wrapped in a `<noscript>` tag.
|
|
67
112
|
|
|
68
113
|
## [2.2.0] - 2020-05-20
|
|
114
|
+
|
|
69
115
|
### Added
|
|
116
|
+
|
|
70
117
|
- `renderTemplate` function is now available inside templates rendered by the function.
|
|
118
|
+
|
|
71
119
|
## [2.1.4] - 2020-04-07
|
|
120
|
+
|
|
72
121
|
### Fixed
|
|
122
|
+
|
|
73
123
|
- `getViewUri` had incorrect portlet ID.
|
|
124
|
+
|
|
74
125
|
## [2.1.3] - 2020-02-25
|
|
126
|
+
|
|
75
127
|
### Fixed
|
|
128
|
+
|
|
76
129
|
- Add timestamp to script url in edit mode as well.
|
|
77
130
|
|
|
78
131
|
## [2.1.2] - 2020-02-21
|
|
132
|
+
|
|
79
133
|
### Fixed
|
|
134
|
+
|
|
80
135
|
- Wrapped `renderApp` script in svDocReady in edit mode to be sure it executes when other bundles are loaded.
|
|
81
136
|
|
|
82
137
|
## [2.1.1] - 2020-02-14
|
|
138
|
+
|
|
83
139
|
### Changed
|
|
140
|
+
|
|
84
141
|
- Updated readme, heading levels and examples.
|
|
85
142
|
|
|
86
143
|
## [2.1.0] - 2020-02-14
|
|
144
|
+
|
|
87
145
|
### Added
|
|
146
|
+
|
|
88
147
|
- App data import in client, `@soleil-api/webapp-util/app-data`.
|
|
89
148
|
- `getViewUri` to get the URI that also renders the page.
|
|
90
149
|
- `isOnline` to see if the app is online.
|
|
91
150
|
|
|
92
151
|
### Changed
|
|
152
|
+
|
|
93
153
|
- `vue` is now an optional depedency.
|
|
94
154
|
|
|
95
155
|
## [2.0.0] - 2020-02-12
|
|
156
|
+
|
|
96
157
|
### Changed
|
|
158
|
+
|
|
97
159
|
- Now using `currentScript` to reference the script element the app is running in to pass data when using `renderApp`.
|
|
98
160
|
- `renderApp` is no longer using appName.
|
|
99
|
-
- `render` is now called directly in `./app_src/client/index.js`.
|
|
100
|
-
- `render` and `App` no longer needs to be exported from `./app_src/client/index.js`.
|
|
161
|
+
- `render` is now called directly in `./app_src/client/index.js`.
|
|
162
|
+
- `render` and `App` no longer needs to be exported from `./app_src/client/index.js`.
|
package/common/index.js
CHANGED
package/docs/2.svelte.md
CHANGED
|
@@ -14,6 +14,7 @@ If a client bundle is available the server rendered HTML will be hydrated and no
|
|
|
14
14
|
|
|
15
15
|
| Param | Type | Default | Description |
|
|
16
16
|
| --- | --- | --- | --- |
|
|
17
|
+
| [App] | <code>Svelte</code> | | Svelte app to be rendered. |
|
|
17
18
|
| [props] | <code>Object</code> | <code>{}</code> | Server data that will be available as props and as app data. |
|
|
18
19
|
| [settings] | <code>Object</code> | <code>{}</code> | Settings object. Forwarded to |
|
|
19
20
|
| [settings.async] | <code>Boolean</code> | <code>false</code> | If the app script should be loaded asynchronously. |
|
|
@@ -35,6 +36,31 @@ router.get('/', (req, res) => {
|
|
|
35
36
|
});
|
|
36
37
|
```
|
|
37
38
|
|
|
39
|
+
### `renderServer(App, [props])`
|
|
40
|
+
`@soleil-api/webapp-util/server/svelte`
|
|
41
|
+
|
|
42
|
+
Get a HTML string for rendering a server side Svelte application.
|
|
43
|
+
|
|
44
|
+
**Returns**: <code>String</code> - HTML for rendering a Svelte application.
|
|
45
|
+
|
|
46
|
+
| Param | Type | Default | Description |
|
|
47
|
+
| --- | --- | --- | --- |
|
|
48
|
+
| [App] | <code>Svelte</code> | | Svelte app to be rendered. |
|
|
49
|
+
| [props] | <code>Object</code> | <code>{}</code> | Server data that will be available as props and as app data. |
|
|
50
|
+
|
|
51
|
+
In `app_src/index.js` or `app_src/server/index.js`.
|
|
52
|
+
```javascript
|
|
53
|
+
import router from 'router';
|
|
54
|
+
import { renderServer } from '@soleil-api/webapp-util/server/svelte';
|
|
55
|
+
|
|
56
|
+
import App from './App.svelte';
|
|
57
|
+
|
|
58
|
+
router.get('/', (req, res) => {
|
|
59
|
+
const props = { foo: 'bar' };
|
|
60
|
+
res.send(render(App, data));
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
38
64
|
## main.js
|
|
39
65
|
|
|
40
66
|
### `render(App, [settings])`
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@soleil-se/app-util",
|
|
3
|
-
"version": "4.1.
|
|
4
|
-
"description": "Utility functions for
|
|
3
|
+
"version": "4.1.4",
|
|
4
|
+
"description": "Utility and rendering functions for WebApps.",
|
|
5
5
|
"main": "./common/index.js",
|
|
6
6
|
"author": "Soleil AB",
|
|
7
7
|
"contributors": [
|
|
@@ -11,10 +11,7 @@
|
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"private": false,
|
|
13
13
|
"homepage": "https://docs.soleilit.se/03.packages/@soleil-api&app-util",
|
|
14
|
-
"
|
|
15
|
-
"vue": "^2.6.11"
|
|
16
|
-
},
|
|
17
|
-
"gitHead": "810b8ad5ceb960a03f7af40052b663b444763794",
|
|
14
|
+
"gitHead": "6651e6eb4eb4133134d952e498c45121176c0b13",
|
|
18
15
|
"dependencies": {},
|
|
19
16
|
"devDependencies": {}
|
|
20
17
|
}
|
package/server/svelte/index.js
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
/* eslint-disable import/prefer-default-export */
|
|
2
2
|
import appResource from 'appResource';
|
|
3
|
-
import { setAppData } from '../../common';
|
|
3
|
+
import { appId, setAppData } from '../../common';
|
|
4
4
|
import { render as renderClient } from '../index';
|
|
5
5
|
|
|
6
|
+
const initSSR = (App, props) => {
|
|
7
|
+
setAppData(props);
|
|
8
|
+
return App.render(props).html;
|
|
9
|
+
};
|
|
10
|
+
|
|
6
11
|
/**
|
|
7
12
|
* SSR Svelte App.
|
|
8
13
|
* @export
|
|
@@ -11,9 +16,8 @@ import { render as renderClient } from '../index';
|
|
|
11
16
|
* @return {String} - HTML for rendering a Svelte application.
|
|
12
17
|
*/
|
|
13
18
|
export function renderServer(App, props = {}) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return html;
|
|
19
|
+
const html = initSSR(App, props);
|
|
20
|
+
return `<div id="app_mount_${appId}">${html}</div>`;
|
|
17
21
|
}
|
|
18
22
|
|
|
19
23
|
/**
|
|
@@ -25,9 +29,9 @@ export function renderServer(App, props = {}) {
|
|
|
25
29
|
* @return {String} - HTML for rendering a Svelte application.
|
|
26
30
|
*/
|
|
27
31
|
export function render(App, props = {}, settings) {
|
|
28
|
-
const html =
|
|
32
|
+
const html = initSSR(App, props);
|
|
29
33
|
if (appResource.getNode('client/index.js')) {
|
|
30
34
|
return renderClient(props, { ...settings, html });
|
|
31
35
|
}
|
|
32
|
-
return html
|
|
36
|
+
return `<div id="app_mount_${appId}">${html}</div>`;
|
|
33
37
|
}
|
package/client/.eslintrc
DELETED