@ethlete/contentful 3.9.0 → 4.0.0-beta.3

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/package.json CHANGED
@@ -1,29 +1,34 @@
1
1
  {
2
2
  "name": "@ethlete/contentful",
3
- "version": "3.9.0",
3
+ "version": "4.0.0-beta.3",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "peerDependencies": {
7
- "@angular/cdk": "20.0.3",
8
- "@angular/common": "20.0.3",
9
- "@angular/core": "20.0.3",
10
- "@contentful/rich-text-types": "17.0.0",
11
- "@ethlete/cdk": "^4.0.3",
12
- "@ethlete/core": "^4.0.3",
13
- "@ethlete/query": "^5.0.3",
14
- "rxjs": "7.8.2"
7
+ "@analogjs/vite-plugin-angular": "2.5.1",
8
+ "@angular/cdk": "21.2.11",
9
+ "@angular/common": "21.2.13",
10
+ "@angular/core": "21.2.13",
11
+ "@angular/router": "21.2.13",
12
+ "@contentful/rich-text-types": "17.2.7",
13
+ "@ethlete/cdk": "^5.0.0-beta.12",
14
+ "@ethlete/core": "^5.0.0-beta.11",
15
+ "@ethlete/query": "^6.0.0-beta.8",
16
+ "@nx/vite": "22.7.2",
17
+ "rxjs": "7.8.2",
18
+ "vite": "8.0.13"
15
19
  },
16
20
  "module": "fesm2022/ethlete-contentful.mjs",
17
- "typings": "index.d.ts",
21
+ "typings": "types/ethlete-contentful.d.ts",
18
22
  "exports": {
19
23
  "./package.json": {
20
24
  "default": "./package.json"
21
25
  },
22
26
  ".": {
23
- "types": "./index.d.ts",
27
+ "types": "./types/ethlete-contentful.d.ts",
24
28
  "default": "./fesm2022/ethlete-contentful.mjs"
25
29
  }
26
30
  },
31
+ "type": "module",
27
32
  "dependencies": {
28
33
  "tslib": "^2.3.0"
29
34
  }
@@ -1,14 +1,15 @@
1
1
  import * as _angular_core from '@angular/core';
2
- import { ComponentRef, ViewContainerRef, Renderer2, ElementRef, InputSignal, InjectionToken } from '@angular/core';
2
+ import { ViewContainerRef, ElementRef, ComponentRef, InputSignal, InjectionToken } from '@angular/core';
3
3
  import { NgClassType } from '@ethlete/core';
4
4
  import * as _ethlete_query from '@ethlete/query';
5
5
  import { ComponentType } from '@angular/cdk/portal';
6
6
  import { Mark, BLOCKS, INLINES, NodeData, Block } from '@contentful/rich-text-types';
7
+ import * as _ethlete_contentful from '@ethlete/contentful';
7
8
  import * as _ethlete_cdk from '@ethlete/cdk';
8
9
  import { PictureSource } from '@ethlete/cdk';
9
10
 
10
11
  declare const GQL_FRAGMENT_CONTENTFUL_ASSET: _ethlete_query.GQL;
11
- interface ContentfulGqlAsset {
12
+ type ContentfulGqlAsset = {
12
13
  sys: {
13
14
  id: string;
14
15
  };
@@ -19,7 +20,7 @@ interface ContentfulGqlAsset {
19
20
  width: number | null;
20
21
  height: number | null;
21
22
  size: number | null;
22
- }
23
+ };
23
24
  declare const isContentfulGqlAsset: (asset: any) => asset is ContentfulGqlAsset;
24
25
  type ContentfulGqlWhereFilter<TLinkedFrom extends Record<string, unknown> = Record<string, unknown>> = {
25
26
  /**
@@ -123,7 +124,7 @@ type HtmlOpenRenderCommand = [
123
124
  domPosition: number,
124
125
  index: number,
125
126
  attributes: Record<string, string>,
126
- tagName: string,
127
+ tagName: keyof HTMLElementTagNameMap,
127
128
  textId: string
128
129
  ];
129
130
  type HtmlCloseRenderCommand = [
@@ -131,7 +132,7 @@ type HtmlCloseRenderCommand = [
131
132
  nestingLevel: number,
132
133
  domPosition: number,
133
134
  index: number,
134
- tagName: string,
135
+ tagName: keyof HTMLElementTagNameMap,
135
136
  elementId: string
136
137
  ];
137
138
  type TextRenderCommand = [
@@ -224,22 +225,59 @@ type ContentfulIncludeMap = {
224
225
  */
225
226
  getAssets: (ids: string[]) => ContentfulRestAsset[];
226
227
  };
227
- interface CreateContentfulIncludeMapConfig {
228
+ type CreateContentfulIncludeMapConfig = {
228
229
  /** The entries that should be present inside the map */
229
230
  entries: ContentfulEntry[];
230
231
  /** The assets that should be present inside the map */
231
232
  assets: ContentfulRestAsset[];
232
- }
233
+ };
233
234
  /**
234
235
  * Create a contentful include map using the provided entries and assets.
235
236
  */
236
237
  declare const createContentfulIncludeMap: (config: CreateContentfulIncludeMapConfig) => ContentfulIncludeMap;
237
238
  declare class ContentfulRichTextRendererComponent {
238
239
  _viewContainerRef: ViewContainerRef;
239
- _renderer: Renderer2;
240
+ _renderer: {
241
+ addClass: (element: HTMLElement, ...classes: string[]) => void;
242
+ removeClass: (element: HTMLElement, ...classes: string[]) => void;
243
+ toggleClass: (element: HTMLElement, className: string, force?: boolean) => boolean;
244
+ setStyle: (element: HTMLElement, style: Partial<Record<keyof CSSStyleDeclaration, string | null>>, flags?: _angular_core.RendererStyleFlags2) => void;
245
+ removeStyle: (element: HTMLElement, style: keyof CSSStyleDeclaration | string, flags?: _angular_core.RendererStyleFlags2) => void;
246
+ removeStyles: (element: HTMLElement, ...styles: (keyof CSSStyleDeclaration | string)[]) => void;
247
+ setAttribute: (element: HTMLElement, name: string, value: string | null, namespace?: string | null) => void;
248
+ removeAttribute: (element: HTMLElement, ...names: string[]) => void;
249
+ setProperty: (element: HTMLElement, name: string, value: unknown) => void;
250
+ setProperties: (element: HTMLElement, properties: Record<string, unknown>) => void;
251
+ createElement: <K extends keyof HTMLElementTagNameMap>(tagName: K, namespace?: string | null) => HTMLElementTagNameMap[K];
252
+ createText: (value: string) => globalThis.Text;
253
+ createComment: (value: string) => Comment;
254
+ appendChild: (parent: HTMLElement, newChild: Node) => void;
255
+ insertBefore: (parent: Node, newChild: Node, refChild: Node | null) => void;
256
+ removeChild: (parent: Node, oldChild: Node, isHostElement?: boolean) => void;
257
+ selectRootElement: (selectorOrNode: string | HTMLElement, preserveContent?: boolean) => HTMLElement;
258
+ parentNode: (node: Node) => Node | null;
259
+ nextSibling: (node: Node) => Node | null;
260
+ setValue: (node: Node, value: string) => void;
261
+ listen: (target: HTMLElement | Window | Document | "window" | "document" | "body", eventName: string, callback: (event: Event) => boolean | void) => (() => void);
262
+ destroyNode: (node: Node) => void;
263
+ replaceChild: (parent: Node, newChild: Node, oldChild: Node) => void;
264
+ empty: (element: HTMLElement) => void;
265
+ setTextContent: (element: HTMLElement, text: string) => void;
266
+ setInnerHTML: (element: HTMLElement, html: string) => void;
267
+ setAttributes: (element: HTMLElement, attributes: Record<string, string | null>, namespace?: string | null) => void;
268
+ setDataAttributes: (element: HTMLElement, data: Record<string, string | null>) => void;
269
+ setCssProperty: (element: HTMLElement, name: string, value: string | null) => void;
270
+ setCssProperties: (element: HTMLElement, properties: Record<string, string | null>) => void;
271
+ moveBefore: (config: {
272
+ newParent: HTMLElement;
273
+ child: HTMLElement;
274
+ before?: Node | null;
275
+ }) => void;
276
+ renderer: _angular_core.Renderer2;
277
+ };
240
278
  _elementRef: ElementRef<HTMLElement>;
241
279
  _document: Document;
242
- _config: ContentfulConfig;
280
+ _config: _ethlete_contentful.ContentfulConfig;
243
281
  /**
244
282
  * A cache for all executed commands that are not deleted.
245
283
  * This is used to keep track of all rendered elements and components.
@@ -286,26 +324,32 @@ declare class ContentfulRichTextRendererComponent {
286
324
  }
287
325
 
288
326
  declare const isRichTextRootNode: (node: unknown) => node is RichTextResponse;
289
- declare const translateContentfulNodeTypeToHtmlTag: (nodeType: "text" | BLOCKS | INLINES) => "document" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "ul" | "ol" | "li" | "hr" | "blockquote" | "table" | "tr" | "td" | "th" | "div" | "a" | "span";
327
+ declare const translateContentfulNodeTypeToHtmlTag: (nodeType: "text" | BLOCKS | INLINES) => "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | "p" | "ul" | "ol" | "li" | "hr" | "blockquote" | "table" | "tr" | "td" | "th" | "div" | "a" | "span";
290
328
 
291
329
  type ContentfulImageResizeBehavior = 'pad' | 'crop' | 'fill' | 'scale' | 'thumb' | 'fit';
292
330
  type ContentfulImageFocusArea = 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right' | 'face' | 'faces';
293
331
  type ComponentLikeWithAsset = ComponentType<{
294
332
  asset: InputSignal<ContentfulRestAsset | ContentfulGqlAsset | null | undefined>;
295
333
  }>;
334
+ type ComponentLikeWithLink = ComponentType<{
335
+ href: InputSignal<string>;
336
+ text: InputSignal<string>;
337
+ textClass: InputSignal<string>;
338
+ }>;
296
339
  type ComponentLikeWithContentfulRendererInputs = ComponentType<{
297
340
  fields?: InputSignal<any>;
298
341
  includes?: InputSignal<ContentfulIncludeMap>;
299
342
  metadata?: InputSignal<ContentfulMetadata>;
300
343
  sys?: InputSignal<ContentfulEntrySys>;
301
344
  }>;
302
- interface ContentfulAssetComponents {
345
+ type ContentfulAssetComponents = {
303
346
  file: ComponentLikeWithAsset;
304
347
  image: ComponentLikeWithAsset;
305
348
  video: ComponentLikeWithAsset;
306
349
  audio: ComponentLikeWithAsset;
307
- }
308
- interface ContentfulConfig {
350
+ link: ComponentLikeWithLink;
351
+ };
352
+ type ContentfulConfig = {
309
353
  /**
310
354
  * Default components for rendering contentful assets
311
355
  */
@@ -318,6 +362,15 @@ interface ContentfulConfig {
318
362
  * Determines if the contentful rich text renderer should render the contentful rich text with tailwind css classes
319
363
  */
320
364
  useTailwindClasses: boolean;
365
+ /**
366
+ * Additional hostnames that should be treated as internal links (in addition to the current page's host).
367
+ * Useful when the app runs on localhost during development but Contentful content references the production domain.
368
+ * Comparison is done by primary domain (last two hostname labels), so adding "example.com" is sufficient
369
+ * to also treat "foo.example.com" as internal.
370
+ *
371
+ * @example ['example.com']
372
+ */
373
+ internalHosts: string[];
321
374
  /**
322
375
  * Default options for the contentful image api
323
376
  */
@@ -343,31 +396,31 @@ interface ContentfulConfig {
343
396
  */
344
397
  backgroundColor: string | null;
345
398
  };
346
- }
399
+ };
347
400
  type ContentfulLinkType = 'Space' | 'ContentType' | 'Environment' | 'Entry' | 'Asset' | 'Tag';
348
- interface ContentfulLink<T extends ContentfulLinkType> {
401
+ type ContentfulLink<T extends ContentfulLinkType> = {
349
402
  type: 'Link';
350
403
  linkType: T;
351
404
  id: string;
352
- }
405
+ };
353
406
  type ContentfulSpaceLink = ContentfulLink<'Space'>;
354
407
  type ContentfulEnvironmentLink = ContentfulLink<'Environment'>;
355
408
  type ContentfulContentTypeLink = ContentfulLink<'ContentType'>;
356
409
  type ContentfulEntryLink = ContentfulLink<'Entry'>;
357
410
  type ContentfulAssetLink = ContentfulLink<'Asset'>;
358
411
  type ContentfulTagLink = ContentfulLink<'Tag'>;
359
- interface ContentfulTagLinkItem {
412
+ type ContentfulTagLinkItem = {
360
413
  sys: ContentfulTagLink;
361
- }
362
- interface ContentfulEntryLinkItem {
414
+ };
415
+ type ContentfulEntryLinkItem = {
363
416
  sys: ContentfulEntryLink;
364
- }
365
- interface ContentfulAssetLinkItem {
417
+ };
418
+ type ContentfulAssetLinkItem = {
366
419
  sys: ContentfulAssetLink;
367
- }
368
- interface ContentfulMetadata {
420
+ };
421
+ type ContentfulMetadata = {
369
422
  tags: ContentfulTagLinkItem[];
370
- }
423
+ };
371
424
  type ContentfulSys = {
372
425
  type: string;
373
426
  id: string;
@@ -387,11 +440,11 @@ type ContentfulEntrySys = ContentfulSys & {
387
440
  sys: ContentfulContentTypeLink;
388
441
  };
389
442
  };
390
- interface ContentfulAssetImageData {
443
+ type ContentfulAssetImageData = {
391
444
  width: number;
392
445
  height: number;
393
- }
394
- interface ContentfulAssetFileData {
446
+ };
447
+ type ContentfulAssetFileData = {
395
448
  url: string | null;
396
449
  details: {
397
450
  size: number | null;
@@ -399,8 +452,8 @@ interface ContentfulAssetFileData {
399
452
  };
400
453
  fileName: string | null;
401
454
  contentType: string | null;
402
- }
403
- interface ContentfulRestAsset {
455
+ };
456
+ type ContentfulRestAsset = {
404
457
  sys: ContentfulSys;
405
458
  fields: {
406
459
  title: string;
@@ -408,15 +461,15 @@ interface ContentfulRestAsset {
408
461
  file: ContentfulAssetFileData;
409
462
  };
410
463
  metadata: ContentfulMetadata;
411
- }
412
- interface ContentfulEntry<T = {
464
+ };
465
+ type ContentfulEntry<T = {
413
466
  [key: string]: any;
414
- }> {
467
+ }> = {
415
468
  sys: ContentfulEntrySys;
416
469
  fields: T;
417
470
  metadata: ContentfulMetadata;
418
- }
419
- interface ContentfulCollection {
471
+ };
472
+ type ContentfulCollection = {
420
473
  includes: {
421
474
  Asset: ContentfulRestAsset[];
422
475
  Entry: ContentfulEntry[];
@@ -428,12 +481,12 @@ interface ContentfulCollection {
428
481
  sys: {
429
482
  type: 'Array';
430
483
  };
431
- }
432
- interface RichTextResponse {
484
+ };
485
+ type RichTextResponse = {
433
486
  nodeType: 'document';
434
487
  data: NodeData;
435
488
  content: Block[];
436
- }
489
+ };
437
490
 
438
491
  declare class ContentfulAudioComponent {
439
492
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
@@ -462,7 +515,7 @@ declare class ContentfulFileComponent {
462
515
  }
463
516
 
464
517
  declare class ContentfulImageComponent {
465
- _contentfulConfig: ContentfulConfig;
518
+ _contentfulConfig: _ethlete_contentful.ContentfulConfig;
466
519
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
467
520
  backgroundColor: _angular_core.InputSignal<string | null>;
468
521
  srcsetSizes: _angular_core.InputSignal<string[]>;
@@ -502,6 +555,20 @@ declare const parseContentfulImageSize: (size: string) => {
502
555
  };
503
556
  declare const generateContentfulImageSources: (data: ContentfulRestAsset | ContentfulGqlAsset, srcsetSizes: string[], backgroundColor: string | null, quality: number | null, focusArea: ContentfulImageFocusArea | null, resizeBehavior: ContentfulImageResizeBehavior | null) => PictureSource[];
504
557
 
558
+ declare class ContentfulLinkComponent {
559
+ private readonly _document;
560
+ private readonly _config;
561
+ href: _angular_core.InputSignal<string>;
562
+ text: _angular_core.InputSignal<string>;
563
+ textClass: _angular_core.InputSignal<string>;
564
+ isExternal: _angular_core.Signal<boolean>;
565
+ openInNewTab: _angular_core.Signal<boolean>;
566
+ internalPath: _angular_core.Signal<string>;
567
+ linkClass: _angular_core.Signal<string>;
568
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulLinkComponent, never>;
569
+ static ɵcmp: _angular_core.ɵɵComponentDeclaration<ContentfulLinkComponent, "et-contentful-link", never, { "href": { "alias": "href"; "required": true; "isSignal": true; }; "text": { "alias": "text"; "required": true; "isSignal": true; }; "textClass": { "alias": "textClass"; "required": false; "isSignal": true; }; }, {}, never, never, true, never>;
570
+ }
571
+
505
572
  declare class ContentfulVideoComponent {
506
573
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
507
574
  videoClass: _angular_core.InputSignal<NgClassType>;
@@ -525,5 +592,5 @@ declare const provideContentfulConfig: (contentfulConfig?: Partial<ContentfulCon
525
592
  };
526
593
  declare const isContentfulEntryType: <T extends ContentfulEntry>(entry: ContentfulEntry, type: string) => entry is T;
527
594
 
528
- export { COMPONENT_RENDER_COMMAND_POSITION, CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulRichTextRendererComponent, ContentfulVideoComponent, ET_CONTENTFUL_ANY_ENTRY_CONTENT_TYPE_SYS_ID, GQL_FRAGMENT_CONTENTFUL_ASSET, HTML_CLOSE_RENDER_COMMAND_POSITION, HTML_OPEN_RENDER_COMMAND_POSITION, RENDER_COMMAND_POSITION, RENDER_COMMAND_TYPE, RENDER_INSTRUCTION_POSITION, RENDER_INSTRUCTION_TYPE, TEXT_RENDER_COMMAND_POSITION, createContentfulConfig, createContentfulIncludeMap, generateContentfulImageSources, generateDefaultContentfulImageSource, getRenderCommandId, isComponentRenderCommand, isContentfulEntryType, isContentfulGqlAsset, isExecutedComponentCommandCacheItem, isExecutedHtmlOrTextCommandCacheItem, isExecutedTextCommandCacheItem, isHtmlCloseRenderCommand, isHtmlOpenRenderCommand, isRichTextRootNode, isTextRenderCommand, marksToClass, parseContentfulImageSize, provideContentfulConfig, translateContentfulNodeTypeToHtmlTag };
529
- export type { ComponentLikeWithAsset, ComponentLikeWithContentfulRendererInputs, ContentfulAssetComponents, ContentfulAssetFileData, ContentfulAssetImageData, ContentfulAssetLink, ContentfulAssetLinkItem, ContentfulCollection, ContentfulConfig, ContentfulContentTypeLink, ContentfulEntry, ContentfulEntryLink, ContentfulEntryLinkItem, ContentfulEntrySys, ContentfulEnvironmentLink, ContentfulGqlAsset, ContentfulGqlCollectionFilterVariables, ContentfulGqlOrder, ContentfulGqlWhereFilter, ContentfulImageFocusArea, ContentfulImageResizeBehavior, ContentfulIncludeMap, ContentfulLink, ContentfulLinkType, ContentfulMetadata, ContentfulRestAsset, ContentfulSpaceLink, ContentfulSys, ContentfulTagLink, ContentfulTagLinkItem, CreateContentfulIncludeMapConfig, RichTextResponse };
595
+ export { COMPONENT_RENDER_COMMAND_POSITION, CONTENTFUL_CONFIG, ContentfulAudioComponent, ContentfulFileComponent, ContentfulImageComponent, ContentfulImports, ContentfulLinkComponent, ContentfulRichTextRendererComponent, ContentfulVideoComponent, ET_CONTENTFUL_ANY_ENTRY_CONTENT_TYPE_SYS_ID, GQL_FRAGMENT_CONTENTFUL_ASSET, HTML_CLOSE_RENDER_COMMAND_POSITION, HTML_OPEN_RENDER_COMMAND_POSITION, RENDER_COMMAND_POSITION, RENDER_COMMAND_TYPE, RENDER_INSTRUCTION_POSITION, RENDER_INSTRUCTION_TYPE, TEXT_RENDER_COMMAND_POSITION, createContentfulConfig, createContentfulIncludeMap, generateContentfulImageSources, generateDefaultContentfulImageSource, getRenderCommandId, isComponentRenderCommand, isContentfulEntryType, isContentfulGqlAsset, isExecutedComponentCommandCacheItem, isExecutedHtmlOrTextCommandCacheItem, isExecutedTextCommandCacheItem, isHtmlCloseRenderCommand, isHtmlOpenRenderCommand, isRichTextRootNode, isTextRenderCommand, marksToClass, parseContentfulImageSize, provideContentfulConfig, translateContentfulNodeTypeToHtmlTag };
596
+ export type { ComponentLikeWithAsset, ComponentLikeWithContentfulRendererInputs, ComponentLikeWithLink, ContentfulAssetComponents, ContentfulAssetFileData, ContentfulAssetImageData, ContentfulAssetLink, ContentfulAssetLinkItem, ContentfulCollection, ContentfulConfig, ContentfulContentTypeLink, ContentfulEntry, ContentfulEntryLink, ContentfulEntryLinkItem, ContentfulEntrySys, ContentfulEnvironmentLink, ContentfulGqlAsset, ContentfulGqlCollectionFilterVariables, ContentfulGqlOrder, ContentfulGqlWhereFilter, ContentfulImageFocusArea, ContentfulImageResizeBehavior, ContentfulIncludeMap, ContentfulLink, ContentfulLinkType, ContentfulMetadata, ContentfulRestAsset, ContentfulSpaceLink, ContentfulSys, ContentfulTagLink, ContentfulTagLinkItem, CreateContentfulIncludeMapConfig, RichTextResponse };