@hkdigital/lib-sveltekit 0.0.77 → 0.0.78

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.
@@ -2,16 +2,17 @@
2
2
  * Configures and returns a function that can be used as
3
3
  * 'resolveConfigs' parameter in imagetools config
4
4
  *
5
- * - This function runs after 'defaultDirectives'
6
- *
7
5
  * @param {object} [options]
8
6
  * @param {number[]} [options.widths=DEFAULT_WIDTHS]
9
- *
10
- * @returns {(config: [ key:string, [ value: string] ][]) => Record<string, string>[]|undefined}
7
+ * @returns {(
8
+ * entries: [string, string[]][]
9
+ * ) => { [key: string]: string | string[] }[]}
11
10
  */
12
11
  export function generateResponseConfigs(options?: {
13
12
  widths?: number[];
14
- }): (config: [key: string, [value: string]][]) => Record<string, string>[] | undefined;
13
+ }): (entries: [string, string[]][]) => {
14
+ [key: string]: string | string[];
15
+ }[];
15
16
  /**
16
17
  * Configures and returns a function that can be used as
17
18
  * 'defaultDirectives' parameter in imagetools config
@@ -32,39 +32,29 @@ const DEFAULT_PRESETS = {
32
32
  * Configures and returns a function that can be used as
33
33
  * 'resolveConfigs' parameter in imagetools config
34
34
  *
35
- * - This function runs after 'defaultDirectives'
36
- *
37
35
  * @param {object} [options]
38
36
  * @param {number[]} [options.widths=DEFAULT_WIDTHS]
39
- *
40
- * @returns {(config: [ key:string, [ value: string] ][]) => Record<string, string>[]|undefined}
37
+ * @returns {(
38
+ * entries: [string, string[]][]
39
+ * ) => { [key: string]: string | string[] }[]}
41
40
  */
42
41
  export function generateResponseConfigs(options) {
43
- /**
44
- * Function that returns a list that specifies the image
45
- * widths for the image variants that should be generated
46
- * when the directive 'responsive' is set.
47
- *
48
- * @param {[ key:string, [ value: string] ][]} config
49
- *
50
- * @returns {Record<string, string>[]|undefined}
51
- */
52
- return function resolveConfigs(config) {
53
- console.log('resolveConfigs:config', config);
42
+ return function resolveConfigs(entries /*, outputFormats*/) {
43
+ console.log('resolveConfigs:entries', entries);
54
44
 
55
45
  // @ts-ignore
56
- const responsiveConfig = config.find(([key]) => key === 'responsive');
46
+ const responsiveConfig = entries.find(([key]) => key === 'responsive');
57
47
 
58
48
  if (!responsiveConfig) {
59
- // Driective 'responsive' was not set => do nothing
60
- return undefined;
49
+ // Directive 'responsive' was not set => do nothing
50
+ return [];
61
51
  }
62
52
 
63
53
  const widths = options?.widths ?? DEFAULT_WIDTHS;
64
54
 
65
55
  const configPairs = {};
66
56
 
67
- for (const current of config) {
57
+ for (const current of entries) {
68
58
  const key = current[0];
69
59
  const value = current[1][0];
70
60
 
@@ -72,6 +62,7 @@ export function generateResponseConfigs(options) {
72
62
  configPairs[key] = value;
73
63
  }
74
64
 
65
+ /** @type {[key: string]: string | string[] }[]} */
75
66
  return widths.map((w) => {
76
67
  return { ...configPairs, w: String(w) };
77
68
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hkdigital/lib-sveltekit",
3
- "version": "0.0.77",
3
+ "version": "0.0.78",
4
4
  "author": "Jens Kleinhout, HKdigital (https://hkdigital.nl)",
5
5
  "license": "ISC",
6
6
  "repository": {