microboard-temp 0.13.78 → 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 +124 -70
- package/dist/cjs/index.js +124 -70
- package/dist/cjs/node.js +124 -70
- package/dist/cjs/protocol.js +0 -16
- package/dist/esm/browser.js +144 -90
- package/dist/esm/index.js +144 -90
- package/dist/esm/node.js +144 -90
- package/dist/esm/protocol.js +0 -16
- package/dist/types/Events/Events.d.ts +6 -0
- package/dist/types/Events/MessageRouter/boardMessageInterface.d.ts +1 -3
- package/dist/types/Events/MessageRouter/socketContract.d.ts +0 -13
- 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 -24
- 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/cjs/browser.js
CHANGED
|
@@ -3638,6 +3638,8 @@ var init_Settings = __esm(() => {
|
|
|
3638
3638
|
getDPI: () => 1,
|
|
3639
3639
|
reactEditorFocus: () => {},
|
|
3640
3640
|
reactEditorToSlatePoint: () => null,
|
|
3641
|
+
onAuthInvalid: async () => false,
|
|
3642
|
+
onAuthTerminalFailure: () => {},
|
|
3641
3643
|
planNames: {
|
|
3642
3644
|
basic: "Basic",
|
|
3643
3645
|
plus: "Plus",
|
|
@@ -3827,24 +3829,6 @@ var init_Settings = __esm(() => {
|
|
|
3827
3829
|
HIGHLIGHTER_DEFAULT_COLOR: "rgba(0, 158, 41, 0.5)",
|
|
3828
3830
|
ERASER_DEFAULT_COLOR: "rgba(222, 224, 227, 0.5)",
|
|
3829
3831
|
ERASER_MAX_LINE_LENGTH: 12,
|
|
3830
|
-
TEMPLATE_CATEGORIES: [
|
|
3831
|
-
"Research & Analysis",
|
|
3832
|
-
"Diagramming",
|
|
3833
|
-
"Meeting & Workshop",
|
|
3834
|
-
"Strategy & Planning",
|
|
3835
|
-
"Brainstorming",
|
|
3836
|
-
"Agile Workflow",
|
|
3837
|
-
"Icebreaker & Game",
|
|
3838
|
-
"Education"
|
|
3839
|
-
],
|
|
3840
|
-
TEMPLATE_LANGUAGES: [
|
|
3841
|
-
{ value: "ru", label: "Russian" },
|
|
3842
|
-
{ value: "en", label: "English" },
|
|
3843
|
-
{ value: "de", label: "German" },
|
|
3844
|
-
{ value: "es", label: "Spanish" },
|
|
3845
|
-
{ value: "fr", label: "French" },
|
|
3846
|
-
{ value: "zh", label: "Chinese" }
|
|
3847
|
-
],
|
|
3848
3832
|
CANVAS_BG_COLOR: "#f6f6f6",
|
|
3849
3833
|
URL_REGEX: /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i,
|
|
3850
3834
|
AI_NODE_DEFAULT_NODE_WIDTH: 640,
|
|
@@ -14450,6 +14434,11 @@ class Events {
|
|
|
14450
14434
|
getOpKey(op) {
|
|
14451
14435
|
return op.method;
|
|
14452
14436
|
}
|
|
14437
|
+
refreshIdentity() {
|
|
14438
|
+
const sessionId = this.getSessionId();
|
|
14439
|
+
const authorUserId = this.getAuthorUserId();
|
|
14440
|
+
this.log.refreshUnconfirmedIdentity(sessionId, authorUserId);
|
|
14441
|
+
}
|
|
14453
14442
|
getSessionId() {
|
|
14454
14443
|
return getConnectionSessionId(this.connection);
|
|
14455
14444
|
}
|
|
@@ -28357,7 +28346,7 @@ function normalizeBoardSubscriptionCompletedMsg(data) {
|
|
|
28357
28346
|
eventsSinceLastSnapshot: exports_external.array(SocketSyncEventSchema).parse(parsed.eventsSinceLastSnapshot)
|
|
28358
28347
|
});
|
|
28359
28348
|
}
|
|
28360
|
-
var StringOrNumberSchema, StringArraySchema, UnknownRecordSchema, TimestampSchema, accessModeValues, AccessModeSchema, OptionalTransportTimestampSchema, MatrixDataSchema, ApplyMatrixItemSchema, UndoOperationSchema, RedoOperationSchema, AddSingleItemBoardOperationSchema, AddManyItemsBoardOperationSchema, BoardOperationSchemas, TranslateOperationSchema, ScaleOperationSchema, RotateOperationSchema, ScaleRelativeToOperationSchema, ScaleByTranslateByOperationSchema, ApplyMatrixOperationSchema, TransformManyItemsOperationSchema, TransformationOperationSchemas, ShapeOperationSchemas, StickerOperationSchema, RichTextWholeTextOperationSchema, RichTextSelectionOperationSchema, RichTextGroupEditOperationSchema, ConnectorOperationSchemas, DrawingOperationSchemas, FrameOperationSchemas, LinkToOperationSchema, PlaceholderOperationSchemas, GroupOperationSchemas, CommentOperationSchemas, ImageOperationSchema, VideoOperationSchema, AudioOperationSchema, SocketOperationSchema, SocketBoardEventBodySchema, SocketBoardEventPackBodySchema, SocketBoardEventSchema, SocketBoardEventPackSchema, SocketSyncBoardEventSchema, SocketSyncBoardEventPackSchema, SocketSyncEventSchema, PointerMovePresenceEventSchema, SelectionPresenceEventSchema, SetUserColorPresenceEventSchema, DrawSelectPresenceEventSchema, CancelDrawSelectPresenceEventSchema, CameraPresenceEventSchema, PingPresenceEventSchema, BringToMePresenceEventSchema, StopFollowingPresenceEventSchema, FollowPresenceEventSchema, PresenceEventSchema, TextActionSchema, UserRequestAiChatEventSchema, GenerateImageRequestAiChatEventSchema, GenerateImageResponseAiChatEventSchema, GenerateAudioRequestAiChatEventSchema, GenerateAudioResponseAiChatEventSchema, StopGenerationAiChatEventSchema, ChatChunkAiChatEventSchema, AiChatEventSchema, SocketBoardSnapshotSchema, NormalizedBoardSnapshotSchema, AuthMsgSchema, LogoutMsgSchema, InvalidateRightsMsgSchema, GetModeMsgSchema, SubscribeMsgSchema, UnsubscribeMsgSchema, ErrorMsgSchema, VersionCheckMsgSchema, AuthConfirmationMsgSchema, PingMsgSchema, PongMsgSchema, BoardAccessDeniedMsgSchema, BoardSubscriptionCompletedMsgSchema, NormalizedBoardSubscriptionCompletedMsgSchema, BoardSnapshotMsgSchema, AiChatMsgSchema, BoardEventMsgSchema, ConfirmationMsgSchema, ModeMsgSchema, SnapshotRequestMsgSchema, UserJoinMsgSchema, PresenceEventMsgSchema, EventsMsgSchema, SocketMsgSchema, BoardWsHandshakeJwtPayloadSchema,
|
|
28349
|
+
var StringOrNumberSchema, StringArraySchema, UnknownRecordSchema, TimestampSchema, accessModeValues, AccessModeSchema, OptionalTransportTimestampSchema, MatrixDataSchema, ApplyMatrixItemSchema, UndoOperationSchema, RedoOperationSchema, AddSingleItemBoardOperationSchema, AddManyItemsBoardOperationSchema, BoardOperationSchemas, TranslateOperationSchema, ScaleOperationSchema, RotateOperationSchema, ScaleRelativeToOperationSchema, ScaleByTranslateByOperationSchema, ApplyMatrixOperationSchema, TransformManyItemsOperationSchema, TransformationOperationSchemas, ShapeOperationSchemas, StickerOperationSchema, RichTextWholeTextOperationSchema, RichTextSelectionOperationSchema, RichTextGroupEditOperationSchema, ConnectorOperationSchemas, DrawingOperationSchemas, FrameOperationSchemas, LinkToOperationSchema, PlaceholderOperationSchemas, GroupOperationSchemas, CommentOperationSchemas, ImageOperationSchema, VideoOperationSchema, AudioOperationSchema, SocketOperationSchema, SocketBoardEventBodySchema, SocketBoardEventPackBodySchema, SocketBoardEventSchema, SocketBoardEventPackSchema, SocketSyncBoardEventSchema, SocketSyncBoardEventPackSchema, SocketSyncEventSchema, PointerMovePresenceEventSchema, SelectionPresenceEventSchema, SetUserColorPresenceEventSchema, DrawSelectPresenceEventSchema, CancelDrawSelectPresenceEventSchema, CameraPresenceEventSchema, PingPresenceEventSchema, BringToMePresenceEventSchema, StopFollowingPresenceEventSchema, FollowPresenceEventSchema, PresenceEventSchema, TextActionSchema, UserRequestAiChatEventSchema, GenerateImageRequestAiChatEventSchema, GenerateImageResponseAiChatEventSchema, GenerateAudioRequestAiChatEventSchema, GenerateAudioResponseAiChatEventSchema, StopGenerationAiChatEventSchema, ChatChunkAiChatEventSchema, AiChatEventSchema, SocketBoardSnapshotSchema, NormalizedBoardSnapshotSchema, AuthMsgSchema, LogoutMsgSchema, InvalidateRightsMsgSchema, GetModeMsgSchema, SubscribeMsgSchema, UnsubscribeMsgSchema, ErrorMsgSchema, VersionCheckMsgSchema, AuthConfirmationMsgSchema, PingMsgSchema, PongMsgSchema, BoardAccessDeniedMsgSchema, BoardSubscriptionCompletedMsgSchema, NormalizedBoardSubscriptionCompletedMsgSchema, BoardSnapshotMsgSchema, AiChatMsgSchema, BoardEventMsgSchema, ConfirmationMsgSchema, ModeMsgSchema, SnapshotRequestMsgSchema, UserJoinMsgSchema, PresenceEventMsgSchema, EventsMsgSchema, SocketMsgSchema, BoardWsHandshakeJwtPayloadSchema, BoardConnectResponseSchema;
|
|
28361
28350
|
var init_socketContract = __esm(() => {
|
|
28362
28351
|
init_zod();
|
|
28363
28352
|
StringOrNumberSchema = exports_external.union([exports_external.string(), exports_external.number()]);
|
|
@@ -29346,11 +29335,6 @@ var init_socketContract = __esm(() => {
|
|
|
29346
29335
|
accessMode: exports_external.enum(accessModeValues),
|
|
29347
29336
|
isWsToken: exports_external.literal(true)
|
|
29348
29337
|
}).strict();
|
|
29349
|
-
TemplateWsHandshakeJwtPayloadSchema = exports_external.object({
|
|
29350
|
-
templateId: exports_external.string(),
|
|
29351
|
-
connectionType: exports_external.literal("template"),
|
|
29352
|
-
isWsToken: exports_external.literal(true)
|
|
29353
|
-
}).strict();
|
|
29354
29338
|
BoardConnectResponseSchema = exports_external.object({
|
|
29355
29339
|
wsUrl: exports_external.string(),
|
|
29356
29340
|
jwt: exports_external.string(),
|
|
@@ -29358,11 +29342,6 @@ var init_socketContract = __esm(() => {
|
|
|
29358
29342
|
sessionId: exports_external.string(),
|
|
29359
29343
|
accessMode: exports_external.enum(accessModeValues)
|
|
29360
29344
|
}).strict();
|
|
29361
|
-
TemplateConnectResponseSchema = exports_external.object({
|
|
29362
|
-
wsUrl: exports_external.string(),
|
|
29363
|
-
jwt: exports_external.string(),
|
|
29364
|
-
userId: exports_external.string()
|
|
29365
|
-
}).strict();
|
|
29366
29345
|
});
|
|
29367
29346
|
|
|
29368
29347
|
// src/Events/MessageRouter/createMessageRouter.ts
|
|
@@ -31899,7 +31878,32 @@ var init_setLink = __esm(() => {
|
|
|
31899
31878
|
|
|
31900
31879
|
// src/Items/RichText/editorHelpers/common/getSelectionMarks.ts
|
|
31901
31880
|
function getSelectionMarks(editor) {
|
|
31902
|
-
|
|
31881
|
+
const marks = import_slate42.Editor.marks(editor);
|
|
31882
|
+
if (!editor.selection) {
|
|
31883
|
+
return marks;
|
|
31884
|
+
}
|
|
31885
|
+
if (!import_slate42.Range.isExpanded(editor.selection) || marks && Object.keys(marks).length > 0) {
|
|
31886
|
+
return marks;
|
|
31887
|
+
}
|
|
31888
|
+
const textEntries = Array.from(import_slate42.Editor.nodes(editor, {
|
|
31889
|
+
at: editor.selection,
|
|
31890
|
+
match: (node) => import_slate42.Text.isText(node)
|
|
31891
|
+
}));
|
|
31892
|
+
const [firstEntry, ...restEntries] = textEntries;
|
|
31893
|
+
if (!firstEntry) {
|
|
31894
|
+
return marks;
|
|
31895
|
+
}
|
|
31896
|
+
const { text: _firstText, ...firstMarks } = firstEntry[0];
|
|
31897
|
+
const commonMarks = { ...firstMarks };
|
|
31898
|
+
for (const [node] of restEntries) {
|
|
31899
|
+
const { text: _text, ...nodeMarks } = node;
|
|
31900
|
+
for (const key of Object.keys(commonMarks)) {
|
|
31901
|
+
if (commonMarks[key] !== nodeMarks[key]) {
|
|
31902
|
+
delete commonMarks[key];
|
|
31903
|
+
}
|
|
31904
|
+
}
|
|
31905
|
+
}
|
|
31906
|
+
return commonMarks;
|
|
31903
31907
|
}
|
|
31904
31908
|
var import_slate42;
|
|
31905
31909
|
var init_getSelectionMarks = __esm(() => {
|
|
@@ -39522,7 +39526,14 @@ function setSelectionFontSize(editor, isAutosize, fontSize, selectionContext) {
|
|
|
39522
39526
|
shouldUpdateElement = true;
|
|
39523
39527
|
}
|
|
39524
39528
|
} else {
|
|
39525
|
-
import_slate53.
|
|
39529
|
+
if (editor.selection && import_slate53.Range.isExpanded(editor.selection)) {
|
|
39530
|
+
import_slate53.Transforms.setNodes(editor, { fontSize: size }, {
|
|
39531
|
+
match: (n) => import_slate53.Text.isText(n),
|
|
39532
|
+
split: true
|
|
39533
|
+
});
|
|
39534
|
+
} else {
|
|
39535
|
+
import_slate53.Editor.addMark(editor, "fontSize", size);
|
|
39536
|
+
}
|
|
39526
39537
|
}
|
|
39527
39538
|
}
|
|
39528
39539
|
if (selectionContext === "EditTextUnderPointer") {
|
|
@@ -39602,7 +39613,14 @@ function setSelectionFontColor(editor, format, selectionContext) {
|
|
|
39602
39613
|
return;
|
|
39603
39614
|
}
|
|
39604
39615
|
if (marks.fontColor !== format) {
|
|
39605
|
-
import_slate55.
|
|
39616
|
+
if (editor.selection && import_slate55.Range.isExpanded(editor.selection)) {
|
|
39617
|
+
import_slate55.Transforms.setNodes(editor, { fontColor: format }, {
|
|
39618
|
+
match: (n) => import_slate55.Text.isText(n),
|
|
39619
|
+
split: true
|
|
39620
|
+
});
|
|
39621
|
+
} else {
|
|
39622
|
+
import_slate55.Editor.addMark(editor, "fontColor", format);
|
|
39623
|
+
}
|
|
39606
39624
|
}
|
|
39607
39625
|
if (selectionContext === "EditTextUnderPointer") {
|
|
39608
39626
|
try {
|
|
@@ -40153,7 +40171,14 @@ function applySelectionFontColor(editor, fontColor) {
|
|
|
40153
40171
|
if (!marks) {
|
|
40154
40172
|
return;
|
|
40155
40173
|
}
|
|
40156
|
-
import_slate57.
|
|
40174
|
+
if (editor.selection && import_slate57.Range.isExpanded(editor.selection)) {
|
|
40175
|
+
import_slate57.Transforms.setNodes(editor, { fontColor }, {
|
|
40176
|
+
match: (n) => import_slate57.Text.isText(n),
|
|
40177
|
+
split: true
|
|
40178
|
+
});
|
|
40179
|
+
} else {
|
|
40180
|
+
import_slate57.Editor.addMark(editor, "fontColor", fontColor);
|
|
40181
|
+
}
|
|
40157
40182
|
}
|
|
40158
40183
|
var import_slate57;
|
|
40159
40184
|
var init_applySelectionFontColor = __esm(() => {
|
|
@@ -40181,7 +40206,14 @@ function applySelectionFontSize(editor, fontSize, selectionContext) {
|
|
|
40181
40206
|
focus: import_slate58.Editor.end(editor, [])
|
|
40182
40207
|
});
|
|
40183
40208
|
}
|
|
40184
|
-
import_slate58.
|
|
40209
|
+
if (editor.selection && import_slate58.Range.isExpanded(editor.selection)) {
|
|
40210
|
+
import_slate58.Transforms.setNodes(editor, { fontSize: size }, {
|
|
40211
|
+
match: (n) => import_slate58.Text.isText(n),
|
|
40212
|
+
split: true
|
|
40213
|
+
});
|
|
40214
|
+
} else {
|
|
40215
|
+
import_slate58.Editor.addMark(editor, "fontSize", size);
|
|
40216
|
+
}
|
|
40185
40217
|
if (selectionContext === "EditTextUnderPointer") {}
|
|
40186
40218
|
}
|
|
40187
40219
|
var import_slate58;
|
|
@@ -41849,6 +41881,35 @@ var init_Audio = __esm(() => {
|
|
|
41849
41881
|
};
|
|
41850
41882
|
});
|
|
41851
41883
|
|
|
41884
|
+
// src/api/AuthRequest.ts
|
|
41885
|
+
async function authenticatedFetch(url2, init2 = {}, boardId) {
|
|
41886
|
+
const getAuthInit = (originalInit) => {
|
|
41887
|
+
const token = conf.getAccessToken();
|
|
41888
|
+
if (!token) {
|
|
41889
|
+
return originalInit;
|
|
41890
|
+
}
|
|
41891
|
+
const headers = new Headers(originalInit.headers);
|
|
41892
|
+
headers.set("Authorization", `Bearer ${token}`);
|
|
41893
|
+
return { ...originalInit, headers };
|
|
41894
|
+
};
|
|
41895
|
+
let response = await fetch(url2, getAuthInit(init2));
|
|
41896
|
+
if (response.status === 401) {
|
|
41897
|
+
const body = await response.clone().json().catch(() => ({}));
|
|
41898
|
+
if (body.code === "AUTH_INVALID_ACCESS_TOKEN") {
|
|
41899
|
+
const refreshed = await conf.onAuthInvalid(boardId);
|
|
41900
|
+
if (refreshed) {
|
|
41901
|
+
response = await fetch(url2, getAuthInit(init2));
|
|
41902
|
+
} else {
|
|
41903
|
+
conf.onAuthTerminalFailure(boardId, body.code);
|
|
41904
|
+
}
|
|
41905
|
+
}
|
|
41906
|
+
}
|
|
41907
|
+
return response;
|
|
41908
|
+
}
|
|
41909
|
+
var init_AuthRequest = __esm(() => {
|
|
41910
|
+
init_Settings();
|
|
41911
|
+
});
|
|
41912
|
+
|
|
41852
41913
|
// src/api/MediaHelpers.ts
|
|
41853
41914
|
function getAccessTypeFromUrl(url2) {
|
|
41854
41915
|
try {
|
|
@@ -41866,15 +41927,14 @@ function getAccessTypeFromUrl(url2) {
|
|
|
41866
41927
|
}
|
|
41867
41928
|
return null;
|
|
41868
41929
|
}
|
|
41869
|
-
var uploadSvgDirectly = async (blob,
|
|
41870
|
-
const response = await
|
|
41930
|
+
var uploadSvgDirectly = async (blob, boardId, baseUrl) => {
|
|
41931
|
+
const response = await authenticatedFetch(`${baseUrl || ""}/svg/${boardId}`, {
|
|
41871
41932
|
method: "POST",
|
|
41872
41933
|
headers: {
|
|
41873
|
-
"Content-Type": "image/svg+xml"
|
|
41874
|
-
Authorization: `Bearer ${accessToken}`
|
|
41934
|
+
"Content-Type": "image/svg+xml"
|
|
41875
41935
|
},
|
|
41876
41936
|
body: blob
|
|
41877
|
-
});
|
|
41937
|
+
}, boardId);
|
|
41878
41938
|
if (!response.ok) {
|
|
41879
41939
|
conf.hooks.onUploadMediaError(response, "image");
|
|
41880
41940
|
throw new Error(`Failed to upload SVG. Status: ${response.status}`);
|
|
@@ -41884,19 +41944,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41884
41944
|
throw new Error("Server did not provide a key for the uploaded SVG.");
|
|
41885
41945
|
}
|
|
41886
41946
|
return data.url;
|
|
41887
|
-
}, uploadWithPresignedUrl = async (blob,
|
|
41888
|
-
const generateUrlResponse = await
|
|
41947
|
+
}, uploadWithPresignedUrl = async (blob, boardId, type, baseUrl) => {
|
|
41948
|
+
const generateUrlResponse = await authenticatedFetch(`${baseUrl || ""}/media/upload`, {
|
|
41889
41949
|
method: "POST",
|
|
41890
41950
|
headers: {
|
|
41891
|
-
"Content-Type": "application/json"
|
|
41892
|
-
Authorization: `Bearer ${accessToken}`
|
|
41951
|
+
"Content-Type": "application/json"
|
|
41893
41952
|
},
|
|
41894
41953
|
body: JSON.stringify({
|
|
41895
41954
|
fileSize: blob.size,
|
|
41896
41955
|
fileType: blob.type,
|
|
41897
41956
|
boardId
|
|
41898
41957
|
})
|
|
41899
|
-
});
|
|
41958
|
+
}, boardId);
|
|
41900
41959
|
if (!generateUrlResponse.ok) {
|
|
41901
41960
|
conf.hooks.onUploadMediaError(generateUrlResponse, type);
|
|
41902
41961
|
throw new Error(`Failed to get presigned URL. Status: ${generateUrlResponse.status}`);
|
|
@@ -41918,18 +41977,18 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41918
41977
|
throw new Error(`Direct upload to storage failed. Status: ${uploadResponse.status}`);
|
|
41919
41978
|
}
|
|
41920
41979
|
return url2;
|
|
41921
|
-
}, uploadMediaToStorage = async (blob,
|
|
41980
|
+
}, uploadMediaToStorage = async (blob, boardId, type, baseUrl) => {
|
|
41922
41981
|
try {
|
|
41923
41982
|
if (blob.type === "image/svg+xml") {
|
|
41924
|
-
return await uploadSvgDirectly(blob,
|
|
41983
|
+
return await uploadSvgDirectly(blob, boardId, baseUrl);
|
|
41925
41984
|
} else {
|
|
41926
|
-
return await uploadWithPresignedUrl(blob,
|
|
41985
|
+
return await uploadWithPresignedUrl(blob, boardId, type, baseUrl);
|
|
41927
41986
|
}
|
|
41928
41987
|
} catch (error48) {
|
|
41929
41988
|
console.error("Media upload process error:", error48);
|
|
41930
41989
|
throw error48;
|
|
41931
41990
|
}
|
|
41932
|
-
}, getMediaSignedUrl = async (url2
|
|
41991
|
+
}, getMediaSignedUrl = async (url2) => {
|
|
41933
41992
|
const accessType = getAccessTypeFromUrl(url2);
|
|
41934
41993
|
if (!accessType) {
|
|
41935
41994
|
return null;
|
|
@@ -41937,15 +41996,9 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41937
41996
|
if (accessType === "anonymous") {
|
|
41938
41997
|
return url2;
|
|
41939
41998
|
}
|
|
41940
|
-
if (!accessToken) {
|
|
41941
|
-
return null;
|
|
41942
|
-
}
|
|
41943
41999
|
try {
|
|
41944
|
-
const response = await
|
|
41945
|
-
method: "GET"
|
|
41946
|
-
headers: {
|
|
41947
|
-
Authorization: `Bearer ${accessToken}`
|
|
41948
|
-
}
|
|
42000
|
+
const response = await authenticatedFetch(url2, {
|
|
42001
|
+
method: "GET"
|
|
41949
42002
|
});
|
|
41950
42003
|
if (!response.ok) {
|
|
41951
42004
|
console.error("Failed to get media signed url:", response.status, response.statusText);
|
|
@@ -41960,15 +42013,16 @@ var uploadSvgDirectly = async (blob, accessToken, boardId, baseUrl) => {
|
|
|
41960
42013
|
};
|
|
41961
42014
|
var init_MediaHelpers = __esm(() => {
|
|
41962
42015
|
init_Settings();
|
|
42016
|
+
init_AuthRequest();
|
|
41963
42017
|
});
|
|
41964
42018
|
|
|
41965
42019
|
// src/Items/Audio/AudioHelpers.ts
|
|
41966
|
-
var prepareAudio = (file2,
|
|
42020
|
+
var prepareAudio = (file2, boardId, baseUrl) => {
|
|
41967
42021
|
return new Promise((resolve, reject) => {
|
|
41968
42022
|
const audio = document.createElement("audio");
|
|
41969
42023
|
audio.src = URL.createObjectURL(file2);
|
|
41970
42024
|
audio.onloadedmetadata = () => {
|
|
41971
|
-
uploadMediaToStorage(file2,
|
|
42025
|
+
uploadMediaToStorage(file2, boardId, "audio", baseUrl).then((url2) => {
|
|
41972
42026
|
resolve(url2);
|
|
41973
42027
|
}).catch(reject);
|
|
41974
42028
|
};
|
|
@@ -60495,7 +60549,7 @@ var init_Video = __esm(() => {
|
|
|
60495
60549
|
async setPreviewUrl(url2) {
|
|
60496
60550
|
if (this.isStorageUrl) {
|
|
60497
60551
|
try {
|
|
60498
|
-
this.preview.src = await getMediaSignedUrl(url2
|
|
60552
|
+
this.preview.src = await getMediaSignedUrl(url2) || "";
|
|
60499
60553
|
} catch (err) {
|
|
60500
60554
|
console.error(err);
|
|
60501
60555
|
this.onError();
|
|
@@ -60855,9 +60909,9 @@ var getBlobFromDataURL = (dataURL) => {
|
|
|
60855
60909
|
};
|
|
60856
60910
|
}
|
|
60857
60911
|
});
|
|
60858
|
-
}, prepareImage = (inp,
|
|
60912
|
+
}, prepareImage = (inp, boardId, baseUrl) => resizeAndConvertToPng(inp).then(({ width: width2, height: height2, dataURL, hash: hash2 }) => {
|
|
60859
60913
|
const { blob, mimeType } = getBlobFromDataURL(dataURL);
|
|
60860
|
-
return uploadMediaToStorage(blob,
|
|
60914
|
+
return uploadMediaToStorage(blob, boardId, "image", baseUrl).then((src) => {
|
|
60861
60915
|
return {
|
|
60862
60916
|
imageDimension: { width: width2, height: height2 },
|
|
60863
60917
|
base64: dataURL,
|
|
@@ -60898,15 +60952,15 @@ var getVideoMetadata = (file2) => {
|
|
|
60898
60952
|
board.selection.add(boardVideo);
|
|
60899
60953
|
onLoadCb(boardVideo);
|
|
60900
60954
|
});
|
|
60901
|
-
}, prepareVideo = (file2,
|
|
60955
|
+
}, prepareVideo = (file2, boardId, baseUrl) => {
|
|
60902
60956
|
return new Promise((resolve2, reject) => {
|
|
60903
60957
|
const video = document.createElement("video");
|
|
60904
60958
|
video.src = URL.createObjectURL(file2);
|
|
60905
60959
|
video.onloadedmetadata = () => {
|
|
60906
60960
|
video.onseeked = () => {
|
|
60907
60961
|
video.onseeked = null;
|
|
60908
|
-
prepareImage(captureFrame(0.1, video)?.src,
|
|
60909
|
-
uploadMediaToStorage(file2,
|
|
60962
|
+
prepareImage(captureFrame(0.1, video)?.src, boardId, baseUrl).then((imageData) => {
|
|
60963
|
+
uploadMediaToStorage(file2, boardId, "video", baseUrl).then((url2) => {
|
|
60910
60964
|
resolve2({
|
|
60911
60965
|
url: url2,
|
|
60912
60966
|
previewUrl: imageData.storageLink
|
|
@@ -66894,8 +66948,8 @@ var init_Card = __esm(() => {
|
|
|
66894
66948
|
async createImages() {
|
|
66895
66949
|
this.face = conf.documentFactory.createElement("img");
|
|
66896
66950
|
this.backside = conf.documentFactory.createElement("img");
|
|
66897
|
-
this.face.src = await getMediaSignedUrl(this.faceUrl
|
|
66898
|
-
this.backside.src = await getMediaSignedUrl(this.backsideUrl
|
|
66951
|
+
this.face.src = await getMediaSignedUrl(this.faceUrl) || "";
|
|
66952
|
+
this.backside.src = await getMediaSignedUrl(this.backsideUrl) || "";
|
|
66899
66953
|
this.face.onload = () => {
|
|
66900
66954
|
this.subject.publish(this);
|
|
66901
66955
|
};
|
|
@@ -67596,7 +67650,7 @@ var init_Dice = __esm(() => {
|
|
|
67596
67650
|
this.renderValues[index2] = value;
|
|
67597
67651
|
} else {
|
|
67598
67652
|
const image2 = conf.documentFactory.createElement("img");
|
|
67599
|
-
image2.src = await getMediaSignedUrl(value
|
|
67653
|
+
image2.src = await getMediaSignedUrl(value) || "";
|
|
67600
67654
|
this.renderValues[index2] = image2;
|
|
67601
67655
|
image2.onload = () => {
|
|
67602
67656
|
this.subject.publish(this);
|
|
@@ -68051,7 +68105,7 @@ var init_Screen = __esm(() => {
|
|
|
68051
68105
|
this.backgroundUrl = url2 || "";
|
|
68052
68106
|
if (url2) {
|
|
68053
68107
|
this.backgroundImage = conf.documentFactory.createElement("img");
|
|
68054
|
-
this.backgroundImage.src = await getMediaSignedUrl(url2
|
|
68108
|
+
this.backgroundImage.src = await getMediaSignedUrl(url2) || "";
|
|
68055
68109
|
this.applyBackgroundColor("none");
|
|
68056
68110
|
this.backgroundImage.onload = () => {
|
|
68057
68111
|
this.subject.publish(this);
|
|
@@ -69913,7 +69967,7 @@ var init_Image = __esm(() => {
|
|
|
69913
69967
|
}
|
|
69914
69968
|
async setStorageLink(link2) {
|
|
69915
69969
|
this.storageLink = link2;
|
|
69916
|
-
this.signedUrl = await getMediaSignedUrl(link2
|
|
69970
|
+
this.signedUrl = await getMediaSignedUrl(link2) || "";
|
|
69917
69971
|
if (!this.signedUrl) {
|
|
69918
69972
|
const canvas = conf.documentFactory.createElement("canvas");
|
|
69919
69973
|
canvas.width = 100;
|
|
@@ -70334,7 +70388,7 @@ function handleAudioGenerate(response, board) {
|
|
|
70334
70388
|
}
|
|
70335
70389
|
function handleImageGenerate(response, board) {
|
|
70336
70390
|
if (response.status === "completed" && response.base64) {
|
|
70337
|
-
prepareImage(response.base64,
|
|
70391
|
+
prepareImage(response.base64, board.getBoardId()).then((imageData) => {
|
|
70338
70392
|
const placeholderId = board.aiImagePlaceholder?.getId();
|
|
70339
70393
|
if (placeholderId) {
|
|
70340
70394
|
const placeholderNode = board.items.getById(placeholderId);
|