@gxpl/sdk 0.0.13 → 0.0.14
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/lib/sdk/Client/Client.d.ts +3 -7
- package/lib/sdk/Client/Client.js +9 -38
- package/lib/sdk/schemas/project/Project.schema.d.ts +28 -57
- package/lib/sdk/schemas/project/Project.schema.js +7 -10
- package/lib/sdk/transitions/transitionMachine.d.ts +616 -0
- package/lib/sdk/transitions/transitionMachine.js +258 -0
- package/lib/sdk/transitions/utils/findRelation.d.ts +2 -0
- package/lib/sdk/transitions/utils/findRelation.js +10 -0
- package/lib/sdk/transitions/utils/getAvailableTransitions.d.ts +7 -0
- package/lib/sdk/transitions/utils/getAvailableTransitions.js +12 -0
- package/lib/sdk/transitions/utils/getAxis.d.ts +2 -0
- package/lib/sdk/transitions/utils/getAxis.js +6 -0
- package/lib/sdk/transitions/utils/getDeltaAndProgress.d.ts +11 -0
- package/lib/sdk/transitions/utils/getDeltaAndProgress.js +13 -0
- package/lib/sdk/transitions/utils/getScenesOnEnd.d.ts +21 -0
- package/lib/sdk/transitions/utils/getScenesOnEnd.js +30 -0
- package/lib/sdk/transitions/utils/getScenesOnInit.d.ts +6 -0
- package/lib/sdk/transitions/utils/getScenesOnInit.js +20 -0
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.d.ts +2 -0
- package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +38 -0
- package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.d.ts +26 -0
- package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.js +15 -0
- package/lib/sdk/transitions/utils/getScenesOnStart.d.ts +21 -0
- package/lib/sdk/transitions/utils/getScenesOnStart.js +52 -0
- package/lib/sdk/transitions/utils/isActiveSwipeTransition.d.ts +2 -0
- package/lib/sdk/transitions/utils/isActiveSwipeTransition.js +12 -0
- package/lib/sdk/transitions/utils/isOverThreshold.d.ts +1 -0
- package/lib/sdk/transitions/utils/isOverThreshold.js +6 -0
- package/lib/sdk/transitions/utils/isTransitionSuccess.d.ts +2 -0
- package/lib/sdk/transitions/utils/isTransitionSuccess.js +15 -0
- package/lib/sdk/transitions/utils/normalizeOpacity.d.ts +1 -0
- package/lib/sdk/transitions/utils/normalizeOpacity.js +8 -0
- package/lib/sdk/transitions/utils/types.d.ts +49 -0
- package/lib/sdk/transitions/utils/types.js +2 -0
- package/lib/sdk/types/project/Page.d.ts +0 -7
- package/lib/sdk/types/project/Project.d.ts +2 -0
- package/lib/sdk/types/project/Relation.d.ts +8 -0
- package/lib/sdk/types/project/Relation.js +2 -0
- package/lib/sdk-nextjs/components/Article.d.ts +9 -2
- package/lib/sdk-nextjs/components/Article.js +8 -5
- package/lib/sdk-nextjs/components/ArticleWrapper.d.ts +12 -1
- package/lib/sdk-nextjs/components/ArticleWrapper.js +155 -2
- package/lib/sdk-nextjs/components/Head.d.ts +0 -2
- package/lib/sdk-nextjs/components/Head.js +2 -1
- package/lib/sdk-nextjs/components/Page.d.ts +4 -7
- package/lib/sdk-nextjs/components/Page.js +13 -7
- package/lib/sdk-nextjs/components/Scenes/Scenes.d.ts +11 -0
- package/lib/sdk-nextjs/components/Scenes/Scenes.js +16 -0
- package/lib/sdk-nextjs/components/items/RectangleItem/RectangleItem.js +3 -3
- package/lib/sdk-nextjs/provider/CntrlSdkContext.d.ts +2 -2
- package/lib/sdk-nextjs/provider/CntrlSdkContext.js +4 -2
- package/lib/sdk-nextjs/provider/TransitionMachineContext.d.ts +2186 -0
- package/lib/sdk-nextjs/provider/TransitionMachineContext.js +6 -0
- package/package.json +3 -1
|
@@ -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
|
-
|
|
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
|
|
22
|
+
interface CntrlPageData {
|
|
27
23
|
project: Project;
|
|
28
|
-
|
|
24
|
+
articlesData: Record<string, ArticleData>;
|
|
29
25
|
}
|
|
30
26
|
export {};
|
package/lib/sdk/Client/Client.js
CHANGED
|
@@ -29,29 +29,19 @@ class Client {
|
|
|
29
29
|
throw new Error('API key is missing in the URL.');
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
|
|
33
|
-
|
|
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
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
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
|
-
|
|
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;
|
|
@@ -36,53 +36,14 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
36
36
|
}>;
|
|
37
37
|
exemplary: z.ZodNumber;
|
|
38
38
|
pages: z.ZodArray<z.ZodObject<{
|
|
39
|
-
title: z.ZodString;
|
|
40
39
|
articleId: z.ZodString;
|
|
41
|
-
slug: z.ZodString;
|
|
42
|
-
meta: z.ZodOptional<z.ZodObject<{
|
|
43
|
-
title: z.ZodOptional<z.ZodString>;
|
|
44
|
-
description: z.ZodOptional<z.ZodString>;
|
|
45
|
-
opengraphThumbnail: z.ZodOptional<z.ZodString>;
|
|
46
|
-
keywords: z.ZodOptional<z.ZodString>;
|
|
47
|
-
enabled: z.ZodBoolean;
|
|
48
|
-
}, "strip", z.ZodTypeAny, {
|
|
49
|
-
enabled: boolean;
|
|
50
|
-
title?: string | undefined;
|
|
51
|
-
description?: string | undefined;
|
|
52
|
-
opengraphThumbnail?: string | undefined;
|
|
53
|
-
keywords?: string | undefined;
|
|
54
|
-
}, {
|
|
55
|
-
enabled: boolean;
|
|
56
|
-
title?: string | undefined;
|
|
57
|
-
description?: string | undefined;
|
|
58
|
-
opengraphThumbnail?: string | undefined;
|
|
59
|
-
keywords?: string | undefined;
|
|
60
|
-
}>>;
|
|
61
40
|
id: z.ZodString;
|
|
62
41
|
}, "strip", z.ZodTypeAny, {
|
|
63
42
|
id: string;
|
|
64
|
-
title: string;
|
|
65
43
|
articleId: string;
|
|
66
|
-
slug: string;
|
|
67
|
-
meta?: {
|
|
68
|
-
enabled: boolean;
|
|
69
|
-
title?: string | undefined;
|
|
70
|
-
description?: string | undefined;
|
|
71
|
-
opengraphThumbnail?: string | undefined;
|
|
72
|
-
keywords?: string | undefined;
|
|
73
|
-
} | undefined;
|
|
74
44
|
}, {
|
|
75
45
|
id: string;
|
|
76
|
-
title: string;
|
|
77
46
|
articleId: string;
|
|
78
|
-
slug: string;
|
|
79
|
-
meta?: {
|
|
80
|
-
enabled: boolean;
|
|
81
|
-
title?: string | undefined;
|
|
82
|
-
description?: string | undefined;
|
|
83
|
-
opengraphThumbnail?: string | undefined;
|
|
84
|
-
keywords?: string | undefined;
|
|
85
|
-
} | undefined;
|
|
86
47
|
}>, "many">;
|
|
87
48
|
fonts: z.ZodObject<{
|
|
88
49
|
google: z.ZodString;
|
|
@@ -143,6 +104,22 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
143
104
|
google: string;
|
|
144
105
|
adobe: string;
|
|
145
106
|
}>;
|
|
107
|
+
relations: z.ZodArray<z.ZodObject<{
|
|
108
|
+
from: z.ZodString;
|
|
109
|
+
to: z.ZodString;
|
|
110
|
+
type: z.ZodEnum<["slide", "fade"]>;
|
|
111
|
+
direction: z.ZodEnum<["north", "east", "south", "west"]>;
|
|
112
|
+
}, "strip", z.ZodTypeAny, {
|
|
113
|
+
type: "slide" | "fade";
|
|
114
|
+
from: string;
|
|
115
|
+
to: string;
|
|
116
|
+
direction: "north" | "east" | "south" | "west";
|
|
117
|
+
}, {
|
|
118
|
+
type: "slide" | "fade";
|
|
119
|
+
from: string;
|
|
120
|
+
to: string;
|
|
121
|
+
direction: "north" | "east" | "south" | "west";
|
|
122
|
+
}>, "many">;
|
|
146
123
|
}, "strip", z.ZodTypeAny, {
|
|
147
124
|
html: {
|
|
148
125
|
head: string;
|
|
@@ -160,16 +137,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
160
137
|
exemplary: number;
|
|
161
138
|
pages: {
|
|
162
139
|
id: string;
|
|
163
|
-
title: string;
|
|
164
140
|
articleId: string;
|
|
165
|
-
slug: string;
|
|
166
|
-
meta?: {
|
|
167
|
-
enabled: boolean;
|
|
168
|
-
title?: string | undefined;
|
|
169
|
-
description?: string | undefined;
|
|
170
|
-
opengraphThumbnail?: string | undefined;
|
|
171
|
-
keywords?: string | undefined;
|
|
172
|
-
} | undefined;
|
|
173
141
|
}[];
|
|
174
142
|
fonts: {
|
|
175
143
|
custom: {
|
|
@@ -184,6 +152,12 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
184
152
|
google: string;
|
|
185
153
|
adobe: string;
|
|
186
154
|
};
|
|
155
|
+
relations: {
|
|
156
|
+
type: "slide" | "fade";
|
|
157
|
+
from: string;
|
|
158
|
+
to: string;
|
|
159
|
+
direction: "north" | "east" | "south" | "west";
|
|
160
|
+
}[];
|
|
187
161
|
}, {
|
|
188
162
|
html: {
|
|
189
163
|
head: string;
|
|
@@ -201,16 +175,7 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
201
175
|
exemplary: number;
|
|
202
176
|
pages: {
|
|
203
177
|
id: string;
|
|
204
|
-
title: string;
|
|
205
178
|
articleId: string;
|
|
206
|
-
slug: string;
|
|
207
|
-
meta?: {
|
|
208
|
-
enabled: boolean;
|
|
209
|
-
title?: string | undefined;
|
|
210
|
-
description?: string | undefined;
|
|
211
|
-
opengraphThumbnail?: string | undefined;
|
|
212
|
-
keywords?: string | undefined;
|
|
213
|
-
} | undefined;
|
|
214
179
|
}[];
|
|
215
180
|
fonts: {
|
|
216
181
|
custom: {
|
|
@@ -225,4 +190,10 @@ export declare const ProjectSchema: z.ZodObject<{
|
|
|
225
190
|
google: string;
|
|
226
191
|
adobe: string;
|
|
227
192
|
};
|
|
193
|
+
relations: {
|
|
194
|
+
type: "slide" | "fade";
|
|
195
|
+
from: string;
|
|
196
|
+
to: string;
|
|
197
|
+
direction: "north" | "east" | "south" | "west";
|
|
198
|
+
}[];
|
|
228
199
|
}>;
|
|
@@ -19,16 +19,7 @@ exports.ProjectSchema = zod_1.z.object({
|
|
|
19
19
|
}),
|
|
20
20
|
exemplary: zod_1.z.number().positive(),
|
|
21
21
|
pages: zod_1.z.array(zod_1.z.object({
|
|
22
|
-
title: zod_1.z.string(),
|
|
23
22
|
articleId: zod_1.z.string().min(1),
|
|
24
|
-
slug: zod_1.z.string(),
|
|
25
|
-
meta: zod_1.z.object({
|
|
26
|
-
title: zod_1.z.string().optional(),
|
|
27
|
-
description: zod_1.z.string().optional(),
|
|
28
|
-
opengraphThumbnail: zod_1.z.string().optional(),
|
|
29
|
-
keywords: zod_1.z.string().optional(),
|
|
30
|
-
enabled: zod_1.z.boolean()
|
|
31
|
-
}).optional(),
|
|
32
23
|
id: zod_1.z.string().min(1)
|
|
33
24
|
})),
|
|
34
25
|
fonts: zod_1.z.object({
|
|
@@ -43,5 +34,11 @@ exports.ProjectSchema = zod_1.z.object({
|
|
|
43
34
|
url: zod_1.z.string()
|
|
44
35
|
}))
|
|
45
36
|
}))
|
|
46
|
-
})
|
|
37
|
+
}),
|
|
38
|
+
relations: zod_1.z.array(zod_1.z.object({
|
|
39
|
+
from: zod_1.z.string().min(1),
|
|
40
|
+
to: zod_1.z.string().min(1),
|
|
41
|
+
type: zod_1.z.enum(['slide', 'fade']),
|
|
42
|
+
direction: zod_1.z.enum(['north', 'east', 'south', 'west'])
|
|
43
|
+
}))
|
|
47
44
|
});
|