microboard-temp 0.13.79 → 0.13.80
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 +123 -41
- package/dist/cjs/index.js +123 -41
- package/dist/cjs/node.js +123 -41
- package/dist/esm/browser.js +143 -61
- package/dist/esm/index.js +143 -61
- package/dist/esm/node.js +143 -61
- package/dist/types/Events/Events.d.ts +6 -0
- 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",
|
|
@@ -14419,6 +14421,11 @@ class Events {
|
|
|
14419
14421
|
getOpKey(op) {
|
|
14420
14422
|
return op.method;
|
|
14421
14423
|
}
|
|
14424
|
+
refreshIdentity() {
|
|
14425
|
+
const sessionId = this.getSessionId();
|
|
14426
|
+
const authorUserId = this.getAuthorUserId();
|
|
14427
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14428
|
+
}
|
|
14422
14429
|
getSessionId() {
|
|
14423
14430
|
return getConnectionSessionId(this.connection);
|
|
14424
14431
|
}
|
|
@@ -31901,9 +31908,34 @@ var init_setLink = __esm(() => {
|
|
|
31901
31908
|
});
|
|
31902
31909
|
|
|
31903
31910
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31904
|
-
import { Editor as Editor12 } from "slate";
|
|
31911
|
+
import { Editor as Editor12, Range as Range6, Text as Text7 } from "slate";
|
|
31905
31912
|
function getSelectionMarks(editor) {
|
|
31906
|
-
|
|
31913
|
+
const marks = Editor12.marks(editor);
|
|
31914
|
+
if (!editor.selection) {
|
|
31915
|
+
return marks;
|
|
31916
|
+
}
|
|
31917
|
+
if (!Range6.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31918
|
+
return marks;
|
|
31919
|
+
}
|
|
31920
|
+
const textEntries = Array.from(Editor12.nodes(editor, {
|
|
31921
|
+
at: editor.selection,
|
|
31922
|
+
match: (node) => Text7.isText(node)
|
|
31923
|
+
}));
|
|
31924
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31925
|
+
if (!firstEntry) {
|
|
31926
|
+
return marks;
|
|
31927
|
+
}
|
|
31928
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31929
|
+
const commonMarks = { ...firstMarks };
|
|
31930
|
+
for (const [node] of restEntries) {
|
|
31931
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31932
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31933
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31934
|
+
delete commonMarks[key];
|
|
31935
|
+
}
|
|
31936
|
+
}
|
|
31937
|
+
}
|
|
31938
|
+
return commonMarks;
|
|
31907
31939
|
}
|
|
31908
31940
|
var init_getSelectionMarks = () => {};
|
|
31909
31941
|
|
|
@@ -31922,13 +31954,13 @@ var init_clearText = __esm(() => {
|
|
|
31922
31954
|
});
|
|
31923
31955
|
|
|
31924
31956
|
// src/Items/RichText/editorHelpers/common/hasTextInSelection.ts
|
|
31925
|
-
import { Editor as Editor14, Range as
|
|
31957
|
+
import { Editor as Editor14, Range as Range7 } from "slate";
|
|
31926
31958
|
function hasTextInSelection(editor) {
|
|
31927
31959
|
const { selection } = editor;
|
|
31928
|
-
if (!selection ||
|
|
31960
|
+
if (!selection || Range7.isCollapsed(selection)) {
|
|
31929
31961
|
return false;
|
|
31930
31962
|
}
|
|
31931
|
-
const [start, end] =
|
|
31963
|
+
const [start, end] = Range7.edges(selection);
|
|
31932
31964
|
const text = Editor14.string(editor, { anchor: start, focus: end });
|
|
31933
31965
|
return text.length > 0;
|
|
31934
31966
|
}
|
|
@@ -41801,7 +41833,7 @@ function getParagraphWithPassedTextNode(textNode) {
|
|
|
41801
41833
|
}
|
|
41802
41834
|
|
|
41803
41835
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontSize.ts
|
|
41804
|
-
import { Editor as Editor23, Transforms as Transforms16 } from "slate";
|
|
41836
|
+
import { Editor as Editor23, Range as Range8, Text as Text8, Transforms as Transforms16 } from "slate";
|
|
41805
41837
|
import { ReactEditor as ReactEditor3 } from "slate-react";
|
|
41806
41838
|
function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
41807
41839
|
const size = fontSize;
|
|
@@ -41836,7 +41868,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
41836
41868
|
shouldUpdateElement = true;
|
|
41837
41869
|
}
|
|
41838
41870
|
} else {
|
|
41839
|
-
|
|
41871
|
+
if (editor.selection && Range8.isExpanded(editor.selection)) {
|
|
41872
|
+
Transforms16.setNodes(editor, { fontSize: size }, {
|
|
41873
|
+
match: (n) => Text8.isText(n),
|
|
41874
|
+
split: true
|
|
41875
|
+
});
|
|
41876
|
+
} else {
|
|
41877
|
+
Editor23.addMark(editor, "fontSize", size);
|
|
41878
|
+
}
|
|
41840
41879
|
}
|
|
41841
41880
|
}
|
|
41842
41881
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -41874,7 +41913,7 @@ var init_getEachNodeInSelectionStyles = __esm(() => {
|
|
|
41874
41913
|
});
|
|
41875
41914
|
|
|
41876
41915
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontStyle.ts
|
|
41877
|
-
import { Editor as Editor24, Range as
|
|
41916
|
+
import { Editor as Editor24, Range as Range9, Transforms as Transforms17 } from "slate";
|
|
41878
41917
|
function setSelectionFontStyle(editor, style) {
|
|
41879
41918
|
const styleList = Array.isArray(style) ? style : [style];
|
|
41880
41919
|
for (const style2 of styleList) {
|
|
@@ -41891,7 +41930,7 @@ function setSelectionFontStyle(editor, style) {
|
|
|
41891
41930
|
continue;
|
|
41892
41931
|
}
|
|
41893
41932
|
const { selection } = editor;
|
|
41894
|
-
if (selection &&
|
|
41933
|
+
if (selection && Range9.isExpanded(selection)) {
|
|
41895
41934
|
Transforms17.setNodes(editor, { [style2]: value }, {
|
|
41896
41935
|
match: (n) => !Editor24.isEditor(n) && n.type === "text",
|
|
41897
41936
|
split: true
|
|
@@ -41906,7 +41945,7 @@ var init_setSelectionFontStyle = __esm(() => {
|
|
|
41906
41945
|
});
|
|
41907
41946
|
|
|
41908
41947
|
// src/Items/RichText/editorHelpers/selectionOps/setSelectionFontColor.ts
|
|
41909
|
-
import { Editor as Editor25 } from "slate";
|
|
41948
|
+
import { Editor as Editor25, Range as Range10, Text as Text9, Transforms as Transforms18 } from "slate";
|
|
41910
41949
|
import { ReactEditor as ReactEditor4 } from "slate-react";
|
|
41911
41950
|
function setSelectionFontColor(editor, format, selectionContext) {
|
|
41912
41951
|
const marks = getSelectionMarks(editor);
|
|
@@ -41914,7 +41953,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
41914
41953
|
return;
|
|
41915
41954
|
}
|
|
41916
41955
|
if (marks.fontColor !== format) {
|
|
41917
|
-
|
|
41956
|
+
if (editor.selection && Range10.isExpanded(editor.selection)) {
|
|
41957
|
+
Transforms18.setNodes(editor, { fontColor: format }, {
|
|
41958
|
+
match: (n) => Text9.isText(n),
|
|
41959
|
+
split: true
|
|
41960
|
+
});
|
|
41961
|
+
} else {
|
|
41962
|
+
Editor25.addMark(editor, "fontColor", format);
|
|
41963
|
+
}
|
|
41918
41964
|
}
|
|
41919
41965
|
if (selectionContext === "EditTextUnderPointer") {
|
|
41920
41966
|
try {
|
|
@@ -41932,7 +41978,7 @@ var init_setSelectionFontColor = __esm(() => {
|
|
|
41932
41978
|
import {
|
|
41933
41979
|
createEditor,
|
|
41934
41980
|
Editor as Editor26,
|
|
41935
|
-
Transforms as
|
|
41981
|
+
Transforms as Transforms19
|
|
41936
41982
|
} from "slate";
|
|
41937
41983
|
import { withReact } from "slate-react";
|
|
41938
41984
|
|
|
@@ -42208,7 +42254,7 @@ class EditorContainer {
|
|
|
42208
42254
|
break;
|
|
42209
42255
|
}
|
|
42210
42256
|
if (selection) {
|
|
42211
|
-
|
|
42257
|
+
Transforms19.select(this.editor, selection);
|
|
42212
42258
|
}
|
|
42213
42259
|
}
|
|
42214
42260
|
applyMaxWidth(maxWidth) {
|
|
@@ -42368,7 +42414,7 @@ class EditorContainer {
|
|
|
42368
42414
|
return JSON.parse(JSON.stringify(this.editor.selection));
|
|
42369
42415
|
}
|
|
42370
42416
|
splitNode() {
|
|
42371
|
-
|
|
42417
|
+
Transforms19.splitNodes(this.editor, { always: true });
|
|
42372
42418
|
}
|
|
42373
42419
|
getBlockNodes() {
|
|
42374
42420
|
return this.editor.children;
|
|
@@ -42458,7 +42504,7 @@ var init_findOptimalMaxWidthForTextAutoSize = __esm(() => {
|
|
|
42458
42504
|
});
|
|
42459
42505
|
|
|
42460
42506
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontColor.ts
|
|
42461
|
-
import { Editor as Editor27 } from "slate";
|
|
42507
|
+
import { Editor as Editor27, Range as Range11, Text as Text10, Transforms as Transforms20 } from "slate";
|
|
42462
42508
|
function applySelectionFontColor(editor, fontColor) {
|
|
42463
42509
|
if (!editor) {
|
|
42464
42510
|
throw new Error("Editor is not initialized");
|
|
@@ -42467,14 +42513,21 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
42467
42513
|
if (!marks) {
|
|
42468
42514
|
return;
|
|
42469
42515
|
}
|
|
42470
|
-
|
|
42516
|
+
if (editor.selection && Range11.isExpanded(editor.selection)) {
|
|
42517
|
+
Transforms20.setNodes(editor, { fontColor }, {
|
|
42518
|
+
match: (n) => Text10.isText(n),
|
|
42519
|
+
split: true
|
|
42520
|
+
});
|
|
42521
|
+
} else {
|
|
42522
|
+
Editor27.addMark(editor, "fontColor", fontColor);
|
|
42523
|
+
}
|
|
42471
42524
|
}
|
|
42472
42525
|
var init_applySelectionFontColor = __esm(() => {
|
|
42473
42526
|
init_getSelectionMarks();
|
|
42474
42527
|
});
|
|
42475
42528
|
|
|
42476
42529
|
// src/Items/RichText/editorHelpers/selectionOps/applySelectionFontSize.ts
|
|
42477
|
-
import { Editor as Editor28, Transforms as
|
|
42530
|
+
import { Editor as Editor28, Range as Range12, Text as Text11, Transforms as Transforms21 } from "slate";
|
|
42478
42531
|
function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
42479
42532
|
const size = fontSize;
|
|
42480
42533
|
if (typeof size !== "number") {
|
|
@@ -42489,12 +42542,19 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
42489
42542
|
return;
|
|
42490
42543
|
}
|
|
42491
42544
|
if (JSON.stringify(selection?.anchor) === JSON.stringify(selection?.focus)) {
|
|
42492
|
-
|
|
42545
|
+
Transforms21.select(editor, {
|
|
42493
42546
|
anchor: Editor28.start(editor, []),
|
|
42494
42547
|
focus: Editor28.end(editor, [])
|
|
42495
42548
|
});
|
|
42496
42549
|
}
|
|
42497
|
-
|
|
42550
|
+
if (editor.selection && Range12.isExpanded(editor.selection)) {
|
|
42551
|
+
Transforms21.setNodes(editor, { fontSize: size }, {
|
|
42552
|
+
match: (n) => Text11.isText(n),
|
|
42553
|
+
split: true
|
|
42554
|
+
});
|
|
42555
|
+
} else {
|
|
42556
|
+
Editor28.addMark(editor, "fontSize", size);
|
|
42557
|
+
}
|
|
42498
42558
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
42499
42559
|
}
|
|
42500
42560
|
var init_applySelectionFontSize = __esm(() => {
|
|
@@ -42577,8 +42637,8 @@ var init_setEditorFocus = () => {};
|
|
|
42577
42637
|
import {
|
|
42578
42638
|
Editor as Editor30,
|
|
42579
42639
|
Element as Element9,
|
|
42580
|
-
Text as
|
|
42581
|
-
Transforms as
|
|
42640
|
+
Text as Text12,
|
|
42641
|
+
Transforms as Transforms22
|
|
42582
42642
|
} from "slate";
|
|
42583
42643
|
var isEditInProcessValue = false, counter = 0, RichText;
|
|
42584
42644
|
var init_RichText = __esm(() => {
|
|
@@ -42613,7 +42673,7 @@ var init_RichText = __esm(() => {
|
|
|
42613
42673
|
parent = "Board";
|
|
42614
42674
|
subject = new Subject;
|
|
42615
42675
|
editor;
|
|
42616
|
-
editorTransforms =
|
|
42676
|
+
editorTransforms = Transforms22;
|
|
42617
42677
|
editorEditor = Editor30;
|
|
42618
42678
|
isContainerSet = false;
|
|
42619
42679
|
isRenderEnabled = true;
|
|
@@ -43145,7 +43205,7 @@ var init_RichText = __esm(() => {
|
|
|
43145
43205
|
}
|
|
43146
43206
|
getMinFontSize() {
|
|
43147
43207
|
const textNodes = Editor30.nodes(this.editor.editor, {
|
|
43148
|
-
match: (n) =>
|
|
43208
|
+
match: (n) => Text12.isText(n),
|
|
43149
43209
|
at: []
|
|
43150
43210
|
});
|
|
43151
43211
|
const fontSizes = [];
|
|
@@ -43249,9 +43309,9 @@ var init_RichText = __esm(() => {
|
|
|
43249
43309
|
}
|
|
43250
43310
|
restoreSelection(selection) {
|
|
43251
43311
|
if (selection) {
|
|
43252
|
-
|
|
43312
|
+
Transforms22.select(this.editor.editor, selection);
|
|
43253
43313
|
} else {
|
|
43254
|
-
|
|
43314
|
+
Transforms22.deselect(this.editor.editor);
|
|
43255
43315
|
}
|
|
43256
43316
|
}
|
|
43257
43317
|
deserialize(data) {
|
|
@@ -44161,6 +44221,35 @@ var init_Audio = __esm(() => {
|
|
|
44161
44221
|
};
|
|
44162
44222
|
});
|
|
44163
44223
|
|
|
44224
|
+
// src/api/AuthRequest.ts
|
|
44225
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
44226
|
+
const getAuthInit = (originalInit) => {
|
|
44227
|
+
const token = conf.getAccessToken();
|
|
44228
|
+
if (!token) {
|
|
44229
|
+
return originalInit;
|
|
44230
|
+
}
|
|
44231
|
+
const headers = new Headers(originalInit.headers);
|
|
44232
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
44233
|
+
return { ...originalInit, headers };
|
|
44234
|
+
};
|
|
44235
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
44236
|
+
if (response.status === 401) {
|
|
44237
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
44238
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
44239
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
44240
|
+
if (refreshed) {
|
|
44241
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
44242
|
+
} else {
|
|
44243
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
44244
|
+
}
|
|
44245
|
+
}
|
|
44246
|
+
}
|
|
44247
|
+
return response;
|
|
44248
|
+
}
|
|
44249
|
+
var init_AuthRequest = __esm(() => {
|
|
44250
|
+
init_Settings();
|
|
44251
|
+
});
|
|
44252
|
+
|
|
44164
44253
|
// src/api/MediaHelpers.ts
|
|
44165
44254
|
function getAccessTypeFromUrl(url2) {
|
|
44166
44255
|
try {
|
|
@@ -44178,15 +44267,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
44178
44267
|
}
|
|
44179
44268
|
return null;
|
|
44180
44269
|
}
|
|
44181
|
-
var uploadSvgDirectly = async (blob,
|
|
44182
|
-
const response = await
|
|
44270
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
44271
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
44183
44272
|
method: "POST",
|
|
44184
44273
|
headers: {
|
|
44185
|
-
"Content-Type": "image/svg+xml"
|
|
44186
|
-
Authorization: `Bearer ${accessToken}`
|
|
44274
|
+
"Content-Type": "image/svg+xml"
|
|
44187
44275
|
},
|
|
44188
44276
|
body: blob
|
|
44189
|
-
});
|
|
44277
|
+
}, boardId);
|
|
44190
44278
|
if (!response.ok) {
|
|
44191
44279
|
conf.hooks.onUploadMediaError(response, "image");
|
|
44192
44280
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -44196,19 +44284,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44196
44284
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
44197
44285
|
}
|
|
44198
44286
|
return data.url;
|
|
44199
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
44200
|
-
const generateUrlResponse = await
|
|
44287
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
44288
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
44201
44289
|
method: "POST",
|
|
44202
44290
|
headers: {
|
|
44203
|
-
"Content-Type": "application/json"
|
|
44204
|
-
Authorization: `Bearer ${accessToken}`
|
|
44291
|
+
"Content-Type": "application/json"
|
|
44205
44292
|
},
|
|
44206
44293
|
body: JSON.stringify({
|
|
44207
44294
|
fileSize: blob.size,
|
|
44208
44295
|
fileType: blob.type,
|
|
44209
44296
|
boardId
|
|
44210
44297
|
})
|
|
44211
|
-
});
|
|
44298
|
+
}, boardId);
|
|
44212
44299
|
if (!generateUrlResponse.ok) {
|
|
44213
44300
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
44214
44301
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -44230,18 +44317,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44230
44317
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
44231
44318
|
}
|
|
44232
44319
|
return url2;
|
|
44233
|
-
}, uploadMediaToStorage = async (blob,
|
|
44320
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
44234
44321
|
try {
|
|
44235
44322
|
if (blob.type === "image/svg+xml") {
|
|
44236
|
-
return await uploadSvgDirectly(blob,
|
|
44323
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
44237
44324
|
} else {
|
|
44238
|
-
return await uploadWithPresignedUrl(blob,
|
|
44325
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
44239
44326
|
}
|
|
44240
44327
|
} catch (error48) {
|
|
44241
44328
|
console.error("Media upload process error:", error48);
|
|
44242
44329
|
throw error48;
|
|
44243
44330
|
}
|
|
44244
|
-
}, getMediaSignedUrl = async (url2
|
|
44331
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
44245
44332
|
const accessType = getAccessTypeFromUrl(url2);
|
|
44246
44333
|
if (!accessType) {
|
|
44247
44334
|
return null;
|
|
@@ -44249,15 +44336,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44249
44336
|
if (accessType === "anonymous") {
|
|
44250
44337
|
return url2;
|
|
44251
44338
|
}
|
|
44252
|
-
if (!accessToken) {
|
|
44253
|
-
return null;
|
|
44254
|
-
}
|
|
44255
44339
|
try {
|
|
44256
|
-
const response = await
|
|
44257
|
-
method: "GET"
|
|
44258
|
-
headers: {
|
|
44259
|
-
Authorization: `Bearer ${accessToken}`
|
|
44260
|
-
}
|
|
44340
|
+
const response = await authenticatedFetch(url2, {
|
|
44341
|
+
method: "GET"
|
|
44261
44342
|
});
|
|
44262
44343
|
if (!response.ok) {
|
|
44263
44344
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -44272,15 +44353,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
44272
44353
|
};
|
|
44273
44354
|
var init_MediaHelpers = __esm(() => {
|
|
44274
44355
|
init_Settings();
|
|
44356
|
+
init_AuthRequest();
|
|
44275
44357
|
});
|
|
44276
44358
|
|
|
44277
44359
|
// src/Items/Audio/AudioHelpers.ts
|
|
44278
|
-
var prepareAudio = (file2,
|
|
44360
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
44279
44361
|
return new Promise((resolve, reject) => {
|
|
44280
44362
|
const audio = document.createElement("audio");
|
|
44281
44363
|
audio.src = URL.createObjectURL(file2);
|
|
44282
44364
|
audio.onloadedmetadata = () => {
|
|
44283
|
-
uploadMediaToStorage(file2,
|
|
44365
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
44284
44366
|
resolve(url2);
|
|
44285
44367
|
}).catch(reject);
|
|
44286
44368
|
};
|
|
@@ -62807,7 +62889,7 @@ var init_Video = __esm(() => {
|
|
|
62807
62889
|
async setPreviewUrl(url2) {
|
|
62808
62890
|
if (this.isStorageUrl) {
|
|
62809
62891
|
try {
|
|
62810
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
62892
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
62811
62893
|
} catch (err) {
|
|
62812
62894
|
console.error(err);
|
|
62813
62895
|
this.onError();
|
|
@@ -63167,9 +63249,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
63167
63249
|
};
|
|
63168
63250
|
}
|
|
63169
63251
|
});
|
|
63170
|
-
}, prepareImage = (inp,
|
|
63252
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
63171
63253
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
63172
|
-
return uploadMediaToStorage(blob,
|
|
63254
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
63173
63255
|
return {
|
|
63174
63256
|
imageDimension: { width: width2, height: height2 },
|
|
63175
63257
|
base64: dataURL,
|
|
@@ -63210,15 +63292,15 @@ var getVideoMetadata = (file2) => {
|
|
|
63210
63292
|
board.selection.add(boardVideo);
|
|
63211
63293
|
onLoadCb(boardVideo);
|
|
63212
63294
|
});
|
|
63213
|
-
}, prepareVideo = (file2,
|
|
63295
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
63214
63296
|
return new Promise((resolve2, reject) => {
|
|
63215
63297
|
const video = document.createElement("video");
|
|
63216
63298
|
video.src = URL.createObjectURL(file2);
|
|
63217
63299
|
video.onloadedmetadata = () => {
|
|
63218
63300
|
video.onseeked = () => {
|
|
63219
63301
|
video.onseeked = null;
|
|
63220
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
63221
|
-
uploadMediaToStorage(file2,
|
|
63302
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
63303
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
63222
63304
|
resolve2({
|
|
63223
63305
|
url: url2,
|
|
63224
63306
|
previewUrl: imageData.storageLink
|
|
@@ -69206,8 +69288,8 @@ var init_Card = __esm(() => {
|
|
|
69206
69288
|
async createImages() {
|
|
69207
69289
|
this.face = conf.documentFactory.createElement("img");
|
|
69208
69290
|
this.backside = conf.documentFactory.createElement("img");
|
|
69209
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
69210
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
69291
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
69292
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
69211
69293
|
this.face.onload = () => {
|
|
69212
69294
|
this.subject.publish(this);
|
|
69213
69295
|
};
|
|
@@ -69908,7 +69990,7 @@ var init_Dice = __esm(() => {
|
|
|
69908
69990
|
this.renderValues[index2] = value;
|
|
69909
69991
|
} else {
|
|
69910
69992
|
const image2 = conf.documentFactory.createElement("img");
|
|
69911
|
-
image2.src = await getMediaSignedUrl(value
|
|
69993
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
69912
69994
|
this.renderValues[index2] = image2;
|
|
69913
69995
|
image2.onload = () => {
|
|
69914
69996
|
this.subject.publish(this);
|
|
@@ -70363,7 +70445,7 @@ var init_Screen = __esm(() => {
|
|
|
70363
70445
|
this.backgroundUrl = url2 || "";
|
|
70364
70446
|
if (url2) {
|
|
70365
70447
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
70366
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
70448
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
70367
70449
|
this.applyBackgroundColor("none");
|
|
70368
70450
|
this.backgroundImage.onload = () => {
|
|
70369
70451
|
this.subject.publish(this);
|
|
@@ -72225,7 +72307,7 @@ var init_Image = __esm(() => {
|
|
|
72225
72307
|
}
|
|
72226
72308
|
async setStorageLink(link2) {
|
|
72227
72309
|
this.storageLink = link2;
|
|
72228
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
72310
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
72229
72311
|
if (!this.signedUrl) {
|
|
72230
72312
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
72231
72313
|
canvas.width = 100;
|
|
@@ -72646,7 +72728,7 @@ function handleAudioGenerate(response, board) {
|
|
|
72646
72728
|
}
|
|
72647
72729
|
function handleImageGenerate(response, board) {
|
|
72648
72730
|
if (response.status === "completed" && response.base64) {
|
|
72649
|
-
prepareImage(response.base64,
|
|
72731
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
72650
72732
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
72651
72733
|
if (placeholderId) {
|
|
72652
72734
|
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>;
|