@soleil-se/app-util 5.12.0 → 5.12.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,14 @@ 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.12.2] - 2025-12-03
11
+
12
+ - Better type definitions for Svelte render functions.
13
+
14
+ ## [5.12.1] - 2025-10-15
15
+
16
+ - Return identifier for Node instances in `toString` function in `app-data` and `global-app-data`.
17
+
10
18
  ## [5.12.0] - 2025-10-09
11
19
 
12
20
  - Add `iteratorToArray`, `nodeIteratorToArray`, `listToArray` and `setToArray` utility functions to convert these data structures into arrays.
package/client/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { default as preventDefault } from "./prevent-default";
2
- export { getUrlParam, getUrlParams, setUrlParams, updateUrlParams, clearUrlParams } from "./url-params";
3
- export { default as fetchJson, FetchError } from "./fetch-json";
1
+ export { default as preventDefault } from "./prevent-default";
2
+ export { getUrlParam, getUrlParams, setUrlParams, updateUrlParams, clearUrlParams } from "./url-params";
3
+ export { default as fetchJson, FetchError } from "./fetch-json";
@@ -1 +1 @@
1
- export default function preventDefault(fn: any): (...args: any[]) => any;
1
+ export default function preventDefault(fn: any): (...args: any[]) => any;
@@ -1 +1 @@
1
- export { render } from "../4";
1
+ export { render } from "../4";
@@ -1,21 +1,21 @@
1
- /** @typedef {import('svelte').SvelteComponent} Component */
2
- /**
3
- * Renders a client side Svelte application.
4
- * @param {Component<any>} App Svelte app root component.
5
- * @param {object} [settings={}] Settings object.
6
- * @param {HTMLElement} [settings.target] Target where app should be mounted.
7
- * @param {Record<string, any>} [settings.props] Root component props.
8
- * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
9
- * DOM (usually from server-side rendering) rather than creating new elements. By default the app
10
- * will hydrate when the target has any child nodes.
11
- * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
12
- * rather than waiting for subsequent state changes.
13
- * @return {Component} Initialized Svelte component.
14
- */
15
- export function render(App: any, { target, props, intro, hydrate, }?: {
16
- target?: HTMLElement;
17
- props?: Record<string, any>;
18
- hydrate?: boolean;
19
- intro?: boolean;
20
- }): Component;
21
- export type Component = import('svelte').SvelteComponent;
1
+ /** @typedef {import('svelte').SvelteComponent} Component */
2
+ /**
3
+ * Renders a client side Svelte application.
4
+ * @param {Component<any>} App Svelte app root component.
5
+ * @param {object} [settings={}] Settings object.
6
+ * @param {HTMLElement} [settings.target] Target where app should be mounted.
7
+ * @param {Record<string, any>} [settings.props] Root component props.
8
+ * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
9
+ * DOM (usually from server-side rendering) rather than creating new elements. By default the app
10
+ * will hydrate when the target has any child nodes.
11
+ * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
12
+ * rather than waiting for subsequent state changes.
13
+ * @return {Component} Initialized Svelte component.
14
+ */
15
+ export function render(App: any, { target, props, intro, hydrate, }?: {
16
+ target?: HTMLElement;
17
+ props?: Record<string, any>;
18
+ hydrate?: boolean;
19
+ intro?: boolean;
20
+ }): Component;
21
+ export type Component = import('svelte').SvelteComponent;
@@ -1,18 +1,40 @@
1
- /**
2
- * Renders a client side Svelte application.
3
- * @param {import('svelte').Component<any>} App Svelte app root component.
4
- * @param {object} [settings={}] Settings object.
5
- * @param {HTMLElement} [settings.target] Target where app should be mounted.
6
- * @param {Record<string, any>} [settings.props] Root component props.
7
- * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
8
- * DOM (usually from server-side rendering) rather than creating new elements. By default the app
9
- * will hydrate when the target has any child nodes.
10
- * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
11
- * rather than waiting for subsequent state changes.
12
- */
13
- export function render(App: import('svelte').Component<any>, { target, props, hydrate, intro, }?: {
14
- target?: HTMLElement;
15
- props?: Record<string, any>;
16
- hydrate?: boolean;
17
- intro?: boolean;
18
- }): void;
1
+ /// <reference types="svelte" />
2
+ /**
3
+ * @template {Record<string, unknown>} TProps
4
+ * @typedef {object} RenderSettings
5
+ * @property {HTMLElement} [target] Target where app should be mounted.
6
+ * @property {TProps} [props] Root component props.
7
+ * @property {boolean} [hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing DOM
8
+ * (usually from server-side rendering) rather than creating new elements. By default the app will
9
+ * hydrate when the target has any child nodes.
10
+ * @property {boolean} [intro=false] If true, will play transitions on initial render, rather than
11
+ * waiting for subsequent state changes.
12
+ */
13
+ /**
14
+ * Renders a client side Svelte application.
15
+ * @template {Record<string, unknown>} [TProps=Record<string, unknown>]
16
+ * @param {import('svelte').Component<TProps>} App Svelte app root component.
17
+ * @param {RenderSettings<TProps>} [settings={}] Settings object.
18
+ */
19
+ export function render<TProps extends Record<string, unknown> = Record<string, unknown>>(App: import("svelte").Component<TProps, any, string>, { target, props, hydrate, intro, }?: RenderSettings<TProps>): void;
20
+ export type RenderSettings<TProps extends Record<string, unknown>> = {
21
+ /**
22
+ * Target where app should be mounted.
23
+ */
24
+ target?: HTMLElement;
25
+ /**
26
+ * Root component props.
27
+ */
28
+ props?: TProps;
29
+ /**
30
+ * Instructs Svelte to upgrade existing DOM
31
+ * (usually from server-side rendering) rather than creating new elements. By default the app will
32
+ * hydrate when the target has any child nodes.
33
+ */
34
+ hydrate?: boolean;
35
+ /**
36
+ * If true, will play transitions on initial render, rather than
37
+ * waiting for subsequent state changes.
38
+ */
39
+ intro?: boolean;
40
+ };
@@ -3,17 +3,23 @@ import { mount as svelteMount, hydrate as svelteHydrate } from 'svelte';
3
3
 
4
4
  import { setAppProps } from '../../../common';
5
5
 
6
+ /**
7
+ * @template {Record<string, unknown>} TProps
8
+ * @typedef {object} RenderSettings
9
+ * @property {HTMLElement} [target] Target where app should be mounted.
10
+ * @property {TProps} [props] Root component props.
11
+ * @property {boolean} [hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing DOM
12
+ * (usually from server-side rendering) rather than creating new elements. By default the app will
13
+ * hydrate when the target has any child nodes.
14
+ * @property {boolean} [intro=false] If true, will play transitions on initial render, rather than
15
+ * waiting for subsequent state changes.
16
+ */
17
+
6
18
  /**
7
19
  * Renders a client side Svelte application.
8
- * @param {import('svelte').Component<any>} App Svelte app root component.
9
- * @param {object} [settings={}] Settings object.
10
- * @param {HTMLElement} [settings.target] Target where app should be mounted.
11
- * @param {Record<string, any>} [settings.props] Root component props.
12
- * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
13
- * DOM (usually from server-side rendering) rather than creating new elements. By default the app
14
- * will hydrate when the target has any child nodes.
15
- * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
16
- * rather than waiting for subsequent state changes.
20
+ * @template {Record<string, unknown>} [TProps=Record<string, unknown>]
21
+ * @param {import('svelte').Component<TProps>} App Svelte app root component.
22
+ * @param {RenderSettings<TProps>} [settings={}] Settings object.
17
23
  */
18
24
  export function render(App, {
19
25
  target,
@@ -1,21 +1,21 @@
1
- /**
2
- * Renders a client side Svelte 3 or 4 application.
3
- * @deprecated Use rendering function for specific Svelte version instead.
4
- * `import { render } from '@soleil-api/webapp-util/client/svelte/{3|4|5}';`
5
- * @param {import('svelte').SvelteComponent<any>} App Svelte app root component.
6
- * @param {object} [settings={}] Settings object.
7
- * @param {string} [settings.target] Target where app should be mounted.
8
- * @param {string} [settings.props] Root component props.
9
- * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
10
- * DOM (usually from server-side rendering) rather than creating new elements. By default the app
11
- * will hydrate when the target has any child nodes.
12
- * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
13
- * rather than waiting for subsequent state changes.
14
- * @return {import('svelte').SvelteComponent} Initialized Svelte component.
15
- */
16
- export function render(App: import('svelte').SvelteComponent<any>, settings?: {
17
- target?: string;
18
- props?: string;
19
- hydrate?: boolean;
20
- intro?: boolean;
21
- }): import('svelte').SvelteComponent;
1
+ /**
2
+ * Renders a client side Svelte 3 or 4 application.
3
+ * @deprecated Use rendering function for specific Svelte version instead.
4
+ * `import { render } from '@soleil-api/webapp-util/client/svelte/{3|4|5}';`
5
+ * @param {import('svelte').SvelteComponent<any>} App Svelte app root component.
6
+ * @param {object} [settings={}] Settings object.
7
+ * @param {string} [settings.target] Target where app should be mounted.
8
+ * @param {string} [settings.props] Root component props.
9
+ * @param {boolean} [settings.hydrate=target.hasChildNodes()] Instructs Svelte to upgrade existing
10
+ * DOM (usually from server-side rendering) rather than creating new elements. By default the app
11
+ * will hydrate when the target has any child nodes.
12
+ * @param {boolean} [settings.intro=false] If true, will play transitions on initial render,
13
+ * rather than waiting for subsequent state changes.
14
+ * @return {import('svelte').SvelteComponent} Initialized Svelte component.
15
+ */
16
+ export function render(App: import('svelte').SvelteComponent<any>, settings?: {
17
+ target?: string;
18
+ props?: string;
19
+ hydrate?: boolean;
20
+ intro?: boolean;
21
+ }): import('svelte').SvelteComponent;
package/common/index.d.ts CHANGED
@@ -1,81 +1,81 @@
1
- /**
2
- * Get a prefixed namespace unique for app.
3
- * @param {string} [prefix='app']
4
- * @return {string} - Prefixed namespace.
5
- */
6
- export function getNamespace(prefix?: string): string;
7
- /**
8
- * Generate a unique identifier with a random UUID without dashes.
9
- * @param {string} prefix Prefix for the identifier.
10
- * @returns {string} Unique identifier.
11
- */
12
- export function generateId(prefix?: string): string;
13
- /**
14
- * Stringify an object to a query string compatible with Sitevision.
15
- * @param {Object} params Object with parameters to stringify.
16
- * @param {Object} [options] Optional options.
17
- * @param {Boolean} [options.addQueryPrefix = false] If a leading ? should be added to the string.
18
- * @returns Stringified parameters.
19
- */
20
- export function stringifyParams(params?: any, { addQueryPrefix }?: {
21
- addQueryPrefix?: boolean;
22
- }): string;
23
- /**
24
- * Parse an URL or URI to an object containing its query parameters.
25
- * @param {String} url URL or URI to be parsed, must start with or contain "?".
26
- * @returns Object with parsed parameters.
27
- */
28
- export function parseParams(url?: string): {};
29
- /**
30
- * Get URI for a route, same as `getStandaloneUrl` in Sitevision router.
31
- * @param {string} route A route.
32
- * @param {object} params Query parameters.
33
- * @returns {string} URI for route.
34
- */
35
- export function getRouteUri(route?: string, params?: object): string;
36
- /**
37
- * Get URI for a view, same as `getUrl` in Sitevision router.
38
- * @deprecated Not used in WebApps 2.
39
- * @param {string} route A route.
40
- * @returns {string} URI for view.
41
- */
42
- export function getViewUri(route?: string, params?: any): string;
43
- /**
44
- * Get URI for a resource.
45
- * @param {string} resource A resource.
46
- * @returns {string} URI for a resource.
47
- */
48
- export function getResourceUri(resource?: string): string;
49
- export function setAppProps(data: any): void;
50
- /**
51
- * Get appData value or object that is passed to app when rendering.
52
- * @export
53
- * @param {string} [key] - Key for value.
54
- * @return {*|object} - Value or object.
55
- */
56
- export function getAppProps(key?: string): any | object;
57
- /**
58
- * If the current code is running on the server.
59
- * @constant {boolean}
60
- */
61
- export const isServer: any;
62
- /**
63
- * If the current code is running in the browser.
64
- * @constant {boolean}
65
- */
66
- export const isBrowser: boolean;
67
- /**
68
- * DOM friendly unique identifier for the WebApp.
69
- * @constant {string}
70
- */
71
- export const appId: string;
72
- /**
73
- * If the WebApp is running in offline mode or not.
74
- * @constant {boolean}
75
- */
76
- export const isOffline: boolean;
77
- /**
78
- * If the WebApp is running in online mode or not.
79
- * @constant {boolean}
80
- */
81
- export const isOnline: boolean;
1
+ /**
2
+ * Get a prefixed namespace unique for app.
3
+ * @param {string} [prefix='app']
4
+ * @return {string} - Prefixed namespace.
5
+ */
6
+ export function getNamespace(prefix?: string): string;
7
+ /**
8
+ * Generate a unique identifier with a random UUID without dashes.
9
+ * @param {string} prefix Prefix for the identifier.
10
+ * @returns {string} Unique identifier.
11
+ */
12
+ export function generateId(prefix?: string): string;
13
+ /**
14
+ * Stringify an object to a query string compatible with Sitevision.
15
+ * @param {Object} params Object with parameters to stringify.
16
+ * @param {Object} [options] Optional options.
17
+ * @param {Boolean} [options.addQueryPrefix = false] If a leading ? should be added to the string.
18
+ * @returns Stringified parameters.
19
+ */
20
+ export function stringifyParams(params?: any, { addQueryPrefix }?: {
21
+ addQueryPrefix?: boolean;
22
+ }): string;
23
+ /**
24
+ * Parse an URL or URI to an object containing its query parameters.
25
+ * @param {String} url URL or URI to be parsed, must start with or contain "?".
26
+ * @returns Object with parsed parameters.
27
+ */
28
+ export function parseParams(url?: string): {};
29
+ /**
30
+ * Get URI for a route, same as `getStandaloneUrl` in Sitevision router.
31
+ * @param {string} route A route.
32
+ * @param {object} params Query parameters.
33
+ * @returns {string} URI for route.
34
+ */
35
+ export function getRouteUri(route?: string, params?: object): string;
36
+ /**
37
+ * Get URI for a view, same as `getUrl` in Sitevision router.
38
+ * @deprecated Not used in WebApps 2.
39
+ * @param {string} route A route.
40
+ * @returns {string} URI for view.
41
+ */
42
+ export function getViewUri(route?: string, params?: any): string;
43
+ /**
44
+ * Get URI for a resource.
45
+ * @param {string} resource A resource.
46
+ * @returns {string} URI for a resource.
47
+ */
48
+ export function getResourceUri(resource?: string): string;
49
+ export function setAppProps(data: any): void;
50
+ /**
51
+ * Get appData value or object that is passed to app when rendering.
52
+ * @export
53
+ * @param {string} [key] - Key for value.
54
+ * @return {*|object} - Value or object.
55
+ */
56
+ export function getAppProps(key?: string): any | object;
57
+ /**
58
+ * If the current code is running on the server.
59
+ * @constant {boolean}
60
+ */
61
+ export const isServer: any;
62
+ /**
63
+ * If the current code is running in the browser.
64
+ * @constant {boolean}
65
+ */
66
+ export const isBrowser: boolean;
67
+ /**
68
+ * DOM friendly unique identifier for the WebApp.
69
+ * @constant {string}
70
+ */
71
+ export const appId: string;
72
+ /**
73
+ * If the WebApp is running in offline mode or not.
74
+ * @constant {boolean}
75
+ */
76
+ export const isOffline: boolean;
77
+ /**
78
+ * If the WebApp is running in online mode or not.
79
+ * @constant {boolean}
80
+ */
81
+ export const isOnline: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@soleil-se/app-util",
3
- "version": "5.12.0",
3
+ "version": "5.12.2",
4
4
  "description": "Utility functions for WebApps, RESTApps and Widgets in Sitevision.",
5
5
  "main": "./common/index.js",
6
6
  "author": "Soleil AB",
@@ -25,5 +25,5 @@
25
25
  "scripts": {
26
26
  "create-type-definitions": "node ../../utils/createTypeDefinitions.js ./common/index.js ./client/index.js ./client/svelte/index.js ./client/svelte/3/index.js ./client/svelte/4/index.js ./client/svelte/5/index.js ./server/index.js ./server/svelte/index.js ./server/svelte/3/index.js ./server/svelte/4/index.js ./server/svelte/5/index.js ./server/app-data/index.js ./server/global-app-data/index.js"
27
27
  },
28
- "gitHead": "b307141c40e0116c6f2f2c3354656904d9fedb79"
28
+ "gitHead": "090c22c4eee4dc2f68096f8f50cca8015a91acf7"
29
29
  }
@@ -1,84 +1,84 @@
1
- export default appData;
2
- declare namespace appData {
3
- /**
4
- * Get a value from app data, same as get in \@sitevision/api/server/appData.
5
- * @param {string} key - The key of app data to retrieve.
6
- * @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
7
- * @returns {unknown} The value of the app data or a properties of a JCR Node.
8
- */
9
- function get(key: string, ...properties?: string[]): unknown;
10
- /**
11
- * Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
12
- * @param {string} key - The key of app data to retrieve.
13
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
14
- * Nodes for list components or value wrapped in an array for single type components.
15
- */
16
- function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
17
- /**
18
- * Get a string value from app data.
19
- * @param {string} key - The key of app data to retrieve.
20
- * @returns {string | undefined} The string value or undefined if not set.
21
- */
22
- function getString(key: string): string | undefined;
23
- /**
24
- * Get a boolean value from app data.
25
- * @param {string} key - The key of app data to retrieve.
26
- * @returns {boolean | undefined} The boolean value or undefined if not set.
27
- */
28
- function getBoolean(key: string): boolean | undefined;
29
- /**
30
- * Get a number value from app data.
31
- * @param {string} key - The key of app data to retrieve.
32
- * @returns {number | undefined} The number value, undefined if not set or not a number.
33
- */
34
- function getNumber(key: string): number | undefined;
35
- /**
36
- * Get an array of nodes from app data.
37
- * @param {string} key - The key of app data to retrieve.
38
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
39
- * empty array if not set.
40
- */
41
- function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
42
- /**
43
- * Get an array of strings from app data.
44
- * @param {string} key - The key of app data to retrieve.
45
- * @returns {string[]} The array of strings or an empty array if not set.
46
- */
47
- function getStrings(key: string): string[];
48
- /**
49
- * Get a JCR Node from app data.
50
- * @param {string} key - The key of the property to retrieve.
51
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
52
- * undefined if not set.
53
- */
54
- function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
55
- /**
56
- * Get a string property from a JCR Node referenced in app data.
57
- * @param {string} key - The key of the app data value.
58
- * @param {string} property - The property to retrieve from the node.
59
- * @returns {string | undefined} The string property value or undefined if not set.
60
- */
61
- function getStringProperty(key: string, property: string): string | undefined;
62
- /**
63
- * Get a string array property or a single string wrapped in an array from a JCR Node referenced
64
- * in app data.
65
- * @param {string} key - The key of app data to retrieve.
66
- * @param {string} property - The property to retrieve from the node.
67
- * @returns {string[]} The array of strings or an empty array if not set.
68
- */
69
- function getStringsProperty(key: string, property: string): string[];
70
- /**
71
- * Get a boolean property from a JCR Node referenced in app data.
72
- * @param {string} key - The key of the app data value.
73
- * @param {string} property - The property to retrieve from the node.
74
- * @returns {boolean | undefined} The boolean property value or undefined if not set.
75
- */
76
- function getBooleanProperty(key: string, property: string): boolean | undefined;
77
- /**
78
- * Get a number property from a JCR Node referenced in app data.
79
- * @param {string} key - The key of the app data value.
80
- * @param {string} property - The property to retrieve from the node.
81
- * @returns {number | undefined} The number property value, undefined if not set or not a number.
82
- */
83
- function getNumberProperty(key: string, property: string): number | undefined;
84
- }
1
+ export default appData;
2
+ declare namespace appData {
3
+ /**
4
+ * Get a value from app data, same as get in \@sitevision/api/server/appData.
5
+ * @param {string} key - The key of app data to retrieve.
6
+ * @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
7
+ * @returns {unknown} The value of the app data or a properties of a JCR Node.
8
+ */
9
+ function get(key: string, ...properties?: string[]): unknown;
10
+ /**
11
+ * Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
12
+ * @param {string} key - The key of app data to retrieve.
13
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
14
+ * Nodes for list components or value wrapped in an array for single type components.
15
+ */
16
+ function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
17
+ /**
18
+ * Get a string value from app data.
19
+ * @param {string} key - The key of app data to retrieve.
20
+ * @returns {string | undefined} The string value or undefined if not set.
21
+ */
22
+ function getString(key: string): string | undefined;
23
+ /**
24
+ * Get a boolean value from app data.
25
+ * @param {string} key - The key of app data to retrieve.
26
+ * @returns {boolean | undefined} The boolean value or undefined if not set.
27
+ */
28
+ function getBoolean(key: string): boolean | undefined;
29
+ /**
30
+ * Get a number value from app data.
31
+ * @param {string} key - The key of app data to retrieve.
32
+ * @returns {number | undefined} The number value, undefined if not set or not a number.
33
+ */
34
+ function getNumber(key: string): number | undefined;
35
+ /**
36
+ * Get an array of nodes from app data.
37
+ * @param {string} key - The key of app data to retrieve.
38
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
39
+ * empty array if not set.
40
+ */
41
+ function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
42
+ /**
43
+ * Get an array of strings from app data.
44
+ * @param {string} key - The key of app data to retrieve.
45
+ * @returns {string[]} The array of strings or an empty array if not set.
46
+ */
47
+ function getStrings(key: string): string[];
48
+ /**
49
+ * Get a JCR Node from app data.
50
+ * @param {string} key - The key of the property to retrieve.
51
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
52
+ * undefined if not set.
53
+ */
54
+ function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
55
+ /**
56
+ * Get a string property from a JCR Node referenced in app data.
57
+ * @param {string} key - The key of the app data value.
58
+ * @param {string} property - The property to retrieve from the node.
59
+ * @returns {string | undefined} The string property value or undefined if not set.
60
+ */
61
+ function getStringProperty(key: string, property: string): string | undefined;
62
+ /**
63
+ * Get a string array property or a single string wrapped in an array from a JCR Node referenced
64
+ * in app data.
65
+ * @param {string} key - The key of app data to retrieve.
66
+ * @param {string} property - The property to retrieve from the node.
67
+ * @returns {string[]} The array of strings or an empty array if not set.
68
+ */
69
+ function getStringsProperty(key: string, property: string): string[];
70
+ /**
71
+ * Get a boolean property from a JCR Node referenced in app data.
72
+ * @param {string} key - The key of the app data value.
73
+ * @param {string} property - The property to retrieve from the node.
74
+ * @returns {boolean | undefined} The boolean property value or undefined if not set.
75
+ */
76
+ function getBooleanProperty(key: string, property: string): boolean | undefined;
77
+ /**
78
+ * Get a number property from a JCR Node referenced in app data.
79
+ * @param {string} key - The key of the app data value.
80
+ * @param {string} property - The property to retrieve from the node.
81
+ * @returns {number | undefined} The number property value, undefined if not set or not a number.
82
+ */
83
+ function getNumberProperty(key: string, property: string): number | undefined;
84
+ }
@@ -9,6 +9,7 @@ import InstanceTypeUtil from '@sitevision/api/server/InstanceTypeUtil';
9
9
  */
10
10
  function toString(value) {
11
11
  if (value === null || value === undefined) return undefined;
12
+ if (InstanceTypeUtil.isNode(value)) return value.getIdentifier();
12
13
  return value.toString();
13
14
  }
14
15
 
@@ -1,84 +1,84 @@
1
- export default globalAppData;
2
- declare namespace globalAppData {
3
- /**
4
- * Get a value from app data, same as get in \@sitevision/api/server/appData.
5
- * @param {string} key - The key of app data to retrieve.
6
- * @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
7
- * @returns {unknown} The value of the app data or a properties of a JCR Node.
8
- */
9
- function get(key: string, ...properties?: string[]): unknown;
10
- /**
11
- * Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
12
- * @param {string} key - The key of app data to retrieve.
13
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
14
- * Nodes for list components or value wrapped in an array for single type components.
15
- */
16
- function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
17
- /**
18
- * Get a string value from app data.
19
- * @param {string} key - The key of app data to retrieve.
20
- * @returns {string | undefined} The string value or undefined if not set.
21
- */
22
- function getString(key: string): string | undefined;
23
- /**
24
- * Get a boolean value from app data.
25
- * @param {string} key - The key of app data to retrieve.
26
- * @returns {boolean | undefined} The boolean value or undefined if not set.
27
- */
28
- function getBoolean(key: string): boolean | undefined;
29
- /**
30
- * Get a number value from app data.
31
- * @param {string} key - The key of app data to retrieve.
32
- * @returns {number | undefined} The number value, undefined if not set or not a number.
33
- */
34
- function getNumber(key: string): number | undefined;
35
- /**
36
- * Get an array of nodes from app data.
37
- * @param {string} key - The key of app data to retrieve.
38
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
39
- * empty array if not set.
40
- */
41
- function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
42
- /**
43
- * Get an array of strings from app data.
44
- * @param {string} key - The key of app data to retrieve.
45
- * @returns {string[]} The array of strings or an empty array if not set.
46
- */
47
- function getStrings(key: string): string[];
48
- /**
49
- * Get a JCR Node from app data.
50
- * @param {string} key - The key of the property to retrieve.
51
- * @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
52
- * undefined if not set.
53
- */
54
- function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
55
- /**
56
- * Get a string property from a JCR Node referenced in app data.
57
- * @param {string} key - The key of the app data value.
58
- * @param {string} property - The property to retrieve from the node.
59
- * @returns {string | undefined} The string property value or undefined if not set.
60
- */
61
- function getStringProperty(key: string, property: string): string | undefined;
62
- /**
63
- * Get a string array property or a single string wrapped in an array from a JCR Node referenced
64
- * in app data.
65
- * @param {string} key - The key of app data to retrieve.
66
- * @param {string} property - The property to retrieve from the node.
67
- * @returns {string[]} The array of strings or an empty array if not set.
68
- */
69
- function getStringsProperty(key: string, property: string): string[];
70
- /**
71
- * Get a boolean property from a JCR Node referenced in app data.
72
- * @param {string} key - The key of the app data value.
73
- * @param {string} property - The property to retrieve from the node.
74
- * @returns {boolean | undefined} The boolean property value or undefined if not set.
75
- */
76
- function getBooleanProperty(key: string, property: string): boolean | undefined;
77
- /**
78
- * Get a number property from a JCR Node referenced in app data.
79
- * @param {string} key - The key of the app data value.
80
- * @param {string} property - The property to retrieve from the node.
81
- * @returns {number | undefined} The number property value, undefined if not set or not a number.
82
- */
83
- function getNumberProperty(key: string, property: string): number | undefined;
84
- }
1
+ export default globalAppData;
2
+ declare namespace globalAppData {
3
+ /**
4
+ * Get a value from app data, same as get in \@sitevision/api/server/appData.
5
+ * @param {string} key - The key of app data to retrieve.
6
+ * @param {...string} [properties] - The keys of the properties to retrieve from a JCR Node.
7
+ * @returns {unknown} The value of the app data or a properties of a JCR Node.
8
+ */
9
+ function get(key: string, ...properties?: string[]): unknown;
10
+ /**
11
+ * Get a value from app data as an array, same as getArray in \@sitevision/api/server/appData.
12
+ * @param {string} key - The key of app data to retrieve.
13
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[] | string[]} An array of JCR
14
+ * Nodes for list components or value wrapped in an array for single type components.
15
+ */
16
+ function getArray(key: string): string[] | import("@sitevision/api/types/javax/jcr/Node").Node[];
17
+ /**
18
+ * Get a string value from app data.
19
+ * @param {string} key - The key of app data to retrieve.
20
+ * @returns {string | undefined} The string value or undefined if not set.
21
+ */
22
+ function getString(key: string): string | undefined;
23
+ /**
24
+ * Get a boolean value from app data.
25
+ * @param {string} key - The key of app data to retrieve.
26
+ * @returns {boolean | undefined} The boolean value or undefined if not set.
27
+ */
28
+ function getBoolean(key: string): boolean | undefined;
29
+ /**
30
+ * Get a number value from app data.
31
+ * @param {string} key - The key of app data to retrieve.
32
+ * @returns {number | undefined} The number value, undefined if not set or not a number.
33
+ */
34
+ function getNumber(key: string): number | undefined;
35
+ /**
36
+ * Get an array of nodes from app data.
37
+ * @param {string} key - The key of app data to retrieve.
38
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node[]} The array of nodes or an
39
+ * empty array if not set.
40
+ */
41
+ function getNodes(key: string): import("@sitevision/api/types/javax/jcr/Node").Node[];
42
+ /**
43
+ * Get an array of strings from app data.
44
+ * @param {string} key - The key of app data to retrieve.
45
+ * @returns {string[]} The array of strings or an empty array if not set.
46
+ */
47
+ function getStrings(key: string): string[];
48
+ /**
49
+ * Get a JCR Node from app data.
50
+ * @param {string} key - The key of the property to retrieve.
51
+ * @returns {import('@sitevision/api/types/javax/jcr/Node').Node | undefined} The JCR Node or
52
+ * undefined if not set.
53
+ */
54
+ function getNode(key: string): import("@sitevision/api/types/javax/jcr/Node").Node;
55
+ /**
56
+ * Get a string property from a JCR Node referenced in app data.
57
+ * @param {string} key - The key of the app data value.
58
+ * @param {string} property - The property to retrieve from the node.
59
+ * @returns {string | undefined} The string property value or undefined if not set.
60
+ */
61
+ function getStringProperty(key: string, property: string): string | undefined;
62
+ /**
63
+ * Get a string array property or a single string wrapped in an array from a JCR Node referenced
64
+ * in app data.
65
+ * @param {string} key - The key of app data to retrieve.
66
+ * @param {string} property - The property to retrieve from the node.
67
+ * @returns {string[]} The array of strings or an empty array if not set.
68
+ */
69
+ function getStringsProperty(key: string, property: string): string[];
70
+ /**
71
+ * Get a boolean property from a JCR Node referenced in app data.
72
+ * @param {string} key - The key of the app data value.
73
+ * @param {string} property - The property to retrieve from the node.
74
+ * @returns {boolean | undefined} The boolean property value or undefined if not set.
75
+ */
76
+ function getBooleanProperty(key: string, property: string): boolean | undefined;
77
+ /**
78
+ * Get a number property from a JCR Node referenced in app data.
79
+ * @param {string} key - The key of the app data value.
80
+ * @param {string} property - The property to retrieve from the node.
81
+ * @returns {number | undefined} The number property value, undefined if not set or not a number.
82
+ */
83
+ function getNumberProperty(key: string, property: string): number | undefined;
84
+ }
@@ -9,6 +9,7 @@ import InstanceTypeUtil from '@sitevision/api/server/InstanceTypeUtil';
9
9
  */
10
10
  function toString(value) {
11
11
  if (value === null || value === undefined) return undefined;
12
+ if (InstanceTypeUtil.isNode(value)) return value.getIdentifier();
12
13
  return value.toString();
13
14
  }
14
15
 
@@ -1 +1 @@
1
- export { render } from "../4";
1
+ export { render } from "../4";
@@ -1,9 +1,9 @@
1
- /** @typedef {import('svelte').SvelteComponent} Component */
2
- /**
3
- * Returns HTML for a server rendered Svelte app.
4
- * @param {Component<any>} App Svelte component that is root of app.
5
- * @param {Record<string, any>} props Props passed to root component.
6
- * @return {string} HTML for the server rendered app.
7
- */
8
- export function render(App: any, props: Record<string, any>): string;
9
- export type Component = import('svelte').SvelteComponent;
1
+ /** @typedef {import('svelte').SvelteComponent} Component */
2
+ /**
3
+ * Returns HTML for a server rendered Svelte app.
4
+ * @param {Component<any>} App Svelte component that is root of app.
5
+ * @param {Record<string, any>} props Props passed to root component.
6
+ * @return {string} HTML for the server rendered app.
7
+ */
8
+ export function render(App: any, props: Record<string, any>): string;
9
+ export type Component = import('svelte').SvelteComponent;
@@ -1,7 +1,9 @@
1
- /**
2
- * Returns HTML for a server rendered Svelte app.
3
- * @param {import('svelte').Component<any>} App Svelte component that is root of app.
4
- * @param {Record<string, any>} props Props passed to root component.
5
- * @return {string} HTML for the server rendered app.
6
- */
7
- export function render(App: import('svelte').Component<any>, props: Record<string, any>): string;
1
+ /// <reference types="svelte" />
2
+ /**
3
+ * Returns HTML for a server rendered Svelte app.
4
+ * @template {Record<string, unknown>} [TProps=Record<string, unknown>]
5
+ * @param {import('svelte').Component<TProps>} App Svelte component that is root of app.
6
+ * @param {TProps} props Props passed to root component.
7
+ * @return {string} HTML for the server rendered app.
8
+ */
9
+ export function render<TProps extends Record<string, unknown> = Record<string, unknown>>(App: import("svelte").Component<TProps, any, string>, props: TProps): string;
@@ -3,8 +3,9 @@ import { appId, setAppProps } from '../../../common';
3
3
 
4
4
  /**
5
5
  * Returns HTML for a server rendered Svelte app.
6
- * @param {import('svelte').Component<any>} App Svelte component that is root of app.
7
- * @param {Record<string, any>} props Props passed to root component.
6
+ * @template {Record<string, unknown>} [TProps=Record<string, unknown>]
7
+ * @param {import('svelte').Component<TProps>} App Svelte component that is root of app.
8
+ * @param {TProps} props Props passed to root component.
8
9
  * @return {string} HTML for the server rendered app.
9
10
  */
10
11
  export function render(App, props) {
@@ -1,9 +1,9 @@
1
- /**
2
- * Returns HTML for a server rendered Svelte 3 or 4 app.
3
- * @deprecated Use rendering function for specific Svelte version instead.
4
- * `import { render } from '@soleil-api/webapp-util/server/svelte/{3|4|5}';`
5
- * @param {import('svelte').SvelteComponent<any>} App Svelte component that is root of app.
6
- * @param {object} props Props passed to root component.
7
- * @return {string} HTML for the server rendered app.
8
- */
9
- export function render(App: import('svelte').SvelteComponent<any>, props: object): string;
1
+ /**
2
+ * Returns HTML for a server rendered Svelte 3 or 4 app.
3
+ * @deprecated Use rendering function for specific Svelte version instead.
4
+ * `import { render } from '@soleil-api/webapp-util/server/svelte/{3|4|5}';`
5
+ * @param {import('svelte').SvelteComponent<any>} App Svelte component that is root of app.
6
+ * @param {object} props Props passed to root component.
7
+ * @return {string} HTML for the server rendered app.
8
+ */
9
+ export function render(App: import('svelte').SvelteComponent<any>, props: object): string;