@financial-times/custom-code-component 2.0.1-alpha.9 → 2.0.1-beta.10

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.
Files changed (32) hide show
  1. package/dist/CustomCodeComponent.js +7 -0
  2. package/dist/CustomCodeComponent.js.map +1 -0
  3. package/dist/custom-element.d.ts +114 -0
  4. package/dist/{index.js → custom-element.js} +211 -200
  5. package/dist/custom-element.js.map +1 -0
  6. package/dist/{webcomponent/src/index.d.ts → index.d.ts} +3 -1
  7. package/package.json +11 -6
  8. package/src/custom-code-component.css +11 -0
  9. package/src/custom-code-component.ts +133 -89
  10. package/src/environment.ts +31 -40
  11. package/src/errors.ts +8 -4
  12. package/src/events.ts +1 -1
  13. package/src/path.ts +20 -23
  14. package/dist/index.js.map +0 -1
  15. package/dist/webcomponent/src/custom-code-component.d.ts +0 -55
  16. package/dist/webcomponent/src/environment.d.ts +0 -15
  17. package/dist/webcomponent/src/errors.d.ts +0 -27
  18. package/dist/webcomponent/src/events.d.ts +0 -10
  19. package/dist/webcomponent/src/get-trace.d.ts +0 -8
  20. package/dist/webcomponent/src/logger.d.ts +0 -20
  21. package/dist/webcomponent/src/path.d.ts +0 -23
  22. package/dist/webcomponent/src/tracking.d.ts +0 -32
  23. package/dist/webcomponent/src/util.d.ts +0 -33
  24. package/dist/webcomponent/test/environment.test.d.ts +0 -1
  25. package/dist/webcomponent/test/error-handling.test.d.ts +0 -8
  26. package/dist/webcomponent/test/example.d.ts +0 -11
  27. package/dist/webcomponent/test/generate-readable-stream.d.ts +0 -8
  28. package/dist/webcomponent/test/path.test.d.ts +0 -5
  29. package/dist/webcomponent/test/ssr.test.d.ts +0 -4
  30. package/dist/webcomponent/test/utils.test.d.ts +0 -1
  31. package/dist/webcomponent/vite.config.d.ts +0 -2
  32. package/dist/webcomponent/vitest.config.d.ts +0 -2
@@ -0,0 +1,7 @@
1
+ import { FTCustomCodeComponent as o } from "./custom-element.js";
2
+ const t = () => customElements.define("custom-code-component", o);
3
+ customElements && !customElements.get("custom-code-component") && t();
4
+ export {
5
+ t as init
6
+ };
7
+ //# sourceMappingURL=CustomCodeComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomCodeComponent.js","sources":["../src/index.ts"],"sourcesContent":["import { FTCustomCodeComponent } from \"./custom-code-component\";\n\n// Register the custom element\nexport const init = () =>\n customElements.define(\"custom-code-component\", FTCustomCodeComponent);\n\n// Allows module to be imported multiple times but custom element only registered once\nif (customElements && !customElements.get(\"custom-code-component\")) init();\n"],"names":["init","FTCustomCodeComponent"],"mappings":";AAGO,MAAMA,IAAO,MAClB,eAAe,OAAO,yBAAyBC,CAAqB;AAGlE,kBAAkB,CAAC,eAAe,IAAI,uBAAuB,KAAQD,EAAA;"}
@@ -0,0 +1,114 @@
1
+ import { BaseRenderer } from '../../ccc-sdk/src/renderers/BaseRenderer';
2
+ import { ContentTree } from '@financial-times/content-tree';
3
+
4
+ declare class ComponentPath {
5
+ org: string;
6
+ repo: string;
7
+ name: string;
8
+ versionRange: string;
9
+ constructor(path: ComponentPathType | string);
10
+ set path(path: ComponentPathType | string);
11
+ get path(): string;
12
+ toString(): string;
13
+ static fromString(path: string | null, v?: string | null): ComponentPath;
14
+ }
15
+
16
+ declare type ComponentPathType = {
17
+ org: string;
18
+ repo: string;
19
+ name: string;
20
+ versionRange: string;
21
+ };
22
+
23
+ export declare interface CustomCodeComponent extends ContentTree.Node {
24
+ type: "CustomCodeComponent";
25
+ path: string;
26
+ versionRange: string;
27
+ altText: string;
28
+ lastModified: string;
29
+ fallbackImage?: ContentTree.Image;
30
+ displayFallbackText: boolean;
31
+ layout: "in-line" | "mid-grid" | "full-grid" | "full-bleed";
32
+ attributes: {
33
+ [key: string]: string | boolean | undefined;
34
+ } | {
35
+ children?: CustomCodeComponent | Array<CustomCodeComponent>;
36
+ };
37
+ }
38
+
39
+ declare class FTCustomCodeComponent extends HTMLElement {
40
+ app?: typeof BaseRenderer.prototype.render;
41
+ mode: "closed" | "open";
42
+ RESERVED_ATTRS: Set<string>;
43
+ source?: string;
44
+ tracking?: Tracking;
45
+ component?: ComponentPath;
46
+ log: Logger;
47
+ constructor();
48
+ connectedCallback(): Promise<void>;
49
+ emitError(error: Error): void;
50
+ disconnectedCallback(): void;
51
+ channel: MessageChannel;
52
+ onmessage(): void;
53
+ onunmount(root?: any): void;
54
+ onready(app: Promise<void>): Promise<void>;
55
+ postMessage(event: any): void;
56
+ mount(prerendered?: ShadowRoot | null): Promise<void>;
57
+ unmount(e: Error): void;
58
+ load(): Promise<(shadowRoot: ShadowRoot, attrs: any, ssr?: boolean) => {
59
+ unmount: (root: any) => void;
60
+ onmessage: {
61
+ (...data: any[]): void;
62
+ (message?: any, ...optionalParams: any[]): void;
63
+ };
64
+ ready: Promise<void>;
65
+ }>;
66
+ initTracking: () => Promise<void>;
67
+ }
68
+ export { FTCustomCodeComponent as CCCHTMLElement }
69
+ export { FTCustomCodeComponent }
70
+
71
+ declare class Logger {
72
+ level: number;
73
+ constructor({ level }?: {
74
+ level: number;
75
+ });
76
+ debug(...args: any[]): void;
77
+ log: (...args: any[]) => void;
78
+ info(...args: any[]): void;
79
+ warn(...args: any[]): void;
80
+ error(...args: any[]): void;
81
+ }
82
+
83
+ declare class Tracking {
84
+ cccId: string;
85
+ cccName: string;
86
+ subtype: string;
87
+ teamName: string;
88
+ shadowRoot: ShadowRoot | null;
89
+ category: string;
90
+ elements: string | string[];
91
+ isInitialised: boolean;
92
+ log: Logger;
93
+ constructor({ id, name, subtype, teamName, shadowRoot, category, elements, logger, }: {
94
+ id?: string;
95
+ name: string;
96
+ subtype: string;
97
+ teamName?: string;
98
+ shadowRoot: ShadowRoot | null;
99
+ category?: string;
100
+ elements?: string | string[];
101
+ logger: Logger;
102
+ });
103
+ getEventProperties(event: any): {
104
+ [k: string]: any;
105
+ };
106
+ handleClickEvent(eventData: {
107
+ action: string;
108
+ category: string;
109
+ }, root: Element): (clickEvent: Event, clickElement: HTMLElement) => void;
110
+ sendSpoorEvent(triggerAction: any, extraDetail: any): void;
111
+ init(id: string): void;
112
+ }
113
+
114
+ export { }