@gxpl/sdk 0.0.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/LICENSE +21 -0
- package/README.md +2 -0
- package/dist/Client/Client.d.ts +32 -0
- package/dist/Client/Client.js +128 -0
- package/dist/Client/Client.test.d.ts +1 -0
- package/dist/Client/__mock__/articleMock.d.ts +2 -0
- package/dist/Client/__mock__/keyframesMock.d.ts +2 -0
- package/dist/Client/__mock__/projectMock.d.ts +2 -0
- package/dist/Components/ControlSlider/ControlSlider.d.ts +91 -0
- package/dist/Components/ControlSlider/ControlSliderComponent.d.ts +519 -0
- package/dist/Components/ImageRevealSlider/ControlImageRevealSliderComponent.d.ts +209 -0
- package/dist/Components/ImageRevealSlider/ImageRevealSlider.d.ts +39 -0
- package/dist/Components/components.d.ts +2 -0
- package/dist/Components/helpers/RichTextRenderer/RichTextRenderer.d.ts +6 -0
- package/dist/Components/helpers/SvgImage/SvgImage.d.ts +9 -0
- package/dist/Components/utils/scalingValue.d.ts +1 -0
- package/dist/FontFaceGenerator/FontFaceGenerator.d.ts +6 -0
- package/dist/FontFaceGenerator/FontFaceGenerator.test.d.ts +1 -0
- package/dist/ScrollPlaybackVideoManager/ScrollPlaybackVideoManager.d.ts +31 -0
- package/dist/VideoDecoder/VideoDecoder.d.ts +12 -0
- package/dist/cli.d.ts +10 -0
- package/dist/cli.js +64 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +2730 -0
- package/dist/index.mjs +2713 -0
- package/dist/schemas/article/Article.schema.d.ts +328 -0
- package/dist/schemas/article/Article.schema.js +11 -0
- package/dist/schemas/article/FillLayer.schema.d.ts +186 -0
- package/dist/schemas/article/FillLayer.schema.js +53 -0
- package/dist/schemas/article/Interaction.schema.d.ts +103 -0
- package/dist/schemas/article/Interaction.schema.js +30 -0
- package/dist/schemas/article/Item.schema.d.ts +40 -0
- package/dist/schemas/article/Item.schema.js +242 -0
- package/dist/schemas/article/ItemArea.schema.d.ts +36 -0
- package/dist/schemas/article/ItemArea.schema.js +17 -0
- package/dist/schemas/article/ItemBase.schema.d.ts +137 -0
- package/dist/schemas/article/ItemBase.schema.js +23 -0
- package/dist/schemas/article/ItemState.schema.d.ts +15723 -0
- package/dist/schemas/article/ItemState.schema.js +75 -0
- package/dist/schemas/article/RichTextItem.schema.d.ts +1372 -0
- package/dist/schemas/article/RichTextItem.schema.js +60 -0
- package/dist/schemas/article/Section.schema.d.ts +176 -0
- package/dist/schemas/article/Section.schema.js +38 -0
- package/dist/schemas/keyframe/Keyframes.schema.d.ts +2000 -0
- package/dist/schemas/keyframe/Keyframes.schema.js +116 -0
- package/dist/schemas/project/Layout.schema.d.ts +17 -0
- package/dist/schemas/project/Layout.schema.js +10 -0
- package/dist/schemas/project/Project.schema.d.ts +253 -0
- package/dist/schemas/project/Project.schema.js +48 -0
- package/dist/schemas/shared/FillLayer.schema.d.ts +186 -0
- package/dist/sdk.css +1 -0
- package/dist/types/article/Article.d.ts +7 -0
- package/dist/types/article/Article.js +2 -0
- package/dist/types/article/ArticleItemType.d.ts +13 -0
- package/dist/types/article/ArticleItemType.js +17 -0
- package/dist/types/article/CompoundSettings.d.ts +6 -0
- package/dist/types/article/CompoundSettings.js +2 -0
- package/dist/types/article/FX.d.ts +23 -0
- package/dist/types/article/FX.js +2 -0
- package/dist/types/article/Interaction.d.ts +28 -0
- package/dist/types/article/Interaction.js +2 -0
- package/dist/types/article/Item.d.ts +250 -0
- package/dist/types/article/Item.js +3 -0
- package/dist/types/article/ItemArea.d.ts +36 -0
- package/dist/types/article/ItemArea.js +31 -0
- package/dist/types/article/ItemState.d.ts +78 -0
- package/dist/types/article/ItemState.js +3 -0
- package/dist/types/article/RichText.d.ts +40 -0
- package/dist/types/article/RichText.js +27 -0
- package/dist/types/article/Section.d.ts +37 -0
- package/dist/types/article/Section.js +8 -0
- package/dist/types/component/Component.d.ts +15 -0
- package/dist/types/keyframe/Keyframe.d.ts +86 -0
- package/dist/types/keyframe/Keyframe.js +21 -0
- package/dist/types/project/Fonts.d.ts +22 -0
- package/dist/types/project/Fonts.js +11 -0
- package/dist/types/project/Layout.d.ts +6 -0
- package/dist/types/project/Layout.js +2 -0
- package/dist/types/project/Meta.d.ts +9 -0
- package/dist/types/project/Meta.js +2 -0
- package/dist/types/project/Page.d.ts +11 -0
- package/dist/types/project/Page.js +2 -0
- package/dist/types/project/Project.d.ts +17 -0
- package/dist/types/project/Project.js +2 -0
- package/dist/utils.d.ts +3 -0
- package/package.json +84 -0
- package/resources/template.scss.ejs +50 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 GX Platform
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { Meta } from '../types/project/Meta';
|
|
2
|
+
import { Project } from '../types/project/Project';
|
|
3
|
+
import { Layout } from '../types/project/Layout';
|
|
4
|
+
import { Article } from '../types/article/Article';
|
|
5
|
+
import { KeyframeAny } from '../types/keyframe/Keyframe';
|
|
6
|
+
export declare class Client {
|
|
7
|
+
private fetchImpl;
|
|
8
|
+
private url;
|
|
9
|
+
constructor(APIUrl: string, fetchImpl?: FetchImpl);
|
|
10
|
+
private static getPageMeta;
|
|
11
|
+
getPageData(pageSlug: string, buildMode?: 'default' | 'self-hosted'): Promise<CntrlPageData>;
|
|
12
|
+
getProjectPagesPaths(): Promise<string[]>;
|
|
13
|
+
getLayouts(): Promise<Layout[]>;
|
|
14
|
+
private fetchProject;
|
|
15
|
+
private fetchArticle;
|
|
16
|
+
private findArticleIdByPageSlug;
|
|
17
|
+
}
|
|
18
|
+
interface FetchImplResponse {
|
|
19
|
+
ok: boolean;
|
|
20
|
+
json(): Promise<any>;
|
|
21
|
+
statusText: string;
|
|
22
|
+
}
|
|
23
|
+
type FetchImpl = (url: string, init?: RequestInit) => Promise<FetchImplResponse>;
|
|
24
|
+
interface ArticleData {
|
|
25
|
+
article: Article;
|
|
26
|
+
keyframes: KeyframeAny[];
|
|
27
|
+
}
|
|
28
|
+
interface CntrlPageData extends ArticleData {
|
|
29
|
+
project: Project;
|
|
30
|
+
meta: Meta;
|
|
31
|
+
}
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Client = void 0;
|
|
16
|
+
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch"));
|
|
17
|
+
const url_1 = require("url");
|
|
18
|
+
const Article_schema_1 = require("../schemas/article/Article.schema");
|
|
19
|
+
const Project_schema_1 = require("../schemas/project/Project.schema");
|
|
20
|
+
const Keyframes_schema_1 = require("../schemas/keyframe/Keyframes.schema");
|
|
21
|
+
class Client {
|
|
22
|
+
constructor(APIUrl, fetchImpl = isomorphic_fetch_1.default) {
|
|
23
|
+
this.fetchImpl = fetchImpl;
|
|
24
|
+
this.url = new url_1.URL(APIUrl);
|
|
25
|
+
if (!this.url.username) {
|
|
26
|
+
throw new Error('Project ID is missing in the URL.');
|
|
27
|
+
}
|
|
28
|
+
if (!this.url.password) {
|
|
29
|
+
throw new Error('API key is missing in the URL.');
|
|
30
|
+
}
|
|
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') {
|
|
44
|
+
try {
|
|
45
|
+
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);
|
|
50
|
+
return {
|
|
51
|
+
project,
|
|
52
|
+
article,
|
|
53
|
+
keyframes,
|
|
54
|
+
meta
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
throw e;
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
}
|
|
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
|
+
getLayouts() {
|
|
74
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
75
|
+
try {
|
|
76
|
+
const { layouts } = yield this.fetchProject();
|
|
77
|
+
return layouts;
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
throw e;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
fetchProject() {
|
|
85
|
+
return __awaiter(this, arguments, void 0, function* (buildMode = 'default') {
|
|
86
|
+
const { username: projectId, password: apiKey, origin } = this.url;
|
|
87
|
+
const url = new url_1.URL(`/projects/${projectId}?buildMode=${buildMode}`, origin);
|
|
88
|
+
const response = yield this.fetchImpl(url.href, {
|
|
89
|
+
headers: {
|
|
90
|
+
Authorization: `Bearer ${apiKey}`
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
if (!response.ok) {
|
|
94
|
+
throw new Error(`Failed to fetch project with id #${projectId}: ${response.statusText}`);
|
|
95
|
+
}
|
|
96
|
+
const data = yield response.json();
|
|
97
|
+
const project = Project_schema_1.ProjectSchema.parse(data);
|
|
98
|
+
return project;
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
fetchArticle(articleId_1) {
|
|
102
|
+
return __awaiter(this, arguments, void 0, function* (articleId, buildMode = 'default') {
|
|
103
|
+
const { username: projectId, password: apiKey, origin } = this.url;
|
|
104
|
+
const url = new url_1.URL(`/projects/${projectId}/articles/${articleId}?buildMode=${buildMode}`, origin);
|
|
105
|
+
const response = yield this.fetchImpl(url.href, {
|
|
106
|
+
headers: {
|
|
107
|
+
Authorization: `Bearer ${apiKey}`
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if (!response.ok) {
|
|
111
|
+
throw new Error(`Failed to fetch article with id #${articleId}: ${response.statusText}`);
|
|
112
|
+
}
|
|
113
|
+
const data = yield response.json();
|
|
114
|
+
const article = Article_schema_1.ArticleSchema.parse(data.article);
|
|
115
|
+
const keyframes = Keyframes_schema_1.KeyframesSchema.parse(data.keyframes);
|
|
116
|
+
return { article, keyframes };
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
findArticleIdByPageSlug(slug, pages) {
|
|
120
|
+
const { username: projectId } = this.url;
|
|
121
|
+
const page = pages.find((page) => page.slug === slug);
|
|
122
|
+
if (!page) {
|
|
123
|
+
throw new Error(`Page with a slug ${slug} was not found in project with id #${projectId}`);
|
|
124
|
+
}
|
|
125
|
+
return page.articleId;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
exports.Client = Client;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
interface SliderProps {
|
|
3
|
+
settings: SliderSettings;
|
|
4
|
+
content: SliderItem[];
|
|
5
|
+
styles: SliderStyles;
|
|
6
|
+
isEditor?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function ControlSlider({ settings, content, styles: sliderStyles, isEditor }: SliderProps): React.JSX.Element;
|
|
9
|
+
type SliderItem = {
|
|
10
|
+
image: {
|
|
11
|
+
url: string;
|
|
12
|
+
name?: string;
|
|
13
|
+
objectFit?: 'cover' | 'contain';
|
|
14
|
+
};
|
|
15
|
+
imageCaption: any[];
|
|
16
|
+
};
|
|
17
|
+
type Offset = {
|
|
18
|
+
x: number;
|
|
19
|
+
y: number;
|
|
20
|
+
};
|
|
21
|
+
type SliderControls = {
|
|
22
|
+
arrowsImgUrl: string | null;
|
|
23
|
+
isActive: boolean;
|
|
24
|
+
color: string;
|
|
25
|
+
hover: string;
|
|
26
|
+
offset: Offset;
|
|
27
|
+
scale: number;
|
|
28
|
+
};
|
|
29
|
+
type SliderPagination = {
|
|
30
|
+
position: 'outside-1' | 'outside-2' | 'inside-1' | 'inside-2';
|
|
31
|
+
isActive: boolean;
|
|
32
|
+
scale: number;
|
|
33
|
+
offset: Offset;
|
|
34
|
+
colors: string[];
|
|
35
|
+
hover: string;
|
|
36
|
+
};
|
|
37
|
+
type Alignment = 'top-left' | 'top-center' | 'top-right' | 'middle-left' | 'middle-center' | 'middle-right' | 'bottom-left' | 'bottom-center' | 'bottom-right';
|
|
38
|
+
type SliderCaption = {
|
|
39
|
+
alignment: Alignment;
|
|
40
|
+
isActive: boolean;
|
|
41
|
+
color: string;
|
|
42
|
+
offset: Offset;
|
|
43
|
+
hover: string;
|
|
44
|
+
};
|
|
45
|
+
type Triggers = {
|
|
46
|
+
triggersList: {
|
|
47
|
+
click: boolean;
|
|
48
|
+
drag: boolean;
|
|
49
|
+
};
|
|
50
|
+
autoPlay: string | null;
|
|
51
|
+
};
|
|
52
|
+
type SliderSettings = {
|
|
53
|
+
controls: SliderControls;
|
|
54
|
+
pagination: SliderPagination;
|
|
55
|
+
direction: 'horiz' | 'vert';
|
|
56
|
+
transition: {
|
|
57
|
+
type: 'slide' | 'fade in';
|
|
58
|
+
duration: string;
|
|
59
|
+
backgroundColor: string | null;
|
|
60
|
+
};
|
|
61
|
+
caption: SliderCaption;
|
|
62
|
+
triggers: Triggers;
|
|
63
|
+
};
|
|
64
|
+
type CaptionStyles = {
|
|
65
|
+
fontSettings: {
|
|
66
|
+
fontFamily: string;
|
|
67
|
+
fontWeight: number;
|
|
68
|
+
fontStyle: string;
|
|
69
|
+
};
|
|
70
|
+
widthSettings: {
|
|
71
|
+
width: number;
|
|
72
|
+
sizing: 'auto' | 'manual';
|
|
73
|
+
};
|
|
74
|
+
letterSpacing: number;
|
|
75
|
+
textAlign: 'left' | 'center' | 'right';
|
|
76
|
+
wordSpacing: number;
|
|
77
|
+
fontSizeLineHeight: {
|
|
78
|
+
fontSize: number;
|
|
79
|
+
lineHeight: number;
|
|
80
|
+
};
|
|
81
|
+
textAppearance: {
|
|
82
|
+
textTransform: 'none' | 'uppercase' | 'lowercase';
|
|
83
|
+
textDecoration: 'none' | 'underline';
|
|
84
|
+
fontVariant: 'normal' | 'small-caps';
|
|
85
|
+
};
|
|
86
|
+
color: string;
|
|
87
|
+
};
|
|
88
|
+
type SliderStyles = {
|
|
89
|
+
caption: CaptionStyles;
|
|
90
|
+
};
|
|
91
|
+
export {};
|