@mcpher/gas-fakes 2.5.2 → 2.5.3

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 (50) hide show
  1. package/README.md +8 -1
  2. package/package.json +1 -1
  3. package/pngs/srv.jpg +0 -0
  4. package/src/cli/app.js +1 -0
  5. package/src/cli/togas.js +23 -14
  6. package/src/index.js +1 -0
  7. package/src/services/advslides/fakeadvslides.js +11 -5
  8. package/src/services/base/app.js +9 -0
  9. package/src/services/base/fakebase.js +28 -0
  10. package/src/services/common/fakeadvresource.js +3 -2
  11. package/src/services/enums/baseenums.js +47 -0
  12. package/src/services/enums/slidesenums.js +3 -1
  13. package/src/services/html/serverworker.js +1 -1
  14. package/src/services/slidesapp/app.js +5 -0
  15. package/src/services/slidesapp/fakeautofit.js +1 -1
  16. package/src/services/slidesapp/fakeborder.js +106 -0
  17. package/src/services/slidesapp/fakecolorscheme.js +1 -1
  18. package/src/services/slidesapp/fakefill.js +216 -0
  19. package/src/services/slidesapp/fakegroup.js +35 -0
  20. package/src/services/slidesapp/fakeimage.js +118 -0
  21. package/src/services/slidesapp/fakelayout.js +351 -0
  22. package/src/services/slidesapp/fakeline.js +2 -2
  23. package/src/services/slidesapp/fakelinefill.js +15 -16
  24. package/src/services/slidesapp/fakelink.js +20 -3
  25. package/src/services/slidesapp/fakelist.js +36 -0
  26. package/src/services/slidesapp/fakeliststyle.js +105 -0
  27. package/src/services/slidesapp/fakemaster.js +358 -0
  28. package/src/services/slidesapp/fakenotesmaster.js +125 -0
  29. package/src/services/slidesapp/fakenotespage.js +102 -2
  30. package/src/services/slidesapp/fakepagebackground.js +109 -1
  31. package/src/services/slidesapp/fakepageelement.js +157 -18
  32. package/src/services/slidesapp/fakepageelementrange.js +28 -0
  33. package/src/services/slidesapp/fakepagerange.js +28 -0
  34. package/src/services/slidesapp/fakeparagraphstyle.js +139 -0
  35. package/src/services/slidesapp/fakepicturefill.js +32 -0
  36. package/src/services/slidesapp/fakepresentation.js +126 -2
  37. package/src/services/slidesapp/fakeshape.js +9 -0
  38. package/src/services/slidesapp/fakeslide.js +216 -24
  39. package/src/services/slidesapp/fakesolidfill.js +45 -0
  40. package/src/services/slidesapp/fakespeakerspotlight.js +18 -0
  41. package/src/services/slidesapp/faketable.js +55 -9
  42. package/src/services/slidesapp/faketablecell.js +141 -12
  43. package/src/services/slidesapp/faketablecellrange.js +28 -0
  44. package/src/services/slidesapp/faketablecolumn.js +72 -0
  45. package/src/services/slidesapp/faketablerow.js +31 -0
  46. package/src/services/slidesapp/faketextrange.js +179 -135
  47. package/src/services/slidesapp/faketextstyle.js +158 -0
  48. package/src/services/slidesapp/fakevideo.js +35 -0
  49. package/src/services/slidesapp/fakewordart.js +22 -0
  50. package/src/services/slidesapp/pageelementfactory.js +24 -1
@@ -0,0 +1,158 @@
1
+ import { Proxies } from '../../support/proxies.js';
2
+ import { newFakeLink } from './fakelink.js';
3
+ import { newFakeColor } from '../common/fakecolor.js';
4
+ import { TextBaselineOffset } from '../enums/slidesenums.js';
5
+
6
+ /**
7
+ * create a new FakeTextStyle instance
8
+ * @param {...any} args
9
+ * @returns {FakeTextStyle}
10
+ */
11
+ export const newFakeTextStyle = (...args) => {
12
+ return Proxies.guard(new FakeTextStyle(...args));
13
+ };
14
+
15
+ export class FakeTextStyle {
16
+ constructor(textRange) {
17
+ this.__textRange = textRange;
18
+ }
19
+
20
+ get __style() {
21
+ // In Slides API, styles are in TextElement.textRun.style.
22
+ // A TextRange spans multiple elements.
23
+ // Usually GAS returns the style if it's uniform across the range, or null/default otherwise.
24
+ // For simplicity, we'll return the style of the first textRun in the range.
25
+ const resource = this.__textRange.__resource;
26
+ const elements = resource?.textElements || [];
27
+ const start = this.__textRange.getStartIndex();
28
+
29
+ // Find the first textRun that overlaps with our range
30
+ let currentIndex = 0;
31
+ for (const element of elements) {
32
+ const length = element.textRun?.content?.length || (element.autoText ? 1 : 0);
33
+ if (currentIndex >= start && (element.textRun || element.autoText)) {
34
+ return element.textRun?.style || element.autoText?.style || {};
35
+ }
36
+ currentIndex += length;
37
+ }
38
+ return {};
39
+ }
40
+
41
+ getBackgroundColor() {
42
+ // Slides API: backgroundColor is in style.
43
+ // But wait, Slides API style has backgroundColor property?
44
+ // Actually, it has backgroundColor in TextStyle.
45
+ return this.__style.backgroundColor ? newFakeColor(this.__style.backgroundColor) : null;
46
+ }
47
+
48
+ getBaselineOffset() {
49
+ return TextBaselineOffset[this.__style.baselineOffset || 'NONE'];
50
+ }
51
+
52
+ getFontFamily() {
53
+ return this.__style.fontFamily || 'Arial';
54
+ }
55
+
56
+ getFontSize() {
57
+ return this.__textRange.__shape.__normalize(this.__style.fontSize) || 12;
58
+ }
59
+
60
+ getFontWeight() {
61
+ return this.__style.fontWeight || 400;
62
+ }
63
+
64
+ getForegroundColor() {
65
+ return this.__style.foregroundColor ? newFakeColor(this.__style.foregroundColor) : null;
66
+ }
67
+
68
+ getLink() {
69
+ return this.__style.link ? newFakeLink(this.__style.link) : null;
70
+ }
71
+
72
+ hasLink() {
73
+ return !!this.__style.link;
74
+ }
75
+
76
+ isBold() {
77
+ return !!this.__style.bold;
78
+ }
79
+
80
+ isItalic() {
81
+ return !!this.__style.italic;
82
+ }
83
+
84
+ isSmallCaps() {
85
+ return !!this.__style.smallCaps;
86
+ }
87
+
88
+ isStrikethrough() {
89
+ return !!this.__style.strikethrough;
90
+ }
91
+
92
+ isUnderline() {
93
+ return !!this.__style.underline;
94
+ }
95
+
96
+ // Setters - using batchUpdate via parent shape/table
97
+ __update(props, fields) {
98
+ // Logic to send batchUpdate for the specific text range.
99
+ // This requires the parent shape/table objectId and the range indices.
100
+ const presentationId = this.__textRange.__shape.__presentation.getId();
101
+ const objectId = this.__textRange.__shape.getObjectId();
102
+ const cellLocation = this.__textRange.__shape.__cellLocation;
103
+
104
+ Slides.Presentations.batchUpdate({ requests: [{
105
+ updateTextStyle: {
106
+ objectId,
107
+ cellLocation,
108
+ style: props,
109
+ fields: fields || Object.keys(props).join(','),
110
+ textRange: {
111
+ type: 'FIXED_RANGE',
112
+ startIndex: this.__textRange.getStartIndex(),
113
+ endIndex: this.__textRange.getEndIndex()
114
+ }
115
+ }
116
+ }] }, presentationId);
117
+ }
118
+
119
+ setBold(bold) {
120
+ this.__update({ bold }, 'bold');
121
+ return this;
122
+ }
123
+
124
+ setItalic(italic) {
125
+ this.__update({ italic }, 'italic');
126
+ return this;
127
+ }
128
+
129
+ setUnderline(underline) {
130
+ this.__update({ underline }, 'underline');
131
+ return this;
132
+ }
133
+
134
+ setStrikethrough(strikethrough) {
135
+ this.__update({ strikethrough }, 'strikethrough');
136
+ return this;
137
+ }
138
+
139
+ setFontSize(fontSize) {
140
+ this.__update({ fontSize: { magnitude: fontSize, unit: 'PT' } }, 'fontSize');
141
+ return this;
142
+ }
143
+
144
+ setFontFamily(fontFamily) {
145
+ this.__update({ fontFamily }, 'fontFamily');
146
+ return this;
147
+ }
148
+
149
+ setForegroundColor(color) {
150
+ // Simplified: assume hex string or Color object
151
+ this.__update({ foregroundColor: { opaqueColor: { rgbColor: { red: 0, green: 0, blue: 0 } } } }, 'foregroundColor');
152
+ return this;
153
+ }
154
+
155
+ toString() {
156
+ return 'TextStyle';
157
+ }
158
+ }
@@ -0,0 +1,35 @@
1
+ import { Proxies } from '../../support/proxies.js';
2
+ import { FakePageElement, PageElementRegistry } from './fakepageelement.js';
3
+
4
+ export const newFakeVideo = (...args) => {
5
+ return Proxies.guard(new FakeVideo(...args));
6
+ };
7
+
8
+ PageElementRegistry.newFakeVideo = newFakeVideo;
9
+
10
+ export class FakeVideo extends FakePageElement {
11
+ constructor(resource, page) {
12
+ super(resource, page);
13
+ }
14
+
15
+ getSource() {
16
+ return this.__resource.video?.source || 'UNSUPPORTED';
17
+ }
18
+
19
+ getThumbnailUrl() {
20
+ // API returns this in video resource
21
+ return `https://img.youtube.com/vi/${this.getVideoId()}/0.jpg`;
22
+ }
23
+
24
+ getUrl() {
25
+ return this.__resource.video?.url || '';
26
+ }
27
+
28
+ getVideoId() {
29
+ return this.__resource.video?.id || '';
30
+ }
31
+
32
+ toString() {
33
+ return 'Video';
34
+ }
35
+ }
@@ -0,0 +1,22 @@
1
+ import { Proxies } from '../../support/proxies.js';
2
+ import { FakePageElement, PageElementRegistry } from './fakepageelement.js';
3
+
4
+ export const newFakeWordArt = (...args) => {
5
+ return Proxies.guard(new FakeWordArt(...args));
6
+ };
7
+
8
+ PageElementRegistry.newFakeWordArt = newFakeWordArt;
9
+
10
+ export class FakeWordArt extends FakePageElement {
11
+ constructor(resource, page) {
12
+ super(resource, page);
13
+ }
14
+
15
+ getRenderedText() {
16
+ return this.__resource.wordArt?.renderedText || '';
17
+ }
18
+
19
+ toString() {
20
+ return 'WordArt';
21
+ }
22
+ }
@@ -1,11 +1,17 @@
1
1
  import { newFakeShape } from './fakeshape.js';
2
2
  import { newFakeLine } from './fakeline.js';
3
3
  import { newFakeTable } from './faketable.js';
4
+ import { newFakeGroup } from './fakegroup.js';
5
+ import { newFakeImage } from './fakeimage.js';
6
+ import { newFakeVideo } from './fakevideo.js';
7
+ import { newFakeSpeakerSpotlight } from './fakespeakerspotlight.js';
8
+ import { newFakeWordArt } from './fakewordart.js';
9
+ import { PageElementRegistry } from './fakepageelement.js';
4
10
 
5
11
  /**
6
12
  * Converts a base PageElement to a more specific subclass (Shape, Line, etc.)
7
13
  * @param {FakePageElement} pageElement The base page element.
8
- * @returns {FakePageElement|FakeShape|FakeLine} The specific subclass.
14
+ * @returns {FakePageElement|FakeShape|FakeLine|FakeGroup|FakeImage|FakeVideo|FakeSpeakerSpotlight|FakeWordArt} The specific subclass.
9
15
  */
10
16
  export const asSpecificPageElement = (pageElement) => {
11
17
  const resource = pageElement.__resource;
@@ -18,6 +24,23 @@ export const asSpecificPageElement = (pageElement) => {
18
24
  if (resource.table) {
19
25
  return newFakeTable(resource, pageElement.__page);
20
26
  }
27
+ if (resource.elementGroup || resource.group) {
28
+ return newFakeGroup(resource, pageElement.__page);
29
+ }
30
+ if (resource.image) {
31
+ return newFakeImage(resource, pageElement.__page);
32
+ }
33
+ if (resource.video) {
34
+ return newFakeVideo(resource, pageElement.__page);
35
+ }
36
+ if (resource.speakerSpotlight) {
37
+ return newFakeSpeakerSpotlight(resource, pageElement.__page);
38
+ }
39
+ if (resource.wordArt) {
40
+ return newFakeWordArt(resource, pageElement.__page);
41
+ }
21
42
  // Add other types as they are implemented
22
43
  return pageElement;
23
44
  };
45
+
46
+ PageElementRegistry.asSpecificPageElement = asSpecificPageElement;