@podium/podlet 5.0.0-next.6 → 5.0.0-next.8

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,3 +1,116 @@
1
+ # [5.0.0-next.8](https://github.com/podium-lib/podlet/compare/v5.0.0-next.7...v5.0.0-next.8) (2023-11-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * adding type information closes [#344](https://github.com/podium-lib/podlet/issues/344) ([28e6ed9](https://github.com/podium-lib/podlet/commit/28e6ed9508d9218046f925e85fd97d17479bf390))
7
+ * CJS-shaped export in type definition ([fd96046](https://github.com/podium-lib/podlet/commit/fd96046ca16b89d02526453ff3cbf6d3ace694bd))
8
+ * **deps:** update all dependencies (non-major) ([bf963ad](https://github.com/podium-lib/podlet/commit/bf963ad4f82ca1dabad6a960c2a836f075512385))
9
+ * **deps:** update all dependencies (non-major) ([4475c67](https://github.com/podium-lib/podlet/commit/4475c67d637af2bcc7f843eed386614efc3d7c61))
10
+ * **deps:** update all dependencies (non-major) ([0a47c72](https://github.com/podium-lib/podlet/commit/0a47c7289869c023235d32d301e83fd5de77f7f2))
11
+ * **deps:** update all dependencies (non-major) ([08a5c70](https://github.com/podium-lib/podlet/commit/08a5c702797432b7668195d10c96def7bfc0c0bf))
12
+ * **deps:** update all dependencies (non-major) ([0d14c8a](https://github.com/podium-lib/podlet/commit/0d14c8aae8a69ba80a32021fcd87f7f6e06b791f))
13
+ * **deps:** update all dependencies (non-major) ([94707a5](https://github.com/podium-lib/podlet/commit/94707a5f92f72af94b23b77ac6b27b1dd379efcb))
14
+ * **deps:** update all dependencies (non-major) ([6ab8c85](https://github.com/podium-lib/podlet/commit/6ab8c85ff5ef299049a21e0dc3882d1a8ae1a837))
15
+ * **deps:** update all dependencies (non-major) ([bf8620d](https://github.com/podium-lib/podlet/commit/bf8620dc2693a5c25daa9ae26969b591848ec541))
16
+ * **types:** Add pathname() method to Podium type ([779f8c3](https://github.com/podium-lib/podlet/commit/779f8c33dc92183acec90cd647865a83a99b558e))
17
+
18
+
19
+ ### Features
20
+
21
+ * filter assets by scope if scope is provided ([95129b3](https://github.com/podium-lib/podlet/commit/95129b3e2de5b955cc4b5a2aa5942ddc0af39e8e))
22
+
23
+ # [4.5.0](https://github.com/podium-lib/podlet/compare/v4.4.75...v4.5.0) (2023-11-22)
24
+
25
+
26
+ ### Features
27
+
28
+ * filter assets by scope if scope is provided ([95129b3](https://github.com/podium-lib/podlet/commit/95129b3e2de5b955cc4b5a2aa5942ddc0af39e8e))
29
+
30
+ ## [4.4.75](https://github.com/podium-lib/podlet/compare/v4.4.74...v4.4.75) (2023-11-20)
31
+
32
+
33
+ ### Bug Fixes
34
+
35
+ * **deps:** update all dependencies (non-major) ([bf963ad](https://github.com/podium-lib/podlet/commit/bf963ad4f82ca1dabad6a960c2a836f075512385))
36
+
37
+ ## [4.4.74](https://github.com/podium-lib/podlet/compare/v4.4.73...v4.4.74) (2023-10-23)
38
+
39
+
40
+ ### Bug Fixes
41
+
42
+ * **deps:** update all dependencies (non-major) ([4475c67](https://github.com/podium-lib/podlet/commit/4475c67d637af2bcc7f843eed386614efc3d7c61))
43
+
44
+ ## [4.4.73](https://github.com/podium-lib/podlet/compare/v4.4.72...v4.4.73) (2023-10-09)
45
+
46
+
47
+ ### Bug Fixes
48
+
49
+ * CJS-shaped export in type definition ([fd96046](https://github.com/podium-lib/podlet/commit/fd96046ca16b89d02526453ff3cbf6d3ace694bd))
50
+
51
+ ## [4.4.72](https://github.com/podium-lib/podlet/compare/v4.4.71...v4.4.72) (2023-09-25)
52
+
53
+
54
+ ### Bug Fixes
55
+
56
+ * **deps:** update all dependencies (non-major) ([0a47c72](https://github.com/podium-lib/podlet/commit/0a47c7289869c023235d32d301e83fd5de77f7f2))
57
+
58
+ ## [4.4.71](https://github.com/podium-lib/podlet/compare/v4.4.70...v4.4.71) (2023-09-18)
59
+
60
+
61
+ ### Bug Fixes
62
+
63
+ * **deps:** update all dependencies (non-major) ([08a5c70](https://github.com/podium-lib/podlet/commit/08a5c702797432b7668195d10c96def7bfc0c0bf))
64
+
65
+ ## [4.4.70](https://github.com/podium-lib/podlet/compare/v4.4.69...v4.4.70) (2023-09-13)
66
+
67
+
68
+ ### Bug Fixes
69
+
70
+ * adding type information closes [#344](https://github.com/podium-lib/podlet/issues/344) ([28e6ed9](https://github.com/podium-lib/podlet/commit/28e6ed9508d9218046f925e85fd97d17479bf390))
71
+
72
+ ## [4.4.69](https://github.com/podium-lib/podlet/compare/v4.4.68...v4.4.69) (2023-01-09)
73
+
74
+
75
+ ### Bug Fixes
76
+
77
+ * **deps:** update all dependencies (non-major) ([0d14c8a](https://github.com/podium-lib/podlet/commit/0d14c8aae8a69ba80a32021fcd87f7f6e06b791f))
78
+
79
+ ## [4.4.68](https://github.com/podium-lib/podlet/compare/v4.4.67...v4.4.68) (2022-12-12)
80
+
81
+
82
+ ### Bug Fixes
83
+
84
+ * **deps:** update all dependencies (non-major) ([94707a5](https://github.com/podium-lib/podlet/commit/94707a5f92f72af94b23b77ac6b27b1dd379efcb))
85
+
86
+ ## [4.4.67](https://github.com/podium-lib/podlet/compare/v4.4.66...v4.4.67) (2022-11-21)
87
+
88
+
89
+ ### Bug Fixes
90
+
91
+ * **deps:** update all dependencies (non-major) ([6ab8c85](https://github.com/podium-lib/podlet/commit/6ab8c85ff5ef299049a21e0dc3882d1a8ae1a837))
92
+
93
+ ## [4.4.66](https://github.com/podium-lib/podlet/compare/v4.4.65...v4.4.66) (2022-11-14)
94
+
95
+
96
+ ### Bug Fixes
97
+
98
+ * **deps:** update all dependencies (non-major) ([bf8620d](https://github.com/podium-lib/podlet/commit/bf8620dc2693a5c25daa9ae26969b591848ec541))
99
+
100
+ ## [4.4.65](https://github.com/podium-lib/podlet/compare/v4.4.64...v4.4.65) (2022-09-02)
101
+
102
+
103
+ ### Bug Fixes
104
+
105
+ * **types:** Add pathname() method to Podium type ([779f8c3](https://github.com/podium-lib/podlet/commit/779f8c33dc92183acec90cd647865a83a99b558e))
106
+
107
+ # [5.0.0-next.7](https://github.com/podium-lib/podlet/compare/v5.0.0-next.6...v5.0.0-next.7) (2023-11-20)
108
+
109
+
110
+ ### Features
111
+
112
+ * add support for strategy and scope via @podium/schemas and @podium/utils update ([128eaa1](https://github.com/podium-lib/podlet/commit/128eaa1b3de35581d8fe537c63ebc001ce82c282))
113
+
1
114
  # [5.0.0-next.6](https://github.com/podium-lib/podlet/compare/v5.0.0-next.5...v5.0.0-next.6) (2022-09-21)
2
115
 
3
116
 
package/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  import { HttpIncoming, AssetJs, AssetCss } from '@podium/utils';
2
+ import PodiumProxy from '@podium/proxy';
3
+ import MetricsClient from '@metrics/client';
2
4
 
3
5
  // Use declaration merging to extend Express.
4
6
  declare global {
@@ -9,19 +11,38 @@ declare global {
9
11
  }
10
12
  }
11
13
 
12
- export interface PodletOptions {
14
+ declare class Podlet {
15
+ constructor(options: Podlet.PodletOptions);
16
+
13
17
  name: string;
14
- pathname: string;
18
+
15
19
  version: string;
16
- manifest?: string;
17
- content?: string;
18
- fallback?: string;
19
- logger?: any;
20
- development?: boolean;
21
- }
22
20
 
23
- export default class Podlet {
24
- constructor(options: PodletOptions);
21
+ manifestRoute: string;
22
+
23
+ contentRoute: string;
24
+
25
+ fallbackRoute: string;
26
+
27
+ cssRoute: AssetCss[];
28
+
29
+ jsRoute: AssetJs[];
30
+
31
+ proxyRoutes: Record<string, string>;
32
+
33
+ log: Podlet.AbsLogger;
34
+
35
+ development: boolean;
36
+
37
+ httpProxy: PodiumProxy;
38
+
39
+ baseContext: Podlet.PodletContext;
40
+
41
+ defaultContext: Podlet.PodletContext;
42
+
43
+ metrics: MetricsClient;
44
+
45
+ pathname(): string;
25
46
 
26
47
  middleware(): (req: any, res: any, next: any) => Promise<void>;
27
48
 
@@ -39,19 +60,55 @@ export default class Podlet {
39
60
 
40
61
  defaults(context: any): any;
41
62
 
42
- view(
63
+ view<T = { [key: string]: unknown }>(
43
64
  template: (
44
- incoming: HttpIncoming,
65
+ incoming: HttpIncoming<T>,
45
66
  fragment: string,
46
67
  ...args: unknown[]
47
68
  ) => string,
48
69
  ): void;
49
70
 
50
- render(
51
- incoming: HttpIncoming,
71
+ render<T = { [key: string]: unknown }>(
72
+ incoming: HttpIncoming<T>,
52
73
  fragment: string,
53
74
  ...args: unknown[]
54
75
  ): string;
55
76
 
56
77
  process(incoming: HttpIncoming): Promise<HttpIncoming>;
57
78
  }
79
+
80
+ declare namespace Podlet {
81
+ export type AbsLogger = {
82
+ trace: LogFunction;
83
+ debug: LogFunction;
84
+ info: LogFunction;
85
+ warn: LogFunction;
86
+ error: LogFunction;
87
+ fatal: LogFunction;
88
+ };
89
+
90
+ type LogFunction = (...args: any) => void;
91
+
92
+ export type PodletContext = {
93
+ debug: 'true' | 'false';
94
+ locale: string;
95
+ deviceType: string;
96
+ requestedBy: string;
97
+ mountOrigin: string;
98
+ mountPathname: string;
99
+ publicPathname: string;
100
+ };
101
+
102
+ export interface PodletOptions {
103
+ name: string;
104
+ pathname: string;
105
+ version: string;
106
+ manifest?: string;
107
+ content?: string;
108
+ fallback?: string;
109
+ logger?: Console | AbsLogger;
110
+ development?: boolean;
111
+ }
112
+ }
113
+
114
+ export = Podlet;
package/lib/podlet.js CHANGED
@@ -28,6 +28,7 @@ const { template } = utils;
28
28
  const _sanitize = Symbol('_sanitize');
29
29
  const _addCssAsset = Symbol('_addCssAsset');
30
30
  const _addJsAsset = Symbol('_addJsAsset');
31
+ const _currentScope = Symbol('_currentScope');
31
32
 
32
33
 
33
34
  export default class PodiumPodlet {
@@ -314,8 +315,16 @@ export default class PodiumPodlet {
314
315
 
315
316
  async process(incoming, { proxy = true } = {}) {
316
317
  incoming.name = this.name;
317
- incoming.css = this.cssRoute;
318
- incoming.js = this.jsRoute;
318
+ incoming.css = this.cssRoute.filter(
319
+ ({ scope = 'all' }) =>
320
+ scope === this[_currentScope](incoming) ||
321
+ scope === 'all',
322
+ );
323
+ incoming.js = this.jsRoute.filter(
324
+ ({ scope = 'all' }) =>
325
+ scope === this[_currentScope](incoming) ||
326
+ scope === 'all',
327
+ );
319
328
 
320
329
  // Determine if request comes from layout server or not
321
330
  if (
@@ -397,4 +406,21 @@ export default class PodiumPodlet {
397
406
  }
398
407
  return uri;
399
408
  }
409
+
410
+ [_currentScope](incoming) {
411
+ const fallback = this.fallback({ prefix: true });
412
+ const content = this.content({ prefix: true });
413
+ const { pathname } = incoming.url;
414
+
415
+ // only check fallback if defined
416
+ // match fallback first since fallback is a more accurate match since
417
+ // fallback cannot take dynamic path segments and we can use exact matching
418
+ if (!!fallback && pathname === fallback) return 'fallback';
419
+
420
+ // fallback didn't match so check content
421
+ // we have to use startsWith since content may contain dynamic path segments
422
+ if (pathname.startsWith(content)) return 'content';
423
+
424
+ return 'all';
425
+ }
400
426
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@podium/podlet",
3
- "version": "5.0.0-next.6",
3
+ "version": "5.0.0-next.8",
4
4
  "type": "module",
5
5
  "description": "Module for building page fragment servers in a micro frontend architecture.",
6
6
  "license": "MIT",
@@ -29,27 +29,31 @@
29
29
  "test": "tap --no-check-coverage"
30
30
  },
31
31
  "dependencies": {
32
- "@metrics/client": "2.5.0",
33
- "@podium/proxy": "5.0.0-next.7",
34
- "@podium/schemas": "5.0.0-next.6",
35
- "@podium/utils": "5.0.0-next.8",
32
+ "@podium/schemas": "5.0.0-next.7",
33
+ "@podium/utils": "5.0.0-next.10",
34
+ "@metrics/client": "2.5.2",
35
+ "@podium/proxy": "4.2.86",
36
36
  "abslog": "2.4.0",
37
- "ajv": "8.11.0",
37
+ "ajv": "8.12.0",
38
38
  "objobj": "1.0.0"
39
39
  },
40
40
  "devDependencies": {
41
- "@semantic-release/changelog": "6.0.1",
42
- "@semantic-release/git": "10.0.1",
43
- "semantic-release": "19.0.5",
44
- "@podium/test-utils": "2.5.2",
45
41
  "@babel/eslint-parser": "7.19.1",
46
42
  "eslint": "8.23.1",
47
43
  "eslint-config-airbnb-base": "15.0.0",
48
- "eslint-config-prettier": "8.5.0",
49
- "eslint-plugin-import": "2.26.0",
50
44
  "eslint-plugin-prettier": "4.2.1",
51
- "express": "4.18.1",
52
- "prettier": "2.7.1",
53
- "tap": "16.3.0"
45
+ "@semantic-release/changelog": "6.0.3",
46
+ "@semantic-release/commit-analyzer": "9.0.2",
47
+ "@semantic-release/git": "10.0.1",
48
+ "@semantic-release/github": "8.1.0",
49
+ "@semantic-release/npm": "9.0.2",
50
+ "@semantic-release/release-notes-generator": "10.0.3",
51
+ "semantic-release": "19.0.5",
52
+ "@podium/test-utils": "2.5.2",
53
+ "eslint-config-prettier": "8.10.0",
54
+ "eslint-plugin-import": "2.29.0",
55
+ "express": "4.18.2",
56
+ "prettier": "2.8.8",
57
+ "tap": "16.3.9"
54
58
  }
55
59
  }