@case-framework/survey-core 0.2.0 → 0.4.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/build/editor.d.mts +52 -12
- package/build/editor.d.mts.map +1 -1
- package/build/editor.mjs +223 -48
- package/build/editor.mjs.map +1 -1
- package/build/index.d.mts +80 -50
- package/build/index.d.mts.map +1 -1
- package/build/index.mjs +235 -169
- package/build/index.mjs.map +1 -1
- package/build/package.json +8 -8
- package/build/{survey-D3sMutUV.d.mts → survey-DShEOjyz.d.mts} +389 -82
- package/build/survey-DShEOjyz.d.mts.map +1 -0
- package/build/{survey-DQmpzihl.mjs → survey-yXdl8xkf.mjs} +479 -48
- package/build/survey-yXdl8xkf.mjs.map +1 -0
- package/package.json +8 -8
- package/build/survey-D3sMutUV.d.mts.map +0 -1
- package/build/survey-DQmpzihl.mjs.map +0 -1
package/build/editor.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { D as SurveyCardContent, E as NavigationContent, Gt as SurveyItemCore, Jt as RawSurveyItem, M as Content, S as RawSurveyAsset, k as SurveyItemTranslations, m as ItemTypeRegistry, t as Survey, vt as TemplateValueDefinition, w as JsonComponentContent, x as RawSurvey } from "./survey-DShEOjyz.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/editor/ai-context.d.ts
|
|
4
4
|
type SurveyAIContextScope = "tiny" | "focused" | "full";
|
|
@@ -169,22 +169,47 @@ interface CommitMeta {
|
|
|
169
169
|
label: string;
|
|
170
170
|
source?: CommitSource;
|
|
171
171
|
}
|
|
172
|
-
interface
|
|
173
|
-
|
|
172
|
+
interface AssetPatch {
|
|
173
|
+
assetId: string;
|
|
174
|
+
prev?: RawSurveyAsset;
|
|
175
|
+
next?: RawSurveyAsset;
|
|
176
|
+
}
|
|
177
|
+
interface BaseHistoryEntry {
|
|
174
178
|
timestamp: number;
|
|
175
179
|
meta: CommitMeta;
|
|
176
180
|
memorySize: number;
|
|
177
181
|
}
|
|
182
|
+
interface SurveySnapshotHistoryEntry extends BaseHistoryEntry {
|
|
183
|
+
kind: 'survey-snapshot';
|
|
184
|
+
survey: RawSurvey;
|
|
185
|
+
}
|
|
186
|
+
interface AssetChangeHistoryEntry extends BaseHistoryEntry {
|
|
187
|
+
kind: 'asset-change';
|
|
188
|
+
changes: AssetPatch[];
|
|
189
|
+
}
|
|
190
|
+
type HistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry;
|
|
191
|
+
type SerializedHistoryEntry = SurveySnapshotHistoryEntry | AssetChangeHistoryEntry | (BaseHistoryEntry & {
|
|
192
|
+
survey: RawSurvey;
|
|
193
|
+
});
|
|
178
194
|
declare class SurveyEditorUndoRedo {
|
|
179
195
|
private history;
|
|
180
196
|
private currentIndex;
|
|
181
197
|
private _config;
|
|
182
|
-
|
|
198
|
+
private _initialAssets?;
|
|
199
|
+
constructor(initialSurvey: RawSurvey, config?: Partial<UndoRedoConfig>, meta?: CommitMeta, initialAssets?: Record<string, RawSurveyAsset>);
|
|
200
|
+
private saveEntry;
|
|
183
201
|
private saveSnapshot;
|
|
202
|
+
private getBaseAssetsSize;
|
|
184
203
|
private cleanupHistory;
|
|
204
|
+
private dropOldestState;
|
|
185
205
|
private getTotalMemoryUsage;
|
|
206
|
+
private getStateAtIndex;
|
|
207
|
+
private applyAssetPatch;
|
|
208
|
+
private getAssetsAtIndex;
|
|
186
209
|
commit(survey: RawSurvey, meta: CommitMeta): void;
|
|
210
|
+
commitAssetChange(changes: AssetPatch[], meta: CommitMeta): void;
|
|
187
211
|
getCurrentState(): RawSurvey;
|
|
212
|
+
getCurrentAssets(): Record<string, RawSurveyAsset> | undefined;
|
|
188
213
|
undo(): RawSurvey | null;
|
|
189
214
|
redo(): RawSurvey | null;
|
|
190
215
|
canUndo(): boolean;
|
|
@@ -201,6 +226,7 @@ declare class SurveyEditorUndoRedo {
|
|
|
201
226
|
*/
|
|
202
227
|
getHistory(): Array<{
|
|
203
228
|
index: number;
|
|
229
|
+
kind: HistoryEntry['kind'];
|
|
204
230
|
meta: CommitMeta;
|
|
205
231
|
timestamp: number;
|
|
206
232
|
memorySize: number;
|
|
@@ -232,6 +258,7 @@ declare class SurveyEditorUndoRedo {
|
|
|
232
258
|
history: Array<HistoryEntry>;
|
|
233
259
|
currentIndex: number;
|
|
234
260
|
config: UndoRedoConfig;
|
|
261
|
+
initialAssets?: Record<string, RawSurveyAsset>;
|
|
235
262
|
};
|
|
236
263
|
/**
|
|
237
264
|
* Create a new SurveyEditorUndoRedo instance from JSON data
|
|
@@ -239,15 +266,11 @@ declare class SurveyEditorUndoRedo {
|
|
|
239
266
|
* @returns A new SurveyEditorUndoRedo instance with the restored state
|
|
240
267
|
*/
|
|
241
268
|
static deserialize(jsonData: {
|
|
242
|
-
history: Array<
|
|
243
|
-
survey: RawSurvey;
|
|
244
|
-
timestamp: number;
|
|
245
|
-
meta: CommitMeta;
|
|
246
|
-
memorySize: number;
|
|
247
|
-
}>;
|
|
269
|
+
history: Array<SerializedHistoryEntry>;
|
|
248
270
|
currentIndex: number;
|
|
249
271
|
config: UndoRedoConfig;
|
|
250
|
-
|
|
272
|
+
initialAssets?: Record<string, RawSurveyAsset>;
|
|
273
|
+
}, initialAssetsOverride?: Record<string, RawSurveyAsset>): SurveyEditorUndoRedo;
|
|
251
274
|
}
|
|
252
275
|
//#endregion
|
|
253
276
|
//#region src/editor/survey-editor.d.ts
|
|
@@ -272,6 +295,7 @@ declare class SurveyEditor {
|
|
|
272
295
|
get hasUncommittedChanges(): boolean;
|
|
273
296
|
get undoRedo(): SurveyEditorUndoRedo;
|
|
274
297
|
commit(meta: CommitMeta): void;
|
|
298
|
+
private restoreHistoryState;
|
|
275
299
|
commitIfNeeded(): void;
|
|
276
300
|
undo(): boolean;
|
|
277
301
|
redo(): boolean;
|
|
@@ -390,6 +414,22 @@ declare class SurveyEditor {
|
|
|
390
414
|
* Remove a template value.
|
|
391
415
|
*/
|
|
392
416
|
removeTemplateValue(key: string): void;
|
|
417
|
+
/**
|
|
418
|
+
* Get a survey asset immutably.
|
|
419
|
+
*/
|
|
420
|
+
getAsset(assetId: string): RawSurveyAsset | undefined;
|
|
421
|
+
/**
|
|
422
|
+
* Get all survey assets immutably.
|
|
423
|
+
*/
|
|
424
|
+
getAssets(): Map<string, RawSurveyAsset>;
|
|
425
|
+
/**
|
|
426
|
+
* Add or replace a survey asset.
|
|
427
|
+
*/
|
|
428
|
+
setAsset(assetId: string, asset: RawSurveyAsset): void;
|
|
429
|
+
/**
|
|
430
|
+
* Remove a survey asset.
|
|
431
|
+
*/
|
|
432
|
+
removeAsset(assetId: string): void;
|
|
393
433
|
/**
|
|
394
434
|
* Copy a survey item and all its data to clipboard format
|
|
395
435
|
* @param itemId - The ID of the item to copy
|
|
@@ -405,5 +445,5 @@ declare class SurveyEditor {
|
|
|
405
445
|
pasteItem(clipboardData: SurveyItemClipboardData, target: Target): string;
|
|
406
446
|
}
|
|
407
447
|
//#endregion
|
|
408
|
-
export { BuildSurveyAIContextPackOptions, CommitMeta, CommitSource, ItemCopyPaste, SerializedSurveyEditor, SerializedTranslations, SurveyAIContextIndexes, SurveyAIContextPack, SurveyAIContextPurpose, SurveyAIContextScope, SurveyAIFocus, SurveyAIItemContextNode, SurveyAIKeyIndexEntry, SurveyAIOutlineNode, SurveyAITranslationSnippet, SurveyEditor, SurveyEditorConfig, SurveyEditorUndoRedo, SurveyItemClipboardData, Target, UndoRedoConfig, buildSurveyAIContextPack };
|
|
448
|
+
export { AssetPatch, BuildSurveyAIContextPackOptions, CommitMeta, CommitSource, ItemCopyPaste, SerializedSurveyEditor, SerializedTranslations, SurveyAIContextIndexes, SurveyAIContextPack, SurveyAIContextPurpose, SurveyAIContextScope, SurveyAIFocus, SurveyAIItemContextNode, SurveyAIKeyIndexEntry, SurveyAIOutlineNode, SurveyAITranslationSnippet, SurveyEditor, SurveyEditorConfig, SurveyEditorUndoRedo, SurveyItemClipboardData, Target, UndoRedoConfig, buildSurveyAIContextPack };
|
|
409
449
|
//# sourceMappingURL=editor.d.mts.map
|
package/build/editor.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/ai-context.ts","../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;KAKY,oBAAA;AAAA,KACA,sBAAA;AAAA,UAQK,mBAAA;EACf,MAAA;EACA,QAAA;EACA,KAAA;EACA,QAAA;EACA,GAAA;EACA,OAAA;EACA,SAAA;EACA,UAAA;AAAA;AAAA,UAGe,aAAA;EACf,WAAA;EACA,YAAA;EACA,WAAA;EACA,cAAA;EACA,YAAA;AAAA;AAAA,UAGe,0BAAA;EACf,MAAA;EACA,UAAA;EACA,IAAA;AAAA;AAAA,UAGe,uBAAA;EACf,MAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,SAAA;EACA,WAAA;EACA,YAAA,EAAc,0BAAA;EACd,WAAA,EAAa,uBAAA;AAAA;AAAA,UAGE,qBAAA;EACf,MAAA;EACA,QAAA;EACA,GAAA;EACA,OAAA;EACA,SAAA;EACA,IAAA;AAAA;AAAA,UAGe,sBAAA;EACf,QAAA,EAAU,qBAAA;EACV,aAAA;AAAA;AAAA,UAGe,mBAAA;EACf,OAAA,EAAS,sBAAA;EACT,KAAA,EAAO,oBAAA;EACP,SAAA;EACA,OAAA;EACA,SAAA;EACA,OAAA,EAAS,mBAAA;EACT,KAAA,GAAQ,aAAA;EACR,SAAA,GAAY,uBAAA;EACZ,OAAA,GAAU,sBAAA;EACV,KAAA;IACE,gBAAA;IACA,iBAAA;IACA,sBAAA;EAAA;EAEF,SAAA,GAAY,SAAA;AAAA;AAAA,UAGG,+BAAA;EACf,OAAA,GAAU,sBAAA;EACV,KAAA,GAAQ,oBAAA;EACR,WAAA;EACA,gBAAA;EACA,YAAA;EACA,cAAA;EACA,oBAAA;EACA,kBAAA;EACA,+BAAA;EACA,2BAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"editor.d.mts","names":[],"sources":["../src/editor/ai-context.ts","../src/editor/types.ts","../src/editor/item-copy-paste.ts","../src/editor/undo-redo.ts","../src/editor/survey-editor.ts"],"mappings":";;;KAKY,oBAAA;AAAA,KACA,sBAAA;AAAA,UAQK,mBAAA;EACf,MAAA;EACA,QAAA;EACA,KAAA;EACA,QAAA;EACA,GAAA;EACA,OAAA;EACA,SAAA;EACA,UAAA;AAAA;AAAA,UAGe,aAAA;EACf,WAAA;EACA,YAAA;EACA,WAAA;EACA,cAAA;EACA,YAAA;AAAA;AAAA,UAGe,0BAAA;EACf,MAAA;EACA,UAAA;EACA,IAAA;AAAA;AAAA,UAGe,uBAAA;EACf,MAAA;EACA,QAAA;EACA,OAAA;EACA,OAAA;EACA,SAAA;EACA,WAAA;EACA,YAAA,EAAc,0BAAA;EACd,WAAA,EAAa,uBAAA;AAAA;AAAA,UAGE,qBAAA;EACf,MAAA;EACA,QAAA;EACA,GAAA;EACA,OAAA;EACA,SAAA;EACA,IAAA;AAAA;AAAA,UAGe,sBAAA;EACf,QAAA,EAAU,qBAAA;EACV,aAAA;AAAA;AAAA,UAGe,mBAAA;EACf,OAAA,EAAS,sBAAA;EACT,KAAA,EAAO,oBAAA;EACP,SAAA;EACA,OAAA;EACA,SAAA;EACA,OAAA,EAAS,mBAAA;EACT,KAAA,GAAQ,aAAA;EACR,SAAA,GAAY,uBAAA;EACZ,OAAA,GAAU,sBAAA;EACV,KAAA;IACE,gBAAA;IACA,iBAAA;IACA,sBAAA;EAAA;EAEF,SAAA,GAAY,SAAA;AAAA;AAAA,UAGG,+BAAA;EACf,OAAA,GAAU,sBAAA;EACV,KAAA,GAAQ,oBAAA;EACR,WAAA;EACA,gBAAA;EACA,YAAA;EACA,cAAA;EACA,oBAAA;EACA,kBAAA;EACA,+BAAA;EACA,2BAAA;AAAA;AAAA,iBAiZc,wBAAA,CACd,MAAA,EAAQ,M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;;EIyGR,mBAAA,CAAoB,GAAA;EJvGnB;;;EI+GD,QAAA,CAAS,OAAA,WAAkB,cAAA;;;AH/lB7B;EGumBE,SAAA,CAAA,GAAa,GAAA,SAAY,cAAA;;;;EAOzB,QAAA,CAAS,OAAA,UAAiB,KAAA,EAAO,cAAA;;;AFnmBnC;EEmnBE,WAAA,CAAY,OAAA;;;;AF9mBd;;EEkoBE,QAAA,CAAS,MAAA,WAAiB,uBAAA;EF7nBd;;;;;;EEwoBZ,SAAA,CAAU,aAAA,EAAe,uBAAA,EAAyB,MAAA,EAAQ,MAAA;AAAA"}
|
package/build/editor.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { $ as generateId, a as getContentPlainText, nt as structuredCloneMethod, t as Survey, u as SurveyItemTranslations, v as GroupItemCore } from "./survey-yXdl8xkf.mjs";
|
|
3
2
|
//#region src/editor/ai-context.ts
|
|
4
3
|
const DEFAULT_SCOPE_LIMITS = {
|
|
5
4
|
tiny: 40,
|
|
@@ -175,10 +174,7 @@ const normalizeSnippetText = (text, maxChars) => {
|
|
|
175
174
|
return text.trim().replace(/\s+/g, " ").slice(0, maxChars);
|
|
176
175
|
};
|
|
177
176
|
const getContentText = (content, maxChars) => {
|
|
178
|
-
|
|
179
|
-
const maybeText = content.content;
|
|
180
|
-
if (typeof maybeText !== "string") return null;
|
|
181
|
-
const normalized = normalizeSnippetText(maybeText, maxChars);
|
|
177
|
+
const normalized = normalizeSnippetText(getContentPlainText(content), maxChars);
|
|
182
178
|
return normalized.length > 0 ? normalized : null;
|
|
183
179
|
};
|
|
184
180
|
function getItemTranslationSnippets(survey, itemId, maxSnippets, textLimit) {
|
|
@@ -300,7 +296,6 @@ function buildSurveyAIContextPack(survey, options = {}) {
|
|
|
300
296
|
rawSurvey: includeRawSurvey ? survey.serialize() : void 0
|
|
301
297
|
};
|
|
302
298
|
}
|
|
303
|
-
|
|
304
299
|
//#endregion
|
|
305
300
|
//#region src/editor/item-copy-paste.ts
|
|
306
301
|
var ItemCopyPaste = class ItemCopyPaste {
|
|
@@ -441,7 +436,7 @@ var ItemCopyPaste = class ItemCopyPaste {
|
|
|
441
436
|
*/
|
|
442
437
|
updateItemIdsInData(itemData, idMapping) {
|
|
443
438
|
const updatedData = JSON.parse(JSON.stringify(itemData));
|
|
444
|
-
if (updatedData.itemType ===
|
|
439
|
+
if (updatedData.itemType === "group" && updatedData.config) {
|
|
445
440
|
const config = updatedData.config;
|
|
446
441
|
if (config.items) config.items = config.items.map((childId) => idMapping[childId] ?? childId);
|
|
447
442
|
}
|
|
@@ -462,6 +457,11 @@ var ItemCopyPaste = class ItemCopyPaste {
|
|
|
462
457
|
if (itemData.validations) Object.values(itemData.validations).forEach((expr) => {
|
|
463
458
|
if (expr) this.updateExpressionReferences(expr, idMapping);
|
|
464
459
|
});
|
|
460
|
+
if (itemData.prefills) itemData.prefills.forEach((prefill) => {
|
|
461
|
+
if (prefill.when) this.updateExpressionReferences(prefill.when, idMapping);
|
|
462
|
+
if (prefill.source.type === "expression") this.updateExpressionReferences(prefill.source.expression, idMapping);
|
|
463
|
+
if (prefill.source.type === "previousResponse") prefill.source.ref.itemId = idMapping[prefill.source.ref.itemId] ?? prefill.source.ref.itemId;
|
|
464
|
+
});
|
|
465
465
|
}
|
|
466
466
|
/**
|
|
467
467
|
* Update references in a single expression (recursive)
|
|
@@ -502,7 +502,6 @@ var ItemCopyPaste = class ItemCopyPaste {
|
|
|
502
502
|
return clipboardData.type === "survey-item" && clipboardData.version === "1.0.0" && clipboardData.rootItemId !== void 0;
|
|
503
503
|
}
|
|
504
504
|
};
|
|
505
|
-
|
|
506
505
|
//#endregion
|
|
507
506
|
//#region src/editor/undo-redo.ts
|
|
508
507
|
const CommitSource = {
|
|
@@ -531,52 +530,152 @@ var MemoryCalculator = class {
|
|
|
531
530
|
return `${size.toFixed(1)} ${units[unitIndex]}`;
|
|
532
531
|
}
|
|
533
532
|
};
|
|
533
|
+
function cloneAssets(assets) {
|
|
534
|
+
if (!assets || Object.keys(assets).length === 0) return;
|
|
535
|
+
return structuredCloneMethod(assets);
|
|
536
|
+
}
|
|
537
|
+
function normalizeHistoryEntry(entry) {
|
|
538
|
+
if ("kind" in entry) {
|
|
539
|
+
if (entry.kind === "survey-snapshot") return {
|
|
540
|
+
kind: "survey-snapshot",
|
|
541
|
+
survey: structuredCloneMethod(entry.survey),
|
|
542
|
+
timestamp: entry.timestamp,
|
|
543
|
+
meta: entry.meta,
|
|
544
|
+
memorySize: entry.memorySize
|
|
545
|
+
};
|
|
546
|
+
return {
|
|
547
|
+
kind: "asset-change",
|
|
548
|
+
changes: structuredCloneMethod(entry.changes),
|
|
549
|
+
timestamp: entry.timestamp,
|
|
550
|
+
meta: entry.meta,
|
|
551
|
+
memorySize: entry.memorySize
|
|
552
|
+
};
|
|
553
|
+
}
|
|
554
|
+
return {
|
|
555
|
+
kind: "survey-snapshot",
|
|
556
|
+
survey: structuredCloneMethod(entry.survey),
|
|
557
|
+
timestamp: entry.timestamp,
|
|
558
|
+
meta: entry.meta,
|
|
559
|
+
memorySize: entry.memorySize
|
|
560
|
+
};
|
|
561
|
+
}
|
|
534
562
|
var SurveyEditorUndoRedo = class SurveyEditorUndoRedo {
|
|
535
563
|
history = [];
|
|
536
564
|
currentIndex = -1;
|
|
537
565
|
_config;
|
|
566
|
+
_initialAssets;
|
|
538
567
|
constructor(initialSurvey, config = {}, meta = {
|
|
539
568
|
label: "Initial state",
|
|
540
569
|
source: CommitSource.SYSTEM
|
|
541
|
-
}) {
|
|
570
|
+
}, initialAssets) {
|
|
542
571
|
this._config = {
|
|
543
572
|
maxTotalMemoryMB: 50,
|
|
544
573
|
minHistorySize: 10,
|
|
545
574
|
maxHistorySize: 200,
|
|
546
575
|
...config
|
|
547
576
|
};
|
|
577
|
+
this._initialAssets = cloneAssets(initialAssets);
|
|
548
578
|
this.saveSnapshot(initialSurvey, meta);
|
|
549
579
|
}
|
|
550
|
-
|
|
551
|
-
const
|
|
580
|
+
saveEntry(entry) {
|
|
581
|
+
const payload = entry.kind === "survey-snapshot" ? {
|
|
582
|
+
kind: entry.kind,
|
|
583
|
+
survey: entry.survey
|
|
584
|
+
} : {
|
|
585
|
+
kind: entry.kind,
|
|
586
|
+
changes: entry.changes
|
|
587
|
+
};
|
|
588
|
+
const memorySize = MemoryCalculator.calculateSize(payload);
|
|
552
589
|
this.history = this.history.slice(0, this.currentIndex + 1);
|
|
553
590
|
this.history.push({
|
|
554
|
-
|
|
591
|
+
...structuredCloneMethod(entry),
|
|
555
592
|
timestamp: Date.now(),
|
|
556
|
-
meta,
|
|
557
593
|
memorySize
|
|
558
594
|
});
|
|
559
595
|
this.currentIndex++;
|
|
560
596
|
this.cleanupHistory();
|
|
561
597
|
}
|
|
598
|
+
saveSnapshot(survey, meta) {
|
|
599
|
+
this.saveEntry({
|
|
600
|
+
kind: "survey-snapshot",
|
|
601
|
+
survey: structuredCloneMethod(survey),
|
|
602
|
+
meta
|
|
603
|
+
});
|
|
604
|
+
}
|
|
605
|
+
getBaseAssetsSize() {
|
|
606
|
+
return this._initialAssets ? MemoryCalculator.calculateSize(this._initialAssets) : 0;
|
|
607
|
+
}
|
|
562
608
|
cleanupHistory() {
|
|
563
|
-
let totalMemory = this.getTotalMemoryUsage();
|
|
564
609
|
const maxMemoryBytes = this._config.maxTotalMemoryMB * 1024 * 1024;
|
|
565
|
-
while (this.history.length > this._config.minHistorySize && (
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
610
|
+
while (this.history.length > this._config.minHistorySize && (this.getTotalMemoryUsage() > maxMemoryBytes || this.history.length > this._config.maxHistorySize)) if (this.dropOldestState() <= 0) break;
|
|
611
|
+
}
|
|
612
|
+
dropOldestState() {
|
|
613
|
+
if (this.history.length <= 1) return 0;
|
|
614
|
+
const nextStateIndex = 1;
|
|
615
|
+
const nextStateSurvey = this.getStateAtIndex(nextStateIndex);
|
|
616
|
+
const nextStateAssets = this.getAssetsAtIndex(nextStateIndex);
|
|
617
|
+
const nextEntry = this.history[nextStateIndex];
|
|
618
|
+
const newFirstEntry = {
|
|
619
|
+
kind: "survey-snapshot",
|
|
620
|
+
survey: nextStateSurvey,
|
|
621
|
+
meta: nextEntry.meta,
|
|
622
|
+
timestamp: nextEntry.timestamp,
|
|
623
|
+
memorySize: MemoryCalculator.calculateSize({
|
|
624
|
+
kind: "survey-snapshot",
|
|
625
|
+
survey: nextStateSurvey
|
|
626
|
+
})
|
|
627
|
+
};
|
|
628
|
+
const removedBytes = this.history[0].memorySize;
|
|
629
|
+
this._initialAssets = cloneAssets(nextStateAssets);
|
|
630
|
+
this.history = [newFirstEntry, ...this.history.slice(nextStateIndex + 1)];
|
|
631
|
+
this.currentIndex--;
|
|
632
|
+
return removedBytes;
|
|
570
633
|
}
|
|
571
634
|
getTotalMemoryUsage() {
|
|
572
|
-
return this.history.reduce((total, entry) => total + entry.memorySize, 0);
|
|
635
|
+
return this.getBaseAssetsSize() + this.history.reduce((total, entry) => total + entry.memorySize, 0);
|
|
636
|
+
}
|
|
637
|
+
getStateAtIndex(index) {
|
|
638
|
+
if (index < 0 || index >= this.history.length) throw new Error("Invalid history state");
|
|
639
|
+
for (let i = index; i >= 0; i--) {
|
|
640
|
+
const entry = this.history[i];
|
|
641
|
+
if (entry.kind === "survey-snapshot") return structuredCloneMethod(entry.survey);
|
|
642
|
+
}
|
|
643
|
+
throw new Error("Invalid history state");
|
|
644
|
+
}
|
|
645
|
+
applyAssetPatch(assets, patch) {
|
|
646
|
+
const nextAssets = structuredCloneMethod(assets);
|
|
647
|
+
if (patch.next) nextAssets[patch.assetId] = structuredCloneMethod(patch.next);
|
|
648
|
+
else delete nextAssets[patch.assetId];
|
|
649
|
+
return nextAssets;
|
|
650
|
+
}
|
|
651
|
+
getAssetsAtIndex(index) {
|
|
652
|
+
if (index < 0 || index >= this.history.length) throw new Error("Invalid history state");
|
|
653
|
+
let assets = cloneAssets(this._initialAssets) ?? {};
|
|
654
|
+
for (let i = 1; i <= index; i++) {
|
|
655
|
+
const entry = this.history[i];
|
|
656
|
+
if (entry.kind !== "asset-change") continue;
|
|
657
|
+
for (const patch of entry.changes) assets = this.applyAssetPatch(assets, patch);
|
|
658
|
+
}
|
|
659
|
+
return Object.keys(assets).length > 0 ? assets : void 0;
|
|
573
660
|
}
|
|
574
661
|
commit(survey, meta) {
|
|
575
662
|
this.saveSnapshot(survey, meta);
|
|
576
663
|
}
|
|
664
|
+
commitAssetChange(changes, meta) {
|
|
665
|
+
if (changes.length === 0) return;
|
|
666
|
+
this.saveEntry({
|
|
667
|
+
kind: "asset-change",
|
|
668
|
+
changes: structuredCloneMethod(changes),
|
|
669
|
+
meta
|
|
670
|
+
});
|
|
671
|
+
}
|
|
577
672
|
getCurrentState() {
|
|
578
673
|
if (this.currentIndex < 0 || this.currentIndex >= this.history.length) throw new Error("Invalid history state");
|
|
579
|
-
return
|
|
674
|
+
return this.getStateAtIndex(this.currentIndex);
|
|
675
|
+
}
|
|
676
|
+
getCurrentAssets() {
|
|
677
|
+
if (this.currentIndex < 0 || this.currentIndex >= this.history.length) throw new Error("Invalid history state");
|
|
678
|
+
return this.getAssetsAtIndex(this.currentIndex);
|
|
580
679
|
}
|
|
581
680
|
undo() {
|
|
582
681
|
if (!this.canUndo()) return null;
|
|
@@ -617,6 +716,7 @@ var SurveyEditorUndoRedo = class SurveyEditorUndoRedo {
|
|
|
617
716
|
getHistory() {
|
|
618
717
|
return this.history.map((entry, index) => ({
|
|
619
718
|
index,
|
|
719
|
+
kind: entry.kind,
|
|
620
720
|
meta: entry.meta,
|
|
621
721
|
timestamp: entry.timestamp,
|
|
622
722
|
memorySize: entry.memorySize,
|
|
@@ -657,14 +757,25 @@ var SurveyEditorUndoRedo = class SurveyEditorUndoRedo {
|
|
|
657
757
|
*/
|
|
658
758
|
serialize() {
|
|
659
759
|
return {
|
|
660
|
-
history: this.history.map((entry) =>
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
760
|
+
history: this.history.map((entry) => {
|
|
761
|
+
if (entry.kind === "survey-snapshot") return {
|
|
762
|
+
kind: "survey-snapshot",
|
|
763
|
+
survey: entry.survey,
|
|
764
|
+
timestamp: entry.timestamp,
|
|
765
|
+
meta: entry.meta,
|
|
766
|
+
memorySize: entry.memorySize
|
|
767
|
+
};
|
|
768
|
+
return {
|
|
769
|
+
kind: "asset-change",
|
|
770
|
+
changes: entry.changes,
|
|
771
|
+
timestamp: entry.timestamp,
|
|
772
|
+
meta: entry.meta,
|
|
773
|
+
memorySize: entry.memorySize
|
|
774
|
+
};
|
|
775
|
+
}),
|
|
666
776
|
currentIndex: this.currentIndex,
|
|
667
|
-
config: { ...this._config }
|
|
777
|
+
config: { ...this._config },
|
|
778
|
+
initialAssets: cloneAssets(this._initialAssets)
|
|
668
779
|
};
|
|
669
780
|
}
|
|
670
781
|
/**
|
|
@@ -672,24 +783,34 @@ var SurveyEditorUndoRedo = class SurveyEditorUndoRedo {
|
|
|
672
783
|
* @param jsonData The serialized undo/redo state
|
|
673
784
|
* @returns A new SurveyEditorUndoRedo instance with the restored state
|
|
674
785
|
*/
|
|
675
|
-
static deserialize(jsonData) {
|
|
786
|
+
static deserialize(jsonData, initialAssetsOverride) {
|
|
676
787
|
if (!jsonData.history || !Array.isArray(jsonData.history) || jsonData.history.length === 0) throw new Error("Invalid object: history must be an array and must not be empty");
|
|
677
788
|
if (typeof jsonData.currentIndex !== "number" || jsonData.currentIndex < 0 || jsonData.currentIndex >= jsonData.history.length) throw new Error("Invalid object: currentIndex must be a valid index within the history array");
|
|
678
789
|
if (!jsonData.config) throw new Error("Invalid object: config is required");
|
|
679
|
-
const
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
}));
|
|
790
|
+
const normalizedHistory = jsonData.history.map(normalizeHistoryEntry);
|
|
791
|
+
const firstEntry = normalizedHistory[0];
|
|
792
|
+
const instance = new SurveyEditorUndoRedo(firstEntry.kind === "survey-snapshot" ? firstEntry.survey : (() => {
|
|
793
|
+
throw new Error("Invalid object: first history entry must resolve to a survey snapshot");
|
|
794
|
+
})(), jsonData.config, firstEntry.meta, initialAssetsOverride ?? jsonData.initialAssets);
|
|
795
|
+
instance.history = normalizedHistory;
|
|
686
796
|
instance.currentIndex = jsonData.currentIndex;
|
|
797
|
+
instance._initialAssets = cloneAssets(initialAssetsOverride ?? jsonData.initialAssets);
|
|
687
798
|
return instance;
|
|
688
799
|
}
|
|
689
800
|
};
|
|
690
|
-
|
|
691
801
|
//#endregion
|
|
692
802
|
//#region src/editor/survey-editor.ts
|
|
803
|
+
function stripAssetsFromSurveySnapshot(survey) {
|
|
804
|
+
const snapshot = structuredCloneMethod(survey);
|
|
805
|
+
delete snapshot.assets;
|
|
806
|
+
return snapshot;
|
|
807
|
+
}
|
|
808
|
+
function mergeSurveySnapshotWithAssets(snapshot, assets) {
|
|
809
|
+
const merged = structuredCloneMethod(snapshot);
|
|
810
|
+
if (assets && Object.keys(assets).length > 0) merged.assets = structuredCloneMethod(assets);
|
|
811
|
+
else delete merged.assets;
|
|
812
|
+
return merged;
|
|
813
|
+
}
|
|
693
814
|
var SurveyEditor = class SurveyEditor {
|
|
694
815
|
_survey;
|
|
695
816
|
_undoRedo;
|
|
@@ -699,7 +820,8 @@ var SurveyEditor = class SurveyEditor {
|
|
|
699
820
|
this._survey = survey;
|
|
700
821
|
const { pluginRegistry, ...undoRedoConfig } = config;
|
|
701
822
|
this._pluginRegistry = pluginRegistry;
|
|
702
|
-
|
|
823
|
+
const serialized = survey.serialize();
|
|
824
|
+
this._undoRedo = new SurveyEditorUndoRedo(stripAssetsFromSurveySnapshot(serialized), undoRedoConfig, meta, serialized.assets);
|
|
703
825
|
}
|
|
704
826
|
/** Returns an immutable copy of the current survey state. */
|
|
705
827
|
get survey() {
|
|
@@ -714,9 +836,13 @@ var SurveyEditor = class SurveyEditor {
|
|
|
714
836
|
return this._undoRedo;
|
|
715
837
|
}
|
|
716
838
|
commit(meta) {
|
|
717
|
-
|
|
839
|
+
if (!this._hasUncommittedChanges) return;
|
|
840
|
+
this._undoRedo.commit(stripAssetsFromSurveySnapshot(this._survey.serialize()), meta);
|
|
718
841
|
this._hasUncommittedChanges = false;
|
|
719
842
|
}
|
|
843
|
+
restoreHistoryState(snapshot, assets) {
|
|
844
|
+
this._survey = Survey.fromJson(mergeSurveySnapshotWithAssets(snapshot, assets), this._pluginRegistry);
|
|
845
|
+
}
|
|
720
846
|
commitIfNeeded() {
|
|
721
847
|
if (this._hasUncommittedChanges) this.commit({
|
|
722
848
|
label: "Latest content changes",
|
|
@@ -725,13 +851,13 @@ var SurveyEditor = class SurveyEditor {
|
|
|
725
851
|
}
|
|
726
852
|
undo() {
|
|
727
853
|
if (this._hasUncommittedChanges) {
|
|
728
|
-
this.
|
|
854
|
+
this.restoreHistoryState(this._undoRedo.getCurrentState(), this._undoRedo.getCurrentAssets());
|
|
729
855
|
this._hasUncommittedChanges = false;
|
|
730
856
|
return true;
|
|
731
857
|
} else {
|
|
732
858
|
const previousState = this._undoRedo.undo();
|
|
733
859
|
if (previousState) {
|
|
734
|
-
this.
|
|
860
|
+
this.restoreHistoryState(previousState, this._undoRedo.getCurrentAssets());
|
|
735
861
|
this._hasUncommittedChanges = false;
|
|
736
862
|
return true;
|
|
737
863
|
}
|
|
@@ -742,7 +868,7 @@ var SurveyEditor = class SurveyEditor {
|
|
|
742
868
|
if (this._hasUncommittedChanges) return false;
|
|
743
869
|
const nextState = this._undoRedo.redo();
|
|
744
870
|
if (nextState) {
|
|
745
|
-
this.
|
|
871
|
+
this.restoreHistoryState(nextState, this._undoRedo.getCurrentAssets());
|
|
746
872
|
this._hasUncommittedChanges = false;
|
|
747
873
|
return true;
|
|
748
874
|
}
|
|
@@ -755,7 +881,7 @@ var SurveyEditor = class SurveyEditor {
|
|
|
755
881
|
if (this._hasUncommittedChanges) return false;
|
|
756
882
|
const targetState = this._undoRedo.jumpToIndex(targetIndex);
|
|
757
883
|
if (targetState) {
|
|
758
|
-
this.
|
|
884
|
+
this.restoreHistoryState(targetState, this._undoRedo.getCurrentAssets());
|
|
759
885
|
this._hasUncommittedChanges = false;
|
|
760
886
|
return true;
|
|
761
887
|
}
|
|
@@ -808,8 +934,14 @@ var SurveyEditor = class SurveyEditor {
|
|
|
808
934
|
if (typeof jsonData.hasUncommittedChanges !== "boolean") throw new Error("Invalid object: hasUncommittedChanges must be a boolean");
|
|
809
935
|
if (jsonData.version && !jsonData.version.startsWith("1.")) console.warn(`Warning: Loading SurveyEditor with version ${jsonData.version}, current version is 1.0.0`);
|
|
810
936
|
const editor = new SurveyEditor(Survey.fromJson(jsonData.survey, pluginRegistry), { pluginRegistry });
|
|
811
|
-
editor._undoRedo = SurveyEditorUndoRedo.deserialize(
|
|
812
|
-
|
|
937
|
+
editor._undoRedo = SurveyEditorUndoRedo.deserialize({
|
|
938
|
+
...jsonData.undoRedo,
|
|
939
|
+
history: jsonData.undoRedo.history.map((entry) => "survey" in entry ? {
|
|
940
|
+
...entry,
|
|
941
|
+
survey: stripAssetsFromSurveySnapshot(entry.survey)
|
|
942
|
+
} : entry)
|
|
943
|
+
}, jsonData.survey.assets);
|
|
944
|
+
editor._hasUncommittedChanges = JSON.stringify(stripAssetsFromSurveySnapshot(jsonData.survey)) !== JSON.stringify(editor._undoRedo.getCurrentState());
|
|
813
945
|
return editor;
|
|
814
946
|
}
|
|
815
947
|
markAsModified() {
|
|
@@ -923,8 +1055,8 @@ var SurveyEditor = class SurveyEditor {
|
|
|
923
1055
|
this.markAsModified();
|
|
924
1056
|
}
|
|
925
1057
|
updateItemTranslations(itemId, updatedContent) {
|
|
1058
|
+
if (!this._survey.surveyItems.get(itemId)) return false;
|
|
926
1059
|
this.markAsModified();
|
|
927
|
-
if (!this._survey.surveyItems.get(itemId)) throw new Error(`Item with id '${itemId}' not found`);
|
|
928
1060
|
this._survey.translations.setItemTranslations(itemId, updatedContent);
|
|
929
1061
|
return true;
|
|
930
1062
|
}
|
|
@@ -1000,6 +1132,49 @@ var SurveyEditor = class SurveyEditor {
|
|
|
1000
1132
|
this._survey.deleteTemplateValue(key);
|
|
1001
1133
|
}
|
|
1002
1134
|
/**
|
|
1135
|
+
* Get a survey asset immutably.
|
|
1136
|
+
*/
|
|
1137
|
+
getAsset(assetId) {
|
|
1138
|
+
const asset = this._survey.getAsset(assetId);
|
|
1139
|
+
return asset ? structuredCloneMethod(asset) : void 0;
|
|
1140
|
+
}
|
|
1141
|
+
/**
|
|
1142
|
+
* Get all survey assets immutably.
|
|
1143
|
+
*/
|
|
1144
|
+
getAssets() {
|
|
1145
|
+
return this._survey.getAssets();
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* Add or replace a survey asset.
|
|
1149
|
+
*/
|
|
1150
|
+
setAsset(assetId, asset) {
|
|
1151
|
+
const previousAsset = this._survey.getAsset(assetId);
|
|
1152
|
+
this._survey.setAsset(assetId, structuredCloneMethod(asset));
|
|
1153
|
+
this._undoRedo.commitAssetChange([{
|
|
1154
|
+
assetId,
|
|
1155
|
+
prev: previousAsset,
|
|
1156
|
+
next: structuredCloneMethod(asset)
|
|
1157
|
+
}], {
|
|
1158
|
+
label: `Update asset: ${assetId}`,
|
|
1159
|
+
source: CommitSource.USER
|
|
1160
|
+
});
|
|
1161
|
+
}
|
|
1162
|
+
/**
|
|
1163
|
+
* Remove a survey asset.
|
|
1164
|
+
*/
|
|
1165
|
+
removeAsset(assetId) {
|
|
1166
|
+
const previousAsset = this._survey.getAsset(assetId);
|
|
1167
|
+
if (!previousAsset) return;
|
|
1168
|
+
this._survey.deleteAsset(assetId);
|
|
1169
|
+
this._undoRedo.commitAssetChange([{
|
|
1170
|
+
assetId,
|
|
1171
|
+
prev: previousAsset
|
|
1172
|
+
}], {
|
|
1173
|
+
label: `Remove asset: ${assetId}`,
|
|
1174
|
+
source: CommitSource.USER
|
|
1175
|
+
});
|
|
1176
|
+
}
|
|
1177
|
+
/**
|
|
1003
1178
|
* Copy a survey item and all its data to clipboard format
|
|
1004
1179
|
* @param itemId - The ID of the item to copy
|
|
1005
1180
|
* @returns Clipboard data that can be serialized to JSON for clipboard
|
|
@@ -1018,7 +1193,7 @@ var SurveyEditor = class SurveyEditor {
|
|
|
1018
1193
|
return new ItemCopyPaste(this._survey).pasteItem(clipboardData, target);
|
|
1019
1194
|
}
|
|
1020
1195
|
};
|
|
1021
|
-
|
|
1022
1196
|
//#endregion
|
|
1023
1197
|
export { CommitSource, ItemCopyPaste, SurveyEditor, SurveyEditorUndoRedo, buildSurveyAIContextPack };
|
|
1198
|
+
|
|
1024
1199
|
//# sourceMappingURL=editor.mjs.map
|