ooxml-ui 1.28.0 → 1.29.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.
- package/dist/chart/format-pane-3d.d.ts +1 -0
- package/dist/chart/format-pane-fill-kinds.d.ts +0 -1
- package/dist/chart/format-pane-targets.d.ts +0 -1
- package/dist/chart/format-pane-types.d.ts +0 -1
- package/dist/chart/format-pane-view.d.ts +0 -1
- package/dist/{chunk-2EFIFIPB.js → chunk-LNHFMJ2P.js} +1 -1
- package/dist/{chunk-FHO7TEWA.js → chunk-WYKMVMX4.js} +14 -1
- package/dist/{chunk-WBE2Q5DC.js → chunk-YMZFOG2U.js} +2 -2
- package/dist/comments/mentions.d.ts +63 -0
- package/dist/comments/mentions.d.ts.map +1 -0
- package/dist/form/checkable.d.ts +0 -1
- package/dist/index.js +3 -3
- package/dist/pptx/ai/host.cjs +121 -0
- package/dist/pptx/ai/host.d.ts +39 -0
- package/dist/pptx/ai/host.d.ts.map +1 -0
- package/dist/pptx/ai/host.mjs +4 -0
- package/dist/pptx/ai/index.cjs +120 -870
- package/dist/pptx/ai/index.mjs +6 -842
- package/dist/pptx/{chunk-WBFAVFD4.cjs → chunk-BXCXY4HB.cjs} +722 -279
- package/dist/pptx/{chunk-CT7UD6VL.mjs → chunk-DVLU476S.mjs} +688 -231
- package/dist/pptx/{chunk-MJACF7Y2.mjs → chunk-EHIQ4ANA.mjs} +5 -0
- package/dist/pptx/chunk-IY7H76CZ.cjs +874 -0
- package/dist/pptx/{chunk-GWKTHP6U.cjs → chunk-PATUICO4.cjs} +5 -0
- package/dist/pptx/{chunk-3AFB46RL.cjs → chunk-UTBHXIDK.cjs} +46 -46
- package/dist/pptx/{chunk-7OD74VJC.mjs → chunk-YO3EMGXD.mjs} +2 -2
- package/dist/pptx/chunk-YQANSI3A.mjs +844 -0
- package/dist/pptx/dom/glyph-outline-cache.d.ts +3 -1
- package/dist/pptx/dom/glyph-outline-cache.d.ts.map +1 -1
- package/dist/pptx/dom/index.cjs +399 -398
- package/dist/pptx/dom/index.mjs +15 -14
- package/dist/pptx/dom/load-presentation.d.ts +7 -1
- package/dist/pptx/dom/load-presentation.d.ts.map +1 -1
- package/dist/pptx/export/html2canvas-clone.cjs +4 -4
- package/dist/pptx/export/html2canvas-clone.mjs +1 -1
- package/dist/pptx/export/print-document.cjs +18 -18
- package/dist/pptx/export/print-document.mjs +2 -2
- package/dist/pptx/i18n/index.cjs +6 -6
- package/dist/pptx/i18n/index.mjs +1 -1
- package/dist/pptx/i18n/translations-en.d.ts.map +1 -1
- package/dist/pptx/index.cjs +3185 -3161
- package/dist/pptx/index.mjs +9 -9
- package/dist/pptx/render/comment-mentions.d.ts +16 -1
- package/dist/pptx/render/comment-mentions.d.ts.map +1 -1
- package/dist/pptx/render/comments-list.d.ts +11 -7
- package/dist/pptx/render/comments-list.d.ts.map +1 -1
- package/dist/pptx/render/embedded-font-trust.d.ts +7 -0
- package/dist/pptx/render/embedded-font-trust.d.ts.map +1 -1
- package/dist/pptx/render/embedded-fonts.d.ts +4 -3
- package/dist/pptx/render/embedded-fonts.d.ts.map +1 -1
- package/dist/pptx/render/glyph-outline-font-registration.d.ts +83 -0
- package/dist/pptx/render/glyph-outline-font-registration.d.ts.map +1 -0
- package/dist/pptx/render/index.d.ts +2 -0
- package/dist/pptx/render/index.d.ts.map +1 -1
- package/dist/pptx/render/load-limits.d.ts +18 -0
- package/dist/pptx/render/load-limits.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts +39 -0
- package/dist/pptx/render/text-warp-glyph-outline-lookup.d.ts.map +1 -0
- package/dist/pptx/render/text-warp-opentype-parser.d.ts +15 -2
- package/dist/pptx/render/text-warp-opentype-parser.d.ts.map +1 -1
- package/dist/pptx/render/text-warp-outline-font-cache.d.ts +116 -42
- package/dist/pptx/render/text-warp-outline-font-cache.d.ts.map +1 -1
- package/dist/pptx/render/viewer-props-manifest.d.ts.map +1 -1
- package/dist/pptx/{smartart-insert-preview-3BY6HNZL.cjs → smartart-insert-preview-DHQ47GXP.cjs} +11 -11
- package/dist/pptx/{smartart-insert-preview-7CRBDPYF.mjs → smartart-insert-preview-IQVC5LMF.mjs} +10 -10
- package/dist/{presentation-preview-KY56TONW.js → presentation-preview-XGJMARKI.js} +1 -1
- package/dist/teams/app/presentation-preview.d.ts +3 -0
- package/dist/teams.js +2 -2
- package/dist/xlsx.js +4 -4
- package/package.json +8 -8
- package/dist/pptx/{chunk-YMITEJST.cjs → chunk-3CYWRMYZ.cjs} +1 -1
- package/dist/pptx/{chunk-3LOVEO7U.mjs → chunk-5VSUIPDX.mjs} +1 -1
- /package/dist/pptx/{chunk-FM4C4MBJ.cjs → chunk-67UQWOEQ.cjs} +0 -0
- /package/dist/pptx/{chunk-AMW2AR7J.mjs → chunk-6MZFWTBS.mjs} +0 -0
package/dist/pptx/ai/index.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var chunkIY7H76CZ_cjs = require('../chunk-IY7H76CZ.cjs');
|
|
3
4
|
var chunkA5MANNJR_cjs = require('../chunk-A5MANNJR.cjs');
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
require('../chunk-Y6DO6SVT.cjs');
|
|
6
|
+
require('../chunk-PBZWDEXQ.cjs');
|
|
6
7
|
var pptx = require('ooxml-core/pptx');
|
|
7
8
|
var zod = require('zod');
|
|
8
9
|
var tableMerge = require('ooxml-core/pptx/editor/ai/table-merge');
|
|
@@ -50,446 +51,6 @@ function resetAiSdkCache() {
|
|
|
50
51
|
cached = void 0;
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
// src/pptx/ai/deck-data-diff.ts
|
|
54
|
-
function deckDataFieldChanged(a, b) {
|
|
55
|
-
return JSON.stringify(a) !== JSON.stringify(b);
|
|
56
|
-
}
|
|
57
|
-
function applyElementUpdate(el, u) {
|
|
58
|
-
if (u.x !== void 0) {
|
|
59
|
-
el.x = u.x;
|
|
60
|
-
}
|
|
61
|
-
if (u.y !== void 0) {
|
|
62
|
-
el.y = u.y;
|
|
63
|
-
}
|
|
64
|
-
if (u.width !== void 0) {
|
|
65
|
-
el.width = u.width;
|
|
66
|
-
}
|
|
67
|
-
if (u.height !== void 0) {
|
|
68
|
-
el.height = u.height;
|
|
69
|
-
}
|
|
70
|
-
if (u.rotation !== void 0) {
|
|
71
|
-
el.rotation = u.rotation;
|
|
72
|
-
}
|
|
73
|
-
if (u.opacity !== void 0) {
|
|
74
|
-
el.opacity = u.opacity;
|
|
75
|
-
}
|
|
76
|
-
if (u.hidden !== void 0) {
|
|
77
|
-
el.hidden = u.hidden;
|
|
78
|
-
}
|
|
79
|
-
if (u.flipHorizontal !== void 0) {
|
|
80
|
-
el.flipHorizontal = u.flipHorizontal;
|
|
81
|
-
}
|
|
82
|
-
if (u.flipVertical !== void 0) {
|
|
83
|
-
el.flipVertical = u.flipVertical;
|
|
84
|
-
}
|
|
85
|
-
applyTextUpdate(el, u);
|
|
86
|
-
applyShapeStyleUpdate(el, u);
|
|
87
|
-
}
|
|
88
|
-
function applyTextUpdate(el, u) {
|
|
89
|
-
if (!pptx.hasTextProperties(el)) {
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
const textEl = el;
|
|
93
|
-
if (u.text !== void 0) {
|
|
94
|
-
textEl.text = u.text;
|
|
95
|
-
if (textEl.textSegments && textEl.textSegments.length > 0) {
|
|
96
|
-
textEl.textSegments[0].text = u.text;
|
|
97
|
-
} else {
|
|
98
|
-
textEl.textSegments = [{ text: u.text, style: {} }];
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
if (u.fontSize === void 0 && u.fontFamily === void 0 && u.fontColor === void 0 && u.bold === void 0 && u.italic === void 0 && u.underline === void 0 && u.align === void 0) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
const textStyle = {};
|
|
105
|
-
if (u.fontSize !== void 0) {
|
|
106
|
-
textStyle.fontSize = u.fontSize;
|
|
107
|
-
}
|
|
108
|
-
if (u.fontFamily !== void 0) {
|
|
109
|
-
textStyle.fontFamily = u.fontFamily;
|
|
110
|
-
}
|
|
111
|
-
if (u.fontColor !== void 0) {
|
|
112
|
-
textStyle.color = u.fontColor;
|
|
113
|
-
}
|
|
114
|
-
if (u.bold !== void 0) {
|
|
115
|
-
textStyle.bold = u.bold;
|
|
116
|
-
}
|
|
117
|
-
if (u.italic !== void 0) {
|
|
118
|
-
textStyle.italic = u.italic;
|
|
119
|
-
}
|
|
120
|
-
if (u.underline !== void 0) {
|
|
121
|
-
textStyle.underline = u.underline;
|
|
122
|
-
}
|
|
123
|
-
if (u.align !== void 0) {
|
|
124
|
-
textStyle.align = u.align;
|
|
125
|
-
}
|
|
126
|
-
textEl.textStyle = { ...textEl.textStyle, ...textStyle };
|
|
127
|
-
if (textEl.textSegments) {
|
|
128
|
-
textEl.textSegments = textEl.textSegments.map((seg) => chunkPBZWDEXQ_cjs.updateTextSegmentStyle(seg, textStyle));
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function applyShapeStyleUpdate(el, u) {
|
|
132
|
-
if (u.fillColor === void 0 && u.strokeColor === void 0 && u.strokeWidth === void 0) {
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
if (!pptx.hasShapeProperties(el)) {
|
|
136
|
-
return;
|
|
137
|
-
}
|
|
138
|
-
const holder = el;
|
|
139
|
-
holder.shapeStyle ??= {};
|
|
140
|
-
const style = holder.shapeStyle;
|
|
141
|
-
if (u.fillColor !== void 0) {
|
|
142
|
-
style.fillColor = u.fillColor;
|
|
143
|
-
}
|
|
144
|
-
if (u.strokeColor !== void 0) {
|
|
145
|
-
style.strokeColor = u.strokeColor;
|
|
146
|
-
}
|
|
147
|
-
if (u.strokeWidth !== void 0) {
|
|
148
|
-
style.strokeWidth = u.strokeWidth;
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// src/pptx/ai/bridge-factory.ts
|
|
153
|
-
var TITLE_MAX_LENGTH = 120;
|
|
154
|
-
function pptxAiDeckTitle(slides) {
|
|
155
|
-
for (const element of slides[0]?.elements ?? []) {
|
|
156
|
-
const text = "text" in element && typeof element.text === "string" ? element.text.trim() : "";
|
|
157
|
-
if (text) {
|
|
158
|
-
return text.slice(0, TITLE_MAX_LENGTH);
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
return void 0;
|
|
162
|
-
}
|
|
163
|
-
function copy(list) {
|
|
164
|
-
return list ? [...list] : void 0;
|
|
165
|
-
}
|
|
166
|
-
function readDeckData(port) {
|
|
167
|
-
const canvas = port.getCanvasSize();
|
|
168
|
-
return {
|
|
169
|
-
slides: [...port.getSlides()],
|
|
170
|
-
width: canvas.width,
|
|
171
|
-
height: canvas.height,
|
|
172
|
-
theme: port.getTheme(),
|
|
173
|
-
sections: copy(port.getSections()),
|
|
174
|
-
presentationProperties: port.getPresentationProperties(),
|
|
175
|
-
customProperties: copy(port.getCustomProperties()),
|
|
176
|
-
coreProperties: port.getCoreProperties(),
|
|
177
|
-
appProperties: port.getAppProperties(),
|
|
178
|
-
viewProperties: port.getViewProperties(),
|
|
179
|
-
tableStyleMap: port.getTableStyleMap(),
|
|
180
|
-
tableStylesDefaultId: port.getTableStylesDefaultId(),
|
|
181
|
-
tags: copy(port.getTagCollections())
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
function commitDocumentProperties(port, before, after) {
|
|
185
|
-
const differs = deckDataFieldChanged;
|
|
186
|
-
const core = after.coreProperties ?? before.coreProperties;
|
|
187
|
-
const app = after.appProperties ?? before.appProperties;
|
|
188
|
-
const custom = after.customProperties ?? before.customProperties ?? [];
|
|
189
|
-
const coreChanged = differs(before.coreProperties, core);
|
|
190
|
-
if (!coreChanged && !differs(before.appProperties, app) && !differs(before.customProperties, custom)) {
|
|
191
|
-
return false;
|
|
192
|
-
}
|
|
193
|
-
port.setDocumentProperties(core ?? {}, app ?? {}, custom);
|
|
194
|
-
if (coreChanged && core) {
|
|
195
|
-
port.onCorePropertiesChanged?.(core);
|
|
196
|
-
}
|
|
197
|
-
return true;
|
|
198
|
-
}
|
|
199
|
-
function commitDeckData(port, before, after, label) {
|
|
200
|
-
const differs = deckDataFieldChanged;
|
|
201
|
-
let changed = false;
|
|
202
|
-
if (differs(before.slides, after.slides)) {
|
|
203
|
-
port.updateSlides(() => after.slides, label);
|
|
204
|
-
changed = true;
|
|
205
|
-
}
|
|
206
|
-
if (before.width !== after.width || before.height !== after.height) {
|
|
207
|
-
port.setCanvasSize({ width: after.width, height: after.height });
|
|
208
|
-
changed = true;
|
|
209
|
-
}
|
|
210
|
-
const sections = after.sections ?? before.sections ?? [];
|
|
211
|
-
if (differs(before.sections, sections)) {
|
|
212
|
-
port.setSections(sections);
|
|
213
|
-
changed = true;
|
|
214
|
-
}
|
|
215
|
-
const presentation = after.presentationProperties ?? before.presentationProperties ?? {};
|
|
216
|
-
if (differs(before.presentationProperties, presentation)) {
|
|
217
|
-
port.setPresentationProperties(presentation);
|
|
218
|
-
changed = true;
|
|
219
|
-
}
|
|
220
|
-
changed = commitDocumentProperties(port, before, after) || changed;
|
|
221
|
-
if (differs(before.viewProperties, after.viewProperties)) {
|
|
222
|
-
port.setViewProperties(after.viewProperties);
|
|
223
|
-
changed = true;
|
|
224
|
-
}
|
|
225
|
-
if (differs(before.tableStyleMap, after.tableStyleMap)) {
|
|
226
|
-
port.setTableStyleMap(after.tableStyleMap ?? {});
|
|
227
|
-
changed = true;
|
|
228
|
-
}
|
|
229
|
-
if (differs(before.tableStylesDefaultId, after.tableStylesDefaultId)) {
|
|
230
|
-
port.setTableStylesDefaultId(after.tableStylesDefaultId);
|
|
231
|
-
changed = true;
|
|
232
|
-
}
|
|
233
|
-
const tags = after.tags ?? before.tags ?? [];
|
|
234
|
-
if (differs(before.tags, tags)) {
|
|
235
|
-
port.setTagCollections(tags);
|
|
236
|
-
changed = true;
|
|
237
|
-
}
|
|
238
|
-
return changed;
|
|
239
|
-
}
|
|
240
|
-
function createPptxAiBridge(port) {
|
|
241
|
-
const applySlidesUpdate = (updater, label) => {
|
|
242
|
-
port.updateSlides((current) => updater(structuredClone([...current])), label);
|
|
243
|
-
};
|
|
244
|
-
const bridge = {
|
|
245
|
-
getDeckMeta() {
|
|
246
|
-
const slides = port.getSlides();
|
|
247
|
-
const canvas = port.getCanvasSize();
|
|
248
|
-
return {
|
|
249
|
-
slideCount: slides.length,
|
|
250
|
-
activeSlideIndex: port.getActiveSlideIndex(),
|
|
251
|
-
title: port.getFileName?.() ?? pptxAiDeckTitle(slides),
|
|
252
|
-
width: canvas.width,
|
|
253
|
-
height: canvas.height
|
|
254
|
-
};
|
|
255
|
-
},
|
|
256
|
-
getSlides: () => [...port.getSlides()],
|
|
257
|
-
getActiveSlideIndex: () => port.getActiveSlideIndex(),
|
|
258
|
-
getTheme: () => port.getTheme(),
|
|
259
|
-
getHandler: () => port.getHandler() ?? void 0,
|
|
260
|
-
goToSlide: (index) => port.goToSlide(index),
|
|
261
|
-
selectElements: (slideIndex2, elementIds) => port.selectElements(slideIndex2, elementIds),
|
|
262
|
-
applySlidesUpdate,
|
|
263
|
-
updateElement(slideIndex2, elementId2, updates) {
|
|
264
|
-
applySlidesUpdate((slides) => {
|
|
265
|
-
const element = slides[slideIndex2]?.elements.find((el) => el.id === elementId2);
|
|
266
|
-
if (element) {
|
|
267
|
-
applyElementUpdate(element, updates);
|
|
268
|
-
}
|
|
269
|
-
return slides;
|
|
270
|
-
}, `Update element ${elementId2}`);
|
|
271
|
-
},
|
|
272
|
-
applyTheme: (updates) => port.applyTheme(updates),
|
|
273
|
-
getDeckData: () => readDeckData(port),
|
|
274
|
-
applyDeckData(updater, label) {
|
|
275
|
-
const before = readDeckData(port);
|
|
276
|
-
const after = updater(structuredClone(before));
|
|
277
|
-
if (commitDeckData(port, before, after, label)) {
|
|
278
|
-
port.afterDeckUpdate?.();
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
if (port.getFocusedTargets) {
|
|
283
|
-
bridge.getFocusedTargets = () => port.getFocusedTargets?.() ?? [];
|
|
284
|
-
}
|
|
285
|
-
if (port.notify) {
|
|
286
|
-
bridge.notify = (message, level) => port.notify?.(message, level);
|
|
287
|
-
}
|
|
288
|
-
return bridge;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// src/pptx/ai/focus-targets.ts
|
|
292
|
-
function computeFocusTargets(input) {
|
|
293
|
-
const { activeSlideIndex, selectedElementIds, selectedElementId } = input;
|
|
294
|
-
const ids = selectedElementIds.length > 0 ? [...selectedElementIds] : selectedElementId ? [selectedElementId] : [];
|
|
295
|
-
if (ids.length === 0) {
|
|
296
|
-
return [{ kind: "slide", slideIndex: activeSlideIndex }];
|
|
297
|
-
}
|
|
298
|
-
return ids.map((elementId2) => ({ kind: "element", slideIndex: activeSlideIndex, elementId: elementId2 }));
|
|
299
|
-
}
|
|
300
|
-
function elementTypeLabel(type) {
|
|
301
|
-
if (type === "smartArt") {
|
|
302
|
-
return "SmartArt";
|
|
303
|
-
}
|
|
304
|
-
if (type === "ole") {
|
|
305
|
-
return "OLE";
|
|
306
|
-
}
|
|
307
|
-
return type.charAt(0).toUpperCase() + type.slice(1);
|
|
308
|
-
}
|
|
309
|
-
function shortElementId(id) {
|
|
310
|
-
const trimmed = id.trimEnd();
|
|
311
|
-
let start = trimmed.length;
|
|
312
|
-
while (start > 0 && isAsciiDigit(trimmed.charCodeAt(start - 1))) {
|
|
313
|
-
start -= 1;
|
|
314
|
-
}
|
|
315
|
-
if (start < trimmed.length) {
|
|
316
|
-
return trimmed.slice(start);
|
|
317
|
-
}
|
|
318
|
-
const separator = Math.max(id.lastIndexOf("/"), id.lastIndexOf("."), id.lastIndexOf("-"));
|
|
319
|
-
const tail = separator === -1 ? id : id.slice(separator + 1);
|
|
320
|
-
return tail || id;
|
|
321
|
-
}
|
|
322
|
-
function isAsciiDigit(code) {
|
|
323
|
-
return code >= 48 && code <= 57;
|
|
324
|
-
}
|
|
325
|
-
function focusTargetChips(targets, slides) {
|
|
326
|
-
return targets.map((target, index) => {
|
|
327
|
-
if (target.kind === "slide") {
|
|
328
|
-
const label2 = `Slide ${target.slideIndex + 1}`;
|
|
329
|
-
return { key: `slide-${target.slideIndex}-${index}`, label: label2, title: label2 };
|
|
330
|
-
}
|
|
331
|
-
const el = slides[target.slideIndex]?.elements.find((e) => e.id === target.elementId);
|
|
332
|
-
const typeLabel = el ? elementTypeLabel(el.type) : "Element";
|
|
333
|
-
const label = el ? `${typeLabel} ${shortElementId(target.elementId)}` : `${typeLabel} (missing)`;
|
|
334
|
-
return {
|
|
335
|
-
key: `el-${target.elementId}-${index}`,
|
|
336
|
-
label,
|
|
337
|
-
title: `${typeLabel}: ${target.elementId}`
|
|
338
|
-
};
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
function isTwoTableFocus(targets, slides) {
|
|
342
|
-
if (targets.length !== 2 || targets.some((target) => target.kind !== "element")) {
|
|
343
|
-
return false;
|
|
344
|
-
}
|
|
345
|
-
const [a, b] = targets;
|
|
346
|
-
if (a.slideIndex !== b.slideIndex) {
|
|
347
|
-
return false;
|
|
348
|
-
}
|
|
349
|
-
const slide = slides[a.slideIndex];
|
|
350
|
-
const elA = slide?.elements.find((e) => e.id === a.elementId);
|
|
351
|
-
const elB = slide?.elements.find((e) => e.id === b.elementId);
|
|
352
|
-
if (elA?.type !== "table" || elB?.type !== "table") {
|
|
353
|
-
return false;
|
|
354
|
-
}
|
|
355
|
-
return { slideIndex: a.slideIndex, elementIdA: a.elementId, elementIdB: b.elementId };
|
|
356
|
-
}
|
|
357
|
-
function mergeTablesDirective(slideIndex2, elementIdA, elementIdB) {
|
|
358
|
-
return `Merge the two selected tables (elementIdA=${elementIdA}, elementIdB=${elementIdB}) on slide ${slideIndex2 + 1} using merge_tables; stage it now, do not ask me to confirm.`;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
// src/pptx/ai/panel-controller.ts
|
|
362
|
-
var AI_TOOL_FLASH_MS = 2600;
|
|
363
|
-
function aiFixDirective(element, slideIndex2) {
|
|
364
|
-
return `Review and fix any issues with this ${element.type} (id=${element.id}) on slide ${slideIndex2 + 1}.`;
|
|
365
|
-
}
|
|
366
|
-
function resolveAiEffectiveTargets(state, liveTargets) {
|
|
367
|
-
if (state.pickTargets.length > 0) {
|
|
368
|
-
return state.pickTargets;
|
|
369
|
-
}
|
|
370
|
-
if (state.pinnedFocus && state.pinnedFocus.length > 0) {
|
|
371
|
-
return state.pinnedFocus;
|
|
372
|
-
}
|
|
373
|
-
return liveTargets;
|
|
374
|
-
}
|
|
375
|
-
function isAiFocusPinned(state) {
|
|
376
|
-
return state.pickTargets.length === 0 && state.pinnedFocus !== null;
|
|
377
|
-
}
|
|
378
|
-
function buildHighlights(pickTargets, toolFocus) {
|
|
379
|
-
const out = [];
|
|
380
|
-
for (const target of pickTargets) {
|
|
381
|
-
if (target.kind === "element") {
|
|
382
|
-
out.push({ slideIndex: target.slideIndex, elementId: target.elementId, variant: "pick" });
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
for (const elementId2 of toolFocus?.elementIds ?? []) {
|
|
386
|
-
out.push({ slideIndex: toolFocus?.slideIndex ?? 0, elementId: elementId2, variant: "active" });
|
|
387
|
-
}
|
|
388
|
-
return out;
|
|
389
|
-
}
|
|
390
|
-
var INITIAL_STATE = {
|
|
391
|
-
isOpen: false,
|
|
392
|
-
pinnedFocus: null,
|
|
393
|
-
prefill: { text: "", nonce: 0 },
|
|
394
|
-
pickMode: false,
|
|
395
|
-
pickTargets: [],
|
|
396
|
-
canvasHighlights: [],
|
|
397
|
-
canvasAnimating: false,
|
|
398
|
-
changeBatch: null
|
|
399
|
-
};
|
|
400
|
-
function createPptxAiPanelController(deps) {
|
|
401
|
-
const store = chunkY6DO6SVT_cjs.createControllerStore(INITIAL_STATE);
|
|
402
|
-
let toolFocus = null;
|
|
403
|
-
let flashing = false;
|
|
404
|
-
let flashTimer = null;
|
|
405
|
-
const update = (patch) => {
|
|
406
|
-
store.update((current) => {
|
|
407
|
-
const next = { ...current, ...patch };
|
|
408
|
-
const canvasHighlights = buildHighlights(next.pickTargets, toolFocus);
|
|
409
|
-
const sameHighlights = canvasHighlights.length === current.canvasHighlights.length && canvasHighlights.every((h, i) => {
|
|
410
|
-
const prev = current.canvasHighlights[i];
|
|
411
|
-
return prev?.elementId === h.elementId && prev.slideIndex === h.slideIndex && prev.variant === h.variant;
|
|
412
|
-
});
|
|
413
|
-
return {
|
|
414
|
-
...next,
|
|
415
|
-
canvasHighlights: sameHighlights ? current.canvasHighlights : canvasHighlights,
|
|
416
|
-
canvasAnimating: flashing || canvasHighlights.length > 0
|
|
417
|
-
};
|
|
418
|
-
});
|
|
419
|
-
};
|
|
420
|
-
const liveTargets = () => computeFocusTargets(deps.getSelection());
|
|
421
|
-
const openPanel = (patch) => {
|
|
422
|
-
update({ ...patch, isOpen: true });
|
|
423
|
-
deps.onOpen?.();
|
|
424
|
-
};
|
|
425
|
-
const fixElement = (element, slideIndex2) => {
|
|
426
|
-
const { prefill } = store.getSnapshot();
|
|
427
|
-
openPanel({
|
|
428
|
-
pinnedFocus: liveTargets(),
|
|
429
|
-
prefill: {
|
|
430
|
-
text: element ? aiFixDirective(element, slideIndex2) : "",
|
|
431
|
-
nonce: prefill.nonce + 1
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
};
|
|
435
|
-
return {
|
|
436
|
-
getSnapshot: store.getSnapshot,
|
|
437
|
-
subscribe: store.subscribe,
|
|
438
|
-
open: () => openPanel({}),
|
|
439
|
-
close: () => update({ isOpen: false }),
|
|
440
|
-
toggle() {
|
|
441
|
-
if (store.getSnapshot().isOpen) {
|
|
442
|
-
update({ isOpen: false });
|
|
443
|
-
} else {
|
|
444
|
-
openPanel({});
|
|
445
|
-
}
|
|
446
|
-
},
|
|
447
|
-
getLiveTargets: liveTargets,
|
|
448
|
-
getEffectiveTargets: () => resolveAiEffectiveTargets(store.getSnapshot(), liveTargets()),
|
|
449
|
-
pinFocus: () => update({ pinnedFocus: liveTargets() }),
|
|
450
|
-
clearPinnedFocus: () => update({ pinnedFocus: null }),
|
|
451
|
-
askAboutSelection() {
|
|
452
|
-
const { prefill } = store.getSnapshot();
|
|
453
|
-
openPanel({ pinnedFocus: liveTargets(), prefill: { text: "", nonce: prefill.nonce + 1 } });
|
|
454
|
-
},
|
|
455
|
-
fixSelection() {
|
|
456
|
-
fixElement(deps.getSelectedElement?.(), deps.getSelection().activeSlideIndex);
|
|
457
|
-
},
|
|
458
|
-
fixElement,
|
|
459
|
-
startPicking: () => openPanel({ pickMode: true }),
|
|
460
|
-
stopPicking: () => update({ pickMode: false }),
|
|
461
|
-
addPick(slideIndex2, elementId2) {
|
|
462
|
-
const { pickTargets } = store.getSnapshot();
|
|
463
|
-
if (pickTargets.some((t) => t.kind === "element" && t.elementId === elementId2)) {
|
|
464
|
-
return;
|
|
465
|
-
}
|
|
466
|
-
update({ pickTargets: [...pickTargets, { kind: "element", slideIndex: slideIndex2, elementId: elementId2 }] });
|
|
467
|
-
},
|
|
468
|
-
clearPicks: () => update({ pickTargets: [], pickMode: false }),
|
|
469
|
-
flashToolTarget(target) {
|
|
470
|
-
toolFocus = target && target.slideIndex !== void 0 && target.elementIds.length > 0 ? { slideIndex: target.slideIndex, elementIds: target.elementIds } : null;
|
|
471
|
-
flashing = true;
|
|
472
|
-
if (flashTimer) {
|
|
473
|
-
clearTimeout(flashTimer);
|
|
474
|
-
}
|
|
475
|
-
flashTimer = setTimeout(() => {
|
|
476
|
-
toolFocus = null;
|
|
477
|
-
flashing = false;
|
|
478
|
-
flashTimer = null;
|
|
479
|
-
update({});
|
|
480
|
-
}, AI_TOOL_FLASH_MS);
|
|
481
|
-
update({});
|
|
482
|
-
},
|
|
483
|
-
showChangeBatch: (batch) => update({ changeBatch: batch }),
|
|
484
|
-
dispose() {
|
|
485
|
-
if (flashTimer) {
|
|
486
|
-
clearTimeout(flashTimer);
|
|
487
|
-
flashTimer = null;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
};
|
|
491
|
-
}
|
|
492
|
-
|
|
493
54
|
// src/pptx/ai/config.ts
|
|
494
55
|
function resolveChatTransport(options) {
|
|
495
56
|
const { sdk, connection } = options;
|
|
@@ -1713,145 +1274,6 @@ function buildToolSet(sdk, config, executors, options) {
|
|
|
1713
1274
|
return { ...tools, ...config.tools?.extra ?? {} };
|
|
1714
1275
|
}
|
|
1715
1276
|
|
|
1716
|
-
// src/pptx/ai/change-diff.ts
|
|
1717
|
-
function bounds2(el) {
|
|
1718
|
-
return { x: el.x, y: el.y, width: el.width, height: el.height };
|
|
1719
|
-
}
|
|
1720
|
-
function moved(a, b) {
|
|
1721
|
-
return Math.abs(a.x - b.x) > 0.5 || Math.abs(a.y - b.y) > 0.5;
|
|
1722
|
-
}
|
|
1723
|
-
function resized(a, b) {
|
|
1724
|
-
return Math.abs(a.width - b.width) > 0.5 || Math.abs(a.height - b.height) > 0.5;
|
|
1725
|
-
}
|
|
1726
|
-
function textOf(el) {
|
|
1727
|
-
return "text" in el && typeof el.text === "string" ? el.text : void 0;
|
|
1728
|
-
}
|
|
1729
|
-
function styleSignature(el) {
|
|
1730
|
-
const rest = { ...el };
|
|
1731
|
-
delete rest["x"];
|
|
1732
|
-
delete rest["y"];
|
|
1733
|
-
delete rest["width"];
|
|
1734
|
-
delete rest["height"];
|
|
1735
|
-
delete rest["id"];
|
|
1736
|
-
delete rest["rotation"];
|
|
1737
|
-
return JSON.stringify(rest);
|
|
1738
|
-
}
|
|
1739
|
-
function classify(before, after) {
|
|
1740
|
-
if (moved(before, after)) {
|
|
1741
|
-
return "moved";
|
|
1742
|
-
}
|
|
1743
|
-
if (resized(before, after)) {
|
|
1744
|
-
return "resized";
|
|
1745
|
-
}
|
|
1746
|
-
if (textOf(before) !== textOf(after)) {
|
|
1747
|
-
return "text";
|
|
1748
|
-
}
|
|
1749
|
-
if (styleSignature(before) !== styleSignature(after)) {
|
|
1750
|
-
return "restyled";
|
|
1751
|
-
}
|
|
1752
|
-
return null;
|
|
1753
|
-
}
|
|
1754
|
-
function diffChangedElements(before, after) {
|
|
1755
|
-
const changes = [];
|
|
1756
|
-
const beforeById = new Map(before.map((s) => [s.id, s]));
|
|
1757
|
-
after.forEach((afterSlide, slideIndex2) => {
|
|
1758
|
-
const beforeSlide = beforeById.get(afterSlide.id) ?? before[slideIndex2];
|
|
1759
|
-
const beforeEls = new Map((beforeSlide?.elements ?? []).map((e) => [e.id, e]));
|
|
1760
|
-
const afterIds = new Set(afterSlide.elements.map((e) => e.id));
|
|
1761
|
-
for (const el of afterSlide.elements) {
|
|
1762
|
-
const prev = beforeEls.get(el.id);
|
|
1763
|
-
if (!prev) {
|
|
1764
|
-
changes.push({ slideIndex: slideIndex2, elementId: el.id, kind: "added", to: bounds2(el) });
|
|
1765
|
-
continue;
|
|
1766
|
-
}
|
|
1767
|
-
const kind = classify(prev, el);
|
|
1768
|
-
if (kind) {
|
|
1769
|
-
changes.push({ slideIndex: slideIndex2, elementId: el.id, kind, from: bounds2(prev), to: bounds2(el) });
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
for (const prev of beforeSlide?.elements ?? []) {
|
|
1773
|
-
if (!afterIds.has(prev.id)) {
|
|
1774
|
-
changes.push({
|
|
1775
|
-
slideIndex: slideIndex2,
|
|
1776
|
-
elementId: prev.id,
|
|
1777
|
-
kind: "removed",
|
|
1778
|
-
from: bounds2(prev)
|
|
1779
|
-
});
|
|
1780
|
-
}
|
|
1781
|
-
}
|
|
1782
|
-
});
|
|
1783
|
-
return changes;
|
|
1784
|
-
}
|
|
1785
|
-
|
|
1786
|
-
// src/pptx/ai/change-animator.ts
|
|
1787
|
-
var DEFAULTS = {
|
|
1788
|
-
enabled: true,
|
|
1789
|
-
durationMs: 900,
|
|
1790
|
-
glow: true,
|
|
1791
|
-
tween: true,
|
|
1792
|
-
color: "rgba(59,130,246,1)"
|
|
1793
|
-
};
|
|
1794
|
-
function resolveChangeAnimationConfig(config) {
|
|
1795
|
-
return {
|
|
1796
|
-
enabled: config?.enabled ?? DEFAULTS.enabled,
|
|
1797
|
-
durationMs: config?.durationMs ?? DEFAULTS.durationMs,
|
|
1798
|
-
glow: config?.glow ?? DEFAULTS.glow,
|
|
1799
|
-
tween: config?.tween ?? DEFAULTS.tween,
|
|
1800
|
-
color: config?.color ?? DEFAULTS.color
|
|
1801
|
-
};
|
|
1802
|
-
}
|
|
1803
|
-
var defaultSchedule = (fn, ms) => {
|
|
1804
|
-
const id = setTimeout(fn, ms);
|
|
1805
|
-
return () => clearTimeout(id);
|
|
1806
|
-
};
|
|
1807
|
-
function createAiChangeAnimator(config, schedule = defaultSchedule) {
|
|
1808
|
-
let resolved = resolveChangeAnimationConfig(config);
|
|
1809
|
-
let batch = null;
|
|
1810
|
-
let nonce = 0;
|
|
1811
|
-
let cancelClear = null;
|
|
1812
|
-
const listeners = /* @__PURE__ */ new Set();
|
|
1813
|
-
const emit = () => {
|
|
1814
|
-
for (const l of listeners) {
|
|
1815
|
-
l(batch);
|
|
1816
|
-
}
|
|
1817
|
-
};
|
|
1818
|
-
return {
|
|
1819
|
-
publish(before, after) {
|
|
1820
|
-
if (!resolved.enabled) {
|
|
1821
|
-
return null;
|
|
1822
|
-
}
|
|
1823
|
-
const changes = diffChangedElements(before, after);
|
|
1824
|
-
if (changes.length === 0) {
|
|
1825
|
-
return null;
|
|
1826
|
-
}
|
|
1827
|
-
cancelClear?.();
|
|
1828
|
-
nonce += 1;
|
|
1829
|
-
batch = { changes, slideIndex: changes[0].slideIndex, nonce, config: resolved };
|
|
1830
|
-
emit();
|
|
1831
|
-
cancelClear = schedule(() => {
|
|
1832
|
-
batch = null;
|
|
1833
|
-
cancelClear = null;
|
|
1834
|
-
emit();
|
|
1835
|
-
}, resolved.durationMs + 250);
|
|
1836
|
-
return batch;
|
|
1837
|
-
},
|
|
1838
|
-
subscribe(listener) {
|
|
1839
|
-
listeners.add(listener);
|
|
1840
|
-
return () => listeners.delete(listener);
|
|
1841
|
-
},
|
|
1842
|
-
current: () => batch,
|
|
1843
|
-
configure(next) {
|
|
1844
|
-
resolved = resolveChangeAnimationConfig(next);
|
|
1845
|
-
},
|
|
1846
|
-
dispose() {
|
|
1847
|
-
cancelClear?.();
|
|
1848
|
-
cancelClear = null;
|
|
1849
|
-
listeners.clear();
|
|
1850
|
-
batch = null;
|
|
1851
|
-
}
|
|
1852
|
-
};
|
|
1853
|
-
}
|
|
1854
|
-
|
|
1855
1277
|
// src/pptx/ai/session.ts
|
|
1856
1278
|
async function createAiChatSession(bridge, config) {
|
|
1857
1279
|
const sdk = await loadAiSdk();
|
|
@@ -1860,7 +1282,7 @@ async function createAiChatSession(bridge, config) {
|
|
|
1860
1282
|
'The optional "ai" SDK is not installed. Install `ai` (>=6 <8) to enable the assistant.'
|
|
1861
1283
|
);
|
|
1862
1284
|
}
|
|
1863
|
-
const changeAnimator = createAiChangeAnimator(config.changeAnimation);
|
|
1285
|
+
const changeAnimator = chunkIY7H76CZ_cjs.createAiChangeAnimator(config.changeAnimation);
|
|
1864
1286
|
const proposals = new ProposalStore(bridge, changeAnimator);
|
|
1865
1287
|
const executors = buildToolExecutors(bridge, proposals, config, changeAnimator);
|
|
1866
1288
|
const tools = buildToolSet(sdk, config, executors, { withExecute: false });
|
|
@@ -1896,265 +1318,6 @@ async function createAiChatSession(bridge, config) {
|
|
|
1896
1318
|
};
|
|
1897
1319
|
}
|
|
1898
1320
|
|
|
1899
|
-
// src/pptx/ai/change-animation-css.ts
|
|
1900
|
-
var AI_CHANGE_ATTR = "data-pptx-ai-changed";
|
|
1901
|
-
function aiChangeAnimationCss(config) {
|
|
1902
|
-
const { color, durationMs } = config;
|
|
1903
|
-
return `
|
|
1904
|
-
@keyframes pptx-ai-change-glow {
|
|
1905
|
-
0% { box-shadow: 0 0 0 0 ${color}, 0 0 0 0 ${color}; }
|
|
1906
|
-
50% { box-shadow: 0 0 0 4px transparent, 0 0 16px 5px ${color}; }
|
|
1907
|
-
100% { box-shadow: 0 0 0 0 transparent, 0 0 10px 2px transparent; }
|
|
1908
|
-
}
|
|
1909
|
-
[${AI_CHANGE_ATTR}] {
|
|
1910
|
-
animation: pptx-ai-change-glow ${durationMs}ms ease-out;
|
|
1911
|
-
outline: 2px solid ${color};
|
|
1912
|
-
outline-offset: 1px;
|
|
1913
|
-
border-radius: 3px;
|
|
1914
|
-
transition: color ${Math.round(durationMs / 2)}ms ease, fill ${Math.round(durationMs / 2)}ms ease,
|
|
1915
|
-
stroke ${Math.round(durationMs / 2)}ms ease, background-color ${Math.round(durationMs / 2)}ms ease;
|
|
1916
|
-
}
|
|
1917
|
-
`;
|
|
1918
|
-
}
|
|
1919
|
-
var PAD = 3;
|
|
1920
|
-
function changeGhostStyle(change, phase, config) {
|
|
1921
|
-
const at = phase === "start" ? change.from ?? change.to : change.to ?? change.from;
|
|
1922
|
-
const box = at ?? { x: 0, y: 0, width: 0, height: 0 };
|
|
1923
|
-
const ms = config.durationMs;
|
|
1924
|
-
const tween = config.tween;
|
|
1925
|
-
let opacity = 1;
|
|
1926
|
-
let transform = "scale(1)";
|
|
1927
|
-
if (change.kind === "added") {
|
|
1928
|
-
opacity = phase === "start" ? 0 : 1;
|
|
1929
|
-
transform = phase === "start" ? "scale(0.92)" : "scale(1)";
|
|
1930
|
-
} else if (change.kind === "removed") {
|
|
1931
|
-
opacity = phase === "start" ? 0.9 : 0;
|
|
1932
|
-
transform = phase === "start" ? "scale(1)" : "scale(0.92)";
|
|
1933
|
-
} else {
|
|
1934
|
-
opacity = phase === "start" ? 0.85 : 0;
|
|
1935
|
-
}
|
|
1936
|
-
const transition = tween ? `left ${ms}ms ease, top ${ms}ms ease, width ${ms}ms ease, height ${ms}ms ease, opacity ${ms}ms ease, transform ${ms}ms ease` : `opacity ${ms}ms ease`;
|
|
1937
|
-
return {
|
|
1938
|
-
position: "absolute",
|
|
1939
|
-
left: box.x - PAD,
|
|
1940
|
-
top: box.y - PAD,
|
|
1941
|
-
width: box.width + PAD * 2,
|
|
1942
|
-
height: box.height + PAD * 2,
|
|
1943
|
-
opacity,
|
|
1944
|
-
transform,
|
|
1945
|
-
transition,
|
|
1946
|
-
boxShadow: config.glow ? `0 0 14px 3px ${config.color}` : "none",
|
|
1947
|
-
border: `2px solid ${config.color}`,
|
|
1948
|
-
borderRadius: "4px",
|
|
1949
|
-
pointerEvents: "none",
|
|
1950
|
-
zIndex: 9997
|
|
1951
|
-
};
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
// src/pptx/ai/ui-parts.ts
|
|
1955
|
-
function isTextPart(part) {
|
|
1956
|
-
return part.type === "text";
|
|
1957
|
-
}
|
|
1958
|
-
function isToolPart(part) {
|
|
1959
|
-
return typeof part.type === "string" && part.type.startsWith("tool-");
|
|
1960
|
-
}
|
|
1961
|
-
function isDynamicToolPart(part) {
|
|
1962
|
-
return part.type === "dynamic-tool";
|
|
1963
|
-
}
|
|
1964
|
-
function toolNameOf(part) {
|
|
1965
|
-
if (isDynamicToolPart(part)) {
|
|
1966
|
-
return part.toolName ?? "tool";
|
|
1967
|
-
}
|
|
1968
|
-
return typeof part.type === "string" ? part.type.slice("tool-".length) : "tool";
|
|
1969
|
-
}
|
|
1970
|
-
var READY_TOOL_STATES = /* @__PURE__ */ new Set([
|
|
1971
|
-
"input-available",
|
|
1972
|
-
"output-available",
|
|
1973
|
-
"output-error"
|
|
1974
|
-
]);
|
|
1975
|
-
function extractReadyToolCalls(messages) {
|
|
1976
|
-
const out = [];
|
|
1977
|
-
for (const message of messages) {
|
|
1978
|
-
for (const rawPart of message.parts) {
|
|
1979
|
-
const part = rawPart;
|
|
1980
|
-
if (!isToolPart(part) && !isDynamicToolPart(part)) {
|
|
1981
|
-
continue;
|
|
1982
|
-
}
|
|
1983
|
-
const toolCallId = part.toolCallId ?? "";
|
|
1984
|
-
if (toolCallId.length === 0 || part.input === void 0) {
|
|
1985
|
-
continue;
|
|
1986
|
-
}
|
|
1987
|
-
if (!READY_TOOL_STATES.has(part.state ?? "")) {
|
|
1988
|
-
continue;
|
|
1989
|
-
}
|
|
1990
|
-
out.push({ toolName: toolNameOf(part), toolCallId, input: part.input });
|
|
1991
|
-
}
|
|
1992
|
-
}
|
|
1993
|
-
return out;
|
|
1994
|
-
}
|
|
1995
|
-
function toRenderableParts(message) {
|
|
1996
|
-
const out = [];
|
|
1997
|
-
for (const rawPart of message.parts) {
|
|
1998
|
-
const part = rawPart;
|
|
1999
|
-
if (isTextPart(part)) {
|
|
2000
|
-
const text = part.text ?? "";
|
|
2001
|
-
if (text.trim().length > 0) {
|
|
2002
|
-
out.push({ kind: "text", text });
|
|
2003
|
-
}
|
|
2004
|
-
continue;
|
|
2005
|
-
}
|
|
2006
|
-
if (isToolPart(part) || isDynamicToolPart(part)) {
|
|
2007
|
-
out.push({
|
|
2008
|
-
kind: "tool",
|
|
2009
|
-
toolName: toolNameOf(part),
|
|
2010
|
-
toolCallId: part.toolCallId ?? "",
|
|
2011
|
-
state: part.state ?? "input-streaming",
|
|
2012
|
-
input: part.input,
|
|
2013
|
-
output: part.output,
|
|
2014
|
-
errorText: part.errorText
|
|
2015
|
-
});
|
|
2016
|
-
}
|
|
2017
|
-
}
|
|
2018
|
-
return out;
|
|
2019
|
-
}
|
|
2020
|
-
|
|
2021
|
-
// src/pptx/ai/chat-log-export.ts
|
|
2022
|
-
function isoOf(ms) {
|
|
2023
|
-
const n = Number.isFinite(ms) ? ms : 0;
|
|
2024
|
-
return new Date(n).toISOString();
|
|
2025
|
-
}
|
|
2026
|
-
function toLogChat(chat, detailed) {
|
|
2027
|
-
const messages = chat.messages.map((message) => {
|
|
2028
|
-
const parts = toRenderableParts(message);
|
|
2029
|
-
const textRuns = [];
|
|
2030
|
-
const toolCalls = [];
|
|
2031
|
-
for (const part of parts) {
|
|
2032
|
-
if (part.kind === "text") {
|
|
2033
|
-
textRuns.push(part.text);
|
|
2034
|
-
continue;
|
|
2035
|
-
}
|
|
2036
|
-
toolCalls.push({
|
|
2037
|
-
toolName: part.toolName,
|
|
2038
|
-
toolCallId: part.toolCallId,
|
|
2039
|
-
state: part.state,
|
|
2040
|
-
input: detailed ? part.input : void 0,
|
|
2041
|
-
output: detailed ? part.output : void 0,
|
|
2042
|
-
errorText: part.errorText
|
|
2043
|
-
});
|
|
2044
|
-
}
|
|
2045
|
-
return {
|
|
2046
|
-
role: message.role,
|
|
2047
|
-
text: textRuns.join("\n\n"),
|
|
2048
|
-
toolCalls
|
|
2049
|
-
};
|
|
2050
|
-
});
|
|
2051
|
-
return {
|
|
2052
|
-
id: chat.id,
|
|
2053
|
-
title: chat.title,
|
|
2054
|
-
deckId: chat.deckId,
|
|
2055
|
-
createdAt: chat.createdAt,
|
|
2056
|
-
updatedAt: chat.updatedAt,
|
|
2057
|
-
createdAtIso: isoOf(chat.createdAt),
|
|
2058
|
-
updatedAtIso: isoOf(chat.updatedAt),
|
|
2059
|
-
messageCount: chat.messages.length,
|
|
2060
|
-
messages
|
|
2061
|
-
};
|
|
2062
|
-
}
|
|
2063
|
-
function buildChatLogExport(chats, options) {
|
|
2064
|
-
const detailed = options?.detailed ?? true;
|
|
2065
|
-
const now = options?.now ?? Date.now();
|
|
2066
|
-
return {
|
|
2067
|
-
format: "pptx-ai-chat-log",
|
|
2068
|
-
version: 1,
|
|
2069
|
-
exportedAt: isoOf(now),
|
|
2070
|
-
detailed,
|
|
2071
|
-
chatCount: chats.length,
|
|
2072
|
-
chats: chats.map((chat) => toLogChat(chat, detailed))
|
|
2073
|
-
};
|
|
2074
|
-
}
|
|
2075
|
-
function toolCallLine(call, detailed) {
|
|
2076
|
-
const lines = [`- Tool \`${call.toolName}\` (${call.state})`];
|
|
2077
|
-
if (call.errorText) {
|
|
2078
|
-
lines.push(` - error: ${call.errorText}`);
|
|
2079
|
-
}
|
|
2080
|
-
if (detailed) {
|
|
2081
|
-
lines.push(" - input:");
|
|
2082
|
-
lines.push(" ```json");
|
|
2083
|
-
lines.push(JSON.stringify(call.input ?? null, null, 2));
|
|
2084
|
-
lines.push(" ```");
|
|
2085
|
-
lines.push(" - output:");
|
|
2086
|
-
lines.push(" ```json");
|
|
2087
|
-
lines.push(JSON.stringify(call.output ?? null, null, 2));
|
|
2088
|
-
lines.push(" ```");
|
|
2089
|
-
}
|
|
2090
|
-
return lines.join("\n");
|
|
2091
|
-
}
|
|
2092
|
-
function buildChatLogMarkdown(doc) {
|
|
2093
|
-
const out = [
|
|
2094
|
-
`# AI chat logs`,
|
|
2095
|
-
"",
|
|
2096
|
-
`Exported: ${doc.exportedAt}`,
|
|
2097
|
-
`Chats: ${doc.chatCount}`,
|
|
2098
|
-
""
|
|
2099
|
-
];
|
|
2100
|
-
for (const chat of doc.chats) {
|
|
2101
|
-
out.push(`## ${chat.title || chat.id}`);
|
|
2102
|
-
out.push("");
|
|
2103
|
-
out.push(`- id: ${chat.id}`);
|
|
2104
|
-
if (chat.deckId) {
|
|
2105
|
-
out.push(`- deck: ${chat.deckId}`);
|
|
2106
|
-
}
|
|
2107
|
-
out.push(`- created: ${chat.createdAtIso}`);
|
|
2108
|
-
out.push(`- updated: ${chat.updatedAtIso}`);
|
|
2109
|
-
out.push(`- messages: ${chat.messageCount}`);
|
|
2110
|
-
out.push("");
|
|
2111
|
-
for (const message of chat.messages) {
|
|
2112
|
-
out.push(`### ${message.role}`);
|
|
2113
|
-
out.push("");
|
|
2114
|
-
if (message.text) {
|
|
2115
|
-
out.push(message.text);
|
|
2116
|
-
out.push("");
|
|
2117
|
-
}
|
|
2118
|
-
for (const call of message.toolCalls) {
|
|
2119
|
-
out.push(toolCallLine(call, doc.detailed));
|
|
2120
|
-
out.push("");
|
|
2121
|
-
}
|
|
2122
|
-
}
|
|
2123
|
-
}
|
|
2124
|
-
return out.join("\n");
|
|
2125
|
-
}
|
|
2126
|
-
async function collectStoredChats(store = chunkA5MANNJR_cjs.createChatHistoryStore()) {
|
|
2127
|
-
const summaries = await store.listChats();
|
|
2128
|
-
const chats = [];
|
|
2129
|
-
for (const summary of summaries) {
|
|
2130
|
-
const chat = await store.loadChat(summary.id);
|
|
2131
|
-
if (chat) {
|
|
2132
|
-
chats.push(chat);
|
|
2133
|
-
}
|
|
2134
|
-
}
|
|
2135
|
-
return chats;
|
|
2136
|
-
}
|
|
2137
|
-
function timestampSlug(now) {
|
|
2138
|
-
const d = new Date(now);
|
|
2139
|
-
const p = (n) => String(n).padStart(2, "0");
|
|
2140
|
-
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
|
|
2141
|
-
}
|
|
2142
|
-
function exportAiChatLogs(chats, meta, save) {
|
|
2143
|
-
if (chats.length === 0) {
|
|
2144
|
-
return 0;
|
|
2145
|
-
}
|
|
2146
|
-
const now = meta?.now ?? Date.now();
|
|
2147
|
-
const doc = buildChatLogExport(chats, { detailed: meta?.detailed ?? true, now });
|
|
2148
|
-
const slug = timestampSlug(now);
|
|
2149
|
-
const format = meta?.format ?? "json";
|
|
2150
|
-
if (format === "markdown") {
|
|
2151
|
-
save(`pptx-ai-chats-${slug}.md`, buildChatLogMarkdown(doc), "text/markdown");
|
|
2152
|
-
} else {
|
|
2153
|
-
save(`pptx-ai-chats-${slug}.json`, JSON.stringify(doc, null, 2), "application/json");
|
|
2154
|
-
}
|
|
2155
|
-
return chats.length;
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
1321
|
// src/pptx/ai/chat-history-controller.ts
|
|
2159
1322
|
var SAVE_DEBOUNCE_MS = 800;
|
|
2160
1323
|
var TITLE_MAX = 40;
|
|
@@ -2783,6 +1946,122 @@ function toolCanvasTarget(toolName, input) {
|
|
|
2783
1946
|
return { slideIndex: slideIndex2, elementIds };
|
|
2784
1947
|
}
|
|
2785
1948
|
|
|
1949
|
+
Object.defineProperty(exports, "AI_CHANGE_ATTR", {
|
|
1950
|
+
enumerable: true,
|
|
1951
|
+
get: function () { return chunkIY7H76CZ_cjs.AI_CHANGE_ATTR; }
|
|
1952
|
+
});
|
|
1953
|
+
Object.defineProperty(exports, "AI_TOOL_FLASH_MS", {
|
|
1954
|
+
enumerable: true,
|
|
1955
|
+
get: function () { return chunkIY7H76CZ_cjs.AI_TOOL_FLASH_MS; }
|
|
1956
|
+
});
|
|
1957
|
+
Object.defineProperty(exports, "aiChangeAnimationCss", {
|
|
1958
|
+
enumerable: true,
|
|
1959
|
+
get: function () { return chunkIY7H76CZ_cjs.aiChangeAnimationCss; }
|
|
1960
|
+
});
|
|
1961
|
+
Object.defineProperty(exports, "aiFixDirective", {
|
|
1962
|
+
enumerable: true,
|
|
1963
|
+
get: function () { return chunkIY7H76CZ_cjs.aiFixDirective; }
|
|
1964
|
+
});
|
|
1965
|
+
Object.defineProperty(exports, "applyElementUpdate", {
|
|
1966
|
+
enumerable: true,
|
|
1967
|
+
get: function () { return chunkIY7H76CZ_cjs.applyElementUpdate; }
|
|
1968
|
+
});
|
|
1969
|
+
Object.defineProperty(exports, "applyShapeStyleUpdate", {
|
|
1970
|
+
enumerable: true,
|
|
1971
|
+
get: function () { return chunkIY7H76CZ_cjs.applyShapeStyleUpdate; }
|
|
1972
|
+
});
|
|
1973
|
+
Object.defineProperty(exports, "applyTextUpdate", {
|
|
1974
|
+
enumerable: true,
|
|
1975
|
+
get: function () { return chunkIY7H76CZ_cjs.applyTextUpdate; }
|
|
1976
|
+
});
|
|
1977
|
+
Object.defineProperty(exports, "buildChatLogExport", {
|
|
1978
|
+
enumerable: true,
|
|
1979
|
+
get: function () { return chunkIY7H76CZ_cjs.buildChatLogExport; }
|
|
1980
|
+
});
|
|
1981
|
+
Object.defineProperty(exports, "buildChatLogMarkdown", {
|
|
1982
|
+
enumerable: true,
|
|
1983
|
+
get: function () { return chunkIY7H76CZ_cjs.buildChatLogMarkdown; }
|
|
1984
|
+
});
|
|
1985
|
+
Object.defineProperty(exports, "changeGhostStyle", {
|
|
1986
|
+
enumerable: true,
|
|
1987
|
+
get: function () { return chunkIY7H76CZ_cjs.changeGhostStyle; }
|
|
1988
|
+
});
|
|
1989
|
+
Object.defineProperty(exports, "collectStoredChats", {
|
|
1990
|
+
enumerable: true,
|
|
1991
|
+
get: function () { return chunkIY7H76CZ_cjs.collectStoredChats; }
|
|
1992
|
+
});
|
|
1993
|
+
Object.defineProperty(exports, "computeFocusTargets", {
|
|
1994
|
+
enumerable: true,
|
|
1995
|
+
get: function () { return chunkIY7H76CZ_cjs.computeFocusTargets; }
|
|
1996
|
+
});
|
|
1997
|
+
Object.defineProperty(exports, "createAiChangeAnimator", {
|
|
1998
|
+
enumerable: true,
|
|
1999
|
+
get: function () { return chunkIY7H76CZ_cjs.createAiChangeAnimator; }
|
|
2000
|
+
});
|
|
2001
|
+
Object.defineProperty(exports, "createPptxAiBridge", {
|
|
2002
|
+
enumerable: true,
|
|
2003
|
+
get: function () { return chunkIY7H76CZ_cjs.createPptxAiBridge; }
|
|
2004
|
+
});
|
|
2005
|
+
Object.defineProperty(exports, "createPptxAiPanelController", {
|
|
2006
|
+
enumerable: true,
|
|
2007
|
+
get: function () { return chunkIY7H76CZ_cjs.createPptxAiPanelController; }
|
|
2008
|
+
});
|
|
2009
|
+
Object.defineProperty(exports, "deckDataFieldChanged", {
|
|
2010
|
+
enumerable: true,
|
|
2011
|
+
get: function () { return chunkIY7H76CZ_cjs.deckDataFieldChanged; }
|
|
2012
|
+
});
|
|
2013
|
+
Object.defineProperty(exports, "diffChangedElements", {
|
|
2014
|
+
enumerable: true,
|
|
2015
|
+
get: function () { return chunkIY7H76CZ_cjs.diffChangedElements; }
|
|
2016
|
+
});
|
|
2017
|
+
Object.defineProperty(exports, "exportAiChatLogs", {
|
|
2018
|
+
enumerable: true,
|
|
2019
|
+
get: function () { return chunkIY7H76CZ_cjs.exportAiChatLogs; }
|
|
2020
|
+
});
|
|
2021
|
+
Object.defineProperty(exports, "extractReadyToolCalls", {
|
|
2022
|
+
enumerable: true,
|
|
2023
|
+
get: function () { return chunkIY7H76CZ_cjs.extractReadyToolCalls; }
|
|
2024
|
+
});
|
|
2025
|
+
Object.defineProperty(exports, "focusTargetChips", {
|
|
2026
|
+
enumerable: true,
|
|
2027
|
+
get: function () { return chunkIY7H76CZ_cjs.focusTargetChips; }
|
|
2028
|
+
});
|
|
2029
|
+
Object.defineProperty(exports, "isAiFocusPinned", {
|
|
2030
|
+
enumerable: true,
|
|
2031
|
+
get: function () { return chunkIY7H76CZ_cjs.isAiFocusPinned; }
|
|
2032
|
+
});
|
|
2033
|
+
Object.defineProperty(exports, "isTwoTableFocus", {
|
|
2034
|
+
enumerable: true,
|
|
2035
|
+
get: function () { return chunkIY7H76CZ_cjs.isTwoTableFocus; }
|
|
2036
|
+
});
|
|
2037
|
+
Object.defineProperty(exports, "mergeTablesDirective", {
|
|
2038
|
+
enumerable: true,
|
|
2039
|
+
get: function () { return chunkIY7H76CZ_cjs.mergeTablesDirective; }
|
|
2040
|
+
});
|
|
2041
|
+
Object.defineProperty(exports, "pptxAiDeckTitle", {
|
|
2042
|
+
enumerable: true,
|
|
2043
|
+
get: function () { return chunkIY7H76CZ_cjs.pptxAiDeckTitle; }
|
|
2044
|
+
});
|
|
2045
|
+
Object.defineProperty(exports, "resolveAiEffectiveTargets", {
|
|
2046
|
+
enumerable: true,
|
|
2047
|
+
get: function () { return chunkIY7H76CZ_cjs.resolveAiEffectiveTargets; }
|
|
2048
|
+
});
|
|
2049
|
+
Object.defineProperty(exports, "resolveChangeAnimationConfig", {
|
|
2050
|
+
enumerable: true,
|
|
2051
|
+
get: function () { return chunkIY7H76CZ_cjs.resolveChangeAnimationConfig; }
|
|
2052
|
+
});
|
|
2053
|
+
Object.defineProperty(exports, "toLogChat", {
|
|
2054
|
+
enumerable: true,
|
|
2055
|
+
get: function () { return chunkIY7H76CZ_cjs.toLogChat; }
|
|
2056
|
+
});
|
|
2057
|
+
Object.defineProperty(exports, "toRenderableParts", {
|
|
2058
|
+
enumerable: true,
|
|
2059
|
+
get: function () { return chunkIY7H76CZ_cjs.toRenderableParts; }
|
|
2060
|
+
});
|
|
2061
|
+
Object.defineProperty(exports, "toolCallLine", {
|
|
2062
|
+
enumerable: true,
|
|
2063
|
+
get: function () { return chunkIY7H76CZ_cjs.toolCallLine; }
|
|
2064
|
+
});
|
|
2786
2065
|
Object.defineProperty(exports, "createChatHistoryStore", {
|
|
2787
2066
|
enumerable: true,
|
|
2788
2067
|
get: function () { return chunkA5MANNJR_cjs.createChatHistoryStore; }
|
|
@@ -2791,20 +2070,11 @@ Object.defineProperty(exports, "mergeTableElements", {
|
|
|
2791
2070
|
enumerable: true,
|
|
2792
2071
|
get: function () { return tableMerge.mergeTableElements; }
|
|
2793
2072
|
});
|
|
2794
|
-
exports.AI_CHANGE_ATTR = AI_CHANGE_ATTR;
|
|
2795
|
-
exports.AI_TOOL_FLASH_MS = AI_TOOL_FLASH_MS;
|
|
2796
2073
|
exports.BASE_SYSTEM_PROMPT = BASE_SYSTEM_PROMPT;
|
|
2797
2074
|
exports.BESPOKE_TOOL_ENTRIES = BESPOKE_TOOL_ENTRIES;
|
|
2798
2075
|
exports.MCP_TOOL_ENTRIES = MCP_TOOL_ENTRIES;
|
|
2799
2076
|
exports.ProposalStore = ProposalStore;
|
|
2800
|
-
exports.aiChangeAnimationCss = aiChangeAnimationCss;
|
|
2801
|
-
exports.aiFixDirective = aiFixDirective;
|
|
2802
2077
|
exports.allToolNames = allToolNames;
|
|
2803
|
-
exports.applyElementUpdate = applyElementUpdate;
|
|
2804
|
-
exports.applyShapeStyleUpdate = applyShapeStyleUpdate;
|
|
2805
|
-
exports.applyTextUpdate = applyTextUpdate;
|
|
2806
|
-
exports.buildChatLogExport = buildChatLogExport;
|
|
2807
|
-
exports.buildChatLogMarkdown = buildChatLogMarkdown;
|
|
2808
2078
|
exports.buildDeckContext = buildDeckContext;
|
|
2809
2079
|
exports.buildDeckOutline = buildDeckOutline;
|
|
2810
2080
|
exports.buildFocusedTargetsContext = buildFocusedTargetsContext;
|
|
@@ -2814,47 +2084,27 @@ exports.buildSlideMarkdown = buildSlideMarkdown;
|
|
|
2814
2084
|
exports.buildSystemPrompt = buildSystemPrompt;
|
|
2815
2085
|
exports.buildToolExecutors = buildToolExecutors;
|
|
2816
2086
|
exports.buildToolSet = buildToolSet;
|
|
2817
|
-
exports.changeGhostStyle = changeGhostStyle;
|
|
2818
2087
|
exports.clampToTokenBudget = clampToTokenBudget;
|
|
2819
|
-
exports.collectStoredChats = collectStoredChats;
|
|
2820
|
-
exports.computeFocusTargets = computeFocusTargets;
|
|
2821
|
-
exports.createAiChangeAnimator = createAiChangeAnimator;
|
|
2822
2088
|
exports.createAiChatHistoryController = createAiChatHistoryController;
|
|
2823
2089
|
exports.createAiChatSession = createAiChatSession;
|
|
2824
|
-
exports.createPptxAiBridge = createPptxAiBridge;
|
|
2825
|
-
exports.createPptxAiPanelController = createPptxAiPanelController;
|
|
2826
2090
|
exports.createVanillaChat = createVanillaChat;
|
|
2827
|
-
exports.deckDataFieldChanged = deckDataFieldChanged;
|
|
2828
2091
|
exports.deckIdFromBridge = deckIdFromBridge;
|
|
2829
2092
|
exports.deriveChatTitle = deriveChatTitle;
|
|
2830
2093
|
exports.describeToolActivity = describeToolActivity;
|
|
2831
|
-
exports.diffChangedElements = diffChangedElements;
|
|
2832
2094
|
exports.diffSlides = diffSlides;
|
|
2833
2095
|
exports.enabledToolNames = enabledToolNames;
|
|
2834
2096
|
exports.estimateTokens = estimateTokens;
|
|
2835
|
-
exports.exportAiChatLogs = exportAiChatLogs;
|
|
2836
|
-
exports.extractReadyToolCalls = extractReadyToolCalls;
|
|
2837
|
-
exports.focusTargetChips = focusTargetChips;
|
|
2838
2097
|
exports.humanizeDiffLine = humanizeDiffLine;
|
|
2839
2098
|
exports.isAiAvailable = isAiAvailable;
|
|
2840
|
-
exports.isAiFocusPinned = isAiFocusPinned;
|
|
2841
|
-
exports.isTwoTableFocus = isTwoTableFocus;
|
|
2842
2099
|
exports.loadAiSdk = loadAiSdk;
|
|
2843
|
-
exports.mergeTablesDirective = mergeTablesDirective;
|
|
2844
2100
|
exports.newChatId = newChatId;
|
|
2845
|
-
exports.pptxAiDeckTitle = pptxAiDeckTitle;
|
|
2846
2101
|
exports.requireElement = requireElement;
|
|
2847
2102
|
exports.requireSlide = requireSlide;
|
|
2848
2103
|
exports.resetAiSdkCache = resetAiSdkCache;
|
|
2849
|
-
exports.resolveAiEffectiveTargets = resolveAiEffectiveTargets;
|
|
2850
|
-
exports.resolveChangeAnimationConfig = resolveChangeAnimationConfig;
|
|
2851
2104
|
exports.resolveChatTransport = resolveChatTransport;
|
|
2852
2105
|
exports.routeWrite = routeWrite;
|
|
2853
2106
|
exports.runSharedTool = runSharedTool;
|
|
2854
2107
|
exports.slideTitle = slideTitle;
|
|
2855
2108
|
exports.summarizeToolArgs = summarizeToolArgs;
|
|
2856
|
-
exports.toLogChat = toLogChat;
|
|
2857
|
-
exports.toRenderableParts = toRenderableParts;
|
|
2858
|
-
exports.toolCallLine = toolCallLine;
|
|
2859
2109
|
exports.toolCanvasTarget = toolCanvasTarget;
|
|
2860
2110
|
exports.toolLabel = toolLabel;
|