hyperbook 0.72.2 → 0.73.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/dist/index.js CHANGED
@@ -155955,7 +155955,27 @@ var en_default = {
155955
155955
  "webide-reset": "Reset",
155956
155956
  "webide-reset-prompt": "Are you sure you want to reset the code?",
155957
155957
  "webide-copy": "Copy",
155958
- "webide-download": "Download"
155958
+ "webide-download": "Download",
155959
+ "typst-code": "Typst",
155960
+ "typst-reset": "Reset",
155961
+ "typst-reset-prompt": "Are you sure you want to reset the code?",
155962
+ "typst-download-pdf": "Download PDF",
155963
+ "typst-pdf-error": "Error exporting PDF",
155964
+ "typst-download-project": "Download Project",
155965
+ "typst-loading": "Loading Typst...",
155966
+ "typst-add-source-file": "Add source file",
155967
+ "typst-add-binary-file": "Add binary file",
155968
+ "typst-source": "Source",
155969
+ "typst-binary": "Binary",
155970
+ "typst-add": "Add",
155971
+ "typst-delete-file": "Delete file",
155972
+ "typst-delete-confirm": "Delete",
155973
+ "typst-filename-prompt": "Enter filename (e.g., helper.typ):",
155974
+ "typst-filename-error": "Filename must end with .typ or .typst",
155975
+ "typst-filename-exists": "File already exists",
155976
+ "typst-file-replace": "Replace existing file?",
155977
+ "typst-binary-files": "Binary Files",
155978
+ "typst-no-binary-files": "No binary files"
155959
155979
  };
155960
155980
 
155961
155981
  // locales/de.json
@@ -156014,7 +156034,27 @@ var de_default = {
156014
156034
  "webide-reset": "Zur\xFCcksetzen",
156015
156035
  "webide-reset-prompt": "Sind Sie sicher, dass Sie den Code zur\xFCcksetzen m\xF6chten?",
156016
156036
  "webide-copy": "Kopieren",
156017
- "webide-download": "Herunterladen"
156037
+ "webide-download": "Herunterladen",
156038
+ "typst-code": "Typst",
156039
+ "typst-reset": "Zur\xFCcksetzen",
156040
+ "typst-reset-prompt": "Sind Sie sicher, dass Sie den Code zur\xFCcksetzen m\xF6chten?",
156041
+ "typst-download-pdf": "PDF herunterladen",
156042
+ "typst-pdf-error": "Fehler beim PDF-Export",
156043
+ "typst-download-project": "Projekt herunterladen",
156044
+ "typst-loading": "Typst wird geladen...",
156045
+ "typst-add-source-file": "Quelldatei hinzuf\xFCgen",
156046
+ "typst-add-binary-file": "Bin\xE4rdatei hinzuf\xFCgen",
156047
+ "typst-source": "Quelle",
156048
+ "typst-binary": "Bin\xE4r",
156049
+ "typst-add": "Hinzuf\xFCgen",
156050
+ "typst-delete-file": "Datei l\xF6schen",
156051
+ "typst-delete-confirm": "L\xF6schen",
156052
+ "typst-filename-prompt": "Dateiname eingeben (z.B. helper.typ):",
156053
+ "typst-filename-error": "Dateiname muss auf .typ oder .typst enden",
156054
+ "typst-filename-exists": "Datei existiert bereits",
156055
+ "typst-file-replace": "Existierende Datei ersetzen?",
156056
+ "typst-binary-files": "Bin\xE4rdateien",
156057
+ "typst-no-binary-files": "Keine Bin\xE4rdateien"
156018
156058
  };
156019
156059
 
156020
156060
  // src/i18n.ts
@@ -157208,6 +157248,15 @@ window.Prism.manual = true;`
157208
157248
  },
157209
157249
  children: []
157210
157250
  },
157251
+ {
157252
+ type: "element",
157253
+ tagName: "script",
157254
+ properties: {
157255
+ src: makeUrl(["prism", "prism-typst.js"], "assets"),
157256
+ defer: true
157257
+ },
157258
+ children: []
157259
+ },
157211
157260
  {
157212
157261
  type: "element",
157213
157262
  tagName: "link",
@@ -173397,6 +173446,378 @@ var remarkDirectiveTextinput_default = (ctx) => () => {
173397
173446
  };
173398
173447
  };
173399
173448
 
173449
+ // src/remarkDirectiveTypst.ts
173450
+ function htmlEntities4(str) {
173451
+ return String(str).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
173452
+ }
173453
+ var remarkDirectiveTypst_default = (ctx) => () => {
173454
+ const name = "typst";
173455
+ return (tree, file) => {
173456
+ visit(tree, function(node3) {
173457
+ if (isDirective(node3) && node3.name === name) {
173458
+ const {
173459
+ height = "auto",
173460
+ id = hash(node3),
173461
+ mode = "preview"
173462
+ } = node3.attributes || {};
173463
+ const data = node3.data || (node3.data = {});
173464
+ expectContainerDirective(node3, file, name);
173465
+ registerDirective(file, name, ["client.js"], ["style.css"], []);
173466
+ requestJS(file, ["code-input", "code-input.min.js"]);
173467
+ requestCSS(file, ["code-input", "code-input.min.css"]);
173468
+ requestJS(file, ["code-input", "auto-close-brackets.min.js"]);
173469
+ requestJS(file, ["code-input", "indent.min.js"]);
173470
+ requestJS(file, ["uzip", "uzip.js"]);
173471
+ const sourceFiles = [];
173472
+ const binaryFiles = [];
173473
+ for (const child of node3.children) {
173474
+ if (child.type === "text") {
173475
+ const text9 = child.value;
173476
+ const fileMatches = text9.matchAll(
173477
+ /@file\s+dest="([^"]+)"\s+src="([^"]+)"/g
173478
+ );
173479
+ for (const match of fileMatches) {
173480
+ const dest = match[1];
173481
+ const src = match[2];
173482
+ const url = ctx.makeUrl(
173483
+ src,
173484
+ "public",
173485
+ ctx.navigation.current || void 0
173486
+ );
173487
+ binaryFiles.push({ dest, url });
173488
+ }
173489
+ const sourceMatches = text9.matchAll(
173490
+ /@source\s+dest="([^"]+)"\s+src="([^"]+)"/g
173491
+ );
173492
+ for (const match of sourceMatches) {
173493
+ const dest = match[1];
173494
+ const src = match[2];
173495
+ const content5 = readFile(src, ctx) || "";
173496
+ sourceFiles.push({ filename: dest, content: content5 });
173497
+ }
173498
+ } else if (child.type === "paragraph") {
173499
+ for (const textNode of child.children) {
173500
+ if (textNode.type === "text") {
173501
+ const text9 = textNode.value;
173502
+ const fileMatches = text9.matchAll(
173503
+ /@file\s+dest="([^"]+)"\s+src="([^"]+)"/g
173504
+ );
173505
+ for (const match of fileMatches) {
173506
+ const dest = match[1];
173507
+ const src = match[2];
173508
+ const url = ctx.makeUrl(
173509
+ src,
173510
+ "public",
173511
+ ctx.navigation.current || void 0
173512
+ );
173513
+ binaryFiles.push({ dest, url });
173514
+ }
173515
+ const sourceMatches = text9.matchAll(
173516
+ /@source\s+dest="([^"]+)"\s+src="([^"]+)"/g
173517
+ );
173518
+ for (const match of sourceMatches) {
173519
+ const dest = match[1];
173520
+ const src = match[2];
173521
+ const content5 = readFile(src, ctx) || "";
173522
+ sourceFiles.push({ filename: dest, content: content5 });
173523
+ }
173524
+ }
173525
+ }
173526
+ }
173527
+ }
173528
+ const codeBlocks = node3.children.filter(
173529
+ (n) => n.type === "code" && (n.lang === "typ" || n.lang === "typst")
173530
+ );
173531
+ if (codeBlocks.length > 0) {
173532
+ for (const codeBlock of codeBlocks) {
173533
+ const filename = codeBlock.meta?.trim() || "main.typ";
173534
+ sourceFiles.push({
173535
+ filename,
173536
+ content: codeBlock.value
173537
+ });
173538
+ }
173539
+ }
173540
+ let mainSource = sourceFiles.find(
173541
+ (f) => f.filename == "main.typ" || f.filename == "main.typst"
173542
+ );
173543
+ if (!mainSource && sourceFiles.length > 0) {
173544
+ mainSource = sourceFiles[0];
173545
+ } else if (!mainSource) {
173546
+ mainSource = { filename: "main.typ", content: "" };
173547
+ }
173548
+ const isEditMode = mode === "edit";
173549
+ const isPreviewMode = mode === "preview" || !isEditMode;
173550
+ data.hName = "div";
173551
+ data.hProperties = {
173552
+ class: ["directive-typst", isPreviewMode ? "preview-only" : ""].join(" ").trim(),
173553
+ "data-id": id,
173554
+ "data-source-files": Buffer.from(
173555
+ JSON.stringify(sourceFiles)
173556
+ ).toString("base64"),
173557
+ "data-binary-files": Buffer.from(
173558
+ JSON.stringify(binaryFiles)
173559
+ ).toString("base64")
173560
+ };
173561
+ const previewContainer = {
173562
+ type: "element",
173563
+ tagName: "div",
173564
+ properties: {
173565
+ class: "preview-container",
173566
+ style: `height: ${height};`
173567
+ },
173568
+ children: [
173569
+ {
173570
+ type: "element",
173571
+ tagName: "div",
173572
+ properties: {
173573
+ class: "typst-loading"
173574
+ },
173575
+ children: [
173576
+ {
173577
+ type: "element",
173578
+ tagName: "div",
173579
+ properties: {
173580
+ class: "typst-spinner"
173581
+ },
173582
+ children: []
173583
+ },
173584
+ {
173585
+ type: "element",
173586
+ tagName: "span",
173587
+ properties: {},
173588
+ children: [
173589
+ {
173590
+ type: "text",
173591
+ value: i18n.get("typst-loading")
173592
+ }
173593
+ ]
173594
+ }
173595
+ ]
173596
+ },
173597
+ {
173598
+ type: "element",
173599
+ tagName: "div",
173600
+ properties: {
173601
+ class: "typst-preview"
173602
+ },
173603
+ children: []
173604
+ }
173605
+ ]
173606
+ };
173607
+ const downloadButton = {
173608
+ type: "element",
173609
+ tagName: "button",
173610
+ properties: {
173611
+ class: "download-pdf"
173612
+ },
173613
+ children: [
173614
+ {
173615
+ type: "text",
173616
+ value: i18n.get("typst-download-pdf")
173617
+ }
173618
+ ]
173619
+ };
173620
+ const downloadProjectButton = {
173621
+ type: "element",
173622
+ tagName: "button",
173623
+ properties: {
173624
+ class: "download-project"
173625
+ },
173626
+ children: [
173627
+ {
173628
+ type: "text",
173629
+ value: i18n.get("typst-download-project")
173630
+ }
173631
+ ]
173632
+ };
173633
+ if (isEditMode) {
173634
+ data.hChildren = [
173635
+ previewContainer,
173636
+ {
173637
+ type: "element",
173638
+ tagName: "div",
173639
+ properties: {
173640
+ class: "editor-container"
173641
+ },
173642
+ children: [
173643
+ {
173644
+ type: "element",
173645
+ tagName: "div",
173646
+ properties: {
173647
+ class: "file-tabs"
173648
+ },
173649
+ children: [
173650
+ {
173651
+ type: "element",
173652
+ tagName: "div",
173653
+ properties: {
173654
+ class: "tabs-list"
173655
+ },
173656
+ children: []
173657
+ },
173658
+ {
173659
+ type: "element",
173660
+ tagName: "button",
173661
+ properties: {
173662
+ class: "add-source-file",
173663
+ title: i18n.get("typst-add-source-file")
173664
+ },
173665
+ children: [
173666
+ {
173667
+ type: "text",
173668
+ value: "+"
173669
+ }
173670
+ ]
173671
+ }
173672
+ ]
173673
+ },
173674
+ {
173675
+ type: "element",
173676
+ tagName: "details",
173677
+ properties: {
173678
+ class: "binary-files-section"
173679
+ },
173680
+ children: [
173681
+ {
173682
+ type: "element",
173683
+ tagName: "summary",
173684
+ properties: {},
173685
+ children: [
173686
+ {
173687
+ type: "element",
173688
+ tagName: "span",
173689
+ properties: {
173690
+ class: "summary-text"
173691
+ },
173692
+ children: [
173693
+ {
173694
+ type: "element",
173695
+ tagName: "span",
173696
+ properties: {
173697
+ class: "summary-indicator"
173698
+ },
173699
+ children: [
173700
+ {
173701
+ type: "text",
173702
+ value: "\u25B6"
173703
+ }
173704
+ ]
173705
+ },
173706
+ {
173707
+ type: "text",
173708
+ value: i18n.get("typst-binary-files")
173709
+ }
173710
+ ]
173711
+ }
173712
+ ]
173713
+ },
173714
+ {
173715
+ type: "element",
173716
+ tagName: "div",
173717
+ properties: {
173718
+ class: "binary-files-list"
173719
+ },
173720
+ children: []
173721
+ },
173722
+ {
173723
+ type: "element",
173724
+ tagName: "div",
173725
+ properties: {
173726
+ class: "binary-files-actions"
173727
+ },
173728
+ children: [
173729
+ {
173730
+ type: "element",
173731
+ tagName: "button",
173732
+ properties: {
173733
+ class: "add-binary-file",
173734
+ title: i18n.get("typst-add-binary-file")
173735
+ },
173736
+ children: [
173737
+ {
173738
+ type: "text",
173739
+ value: "+ " + i18n.get("typst-add")
173740
+ }
173741
+ ]
173742
+ }
173743
+ ]
173744
+ }
173745
+ ]
173746
+ },
173747
+ {
173748
+ type: "element",
173749
+ tagName: "code-input",
173750
+ properties: {
173751
+ class: "editor typst active line-numbers",
173752
+ language: "typst",
173753
+ template: "typst-highlighted"
173754
+ },
173755
+ children: [
173756
+ {
173757
+ type: "raw",
173758
+ value: htmlEntities4(mainSource.content)
173759
+ }
173760
+ ]
173761
+ },
173762
+ {
173763
+ type: "element",
173764
+ tagName: "div",
173765
+ properties: {
173766
+ class: "buttons bottom"
173767
+ },
173768
+ children: [
173769
+ {
173770
+ type: "element",
173771
+ tagName: "button",
173772
+ properties: {
173773
+ class: "reset"
173774
+ },
173775
+ children: [
173776
+ {
173777
+ type: "text",
173778
+ value: i18n.get("typst-reset")
173779
+ }
173780
+ ]
173781
+ },
173782
+ downloadProjectButton,
173783
+ downloadButton
173784
+ ]
173785
+ }
173786
+ ]
173787
+ }
173788
+ ];
173789
+ } else {
173790
+ data.hChildren = [
173791
+ previewContainer,
173792
+ {
173793
+ type: "element",
173794
+ tagName: "div",
173795
+ properties: {
173796
+ class: "buttons bottom"
173797
+ },
173798
+ children: [downloadProjectButton, downloadButton]
173799
+ },
173800
+ {
173801
+ type: "element",
173802
+ tagName: "textarea",
173803
+ properties: {
173804
+ class: "typst-source hidden",
173805
+ style: "display: none;"
173806
+ },
173807
+ children: [
173808
+ {
173809
+ type: "text",
173810
+ value: mainSource.content
173811
+ }
173812
+ ]
173813
+ }
173814
+ ];
173815
+ }
173816
+ }
173817
+ });
173818
+ };
173819
+ };
173820
+
173400
173821
  // src/process.ts
173401
173822
  var remark = (ctx) => {
173402
173823
  i18n.init(ctx.config.language || "en");
@@ -173441,6 +173862,7 @@ var remark = (ctx) => {
173441
173862
  remarkDirectiveMultievent_default(ctx),
173442
173863
  remarkDirectiveLearningmap_default(ctx),
173443
173864
  remarkDirectiveTextinput_default(ctx),
173865
+ remarkDirectiveTypst_default(ctx),
173444
173866
  remarkCode_default(ctx),
173445
173867
  remarkMath,
173446
173868
  /* needs to be last directive */
@@ -173523,7 +173945,7 @@ module.exports = /*#__PURE__*/JSON.parse('{"application/1d-interleaved-parityfec
173523
173945
  /***/ ((module) => {
173524
173946
 
173525
173947
  "use strict";
173526
- module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.72.2","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
173948
+ module.exports = /*#__PURE__*/JSON.parse('{"name":"hyperbook","version":"0.73.0","author":"Mike Barkmin","homepage":"https://github.com/openpatch/hyperbook#readme","license":"MIT","bin":{"hyperbook":"./dist/index.js"},"files":["dist"],"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/openpatch/hyperbook.git","directory":"packages/hyperbook"},"bugs":{"url":"https://github.com/openpatch/hyperbook/issues"},"engines":{"node":">=12.22.0"},"scripts":{"version":"pnpm build","lint":"tsc --noEmit","dev":"ncc build ./index.ts -w -o dist/","build":"rimraf dist && ncc build ./index.ts -o ./dist/ --no-cache --no-source-map-register --external favicons --external sharp && node postbuild.mjs"},"dependencies":{"favicons":"^7.2.0"},"devDependencies":{"create-hyperbook":"workspace:*","@hyperbook/fs":"workspace:*","@hyperbook/markdown":"workspace:*","@hyperbook/types":"workspace:*","@pnpm/exportable-manifest":"1000.0.6","@types/archiver":"6.0.3","@types/async-retry":"1.4.9","@types/cross-spawn":"6.0.6","@types/lunr":"^2.3.7","@types/prompts":"2.4.9","@types/tar":"6.1.13","@types/ws":"^8.5.14","@vercel/ncc":"0.38.3","archiver":"7.0.1","async-retry":"1.3.3","chalk":"5.4.1","chokidar":"4.0.3","commander":"12.1.0","cpy":"11.1.0","cross-spawn":"7.0.6","domutils":"^3.2.2","extract-zip":"^2.0.1","got":"12.6.0","htmlparser2":"^10.0.0","lunr":"^2.3.9","lunr-languages":"^1.14.0","mime":"^4.0.6","prompts":"2.4.2","rimraf":"6.0.1","tar":"7.4.3","update-check":"1.5.4","ws":"^8.18.0"}}');
173527
173949
 
173528
173950
  /***/ })
173529
173951
 
@@ -53,5 +53,25 @@
53
53
  "webide-reset": "Zurücksetzen",
54
54
  "webide-reset-prompt": "Sind Sie sicher, dass Sie den Code zurücksetzen möchten?",
55
55
  "webide-copy": "Kopieren",
56
- "webide-download": "Herunterladen"
56
+ "webide-download": "Herunterladen",
57
+ "typst-code": "Typst",
58
+ "typst-reset": "Zurücksetzen",
59
+ "typst-reset-prompt": "Sind Sie sicher, dass Sie den Code zurücksetzen möchten?",
60
+ "typst-download-pdf": "PDF herunterladen",
61
+ "typst-pdf-error": "Fehler beim PDF-Export",
62
+ "typst-download-project": "Projekt herunterladen",
63
+ "typst-loading": "Typst wird geladen...",
64
+ "typst-add-source-file": "Quelldatei hinzufügen",
65
+ "typst-add-binary-file": "Binärdatei hinzufügen",
66
+ "typst-source": "Quelle",
67
+ "typst-binary": "Binär",
68
+ "typst-add": "Hinzufügen",
69
+ "typst-delete-file": "Datei löschen",
70
+ "typst-delete-confirm": "Löschen",
71
+ "typst-filename-prompt": "Dateiname eingeben (z.B. helper.typ):",
72
+ "typst-filename-error": "Dateiname muss auf .typ oder .typst enden",
73
+ "typst-filename-exists": "Datei existiert bereits",
74
+ "typst-file-replace": "Existierende Datei ersetzen?",
75
+ "typst-binary-files": "Binärdateien",
76
+ "typst-no-binary-files": "Keine Binärdateien"
57
77
  }
@@ -53,5 +53,25 @@
53
53
  "webide-reset": "Reset",
54
54
  "webide-reset-prompt": "Are you sure you want to reset the code?",
55
55
  "webide-copy": "Copy",
56
- "webide-download": "Download"
56
+ "webide-download": "Download",
57
+ "typst-code": "Typst",
58
+ "typst-reset": "Reset",
59
+ "typst-reset-prompt": "Are you sure you want to reset the code?",
60
+ "typst-download-pdf": "Download PDF",
61
+ "typst-pdf-error": "Error exporting PDF",
62
+ "typst-download-project": "Download Project",
63
+ "typst-loading": "Loading Typst...",
64
+ "typst-add-source-file": "Add source file",
65
+ "typst-add-binary-file": "Add binary file",
66
+ "typst-source": "Source",
67
+ "typst-binary": "Binary",
68
+ "typst-add": "Add",
69
+ "typst-delete-file": "Delete file",
70
+ "typst-delete-confirm": "Delete",
71
+ "typst-filename-prompt": "Enter filename (e.g., helper.typ):",
72
+ "typst-filename-error": "Filename must end with .typ or .typst",
73
+ "typst-filename-exists": "File already exists",
74
+ "typst-file-replace": "Replace existing file?",
75
+ "typst-binary-files": "Binary Files",
76
+ "typst-no-binary-files": "No binary files"
57
77
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hyperbook",
3
- "version": "0.72.2",
3
+ "version": "0.73.0",
4
4
  "author": "Mike Barkmin",
5
5
  "homepage": "https://github.com/openpatch/hyperbook#readme",
6
6
  "license": "MIT",
@@ -57,8 +57,8 @@
57
57
  "update-check": "1.5.4",
58
58
  "ws": "^8.18.0",
59
59
  "create-hyperbook": "0.3.0",
60
- "@hyperbook/markdown": "0.45.0",
61
60
  "@hyperbook/fs": "0.21.0",
61
+ "@hyperbook/markdown": "0.46.0",
62
62
  "@hyperbook/types": "0.18.0"
63
63
  },
64
64
  "scripts": {