pds-dev-kit-web-test 0.2.38 → 0.2.40
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/src/sub/DynamicLayout/sectionActionTypes.d.ts +3 -0
- package/dist/src/sub/DynamicLayout/sections/CustomSection/CustomSection.js +18 -0
- package/package.json +1 -1
- package/release-note.md +3 -2
- package/dist/src/sub/GoogleFontkit/GoogleFontApplyExample.d.ts +0 -3
- package/dist/src/sub/GoogleFontkit/GoogleFontApplyExample.js +0 -93
- package/dist/src/sub/GoogleFontkit/GoogleFontsListExample.d.ts +0 -3
- package/dist/src/sub/GoogleFontkit/GoogleFontsListExample.js +0 -57
- package/dist/src/sub/GoogleFontkit/api/getGoogleFontCss.d.ts +0 -10
- package/dist/src/sub/GoogleFontkit/api/getGoogleFontCss.js +0 -53
- package/dist/src/sub/GoogleFontkit/api/getGoogleFontDefaultText.d.ts +0 -2
- package/dist/src/sub/GoogleFontkit/api/getGoogleFontDefaultText.js +0 -55
- package/dist/src/sub/GoogleFontkit/api/getGoogleWebFonts.d.ts +0 -10
- package/dist/src/sub/GoogleFontkit/api/getGoogleWebFonts.js +0 -53
- package/dist/src/sub/GoogleFontkit/constants.d.ts +0 -7
- package/dist/src/sub/GoogleFontkit/constants.js +0 -42
- package/dist/src/sub/GoogleFontkit/headless/GoogleFontItem.d.ts +0 -13
- package/dist/src/sub/GoogleFontkit/headless/GoogleFontItem.js +0 -107
- package/dist/src/sub/GoogleFontkit/headless/GoogleFontsList.d.ts +0 -17
- package/dist/src/sub/GoogleFontkit/headless/GoogleFontsList.js +0 -145
- package/dist/src/sub/GoogleFontkit/hooks/useDebounce.d.ts +0 -1
- package/dist/src/sub/GoogleFontkit/hooks/useDebounce.js +0 -14
- package/dist/src/sub/GoogleFontkit/hooks/useIntersectionObserver.d.ts +0 -6
- package/dist/src/sub/GoogleFontkit/hooks/useIntersectionObserver.js +0 -29
- package/dist/src/sub/GoogleFontkit/index.d.ts +0 -2
- package/dist/src/sub/GoogleFontkit/index.js +0 -10
- package/dist/src/sub/GoogleFontkit/types.d.ts +0 -44
- package/dist/src/sub/GoogleFontkit/types.js +0 -14
- package/dist/src/sub/GoogleFontkit/utils/applyActiveFont.d.ts +0 -5
- package/dist/src/sub/GoogleFontkit/utils/applyActiveFont.js +0 -15
- package/dist/src/sub/GoogleFontkit/utils/callGoogleFontCSSAndApply.d.ts +0 -2
- package/dist/src/sub/GoogleFontkit/utils/callGoogleFontCSSAndApply.js +0 -83
- package/dist/src/sub/GoogleFontkit/utils/createStyleSheet.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/createStyleSheet.js +0 -13
- package/dist/src/sub/GoogleFontkit/utils/extractFontStyles.d.ts +0 -1
- package/dist/src/sub/GoogleFontkit/utils/extractFontStyles.js +0 -26
- package/dist/src/sub/GoogleFontkit/utils/fillStyleSheet.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/fillStyleSheet.js +0 -17
- package/dist/src/sub/GoogleFontkit/utils/getActiveFontStylesheet.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/getActiveFontStylesheet.js +0 -16
- package/dist/src/sub/GoogleFontkit/utils/getFontId.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/getFontId.js +0 -9
- package/dist/src/sub/GoogleFontkit/utils/getMatches.d.ts +0 -1
- package/dist/src/sub/GoogleFontkit/utils/getMatches.js +0 -14
- package/dist/src/sub/GoogleFontkit/utils/isStyleSheetExists.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/isStyleSheetExists.js +0 -15
- package/dist/src/sub/GoogleFontkit/utils/parseFontVariants.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/parseFontVariants.js +0 -18
- package/dist/src/sub/GoogleFontkit/utils/setStyleSheetType.d.ts +0 -4
- package/dist/src/sub/GoogleFontkit/utils/setStyleSheetType.js +0 -18
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var getGoogleFontCss_1 = __importDefault(require("../api/getGoogleFontCss"));
|
|
43
|
-
var getGoogleWebFonts_1 = __importDefault(require("../api/getGoogleWebFonts"));
|
|
44
|
-
var createStyleSheet_1 = __importDefault(require("./createStyleSheet"));
|
|
45
|
-
var extractFontStyles_1 = __importDefault(require("./extractFontStyles"));
|
|
46
|
-
var fillStyleSheet_1 = __importDefault(require("./fillStyleSheet"));
|
|
47
|
-
var getFontId_1 = __importDefault(require("./getFontId"));
|
|
48
|
-
var isStyleSheetExists_1 = __importDefault(require("./isStyleSheetExists"));
|
|
49
|
-
var parseFontVariants_1 = __importDefault(require("./parseFontVariants"));
|
|
50
|
-
function callGoogleFontCSSAndApply(key, fontFamily) {
|
|
51
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
-
var items, font, css, fontStyles;
|
|
53
|
-
return __generator(this, function (_a) {
|
|
54
|
-
switch (_a.label) {
|
|
55
|
-
case 0: return [4 /*yield*/, (0, getGoogleWebFonts_1.default)({
|
|
56
|
-
key: key,
|
|
57
|
-
family: fontFamily
|
|
58
|
-
})];
|
|
59
|
-
case 1:
|
|
60
|
-
items = (_a.sent()).items;
|
|
61
|
-
font = items[0];
|
|
62
|
-
font.id = (0, getFontId_1.default)(font.family);
|
|
63
|
-
if ((0, isStyleSheetExists_1.default)(font.id)) {
|
|
64
|
-
return [2 /*return*/];
|
|
65
|
-
}
|
|
66
|
-
(0, createStyleSheet_1.default)(font.id, false);
|
|
67
|
-
return [4 /*yield*/, (0, getGoogleFontCss_1.default)({
|
|
68
|
-
family: "".concat(font.family).concat((0, parseFontVariants_1.default)(font.variants, {
|
|
69
|
-
prefix: ':wght@',
|
|
70
|
-
separator: ';'
|
|
71
|
-
})),
|
|
72
|
-
'font-display': 'swap'
|
|
73
|
-
})];
|
|
74
|
-
case 2:
|
|
75
|
-
css = _a.sent();
|
|
76
|
-
fontStyles = (0, extractFontStyles_1.default)(css);
|
|
77
|
-
(0, fillStyleSheet_1.default)(font.id, fontStyles[font.id]);
|
|
78
|
-
return [2 /*return*/];
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
exports.default = callGoogleFontCSSAndApply;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var constants_1 = require("../constants");
|
|
4
|
-
/**
|
|
5
|
-
* Attach a new font stylesheet to the document head using the provided content
|
|
6
|
-
*/
|
|
7
|
-
function createStylesheet(fontId, isPreview) {
|
|
8
|
-
var stylesheetNode = document.createElement('style');
|
|
9
|
-
stylesheetNode.id = fontId;
|
|
10
|
-
stylesheetNode.setAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME, isPreview.toString());
|
|
11
|
-
document.head.appendChild(stylesheetNode);
|
|
12
|
-
}
|
|
13
|
-
exports.default = createStylesheet;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function extractFontStyles(allFontStyles: string): Record<string, string>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var constants_1 = require("../constants");
|
|
7
|
-
var getFontId_1 = __importDefault(require("./getFontId"));
|
|
8
|
-
var getMatches_1 = __importDefault(require("./getMatches"));
|
|
9
|
-
function extractFontStyles(allFontStyles) {
|
|
10
|
-
// Run Regex to separate font-face rules
|
|
11
|
-
var rules = (0, getMatches_1.default)(constants_1.FONT_FACE_REGEX, allFontStyles);
|
|
12
|
-
// Assign font-face rules to fontIds
|
|
13
|
-
var fontStyles = {};
|
|
14
|
-
rules.forEach(function (rule) {
|
|
15
|
-
// Run regex to get font family
|
|
16
|
-
var fontFamily = (0, getMatches_1.default)(constants_1.FONT_FAMILY_REGEX, rule)[0];
|
|
17
|
-
var fontId = (0, getFontId_1.default)(fontFamily);
|
|
18
|
-
// Append rule to font font family's other rules
|
|
19
|
-
if (!(fontId in fontStyles)) {
|
|
20
|
-
fontStyles[fontId] = '';
|
|
21
|
-
}
|
|
22
|
-
fontStyles[fontId] += "@font-face {\n".concat(rule, "\n}\n\n");
|
|
23
|
-
});
|
|
24
|
-
return fontStyles;
|
|
25
|
-
}
|
|
26
|
-
exports.default = extractFontStyles;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Insert the provided styles in the font's <style> element (existing styles are replaced)
|
|
5
|
-
*/
|
|
6
|
-
function fillStylesheet(fontId, styles) {
|
|
7
|
-
// const stylesheetId = getStylesheetId(fontId);
|
|
8
|
-
var stylesheetNode = document.getElementById(fontId);
|
|
9
|
-
if (stylesheetNode) {
|
|
10
|
-
stylesheetNode.textContent = styles;
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
// eslint-disable-next-line no-console
|
|
14
|
-
console.error("Could not fill stylesheet: Stylesheet with ID \"".concat(fontId, "\" not found"));
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.default = fillStylesheet;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Create/find and return the apply-font stylesheet for the provided selectorSuffix
|
|
5
|
-
*/
|
|
6
|
-
function getActiveFontStylesheet(selectorSuffix) {
|
|
7
|
-
var stylesheetId = "active-font-".concat(selectorSuffix);
|
|
8
|
-
var activeFontStylesheet = document.getElementById(stylesheetId);
|
|
9
|
-
if (!activeFontStylesheet) {
|
|
10
|
-
activeFontStylesheet = document.createElement('style');
|
|
11
|
-
activeFontStylesheet.id = stylesheetId;
|
|
12
|
-
document.head.appendChild(activeFontStylesheet);
|
|
13
|
-
}
|
|
14
|
-
return activeFontStylesheet;
|
|
15
|
-
}
|
|
16
|
-
exports.default = getActiveFontStylesheet;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/**
|
|
4
|
-
* Return the fontId based on the provided font family
|
|
5
|
-
*/
|
|
6
|
-
function getFontId(fontFamily) {
|
|
7
|
-
return fontFamily.replace(/\s+/g, '-').toLowerCase();
|
|
8
|
-
}
|
|
9
|
-
exports.default = getFontId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export default function getMatches(regex: RegExp, str: string): string[];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function getMatches(regex, str) {
|
|
4
|
-
var matches = [];
|
|
5
|
-
var match;
|
|
6
|
-
do {
|
|
7
|
-
match = regex.exec(str);
|
|
8
|
-
if (match) {
|
|
9
|
-
matches.push(match[1]);
|
|
10
|
-
}
|
|
11
|
-
} while (match);
|
|
12
|
-
return matches;
|
|
13
|
-
}
|
|
14
|
-
exports.default = getMatches;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var constants_1 = require("../constants");
|
|
4
|
-
/**
|
|
5
|
-
* Check whether a font stylesheet already exists in the document head
|
|
6
|
-
*/
|
|
7
|
-
function isStylesheetExists(fontId, isPreview) {
|
|
8
|
-
var stylesheetNode = document.getElementById(fontId);
|
|
9
|
-
if (isPreview === null || isPreview === undefined) {
|
|
10
|
-
return stylesheetNode !== null;
|
|
11
|
-
}
|
|
12
|
-
return (stylesheetNode !== null &&
|
|
13
|
-
stylesheetNode.getAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME) === isPreview.toString());
|
|
14
|
-
}
|
|
15
|
-
exports.default = isStylesheetExists;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
function parseVariants(variant, _a) {
|
|
4
|
-
var prefix = _a.prefix, separator = _a.separator;
|
|
5
|
-
var initialAcc = '';
|
|
6
|
-
var fontWeights = variant.reduce(function (acc, cur) {
|
|
7
|
-
var conditionalPrefix = acc === '' ? '' : separator;
|
|
8
|
-
if (cur === 'regular') {
|
|
9
|
-
return "".concat(acc + conditionalPrefix).concat(400);
|
|
10
|
-
}
|
|
11
|
-
if (Number.isNaN(Number(cur))) {
|
|
12
|
-
return acc;
|
|
13
|
-
}
|
|
14
|
-
return "".concat(acc + conditionalPrefix).concat(cur);
|
|
15
|
-
}, initialAcc);
|
|
16
|
-
return "".concat(prefix).concat(fontWeights);
|
|
17
|
-
}
|
|
18
|
-
exports.default = parseVariants;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var constants_1 = require("../constants");
|
|
4
|
-
/**
|
|
5
|
-
* Update the value of a stylesheet's "data-is-preview" attribute
|
|
6
|
-
*/
|
|
7
|
-
function setStylesheetType(fontId, isPreview) {
|
|
8
|
-
var stylesheetId = fontId;
|
|
9
|
-
var stylesheetNode = document.getElementById(stylesheetId);
|
|
10
|
-
if (stylesheetNode) {
|
|
11
|
-
stylesheetNode.setAttribute(constants_1.PREVIEW_ATTRIBUTE_NAME, isPreview.toString());
|
|
12
|
-
}
|
|
13
|
-
else {
|
|
14
|
-
// eslint-disable-next-line no-console
|
|
15
|
-
console.error("Could not change stylesheet type: Stylesheet with ID \"".concat(stylesheetId, "\" not found"));
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.default = setStylesheetType;
|