From 689472ffe2aedfec9c88d0804d09b4e0c4cb829d Mon Sep 17 00:00:00 2001 From: Kento Okura Date: Tue, 20 Oct 2026 16:56:18 +0200 Subject: [PATCH] Create separate JS programs for preview and publishing --- bin/forester/App.ml | 10 ---------- bin/forester/Preview_app.ml | 19 +++++++++++++++++++ bin/forester/dune | 18 +++++++++++++----- dune-project | 2 +- forester.opam | 2 +- test/subdirectory-deploy.t | 1 + 6 files changed, 35 insertions(+), 17 deletions(-) create mode 100644 bin/forester/Preview_app.ml diff --git a/bin/forester/App.ml b/bin/forester/App.ml index 033d2b53..ed76ba2b 100644 --- a/bin/forester/App.ml +++ b/bin/forester/App.ml @@ -4,23 +4,13 @@ * SPDX-License-Identifier: GPL-3.0-or-later *) -open Forester_prelude open Forester_app -open Brr let () = Jsont.Error.disable_ansi_styler () -let manifest_poll_interval_ms = 1000 - -let ( let* ) r f = - match r with Ok v -> f v | Error err -> Console.error [Jv.Error.message err] - let () = Search_modal.init (); ignore @@ Jump_to_subtree.init (); ignore @@ Collapse.init (); - ignore @@ Open_in_editor.init (); - ignore @@ Live_reload.init (); ignore @@ Katex_render.init (); - ignore @@ Diagnostics_panel.init (); ignore @@ Preview_hover.init () diff --git a/bin/forester/Preview_app.ml b/bin/forester/Preview_app.ml new file mode 100644 index 00000000..852748df --- /dev/null +++ b/bin/forester/Preview_app.ml @@ -0,0 +1,19 @@ +(* + * SPDX-FileCopyrightText: 2026 The Forester Project Contributors + * + * SPDX-License-Identifier: GPL-3.0-or-later + *) + +open Forester_app + +let () = Jsont.Error.disable_ansi_styler () + +let () = + Search_modal.init ~full_text_search:Full_text_search.search (); + ignore @@ Jump_to_subtree.init (); + ignore @@ Collapse.init (); + ignore @@ Open_in_editor.init (); + ignore @@ Live_reload.init (); + ignore @@ Katex_render.init (); + ignore @@ Diagnostics_panel.init (); + ignore @@ Preview_hover.init () diff --git a/bin/forester/dune b/bin/forester/dune index 3951e479..5cbc04ae 100644 --- a/bin/forester/dune +++ b/bin/forester/dune @@ -8,17 +8,19 @@ (forester themes))) (files (min.js as default/min.js) + (preview.min.js as default/preview.min.js) (glob_files_rec (theme/* with_prefix default)))) -(executable - (name app) - (modules app) +(executables + (names app preview_app) + (modules app preview_app) (modes js) (js_of_ocaml + (compilation_mode whole_program) + (sourcemap no) (flags - (--opt 3)) - (link_flags (--no-sourcemap))) + (--opt 3))) (libraries brr jsont.brr forester.app forester.prelude)) (rule @@ -27,6 +29,12 @@ (action (run cp %{deps} %{targets}))) +(rule + (targets preview.min.js) + (deps preview_app.bc.js) + (action + (run cp %{deps} %{targets}))) + (executable (public_name forester) (name main) diff --git a/dune-project b/dune-project index 95a757ba..5eec3240 100644 --- a/dune-project +++ b/dune-project @@ -1,4 +1,4 @@ -(lang dune 3.13) +(lang dune 3.17) ;;; SPDX-FileCopyrightText: 2024 The Forester Project Contributors ;;; diff --git a/forester.opam b/forester.opam index b15fe220..1c57e0e1 100644 --- a/forester.opam +++ b/forester.opam @@ -11,7 +11,7 @@ depends: [ "menhir" {>= "20240715"} "ocamlgraph" {>= "2.1.0"} "ocaml" {>= "5.4.0"} - "dune" {>= "3.13"} + "dune" {>= "3.17"} "dune-site" "ocaml-index" "ppx_deriving" diff --git a/test/subdirectory-deploy.t b/test/subdirectory-deploy.t index d3544668..b9393193 100644 --- a/test/subdirectory-deploy.t +++ b/test/subdirectory-deploy.t @@ -111,6 +111,7 @@ output/notes/og-image.png output/notes/package-lock.json output/notes/package.json + output/notes/preview.min.js output/notes/style.css output/notes/tree.xsl -- knotmirror 0.0.1