pds-dev-kit-web-test 0.2.49 → 0.2.50

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.
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
2
  import type { DynamicLayoutProps } from './types';
3
- declare function DynamicLayout({ device, mode, isPreview, sections, scrollDownTargetSectionId, editingSectionId, navigationHandler, sectionActionHandler, onClickEditSection, programmedSectionComponents }: DynamicLayoutProps): JSX.Element;
3
+ declare function DynamicLayout({ device, mode, isPreview, sections, scrollDownTargetSectionId, editingSectionId, navigationHandler, sectionActionHandler, onClickEditSection, programmedSectionComponents, config }: DynamicLayoutProps): JSX.Element;
4
4
  export default DynamicLayout;
@@ -25,7 +25,7 @@ var EditModeSectionMatcher_1 = require("./components/EditModeSectionMatcher");
25
25
  var SectionMatcher_1 = require("./components/SectionMatcher");
26
26
  var dynamicLayoutContext_1 = require("./dynamicLayoutContext");
27
27
  function DynamicLayout(_a) {
28
- var device = _a.device, _b = _a.mode, mode = _b === void 0 ? 'NORMAL' : _b, isPreview = _a.isPreview, sections = _a.sections, scrollDownTargetSectionId = _a.scrollDownTargetSectionId, editingSectionId = _a.editingSectionId, navigationHandler = _a.navigationHandler, sectionActionHandler = _a.sectionActionHandler, onClickEditSection = _a.onClickEditSection, programmedSectionComponents = _a.programmedSectionComponents;
28
+ var device = _a.device, _b = _a.mode, mode = _b === void 0 ? 'NORMAL' : _b, isPreview = _a.isPreview, sections = _a.sections, scrollDownTargetSectionId = _a.scrollDownTargetSectionId, editingSectionId = _a.editingSectionId, navigationHandler = _a.navigationHandler, sectionActionHandler = _a.sectionActionHandler, onClickEditSection = _a.onClickEditSection, programmedSectionComponents = _a.programmedSectionComponents, config = _a.config;
29
29
  var filteredSortedSection = __spreadArray([], sections, true).filter(function (section) { return section.display; })
30
30
  .sort(function (a, b) { return a.order - b.order; });
31
31
  var iframeSection = filteredSortedSection.find(function (section) { return section.manifest.schema === 'EXP_IFRAME' && section.display; });
@@ -36,7 +36,8 @@ function DynamicLayout(_a) {
36
36
  navigationHandler: navigationHandler,
37
37
  sectionActionHandler: sectionActionHandler,
38
38
  editingSectionId: editingSectionId,
39
- programmedSectionComponents: programmedSectionComponents
39
+ programmedSectionComponents: programmedSectionComponents,
40
+ config: config
40
41
  } }, { children: [mode === 'EDIT' && onClickEditSection && ((0, jsx_runtime_1.jsx)(EditModeSectionMatcher_1.EditModeSectionMatcher, { editingSectionId: editingSectionId, scrollDownTargetSectionId: scrollDownTargetSectionId, filteredSortedSection: filteredSortedSection, onClickEditSection: onClickEditSection })), mode !== 'EDIT' &&
41
42
  (iframeSection ? ((0, jsx_runtime_1.jsx)(SectionMatcher_1.SectionMatcher, __assign({}, iframeSection), iframeSection.id)) : (filteredSortedSection.map(function (section) { return (0, jsx_runtime_1.jsx)(SectionMatcher_1.SectionMatcher, __assign({}, section), section.id); })))] })));
42
43
  }
@@ -4,5 +4,8 @@ exports.dynamicLayoutContext = void 0;
4
4
  var react_1 = require("react");
5
5
  exports.dynamicLayoutContext = (0, react_1.createContext)({
6
6
  device: 'DESKTOP',
7
- mode: 'NORMAL'
7
+ mode: 'NORMAL',
8
+ config: {
9
+ googleFontsApiKey: ''
10
+ }
8
11
  });
@@ -1,123 +1,19 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
29
- 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;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
4
  };
52
5
  Object.defineProperty(exports, "__esModule", { value: true });
53
6
  var react_1 = require("react");
54
- var getGoogleFontCss_1 = __importDefault(require("../../../../../../../GoogleFontkit/api/getGoogleFontCss"));
55
- var getGoogleWebFonts_1 = __importDefault(require("../../../../../../../GoogleFontkit/api/getGoogleWebFonts"));
56
- var createStyleSheet_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/createStyleSheet"));
57
- var extractFontStyles_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/extractFontStyles"));
58
- var fillStyleSheet_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/fillStyleSheet"));
59
- var getFontId_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/getFontId"));
60
- var isStyleSheetExists_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/isStyleSheetExists"));
61
- var parseFontVariants_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/parseFontVariants"));
7
+ var dynamicLayoutContext_1 = require("../../../../../../../DynamicLayout/dynamicLayoutContext");
8
+ var callGoogleFontCSSAndApply_1 = __importDefault(require("../../../../../../../GoogleFontkit/utils/callGoogleFontCSSAndApply"));
62
9
  function useGoogleFonts(_a) {
63
10
  var fonts = _a.fonts;
11
+ var googleFontsApiKey = (0, react_1.useContext)(dynamicLayoutContext_1.dynamicLayoutContext).config.googleFontsApiKey;
64
12
  (0, react_1.useEffect)(function () {
65
13
  fonts.forEach(function (fontFamily) {
66
14
  var parsedFontFamily = fontFamily.substring(7);
67
- var fontId = (0, getFontId_1.default)(parsedFontFamily);
68
- if ((0, isStyleSheetExists_1.default)(fontId)) {
69
- return;
70
- }
71
- (0, createStyleSheet_1.default)(fontId, false);
72
- getFonts(parsedFontFamily);
15
+ (0, callGoogleFontCSSAndApply_1.default)(googleFontsApiKey, parsedFontFamily);
73
16
  });
74
- function getCss(font) {
75
- return __awaiter(this, void 0, void 0, function () {
76
- var css, fontStyles;
77
- return __generator(this, function (_a) {
78
- switch (_a.label) {
79
- case 0: return [4 /*yield*/, (0, getGoogleFontCss_1.default)({
80
- family: "".concat(font.family).concat((0, parseFontVariants_1.default)(font.variants, {
81
- prefix: ':wght@',
82
- separator: ';'
83
- })),
84
- 'font-display': 'swap'
85
- })];
86
- case 1:
87
- css = _a.sent();
88
- fontStyles = (0, extractFontStyles_1.default)(css);
89
- (0, fillStyleSheet_1.default)(font.id, fontStyles[font.id]);
90
- return [2 /*return*/];
91
- }
92
- });
93
- });
94
- }
95
- function getFonts(fontFamily) {
96
- return __awaiter(this, void 0, void 0, function () {
97
- var items, googleFonts, e_1;
98
- return __generator(this, function (_a) {
99
- switch (_a.label) {
100
- case 0:
101
- _a.trys.push([0, 2, , 3]);
102
- return [4 /*yield*/, (0, getGoogleWebFonts_1.default)({
103
- key: 'AIzaSyDvOkXcd-jqqD1z1P-RmIBM9RzGpEXRwV0',
104
- family: fontFamily
105
- })];
106
- case 1:
107
- items = (_a.sent()).items;
108
- googleFonts = items.map(function (item) { return (__assign(__assign({}, item), { id: (0, getFontId_1.default)(item.family) })); });
109
- googleFonts.forEach(function (font) { return getCss(font); });
110
- return [3 /*break*/, 3];
111
- case 2:
112
- e_1 = _a.sent();
113
- // eslint-disable-next-line no-console
114
- console.error(e_1);
115
- return [3 /*break*/, 3];
116
- case 3: return [2 /*return*/];
117
- }
118
- });
119
- });
120
- }
121
17
  }, [fonts]);
122
18
  }
123
19
  exports.default = useGoogleFonts;
@@ -224,6 +224,9 @@ export type DynamicLayoutProps = {
224
224
  sectionActionHandler?: (action: TypeOfSectionAction) => void;
225
225
  programmedSectionComponents?: IProgrammedSectionComponents;
226
226
  width?: number;
227
+ config: {
228
+ googleFontsApiKey: string;
229
+ };
227
230
  };
228
231
  export type NavHandlerAction = {
229
232
  openNewTab: boolean;
@@ -94,22 +94,30 @@ function GoogleFontsList(_a) {
94
94
  call();
95
95
  }, [apiKey, sort]);
96
96
  (0, react_1.useEffect)(function () {
97
- var filteredFonts = fonts.filter(function (font) {
98
- var categories = filterOptions.categories, searchQuery = filterOptions.searchQuery, subsets = filterOptions.subsets;
99
- var isSelectedCategory = categories.includes(font.category);
100
- var query = searchQuery.toLocaleLowerCase().trim();
101
- var matchSearchQuery = font.family.toLocaleLowerCase().includes(query);
102
- if (!matchSearchQuery) {
103
- return false;
104
- }
105
- var hasSomeScript = subsets.length > 0 ? font.subsets.some(function (subset) { return subsets.includes(subset); }) : true;
106
- if (isSelectedCategory && hasSomeScript) {
107
- return true;
108
- }
109
- return false;
97
+ function getFilteredFontsAsync() {
98
+ return new Promise(function (resolve) {
99
+ var filteredFonts = fonts.filter(function (font) {
100
+ var categories = filterOptions.categories, searchQuery = filterOptions.searchQuery, subsets = filterOptions.subsets;
101
+ var isSelectedCategory = categories.includes(font.category);
102
+ var query = searchQuery.toLocaleLowerCase().trim();
103
+ var matchSearchQuery = font.family.toLocaleLowerCase().includes(query);
104
+ if (!matchSearchQuery) {
105
+ return false;
106
+ }
107
+ var hasSomeScript = subsets.length > 0 ? font.subsets.some(function (subset) { return subsets.includes(subset); }) : true;
108
+ if (isSelectedCategory && hasSomeScript) {
109
+ return true;
110
+ }
111
+ return false;
112
+ });
113
+ resolve(filteredFonts);
114
+ });
115
+ }
116
+ setIsLoading(true);
117
+ getFilteredFontsAsync().then(function (res) {
118
+ setFilteredFonts(res);
119
+ setIsLoading(false);
110
120
  });
111
- setFilteredFonts(filteredFonts);
112
- setIsLoading(false);
113
121
  }, [filterOptions, fonts]);
114
122
  function changeSort(sortOption) {
115
123
  return __awaiter(this, void 0, void 0, function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "0.2.49",
3
+ "version": "0.2.50",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
package/release-note.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # pds-dev-kit-web-test Release Notes
2
- ## [v0.2.49]
2
+ ## [v0.2.50]
3
3
  ## 기준 pds-dev-kit-web 버전 @2.2.10
4
4
  ### sub
5
5
  * GoogleFontKit
6
- * 폰트/Subset/Category 순서 변경
7
- * blocking 성능이슈 개선
6
+ * DL에 API-KEY를 받도록 추가
7
+ * 성능 개선 시도