pds-dev-kit-web-test 0.2.48 → 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;
@@ -11,10 +11,14 @@ exports.CATEGORIES = [
11
11
  'handwriting',
12
12
  'monospace'
13
13
  ];
14
- exports.SORTS = ['alpha', 'date', 'popularity', 'trending'];
14
+ exports.SORTS = ['trending', 'popularity', 'date', 'alpha'];
15
15
  exports.SUBSETS = [
16
+ 'korean',
17
+ 'latin',
18
+ 'latin-ext',
16
19
  'arabic',
17
20
  'bengali',
21
+ 'chinese-hongkong',
18
22
  'chinese-simplified',
19
23
  'chinese-traditional',
20
24
  'cyrillic',
@@ -28,9 +32,6 @@ exports.SUBSETS = [
28
32
  'japanese',
29
33
  'kannada',
30
34
  'khmer',
31
- 'korean',
32
- 'latin',
33
- 'latin-ext',
34
35
  'malayalam',
35
36
  'myanmar',
36
37
  'oriya',
@@ -38,5 +39,6 @@ exports.SUBSETS = [
38
39
  'tamil',
39
40
  '​telugu',
40
41
  'thai',
42
+ 'tibetan',
41
43
  'vietnamese'
42
44
  ];
@@ -64,11 +64,12 @@ function GoogleFontsList(_a) {
64
64
  var apiKey = _a.apiKey, sort = _a.sort, children = _a.children;
65
65
  var _b = (0, react_1.useState)(false), isLoading = _b[0], setIsLoading = _b[1];
66
66
  var _c = (0, react_1.useState)([]), fonts = _c[0], setFonts = _c[1];
67
- var _d = (0, react_1.useState)({
67
+ var _d = (0, react_1.useState)([]), filteredFonts = _d[0], setFilteredFonts = _d[1];
68
+ var _e = (0, react_1.useState)({
68
69
  searchQuery: '',
69
70
  categories: DEFAULT_CATEGORIES,
70
71
  subsets: []
71
- }), filterOptions = _d[0], setFilterOptions = _d[1];
72
+ }), filterOptions = _e[0], setFilterOptions = _e[1];
72
73
  (0, react_1.useEffect)(function () {
73
74
  function call() {
74
75
  return __awaiter(this, void 0, void 0, function () {
@@ -92,6 +93,32 @@ function GoogleFontsList(_a) {
92
93
  }
93
94
  call();
94
95
  }, [apiKey, sort]);
96
+ (0, react_1.useEffect)(function () {
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);
120
+ });
121
+ }, [filterOptions, fonts]);
95
122
  function changeSort(sortOption) {
96
123
  return __awaiter(this, void 0, void 0, function () {
97
124
  var items;
@@ -106,33 +133,19 @@ function GoogleFontsList(_a) {
106
133
  case 1:
107
134
  items = (_a.sent()).items;
108
135
  setFonts(items.map(function (item) { return (__assign(__assign({}, item), { id: (0, getFontId_1.default)(item.family) })); }));
109
- setIsLoading(false);
110
136
  return [2 /*return*/];
111
137
  }
112
138
  });
113
139
  });
114
140
  }
115
- function changeFilterOption(arg) {
141
+ function changeFilterOption(arg, setLoading) {
116
142
  var name = arg.name, value = arg.value;
143
+ setLoading && setIsLoading(true);
117
144
  setFilterOptions(function (prev) {
118
145
  var _a;
119
146
  return (__assign(__assign({}, prev), (_a = {}, _a[name] = value, _a)));
120
147
  });
121
148
  }
122
- var filteredFonts = fonts.filter(function (font) {
123
- var categories = filterOptions.categories, searchQuery = filterOptions.searchQuery, subsets = filterOptions.subsets;
124
- var isSelectedCategory = categories.includes(font.category);
125
- var query = searchQuery.toLocaleLowerCase().trim();
126
- var matchSearchQuery = font.family.toLocaleLowerCase().includes(query);
127
- if (!matchSearchQuery) {
128
- return false;
129
- }
130
- var hasSomeScript = subsets.length > 0 ? font.subsets.some(function (subset) { return subsets.includes(subset); }) : true;
131
- if (isSelectedCategory && hasSomeScript) {
132
- return true;
133
- }
134
- return false;
135
- });
136
149
  return children({
137
150
  isLoading: isLoading,
138
151
  fonts: fonts,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pds-dev-kit-web-test",
3
- "version": "0.2.48",
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,6 +1,7 @@
1
1
  # pds-dev-kit-web-test Release Notes
2
- ## [v0.2.48]
2
+ ## [v0.2.50]
3
3
  ## 기준 pds-dev-kit-web 버전 @2.2.10
4
4
  ### sub
5
5
  * GoogleFontKit
6
- * 폰트/Subset/Category 순서 변경
6
+ * DL에 API-KEY를 받도록 추가
7
+ * 성능 개선 시도