@univerjs/docs 1.3.0 → 1.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/lib/cjs/facade.js +14 -28
- package/lib/cjs/index.js +191 -1432
- package/lib/cjs/worker-BkTyL8zs.js +1293 -0
- package/lib/cjs/worker.js +44 -0
- package/lib/es/facade.js +14 -28
- package/lib/es/index.js +70 -1311
- package/lib/es/worker-Dny9WctR.js +1186 -0
- package/lib/es/worker.js +38 -0
- package/lib/facade.js +14 -28
- package/lib/index.js +70 -1311
- package/lib/types/config/config.d.ts +4 -0
- package/lib/types/index.d.ts +6 -2
- package/lib/types/layout-worker/index.d.ts +1 -5
- package/lib/types/layout-worker/worker.d.ts +1 -1
- package/lib/types/services/doc-interceptor/doc-interceptor.service.d.ts +1 -1
- package/lib/types/services/doc-state-change-manager.service.d.ts +1 -1
- package/lib/types/services/permission/document-permission.d.ts +1 -1
- package/lib/types/worker.d.ts +27 -0
- package/lib/umd/index.js +2 -2
- package/lib/worker-Dny9WctR.js +1186 -0
- package/lib/worker.js +38 -0
- package/package.json +15 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_worker = require("./worker-BkTyL8zs.js");
|
|
2
3
|
let _univerjs_core = require("@univerjs/core");
|
|
3
4
|
let _univerjs_engine_render = require("@univerjs/engine-render");
|
|
4
5
|
let rxjs = require("rxjs");
|
|
5
6
|
let _univerjs_protocol = require("@univerjs/protocol");
|
|
6
7
|
let _univerjs_rpc = require("@univerjs/rpc");
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
// src/commands/operations/text-selection.operation.ts
|
|
9
10
|
const SetTextSelectionsOperation = {
|
|
10
11
|
id: "doc.operation.set-selections",
|
|
11
12
|
type: _univerjs_core.CommandType.OPERATION,
|
|
@@ -14,67 +15,7 @@ const SetTextSelectionsOperation = {
|
|
|
14
15
|
}
|
|
15
16
|
};
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/typeof.js
|
|
19
|
-
function _typeof(o) {
|
|
20
|
-
"@babel/helpers - typeof";
|
|
21
|
-
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
22
|
-
return typeof o;
|
|
23
|
-
} : function(o) {
|
|
24
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
25
|
-
}, _typeof(o);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
//#endregion
|
|
29
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPrimitive.js
|
|
30
|
-
function toPrimitive(t, r) {
|
|
31
|
-
if ("object" != _typeof(t) || !t) return t;
|
|
32
|
-
var e = t[Symbol.toPrimitive];
|
|
33
|
-
if (void 0 !== e) {
|
|
34
|
-
var i = e.call(t, r || "default");
|
|
35
|
-
if ("object" != _typeof(i)) return i;
|
|
36
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
37
|
-
}
|
|
38
|
-
return ("string" === r ? String : Number)(t);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/toPropertyKey.js
|
|
43
|
-
function toPropertyKey(t) {
|
|
44
|
-
var i = toPrimitive(t, "string");
|
|
45
|
-
return "symbol" == _typeof(i) ? i : i + "";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
//#endregion
|
|
49
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/defineProperty.js
|
|
50
|
-
function _defineProperty(e, r, t) {
|
|
51
|
-
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
52
|
-
value: t,
|
|
53
|
-
enumerable: !0,
|
|
54
|
-
configurable: !0,
|
|
55
|
-
writable: !0
|
|
56
|
-
}) : e[r] = t, e;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorateParam.js
|
|
61
|
-
function __decorateParam(paramIndex, decorator) {
|
|
62
|
-
return function(target, key) {
|
|
63
|
-
decorator(target, key, paramIndex);
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
//#endregion
|
|
68
|
-
//#region \0@oxc-project+runtime@0.153.0/helpers/esm/decorate.js
|
|
69
|
-
function __decorate(decorators, target, key, desc) {
|
|
70
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
71
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
72
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
73
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//#endregion
|
|
77
|
-
//#region src/services/doc-selection-manager.service.ts
|
|
18
|
+
// src/services/doc-selection-manager.service.ts
|
|
78
19
|
/**
|
|
79
20
|
* Keeps a programmatically restored collapsed caret from being promoted back
|
|
80
21
|
* into a neighboring whole-entity selection by feature-specific UI.
|
|
@@ -85,12 +26,12 @@ let DocSelectionManagerService = class DocSelectionManagerService extends _unive
|
|
|
85
26
|
super();
|
|
86
27
|
this._commandService = _commandService;
|
|
87
28
|
this._univerInstanceService = _univerInstanceService;
|
|
88
|
-
_defineProperty(this, "_currentSelection", null);
|
|
89
|
-
_defineProperty(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
90
|
-
_defineProperty(this, "_textSelection$", new rxjs.Subject());
|
|
91
|
-
_defineProperty(this, "textSelection$", this._textSelection$.asObservable());
|
|
92
|
-
_defineProperty(this, "_refreshSelection$", new rxjs.BehaviorSubject(null));
|
|
93
|
-
_defineProperty(this, "refreshSelection$", this._refreshSelection$.asObservable());
|
|
29
|
+
require_worker._defineProperty(this, "_currentSelection", null);
|
|
30
|
+
require_worker._defineProperty(this, "_textSelectionInfo", /* @__PURE__ */ new Map());
|
|
31
|
+
require_worker._defineProperty(this, "_textSelection$", new rxjs.Subject());
|
|
32
|
+
require_worker._defineProperty(this, "textSelection$", this._textSelection$.asObservable());
|
|
33
|
+
require_worker._defineProperty(this, "_refreshSelection$", new rxjs.BehaviorSubject(null));
|
|
34
|
+
require_worker._defineProperty(this, "refreshSelection$", this._refreshSelection$.asObservable());
|
|
94
35
|
this._listenCurrentUnit();
|
|
95
36
|
}
|
|
96
37
|
_listenCurrentUnit() {
|
|
@@ -250,666 +191,9 @@ let DocSelectionManagerService = class DocSelectionManagerService extends _unive
|
|
|
250
191
|
else unitTextRange.get(subUnitId).textRanges.push(...insertParam.textRanges);
|
|
251
192
|
}
|
|
252
193
|
};
|
|
253
|
-
DocSelectionManagerService = __decorate([__decorateParam(0, _univerjs_core.ICommandService), __decorateParam(1, _univerjs_core.IUniverInstanceService)], DocSelectionManagerService);
|
|
254
|
-
|
|
255
|
-
//#endregion
|
|
256
|
-
//#region src/commands/mutations/core-editing.mutation-id.ts
|
|
257
|
-
/**
|
|
258
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
259
|
-
*
|
|
260
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
261
|
-
* you may not use this file except in compliance with the License.
|
|
262
|
-
* You may obtain a copy of the License at
|
|
263
|
-
*
|
|
264
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
265
|
-
*
|
|
266
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
267
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
268
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
269
|
-
* See the License for the specific language governing permissions and
|
|
270
|
-
* limitations under the License.
|
|
271
|
-
*/
|
|
272
|
-
const RICH_TEXT_EDITING_MUTATION_ID = "doc.mutation.rich-text-editing";
|
|
273
|
-
|
|
274
|
-
//#endregion
|
|
275
|
-
//#region src/services/document-layout-snapshot.ts
|
|
276
|
-
function projectCustomBlock(block) {
|
|
277
|
-
const { docxRawXml: _docxRawXml, docxExportTs: _docxExportTs, ...layoutBlock } = block;
|
|
278
|
-
return layoutBlock;
|
|
279
|
-
}
|
|
280
|
-
function projectDocumentBody(body) {
|
|
281
|
-
const { docxRawCustomBlocks: _docxRawCustomBlocks, docxRawBlocks: _docxRawBlocks, docxExportExcludedRanges: _docxExportExcludedRanges, payloads: _payloads, customBlocks, ...layoutBody } = body;
|
|
282
|
-
return {
|
|
283
|
-
...layoutBody,
|
|
284
|
-
...customBlocks == null ? {} : { customBlocks: customBlocks.map(projectCustomBlock) }
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
|
-
function projectHeader(header) {
|
|
288
|
-
return {
|
|
289
|
-
...header,
|
|
290
|
-
body: projectDocumentBody(header.body)
|
|
291
|
-
};
|
|
292
|
-
}
|
|
293
|
-
function projectFooter(footer) {
|
|
294
|
-
return {
|
|
295
|
-
...footer,
|
|
296
|
-
body: projectDocumentBody(footer.body)
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
/**
|
|
300
|
-
* Builds the model snapshot owned by the layout Worker. Exchange-only payloads
|
|
301
|
-
* remain in the authoritative Main model and are deliberately excluded from
|
|
302
|
-
* the structured-clone boundary because they do not affect document geometry.
|
|
303
|
-
*/
|
|
304
|
-
function createDocumentLayoutSnapshot(snapshot) {
|
|
305
|
-
const { resources: _resources, body, headers, footers, footnotes, endnotes, ...layoutSnapshot } = snapshot;
|
|
306
|
-
return {
|
|
307
|
-
...layoutSnapshot,
|
|
308
|
-
...footnotes == null ? {} : { footnotes: Object.fromEntries(Object.entries(footnotes).map(([id, note]) => [id, {
|
|
309
|
-
...note,
|
|
310
|
-
body: projectDocumentBody(note.body)
|
|
311
|
-
}])) },
|
|
312
|
-
...endnotes == null ? {} : { endnotes: Object.fromEntries(Object.entries(endnotes).map(([id, note]) => [id, {
|
|
313
|
-
...note,
|
|
314
|
-
body: projectDocumentBody(note.body)
|
|
315
|
-
}])) },
|
|
316
|
-
...body == null ? {} : { body: projectDocumentBody(body) },
|
|
317
|
-
...headers == null ? {} : { headers: Object.fromEntries(Object.entries(headers).map(([headerId, header]) => [headerId, projectHeader(header)])) },
|
|
318
|
-
...footers == null ? {} : { footers: Object.fromEntries(Object.entries(footers).map(([footerId, footer]) => [footerId, projectFooter(footer)])) }
|
|
319
|
-
};
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
//#endregion
|
|
323
|
-
//#region src/services/doc-layout-executor.service.ts
|
|
324
|
-
var _DocLayoutExecutorService;
|
|
325
|
-
let DocLayoutExecutorType = /* @__PURE__ */ function(DocLayoutExecutorType) {
|
|
326
|
-
DocLayoutExecutorType["MAIN_THREAD"] = "main-thread";
|
|
327
|
-
DocLayoutExecutorType["WORKER"] = "worker";
|
|
328
|
-
return DocLayoutExecutorType;
|
|
329
|
-
}({});
|
|
330
|
-
let DocLayoutSessionStatus = /* @__PURE__ */ function(DocLayoutSessionStatus) {
|
|
331
|
-
DocLayoutSessionStatus["ACCEPTED"] = "accepted";
|
|
332
|
-
DocLayoutSessionStatus["NOT_FOUND"] = "not-found";
|
|
333
|
-
DocLayoutSessionStatus["RESNAPSHOT_REQUIRED"] = "resnapshot-required";
|
|
334
|
-
DocLayoutSessionStatus["SUPERSEDED"] = "superseded";
|
|
335
|
-
return DocLayoutSessionStatus;
|
|
336
|
-
}({});
|
|
337
|
-
let DocLayoutExecutorState = /* @__PURE__ */ function(DocLayoutExecutorState) {
|
|
338
|
-
DocLayoutExecutorState["UNREGISTERED"] = "unregistered";
|
|
339
|
-
DocLayoutExecutorState["INITIALIZING"] = "initializing";
|
|
340
|
-
DocLayoutExecutorState["ACTIVE"] = "active";
|
|
341
|
-
DocLayoutExecutorState["RECOVERING"] = "recovering";
|
|
342
|
-
DocLayoutExecutorState["FAILED"] = "failed";
|
|
343
|
-
return DocLayoutExecutorState;
|
|
344
|
-
}({});
|
|
345
|
-
function areShallowRecordsEqual(left, right) {
|
|
346
|
-
const leftRecord = left;
|
|
347
|
-
const rightRecord = right;
|
|
348
|
-
const leftKeys = Object.keys(leftRecord);
|
|
349
|
-
const rightKeys = Object.keys(rightRecord);
|
|
350
|
-
return leftKeys.length === rightKeys.length && leftKeys.every((key) => leftRecord[key] === rightRecord[key]);
|
|
351
|
-
}
|
|
352
|
-
function createRecordPatch(previous, current) {
|
|
353
|
-
const upserts = {};
|
|
354
|
-
const removals = [];
|
|
355
|
-
for (const [key, value] of Object.entries(current)) if (previous[key] == null || !areShallowRecordsEqual(previous[key], value)) upserts[key] = value;
|
|
356
|
-
for (const key of Object.keys(previous)) if (current[key] == null) removals.push(key);
|
|
357
|
-
return {
|
|
358
|
-
removals,
|
|
359
|
-
upserts
|
|
360
|
-
};
|
|
361
|
-
}
|
|
362
|
-
function getCustomRangePresentationKey$1(entry) {
|
|
363
|
-
return JSON.stringify([entry.segmentId, entry.rangeId]);
|
|
364
|
-
}
|
|
365
|
-
function toCustomRangePresentationMap(entries) {
|
|
366
|
-
return new Map(entries.map((entry) => [getCustomRangePresentationKey$1(entry), entry]));
|
|
367
|
-
}
|
|
368
|
-
function createCustomRangePresentationPatch(previous, current) {
|
|
369
|
-
const upserts = [];
|
|
370
|
-
const removals = [];
|
|
371
|
-
for (const [key, entry] of current) {
|
|
372
|
-
const previousEntry = previous.get(key);
|
|
373
|
-
if (previousEntry == null || !areShallowRecordsEqual(previousEntry.presentation, entry.presentation)) upserts.push(entry);
|
|
374
|
-
}
|
|
375
|
-
for (const [key, entry] of previous) if (!current.has(key)) removals.push({
|
|
376
|
-
segmentId: entry.segmentId,
|
|
377
|
-
rangeId: entry.rangeId
|
|
378
|
-
});
|
|
379
|
-
return {
|
|
380
|
-
removals,
|
|
381
|
-
upserts
|
|
382
|
-
};
|
|
383
|
-
}
|
|
384
|
-
function isRichTextEditingMutationParams(value) {
|
|
385
|
-
return typeof value === "object" && value != null && "unitId" in value && typeof value.unitId === "string" && "actions" in value;
|
|
386
|
-
}
|
|
387
|
-
function collectCustomBlockViewports(dataModel, options) {
|
|
388
|
-
var _documentStyle$pageSi, _documentStyle$pageSi2;
|
|
389
|
-
const snapshot = dataModel.getSnapshot();
|
|
390
|
-
const documentStyle = snapshot.documentStyle;
|
|
391
|
-
const isModern = documentStyle.documentFlavor === _univerjs_core.DocumentFlavor.MODERN;
|
|
392
|
-
const modernMargin = options.modernHorizontalMargin ?? _univerjs_core.MODERN_DOCUMENT_DEFAULT_MARGIN;
|
|
393
|
-
const pageMarginLeft = isModern ? modernMargin : documentStyle.marginLeft;
|
|
394
|
-
const pageMarginRight = isModern ? modernMargin : documentStyle.marginRight;
|
|
395
|
-
const pageWidth = isModern ? options.modernPageWidth ?? ((_documentStyle$pageSi = documentStyle.pageSize) === null || _documentStyle$pageSi === void 0 ? void 0 : _documentStyle$pageSi.width) ?? _univerjs_core.MODERN_DOCUMENT_WIDTH[_univerjs_core.ModernDocumentWidthMode.MEDIUM] : (_documentStyle$pageSi2 = documentStyle.pageSize) === null || _documentStyle$pageSi2 === void 0 ? void 0 : _documentStyle$pageSi2.width;
|
|
396
|
-
const viewports = {};
|
|
397
|
-
const bodies = [
|
|
398
|
-
snapshot.body,
|
|
399
|
-
...Object.values(snapshot.headers ?? {}).map((header) => header.body),
|
|
400
|
-
...Object.values(snapshot.footers ?? {}).map((footer) => footer.body)
|
|
401
|
-
];
|
|
402
|
-
for (const customBlock of bodies.flatMap((body) => (body === null || body === void 0 ? void 0 : body.customBlocks) ?? [])) {
|
|
403
|
-
var _snapshot$drawings;
|
|
404
|
-
const drawing = (_snapshot$drawings = snapshot.drawings) === null || _snapshot$drawings === void 0 ? void 0 : _snapshot$drawings[customBlock.blockId];
|
|
405
|
-
if (drawing == null) continue;
|
|
406
|
-
const viewport = (0, _univerjs_engine_render.getDocsCustomBlockRenderViewport)(dataModel.getUnitId(), customBlock.blockId, {
|
|
407
|
-
fallbackHeight: drawing.docTransform.size.height ?? 0,
|
|
408
|
-
fallbackWidth: drawing.docTransform.size.width ?? 0,
|
|
409
|
-
pageMarginLeft,
|
|
410
|
-
pageMarginRight,
|
|
411
|
-
pageWidth
|
|
412
|
-
});
|
|
413
|
-
if (viewport != null) viewports[customBlock.blockId] = { ...viewport };
|
|
414
|
-
}
|
|
415
|
-
return viewports;
|
|
416
|
-
}
|
|
417
|
-
let DocLayoutExecutorService = _DocLayoutExecutorService = class DocLayoutExecutorService extends _univerjs_core.Disposable {
|
|
418
|
-
constructor(_univerInstanceService, _commandService, _localeService, _logService) {
|
|
419
|
-
super();
|
|
420
|
-
this._univerInstanceService = _univerInstanceService;
|
|
421
|
-
this._commandService = _commandService;
|
|
422
|
-
this._localeService = _localeService;
|
|
423
|
-
this._logService = _logService;
|
|
424
|
-
_defineProperty(this, "_executor", null);
|
|
425
|
-
_defineProperty(this, "_executorReady", null);
|
|
426
|
-
_defineProperty(this, "_recoveryFailure", null);
|
|
427
|
-
_defineProperty(this, "_sessionEpoch", 0);
|
|
428
|
-
_defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
|
|
429
|
-
_defineProperty(this, "_hydrationSamples", /* @__PURE__ */ new Map());
|
|
430
|
-
_defineProperty(this, "_customRangePresentationProviders", /* @__PURE__ */ new Set());
|
|
431
|
-
_defineProperty(this, "_executorStatus$", new rxjs.BehaviorSubject({
|
|
432
|
-
state: "unregistered",
|
|
433
|
-
executor: null,
|
|
434
|
-
diagnostic: null,
|
|
435
|
-
recoveryUnitId: null
|
|
436
|
-
}));
|
|
437
|
-
_defineProperty(this, "executorStatus$", this._executorStatus$.asObservable());
|
|
438
|
-
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitAdded$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe(({ unit }) => this._createSessionIfEligible(unit)));
|
|
439
|
-
this.disposeWithMe(this._univerInstanceService.getTypeOfUnitDisposed$(_univerjs_core.UniverInstanceType.UNIVER_DOC).subscribe((unit) => this._disposeSession(unit.getUnitId())));
|
|
440
|
-
this.disposeWithMe(this._commandService.onCommandExecuted((command) => {
|
|
441
|
-
if (command.id !== "doc.mutation.rich-text-editing") return;
|
|
442
|
-
const params = command.params;
|
|
443
|
-
if (!isRichTextEditingMutationParams(params)) {
|
|
444
|
-
this._logService.warn("[DocLayoutExecutorService]: ignored malformed document mutation parameters.");
|
|
445
|
-
return;
|
|
446
|
-
}
|
|
447
|
-
this._enqueueCommittedMutation(params);
|
|
448
|
-
}));
|
|
449
|
-
this.disposeWithMe(this._localeService.localeChanged$.subscribe(() => {
|
|
450
|
-
for (const unitId of this._sessions.keys()) {
|
|
451
|
-
const dataModel = this._getEligibleModel(unitId);
|
|
452
|
-
if (dataModel != null) this._replaceSession(dataModel).catch((error) => {
|
|
453
|
-
this._logService.error("[DocLayoutExecutorService]: failed to refresh Worker locale.", error);
|
|
454
|
-
});
|
|
455
|
-
}
|
|
456
|
-
}));
|
|
457
|
-
}
|
|
458
|
-
register(executor) {
|
|
459
|
-
if (this._executor != null) throw new Error("A document layout executor is already registered.");
|
|
460
|
-
this._executor = executor;
|
|
461
|
-
this._recoveryFailure = null;
|
|
462
|
-
this._executorStatus$.next({
|
|
463
|
-
state: "initializing",
|
|
464
|
-
executor: executor.type,
|
|
465
|
-
diagnostic: null,
|
|
466
|
-
recoveryUnitId: null
|
|
467
|
-
});
|
|
468
|
-
const executorReady = executor.initialize();
|
|
469
|
-
this._executorReady = executorReady;
|
|
470
|
-
executorReady.then(() => {
|
|
471
|
-
if (this._executor === executor) this._executorStatus$.next({
|
|
472
|
-
state: "active",
|
|
473
|
-
executor: executor.type,
|
|
474
|
-
diagnostic: null,
|
|
475
|
-
recoveryUnitId: null
|
|
476
|
-
});
|
|
477
|
-
}).catch((error) => {
|
|
478
|
-
if (this._executor !== executor) return;
|
|
479
|
-
this._executor = null;
|
|
480
|
-
this._executorReady = null;
|
|
481
|
-
this._disposeManagedSessions();
|
|
482
|
-
this._sessions.clear();
|
|
483
|
-
const diagnostic = error instanceof Error ? error.message : String(error);
|
|
484
|
-
this._executorStatus$.next({
|
|
485
|
-
state: "failed",
|
|
486
|
-
executor: executor.type,
|
|
487
|
-
diagnostic,
|
|
488
|
-
recoveryUnitId: null
|
|
489
|
-
});
|
|
490
|
-
this._logService.error("[DocLayoutExecutorService]: document layout executor initialization failed.", error);
|
|
491
|
-
});
|
|
492
|
-
for (const unit of this._univerInstanceService.getAllUnitsForType(_univerjs_core.UniverInstanceType.UNIVER_DOC)) this._createSessionIfEligible(unit);
|
|
493
|
-
return (0, _univerjs_core.toDisposable)(() => {
|
|
494
|
-
if (this._executor === executor) {
|
|
495
|
-
this._executor = null;
|
|
496
|
-
this._executorReady = null;
|
|
497
|
-
this._disposeManagedSessions();
|
|
498
|
-
this._sessions.clear();
|
|
499
|
-
this._executorStatus$.next({
|
|
500
|
-
state: "unregistered",
|
|
501
|
-
executor: null,
|
|
502
|
-
diagnostic: null,
|
|
503
|
-
recoveryUnitId: null
|
|
504
|
-
});
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
}
|
|
508
|
-
getExecutor() {
|
|
509
|
-
return this._executor;
|
|
510
|
-
}
|
|
511
|
-
getExecutorStatus() {
|
|
512
|
-
return this._executorStatus$.value;
|
|
513
|
-
}
|
|
514
|
-
registerCustomRangePresentationProvider(provider) {
|
|
515
|
-
this._customRangePresentationProviders.add(provider);
|
|
516
|
-
return (0, _univerjs_core.toDisposable)(() => this._customRangePresentationProviders.delete(provider));
|
|
517
|
-
}
|
|
518
|
-
async getPerformanceMetrics(unitId) {
|
|
519
|
-
var _this$_executor;
|
|
520
|
-
const executorMetrics = await ((_this$_executor = this._executor) === null || _this$_executor === void 0 ? void 0 : _this$_executor.getPerformanceMetrics(unitId));
|
|
521
|
-
return {
|
|
522
|
-
hydrationMs: [...this._hydrationSamples.get(unitId) ?? []],
|
|
523
|
-
mutationTransferMs: [...(executorMetrics === null || executorMetrics === void 0 ? void 0 : executorMetrics.mutationTransferMs) ?? []],
|
|
524
|
-
patchTransferMs: [...(executorMetrics === null || executorMetrics === void 0 ? void 0 : executorMetrics.patchTransferMs) ?? []],
|
|
525
|
-
snapshotTransferMs: [...(executorMetrics === null || executorMetrics === void 0 ? void 0 : executorMetrics.snapshotTransferMs) ?? []]
|
|
526
|
-
};
|
|
527
|
-
}
|
|
528
|
-
async resetPerformanceMetrics(unitId) {
|
|
529
|
-
var _this$_executor2;
|
|
530
|
-
this._hydrationSamples.delete(unitId);
|
|
531
|
-
await ((_this$_executor2 = this._executor) === null || _this$_executor2 === void 0 ? void 0 : _this$_executor2.resetPerformanceMetrics(unitId));
|
|
532
|
-
}
|
|
533
|
-
recordHydrationDuration(unitId, durationMs) {
|
|
534
|
-
this._appendPerformanceSample(this._hydrationSamples, unitId, durationMs);
|
|
535
|
-
}
|
|
536
|
-
async recoverExecutor(unitId, diagnostic) {
|
|
537
|
-
const executor = this._requireExecutor();
|
|
538
|
-
this._executorStatus$.next({
|
|
539
|
-
state: "recovering",
|
|
540
|
-
executor: executor.type,
|
|
541
|
-
diagnostic,
|
|
542
|
-
recoveryUnitId: unitId
|
|
543
|
-
});
|
|
544
|
-
for (const session of this._sessions.values()) this._markSessionDisposed(session);
|
|
545
|
-
this._sessions.clear();
|
|
546
|
-
this._hydrationSamples.clear();
|
|
547
|
-
try {
|
|
548
|
-
const executorReady = executor.recover();
|
|
549
|
-
this._executorReady = executorReady;
|
|
550
|
-
await executorReady;
|
|
551
|
-
} catch (error) {
|
|
552
|
-
if (this._executor === executor) {
|
|
553
|
-
const recoveryDiagnostic = error instanceof Error ? error.message : String(error);
|
|
554
|
-
this._executor = null;
|
|
555
|
-
this._executorReady = null;
|
|
556
|
-
this._recoveryFailure = {
|
|
557
|
-
diagnostic: recoveryDiagnostic,
|
|
558
|
-
unitId
|
|
559
|
-
};
|
|
560
|
-
this._executorStatus$.next({
|
|
561
|
-
state: "recovering",
|
|
562
|
-
executor: executor.type,
|
|
563
|
-
diagnostic: recoveryDiagnostic,
|
|
564
|
-
recoveryUnitId: unitId
|
|
565
|
-
});
|
|
566
|
-
}
|
|
567
|
-
throw error;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
completeRecovery(unitId) {
|
|
571
|
-
var _this$_recoveryFailur;
|
|
572
|
-
const status = this._executorStatus$.value;
|
|
573
|
-
if (status.state !== "recovering" || status.recoveryUnitId !== unitId) return;
|
|
574
|
-
const recoveryFailure = ((_this$_recoveryFailur = this._recoveryFailure) === null || _this$_recoveryFailur === void 0 ? void 0 : _this$_recoveryFailur.unitId) === unitId ? this._recoveryFailure : null;
|
|
575
|
-
this._recoveryFailure = null;
|
|
576
|
-
this._executorStatus$.next({
|
|
577
|
-
state: recoveryFailure == null ? "active" : "failed",
|
|
578
|
-
executor: status.executor,
|
|
579
|
-
diagnostic: (recoveryFailure === null || recoveryFailure === void 0 ? void 0 : recoveryFailure.diagnostic) ?? null,
|
|
580
|
-
recoveryUnitId: null
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
async startLayout(identity, options, budgetMs) {
|
|
584
|
-
const { unitId } = identity;
|
|
585
|
-
const executor = this._executor;
|
|
586
|
-
const dataModel = this._getEligibleModel(unitId);
|
|
587
|
-
if (executor == null || dataModel == null) return null;
|
|
588
|
-
let session = this._sessions.get(unitId);
|
|
589
|
-
if (session != null && session.sourceMutationRevision !== dataModel.getMutationRevision()) session.needsResnapshot = true;
|
|
590
|
-
if (session == null || session.needsResnapshot) session = await this._replaceSession(dataModel);
|
|
591
|
-
if (session.disposed || this._executor !== executor || this._getEligibleModel(unitId) !== dataModel) return null;
|
|
592
|
-
let result = await this._startSynchronizedLayout(executor, session, identity, options, budgetMs);
|
|
593
|
-
if (session.disposed || this._executor !== executor || this._getEligibleModel(unitId) !== dataModel) return null;
|
|
594
|
-
if (result.status === "not-found" || result.status === "resnapshot-required") {
|
|
595
|
-
session = await this._replaceSession(dataModel);
|
|
596
|
-
result = await this._startSynchronizedLayout(executor, session, identity, options, budgetMs);
|
|
597
|
-
}
|
|
598
|
-
return result;
|
|
599
|
-
}
|
|
600
|
-
stepLayout(request) {
|
|
601
|
-
return this._requireExecutor().stepLayout(request);
|
|
602
|
-
}
|
|
603
|
-
publishBacklog(request) {
|
|
604
|
-
return this._requireExecutor().publishBacklog(request);
|
|
605
|
-
}
|
|
606
|
-
getLayoutPage(request) {
|
|
607
|
-
return this._requireExecutor().getLayoutPage(request);
|
|
608
|
-
}
|
|
609
|
-
cancelLayout(request) {
|
|
610
|
-
const executor = this._executor;
|
|
611
|
-
return executor == null ? Promise.resolve() : executor.cancelLayout(request);
|
|
612
|
-
}
|
|
613
|
-
disposeLayoutMount(request) {
|
|
614
|
-
const executor = this._executor;
|
|
615
|
-
const session = this._sessions.get(request.unitId);
|
|
616
|
-
const latestStart = session === null || session === void 0 ? void 0 : session.latestStarts.get(request.mountId);
|
|
617
|
-
if ((latestStart === null || latestStart === void 0 ? void 0 : latestStart.mountEpoch) === request.mountEpoch && latestStart.viewportEpoch === request.viewportEpoch) {
|
|
618
|
-
session === null || session === void 0 || session.latestStarts.delete(request.mountId);
|
|
619
|
-
session === null || session === void 0 || session.customBlockViewportsByMount.delete(request.mountId);
|
|
620
|
-
}
|
|
621
|
-
return executor == null ? Promise.resolve() : executor.disposeLayoutMount(request);
|
|
622
|
-
}
|
|
623
|
-
dispose() {
|
|
624
|
-
const executor = this._executor;
|
|
625
|
-
if (executor != null) for (const [unitId, session] of this._sessions) {
|
|
626
|
-
this._markSessionDisposed(session);
|
|
627
|
-
executor.disposeSession({
|
|
628
|
-
unitId,
|
|
629
|
-
sessionEpoch: session.sessionEpoch
|
|
630
|
-
}).catch((error) => {
|
|
631
|
-
if (this._executor === executor) this._logService.error("[DocLayoutExecutorService]: failed to dispose a Worker session.", error);
|
|
632
|
-
});
|
|
633
|
-
}
|
|
634
|
-
this._sessions.clear();
|
|
635
|
-
this._executor = null;
|
|
636
|
-
this._executorReady = null;
|
|
637
|
-
this._recoveryFailure = null;
|
|
638
|
-
this._executorStatus$.complete();
|
|
639
|
-
this._customRangePresentationProviders.clear();
|
|
640
|
-
super.dispose();
|
|
641
|
-
}
|
|
642
|
-
_createSessionIfEligible(dataModel) {
|
|
643
|
-
if (this._executor == null || !this._isEligible(dataModel) || this._sessions.has(dataModel.getUnitId())) return;
|
|
644
|
-
this._replaceSession(dataModel).catch((error) => {
|
|
645
|
-
this._logService.error("[DocLayoutExecutorService]: failed to create a Worker session.", error);
|
|
646
|
-
});
|
|
647
|
-
}
|
|
648
|
-
_enqueueCommittedMutation(params) {
|
|
649
|
-
var _params$actions;
|
|
650
|
-
const executor = this._executor;
|
|
651
|
-
const dataModel = this._getEligibleModel(params.unitId);
|
|
652
|
-
if (executor == null || dataModel == null) return;
|
|
653
|
-
if (_univerjs_core.JSONX.isNoop(params.actions) || ((_params$actions = params.actions) === null || _params$actions === void 0 ? void 0 : _params$actions.length) === 0) return;
|
|
654
|
-
const session = this._sessions.get(params.unitId);
|
|
655
|
-
if (session == null) {
|
|
656
|
-
this._replaceSession(dataModel).catch((error) => {
|
|
657
|
-
this._logService.error("[DocLayoutExecutorService]: failed to snapshot a document mutation.", error);
|
|
658
|
-
});
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
const sourceMutationRevision = dataModel.getMutationRevision();
|
|
662
|
-
if (sourceMutationRevision !== session.sourceMutationRevision + 1) {
|
|
663
|
-
session.needsResnapshot = true;
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
const baseRevision = session.modelRevision;
|
|
667
|
-
const modelRevision = baseRevision + 1;
|
|
668
|
-
session.modelRevision = modelRevision;
|
|
669
|
-
session.sourceMutationRevision = sourceMutationRevision;
|
|
670
|
-
session.pendingMutations.push({
|
|
671
|
-
baseRevision,
|
|
672
|
-
modelRevision,
|
|
673
|
-
actions: params.actions
|
|
674
|
-
});
|
|
675
|
-
}
|
|
676
|
-
async _startSynchronizedLayout(executor, session, identity, options, budgetMs) {
|
|
677
|
-
var _session$latestStarts;
|
|
678
|
-
const { unitId, mountId } = identity;
|
|
679
|
-
const startId = (((_session$latestStarts = session.latestStarts.get(mountId)) === null || _session$latestStarts === void 0 ? void 0 : _session$latestStarts.startId) ?? 0) + 1;
|
|
680
|
-
const startIdentity = {
|
|
681
|
-
startId,
|
|
682
|
-
mountEpoch: identity.mountEpoch,
|
|
683
|
-
viewportEpoch: identity.viewportEpoch
|
|
684
|
-
};
|
|
685
|
-
session.latestStarts.set(mountId, startIdentity);
|
|
686
|
-
const startTask = session.queue.then(async () => {
|
|
687
|
-
if (session.disposed || this._executor !== executor) return { status: "not-found" };
|
|
688
|
-
const currentModel = this._getEligibleModel(unitId);
|
|
689
|
-
if (currentModel == null || currentModel.getMutationRevision() !== session.sourceMutationRevision) {
|
|
690
|
-
session.needsResnapshot = true;
|
|
691
|
-
return {
|
|
692
|
-
status: "resnapshot-required",
|
|
693
|
-
modelRevision: session.workerRevision
|
|
694
|
-
};
|
|
695
|
-
}
|
|
696
|
-
if (session.latestStarts.get(mountId) !== startIdentity) return { status: "superseded" };
|
|
697
|
-
const mutations = session.pendingMutations.slice();
|
|
698
|
-
const projections = this._createLayoutProjectionPayload(session, identity, this._getRequiredModel(unitId), options);
|
|
699
|
-
const request = {
|
|
700
|
-
...identity,
|
|
701
|
-
metricsRevision: startId,
|
|
702
|
-
baseRevision: session.workerRevision,
|
|
703
|
-
modelRevision: session.modelRevision,
|
|
704
|
-
mutations,
|
|
705
|
-
...projections.request,
|
|
706
|
-
budgetMs,
|
|
707
|
-
...options
|
|
708
|
-
};
|
|
709
|
-
const result = await executor.startLayout(request);
|
|
710
|
-
if (result.status === "accepted") {
|
|
711
|
-
session.workerRevision = request.modelRevision;
|
|
712
|
-
session.pendingMutations.splice(0, mutations.length);
|
|
713
|
-
session.customBlockViewportsByMount.set(mountId, {
|
|
714
|
-
mountEpoch: identity.mountEpoch,
|
|
715
|
-
value: projections.customBlockViewports
|
|
716
|
-
});
|
|
717
|
-
session.customRangePresentations = projections.customRangePresentations;
|
|
718
|
-
} else session.needsResnapshot = true;
|
|
719
|
-
return result;
|
|
720
|
-
});
|
|
721
|
-
session.queue = startTask.then(() => void 0, (error) => {
|
|
722
|
-
if (session.disposed || this._executor !== executor) return;
|
|
723
|
-
session.needsResnapshot = true;
|
|
724
|
-
this._logService.error("[DocLayoutExecutorService]: synchronized layout start failed.", error);
|
|
725
|
-
});
|
|
726
|
-
return startTask;
|
|
727
|
-
}
|
|
728
|
-
_createLayoutProjectionPayload(session, identity, dataModel, options) {
|
|
729
|
-
const customBlockViewports = collectCustomBlockViewports(dataModel, options);
|
|
730
|
-
const previousCustomBlockViewports = session.customBlockViewportsByMount.get(identity.mountId);
|
|
731
|
-
const customRangePresentations = this._collectCustomRangePresentations(dataModel);
|
|
732
|
-
const customRangePresentationMap = toCustomRangePresentationMap(customRangePresentations);
|
|
733
|
-
const request = {};
|
|
734
|
-
if (previousCustomBlockViewports == null || previousCustomBlockViewports.mountEpoch !== identity.mountEpoch) request.customBlockViewports = customBlockViewports;
|
|
735
|
-
else {
|
|
736
|
-
const patch = createRecordPatch(previousCustomBlockViewports.value, customBlockViewports);
|
|
737
|
-
if (patch.removals.length > 0 || Object.keys(patch.upserts).length > 0) request.customBlockViewportPatch = patch;
|
|
738
|
-
}
|
|
739
|
-
if (session.customRangePresentations == null) request.customRangePresentations = customRangePresentations;
|
|
740
|
-
else {
|
|
741
|
-
const patch = createCustomRangePresentationPatch(session.customRangePresentations, customRangePresentationMap);
|
|
742
|
-
if (patch.removals.length > 0 || patch.upserts.length > 0) request.customRangePresentationPatch = patch;
|
|
743
|
-
}
|
|
744
|
-
return {
|
|
745
|
-
request,
|
|
746
|
-
customBlockViewports,
|
|
747
|
-
customRangePresentations: customRangePresentationMap
|
|
748
|
-
};
|
|
749
|
-
}
|
|
750
|
-
async _replaceSession(dataModel) {
|
|
751
|
-
const executor = this._requireExecutor();
|
|
752
|
-
const unitId = dataModel.getUnitId();
|
|
753
|
-
const previous = this._sessions.get(unitId);
|
|
754
|
-
if (previous != null) this._markSessionDisposed(previous);
|
|
755
|
-
const modelRevision = (previous === null || previous === void 0 ? void 0 : previous.modelRevision) ?? 0;
|
|
756
|
-
const session = {
|
|
757
|
-
sessionEpoch: ++this._sessionEpoch,
|
|
758
|
-
modelRevision,
|
|
759
|
-
sourceMutationRevision: dataModel.getMutationRevision(),
|
|
760
|
-
workerRevision: modelRevision,
|
|
761
|
-
pendingMutations: [],
|
|
762
|
-
latestStarts: /* @__PURE__ */ new Map(),
|
|
763
|
-
customBlockViewportsByMount: /* @__PURE__ */ new Map(),
|
|
764
|
-
customRangePresentations: null,
|
|
765
|
-
queue: Promise.resolve(),
|
|
766
|
-
needsResnapshot: false,
|
|
767
|
-
disposed: false,
|
|
768
|
-
cancelPendingCreateTask: null
|
|
769
|
-
};
|
|
770
|
-
const createTask = this._createSessionOnNextMacroTask(executor, session, dataModel);
|
|
771
|
-
session.queue = createTask;
|
|
772
|
-
this._sessions.set(unitId, session);
|
|
773
|
-
try {
|
|
774
|
-
await createTask;
|
|
775
|
-
} catch (error) {
|
|
776
|
-
if (!session.disposed && this._executor === executor) {
|
|
777
|
-
session.needsResnapshot = true;
|
|
778
|
-
throw error;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
return session;
|
|
782
|
-
}
|
|
783
|
-
_disposeSession(unitId) {
|
|
784
|
-
const session = this._sessions.get(unitId);
|
|
785
|
-
if (session == null) return;
|
|
786
|
-
this._markSessionDisposed(session);
|
|
787
|
-
this._sessions.delete(unitId);
|
|
788
|
-
this._hydrationSamples.delete(unitId);
|
|
789
|
-
const executor = this._executor;
|
|
790
|
-
executor === null || executor === void 0 || executor.disposeSession({
|
|
791
|
-
unitId,
|
|
792
|
-
sessionEpoch: session.sessionEpoch
|
|
793
|
-
}).catch((error) => {
|
|
794
|
-
if (this._executor === executor) this._logService.error("[DocLayoutExecutorService]: failed to dispose a Worker session.", error);
|
|
795
|
-
});
|
|
796
|
-
}
|
|
797
|
-
_getEligibleModel(unitId) {
|
|
798
|
-
const dataModel = this._univerInstanceService.getUnit(unitId, _univerjs_core.UniverInstanceType.UNIVER_DOC);
|
|
799
|
-
return dataModel != null && this._isEligible(dataModel) ? dataModel : null;
|
|
800
|
-
}
|
|
801
|
-
_getRequiredModel(unitId) {
|
|
802
|
-
const dataModel = this._getEligibleModel(unitId);
|
|
803
|
-
if (dataModel == null) throw new Error(`Eligible document model not found for Worker layout: "${unitId}".`);
|
|
804
|
-
return dataModel;
|
|
805
|
-
}
|
|
806
|
-
_collectCustomRangePresentations(dataModel) {
|
|
807
|
-
const presentations = [];
|
|
808
|
-
const providers = Array.from(this._customRangePresentationProviders).reverse();
|
|
809
|
-
if (providers.length === 0) return presentations;
|
|
810
|
-
const collectSegment = (segmentId, body) => {
|
|
811
|
-
if (body == null) return;
|
|
812
|
-
const seenRangeIds = /* @__PURE__ */ new Set();
|
|
813
|
-
for (const range of body.customRanges ?? []) {
|
|
814
|
-
if (seenRangeIds.has(range.rangeId)) continue;
|
|
815
|
-
seenRangeIds.add(range.rangeId);
|
|
816
|
-
for (const provider of providers) {
|
|
817
|
-
const presentation = provider(dataModel.getUnitId(), range, {
|
|
818
|
-
segmentId,
|
|
819
|
-
body
|
|
820
|
-
});
|
|
821
|
-
if (presentation != null) {
|
|
822
|
-
presentations.push({
|
|
823
|
-
segmentId,
|
|
824
|
-
rangeId: range.rangeId,
|
|
825
|
-
presentation: { ...presentation }
|
|
826
|
-
});
|
|
827
|
-
break;
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
};
|
|
832
|
-
collectSegment("", dataModel.getBody());
|
|
833
|
-
for (const [segmentId, headerModel] of dataModel.headerModelMap) collectSegment(segmentId, headerModel.getBody());
|
|
834
|
-
for (const [segmentId, footerModel] of dataModel.footerModelMap) collectSegment(segmentId, footerModel.getBody());
|
|
835
|
-
return presentations;
|
|
836
|
-
}
|
|
837
|
-
_isEligible(dataModel) {
|
|
838
|
-
if ((0, _univerjs_core.isInternalEditorID)(dataModel.getUnitId())) return false;
|
|
839
|
-
const flavor = dataModel.getSnapshot().documentStyle.documentFlavor;
|
|
840
|
-
return flavor === _univerjs_core.DocumentFlavor.TRADITIONAL || flavor === _univerjs_core.DocumentFlavor.MODERN;
|
|
841
|
-
}
|
|
842
|
-
_requireExecutor() {
|
|
843
|
-
if (this._executor == null) throw new Error("No document layout executor is registered.");
|
|
844
|
-
return this._executor;
|
|
845
|
-
}
|
|
846
|
-
_appendPerformanceSample(target, unitId, durationMs) {
|
|
847
|
-
const samples = target.get(unitId) ?? [];
|
|
848
|
-
samples.push(durationMs);
|
|
849
|
-
if (samples.length > _DocLayoutExecutorService._performanceSampleLimit) samples.splice(0, samples.length - _DocLayoutExecutorService._performanceSampleLimit);
|
|
850
|
-
target.set(unitId, samples);
|
|
851
|
-
}
|
|
852
|
-
_createSessionOnNextMacroTask(executor, session, dataModel) {
|
|
853
|
-
return new Promise((resolve, reject) => {
|
|
854
|
-
const cancelTask = (0, _univerjs_core.requestImmediateMacroTask)(() => {
|
|
855
|
-
session.cancelPendingCreateTask = null;
|
|
856
|
-
const unitId = dataModel.getUnitId();
|
|
857
|
-
if (session.disposed || this._executor !== executor || this._sessions.get(unitId) !== session) {
|
|
858
|
-
resolve();
|
|
859
|
-
return;
|
|
860
|
-
}
|
|
861
|
-
const executorReady = this._executorReady;
|
|
862
|
-
if (executorReady == null) {
|
|
863
|
-
resolve();
|
|
864
|
-
return;
|
|
865
|
-
}
|
|
866
|
-
executorReady.then(() => {
|
|
867
|
-
if (session.disposed || this._executor !== executor || this._sessions.get(unitId) !== session || this._getEligibleModel(unitId) !== dataModel) {
|
|
868
|
-
resolve();
|
|
869
|
-
return;
|
|
870
|
-
}
|
|
871
|
-
session.sourceMutationRevision = dataModel.getMutationRevision();
|
|
872
|
-
session.workerRevision = session.modelRevision;
|
|
873
|
-
session.pendingMutations.length = 0;
|
|
874
|
-
const request = {
|
|
875
|
-
unitId,
|
|
876
|
-
sessionEpoch: session.sessionEpoch,
|
|
877
|
-
snapshot: createDocumentLayoutSnapshot(dataModel.getSnapshot()),
|
|
878
|
-
modelRevision: session.modelRevision,
|
|
879
|
-
locale: this._localeService.getCurrentLocale(),
|
|
880
|
-
localeData: this._localeService.getLocales(),
|
|
881
|
-
direction: this._localeService.getDirection()
|
|
882
|
-
};
|
|
883
|
-
executor.createSession(request).then(resolve, reject);
|
|
884
|
-
}, reject);
|
|
885
|
-
});
|
|
886
|
-
session.cancelPendingCreateTask = () => {
|
|
887
|
-
cancelTask();
|
|
888
|
-
session.cancelPendingCreateTask = null;
|
|
889
|
-
resolve();
|
|
890
|
-
};
|
|
891
|
-
});
|
|
892
|
-
}
|
|
893
|
-
_markSessionDisposed(session) {
|
|
894
|
-
var _session$cancelPendin;
|
|
895
|
-
session.disposed = true;
|
|
896
|
-
(_session$cancelPendin = session.cancelPendingCreateTask) === null || _session$cancelPendin === void 0 || _session$cancelPendin.call(session);
|
|
897
|
-
session.cancelPendingCreateTask = null;
|
|
898
|
-
}
|
|
899
|
-
_disposeManagedSessions() {
|
|
900
|
-
for (const session of this._sessions.values()) this._markSessionDisposed(session);
|
|
901
|
-
}
|
|
902
|
-
};
|
|
903
|
-
_defineProperty(DocLayoutExecutorService, "_performanceSampleLimit", 2048);
|
|
904
|
-
DocLayoutExecutorService = _DocLayoutExecutorService = __decorate([
|
|
905
|
-
__decorateParam(0, _univerjs_core.IUniverInstanceService),
|
|
906
|
-
__decorateParam(1, _univerjs_core.ICommandService),
|
|
907
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
908
|
-
__decorateParam(3, _univerjs_core.ILogService)
|
|
909
|
-
], DocLayoutExecutorService);
|
|
194
|
+
DocSelectionManagerService = require_worker.__decorate([require_worker.__decorateParam(0, _univerjs_core.ICommandService), require_worker.__decorateParam(1, _univerjs_core.IUniverInstanceService)], DocSelectionManagerService);
|
|
910
195
|
|
|
911
|
-
|
|
912
|
-
//#region src/services/doc-skeleton-manager.service.ts
|
|
196
|
+
// src/services/doc-skeleton-manager.service.ts
|
|
913
197
|
let DocSkeletonManagerService = class DocSkeletonManagerService extends _univerjs_core.RxDisposable {
|
|
914
198
|
constructor(_context, _localeService, _univerInstanceService, _docLayoutExecutorService, _configService) {
|
|
915
199
|
super();
|
|
@@ -918,14 +202,14 @@ let DocSkeletonManagerService = class DocSkeletonManagerService extends _univerj
|
|
|
918
202
|
this._univerInstanceService = _univerInstanceService;
|
|
919
203
|
this._docLayoutExecutorService = _docLayoutExecutorService;
|
|
920
204
|
this._configService = _configService;
|
|
921
|
-
_defineProperty(this, "_skeleton", void 0);
|
|
922
|
-
_defineProperty(this, "_docViewModel", void 0);
|
|
923
|
-
_defineProperty(this, "_currentSkeleton$", new rxjs.BehaviorSubject(null));
|
|
924
|
-
_defineProperty(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
925
|
-
_defineProperty(this, "_currentSkeletonBefore$", new rxjs.BehaviorSubject(null));
|
|
926
|
-
_defineProperty(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
927
|
-
_defineProperty(this, "_currentViewModel$", new rxjs.BehaviorSubject(null));
|
|
928
|
-
_defineProperty(this, "currentViewModel$", this._currentViewModel$.asObservable());
|
|
205
|
+
require_worker._defineProperty(this, "_skeleton", void 0);
|
|
206
|
+
require_worker._defineProperty(this, "_docViewModel", void 0);
|
|
207
|
+
require_worker._defineProperty(this, "_currentSkeleton$", new rxjs.BehaviorSubject(null));
|
|
208
|
+
require_worker._defineProperty(this, "currentSkeleton$", this._currentSkeleton$.asObservable());
|
|
209
|
+
require_worker._defineProperty(this, "_currentSkeletonBefore$", new rxjs.BehaviorSubject(null));
|
|
210
|
+
require_worker._defineProperty(this, "currentSkeletonBefore$", this._currentSkeletonBefore$.asObservable());
|
|
211
|
+
require_worker._defineProperty(this, "_currentViewModel$", new rxjs.BehaviorSubject(null));
|
|
212
|
+
require_worker._defineProperty(this, "currentViewModel$", this._currentViewModel$.asObservable());
|
|
929
213
|
this._init();
|
|
930
214
|
this._univerInstanceService.getCurrentTypeOfUnit$(_univerjs_core.UniverInstanceType.UNIVER_DOC).pipe((0, rxjs.takeUntil)(this.dispose$)).subscribe((documentModel) => {
|
|
931
215
|
if (documentModel && documentModel.getUnitId() === this._context.unitId) this._update(documentModel);
|
|
@@ -981,23 +265,22 @@ let DocSkeletonManagerService = class DocSkeletonManagerService extends _univerj
|
|
|
981
265
|
return _univerjs_engine_render.DocumentSkeleton.create(documentViewModel, this._localeService, { lineGap: isSheetEditor ? this._configService.getConfig(_univerjs_core.SHEET_TEXT_LINE_GAP) : void 0 });
|
|
982
266
|
}
|
|
983
267
|
_buildDocViewModel(documentDataModel) {
|
|
984
|
-
return new _univerjs_engine_render.DocumentViewModel(documentDataModel);
|
|
268
|
+
return this._context.unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || this._context.unitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY ? new _univerjs_engine_render.SheetCellDocumentViewModel(documentDataModel) : new _univerjs_engine_render.DocumentViewModel(documentDataModel);
|
|
985
269
|
}
|
|
986
270
|
};
|
|
987
|
-
DocSkeletonManagerService = __decorate([
|
|
988
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
989
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
990
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(DocLayoutExecutorService)),
|
|
991
|
-
__decorateParam(4, _univerjs_core.IConfigService)
|
|
271
|
+
DocSkeletonManagerService = require_worker.__decorate([
|
|
272
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.LocaleService)),
|
|
273
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
274
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(require_worker.DocLayoutExecutorService)),
|
|
275
|
+
require_worker.__decorateParam(4, _univerjs_core.IConfigService)
|
|
992
276
|
], DocSkeletonManagerService);
|
|
993
277
|
|
|
994
|
-
|
|
995
|
-
//#region src/services/doc-state-emit.service.ts
|
|
278
|
+
// src/services/doc-state-emit.service.ts
|
|
996
279
|
var DocStateEmitService = class extends _univerjs_core.RxDisposable {
|
|
997
280
|
constructor() {
|
|
998
281
|
super();
|
|
999
|
-
_defineProperty(this, "_docStateChangeParams$", new rxjs.BehaviorSubject(null));
|
|
1000
|
-
_defineProperty(this, "docStateChangeParams$", this._docStateChangeParams$.asObservable());
|
|
282
|
+
require_worker._defineProperty(this, "_docStateChangeParams$", new rxjs.BehaviorSubject(null));
|
|
283
|
+
require_worker._defineProperty(this, "docStateChangeParams$", this._docStateChangeParams$.asObservable());
|
|
1001
284
|
}
|
|
1002
285
|
emitStateChangeInfo(params) {
|
|
1003
286
|
this._docStateChangeParams$.next(params);
|
|
@@ -1008,8 +291,7 @@ var DocStateEmitService = class extends _univerjs_core.RxDisposable {
|
|
|
1008
291
|
}
|
|
1009
292
|
};
|
|
1010
293
|
|
|
1011
|
-
|
|
1012
|
-
//#region src/commands/mutations/doc-structure-mutation-validation.ts
|
|
294
|
+
// src/commands/mutations/doc-structure-mutation-validation.ts
|
|
1013
295
|
const STRUCTURAL_BODY_FIELDS = [
|
|
1014
296
|
"paragraphs",
|
|
1015
297
|
"sectionBreaks",
|
|
@@ -1052,7 +334,7 @@ const NON_STRUCTURAL_ROOT_FIELDS = /* @__PURE__ */ new Set([
|
|
|
1052
334
|
"tableSource",
|
|
1053
335
|
"title"
|
|
1054
336
|
]);
|
|
1055
|
-
function isRecord$
|
|
337
|
+
function isRecord$2(value) {
|
|
1056
338
|
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
1057
339
|
}
|
|
1058
340
|
function containsStructuralToken(dataStream) {
|
|
@@ -1060,7 +342,7 @@ function containsStructuralToken(dataStream) {
|
|
|
1060
342
|
return false;
|
|
1061
343
|
}
|
|
1062
344
|
function isStructurePreservingBody(value) {
|
|
1063
|
-
if (!isRecord$
|
|
345
|
+
if (!isRecord$2(value)) return false;
|
|
1064
346
|
const dataStream = value.dataStream;
|
|
1065
347
|
if (dataStream != null && (typeof dataStream !== "string" || containsStructuralToken(dataStream))) return false;
|
|
1066
348
|
return STRUCTURAL_BODY_FIELDS.every((field) => {
|
|
@@ -1071,7 +353,7 @@ function isStructurePreservingBody(value) {
|
|
|
1071
353
|
function isStructurePreservingTextXEdit(value) {
|
|
1072
354
|
if (!Array.isArray(value)) return false;
|
|
1073
355
|
return value.every((action) => {
|
|
1074
|
-
if (!isRecord$
|
|
356
|
+
if (!isRecord$2(action) || typeof action.len !== "number" || !Number.isFinite(action.len)) return false;
|
|
1075
357
|
if (action.t === _univerjs_core.TextXActionType.DELETE) return true;
|
|
1076
358
|
if (action.t === _univerjs_core.TextXActionType.INSERT) return isStructurePreservingBody(action.body);
|
|
1077
359
|
return action.t === _univerjs_core.TextXActionType.RETAIN && (action.body == null || isStructurePreservingBody(action.body));
|
|
@@ -1246,9 +528,9 @@ function validateDocStructureMutation(documentDataModel, segmentId, actions, und
|
|
|
1246
528
|
const path = cursor.getPath();
|
|
1247
529
|
if (path[0] === "notes" && (path.length <= 2 || path[2] !== "body") || path.includes("customRanges")) changesFootnoteStructure = true;
|
|
1248
530
|
if (component.et === _univerjs_core.TextX.id && Array.isArray(component.e)) for (const action of component.e) {
|
|
1249
|
-
if (isRecord$
|
|
1250
|
-
const ranges = isRecord$
|
|
1251
|
-
if (Array.isArray(ranges) && ranges.some((range) => isRecord$
|
|
531
|
+
if (isRecord$2(action) && Array.isArray(action.rangeUpdates) && action.rangeUpdates.some((update) => isRecord$2(update) && isRecord$2(update.range) && (update.range.rangeType === _univerjs_core.CustomRangeType.FOOTNOTE || update.range.rangeType === _univerjs_core.CustomRangeType.ENDNOTE))) changesFootnoteStructure = true;
|
|
532
|
+
const ranges = isRecord$2(action) && isRecord$2(action.body) ? action.body.customRanges : void 0;
|
|
533
|
+
if (Array.isArray(ranges) && ranges.some((range) => isRecord$2(range) && (range.rangeType === _univerjs_core.CustomRangeType.FOOTNOTE || range.rangeType === _univerjs_core.CustomRangeType.ENDNOTE))) changesFootnoteStructure = true;
|
|
1252
534
|
}
|
|
1253
535
|
});
|
|
1254
536
|
if (changesFootnoteStructure) {
|
|
@@ -1258,8 +540,7 @@ function validateDocStructureMutation(documentDataModel, segmentId, actions, und
|
|
|
1258
540
|
return preservesStructure && !changesFootnoteStructure;
|
|
1259
541
|
}
|
|
1260
542
|
|
|
1261
|
-
|
|
1262
|
-
//#region src/commands/mutations/core-editing.mutation.ts
|
|
543
|
+
// src/commands/mutations/core-editing.mutation.ts
|
|
1263
544
|
let DocHistoryAction = /* @__PURE__ */ function(DocHistoryAction) {
|
|
1264
545
|
DocHistoryAction["DeleteChart"] = "delete-chart";
|
|
1265
546
|
DocHistoryAction["DeleteDivider"] = "delete-divider";
|
|
@@ -1403,7 +684,7 @@ function scheduleDocumentSelectionUpdate(selectionManager, params, isSync) {
|
|
|
1403
684
|
* send to undo redo service (will be used by the triggering command).
|
|
1404
685
|
*/
|
|
1405
686
|
const RichTextEditingMutation = {
|
|
1406
|
-
id: RICH_TEXT_EDITING_MUTATION_ID,
|
|
687
|
+
id: require_worker.RICH_TEXT_EDITING_MUTATION_ID,
|
|
1407
688
|
type: _univerjs_core.CommandType.MUTATION,
|
|
1408
689
|
handler: (accessor, params, options) => {
|
|
1409
690
|
var _renderManagerService;
|
|
@@ -1449,7 +730,7 @@ const RichTextEditingMutation = {
|
|
|
1449
730
|
resetDocumentViewModel(documentViewModel, documentDataModel, segmentId, appliedActions, preservesStructure);
|
|
1450
731
|
scheduleDocumentSelectionUpdate(docSelectionManagerService, params, isSync);
|
|
1451
732
|
const changeState = {
|
|
1452
|
-
commandId: RICH_TEXT_EDITING_MUTATION_ID,
|
|
733
|
+
commandId: require_worker.RICH_TEXT_EDITING_MUTATION_ID,
|
|
1453
734
|
unitId,
|
|
1454
735
|
segmentId,
|
|
1455
736
|
trigger,
|
|
@@ -1483,8 +764,7 @@ const RichTextEditingMutation = {
|
|
|
1483
764
|
}
|
|
1484
765
|
};
|
|
1485
766
|
|
|
1486
|
-
|
|
1487
|
-
//#region src/commands/commands/core-editing.command.ts
|
|
767
|
+
// src/commands/commands/core-editing.command.ts
|
|
1488
768
|
/**
|
|
1489
769
|
* The command to insert text. The changed range could be non-collapsed, mainly use in line break and normal input.
|
|
1490
770
|
*/
|
|
@@ -1640,8 +920,7 @@ const UpdateTextCommand = {
|
|
|
1640
920
|
}
|
|
1641
921
|
};
|
|
1642
922
|
|
|
1643
|
-
|
|
1644
|
-
//#region src/commands/commands/create-header-footer.command.ts
|
|
923
|
+
// src/commands/commands/create-header-footer.command.ts
|
|
1645
924
|
let HeaderFooterType = /* @__PURE__ */ function(HeaderFooterType) {
|
|
1646
925
|
HeaderFooterType[HeaderFooterType["FIRST_PAGE_HEADER"] = 0] = "FIRST_PAGE_HEADER";
|
|
1647
926
|
HeaderFooterType[HeaderFooterType["FIRST_PAGE_FOOTER"] = 1] = "FIRST_PAGE_FOOTER";
|
|
@@ -1784,8 +1063,7 @@ const CreateHeaderFooterCommand = {
|
|
|
1784
1063
|
}
|
|
1785
1064
|
};
|
|
1786
1065
|
|
|
1787
|
-
|
|
1788
|
-
//#region src/commands/commands/set-document-default-paragraph-style.command.ts
|
|
1066
|
+
// src/commands/commands/set-document-default-paragraph-style.command.ts
|
|
1789
1067
|
const SetDocumentDefaultParagraphStyleCommand = {
|
|
1790
1068
|
id: "doc.command.set-default-paragraph-style",
|
|
1791
1069
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1828,8 +1106,7 @@ const SetDocumentDefaultParagraphStyleCommand = {
|
|
|
1828
1106
|
}
|
|
1829
1107
|
};
|
|
1830
1108
|
|
|
1831
|
-
|
|
1832
|
-
//#region src/commands/mutations/docs-rename.mutation.ts
|
|
1109
|
+
// src/commands/mutations/docs-rename.mutation.ts
|
|
1833
1110
|
const DocsRenameMutation = {
|
|
1834
1111
|
id: "doc.mutation.rename-doc",
|
|
1835
1112
|
type: _univerjs_core.CommandType.MUTATION,
|
|
@@ -1841,8 +1118,7 @@ const DocsRenameMutation = {
|
|
|
1841
1118
|
}
|
|
1842
1119
|
};
|
|
1843
1120
|
|
|
1844
|
-
|
|
1845
|
-
//#region src/commands/commands/set-document-name.command.ts
|
|
1121
|
+
// src/commands/commands/set-document-name.command.ts
|
|
1846
1122
|
const SetDocumentNameCommand = {
|
|
1847
1123
|
id: "doc.command.set-name",
|
|
1848
1124
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -1875,123 +1151,114 @@ const SetDocumentNameCommand = {
|
|
|
1875
1151
|
}
|
|
1876
1152
|
};
|
|
1877
1153
|
|
|
1878
|
-
|
|
1879
|
-
//#region src/services/permission/permission-point/document/comment.ts
|
|
1154
|
+
// src/services/permission/permission-point/document/comment.ts
|
|
1880
1155
|
var DocumentCommentPermission = class {
|
|
1881
1156
|
constructor(unitId) {
|
|
1882
1157
|
this.unitId = unitId;
|
|
1883
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1884
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Comment);
|
|
1885
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1886
|
-
_defineProperty(this, "id", void 0);
|
|
1887
|
-
_defineProperty(this, "value", true);
|
|
1158
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1159
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Comment);
|
|
1160
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1161
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1162
|
+
require_worker._defineProperty(this, "value", true);
|
|
1888
1163
|
this.id = `${this.type}.${this.subType}_${unitId}`;
|
|
1889
1164
|
}
|
|
1890
1165
|
};
|
|
1891
1166
|
|
|
1892
|
-
|
|
1893
|
-
//#region src/services/permission/permission-point/document/copy.ts
|
|
1167
|
+
// src/services/permission/permission-point/document/copy.ts
|
|
1894
1168
|
var DocumentCopyPermission = class {
|
|
1895
1169
|
constructor(unitId) {
|
|
1896
1170
|
this.unitId = unitId;
|
|
1897
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1898
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Copy);
|
|
1899
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1900
|
-
_defineProperty(this, "id", void 0);
|
|
1901
|
-
_defineProperty(this, "value", true);
|
|
1171
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1172
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Copy);
|
|
1173
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1174
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1175
|
+
require_worker._defineProperty(this, "value", true);
|
|
1902
1176
|
this.id = `${this.type}.${this.subType}_${unitId}`;
|
|
1903
1177
|
}
|
|
1904
1178
|
};
|
|
1905
1179
|
|
|
1906
|
-
|
|
1907
|
-
//#region src/services/permission/permission-point/document/editable.ts
|
|
1180
|
+
// src/services/permission/permission-point/document/editable.ts
|
|
1908
1181
|
var DocumentEditablePermission = class {
|
|
1909
1182
|
constructor(unitId) {
|
|
1910
1183
|
this.unitId = unitId;
|
|
1911
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1912
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1913
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1914
|
-
_defineProperty(this, "id", void 0);
|
|
1915
|
-
_defineProperty(this, "value", true);
|
|
1184
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1185
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1186
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1187
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1188
|
+
require_worker._defineProperty(this, "value", true);
|
|
1916
1189
|
this.id = `${this.type}.${this.subType}_${unitId}`;
|
|
1917
1190
|
}
|
|
1918
1191
|
};
|
|
1919
1192
|
|
|
1920
|
-
|
|
1921
|
-
//#region src/services/permission/permission-point/document/export.ts
|
|
1193
|
+
// src/services/permission/permission-point/document/export.ts
|
|
1922
1194
|
var DocumentExportPermission = class {
|
|
1923
1195
|
constructor(unitId) {
|
|
1924
1196
|
this.unitId = unitId;
|
|
1925
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1926
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Export);
|
|
1927
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1928
|
-
_defineProperty(this, "id", void 0);
|
|
1929
|
-
_defineProperty(this, "value", true);
|
|
1197
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1198
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Export);
|
|
1199
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1200
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1201
|
+
require_worker._defineProperty(this, "value", true);
|
|
1930
1202
|
this.id = `${this.type}.${this.subType}_${unitId}`;
|
|
1931
1203
|
}
|
|
1932
1204
|
};
|
|
1933
1205
|
|
|
1934
|
-
|
|
1935
|
-
//#region src/services/permission/permission-point/document/print.ts
|
|
1206
|
+
// src/services/permission/permission-point/document/print.ts
|
|
1936
1207
|
var DocumentPrintPermission = class {
|
|
1937
1208
|
constructor(unitId) {
|
|
1938
1209
|
this.unitId = unitId;
|
|
1939
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1940
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Print);
|
|
1941
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1942
|
-
_defineProperty(this, "id", void 0);
|
|
1943
|
-
_defineProperty(this, "value", true);
|
|
1210
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.Document);
|
|
1211
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Print);
|
|
1212
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1213
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1214
|
+
require_worker._defineProperty(this, "value", true);
|
|
1944
1215
|
this.id = `${this.type}.${this.subType}_${unitId}`;
|
|
1945
1216
|
}
|
|
1946
1217
|
};
|
|
1947
1218
|
|
|
1948
|
-
|
|
1949
|
-
//#region src/services/permission/permission-point/entity/edit.ts
|
|
1219
|
+
// src/services/permission/permission-point/entity/edit.ts
|
|
1950
1220
|
var DocumentEntityEditPermission = class {
|
|
1951
1221
|
constructor(unitId, objectId) {
|
|
1952
1222
|
this.unitId = unitId;
|
|
1953
1223
|
this.objectId = objectId;
|
|
1954
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentEntity);
|
|
1955
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1956
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1957
|
-
_defineProperty(this, "id", void 0);
|
|
1958
|
-
_defineProperty(this, "value", true);
|
|
1224
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentEntity);
|
|
1225
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1226
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1227
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1228
|
+
require_worker._defineProperty(this, "value", true);
|
|
1959
1229
|
this.id = `${this.type}.${this.subType}_${unitId}_${objectId}`;
|
|
1960
1230
|
}
|
|
1961
1231
|
};
|
|
1962
1232
|
|
|
1963
|
-
|
|
1964
|
-
//#region src/services/permission/permission-point/paragraph/edit.ts
|
|
1233
|
+
// src/services/permission/permission-point/paragraph/edit.ts
|
|
1965
1234
|
var DocumentParagraphEditPermission = class {
|
|
1966
1235
|
constructor(unitId, objectId) {
|
|
1967
1236
|
this.unitId = unitId;
|
|
1968
1237
|
this.objectId = objectId;
|
|
1969
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentParagraph);
|
|
1970
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1971
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1972
|
-
_defineProperty(this, "id", void 0);
|
|
1973
|
-
_defineProperty(this, "value", true);
|
|
1238
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentParagraph);
|
|
1239
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1240
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1241
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1242
|
+
require_worker._defineProperty(this, "value", true);
|
|
1974
1243
|
this.id = `${this.type}.${this.subType}_${unitId}_${objectId}`;
|
|
1975
1244
|
}
|
|
1976
1245
|
};
|
|
1977
1246
|
|
|
1978
|
-
|
|
1979
|
-
//#region src/services/permission/permission-point/section/edit.ts
|
|
1247
|
+
// src/services/permission/permission-point/section/edit.ts
|
|
1980
1248
|
var DocumentSectionEditPermission = class {
|
|
1981
1249
|
constructor(unitId, objectId) {
|
|
1982
1250
|
this.unitId = unitId;
|
|
1983
1251
|
this.objectId = objectId;
|
|
1984
|
-
_defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentSection);
|
|
1985
|
-
_defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1986
|
-
_defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1987
|
-
_defineProperty(this, "id", void 0);
|
|
1988
|
-
_defineProperty(this, "value", true);
|
|
1252
|
+
require_worker._defineProperty(this, "type", _univerjs_protocol.UnitObject.DocumentSection);
|
|
1253
|
+
require_worker._defineProperty(this, "subType", _univerjs_protocol.UnitAction.Edit);
|
|
1254
|
+
require_worker._defineProperty(this, "status", _univerjs_core.PermissionStatus.INIT);
|
|
1255
|
+
require_worker._defineProperty(this, "id", void 0);
|
|
1256
|
+
require_worker._defineProperty(this, "value", true);
|
|
1989
1257
|
this.id = `${this.type}.${this.subType}_${unitId}_${objectId}`;
|
|
1990
1258
|
}
|
|
1991
1259
|
};
|
|
1992
1260
|
|
|
1993
|
-
|
|
1994
|
-
//#region src/services/permission/document-permission.ts
|
|
1261
|
+
// src/services/permission/document-permission.ts
|
|
1995
1262
|
const DOCUMENT_UNIT_PERMISSION_ACTIONS = [
|
|
1996
1263
|
_univerjs_protocol.UnitAction.Edit,
|
|
1997
1264
|
_univerjs_protocol.UnitAction.Copy,
|
|
@@ -2054,8 +1321,7 @@ function canEditDocumentTargets(permissionService, unitId, objectIds) {
|
|
|
2054
1321
|
return true;
|
|
2055
1322
|
}
|
|
2056
1323
|
|
|
2057
|
-
|
|
2058
|
-
//#region src/commands/commands/set-document-permission.command.ts
|
|
1324
|
+
// src/commands/commands/set-document-permission.command.ts
|
|
2059
1325
|
const SetDocumentPermissionCommand = {
|
|
2060
1326
|
type: _univerjs_core.CommandType.COMMAND,
|
|
2061
1327
|
id: "doc.command.set-permission",
|
|
@@ -2081,8 +1347,7 @@ const SetDocumentPermissionCommand = {
|
|
|
2081
1347
|
}
|
|
2082
1348
|
};
|
|
2083
1349
|
|
|
2084
|
-
|
|
2085
|
-
//#region src/commands/commands/set-document-permissions.command.ts
|
|
1350
|
+
// src/commands/commands/set-document-permissions.command.ts
|
|
2086
1351
|
const SetDocumentPermissionsCommand = {
|
|
2087
1352
|
type: _univerjs_core.CommandType.COMMAND,
|
|
2088
1353
|
id: "doc.command.set-permissions",
|
|
@@ -2104,8 +1369,7 @@ const SetDocumentPermissionsCommand = {
|
|
|
2104
1369
|
}
|
|
2105
1370
|
};
|
|
2106
1371
|
|
|
2107
|
-
|
|
2108
|
-
//#region src/utils/sections.ts
|
|
1372
|
+
// src/utils/sections.ts
|
|
2109
1373
|
/** Returns document-level section breaks, excluding table-cell and modern-column sentinels. */
|
|
2110
1374
|
function getTopLevelSectionBreaks(body) {
|
|
2111
1375
|
const sectionBreakByIndex = new Map((body.sectionBreaks ?? []).map((sectionBreak) => [sectionBreak.startIndex, sectionBreak]));
|
|
@@ -2126,8 +1390,7 @@ function getTopLevelSectionBreaks(body) {
|
|
|
2126
1390
|
return result;
|
|
2127
1391
|
}
|
|
2128
1392
|
|
|
2129
|
-
|
|
2130
|
-
//#region src/services/permission/document-permission-resolver.ts
|
|
1393
|
+
// src/services/permission/document-permission-resolver.ts
|
|
2131
1394
|
const HEADER_FOOTER_REFERENCE_KEYS = [
|
|
2132
1395
|
"defaultHeaderId",
|
|
2133
1396
|
"defaultFooterId",
|
|
@@ -2315,18 +1578,18 @@ function getDrawingIdsFromActions(actions) {
|
|
|
2315
1578
|
});
|
|
2316
1579
|
return;
|
|
2317
1580
|
}
|
|
2318
|
-
if (!isRecord$
|
|
1581
|
+
if (!isRecord$1(value)) return;
|
|
2319
1582
|
Object.values(value).forEach(visit);
|
|
2320
1583
|
};
|
|
2321
1584
|
visit(actions);
|
|
2322
1585
|
return [...result];
|
|
2323
1586
|
}
|
|
2324
1587
|
function isTextXAction(value) {
|
|
2325
|
-
if (!isRecord$
|
|
2326
|
-
if (value.t === _univerjs_core.TextXActionType.INSERT) return isRecord$
|
|
1588
|
+
if (!isRecord$1(value) || typeof value.len !== "number") return false;
|
|
1589
|
+
if (value.t === _univerjs_core.TextXActionType.INSERT) return isRecord$1(value.body);
|
|
2327
1590
|
return value.t === _univerjs_core.TextXActionType.RETAIN || value.t === _univerjs_core.TextXActionType.DELETE;
|
|
2328
1591
|
}
|
|
2329
|
-
function isRecord$
|
|
1592
|
+
function isRecord$1(value) {
|
|
2330
1593
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2331
1594
|
}
|
|
2332
1595
|
function getDocumentEntityParentPermissionObjectIds(documentDataModel, segmentId, entityType, entityId) {
|
|
@@ -2390,8 +1653,7 @@ function getHeaderFooterOwnerSectionIds(documentDataModel, segmentId, sections =
|
|
|
2390
1653
|
return [...result];
|
|
2391
1654
|
}
|
|
2392
1655
|
|
|
2393
|
-
|
|
2394
|
-
//#region src/commands/commands/set-heading-collapsed.command.ts
|
|
1656
|
+
// src/commands/commands/set-heading-collapsed.command.ts
|
|
2395
1657
|
const SetHeadingCollapsedCommand = {
|
|
2396
1658
|
id: "doc.command.set-heading-collapsed",
|
|
2397
1659
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -2459,8 +1721,7 @@ const SetHeadingCollapsedCommand = {
|
|
|
2459
1721
|
}
|
|
2460
1722
|
};
|
|
2461
1723
|
|
|
2462
|
-
|
|
2463
|
-
//#region src/commands/commands/set-section-header-footer-link.command.ts
|
|
1724
|
+
// src/commands/commands/set-section-header-footer-link.command.ts
|
|
2464
1725
|
const SetSectionHeaderFooterLinkCommand = {
|
|
2465
1726
|
id: "doc.command.set-section-header-footer-link",
|
|
2466
1727
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -2554,8 +1815,7 @@ function buildUnlinkActions(context, kind, requestedSegmentId) {
|
|
|
2554
1815
|
], segmentId)];
|
|
2555
1816
|
}
|
|
2556
1817
|
|
|
2557
|
-
|
|
2558
|
-
//#region src/commands/commands/update-document-paragraph-style.command.ts
|
|
1818
|
+
// src/commands/commands/update-document-paragraph-style.command.ts
|
|
2559
1819
|
function isValidParams(params) {
|
|
2560
1820
|
return Boolean((params === null || params === void 0 ? void 0 : params.unitId) && params.paragraphId && Number.isInteger(params.startOffset) && Number.isInteger(params.endOffset) && params.startOffset >= 0 && params.endOffset >= params.startOffset && params.style && Object.keys(params.style).length > 0);
|
|
2561
1821
|
}
|
|
@@ -2653,8 +1913,7 @@ const UpdateDocumentParagraphStyleCommand = {
|
|
|
2653
1913
|
}
|
|
2654
1914
|
};
|
|
2655
1915
|
|
|
2656
|
-
|
|
2657
|
-
//#region src/utils/section-columns.ts
|
|
1916
|
+
// src/utils/section-columns.ts
|
|
2658
1917
|
function resolveSectionValue(sectionValue, documentValue, fallback) {
|
|
2659
1918
|
return sectionValue ?? documentValue ?? fallback;
|
|
2660
1919
|
}
|
|
@@ -2722,8 +1981,7 @@ function createSectionColumnProperties(documentStyle, section, columnCount, gap,
|
|
|
2722
1981
|
}));
|
|
2723
1982
|
}
|
|
2724
1983
|
|
|
2725
|
-
|
|
2726
|
-
//#region src/commands/commands/update-document-section.command.ts
|
|
1984
|
+
// src/commands/commands/update-document-section.command.ts
|
|
2727
1985
|
const UpdateDocumentSectionCommand = {
|
|
2728
1986
|
id: "doc.command.update-section",
|
|
2729
1987
|
type: _univerjs_core.CommandType.COMMAND,
|
|
@@ -2925,8 +2183,7 @@ function executeSectionTextX(commandService, documentDataModel, textX, trigger)
|
|
|
2925
2183
|
}));
|
|
2926
2184
|
}
|
|
2927
2185
|
|
|
2928
|
-
|
|
2929
|
-
//#region src/services/permission/document-permission-rule.model.ts
|
|
2186
|
+
// src/services/permission/document-permission-rule.model.ts
|
|
2930
2187
|
/**
|
|
2931
2188
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
2932
2189
|
*
|
|
@@ -2951,10 +2208,9 @@ let DocumentPermissionRuleModel = class DocumentPermissionRuleModel extends _uni
|
|
|
2951
2208
|
]);
|
|
2952
2209
|
}
|
|
2953
2210
|
};
|
|
2954
|
-
DocumentPermissionRuleModel = __decorate([__decorateParam(0, _univerjs_core.IResourceManagerService)], DocumentPermissionRuleModel);
|
|
2211
|
+
DocumentPermissionRuleModel = require_worker.__decorate([require_worker.__decorateParam(0, _univerjs_core.IResourceManagerService)], DocumentPermissionRuleModel);
|
|
2955
2212
|
|
|
2956
|
-
|
|
2957
|
-
//#region src/commands/mutations/set-document-permission-rule.mutation.ts
|
|
2213
|
+
// src/commands/mutations/set-document-permission-rule.mutation.ts
|
|
2958
2214
|
const SetDocumentPermissionRuleMutation = {
|
|
2959
2215
|
id: "doc.mutation.set-permission-rule",
|
|
2960
2216
|
type: _univerjs_core.CommandType.MUTATION,
|
|
@@ -2964,8 +2220,7 @@ const SetDocumentPermissionRuleMutation = {
|
|
|
2964
2220
|
}
|
|
2965
2221
|
};
|
|
2966
2222
|
|
|
2967
|
-
|
|
2968
|
-
//#region src/commands/mutations/set-document-permission-rules.mutation.ts
|
|
2223
|
+
// src/commands/mutations/set-document-permission-rules.mutation.ts
|
|
2969
2224
|
const SetDocumentPermissionRulesMutation = {
|
|
2970
2225
|
id: "doc.mutation.set-permission-rules",
|
|
2971
2226
|
type: _univerjs_core.CommandType.MUTATION,
|
|
@@ -2975,8 +2230,7 @@ const SetDocumentPermissionRulesMutation = {
|
|
|
2975
2230
|
}
|
|
2976
2231
|
};
|
|
2977
2232
|
|
|
2978
|
-
|
|
2979
|
-
//#region src/embed-host-anchor.ts
|
|
2233
|
+
// src/embed-host-anchor.ts
|
|
2980
2234
|
const EMBED_DOCS_CUSTOM_BLOCK_DEFAULT_COMPONENT_KEY = "UniverEmbedDocsCustomBlock";
|
|
2981
2235
|
const DEFAULT_CUSTOM_BLOCK_SIZE = {
|
|
2982
2236
|
width: 720,
|
|
@@ -3133,34 +2387,7 @@ function composeActions(actions) {
|
|
|
3133
2387
|
}, []);
|
|
3134
2388
|
}
|
|
3135
2389
|
|
|
3136
|
-
|
|
3137
|
-
//#region package.json
|
|
3138
|
-
var name = "@univerjs/docs";
|
|
3139
|
-
var version = "1.3.0";
|
|
3140
|
-
|
|
3141
|
-
//#endregion
|
|
3142
|
-
//#region src/config/config.ts
|
|
3143
|
-
/**
|
|
3144
|
-
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3145
|
-
*
|
|
3146
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3147
|
-
* you may not use this file except in compliance with the License.
|
|
3148
|
-
* You may obtain a copy of the License at
|
|
3149
|
-
*
|
|
3150
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
3151
|
-
*
|
|
3152
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
3153
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
3154
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3155
|
-
* See the License for the specific language governing permissions and
|
|
3156
|
-
* limitations under the License.
|
|
3157
|
-
*/
|
|
3158
|
-
const DOCS_PLUGIN_CONFIG_KEY = "docs.config";
|
|
3159
|
-
const configSymbol$1 = Symbol(DOCS_PLUGIN_CONFIG_KEY);
|
|
3160
|
-
const defaultPluginConfig = {};
|
|
3161
|
-
|
|
3162
|
-
//#endregion
|
|
3163
|
-
//#region src/controllers/custom-range.controller.ts
|
|
2390
|
+
// src/controllers/custom-range.controller.ts
|
|
3164
2391
|
let DocCustomRangeController = class DocCustomRangeController extends _univerjs_core.Disposable {
|
|
3165
2392
|
constructor(_commandService, _textSelectionManagerService, _univerInstanceService) {
|
|
3166
2393
|
super();
|
|
@@ -3208,14 +2435,13 @@ let DocCustomRangeController = class DocCustomRangeController extends _univerjs_
|
|
|
3208
2435
|
}));
|
|
3209
2436
|
}
|
|
3210
2437
|
};
|
|
3211
|
-
DocCustomRangeController = __decorate([
|
|
3212
|
-
__decorateParam(0, _univerjs_core.ICommandService),
|
|
3213
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(DocSelectionManagerService)),
|
|
3214
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService)
|
|
2438
|
+
DocCustomRangeController = require_worker.__decorate([
|
|
2439
|
+
require_worker.__decorateParam(0, _univerjs_core.ICommandService),
|
|
2440
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(DocSelectionManagerService)),
|
|
2441
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService)
|
|
3215
2442
|
], DocCustomRangeController);
|
|
3216
2443
|
|
|
3217
|
-
|
|
3218
|
-
//#region src/controllers/doc-permission.controller.ts
|
|
2444
|
+
// src/controllers/doc-permission.controller.ts
|
|
3219
2445
|
const NON_EDIT_DOCUMENT_COMMAND_IDS = /* @__PURE__ */ new Set([
|
|
3220
2446
|
SetDocumentPermissionCommand.id,
|
|
3221
2447
|
SetDocumentPermissionsCommand.id,
|
|
@@ -3289,11 +2515,11 @@ let DocPermissionController = class DocPermissionController extends _univerjs_co
|
|
|
3289
2515
|
return isDocumentEditCommand(commandInfo.id) || isDocumentDataMutation(commandInfo) ? [] : null;
|
|
3290
2516
|
}
|
|
3291
2517
|
};
|
|
3292
|
-
DocPermissionController = __decorate([
|
|
3293
|
-
__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3294
|
-
__decorateParam(1, _univerjs_core.ICommandService),
|
|
3295
|
-
__decorateParam(2, _univerjs_core.IPermissionService),
|
|
3296
|
-
__decorateParam(3, _univerjs_core.IUniverInstanceService)
|
|
2518
|
+
DocPermissionController = require_worker.__decorate([
|
|
2519
|
+
require_worker.__decorateParam(0, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
2520
|
+
require_worker.__decorateParam(1, _univerjs_core.ICommandService),
|
|
2521
|
+
require_worker.__decorateParam(2, _univerjs_core.IPermissionService),
|
|
2522
|
+
require_worker.__decorateParam(3, _univerjs_core.IUniverInstanceService)
|
|
3297
2523
|
], DocPermissionController);
|
|
3298
2524
|
function isDocumentEditCommand(id) {
|
|
3299
2525
|
if (NON_EDIT_DOCUMENT_COMMAND_IDS.has(id)) return false;
|
|
@@ -3305,12 +2531,12 @@ function isDocumentDataMutation(commandInfo) {
|
|
|
3305
2531
|
return id.startsWith("doc.mutation.") || id.startsWith("docs.mutation.") || /^docs-[^.]+\.mutation\./.test(id);
|
|
3306
2532
|
}
|
|
3307
2533
|
function isDerivedDocumentMutation(commandInfo) {
|
|
3308
|
-
const params = isRecord
|
|
2534
|
+
const params = isRecord(commandInfo.params) ? commandInfo.params : void 0;
|
|
3309
2535
|
return DERIVED_DOCUMENT_MUTATION_IDS.has(commandInfo.id) || commandInfo.id === "doc.mutation.update-shape-data" && !!(params === null || params === void 0 ? void 0 : params.formulaLastValueGuard);
|
|
3310
2536
|
}
|
|
3311
2537
|
function resolveEntityTargets(documentDataModel, commandInfo) {
|
|
3312
2538
|
const params = commandInfo.params;
|
|
3313
|
-
if (!isRecord
|
|
2539
|
+
if (!isRecord(params)) return [];
|
|
3314
2540
|
const result = /* @__PURE__ */ new Set();
|
|
3315
2541
|
const add = (segmentId, entityType, entityId) => {
|
|
3316
2542
|
result.add(getDocumentEntityPermissionObjectId(segmentId, entityType, entityId));
|
|
@@ -3349,14 +2575,14 @@ function collectEntityReferences(value) {
|
|
|
3349
2575
|
candidate.forEach((item) => visit(item, singularKey));
|
|
3350
2576
|
return;
|
|
3351
2577
|
}
|
|
3352
|
-
if (!isRecord
|
|
2578
|
+
if (!isRecord(candidate)) return;
|
|
3353
2579
|
Object.entries(candidate).forEach(([childKey, child]) => visit(child, childKey));
|
|
3354
2580
|
};
|
|
3355
2581
|
visit(value);
|
|
3356
2582
|
return [...result.values()];
|
|
3357
2583
|
}
|
|
3358
2584
|
function getUnitId(commandInfo, options) {
|
|
3359
|
-
const params = isRecord
|
|
2585
|
+
const params = isRecord(commandInfo.params) ? commandInfo.params : void 0;
|
|
3360
2586
|
return typeof (params === null || params === void 0 ? void 0 : params.unitId) === "string" ? params.unitId : typeof (options === null || options === void 0 ? void 0 : options.unitId) === "string" ? options.unitId : void 0;
|
|
3361
2587
|
}
|
|
3362
2588
|
function getDocumentUnitAction(commandId) {
|
|
@@ -3413,17 +2639,16 @@ function resolveSectionTargets(documentDataModel, commandInfo) {
|
|
|
3413
2639
|
}
|
|
3414
2640
|
return null;
|
|
3415
2641
|
}
|
|
3416
|
-
function isRecord
|
|
2642
|
+
function isRecord(value) {
|
|
3417
2643
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3418
2644
|
}
|
|
3419
2645
|
|
|
3420
|
-
|
|
3421
|
-
//#region src/services/doc-block-move-validator.service.ts
|
|
2646
|
+
// src/services/doc-block-move-validator.service.ts
|
|
3422
2647
|
var DocBlockMoveValidatorService = class extends _univerjs_core.Disposable {
|
|
3423
2648
|
constructor(..._args) {
|
|
3424
2649
|
super(..._args);
|
|
3425
|
-
_defineProperty(this, "_validators", []);
|
|
3426
|
-
_defineProperty(this, "_transformers", []);
|
|
2650
|
+
require_worker._defineProperty(this, "_validators", []);
|
|
2651
|
+
require_worker._defineProperty(this, "_transformers", []);
|
|
3427
2652
|
}
|
|
3428
2653
|
registerValidator(validator) {
|
|
3429
2654
|
this._validators.push(validator);
|
|
@@ -3444,8 +2669,7 @@ var DocBlockMoveValidatorService = class extends _univerjs_core.Disposable {
|
|
|
3444
2669
|
}
|
|
3445
2670
|
};
|
|
3446
2671
|
|
|
3447
|
-
|
|
3448
|
-
//#region src/services/doc-content-insert.service.ts
|
|
2672
|
+
// src/services/doc-content-insert.service.ts
|
|
3449
2673
|
/**
|
|
3450
2674
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3451
2675
|
*
|
|
@@ -3464,7 +2688,7 @@ var DocBlockMoveValidatorService = class extends _univerjs_core.Disposable {
|
|
|
3464
2688
|
var DocContentInsertService = class extends _univerjs_core.Disposable {
|
|
3465
2689
|
constructor(..._args) {
|
|
3466
2690
|
super(..._args);
|
|
3467
|
-
_defineProperty(this, "_range", null);
|
|
2691
|
+
require_worker._defineProperty(this, "_range", null);
|
|
3468
2692
|
}
|
|
3469
2693
|
setInsertRange(range) {
|
|
3470
2694
|
this._range = range;
|
|
@@ -3481,8 +2705,7 @@ var DocContentInsertService = class extends _univerjs_core.Disposable {
|
|
|
3481
2705
|
}
|
|
3482
2706
|
};
|
|
3483
2707
|
|
|
3484
|
-
|
|
3485
|
-
//#region src/services/doc-state-change-manager.service.ts
|
|
2708
|
+
// src/services/doc-state-change-manager.service.ts
|
|
3486
2709
|
const DEBOUNCE_DELAY = 300;
|
|
3487
2710
|
const IDocStateChangeInterceptorService = (0, _univerjs_core.createIdentifier)("doc.state-change-interceptor-service");
|
|
3488
2711
|
let DocStateChangeManagerService = class DocStateChangeManagerService extends _univerjs_core.RxDisposable {
|
|
@@ -3493,12 +2716,12 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
|
|
|
3493
2716
|
this._univerInstanceService = _univerInstanceService;
|
|
3494
2717
|
this._docStateEmitService = _docStateEmitService;
|
|
3495
2718
|
this._docStateChangeInterceptorService = _docStateChangeInterceptorService;
|
|
3496
|
-
_defineProperty(this, "_docStateChange$", new rxjs.BehaviorSubject(null));
|
|
3497
|
-
_defineProperty(this, "docStateChange$", this._docStateChange$.asObservable());
|
|
3498
|
-
_defineProperty(this, "_historyStateCache", /* @__PURE__ */ new Map());
|
|
3499
|
-
_defineProperty(this, "_changeStateCache", /* @__PURE__ */ new Map());
|
|
3500
|
-
_defineProperty(this, "_historyTimer", null);
|
|
3501
|
-
_defineProperty(this, "_changeStateCacheTimer", null);
|
|
2719
|
+
require_worker._defineProperty(this, "_docStateChange$", new rxjs.BehaviorSubject(null));
|
|
2720
|
+
require_worker._defineProperty(this, "docStateChange$", this._docStateChange$.asObservable());
|
|
2721
|
+
require_worker._defineProperty(this, "_historyStateCache", /* @__PURE__ */ new Map());
|
|
2722
|
+
require_worker._defineProperty(this, "_changeStateCache", /* @__PURE__ */ new Map());
|
|
2723
|
+
require_worker._defineProperty(this, "_historyTimer", null);
|
|
2724
|
+
require_worker._defineProperty(this, "_changeStateCacheTimer", null);
|
|
3502
2725
|
this._initialize();
|
|
3503
2726
|
this._listenDocStateChange();
|
|
3504
2727
|
}
|
|
@@ -3661,16 +2884,15 @@ let DocStateChangeManagerService = class DocStateChangeManagerService extends _u
|
|
|
3661
2884
|
this._docStateChange$.next(changeState);
|
|
3662
2885
|
}
|
|
3663
2886
|
};
|
|
3664
|
-
DocStateChangeManagerService = __decorate([
|
|
3665
|
-
__decorateParam(0, (0, _univerjs_core.Optional)(_univerjs_core.IUndoRedoService)),
|
|
3666
|
-
__decorateParam(1, _univerjs_core.ICommandService),
|
|
3667
|
-
__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
3668
|
-
__decorateParam(3, (0, _univerjs_core.Inject)(DocStateEmitService)),
|
|
3669
|
-
__decorateParam(4, (0, _univerjs_core.Optional)(IDocStateChangeInterceptorService))
|
|
2887
|
+
DocStateChangeManagerService = require_worker.__decorate([
|
|
2888
|
+
require_worker.__decorateParam(0, (0, _univerjs_core.Optional)(_univerjs_core.IUndoRedoService)),
|
|
2889
|
+
require_worker.__decorateParam(1, _univerjs_core.ICommandService),
|
|
2890
|
+
require_worker.__decorateParam(2, _univerjs_core.IUniverInstanceService),
|
|
2891
|
+
require_worker.__decorateParam(3, (0, _univerjs_core.Inject)(DocStateEmitService)),
|
|
2892
|
+
require_worker.__decorateParam(4, (0, _univerjs_core.Optional)(IDocStateChangeInterceptorService))
|
|
3670
2893
|
], DocStateChangeManagerService);
|
|
3671
2894
|
|
|
3672
|
-
|
|
3673
|
-
//#region src/services/doc-text-resolver.service.ts
|
|
2895
|
+
// src/services/doc-text-resolver.service.ts
|
|
3674
2896
|
/**
|
|
3675
2897
|
* Builds a consumer-facing text projection while retaining a mapping back to
|
|
3676
2898
|
* the native document offsets.
|
|
@@ -3682,9 +2904,9 @@ DocStateChangeManagerService = __decorate([
|
|
|
3682
2904
|
var DocTextResolverService = class extends _univerjs_core.Disposable {
|
|
3683
2905
|
constructor(..._args) {
|
|
3684
2906
|
super(..._args);
|
|
3685
|
-
_defineProperty(this, "_resolvers", /* @__PURE__ */ new Set());
|
|
3686
|
-
_defineProperty(this, "_textChanged$", new rxjs.Subject());
|
|
3687
|
-
_defineProperty(this, "textChanged$", this._textChanged$.asObservable());
|
|
2907
|
+
require_worker._defineProperty(this, "_resolvers", /* @__PURE__ */ new Set());
|
|
2908
|
+
require_worker._defineProperty(this, "_textChanged$", new rxjs.Subject());
|
|
2909
|
+
require_worker._defineProperty(this, "textChanged$", this._textChanged$.asObservable());
|
|
3688
2910
|
}
|
|
3689
2911
|
register(resolver) {
|
|
3690
2912
|
this._resolvers.add(resolver);
|
|
@@ -3742,16 +2964,15 @@ var DocTextResolverService = class extends _univerjs_core.Disposable {
|
|
|
3742
2964
|
}
|
|
3743
2965
|
};
|
|
3744
2966
|
|
|
3745
|
-
|
|
3746
|
-
//#region src/plugin.ts
|
|
2967
|
+
// src/plugin.ts
|
|
3747
2968
|
let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
|
|
3748
|
-
constructor(_config = defaultPluginConfig, _injector, _configService) {
|
|
2969
|
+
constructor(_config = require_worker.defaultPluginConfig, _injector, _configService) {
|
|
3749
2970
|
super();
|
|
3750
2971
|
this._config = _config;
|
|
3751
2972
|
this._injector = _injector;
|
|
3752
2973
|
this._configService = _configService;
|
|
3753
|
-
const { ...rest } = (0, _univerjs_core.merge)({}, defaultPluginConfig, this._config);
|
|
3754
|
-
this._configService.setConfig(DOCS_PLUGIN_CONFIG_KEY, rest);
|
|
2974
|
+
const { ...rest } = (0, _univerjs_core.merge)({}, require_worker.defaultPluginConfig, this._config);
|
|
2975
|
+
this._configService.setConfig(require_worker.DOCS_PLUGIN_CONFIG_KEY, rest);
|
|
3755
2976
|
}
|
|
3756
2977
|
onStarting() {
|
|
3757
2978
|
this._injector.add([DocumentPermissionRuleModel]);
|
|
@@ -3811,7 +3032,7 @@ let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
|
|
|
3811
3032
|
[DocStateChangeManagerService],
|
|
3812
3033
|
[DocBlockMoveValidatorService],
|
|
3813
3034
|
[DocContentInsertService],
|
|
3814
|
-
[DocLayoutExecutorService],
|
|
3035
|
+
[require_worker.DocLayoutExecutorService],
|
|
3815
3036
|
[DocTextResolverService],
|
|
3816
3037
|
[DocCustomRangeController],
|
|
3817
3038
|
[DocPermissionController]
|
|
@@ -3823,13 +3044,12 @@ let UniverDocsPlugin = class UniverDocsPlugin extends _univerjs_core.Plugin {
|
|
|
3823
3044
|
this._injector.get(DocPermissionController);
|
|
3824
3045
|
}
|
|
3825
3046
|
};
|
|
3826
|
-
_defineProperty(UniverDocsPlugin, "pluginName", "DOCS_PLUGIN");
|
|
3827
|
-
_defineProperty(UniverDocsPlugin, "packageName", name);
|
|
3828
|
-
_defineProperty(UniverDocsPlugin, "version", version);
|
|
3829
|
-
UniverDocsPlugin = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), __decorateParam(2, _univerjs_core.IConfigService)], UniverDocsPlugin);
|
|
3047
|
+
require_worker._defineProperty(UniverDocsPlugin, "pluginName", "DOCS_PLUGIN");
|
|
3048
|
+
require_worker._defineProperty(UniverDocsPlugin, "packageName", require_worker.name);
|
|
3049
|
+
require_worker._defineProperty(UniverDocsPlugin, "version", require_worker.version);
|
|
3050
|
+
UniverDocsPlugin = require_worker.__decorate([require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)), require_worker.__decorateParam(2, _univerjs_core.IConfigService)], UniverDocsPlugin);
|
|
3830
3051
|
|
|
3831
|
-
|
|
3832
|
-
//#region src/layout-worker/config/config.ts
|
|
3052
|
+
// src/layout-worker/config/config.ts
|
|
3833
3053
|
/**
|
|
3834
3054
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3835
3055
|
*
|
|
@@ -3850,8 +3070,7 @@ const configSymbol = Symbol(DOCS_LAYOUT_WORKER_PLUGIN_CONFIG_KEY);
|
|
|
3850
3070
|
const DEFAULT_DOCS_LAYOUT_WORKER_REQUEST_TIMEOUT_MS = 15e3;
|
|
3851
3071
|
const defaultPluginDocsLayoutWorkerConfig = { requestTimeoutMs: DEFAULT_DOCS_LAYOUT_WORKER_REQUEST_TIMEOUT_MS };
|
|
3852
3072
|
|
|
3853
|
-
|
|
3854
|
-
//#region src/layout-worker/document-font-metrics.ts
|
|
3073
|
+
// src/layout-worker/document-font-metrics.ts
|
|
3855
3074
|
/**
|
|
3856
3075
|
* Copyright 2023-present DreamNum Co., Ltd.
|
|
3857
3076
|
*
|
|
@@ -3897,459 +3116,7 @@ function measureDocumentFontFamilies(families) {
|
|
|
3897
3116
|
return _univerjs_engine_render.FontCache.getNormalLineHeightCache();
|
|
3898
3117
|
}
|
|
3899
3118
|
|
|
3900
|
-
|
|
3901
|
-
//#region src/layout-worker/font-loader.ts
|
|
3902
|
-
/** Owns the same explicitly supplied font faces in the rendering and layout realms. */
|
|
3903
|
-
var DocsLayoutFontLoader = class extends _univerjs_core.Disposable {
|
|
3904
|
-
constructor(..._args) {
|
|
3905
|
-
super(..._args);
|
|
3906
|
-
_defineProperty(this, "_loading", null);
|
|
3907
|
-
_defineProperty(this, "_fontSet", void 0);
|
|
3908
|
-
_defineProperty(this, "_faces", []);
|
|
3909
|
-
}
|
|
3910
|
-
load(fonts) {
|
|
3911
|
-
this._loading ??= this._load(fonts);
|
|
3912
|
-
return this._loading;
|
|
3913
|
-
}
|
|
3914
|
-
dispose() {
|
|
3915
|
-
for (const face of this._faces) {
|
|
3916
|
-
var _this$_fontSet;
|
|
3917
|
-
(_this$_fontSet = this._fontSet) === null || _this$_fontSet === void 0 || _this$_fontSet.delete(face);
|
|
3918
|
-
}
|
|
3919
|
-
if (this._faces.length > 0) _univerjs_engine_render.FontCache.invalidateMetrics(() => true);
|
|
3920
|
-
this._faces = [];
|
|
3921
|
-
this._fontSet = void 0;
|
|
3922
|
-
super.dispose();
|
|
3923
|
-
}
|
|
3924
|
-
async _load(fonts) {
|
|
3925
|
-
this.ensureNotDisposed();
|
|
3926
|
-
if (fonts.length === 0) return;
|
|
3927
|
-
const fontSet = typeof document === "undefined" ? globalThis.fonts : document.fonts;
|
|
3928
|
-
if (typeof FontFace === "undefined" || fontSet == null) throw new Error("Document layout requires FontFace support to load the configured fonts.");
|
|
3929
|
-
try {
|
|
3930
|
-
const faces = fonts.map(({ family, source, descriptors }) => {
|
|
3931
|
-
if (!family.trim() || (typeof source === "string" ? !source.trim() : source.byteLength === 0)) throw new TypeError("Document layout font family and source must not be empty.");
|
|
3932
|
-
return new FontFace(family, source, descriptors);
|
|
3933
|
-
});
|
|
3934
|
-
await Promise.all(faces.map((face) => face.load()));
|
|
3935
|
-
this.ensureNotDisposed();
|
|
3936
|
-
this._fontSet = fontSet;
|
|
3937
|
-
this._faces = faces;
|
|
3938
|
-
for (const face of faces) fontSet.add(face);
|
|
3939
|
-
_univerjs_engine_render.FontCache.invalidateMetrics(() => true);
|
|
3940
|
-
} catch (error) {
|
|
3941
|
-
this.dispose();
|
|
3942
|
-
throw error;
|
|
3943
|
-
}
|
|
3944
|
-
}
|
|
3945
|
-
};
|
|
3946
|
-
|
|
3947
|
-
//#endregion
|
|
3948
|
-
//#region src/layout-worker/performance-tracker.ts
|
|
3949
|
-
const PERFORMANCE_SAMPLE_LIMIT = 2048;
|
|
3950
|
-
function isRecord(value) {
|
|
3951
|
-
return typeof value === "object" && value != null;
|
|
3952
|
-
}
|
|
3953
|
-
function getRequest(message) {
|
|
3954
|
-
if (!isRecord(message) || typeof message.method !== "string" || !Array.isArray(message.args)) return null;
|
|
3955
|
-
const request = message.args[0];
|
|
3956
|
-
return isRecord(request) ? {
|
|
3957
|
-
method: message.method,
|
|
3958
|
-
request
|
|
3959
|
-
} : null;
|
|
3960
|
-
}
|
|
3961
|
-
function getPublicationResult(message) {
|
|
3962
|
-
if (!isRecord(message) || !isRecord(message.data)) return null;
|
|
3963
|
-
const result = message.data;
|
|
3964
|
-
if (isRecord(result.step)) return result.step;
|
|
3965
|
-
return result;
|
|
3966
|
-
}
|
|
3967
|
-
function createTransferMetrics() {
|
|
3968
|
-
return {
|
|
3969
|
-
mutationTransferMs: [],
|
|
3970
|
-
patchTransferMs: [],
|
|
3971
|
-
snapshotTransferMs: []
|
|
3972
|
-
};
|
|
3973
|
-
}
|
|
3974
|
-
var DocsLayoutWorkerPerformanceTracker = class {
|
|
3975
|
-
constructor() {
|
|
3976
|
-
_defineProperty(this, "_metrics", /* @__PURE__ */ new Map());
|
|
3977
|
-
}
|
|
3978
|
-
recordRequest(message, durationMs) {
|
|
3979
|
-
const requestInfo = getRequest(message);
|
|
3980
|
-
const unitId = requestInfo === null || requestInfo === void 0 ? void 0 : requestInfo.request.unitId;
|
|
3981
|
-
if (requestInfo == null || typeof unitId !== "string") return;
|
|
3982
|
-
if (requestInfo.method === "createSession") {
|
|
3983
|
-
this._append(unitId, "snapshotTransferMs", durationMs);
|
|
3984
|
-
return;
|
|
3985
|
-
}
|
|
3986
|
-
if (requestInfo.method === "startLayout" && Array.isArray(requestInfo.request.mutations) && requestInfo.request.mutations.length > 0) this._append(unitId, "mutationTransferMs", durationMs);
|
|
3987
|
-
}
|
|
3988
|
-
recordResponse(message, durationMs) {
|
|
3989
|
-
const result = getPublicationResult(message);
|
|
3990
|
-
if (result == null || typeof result.unitId !== "string" || result.publication == null) return;
|
|
3991
|
-
this._append(result.unitId, "patchTransferMs", durationMs);
|
|
3992
|
-
}
|
|
3993
|
-
getMetrics(unitId) {
|
|
3994
|
-
const metrics = this._metrics.get(unitId) ?? createTransferMetrics();
|
|
3995
|
-
return {
|
|
3996
|
-
mutationTransferMs: [...metrics.mutationTransferMs],
|
|
3997
|
-
patchTransferMs: [...metrics.patchTransferMs],
|
|
3998
|
-
snapshotTransferMs: [...metrics.snapshotTransferMs]
|
|
3999
|
-
};
|
|
4000
|
-
}
|
|
4001
|
-
reset(unitId) {
|
|
4002
|
-
this._metrics.delete(unitId);
|
|
4003
|
-
}
|
|
4004
|
-
resetAll() {
|
|
4005
|
-
this._metrics.clear();
|
|
4006
|
-
}
|
|
4007
|
-
_append(unitId, metric, durationMs) {
|
|
4008
|
-
const metrics = this._metrics.get(unitId) ?? createTransferMetrics();
|
|
4009
|
-
const samples = metrics[metric];
|
|
4010
|
-
samples.push(durationMs);
|
|
4011
|
-
if (samples.length > PERFORMANCE_SAMPLE_LIMIT) samples.splice(0, samples.length - PERFORMANCE_SAMPLE_LIMIT);
|
|
4012
|
-
this._metrics.set(unitId, metrics);
|
|
4013
|
-
}
|
|
4014
|
-
};
|
|
4015
|
-
|
|
4016
|
-
//#endregion
|
|
4017
|
-
//#region src/layout-worker/protocol.ts
|
|
4018
|
-
const DOCS_LAYOUT_WORKER_CHANNEL = "univer.docs-layout-worker";
|
|
4019
|
-
|
|
4020
|
-
//#endregion
|
|
4021
|
-
//#region src/layout-worker/worker.ts
|
|
4022
|
-
const FONT_PROBE_CONTENT = "Univer 文档 Worker 0123456789";
|
|
4023
|
-
const FONT_PROBE_STYLE = "16px Arial";
|
|
4024
|
-
const WORKER_LAYOUT_INTERRUPT_INTERVAL = 8;
|
|
4025
|
-
function yieldForWorkerMessage() {
|
|
4026
|
-
return new Promise((resolve) => {
|
|
4027
|
-
(0, _univerjs_core.requestImmediateMacroTask)(() => resolve());
|
|
4028
|
-
});
|
|
4029
|
-
}
|
|
4030
|
-
function createDocsLayoutWorkerMessageProtocol$1(performanceTracker) {
|
|
4031
|
-
return {
|
|
4032
|
-
send(message) {
|
|
4033
|
-
const startedAt = _univerjs_core.Tools.now();
|
|
4034
|
-
postMessage(message);
|
|
4035
|
-
performanceTracker.recordResponse(message, _univerjs_core.Tools.now() - startedAt);
|
|
4036
|
-
},
|
|
4037
|
-
onMessage: new rxjs.Observable((subscriber) => {
|
|
4038
|
-
const handler = (event) => subscriber.next(event.data);
|
|
4039
|
-
addEventListener("message", handler);
|
|
4040
|
-
return () => removeEventListener("message", handler);
|
|
4041
|
-
}).pipe((0, rxjs.shareReplay)({
|
|
4042
|
-
bufferSize: 1,
|
|
4043
|
-
refCount: true
|
|
4044
|
-
}))
|
|
4045
|
-
};
|
|
4046
|
-
}
|
|
4047
|
-
function getCustomRangePresentationKey(entry) {
|
|
4048
|
-
return JSON.stringify([entry.segmentId, entry.rangeId]);
|
|
4049
|
-
}
|
|
4050
|
-
function applyRecordPatch(target, patch) {
|
|
4051
|
-
if (patch == null) return;
|
|
4052
|
-
for (const key of patch.removals) delete target[key];
|
|
4053
|
-
Object.assign(target, patch.upserts);
|
|
4054
|
-
}
|
|
4055
|
-
var DocsLayoutWorkerRuntime = class {
|
|
4056
|
-
constructor(_performanceTracker = new DocsLayoutWorkerPerformanceTracker()) {
|
|
4057
|
-
this._performanceTracker = _performanceTracker;
|
|
4058
|
-
_defineProperty(this, "_sessions", /* @__PURE__ */ new Map());
|
|
4059
|
-
_defineProperty(this, "_fontLoader", new DocsLayoutFontLoader());
|
|
4060
|
-
_defineProperty(this, "type", "worker");
|
|
4061
|
-
}
|
|
4062
|
-
initialize(fontFaces = []) {
|
|
4063
|
-
return this._fontLoader.load(fontFaces);
|
|
4064
|
-
}
|
|
4065
|
-
async getCapabilities() {
|
|
4066
|
-
const metrics = _univerjs_engine_render.FontCache.getMeasureText(FONT_PROBE_CONTENT, FONT_PROBE_STYLE);
|
|
4067
|
-
return {
|
|
4068
|
-
protocolVersion: 5,
|
|
4069
|
-
executor: "worker",
|
|
4070
|
-
offscreenCanvas: typeof OffscreenCanvas !== "undefined",
|
|
4071
|
-
structuredClone: typeof structuredClone === "function",
|
|
4072
|
-
fontProbe: {
|
|
4073
|
-
content: FONT_PROBE_CONTENT,
|
|
4074
|
-
font: FONT_PROBE_STYLE,
|
|
4075
|
-
width: metrics.width,
|
|
4076
|
-
actualBoundingBoxAscent: metrics.actualBoundingBoxAscent,
|
|
4077
|
-
actualBoundingBoxDescent: metrics.actualBoundingBoxDescent
|
|
4078
|
-
}
|
|
4079
|
-
};
|
|
4080
|
-
}
|
|
4081
|
-
async recover() {
|
|
4082
|
-
for (const session of this._sessions.values()) for (const mount of session.layoutSessions.values()) mount.layoutSession.dispose();
|
|
4083
|
-
this._sessions.clear();
|
|
4084
|
-
}
|
|
4085
|
-
async createSession(request) {
|
|
4086
|
-
if (typeof OffscreenCanvas === "undefined") throw new Error("Document layout Worker requires OffscreenCanvas text measurement support.");
|
|
4087
|
-
const currentSession = this._sessions.get(request.unitId);
|
|
4088
|
-
if (currentSession != null && request.sessionEpoch < currentSession.sessionEpoch) return;
|
|
4089
|
-
this._disposeSession(request.unitId);
|
|
4090
|
-
_univerjs_engine_render.FontCache.setNormalLineHeightCache(request.normalFontLineHeights ?? {});
|
|
4091
|
-
const dataModel = new _univerjs_core.DocumentDataModel(request.snapshot);
|
|
4092
|
-
const localeService = new _univerjs_core.LocaleService();
|
|
4093
|
-
if (request.localeData != null) localeService.load({ [request.locale]: request.localeData });
|
|
4094
|
-
localeService.setLocale(request.locale);
|
|
4095
|
-
localeService.setDirection(request.direction);
|
|
4096
|
-
this._sessions.set(request.unitId, {
|
|
4097
|
-
sessionEpoch: request.sessionEpoch,
|
|
4098
|
-
dataModel,
|
|
4099
|
-
layoutSessions: /* @__PURE__ */ new Map(),
|
|
4100
|
-
localeService,
|
|
4101
|
-
modelRevision: request.modelRevision,
|
|
4102
|
-
customRangePresentations: /* @__PURE__ */ new Map()
|
|
4103
|
-
});
|
|
4104
|
-
}
|
|
4105
|
-
async startLayout(request) {
|
|
4106
|
-
const session = this._sessions.get(request.unitId);
|
|
4107
|
-
if (session == null) return { status: "not-found" };
|
|
4108
|
-
if (session.modelRevision !== request.baseRevision) return {
|
|
4109
|
-
status: "resnapshot-required",
|
|
4110
|
-
modelRevision: session.modelRevision
|
|
4111
|
-
};
|
|
4112
|
-
if (!this._applyMutations(session, request)) return {
|
|
4113
|
-
status: "resnapshot-required",
|
|
4114
|
-
modelRevision: session.modelRevision
|
|
4115
|
-
};
|
|
4116
|
-
_univerjs_engine_render.FontCache.setNormalLineHeightCache(request.normalFontLineHeights ?? {});
|
|
4117
|
-
this._updateCustomRangePresentations(session, request);
|
|
4118
|
-
this._applyCustomRangePresentations(session.dataModel, Array.from(session.customRangePresentations.values()));
|
|
4119
|
-
let mount = session.layoutSessions.get(request.mountId);
|
|
4120
|
-
if (mount != null && (request.mountEpoch < mount.mountEpoch || request.mountEpoch === mount.mountEpoch && request.viewportEpoch < mount.viewportEpoch)) return { status: "superseded" };
|
|
4121
|
-
if (mount != null && request.mountEpoch > mount.mountEpoch) {
|
|
4122
|
-
mount.layoutSession.dispose();
|
|
4123
|
-
session.layoutSessions.delete(request.mountId);
|
|
4124
|
-
mount = void 0;
|
|
4125
|
-
}
|
|
4126
|
-
if (mount == null) {
|
|
4127
|
-
const customBlockViewports = { ...request.customBlockViewports };
|
|
4128
|
-
applyRecordPatch(customBlockViewports, request.customBlockViewportPatch);
|
|
4129
|
-
mount = {
|
|
4130
|
-
mountId: request.mountId,
|
|
4131
|
-
layoutSession: new _univerjs_engine_render.DocumentLayoutSession(session.dataModel, session.localeService),
|
|
4132
|
-
customBlockViewports,
|
|
4133
|
-
metricsRevision: request.metricsRevision,
|
|
4134
|
-
mountEpoch: request.mountEpoch,
|
|
4135
|
-
viewportEpoch: request.viewportEpoch,
|
|
4136
|
-
activeGeneration: null,
|
|
4137
|
-
cancelledGeneration: null
|
|
4138
|
-
};
|
|
4139
|
-
session.layoutSessions.set(request.mountId, mount);
|
|
4140
|
-
} else {
|
|
4141
|
-
if (request.customBlockViewports != null) mount.customBlockViewports = { ...request.customBlockViewports };
|
|
4142
|
-
applyRecordPatch(mount.customBlockViewports, request.customBlockViewportPatch);
|
|
4143
|
-
mount.metricsRevision = request.metricsRevision;
|
|
4144
|
-
mount.viewportEpoch = request.viewportEpoch;
|
|
4145
|
-
}
|
|
4146
|
-
const generation = mount.layoutSession.start({
|
|
4147
|
-
waitForHyphenationPatterns: true,
|
|
4148
|
-
reason: request.reason,
|
|
4149
|
-
anchor: request.anchor,
|
|
4150
|
-
priorityAnchor: request.priorityAnchor,
|
|
4151
|
-
invalidation: request.invalidation,
|
|
4152
|
-
modernPageWidth: request.modernPageWidth,
|
|
4153
|
-
modernHorizontalMargin: request.modernHorizontalMargin
|
|
4154
|
-
});
|
|
4155
|
-
mount.activeGeneration = generation;
|
|
4156
|
-
mount.cancelledGeneration = null;
|
|
4157
|
-
return {
|
|
4158
|
-
status: "accepted",
|
|
4159
|
-
step: await this._runLayoutStep(session, mount, generation, request.budgetMs)
|
|
4160
|
-
};
|
|
4161
|
-
}
|
|
4162
|
-
_applyMutations(session, request) {
|
|
4163
|
-
for (const mutation of request.mutations) {
|
|
4164
|
-
if (mutation.baseRevision !== session.modelRevision || mutation.modelRevision !== mutation.baseRevision + 1) return false;
|
|
4165
|
-
session.dataModel.apply(mutation.actions);
|
|
4166
|
-
session.modelRevision = mutation.modelRevision;
|
|
4167
|
-
}
|
|
4168
|
-
if (session.modelRevision !== request.modelRevision) return false;
|
|
4169
|
-
if (request.mutations.length > 0) for (const mount of session.layoutSessions.values()) {
|
|
4170
|
-
mount.activeGeneration = null;
|
|
4171
|
-
mount.cancelledGeneration = null;
|
|
4172
|
-
mount.layoutSession.resetDataModel(session.dataModel);
|
|
4173
|
-
}
|
|
4174
|
-
return true;
|
|
4175
|
-
}
|
|
4176
|
-
_applyCustomRangePresentations(dataModel, presentations) {
|
|
4177
|
-
const rangeMaps = /* @__PURE__ */ new Map();
|
|
4178
|
-
const segmentModels = [
|
|
4179
|
-
["", dataModel],
|
|
4180
|
-
...dataModel.headerModelMap,
|
|
4181
|
-
...dataModel.footerModelMap
|
|
4182
|
-
];
|
|
4183
|
-
for (const [segmentId, segmentModel] of segmentModels) {
|
|
4184
|
-
var _segmentModel$getBody;
|
|
4185
|
-
const rangeMap = /* @__PURE__ */ new Map();
|
|
4186
|
-
for (const range of ((_segmentModel$getBody = segmentModel.getBody()) === null || _segmentModel$getBody === void 0 ? void 0 : _segmentModel$getBody.customRanges) ?? []) {
|
|
4187
|
-
const workerRange = range;
|
|
4188
|
-
delete workerRange.active;
|
|
4189
|
-
delete workerRange.glyphAscentEm;
|
|
4190
|
-
delete workerRange.glyphDescentEm;
|
|
4191
|
-
delete workerRange.glyphWidthEm;
|
|
4192
|
-
delete workerRange.show;
|
|
4193
|
-
if (!rangeMap.has(range.rangeId)) rangeMap.set(range.rangeId, workerRange);
|
|
4194
|
-
}
|
|
4195
|
-
rangeMaps.set(segmentId, rangeMap);
|
|
4196
|
-
}
|
|
4197
|
-
for (const { segmentId, rangeId, presentation } of presentations ?? []) {
|
|
4198
|
-
const rangeMap = rangeMaps.get(segmentId);
|
|
4199
|
-
const range = rangeMap === null || rangeMap === void 0 ? void 0 : rangeMap.get(rangeId);
|
|
4200
|
-
if (range != null) {
|
|
4201
|
-
Object.assign(range, presentation);
|
|
4202
|
-
rangeMap === null || rangeMap === void 0 || rangeMap.delete(rangeId);
|
|
4203
|
-
}
|
|
4204
|
-
}
|
|
4205
|
-
}
|
|
4206
|
-
_updateCustomRangePresentations(session, request) {
|
|
4207
|
-
var _request$customRangeP, _request$customRangeP2;
|
|
4208
|
-
if (request.customRangePresentations != null) {
|
|
4209
|
-
session.customRangePresentations.clear();
|
|
4210
|
-
for (const entry of request.customRangePresentations) {
|
|
4211
|
-
const key = getCustomRangePresentationKey(entry);
|
|
4212
|
-
if (!session.customRangePresentations.has(key)) session.customRangePresentations.set(key, entry);
|
|
4213
|
-
}
|
|
4214
|
-
}
|
|
4215
|
-
for (const removal of ((_request$customRangeP = request.customRangePresentationPatch) === null || _request$customRangeP === void 0 ? void 0 : _request$customRangeP.removals) ?? []) session.customRangePresentations.delete(getCustomRangePresentationKey(removal));
|
|
4216
|
-
for (const entry of ((_request$customRangeP2 = request.customRangePresentationPatch) === null || _request$customRangeP2 === void 0 ? void 0 : _request$customRangeP2.upserts) ?? []) session.customRangePresentations.set(getCustomRangePresentationKey(entry), entry);
|
|
4217
|
-
}
|
|
4218
|
-
async stepLayout(request) {
|
|
4219
|
-
const session = this._getSession(request.unitId);
|
|
4220
|
-
const mount = this._getLayoutMount(session, request);
|
|
4221
|
-
return await this._runLayoutStep(session, mount, request.generation, request.budgetMs);
|
|
4222
|
-
}
|
|
4223
|
-
async publishBacklog(request) {
|
|
4224
|
-
const session = this._getSession(request.unitId);
|
|
4225
|
-
const mount = this._getLayoutMount(session, request);
|
|
4226
|
-
return this._runWithCustomBlockViewports(session, mount, () => ({
|
|
4227
|
-
...mount.layoutSession.publishBacklog(request.generation),
|
|
4228
|
-
unitId: request.unitId,
|
|
4229
|
-
mountId: request.mountId,
|
|
4230
|
-
mountEpoch: mount.mountEpoch,
|
|
4231
|
-
viewportEpoch: mount.viewportEpoch,
|
|
4232
|
-
modelRevision: session.modelRevision,
|
|
4233
|
-
metricsRevision: mount.metricsRevision
|
|
4234
|
-
}));
|
|
4235
|
-
}
|
|
4236
|
-
async getLayoutPage(request) {
|
|
4237
|
-
const session = this._getSession(request.unitId);
|
|
4238
|
-
const mount = this._getLayoutMount(session, request);
|
|
4239
|
-
return {
|
|
4240
|
-
...request,
|
|
4241
|
-
modelRevision: session.modelRevision,
|
|
4242
|
-
metricsRevision: mount.metricsRevision,
|
|
4243
|
-
page: mount.layoutSession.getPage(request.pageIndex)
|
|
4244
|
-
};
|
|
4245
|
-
}
|
|
4246
|
-
async cancelLayout(request) {
|
|
4247
|
-
var _this$_sessions$get;
|
|
4248
|
-
const mount = (_this$_sessions$get = this._sessions.get(request.unitId)) === null || _this$_sessions$get === void 0 ? void 0 : _this$_sessions$get.layoutSessions.get(request.mountId);
|
|
4249
|
-
if ((mount === null || mount === void 0 ? void 0 : mount.mountEpoch) === request.mountEpoch && mount.viewportEpoch === request.viewportEpoch) {
|
|
4250
|
-
if (request.generation == null || request.generation === mount.activeGeneration) mount.cancelledGeneration = request.generation ?? mount.activeGeneration;
|
|
4251
|
-
mount.layoutSession.cancel(request.generation);
|
|
4252
|
-
}
|
|
4253
|
-
}
|
|
4254
|
-
async getPerformanceMetrics(unitId) {
|
|
4255
|
-
return this._performanceTracker.getMetrics(unitId);
|
|
4256
|
-
}
|
|
4257
|
-
async resetPerformanceMetrics(unitId) {
|
|
4258
|
-
this._performanceTracker.reset(unitId);
|
|
4259
|
-
}
|
|
4260
|
-
async disposeLayoutMount(request) {
|
|
4261
|
-
const session = this._sessions.get(request.unitId);
|
|
4262
|
-
const mount = session === null || session === void 0 ? void 0 : session.layoutSessions.get(request.mountId);
|
|
4263
|
-
if (session == null || mount == null || mount.mountEpoch !== request.mountEpoch || mount.viewportEpoch !== request.viewportEpoch) return;
|
|
4264
|
-
session.layoutSessions.delete(request.mountId);
|
|
4265
|
-
mount.activeGeneration = null;
|
|
4266
|
-
mount.layoutSession.dispose();
|
|
4267
|
-
}
|
|
4268
|
-
async disposeSession(request) {
|
|
4269
|
-
const session = this._sessions.get(request.unitId);
|
|
4270
|
-
if ((session === null || session === void 0 ? void 0 : session.sessionEpoch) !== request.sessionEpoch) return;
|
|
4271
|
-
this._disposeSession(request.unitId);
|
|
4272
|
-
this._performanceTracker.reset(request.unitId);
|
|
4273
|
-
}
|
|
4274
|
-
dispose() {
|
|
4275
|
-
this._fontLoader.dispose();
|
|
4276
|
-
for (const unitId of this._sessions.keys()) this._disposeSession(unitId);
|
|
4277
|
-
this._performanceTracker.resetAll();
|
|
4278
|
-
}
|
|
4279
|
-
_getSession(unitId) {
|
|
4280
|
-
const session = this._sessions.get(unitId);
|
|
4281
|
-
if (session == null) throw new Error(`Document layout Worker session not found for unit "${unitId}".`);
|
|
4282
|
-
return session;
|
|
4283
|
-
}
|
|
4284
|
-
_getLayoutMount(session, request) {
|
|
4285
|
-
const mount = session.layoutSessions.get(request.mountId);
|
|
4286
|
-
if (mount == null) throw new Error(`Document layout Worker mount not found: "${request.mountId}".`);
|
|
4287
|
-
if (mount.mountEpoch !== request.mountEpoch || mount.viewportEpoch !== request.viewportEpoch) throw new Error(`Document layout Worker rejected a stale mount publication: "${request.mountId}".`);
|
|
4288
|
-
return mount;
|
|
4289
|
-
}
|
|
4290
|
-
async _runLayoutStep(session, mount, generation, budgetMs) {
|
|
4291
|
-
const result = this._runWithCustomBlockViewports(session, mount, () => ({
|
|
4292
|
-
...mount.layoutSession.step(generation, budgetMs, WORKER_LAYOUT_INTERRUPT_INTERVAL),
|
|
4293
|
-
unitId: session.dataModel.getUnitId(),
|
|
4294
|
-
mountId: mount.mountId,
|
|
4295
|
-
mountEpoch: mount.mountEpoch,
|
|
4296
|
-
viewportEpoch: mount.viewportEpoch,
|
|
4297
|
-
modelRevision: session.modelRevision,
|
|
4298
|
-
metricsRevision: mount.metricsRevision
|
|
4299
|
-
}));
|
|
4300
|
-
await yieldForWorkerMessage();
|
|
4301
|
-
if (mount.activeGeneration === generation && mount.cancelledGeneration !== generation) return result;
|
|
4302
|
-
return this._runWithCustomBlockViewports(session, mount, () => ({
|
|
4303
|
-
...mount.layoutSession.step(generation, 0, 1),
|
|
4304
|
-
unitId: session.dataModel.getUnitId(),
|
|
4305
|
-
mountId: mount.mountId,
|
|
4306
|
-
mountEpoch: mount.mountEpoch,
|
|
4307
|
-
viewportEpoch: mount.viewportEpoch,
|
|
4308
|
-
modelRevision: session.modelRevision,
|
|
4309
|
-
metricsRevision: mount.metricsRevision
|
|
4310
|
-
}));
|
|
4311
|
-
}
|
|
4312
|
-
_runWithCustomBlockViewports(session, mount, run) {
|
|
4313
|
-
const unregister = (0, _univerjs_engine_render.setDocsCustomBlockRenderViewportProvider)((unitId, blockId) => unitId === session.dataModel.getUnitId() ? mount.customBlockViewports[blockId] : null);
|
|
4314
|
-
try {
|
|
4315
|
-
return run();
|
|
4316
|
-
} finally {
|
|
4317
|
-
unregister();
|
|
4318
|
-
}
|
|
4319
|
-
}
|
|
4320
|
-
_disposeSession(unitId) {
|
|
4321
|
-
const session = this._sessions.get(unitId);
|
|
4322
|
-
if (session == null) return;
|
|
4323
|
-
this._sessions.delete(unitId);
|
|
4324
|
-
for (const mount of session.layoutSessions.values()) {
|
|
4325
|
-
mount.activeGeneration = null;
|
|
4326
|
-
mount.layoutSession.dispose();
|
|
4327
|
-
}
|
|
4328
|
-
session.layoutSessions.clear();
|
|
4329
|
-
session.dataModel.dispose();
|
|
4330
|
-
session.localeService.dispose();
|
|
4331
|
-
}
|
|
4332
|
-
};
|
|
4333
|
-
var DocsLayoutWorkerChannelService = class extends _univerjs_rpc.ChannelService {
|
|
4334
|
-
constructor(protocol, _runtime) {
|
|
4335
|
-
super(protocol);
|
|
4336
|
-
this._runtime = _runtime;
|
|
4337
|
-
}
|
|
4338
|
-
dispose() {
|
|
4339
|
-
this._runtime.dispose();
|
|
4340
|
-
super.dispose();
|
|
4341
|
-
}
|
|
4342
|
-
};
|
|
4343
|
-
function startDocsLayoutWorker() {
|
|
4344
|
-
const performanceTracker = new DocsLayoutWorkerPerformanceTracker();
|
|
4345
|
-
const runtime = new DocsLayoutWorkerRuntime(performanceTracker);
|
|
4346
|
-
const channelService = new DocsLayoutWorkerChannelService(createDocsLayoutWorkerMessageProtocol$1(performanceTracker), runtime);
|
|
4347
|
-
channelService.registerChannel(DOCS_LAYOUT_WORKER_CHANNEL, (0, _univerjs_rpc.fromModule)(runtime));
|
|
4348
|
-
return channelService;
|
|
4349
|
-
}
|
|
4350
|
-
|
|
4351
|
-
//#endregion
|
|
4352
|
-
//#region src/layout-worker/index.ts
|
|
3119
|
+
// src/layout-worker/index.ts
|
|
4353
3120
|
const FONT_METRICS_TOLERANCE = 1;
|
|
4354
3121
|
var DocsLayoutWorkerCapabilityError = class extends Error {
|
|
4355
3122
|
constructor(message) {
|
|
@@ -4380,15 +3147,15 @@ var DocsLayoutWorkerClientService = class extends _univerjs_core.Disposable {
|
|
|
4380
3147
|
this._workerFactory = _workerFactory;
|
|
4381
3148
|
this._requestTimeoutMs = _requestTimeoutMs;
|
|
4382
3149
|
this._fontFaces = _fontFaces;
|
|
4383
|
-
_defineProperty(this, "type", "worker");
|
|
4384
|
-
_defineProperty(this, "_worker", null);
|
|
4385
|
-
_defineProperty(this, "_channelService", null);
|
|
4386
|
-
_defineProperty(this, "_runtime", null);
|
|
4387
|
-
_defineProperty(this, "_initialization", void 0);
|
|
4388
|
-
_defineProperty(this, "_initialized", false);
|
|
4389
|
-
_defineProperty(this, "_performanceTracker", new DocsLayoutWorkerPerformanceTracker());
|
|
4390
|
-
_defineProperty(this, "_fontFamilies", /* @__PURE__ */ new Map());
|
|
4391
|
-
_defineProperty(this, "_fontLoader", new DocsLayoutFontLoader());
|
|
3150
|
+
require_worker._defineProperty(this, "type", "worker");
|
|
3151
|
+
require_worker._defineProperty(this, "_worker", null);
|
|
3152
|
+
require_worker._defineProperty(this, "_channelService", null);
|
|
3153
|
+
require_worker._defineProperty(this, "_runtime", null);
|
|
3154
|
+
require_worker._defineProperty(this, "_initialization", void 0);
|
|
3155
|
+
require_worker._defineProperty(this, "_initialized", false);
|
|
3156
|
+
require_worker._defineProperty(this, "_performanceTracker", new require_worker.DocsLayoutWorkerPerformanceTracker());
|
|
3157
|
+
require_worker._defineProperty(this, "_fontFamilies", /* @__PURE__ */ new Map());
|
|
3158
|
+
require_worker._defineProperty(this, "_fontLoader", new require_worker.DocsLayoutFontLoader());
|
|
4392
3159
|
this.disposeWithMe(this._fontLoader);
|
|
4393
3160
|
this._initialization = this._replaceRuntime();
|
|
4394
3161
|
}
|
|
@@ -4482,7 +3249,7 @@ var DocsLayoutWorkerClientService = class extends _univerjs_core.Disposable {
|
|
|
4482
3249
|
const channelService = new _univerjs_rpc.ChannelService(createDocsLayoutWorkerMessageProtocol(worker, this._performanceTracker));
|
|
4483
3250
|
this._worker = worker;
|
|
4484
3251
|
this._channelService = channelService;
|
|
4485
|
-
this._runtime = (0, _univerjs_rpc.toModule)(channelService.requestChannel(DOCS_LAYOUT_WORKER_CHANNEL));
|
|
3252
|
+
this._runtime = (0, _univerjs_rpc.toModule)(channelService.requestChannel(require_worker.DOCS_LAYOUT_WORKER_CHANNEL));
|
|
4486
3253
|
try {
|
|
4487
3254
|
await this._withTimeout(this._runtime.initialize(this._fontFaces), "load Worker fonts");
|
|
4488
3255
|
await this._withTimeout(this._verifyCapabilities(), "verify capabilities");
|
|
@@ -4551,18 +3318,17 @@ let UniverDocsLayoutWorkerPlugin = class UniverDocsLayoutWorkerPlugin extends _u
|
|
|
4551
3318
|
this.disposeWithMe(this._layoutExecutorService.register(client));
|
|
4552
3319
|
}
|
|
4553
3320
|
};
|
|
4554
|
-
_defineProperty(UniverDocsLayoutWorkerPlugin, "pluginName", "DOCS_LAYOUT_WORKER_PLUGIN");
|
|
4555
|
-
_defineProperty(UniverDocsLayoutWorkerPlugin, "packageName", name);
|
|
4556
|
-
_defineProperty(UniverDocsLayoutWorkerPlugin, "version", version);
|
|
4557
|
-
UniverDocsLayoutWorkerPlugin = __decorate([
|
|
3321
|
+
require_worker._defineProperty(UniverDocsLayoutWorkerPlugin, "pluginName", "DOCS_LAYOUT_WORKER_PLUGIN");
|
|
3322
|
+
require_worker._defineProperty(UniverDocsLayoutWorkerPlugin, "packageName", require_worker.name);
|
|
3323
|
+
require_worker._defineProperty(UniverDocsLayoutWorkerPlugin, "version", require_worker.version);
|
|
3324
|
+
UniverDocsLayoutWorkerPlugin = require_worker.__decorate([
|
|
4558
3325
|
(0, _univerjs_core.DependentOn)(UniverDocsPlugin),
|
|
4559
|
-
__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
4560
|
-
__decorateParam(2, (0, _univerjs_core.Inject)(DocLayoutExecutorService)),
|
|
4561
|
-
__decorateParam(3, _univerjs_core.IConfigService)
|
|
3326
|
+
require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(_univerjs_core.Injector)),
|
|
3327
|
+
require_worker.__decorateParam(2, (0, _univerjs_core.Inject)(require_worker.DocLayoutExecutorService)),
|
|
3328
|
+
require_worker.__decorateParam(3, _univerjs_core.IConfigService)
|
|
4562
3329
|
], UniverDocsLayoutWorkerPlugin);
|
|
4563
3330
|
|
|
4564
|
-
|
|
4565
|
-
//#region src/services/doc-interceptor/interceptor-const.ts
|
|
3331
|
+
// src/services/doc-interceptor/interceptor-const.ts
|
|
4566
3332
|
const CUSTOM_RANGE = (0, _univerjs_core.createInterceptorKey)("CUSTOM_RANGE");
|
|
4567
3333
|
const CUSTOM_DECORATION = (0, _univerjs_core.createInterceptorKey)("CUSTOM_DECORATION");
|
|
4568
3334
|
const DOC_INTERCEPTOR_POINT = {
|
|
@@ -4570,14 +3336,13 @@ const DOC_INTERCEPTOR_POINT = {
|
|
|
4570
3336
|
CUSTOM_DECORATION
|
|
4571
3337
|
};
|
|
4572
3338
|
|
|
4573
|
-
|
|
4574
|
-
//#region src/services/doc-interceptor/doc-interceptor.service.ts
|
|
3339
|
+
// src/services/doc-interceptor/doc-interceptor.service.ts
|
|
4575
3340
|
let DocInterceptorService = class DocInterceptorService extends _univerjs_core.Disposable {
|
|
4576
3341
|
constructor(_context, _docSkeletonManagerService) {
|
|
4577
3342
|
super();
|
|
4578
3343
|
this._context = _context;
|
|
4579
3344
|
this._docSkeletonManagerService = _docSkeletonManagerService;
|
|
4580
|
-
_defineProperty(this, "_interceptorsByName", /* @__PURE__ */ new Map());
|
|
3345
|
+
require_worker._defineProperty(this, "_interceptorsByName", /* @__PURE__ */ new Map());
|
|
4581
3346
|
const viewModel = this._docSkeletonManagerService.getViewModel();
|
|
4582
3347
|
const unitId = viewModel.getDataModel().getUnitId();
|
|
4583
3348
|
if (unitId === _univerjs_core.DOCS_NORMAL_EDITOR_UNIT_ID_KEY || unitId === _univerjs_core.DOCS_FORMULA_BAR_EDITOR_UNIT_ID_KEY) return;
|
|
@@ -4633,10 +3398,9 @@ let DocInterceptorService = class DocInterceptorService extends _univerjs_core.D
|
|
|
4633
3398
|
return disposableCollection;
|
|
4634
3399
|
}
|
|
4635
3400
|
};
|
|
4636
|
-
DocInterceptorService = __decorate([__decorateParam(1, (0, _univerjs_core.Inject)(DocSkeletonManagerService))], DocInterceptorService);
|
|
3401
|
+
DocInterceptorService = require_worker.__decorate([require_worker.__decorateParam(1, (0, _univerjs_core.Inject)(DocSkeletonManagerService))], DocInterceptorService);
|
|
4637
3402
|
|
|
4638
|
-
|
|
4639
|
-
//#region src/utils/custom-range-factory.ts
|
|
3403
|
+
// src/utils/custom-range-factory.ts
|
|
4640
3404
|
function addCustomRangeFactory(accessor, param, body) {
|
|
4641
3405
|
const { unitId, segmentId } = param;
|
|
4642
3406
|
const documentDataModel = accessor.get(_univerjs_core.IUniverInstanceService).getUnit(unitId);
|
|
@@ -4726,8 +3490,7 @@ function deleteCustomRangeFactory(accessor, params) {
|
|
|
4726
3490
|
return doMutation;
|
|
4727
3491
|
}
|
|
4728
3492
|
|
|
4729
|
-
|
|
4730
|
-
//#region src/utils/paragraphs.ts
|
|
3493
|
+
// src/utils/paragraphs.ts
|
|
4731
3494
|
/** Builds paragraph metadata for inserted paragraph tokens, including horizontal-rule borders. */
|
|
4732
3495
|
function generateParagraphs(dataStream, prevParagraph, borderBottom, existingParagraphIds = []) {
|
|
4733
3496
|
const paragraphs = [];
|
|
@@ -4755,8 +3518,7 @@ function generateParagraphs(dataStream, prevParagraph, borderBottom, existingPar
|
|
|
4755
3518
|
return paragraphs;
|
|
4756
3519
|
}
|
|
4757
3520
|
|
|
4758
|
-
|
|
4759
|
-
//#region src/utils/replace-selection-factory.ts
|
|
3521
|
+
// src/utils/replace-selection-factory.ts
|
|
4760
3522
|
function replaceSelectionFactory(accessor, params) {
|
|
4761
3523
|
var _params$selection, _docDataModel$getSelf;
|
|
4762
3524
|
const { unitId, body: insertBody, doc } = params;
|
|
@@ -4797,8 +3559,7 @@ function replaceSelectionFactory(accessor, params) {
|
|
|
4797
3559
|
return doMutation;
|
|
4798
3560
|
}
|
|
4799
3561
|
|
|
4800
|
-
|
|
4801
|
-
//#region src/utils/transform-position.ts
|
|
3562
|
+
// src/utils/transform-position.ts
|
|
4802
3563
|
function buildDocTransform(width, height, position) {
|
|
4803
3564
|
return {
|
|
4804
3565
|
size: {
|
|
@@ -4846,8 +3607,7 @@ function transformToDocDrawingPosition(transform, marginLeft = 0, marginTop = 0)
|
|
|
4846
3607
|
};
|
|
4847
3608
|
}
|
|
4848
3609
|
|
|
4849
|
-
|
|
4850
|
-
//#region src/utils/util.ts
|
|
3610
|
+
// src/utils/util.ts
|
|
4851
3611
|
function consumeContentInsertRange(accessor, unitId) {
|
|
4852
3612
|
try {
|
|
4853
3613
|
return accessor.get(DocContentInsertService).consumeInsertRange(unitId);
|
|
@@ -4879,7 +3639,6 @@ function normalizeTextRange(textRange) {
|
|
|
4879
3639
|
};
|
|
4880
3640
|
}
|
|
4881
3641
|
|
|
4882
|
-
//#endregion
|
|
4883
3642
|
exports.CreateHeaderFooterCommand = CreateHeaderFooterCommand;
|
|
4884
3643
|
exports.DOCUMENT_UNIT_PERMISSION_ACTIONS = DOCUMENT_UNIT_PERMISSION_ACTIONS;
|
|
4885
3644
|
exports.DOC_INTERCEPTOR_POINT = DOC_INTERCEPTOR_POINT;
|
|
@@ -4898,12 +3657,12 @@ Object.defineProperty(exports, "DocInterceptorService", {
|
|
|
4898
3657
|
Object.defineProperty(exports, "DocLayoutExecutorService", {
|
|
4899
3658
|
enumerable: true,
|
|
4900
3659
|
get: function () {
|
|
4901
|
-
return DocLayoutExecutorService;
|
|
3660
|
+
return require_worker.DocLayoutExecutorService;
|
|
4902
3661
|
}
|
|
4903
3662
|
});
|
|
4904
|
-
exports.DocLayoutExecutorState = DocLayoutExecutorState;
|
|
4905
|
-
exports.DocLayoutExecutorType = DocLayoutExecutorType;
|
|
4906
|
-
exports.DocLayoutSessionStatus = DocLayoutSessionStatus;
|
|
3663
|
+
exports.DocLayoutExecutorState = require_worker.DocLayoutExecutorState;
|
|
3664
|
+
exports.DocLayoutExecutorType = require_worker.DocLayoutExecutorType;
|
|
3665
|
+
exports.DocLayoutSessionStatus = require_worker.DocLayoutSessionStatus;
|
|
4907
3666
|
Object.defineProperty(exports, "DocSelectionManagerService", {
|
|
4908
3667
|
enumerable: true,
|
|
4909
3668
|
get: function () {
|
|
@@ -4993,6 +3752,6 @@ exports.replaceSelectionFactory = replaceSelectionFactory;
|
|
|
4993
3752
|
exports.resolveDocsCustomBlockSize = resolveDocsCustomBlockSize;
|
|
4994
3753
|
exports.setDocumentPermissionValue = setDocumentPermissionValue;
|
|
4995
3754
|
exports.shouldUseInlineTextSelectionForDocsCustomBlockDrawing = shouldUseInlineTextSelectionForDocsCustomBlockDrawing;
|
|
4996
|
-
exports.startDocsLayoutWorker = startDocsLayoutWorker;
|
|
3755
|
+
exports.startDocsLayoutWorker = require_worker.startDocsLayoutWorker;
|
|
4997
3756
|
exports.transformDocumentTextRanges = transformDocumentTextRanges;
|
|
4998
3757
|
exports.transformToDocDrawingPosition = transformToDocDrawingPosition;
|