microboard-temp 0.13.79 → 0.13.81
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +126 -42
- package/dist/cjs/index.js +126 -42
- package/dist/cjs/node.js +126 -42
- package/dist/esm/browser.js +146 -62
- package/dist/esm/index.js +146 -62
- package/dist/esm/node.js +146 -62
- package/dist/types/Events/Events.d.ts +6 -0
- package/dist/types/Events/Log/getSnapshotFromList.d.ts +1 -1
- package/dist/types/Items/Audio/AudioHelpers.d.ts +1 -1
- package/dist/types/Items/Image/ImageHelpers.d.ts +1 -1
- package/dist/types/Items/Video/VideoHelpers.d.ts +1 -1
- package/dist/types/Settings.d.ts +8 -0
- package/dist/types/api/AuthRequest.d.ts +6 -0
- package/dist/types/api/MediaHelpers.d.ts +2 -2
- package/package.json +1 -1
package/dist/esm/node.js
CHANGED
|
@@ -3640,6 +3640,8 @@ var init_Settings = __esm(() => {
|
|
|
3640
3640
|
getDPI: () => 1,
|
|
3641
3641
|
reactEditorFocus: () => {},
|
|
3642
3642
|
reactEditorToSlatePoint: () => null,
|
|
3643
|
+
onAuthInvalid: async () => false,
|
|
3644
|
+
onAuthTerminalFailure: () => {},
|
|
3643
3645
|
planNames: {
|
|
3644
3646
|
basic: "Basic",
|
|
3645
3647
|
plus: "Plus",
|
|
@@ -6150,11 +6152,12 @@ function getSnapshotFromList(list, board) {
|
|
|
6150
6152
|
const snapshot = {
|
|
6151
6153
|
events: list.getConfirmedRecords().map((record) => record.event),
|
|
6152
6154
|
items: board.serialize(),
|
|
6153
|
-
lastIndex: list
|
|
6155
|
+
lastIndex: getLastIndexFromList(list)
|
|
6154
6156
|
};
|
|
6155
6157
|
list.applyUnconfirmed();
|
|
6156
6158
|
return snapshot;
|
|
6157
6159
|
}
|
|
6160
|
+
var init_getSnapshotFromList = () => {};
|
|
6158
6161
|
|
|
6159
6162
|
// src/Events/Log/EventsLog.ts
|
|
6160
6163
|
class EventsLog {
|
|
@@ -6243,6 +6246,7 @@ var init_EventsLog = __esm(() => {
|
|
|
6243
6246
|
init_getUndoRecordFromList();
|
|
6244
6247
|
init_getUnpublishedEventFromList();
|
|
6245
6248
|
init_insertEventsFromOtherConnectionsIntoList();
|
|
6249
|
+
init_getSnapshotFromList();
|
|
6246
6250
|
});
|
|
6247
6251
|
|
|
6248
6252
|
// src/Events/Log/index.ts
|
|
@@ -14419,6 +14423,11 @@ class Events {
|
|
|
14419
14423
|
getOpKey(op) {
|
|
14420
14424
|
return op.method;
|
|
14421
14425
|
}
|
|
14426
|
+
refreshIdentity() {
|
|
14427
|
+
const sessionId = this.getSessionId();
|
|
14428
|
+
const authorUserId = this.getAuthorUserId();
|
|
14429
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14430
|
+
}
|
|
14422
14431
|
getSessionId() {
|
|
14423
14432
|
return getConnectionSessionId(this.connection);
|
|
14424
14433
|
}
|
|
@@ -31901,9 +31910,34 @@ var init_setLink = __esm(() => {
|
|
|
31901
31910
|
});
|
|
31902
31911
|
|
|
31903
31912
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31904
|
-
import { Editor as Editor12 } from "slate";
|
|
31913
|
+
import { Editor as Editor12, Range as Range6, Text as Text7 } from "slate";
|
|
31905
31914
|
function getSelectionMarks(editor) {
|
|
31906
|
-
|
|
31915
|
+
const marks = Editor12.marks(editor);
|
|
31916
|
+
if (!editor.selection) {
|
|
31917
|
+
return marks;
|
|
31918
|
+
}
|
|
31919
|
+
if (!Range6.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31920
|
+
return marks;
|
|
31921
|
+
}
|
|
31922
|
+
const textEntries = Array.from(Editor12.nodes(editor, {
|
|
31923
|
+
at: editor.selection,
|
|
31924
|
+
match: (node) => Text7.isText(node)
|
|
31925
|
+
}));
|
|
31926
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31927
|
+
if (!firstEntry) {
|
|
31928
|
+
return marks;
|
|
31929
|
+
}
|
|
31930
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31931
|
+
const commonMarks = { ...firstMarks };
|
|
31932
|
+
for (const [node] of restEntries) {
|
|
31933
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31934
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31935
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31936
|
+
delete commonMarks[key];
|
|
31937
|
+
}
|
|
31938
|
+
}
|
|
31939
|
+
}
|
|
31940
|
+
return commonMarks;
|
|
31907
31941
|
}
|
|
31908
31942
|
var init_getSelectionMarks = () => {};
|
|
31909
31943
|
|
|
@@ -31922,13 +31956,13 @@ var init_clearText = __esm(() => {
|
|
|
31922
31956
|
});
|
|
31923
31957
|
|
|
31924
31958
|
// src/Items/RichText/editorHelpers/common/hasTextInSelection.ts
|
|
31925
|
-
import { Editor as Editor14, Range as
|
|
31959
|
+
import { Editor as Editor14, Range as Range7 } from "slate";
|
|
31926
31960
|
function hasTextInSelection(editor) {
|
|
31927
31961
|
const { selection } = editor;
|
|
31928
|
-
if (!selection ||
|
|
31962
|
+
if (!selection || Range7.isCollapsed(selection)) {
|
|
31929
31963
|
return false;
|
|
31930
31964
|
}
|
|
31931
|
-
const [start, end] =
|
|
31965
|
+
const [start, end] = Range7.edges(selection);
|
|
31932
31966
|
const text = Editor14.string(editor, { anchor: start, focus: end });
|
|
31933
31967
|
return text.length > 0;
|
|
31934
31968
|
}
|
|
@@ -41801,7 +41835,7 @@ function getParagraphWithPassedTextNode(textNode) {
|
|
|
41801
41835
|
}
|
|
41802
41836
|
|
|
41803
41837
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontSize.ts
|
|
41804
|
-
import { Editor as Editor23, Transforms as Transforms16 } from "slate";
|
|
41838
|
+
import { Editor as Editor23, Range as Range8, Text as Text8, Transforms as Transforms16 } from "slate";
|
|
41805
41839
|
import { ReactEditor as ReactEditor3 } from "slate-react";
|
|
41806
41840
|
function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
41807
41841
|
const size = fontSize;
|
|
@@ -41836,7 +41870,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
41836
41870
|
shouldUpdateElement = true;
|
|
41837
41871
|
}
|
|
41838
41872
|
} else {
|
|
41839
|
-
|
|
41873
|
+
if (editor.selection && Range8.isExpanded(editor.selection)) {
|
|
41874
|
+
Transforms16.setNodes(editor, { fontSize: size }, {
|
|
41875
|
+
match: (n) => Text8.isText(n),
|
|
41876
|
+
split: true
|
|
41877
|
+
});
|
|
41878
|
+
} else {
|
|
41879
|
+
Editor23.addMark(editor, "fontSize", size);
|
|
41880
|
+
}
|
|
41840
41881
|
}
|
|
41841
41882
|
}
|
|
41842
41883
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -41874,7 +41915,7 @@ var init_getEachNodeInSelectionStyles = __esm(() => {
|
|
|
41874
41915
|
});
|
|
41875
41916
|
|
|
41876
41917
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontStyle.ts
|
|
41877
|
-
import { Editor as Editor24, Range as
|
|
41918
|
+
import { Editor as Editor24, Range as Range9, Transforms as Transforms17 } from "slate";
|
|
41878
41919
|
function setSelectionFontStyle(editor, style) {
|
|
41879
41920
|
const styleList = Array.isArray(style) ? style : [style];
|
|
41880
41921
|
for (const style2 of styleList) {
|
|
@@ -41891,7 +41932,7 @@ function setSelectionFontStyle(editor, style) {
|
|
|
41891
41932
|
continue;
|
|
41892
41933
|
}
|
|
41893
41934
|
const { selection } = editor;
|
|
41894
|
-
if (selection &&
|
|
41935
|
+
if (selection && Range9.isExpanded(selection)) {
|
|
41895
41936
|
Transforms17.setNodes(editor, { [style2]: value }, {
|
|
41896
41937
|
match: (n) => !Editor24.isEditor(n) && n.type === "text",
|
|
41897
41938
|
split: true
|
|
@@ -41906,7 +41947,7 @@ var init_setSelectionFontStyle = __esm(() => {
|
|
|
41906
41947
|
});
|
|
41907
41948
|
|
|
41908
41949
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontColor.ts
|
|
41909
|
-
import { Editor as Editor25 } from "slate";
|
|
41950
|
+
import { Editor as Editor25, Range as Range10, Text as Text9, Transforms as Transforms18 } from "slate";
|
|
41910
41951
|
import { ReactEditor as ReactEditor4 } from "slate-react";
|
|
41911
41952
|
function setSelectionFontColor(editor, format, selectionContext) {
|
|
41912
41953
|
const marks = getSelectionMarks(editor);
|
|
@@ -41914,7 +41955,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
41914
41955
|
return;
|
|
41915
41956
|
}
|
|
41916
41957
|
if (marks.fontColor !== format) {
|
|
41917
|
-
|
|
41958
|
+
if (editor.selection && Range10.isExpanded(editor.selection)) {
|
|
41959
|
+
Transforms18.setNodes(editor, { fontColor: format }, {
|
|
41960
|
+
match: (n) => Text9.isText(n),
|
|
41961
|
+
split: true
|
|
41962
|
+
});
|
|
41963
|
+
} else {
|
|
41964
|
+
Editor25.addMark(editor, "fontColor", format);
|
|
41965
|
+
}
|
|
41918
41966
|
}
|
|
41919
41967
|
if (selectionContext === "EditTextUnderPointer") {
|
|
41920
41968
|
try {
|
|
@@ -41932,7 +41980,7 @@ var init_setSelectionFontColor = __esm(() => {
|
|
|
41932
41980
|
import {
|
|
41933
41981
|
createEditor,
|
|
41934
41982
|
Editor as Editor26,
|
|
41935
|
-
Transforms as
|
|
41983
|
+
Transforms as Transforms19
|
|
41936
41984
|
} from "slate";
|
|
41937
41985
|
import { withReact } from "slate-react";
|
|
41938
41986
|
|
|
@@ -42208,7 +42256,7 @@ class EditorContainer {
|
|
|
42208
42256
|
break;
|
|
42209
42257
|
}
|
|
42210
42258
|
if (selection) {
|
|
42211
|
-
|
|
42259
|
+
Transforms19.select(this.editor, selection);
|
|
42212
42260
|
}
|
|
42213
42261
|
}
|
|
42214
42262
|
applyMaxWidth(maxWidth) {
|
|
@@ -42368,7 +42416,7 @@ class EditorContainer {
|
|
|
42368
42416
|
return JSON.parse(JSON.stringify(this.editor.selection));
|
|
42369
42417
|
}
|
|
42370
42418
|
splitNode() {
|
|
42371
|
-
|
|
42419
|
+
Transforms19.splitNodes(this.editor, { always: true });
|
|
42372
42420
|
}
|
|
42373
42421
|
getBlockNodes() {
|
|
42374
42422
|
return this.editor.children;
|
|
@@ -42458,7 +42506,7 @@ var init_findOptimalMaxWidthForTextAutoSize = __esm(() => {
|
|
|
42458
42506
|
});
|
|
42459
42507
|
|
|
42460
42508
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontColor.ts
|
|
42461
|
-
import { Editor as Editor27 } from "slate";
|
|
42509
|
+
import { Editor as Editor27, Range as Range11, Text as Text10, Transforms as Transforms20 } from "slate";
|
|
42462
42510
|
function applySelectionFontColor(editor, fontColor) {
|
|
42463
42511
|
if (!editor) {
|
|
42464
42512
|
throw new Error("Editor is not initialized");
|
|
@@ -42467,14 +42515,21 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
42467
42515
|
if (!marks) {
|
|
42468
42516
|
return;
|
|
42469
42517
|
}
|
|
42470
|
-
|
|
42518
|
+
if (editor.selection && Range11.isExpanded(editor.selection)) {
|
|
42519
|
+
Transforms20.setNodes(editor, { fontColor }, {
|
|
42520
|
+
match: (n) => Text10.isText(n),
|
|
42521
|
+
split: true
|
|
42522
|
+
});
|
|
42523
|
+
} else {
|
|
42524
|
+
Editor27.addMark(editor, "fontColor", fontColor);
|
|
42525
|
+
}
|
|
42471
42526
|
}
|
|
42472
42527
|
var init_applySelectionFontColor = __esm(() => {
|
|
42473
42528
|
init_getSelectionMarks();
|
|
42474
42529
|
});
|
|
42475
42530
|
|
|
42476
42531
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontSize.ts
|
|
42477
|
-
import { Editor as Editor28, Transforms as
|
|
42532
|
+
import { Editor as Editor28, Range as Range12, Text as Text11, Transforms as Transforms21 } from "slate";
|
|
42478
42533
|
function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
42479
42534
|
const size = fontSize;
|
|
42480
42535
|
if (typeof size !== "number") {
|
|
@@ -42489,12 +42544,19 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
42489
42544
|
return;
|
|
42490
42545
|
}
|
|
42491
42546
|
if (JSON.stringify(selection?.anchor) === JSON.stringify(selection?.focus)) {
|
|
42492
|
-
|
|
42547
|
+
Transforms21.select(editor, {
|
|
42493
42548
|
anchor: Editor28.start(editor, []),
|
|
42494
42549
|
focus: Editor28.end(editor, [])
|
|
42495
42550
|
});
|
|
42496
42551
|
}
|
|
42497
|
-
|
|
42552
|
+
if (editor.selection && Range12.isExpanded(editor.selection)) {
|
|
42553
|
+
Transforms21.setNodes(editor, { fontSize: size }, {
|
|
42554
|
+
match: (n) => Text11.isText(n),
|
|
42555
|
+
split: true
|
|
42556
|
+
});
|
|
42557
|
+
} else {
|
|
42558
|
+
Editor28.addMark(editor, "fontSize", size);
|
|
42559
|
+
}
|
|
42498
42560
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
42499
42561
|
}
|
|
42500
42562
|
var init_applySelectionFontSize = __esm(() => {
|
|
@@ -42577,8 +42639,8 @@ var init_setEditorFocus = () => {};
|
|
|
42577
42639
|
import {
|
|
42578
42640
|
Editor as Editor30,
|
|
42579
42641
|
Element as Element9,
|
|
42580
|
-
Text as
|
|
42581
|
-
Transforms as
|
|
42642
|
+
Text as Text12,
|
|
42643
|
+
Transforms as Transforms22
|
|
42582
42644
|
} from "slate";
|
|
42583
42645
|
var isEditInProcessValue = false, counter = 0, RichText;
|
|
42584
42646
|
var init_RichText = __esm(() => {
|
|
@@ -42613,7 +42675,7 @@ var init_RichText = __esm(() => {
|
|
|
42613
42675
|
parent = "Board";
|
|
42614
42676
|
subject = new Subject;
|
|
42615
42677
|
editor;
|
|
42616
|
-
editorTransforms =
|
|
42678
|
+
editorTransforms = Transforms22;
|
|
42617
42679
|
editorEditor = Editor30;
|
|
42618
42680
|
isContainerSet = false;
|
|
42619
42681
|
isRenderEnabled = true;
|
|
@@ -43145,7 +43207,7 @@ var init_RichText = __esm(() => {
|
|
|
43145
43207
|
}
|
|
43146
43208
|
getMinFontSize() {
|
|
43147
43209
|
const textNodes = Editor30.nodes(this.editor.editor, {
|
|
43148
|
-
match: (n) =>
|
|
43210
|
+
match: (n) => Text12.isText(n),
|
|
43149
43211
|
at: []
|
|
43150
43212
|
});
|
|
43151
43213
|
const fontSizes = [];
|
|
@@ -43249,9 +43311,9 @@ var init_RichText = __esm(() => {
|
|
|
43249
43311
|
}
|
|
43250
43312
|
restoreSelection(selection) {
|
|
43251
43313
|
if (selection) {
|
|
43252
|
-
|
|
43314
|
+
Transforms22.select(this.editor.editor, selection);
|
|
43253
43315
|
} else {
|
|
43254
|
-
|
|
43316
|
+
Transforms22.deselect(this.editor.editor);
|
|
43255
43317
|
}
|
|
43256
43318
|
}
|
|
43257
43319
|
deserialize(data) {
|
|
@@ -44161,6 +44223,35 @@ var init_Audio = __esm(() => {
|
|
|
44161
44223
|
};
|
|
44162
44224
|
});
|
|
44163
44225
|
|
|
44226
|
+
// src/api/AuthRequest.ts
|
|
44227
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
44228
|
+
const getAuthInit = (originalInit) => {
|
|
44229
|
+
const token = conf.getAccessToken();
|
|
44230
|
+
if (!token) {
|
|
44231
|
+
return originalInit;
|
|
44232
|
+
}
|
|
44233
|
+
const headers = new Headers(originalInit.headers);
|
|
44234
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
44235
|
+
return { ...originalInit, headers };
|
|
44236
|
+
};
|
|
44237
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
44238
|
+
if (response.status === 401) {
|
|
44239
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
44240
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
44241
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
44242
|
+
if (refreshed) {
|
|
44243
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
44244
|
+
} else {
|
|
44245
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
44246
|
+
}
|
|
44247
|
+
}
|
|
44248
|
+
}
|
|
44249
|
+
return response;
|
|
44250
|
+
}
|
|
44251
|
+
var init_AuthRequest = __esm(() => {
|
|
44252
|
+
init_Settings();
|
|
44253
|
+
});
|
|
44254
|
+
|
|
44164
44255
|
// src/api/MediaHelpers.ts
|
|
44165
44256
|
function getAccessTypeFromUrl(url2) {
|
|
44166
44257
|
try {
|
|
@@ -44178,15 +44269,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
44178
44269
|
}
|
|
44179
44270
|
return null;
|
|
44180
44271
|
}
|
|
44181
|
-
var uploadSvgDirectly = async (blob,
|
|
44182
|
-
const response = await
|
|
44272
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
44273
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
44183
44274
|
method: "POST",
|
|
44184
44275
|
headers: {
|
|
44185
|
-
"Content-Type": "image/svg+xml"
|
|
44186
|
-
Authorization: `Bearer ${accessToken}`
|
|
44276
|
+
"Content-Type": "image/svg+xml"
|
|
44187
44277
|
},
|
|
44188
44278
|
body: blob
|
|
44189
|
-
});
|
|
44279
|
+
}, boardId);
|
|
44190
44280
|
if (!response.ok) {
|
|
44191
44281
|
conf.hooks.onUploadMediaError(response, "image");
|
|
44192
44282
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -44196,19 +44286,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44196
44286
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
44197
44287
|
}
|
|
44198
44288
|
return data.url;
|
|
44199
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
44200
|
-
const generateUrlResponse = await
|
|
44289
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
44290
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
44201
44291
|
method: "POST",
|
|
44202
44292
|
headers: {
|
|
44203
|
-
"Content-Type": "application/json"
|
|
44204
|
-
Authorization: `Bearer ${accessToken}`
|
|
44293
|
+
"Content-Type": "application/json"
|
|
44205
44294
|
},
|
|
44206
44295
|
body: JSON.stringify({
|
|
44207
44296
|
fileSize: blob.size,
|
|
44208
44297
|
fileType: blob.type,
|
|
44209
44298
|
boardId
|
|
44210
44299
|
})
|
|
44211
|
-
});
|
|
44300
|
+
}, boardId);
|
|
44212
44301
|
if (!generateUrlResponse.ok) {
|
|
44213
44302
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
44214
44303
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -44230,18 +44319,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44230
44319
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
44231
44320
|
}
|
|
44232
44321
|
return url2;
|
|
44233
|
-
}, uploadMediaToStorage = async (blob,
|
|
44322
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
44234
44323
|
try {
|
|
44235
44324
|
if (blob.type === "image/svg+xml") {
|
|
44236
|
-
return await uploadSvgDirectly(blob,
|
|
44325
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
44237
44326
|
} else {
|
|
44238
|
-
return await uploadWithPresignedUrl(blob,
|
|
44327
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
44239
44328
|
}
|
|
44240
44329
|
} catch (error48) {
|
|
44241
44330
|
console.error("Media upload process error:", error48);
|
|
44242
44331
|
throw error48;
|
|
44243
44332
|
}
|
|
44244
|
-
}, getMediaSignedUrl = async (url2
|
|
44333
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
44245
44334
|
const accessType = getAccessTypeFromUrl(url2);
|
|
44246
44335
|
if (!accessType) {
|
|
44247
44336
|
return null;
|
|
@@ -44249,15 +44338,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44249
44338
|
if (accessType === "anonymous") {
|
|
44250
44339
|
return url2;
|
|
44251
44340
|
}
|
|
44252
|
-
if (!accessToken) {
|
|
44253
|
-
return null;
|
|
44254
|
-
}
|
|
44255
44341
|
try {
|
|
44256
|
-
const response = await
|
|
44257
|
-
method: "GET"
|
|
44258
|
-
headers: {
|
|
44259
|
-
Authorization: `Bearer ${accessToken}`
|
|
44260
|
-
}
|
|
44342
|
+
const response = await authenticatedFetch(url2, {
|
|
44343
|
+
method: "GET"
|
|
44261
44344
|
});
|
|
44262
44345
|
if (!response.ok) {
|
|
44263
44346
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -44272,15 +44355,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44272
44355
|
};
|
|
44273
44356
|
var init_MediaHelpers = __esm(() => {
|
|
44274
44357
|
init_Settings();
|
|
44358
|
+
init_AuthRequest();
|
|
44275
44359
|
});
|
|
44276
44360
|
|
|
44277
44361
|
// src/Items/Audio/AudioHelpers.ts
|
|
44278
|
-
var prepareAudio = (file2,
|
|
44362
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
44279
44363
|
return new Promise((resolve, reject) => {
|
|
44280
44364
|
const audio = document.createElement("audio");
|
|
44281
44365
|
audio.src = URL.createObjectURL(file2);
|
|
44282
44366
|
audio.onloadedmetadata = () => {
|
|
44283
|
-
uploadMediaToStorage(file2,
|
|
44367
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
44284
44368
|
resolve(url2);
|
|
44285
44369
|
}).catch(reject);
|
|
44286
44370
|
};
|
|
@@ -62807,7 +62891,7 @@ var init_Video = __esm(() => {
|
|
|
62807
62891
|
async setPreviewUrl(url2) {
|
|
62808
62892
|
if (this.isStorageUrl) {
|
|
62809
62893
|
try {
|
|
62810
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
62894
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
62811
62895
|
} catch (err) {
|
|
62812
62896
|
console.error(err);
|
|
62813
62897
|
this.onError();
|
|
@@ -63167,9 +63251,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
63167
63251
|
};
|
|
63168
63252
|
}
|
|
63169
63253
|
});
|
|
63170
|
-
}, prepareImage = (inp,
|
|
63254
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
63171
63255
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
63172
|
-
return uploadMediaToStorage(blob,
|
|
63256
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
63173
63257
|
return {
|
|
63174
63258
|
imageDimension: { width: width2, height: height2 },
|
|
63175
63259
|
base64: dataURL,
|
|
@@ -63210,15 +63294,15 @@ var getVideoMetadata = (file2) => {
|
|
|
63210
63294
|
board.selection.add(boardVideo);
|
|
63211
63295
|
onLoadCb(boardVideo);
|
|
63212
63296
|
});
|
|
63213
|
-
}, prepareVideo = (file2,
|
|
63297
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
63214
63298
|
return new Promise((resolve2, reject) => {
|
|
63215
63299
|
const video = document.createElement("video");
|
|
63216
63300
|
video.src = URL.createObjectURL(file2);
|
|
63217
63301
|
video.onloadedmetadata = () => {
|
|
63218
63302
|
video.onseeked = () => {
|
|
63219
63303
|
video.onseeked = null;
|
|
63220
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
63221
|
-
uploadMediaToStorage(file2,
|
|
63304
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
63305
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
63222
63306
|
resolve2({
|
|
63223
63307
|
url: url2,
|
|
63224
63308
|
previewUrl: imageData.storageLink
|
|
@@ -69206,8 +69290,8 @@ var init_Card = __esm(() => {
|
|
|
69206
69290
|
async createImages() {
|
|
69207
69291
|
this.face = conf.documentFactory.createElement("img");
|
|
69208
69292
|
this.backside = conf.documentFactory.createElement("img");
|
|
69209
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
69210
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
69293
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
69294
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
69211
69295
|
this.face.onload = () => {
|
|
69212
69296
|
this.subject.publish(this);
|
|
69213
69297
|
};
|
|
@@ -69908,7 +69992,7 @@ var init_Dice = __esm(() => {
|
|
|
69908
69992
|
this.renderValues[index2] = value;
|
|
69909
69993
|
} else {
|
|
69910
69994
|
const image2 = conf.documentFactory.createElement("img");
|
|
69911
|
-
image2.src = await getMediaSignedUrl(value
|
|
69995
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
69912
69996
|
this.renderValues[index2] = image2;
|
|
69913
69997
|
image2.onload = () => {
|
|
69914
69998
|
this.subject.publish(this);
|
|
@@ -70363,7 +70447,7 @@ var init_Screen = __esm(() => {
|
|
|
70363
70447
|
this.backgroundUrl = url2 || "";
|
|
70364
70448
|
if (url2) {
|
|
70365
70449
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
70366
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
70450
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
70367
70451
|
this.applyBackgroundColor("none");
|
|
70368
70452
|
this.backgroundImage.onload = () => {
|
|
70369
70453
|
this.subject.publish(this);
|
|
@@ -72225,7 +72309,7 @@ var init_Image = __esm(() => {
|
|
|
72225
72309
|
}
|
|
72226
72310
|
async setStorageLink(link2) {
|
|
72227
72311
|
this.storageLink = link2;
|
|
72228
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
72312
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
72229
72313
|
if (!this.signedUrl) {
|
|
72230
72314
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
72231
72315
|
canvas.width = 100;
|
|
@@ -72646,7 +72730,7 @@ function handleAudioGenerate(response, board) {
|
|
|
72646
72730
|
}
|
|
72647
72731
|
function handleImageGenerate(response, board) {
|
|
72648
72732
|
if (response.status === "completed" && response.base64) {
|
|
72649
|
-
prepareImage(response.base64,
|
|
72733
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
72650
72734
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
72651
72735
|
if (placeholderId) {
|
|
72652
72736
|
const placeholderNode = board.items.getById(placeholderId);
|
|
@@ -92,6 +92,12 @@ export declare class Events {
|
|
|
92
92
|
private canUndoEvent;
|
|
93
93
|
private setLatestUserEvent;
|
|
94
94
|
private getOpKey;
|
|
95
|
+
/**
|
|
96
|
+
* Synchronizes the identity of all unconfirmed local events with the current connection state.
|
|
97
|
+
* Call this after a successful token refresh or when falling back to an anonymous session
|
|
98
|
+
* to ensure pending operations are sent with the correct session and user IDs.
|
|
99
|
+
*/
|
|
100
|
+
refreshIdentity(): void;
|
|
95
101
|
private getSessionId;
|
|
96
102
|
private getSessionIds;
|
|
97
103
|
private getAuthorUserId;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Board } from '../../Board';
|
|
2
2
|
import { AudioItem } from '../Audio/Audio';
|
|
3
3
|
import { Matrix } from '../Transformation/Matrix';
|
|
4
|
-
export declare const prepareAudio: (file: File,
|
|
4
|
+
export declare const prepareAudio: (file: File, boardId: string, baseUrl?: string) => Promise<string>;
|
|
5
5
|
export declare const calculateAudioPosition: (board: Board, audioItem: AudioItem) => Matrix;
|
|
@@ -16,4 +16,4 @@ export declare const resizeAndConvertToPng: (inp: string | ArrayBuffer | null |
|
|
|
16
16
|
* @param boardId
|
|
17
17
|
* @returns An object containing prepared image information on success, err otherwise
|
|
18
18
|
*/
|
|
19
|
-
export declare const prepareImage: (inp: string | ArrayBuffer | null | undefined,
|
|
19
|
+
export declare const prepareImage: (inp: string | ArrayBuffer | null | undefined, boardId: string, baseUrl?: string) => Promise<ImageConstructorData>;
|
|
@@ -5,7 +5,7 @@ export declare const getVideoMetadata: (file: File) => Promise<{
|
|
|
5
5
|
height: number;
|
|
6
6
|
}>;
|
|
7
7
|
export declare const createVideoItem: (board: Board, extension: "mp4" | "webm", videoData: VideoConstructorData, onLoadCb: (video: VideoItem) => void) => void;
|
|
8
|
-
export declare const prepareVideo: (file: File,
|
|
8
|
+
export declare const prepareVideo: (file: File, boardId: string, baseUrl?: string) => Promise<{
|
|
9
9
|
url: string;
|
|
10
10
|
previewUrl: string;
|
|
11
11
|
}>;
|
package/dist/types/Settings.d.ts
CHANGED
|
@@ -97,6 +97,8 @@ type GetDocumentWidthFunction = () => number;
|
|
|
97
97
|
type GetDocumentHeightFunction = () => number;
|
|
98
98
|
type GetDPIFunction = () => number;
|
|
99
99
|
type GetYouTubeIdFunction = (url?: string) => string | null;
|
|
100
|
+
type OnAuthInvalidFunction = (boardId?: string) => Promise<boolean>;
|
|
101
|
+
type OnAuthTerminalFailureFunction = (boardId?: string, reason?: string) => void;
|
|
100
102
|
type GetDOMParser = () => {
|
|
101
103
|
parseFromString: (str: string, type: DOMParserSupportedType) => Document;
|
|
102
104
|
};
|
|
@@ -129,6 +131,12 @@ export declare const conf: {
|
|
|
129
131
|
getDPI: GetDPIFunction;
|
|
130
132
|
reactEditorFocus: ReactEditorFocus;
|
|
131
133
|
reactEditorToSlatePoint: ReactEditorToSlatePoint;
|
|
134
|
+
/**
|
|
135
|
+
* Coordination hooks for authentication and connection state.
|
|
136
|
+
* UI repository should implement these to handle token refresh and terminal failure.
|
|
137
|
+
*/
|
|
138
|
+
onAuthInvalid: OnAuthInvalidFunction;
|
|
139
|
+
onAuthTerminalFailure: OnAuthTerminalFailureFunction;
|
|
132
140
|
planNames: {
|
|
133
141
|
basic: string;
|
|
134
142
|
plus: string;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal authenticated fetch wrapper.
|
|
3
|
+
* Detects 401 AUTH_INVALID_ACCESS_TOKEN and coordinates refresh with the UI layer via Settings hooks.
|
|
4
|
+
* Compatible with Browser, Node.js (v18+), and Cloudflare Workers.
|
|
5
|
+
*/
|
|
6
|
+
export declare function authenticatedFetch(url: string, init?: RequestInit, boardId?: string): Promise<Response>;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const uploadMediaToStorage: (blob: Blob,
|
|
2
|
-
export declare const getMediaSignedUrl: (url: string
|
|
1
|
+
export declare const uploadMediaToStorage: (blob: Blob, boardId: string, type: "video" | "audio" | "image", baseUrl?: string) => Promise<string>;
|
|
2
|
+
export declare const getMediaSignedUrl: (url: string) => Promise<string | null>;
|