lucid-extension-sdk 0.0.214 → 0.0.216
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/core/checks.d.ts +4 -0
- package/core/checks.js +9 -1
- package/core/iframe/iframeutils.d.ts +14 -2
- package/core/iframe/iframeutils.js +7 -0
- package/package.json +1 -1
package/core/checks.d.ts
CHANGED
|
@@ -98,6 +98,10 @@ export declare function isArray(val: unknown): val is unknown[];
|
|
|
98
98
|
* @return Whether variable is an array of the given type.
|
|
99
99
|
*/
|
|
100
100
|
export declare function isTypedArray<T>(typeGuard: (a: unknown) => a is T): (val: unknown) => val is T[];
|
|
101
|
+
export type Tuple<T, N extends number> = N extends N ? (number extends N ? T[] : TupleOfHelper<T, N, []>) : never;
|
|
102
|
+
type TupleOfHelper<T, N extends number, R extends unknown[]> = R['length'] extends N ? R : TupleOfHelper<T, N, [T, ...R]>;
|
|
103
|
+
export declare function isExactLength<T, N extends number>(arr: T[], exactLength: N): arr is Tuple<T, N>;
|
|
104
|
+
export declare function isAtLeastLength<T, N extends number>(arr: T[], minimumLength: N): arr is [...Tuple<T, N>, ...T[]];
|
|
101
105
|
/**
|
|
102
106
|
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
103
107
|
*
|
package/core/checks.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
3
|
+
exports.isInstanceOf = exports.isLiteral = exports.isPromise = exports.isUnknown = exports.isAny = exports.isEmptyOrNullishObject = exports.isAtLeastLength = exports.isExactLength = exports.isTypedArray = exports.isArray = exports.isRecord = exports.isObject = exports.isFunction = exports.isInfinite = exports.isInt = exports.isNumber = exports.isBoolean = exports.isString = exports.isNullish = exports.isDefAndNotNull = exports.isVoid = exports.isUndefined = exports.isNull = exports.isDef = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* Returns true if the specified value is not undefined.
|
|
6
6
|
*
|
|
@@ -154,6 +154,14 @@ function isTypedArray(typeGuard) {
|
|
|
154
154
|
};
|
|
155
155
|
}
|
|
156
156
|
exports.isTypedArray = isTypedArray;
|
|
157
|
+
function isExactLength(arr, exactLength) {
|
|
158
|
+
return arr.length === exactLength;
|
|
159
|
+
}
|
|
160
|
+
exports.isExactLength = isExactLength;
|
|
161
|
+
function isAtLeastLength(arr, minimumLength) {
|
|
162
|
+
return arr.length >= minimumLength;
|
|
163
|
+
}
|
|
164
|
+
exports.isAtLeastLength = isAtLeastLength;
|
|
157
165
|
/**
|
|
158
166
|
* Returns true if the specified object is either empty or all existing keys map to a nullish value
|
|
159
167
|
*
|
|
@@ -9,11 +9,23 @@
|
|
|
9
9
|
export declare const DEFAULT_IFRAME_WIDTH: number;
|
|
10
10
|
export declare const DEFAULT_IFRAME_HEIGHT: number;
|
|
11
11
|
/** @ignore */
|
|
12
|
-
export
|
|
12
|
+
export type IframeAttributes =
|
|
13
|
+
/**
|
|
14
|
+
* This type syntax makes it so either src or srcdoc is always provided, but never both.
|
|
15
|
+
*/
|
|
16
|
+
({
|
|
13
17
|
/**
|
|
14
18
|
* The source url
|
|
15
19
|
*/
|
|
16
20
|
src: string;
|
|
21
|
+
srcdoc?: undefined;
|
|
22
|
+
} | {
|
|
23
|
+
/**
|
|
24
|
+
* The html content of the iframe if not using a source url
|
|
25
|
+
*/
|
|
26
|
+
srcdoc: string;
|
|
27
|
+
src?: undefined;
|
|
28
|
+
}) & {
|
|
17
29
|
/**
|
|
18
30
|
* The iFrame height
|
|
19
31
|
*/
|
|
@@ -26,7 +38,7 @@ export interface IframeAttributes {
|
|
|
26
38
|
* The iFrame title for accessibility
|
|
27
39
|
*/
|
|
28
40
|
title?: string;
|
|
29
|
-
}
|
|
41
|
+
};
|
|
30
42
|
/**
|
|
31
43
|
* Generate iframe HTML from the IFrameAttributes object
|
|
32
44
|
* @returns the generated iframe HTML
|
|
@@ -54,6 +54,13 @@ exports.generateIFrameHTML = generateIFrameHTML;
|
|
|
54
54
|
*/
|
|
55
55
|
function parseIFrameAttributesFromHTML(iframeHTML) {
|
|
56
56
|
var _a, _b, _c, _d, _e, _f;
|
|
57
|
+
if (!iframeHTML.startsWith('<iframe')) {
|
|
58
|
+
return {
|
|
59
|
+
srcdoc: iframeHTML,
|
|
60
|
+
height: exports.DEFAULT_IFRAME_HEIGHT,
|
|
61
|
+
width: exports.DEFAULT_IFRAME_WIDTH,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
57
64
|
const src = (_b = (_a = iframeHTML.match(iframeRegExps.src)) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : '';
|
|
58
65
|
const height = (_c = iframeHTML.match(iframeRegExps.height)) === null || _c === void 0 ? void 0 : _c[1];
|
|
59
66
|
const width = (_d = iframeHTML.match(iframeRegExps.width)) === null || _d === void 0 ? void 0 : _d[1];
|