@gxpl/sdk 0.0.13 → 0.0.15-0

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 (59) hide show
  1. package/lib/index.d.ts +1 -0
  2. package/lib/sdk/Client/Client.d.ts +3 -7
  3. package/lib/sdk/Client/Client.js +9 -38
  4. package/lib/sdk/schemas/article/Article.schema.d.ts +6 -6
  5. package/lib/sdk/schemas/article/Section.schema.d.ts +6 -6
  6. package/lib/sdk/schemas/project/Project.schema.d.ts +1126 -57
  7. package/lib/sdk/schemas/project/Project.schema.js +33 -11
  8. package/lib/sdk/transitions/transitionMachine.d.ts +616 -0
  9. package/lib/sdk/transitions/transitionMachine.js +258 -0
  10. package/lib/sdk/transitions/utils/findRelation.d.ts +2 -0
  11. package/lib/sdk/transitions/utils/findRelation.js +10 -0
  12. package/lib/sdk/transitions/utils/getAvailableTransitions.d.ts +7 -0
  13. package/lib/sdk/transitions/utils/getAvailableTransitions.js +12 -0
  14. package/lib/sdk/transitions/utils/getAxis.d.ts +2 -0
  15. package/lib/sdk/transitions/utils/getAxis.js +6 -0
  16. package/lib/sdk/transitions/utils/getDeltaAndProgress.d.ts +11 -0
  17. package/lib/sdk/transitions/utils/getDeltaAndProgress.js +13 -0
  18. package/lib/sdk/transitions/utils/getScenesOnEnd.d.ts +21 -0
  19. package/lib/sdk/transitions/utils/getScenesOnEnd.js +30 -0
  20. package/lib/sdk/transitions/utils/getScenesOnInit.d.ts +6 -0
  21. package/lib/sdk/transitions/utils/getScenesOnInit.js +20 -0
  22. package/lib/sdk/transitions/utils/getScenesOnInstantTransition.d.ts +2 -0
  23. package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +38 -0
  24. package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.d.ts +26 -0
  25. package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.js +15 -0
  26. package/lib/sdk/transitions/utils/getScenesOnStart.d.ts +21 -0
  27. package/lib/sdk/transitions/utils/getScenesOnStart.js +52 -0
  28. package/lib/sdk/transitions/utils/isActiveSwipeTransition.d.ts +2 -0
  29. package/lib/sdk/transitions/utils/isActiveSwipeTransition.js +12 -0
  30. package/lib/sdk/transitions/utils/isOverThreshold.d.ts +1 -0
  31. package/lib/sdk/transitions/utils/isOverThreshold.js +6 -0
  32. package/lib/sdk/transitions/utils/isTransitionSuccess.d.ts +2 -0
  33. package/lib/sdk/transitions/utils/isTransitionSuccess.js +15 -0
  34. package/lib/sdk/transitions/utils/normalizeOpacity.d.ts +1 -0
  35. package/lib/sdk/transitions/utils/normalizeOpacity.js +8 -0
  36. package/lib/sdk/transitions/utils/types.d.ts +49 -0
  37. package/lib/sdk/transitions/utils/types.js +2 -0
  38. package/lib/sdk/types/project/FixedLayer.d.ts +27 -0
  39. package/lib/sdk/types/project/FixedLayer.js +2 -0
  40. package/lib/sdk/types/project/Page.d.ts +0 -7
  41. package/lib/sdk/types/project/Project.d.ts +5 -0
  42. package/lib/sdk/types/project/Relation.d.ts +8 -0
  43. package/lib/sdk/types/project/Relation.js +2 -0
  44. package/lib/sdk-nextjs/components/Article.d.ts +9 -2
  45. package/lib/sdk-nextjs/components/Article.js +8 -5
  46. package/lib/sdk-nextjs/components/ArticleWrapper.d.ts +12 -1
  47. package/lib/sdk-nextjs/components/ArticleWrapper.js +155 -2
  48. package/lib/sdk-nextjs/components/Head.d.ts +0 -2
  49. package/lib/sdk-nextjs/components/Head.js +2 -1
  50. package/lib/sdk-nextjs/components/Page.d.ts +4 -7
  51. package/lib/sdk-nextjs/components/Page.js +13 -7
  52. package/lib/sdk-nextjs/components/Scenes/Scenes.d.ts +11 -0
  53. package/lib/sdk-nextjs/components/Scenes/Scenes.js +16 -0
  54. package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +3 -3
  55. package/lib/sdk-nextjs/provider/CntrlSdkContext.d.ts +2 -2
  56. package/lib/sdk-nextjs/provider/CntrlSdkContext.js +4 -2
  57. package/lib/sdk-nextjs/provider/TransitionMachineContext.d.ts +2186 -0
  58. package/lib/sdk-nextjs/provider/TransitionMachineContext.js +6 -0
  59. package/package.json +3 -1
package/lib/index.d.ts CHANGED
@@ -14,6 +14,7 @@ export type { ItemArea } from './sdk/types/article/ItemArea';
14
14
  export type { ItemState, ItemStateParams, StateParams, ItemStatesMap } from './sdk/types/article/ItemState';
15
15
  export type { Interaction, InteractionItemTrigger, InteractionScrollTrigger, InteractionState } from './sdk/types/article/Interaction';
16
16
  export type { Project } from './sdk/types/project/Project';
17
+ export type { TFixedLayer, FixedLayerTransition, TransitionTiming } from './sdk/types/project/FixedLayer';
17
18
  export type { Meta } from './sdk/types/project/Meta';
18
19
  export type { KeyframeValueMap, KeyframeAny } from './sdk/types/keyframe/Keyframe';
19
20
  export type { CompoundSettings } from './sdk/types/article/CompoundSettings';
@@ -1,4 +1,3 @@
1
- import { Meta } from '../types/project/Meta';
2
1
  import { Project } from '../types/project/Project';
3
2
  import { Article } from '../types/article/Article';
4
3
  import { KeyframeAny } from '../types/keyframe/Keyframe';
@@ -6,12 +5,9 @@ export declare class Client {
6
5
  private fetchImpl;
7
6
  private url;
8
7
  constructor(APIUrl: string, fetchImpl?: FetchImpl);
9
- private static getPageMeta;
10
- getPageData(pageSlug: string, buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
11
- getProjectPagesPaths(): Promise<string[]>;
8
+ getPageData(buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
12
9
  private fetchProject;
13
10
  private fetchArticle;
14
- private findArticleIdByPageSlug;
15
11
  }
16
12
  interface FetchImplResponse {
17
13
  ok: boolean;
@@ -23,8 +19,8 @@ interface ArticleData {
23
19
  article: Article;
24
20
  keyframes: KeyframeAny[];
25
21
  }
26
- interface CntrlPageData extends ArticleData {
22
+ interface CntrlPageData {
27
23
  project: Project;
28
- meta: Meta;
24
+ articlesData: Record<string, ArticleData>;
29
25
  }
30
26
  export {};
@@ -29,29 +29,19 @@ class Client {
29
29
  throw new Error('API key is missing in the URL.');
30
30
  }
31
31
  }
32
- static getPageMeta(projectMeta, pageMeta) {
33
- var _a, _b, _c, _d, _e;
34
- return pageMeta.enabled ? {
35
- title: pageMeta.title ? pageMeta.title : (_a = projectMeta.title) !== null && _a !== void 0 ? _a : '',
36
- description: pageMeta.description ? pageMeta.description : (_b = projectMeta.description) !== null && _b !== void 0 ? _b : '',
37
- keywords: pageMeta.keywords ? pageMeta.keywords : (_c = projectMeta.keywords) !== null && _c !== void 0 ? _c : '',
38
- opengraphThumbnail: pageMeta.opengraphThumbnail ? pageMeta.opengraphThumbnail : (_d = projectMeta.opengraphThumbnail) !== null && _d !== void 0 ? _d : '',
39
- favicon: (_e = projectMeta.favicon) !== null && _e !== void 0 ? _e : ''
40
- } : projectMeta;
41
- }
42
- getPageData(pageSlug_1) {
43
- return __awaiter(this, arguments, void 0, function* (pageSlug, buildMode = 'default') {
32
+ getPageData() {
33
+ return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
44
34
  try {
45
35
  const project = yield this.fetchProject(buildMode);
46
- const articleId = this.findArticleIdByPageSlug(pageSlug, project.pages);
47
- const { article, keyframes } = yield this.fetchArticle(articleId, buildMode);
48
- const page = project.pages.find(page => page.slug === pageSlug);
49
- const meta = Client.getPageMeta(project.meta, page === null || page === void 0 ? void 0 : page.meta);
36
+ const articlesIds = project.pages.map(page => page.articleId);
37
+ const articlesDataArr = yield Promise.all(articlesIds.map(articleId => this.fetchArticle(articleId, buildMode)));
38
+ const articlesData = articlesDataArr.reduce((acc, articleData) => {
39
+ acc[articleData.article.id] = articleData;
40
+ return acc;
41
+ }, {});
50
42
  return {
51
43
  project,
52
- article,
53
- keyframes,
54
- meta
44
+ articlesData
55
45
  };
56
46
  }
57
47
  catch (e) {
@@ -59,17 +49,6 @@ class Client {
59
49
  }
60
50
  });
61
51
  }
62
- getProjectPagesPaths() {
63
- return __awaiter(this, void 0, void 0, function* () {
64
- try {
65
- const { pages } = yield this.fetchProject();
66
- return pages.map(p => p.slug);
67
- }
68
- catch (e) {
69
- throw e;
70
- }
71
- });
72
- }
73
52
  fetchProject() {
74
53
  return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
75
54
  const { username: projectId, password: apiKey, origin } = this.url;
@@ -105,13 +84,5 @@ class Client {
105
84
  return { article, keyframes };
106
85
  });
107
86
  }
108
- findArticleIdByPageSlug(slug, pages) {
109
- const { username: projectId } = this.url;
110
- const page = pages.find((page) => page.slug === slug);
111
- if (!page) {
112
- throw new Error(`Page with a slug ${slug} was not found in project with id #${projectId}`);
113
- }
114
- return page.articleId;
115
- }
116
87
  }
117
88
  exports.Client = Client;
@@ -29,17 +29,17 @@ export declare const ArticleSchema: z.ZodObject<{
29
29
  position: z.ZodString;
30
30
  offsetX: z.ZodNullable<z.ZodNumber>;
31
31
  }, "strip", z.ZodTypeAny, {
32
+ play: "on-click" | "auto";
32
33
  url: string;
33
34
  coverUrl: string | null;
34
- play: "on-click" | "auto";
35
35
  position: string;
36
36
  type: "video";
37
37
  size: string;
38
38
  offsetX: number | null;
39
39
  }, {
40
+ play: "on-click" | "auto";
40
41
  url: string;
41
42
  coverUrl: string | null;
42
- play: "on-click" | "auto";
43
43
  position: string;
44
44
  type: "video";
45
45
  size: string;
@@ -75,9 +75,9 @@ export declare const ArticleSchema: z.ZodObject<{
75
75
  items: import("../../..").ItemAny[];
76
76
  name?: string | undefined;
77
77
  media?: {
78
+ play: "on-click" | "auto";
78
79
  url: string;
79
80
  coverUrl: string | null;
80
- play: "on-click" | "auto";
81
81
  position: string;
82
82
  type: "video";
83
83
  size: string;
@@ -101,9 +101,9 @@ export declare const ArticleSchema: z.ZodObject<{
101
101
  items: import("../../..").ItemAny[];
102
102
  name?: string | undefined;
103
103
  media?: {
104
+ play: "on-click" | "auto";
104
105
  url: string;
105
106
  coverUrl: string | null;
106
- play: "on-click" | "auto";
107
107
  position: string;
108
108
  type: "video";
109
109
  size: string;
@@ -232,9 +232,9 @@ export declare const ArticleSchema: z.ZodObject<{
232
232
  items: import("../../..").ItemAny[];
233
233
  name?: string | undefined;
234
234
  media?: {
235
+ play: "on-click" | "auto";
235
236
  url: string;
236
237
  coverUrl: string | null;
237
- play: "on-click" | "auto";
238
238
  position: string;
239
239
  type: "video";
240
240
  size: string;
@@ -283,9 +283,9 @@ export declare const ArticleSchema: z.ZodObject<{
283
283
  items: import("../../..").ItemAny[];
284
284
  name?: string | undefined;
285
285
  media?: {
286
+ play: "on-click" | "auto";
286
287
  url: string;
287
288
  coverUrl: string | null;
288
- play: "on-click" | "auto";
289
289
  position: string;
290
290
  type: "video";
291
291
  size: string;
@@ -22,17 +22,17 @@ export declare const SectionMediaSchema: z.ZodDiscriminatedUnion<"type", [z.ZodO
22
22
  position: z.ZodString;
23
23
  offsetX: z.ZodNullable<z.ZodNumber>;
24
24
  }, "strip", z.ZodTypeAny, {
25
+ play: "on-click" | "auto";
25
26
  url: string;
26
27
  coverUrl: string | null;
27
- play: "on-click" | "auto";
28
28
  position: string;
29
29
  type: "video";
30
30
  size: string;
31
31
  offsetX: number | null;
32
32
  }, {
33
+ play: "on-click" | "auto";
33
34
  url: string;
34
35
  coverUrl: string | null;
35
- play: "on-click" | "auto";
36
36
  position: string;
37
37
  type: "video";
38
38
  size: string;
@@ -84,17 +84,17 @@ export declare const SectionSchema: z.ZodObject<{
84
84
  position: z.ZodString;
85
85
  offsetX: z.ZodNullable<z.ZodNumber>;
86
86
  }, "strip", z.ZodTypeAny, {
87
+ play: "on-click" | "auto";
87
88
  url: string;
88
89
  coverUrl: string | null;
89
- play: "on-click" | "auto";
90
90
  position: string;
91
91
  type: "video";
92
92
  size: string;
93
93
  offsetX: number | null;
94
94
  }, {
95
+ play: "on-click" | "auto";
95
96
  url: string;
96
97
  coverUrl: string | null;
97
- play: "on-click" | "auto";
98
98
  position: string;
99
99
  type: "video";
100
100
  size: string;
@@ -130,9 +130,9 @@ export declare const SectionSchema: z.ZodObject<{
130
130
  items: import("../../..").ItemAny[];
131
131
  name?: string | undefined;
132
132
  media?: {
133
+ play: "on-click" | "auto";
133
134
  url: string;
134
135
  coverUrl: string | null;
135
- play: "on-click" | "auto";
136
136
  position: string;
137
137
  type: "video";
138
138
  size: string;
@@ -156,9 +156,9 @@ export declare const SectionSchema: z.ZodObject<{
156
156
  items: import("../../..").ItemAny[];
157
157
  name?: string | undefined;
158
158
  media?: {
159
+ play: "on-click" | "auto";
159
160
  url: string;
160
161
  coverUrl: string | null;
161
- play: "on-click" | "auto";
162
162
  position: string;
163
163
  type: "video";
164
164
  size: string;