lucid-extension-sdk 0.0.33 → 0.0.36
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/package.json +1 -1
- package/sdk/commandtypes.d.ts +28 -0
- package/sdk/commandtypes.js +1 -0
- package/sdk/core/base64.d.ts +1 -0
- package/sdk/core/base64.js +38 -1
- package/sdk/core/unfurl/unfurlcallbacks.d.ts +22 -0
- package/sdk/core/unfurl/unfurlcallbacks.js +9 -0
- package/sdk/core/unfurl/unfurldetails.d.ts +67 -0
- package/sdk/core/unfurl/unfurldetails.js +42 -0
- package/sdk/core/unfurl/unfurliframe.d.ts +37 -0
- package/sdk/core/unfurl/unfurliframe.js +36 -0
- package/sdk/core/unfurl/unfurlthumbnail.d.ts +34 -0
- package/sdk/core/unfurl/unfurlthumbnail.js +30 -0
- package/sdk/document/blockclasses/linkunfurlblockproxy.js +2 -2
- package/sdk/editorclient.d.ts +18 -0
- package/sdk/editorclient.js +51 -0
- package/sdk/index.d.ts +1 -0
- package/sdk/index.js +1 -0
- package/sdk/message/registerunfurlmessage.d.ts +28 -0
- package/sdk/message/registerunfurlmessage.js +30 -0
package/package.json
CHANGED
package/sdk/commandtypes.d.ts
CHANGED
|
@@ -31,6 +31,7 @@ export declare const enum CommandName {
|
|
|
31
31
|
CreateDataSource = "cds",
|
|
32
32
|
CreateLine = "cl",
|
|
33
33
|
CreatePage = "cp",
|
|
34
|
+
CreateUserImage = "cui",
|
|
34
35
|
DataAction = "da",
|
|
35
36
|
DataItemExists = "die",
|
|
36
37
|
DeleteItem = "di",
|
|
@@ -73,6 +74,7 @@ export declare const enum CommandName {
|
|
|
73
74
|
OffsetItems = "oi",
|
|
74
75
|
PatchDataItems = "pdi",
|
|
75
76
|
RegisterPanel = "rp",
|
|
77
|
+
RegisterUnfurl = "ru",
|
|
76
78
|
ReloadExtension = "r",
|
|
77
79
|
SendOAuthRequest = "oauth",
|
|
78
80
|
SendUIMessage = "suim",
|
|
@@ -154,6 +156,10 @@ export declare type CommandArgs = {
|
|
|
154
156
|
query: CreatePageQuery;
|
|
155
157
|
result: CreatePageResult;
|
|
156
158
|
};
|
|
159
|
+
[CommandName.CreateUserImage]: {
|
|
160
|
+
query: CreateUserImageQuery;
|
|
161
|
+
result: CreateUserImageResult;
|
|
162
|
+
};
|
|
157
163
|
[CommandName.DataAction]: {
|
|
158
164
|
query: DataActionQuery;
|
|
159
165
|
result: DataActionResult;
|
|
@@ -322,6 +328,10 @@ export declare type CommandArgs = {
|
|
|
322
328
|
query: RegisterPanelQuery;
|
|
323
329
|
result: RegisterPanelResult;
|
|
324
330
|
};
|
|
331
|
+
[CommandName.RegisterUnfurl]: {
|
|
332
|
+
query: RegisterUnfurlQuery;
|
|
333
|
+
result: RegisterUnfurlResult;
|
|
334
|
+
};
|
|
325
335
|
[CommandName.ReloadExtension]: {
|
|
326
336
|
query: ReloadExtensionQuery;
|
|
327
337
|
result: ReloadExtensionResult;
|
|
@@ -531,6 +541,17 @@ export declare type CreateLineQuery = {
|
|
|
531
541
|
export declare type CreateLineResult = string;
|
|
532
542
|
export declare type CreatePageQuery = void;
|
|
533
543
|
export declare type CreatePageResult = string;
|
|
544
|
+
export declare type CreateUserImageQuery = {
|
|
545
|
+
/** media type */
|
|
546
|
+
't': string;
|
|
547
|
+
/** base64-encoded image data */
|
|
548
|
+
'd': string;
|
|
549
|
+
};
|
|
550
|
+
export declare type RawCreateUserImageResult = {
|
|
551
|
+
/** The resulting image URL */
|
|
552
|
+
'u': string;
|
|
553
|
+
};
|
|
554
|
+
export declare type CreateUserImageResult = Promise<RawCreateUserImageResult>;
|
|
534
555
|
export declare type DataActionQuery = {
|
|
535
556
|
/** Flow Name */
|
|
536
557
|
'fn': string;
|
|
@@ -775,6 +796,13 @@ export declare type RegisterPanelQuery = {
|
|
|
775
796
|
'i': string;
|
|
776
797
|
};
|
|
777
798
|
export declare type RegisterPanelResult = undefined;
|
|
799
|
+
export declare type RegisterUnfurlQuery = {
|
|
800
|
+
/** Domain to unfurl, e.g. www.google.com */
|
|
801
|
+
'd': string;
|
|
802
|
+
/** Action to call to configure the unfurl */
|
|
803
|
+
'a': string;
|
|
804
|
+
};
|
|
805
|
+
export declare type RegisterUnfurlResult = boolean;
|
|
778
806
|
export declare type ReloadExtensionQuery = void;
|
|
779
807
|
export declare type ReloadExtensionResult = undefined;
|
|
780
808
|
export declare type SendOAuthRequestQuery = SendXHRQuery & {
|
package/sdk/commandtypes.js
CHANGED
|
@@ -59,6 +59,7 @@ exports.commandTitles = new Map([
|
|
|
59
59
|
["oi" /* OffsetItems */, 'OffsetItems'],
|
|
60
60
|
["pdi" /* PatchDataItems */, 'PatchDataItems'],
|
|
61
61
|
["rp" /* RegisterPanel */, 'RegisterPanel'],
|
|
62
|
+
["ru" /* RegisterUnfurl */, 'RegisterUnfurl'],
|
|
62
63
|
["r" /* ReloadExtension */, 'ReloadExtension'],
|
|
63
64
|
["oauth" /* SendOAuthRequest */, 'SendOAuthRequest'],
|
|
64
65
|
["suim" /* SendUIMessage */, 'SendUIMessage'],
|
package/sdk/core/base64.d.ts
CHANGED
package/sdk/core/base64.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeBase64 = void 0;
|
|
3
|
+
exports.encodeBase64 = exports.decodeBase64 = void 0;
|
|
4
4
|
const alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
5
5
|
//This gives a ~8x speedup vs. using alphabet.indexOf() in the main decode loop.
|
|
6
6
|
const charCodeToEncodedInt = [];
|
|
@@ -43,3 +43,40 @@ function decodeBase64(base64String) {
|
|
|
43
43
|
return output;
|
|
44
44
|
}
|
|
45
45
|
exports.decodeBase64 = decodeBase64;
|
|
46
|
+
function encodeBase64(byteArray) {
|
|
47
|
+
// 3 bytes of input become 4 chars of output
|
|
48
|
+
// i.e. every 6 bits of input becomes 1 char of output
|
|
49
|
+
const fullByteChunkCount = Math.floor(byteArray.length / 3);
|
|
50
|
+
const outputLength = Math.ceil(byteArray.length / 3) * 4;
|
|
51
|
+
const output = new Array(outputLength);
|
|
52
|
+
let inputIndex = 0;
|
|
53
|
+
let outputIndex = 0;
|
|
54
|
+
for (let byteChunkIndex = 0; byteChunkIndex < fullByteChunkCount; byteChunkIndex++) {
|
|
55
|
+
const byte1 = byteArray[inputIndex++];
|
|
56
|
+
const byte2 = byteArray[inputIndex++];
|
|
57
|
+
const byte3 = byteArray[inputIndex++];
|
|
58
|
+
const enc1 = byte1 >> 2; // first 6 bits of byte1
|
|
59
|
+
const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4); // last 2 bits of byte1 and first 4 bits of byte2
|
|
60
|
+
const enc3 = ((byte2 & 15) << 2) | (byte3 >> 6); // last 4 bits of byte2 and first 2 bits of byte3
|
|
61
|
+
const enc4 = byte3 & 63; // last 6 bits of byte3
|
|
62
|
+
output[outputIndex++] = alphabet[enc1];
|
|
63
|
+
output[outputIndex++] = alphabet[enc2];
|
|
64
|
+
output[outputIndex++] = alphabet[enc3];
|
|
65
|
+
output[outputIndex++] = alphabet[enc4];
|
|
66
|
+
}
|
|
67
|
+
// handle remainder, i.e. trailing one or two bytes
|
|
68
|
+
if (inputIndex < byteArray.length) {
|
|
69
|
+
const byte1 = byteArray[inputIndex++];
|
|
70
|
+
const hasSecondByte = inputIndex < byteArray.length;
|
|
71
|
+
const byte2 = hasSecondByte ? byteArray[inputIndex++] : 0;
|
|
72
|
+
const enc1 = byte1 >> 2; // first 6 bits of byte1
|
|
73
|
+
const enc2 = ((byte1 & 3) << 4) | (byte2 >> 4); // last 2 bits of byte1 and first 4 bits of byte2
|
|
74
|
+
const enc3 = hasSecondByte ? (byte2 & 15) << 2 : 64; // last 4 bits of byte2
|
|
75
|
+
output[outputIndex++] = alphabet[enc1];
|
|
76
|
+
output[outputIndex++] = alphabet[enc2];
|
|
77
|
+
output[outputIndex++] = alphabet[enc3];
|
|
78
|
+
output[outputIndex++] = '=';
|
|
79
|
+
}
|
|
80
|
+
return output.join('');
|
|
81
|
+
}
|
|
82
|
+
exports.encodeBase64 = encodeBase64;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { UnfurlDetails } from './unfurldetails';
|
|
2
|
+
export declare enum UnfurlCallbackType {
|
|
3
|
+
Unfurl = "u",
|
|
4
|
+
AfterUnfurl = "a",
|
|
5
|
+
Refresh = "r"
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The callbacks that handle unfurls and refreshing.
|
|
9
|
+
* @ignore
|
|
10
|
+
*/
|
|
11
|
+
export interface UnfurlCallbacks {
|
|
12
|
+
/**
|
|
13
|
+
* Callback upon initial unfurl.
|
|
14
|
+
*
|
|
15
|
+
* This should return with minimal delay to get a partial unfurl shown to the user as quick as possible.
|
|
16
|
+
* Final configuration of the unfurl should be done in afterUnfurlCallback.
|
|
17
|
+
* @param url The url to unfurl
|
|
18
|
+
* @return The details of the unfurl or undefined
|
|
19
|
+
* @ignore
|
|
20
|
+
*/
|
|
21
|
+
unfurlCallback: (url: string) => Promise<UnfurlDetails | undefined>;
|
|
22
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnfurlCallbackType = void 0;
|
|
4
|
+
var UnfurlCallbackType;
|
|
5
|
+
(function (UnfurlCallbackType) {
|
|
6
|
+
UnfurlCallbackType["Unfurl"] = "u";
|
|
7
|
+
UnfurlCallbackType["AfterUnfurl"] = "a";
|
|
8
|
+
UnfurlCallbackType["Refresh"] = "r";
|
|
9
|
+
})(UnfurlCallbackType = exports.UnfurlCallbackType || (exports.UnfurlCallbackType = {}));
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { isString } from '../checks';
|
|
2
|
+
import { SerializedUnfurlIframe, UnfurlIframe } from './unfurliframe';
|
|
3
|
+
import { SerializedUnfurlThumbnail, UnfurlThumbnail } from './unfurlthumbnail';
|
|
4
|
+
/**
|
|
5
|
+
* A definition of the details required to show an unfurl block in the editor.
|
|
6
|
+
*/
|
|
7
|
+
export interface UnfurlDetails {
|
|
8
|
+
/**
|
|
9
|
+
* The name of the extension attributed to the unfurl. This is a user facing name that is used to attribute the
|
|
10
|
+
* unfurl to a specific third party.
|
|
11
|
+
*/
|
|
12
|
+
providerName: string;
|
|
13
|
+
/**
|
|
14
|
+
* The favicon of the provider of this unfurl.
|
|
15
|
+
*/
|
|
16
|
+
providerFaviconUrl: string;
|
|
17
|
+
/**
|
|
18
|
+
* The title associated with the link being unfurled. For example, the document or web page title.
|
|
19
|
+
*/
|
|
20
|
+
unfurlTitle?: string;
|
|
21
|
+
/**
|
|
22
|
+
* If the unfurl supports an expandable iframe, this configuration defines its properties.
|
|
23
|
+
*/
|
|
24
|
+
iframe?: UnfurlIframe;
|
|
25
|
+
/**
|
|
26
|
+
* If the unfurl contains one or more images, this configuration defines those properties.
|
|
27
|
+
*/
|
|
28
|
+
thumbnails?: UnfurlThumbnail[];
|
|
29
|
+
/**
|
|
30
|
+
* The url to show if there are no thumbnails.
|
|
31
|
+
*
|
|
32
|
+
* This can be useful to show an initial image while using other mechanisms to add all thumbnails after the unfurl is created.
|
|
33
|
+
*/
|
|
34
|
+
previewImageUrl?: string;
|
|
35
|
+
}
|
|
36
|
+
/** @ignore */
|
|
37
|
+
export interface SerializedUnfurlDetails {
|
|
38
|
+
'ProviderName': string;
|
|
39
|
+
'ProviderFaviconUrl': string;
|
|
40
|
+
'UnfurlTitle'?: string;
|
|
41
|
+
'Iframe'?: SerializedUnfurlIframe;
|
|
42
|
+
'Thumbnails'?: SerializedUnfurlThumbnail[];
|
|
43
|
+
'PreviewImageUrl'?: string;
|
|
44
|
+
}
|
|
45
|
+
/** @ignore */
|
|
46
|
+
export declare const isValidUnfurlDetails: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
|
|
47
|
+
ProviderName: typeof isString;
|
|
48
|
+
ProviderFaviconUrl: typeof isString;
|
|
49
|
+
UnfurlTitle: (x: unknown) => x is string | undefined;
|
|
50
|
+
Iframe: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
|
|
51
|
+
IframeUrl: typeof isString;
|
|
52
|
+
Size: (x: unknown) => x is import("./unfurliframe").UnfurlIframeSize.Standard | undefined;
|
|
53
|
+
}> | undefined;
|
|
54
|
+
Thumbnails: (x: unknown) => x is import("../guards").DestructureGuardedTypeObj<{
|
|
55
|
+
url: typeof isString;
|
|
56
|
+
width: (x: unknown) => x is number | null | undefined;
|
|
57
|
+
/**
|
|
58
|
+
* The title associated with the link being unfurled. For example, the document or web page title.
|
|
59
|
+
*/
|
|
60
|
+
height: (x: unknown) => x is number | null | undefined;
|
|
61
|
+
}>[] | undefined;
|
|
62
|
+
PreviewImageUrl: (x: unknown) => x is string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
/** @ignore */
|
|
65
|
+
export declare function deserializeUnfurlDetails(raw: SerializedUnfurlDetails): UnfurlDetails;
|
|
66
|
+
/** @ignore */
|
|
67
|
+
export declare function serializeUnfurlDetails(concrete: UnfurlDetails): SerializedUnfurlDetails;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeUnfurlDetails = exports.deserializeUnfurlDetails = exports.isValidUnfurlDetails = void 0;
|
|
4
|
+
const checks_1 = require("../checks");
|
|
5
|
+
const validators_1 = require("../validators/validators");
|
|
6
|
+
const unfurliframe_1 = require("./unfurliframe");
|
|
7
|
+
const unfurlthumbnail_1 = require("./unfurlthumbnail");
|
|
8
|
+
/** @ignore */
|
|
9
|
+
exports.isValidUnfurlDetails = (0, validators_1.objectValidator)({
|
|
10
|
+
'ProviderName': checks_1.isString,
|
|
11
|
+
'ProviderFaviconUrl': checks_1.isString,
|
|
12
|
+
'UnfurlTitle': (0, validators_1.option)(checks_1.isString),
|
|
13
|
+
'Iframe': (0, validators_1.option)(unfurliframe_1.isValidUnfurlIframe),
|
|
14
|
+
'Thumbnails': (0, validators_1.option)((0, validators_1.arrayValidator)(unfurlthumbnail_1.isValidUnfurlThumbnail)),
|
|
15
|
+
'PreviewImageUrl': (0, validators_1.option)(checks_1.isString),
|
|
16
|
+
});
|
|
17
|
+
/** @ignore */
|
|
18
|
+
function deserializeUnfurlDetails(raw) {
|
|
19
|
+
var _a;
|
|
20
|
+
return {
|
|
21
|
+
providerName: raw['ProviderName'],
|
|
22
|
+
providerFaviconUrl: raw['ProviderFaviconUrl'],
|
|
23
|
+
unfurlTitle: raw['UnfurlTitle'],
|
|
24
|
+
iframe: raw['Iframe'] && (0, unfurliframe_1.deserializeUnfurlIframe)(raw['Iframe']),
|
|
25
|
+
thumbnails: (_a = raw['Thumbnails']) === null || _a === void 0 ? void 0 : _a.map((raw) => (0, unfurlthumbnail_1.deserializeUnfurlThumbnail)(raw)),
|
|
26
|
+
previewImageUrl: raw['PreviewImageUrl'],
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
exports.deserializeUnfurlDetails = deserializeUnfurlDetails;
|
|
30
|
+
/** @ignore */
|
|
31
|
+
function serializeUnfurlDetails(concrete) {
|
|
32
|
+
var _a;
|
|
33
|
+
return {
|
|
34
|
+
'ProviderName': concrete.providerName,
|
|
35
|
+
'ProviderFaviconUrl': concrete.providerFaviconUrl,
|
|
36
|
+
'UnfurlTitle': concrete.unfurlTitle,
|
|
37
|
+
'Iframe': concrete.iframe && (0, unfurliframe_1.serializeUnfurlIframe)(concrete.iframe),
|
|
38
|
+
'Thumbnails': (_a = concrete.thumbnails) === null || _a === void 0 ? void 0 : _a.map((raw) => (0, unfurlthumbnail_1.serializeUnfurlThumbnail)(raw)),
|
|
39
|
+
'PreviewImageUrl': concrete.previewImageUrl,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
exports.serializeUnfurlDetails = serializeUnfurlDetails;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isString } from '../checks';
|
|
2
|
+
/**
|
|
3
|
+
* An enumeration of of the supported unfurl Iframe sizes.
|
|
4
|
+
*/
|
|
5
|
+
export declare enum UnfurlIframeSize {
|
|
6
|
+
/**
|
|
7
|
+
* The standard iframe size.
|
|
8
|
+
*/
|
|
9
|
+
Standard = "standard"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* A definition of the properties needed to expand an iframe for an unfurl
|
|
13
|
+
*/
|
|
14
|
+
export interface UnfurlIframe {
|
|
15
|
+
/**
|
|
16
|
+
* The iframe url
|
|
17
|
+
*/
|
|
18
|
+
iframeUrl: string;
|
|
19
|
+
/**
|
|
20
|
+
* The size of the iframe requested
|
|
21
|
+
*/
|
|
22
|
+
size?: UnfurlIframeSize;
|
|
23
|
+
}
|
|
24
|
+
/** @ignore */
|
|
25
|
+
export interface SerializedUnfurlIframe {
|
|
26
|
+
'IframeUrl': string;
|
|
27
|
+
'Size'?: UnfurlIframeSize;
|
|
28
|
+
}
|
|
29
|
+
/** @ignore */
|
|
30
|
+
export declare const isValidUnfurlIframe: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
|
|
31
|
+
IframeUrl: typeof isString;
|
|
32
|
+
Size: (x: unknown) => x is UnfurlIframeSize.Standard | undefined;
|
|
33
|
+
}>;
|
|
34
|
+
/** @ignore */
|
|
35
|
+
export declare function deserializeUnfurlIframe(raw: SerializedUnfurlIframe): UnfurlIframe;
|
|
36
|
+
/** @ignore */
|
|
37
|
+
export declare function serializeUnfurlIframe(concrete: UnfurlIframe): SerializedUnfurlIframe;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeUnfurlIframe = exports.deserializeUnfurlIframe = exports.isValidUnfurlIframe = exports.UnfurlIframeSize = void 0;
|
|
4
|
+
const checks_1 = require("../checks");
|
|
5
|
+
const validators_1 = require("../validators/validators");
|
|
6
|
+
/**
|
|
7
|
+
* An enumeration of of the supported unfurl Iframe sizes.
|
|
8
|
+
*/
|
|
9
|
+
var UnfurlIframeSize;
|
|
10
|
+
(function (UnfurlIframeSize) {
|
|
11
|
+
/**
|
|
12
|
+
* The standard iframe size.
|
|
13
|
+
*/
|
|
14
|
+
UnfurlIframeSize["Standard"] = "standard";
|
|
15
|
+
})(UnfurlIframeSize = exports.UnfurlIframeSize || (exports.UnfurlIframeSize = {}));
|
|
16
|
+
/** @ignore */
|
|
17
|
+
exports.isValidUnfurlIframe = (0, validators_1.objectValidator)({
|
|
18
|
+
'IframeUrl': checks_1.isString,
|
|
19
|
+
'Size': (0, validators_1.option)((0, validators_1.stringEnumValidator)(UnfurlIframeSize)),
|
|
20
|
+
});
|
|
21
|
+
/** @ignore */
|
|
22
|
+
function deserializeUnfurlIframe(raw) {
|
|
23
|
+
return {
|
|
24
|
+
iframeUrl: raw['IframeUrl'],
|
|
25
|
+
size: raw['Size'],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
exports.deserializeUnfurlIframe = deserializeUnfurlIframe;
|
|
29
|
+
/** @ignore */
|
|
30
|
+
function serializeUnfurlIframe(concrete) {
|
|
31
|
+
return {
|
|
32
|
+
'IframeUrl': concrete.iframeUrl,
|
|
33
|
+
'Size': concrete.size,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
exports.serializeUnfurlIframe = serializeUnfurlIframe;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { isString } from '../checks';
|
|
2
|
+
/**
|
|
3
|
+
* A definition of a single unfurl thumbnail
|
|
4
|
+
*/
|
|
5
|
+
export interface UnfurlThumbnail {
|
|
6
|
+
/**
|
|
7
|
+
* The URL to fetch the image from
|
|
8
|
+
*/
|
|
9
|
+
url: string;
|
|
10
|
+
/**
|
|
11
|
+
* The width of the image. This is not the height it will be displayed at, but rather the width the image actually is.
|
|
12
|
+
*/
|
|
13
|
+
width?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The height of the image. This is not the height it will be displayed at, but rather the height the image actually is.
|
|
16
|
+
*/
|
|
17
|
+
height?: number;
|
|
18
|
+
}
|
|
19
|
+
/** @ignore */
|
|
20
|
+
export interface SerializedUnfurlThumbnail {
|
|
21
|
+
'url': string;
|
|
22
|
+
'width'?: number | null;
|
|
23
|
+
'height'?: number | null;
|
|
24
|
+
}
|
|
25
|
+
/** @ignore */
|
|
26
|
+
export declare const isValidUnfurlThumbnail: (subject: unknown) => subject is import("../guards").DestructureGuardedTypeObj<{
|
|
27
|
+
url: typeof isString;
|
|
28
|
+
width: (x: unknown) => x is number | null | undefined;
|
|
29
|
+
height: (x: unknown) => x is number | null | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
/** @ignore */
|
|
32
|
+
export declare function deserializeUnfurlThumbnail(raw: SerializedUnfurlThumbnail): UnfurlThumbnail;
|
|
33
|
+
/** @ignore */
|
|
34
|
+
export declare function serializeUnfurlThumbnail(concrete: UnfurlThumbnail): SerializedUnfurlThumbnail;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeUnfurlThumbnail = exports.deserializeUnfurlThumbnail = exports.isValidUnfurlThumbnail = void 0;
|
|
4
|
+
const checks_1 = require("../checks");
|
|
5
|
+
const validators_1 = require("../validators/validators");
|
|
6
|
+
/** @ignore */
|
|
7
|
+
exports.isValidUnfurlThumbnail = (0, validators_1.objectValidator)({
|
|
8
|
+
'url': checks_1.isString,
|
|
9
|
+
'width': (0, validators_1.nullableOption)(checks_1.isNumber),
|
|
10
|
+
'height': (0, validators_1.nullableOption)(checks_1.isNumber),
|
|
11
|
+
});
|
|
12
|
+
/** @ignore */
|
|
13
|
+
function deserializeUnfurlThumbnail(raw) {
|
|
14
|
+
var _a, _b;
|
|
15
|
+
return {
|
|
16
|
+
url: raw['url'],
|
|
17
|
+
width: (_a = raw['width']) !== null && _a !== void 0 ? _a : undefined,
|
|
18
|
+
height: (_b = raw['height']) !== null && _b !== void 0 ? _b : undefined,
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.deserializeUnfurlThumbnail = deserializeUnfurlThumbnail;
|
|
22
|
+
/** @ignore */
|
|
23
|
+
function serializeUnfurlThumbnail(concrete) {
|
|
24
|
+
return {
|
|
25
|
+
'url': concrete.url,
|
|
26
|
+
'width': concrete.width,
|
|
27
|
+
'height': concrete.height,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.serializeUnfurlThumbnail = serializeUnfurlThumbnail;
|
|
@@ -39,7 +39,7 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
|
|
|
39
39
|
* @ignore
|
|
40
40
|
*/
|
|
41
41
|
setPreviewThumbnailUrl(thumbnailUrl) {
|
|
42
|
-
|
|
42
|
+
this.properties.set('LinkUnfurlThumbnailUrl', thumbnailUrl);
|
|
43
43
|
}
|
|
44
44
|
/**
|
|
45
45
|
* Sets additional thumbnails on the block
|
|
@@ -47,7 +47,7 @@ class ExperimentalLinkUnfurlBlockProxy extends blockproxy_1.BlockProxy {
|
|
|
47
47
|
* @ignore
|
|
48
48
|
*/
|
|
49
49
|
setThumbnailUrls(thumbnails) {
|
|
50
|
-
|
|
50
|
+
this.properties.set('LinkUnfurlThumbnailUrls', thumbnails);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
53
|
exports.ExperimentalLinkUnfurlBlockProxy = ExperimentalLinkUnfurlBlockProxy;
|
package/sdk/editorclient.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CommandArgs, CommandName, UnionToIntersection } from './commandtypes';
|
|
2
2
|
import { JsonSerializable } from './core/jsonserializable';
|
|
3
|
+
import { UnfurlCallbacks } from './core/unfurl/unfurlcallbacks';
|
|
3
4
|
import { BlockDefinition } from './document/blockdefinition';
|
|
4
5
|
import { BlockProxy } from './document/blockproxy';
|
|
5
6
|
import { ElementProxy } from './document/elementproxy';
|
|
@@ -65,6 +66,16 @@ export declare class EditorClient {
|
|
|
65
66
|
* @param base64 If true, base64 decode the data before downloading it
|
|
66
67
|
*/
|
|
67
68
|
download(filename: string, data: string, mime: string, base64: boolean): void;
|
|
69
|
+
/**
|
|
70
|
+
* Upload an image and return a URL that can be used for displaying that image on the canvas. Note: the URL is
|
|
71
|
+
* public - anyone with the URL can access the image.
|
|
72
|
+
* @param data The binary image contents, or a base64-encoded string
|
|
73
|
+
* @param mediaType The media type, e.g. 'image/png'
|
|
74
|
+
* @returns A promise that resolves with the URL of the created image.
|
|
75
|
+
*
|
|
76
|
+
* @ignore
|
|
77
|
+
*/
|
|
78
|
+
experimentalCreateUserImage(mediaType: string, data: Uint8Array | string): Promise<string>;
|
|
68
79
|
/**
|
|
69
80
|
*
|
|
70
81
|
* @param flowName
|
|
@@ -106,6 +117,13 @@ export declare class EditorClient {
|
|
|
106
117
|
* @param callback Function to execute when this action is invoked
|
|
107
118
|
*/
|
|
108
119
|
registerFileUploadAction(name: string, callback: (files: FileUploadData[]) => void): void;
|
|
120
|
+
/**
|
|
121
|
+
* @ignore
|
|
122
|
+
* Registers an handler for link unfurling.
|
|
123
|
+
* @param domain The domain
|
|
124
|
+
* @param callbacks The callbacks to call when a link matching the domain is pasted.
|
|
125
|
+
*/
|
|
126
|
+
experimentalRegisterUnfurlHandler(domain: string, callbacks: UnfurlCallbacks): void;
|
|
109
127
|
/**
|
|
110
128
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
111
129
|
* @param name name of the action to unregister
|
package/sdk/editorclient.js
CHANGED
|
@@ -3,6 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EditorClient = void 0;
|
|
4
4
|
const commandtypes_1 = require("./commandtypes");
|
|
5
5
|
const base64_1 = require("./core/base64");
|
|
6
|
+
const checks_1 = require("./core/checks");
|
|
7
|
+
const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
|
|
8
|
+
const unfurldetails_1 = require("./core/unfurl/unfurldetails");
|
|
6
9
|
const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
|
|
7
10
|
const blockproxy_1 = require("./document/blockproxy");
|
|
8
11
|
const documentproxy_1 = require("./document/documentproxy");
|
|
@@ -10,6 +13,7 @@ const elementproxy_1 = require("./document/elementproxy");
|
|
|
10
13
|
const groupproxy_1 = require("./document/groupproxy");
|
|
11
14
|
const lineproxy_1 = require("./document/lineproxy");
|
|
12
15
|
const pageproxy_1 = require("./document/pageproxy");
|
|
16
|
+
const registerunfurlmessage_1 = require("./message/registerunfurlmessage");
|
|
13
17
|
class EditorClient {
|
|
14
18
|
constructor() {
|
|
15
19
|
this.nextId = 0;
|
|
@@ -49,6 +53,22 @@ class EditorClient {
|
|
|
49
53
|
'b64': base64,
|
|
50
54
|
});
|
|
51
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* Upload an image and return a URL that can be used for displaying that image on the canvas. Note: the URL is
|
|
58
|
+
* public - anyone with the URL can access the image.
|
|
59
|
+
* @param data The binary image contents, or a base64-encoded string
|
|
60
|
+
* @param mediaType The media type, e.g. 'image/png'
|
|
61
|
+
* @returns A promise that resolves with the URL of the created image.
|
|
62
|
+
*
|
|
63
|
+
* @ignore
|
|
64
|
+
*/
|
|
65
|
+
async experimentalCreateUserImage(mediaType, data) {
|
|
66
|
+
const result = await this.sendCommand("cui" /* CreateUserImage */, {
|
|
67
|
+
't': mediaType,
|
|
68
|
+
'd': (0, checks_1.isString)(data) ? data : (0, base64_1.encodeBase64)(data),
|
|
69
|
+
});
|
|
70
|
+
return result['u'];
|
|
71
|
+
}
|
|
52
72
|
/**
|
|
53
73
|
*
|
|
54
74
|
* @param flowName
|
|
@@ -181,6 +201,37 @@ class EditorClient {
|
|
|
181
201
|
}));
|
|
182
202
|
});
|
|
183
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* @ignore
|
|
206
|
+
* Registers an handler for link unfurling.
|
|
207
|
+
* @param domain The domain
|
|
208
|
+
* @param callbacks The callbacks to call when a link matching the domain is pasted.
|
|
209
|
+
*/
|
|
210
|
+
experimentalRegisterUnfurlHandler(domain, callbacks) {
|
|
211
|
+
const action = this.getUniqueActionName();
|
|
212
|
+
this.registerAction(action, async (rawMsg) => {
|
|
213
|
+
const msg = (0, registerunfurlmessage_1.deserializeRegisterUnfurlMessage)(rawMsg);
|
|
214
|
+
switch (msg.unfurlCallbackType) {
|
|
215
|
+
case unfurlcallbacks_1.UnfurlCallbackType.Unfurl: {
|
|
216
|
+
const result = await callbacks.unfurlCallback(msg.url);
|
|
217
|
+
if (result) {
|
|
218
|
+
return (0, unfurldetails_1.serializeUnfurlDetails)(result);
|
|
219
|
+
}
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case unfurlcallbacks_1.UnfurlCallbackType.AfterUnfurl: {
|
|
223
|
+
throw new Error('UnfurlCallbackType afterUnfurl not implmeneted');
|
|
224
|
+
}
|
|
225
|
+
case unfurlcallbacks_1.UnfurlCallbackType.Refresh: {
|
|
226
|
+
throw new Error('UnfurlCallbackType refresh not implmeneted');
|
|
227
|
+
}
|
|
228
|
+
default:
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
return undefined;
|
|
232
|
+
});
|
|
233
|
+
this.sendCommand("ru" /* RegisterUnfurl */, { 'd': domain, 'a': action });
|
|
234
|
+
}
|
|
184
235
|
/**
|
|
185
236
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
186
237
|
* @param name name of the action to unregister
|
package/sdk/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export * from './core/jsonserializable';
|
|
|
4
4
|
export * from './core/offsettype';
|
|
5
5
|
export * from './core/serializeddataerror';
|
|
6
6
|
export * from './core/shapedatainheritance';
|
|
7
|
+
export * from './core/unfurl/unfurldetails';
|
|
7
8
|
export * from './data/collectionproxy';
|
|
8
9
|
export * from './data/dataerror';
|
|
9
10
|
export * from './data/dataitemproxy';
|
package/sdk/index.js
CHANGED
|
@@ -16,6 +16,7 @@ __exportStar(require("./core/jsonserializable"), exports);
|
|
|
16
16
|
__exportStar(require("./core/offsettype"), exports);
|
|
17
17
|
__exportStar(require("./core/serializeddataerror"), exports);
|
|
18
18
|
__exportStar(require("./core/shapedatainheritance"), exports);
|
|
19
|
+
__exportStar(require("./core/unfurl/unfurldetails"), exports);
|
|
19
20
|
__exportStar(require("./data/collectionproxy"), exports);
|
|
20
21
|
__exportStar(require("./data/dataerror"), exports);
|
|
21
22
|
__exportStar(require("./data/dataitemproxy"), exports);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { JsonObject } from '../../lucid-extension-sdk';
|
|
2
|
+
import { isString } from '../core/checks';
|
|
3
|
+
import { UnfurlCallbackType } from '../core/unfurl/unfurlcallbacks';
|
|
4
|
+
/** @ignore */
|
|
5
|
+
export interface RegisterUnfurlMessage {
|
|
6
|
+
/** @ignore */
|
|
7
|
+
id: string;
|
|
8
|
+
/** @ignore */
|
|
9
|
+
url: string;
|
|
10
|
+
/** @ignore */
|
|
11
|
+
unfurlCallbackType: UnfurlCallbackType;
|
|
12
|
+
}
|
|
13
|
+
/** @ignore */
|
|
14
|
+
export interface SerializedRegisterUnfurlMessage extends JsonObject {
|
|
15
|
+
'id': string;
|
|
16
|
+
'u': string;
|
|
17
|
+
't': UnfurlCallbackType;
|
|
18
|
+
}
|
|
19
|
+
/** @ignore */
|
|
20
|
+
export declare const isValidRegisterUnfurlMessage: (subject: unknown) => subject is import("../core/guards").DestructureGuardedTypeObj<{
|
|
21
|
+
id: typeof isString;
|
|
22
|
+
u: typeof isString;
|
|
23
|
+
t: (x: unknown) => x is UnfurlCallbackType;
|
|
24
|
+
}>;
|
|
25
|
+
/** @ignore */
|
|
26
|
+
export declare function deserializeRegisterUnfurlMessage(raw: SerializedRegisterUnfurlMessage): RegisterUnfurlMessage;
|
|
27
|
+
/** @ignore */
|
|
28
|
+
export declare function serializeRegisterUnfurlMessage(concrete: RegisterUnfurlMessage): SerializedRegisterUnfurlMessage;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.serializeRegisterUnfurlMessage = exports.deserializeRegisterUnfurlMessage = exports.isValidRegisterUnfurlMessage = void 0;
|
|
4
|
+
const checks_1 = require("../core/checks");
|
|
5
|
+
const unfurlcallbacks_1 = require("../core/unfurl/unfurlcallbacks");
|
|
6
|
+
const validators_1 = require("../core/validators/validators");
|
|
7
|
+
/** @ignore */
|
|
8
|
+
exports.isValidRegisterUnfurlMessage = (0, validators_1.objectValidator)({
|
|
9
|
+
'id': checks_1.isString,
|
|
10
|
+
'u': checks_1.isString,
|
|
11
|
+
't': (0, validators_1.stringEnumValidator)(unfurlcallbacks_1.UnfurlCallbackType),
|
|
12
|
+
});
|
|
13
|
+
/** @ignore */
|
|
14
|
+
function deserializeRegisterUnfurlMessage(raw) {
|
|
15
|
+
return {
|
|
16
|
+
id: raw['id'],
|
|
17
|
+
url: raw['u'],
|
|
18
|
+
unfurlCallbackType: raw['t'],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
exports.deserializeRegisterUnfurlMessage = deserializeRegisterUnfurlMessage;
|
|
22
|
+
/** @ignore */
|
|
23
|
+
function serializeRegisterUnfurlMessage(concrete) {
|
|
24
|
+
return {
|
|
25
|
+
'id': concrete.id,
|
|
26
|
+
'u': concrete.url,
|
|
27
|
+
't': concrete.unfurlCallbackType,
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
exports.serializeRegisterUnfurlMessage = serializeRegisterUnfurlMessage;
|