@gxpl/sdk 0.0.54 → 0.0.57

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 (34) hide show
  1. package/lib/sdk/schemas/article/ItemBase.schema.d.ts +180 -10
  2. package/lib/sdk/schemas/article/ItemBase.schema.js +26 -8
  3. package/lib/sdk/schemas/article/RichTextItem.schema.d.ts +76 -6
  4. package/lib/sdk/schemas/project/Project.schema.d.ts +46 -11
  5. package/lib/sdk/schemas/project/Project.schema.js +14 -3
  6. package/lib/sdk/transitions/transitionMachine.d.ts +104 -0
  7. package/lib/sdk/transitions/transitionMachine.js +19 -17
  8. package/lib/sdk/transitions/utils/getInstantTransitionParams.d.ts +36 -0
  9. package/lib/sdk/transitions/utils/getInstantTransitionParams.js +29 -0
  10. package/lib/sdk/transitions/utils/getScenesOnEnd.d.ts +13 -0
  11. package/lib/sdk/transitions/utils/getScenesOnEnd.js +22 -0
  12. package/lib/sdk/transitions/utils/getScenesOnInstantTransition.js +26 -3
  13. package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.d.ts +13 -0
  14. package/lib/sdk/transitions/utils/getScenesOnProgressUpdate.js +7 -0
  15. package/lib/sdk/transitions/utils/getScenesOnStart.d.ts +1 -0
  16. package/lib/sdk/transitions/utils/getScenesOnStart.js +24 -4
  17. package/lib/sdk/transitions/utils/getTransitionFromLink.d.ts +23 -0
  18. package/lib/sdk/transitions/utils/getTransitionFromLink.js +31 -0
  19. package/lib/sdk/transitions/utils/getTransitionFromRelation.d.ts +17 -0
  20. package/lib/sdk/transitions/utils/getTransitionFromRelation.js +26 -0
  21. package/lib/sdk/transitions/utils/getTransitionParams.d.ts +20 -0
  22. package/lib/sdk/transitions/utils/getTransitionParams.js +29 -0
  23. package/lib/sdk/transitions/utils/types.d.ts +56 -14
  24. package/lib/sdk/types/article/Item.d.ts +16 -3
  25. package/lib/sdk/types/project/Relation.d.ts +19 -4
  26. package/lib/sdk-nextjs/components/Preview/Preview.js +4 -7
  27. package/lib/sdk-nextjs/components/Preview/PreviewListener.js +2 -8
  28. package/lib/sdk-nextjs/components/Scene.d.ts +1 -0
  29. package/lib/sdk-nextjs/components/Scene.js +8 -5
  30. package/lib/sdk-nextjs/components/items/LinkWrapper.js +3 -7
  31. package/lib/sdk-nextjs/provider/TransitionMachineContext.d.ts +384 -0
  32. package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.d.ts +1 -0
  33. package/lib/sdk-nextjs/utils/RichTextConverter/RichTextConverter.js +31 -8
  34. package/package.json +1 -1
@@ -6,5 +6,6 @@ export declare class RichTextConverter {
6
6
  private serializeRanges;
7
7
  private normalizeStyles;
8
8
  private groupEntities;
9
+ private getLinkFromEntity;
9
10
  private static fromRangeStylesToInline;
10
11
  }
@@ -13,7 +13,7 @@ exports.FontStyles = {
13
13
  };
14
14
  class RichTextConverter {
15
15
  toHtml(richText, exemplary) {
16
- var _a, _b, _c, _d, _e, _f, _g, _h;
16
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
17
17
  const { text, blocks = [] } = richText.params;
18
18
  const root = [];
19
19
  const styleRules = [];
@@ -76,7 +76,7 @@ class RichTextConverter {
76
76
  continue;
77
77
  }
78
78
  if (entity.value) {
79
- kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: { value: entity.value, animation: (_f = entity.animation) !== null && _f !== void 0 ? _f : 'fade', direction: (_g = entity.direction) !== null && _g !== void 0 ? _g : 'north', duration: 0 }, children: entityKids }, entity.start));
79
+ kids.push((0, jsx_runtime_1.jsx)(LinkWrapper_1.LinkWrapper, { link: Object.assign({ type: 'scene', value: entity.value, animation: (_f = entity.animation) !== null && _f !== void 0 ? _f : 'fade', direction: (_g = entity.direction) !== null && _g !== void 0 ? _g : 'north', duration: (_h = entity.duration) !== null && _h !== void 0 ? _h : 200 }, (entity.animation === 'reveal' ? { offset: (_j = entity.offset) !== null && _j !== void 0 ? _j : 0, mode: (_k = entity.mode) !== null && _k !== void 0 ? _k : 'normal' } : {})), children: entityKids }, entity.start));
80
80
  continue;
81
81
  }
82
82
  kids.push(...entityKids);
@@ -85,7 +85,7 @@ class RichTextConverter {
85
85
  kids.push(sliceSymbols(content, offset));
86
86
  }
87
87
  for (const styles of group) {
88
- const entitiesGroups = (_h = this.groupEntities(entities, styles)) !== null && _h !== void 0 ? _h : [];
88
+ const entitiesGroups = (_l = this.groupEntities(entities, styles)) !== null && _l !== void 0 ? _l : [];
89
89
  for (const entitiesGroup of entitiesGroups) {
90
90
  if (!entitiesGroup.stylesGroup)
91
91
  continue;
@@ -151,7 +151,6 @@ class RichTextConverter {
151
151
  return styleGroups;
152
152
  }
153
153
  groupEntities(entities, styleGroups) {
154
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
155
154
  const entitiesGroups = [];
156
155
  if (!entities.length && !styleGroups)
157
156
  return;
@@ -170,8 +169,8 @@ class RichTextConverter {
170
169
  const start = dividers[i];
171
170
  const end = dividers[i + 1];
172
171
  const entity = entities.find(e => e.start === start);
173
- entitiesGroups.push(Object.assign(Object.assign({ stylesGroup: [], start,
174
- end }, (entity && (((_a = entity.data) === null || _a === void 0 ? void 0 : _a.type) === 'url' || ((_b = entity.data) === null || _b === void 0 ? void 0 : _b.type) === 'anchor') && { link: entity.data.url, target: (_c = entity.data.target) !== null && _c !== void 0 ? _c : '_self' })), (entity && ((_d = entity.data) === null || _d === void 0 ? void 0 : _d.type) === 'scene' && { value: entity.data.value, animation: (_e = entity.data.animation) !== null && _e !== void 0 ? _e : 'fade', direction: (_f = entity.data.direction) !== null && _f !== void 0 ? _f : 'north', duration: (_g = entity.data.duration) !== null && _g !== void 0 ? _g : 0 })));
172
+ entitiesGroups.push(Object.assign({ stylesGroup: [], start,
173
+ end }, this.getLinkFromEntity(entity)));
175
174
  }
176
175
  return entitiesGroups;
177
176
  }
@@ -197,11 +196,35 @@ class RichTextConverter {
197
196
  const start = entityDividers[i];
198
197
  const end = entityDividers[i + 1];
199
198
  const entity = entities.find(e => e.start === start);
200
- entitiesGroups.push(Object.assign(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
201
- end }, (entity && ((_h = entity.data) === null || _h === void 0 ? void 0 : _h.url) && { link: entity.data.url, target: (_j = entity.data.target) !== null && _j !== void 0 ? _j : '_self' })), (entity && ((_k = entity.data) === null || _k === void 0 ? void 0 : _k.value) && { value: entity.data.value, animation: (_l = entity.data.animation) !== null && _l !== void 0 ? _l : 'fade', direction: (_m = entity.data.direction) !== null && _m !== void 0 ? _m : 'north', duration: (_o = entity.data.duration) !== null && _o !== void 0 ? _o : 0 })));
199
+ const link = this.getLinkFromEntity(entity);
200
+ entitiesGroups.push(Object.assign({ stylesGroup: styleGroups.filter(s => s.start >= start && s.end <= end), start,
201
+ end }, link));
202
202
  }
203
203
  return entitiesGroups;
204
204
  }
205
+ getLinkFromEntity(entity) {
206
+ var _a, _b, _c, _d, _e, _f, _g, _h;
207
+ if (!entity)
208
+ return;
209
+ const { data } = entity;
210
+ if (!data)
211
+ return;
212
+ if (data.type === 'url' || data.type === 'anchor') {
213
+ return { url: data.url, target: (_a = data.target) !== null && _a !== void 0 ? _a : '_self' };
214
+ }
215
+ if (data.type === 'scene') {
216
+ if (data.animation === 'fade') {
217
+ return { type: 'scene', value: data.value, animation: 'fade', duration: (_b = data.duration) !== null && _b !== void 0 ? _b : 0 };
218
+ }
219
+ if (data.animation === 'slide') {
220
+ return { type: 'scene', value: data.value, animation: 'slide', direction: (_c = data.direction) !== null && _c !== void 0 ? _c : 'north', duration: (_d = data.duration) !== null && _d !== void 0 ? _d : 0 };
221
+ }
222
+ if (data.animation === 'reveal') {
223
+ return { type: 'scene', value: data.value, animation: 'reveal', direction: (_e = data.direction) !== null && _e !== void 0 ? _e : 'north', offset: (_f = data.offset) !== null && _f !== void 0 ? _f : 0, mode: (_g = data.mode) !== null && _g !== void 0 ? _g : 'normal', duration: (_h = data.duration) !== null && _h !== void 0 ? _h : 0 };
224
+ }
225
+ }
226
+ return;
227
+ }
205
228
  static fromRangeStylesToInline(draftStyle, exemplary) {
206
229
  const { value, name } = draftStyle;
207
230
  const map = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gxpl/sdk",
3
- "version": "0.0.54",
3
+ "version": "0.0.57",
4
4
  "description": "Generic SDK for use in public websites.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",