imsg-grep 0.1.6.pre-darwin → 0.1.8-darwin

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: 40b1912c5695bdf6be658c8d149f5ff994b779116d3005e8e8efa53e8eb4f299
4
- data.tar.gz: d01d37b5ec34c20eaaaaa013a3175ffd4eff37313379fdcda2b39944ca74f827
3
+ metadata.gz: f76e2f8bd190242f5894404a9a7e06d27a326f9c9ac53a554b0737de814368de
4
+ data.tar.gz: 0e132c730b11b689ea2c49dc54d169e6cdd8e04224069ead6ef76c1bb047e08e
5
5
  SHA512:
6
- metadata.gz: ba85f02f8e8b742387049b381a042caa136da0cea1f78b622ee1fa5916e81c6be0a6755173e880276a692fd8b1c8ab17975759067b16c713090baf120c9b9ea9
7
- data.tar.gz: 23df2fbe2ea59d443f7346faeb66dc805724ef65aacf29a79c86d8612bba84d590f7b00af4d32ed51f0bfefd98f926f07014b1986ebb824eeab1abfa89045fb5
6
+ metadata.gz: 195e09aba5f3dff9d9ccf557a76daf28052cc3960762cf9f31455b853363df0ce889be7a1b3f3e109b2e7b34a51ad9a4499bccc598f6b43b15676b08feceee7d
7
+ data.tar.gz: 0c0fd316926a265389611ea3aee83c867829a22059117534b7a949395d0ef81d15295ea09d8fc885d4d03ba215845c4556d3d3f804dcfbfd1f5bfb0684abb66e
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # imsg-grep
1
+ # imsg-grep
2
2
 
3
3
  Search and filter iMessage history from command line.
4
4
 
5
+ <img width="721" height="406" alt="preview" src="https://github.com/user-attachments/assets/c935e32f-4373-4205-97e2-3fc44b2e6f82" />
6
+
5
7
  ## Features
6
8
 
7
9
  Search iMessage history with regex patterns, date ranges, and participant filters. Extract links and media files. Output text or JSON.
@@ -26,6 +28,7 @@ swiftc for development. (run `rake build:lib`)
26
28
  ## Installing
27
29
 
28
30
  ```
31
+ brew install ruby
29
32
  gem install imsg-grep
30
33
  ```
31
34
 
data/bin/img2png ADDED
Binary file
data/bin/imsg-grep CHANGED
@@ -340,6 +340,11 @@ begin
340
340
  end
341
341
  end
342
342
 
343
+ if preview? && !$stdout.tty?
344
+ warn! "previews disabled: stdout not a tty"
345
+ @preview = nil
346
+ end
347
+
343
348
  ################################################################################
344
349
  ### build sql query ############################################################
345
350
  ################################################################################
@@ -578,12 +583,12 @@ begin
578
583
  messages.each do |msg|
579
584
  preview?(:links) and
580
585
  link = msg[:link] and
586
+ link.tap{ it[:guid] = msg[:guid] } and # adding guid ensures link is a uniq key so identical links dont overwrite the prev
581
587
  @link_images[link] = Concurrent::Promises.future_on(POOL, msg) do |msg|
582
- ix = link[:image_idx] or next
583
- file = msg.dig(:files, ix) or next
584
- path = file[:filename] or next
585
- path = File.expand_path path
586
- File.exist?(path) or next
588
+ ix = link[:image_idx] and
589
+ file = msg.dig(:files, ix) and
590
+ path = file[:filename] and
591
+ path = File.expand_path(path) and File.exist?(path) and
587
592
  img = Imaginator::Image.new(path).load or next
588
593
  fit, fits = img.fit @link_preview_cols, @link_preview_min_rows
589
594
  png = img.png_transform w:fit.w, h:fit.h, pad_w:fits[:cfit].pad_w
@@ -595,11 +600,11 @@ begin
595
600
  [fit, png, img]
596
601
  end
597
602
  msg[:images] = msg[:files].select{ it[:mime_type]&.start_with?('image/') }
598
- preview?(:images) and msg[:images].each do |im|
603
+ preview?(:images) and
604
+ msg[:images].each do |im|
599
605
  @images[im] = Concurrent::Promises.future_on(POOL, im) do |im|
600
- path = im[:filename] or next
601
- path = File.expand_path path
602
- File.exist?(path) or next
606
+ path = im[:filename] and
607
+ path = File.expand_path(path) and File.exist?(path) and
603
608
  img = Imaginator::Image.new(path).load or next
604
609
  fit, = img.fit 25, @img_rows
605
610
  png = img.png_transform w:fit.w, h:fit.h
@@ -1 +1 @@
1
- 0.1.6.pre
1
+ 0.1.8
@@ -60,20 +60,16 @@ module Imaginator
60
60
 
61
61
  end
62
62
 
63
-
64
63
  def term_seq(seq, end_marker)
65
- t = ->{ Process.clock_gettime Process::CLOCK_MONOTONIC }
66
- buf = ""
64
+ buf = +""
67
65
  IO.console.raw do |tty|
68
66
  tty << seq
69
67
  tty.flush
70
- timeout = t.() + 0.1
71
68
  loop do
72
- buf << tty.read_nonblock(1)
73
69
  break if buf.end_with? end_marker
74
- rescue IO::WaitReadable
75
- break if t.() > timeout
76
- IO.select([tty], nil, nil, 0.01)
70
+ break unless tty.wait_readable(0.05)
71
+ buf << tty.read_nonblock(4096)
72
+ rescue IO::WaitReadable, EOFError
77
73
  end
78
74
  end
79
75
  buf
Binary file
@@ -1,22 +1,20 @@
1
- require "fiddle"
2
- require "fiddle/import"
1
+ require "ffi"
3
2
 
4
3
  module Img2png
5
- extend Fiddle::Importer
4
+ extend FFI::Library
5
+ ffi_lib "#{__dir__}/img2png.dylib"
6
6
 
7
- dlload "#{__dir__}/img2png.dylib"
8
-
9
- extern "void* img2png_load_path(char*, int*, int*)"
10
- extern "void* img2png_load(void*, int, int*, int*)"
11
- extern "int img2png_convert(void*, int, int, int, int, void**, int*)"
12
- extern "void img2png_release(void*)"
13
- extern "void img2png_free(void*)"
7
+ attach_function :img2png_load_path, [:string, :pointer, :pointer], :pointer, blocking: true
8
+ attach_function :img2png_load, [:pointer, :int, :pointer, :pointer], :pointer, blocking: true
9
+ attach_function :img2png_convert, [:pointer, :int, :int, :int, :int, :pointer, :pointer], :bool, blocking: true
10
+ attach_function :img2png_release, [:pointer], :void
11
+ attach_function :img2png_free, [:pointer], :void
14
12
 
15
13
  class Image
16
- def initialize(path: nil, data: nil)
14
+ def initialize(path:nil, data:nil)
17
15
  [path, data].compact.size == 1 or raise ArgumentError, "One of path: or data: must be specified"
18
- out_w = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
19
- out_h = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
16
+ out_w = FFI::MemoryPointer.new(:int)
17
+ out_h = FFI::MemoryPointer.new(:int)
20
18
 
21
19
  @handle = case
22
20
  when data then Img2png.img2png_load(data, data.bytesize, out_w, out_h)
@@ -24,15 +22,15 @@ module Img2png
24
22
  end
25
23
  raise "Failed to load image" if @handle.null?
26
24
 
27
- @width = out_w[0, Fiddle::SIZEOF_INT].unpack1("i")
28
- @height = out_h[0, Fiddle::SIZEOF_INT].unpack1("i")
25
+ @width = out_w.read_int
26
+ @height = out_h.read_int
29
27
  end
30
28
 
31
29
  def dimensions = [@width, @height]
32
30
 
33
31
  def convert(fit_w: nil, fit_h: nil, box_w: nil, box_h: nil)
34
- out_data = Fiddle::Pointer.malloc(Fiddle::SIZEOF_VOIDP)
35
- out_len = Fiddle::Pointer.malloc(Fiddle::SIZEOF_INT)
32
+ out_data = FFI::MemoryPointer.new(:pointer)
33
+ out_len = FFI::MemoryPointer.new(:int)
36
34
 
37
35
  success = Img2png.img2png_convert(
38
36
  @handle,
@@ -41,18 +39,18 @@ module Img2png
41
39
  out_data, out_len
42
40
  )
43
41
 
44
- return nil if success == 0
42
+ return nil unless success
45
43
 
46
- ptr = Fiddle::Pointer.new(out_data[0, Fiddle::SIZEOF_VOIDP].unpack1("J"))
47
- len = out_len[0, Fiddle::SIZEOF_INT].unpack1("i")
48
- result = ptr[0, len]
44
+ ptr = out_data.read_pointer
45
+ len = out_len.read_int
46
+ result = ptr.read_bytes(len)
49
47
  Img2png.img2png_free(ptr)
50
48
  result
51
49
  end
52
50
 
53
51
  def release
54
52
  Img2png.img2png_release(@handle) unless @handle.null?
55
- @handle = Fiddle::NULL
53
+ @handle = FFI::Pointer::NULL
56
54
  end
57
55
 
58
56
  def self.finalize(handle)
@@ -65,7 +63,7 @@ end
65
63
  # input = File.binread("x.heic")
66
64
 
67
65
  # # Load once, use multiple times
68
- # img = Img2png::Image.new(data: input)
66
+ # img = Img2png::Image.new(input)
69
67
 
70
68
  # # Get dimensions
71
69
  # p img.dimensions # => [4032, 3024]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imsg-grep
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6.pre
4
+ version: 0.1.8
5
5
  platform: darwin
6
6
  authors:
7
7
  - Caio Chassot
@@ -24,19 +24,19 @@ dependencies:
24
24
  - !ruby/object:Gem::Version
25
25
  version: '0.3'
26
26
  - !ruby/object:Gem::Dependency
27
- name: fiddle
27
+ name: ffi
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - "~>"
31
31
  - !ruby/object:Gem::Version
32
- version: 1.1.8
32
+ version: '1.17'
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
- version: 1.1.8
39
+ version: '1.17'
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: io-console
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -173,6 +173,7 @@ extra_rdoc_files: []
173
173
  files:
174
174
  - LICENSE
175
175
  - README.md
176
+ - bin/img2png
176
177
  - bin/imsg-grep
177
178
  - bin/msg-info
178
179
  - bin/sql-shell
@@ -210,7 +211,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
210
211
  - !ruby/object:Gem::Version
211
212
  version: '0'
212
213
  requirements: []
213
- rubygems_version: 4.0.0
214
+ rubygems_version: 4.0.3
214
215
  specification_version: 4
215
216
  summary: iMessage database search
216
217
  test_files: []