@enonic/nextjs-adapter 1.0.0-RC2 → 1.0.1

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.
@@ -10,7 +10,7 @@ function toSelectorName(type) {
10
10
  }
11
11
  }
12
12
  export const CATCH_ALL = '*';
13
- export class ComponentRegistry {
13
+ class ComponentRegistry {
14
14
  static getSelector(name) {
15
15
  switch (name) {
16
16
  case 'contentType':
@@ -119,3 +119,4 @@ ComponentRegistry.components = {};
119
119
  ComponentRegistry.parts = {};
120
120
  ComponentRegistry.layouts = {};
121
121
  ComponentRegistry.macros = {};
122
+ export { ComponentRegistry };
package/UrlProcessor.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { commonChars, RENDER_MODE, SITE_KEY } from './utils';
2
2
  import { useRouter } from 'next/router';
3
- export class UrlProcessor {
3
+ class UrlProcessor {
4
4
  static process(url, meta) {
5
5
  let result;
6
6
  if (!meta || !this.isPageUrl(url) && meta.renderMode === RENDER_MODE.NEXT) {
@@ -79,5 +79,6 @@ UrlProcessor.IMG_ATMT_REGEXP = /_\/image\/|_\/attachment\//;
79
79
  UrlProcessor.endSlashPattern = /\/+$/;
80
80
  UrlProcessor.startSlashPattern = /^\/+/;
81
81
  UrlProcessor.localhostPattern = /localhost/;
82
+ export { UrlProcessor };
82
83
  UrlProcessor.setSiteKey(SITE_KEY);
83
84
  export const getUrl = UrlProcessor.process.bind(UrlProcessor);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enonic/nextjs-adapter",
3
- "version": "1.0.0-RC2",
3
+ "version": "1.0.1",
4
4
  "license": "Apache-2.0",
5
5
  "main": "index.js",
6
6
  "publishConfig": {
@@ -13,22 +13,22 @@
13
13
  "lint:fix": "eslint --fix server && eslint --fix src"
14
14
  },
15
15
  "dependencies": {
16
- "html-react-parser": "^3.0.11",
17
- "lru-cache": "^7.17.0",
18
- "next": "^13.2.3",
16
+ "html-react-parser": "^3.0.15",
17
+ "lru-cache": "^8.0.4",
18
+ "next": "^13.2.4",
19
19
  "react": "^18.2.0",
20
20
  "react-dom": "^18.2.0",
21
21
  "unescape": "^1.0.1"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@enonic/eslint-config": "^1.1.0",
25
- "@types/node": "^18.14.6",
26
- "@types/react": "^18.0.28",
25
+ "@types/node": "^18.15.10",
26
+ "@types/react": "^18.0.29",
27
27
  "@types/react-dom": "^18.0.11",
28
- "@typescript-eslint/eslint-plugin": "^5.54.0",
29
- "@typescript-eslint/parser": "^5.54.0",
30
- "eslint": "^8.35.0",
28
+ "@typescript-eslint/eslint-plugin": "^5.56.0",
29
+ "@typescript-eslint/parser": "^5.56.0",
30
+ "eslint": "^8.36.0",
31
31
  "eslint-plugin-react": "^7.32.2",
32
- "typescript": "^4.9.5"
32
+ "typescript": "^5.0.2"
33
33
  }
34
34
  }
package/server/index.js CHANGED
@@ -78,8 +78,14 @@ exports.default = (function (next) { return __awaiter(void 0, void 0, void 0, fu
78
78
  return [4 /*yield*/, nextHandler(req, res)];
79
79
  case 1:
80
80
  _a.sent();
81
- return [3 /*break*/, 4];
81
+ return [3 /*break*/, 5];
82
82
  case 2:
83
+ if (!dev) return [3 /*break*/, 3];
84
+ console.warn('\nCache clearing is not available in DEV mode.\n');
85
+ res.setHeader('Content-Type', 'application/json');
86
+ res.end(JSON.stringify({ purged: false }));
87
+ return [3 /*break*/, 5];
88
+ case 3:
83
89
  tokenParam = parsedUrl.searchParams.get('token');
84
90
  if (tokenParam !== process.env.API_TOKEN) {
85
91
  // XP hijacks 401 to show login page, so send 407 instead
@@ -92,12 +98,12 @@ exports.default = (function (next) { return __awaiter(void 0, void 0, void 0, fu
92
98
  });
93
99
  pathParam = parsedUrl.searchParams.get('path') || undefined;
94
100
  return [4 /*yield*/, (0, cache_1.purgeCache)(cache, pathParam)];
95
- case 3:
101
+ case 4:
96
102
  _a.sent();
97
103
  res.setHeader('Content-Type', 'application/json');
98
104
  res.end(JSON.stringify({ purged: true }));
99
- _a.label = 4;
100
- case 4: return [2 /*return*/];
105
+ _a.label = 5;
106
+ case 5: return [2 /*return*/];
101
107
  }
102
108
  });
103
109
  }); }).listen(port, host, function () {