@brillout/docpress 0.5.1 → 0.5.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.
package/dist/index.d.ts CHANGED
@@ -101,13 +101,9 @@ declare function RepoLink({ path, text, editMode }: {
101
101
 
102
102
  declare function P(props: React$1.HTMLProps<HTMLDivElement>): JSX.Element;
103
103
 
104
- declare function Info({ children }: {
105
- children: React$1.ReactNode;
106
- }): JSX.Element;
107
-
108
104
  declare function ReadingRecommendation({ tour, links }: {
109
105
  tour?: true;
110
- links: string[];
106
+ links?: string[];
111
107
  }): JSX.Element;
112
108
 
113
109
  declare function Warning({ children }: {
@@ -119,6 +115,14 @@ declare function Construction({ children }: {
119
115
  declare function Danger({ children }: {
120
116
  children: JSX.Element;
121
117
  }): JSX.Element;
118
+ declare function NoteWithoutIcon({ children }: {
119
+ children: JSX.Element;
120
+ }): JSX.Element;
121
+ type CustomIcon = JSX.Element | string;
122
+ declare function NoteWithCustomIcon({ icon, children }: {
123
+ children: JSX.Element;
124
+ icon: CustomIcon;
125
+ }): JSX.Element;
122
126
 
123
127
  declare function ImportMeta({ prop }: {
124
128
  prop: string;
@@ -154,4 +158,4 @@ declare function CodeBlockTransformer({ children, lineBreak }: {
154
158
  lineBreak: LineBreak;
155
159
  }): JSX.Element;
156
160
 
157
- export { CodeBlockTransformer, Config, Construction, Danger, Emoji, EmojiName, HeadingDefinition, HeadingDetachedDefinition, HorizontalLine, ImportMeta, Info, Link, P, ReadingRecommendation, RepoLink, Sponsor, Sponsors, Warning, assert, assertUsage, assertWarning, crawlAllFiles, determineSectionTitle, determineSectionUrlHash, filter, isBrowser, isRepoLink, jsxToTextContent, objectAssign };
161
+ export { CodeBlockTransformer, Config, Construction, Danger, Emoji, EmojiName, HeadingDefinition, HeadingDetachedDefinition, HorizontalLine, ImportMeta, Link, NoteWithCustomIcon, NoteWithoutIcon, P, ReadingRecommendation, RepoLink, Sponsor, Sponsors, Warning, assert, assertUsage, assertWarning, crawlAllFiles, determineSectionTitle, determineSectionUrlHash, filter, isBrowser, isRepoLink, jsxToTextContent, objectAssign };
package/dist/index.js CHANGED
@@ -139,72 +139,83 @@ function P(props) {
139
139
  });
140
140
  }
141
141
 
142
- // src/components/Info.tsx
143
- import React3 from "react";
144
- function Info({ children }) {
145
- return /* @__PURE__ */ React3.createElement("blockquote", null, /* @__PURE__ */ React3.createElement(P, null, children));
146
- }
147
-
148
142
  // src/components/ReadingRecommendation.tsx
149
- import React4 from "react";
143
+ import React3 from "react";
150
144
  function ReadingRecommendation({ tour, links }) {
145
+ links ?? (links = []);
146
+ if (!links.length)
147
+ tour = true;
151
148
  const multiple = links.length + (tour ? 1 : 0) > 1;
152
- return /* @__PURE__ */ React4.createElement(Info, null, multiple ? " " : "", /* @__PURE__ */ React4.createElement("b", null, "Reading Recommendation", multiple ? "." : ": "), (() => {
149
+ const intro = /* @__PURE__ */ React3.createElement("b", null, "Reading Recommendation", multiple ? "." : ": ");
150
+ return /* @__PURE__ */ React3.createElement("blockquote", null, (() => {
153
151
  if (!multiple) {
154
- const link = tour ? /* @__PURE__ */ React4.createElement(TourLink, null) : /* @__PURE__ */ React4.createElement(Link, {
152
+ const link = tour ? /* @__PURE__ */ React3.createElement(TourLink, null) : /* @__PURE__ */ React3.createElement(Link, {
155
153
  href: links[0]
156
154
  });
157
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, link, ".");
155
+ return /* @__PURE__ */ React3.createElement("p", null, intro, link);
158
156
  }
159
- return /* @__PURE__ */ React4.createElement("ul", {
157
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement("p", null, " ", intro), /* @__PURE__ */ React3.createElement("ul", {
160
158
  style: {
161
159
  marginLeft: 18,
162
160
  marginTop: 11
163
161
  }
164
- }, tour && /* @__PURE__ */ React4.createElement("li", null, /* @__PURE__ */ React4.createElement(TourLink, null)), links.map((link, i) => /* @__PURE__ */ React4.createElement("li", {
162
+ }, tour && /* @__PURE__ */ React3.createElement("li", null, /* @__PURE__ */ React3.createElement(TourLink, null)), links.map((link, i) => /* @__PURE__ */ React3.createElement("li", {
165
163
  key: i
166
- }, /* @__PURE__ */ React4.createElement(Link, {
164
+ }, /* @__PURE__ */ React3.createElement(Link, {
167
165
  href: link
168
- }))));
166
+ })))));
169
167
  })());
170
168
  }
171
169
  function TourLink() {
172
- return /* @__PURE__ */ React4.createElement(React4.Fragment, null, /* @__PURE__ */ React4.createElement(Link, {
170
+ return /* @__PURE__ */ React3.createElement(React3.Fragment, null, /* @__PURE__ */ React3.createElement(Link, {
173
171
  href: "/react-tour",
174
172
  noBreadcrumb: true
175
- }), " or ", /* @__PURE__ */ React4.createElement(Link, {
173
+ }), " or ", /* @__PURE__ */ React3.createElement(Link, {
176
174
  href: "/vue-tour",
177
175
  noBreadcrumb: true
178
176
  }));
179
177
  }
180
178
 
181
179
  // src/components/Note.tsx
182
- import React5 from "react";
180
+ import React4 from "react";
183
181
  function Warning({ children }) {
184
- return /* @__PURE__ */ React5.createElement(Note, {
182
+ return /* @__PURE__ */ React4.createElement(NoteGeneric, {
185
183
  type: "warning"
186
184
  }, children);
187
185
  }
188
186
  function Construction({ children }) {
189
- return /* @__PURE__ */ React5.createElement(Note, {
187
+ return /* @__PURE__ */ React4.createElement(NoteGeneric, {
190
188
  type: "construction"
191
189
  }, children);
192
190
  }
193
191
  function Danger({ children }) {
194
- return /* @__PURE__ */ React5.createElement(Note, {
192
+ return /* @__PURE__ */ React4.createElement(NoteGeneric, {
195
193
  type: "danger"
196
194
  }, children);
197
195
  }
198
- function Note({
196
+ function NoteWithoutIcon({ children }) {
197
+ return /* @__PURE__ */ React4.createElement(NoteGeneric, {
198
+ icon: null
199
+ }, children);
200
+ }
201
+ function NoteWithCustomIcon({ icon, children }) {
202
+ if (!icon)
203
+ throw new Error(`<NoteWithCustomIcon icon={/*...*/}> property 'icon' is \`${icon}\` which is forbidden`);
204
+ return /* @__PURE__ */ React4.createElement(NoteGeneric, {
205
+ icon
206
+ }, children);
207
+ }
208
+ function NoteGeneric({
199
209
  type,
200
210
  icon,
201
211
  children
202
212
  }) {
213
+ assert(icon === null || icon || type, { icon, type });
203
214
  let className = "custom-icon";
204
215
  if (type) {
205
216
  className = `${className} type-${type}`;
206
217
  }
207
- if (!icon) {
218
+ if (!icon && type) {
208
219
  let classColor = "";
209
220
  if (type === "danger") {
210
221
  icon = ":no_entry:";
@@ -218,37 +229,37 @@ function Note({
218
229
  icon = ":construction:";
219
230
  classColor = "note-color-yellow";
220
231
  }
221
- if (classColor) {
222
- className = `${className} ${classColor}`;
223
- }
232
+ assert(icon);
233
+ assert(classColor);
234
+ className = `${className} ${classColor}`;
224
235
  }
225
- return /* @__PURE__ */ React5.createElement("blockquote", {
236
+ return /* @__PURE__ */ React4.createElement("blockquote", {
226
237
  className
227
- }, /* @__PURE__ */ React5.createElement("div", {
238
+ }, /* @__PURE__ */ React4.createElement("div", {
228
239
  style: { marginBottom: 20 }
229
- }), icon, " ", /* @__PURE__ */ React5.createElement("div", {
240
+ }), icon, " ", /* @__PURE__ */ React4.createElement("div", {
230
241
  className: "blockquote-content"
231
- }, children), /* @__PURE__ */ React5.createElement("div", {
242
+ }, children), /* @__PURE__ */ React4.createElement("div", {
232
243
  style: { marginTop: 20 }
233
244
  }));
234
245
  }
235
246
 
236
247
  // src/components/ImportMeta.tsx
237
- import React6 from "react";
248
+ import React5 from "react";
238
249
  function ImportMeta({ prop }) {
239
250
  assert(!prop.startsWith("import"));
240
251
  assert(!prop.startsWith("."));
241
252
  const text = "import.meta." + prop;
242
- return /* @__PURE__ */ React6.createElement("code", null, text);
253
+ return /* @__PURE__ */ React5.createElement("code", null, text);
243
254
  }
244
255
 
245
256
  // src/components/HorizontalLine.tsx
246
- import React7 from "react";
257
+ import React6 from "react";
247
258
  function HorizontalLine({ primary }) {
248
- return /* @__PURE__ */ React7.createElement("div", {
259
+ return /* @__PURE__ */ React6.createElement("div", {
249
260
  className: "header-separator-line " + (primary ? "primary" : ""),
250
261
  style: { textAlign: "center" }
251
- }, /* @__PURE__ */ React7.createElement("hr", {
262
+ }, /* @__PURE__ */ React6.createElement("hr", {
252
263
  style: {
253
264
  display: "inline-block",
254
265
  margin: 0,
@@ -261,7 +272,7 @@ function HorizontalLine({ primary }) {
261
272
  }
262
273
 
263
274
  // src/components/Sponsors.tsx
264
- import React8 from "react";
275
+ import React7 from "react";
265
276
 
266
277
  // src/icons/heart.svg
267
278
  var heart_default = "/assets/heart-OINVKOXO.svg";
@@ -393,9 +404,9 @@ function Sponsors() {
393
404
  const { projectInfo } = pageContext.config;
394
405
  const sponsorsCompanies = sponsorsList.filter(isCompany);
395
406
  const sponsorsIndividuals = sponsorsList.filter(isIndividual);
396
- return /* @__PURE__ */ React8.createElement("div", {
407
+ return /* @__PURE__ */ React7.createElement("div", {
397
408
  style: { textAlign: "center", marginTop: 19 }
398
- }, /* @__PURE__ */ React8.createElement("a", {
409
+ }, /* @__PURE__ */ React7.createElement("a", {
399
410
  className: "button",
400
411
  href: "https://github.com/sponsors/brillout",
401
412
  style: {
@@ -405,19 +416,19 @@ function Sponsors() {
405
416
  padding: "5px 10px",
406
417
  marginBottom: 10
407
418
  }
408
- }, /* @__PURE__ */ React8.createElement("img", {
419
+ }, /* @__PURE__ */ React7.createElement("img", {
409
420
  src: heart_default,
410
421
  height: 22
411
- }), " ", /* @__PURE__ */ React8.createElement("span", {
422
+ }), " ", /* @__PURE__ */ React7.createElement("span", {
412
423
  style: { marginLeft: 7, fontSize: "1.07em" }
413
- }, "Sponsor")), /* @__PURE__ */ React8.createElement("div", null), /* @__PURE__ */ React8.createElement("div", {
424
+ }, "Sponsor")), /* @__PURE__ */ React7.createElement("div", null), /* @__PURE__ */ React7.createElement("div", {
414
425
  style: { maxWidth: 400, display: "inline-block", marginTop: 12, marginBottom: 12 }
415
- }, projectInfo.projectNameJsx || projectInfo.projectName, " is free and open source, made possible by wonderful sponsors."), /* @__PURE__ */ React8.createElement("div", {
426
+ }, projectInfo.projectNameJsx || projectInfo.projectName, " is free and open source, made possible by wonderful sponsors."), /* @__PURE__ */ React7.createElement("div", {
416
427
  style: { display: "flex", flexWrap: "wrap", justifyContent: "space-evenly", alignItems: "end" }
417
- }, sponsorsCompanies.map((sponsor, i) => /* @__PURE__ */ React8.createElement(SponsorDiv, {
428
+ }, sponsorsCompanies.map((sponsor, i) => /* @__PURE__ */ React7.createElement(SponsorDiv, {
418
429
  sponsor,
419
430
  key: i
420
- }))), /* @__PURE__ */ React8.createElement("div", {
431
+ }))), /* @__PURE__ */ React7.createElement("div", {
421
432
  style: {
422
433
  display: "flex",
423
434
  flexWrap: "wrap",
@@ -426,7 +437,7 @@ function Sponsors() {
426
437
  margin: "17px auto",
427
438
  maxWidth: 700
428
439
  }
429
- }, sponsorsIndividuals.map((sponsor, i) => /* @__PURE__ */ React8.createElement(SponsorDiv, {
440
+ }, sponsorsIndividuals.map((sponsor, i) => /* @__PURE__ */ React7.createElement(SponsorDiv, {
430
441
  sponsor,
431
442
  key: i
432
443
  }))));
@@ -461,16 +472,16 @@ function SponsorDiv({ sponsor }) {
461
472
  imgAlt = sponsor.companyName;
462
473
  marginHeight = 20;
463
474
  marginWidth = 10;
464
- label = /* @__PURE__ */ React8.createElement(Label, {
475
+ label = /* @__PURE__ */ React7.createElement(Label, {
465
476
  sponsor
466
477
  });
467
478
  }
468
- return /* @__PURE__ */ React8.createElement("a", {
479
+ return /* @__PURE__ */ React7.createElement("a", {
469
480
  href: website,
470
481
  style: {
471
482
  margin: `${marginHeight}px ${marginWidth}px`
472
483
  }
473
- }, label, /* @__PURE__ */ React8.createElement("div", {
484
+ }, label, /* @__PURE__ */ React7.createElement("div", {
474
485
  style: {
475
486
  backgroundColor,
476
487
  borderRadius: 7,
@@ -483,7 +494,7 @@ function SponsorDiv({ sponsor }) {
483
494
  flexDirection: "column",
484
495
  justifyContent: "center"
485
496
  }
486
- }, /* @__PURE__ */ React8.createElement("img", {
497
+ }, /* @__PURE__ */ React7.createElement("img", {
487
498
  style: { width: `calc(100% - ${padding}px)`, height: height - padding, zIndex: 2, objectFit: "contain" },
488
499
  src: imgSrc,
489
500
  alt: imgAlt
@@ -494,7 +505,7 @@ function Label({ sponsor }) {
494
505
  const labelBg = getLabelBg(sponsor);
495
506
  const labelIcon = getLabelIcon(sponsor);
496
507
  const labelText = getLabelText(sponsor);
497
- return /* @__PURE__ */ React8.createElement("div", {
508
+ return /* @__PURE__ */ React7.createElement("div", {
498
509
  style: {
499
510
  top: 0,
500
511
  display: "flex",
@@ -507,20 +518,20 @@ function Label({ sponsor }) {
507
518
  }
508
519
  function getLabelBg(sponsor) {
509
520
  const height = sponsor.plan === "platinum" ? 32 : 24;
510
- return /* @__PURE__ */ React8.createElement("img", {
521
+ return /* @__PURE__ */ React7.createElement("img", {
511
522
  src: label_default,
512
523
  style: { height, position: "absolute", bottom: 0, zIndex: -1 }
513
524
  });
514
525
  }
515
526
  function getLabelText(sponsor) {
516
527
  if (sponsor.plan === "platinum") {
517
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null);
528
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null);
518
529
  }
519
530
  let letterSpacing = void 0;
520
531
  if (["bronze", "silver", "gold", "indie"].includes(sponsor.plan)) {
521
532
  letterSpacing = 1;
522
533
  }
523
- return /* @__PURE__ */ React8.createElement(React8.Fragment, null, " ", /* @__PURE__ */ React8.createElement("span", {
534
+ return /* @__PURE__ */ React7.createElement(React7.Fragment, null, " ", /* @__PURE__ */ React7.createElement("span", {
524
535
  style: {
525
536
  zIndex: 1,
526
537
  fontSize: "0.82em",
@@ -535,12 +546,12 @@ function getLabelText(sponsor) {
535
546
  function getLabelIcon(sponsor) {
536
547
  let medalSrc;
537
548
  if (sponsor.plan === "platinum") {
538
- return /* @__PURE__ */ React8.createElement(Emoji, {
549
+ return /* @__PURE__ */ React7.createElement(Emoji, {
539
550
  name: "trophy",
540
551
  style: { fontSize: "1.3em" }
541
552
  });
542
553
  } else if (sponsor.plan === "indie") {
543
- return /* @__PURE__ */ React8.createElement(Emoji, {
554
+ return /* @__PURE__ */ React7.createElement(Emoji, {
544
555
  name: "ribbon",
545
556
  style: { fontSize: "0.9em" }
546
557
  });
@@ -553,7 +564,7 @@ function getLabelIcon(sponsor) {
553
564
  } else {
554
565
  assert(false);
555
566
  }
556
- return /* @__PURE__ */ React8.createElement("img", {
567
+ return /* @__PURE__ */ React7.createElement("img", {
557
568
  src: medalSrc,
558
569
  style: { height: 15, zIndex: 1, marginRight: 5 }
559
570
  });
@@ -593,14 +604,14 @@ function isIndividual(sponsor) {
593
604
  }
594
605
 
595
606
  // src/components/CodeBlockTransformer.tsx
596
- import React9 from "react";
607
+ import React8 from "react";
597
608
  function CodeBlockTransformer({ children, lineBreak }) {
598
609
  assert(
599
610
  lineBreak === "white-space" || lineBreak === "break-word",
600
611
  "`lineBreak` is currently the only use case for <CodeBlockTransformer>"
601
612
  );
602
613
  const className = `with-line-break_${lineBreak}`;
603
- return /* @__PURE__ */ React9.createElement("div", {
614
+ return /* @__PURE__ */ React8.createElement("div", {
604
615
  className
605
616
  }, children);
606
617
  }
@@ -612,8 +623,9 @@ export {
612
623
  FeatureList,
613
624
  HorizontalLine,
614
625
  ImportMeta,
615
- Info,
616
626
  Link,
627
+ NoteWithCustomIcon,
628
+ NoteWithoutIcon,
617
629
  P,
618
630
  ReadingRecommendation,
619
631
  RepoLink,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brillout/docpress",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "scripts": {
5
5
  "// Check types while developing": "",
6
6
  "types": "tsc --noEmit --watch",