@podium/podlet 5.2.0-next.5 → 5.2.0-next.7

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
@@ -1,149 +1,56 @@
1
- # [5.2.0-next.5](https://github.com/podium-lib/podlet/compare/v5.2.0-next.4...v5.2.0-next.5) (2024-09-29)
1
+ # [5.2.0-next.7](https://github.com/podium-lib/podlet/compare/v5.2.0-next.6...v5.2.0-next.7) (2024-10-22)
2
2
 
3
3
 
4
4
  ### Bug Fixes
5
5
 
6
- * sharpen up shadow dom usage assertion ([a47c8bc](https://github.com/podium-lib/podlet/commit/a47c8bc7bb33bc6c685d882a7f922cd39914a874))
6
+ * correct the JSDoc for fallback ([#423](https://github.com/podium-lib/podlet/issues/423)) ([7444897](https://github.com/podium-lib/podlet/commit/7444897b7cf45a9e2b9c310ce309f69f80fa91d1))
7
+ * **deps:** update all dependencies (non-major) ([b8eddfd](https://github.com/podium-lib/podlet/commit/b8eddfd676810607adc56cdc71d2622e73b25e0e))
8
+ * **deps:** update all dependencies (non-major) ([81119fe](https://github.com/podium-lib/podlet/commit/81119feda716c226777751564ac9153c7c393096))
9
+ * **deps:** update dependency @podium/proxy to v5.0.26 ([59699f0](https://github.com/podium-lib/podlet/commit/59699f029ee32ff4997c7e971bb543ee6a971251))
10
+ * include some app info as a default metric ([5c9fdcb](https://github.com/podium-lib/podlet/commit/5c9fdcb269f9b1867f8df127fcd412f150d3ca95))
11
+ * type the known context values in an extendable way ([#427](https://github.com/podium-lib/podlet/issues/427)) ([f90ef57](https://github.com/podium-lib/podlet/commit/f90ef577cf6f0fdeabb08edb121a8a0107e77c4d))
7
12
 
8
- # [5.2.0-next.4](https://github.com/podium-lib/podlet/compare/v5.2.0-next.3...v5.2.0-next.4) (2024-09-22)
13
+ ## [5.1.18](https://github.com/podium-lib/podlet/compare/v5.1.17...v5.1.18) (2024-10-11)
9
14
 
10
15
 
11
16
  ### Bug Fixes
12
17
 
13
- * tag asset type when sending hint headers ([56c8614](https://github.com/podium-lib/podlet/commit/56c86144207956c63c7ce1d1103efe4f8ff7d7bf))
18
+ * include some app info as a default metric ([5c9fdcb](https://github.com/podium-lib/podlet/commit/5c9fdcb269f9b1867f8df127fcd412f150d3ca95))
14
19
 
15
- # [5.2.0-next.3](https://github.com/podium-lib/podlet/compare/v5.2.0-next.2...v5.2.0-next.3) (2024-09-10)
16
-
17
-
18
- ### Features
19
-
20
- * add DSD shadow DOM encapsulation support ([02c9a64](https://github.com/podium-lib/podlet/commit/02c9a64a6bb2f460c035416e43405ae380cb6d1c))
21
-
22
- # [5.2.0-next.2](https://github.com/podium-lib/podlet/compare/v5.2.0-next.1...v5.2.0-next.2) (2024-09-06)
20
+ ## [5.1.17](https://github.com/podium-lib/podlet/compare/v5.1.16...v5.1.17) (2024-09-23)
23
21
 
24
22
 
25
23
  ### Bug Fixes
26
24
 
27
- * force release 5.2.0-next.2 ([b2fc84c](https://github.com/podium-lib/podlet/commit/b2fc84cd6ced3716aa0964d76f55063db5c37fce))
28
- * force release 5.2.0-next.2 ([84223e8](https://github.com/podium-lib/podlet/commit/84223e823125544eb40cbd50b2558bcb78ba9ce6))
29
- * force release 5.2.0-next.2 ([4f5f19d](https://github.com/podium-lib/podlet/commit/4f5f19d9e486461b822dddf4bf278207927c63be))
30
- * force release 5.2.0-next.2 ([a5a1953](https://github.com/podium-lib/podlet/commit/a5a19536aab17130e79f14b2a8d7e7f58e61d0f0))
31
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
25
+ * type the known context values in an extendable way ([#427](https://github.com/podium-lib/podlet/issues/427)) ([f90ef57](https://github.com/podium-lib/podlet/commit/f90ef577cf6f0fdeabb08edb121a8a0107e77c4d))
32
26
 
33
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
27
+ ## [5.1.16](https://github.com/podium-lib/podlet/compare/v5.1.15...v5.1.16) (2024-09-23)
34
28
 
35
29
 
36
30
  ### Bug Fixes
37
31
 
38
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
39
- * force release 5.2.0-next.2 ([84223e8](https://github.com/podium-lib/podlet/commit/84223e823125544eb40cbd50b2558bcb78ba9ce6))
40
- * force release 5.2.0-next.2 ([4f5f19d](https://github.com/podium-lib/podlet/commit/4f5f19d9e486461b822dddf4bf278207927c63be))
41
- * force release 5.2.0-next.2 ([a5a1953](https://github.com/podium-lib/podlet/commit/a5a19536aab17130e79f14b2a8d7e7f58e61d0f0))
42
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
43
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
44
-
45
-
46
- ### Features
32
+ * **deps:** update all dependencies (non-major) ([b8eddfd](https://github.com/podium-lib/podlet/commit/b8eddfd676810607adc56cdc71d2622e73b25e0e))
47
33
 
48
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
49
-
50
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
34
+ ## [5.1.15](https://github.com/podium-lib/podlet/compare/v5.1.14...v5.1.15) (2024-09-16)
51
35
 
52
36
 
53
37
  ### Bug Fixes
54
38
 
55
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
56
- * force release 5.2.0-next.2 ([4f5f19d](https://github.com/podium-lib/podlet/commit/4f5f19d9e486461b822dddf4bf278207927c63be))
57
- * force release 5.2.0-next.2 ([a5a1953](https://github.com/podium-lib/podlet/commit/a5a19536aab17130e79f14b2a8d7e7f58e61d0f0))
58
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
59
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
60
-
61
-
62
- ### Features
39
+ * correct the JSDoc for fallback ([#423](https://github.com/podium-lib/podlet/issues/423)) ([7444897](https://github.com/podium-lib/podlet/commit/7444897b7cf45a9e2b9c310ce309f69f80fa91d1))
63
40
 
64
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
65
-
66
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
41
+ ## [5.1.14](https://github.com/podium-lib/podlet/compare/v5.1.13...v5.1.14) (2024-09-16)
67
42
 
68
43
 
69
44
  ### Bug Fixes
70
45
 
71
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
72
- * force release 5.2.0-next.2 ([a5a1953](https://github.com/podium-lib/podlet/commit/a5a19536aab17130e79f14b2a8d7e7f58e61d0f0))
73
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
74
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
75
-
46
+ * **deps:** update dependency @podium/proxy to v5.0.26 ([59699f0](https://github.com/podium-lib/podlet/commit/59699f029ee32ff4997c7e971bb543ee6a971251))
76
47
 
77
- ### Features
78
-
79
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
80
-
81
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
82
-
83
-
84
- ### Bug Fixes
85
-
86
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
87
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
88
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
89
-
90
-
91
- ### Features
92
-
93
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
94
-
95
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
48
+ ## [5.1.13](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.1.13) (2024-09-09)
96
49
 
97
50
 
98
51
  ### Bug Fixes
99
52
 
100
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
101
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
102
- * update @podium/utils ([719c1e0](https://github.com/podium-lib/podlet/commit/719c1e0ae4e06144e084e8b95bd04d94313b116e))
103
-
104
-
105
- ### Features
106
-
107
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
108
-
109
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-05)
110
-
111
-
112
- ### Bug Fixes
113
-
114
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
115
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
116
-
117
-
118
- ### Features
119
-
120
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
121
-
122
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-09-03)
123
-
124
-
125
- ### Bug Fixes
126
-
127
- * ensure both key/value and object conversion are supported for JS data attributes ([f243d60](https://github.com/podium-lib/podlet/commit/f243d607356166cd77c83eb72ef7ea84f4b95d80))
128
- * **types:** fix AssetJsLike type ([19494f5](https://github.com/podium-lib/podlet/commit/19494f51c338468c362668678654c119993795db))
129
-
130
-
131
- ### Features
132
-
133
- * automatically send assets with content/fallback requests as 103 early hints ([c4c8c88](https://github.com/podium-lib/podlet/commit/c4c8c889bc491b8a3c4a896220d1205164e6fde4))
134
-
135
- # [5.2.0-next.1](https://github.com/podium-lib/podlet/compare/v5.1.12...v5.2.0-next.1) (2024-08-19)
136
-
137
-
138
- ### Bug Fixes
139
-
140
- * ensure both key/value and object conversion are supported for JS data attributes ([ccdfd1e](https://github.com/podium-lib/podlet/commit/ccdfd1e791c81b4c5aed045b47a316683911d929))
141
- * **types:** fix AssetJsLike type ([1c29350](https://github.com/podium-lib/podlet/commit/1c29350a9f0682df675b44cf4c5e88468ab24043))
142
-
143
-
144
- ### Features
145
-
146
- * add res.assets for request bound, early hinted asset sending ([caca302](https://github.com/podium-lib/podlet/commit/caca302a2d80144e24d2078c3ae8f7a8f423b1dd))
53
+ * **deps:** update all dependencies (non-major) ([81119fe](https://github.com/podium-lib/podlet/commit/81119feda716c226777751564ac9153c7c393096))
147
54
 
148
55
  ## [5.1.12](https://github.com/podium-lib/podlet/compare/v5.1.11...v5.1.12) (2024-08-19)
149
56
 
package/lib/podlet.js CHANGED
@@ -34,12 +34,12 @@ const { template } = utils;
34
34
  * @property {string} name - (required) podlet name
35
35
  * @property {string} version - (required) podlet version
36
36
  * @property {string} pathname - (required) podlet pathname
37
- * @property {string} [manifest='/manifest.json'] - path where the podlet manifest file is served from (default '/manifest.json')
38
- * @property {string} [content='/'] - path where the podlet content HTML markup is served from (default '/')
39
- * @property {string} [fallback=''] - path where the podlet fallback HTML markup is served from (default '/fallback')
37
+ * @property {string} [manifest="/manifest.json"] - path where the podlet manifest file is served from (default '/manifest.json')
38
+ * @property {string} [content="/"] - path where the podlet content HTML markup is served from (default '/')
39
+ * @property {string} [fallback=""] - path where the podlet fallback HTML markup is served from (default '/fallback')
40
40
  * @property {boolean} [development=false] - a boolean flag that, when true, enables additional development setup (default false)
41
41
  * @property {boolean} [useShadowDOM=false] - a boolean flag that, when true, enables the use of ShadowDOM (default false)
42
- * @property {import('abslog').AbstractLoggerOptions} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
42
+ * @property {import("abslog").AbstractLoggerOptions} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
43
43
  * @property {import("@podium/proxy").PodiumProxyOptions} [proxy] - options that can be provided to configure the @podium/proxy instance used by the podlet. See that module for details.
44
44
  *
45
45
  * @typedef {{ debug: 'true' | 'false', locale: string, deviceType: string, requestedBy: string, mountOrigin: string, mountPathname: string, publicPathname: string }} PodletContext
@@ -141,7 +141,7 @@ export default class PodiumPodlet {
141
141
  httpProxy;
142
142
 
143
143
  /**
144
- * The pathname for the manifest of the podlet. Defaults to /manifest.json. (set in the constructor)
144
+ * The pathname for the manifest of the podlet. Defaults to "/manifest.json".
145
145
  * The value should be relative to the value set on the pathname argument.
146
146
  * In other words if a podlet is mounted into an HTTP server at /foo and the manifest is at /foo/component.json, pathname will be /foo and manifestRoute will be /component.json
147
147
  *
@@ -155,7 +155,7 @@ export default class PodiumPodlet {
155
155
  manifestRoute = '/manifest.json';
156
156
 
157
157
  /**
158
- * The pathname for the content route of the podlet. Defaults to /. (set in the constructor)
158
+ * The pathname for the content route of the podlet. Defaults to "/".
159
159
  * The value should be relative to the value set on the pathname argument.
160
160
  * In other words if a podlet is mounted into an HTTP server at /foo and the content is at /foo/content, pathname will be /foo and contentRoute will be /content
161
161
  *
@@ -169,7 +169,7 @@ export default class PodiumPodlet {
169
169
  contentRoute = '/';
170
170
 
171
171
  /**
172
- * The pathname for the fallback route of the podlet. Defaults to /fallback. (set in the constructor)
172
+ * The pathname for the fallback route of the podlet. Defaults to no fallback.
173
173
  * The value should be relative to the value set on the pathname argument.
174
174
  * In other words if a podlet is mounted into an HTTP server at /foo and the fallback is at /foo/fallback, pathname will be /foo and fallbackRoute will be /fallback
175
175
  *
@@ -407,6 +407,18 @@ export default class PodiumPodlet {
407
407
  });
408
408
 
409
409
  versionGauge.set(1);
410
+
411
+ const podletGauge = this.metrics.gauge({
412
+ name: 'podium_podlet_application_info',
413
+ description: '@podium/podlet application info',
414
+ labels: {
415
+ name: this.name,
416
+ version: this.version,
417
+ has_fallback: Boolean(fallback),
418
+ },
419
+ });
420
+
421
+ podletGauge.set(1);
410
422
  });
411
423
 
412
424
  // @ts-ignore
@@ -935,24 +947,6 @@ export default class PodiumPodlet {
935
947
  await this.httpProxy.process(incoming);
936
948
  }
937
949
 
938
- const js = incoming.js.map(
939
- // @ts-ignore
940
- (asset) => asset.toHeader() + '; asset-type=script',
941
- );
942
-
943
- const css = incoming.css.map(
944
- // @ts-ignore
945
- (asset) => asset.toHeader() + '; asset-type=style',
946
- );
947
-
948
- // Send early hints to layout client in the form of a 103 status code and a link header with js/css asset information.
949
- // Always send this. If no assets present, send an empty string.
950
- if (incoming.response.writeEarlyHints) {
951
- incoming.response.writeEarlyHints({
952
- link: [...js, ...css],
953
- });
954
- }
955
-
956
950
  return incoming;
957
951
  }
958
952
 
@@ -986,6 +980,18 @@ export default class PodiumPodlet {
986
980
  // if this is a proxy request then no further work should be done.
987
981
  if (incoming.proxy) return;
988
982
 
983
+ const js = incoming.js.map(
984
+ // @ts-ignore
985
+ (asset) => asset.toHeader() + '; asset-type=script',
986
+ );
987
+
988
+ const css = incoming.css.map(
989
+ // @ts-ignore
990
+ (asset) => asset.toHeader() + '; asset-type=style',
991
+ );
992
+
993
+ res.header('Link', [...js, ...css].join(', '));
994
+
989
995
  // set "incoming" on res.locals.podium
990
996
  objobj.set('locals.podium', incoming, res);
991
997
 
@@ -993,8 +999,15 @@ export default class PodiumPodlet {
993
999
  res.header('podlet-version', this.version);
994
1000
  }
995
1001
 
996
- res.podiumSend = (data, ...args) =>
997
- res.send(this.render(incoming, data, ...args));
1002
+ res.sendHeaders = () => {
1003
+ res.write('');
1004
+ return res;
1005
+ };
1006
+
1007
+ res.podiumSend = (data, ...args) => {
1008
+ res.write(this.render(incoming, data, ...args));
1009
+ res.end();
1010
+ };
998
1011
 
999
1012
  next();
1000
1013
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podium/podlet",
3
- "version": "5.2.0-next.5",
3
+ "version": "5.2.0-next.7",
4
4
  "type": "module",
5
5
  "description": "Module for building page fragment servers in a micro frontend architecture.",
6
6
  "license": "MIT",
@@ -26,42 +26,34 @@
26
26
  "scripts": {
27
27
  "lint": "eslint .",
28
28
  "lint:fix": "eslint --fix .",
29
- "test": "run-s test:*",
30
- "test:unit": "tap --disable-coverage --allow-empty-coverage",
31
- "test:types": "tsc --project tsconfig.test.json",
32
- "types": "run-s types:tsc types:fixup",
29
+ "test": "tap --disable-coverage --allow-empty-coverage",
30
+ "types": "run-s types:tsc types:fixup types:test",
33
31
  "types:tsc": "tsc --declaration --emitDeclarationOnly",
32
+ "types:test": "tsc --project tsconfig.test.json",
34
33
  "types:fixup": "node ./fixup.js"
35
34
  },
36
35
  "dependencies": {
37
36
  "@metrics/client": "2.5.3",
38
- "@podium/proxy": "5.0.24",
37
+ "@podium/proxy": "5.0.28",
39
38
  "@podium/schemas": "5.0.6",
40
- "@podium/utils": "5.2.1",
39
+ "@podium/utils": "5.3.1",
41
40
  "abslog": "2.4.4",
42
41
  "ajv": "8.17.1",
43
42
  "objobj": "1.0.0"
44
43
  },
45
44
  "devDependencies": {
46
- "@babel/eslint-parser": "7.25.1",
47
- "@podium/test-utils": "2.5.2",
48
- "@semantic-release/changelog": "6.0.3",
49
- "@semantic-release/commit-analyzer": "11.1.0",
50
- "@semantic-release/git": "10.0.1",
51
- "@semantic-release/github": "9.2.6",
52
- "@semantic-release/npm": "11.0.3",
53
- "@semantic-release/release-notes-generator": "12.1.0",
54
- "@types/node": "^20.10.3",
45
+ "@podium/eslint-config": "1.0.0",
46
+ "@podium/semantic-release-config": "2.0.0",
47
+ "@podium/test-utils": "3.0.10",
48
+ "@podium/typescript-config": "1.0.0",
49
+ "@types/node": "20.16.10",
55
50
  "@types/readable-stream": "4.0.15",
56
- "eslint": "9.9.1",
57
- "eslint-config-prettier": "9.1.0",
58
- "eslint-plugin-prettier": "5.2.1",
59
- "express": "4.19.2",
60
- "globals": "15.9.0",
51
+ "eslint": "9.11.1",
52
+ "express": "4.20.0",
61
53
  "json-stringify-safe": "5.0.1",
62
- "npm-run-all2": "5.0.2",
54
+ "npm-run-all2": "6.2.3",
63
55
  "prettier": "3.3.3",
64
- "semantic-release": "23.1.1",
56
+ "semantic-release": "24.1.2",
65
57
  "tap": "18.8.0",
66
58
  "typescript": "5.5.4",
67
59
  "undici": "^6.19.7"
@@ -0,0 +1,72 @@
1
+ declare global {
2
+ namespace Express {
3
+ export interface PodiumHttpIncomingParameters {
4
+ [key: string]: unknown;
5
+ }
6
+
7
+ export interface PodiumHttpIncomingContext {
8
+ /**
9
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
10
+ */
11
+ debug?: string;
12
+ /**
13
+ * Does user agent sniffing to try to guess the visitor's device type.
14
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
15
+ */
16
+ deviceType?: string;
17
+ /**
18
+ * Locale information from the layout.
19
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
20
+ */
21
+ locale?: string;
22
+ /**
23
+ * Used to calculate the podlet's public URL when proxied behind a layout.
24
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
25
+ */
26
+ mountOrigin?: string;
27
+ /**
28
+ * Used to calculate the podlet's public URL when proxied behind a layout.
29
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
30
+ */
31
+ mountPathname?: string;
32
+ /**
33
+ * Used to calculate the podlet's public URL when proxied behind a layout.
34
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
35
+ */
36
+ publicPathname?: string;
37
+ /**
38
+ * Name of the caller.
39
+ */
40
+ requestedBy?: string;
41
+ [key: string]: unknown;
42
+ }
43
+
44
+ export interface PodiumHttpIncomingViewParameters {
45
+ [key: string]: unknown;
46
+ }
47
+
48
+ export interface Locals {
49
+ podium: HttpIncoming<
50
+ PodiumHttpIncomingParameters,
51
+ PodiumHttpIncomingContext,
52
+ PodiumHttpIncomingViewParameters
53
+ >;
54
+ }
55
+
56
+ export interface Response {
57
+ /**
58
+ * Calls the send / write method on the `http.ServerResponse` object.
59
+ *
60
+ * When in development mode this method will wrap the provided fragment in a
61
+ * default HTML document before dispatching. When not in development mode, this
62
+ * method will just dispatch the fragment.
63
+ *
64
+ * @example
65
+ * app.get(podlet.content(), (req, res) => {
66
+ * res.podiumSend('<h1>Hello World</h1>');
67
+ * });
68
+ */
69
+ podiumSend(fragment: string, ...args: unknown[]): Response;
70
+ }
71
+ }
72
+ }
package/types/podlet.d.ts CHANGED
@@ -1,28 +1,74 @@
1
+ declare global {
2
+ namespace Express {
3
+ export interface PodiumHttpIncomingParameters {
4
+ [key: string]: unknown;
5
+ }
1
6
 
2
- import type { HttpIncoming } from "@podium/utils";
7
+ export interface PodiumHttpIncomingContext {
8
+ /**
9
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
10
+ */
11
+ debug?: string;
12
+ /**
13
+ * Does user agent sniffing to try to guess the visitor's device type.
14
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
15
+ */
16
+ deviceType?: string;
17
+ /**
18
+ * Locale information from the layout.
19
+ * @see https://podium-lib.io/docs/guides/context#default-context-variables
20
+ */
21
+ locale?: string;
22
+ /**
23
+ * Used to calculate the podlet's public URL when proxied behind a layout.
24
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
25
+ */
26
+ mountOrigin?: string;
27
+ /**
28
+ * Used to calculate the podlet's public URL when proxied behind a layout.
29
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
30
+ */
31
+ mountPathname?: string;
32
+ /**
33
+ * Used to calculate the podlet's public URL when proxied behind a layout.
34
+ * @see https://podium-lib.io/docs/guides/context#construct-public-urls
35
+ */
36
+ publicPathname?: string;
37
+ /**
38
+ * Name of the caller.
39
+ */
40
+ requestedBy?: string;
41
+ [key: string]: unknown;
42
+ }
3
43
 
4
- declare global {
5
- namespace Express {
6
- export interface Locals {
7
- podium: HttpIncoming;
8
- }
44
+ export interface PodiumHttpIncomingViewParameters {
45
+ [key: string]: unknown;
46
+ }
47
+
48
+ export interface Locals {
49
+ podium: HttpIncoming<
50
+ PodiumHttpIncomingParameters,
51
+ PodiumHttpIncomingContext,
52
+ PodiumHttpIncomingViewParameters
53
+ >;
54
+ }
9
55
 
10
- export interface Response {
11
- /**
12
- * Calls the send / write method on the `http.ServerResponse` object.
13
- *
14
- * When in development mode this method will wrap the provided fragment in a
15
- * default HTML document before dispatching. When not in development mode, this
16
- * method will just dispatch the fragment.
17
- *
18
- * @example
19
- * app.get(podlet.content(), (req, res) => {
20
- * res.podiumSend('<h1>Hello World</h1>');
21
- * });
22
- */
23
- podiumSend(fragment: string, ...args: unknown[]): Response;
56
+ export interface Response {
57
+ /**
58
+ * Calls the send / write method on the `http.ServerResponse` object.
59
+ *
60
+ * When in development mode this method will wrap the provided fragment in a
61
+ * default HTML document before dispatching. When not in development mode, this
62
+ * method will just dispatch the fragment.
63
+ *
64
+ * @example
65
+ * app.get(podlet.content(), (req, res) => {
66
+ * res.podiumSend('<h1>Hello World</h1>');
67
+ * });
68
+ */
69
+ podiumSend(fragment: string, ...args: unknown[]): Response;
70
+ }
24
71
  }
25
- }
26
72
  }
27
73
 
28
74
  /**
@@ -30,12 +76,12 @@ declare global {
30
76
  * @property {string} name - (required) podlet name
31
77
  * @property {string} version - (required) podlet version
32
78
  * @property {string} pathname - (required) podlet pathname
33
- * @property {string} [manifest='/manifest.json'] - path where the podlet manifest file is served from (default '/manifest.json')
34
- * @property {string} [content='/'] - path where the podlet content HTML markup is served from (default '/')
35
- * @property {string} [fallback=''] - path where the podlet fallback HTML markup is served from (default '/fallback')
79
+ * @property {string} [manifest="/manifest.json"] - path where the podlet manifest file is served from (default '/manifest.json')
80
+ * @property {string} [content="/"] - path where the podlet content HTML markup is served from (default '/')
81
+ * @property {string} [fallback=""] - path where the podlet fallback HTML markup is served from (default '/fallback')
36
82
  * @property {boolean} [development=false] - a boolean flag that, when true, enables additional development setup (default false)
37
83
  * @property {boolean} [useShadowDOM=false] - a boolean flag that, when true, enables the use of ShadowDOM (default false)
38
- * @property {import('abslog').AbstractLoggerOptions} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
84
+ * @property {import("abslog").AbstractLoggerOptions} [logger] - a logger to use when provided. Can be the console object if console logging is desired but can also be any Log4j compatible logging object as well. Nothing is logged if no logger is provided. (default null)
39
85
  * @property {import("@podium/proxy").PodiumProxyOptions} [proxy] - options that can be provided to configure the @podium/proxy instance used by the podlet. See that module for details.
40
86
  *
41
87
  * @typedef {{ debug: 'true' | 'false', locale: string, deviceType: string, requestedBy: string, mountOrigin: string, mountPathname: string, publicPathname: string }} PodletContext
@@ -133,7 +179,7 @@ export default class PodiumPodlet {
133
179
  */
134
180
  httpProxy: Proxy;
135
181
  /**
136
- * The pathname for the manifest of the podlet. Defaults to /manifest.json. (set in the constructor)
182
+ * The pathname for the manifest of the podlet. Defaults to "/manifest.json".
137
183
  * The value should be relative to the value set on the pathname argument.
138
184
  * In other words if a podlet is mounted into an HTTP server at /foo and the manifest is at /foo/component.json, pathname will be /foo and manifestRoute will be /component.json
139
185
  *
@@ -146,7 +192,7 @@ export default class PodiumPodlet {
146
192
  */
147
193
  manifestRoute: string;
148
194
  /**
149
- * The pathname for the content route of the podlet. Defaults to /. (set in the constructor)
195
+ * The pathname for the content route of the podlet. Defaults to "/".
150
196
  * The value should be relative to the value set on the pathname argument.
151
197
  * In other words if a podlet is mounted into an HTTP server at /foo and the content is at /foo/content, pathname will be /foo and contentRoute will be /content
152
198
  *
@@ -159,7 +205,7 @@ export default class PodiumPodlet {
159
205
  */
160
206
  contentRoute: string;
161
207
  /**
162
- * The pathname for the fallback route of the podlet. Defaults to /fallback. (set in the constructor)
208
+ * The pathname for the fallback route of the podlet. Defaults to no fallback.
163
209
  * The value should be relative to the value set on the pathname argument.
164
210
  * In other words if a podlet is mounted into an HTTP server at /foo and the fallback is at /foo/fallback, pathname will be /foo and fallbackRoute will be /fallback
165
211
  *