@diplodoc/client 3.0.3 → 3.1.0
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/CHANGELOG.md +20 -0
- package/build/client/112.js +1 -1
- package/build/client/112.js.map +1 -1
- package/build/client/app.css +2 -2
- package/build/client/app.css.map +1 -1
- package/build/client/app.js +1 -1
- package/build/client/app.js.map +1 -1
- package/build/client/app.rtl.css +2 -2
- package/build/client/vendor.css +59 -59
- package/build/client/vendor.css.map +1 -1
- package/build/client/vendor.js +1 -1
- package/build/client/vendor.js.map +1 -1
- package/build/client/vendor.rtl.css +59 -59
- package/build/components/App/index.d.ts +0 -1
- package/build/interceptors/fast-class-applier.d.ts +2 -1
- package/build/server/112.js +1 -1
- package/build/server/112.js.map +1 -1
- package/build/server/app.js +60 -29
- package/build/server/app.js.map +1 -1
- package/build/server/vendor.js +205 -173
- package/build/server/vendor.js.map +1 -1
- package/build/utils.d.ts +3 -0
- package/package.json +4 -3
|
@@ -5,7 +5,6 @@ import type { RouterConfig } from '../Router';
|
|
|
5
5
|
import { DocContentPageData as DocContentPageDataBase, DocLeadingPageData, DocPageData, Lang } from '@diplodoc/components';
|
|
6
6
|
import '@diplodoc/transform/dist/js/yfm';
|
|
7
7
|
import '../../interceptors/leading-page-links';
|
|
8
|
-
import '../../interceptors/fast-class-applier';
|
|
9
8
|
import './App.scss';
|
|
10
9
|
export type DocAnalytics = {
|
|
11
10
|
gtm?: {
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
import type { DocInnerProps } from '../components/App';
|
|
2
|
+
export declare function setRootClasses(data: DocInnerProps): void;
|
package/build/server/112.js
CHANGED
package/build/server/112.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"112.js","mappings":";;UAAA;UACA;;;;;WCDA;WACA;WACA;WACA;WACA,yCAAyC,wCAAwC;WACjF;WACA;WACA;;;;;WCPA;;;;;;ACAA;AACA;AACA;;A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9C;EAEA,IAAI;IACA,MAAM2B,MAAM,GAAG,MAAMH,OAAO,CAACvB,OAAO,CAACsB,IAAI,CAAC;IAE1CH,IAAI,CAACK,WAAW,CAAC;MAACE;IAAM,CAAC,CAAC;EAC9B,CAAC,CAAC,OAAOD,KAAK,EAAE;IACZN,IAAI,CAACK,WAAW,CAAC;MAACC;IAAK,CAAC,CAAC;EAC7B;AACJ,CAAC,C","sources":["webpack://@diplodoc/client/webpack/bootstrap","webpack://@diplodoc/client/webpack/runtime/define property getters","webpack://@diplodoc/client/webpack/runtime/hasOwnProperty shorthand","webpack://@diplodoc/client/./src/components/Search/worker/index.ts"],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","/// <reference no-default-lib=\"true\"/>\n/// <reference lib=\"ES2015\" />\n/// <reference lib=\"webworker\" />\n\n/* eslint-disable new-cap */\nimport type {\n InitMessage,\n MessageType,\n SearchMessage,\n SuggestMessage,\n WorkerApi,\n WorkerConfig,\n} from '../types';\n\n// Default type of `self` is `WorkerGlobalScope & typeof globalThis`\n// https://github.com/microsoft/TypeScript/issues/14877\ndeclare const self: ServiceWorkerGlobalScope & {\n config?: WorkerConfig;\n api?: WorkerApi;\n};\n\nconst UNKNOWN_HANDLER = {\n message: 'Unknown message type!',\n code: 'UNKNOWN_HANDLER',\n};\nconst NOT_INITIALIZED_CONFIG = {\n message: 'Worker is not initialized with required config!',\n code: 'NOT_INITIALIZED',\n};\nconst NOT_INITIALIZED_API = {\n message: 'Worker is not initialized with required api!',\n code: 'NOT_INITIALIZED',\n};\n\nexport function AssertConfig(config: unknown): asserts config is WorkerConfig {\n if (!config) {\n throw NOT_INITIALIZED_CONFIG;\n }\n}\n\nexport function AssertApi(api: unknown): asserts api is WorkerApi {\n if (!api) {\n throw NOT_INITIALIZED_API;\n }\n}\n\nconst HANDLERS = {\n async init(config: InitMessage) {\n self.config = config;\n\n importScripts(self.config.base + '/' + self.config.api);\n\n AssertApi(self.api);\n\n return self.api.init?.();\n },\n\n async suggest({query, count = 10}: SuggestMessage) {\n AssertConfig(self.config);\n AssertApi(self.api);\n\n return self.api.suggest(query, count);\n },\n\n async search({query, count = 10, page = 1}: SearchMessage) {\n AssertConfig(self.config);\n AssertApi(self.api);\n\n return self.api.search(query, count, page);\n },\n} as const;\n\nself.onmessage = async (message) => {\n const [port] = message.ports;\n const {type} = message.data;\n\n const handler = HANDLERS[type as MessageType];\n if (!handler) {\n port.postMessage({error: UNKNOWN_HANDLER});\n }\n\n try {\n const result = await handler(message.data);\n\n port.postMessage({result});\n } catch (error) {\n port.postMessage({error});\n }\n};\n"],"names":["UNKNOWN_HANDLER","message","code","NOT_INITIALIZED_CONFIG","NOT_INITIALIZED_API","AssertConfig","config","AssertApi","api","HANDLERS","init","self","importScripts","base","suggest","query","count","search","page","onmessage","port","ports","type","data","handler","postMessage","error","result"],"sourceRoot":""}
|
package/build/server/app.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/******/ (() => { // webpackBootstrap
|
|
2
2
|
/******/ var __webpack_modules__ = ({
|
|
3
3
|
|
|
4
|
-
/***/
|
|
4
|
+
/***/ 31890:
|
|
5
5
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
6
6
|
|
|
7
7
|
"use strict";
|
|
@@ -54,6 +54,8 @@ const RouterProvider = RouterContext.Provider;
|
|
|
54
54
|
function useRouter() {
|
|
55
55
|
return (0,react.useContext)(RouterContext);
|
|
56
56
|
}
|
|
57
|
+
// EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/utils/index.js + 59 modules
|
|
58
|
+
var utils = __webpack_require__(54878);
|
|
57
59
|
// EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/models/index.js
|
|
58
60
|
var models = __webpack_require__(78184);
|
|
59
61
|
;// CONCATENATED MODULE: ./src/constants.ts
|
|
@@ -78,6 +80,7 @@ const LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG = ['src', 'url', 'href', 'icon', 'image'
|
|
|
78
80
|
const LINK_KEYS = [...new Set([...LINK_KEYS_LEADING_CONFIG, ...LINK_KEYS_PAGE_CONSTRUCTOR_CONFIG])];
|
|
79
81
|
;// CONCATENATED MODULE: ./src/utils.ts
|
|
80
82
|
|
|
83
|
+
|
|
81
84
|
function isBrowser() {
|
|
82
85
|
return typeof document !== 'undefined';
|
|
83
86
|
}
|
|
@@ -109,6 +112,10 @@ function updateRootClassName(states) {
|
|
|
109
112
|
case 'fullScreen':
|
|
110
113
|
toggle('dc-root_full-screen', states[state]);
|
|
111
114
|
break;
|
|
115
|
+
case 'landingPage':
|
|
116
|
+
toggle('dc-root_document-page', !states[state]);
|
|
117
|
+
toggle('dc-root_landing-page', states[state]);
|
|
118
|
+
break;
|
|
112
119
|
case 'mobileView':
|
|
113
120
|
toggle('mobile', states[state]);
|
|
114
121
|
toggle('desktop', !states[state]);
|
|
@@ -140,6 +147,9 @@ function getSettings() {
|
|
|
140
147
|
fullScreen: toBoolean(fullScreen)
|
|
141
148
|
};
|
|
142
149
|
}
|
|
150
|
+
function getLandingPage(data) {
|
|
151
|
+
return (0,utils/* getPageType */.M5)(data) === 'PAGE_CONSTRUCTOR';
|
|
152
|
+
}
|
|
143
153
|
function getMobileView() {
|
|
144
154
|
if (!isBrowser()) {
|
|
145
155
|
return false;
|
|
@@ -175,30 +185,10 @@ function useLang() {
|
|
|
175
185
|
}
|
|
176
186
|
// EXTERNAL MODULE: ./src/interceptors/leading-page-links.js
|
|
177
187
|
var leading_page_links = __webpack_require__(44186);
|
|
178
|
-
;// CONCATENATED MODULE: ./src/interceptors/fast-class-applier.ts
|
|
179
|
-
|
|
180
|
-
if (typeof document !== 'undefined') {
|
|
181
|
-
const {
|
|
182
|
-
theme,
|
|
183
|
-
wideFormat,
|
|
184
|
-
fullScreen
|
|
185
|
-
} = getSettings();
|
|
186
|
-
const mobileView = getMobileView();
|
|
187
|
-
updateRootClassName({
|
|
188
|
-
mobileView,
|
|
189
|
-
wideFormat,
|
|
190
|
-
fullScreen
|
|
191
|
-
});
|
|
192
|
-
updateThemeClassName({
|
|
193
|
-
theme
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
188
|
// EXTERNAL MODULE: ./node_modules/@gravity-ui/page-constructor/build/esm/containers/PageConstructor/Provider.js
|
|
197
189
|
var Provider = __webpack_require__(47658);
|
|
198
190
|
// EXTERNAL MODULE: ./node_modules/@gravity-ui/page-constructor/build/esm/containers/PageConstructor/PageConstructor.js + 10 modules
|
|
199
191
|
var PageConstructor = __webpack_require__(95168);
|
|
200
|
-
// EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/utils/index.js + 59 modules
|
|
201
|
-
var utils = __webpack_require__(54878);
|
|
202
192
|
// EXTERNAL MODULE: ./node_modules/bem-cn-lite/lib/index.js
|
|
203
193
|
var lib = __webpack_require__(23614);
|
|
204
194
|
;// CONCATENATED MODULE: ./src/components/Layout/index.tsx
|
|
@@ -324,6 +314,10 @@ const useContent = (data, CustomPage) => {
|
|
|
324
314
|
};
|
|
325
315
|
// EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/components/SearchSuggest/index.js + 8 modules
|
|
326
316
|
var SearchSuggest = __webpack_require__(9400);
|
|
317
|
+
// EXTERNAL MODULE: ./node_modules/@gravity-ui/uikit/build/esm/components/Icon/Icon.js + 3 modules
|
|
318
|
+
var Icon = __webpack_require__(29504);
|
|
319
|
+
// EXTERNAL MODULE: ./node_modules/@gravity-ui/icons/esm/Magnifier.js
|
|
320
|
+
var Magnifier = __webpack_require__(84941);
|
|
327
321
|
;// CONCATENATED MODULE: ./src/components/index.ts
|
|
328
322
|
|
|
329
323
|
|
|
@@ -368,14 +362,33 @@ class provider_SearchProvider {
|
|
|
368
362
|
// };
|
|
369
363
|
|
|
370
364
|
get base() {
|
|
371
|
-
return window.location.
|
|
365
|
+
return window.location.href.split('/').slice(0, -this.config.depth).join('/');
|
|
372
366
|
}
|
|
373
367
|
async request(message) {
|
|
374
368
|
return request(await this.worker, message);
|
|
375
369
|
}
|
|
376
370
|
}
|
|
371
|
+
const BAD_ORIGIN_ERROR = /Script at '(.*?)' cannot be accessed from origin/;
|
|
372
|
+
async function loadWorker() {
|
|
373
|
+
try {
|
|
374
|
+
return new Worker(new URL(/* worker import */ __webpack_require__.p + __webpack_require__.u(112), __webpack_require__.b));
|
|
375
|
+
} catch (error) {
|
|
376
|
+
// @see https://stackoverflow.com/questions/21408510/chrome-cant-load-web-worker
|
|
377
|
+
if (error instanceof DOMException) {
|
|
378
|
+
const match = BAD_ORIGIN_ERROR.exec(error.message);
|
|
379
|
+
if (match) {
|
|
380
|
+
const url = match[1];
|
|
381
|
+
const blob = new Blob([`importScripts('${url}');`], {
|
|
382
|
+
type: 'text/javascript'
|
|
383
|
+
});
|
|
384
|
+
return new Worker(URL.createObjectURL(blob));
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
throw error;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
377
390
|
async function initWorker(config) {
|
|
378
|
-
const worker =
|
|
391
|
+
const worker = await loadWorker();
|
|
379
392
|
await request(worker, {
|
|
380
393
|
...config,
|
|
381
394
|
type: 'init'
|
|
@@ -428,6 +441,17 @@ function useProvider() {
|
|
|
428
441
|
|
|
429
442
|
|
|
430
443
|
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
|
|
447
|
+
const Suggest_b = (0,lib/* default */.A)('Suggest');
|
|
448
|
+
function SearchButton() {
|
|
449
|
+
return /*#__PURE__*/react.createElement(Icon/* Icon */.I, {
|
|
450
|
+
data: Magnifier/* default */.A,
|
|
451
|
+
className: Suggest_b('end'),
|
|
452
|
+
size: 24
|
|
453
|
+
});
|
|
454
|
+
}
|
|
431
455
|
function Suggest() {
|
|
432
456
|
const provider = useProvider();
|
|
433
457
|
const suggest = (0,react.useRef)(null);
|
|
@@ -454,7 +478,10 @@ function Suggest() {
|
|
|
454
478
|
provider: provider,
|
|
455
479
|
onFocus: onFocus,
|
|
456
480
|
onBlur: onBlur,
|
|
457
|
-
|
|
481
|
+
endContent: /*#__PURE__*/react.createElement(SearchButton, null),
|
|
482
|
+
className: Suggest_b('input'),
|
|
483
|
+
classNameContainer: Suggest_b(),
|
|
484
|
+
closeButton: true
|
|
458
485
|
});
|
|
459
486
|
}
|
|
460
487
|
// EXTERNAL MODULE: ./node_modules/@diplodoc/components/build/esm/components/Controls/ControlsLayout.js
|
|
@@ -541,7 +568,10 @@ const useNavigation = (data, controls, CustomControls, CustomSuggest) => {
|
|
|
541
568
|
const navigationData = (0,react.useMemo)(() => ({
|
|
542
569
|
withBorder: true,
|
|
543
570
|
leftItems: leftItems,
|
|
544
|
-
rightItems: rightItems
|
|
571
|
+
rightItems: rightItems,
|
|
572
|
+
customMobileHeaderItems: [{
|
|
573
|
+
type: 'search'
|
|
574
|
+
}]
|
|
545
575
|
}), [leftItems, rightItems]);
|
|
546
576
|
const navigationTocData = (0,react.useMemo)(() => ({
|
|
547
577
|
toc,
|
|
@@ -756,7 +786,6 @@ function useMobile() {
|
|
|
756
786
|
|
|
757
787
|
|
|
758
788
|
|
|
759
|
-
|
|
760
789
|
function hasNavigation(data) {
|
|
761
790
|
return Boolean(data.toc.navigation);
|
|
762
791
|
}
|
|
@@ -795,16 +824,18 @@ function App(props) {
|
|
|
795
824
|
mobileView
|
|
796
825
|
}), [langs, settings, mobileView]);
|
|
797
826
|
const direction = getDirection(lang);
|
|
827
|
+
const landingPage = getLandingPage(data);
|
|
798
828
|
(0,react.useEffect)(() => {
|
|
799
829
|
updateRootClassName({
|
|
800
830
|
mobileView,
|
|
801
831
|
wideFormat,
|
|
802
|
-
fullScreen
|
|
832
|
+
fullScreen,
|
|
833
|
+
landingPage
|
|
803
834
|
});
|
|
804
835
|
updateThemeClassName({
|
|
805
836
|
theme
|
|
806
837
|
});
|
|
807
|
-
}, [theme, mobileView, wideFormat, fullScreen]);
|
|
838
|
+
}, [theme, mobileView, wideFormat, fullScreen, landingPage]);
|
|
808
839
|
return /*#__PURE__*/react.createElement("div", {
|
|
809
840
|
className: "App"
|
|
810
841
|
}, /*#__PURE__*/react.createElement(ThemeProvider/* ThemeProvider */.N, {
|
|
@@ -1257,7 +1288,7 @@ module.exports = require("util");
|
|
|
1257
1288
|
/******/ __webpack_require__.x = () => {
|
|
1258
1289
|
/******/ // Load entry module and return exports
|
|
1259
1290
|
/******/ // This entry module depends on other loaded chunks and execution need to be delayed
|
|
1260
|
-
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [644,121], () => (__webpack_require__(
|
|
1291
|
+
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, [644,121], () => (__webpack_require__(31890)))
|
|
1261
1292
|
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__);
|
|
1262
1293
|
/******/ return __webpack_exports__;
|
|
1263
1294
|
/******/ };
|