sghtmltopdf 0.2.0 → 0.3.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2407abed524ac92ff4eedd07820136364dc3165ab456cbac689a069cefab60e
4
- data.tar.gz: b851afb780f94f122526e0225b893daee84ce274d600a6a443944f1299b3e4f1
3
+ metadata.gz: de56b0b878dc4ce3c0150d6f2b51e506820b28cd2bcc0577b57b8335ec6e3a90
4
+ data.tar.gz: 0f91a87de49fb27ea32d627873be0c4fe743c54ea38f69ce94f696c2d5791a17
5
5
  SHA512:
6
- metadata.gz: 1e4ea096b42a680a212b681e9822606e20feec07661ad20ca8bfab04533cab58213b58c7c3f63f1c790c73b23361203355f3e54574dc794974c0fc610aab502a
7
- data.tar.gz: 892059d9f349d9073e3e53eb2b342d316083f634506c03662e75cafefcb5f94c506f5c62445fa0611eb7a3dd54acdb21f90ac01b42adf807fb5116df62d4e9ad
6
+ metadata.gz: 89dd71b47c89519290464731545bddee9fc7aa0364f8809db73478eec7a451834f453fce779698cad431a7d63aca40231c7ffd0e33dd4b543be0804d826bf0a5
7
+ data.tar.gz: 5f5444730f3d61dcc1efbf8c0925ca41b1868203460cbc6c53b9da6dae2c88c0e30d341df578313c276e69a574d4bd7d24d1f0ec32b7252b0beb44a76a3026c1
data/Cargo.lock CHANGED
@@ -32,6 +32,12 @@ dependencies = [
32
32
  "num-traits",
33
33
  ]
34
34
 
35
+ [[package]]
36
+ name = "arrayref"
37
+ version = "0.3.9"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "76a2e8124351fda1ef8aaaa3bbd7ebbcb486bbcd4225aca0aa0d84bb2db8fecb"
40
+
35
41
  [[package]]
36
42
  name = "arrayvec"
37
43
  version = "0.7.8"
@@ -228,6 +234,12 @@ dependencies = [
228
234
  "syn 2.0.119",
229
235
  ]
230
236
 
237
+ [[package]]
238
+ name = "data-url"
239
+ version = "0.3.2"
240
+ source = "registry+https://github.com/rust-lang/crates.io-index"
241
+ checksum = "be1e0bca6c3637f992fc1cc7cbc52a78c1ef6db076dbf1059c4323d6a2048376"
242
+
231
243
  [[package]]
232
244
  name = "derive_more"
233
245
  version = "2.1.1"
@@ -279,6 +291,15 @@ dependencies = [
279
291
  "cfg-if",
280
292
  ]
281
293
 
294
+ [[package]]
295
+ name = "euclid"
296
+ version = "0.22.14"
297
+ source = "registry+https://github.com/rust-lang/crates.io-index"
298
+ checksum = "f1a05365e3b1c6d1650318537c7460c6923f1abdd272ad6842baa2b509957a06"
299
+ dependencies = [
300
+ "num-traits",
301
+ ]
302
+
282
303
  [[package]]
283
304
  name = "fast-srgb8"
284
305
  version = "1.0.0"
@@ -316,6 +337,12 @@ dependencies = [
316
337
  "miniz_oxide",
317
338
  ]
318
339
 
340
+ [[package]]
341
+ name = "float-cmp"
342
+ version = "0.9.0"
343
+ source = "registry+https://github.com/rust-lang/crates.io-index"
344
+ checksum = "98de4bbd547a563b716d8dfa9aad1cb19bfab00f4fa09a6a4ed21dbcf44ce9c4"
345
+
319
346
  [[package]]
320
347
  name = "font-types"
321
348
  version = "0.12.2"
@@ -437,6 +464,12 @@ dependencies = [
437
464
  "quick-error",
438
465
  ]
439
466
 
467
+ [[package]]
468
+ name = "imagesize"
469
+ version = "0.13.0"
470
+ source = "registry+https://github.com/rust-lang/crates.io-index"
471
+ checksum = "edcd27d72f2f071c64249075f42e205ff93c9a4c5f6c6da53e79ed9f9832c285"
472
+
440
473
  [[package]]
441
474
  name = "itertools"
442
475
  version = "0.13.0"
@@ -452,6 +485,17 @@ version = "1.0.18"
452
485
  source = "registry+https://github.com/rust-lang/crates.io-index"
453
486
  checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
454
487
 
488
+ [[package]]
489
+ name = "kurbo"
490
+ version = "0.11.3"
491
+ source = "registry+https://github.com/rust-lang/crates.io-index"
492
+ checksum = "c62026ae44756f8a599ba21140f350303d4f08dcdcc71b5ad9c9bb8128c13c62"
493
+ dependencies = [
494
+ "arrayvec",
495
+ "euclid",
496
+ "smallvec",
497
+ ]
498
+
455
499
  [[package]]
456
500
  name = "lazy_static"
457
501
  version = "1.5.0"
@@ -643,9 +687,9 @@ dependencies = [
643
687
 
644
688
  [[package]]
645
689
  name = "pdf-writer"
646
- version = "0.15.0"
690
+ version = "0.12.1"
647
691
  source = "registry+https://github.com/rust-lang/crates.io-index"
648
- checksum = "f5e456864a7a304047bff84977dc6fb162bd956475d40ba50b2dcecaada7f753"
692
+ checksum = "5df03c7d216de06f93f398ef06f1385a60f2c597bb96f8195c8d98e08a26b1d5"
649
693
  dependencies = [
650
694
  "bitflags",
651
695
  "itoa",
@@ -712,6 +756,12 @@ dependencies = [
712
756
  "siphasher",
713
757
  ]
714
758
 
759
+ [[package]]
760
+ name = "pico-args"
761
+ version = "0.5.0"
762
+ source = "registry+https://github.com/rust-lang/crates.io-index"
763
+ checksum = "5be167a7af36ee22fe3115051bc51f6e6c7054c9348e28deb4f49bd6f705a315"
764
+
715
765
  [[package]]
716
766
  name = "png"
717
767
  version = "0.18.1"
@@ -1000,7 +1050,7 @@ dependencies = [
1000
1050
 
1001
1051
  [[package]]
1002
1052
  name = "sghtmltopdf"
1003
- version = "0.2.0"
1053
+ version = "0.3.0"
1004
1054
  dependencies = [
1005
1055
  "magnus",
1006
1056
  "rb-sys",
@@ -1009,7 +1059,7 @@ dependencies = [
1009
1059
 
1010
1060
  [[package]]
1011
1061
  name = "sghtmltopdf-core"
1012
- version = "0.2.0"
1062
+ version = "0.3.0"
1013
1063
  dependencies = [
1014
1064
  "base64",
1015
1065
  "clap",
@@ -1029,6 +1079,7 @@ dependencies = [
1029
1079
  "self_cell",
1030
1080
  "skrifa",
1031
1081
  "subsetter",
1082
+ "svg2pdf",
1032
1083
  "taffy",
1033
1084
  "ureq",
1034
1085
  ]
@@ -1057,6 +1108,15 @@ version = "0.3.10"
1057
1108
  source = "registry+https://github.com/rust-lang/crates.io-index"
1058
1109
  checksum = "3a219298ac11a56ea9a6d2120044824d6f01aeb034955e7af7bc16858527deea"
1059
1110
 
1111
+ [[package]]
1112
+ name = "simplecss"
1113
+ version = "0.2.2"
1114
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1115
+ checksum = "7a9c6883ca9c3c7c90e888de77b7a5c849c779d25d74a1269b0218b14e8b136c"
1116
+ dependencies = [
1117
+ "log",
1118
+ ]
1119
+
1060
1120
  [[package]]
1061
1121
  name = "siphasher"
1062
1122
  version = "1.0.3"
@@ -1094,6 +1154,15 @@ version = "1.2.1"
1094
1154
  source = "registry+https://github.com/rust-lang/crates.io-index"
1095
1155
  checksum = "6ce2be8dc25455e1f91df71bfa12ad37d7af1092ae736f3a6cd0e37bc7810596"
1096
1156
 
1157
+ [[package]]
1158
+ name = "strict-num"
1159
+ version = "0.1.1"
1160
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1161
+ checksum = "6637bab7722d379c8b41ba849228d680cc12d0a45ba1fa2b48f2a30577a06731"
1162
+ dependencies = [
1163
+ "float-cmp",
1164
+ ]
1165
+
1097
1166
  [[package]]
1098
1167
  name = "string_cache"
1099
1168
  version = "0.9.0"
@@ -1139,6 +1208,29 @@ version = "2.6.1"
1139
1208
  source = "registry+https://github.com/rust-lang/crates.io-index"
1140
1209
  checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
1141
1210
 
1211
+ [[package]]
1212
+ name = "svg2pdf"
1213
+ version = "0.13.0"
1214
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1215
+ checksum = "e50dc062439cc1a396181059c80932a6e6bd731b130e674c597c0c8874b6df22"
1216
+ dependencies = [
1217
+ "log",
1218
+ "miniz_oxide",
1219
+ "once_cell",
1220
+ "pdf-writer",
1221
+ "usvg",
1222
+ ]
1223
+
1224
+ [[package]]
1225
+ name = "svgtypes"
1226
+ version = "0.15.3"
1227
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1228
+ checksum = "68c7541fff44b35860c1a7a47a7cadf3e4a304c457b58f9870d9706ece028afc"
1229
+ dependencies = [
1230
+ "kurbo",
1231
+ "siphasher",
1232
+ ]
1233
+
1142
1234
  [[package]]
1143
1235
  name = "syn"
1144
1236
  version = "2.0.119"
@@ -1182,6 +1274,17 @@ dependencies = [
1182
1274
  "new_debug_unreachable",
1183
1275
  ]
1184
1276
 
1277
+ [[package]]
1278
+ name = "tiny-skia-path"
1279
+ version = "0.11.4"
1280
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1281
+ checksum = "9c9e7fc0c2e86a30b117d0462aa261b72b7a99b7ebd7deb3a14ceda95c5bdc93"
1282
+ dependencies = [
1283
+ "arrayref",
1284
+ "bytemuck",
1285
+ "strict-num",
1286
+ ]
1287
+
1185
1288
  [[package]]
1186
1289
  name = "tinyvec"
1187
1290
  version = "1.12.0"
@@ -1238,6 +1341,28 @@ dependencies = [
1238
1341
  "log",
1239
1342
  ]
1240
1343
 
1344
+ [[package]]
1345
+ name = "usvg"
1346
+ version = "0.45.1"
1347
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1348
+ checksum = "80be9b06fbae3b8b303400ab20778c80bbaf338f563afe567cf3c9eea17b47ef"
1349
+ dependencies = [
1350
+ "base64",
1351
+ "data-url",
1352
+ "flate2",
1353
+ "imagesize",
1354
+ "kurbo",
1355
+ "log",
1356
+ "pico-args",
1357
+ "roxmltree",
1358
+ "simplecss",
1359
+ "siphasher",
1360
+ "strict-num",
1361
+ "svgtypes",
1362
+ "tiny-skia-path",
1363
+ "xmlwriter",
1364
+ ]
1365
+
1241
1366
  [[package]]
1242
1367
  name = "utf8-zero"
1243
1368
  version = "0.8.1"
@@ -1356,6 +1481,12 @@ version = "0.52.6"
1356
1481
  source = "registry+https://github.com/rust-lang/crates.io-index"
1357
1482
  checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1358
1483
 
1484
+ [[package]]
1485
+ name = "xmlwriter"
1486
+ version = "0.1.0"
1487
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1488
+ checksum = "ec7a2a501ed189703dba8b08142f057e887dfc4b2cc4db2d343ac6376ba3e0b9"
1489
+
1359
1490
  [[package]]
1360
1491
  name = "zeroize"
1361
1492
  version = "1.9.0"
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "sghtmltopdf"
3
- version = "0.2.0"
3
+ version = "0.3.0"
4
4
  edition = "2021"
5
5
  publish = false
6
6
  description = "Ruby binding for sghtmltopdf (see bindings/ruby)"
@@ -15,6 +15,8 @@ magnus = { version = "0.8", features = ["rb-sys"] }
15
15
  # GVL解放(`rb_thread_call_without_gvl`)はmagnusに無いので直接呼ぶ。
16
16
  rb-sys = "0.9"
17
17
  # HTTPサーバ(tiny_http)は要らないので`server` featureは外す。
18
+ # `svg`はCLIと同じ既定に揃える(gemからもSVGを描画できるようにする)。
18
19
  sghtmltopdf-core = { path = "../../../../core", default-features = false, features = [
19
20
  "cli",
21
+ "svg",
20
22
  ] }
@@ -8,7 +8,7 @@
8
8
  //! 走らせると深さ200弱でスタックを溢れさせる。しかもGVLを解放した状態で
9
9
  //! ガードページに触れるため、プロセスが落ちるのではなくスレッドが固まる。
10
10
  //!
11
- //! そこでレンダリングは[`sghtmltopdf_core::cli::STACK_SIZE`]のスタックを
11
+ //! そこでレンダリングは[`sghtmltopdf_core::render_stack::STACK_SIZE`]のスタックを
12
12
  //! 明示的に確保した専用スレッドで走らせ、確定したチャンクはチャネル越しに
13
13
  //! 元のスレッドへ渡す。Rubyへ触れるのは元のスレッドだけに限る。
14
14
  //!
@@ -292,7 +292,8 @@ pub fn pump_to_block<F>(
292
292
  where
293
293
  F: FnOnce(ChannelSink) -> Result<(), sghtmltopdf_core::cli::CliError> + Send + 'static,
294
294
  {
295
- use sghtmltopdf_core::cli::{CliError, STACK_SIZE};
295
+ use sghtmltopdf_core::cli::CliError;
296
+ use sghtmltopdf_core::render_stack::STACK_SIZE;
296
297
 
297
298
  // どちらも容量0のrendezvous。レンダリング側は1チャンクごとに
298
299
  // ブロックの完了を待つ。
@@ -14,6 +14,7 @@ use std::path::PathBuf;
14
14
  use magnus::rb_sys::AsRawValue;
15
15
  use magnus::{block::Proc, function, prelude::*, Error, RString, Ruby};
16
16
  use sghtmltopdf_core::cli::{self, convert};
17
+ use sghtmltopdf_core::render_stack;
17
18
  use sghtmltopdf_core::sink::{FileSink, MemorySink};
18
19
 
19
20
  use callback_sink::{pump_to_block, BlockSlot, PendingUnwind, ValueSlot};
@@ -36,7 +37,7 @@ fn render_inner(html: Vec<u8>, argv: Vec<String>) -> Result<RString, Error> {
36
37
  // レイアウト・描画の再帰に耐えられないため(`callback_sink`のモジュール
37
38
  // doc参照)。この経路はRubyへコールバックしないので、そのまま移せる。
38
39
  let pdf = gvl::without_gvl(move || {
39
- cli::with_render_stack(move || {
40
+ render_stack::with_render_stack(move || {
40
41
  convert::render_to_memory(&args, &fonts, Cursor::new(html), MemorySink::new())
41
42
  })
42
43
  })
@@ -69,7 +70,7 @@ fn render_to_file_inner(html: Vec<u8>, argv: Vec<String>, path: String) -> Resul
69
70
  })?;
70
71
 
71
72
  gvl::without_gvl(move || {
72
- cli::with_render_stack(move || convert::render(&args, &fonts, Cursor::new(html), sink))
73
+ render_stack::with_render_stack(move || convert::render(&args, &fonts, Cursor::new(html), sink))
73
74
  })
74
75
  .map_err(|e| errors::to_ruby(&ruby, e))?;
75
76
  Ok(())
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sghtmltopdf
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sghtmltopdf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - yo_waka