this repo has no description

fix(odoc-scrollycode-extension): use Js_url resource for x-ocaml.js

Instead of hardcoding x-ocaml.js path in raw HTML, declare it as a
Js_url resource so odoc resolves it relative to --support-uri. Pass
worker URL and backend config via meta tags (matching the pattern
used by odoc-interactive-extension).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

+13 -14
+13 -14
odoc-scrollycode-extension/src/scrollycode_extension.ml
··· 700 700 Buffer.add_string buf shared_js; 701 701 Buffer.add_string buf "</script>\n"; 702 702 703 - (* x-ocaml for playground *) 704 - let x_ocaml_js_url = 705 - match Sys.getenv_opt "ODOC_X_OCAML_JS" with 706 - | Some url -> url 707 - | None -> "/_x-ocaml/x-ocaml.js" 708 - in 709 - let x_ocaml_worker_url = 710 - match Sys.getenv_opt "ODOC_X_OCAML_WORKER" with 711 - | Some url -> url 712 - | None -> "/_x-ocaml/worker.js" 713 - in 714 - Printf.bprintf buf {|<script src="%s" src-worker="%s" backend="jtw"></script> 715 - |} x_ocaml_js_url x_ocaml_worker_url; 716 - 717 703 Buffer.contents buf 718 704 719 705 (** {1 Extension Registration} *) 720 706 707 + let meta_tag_script name value = 708 + Printf.sprintf 709 + {|(function(){var m=document.createElement('meta');m.name='%s';m.content='%s';document.head.appendChild(m)})();|} 710 + name value 711 + 721 712 module Scrolly : Odoc_extension_api.Extension = struct 722 713 let prefix = "scrolly" 723 714 ··· 733 724 }; 734 725 ] 735 726 in 727 + let x_ocaml_worker_url = 728 + match Sys.getenv_opt "ODOC_X_OCAML_WORKER" with 729 + | Some url -> url 730 + | None -> "../odoc-interactive-extension/universe/worker.js" 731 + in 736 732 { 737 733 Odoc_extension_api.content = block; 738 734 overrides = []; 739 735 resources = [ 740 736 Css_url "extensions/scrollycode.css"; 737 + Js_inline (meta_tag_script "x-ocaml-backend" "jtw"); 738 + Js_inline (meta_tag_script "x-ocaml-worker" x_ocaml_worker_url); 739 + Js_url "_x-ocaml/x-ocaml.js"; 741 740 ]; 742 741 assets = []; 743 742 }