@se-studio/core-ui 1.0.55 → 1.0.56
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 +9 -0
- package/CMS_INFRASTRUCTURE.md +12 -17
- package/dist/CmsRendererConfig.d.ts +9 -30
- package/dist/CmsRendererConfig.d.ts.map +1 -1
- package/dist/app-helpers.d.ts +124 -0
- package/dist/app-helpers.d.ts.map +1 -0
- package/dist/app-helpers.js +246 -0
- package/dist/app-helpers.js.map +1 -0
- package/dist/components/ClientMonitor.d.ts.map +1 -1
- package/dist/components/ClientMonitor.js +5 -1
- package/dist/components/ClientMonitor.js.map +1 -1
- package/dist/components/CmsCollection.d.ts.map +1 -1
- package/dist/components/CmsCollection.js +9 -13
- package/dist/components/CmsCollection.js.map +1 -1
- package/dist/components/CmsComponent.d.ts.map +1 -1
- package/dist/components/CmsComponent.js +9 -13
- package/dist/components/CmsComponent.js.map +1 -1
- package/dist/components/CmsContent.d.ts +9 -32
- package/dist/components/CmsContent.d.ts.map +1 -1
- package/dist/components/CmsContent.js +15 -40
- package/dist/components/CmsContent.js.map +1 -1
- package/dist/components/CmsEmbeddedContent.d.ts.map +1 -1
- package/dist/components/CmsEmbeddedContent.js +3 -4
- package/dist/components/CmsEmbeddedContent.js.map +1 -1
- package/dist/components/CmsExternalComponent.d.ts.map +1 -1
- package/dist/components/CmsExternalComponent.js +9 -13
- package/dist/components/CmsExternalComponent.js.map +1 -1
- package/dist/components/banner/BannerManager.d.ts +2 -3
- package/dist/components/banner/BannerManager.d.ts.map +1 -1
- package/dist/components/banner/BannerManager.js +2 -2
- package/dist/components/banner/BannerManager.js.map +1 -1
- package/dist/components/banner/BannerTargeting.d.ts +2 -2
- package/dist/components/banner/BannerTargeting.d.ts.map +1 -1
- package/dist/components/banner/BannerTargeting.js +7 -6
- package/dist/components/banner/BannerTargeting.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/showcase/components/ShowcaseAllRenderPage.d.ts +2 -2
- package/dist/showcase/components/ShowcaseAllRenderPage.d.ts.map +1 -1
- package/dist/showcase/components/ShowcaseAllRenderPage.js +1 -2
- package/dist/showcase/components/ShowcaseAllRenderPage.js.map +1 -1
- package/dist/showcase/components/ShowcasePage.d.ts +1 -1
- package/dist/showcase/components/ShowcasePage.d.ts.map +1 -1
- package/dist/showcase/components/ShowcaseRenderPage.d.ts +2 -2
- package/dist/showcase/components/ShowcaseRenderPage.d.ts.map +1 -1
- package/dist/showcase/components/ShowcaseRenderPage.js +1 -3
- package/dist/showcase/components/ShowcaseRenderPage.js.map +1 -1
- package/dist/showcase/mockFactory.d.ts +2 -2
- package/dist/showcase/mockFactory.d.ts.map +1 -1
- package/dist/showcase/mockFactory.js +2 -2
- package/dist/showcase/mockFactory.js.map +1 -1
- package/dist/utils/buildPageMetadata.d.ts +17 -12
- package/dist/utils/buildPageMetadata.d.ts.map +1 -1
- package/dist/utils/buildPageMetadata.js +4 -1
- package/dist/utils/buildPageMetadata.js.map +1 -1
- package/dist/utils/componentUtils.d.ts +2 -6
- package/dist/utils/componentUtils.d.ts.map +1 -1
- package/dist/utils/componentUtils.js +10 -14
- package/dist/utils/componentUtils.js.map +1 -1
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
package/CMS_INFRASTRUCTURE.md
CHANGED
|
@@ -110,9 +110,7 @@ export const rendererConfig = createCmsRendererConfig<MyProjectConfig>({
|
|
|
110
110
|
},
|
|
111
111
|
visualComponentRenderer: VisualRenderer,
|
|
112
112
|
internalLinkRenderer: InternalLinkRenderer,
|
|
113
|
-
|
|
114
|
-
showUnknownTypeErrors: process.env.NODE_ENV === 'development',
|
|
115
|
-
showRenderErrors: process.env.NODE_ENV === 'development',
|
|
113
|
+
buildInformation,
|
|
116
114
|
});
|
|
117
115
|
```
|
|
118
116
|
|
|
@@ -180,10 +178,9 @@ import { mergeCmsRendererConfig } from "@se-studio/core-ui";
|
|
|
180
178
|
|
|
181
179
|
const baseConfig = createCmsRendererConfig({ ... });
|
|
182
180
|
|
|
183
|
-
// Preview config with
|
|
181
|
+
// Preview config: use buildInformation with isProduction: false to show errors
|
|
184
182
|
export const previewConfig = mergeCmsRendererConfig(baseConfig, {
|
|
185
|
-
|
|
186
|
-
showRenderErrors: true,
|
|
183
|
+
buildInformation: { ...baseConfig.buildInformation, isProduction: false },
|
|
187
184
|
});
|
|
188
185
|
|
|
189
186
|
// Use in preview routes
|
|
@@ -194,15 +191,13 @@ export const previewConfig = mergeCmsRendererConfig(baseConfig, {
|
|
|
194
191
|
|
|
195
192
|
```tsx
|
|
196
193
|
const productionConfig = createCmsRendererConfig({
|
|
194
|
+
buildInformation: { ...buildInfo, isProduction: true },
|
|
197
195
|
componentMap: { ... },
|
|
198
196
|
collectionMap: { ... },
|
|
199
|
-
showUnknownTypeErrors: false,
|
|
200
|
-
showRenderErrors: false,
|
|
201
197
|
});
|
|
202
198
|
|
|
203
199
|
const developmentConfig = mergeCmsRendererConfig(productionConfig, {
|
|
204
|
-
|
|
205
|
-
showRenderErrors: true,
|
|
200
|
+
buildInformation: { ...buildInfo, isProduction: false },
|
|
206
201
|
});
|
|
207
202
|
|
|
208
203
|
export const rendererConfig =
|
|
@@ -247,16 +242,17 @@ The main configuration type that bundles all renderer maps:
|
|
|
247
242
|
|
|
248
243
|
```tsx
|
|
249
244
|
interface CmsRendererConfig<TConfig extends BaseCmsConfig> {
|
|
245
|
+
buildInformation: IBuildInformation;
|
|
250
246
|
componentMap: ComponentMap<TConfig>;
|
|
251
247
|
collectionMap: CollectionMap<TConfig>;
|
|
252
248
|
externalComponentMap?: ExternalComponentMap<TConfig>;
|
|
253
249
|
visualComponentRenderer?: VisualComponentRenderer<TConfig>;
|
|
254
250
|
internalLinkRenderer?: InternalLinkRenderer<TConfig>;
|
|
255
|
-
showUnknownTypeErrors?: boolean;
|
|
256
|
-
showRenderErrors?: boolean;
|
|
257
251
|
}
|
|
258
252
|
```
|
|
259
253
|
|
|
254
|
+
Error panels (unknown types, render errors) are shown when `!buildInformation.isProduction`.
|
|
255
|
+
|
|
260
256
|
### Context Types
|
|
261
257
|
|
|
262
258
|
- `IPageContext<TConfig>`: Page-level context (article, page, tag links)
|
|
@@ -268,7 +264,7 @@ interface CmsRendererConfig<TConfig extends BaseCmsConfig> {
|
|
|
268
264
|
|
|
269
265
|
### Unknown Type Warnings
|
|
270
266
|
|
|
271
|
-
|
|
267
|
+
When not in production (`!buildInformation.isProduction`), the infrastructure displays visual warnings for:
|
|
272
268
|
- Unmapped component/collection types
|
|
273
269
|
- Rendering errors
|
|
274
270
|
- Unused CMS properties
|
|
@@ -277,7 +273,7 @@ In development mode, the infrastructure displays visual warnings for:
|
|
|
277
273
|
|
|
278
274
|
When a component/collection type isn't mapped:
|
|
279
275
|
1. A warning is logged to console
|
|
280
|
-
2.
|
|
276
|
+
2. When not in production, an error panel is displayed
|
|
281
277
|
3. A generic fallback renderer is used
|
|
282
278
|
4. The page continues to render (no crashes)
|
|
283
279
|
|
|
@@ -301,7 +297,7 @@ To migrate an existing project:
|
|
|
301
297
|
1. Install core-ui: `pnpm add @se-studio/core-ui`
|
|
302
298
|
2. Create ComponentMap and CollectionMap
|
|
303
299
|
3. Replace direct component rendering with CmsContent
|
|
304
|
-
4.
|
|
300
|
+
4. Use a non-production build (e.g. `buildInformation.isProduction: false`) to see error panels for missing mappings
|
|
305
301
|
|
|
306
302
|
## Examples
|
|
307
303
|
|
|
@@ -320,8 +316,7 @@ See the example apps in this monorepo for complete working implementations:
|
|
|
320
316
|
- `externalComponentMap`: Map of external component types to renderers (optional)
|
|
321
317
|
- `visualComponentRenderer`: Renderer for Visual content types (optional)
|
|
322
318
|
- `internalLinkRenderer`: Renderer for Internal Link content types (optional)
|
|
323
|
-
- `
|
|
324
|
-
- `showRenderErrors`: Show error panels for rendering errors (default: false)
|
|
319
|
+
- `buildInformation`: Build config (isProduction, baseUrl, etc.). Error panels are shown when `!buildInformation.isProduction`
|
|
325
320
|
|
|
326
321
|
## Future Enhancements
|
|
327
322
|
|
|
@@ -5,6 +5,7 @@ import type { CollectionMap, CollectionRenderer, EmbeddedCollectionMap } from '.
|
|
|
5
5
|
import type { ComponentMap, ComponentRenderer, EmbeddedComponentMap } from './components/CmsComponent';
|
|
6
6
|
import type { InternalLinkRenderer, VisualComponentRenderer } from './components/CmsContent';
|
|
7
7
|
import type { EmbeddedExternalComponentMap, ExternalComponentMap } from './components/CmsExternalComponent';
|
|
8
|
+
import type { IBuildInformation } from './utils/buildPageMetadata';
|
|
8
9
|
export type CmsRendererTypes = {
|
|
9
10
|
ComponentNameType: string;
|
|
10
11
|
ComponentType: any;
|
|
@@ -22,7 +23,8 @@ export type CmsRendererTypes = {
|
|
|
22
23
|
*
|
|
23
24
|
* @example Basic configuration
|
|
24
25
|
* ```tsx
|
|
25
|
-
* const rendererConfig =
|
|
26
|
+
* const rendererConfig = {
|
|
27
|
+
* buildInformation,
|
|
26
28
|
* componentMap: {
|
|
27
29
|
* "Hero": HeroComponent,
|
|
28
30
|
* "CTA": CTAComponent,
|
|
@@ -32,25 +34,11 @@ export type CmsRendererTypes = {
|
|
|
32
34
|
* "FAQs": FAQCollection,
|
|
33
35
|
* "Related Articles": RelatedArticles,
|
|
34
36
|
* },
|
|
35
|
-
*
|
|
36
|
-
* }
|
|
37
|
+
* // ... other required fields
|
|
38
|
+
* };
|
|
37
39
|
* ```
|
|
38
40
|
*
|
|
39
|
-
*
|
|
40
|
-
* ```tsx
|
|
41
|
-
* const rendererConfig = createCmsRendererConfig<MyProjectConfig>({
|
|
42
|
-
* componentMap: { ... },
|
|
43
|
-
* collectionMap: { ... },
|
|
44
|
-
* externalComponentMap: {
|
|
45
|
-
* "Contact Form": ContactFormRenderer,
|
|
46
|
-
* "Newsletter": NewsletterRenderer,
|
|
47
|
-
* },
|
|
48
|
-
* visualComponentRenderer: VisualRenderer,
|
|
49
|
-
* internalLinkRenderer: InternalLinkRenderer,
|
|
50
|
-
* showUnknownTypeErrors: true,
|
|
51
|
-
* showRenderErrors: true,
|
|
52
|
-
* });
|
|
53
|
-
* ```
|
|
41
|
+
* Error panels (unknown types, render errors) are shown when `!buildInformation.isProduction`.
|
|
54
42
|
*/
|
|
55
43
|
export interface CmsRendererConfig<TConfig extends CmsRendererTypes = CmsRendererTypes> {
|
|
56
44
|
/**
|
|
@@ -136,19 +124,10 @@ export interface CmsRendererConfig<TConfig extends CmsRendererTypes = CmsRendere
|
|
|
136
124
|
contentContext: IContentContext;
|
|
137
125
|
}>>>;
|
|
138
126
|
/**
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
* Recommended: Set to `process.env.NODE_ENV === 'development'`
|
|
143
|
-
*/
|
|
144
|
-
showUnknownTypeErrors: boolean;
|
|
145
|
-
/**
|
|
146
|
-
* Show error panels for rendering errors (default: false).
|
|
147
|
-
* When true, displays error details when a component throws during rendering.
|
|
148
|
-
*
|
|
149
|
-
* Recommended: Set to `process.env.NODE_ENV === 'development'`
|
|
127
|
+
* Build configuration (isProduction, baseUrl, etc.).
|
|
128
|
+
* Error panels (unknown types, render errors) are shown when `!buildInformation.isProduction`.
|
|
150
129
|
*/
|
|
151
|
-
|
|
130
|
+
buildInformation: IBuildInformation;
|
|
152
131
|
defaultComponentRenderer: ComponentRenderer<any>;
|
|
153
132
|
defaultCollectionRenderer: CollectionRenderer<any>;
|
|
154
133
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CmsRendererConfig.d.ts","sourceRoot":"","sources":["../src/CmsRendererConfig.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,kEAAkE,CAAC;AAC9F,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,qBAAqB,EACtB,MAAM,4BAA4B,CAAC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OAAO,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC;IAEnF,oBAAoB,EAAE,oBAAoB,CACxC,OAAO,CAAC,mBAAmB,CAAC,EAC5B,OAAO,CAAC,eAAe,CAAC,CACzB,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,aAAa,EAAE,aAAa,CAAC,OAAO,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACvF,qBAAqB,EAAE,qBAAqB,CAC1C,OAAO,CAAC,oBAAoB,CAAC,EAC7B,OAAO,CAAC,gBAAgB,CAAC,CAC1B,CAAC;IAEF;;;;;;;;;;;OAWG;IACH,oBAAoB,EAAE,oBAAoB,CACxC,OAAO,CAAC,2BAA2B,CAAC,EACpC,OAAO,CAAC,uBAAuB,CAAC,CACjC,CAAC;IACF,4BAA4B,EAAE,4BAA4B,CACxD,OAAO,CAAC,2BAA2B,CAAC,EACpC,OAAO,CAAC,uBAAuB,CAAC,CACjC,CAAC;IAEF;;;;;;;;;;OAUG;IACH,uBAAuB,EAAE,uBAAuB,CAAC;IAEjD;;;;;;;;;;OAUG;IACH,oBAAoB,EAAE,oBAAoB,CAAC;IAE3C;;;;;;;;;;;OAWG;IACH,gBAAgB,CAAC,EAAE,OAAO,CACxB,MAAM,CACJ,MAAM,EACN,KAAK,CAAC,EAAE,CAAC;QACP,WAAW,EAAE,GAAG,CAAC;QACjB,cAAc,EAAE,eAAe,CAAC;KACjC,CAAC,CACH,CACF,CAAC;IAEF;;;OAGG;IACH,gBAAgB,EAAE,iBAAiB,CAAC;IAEpC,wBAAwB,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC;IACjD,yBAAyB,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-level helper functions for Contentful CMS integration.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a factory function that creates commonly-used helper functions
|
|
5
|
+
* for Next.js apps using the Contentful REST API. These helpers wrap the low-level
|
|
6
|
+
* API functions with project-specific configuration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createAppHelpers } from '@se-studio/core-ui';
|
|
11
|
+
*
|
|
12
|
+
* const helpers = createAppHelpers({
|
|
13
|
+
* converterContext,
|
|
14
|
+
* getConfig: getContentfulConfig,
|
|
15
|
+
* buildOptions: (options) => buildFetchOptions(options, draftOnly),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* export const {
|
|
19
|
+
* getAllPageLinks,
|
|
20
|
+
* getPageWithErrors,
|
|
21
|
+
* getPreviewFieldIdProps,
|
|
22
|
+
* // ... etc
|
|
23
|
+
* } = helpers;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import type { ArticleTypeFetchOptions, BaseConverterContext, CmsResponse, ContentfulConfig, FetchOptions, IContentfulCollection, IContentfulPerson, IFetchedTemplate, TagFetchOptions } from '@se-studio/contentful-rest-api';
|
|
27
|
+
import type { BaseCollectionContent, IArticleLink, IArticleTypeLink, IBanner, IBaseArticle, IBaseArticleType, IBaseCustomType, IBasePage, IBaseTag, IContentContext, IInternalLink, IPersonLink } from '@se-studio/core-data-types';
|
|
28
|
+
import type { IContent as IPreviewContent } from './utils/previewUtils';
|
|
29
|
+
/**
|
|
30
|
+
* Configuration for creating app helpers
|
|
31
|
+
*/
|
|
32
|
+
export interface AppHelpersConfig {
|
|
33
|
+
/** The converter context with URL calculators and other project-specific settings */
|
|
34
|
+
converterContext: BaseConverterContext;
|
|
35
|
+
/** Function to get Contentful config based on preview mode */
|
|
36
|
+
getConfig: (preview: boolean) => ContentfulConfig;
|
|
37
|
+
/** Function to build fetch options with project-specific defaults */
|
|
38
|
+
buildOptions: (options?: Partial<FetchOptions>) => FetchOptions;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Return type for createAppHelpers factory function.
|
|
42
|
+
* Contains all the helper functions for fetching content and managing preview.
|
|
43
|
+
*/
|
|
44
|
+
export interface AppHelpers<TPage, TArticle, TArticleType, TTag, TPerson, TCustomType, TCollection> {
|
|
45
|
+
getAllPageLinks: (options?: FetchOptions) => Promise<IInternalLink[]>;
|
|
46
|
+
getAllArticleLinks: (options?: FetchOptions) => Promise<IArticleLink[]>;
|
|
47
|
+
getAllTagLinks: (options?: FetchOptions) => Promise<IInternalLink[]>;
|
|
48
|
+
getAllPersonLinks: (options?: FetchOptions) => Promise<IInternalLink[]>;
|
|
49
|
+
getAllArticleTypeLinks: (options?: FetchOptions) => Promise<IArticleTypeLink[]>;
|
|
50
|
+
getRelatedArticles: (information: TCollection, contentContext: IContentContext, count: number | undefined, options?: FetchOptions) => Promise<IArticleLink[]>;
|
|
51
|
+
getRelatedPeople: (information: TCollection, contentContext: IContentContext, count: number, options?: FetchOptions) => Promise<IPersonLink[]>;
|
|
52
|
+
getBannersWithErrors: (options?: FetchOptions) => Promise<CmsResponse<IBanner[] | null>>;
|
|
53
|
+
getPageWithErrors: (slug: string, options?: FetchOptions) => Promise<CmsResponse<TPage | null>>;
|
|
54
|
+
getArticleWithErrors: (articleTypeSlug: string, slug: string, options?: FetchOptions) => Promise<CmsResponse<TArticle | null>>;
|
|
55
|
+
getArticleTypeWithErrors: (slug: string, options?: Partial<ArticleTypeFetchOptions>) => Promise<CmsResponse<TArticleType | null>>;
|
|
56
|
+
getTagWithErrors: (slug: string, options?: Partial<TagFetchOptions>) => Promise<CmsResponse<TTag | null>>;
|
|
57
|
+
getPersonWithErrors: (slug: string, options?: Partial<FetchOptions> & {
|
|
58
|
+
customType?: string;
|
|
59
|
+
}) => Promise<CmsResponse<TPerson | null>>;
|
|
60
|
+
getCustomTypeWithErrors: (slug: string, options?: FetchOptions) => Promise<CmsResponse<TCustomType | null>>;
|
|
61
|
+
getTemplateWithErrors: (cmsLabel: string, options?: FetchOptions) => Promise<CmsResponse<IFetchedTemplate | null>>;
|
|
62
|
+
getPreviewFieldIdProps: (id?: string, fieldId?: string) => {
|
|
63
|
+
'data-contentful-entry-id': string | undefined;
|
|
64
|
+
'data-contentful-asset-id': string | undefined;
|
|
65
|
+
'data-contentful-field-id': string | undefined;
|
|
66
|
+
} | undefined;
|
|
67
|
+
getPreviewAssetIdProps: (assetId?: string) => {
|
|
68
|
+
'data-contentful-entry-id': string | undefined;
|
|
69
|
+
'data-contentful-asset-id': string | undefined;
|
|
70
|
+
'data-contentful-field-id': string | undefined;
|
|
71
|
+
} | undefined;
|
|
72
|
+
getPreviewParentProps: (information: IPreviewContent | null | undefined) => {
|
|
73
|
+
'data-contentful-entry-id': string | undefined;
|
|
74
|
+
'data-contentful-asset-id': string | undefined;
|
|
75
|
+
'data-contentful-field-id': string | undefined;
|
|
76
|
+
} | undefined;
|
|
77
|
+
getPreviewResponsiveVisualFieldIdProps: (id?: string, visualFieldId?: string, mobileVisualFieldId?: string) => {
|
|
78
|
+
visualPreviewProps: {
|
|
79
|
+
'data-contentful-entry-id': string | undefined;
|
|
80
|
+
'data-contentful-asset-id': string | undefined;
|
|
81
|
+
'data-contentful-field-id': string | undefined;
|
|
82
|
+
} | undefined;
|
|
83
|
+
mobileVisualPreviewProps: {
|
|
84
|
+
'data-contentful-entry-id': string | undefined;
|
|
85
|
+
'data-contentful-asset-id': string | undefined;
|
|
86
|
+
'data-contentful-field-id': string | undefined;
|
|
87
|
+
} | undefined;
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a set of helper functions for working with Contentful in Next.js apps.
|
|
92
|
+
*
|
|
93
|
+
* This factory function accepts project-specific configuration and returns
|
|
94
|
+
* a collection of pre-configured helper functions for:
|
|
95
|
+
* - Fetching links (pages, articles, tags, people, article types)
|
|
96
|
+
* - Fetching related content (articles, people)
|
|
97
|
+
* - Fetching full content (pages, articles, article types, tags, people, custom types, templates, banners)
|
|
98
|
+
* - Preview mode utilities (field IDs, asset IDs, parent props)
|
|
99
|
+
*
|
|
100
|
+
* All functions use the provided configuration to automatically handle:
|
|
101
|
+
* - Converter context for transforming Contentful entries
|
|
102
|
+
* - Config selection based on preview mode
|
|
103
|
+
* - Options building with project-specific defaults
|
|
104
|
+
* - Error logging and handling
|
|
105
|
+
*
|
|
106
|
+
* @param config - Configuration object with converter context, config getter, and options builder
|
|
107
|
+
* @returns Object containing all helper functions
|
|
108
|
+
*
|
|
109
|
+
* @example
|
|
110
|
+
* ```typescript
|
|
111
|
+
* const helpers = createAppHelpers({
|
|
112
|
+
* converterContext: myConverterContext,
|
|
113
|
+
* getConfig: getContentfulConfig,
|
|
114
|
+
* buildOptions: (options) => buildFetchOptions(options, draftOnly),
|
|
115
|
+
* });
|
|
116
|
+
*
|
|
117
|
+
* // Use the helpers
|
|
118
|
+
* const pages = await helpers.getAllPageLinks();
|
|
119
|
+
* const page = await helpers.getPageWithErrors('home');
|
|
120
|
+
* const previewProps = helpers.getPreviewFieldIdProps(id, 'title');
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
export declare function createAppHelpers<TPage extends IBasePage = IBasePage, TArticle extends IBaseArticle = IBaseArticle, TArticleType extends IBaseArticleType = IBaseArticleType, TTag extends IBaseTag = IBaseTag, TPerson extends IContentfulPerson = IContentfulPerson, TCustomType extends IBaseCustomType = IBaseCustomType, TCollection extends IContentfulCollection<BaseCollectionContent> = IContentfulCollection<BaseCollectionContent>>(config: AppHelpersConfig): AppHelpers<TPage, TArticle, TArticleType, TTag, TPerson, TCustomType, TCollection>;
|
|
124
|
+
//# sourceMappingURL=app-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-helpers.d.ts","sourceRoot":"","sources":["../src/app-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,YAAY,EACZ,qBAA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C,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;SAChD,GACD,SAAS,CAAC;QACd,wBAAwB,EACpB;YACE,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;YAC/C,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;YAC/C,0BAA0B,EAAE,MAAM,GAAG,SAAS,CAAC;SAChD,GACD,SAAS,CAAC;KACf,CAAC;CACH;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,SAAS,SAAS,GAAG,SAAS,EACnC,QAAQ,SAAS,YAAY,GAAG,YAAY,EAC5C,YAAY,SAAS,gBAAgB,GAAG,gBAAgB,EACxD,IAAI,SAAS,QAAQ,GAAG,QAAQ,EAChC,OAAO,SAAS,iBAAiB,GAAG,iBAAiB,EACrD,WAAW,SAAS,eAAe,GAAG,eAAe,EACrD,WAAW,SACT,qBAAqB,CAAC,qBAAqB,CAAC,GAAG,qBAAqB,CAAC,qBAAqB,CAAC,EAE7F,MAAM,EAAE,gBAAgB,GACvB,UAAU,CAAC,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CA8SpF"}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App-level helper functions for Contentful CMS integration.
|
|
3
|
+
*
|
|
4
|
+
* This module provides a factory function that creates commonly-used helper functions
|
|
5
|
+
* for Next.js apps using the Contentful REST API. These helpers wrap the low-level
|
|
6
|
+
* API functions with project-specific configuration.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* import { createAppHelpers } from '@se-studio/core-ui';
|
|
11
|
+
*
|
|
12
|
+
* const helpers = createAppHelpers({
|
|
13
|
+
* converterContext,
|
|
14
|
+
* getConfig: getContentfulConfig,
|
|
15
|
+
* buildOptions: (options) => buildFetchOptions(options, draftOnly),
|
|
16
|
+
* });
|
|
17
|
+
*
|
|
18
|
+
* export const {
|
|
19
|
+
* getAllPageLinks,
|
|
20
|
+
* getPageWithErrors,
|
|
21
|
+
* getPreviewFieldIdProps,
|
|
22
|
+
* // ... etc
|
|
23
|
+
* } = helpers;
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
import { contentfulAllArticleLinks, contentfulAllArticleTypeLinks, contentfulAllPageLinks, contentfulAllPersonLinks, contentfulAllTagLinks, contentfulArticleRest, contentfulArticleTypeRest, contentfulBannerRest, contentfulCustomTypeRest, contentfulPageRest, contentfulPersonRest, contentfulTagRest, contentfulTemplateRest, } from '@se-studio/contentful-rest-api';
|
|
27
|
+
import { getRelatedArticles as coreGetRelatedArticles, getRelatedPeople as coreGetRelatedPeople, } from './utils/componentUtils';
|
|
28
|
+
import { coreGetPreviewAssetIdProps, coreGetPreviewFieldIdProps, coreGetPreviewParentProps, } from './utils/previewUtils';
|
|
29
|
+
/**
|
|
30
|
+
* Creates a set of helper functions for working with Contentful in Next.js apps.
|
|
31
|
+
*
|
|
32
|
+
* This factory function accepts project-specific configuration and returns
|
|
33
|
+
* a collection of pre-configured helper functions for:
|
|
34
|
+
* - Fetching links (pages, articles, tags, people, article types)
|
|
35
|
+
* - Fetching related content (articles, people)
|
|
36
|
+
* - Fetching full content (pages, articles, article types, tags, people, custom types, templates, banners)
|
|
37
|
+
* - Preview mode utilities (field IDs, asset IDs, parent props)
|
|
38
|
+
*
|
|
39
|
+
* All functions use the provided configuration to automatically handle:
|
|
40
|
+
* - Converter context for transforming Contentful entries
|
|
41
|
+
* - Config selection based on preview mode
|
|
42
|
+
* - Options building with project-specific defaults
|
|
43
|
+
* - Error logging and handling
|
|
44
|
+
*
|
|
45
|
+
* @param config - Configuration object with converter context, config getter, and options builder
|
|
46
|
+
* @returns Object containing all helper functions
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const helpers = createAppHelpers({
|
|
51
|
+
* converterContext: myConverterContext,
|
|
52
|
+
* getConfig: getContentfulConfig,
|
|
53
|
+
* buildOptions: (options) => buildFetchOptions(options, draftOnly),
|
|
54
|
+
* });
|
|
55
|
+
*
|
|
56
|
+
* // Use the helpers
|
|
57
|
+
* const pages = await helpers.getAllPageLinks();
|
|
58
|
+
* const page = await helpers.getPageWithErrors('home');
|
|
59
|
+
* const previewProps = helpers.getPreviewFieldIdProps(id, 'title');
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export function createAppHelpers(config) {
|
|
63
|
+
const { converterContext, getConfig, buildOptions } = config;
|
|
64
|
+
// Determine draft mode from buildOptions behavior
|
|
65
|
+
const testOptions = buildOptions({});
|
|
66
|
+
const draftOnly = testOptions.preview === true;
|
|
67
|
+
/**
|
|
68
|
+
* Generic helper for creating link fetcher functions.
|
|
69
|
+
* Encapsulates the common pattern of building options, fetching, logging errors, and returning data.
|
|
70
|
+
*/
|
|
71
|
+
function createLinksFetcher(fetcher, errorLabel) {
|
|
72
|
+
return (options) => {
|
|
73
|
+
const fullOptions = buildOptions(options);
|
|
74
|
+
return fetcher(converterContext, getConfig(fullOptions.preview), fullOptions).then((response) => {
|
|
75
|
+
if (response.errors.length > 0) {
|
|
76
|
+
console.warn(`Errors occurred while fetching ${errorLabel}:`, response.errors);
|
|
77
|
+
}
|
|
78
|
+
return response.data;
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return {
|
|
83
|
+
// ============================================================================
|
|
84
|
+
// Link Fetchers
|
|
85
|
+
// ============================================================================
|
|
86
|
+
/** Fetch all page links for static params generation and sitemap building */
|
|
87
|
+
getAllPageLinks: createLinksFetcher(contentfulAllPageLinks, 'page links'),
|
|
88
|
+
/** Fetch all article links for static params generation and sitemap building */
|
|
89
|
+
getAllArticleLinks: createLinksFetcher(contentfulAllArticleLinks, 'article links'),
|
|
90
|
+
/** Fetch all tag links for static params generation and sitemap building */
|
|
91
|
+
getAllTagLinks: createLinksFetcher(contentfulAllTagLinks, 'tag links'),
|
|
92
|
+
/** Fetch all person links for static params generation and sitemap building */
|
|
93
|
+
getAllPersonLinks: createLinksFetcher(contentfulAllPersonLinks, 'person links'),
|
|
94
|
+
/** Fetch all article type links for static params generation and sitemap building */
|
|
95
|
+
getAllArticleTypeLinks: createLinksFetcher(contentfulAllArticleTypeLinks, 'article type links'),
|
|
96
|
+
// ============================================================================
|
|
97
|
+
// Related Content Helpers
|
|
98
|
+
// ============================================================================
|
|
99
|
+
/**
|
|
100
|
+
* Get related articles for a collection.
|
|
101
|
+
* Uses the generic core helper with project-specific config.
|
|
102
|
+
*/
|
|
103
|
+
getRelatedArticles(information, contentContext, count, options) {
|
|
104
|
+
const fullOptions = buildOptions(options);
|
|
105
|
+
return coreGetRelatedArticles(information, contentContext, converterContext, getConfig(fullOptions.preview), count, fullOptions);
|
|
106
|
+
},
|
|
107
|
+
/**
|
|
108
|
+
* Get related people for a collection.
|
|
109
|
+
* Uses the generic core helper with project-specific config.
|
|
110
|
+
*/
|
|
111
|
+
getRelatedPeople(information, contentContext, count, options) {
|
|
112
|
+
const fullOptions = buildOptions(options);
|
|
113
|
+
return coreGetRelatedPeople(information, contentContext, converterContext, getConfig(fullOptions.preview), count, fullOptions);
|
|
114
|
+
},
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Content Fetch Functions (with error responses)
|
|
117
|
+
// ============================================================================
|
|
118
|
+
/**
|
|
119
|
+
* Fetch all banners from Contentful (returns full CmsResponse for internal use)
|
|
120
|
+
*
|
|
121
|
+
* @param options - Optional fetch options (preview, cache, locale, retry)
|
|
122
|
+
* @returns Promise resolving to CmsResponse with banners data and any errors
|
|
123
|
+
*
|
|
124
|
+
* @internal This function is for internal use by page rendering logic
|
|
125
|
+
*/
|
|
126
|
+
getBannersWithErrors(options) {
|
|
127
|
+
const fullOptions = buildOptions(options);
|
|
128
|
+
return contentfulBannerRest(converterContext, getConfig(fullOptions.preview), fullOptions);
|
|
129
|
+
},
|
|
130
|
+
/**
|
|
131
|
+
* Fetch a page from Contentful by slug (returns full CmsResponse for internal use)
|
|
132
|
+
*
|
|
133
|
+
* @param slug - The page slug to fetch
|
|
134
|
+
* @param options - Optional fetch options (preview, cache, locale, retry)
|
|
135
|
+
* @returns Promise resolving to CmsResponse with page data and any errors
|
|
136
|
+
*
|
|
137
|
+
* @internal This function is for internal use by page rendering logic
|
|
138
|
+
*/
|
|
139
|
+
getPageWithErrors(slug, options) {
|
|
140
|
+
const fullOptions = buildOptions(options);
|
|
141
|
+
return contentfulPageRest(converterContext, getConfig(fullOptions.preview), slug, fullOptions);
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
* Fetch an article from Contentful by article type slug and article slug (returns full CmsResponse for internal use)
|
|
145
|
+
*
|
|
146
|
+
* @param articleTypeSlug - The article type slug (e.g., 'blog', 'news')
|
|
147
|
+
* @param slug - The article slug to fetch
|
|
148
|
+
* @param options - Optional fetch options (preview, cache, locale, retry)
|
|
149
|
+
* @returns Promise resolving to CmsResponse with article data and any errors
|
|
150
|
+
*
|
|
151
|
+
* @internal This function is for internal use by page rendering logic
|
|
152
|
+
*/
|
|
153
|
+
getArticleWithErrors(articleTypeSlug, slug, options) {
|
|
154
|
+
const fullOptions = buildOptions(options);
|
|
155
|
+
return contentfulArticleRest(converterContext, getConfig(fullOptions.preview), slug, articleTypeSlug, fullOptions);
|
|
156
|
+
},
|
|
157
|
+
/**
|
|
158
|
+
* Fetch an article type from Contentful by slug (returns full CmsResponse for internal use)
|
|
159
|
+
*
|
|
160
|
+
* @param slug - The article type slug (e.g., 'blog', 'news')
|
|
161
|
+
* @param options - Optional fetch options (preview, cache, locale, retry, customType)
|
|
162
|
+
* @returns Promise resolving to CmsResponse with article type data and any errors
|
|
163
|
+
*
|
|
164
|
+
* @internal This function is for internal use by page rendering logic
|
|
165
|
+
*/
|
|
166
|
+
getArticleTypeWithErrors(slug, options) {
|
|
167
|
+
const fullOptions = buildOptions(options);
|
|
168
|
+
return contentfulArticleTypeRest(converterContext, getConfig(fullOptions.preview), slug, fullOptions);
|
|
169
|
+
},
|
|
170
|
+
/**
|
|
171
|
+
* Fetch a tag from Contentful by slug (returns full CmsResponse for internal use)
|
|
172
|
+
*
|
|
173
|
+
* @param slug - The tag slug to fetch
|
|
174
|
+
* @param options - Optional fetch options (preview, cache, locale, retry, customType)
|
|
175
|
+
* @returns Promise resolving to CmsResponse with tag data and any errors
|
|
176
|
+
*
|
|
177
|
+
* @internal This function is for internal use by page rendering logic
|
|
178
|
+
*/
|
|
179
|
+
getTagWithErrors(slug, options) {
|
|
180
|
+
const fullOptions = buildOptions(options);
|
|
181
|
+
return contentfulTagRest(converterContext, getConfig(fullOptions.preview), slug, fullOptions);
|
|
182
|
+
},
|
|
183
|
+
/**
|
|
184
|
+
* Fetch a person from Contentful by slug (returns full CmsResponse for internal use)
|
|
185
|
+
*
|
|
186
|
+
* @param slug - The person slug to fetch
|
|
187
|
+
* @param options - Optional fetch options (preview, cache, locale, retry, customType)
|
|
188
|
+
* @returns Promise resolving to CmsResponse with person data and any errors
|
|
189
|
+
*
|
|
190
|
+
* @internal This function is for internal use by page rendering logic
|
|
191
|
+
*/
|
|
192
|
+
getPersonWithErrors(slug, options) {
|
|
193
|
+
const fullOptions = buildOptions(options);
|
|
194
|
+
return contentfulPersonRest(converterContext, getConfig(fullOptions.preview), slug, fullOptions);
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
* Fetch a custom type from Contentful by slug (returns full CmsResponse for internal use)
|
|
198
|
+
*
|
|
199
|
+
* Custom types represent index pages for categories like Topics or Resources.
|
|
200
|
+
*
|
|
201
|
+
* @param slug - The custom type's slug to fetch (e.g., 'topics', 'resources')
|
|
202
|
+
* @param options - Optional fetch options (preview, cache, locale, retry)
|
|
203
|
+
* @returns Promise resolving to CmsResponse with custom type data and any errors
|
|
204
|
+
*
|
|
205
|
+
* @internal This function is for internal use by page rendering logic
|
|
206
|
+
*/
|
|
207
|
+
getCustomTypeWithErrors(slug, options) {
|
|
208
|
+
const fullOptions = buildOptions(options);
|
|
209
|
+
return contentfulCustomTypeRest(converterContext, getConfig(fullOptions.preview), slug, fullOptions);
|
|
210
|
+
},
|
|
211
|
+
/**
|
|
212
|
+
* Fetch a template from Contentful by cmsLabel (returns full CmsResponse for internal use)
|
|
213
|
+
*
|
|
214
|
+
* Templates are used for shared layouts like the 404 page.
|
|
215
|
+
*
|
|
216
|
+
* @param cmsLabel - The template's cmsLabel to fetch (e.g., '404')
|
|
217
|
+
* @param options - Optional fetch options (preview, cache, locale, retry)
|
|
218
|
+
* @returns Promise resolving to CmsResponse with template data and any errors
|
|
219
|
+
*
|
|
220
|
+
* @internal This function is for internal use by page rendering logic
|
|
221
|
+
*/
|
|
222
|
+
getTemplateWithErrors(cmsLabel, options) {
|
|
223
|
+
const fullOptions = buildOptions(options);
|
|
224
|
+
return contentfulTemplateRest(converterContext, getConfig(fullOptions.preview), cmsLabel, fullOptions);
|
|
225
|
+
},
|
|
226
|
+
// ============================================================================
|
|
227
|
+
// Preview Utilities (wrapped with project draftOnly)
|
|
228
|
+
// ============================================================================
|
|
229
|
+
getPreviewFieldIdProps(id, fieldId) {
|
|
230
|
+
return coreGetPreviewFieldIdProps(id, fieldId, draftOnly);
|
|
231
|
+
},
|
|
232
|
+
getPreviewAssetIdProps(assetId) {
|
|
233
|
+
return coreGetPreviewAssetIdProps(assetId, draftOnly);
|
|
234
|
+
},
|
|
235
|
+
getPreviewParentProps(information) {
|
|
236
|
+
return coreGetPreviewParentProps(information, draftOnly);
|
|
237
|
+
},
|
|
238
|
+
getPreviewResponsiveVisualFieldIdProps(id, visualFieldId = 'visual', mobileVisualFieldId = 'mobileVisual') {
|
|
239
|
+
return {
|
|
240
|
+
visualPreviewProps: coreGetPreviewFieldIdProps(id, visualFieldId, draftOnly),
|
|
241
|
+
mobileVisualPreviewProps: coreGetPreviewFieldIdProps(id, mobileVisualFieldId, draftOnly),
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=app-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-helpers.js","sourceRoot":"","sources":["../src/app-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAaH,OAAO,EACL,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,wBAAwB,EACxB,kBAAkB,EAClB,oBAAoB,EACpB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AAexC,OAAO,EACL,kBAAkB,IAAI,sBAAsB,EAC5C,gBAAgB,IAAI,oBAAoB,GACzC,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EACL,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,GAC1B,MAAM,sBAAsB,CAAC;AAqI9B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,gBAAgB,CAU9B,MAAwB;IAExB,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAE7D,kDAAkD;IAClD,MAAM,WAAW,GAAG,YAAY,CAAC,EAAE,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,WAAW,CAAC,OAAO,KAAK,IAAI,CAAC;IAE/C;;;OAGG;IACH,SAAS,kBAAkB,CACzB,OAAwB,EACxB,UAAkB;QAElB,OAAO,CAAC,OAAsB,EAAE,EAAE;YAChC,MAAM,WAAW,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;YAC1C,OAAO,OAAO,CAAC,gBAAgB,EAAE,SAAS,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC,IAAI,CAChF,CAAC,QAAQ,EAAE,EAAE;gBACX,IAAI,QAAQ,CAAC,MAAM,CAAC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cAAc;YAEpC,OAAO;gBACL,kBAAkB,EAAE,0BAA0B,CAAC,EAAE,EAAE,aAAa,EAAE,SAAS,CAAC;gBAC5E,wBAAwB,EAAE,0BAA0B,CAAC,EAAE,EAAE,mBAAmB,EAAE,SAAS,CAAC;aACzF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ClientMonitor.d.ts","sourceRoot":"","sources":["../../src/components/ClientMonitor.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ClientMonitor.d.ts","sourceRoot":"","sources":["../../src/components/ClientMonitor.tsx"],"names":[],"mappings":"AAybA,UAAU,kBAAkB;IAC1B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,EAAE,CAAC,kBAAkB,CA6BtD,CAAC"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
3
|
import { usePathname } from 'next/navigation';
|
|
4
|
+
import Script from 'next/script';
|
|
3
5
|
import { useEffect } from 'react';
|
|
4
6
|
import { useDocumentVisible } from '../hooks/useDocumentVisible';
|
|
5
7
|
const _observers = new Map();
|
|
@@ -386,6 +388,8 @@ export const ClientMonitor = ({ defaultThreshold = 0.2, enableDebug = false, })
|
|
|
386
388
|
}
|
|
387
389
|
return undefined;
|
|
388
390
|
}, [pathname, isDocumentVisible, roundedDefaultThreshold]);
|
|
389
|
-
return
|
|
391
|
+
return (_jsx(Script, { id: "welcome", strategy: "afterInteractive", children: `
|
|
392
|
+
console.log("%cDesigned and built by Something Else", "font-weight: bold");
|
|
393
|
+
` }));
|
|
390
394
|
};
|
|
391
395
|
//# sourceMappingURL=ClientMonitor.js.map
|