@soleil-se/config-svelte 1.29.2 → 1.30.0
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 +14 -0
- package/components/Checkbox/Component.svelte +1 -1
- package/createTypeDefinitions.js +15 -0
- package/package.json +2 -2
- package/server/index.d.ts +40 -0
- package/server/index.js +43 -15
- package/types/components/Checkbox/Component.svelte.d.ts +1 -1
- package/types/server/index.d.ts +29 -7
- package/types/utils/getAppContext.d.ts +57 -5
- package/utils/getAppContext.d.ts +59 -0
- package/utils/getAppContext.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -8,6 +8,20 @@ All notable changes to this project will be documented in this file.
|
|
|
8
8
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
9
9
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
10
10
|
|
|
11
|
+
## [1.30.0] - 2026-02-18
|
|
12
|
+
|
|
13
|
+
- Add a `res.render({})` call för `createAppProps` and `createAppContext` to correctly render the
|
|
14
|
+
size selector in widget configs.
|
|
15
|
+
|
|
16
|
+
- Deprecate `createAppProps(props)`, use `createAppProps(props, res)` instead.
|
|
17
|
+
```diff lang="js"
|
|
18
|
+
const props = { message: 'Hello from the server!' };
|
|
19
|
+
- res.send(createAppProps(props));
|
|
20
|
+
+ createAppProps(props, res);
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- Value in `Checkbox` component now has a default value of `undefined`.
|
|
24
|
+
|
|
11
25
|
## [1.29.2] - 2025-08-26
|
|
12
26
|
|
|
13
27
|
- Update type definitions for Option.
|
package/createTypeDefinitions.js
CHANGED
|
@@ -18,6 +18,21 @@ globSync('./components/*/types.d.ts').forEach((file) => {
|
|
|
18
18
|
fs.copyFileSync(file, destinationPath);
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
+
function copyManualTypeFiles(dir) {
|
|
22
|
+
globSync(`./${dir}/**/*.js`)
|
|
23
|
+
.map((file) => file.replace(/\.js$/, '.d.ts'))
|
|
24
|
+
.filter((file) => fs.existsSync(file))
|
|
25
|
+
.forEach((file) => {
|
|
26
|
+
const relativePath = path.relative(dir, file);
|
|
27
|
+
const destinationPath = path.join('types', dir, relativePath);
|
|
28
|
+
const destinationDir = path.dirname(destinationPath);
|
|
29
|
+
console.log(`Found manual type definition file: ${file}, copying to ${destinationDir}`);
|
|
30
|
+
fs.mkdirSync(destinationDir, { recursive: true });
|
|
31
|
+
fs.copyFileSync(file, destinationPath);
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
21
35
|
['actions', 'createConfigApp', 'server', 'utils'].forEach((dir) => {
|
|
22
36
|
execSync(`npx -p typescript tsc ./${dir}/index.js --declaration --allowJs --emitDeclarationOnly --outDir types/${dir} --skipLibCheck`, { stdio: 'inherit' });
|
|
37
|
+
copyManualTypeFiles(dir);
|
|
23
38
|
});
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"svelte"
|
|
10
10
|
],
|
|
11
11
|
"homepage": "https://docs.soleil.se/packages/config-svelte",
|
|
12
|
-
"version": "1.
|
|
12
|
+
"version": "1.30.0",
|
|
13
13
|
"main": "./index.js",
|
|
14
14
|
"module": "./index.js",
|
|
15
15
|
"svelte": "./index.js",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"publishConfig": {
|
|
60
60
|
"access": "public"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "405f8c7d65e72fb61520680b4a9815fb559f4b04"
|
|
63
63
|
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Response } from '@sitevision/api/common/router';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Creates a HTML string for passing props to the app.
|
|
5
|
+
* @deprecated Use `createAppProps(props, res)` instead.
|
|
6
|
+
* @example
|
|
7
|
+
* // Before:
|
|
8
|
+
* res.send(createAppProps(props));
|
|
9
|
+
*
|
|
10
|
+
* // After:
|
|
11
|
+
* createAppProps(props, res);
|
|
12
|
+
* @param {Record<string, any>} props Props to be passed to the app.
|
|
13
|
+
* @returns {string} HTML string to make props available to the app.
|
|
14
|
+
*/
|
|
15
|
+
export function createAppProps(props: Record<string, any>): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates app props that can be passed to the app.
|
|
19
|
+
* @param {Record<string, any>} props Props to be passed to the app.
|
|
20
|
+
* @param {Response} res Response from \@sitevision/common/router.
|
|
21
|
+
*/
|
|
22
|
+
export function createAppProps(props: Record<string, any>, res: Response): void;
|
|
23
|
+
/**
|
|
24
|
+
* Creates a HTML string for passing data to the app.
|
|
25
|
+
* @param {Record<string, any>} data Data to be passed to the app.
|
|
26
|
+
* @deprecated Use `createAppProps` instead.
|
|
27
|
+
* @example
|
|
28
|
+
* // Before:
|
|
29
|
+
* res.send(createAppData(data));
|
|
30
|
+
*
|
|
31
|
+
* // After:
|
|
32
|
+
* createAppProps(data, res);
|
|
33
|
+
* @returns {string} HTML string to make data available to the config app.
|
|
34
|
+
*/
|
|
35
|
+
export function createAppData(data: Record<string, any>): string;
|
|
36
|
+
/**
|
|
37
|
+
* Creates app context global variable.
|
|
38
|
+
* @param {Response} res Response from \@sitevision/common/router.
|
|
39
|
+
*/
|
|
40
|
+
export function createAppContext(res: Response): void;
|
package/server/index.js
CHANGED
|
@@ -1,14 +1,32 @@
|
|
|
1
|
-
|
|
2
|
-
import { getCurrentPage } from '@sitevision/api/server/PortletContextUtil';
|
|
1
|
+
import PortletContextUtil from '@sitevision/api/server/PortletContextUtil';
|
|
3
2
|
import appInfo from '@sitevision/api/server/appInfo';
|
|
4
|
-
import
|
|
3
|
+
import ResourceLocatorUtil from '@sitevision/api/server/ResourceLocatorUtil';
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
* @param {object} props Props to be passed to the app.
|
|
9
|
-
* @returns {string} HTML string to make props available to the app.
|
|
6
|
+
* @typedef {import('@sitevision/api/common/router').Response} Response
|
|
10
7
|
*/
|
|
11
|
-
|
|
8
|
+
|
|
9
|
+
let hasRendered = false;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @param {Record<string, any>} props
|
|
13
|
+
* @param {Response} [res]
|
|
14
|
+
* @returns {string | void}
|
|
15
|
+
*/
|
|
16
|
+
export function createAppProps(props, res) {
|
|
17
|
+
if (res) {
|
|
18
|
+
if (appInfo.appType.toLowerCase() === 'widget' && !hasRendered) {
|
|
19
|
+
hasRendered = true;
|
|
20
|
+
res.render({}); // Need to call render to make sure the widget size selector is rendered.
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
res.send(`
|
|
24
|
+
<script>
|
|
25
|
+
window.CONFIG_APP_PROPS = ${JSON.stringify(props)};
|
|
26
|
+
</script>
|
|
27
|
+
`);
|
|
28
|
+
return '';
|
|
29
|
+
}
|
|
12
30
|
return `
|
|
13
31
|
<script>
|
|
14
32
|
window.CONFIG_APP_PROPS = ${JSON.stringify(props)};
|
|
@@ -18,29 +36,39 @@ export function createAppProps(props) {
|
|
|
18
36
|
}
|
|
19
37
|
|
|
20
38
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @
|
|
23
|
-
* @deprecated Use `createAppProps` instead.
|
|
24
|
-
* @returns {string} HTML string to make data available to the config app.
|
|
39
|
+
* @param {Record<string, any>} data
|
|
40
|
+
* @returns {string}
|
|
25
41
|
*/
|
|
26
42
|
export function createAppData(data) {
|
|
27
43
|
return createAppProps(data);
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
/**
|
|
31
|
-
*
|
|
32
|
-
* @
|
|
47
|
+
* @param {Response} res
|
|
48
|
+
* @returns {void}
|
|
33
49
|
*/
|
|
34
50
|
export function createAppContext(res) {
|
|
35
|
-
const siteNode = getSite();
|
|
51
|
+
const siteNode = ResourceLocatorUtil.getSite();
|
|
36
52
|
|
|
37
53
|
const context = {
|
|
38
54
|
...appInfo,
|
|
39
|
-
pageId: getCurrentPage().getIdentifier(),
|
|
55
|
+
pageId: PortletContextUtil.getCurrentPage().getIdentifier(),
|
|
40
56
|
siteId: siteNode.getIdentifier(),
|
|
41
57
|
siteName: siteNode.toString(),
|
|
58
|
+
jcrUuid: appInfo['jcr:uuid'],
|
|
59
|
+
jcrPrimaryType: appInfo['jcr:primaryType'],
|
|
60
|
+
addon: {
|
|
61
|
+
...appInfo.addon,
|
|
62
|
+
jcrUuid: appInfo.addon['jcr:uuid'],
|
|
63
|
+
jcrPrimaryType: appInfo.addon['jcr:primaryType'],
|
|
64
|
+
},
|
|
42
65
|
};
|
|
43
66
|
|
|
67
|
+
if (context.appType.toLowerCase() === 'widget' && !hasRendered) {
|
|
68
|
+
hasRendered = true;
|
|
69
|
+
res.render({}); // Need to call render to make sure the widget size selector is rendered.
|
|
70
|
+
}
|
|
71
|
+
|
|
44
72
|
res.send(`
|
|
45
73
|
<script>
|
|
46
74
|
window.CONFIG_APP_CONTEXT = ${JSON.stringify(context)};
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
|
+
import type { Response } from '@sitevision/api/common/router';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
|
-
* Creates a HTML string for passing
|
|
3
|
-
* @
|
|
4
|
+
* Creates a HTML string for passing props to the app.
|
|
5
|
+
* @deprecated Use `createAppProps(props, res)` instead.
|
|
6
|
+
* @example
|
|
7
|
+
* // Before:
|
|
8
|
+
* res.send(createAppProps(props));
|
|
9
|
+
*
|
|
10
|
+
* // After:
|
|
11
|
+
* createAppProps(props, res);
|
|
12
|
+
* @param {Record<string, any>} props Props to be passed to the app.
|
|
4
13
|
* @returns {string} HTML string to make props available to the app.
|
|
5
14
|
*/
|
|
6
|
-
export function createAppProps(props:
|
|
15
|
+
export function createAppProps(props: Record<string, any>): string;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Creates app props that can be passed to the app.
|
|
19
|
+
* @param {Record<string, any>} props Props to be passed to the app.
|
|
20
|
+
* @param {Response} res Response from \@sitevision/common/router.
|
|
21
|
+
*/
|
|
22
|
+
export function createAppProps(props: Record<string, any>, res: Response): void;
|
|
7
23
|
/**
|
|
8
24
|
* Creates a HTML string for passing data to the app.
|
|
9
|
-
* @param {
|
|
25
|
+
* @param {Record<string, any>} data Data to be passed to the app.
|
|
10
26
|
* @deprecated Use `createAppProps` instead.
|
|
27
|
+
* @example
|
|
28
|
+
* // Before:
|
|
29
|
+
* res.send(createAppData(data));
|
|
30
|
+
*
|
|
31
|
+
* // After:
|
|
32
|
+
* createAppProps(data, res);
|
|
11
33
|
* @returns {string} HTML string to make data available to the config app.
|
|
12
34
|
*/
|
|
13
|
-
export function createAppData(data:
|
|
35
|
+
export function createAppData(data: Record<string, any>): string;
|
|
14
36
|
/**
|
|
15
37
|
* Creates app context global variable.
|
|
16
|
-
* @param {
|
|
38
|
+
* @param {Response} res Response from \@sitevision/common/router.
|
|
17
39
|
*/
|
|
18
|
-
export function createAppContext(res:
|
|
40
|
+
export function createAppContext(res: Response): void;
|
|
@@ -1,7 +1,59 @@
|
|
|
1
|
+
export type AppContextAddon = {
|
|
2
|
+
jcrUuid: string;
|
|
3
|
+
jcrPrimaryType: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type AppContextCertificate = {
|
|
8
|
+
signed: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AppContextRuntime = {
|
|
12
|
+
sitevisionVersion: string;
|
|
13
|
+
scriptEngineLanguageVersion: string;
|
|
14
|
+
scriptEngineName: string;
|
|
15
|
+
serverName: string;
|
|
16
|
+
scriptEngineVersion: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type AppContext = {
|
|
20
|
+
appId: string;
|
|
21
|
+
contextNodeId: string;
|
|
22
|
+
servletPath: string;
|
|
23
|
+
portletId: string;
|
|
24
|
+
dashboardId: string;
|
|
25
|
+
appVersion: string;
|
|
26
|
+
maxUploadSizeInMB: number;
|
|
27
|
+
appHelpURL: string;
|
|
28
|
+
addon: AppContextAddon;
|
|
29
|
+
appName: string;
|
|
30
|
+
appDescription: string;
|
|
31
|
+
certificate: AppContextCertificate;
|
|
32
|
+
active: boolean;
|
|
33
|
+
runtime: AppContextRuntime;
|
|
34
|
+
jcrUuid: string;
|
|
35
|
+
requirePrivileged: boolean;
|
|
36
|
+
appIdentifier: string;
|
|
37
|
+
appAuthor: string;
|
|
38
|
+
appType: string;
|
|
39
|
+
appImportDate: number;
|
|
40
|
+
jcrPrimaryType: string;
|
|
41
|
+
csrfProtection: boolean;
|
|
42
|
+
pageId: string;
|
|
43
|
+
siteId: string;
|
|
44
|
+
siteName: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type AppContextKey = "appId" | "contextNodeId" | "servletPath" | "portletId" | "dashboardId" | "appVersion" | "maxUploadSizeInMB" | "appHelpURL" | "addon" | "appName" | "appDescription" | "certificate" | "active" | "runtime" | "jcrUuid" | "requirePrivileged" | "appIdentifier" | "appAuthor" | "appType" | "appImportDate" | "jcrPrimaryType" | "csrfProtection" | "pageId" | "siteId" | "siteName";
|
|
48
|
+
|
|
1
49
|
/**
|
|
2
|
-
* Get app context
|
|
3
|
-
* @
|
|
4
|
-
* @param {string} [key] - Key for value.
|
|
5
|
-
* @return {*|object} - Value or object.
|
|
50
|
+
* Get app context object that is created for app when rendering.
|
|
51
|
+
* @returns App context object.
|
|
6
52
|
*/
|
|
7
|
-
export default function getAppContext(
|
|
53
|
+
export default function getAppContext(): AppContext;
|
|
54
|
+
/**
|
|
55
|
+
* Get app context object that is created for app when rendering.
|
|
56
|
+
* @param key - Key of the app context property to retrieve.
|
|
57
|
+
* @returns App context object.
|
|
58
|
+
*/
|
|
59
|
+
export default function getAppContext<K extends keyof AppContext>(key: K): AppContext[K];
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type AppContextAddon = {
|
|
2
|
+
jcrUuid: string;
|
|
3
|
+
jcrPrimaryType: string;
|
|
4
|
+
displayName: string;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export type AppContextCertificate = {
|
|
8
|
+
signed: boolean;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export type AppContextRuntime = {
|
|
12
|
+
sitevisionVersion: string;
|
|
13
|
+
scriptEngineLanguageVersion: string;
|
|
14
|
+
scriptEngineName: string;
|
|
15
|
+
serverName: string;
|
|
16
|
+
scriptEngineVersion: string;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type AppContext = {
|
|
20
|
+
appId: string;
|
|
21
|
+
contextNodeId: string;
|
|
22
|
+
servletPath: string;
|
|
23
|
+
portletId: string;
|
|
24
|
+
dashboardId: string;
|
|
25
|
+
appVersion: string;
|
|
26
|
+
maxUploadSizeInMB: number;
|
|
27
|
+
appHelpURL: string;
|
|
28
|
+
addon: AppContextAddon;
|
|
29
|
+
appName: string;
|
|
30
|
+
appDescription: string;
|
|
31
|
+
certificate: AppContextCertificate;
|
|
32
|
+
active: boolean;
|
|
33
|
+
runtime: AppContextRuntime;
|
|
34
|
+
jcrUuid: string;
|
|
35
|
+
requirePrivileged: boolean;
|
|
36
|
+
appIdentifier: string;
|
|
37
|
+
appAuthor: string;
|
|
38
|
+
appType: string;
|
|
39
|
+
appImportDate: number;
|
|
40
|
+
jcrPrimaryType: string;
|
|
41
|
+
csrfProtection: boolean;
|
|
42
|
+
pageId: string;
|
|
43
|
+
siteId: string;
|
|
44
|
+
siteName: string;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type AppContextKey = "appId" | "contextNodeId" | "servletPath" | "portletId" | "dashboardId" | "appVersion" | "maxUploadSizeInMB" | "appHelpURL" | "addon" | "appName" | "appDescription" | "certificate" | "active" | "runtime" | "jcrUuid" | "requirePrivileged" | "appIdentifier" | "appAuthor" | "appType" | "appImportDate" | "jcrPrimaryType" | "csrfProtection" | "pageId" | "siteId" | "siteName";
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Get app context object that is created for app when rendering.
|
|
51
|
+
* @returns App context object.
|
|
52
|
+
*/
|
|
53
|
+
export default function getAppContext(): AppContext;
|
|
54
|
+
/**
|
|
55
|
+
* Get app context object that is created for app when rendering.
|
|
56
|
+
* @param key - Key of the app context property to retrieve.
|
|
57
|
+
* @returns App context object.
|
|
58
|
+
*/
|
|
59
|
+
export default function getAppContext<K extends keyof AppContext>(key: K): AppContext[K];
|
package/utils/getAppContext.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Get app context value or object that is created for app when rendering.
|
|
3
|
-
* @export
|
|
4
|
-
* @param {string} [key] - Key for value.
|
|
5
|
-
* @return {*|object} - Value or object.
|
|
6
|
-
*/
|
|
7
1
|
export default function getAppContext(key) {
|
|
8
2
|
if (!window.CONFIG_APP_CONTEXT) {
|
|
9
3
|
console.warn(`App context is not created, add the following in config/index.js:
|