@ethlete/contentful 3.9.0 → 4.0.0-next.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,26 +1,30 @@
1
1
  {
2
2
  "name": "@ethlete/contentful",
3
- "version": "3.9.0",
3
+ "version": "4.0.0-next.1",
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.3.1",
8
+ "@angular/cdk": "21.2.1",
9
+ "@angular/common": "21.2.1",
10
+ "@angular/core": "21.2.1",
11
+ "@angular/router": "21.2.1",
12
+ "@contentful/rich-text-types": "17.2.5",
13
+ "@ethlete/cdk": "^5.0.0-next.0",
14
+ "@ethlete/core": "^5.0.0-next.0",
15
+ "@ethlete/query": "^6.0.0-next.0",
16
+ "@nx/vite": "22.5.4",
17
+ "rxjs": "7.8.2",
18
+ "vite": "^7.0.0"
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
  },
@@ -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,54 @@ 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
+ renderer: _angular_core.Renderer2;
272
+ };
240
273
  _elementRef: ElementRef<HTMLElement>;
241
274
  _document: Document;
242
- _config: ContentfulConfig;
275
+ _config: _ethlete_contentful.ContentfulConfig;
243
276
  /**
244
277
  * A cache for all executed commands that are not deleted.
245
278
  * This is used to keep track of all rendered elements and components.
@@ -286,26 +319,32 @@ declare class ContentfulRichTextRendererComponent {
286
319
  }
287
320
 
288
321
  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";
322
+ 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
323
 
291
324
  type ContentfulImageResizeBehavior = 'pad' | 'crop' | 'fill' | 'scale' | 'thumb' | 'fit';
292
325
  type ContentfulImageFocusArea = 'top' | 'bottom' | 'left' | 'right' | 'center' | 'top_left' | 'top_right' | 'bottom_left' | 'bottom_right' | 'face' | 'faces';
293
326
  type ComponentLikeWithAsset = ComponentType<{
294
327
  asset: InputSignal<ContentfulRestAsset | ContentfulGqlAsset | null | undefined>;
295
328
  }>;
329
+ type ComponentLikeWithLink = ComponentType<{
330
+ href: InputSignal<string>;
331
+ text: InputSignal<string>;
332
+ textClass: InputSignal<string>;
333
+ }>;
296
334
  type ComponentLikeWithContentfulRendererInputs = ComponentType<{
297
335
  fields?: InputSignal<any>;
298
336
  includes?: InputSignal<ContentfulIncludeMap>;
299
337
  metadata?: InputSignal<ContentfulMetadata>;
300
338
  sys?: InputSignal<ContentfulEntrySys>;
301
339
  }>;
302
- interface ContentfulAssetComponents {
340
+ type ContentfulAssetComponents = {
303
341
  file: ComponentLikeWithAsset;
304
342
  image: ComponentLikeWithAsset;
305
343
  video: ComponentLikeWithAsset;
306
344
  audio: ComponentLikeWithAsset;
307
- }
308
- interface ContentfulConfig {
345
+ link: ComponentLikeWithLink;
346
+ };
347
+ type ContentfulConfig = {
309
348
  /**
310
349
  * Default components for rendering contentful assets
311
350
  */
@@ -318,6 +357,15 @@ interface ContentfulConfig {
318
357
  * Determines if the contentful rich text renderer should render the contentful rich text with tailwind css classes
319
358
  */
320
359
  useTailwindClasses: boolean;
360
+ /**
361
+ * Additional hostnames that should be treated as internal links (in addition to the current page's host).
362
+ * Useful when the app runs on localhost during development but Contentful content references the production domain.
363
+ * Comparison is done by primary domain (last two hostname labels), so adding "example.com" is sufficient
364
+ * to also treat "foo.example.com" as internal.
365
+ *
366
+ * @example ['example.com']
367
+ */
368
+ internalHosts: string[];
321
369
  /**
322
370
  * Default options for the contentful image api
323
371
  */
@@ -343,31 +391,31 @@ interface ContentfulConfig {
343
391
  */
344
392
  backgroundColor: string | null;
345
393
  };
346
- }
394
+ };
347
395
  type ContentfulLinkType = 'Space' | 'ContentType' | 'Environment' | 'Entry' | 'Asset' | 'Tag';
348
- interface ContentfulLink<T extends ContentfulLinkType> {
396
+ type ContentfulLink<T extends ContentfulLinkType> = {
349
397
  type: 'Link';
350
398
  linkType: T;
351
399
  id: string;
352
- }
400
+ };
353
401
  type ContentfulSpaceLink = ContentfulLink<'Space'>;
354
402
  type ContentfulEnvironmentLink = ContentfulLink<'Environment'>;
355
403
  type ContentfulContentTypeLink = ContentfulLink<'ContentType'>;
356
404
  type ContentfulEntryLink = ContentfulLink<'Entry'>;
357
405
  type ContentfulAssetLink = ContentfulLink<'Asset'>;
358
406
  type ContentfulTagLink = ContentfulLink<'Tag'>;
359
- interface ContentfulTagLinkItem {
407
+ type ContentfulTagLinkItem = {
360
408
  sys: ContentfulTagLink;
361
- }
362
- interface ContentfulEntryLinkItem {
409
+ };
410
+ type ContentfulEntryLinkItem = {
363
411
  sys: ContentfulEntryLink;
364
- }
365
- interface ContentfulAssetLinkItem {
412
+ };
413
+ type ContentfulAssetLinkItem = {
366
414
  sys: ContentfulAssetLink;
367
- }
368
- interface ContentfulMetadata {
415
+ };
416
+ type ContentfulMetadata = {
369
417
  tags: ContentfulTagLinkItem[];
370
- }
418
+ };
371
419
  type ContentfulSys = {
372
420
  type: string;
373
421
  id: string;
@@ -387,11 +435,11 @@ type ContentfulEntrySys = ContentfulSys & {
387
435
  sys: ContentfulContentTypeLink;
388
436
  };
389
437
  };
390
- interface ContentfulAssetImageData {
438
+ type ContentfulAssetImageData = {
391
439
  width: number;
392
440
  height: number;
393
- }
394
- interface ContentfulAssetFileData {
441
+ };
442
+ type ContentfulAssetFileData = {
395
443
  url: string | null;
396
444
  details: {
397
445
  size: number | null;
@@ -399,8 +447,8 @@ interface ContentfulAssetFileData {
399
447
  };
400
448
  fileName: string | null;
401
449
  contentType: string | null;
402
- }
403
- interface ContentfulRestAsset {
450
+ };
451
+ type ContentfulRestAsset = {
404
452
  sys: ContentfulSys;
405
453
  fields: {
406
454
  title: string;
@@ -408,15 +456,15 @@ interface ContentfulRestAsset {
408
456
  file: ContentfulAssetFileData;
409
457
  };
410
458
  metadata: ContentfulMetadata;
411
- }
412
- interface ContentfulEntry<T = {
459
+ };
460
+ type ContentfulEntry<T = {
413
461
  [key: string]: any;
414
- }> {
462
+ }> = {
415
463
  sys: ContentfulEntrySys;
416
464
  fields: T;
417
465
  metadata: ContentfulMetadata;
418
- }
419
- interface ContentfulCollection {
466
+ };
467
+ type ContentfulCollection = {
420
468
  includes: {
421
469
  Asset: ContentfulRestAsset[];
422
470
  Entry: ContentfulEntry[];
@@ -428,12 +476,12 @@ interface ContentfulCollection {
428
476
  sys: {
429
477
  type: 'Array';
430
478
  };
431
- }
432
- interface RichTextResponse {
479
+ };
480
+ type RichTextResponse = {
433
481
  nodeType: 'document';
434
482
  data: NodeData;
435
483
  content: Block[];
436
- }
484
+ };
437
485
 
438
486
  declare class ContentfulAudioComponent {
439
487
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
@@ -462,7 +510,7 @@ declare class ContentfulFileComponent {
462
510
  }
463
511
 
464
512
  declare class ContentfulImageComponent {
465
- _contentfulConfig: ContentfulConfig;
513
+ _contentfulConfig: _ethlete_contentful.ContentfulConfig;
466
514
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
467
515
  backgroundColor: _angular_core.InputSignal<string | null>;
468
516
  srcsetSizes: _angular_core.InputSignal<string[]>;
@@ -502,6 +550,20 @@ declare const parseContentfulImageSize: (size: string) => {
502
550
  };
503
551
  declare const generateContentfulImageSources: (data: ContentfulRestAsset | ContentfulGqlAsset, srcsetSizes: string[], backgroundColor: string | null, quality: number | null, focusArea: ContentfulImageFocusArea | null, resizeBehavior: ContentfulImageResizeBehavior | null) => PictureSource[];
504
552
 
553
+ declare class ContentfulLinkComponent {
554
+ private readonly _document;
555
+ private readonly _config;
556
+ href: _angular_core.InputSignal<string>;
557
+ text: _angular_core.InputSignal<string>;
558
+ textClass: _angular_core.InputSignal<string>;
559
+ isExternal: _angular_core.Signal<boolean>;
560
+ openInNewTab: _angular_core.Signal<boolean>;
561
+ internalPath: _angular_core.Signal<string>;
562
+ linkClass: _angular_core.Signal<string>;
563
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<ContentfulLinkComponent, never>;
564
+ 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>;
565
+ }
566
+
505
567
  declare class ContentfulVideoComponent {
506
568
  asset: _angular_core.InputSignal<ContentfulGqlAsset | ContentfulRestAsset | null | undefined>;
507
569
  videoClass: _angular_core.InputSignal<NgClassType>;
@@ -525,5 +587,5 @@ declare const provideContentfulConfig: (contentfulConfig?: Partial<ContentfulCon
525
587
  };
526
588
  declare const isContentfulEntryType: <T extends ContentfulEntry>(entry: ContentfulEntry, type: string) => entry is T;
527
589
 
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 };
590
+ 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 };
591
+ 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 };