codemirror-lang-liquidsoap 0.2.7 → 0.2.8

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.
Files changed (151) hide show
  1. package/dist/cli.js +13 -13
  2. package/dist/index.js +15 -13
  3. package/package.json +2 -2
  4. package/src/index.ts +2 -0
  5. package/src/liquidsoap.grammar +9 -1
  6. package/src/parser.js +8 -8
  7. package/src/parser.terms.js +6 -5
  8. package/tests/liquidsoap/.github/scripts/build-posix.sh +0 -3
  9. package/tests/liquidsoap/.github/workflows/ci.yml +35 -10
  10. package/tests/liquidsoap/.pre-commit-config.yaml +1 -1
  11. package/tests/liquidsoap/CHANGES.md +1 -0
  12. package/tests/liquidsoap/CITATION.cff +17 -0
  13. package/tests/liquidsoap/doc/Makefile +17 -0
  14. package/tests/liquidsoap/doc/content/beets.md +6 -47
  15. package/tests/liquidsoap/doc/content/blank.md +5 -17
  16. package/tests/liquidsoap/doc/content/complete_case.md +1 -53
  17. package/tests/liquidsoap/doc/content/cookbook.md +23 -170
  18. package/tests/liquidsoap/doc/content/crossfade.md +1 -73
  19. package/tests/liquidsoap/doc/content/dynamic_sources.md +1 -47
  20. package/tests/liquidsoap/doc/content/external_decoders.md +6 -118
  21. package/tests/liquidsoap/doc/content/external_encoders.md +2 -4
  22. package/tests/liquidsoap/doc/content/external_streams.md +6 -20
  23. package/tests/liquidsoap/doc/content/ffmpeg_cookbook.md +9 -147
  24. package/tests/liquidsoap/doc/content/ffmpeg_filters.md +6 -93
  25. package/tests/liquidsoap/doc/content/harbor.md +4 -40
  26. package/tests/liquidsoap/doc/content/harbor_http.md +10 -118
  27. package/tests/liquidsoap/doc/content/help.md +1 -9
  28. package/tests/liquidsoap/doc/content/hls_output.md +6 -102
  29. package/tests/liquidsoap/doc/content/http_input.md +2 -4
  30. package/tests/liquidsoap/doc/content/icy_metadata.md +2 -24
  31. package/tests/liquidsoap/doc/content/in_production.md +2 -7
  32. package/tests/liquidsoap/doc/content/json.md +10 -36
  33. package/tests/liquidsoap/doc/content/language.md +1 -1
  34. package/tests/liquidsoap/doc/content/liq/Makefile +8 -0
  35. package/tests/liquidsoap/doc/content/liq/append-silence.liq +46 -0
  36. package/tests/liquidsoap/doc/content/liq/beets-amplify.liq +29 -0
  37. package/tests/liquidsoap/doc/content/liq/beets-protocol.liq +26 -0
  38. package/tests/liquidsoap/doc/content/liq/beets-source.liq +21 -0
  39. package/tests/liquidsoap/doc/content/liq/blank-detect.liq +10 -0
  40. package/tests/liquidsoap/doc/content/liq/blank-sorry.liq +11 -0
  41. package/tests/liquidsoap/doc/content/liq/check +4 -0
  42. package/tests/liquidsoap/doc/content/liq/complete-case.liq +69 -0
  43. package/tests/liquidsoap/doc/content/liq/cross.smart.liq +37 -0
  44. package/tests/liquidsoap/doc/content/liq/crossfade.liq +120 -0
  45. package/tests/liquidsoap/doc/content/liq/decoder-faad.liq +122 -0
  46. package/tests/liquidsoap/doc/content/liq/decoder-flac.liq +19 -0
  47. package/tests/liquidsoap/doc/content/liq/decoder-metaflac.liq +24 -0
  48. package/tests/liquidsoap/doc/content/liq/dump-hourly.liq +7 -0
  49. package/tests/liquidsoap/doc/content/liq/dump-hourly2.liq +4 -0
  50. package/tests/liquidsoap/doc/content/liq/dynamic-source.liq +55 -0
  51. package/tests/liquidsoap/doc/content/liq/external-output.file.liq +7 -0
  52. package/tests/liquidsoap/doc/content/liq/fallback.liq +4 -0
  53. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-dynamic-volume.liq +36 -0
  54. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-flanger-highpass.liq +10 -0
  55. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip.liq +9 -0
  56. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-hflip2.liq +23 -0
  57. package/tests/liquidsoap/doc/content/liq/ffmpeg-filter-parallel-flanger-highpass.liq +36 -0
  58. package/tests/liquidsoap/doc/content/liq/ffmpeg-live-switch.liq +23 -0
  59. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay-ondemand.liq +31 -0
  60. package/tests/liquidsoap/doc/content/liq/ffmpeg-relay.liq +19 -0
  61. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding-rtmp.liq +43 -0
  62. package/tests/liquidsoap/doc/content/liq/ffmpeg-shared-encoding.liq +28 -0
  63. package/tests/liquidsoap/doc/content/liq/frame-size.liq +10 -0
  64. package/tests/liquidsoap/doc/content/liq/harbor-auth.liq +18 -0
  65. package/tests/liquidsoap/doc/content/liq/harbor-insert-metadata.liq +28 -0
  66. package/tests/liquidsoap/doc/content/liq/harbor-metadata.liq +14 -0
  67. package/tests/liquidsoap/doc/content/liq/harbor-redirect.liq +10 -0
  68. package/tests/liquidsoap/doc/content/liq/harbor-simple.liq +10 -0
  69. package/tests/liquidsoap/doc/content/liq/harbor-usage.liq +16 -0
  70. package/tests/liquidsoap/doc/content/liq/harbor.http.register.liq +48 -0
  71. package/tests/liquidsoap/doc/content/liq/harbor.http.response.liq +20 -0
  72. package/tests/liquidsoap/doc/content/liq/hls-metadata.liq +18 -0
  73. package/tests/liquidsoap/doc/content/liq/hls-mp4.liq +35 -0
  74. package/tests/liquidsoap/doc/content/liq/http-input.liq +6 -0
  75. package/tests/liquidsoap/doc/content/liq/icy-update.liq +31 -0
  76. package/tests/liquidsoap/doc/content/liq/input.mplayer.liq +26 -0
  77. package/tests/liquidsoap/doc/content/liq/json-ex.liq +29 -0
  78. package/tests/liquidsoap/doc/content/liq/json-stringify.liq +2 -0
  79. package/tests/liquidsoap/doc/content/liq/json1.liq +3 -0
  80. package/tests/liquidsoap/doc/content/liq/liquidsoap +4 -0
  81. package/tests/liquidsoap/doc/content/liq/live-switch.liq +23 -0
  82. package/tests/liquidsoap/doc/content/liq/medialib.liq +4 -0
  83. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track.liq +24 -0
  84. package/tests/liquidsoap/doc/content/liq/multitrack-add-video-track2.liq +10 -0
  85. package/tests/liquidsoap/doc/content/liq/multitrack-default-video-track.liq +14 -0
  86. package/tests/liquidsoap/doc/content/liq/multitrack.liq +11 -0
  87. package/tests/liquidsoap/doc/content/liq/multitrack2.liq +16 -0
  88. package/tests/liquidsoap/doc/content/liq/multitrack3.liq +10 -0
  89. package/tests/liquidsoap/doc/content/liq/output.file.hls.liq +44 -0
  90. package/tests/liquidsoap/doc/content/liq/prometheus-callback.liq +18 -0
  91. package/tests/liquidsoap/doc/content/liq/prometheus-settings.liq +3 -0
  92. package/tests/liquidsoap/doc/content/liq/radiopi.liq +467 -0
  93. package/tests/liquidsoap/doc/content/liq/re-encode.liq +14 -0
  94. package/tests/liquidsoap/doc/content/liq/regular.liq +8 -0
  95. package/tests/liquidsoap/doc/content/liq/replaygain-metadata.liq +6 -0
  96. package/tests/liquidsoap/doc/content/liq/replaygain-playlist.liq +6 -0
  97. package/tests/liquidsoap/doc/content/liq/rtmp.liq +10 -0
  98. package/tests/liquidsoap/doc/content/liq/samplerate3.liq +8 -0
  99. package/tests/liquidsoap/doc/content/liq/scheduling.liq +7 -0
  100. package/tests/liquidsoap/doc/content/liq/seek-telnet.liq +23 -0
  101. package/tests/liquidsoap/doc/content/liq/settings.liq +8 -0
  102. package/tests/liquidsoap/doc/content/liq/shoutcast.liq +5 -0
  103. package/tests/liquidsoap/doc/content/liq/space_overhead.liq +9 -0
  104. package/tests/liquidsoap/doc/content/liq/split-cue.liq +21 -0
  105. package/tests/liquidsoap/doc/content/liq/srt-receiver.liq +8 -0
  106. package/tests/liquidsoap/doc/content/liq/srt-sender.liq +4 -0
  107. package/tests/liquidsoap/doc/content/liq/transcoding.liq +18 -0
  108. package/tests/liquidsoap/doc/content/liq/video-anonymizer.liq +31 -0
  109. package/tests/liquidsoap/doc/content/liq/video-bluescreen.liq +14 -0
  110. package/tests/liquidsoap/doc/content/liq/video-in-video.liq +7 -0
  111. package/tests/liquidsoap/doc/content/liq/video-logo.liq +9 -0
  112. package/tests/liquidsoap/doc/content/liq/video-osc.liq +26 -0
  113. package/tests/liquidsoap/doc/content/liq/video-simple.liq +12 -0
  114. package/tests/liquidsoap/doc/content/liq/video-static.liq +20 -0
  115. package/tests/liquidsoap/doc/content/liq/video-text.liq +5 -0
  116. package/tests/liquidsoap/doc/content/liq/video-transition.liq +5 -0
  117. package/tests/liquidsoap/doc/content/liq/video-weather.liq +7 -0
  118. package/tests/liquidsoap/doc/content/liq/video-webcam.liq +1 -0
  119. package/tests/liquidsoap/doc/content/memory.md +2 -14
  120. package/tests/liquidsoap/doc/content/multitrack.md +6 -81
  121. package/tests/liquidsoap/doc/content/prometheus.md +8 -22
  122. package/tests/liquidsoap/doc/content/quick_start.md +1 -1
  123. package/tests/liquidsoap/doc/content/radiopi.md +1 -298
  124. package/tests/liquidsoap/doc/content/replay_gain.md +2 -7
  125. package/tests/liquidsoap/doc/content/seek.md +2 -18
  126. package/tests/liquidsoap/doc/content/shoutcast.md +1 -5
  127. package/tests/liquidsoap/doc/content/split-cue.md +1 -26
  128. package/tests/liquidsoap/doc/content/video-static.md +1 -20
  129. package/tests/liquidsoap/doc/content/video.md +23 -111
  130. package/tests/liquidsoap/doc/dune +6 -0
  131. package/tests/liquidsoap/doc/dune.inc +11350 -406
  132. package/tests/liquidsoap/doc/gen_dune.ml +81 -31
  133. package/tests/liquidsoap/doc/no-pandoc +1 -1
  134. package/tests/liquidsoap/liquidsoap +2 -1
  135. package/tests/liquidsoap/src/core/io/srt_io.ml +12 -3
  136. package/tests/liquidsoap/src/core/operators/video_effects.ml +3 -1
  137. package/tests/liquidsoap/src/core/outputs/output.ml +4 -2
  138. package/tests/liquidsoap/src/core/outputs/output.mli +2 -0
  139. package/tests/liquidsoap/src/core/visualization/video_volume.ml +7 -4
  140. package/tests/liquidsoap/src/js/index.html +2 -2
  141. package/tests/liquidsoap/src/lang/parser.mly +10 -10
  142. package/tests/liquidsoap/src/lang/term/parsed_term.ml +7 -11
  143. package/tests/liquidsoap/src/lang/term/term_reducer.ml +32 -32
  144. package/tests/liquidsoap/src/lang/utils.ml +3 -3
  145. package/tests/liquidsoap/src/libs/file.liq +15 -2
  146. package/tests/liquidsoap/src/libs/playlist.liq +3 -0
  147. package/tests/liquidsoap/src/runtime/main.ml +3 -0
  148. package/tests/liquidsoap/src/tooling/parsed_json.ml +9 -10
  149. package/tests/liquidsoap/tests/language/file.liq +4 -0
  150. package/tests/liquidsoap/tests/language/record.liq +33 -0
  151. package/tests/liquidsoap/tests/language/regexp.liq +2 -0
@@ -37,7 +37,8 @@ let mk_subst_rule f =
37
37
  (run %%{subst_md} %%{in_md}))))|}
38
38
  f target)
39
39
 
40
- let mk_html_rule ~content f =
40
+ let mk_html_rule ~liq ~content f =
41
+ let liq = liq |> List.map (fun f -> " " ^ f) |> String.concat "\n" in
41
42
  Printf.printf
42
43
  {|
43
44
  (rule
@@ -45,7 +46,8 @@ let mk_html_rule ~content f =
45
46
  (enabled_if (not %%{bin-available:pandoc}))
46
47
  (deps (:no_pandoc no-pandoc))
47
48
  (target %s)
48
- (action (run cp %%{no_pandoc} %%{target})))
49
+ (action (run cp %%{no_pandoc} %%{target}))
50
+ )
49
51
 
50
52
  (rule
51
53
  (alias doc)
@@ -54,13 +56,20 @@ let mk_html_rule ~content f =
54
56
  liquidsoap.xml
55
57
  language.dtd
56
58
  template.html
57
- (:md %s))
59
+ %s
60
+ (:md %s)
61
+ )
58
62
  (target %s)
59
63
  (action
60
- (ignore-outputs
61
- (run pandoc --syntax-definition=liquidsoap.xml --highlight=pygments %%{md} --metadata pagetitle=%s --template=template.html -o %%{target}))))
64
+ (pipe-stdout
65
+ (run pandoc %%{md} -t json)
66
+ (run pandoc-include --directory content/liq)
67
+ (run pandoc -f json --syntax-definition=liquidsoap.xml --highlight=pygments --metadata pagetitle=%s --template=template.html -o %%{target})
68
+ )
69
+ )
70
+ )
62
71
  |}
63
- (mk_html f) (mk_md ~content f) (mk_html f) (mk_title f)
72
+ (mk_html f) liq (mk_md ~content f) (mk_html f) (mk_title f)
64
73
 
65
74
  let mk_generated_rule (file, option, header) =
66
75
  let header_deps, header_action, header_close =
@@ -71,6 +80,12 @@ let mk_generated_rule (file, option, header) =
71
80
  {|(progn (cat %{header}) (echo "\n")|},
72
81
  ")" )
73
82
  in
83
+ let header_action =
84
+ if header_action = "" then "" else "\n " ^ header_action
85
+ in
86
+ let header_close =
87
+ if header_close = "" then "" else "\n " ^ header_close
88
+ in
74
89
  Printf.printf
75
90
  {|
76
91
  (rule
@@ -78,16 +93,31 @@ let mk_generated_rule (file, option, header) =
78
93
  (deps %s)
79
94
  (target %s)
80
95
  (action
81
- (with-stdout-to %s
82
- %s
96
+ (with-stdout-to %s%s
83
97
  (setenv PAGER none
84
- (run %%{bin:liquidsoap} %s)))))
85
- %s
98
+ (run %%{bin:liquidsoap} %s)))))%s
86
99
  |}
87
100
  header_deps file file header_action option header_close
88
101
 
102
+ let mk_test_rule ~stdlib file =
103
+ let stdlib = stdlib |> List.map (fun f -> " " ^ f) |> String.concat "\n" in
104
+ Printf.printf
105
+ {|
106
+ (rule
107
+ (alias doctest)
108
+ (package liquidsoap)
109
+ (deps
110
+ %s
111
+ (:stdlib ../src/libs/stdlib.liq)
112
+ (:test_liq %s)
113
+ )
114
+ (action (run %%{bin:liquidsoap} --no-stdlib %%{stdlib} --check --no-fallible-check %s))
115
+ )
116
+ |}
117
+ stdlib file file
118
+
89
119
  let mk_html_install f =
90
- Printf.sprintf {|(%s as html/%s)|} (mk_html f) (mk_html f)
120
+ Printf.sprintf {| (%s as html/%s)|} (mk_html f) (mk_html f)
91
121
 
92
122
  let rec readdir ?(cur = []) ~location dir =
93
123
  List.fold_left
@@ -102,29 +132,49 @@ let rec readdir ?(cur = []) ~location dir =
102
132
  let () =
103
133
  let location = Filename.dirname Sys.executable_name in
104
134
  let md =
105
- List.sort compare
106
- (List.filter
107
- (fun f -> Filename.extension f = ".md" || Filename.extension f = ".in")
108
- (Array.to_list (Sys.readdir (Filename.concat location "content"))))
135
+ Sys.readdir (Filename.concat location "content")
136
+ |> Array.to_list
137
+ |> List.filter (fun f ->
138
+ Filename.extension f = ".md" || Filename.extension f = ".in")
139
+ |> List.sort compare
140
+ in
141
+ let liq =
142
+ Sys.readdir (Filename.concat location "content/liq")
143
+ |> Array.to_list
144
+ |> List.filter (fun f -> Filename.extension f = ".liq")
145
+ |> List.sort compare
146
+ |> List.map (fun f -> "content/liq/" ^ f)
147
+ in
148
+ let stdlib =
149
+ Sys.readdir (Filename.concat location "../src/libs")
150
+ |> Array.to_list
151
+ |> List.filter (fun f -> Filename.extension f = ".liq")
152
+ |> List.sort compare
153
+ |> List.map (fun f -> "../src/libs/" ^ f)
109
154
  in
110
155
  List.iter mk_generated_rule generated_md;
111
156
  List.iter mk_subst_rule md;
112
- List.iter (fun (file, _, _) -> mk_html_rule ~content:false file) generated_md;
113
- List.iter (mk_html_rule ~content:true) md;
157
+ List.iter
158
+ (fun (file, _, _) -> mk_html_rule ~liq ~content:false file)
159
+ generated_md;
160
+ List.iter (mk_html_rule ~liq ~content:true) md;
161
+ List.iter (mk_test_rule ~stdlib) liq;
162
+ let files =
163
+ List.map
164
+ (fun f -> Printf.sprintf {| (orig/%s as html/%s)|} f f)
165
+ (readdir ~location:(Filename.concat location "orig") "")
166
+ @ List.map (fun (f, _, _) -> mk_html_install f) generated_md
167
+ @ List.map mk_html_install md
168
+ in
169
+ let files = files |> List.sort compare |> String.concat "\n" in
114
170
  Printf.printf
115
171
  {|
116
172
  (install
117
- (section doc)
118
- (package liquidsoap)
119
- (files
120
- %s
121
- %s
122
- %s))
123
- |}
124
- (String.concat "\n"
125
- (List.map
126
- (fun f -> Printf.sprintf {|(orig/%s as html/%s)|} f f)
127
- (readdir ~location:(Filename.concat location "orig") "")))
128
- (String.concat "\n"
129
- (List.map (fun (f, _, _) -> mk_html_install f) generated_md))
130
- (String.concat "\n" (List.map mk_html_install md))
173
+ (section doc)
174
+ (package liquidsoap)
175
+ (files
176
+ %s
177
+ )
178
+ )
179
+ |}
180
+ files
@@ -1 +1 @@
1
- Please rebuild with pandoc installed to generate liquidsoap documentation..
1
+ Please rebuild with pandoc installed to generate liquidsoap documentation.
@@ -1,6 +1,7 @@
1
1
  #!/bin/sh
2
+ # shellcheck disable=SC2068
2
3
 
3
4
  DIR="$(dirname "$0")"
4
5
  export DIR
5
6
 
6
- dune exec --display=quiet --no-print-directory --root="$DIR" src/bin/liquidsoap.exe -- --no-stdlib "$DIR/src/libs/stdlib.liq" "$@"
7
+ dune exec --display=quiet --no-print-directory --root="$DIR" src/bin/liquidsoap.exe -- --no-stdlib "$DIR/src/libs/stdlib.liq" $@
@@ -182,9 +182,18 @@ let parse_common_options p =
182
182
  ( List.assoc "bind_address" p,
183
183
  Printf.sprintf "Invalid address: %s" (Printexc.to_string exn) ))
184
184
  in
185
- let passphrase =
186
- Lang.to_valued_option Lang.to_string (List.assoc "passphrase" p)
187
- in
185
+ let passphrase_v = List.assoc "passphrase" p in
186
+ let passphrase = Lang.to_valued_option Lang.to_string passphrase_v in
187
+ (match passphrase with
188
+ | Some s when String.length s < 10 ->
189
+ raise
190
+ (Error.Invalid_value
191
+ (passphrase_v, "Passphrase must be at least 10 characters long!"))
192
+ | Some s when String.length s > 79 ->
193
+ raise
194
+ (Error.Invalid_value
195
+ (passphrase_v, "Passphrase must be at most 79 characters long!"))
196
+ | _ -> ());
188
197
  let streamid =
189
198
  Lang.to_valued_option Lang.to_string (List.assoc "streamid" p)
190
199
  in
@@ -153,7 +153,9 @@ let video_opacity =
153
153
  ( "",
154
154
  Lang.getter_t Lang.float_t,
155
155
  None,
156
- Some "Coefficient to scale opacity with." );
156
+ Some
157
+ "Coefficient to scale opacity with: from 0 (fully transparent) to 1 \
158
+ (fully opaque)." );
157
159
  ("", Lang.source_t return_t, None, None);
158
160
  ]
159
161
  ~return_t ~category:`Video ~descr:"Scale opacity of video."
@@ -24,6 +24,8 @@
24
24
 
25
25
  open Source
26
26
 
27
+ let fallibility_check = ref true
28
+
27
29
  let proto =
28
30
  Start_stop.output_proto
29
31
  @ [
@@ -48,8 +50,8 @@ class virtual output ~output_kind ?(name = "") ~infallible
48
50
  initializer
49
51
  (* This should be done before the active_operator initializer attaches us
50
52
  to a clock. *)
51
- if infallible && source#stype <> `Infallible then
52
- raise (Error.Invalid_value (val_source, "That source is fallible"))
53
+ if !fallibility_check && infallible && source#stype <> `Infallible then
54
+ raise (Error.Invalid_value (val_source, "That source is fallible."))
53
55
 
54
56
  initializer Typing.(source#frame_type <: self#frame_type)
55
57
  inherit active_operator ~name:output_kind [source]
@@ -22,6 +22,8 @@
22
22
 
23
23
  (** Abstract classes for easy creation of output nodes. *)
24
24
 
25
+ val fallibility_check : bool ref
26
+
25
27
  (** Parameters needed to instantiate an output. *)
26
28
  val proto : (string * Lang.t * Lang.value option * string option) list
27
29
 
@@ -139,13 +139,16 @@ class visu source =
139
139
  end
140
140
 
141
141
  let _ =
142
- let frame_t =
143
- Lang.frame_t (Lang.univ_t ())
144
- (Frame.Fields.make ~audio:(Format_type.audio ()) ())
142
+ let base_t = Lang.univ_t () in
143
+ let audio_t = Format_type.audio () in
144
+ let frame_t = Lang.frame_t base_t (Frame.Fields.make ~audio:audio_t ()) in
145
+ let video_t = Format_type.video () in
146
+ let return_t =
147
+ Lang.frame_t base_t (Frame.Fields.make ~audio:audio_t ~video:video_t ())
145
148
  in
146
149
  Lang.add_operator ~base:Modules.video "volume"
147
150
  [("", Lang.source_t frame_t, None, None)]
148
- ~return_t:frame_t ~category:`Visualization
151
+ ~return_t ~category:`Visualization
149
152
  ~descr:"Graphical visualization of the sound."
150
153
  (fun p ->
151
154
  let f v = List.assoc v p in
@@ -22,9 +22,9 @@
22
22
  "@codemirror/state": "https://esm.sh/@codemirror/state@6.2.1",
23
23
  "@codemirror/language": "https://esm.sh/@codemirror/language@6.9.1",
24
24
  "@codemirror/view": "https://esm.sh/@codemirror/view@6.21.3",
25
- "codemirror-lang-liquidsoap": "https://esm.sh/codemirror-lang-liquidsoap@0.2.5?external=@codemirror/state,@codemirror/language,@codemirror/view",
25
+ "codemirror-lang-liquidsoap": "https://esm.sh/codemirror-lang-liquidsoap@0.2.7?external=@codemirror/state,@codemirror/language,@codemirror/view",
26
26
  "prettier": "https://esm.sh/prettier@3.0.2/standalone.mjs",
27
- "liquidsoap-prettier": "https://esm.sh/liquidsoap-prettier/src/index.js"
27
+ "liquidsoap-prettier": "https://esm.sh/liquidsoap-prettier@1.4.8/src/index.js"
28
28
  }
29
29
  }
30
30
  </script>
@@ -155,7 +155,7 @@ open Parser_helper
155
155
  %type <Term.pattern> pattern
156
156
  %type <Term.pattern list> pattern_list
157
157
  %type <Term.pattern list * string option * Term.pattern list> pattern_list_with_spread
158
- %type <(string * Parsed_term.t) list> record
158
+ %type <Parsed_term.methods list> record
159
159
  %type <Parser_helper.meth_pattern_el list> record_pattern
160
160
  %type <Term.meth_annotation list> record_ty
161
161
  %type <unit> s
@@ -226,13 +226,12 @@ expr:
226
226
  | ENCODER encoder_opt { mk_encoder ~pos:$loc $1 $2 }
227
227
  | LPAR RPAR { mk ~pos:$loc (`Tuple []) }
228
228
  | LPAR inner_tuple RPAR { mk ~pos:$loc (`Tuple $2) }
229
+ | expr DOT LCUR record RCUR { mk ~pos:$loc (`Methods (Some $1, $4)) }
229
230
  | expr DOT LCUR record optional_comma RCUR
230
- { mk ~pos:$loc (`Methods { base = `Term $1; methods = $4 }) }
231
- | LCUR DOTDOTDOT expr RCUR { mk ~pos:$loc (`Methods { base = `Spread $3; methods = [] }) }
232
- | LCUR record COMMA DOTDOTDOT expr RCUR
233
- { mk ~pos:$loc (`Methods { base = `Spread $5; methods = $2 }) }
234
- | LCUR record optional_comma RCUR { mk ~pos:$loc (`Methods { base = `None; methods = $2 }) }
235
- | LCUR RCUR { mk ~pos:$loc (`Methods {base = `None; methods = []}) }
231
+ { mk ~pos:$loc (`Methods (Some $1, $4)) }
232
+ | LCUR record RCUR { mk ~pos:$loc (`Methods (None, $2)) }
233
+ | LCUR record optional_comma RCUR { mk ~pos:$loc (`Methods (None, $2)) }
234
+ | LCUR RCUR { mk ~pos:$loc (`Methods (None, [])) }
236
235
  | expr QUESTION_DOT invoke { mk ~pos:$loc (`Invoke { invoked = $1; meth = $3; optional = true }) }
237
236
  | expr DOT invoke { mk ~pos:$loc (`Invoke { invoked = $1; meth = $3; optional = false }) }
238
237
  | VARLPAR app_list RPAR { mk ~pos:$loc (`App (mk ~pos:$loc($1) (`Var $1), $2)) }
@@ -583,12 +582,13 @@ plain_encoder_params:
583
582
  | LPAR encoder_params RPAR { $2 }
584
583
 
585
584
  optional_comma:
586
- | {}
587
585
  | COMMA {}
588
586
 
589
587
  record:
590
- | VAR GETS expr { [($1, $3)] }
591
- | record COMMA VAR GETS expr { $1@[($3,$5)] }
588
+ | VAR GETS expr { [`Method ($1, $3)] }
589
+ | DOTDOTDOT expr { [`Ellipsis $2] }
590
+ | record COMMA VAR GETS expr { $1@[`Method ($3,$5)] }
591
+ | record COMMA DOTDOTDOT expr { $1@[`Ellipsis $4] }
592
592
 
593
593
  string_interpolation:
594
594
  | BEGIN_INTERPOLATION string_interpolation_elems END_INTERPOLATION { $1, $2 }
@@ -168,7 +168,7 @@ and parsed_ast =
168
168
  | `Not of t
169
169
  | `Get of t
170
170
  | `Set of t * t
171
- | `Methods of methods
171
+ | `Methods of t option * methods list
172
172
  | `Negative of t
173
173
  | `Append of t * t
174
174
  | `Assoc of t * t
@@ -193,11 +193,7 @@ and t = {
193
193
  mutable comments : (Pos.t * comment) list;
194
194
  }
195
195
 
196
- and methods = {
197
- base : [ `None | `Spread of t | `Term of t ];
198
- methods : (string * t) list;
199
- }
200
-
196
+ and methods = [ `Ellipsis of t | `Method of string * t ]
201
197
  and string_interpolation = [ `String of string | `Term of t ]
202
198
 
203
199
  and encoder_params =
@@ -304,11 +300,11 @@ let rec iter_term fn ({ term } as tm) =
304
300
  iter_term fn tm'
305
301
  | `Parenthesis tm -> iter_term fn tm
306
302
  | `Block tm -> iter_term fn tm
307
- | `Methods { base; methods } ->
308
- (match base with
309
- | `None -> ()
310
- | `Spread tm | `Term tm -> iter_term fn tm);
311
- List.iter (fun (_, tm) -> iter_term fn tm) methods
303
+ | `Methods (base, methods) ->
304
+ (match base with None -> () | Some tm -> iter_term fn tm);
305
+ List.iter
306
+ (function `Method (_, tm) | `Ellipsis tm -> iter_term fn tm)
307
+ methods
312
308
  | `Int _ -> ()
313
309
  | `Float _ -> ()
314
310
  | `String _ -> ()
@@ -835,46 +835,46 @@ and to_term (tm : Parsed_term.t) : Term.t =
835
835
  | `Seq (({ term = `If_version _ } as t), t') ->
836
836
  concat_term (to_term t) (to_term t')
837
837
  | `Parenthesis tm | `Block tm -> to_term tm
838
- | `Methods { base; methods } ->
839
- let term, base_methods =
840
- match base with
841
- | `None -> (`Tuple [], Methods.empty)
842
- | `Term tm ->
843
- let { term; methods } = to_term tm in
844
- (term, methods)
845
- | `Spread tm ->
846
- let term = to_term tm in
847
- (* let _ = tm in let replaces _ = () in _ *)
848
- let { term; methods } =
838
+ | `Methods (base, methods) ->
839
+ (* let _ = src in
840
+ let replaces _ = dst in
841
+ _ *)
842
+ let replace_methods ~src dst =
843
+ mk ~pos:tm.pos
844
+ (`Let
845
+ {
846
+ doc = None;
847
+ replace = false;
848
+ pat = `PVar ["_"];
849
+ gen = [];
850
+ def = src;
851
+ body =
849
852
  mk ~pos:tm.pos
850
853
  (`Let
851
854
  {
852
855
  doc = None;
853
- replace = false;
856
+ replace = true;
854
857
  pat = `PVar ["_"];
855
858
  gen = [];
856
- def = term;
857
- body =
858
- mk ~pos:tm.pos
859
- (`Let
860
- {
861
- doc = None;
862
- replace = true;
863
- pat = `PVar ["_"];
864
- gen = [];
865
- def = mk ~pos:tm.pos (`Tuple []);
866
- body = mk ~pos:tm.pos (`Var "_");
867
- });
868
- })
869
- in
870
- (term, methods)
859
+ def = dst;
860
+ body = mk ~pos:tm.pos (`Var "_");
861
+ });
862
+ })
871
863
  in
872
- let methods =
873
- List.fold_left
874
- (fun methods (k, v) -> Methods.add k (to_term v) methods)
875
- base_methods methods
864
+ let term =
865
+ match base with
866
+ | None -> mk ~pos:tm.pos (`Tuple [])
867
+ | Some tm -> to_term tm
876
868
  in
877
- { t = Type.var ~pos:tm.pos (); term; methods }
869
+ List.fold_left
870
+ (fun term -> function
871
+ | `Ellipsis src -> replace_methods ~src:(to_term src) term
872
+ | `Method (name, tm) ->
873
+ {
874
+ term with
875
+ methods = Methods.add name (to_term tm) term.methods;
876
+ })
877
+ term methods
878
878
  | term ->
879
879
  let comments =
880
880
  List.filter_map
@@ -39,11 +39,11 @@ let readable f =
39
39
  let check_readable ?current_dir ~pos path =
40
40
  let resolved_path = resolve_path ?current_dir path in
41
41
  let details =
42
- if path = resolved_path then ""
43
- else " Given path: " ^ path ^ ", resolved path: " ^ resolved_path
42
+ if path = resolved_path then "Given path: " ^ path
43
+ else "Given path: " ^ path ^ ", resolved path: " ^ resolved_path
44
44
  in
45
45
  if not (Sys.file_exists resolved_path) then
46
- Runtime_error.raise ~pos ~message:("File not found!" ^ details) "not_found";
46
+ Runtime_error.raise ~pos ~message:("File not found! " ^ details) "not_found";
47
47
  if not (readable resolved_path) then
48
48
  Runtime_error.raise ~pos
49
49
  ~message:("File is not readable!" ^ details)
@@ -46,19 +46,32 @@ end
46
46
  # must return `null` or `""` when it has finished sending all its data.
47
47
  # @param ~append Append data if file exists.
48
48
  # @param ~perms Default file rights if created. Default: `0o644`.
49
- # @param path Path to write to
49
+ # @param path Path to write to.
50
50
  def replaces file.write(~data, ~perms=0o644, ~append=false, path) =
51
51
  cb = file.write.stream(append=append, perms=perms, path)
52
52
 
53
53
  def rec write() =
54
54
  s = getter.get(data) ?? ""
55
55
  cb(s)
56
- if getter.is_constant(data) then cb("") elsif s != "" then write() end
56
+ if
57
+ s == ""
58
+ then
59
+ ()
60
+ elsif getter.is_constant(data) then cb("")
61
+ elsif s != "" then write()
62
+ end
57
63
  end
58
64
 
59
65
  write()
60
66
  end
61
67
 
68
+ # Ensure that a file exists, creating it empty if it does not.
69
+ # @category File
70
+ # @param path Path of the file.
71
+ def file.touch(~perms=0o644, path) =
72
+ file.write(data="", perms=perms, append=true, path)
73
+ end
74
+
62
75
  # Read the whole contents of a file.
63
76
  # @category File
64
77
  def file.contents(fname) =
@@ -342,6 +342,7 @@ end
342
342
  # whole round ("randomize" mode), or pick a random file in the playlist each time \
343
343
  # ("random" mode).
344
344
  # @param ~native Use native implementation.
345
+ # @param ~on_done Function executed when the playlist is finished.
345
346
  # @param ~on_fail Function executed when too many requests failed and returning the contents of a fixed playlist.
346
347
  # @param ~on_reload Callback called after playlist has reloaded.
347
348
  # @param ~prefix Add a constant prefix to all requests. Useful for passing extra \
@@ -365,6 +366,7 @@ def replaces playlist(
365
366
  ~mime_type=null(),
366
367
  ~mode="randomize",
367
368
  ~native=false,
369
+ ~on_done={()},
368
370
  ~on_fail=null(),
369
371
  ~on_reload=(fun (_) -> ()),
370
372
  ~prefix="",
@@ -446,6 +448,7 @@ def replaces playlist(
446
448
  loop=loop,
447
449
  mode=mode,
448
450
  native=native,
451
+ on_done=on_done,
449
452
  on_loop=on_loop,
450
453
  on_fail=on_fail,
451
454
  timeout=timeout,
@@ -423,6 +423,9 @@ See <http://liquidsoap.info> for more information.
423
423
  ( ["--safe"],
424
424
  Arg.Unit (fun () -> Typing.do_occur_check := true),
425
425
  "Disable the effects of --unsafe." );
426
+ ( ["--no-fallible-check"],
427
+ Arg.Unit (fun () -> Output.fallibility_check := false),
428
+ "Ignore fallible sources." );
426
429
  ])
427
430
 
428
431
  let expand_options options =
@@ -479,13 +479,9 @@ let rec to_ast_json ~to_json = function
479
479
  ("optional", `Bool optional);
480
480
  ("meth", `Assoc (json_of_invoke_meth ~to_json meth));
481
481
  ]
482
- | `Methods { base; methods } ->
482
+ | `Methods (base, methods) ->
483
483
  let base, base_methods =
484
- match base with
485
- | `None -> (`Null, [])
486
- | `Term t -> (to_json t, [])
487
- | `Spread t ->
488
- (`Null, [`Assoc (ast_node ~typ:"ellipsis" [("value", to_json t)])])
484
+ match base with None -> (`Null, []) | Some t -> (to_json t, [])
489
485
  in
490
486
  ast_node ~typ:"methods"
491
487
  [
@@ -493,10 +489,13 @@ let rec to_ast_json ~to_json = function
493
489
  ( "methods",
494
490
  `Tuple
495
491
  (List.map
496
- (fun (k, v) ->
497
- `Assoc
498
- (ast_node ~typ:"method"
499
- [("name", `String k); ("value", to_json v)]))
492
+ (function
493
+ | `Ellipsis v ->
494
+ `Assoc (ast_node ~typ:"ellipsis" [("value", to_json v)])
495
+ | `Method (k, v) ->
496
+ `Assoc
497
+ (ast_node ~typ:"method"
498
+ [("name", `String k); ("value", to_json v)]))
500
499
  methods
501
500
  @ base_methods) );
502
501
  ]
@@ -30,6 +30,10 @@ def f() =
30
30
  dst_file3 = path.concat(tmpdir, "test-dst-file3")
31
31
  file.move(src_file, dst_file3)
32
32
  test.equals(file.exists(dst_file3), true)
33
+
34
+ file.touch("test-dst-file4")
35
+ test.equals(file.exists("test-dst-file4"), true)
36
+
33
37
  test.pass()
34
38
  end
35
39
 
@@ -275,6 +275,39 @@ def f() =
275
275
  y = x.{foo=123} - 3
276
276
  test.equals("#{y}", "#{-2}")
277
277
 
278
+ x = {foo=123}
279
+ y = {gni="aabb"}
280
+ test.equals({...x, ...y}, {foo=123, gni="aabb"})
281
+ test.equals({...x, gna=3.14, ...y}, {foo=123, bla=3.14, gni="aabb"})
282
+ test.equals(
283
+ {...x, gna=3.14, ...y, foo="bar"}, {foo="bar", bla=3.14, gni="aabb"}
284
+ )
285
+
286
+ x = {foo=1}
287
+ y = {foo=2}
288
+ test.equals({...x, ...y}, {foo=2})
289
+ test.equals({...y, ...x}, {foo=1})
290
+
291
+ x = {foo=1}
292
+ y = {foo=null()}
293
+ test.equals({...x, ...y}, {foo=null()})
294
+ test.equals({...y, ...x}, {foo=1})
295
+
296
+ x = {foo=null()}
297
+ y = {foo=null()}
298
+ test.equals({...x, ...y}, {foo=null()})
299
+ test.equals({...y, ...x}, {foo=null()})
300
+
301
+ x = {foo=1}
302
+ y = {foo="a"}
303
+ test.equals({...x, ...y}, {foo="a"})
304
+ test.equals({...y, ...x}, {foo=1})
305
+
306
+ x = {foo=1}
307
+ y = {foo={bar=1}}
308
+ test.equals({...x, ...y}, {foo={bar=1}})
309
+ test.equals({...y, ...x}, {foo=1})
310
+
278
311
  test.pass()
279
312
  end
280
313
 
@@ -27,6 +27,8 @@ def f() =
27
27
  t(r/bla$/m.test("bla\ngni"), true)
28
28
  t(r/./.test("\n"), false)
29
29
  t(r/./s.test("\n"), true)
30
+ t(r/^\/bla/.test("/blabla"), true)
31
+ t(r/^\/bla/.test("blabla"), false)
30
32
 
31
33
  # Test replace
32
34
  t(r/gni/.replace(fun (_) -> "gno", "blagniblagnibla"), "blagnoblagnibla")