lucid-extension-sdk 0.0.34 → 0.0.35
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 +12 -0
- package/sdk/commandtypes.js +1 -0
- 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/editorclient.d.ts +8 -0
- package/sdk/editorclient.js +34 -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
|
@@ -74,6 +74,7 @@ export declare const enum CommandName {
|
|
|
74
74
|
OffsetItems = "oi",
|
|
75
75
|
PatchDataItems = "pdi",
|
|
76
76
|
RegisterPanel = "rp",
|
|
77
|
+
RegisterUnfurl = "ru",
|
|
77
78
|
ReloadExtension = "r",
|
|
78
79
|
SendOAuthRequest = "oauth",
|
|
79
80
|
SendUIMessage = "suim",
|
|
@@ -327,6 +328,10 @@ export declare type CommandArgs = {
|
|
|
327
328
|
query: RegisterPanelQuery;
|
|
328
329
|
result: RegisterPanelResult;
|
|
329
330
|
};
|
|
331
|
+
[CommandName.RegisterUnfurl]: {
|
|
332
|
+
query: RegisterUnfurlQuery;
|
|
333
|
+
result: RegisterUnfurlResult;
|
|
334
|
+
};
|
|
330
335
|
[CommandName.ReloadExtension]: {
|
|
331
336
|
query: ReloadExtensionQuery;
|
|
332
337
|
result: ReloadExtensionResult;
|
|
@@ -791,6 +796,13 @@ export declare type RegisterPanelQuery = {
|
|
|
791
796
|
'i': string;
|
|
792
797
|
};
|
|
793
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;
|
|
794
806
|
export declare type ReloadExtensionQuery = void;
|
|
795
807
|
export declare type ReloadExtensionResult = undefined;
|
|
796
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'],
|
|
@@ -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;
|
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';
|
|
@@ -116,6 +117,13 @@ export declare class EditorClient {
|
|
|
116
117
|
* @param callback Function to execute when this action is invoked
|
|
117
118
|
*/
|
|
118
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;
|
|
119
127
|
/**
|
|
120
128
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
121
129
|
* @param name name of the action to unregister
|
package/sdk/editorclient.js
CHANGED
|
@@ -4,6 +4,8 @@ exports.EditorClient = void 0;
|
|
|
4
4
|
const commandtypes_1 = require("./commandtypes");
|
|
5
5
|
const base64_1 = require("./core/base64");
|
|
6
6
|
const checks_1 = require("./core/checks");
|
|
7
|
+
const unfurlcallbacks_1 = require("./core/unfurl/unfurlcallbacks");
|
|
8
|
+
const unfurldetails_1 = require("./core/unfurl/unfurldetails");
|
|
7
9
|
const blockproxyregistry_1 = require("./document/blockclasses/blockproxyregistry");
|
|
8
10
|
const blockproxy_1 = require("./document/blockproxy");
|
|
9
11
|
const documentproxy_1 = require("./document/documentproxy");
|
|
@@ -11,6 +13,7 @@ const elementproxy_1 = require("./document/elementproxy");
|
|
|
11
13
|
const groupproxy_1 = require("./document/groupproxy");
|
|
12
14
|
const lineproxy_1 = require("./document/lineproxy");
|
|
13
15
|
const pageproxy_1 = require("./document/pageproxy");
|
|
16
|
+
const registerunfurlmessage_1 = require("./message/registerunfurlmessage");
|
|
14
17
|
class EditorClient {
|
|
15
18
|
constructor() {
|
|
16
19
|
this.nextId = 0;
|
|
@@ -198,6 +201,37 @@ class EditorClient {
|
|
|
198
201
|
}));
|
|
199
202
|
});
|
|
200
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
|
+
}
|
|
201
235
|
/**
|
|
202
236
|
* Remove the callback for a given action. If the action is later invoked, nothing will happen.
|
|
203
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;
|