expo-print 12.3.0 → 12.4.1

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.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,18 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 12.4.1 — 2023-06-27
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - Fixed a regression after refactoring to Swift (restore functionality to print from web url or data string). ([#22997](https://github.com/expo/expo/pull/22997) by [@mroswald](https://github.com/mroswald), [@behenate](https://github.com/behenate))
18
+
19
+ ## 12.4.0 — 2023-06-21
20
+
21
+ ### 🐛 Bug fixes
22
+
23
+ - Fixed Android build warnings for Gradle version 8. ([#22537](https://github.com/expo/expo/pull/22537), [#22609](https://github.com/expo/expo/pull/22609) by [@kudo](https://github.com/kudo))
24
+
13
25
  ## 12.3.0 — 2023-05-08
14
26
 
15
27
  ### 🎉 New features
package/README.md CHANGED
@@ -1,4 +1,11 @@
1
- # expo-print
1
+ <p>
2
+ <a href="https://docs.expo.dev/versions/latest/sdk/print/">
3
+ <img
4
+ src="../../.github/resources/expo-print.svg"
5
+ alt="expo-print"
6
+ height="64" />
7
+ </a>
8
+ </p>
2
9
 
3
10
  Provides an API for iOS (AirPrint) and Android printing functionality.
4
11
 
@@ -3,7 +3,7 @@ apply plugin: 'kotlin-android'
3
3
  apply plugin: 'maven-publish'
4
4
 
5
5
  group = 'host.exp.exponent'
6
- version = '12.3.0'
6
+ version = '12.4.1'
7
7
 
8
8
  buildscript {
9
9
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
@@ -35,19 +35,11 @@ buildscript {
35
35
  }
36
36
  }
37
37
 
38
- // Creating sources with comments
39
- task androidSourcesJar(type: Jar) {
40
- classifier = 'sources'
41
- from android.sourceSets.main.java.srcDirs
42
- }
43
-
44
38
  afterEvaluate {
45
39
  publishing {
46
40
  publications {
47
41
  release(MavenPublication) {
48
42
  from components.release
49
- // Add additional sourcesJar to artifacts
50
- artifact(androidSourcesJar)
51
43
  }
52
44
  }
53
45
  repositories {
@@ -70,15 +62,21 @@ android {
70
62
  jvmTarget = JavaVersion.VERSION_11.majorVersion
71
63
  }
72
64
 
65
+ namespace "expo.modules.print"
73
66
  defaultConfig {
74
67
  minSdkVersion safeExtGet("minSdkVersion", 21)
75
68
  targetSdkVersion safeExtGet("targetSdkVersion", 33)
76
69
  versionCode 27
77
- versionName "12.3.0"
70
+ versionName "12.4.1"
78
71
  }
79
72
  lintOptions {
80
73
  abortOnError false
81
74
  }
75
+ publishing {
76
+ singleVariant("release") {
77
+ withSourcesJar()
78
+ }
79
+ }
82
80
  }
83
81
 
84
82
  dependencies {
@@ -1,5 +1,3 @@
1
-
2
- <manifest package="expo.modules.print">
1
+ <manifest>
3
2
 
4
3
  </manifest>
5
-
@@ -4,6 +4,8 @@ public class ExpoPrintWithPrinter {
4
4
  var renderTasks: [ExpoWKPDFRenderer] = []
5
5
  var cachedPrinters: [String: UIPrinter] = [:]
6
6
  let delegate: ExpoPrintModuleDelegate
7
+ let printURLSession = URLSession(configuration: .default)
8
+ var dataTask: URLSessionDataTask?
7
9
 
8
10
  init(delegate: ExpoPrintModuleDelegate) {
9
11
  self.delegate = delegate
@@ -11,15 +13,16 @@ public class ExpoPrintWithPrinter {
11
13
 
12
14
  func startPrint(options: PrintOptions, promise: Promise) {
13
15
  if let uri = options.uri {
14
- guard let printingData = dataFromUri(uri: uri) else {
15
- promise.reject(InvalidUrlException())
16
- return
16
+ dataFromUri(uri: uri) { [weak self] data in
17
+ if let self = self, let printingData = data {
18
+ self.printWithData(printingData: printingData, options: options, promise: promise)
19
+ } else {
20
+ promise.reject(InvalidUrlException())
21
+ }
17
22
  }
18
- printWithData(printingData: printingData, options: options, promise: promise)
23
+ return
19
24
  }
20
25
 
21
- let pageSize = options.toPageSize()
22
- let printableRect = options.toPrintableRect()
23
26
  // Do this for compatibility with deprecated markup formatter option
24
27
  guard let htmlString = options.markupFormatterIOS ?? options.html else {
25
28
  promise.reject(NoPrintDataException())
@@ -137,11 +140,36 @@ public class ExpoPrintWithPrinter {
137
140
  return printInteractionController
138
141
  }
139
142
 
140
- private func dataFromUri(uri: String) -> Data? {
141
- do {
142
- return try Data(contentsOf: URL(fileURLWithPath: uri))
143
- } catch {
144
- return nil
143
+ private func dataFromUri(uri: String, completion: @escaping (Data?) -> Void) {
144
+ guard var url = URL(string: uri) else {
145
+ completion(nil)
146
+ return
147
+ }
148
+
149
+ // Assume that URLs without a scheme eq. /home/user/file.pdf will be local file urls
150
+ if url.scheme == nil {
151
+ url = URL(fileURLWithPath: uri)
152
+ }
153
+
154
+ // process http and https requests asynchronously
155
+ if url.scheme == "http" || url.scheme == "https" {
156
+ dataTask = printURLSession.dataTask(with: URLRequest(url: url)) { [weak self] data, response, error in
157
+ defer {
158
+ self?.dataTask = nil
159
+ }
160
+
161
+ if error == nil, let response = response as? HTTPURLResponse, response.statusCode == 200 {
162
+ DispatchQueue.main.async {
163
+ completion(data)
164
+ }
165
+ return
166
+ }
167
+ completion(nil)
168
+ }
169
+ dataTask?.resume()
170
+ } else {
171
+ let data = try? Data(contentsOf: url)
172
+ completion(data)
145
173
  }
146
174
  }
147
175
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-print",
3
- "version": "12.3.0",
3
+ "version": "12.4.1",
4
4
  "description": "Provides an API for iOS (AirPrint) and Android printing functionality.",
5
5
  "main": "build/Print.js",
6
6
  "types": "build/Print.d.ts",
@@ -40,5 +40,5 @@
40
40
  "peerDependencies": {
41
41
  "expo": "*"
42
42
  },
43
- "gitHead": "4ba50c428c8369bb6b3a51a860d4898ad4ccbe78"
43
+ "gitHead": "aa6bda733cef821234c77a19bbe6008b72c1c594"
44
44
  }