@brillout/docpress 0.7.2 → 0.7.3

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.
@@ -34,11 +34,11 @@ function NavigationMask() {
34
34
  }
35
35
  function NavigationContent(props) {
36
36
  var navItemsWithComputed = addComputedProps(props.navItems, props.currentUrl);
37
- var navItemsGrouped = groupByLevel1(navItemsWithComputed);
37
+ var navItemsGrouped = groupByLevelMin(navItemsWithComputed);
38
38
  return (React.createElement("div", { id: props.id, className: "navigation-content" },
39
- React.createElement("div", { className: "nav-column", style: { position: 'relative' } }, navItemsGrouped.map(function (navItemLevel1, i) { return (React.createElement("div", { className: "nav-items-level-1-group", key: i },
40
- React.createElement(NavItemComponent, { navItem: navItemLevel1 }),
41
- navItemLevel1.navItemChilds.map(function (navItem, j) { return (React.createElement(NavItemComponent, { navItem: navItem, key: j })); }))); }))));
39
+ React.createElement("div", { className: "nav-column", style: { position: 'relative' } }, navItemsGrouped.map(function (navItemGroup, i) { return (React.createElement("div", { className: "nav-items-group", key: i },
40
+ React.createElement(NavItemComponent, { navItem: navItemGroup }),
41
+ navItemGroup.navItemChilds.map(function (navItem, j) { return (React.createElement(NavItemComponent, { navItem: navItem, key: j })); }))); }))));
42
42
  }
43
43
  function NavItemComponent(_a) {
44
44
  var _b;
@@ -62,16 +62,16 @@ function NavItemComponent(_a) {
62
62
  return (React.createElement("a", { className: [
63
63
  'nav-item',
64
64
  'nav-item-level-' + navItem.level,
65
- navItem.isActive && ' is-active',
66
- navItem.isActiveFirst && ' is-active-first',
67
- navItem.isActiveLast && ' is-active-last',
65
+ navItem.url && navItem.isActive && ' is-active',
66
+ navItem.url && navItem.isActiveFirst && ' is-active-first',
67
+ navItem.url && navItem.isActiveLast && ' is-active-last',
68
68
  navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
69
69
  navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
70
70
  ]
71
71
  .filter(Boolean)
72
72
  .join(' '), href: (_b = navItem.url) !== null && _b !== void 0 ? _b : undefined }, titleInNavJsx));
73
73
  }
74
- function groupByLevel1(navItems) {
74
+ function groupByLevelMin(navItems) {
75
75
  var navItemsGrouped = [];
76
76
  var levelMin = Math.min.apply(Math, navItems.map(function (h) { return h.level; }));
77
77
  navItems.forEach(function (navItem) {
@@ -8,13 +8,13 @@ if (isBrowser()) {
8
8
  console.log([
9
9
  '[@brillout/docpress] DEV MODE',
10
10
  isDevMode() ? 'enabled' : 'disabled',
11
- !isLocalhost() && 'run window.toggleDevMode() to toggle DEV MODE',
11
+ !isLocalhost() && 'run window.toggleDevMode() to toggle DEV MODE',
12
12
  ]
13
13
  .filter(Boolean)
14
14
  .join(' '));
15
15
  if (isDevMode()) {
16
16
  window.onerror = function (err) {
17
- alert(err);
17
+ window.alert(err);
18
18
  window.onerror = null;
19
19
  };
20
20
  }
@@ -35,9 +35,6 @@ function assert(condition, debugInfo) {
35
35
  errMsg += ' Debug info: ' + String(debugInfo);
36
36
  }
37
37
  var err = new Error(errMsg);
38
- if (isBrowser() && isDevMode()) {
39
- window.alert(err.stack);
40
- }
41
38
  throw err;
42
39
  }
43
40
  function assertUsage(condition, msg) {
@@ -45,9 +42,6 @@ function assertUsage(condition, msg) {
45
42
  return;
46
43
  }
47
44
  var err = new Error('[DocPress][Wrong Usage] ' + msg);
48
- if (isBrowser() && isDevMode()) {
49
- window.alert(err.stack);
50
- }
51
45
  throw err;
52
46
  }
53
47
  function isBrowser() {
@@ -77,8 +71,10 @@ function assertWarning(condition, msg) {
77
71
  return;
78
72
  }
79
73
  msg = '[DocPress][Warning] ' + msg;
80
- console.warn(msg);
81
74
  if (isBrowser() && isDevMode()) {
82
- window.alert(msg);
75
+ throw new Error(msg);
76
+ }
77
+ else {
78
+ console.warn(msg);
83
79
  }
84
80
  }
@@ -22,7 +22,7 @@
22
22
  padding-right: 4px;
23
23
  text-decoration: none;
24
24
  }
25
- .nav-column:first-of-type > .nav-items-level-1-group:first-of-type > .nav-item-level-1:first-of-type {
25
+ .nav-column:first-of-type > .nav-items-group:first-of-type > .nav-item-level-1:first-of-type {
26
26
  margin-top: 20px;
27
27
  }
28
28
  .nav-item-level-1 {
@@ -118,7 +118,7 @@ html.navigation-fullscreen .navigation-content > .nav-column {
118
118
  flex-grow: 1;
119
119
  max-width: 350px;
120
120
  }
121
- html.navigation-fullscreen .nav-column > .nav-items-level-1-group:first-child > .nav-item-level-1:first-child {
121
+ html.navigation-fullscreen .nav-column > .nav-items-group:first-child > .nav-item-level-1:first-child {
122
122
  margin-top: 0px;
123
123
  }
124
124
  html.navigation-fullscreen {
@@ -37,7 +37,6 @@ function Navigation({
37
37
  </>
38
38
  )}
39
39
  <NavigationContent id="navigation-content-main" navItems={navItemsAll} currentUrl={currentUrl} />
40
- {/* <ScrollOverlay /> */}
41
40
  <NavigationFullscreenClose />
42
41
  </div>
43
42
  </div>
@@ -69,15 +68,15 @@ function NavigationContent(props: {
69
68
  currentUrl: string
70
69
  }) {
71
70
  const navItemsWithComputed = addComputedProps(props.navItems, props.currentUrl)
72
- const navItemsGrouped = groupByLevel1(navItemsWithComputed)
71
+ const navItemsGrouped = groupByLevelMin(navItemsWithComputed)
73
72
 
74
73
  return (
75
74
  <div id={props.id} className="navigation-content">
76
75
  <div className="nav-column" style={{ position: 'relative' }}>
77
- {navItemsGrouped.map((navItemLevel1, i) => (
78
- <div className="nav-items-level-1-group" key={i}>
79
- <NavItemComponent navItem={navItemLevel1} />
80
- {navItemLevel1.navItemChilds.map((navItem, j) => (
76
+ {navItemsGrouped.map((navItemGroup, i) => (
77
+ <div className="nav-items-group" key={i}>
78
+ <NavItemComponent navItem={navItemGroup} />
79
+ {navItemGroup.navItemChilds.map((navItem, j) => (
81
80
  <NavItemComponent navItem={navItem} key={j} />
82
81
  ))}
83
82
  </div>
@@ -115,9 +114,9 @@ function NavItemComponent({
115
114
  className={[
116
115
  'nav-item',
117
116
  'nav-item-level-' + navItem.level,
118
- navItem.isActive && ' is-active',
119
- navItem.isActiveFirst && ' is-active-first',
120
- navItem.isActiveLast && ' is-active-last',
117
+ navItem.url && navItem.isActive && ' is-active',
118
+ navItem.url && navItem.isActiveFirst && ' is-active-first',
119
+ navItem.url && navItem.isActiveLast && ' is-active-last',
121
120
  navItem.isFirstOfItsKind && 'nav-item-first-of-its-kind',
122
121
  navItem.isLastOfItsKind && 'nav-item-last-of-its-kind',
123
122
  ]
@@ -131,8 +130,8 @@ function NavItemComponent({
131
130
  )
132
131
  }
133
132
 
134
- function groupByLevel1<T extends { level: number }>(navItems: T[]) {
135
- const navItemsGrouped: (T & { navItemChilds: T[] })[] = []
133
+ function groupByLevelMin(navItems: NavItemComputed[]) {
134
+ const navItemsGrouped: (NavItemComputed & { navItemChilds: NavItemComputed[] })[] = []
136
135
  const levelMin: number = Math.min(...navItems.map((h) => h.level))
137
136
  navItems.forEach((navItem) => {
138
137
  if (navItem.level === levelMin) {
@@ -39,7 +39,7 @@ function hideNavigationFullScreen() {
39
39
 
40
40
  function updateColumnWidth() {
41
41
  const navMinWidth = 299
42
- const navH1Groups = Array.from(document.querySelectorAll('#navigation-content-main .nav-items-level-1-group'))
42
+ const navH1Groups = Array.from(document.querySelectorAll('#navigation-content-main .nav-items-group'))
43
43
  const numberOfColumnsMax = navH1Groups.length
44
44
 
45
45
  const widthAvailable = getViewportWidth()
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.7.2",
3
+ "version": "0.7.3",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "======== Build": "",
@@ -19,9 +19,13 @@ import { addFeatureClickHandlers, addTwitterWidgets } from '../components/Featur
19
19
  initOnLinkClick()
20
20
 
21
21
  let root: ReactDOM.Root
22
- function onRenderClient(pageContext: PageContextClient) {
22
+ let renderPromiseResolve: () => void
23
+ async function onRenderClient(pageContext: PageContextClient) {
23
24
  // TODO: stop using any
24
25
  const pageContextResolved: PageContextResolved = (pageContext as any).pageContextResolved
26
+ const renderPromise = new Promise<void>((r) => {
27
+ renderPromiseResolve = r
28
+ })
25
29
  let page = getPageElement(pageContext, pageContextResolved)
26
30
  page = <OnRenderDoneHook>{page}</OnRenderDoneHook>
27
31
  const container = document.getElementById('page-view')!
@@ -33,10 +37,10 @@ function onRenderClient(pageContext: PageContextClient) {
33
37
  }
34
38
  root.render(page)
35
39
  }
36
-
37
40
  if (!pageContext.isHydration) {
38
41
  applyHead(pageContext)
39
42
  }
43
+ await renderPromise
40
44
  }
41
45
 
42
46
  function applyHead(pageContext: PageContextClient) {
@@ -54,6 +58,7 @@ function onRenderDone() {
54
58
  addFeatureClickHandlers()
55
59
  addTwitterWidgets()
56
60
  setHydrationIsFinished()
61
+ renderPromiseResolve()
57
62
  }
58
63
 
59
64
  function OnRenderDoneHook({ children }: { children: React.ReactNode }) {
package/utils/assert.ts CHANGED
@@ -10,14 +10,14 @@ if (isBrowser()) {
10
10
  [
11
11
  '[@brillout/docpress] DEV MODE',
12
12
  isDevMode() ? 'enabled' : 'disabled',
13
- !isLocalhost() && 'run window.toggleDevMode() to toggle DEV MODE',
13
+ !isLocalhost() && 'run window.toggleDevMode() to toggle DEV MODE',
14
14
  ]
15
15
  .filter(Boolean)
16
16
  .join(' '),
17
17
  )
18
18
  if (isDevMode()) {
19
19
  window.onerror = (err) => {
20
- alert(err)
20
+ window.alert(err)
21
21
  window.onerror = null
22
22
  }
23
23
  }
@@ -39,9 +39,6 @@ function assert(condition: unknown, debugInfo?: unknown): asserts condition {
39
39
  errMsg += ' Debug info: ' + String(debugInfo)
40
40
  }
41
41
  const err = new Error(errMsg)
42
- if (isBrowser() && isDevMode()) {
43
- window.alert(err.stack)
44
- }
45
42
  throw err
46
43
  }
47
44
 
@@ -50,9 +47,6 @@ function assertUsage(condition: unknown, msg: string): asserts condition {
50
47
  return
51
48
  }
52
49
  const err = new Error('[DocPress][Wrong Usage] ' + msg)
53
- if (isBrowser() && isDevMode()) {
54
- window.alert(err.stack)
55
- }
56
50
  throw err
57
51
  }
58
52
 
@@ -81,8 +75,9 @@ function assertWarning(condition: unknown, msg: string): asserts condition {
81
75
  return
82
76
  }
83
77
  msg = '[DocPress][Warning] ' + msg
84
- console.warn(msg)
85
78
  if (isBrowser() && isDevMode()) {
86
- window.alert(msg)
79
+ throw new Error(msg)
80
+ } else {
81
+ console.warn(msg)
87
82
  }
88
83
  }