@enonic/nextjs-adapter 3.0.6 → 3.1.0-B1
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/common/UrlProcessor.d.ts +0 -1
- package/common/UrlProcessor.js +19 -5
- package/common/UrlProcessor.js.map +1 -1
- package/guillotine/buildErrorResponse.d.ts +1 -1
- package/guillotine/buildErrorResponse.js +2 -1
- package/guillotine/buildErrorResponse.js.map +1 -1
- package/guillotine/createMetaData.d.ts +2 -1
- package/guillotine/createMetaData.js +2 -1
- package/guillotine/createMetaData.js.map +1 -1
- package/guillotine/fetchContent.js +4 -2
- package/guillotine/fetchContent.js.map +1 -1
- package/guillotine/getMetaData.js +1 -0
- package/guillotine/getMetaData.js.map +1 -1
- package/guillotine/metadata/richTextQuery.js +17 -2
- package/guillotine/metadata/richTextQuery.js.map +1 -1
- package/i18n/LocaleContext.jsx +0 -4
- package/i18n/LocaleContext.jsx.map +1 -1
- package/i18n/i18n.js +0 -4
- package/i18n/i18n.js.map +1 -1
- package/package.json +14 -13
- package/src/common/UrlProcessor.ts +17 -7
- package/src/guillotine/buildErrorResponse.ts +5 -9
- package/src/guillotine/createMetaData.ts +17 -18
- package/src/guillotine/fetchContent.ts +5 -2
- package/src/guillotine/getMetaData.ts +1 -0
- package/src/guillotine/metadata/richTextQuery.ts +18 -3
- package/src/i18n/LocaleContext.tsx +0 -5
- package/src/i18n/i18n.ts +0 -5
- package/src/types/component.ts +15 -31
- package/src/types/componentProps.ts +2 -1
- package/src/types/guillotine.ts +2 -1
- package/src/views/BaseMacro.tsx +1 -1
- package/src/views/RichTextView.tsx +47 -62
- package/types/component.d.ts +5 -26
- package/types/componentProps.d.ts +2 -1
- package/types/guillotine.d.ts +1 -0
- package/views/BaseComponent.d.ts +1 -1
- package/views/BaseMacro.jsx +2 -1
- package/views/BaseMacro.jsx.map +1 -1
- package/views/RichTextView.d.ts +2 -4
- package/views/RichTextView.jsx +28 -59
- package/views/RichTextView.jsx.map +1 -1
package/common/UrlProcessor.d.ts
CHANGED
|
@@ -10,7 +10,6 @@ export declare class UrlProcessor {
|
|
|
10
10
|
private static endSlashPattern;
|
|
11
11
|
private static startSlashPattern;
|
|
12
12
|
private static localhostPattern;
|
|
13
|
-
private static siteKey;
|
|
14
13
|
static process(url: string, meta: MetaData, serverSide?: boolean, isResource?: boolean): string;
|
|
15
14
|
static setSiteKey(key: string): void;
|
|
16
15
|
static isMediaLink(ref: string, linkData: LinkData[]): boolean;
|
package/common/UrlProcessor.js
CHANGED
|
@@ -2,8 +2,10 @@ import { RENDER_MODE } from './constants';
|
|
|
2
2
|
import { fixDoubleSlashes } from '../utils/fixDoubleSlashes';
|
|
3
3
|
import { addBasePath } from 'next/dist/client/add-base-path';
|
|
4
4
|
import { parseUrl } from 'next/dist/shared/lib/router/utils/parse-url';
|
|
5
|
+
import { getLocaleMappingByLocale } from '../utils/getLocaleMappingByLocale';
|
|
5
6
|
export class UrlProcessor {
|
|
6
7
|
static process(url, meta, serverSide = false, isResource = false) {
|
|
8
|
+
var _a;
|
|
7
9
|
if (this.startsWithHash(url) || !meta || (this.isAttachmentUrl(url)) && meta.renderMode === RENDER_MODE.NEXT) {
|
|
8
10
|
// do not process if:
|
|
9
11
|
// - url starts with #
|
|
@@ -13,11 +15,19 @@ export class UrlProcessor {
|
|
|
13
15
|
}
|
|
14
16
|
let normalUrl;
|
|
15
17
|
if (this.isRelative(url)) {
|
|
16
|
-
|
|
18
|
+
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
19
|
+
if ((_a = mapping.site) === null || _a === void 0 ? void 0 : _a.length) {
|
|
20
|
+
// see if url starts with site name and remove it
|
|
21
|
+
const normalSite = mapping.site.replace(this.startSlashPattern, '').replace(this.endSlashPattern, '');
|
|
22
|
+
normalUrl = url.replace(new RegExp(`^/?${normalSite}(?=/|$)`), '');
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
normalUrl = url;
|
|
26
|
+
}
|
|
17
27
|
}
|
|
18
28
|
else {
|
|
19
29
|
// url is absolute, try to make it relative by striping apiUrl
|
|
20
|
-
// NB: will fail if content api is not on the same domain as enonic xp
|
|
30
|
+
// NB: will fail to do so if content api is not on the same domain as enonic xp
|
|
21
31
|
const apiUrl = this.getApiUrl(meta);
|
|
22
32
|
normalUrl = this.stripApiUrl(url, apiUrl);
|
|
23
33
|
// if url is still absolute, return it as is
|
|
@@ -46,8 +56,11 @@ export class UrlProcessor {
|
|
|
46
56
|
}
|
|
47
57
|
return fixDoubleSlashes(result);
|
|
48
58
|
}
|
|
59
|
+
/*
|
|
60
|
+
* Deprecated
|
|
61
|
+
* */
|
|
49
62
|
static setSiteKey(key) {
|
|
50
|
-
|
|
63
|
+
// TODO: remove in next major release
|
|
51
64
|
}
|
|
52
65
|
static isMediaLink(ref, linkData) {
|
|
53
66
|
var _a;
|
|
@@ -112,8 +125,9 @@ export class UrlProcessor {
|
|
|
112
125
|
static getApiUrl(meta) {
|
|
113
126
|
var _a, _b;
|
|
114
127
|
let combinedUrl = ((_a = meta.apiUrl) === null || _a === void 0 ? void 0 : _a.replace(this.endSlashPattern, '')) || '';
|
|
115
|
-
|
|
116
|
-
|
|
128
|
+
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
129
|
+
if ((_b = mapping.site) === null || _b === void 0 ? void 0 : _b.length) {
|
|
130
|
+
combinedUrl += '/' + mapping.site.replace(this.startSlashPattern, '');
|
|
117
131
|
}
|
|
118
132
|
return combinedUrl;
|
|
119
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UrlProcessor.js","sourceRoot":"","sources":["../src/common/UrlProcessor.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAC;AACxC,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,WAAW,EAAC,MAAM,gCAAgC,CAAC;AAC3D,OAAO,EAAC,QAAQ,EAAC,MAAM,6CA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B,qBAAQ,GAAG,gBAAgB,CAAC;AAC5B,sBAAS,GAAG,eAAe,CAAC;AAC5B,uBAAU,GAAG,gBAAgB,CAAC;AAE7B,4BAAe,GAAG,4BAA4B,CAAC;AAC/C,4BAAe,GAAG,MAAM,CAAC;AACzB,8BAAiB,GAAG,MAAM,CAAC;AAC3B,6BAAgB,GAAG,WAAW,CAAC;AA6IlD,MAAM,UAAU,MAAM,CAAC,GAAW,EAAE,IAAc;IAC9C,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAW,EAAE,IAAc;IAChD,OAAO,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { FetchContentResult } from '../types';
|
|
2
2
|
import { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
|
|
3
|
-
export declare function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE, apiUrl: string, baseUrl: string, locale: string, defaultLocale: string, contentPath?: string): (code?: string, message?: string) => FetchContentResult;
|
|
3
|
+
export declare function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE, apiUrl: string, baseUrl: string, locale: string, defaultLocale: string, contentPath?: string, contentId?: string): (code?: string, message?: string) => FetchContentResult;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function buildErrorResponse(requestType, renderMode, apiUrl, baseUrl, locale, defaultLocale, contentPath) {
|
|
1
|
+
export function buildErrorResponse(requestType, renderMode, apiUrl, baseUrl, locale, defaultLocale, contentPath, contentId) {
|
|
2
2
|
return function (code = '500', message = 'Unknown error') {
|
|
3
3
|
return {
|
|
4
4
|
error: {
|
|
@@ -9,6 +9,7 @@ export function buildErrorResponse(requestType, renderMode, apiUrl, baseUrl, loc
|
|
|
9
9
|
common: null,
|
|
10
10
|
data: null,
|
|
11
11
|
meta: {
|
|
12
|
+
id: contentId || '',
|
|
12
13
|
type: '',
|
|
13
14
|
requestType: requestType,
|
|
14
15
|
renderMode: renderMode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"buildErrorResponse.js","sourceRoot":"","sources":["../src/guillotine/buildErrorResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"buildErrorResponse.js","sourceRoot":"","sources":["../src/guillotine/buildErrorResponse.ts"],"names":[],"mappings":"AAMA,MAAM,UAAU,kBAAkB,CAAC,WAA4B,EAAE,UAAuB,EACpF,MAAc,EAAE,OAAe,EAAE,MAAc,EAAE,aAAqB,EACvC,WAAqB,EAAE,SAAkB;IAExE,OAAO,UAAU,IAAI,GAAG,KAAK,EAAE,OAAO,GAAG,eAAe;QACpD,OAAO;YACH,KAAK,EAAE;gBACH,IAAI;gBACJ,OAAO;aACV;YACD,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,IAAI;YACZ,IAAI,EAAE,IAAI;YACV,IAAI,EAAE;gBACF,EAAE,EAAE,SAAS,IAAI,EAAE;gBACnB,IAAI,EAAE,EAAE;gBACR,WAAW,EAAE,WAAW;gBACxB,UAAU,EAAE,UAAU;gBACtB,IAAI,EAAE,WAAW,IAAI,EAAE;gBACvB,SAAS,EAAE,KAAK;gBAChB,QAAQ,EAAE,KAAK;gBACf,MAAM;gBACN,OAAO;gBACP,MAAM;gBACN,aAAa;aAChB;SACJ,CAAC;IACN,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import type { MetaData, PageComponent } from '../types';
|
|
2
2
|
import { RENDER_MODE, XP_REQUEST_TYPE } from '../common/constants';
|
|
3
3
|
export declare function createMetaData({ apiUrl, baseUrl, components, // Optional NOTE: Doesn't handle null
|
|
4
|
-
contentPath, contentType, defaultLocale, locale, pageCmp, // Optional
|
|
4
|
+
contentPath, contentType, contentId, defaultLocale, locale, pageCmp, // Optional
|
|
5
5
|
renderMode, requestedComponentPath, requestType, }: {
|
|
6
6
|
apiUrl: string;
|
|
7
7
|
baseUrl: string;
|
|
8
8
|
components?: PageComponent[];
|
|
9
9
|
contentPath: string;
|
|
10
|
+
contentId: string;
|
|
10
11
|
contentType: string;
|
|
11
12
|
defaultLocale: string;
|
|
12
13
|
locale: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { XP_REQUEST_TYPE } from '../common/constants';
|
|
2
2
|
import { ComponentRegistry } from '../common/ComponentRegistry';
|
|
3
3
|
export function createMetaData({ apiUrl, baseUrl, components = [], // Optional NOTE: Doesn't handle null
|
|
4
|
-
contentPath, contentType, defaultLocale, locale, pageCmp, // Optional
|
|
4
|
+
contentPath, contentType, contentId, defaultLocale, locale, pageCmp, // Optional
|
|
5
5
|
renderMode, requestedComponentPath, requestType, }) {
|
|
6
6
|
var _a;
|
|
7
7
|
// .meta will be visible in final rendered inline props.
|
|
@@ -14,6 +14,7 @@ renderMode, requestedComponentPath, requestType, }) {
|
|
|
14
14
|
catchAll: false, // catchAll only refers to content type catch-all
|
|
15
15
|
defaultLocale,
|
|
16
16
|
locale,
|
|
17
|
+
id: contentId,
|
|
17
18
|
path: contentPath,
|
|
18
19
|
renderMode: renderMode,
|
|
19
20
|
requestType: requestType,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createMetaData.js","sourceRoot":"","sources":["../src/guillotine/createMetaData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createMetaData.js","sourceRoot":"","sources":["../src/guillotine/createMetaData.ts"],"names":[],"mappings":"AAGA,OAAO,EAAc,eAAe,EAAC,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAG9D,MAAM,UAAU,cAAc,CAAC,EACI,MAAM,EACN,OAAO,EACP,UAAU,GAAG,EAAE,EAAE,qCAAqC;AACt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AAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;IACzB,CAAC;IAED,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -63,7 +63,6 @@ export function fetchContent(context) {
|
|
|
63
63
|
const renderMode = getRenderMode(context);
|
|
64
64
|
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
65
65
|
const requestContentPath = getCleanContentPathArrayOrThrow400(context.contentPath);
|
|
66
|
-
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
67
66
|
try {
|
|
68
67
|
const [siteRelativeContentPath, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
69
68
|
if (componentPath) {
|
|
@@ -73,8 +72,9 @@ export function fetchContent(context) {
|
|
|
73
72
|
// ///////////// FIRST GUILLOTINE CALL FOR METADATA /////////////////
|
|
74
73
|
const metaResult = yield fetchMetaData(contentApiUrl, '${site}/' + siteRelativeContentPath, mapping, outHeaders);
|
|
75
74
|
// ///////////////////////////////////////////////////////////////////////
|
|
76
|
-
const { _path, type } = metaResult.meta || {};
|
|
75
|
+
const { _id, _path, type } = metaResult.meta || {};
|
|
77
76
|
const contentPath = _path || siteRelativeContentPath;
|
|
77
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath, _id);
|
|
78
78
|
if (metaResult.error) {
|
|
79
79
|
console.error(metaResult.error);
|
|
80
80
|
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
@@ -187,6 +187,7 @@ export function fetchContent(context) {
|
|
|
187
187
|
components,
|
|
188
188
|
contentPath: siteRelativeContentPath,
|
|
189
189
|
contentType: type,
|
|
190
|
+
contentId: _id,
|
|
190
191
|
defaultLocale,
|
|
191
192
|
locale,
|
|
192
193
|
pageCmp: page,
|
|
@@ -213,6 +214,7 @@ export function fetchContent(context) {
|
|
|
213
214
|
message: e.message,
|
|
214
215
|
};
|
|
215
216
|
}
|
|
217
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
216
218
|
return errorResponse(error.code, error.message);
|
|
217
219
|
}
|
|
218
220
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchContent.js","sourceRoot":"","sources":["../src/guillotine/fetchContent.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,cAAc,CAAC;AAChD,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EACH,yBAAyB,EACzB,8BAA8B,EAC9B,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,eAAe,GAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAC,QAAQ,EAAE,eAAe,EAAE,WAAW,EAAC,MAAM,eAAe,CAAC;AACrE,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAC;AAC3D,OAAO,EAAC,aAAa,EAAC,MAAM,wBAAwB,CAAC;AACrD,OAAO,EAAC,YAAY,EAAC,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAAC,oBAAoB,EAAC,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAC,6BAA6B,EAAC,MAAM,wCAAwC,CAAC;AAErF,OAAO,EAAC,SAAS,EAAC,MAAM,aAAa,CAAC;AACtC,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAC,kCAAkC,EAAC,MAAM,sCAAsC,CAAC;AACxF,OAAO,EAAC,kBAAkB,EAAC,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAC,2BAA2B,EAAC,MAAM,+BAA+B,CAAC;AAC1E,OAAO,EAAC,wBAAwB,EAAC,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAC,sB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AM,iBAAiB,GAAG,GAAG,EAAE,CAAC;;;;;EAKrC,MAAM,CAAC,eAAe,EAAE,EAAC,EAAE,CAAC;;;;EAI5B,MAAM,CAAC,eAAe,EAAE,EAAC,CAAC,CAAC;EAC3B,CAAC;AAEH,MAAM,UAAU,YAAY,CAAC,YAAqB;IAC9C,OAAO;;;;;;EAMT,MAAM,CAAC,YAAY,IAAI,EAAE,EAAE,EAAE,CAAC;;;EAG9B,CAAC;AACH,CAAC"}
|
|
@@ -15,18 +15,33 @@ export const richTextQuery = (fieldName) => {
|
|
|
15
15
|
}
|
|
16
16
|
links {
|
|
17
17
|
ref
|
|
18
|
+
uri
|
|
19
|
+
content {
|
|
20
|
+
_id
|
|
21
|
+
}
|
|
18
22
|
media {
|
|
19
23
|
content {
|
|
20
24
|
_id
|
|
25
|
+
... on media_Image {
|
|
26
|
+
mediaUrl(type: absolute)
|
|
27
|
+
}
|
|
21
28
|
}
|
|
29
|
+
intent
|
|
22
30
|
}
|
|
23
31
|
}
|
|
24
32
|
images {
|
|
25
33
|
ref
|
|
26
34
|
image {
|
|
27
35
|
_id
|
|
36
|
+
... on media_Image {
|
|
37
|
+
imageUrl(scale: "width(768)", type:absolute)
|
|
38
|
+
}
|
|
28
39
|
}
|
|
29
|
-
|
|
30
|
-
|
|
40
|
+
style {
|
|
41
|
+
name
|
|
42
|
+
aspectRatio
|
|
43
|
+
filter
|
|
44
|
+
}
|
|
45
|
+
}}`;
|
|
31
46
|
};
|
|
32
47
|
//# sourceMappingURL=richTextQuery.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richTextQuery.js","sourceRoot":"","sources":["../../src/guillotine/metadata/richTextQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAG1C,MAAM,gBAAgB,GAAG,GAAW,EAAE;IAClC,OAAO,WAAW,CAAC,iBAAiB,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,OAAO,GAAG,SAAS;;;;;;UAMb,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC
|
|
1
|
+
{"version":3,"file":"richTextQuery.js","sourceRoot":"","sources":["../../src/guillotine/metadata/richTextQuery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,iBAAiB,EAAC,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAC,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAG1C,MAAM,gBAAgB,GAAG,GAAW,EAAE;IAClC,OAAO,WAAW,CAAC,iBAAiB,CAAC,SAAS,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;AACpE,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC/C,OAAO,GAAG,SAAS;;;;;;UAMb,MAAM,CAAC,gBAAgB,EAAE,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+BhC,CAAC;AACR,CAAC,CAAC"}
|
package/i18n/LocaleContext.jsx
CHANGED
|
@@ -10,8 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
import React, { createContext, useContext, useEffect, useState } from 'react';
|
|
12
12
|
import { getPhrase, loadPhrases } from './i18n';
|
|
13
|
-
import { getLocaleMappingByLocale } from '../utils/getLocaleMappingByLocale';
|
|
14
|
-
import { UrlProcessor } from '../common/UrlProcessor';
|
|
15
13
|
const LocaleContext = createContext({
|
|
16
14
|
dictionary: {},
|
|
17
15
|
locale: '',
|
|
@@ -26,8 +24,6 @@ export const LocaleContextProvider = ({ children, locale: localeProps = '', }) =
|
|
|
26
24
|
const setLocale = (locale) => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
25
|
setLocaleState(locale);
|
|
28
26
|
setLoadedState(false);
|
|
29
|
-
const mapping = getLocaleMappingByLocale(locale);
|
|
30
|
-
UrlProcessor.setSiteKey(mapping.site);
|
|
31
27
|
return loadPhrases(locale).then((phrases) => {
|
|
32
28
|
setPhrasesState(phrases);
|
|
33
29
|
setLoadedState(true);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LocaleContext.jsx","sourceRoot":"","sources":["../src/i18n/LocaleContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;AAGb,OAAO,KAAK,EAAE,EAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"LocaleContext.jsx","sourceRoot":"","sources":["../src/i18n/LocaleContext.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;;;;;;;;;AAGb,OAAO,KAAK,EAAE,EAAC,aAAa,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAC5E,OAAO,EAAC,SAAS,EAAE,WAAW,EAAC,MAAM,QAAQ,CAAC;AAG9C,MAAM,aAAa,GAAG,aAAa,CAAoB;IACnD,UAAU,EAAE,EAAE;IACd,MAAM,EAAE,EAAE;IACV,QAAQ,EAAE,CAAC,GAAW,EAAE,GAAG,IAAW,EAAE,EAAE,CAAC,GAAG;IAC9C,SAAS,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;CACrD,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE,CAAC,UAAU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SACX,CAAC,CACE;YAAA,CAAC,QAAQ,CACb;QAAA,EAAE,aAAa,CAAC,QAAQ,CAAC,CAC5B,CAAC;AACN,CAAC,CAAC"}
|
package/i18n/i18n.js
CHANGED
|
@@ -7,15 +7,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
7
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
|
-
import { getLocaleMappingByLocale } from '../utils/getLocaleMappingByLocale';
|
|
11
|
-
import { UrlProcessor } from '../common/UrlProcessor';
|
|
12
10
|
export class I18n {
|
|
13
11
|
static setLocale(locale) {
|
|
14
12
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
13
|
this.locale = locale;
|
|
16
14
|
this.isLoaded = false;
|
|
17
|
-
const mapping = getLocaleMappingByLocale(locale);
|
|
18
|
-
UrlProcessor.setSiteKey(mapping.site);
|
|
19
15
|
return loadPhrases(locale).then((phrases) => {
|
|
20
16
|
this.dictionary = phrases;
|
|
21
17
|
this.isLoaded = true;
|
package/i18n/i18n.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n/i18n.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n/i18n.ts"],"names":[],"mappings":";;;;;;;;;AAGA,MAAM,OAAO,IAAI;IAKN,MAAM,CAAO,SAAS,CAAC,MAAc;;YACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;YACrB,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC;YAEtB,OAAO,WAAW,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBACxC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC;gBAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,OAAO,OAAO,CAAC;YAC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AM,EAAE,CAAC;QACd,IAAI,KAAK,GAAG,CAAC,CAAC,CAAC;QACf,OAAO,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;;YAClD,KAAK,EAAE,CAAC;YACR,OAAO,MAAA,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,mCAAI,KAAK,CAAC;QACzC,CAAC,CAAC,CAAC;IACP,CAAC;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enonic/nextjs-adapter",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.1.0-B1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "Pavel Milkevich <pmi@enonic.com>",
|
|
@@ -50,38 +50,39 @@
|
|
|
50
50
|
"test": "jest --no-cache --coverage"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
+
"@enonic/react-components": "^5.0.0-RC5",
|
|
53
54
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
54
|
-
"html-react-parser": "^5.1.
|
|
55
|
+
"html-react-parser": "^5.1.16",
|
|
55
56
|
"negotiator": "^0.6.3",
|
|
56
|
-
"next": "^14.2.
|
|
57
|
+
"next": "^14.2.13",
|
|
57
58
|
"react": "18.3.1",
|
|
58
59
|
"react-dom": "18.3.1",
|
|
59
60
|
"unescape": "^1.0.1"
|
|
60
61
|
},
|
|
61
62
|
"devDependencies": {
|
|
62
|
-
"@edge-runtime/jest-environment": "^3.0.
|
|
63
|
+
"@edge-runtime/jest-environment": "^3.0.3",
|
|
63
64
|
"@enonic-types/core": "^7.14.4",
|
|
64
65
|
"@enonic/eslint-config": "^1.2.1",
|
|
65
|
-
"@testing-library/jest-dom": "^6.
|
|
66
|
-
"@testing-library/react": "^16.0.
|
|
66
|
+
"@testing-library/jest-dom": "^6.5.0",
|
|
67
|
+
"@testing-library/react": "^16.0.1",
|
|
67
68
|
"@types/negotiator": "^0.6.3",
|
|
68
|
-
"@types/node": "^22.4
|
|
69
|
-
"@types/react": "^18.3.
|
|
69
|
+
"@types/node": "^22.7.4",
|
|
70
|
+
"@types/react": "^18.3.10",
|
|
70
71
|
"@types/react-dom": "^18.3.0",
|
|
71
72
|
"@typescript-eslint/eslint-plugin": "^7.17.0",
|
|
72
73
|
"@typescript-eslint/parser": "^7.18.0",
|
|
73
|
-
"concurrently": "^
|
|
74
|
+
"concurrently": "^9.0.1",
|
|
74
75
|
"cpy-cli": "^5.0.0",
|
|
75
76
|
"del-cli": "^5.1.0",
|
|
76
|
-
"eslint": "^8.57.
|
|
77
|
-
"eslint-plugin-react": "^7.
|
|
77
|
+
"eslint": "^8.57.1",
|
|
78
|
+
"eslint-plugin-react": "^7.37.0",
|
|
78
79
|
"jest": "^29.7.0",
|
|
79
80
|
"jest-environment-jsdom": "^29.7.0",
|
|
80
81
|
"madge": "^8.0.0",
|
|
81
82
|
"mkdirp": "^3.0.1",
|
|
82
|
-
"ts-jest": "^29.2.
|
|
83
|
+
"ts-jest": "^29.2.5",
|
|
83
84
|
"ts-node": "^10.9.2",
|
|
84
|
-
"typescript": "^5.
|
|
85
|
+
"typescript": "^5.6.2"
|
|
85
86
|
},
|
|
86
87
|
"types": "index.d.ts"
|
|
87
88
|
}
|
|
@@ -5,6 +5,7 @@ import {RENDER_MODE} from './constants';
|
|
|
5
5
|
import {fixDoubleSlashes} from '../utils/fixDoubleSlashes';
|
|
6
6
|
import {addBasePath} from 'next/dist/client/add-base-path';
|
|
7
7
|
import {parseUrl} from 'next/dist/shared/lib/router/utils/parse-url';
|
|
8
|
+
import {getLocaleMappingByLocale} from '../utils/getLocaleMappingByLocale';
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
export class UrlProcessor {
|
|
@@ -22,8 +23,6 @@ export class UrlProcessor {
|
|
|
22
23
|
private static startSlashPattern = /^\/+/;
|
|
23
24
|
private static localhostPattern = /localhost/;
|
|
24
25
|
|
|
25
|
-
private static siteKey: string;
|
|
26
|
-
|
|
27
26
|
public static process(url: string, meta: MetaData, serverSide = false, isResource = false): string {
|
|
28
27
|
if (this.startsWithHash(url) || !meta || (this.isAttachmentUrl(url)) && meta.renderMode === RENDER_MODE.NEXT) {
|
|
29
28
|
// do not process if:
|
|
@@ -35,10 +34,17 @@ export class UrlProcessor {
|
|
|
35
34
|
|
|
36
35
|
let normalUrl: string;
|
|
37
36
|
if (this.isRelative(url)) {
|
|
38
|
-
|
|
37
|
+
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
38
|
+
if (mapping.site?.length) {
|
|
39
|
+
// see if url starts with site name and remove it
|
|
40
|
+
const normalSite = mapping.site.replace(this.startSlashPattern, '').replace(this.endSlashPattern, '');
|
|
41
|
+
normalUrl = url.replace(new RegExp(`^/?${normalSite}(?=/|$)`), '');
|
|
42
|
+
} else {
|
|
43
|
+
normalUrl = url;
|
|
44
|
+
}
|
|
39
45
|
} else {
|
|
40
46
|
// url is absolute, try to make it relative by striping apiUrl
|
|
41
|
-
// NB: will fail if content api is not on the same domain as enonic xp
|
|
47
|
+
// NB: will fail to do so if content api is not on the same domain as enonic xp
|
|
42
48
|
const apiUrl = this.getApiUrl(meta);
|
|
43
49
|
normalUrl = this.stripApiUrl(url, apiUrl);
|
|
44
50
|
|
|
@@ -71,8 +77,11 @@ export class UrlProcessor {
|
|
|
71
77
|
return fixDoubleSlashes(result);
|
|
72
78
|
}
|
|
73
79
|
|
|
80
|
+
/*
|
|
81
|
+
* Deprecated
|
|
82
|
+
* */
|
|
74
83
|
public static setSiteKey(key: string): void {
|
|
75
|
-
|
|
84
|
+
// TODO: remove in next major release
|
|
76
85
|
}
|
|
77
86
|
|
|
78
87
|
public static isMediaLink(ref: string, linkData: LinkData[]): boolean {
|
|
@@ -145,8 +154,9 @@ export class UrlProcessor {
|
|
|
145
154
|
|
|
146
155
|
private static getApiUrl(meta: MetaData) {
|
|
147
156
|
let combinedUrl = meta.apiUrl?.replace(this.endSlashPattern, '') || '';
|
|
148
|
-
|
|
149
|
-
|
|
157
|
+
const mapping = getLocaleMappingByLocale(meta.locale);
|
|
158
|
+
if (mapping.site?.length) {
|
|
159
|
+
combinedUrl += '/' + mapping.site.replace(this.startSlashPattern, '');
|
|
150
160
|
}
|
|
151
161
|
return combinedUrl;
|
|
152
162
|
}
|
|
@@ -1,17 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
FetchContentResult,
|
|
3
|
-
} from '../types';
|
|
1
|
+
import type {FetchContentResult} from '../types';
|
|
4
2
|
|
|
5
3
|
|
|
6
|
-
import {
|
|
7
|
-
RENDER_MODE,
|
|
8
|
-
XP_REQUEST_TYPE,
|
|
9
|
-
} from '../common/constants';
|
|
4
|
+
import {RENDER_MODE, XP_REQUEST_TYPE} from '../common/constants';
|
|
10
5
|
|
|
11
6
|
|
|
12
7
|
export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: RENDER_MODE,
|
|
13
8
|
apiUrl: string, baseUrl: string, locale: string, defaultLocale: string,
|
|
14
|
-
|
|
9
|
+
contentPath ?: string, contentId?: string): (code ?: string, message ?: string) => FetchContentResult {
|
|
15
10
|
|
|
16
11
|
return function (code = '500', message = 'Unknown error') {
|
|
17
12
|
return {
|
|
@@ -23,6 +18,7 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
|
|
|
23
18
|
common: null,
|
|
24
19
|
data: null,
|
|
25
20
|
meta: {
|
|
21
|
+
id: contentId || '',
|
|
26
22
|
type: '',
|
|
27
23
|
requestType: requestType,
|
|
28
24
|
renderMode: renderMode,
|
|
@@ -36,4 +32,4 @@ export function buildErrorResponse(requestType: XP_REQUEST_TYPE, renderMode: REN
|
|
|
36
32
|
},
|
|
37
33
|
};
|
|
38
34
|
};
|
|
39
|
-
}
|
|
35
|
+
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDefinition,
|
|
3
|
-
MetaData,
|
|
4
|
-
PageComponent,
|
|
5
|
-
} from '../types';
|
|
1
|
+
import type {MetaData, PageComponent} from '../types';
|
|
6
2
|
|
|
7
3
|
|
|
8
4
|
import {RENDER_MODE, XP_REQUEST_TYPE} from '../common/constants';
|
|
@@ -10,22 +6,24 @@ import {ComponentRegistry} from '../common/ComponentRegistry';
|
|
|
10
6
|
|
|
11
7
|
|
|
12
8
|
export function createMetaData({
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
9
|
+
apiUrl,
|
|
10
|
+
baseUrl,
|
|
11
|
+
components = [], // Optional NOTE: Doesn't handle null
|
|
12
|
+
contentPath,
|
|
13
|
+
contentType,
|
|
14
|
+
contentId,
|
|
15
|
+
defaultLocale,
|
|
16
|
+
locale,
|
|
17
|
+
pageCmp, // Optional
|
|
18
|
+
renderMode,
|
|
19
|
+
requestedComponentPath,
|
|
20
|
+
requestType,
|
|
21
|
+
}: {
|
|
25
22
|
apiUrl: string
|
|
26
23
|
baseUrl: string
|
|
27
24
|
components?: PageComponent[]
|
|
28
25
|
contentPath: string
|
|
26
|
+
contentId: string
|
|
29
27
|
contentType: string
|
|
30
28
|
defaultLocale: string
|
|
31
29
|
locale: string
|
|
@@ -44,6 +42,7 @@ export function createMetaData({
|
|
|
44
42
|
catchAll: false, // catchAll only refers to content type catch-all
|
|
45
43
|
defaultLocale,
|
|
46
44
|
locale,
|
|
45
|
+
id: contentId,
|
|
47
46
|
path: contentPath,
|
|
48
47
|
renderMode: renderMode,
|
|
49
48
|
requestType: requestType,
|
|
@@ -70,4 +69,4 @@ export function createMetaData({
|
|
|
70
69
|
}
|
|
71
70
|
|
|
72
71
|
return meta;
|
|
73
|
-
}
|
|
72
|
+
}
|
|
@@ -67,7 +67,6 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
67
67
|
const renderMode = getRenderMode(context);
|
|
68
68
|
let requestType = XP_REQUEST_TYPE.TYPE;
|
|
69
69
|
const requestContentPath = getCleanContentPathArrayOrThrow400(context.contentPath);
|
|
70
|
-
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
71
70
|
|
|
72
71
|
try {
|
|
73
72
|
const [siteRelativeContentPath, componentPath] = getContentAndComponentPaths(requestContentPath);
|
|
@@ -80,9 +79,11 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
80
79
|
const metaResult = await fetchMetaData(contentApiUrl, '${site}/' + siteRelativeContentPath, mapping, outHeaders);
|
|
81
80
|
// ///////////////////////////////////////////////////////////////////////
|
|
82
81
|
|
|
83
|
-
const {_path, type} = metaResult.meta || {};
|
|
82
|
+
const {_id, _path, type} = metaResult.meta || {};
|
|
84
83
|
const contentPath = _path || siteRelativeContentPath;
|
|
85
84
|
|
|
85
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath, _id);
|
|
86
|
+
|
|
86
87
|
if (metaResult.error) {
|
|
87
88
|
console.error(metaResult.error);
|
|
88
89
|
return errorResponse(metaResult.error.code, metaResult.error.message);
|
|
@@ -213,6 +214,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
213
214
|
components,
|
|
214
215
|
contentPath: siteRelativeContentPath,
|
|
215
216
|
contentType: type,
|
|
217
|
+
contentId: _id,
|
|
216
218
|
defaultLocale,
|
|
217
219
|
locale,
|
|
218
220
|
pageCmp: page,
|
|
@@ -239,6 +241,7 @@ export async function fetchContent(context: Context): Promise<FetchContentResult
|
|
|
239
241
|
message: e.message,
|
|
240
242
|
};
|
|
241
243
|
}
|
|
244
|
+
const errorResponse = buildErrorResponse(requestType, renderMode, contentApiUrl, xpBaseUrl, locale, defaultLocale, requestContentPath);
|
|
242
245
|
return errorResponse(error.code, error.message);
|
|
243
246
|
}
|
|
244
247
|
}
|
|
@@ -18,17 +18,32 @@ export const richTextQuery = (fieldName: string) => {
|
|
|
18
18
|
}
|
|
19
19
|
links {
|
|
20
20
|
ref
|
|
21
|
+
uri
|
|
22
|
+
content {
|
|
23
|
+
_id
|
|
24
|
+
}
|
|
21
25
|
media {
|
|
22
26
|
content {
|
|
23
27
|
_id
|
|
28
|
+
... on media_Image {
|
|
29
|
+
mediaUrl(type: absolute)
|
|
30
|
+
}
|
|
24
31
|
}
|
|
32
|
+
intent
|
|
25
33
|
}
|
|
26
34
|
}
|
|
27
35
|
images {
|
|
28
36
|
ref
|
|
29
37
|
image {
|
|
30
38
|
_id
|
|
39
|
+
... on media_Image {
|
|
40
|
+
imageUrl(scale: "width(768)", type:absolute)
|
|
41
|
+
}
|
|
31
42
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
43
|
+
style {
|
|
44
|
+
name
|
|
45
|
+
aspectRatio
|
|
46
|
+
filter
|
|
47
|
+
}
|
|
48
|
+
}}`;
|
|
49
|
+
};
|
|
@@ -3,8 +3,6 @@ import type {Dict, LocaleContextType} from '../types';
|
|
|
3
3
|
|
|
4
4
|
import React, {createContext, useContext, useEffect, useState} from 'react';
|
|
5
5
|
import {getPhrase, loadPhrases} from './i18n';
|
|
6
|
-
import {getLocaleMappingByLocale} from '../utils/getLocaleMappingByLocale';
|
|
7
|
-
import {UrlProcessor} from '../common/UrlProcessor';
|
|
8
6
|
|
|
9
7
|
|
|
10
8
|
const LocaleContext = createContext<LocaleContextType>({
|
|
@@ -31,9 +29,6 @@ export const LocaleContextProvider = ({
|
|
|
31
29
|
setLocaleState(locale);
|
|
32
30
|
setLoadedState(false);
|
|
33
31
|
|
|
34
|
-
const mapping = getLocaleMappingByLocale(locale);
|
|
35
|
-
UrlProcessor.setSiteKey(mapping.site);
|
|
36
|
-
|
|
37
32
|
return loadPhrases(locale).then((phrases) => {
|
|
38
33
|
setPhrasesState(phrases);
|
|
39
34
|
setLoadedState(true);
|
package/src/i18n/i18n.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import type {Dict} from '../types';
|
|
2
|
-
import {getLocaleMappingByLocale} from '../utils/getLocaleMappingByLocale';
|
|
3
|
-
import {UrlProcessor} from '../common/UrlProcessor';
|
|
4
2
|
|
|
5
3
|
|
|
6
4
|
export class I18n {
|
|
@@ -12,9 +10,6 @@ export class I18n {
|
|
|
12
10
|
this.locale = locale;
|
|
13
11
|
this.isLoaded = false;
|
|
14
12
|
|
|
15
|
-
const mapping = getLocaleMappingByLocale(locale);
|
|
16
|
-
UrlProcessor.setSiteKey(mapping.site);
|
|
17
|
-
|
|
18
13
|
return loadPhrases(locale).then((phrases) => {
|
|
19
14
|
this.dictionary = phrases;
|
|
20
15
|
this.isLoaded = true;
|
package/src/types/component.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import type {XP_COMPONENT_TYPE} from '../common/constants';
|
|
2
2
|
import type {Context} from './next';
|
|
3
|
+
import type {
|
|
4
|
+
RichTextData as CompsRichTextData,
|
|
5
|
+
LinkData as CompsLinkData,
|
|
6
|
+
ImageData as CompsImageData,
|
|
7
|
+
MacroData as CompsMacroData,
|
|
8
|
+
} from '@enonic/react-components';
|
|
3
9
|
|
|
4
10
|
// Differs from ComponentDefinition to avoid storing catchAll on all components
|
|
5
11
|
// catchAll is calculated in getType instead
|
|
@@ -30,7 +36,7 @@ export interface ComponentDescriptor {
|
|
|
30
36
|
queryAndVariables?: QueryAndVariables;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
export type ComponentDictionary = Record<string,ComponentDefinitionParams>;
|
|
39
|
+
export type ComponentDictionary = Record<string, ComponentDefinitionParams>;
|
|
34
40
|
|
|
35
41
|
// NB! Always return null or empty object from processor for next is unable to serialize undefined
|
|
36
42
|
export type DataProcessor = (data: any, context?: Context, config?: any) => Promise<Record<string, any>>;
|
|
@@ -42,12 +48,7 @@ export interface FragmentData {
|
|
|
42
48
|
}
|
|
43
49
|
}
|
|
44
50
|
|
|
45
|
-
export
|
|
46
|
-
ref: string;
|
|
47
|
-
image: {
|
|
48
|
-
id: string,
|
|
49
|
-
} | null,
|
|
50
|
-
}
|
|
51
|
+
export type ImageData = CompsImageData;
|
|
51
52
|
|
|
52
53
|
export interface LayoutData {
|
|
53
54
|
descriptor: string;
|
|
@@ -56,23 +57,11 @@ export interface LayoutData {
|
|
|
56
57
|
[customKeysFromQuery: string]: any;
|
|
57
58
|
}
|
|
58
59
|
|
|
59
|
-
export
|
|
60
|
-
ref: string,
|
|
61
|
-
media: {
|
|
62
|
-
content: {
|
|
63
|
-
id: string,
|
|
64
|
-
}
|
|
65
|
-
} | null,
|
|
66
|
-
}
|
|
60
|
+
export type LinkData = CompsLinkData;
|
|
67
61
|
|
|
68
62
|
export type MacroConfig = Record<string, any>;
|
|
69
63
|
|
|
70
|
-
export
|
|
71
|
-
ref: string
|
|
72
|
-
name: string
|
|
73
|
-
descriptor: string
|
|
74
|
-
config: Record<string, MacroConfig>
|
|
75
|
-
}
|
|
64
|
+
export type MacroData = CompsMacroData;
|
|
76
65
|
|
|
77
66
|
export interface PageComponent {
|
|
78
67
|
[key: string]: any; // keeps ts happy when accessing component data field by XP_COMPONENT_TYPE type
|
|
@@ -119,19 +108,14 @@ export type SelectedQueryMaybeVariablesFunc =
|
|
|
119
108
|
| string
|
|
120
109
|
| QueryGetter
|
|
121
110
|
| {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
111
|
+
query: string | QueryGetter
|
|
112
|
+
variables: VariablesGetter
|
|
113
|
+
}
|
|
125
114
|
| [string | QueryGetter, VariablesGetter];
|
|
126
115
|
|
|
127
116
|
export type RegionTree = Record<string, PageRegion>;
|
|
128
117
|
|
|
129
|
-
export
|
|
130
|
-
processedHtml: string
|
|
131
|
-
links: LinkData[]
|
|
132
|
-
macros: MacroData[]
|
|
133
|
-
images: ImageData[]
|
|
134
|
-
}
|
|
118
|
+
export type RichTextData = CompsRichTextData;
|
|
135
119
|
|
|
136
120
|
export interface TextData {
|
|
137
121
|
value: RichTextData;
|
|
@@ -144,4 +128,4 @@ export type VariablesGetter = (path: string, context?: Context, config?: any) =>
|
|
|
144
128
|
export interface VariablesGetterResult {
|
|
145
129
|
[variables: string]: any
|
|
146
130
|
path: string
|
|
147
|
-
}
|
|
131
|
+
}
|
|
@@ -29,7 +29,7 @@ export interface BaseLayoutProps {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export interface BaseMacroProps {
|
|
32
|
-
data: MacroData
|
|
32
|
+
data: Omit<MacroData, 'ref'>;
|
|
33
33
|
meta: MetaData;
|
|
34
34
|
renderInEditMode?: boolean;
|
|
35
35
|
}
|
|
@@ -73,6 +73,7 @@ export interface MacroProps {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
export interface MetaData {
|
|
76
|
+
id: string,
|
|
76
77
|
type: string,
|
|
77
78
|
path: string,
|
|
78
79
|
requestType: XP_REQUEST_TYPE,
|
package/src/types/guillotine.ts
CHANGED
|
@@ -75,6 +75,7 @@ export type GuillotineResult = Result & Record<string, any>;
|
|
|
75
75
|
|
|
76
76
|
export interface MetaResult extends Result {
|
|
77
77
|
meta?: {
|
|
78
|
+
_id: string
|
|
78
79
|
_path: string
|
|
79
80
|
type: string
|
|
80
81
|
pageAsJson?: PageData
|
|
@@ -423,4 +424,4 @@ interface XData_media_cameraInfo_DataConfig {
|
|
|
423
424
|
exposureMode: string
|
|
424
425
|
focusDistance: string
|
|
425
426
|
orientation: string
|
|
426
|
-
}
|
|
427
|
+
}
|
package/src/views/BaseMacro.tsx
CHANGED
|
@@ -17,7 +17,7 @@ export const MACRO_EMBED = 'system:embed';
|
|
|
17
17
|
const BaseMacro = (props: BaseMacroProps) => {
|
|
18
18
|
const {data, meta, renderInEditMode} = props;
|
|
19
19
|
|
|
20
|
-
let config = data.config[sanitizeGraphqlName(data.name)]
|
|
20
|
+
let config = data.config?.[sanitizeGraphqlName(data.name)] ?? {};
|
|
21
21
|
if (data.descriptor !== MACRO_DISABLE) {
|
|
22
22
|
// do not do any processing for disable macro
|
|
23
23
|
config = normalizeValue(config);
|
|
@@ -1,75 +1,60 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {MetaData, Replacer,
|
|
2
|
+
import type {MetaData, RichTextViewProps, Replacer as OldReplacer, MacroConfig, RichTextData} from '../types';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
import {getUrl, UrlProcessor} from '../common/UrlProcessor';
|
|
6
|
-
import HTMLReactParser, {DOMNode, domToReact} from 'html-react-parser';
|
|
7
|
-
import {ElementType} from 'domelementtype';
|
|
4
|
+
import {getUrl} from '../common/UrlProcessor';
|
|
8
5
|
import BaseMacro from './BaseMacro';
|
|
9
6
|
import Link from 'next/link';
|
|
7
|
+
import type {MacroComponentParams, LinkComponentParams, ImageComponentParams, Replacer as NewReplacer} from '@enonic/react-components';
|
|
8
|
+
import {RichText} from '@enonic/react-components';
|
|
9
|
+
import type {DOMNode} from 'html-react-parser';
|
|
10
10
|
|
|
11
|
+
interface ExtraRichTextProps {
|
|
12
|
+
meta: MetaData;
|
|
13
|
+
renderInEditMode?: boolean;
|
|
14
|
+
}
|
|
11
15
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (UrlProcessor.isContentImage(ref, allData.images)) {
|
|
26
|
-
const src = el.attribs['src'];
|
|
27
|
-
if (src) {
|
|
28
|
-
el.attribs['src'] = getUrl(src, meta);
|
|
29
|
-
}
|
|
16
|
+
const RichTextView = (props: RichTextViewProps) => {
|
|
17
|
+
return <RichText<ExtraRichTextProps>
|
|
18
|
+
data={props.data}
|
|
19
|
+
meta={props.meta}
|
|
20
|
+
className={props.className}
|
|
21
|
+
tag={props.tag}
|
|
22
|
+
replacer={wrapReplacer(props.customReplacer, props.meta, props.renderMacroInEditMode)}
|
|
23
|
+
renderInEditMode={props.renderMacroInEditMode}
|
|
24
|
+
Macro={MacroAdapter}
|
|
25
|
+
Link={LinkAdapter}
|
|
26
|
+
Image={ImageAdapter}
|
|
27
|
+
/>;
|
|
28
|
+
};
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
ref = el.attribs[UrlProcessor.LINK_ATTR];
|
|
40
|
-
const href = el.attribs['href'];
|
|
30
|
+
function wrapReplacer(oldReplacer: OldReplacer | undefined, meta: MetaData, renderMacroInEditMode: boolean): NewReplacer {
|
|
31
|
+
if (!oldReplacer) {
|
|
32
|
+
return null;
|
|
33
|
+
}
|
|
34
|
+
return (element: DOMNode, data: RichTextData) => {
|
|
35
|
+
return oldReplacer(element, data, meta, renderMacroInEditMode);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
41
38
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (data) {
|
|
51
|
-
return <BaseMacro data={data} meta={meta} renderInEditMode={renderMacroInEditMode}/>;
|
|
52
|
-
}
|
|
53
|
-
break;
|
|
54
|
-
default:
|
|
55
|
-
if (customReplacer) {
|
|
56
|
-
const result = customReplacer(domNode, allData, meta, renderMacroInEditMode);
|
|
57
|
-
if (result) {
|
|
58
|
-
return result;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
return el;
|
|
39
|
+
function MacroAdapter(props: MacroComponentParams<ExtraRichTextProps>) {
|
|
40
|
+
const name = props.descriptor.substring(props.descriptor.indexOf(':') + 1);
|
|
41
|
+
const data = {
|
|
42
|
+
name: name,
|
|
43
|
+
descriptor: props.descriptor,
|
|
44
|
+
config: {
|
|
45
|
+
[name]: props.config as Record<string, MacroConfig>,
|
|
46
|
+
},
|
|
64
47
|
};
|
|
65
|
-
|
|
48
|
+
|
|
49
|
+
return <BaseMacro data={data} meta={props.meta} renderInEditMode={props.renderInEditMode}/>;
|
|
66
50
|
}
|
|
67
51
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
52
|
+
function LinkAdapter(props: LinkComponentParams<ExtraRichTextProps>) {
|
|
53
|
+
return <Link href={getUrl(props.href, props.meta)}>{props.children}</Link>;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function ImageAdapter(props: ImageComponentParams<ExtraRichTextProps>) {
|
|
57
|
+
return <img src={getUrl(props.src, props.meta)} alt={props.alt} sizes={props.sizes} srcSet={props.srcSet}/>;
|
|
58
|
+
}
|
|
74
59
|
|
|
75
60
|
export default RichTextView;
|
package/types/component.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { XP_COMPONENT_TYPE } from '../common/constants';
|
|
2
2
|
import type { Context } from './next';
|
|
3
|
+
import type { RichTextData as CompsRichTextData, LinkData as CompsLinkData, ImageData as CompsImageData, MacroData as CompsMacroData } from '@enonic/react-components';
|
|
3
4
|
export interface ComponentDefinitionParams {
|
|
4
5
|
query?: SelectedQueryMaybeVariablesFunc;
|
|
5
6
|
configQuery?: string;
|
|
@@ -32,32 +33,15 @@ export interface FragmentData {
|
|
|
32
33
|
components: PageComponent[];
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
|
-
export
|
|
36
|
-
ref: string;
|
|
37
|
-
image: {
|
|
38
|
-
id: string;
|
|
39
|
-
} | null;
|
|
40
|
-
}
|
|
36
|
+
export type ImageData = CompsImageData;
|
|
41
37
|
export interface LayoutData {
|
|
42
38
|
descriptor: string;
|
|
43
39
|
config?: any;
|
|
44
40
|
[customKeysFromQuery: string]: any;
|
|
45
41
|
}
|
|
46
|
-
export
|
|
47
|
-
ref: string;
|
|
48
|
-
media: {
|
|
49
|
-
content: {
|
|
50
|
-
id: string;
|
|
51
|
-
};
|
|
52
|
-
} | null;
|
|
53
|
-
}
|
|
42
|
+
export type LinkData = CompsLinkData;
|
|
54
43
|
export type MacroConfig = Record<string, any>;
|
|
55
|
-
export
|
|
56
|
-
ref: string;
|
|
57
|
-
name: string;
|
|
58
|
-
descriptor: string;
|
|
59
|
-
config: Record<string, MacroConfig>;
|
|
60
|
-
}
|
|
44
|
+
export type MacroData = CompsMacroData;
|
|
61
45
|
export interface PageComponent {
|
|
62
46
|
[key: string]: any;
|
|
63
47
|
type: XP_COMPONENT_TYPE;
|
|
@@ -97,12 +81,7 @@ export type SelectedQueryMaybeVariablesFunc = string | QueryGetter | {
|
|
|
97
81
|
variables: VariablesGetter;
|
|
98
82
|
} | [string | QueryGetter, VariablesGetter];
|
|
99
83
|
export type RegionTree = Record<string, PageRegion>;
|
|
100
|
-
export
|
|
101
|
-
processedHtml: string;
|
|
102
|
-
links: LinkData[];
|
|
103
|
-
macros: MacroData[];
|
|
104
|
-
images: ImageData[];
|
|
105
|
-
}
|
|
84
|
+
export type RichTextData = CompsRichTextData;
|
|
106
85
|
export interface TextData {
|
|
107
86
|
value: RichTextData;
|
|
108
87
|
}
|
|
@@ -14,7 +14,7 @@ export interface BaseLayoutProps {
|
|
|
14
14
|
meta: MetaData;
|
|
15
15
|
}
|
|
16
16
|
export interface BaseMacroProps {
|
|
17
|
-
data: MacroData
|
|
17
|
+
data: Omit<MacroData, 'ref'>;
|
|
18
18
|
meta: MetaData;
|
|
19
19
|
renderInEditMode?: boolean;
|
|
20
20
|
}
|
|
@@ -52,6 +52,7 @@ export interface MacroProps {
|
|
|
52
52
|
meta: MetaData;
|
|
53
53
|
}
|
|
54
54
|
export interface MetaData {
|
|
55
|
+
id: string;
|
|
55
56
|
type: string;
|
|
56
57
|
path: string;
|
|
57
58
|
requestType: XP_REQUEST_TYPE;
|
package/types/guillotine.d.ts
CHANGED
package/views/BaseComponent.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { BaseComponentProps, MetaData } from '../types';
|
|
3
|
-
declare const BaseComponent: ({ component, meta, common }: BaseComponentProps) => JSX.Element;
|
|
3
|
+
declare const BaseComponent: ({ component, meta, common }: BaseComponentProps) => React.JSX.Element;
|
|
4
4
|
export default BaseComponent;
|
|
5
5
|
export declare const MissingComponent: ({ descriptor, type }: {
|
|
6
6
|
descriptor?: string;
|
package/views/BaseMacro.jsx
CHANGED
|
@@ -6,8 +6,9 @@ const unescape = require('unescape');
|
|
|
6
6
|
export const MACRO_DISABLE = 'system:disable';
|
|
7
7
|
export const MACRO_EMBED = 'system:embed';
|
|
8
8
|
const BaseMacro = (props) => {
|
|
9
|
+
var _a, _b;
|
|
9
10
|
const { data, meta, renderInEditMode } = props;
|
|
10
|
-
let config = data.config[sanitizeGraphqlName(data.name)]
|
|
11
|
+
let config = (_b = (_a = data.config) === null || _a === void 0 ? void 0 : _a[sanitizeGraphqlName(data.name)]) !== null && _b !== void 0 ? _b : {};
|
|
11
12
|
if (data.descriptor !== MACRO_DISABLE) {
|
|
12
13
|
// do not do any processing for disable macro
|
|
13
14
|
config = normalizeValue(config);
|
package/views/BaseMacro.jsx.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseMacro.jsx","sourceRoot":"","sources":["../src/views/BaseMacro.tsx"],"names":[],"mappings":"AAIA,OAAO,EAAC,iBAAiB,EAAC,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAC,mBAAmB,EAAC,MAAM,8BAA8B,CAAC;AACjE,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAGhD,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAErC,MAAM,CAAC,MAAM,aAAa,GAA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AE,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,GAAG,GAAG,CAAC,CAAC,CAAC;QACvF,OAAO,KAAK,CAAC;IACjB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEX,OAAO,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AACrD,CAAC;AAED,eAAe,SAAS,CAAC"}
|
package/views/RichTextView.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
export declare function createReplacer(allData: RichTextData, meta: MetaData, renderMacroInEditMode?: boolean, customReplacer?: Replacer): (domNode: DOMNode) => ReplacerResult;
|
|
4
|
-
declare const RichTextView: ({ className, tag, data, meta, renderMacroInEditMode, customReplacer }: RichTextViewProps) => import("react").JSX.Element;
|
|
1
|
+
import type { RichTextViewProps } from '../types';
|
|
2
|
+
declare const RichTextView: (props: RichTextViewProps) => import("react").JSX.Element;
|
|
5
3
|
export default RichTextView;
|
package/views/RichTextView.jsx
CHANGED
|
@@ -1,65 +1,34 @@
|
|
|
1
|
-
import { getUrl
|
|
2
|
-
import HTMLReactParser, { domToReact } from 'html-react-parser';
|
|
3
|
-
import { ElementType } from 'domelementtype';
|
|
1
|
+
import { getUrl } from '../common/UrlProcessor';
|
|
4
2
|
import BaseMacro from './BaseMacro';
|
|
5
3
|
import Link from 'next/link';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ref = el.attribs[UrlProcessor.IMG_ATTR];
|
|
17
|
-
if (ref) {
|
|
18
|
-
if (UrlProcessor.isContentImage(ref, allData.images)) {
|
|
19
|
-
const src = el.attribs['src'];
|
|
20
|
-
if (src) {
|
|
21
|
-
el.attribs['src'] = getUrl(src, meta);
|
|
22
|
-
}
|
|
23
|
-
const srcset = el.attribs['srcset'];
|
|
24
|
-
if (srcset) {
|
|
25
|
-
el.attribs['srcset'] = UrlProcessor.processSrcSet(srcset, meta);
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
break;
|
|
30
|
-
case UrlProcessor.LINK_TAG:
|
|
31
|
-
ref = el.attribs[UrlProcessor.LINK_ATTR];
|
|
32
|
-
const href = el.attribs['href'];
|
|
33
|
-
if (ref && href) {
|
|
34
|
-
const domNodes = el.children;
|
|
35
|
-
return <Link href={getUrl(href, meta)}>{domToReact(domNodes, { replace: replacerFn })}</Link>;
|
|
36
|
-
}
|
|
37
|
-
break;
|
|
38
|
-
case UrlProcessor.MACRO_TAG:
|
|
39
|
-
ref = el.attribs[UrlProcessor.MACRO_ATTR];
|
|
40
|
-
const data = ref && allData.macros.find((d) => d.ref === ref);
|
|
41
|
-
if (data) {
|
|
42
|
-
return <BaseMacro data={data} meta={meta} renderInEditMode={renderMacroInEditMode}/>;
|
|
43
|
-
}
|
|
44
|
-
break;
|
|
45
|
-
default:
|
|
46
|
-
if (customReplacer) {
|
|
47
|
-
const result = customReplacer(domNode, allData, meta, renderMacroInEditMode);
|
|
48
|
-
if (result) {
|
|
49
|
-
return result;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
return el;
|
|
4
|
+
import { RichText } from '@enonic/react-components';
|
|
5
|
+
const RichTextView = (props) => {
|
|
6
|
+
return <RichText data={props.data} meta={props.meta} className={props.className} tag={props.tag} replacer={wrapReplacer(props.customReplacer, props.meta, props.renderMacroInEditMode)} renderInEditMode={props.renderMacroInEditMode} Macro={MacroAdapter} Link={LinkAdapter} Image={ImageAdapter}/>;
|
|
7
|
+
};
|
|
8
|
+
function wrapReplacer(oldReplacer, meta, renderMacroInEditMode) {
|
|
9
|
+
if (!oldReplacer) {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
return (element, data) => {
|
|
13
|
+
return oldReplacer(element, data, meta, renderMacroInEditMode);
|
|
55
14
|
};
|
|
56
|
-
return replacerFn;
|
|
57
15
|
}
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
16
|
+
function MacroAdapter(props) {
|
|
17
|
+
const name = props.descriptor.substring(props.descriptor.indexOf(':') + 1);
|
|
18
|
+
const data = {
|
|
19
|
+
name: name,
|
|
20
|
+
descriptor: props.descriptor,
|
|
21
|
+
config: {
|
|
22
|
+
[name]: props.config,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
return <BaseMacro data={data} meta={props.meta} renderInEditMode={props.renderInEditMode}/>;
|
|
26
|
+
}
|
|
27
|
+
function LinkAdapter(props) {
|
|
28
|
+
return <Link href={getUrl(props.href, props.meta)}>{props.children}</Link>;
|
|
29
|
+
}
|
|
30
|
+
function ImageAdapter(props) {
|
|
31
|
+
return <img src={getUrl(props.src, props.meta)} alt={props.alt} sizes={props.sizes} srcSet={props.srcSet}/>;
|
|
32
|
+
}
|
|
64
33
|
export default RichTextView;
|
|
65
34
|
//# sourceMappingURL=RichTextView.jsx.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RichTextView.jsx","sourceRoot":"","sources":["../src/views/RichTextView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"RichTextView.jsx","sourceRoot":"","sources":["../src/views/RichTextView.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAC,MAAM,EAAC,MAAM,wBAAwB,CAAC;AAC9C,OAAO,SAAS,MAAM,aAAa,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAC,QAAQ,EAAC,MAAM,0BAA0B,CAAC;AAQlD,MAAM,YAAY,GAAG,CAAC,KAAwB,EAAE,EAAE;IAC9C,OAAO,CAAC,QAAQ,CACZ,IAAI,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