expo-print 12.4.1 → 12.5.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.
- package/CHANGELOG.md +10 -0
- package/android/build.gradle +2 -2
- package/build/Print.d.ts.map +1 -1
- package/build/Print.js +11 -1
- package/build/Print.js.map +1 -1
- package/ios/ExpoPrintModule.swift +9 -0
- package/ios/PrintOptions.swift +6 -3
- package/package.json +2 -2
- package/src/Print.ts +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 12.5.0 — 2023-07-28
|
|
14
|
+
|
|
15
|
+
_This version does not introduce any user-facing changes._
|
|
16
|
+
|
|
17
|
+
## 12.4.2 — 2023-06-28
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Fixed missing constants on iOS, restricted possibility of starting multiple print jobs at once, which would lead to crashes. ([#23128](https://github.com/expo/expo/pull/23128) by [@behenate](https://github.com/behenate))
|
|
22
|
+
|
|
13
23
|
## 12.4.1 — 2023-06-27
|
|
14
24
|
|
|
15
25
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -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.
|
|
6
|
+
version = '12.5.0'
|
|
7
7
|
|
|
8
8
|
buildscript {
|
|
9
9
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -67,7 +67,7 @@ android {
|
|
|
67
67
|
minSdkVersion safeExtGet("minSdkVersion", 21)
|
|
68
68
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
69
69
|
versionCode 27
|
|
70
|
-
versionName "12.
|
|
70
|
+
versionName "12.5.0"
|
|
71
71
|
}
|
|
72
72
|
lintOptions {
|
|
73
73
|
abortOnError false
|
package/build/Print.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../src/Print.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,OAAO,EACR,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../src/Print.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,OAAO,EACR,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;AAIrF;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,eAA2C,CAAC;AAGtE;;;;;;;;;;;;GAYG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuBrE;AAGD;;;;GAIG;AACH,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAM3D;AAGD;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,eAAe,CAAC,CAE/F"}
|
package/build/Print.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { UnavailabilityError } from 'expo-modules-core';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
import ExponentPrint from './ExponentPrint';
|
|
4
|
+
let isPrinting = false;
|
|
4
5
|
// @needsAudit @docsMissing
|
|
5
6
|
/**
|
|
6
7
|
* The orientation of the printed content.
|
|
@@ -33,7 +34,16 @@ export async function printAsync(options) {
|
|
|
33
34
|
if (options.markupFormatterIOS !== undefined) {
|
|
34
35
|
console.warn('The markupFormatterIOS option is deprecated. Use useMarkupFormatter instead.');
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
+
if (isPrinting) {
|
|
38
|
+
throw new Error('Another print request is already in progress');
|
|
39
|
+
}
|
|
40
|
+
isPrinting = true;
|
|
41
|
+
try {
|
|
42
|
+
return await ExponentPrint.print(options);
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
isPrinting = false;
|
|
46
|
+
}
|
|
37
47
|
}
|
|
38
48
|
// @needsAudit
|
|
39
49
|
/**
|
package/build/Print.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.js","sourceRoot":"","sources":["../src/Print.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAW5C,2BAA2B;AAC3B;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAoB,aAAa,CAAC,WAAW,CAAC;AAEtE,cAAc;AACd;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAqB;IACpD,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,EAAE;QACzB,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC3C;IACD,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,QAAQ,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC,OAAO,CAAC,kBAAkB,EAAE;QACzF,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;KACjE;IACD,IAAI,OAAO,CAAC,GAAG,IAAI,OAAO,CAAC,IAAI,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,sE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;IAED,UAAU,GAAG,IAAI,CAAC;IAClB,IAAI;QACF,OAAO,MAAM,aAAa,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KAC3C;YAAS;QACR,UAAU,GAAG,KAAK,CAAC;KACpB;AACH,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB;IACtC,IAAI,aAAa,CAAC,aAAa,EAAE;QAC/B,OAAO,MAAM,aAAa,CAAC,aAAa,EAAE,CAAC;KAC5C;IAED,MAAM,IAAI,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,CAAC,CAAC;AAC/D,CAAC;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,UAA4B,EAAE;IACnE,OAAO,MAAM,aAAa,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import { UnavailabilityError } from 'expo-modules-core';\nimport { Platform } from 'react-native';\n\nimport ExponentPrint from './ExponentPrint';\nimport {\n FilePrintOptions,\n FilePrintResult,\n OrientationType,\n PrintOptions,\n Printer,\n} from './Print.types';\n\nexport { FilePrintOptions, FilePrintResult, OrientationType, PrintOptions, Printer };\n\nlet isPrinting = false;\n// @needsAudit @docsMissing\n/**\n * The orientation of the printed content.\n */\nexport const Orientation: OrientationType = ExponentPrint.Orientation;\n\n// @needsAudit\n/**\n * Prints a document or HTML, on web this prints the HTML from the page.\n * > Note: On iOS, printing from HTML source doesn't support local asset URLs (due to `WKWebView`\n * > limitations). As a workaround you can use inlined base64-encoded strings.\n * > See [this comment](https://github.com/expo/expo/issues/7940#issuecomment-657111033) for more details.\n *\n * > Note: on iOS, when printing without providing a `PrintOptions.printerUrl` the `Promise` will be\n * > resolved once printing is started in the native print window and rejected if the window is closed without\n * > starting the print. On Android the `Promise` will be resolved immediately after displaying the native print window\n * > and won't be rejected if the window is closed without starting the print.\n * @param options A map defining what should be printed.\n * @return Resolves to an empty `Promise` if printing started.\n */\nexport async function printAsync(options: PrintOptions): Promise<void> {\n if (Platform.OS === 'web') {\n return await ExponentPrint.print(options);\n }\n if (!options.uri && !options.html && Platform.OS === 'ios' && !options.markupFormatterIOS) {\n throw new Error('Must provide either `html` or `uri` to print');\n }\n if (options.uri && options.html) {\n throw new Error('Must provide exactly one of `html` and `uri` but both were specified');\n }\n if (options.markupFormatterIOS !== undefined) {\n console.warn('The markupFormatterIOS option is deprecated. Use useMarkupFormatter instead.');\n }\n if (isPrinting) {\n throw new Error('Another print request is already in progress');\n }\n\n isPrinting = true;\n try {\n return await ExponentPrint.print(options);\n } finally {\n isPrinting = false;\n }\n}\n\n// @needsAudit\n/**\n * Chooses a printer that can be later used in `printAsync`\n * @return A promise which fulfils with an object containing `name` and `url` of the selected printer.\n * @platform ios\n */\nexport async function selectPrinterAsync(): Promise<Printer> {\n if (ExponentPrint.selectPrinter) {\n return await ExponentPrint.selectPrinter();\n }\n\n throw new UnavailabilityError('Print', 'selectPrinterAsync');\n}\n\n// @needsAudit\n/**\n * Prints HTML to PDF file and saves it to [app's cache directory](./filesystem/#filesystemcachedirectory).\n * On Web this method opens the print dialog.\n * @param options A map of print options.\n */\nexport async function printToFileAsync(options: FilePrintOptions = {}): Promise<FilePrintResult> {\n return await ExponentPrint.printToFileAsync(options);\n}\n"]}
|
|
@@ -21,6 +21,15 @@ public class ExpoPrintModule: Module {
|
|
|
21
21
|
public func definition() -> ModuleDefinition {
|
|
22
22
|
Name("ExpoPrint")
|
|
23
23
|
|
|
24
|
+
Constants {
|
|
25
|
+
[
|
|
26
|
+
"Orientation": [
|
|
27
|
+
"portrait": PrintOrientation.portrait.rawValue,
|
|
28
|
+
"landscape": PrintOrientation.landscape.rawValue
|
|
29
|
+
]
|
|
30
|
+
]
|
|
31
|
+
}
|
|
32
|
+
|
|
24
33
|
AsyncFunction("print") { (options: PrintOptions, promise: Promise) in
|
|
25
34
|
printWithPrinter.startPrint(options: options, promise: promise)
|
|
26
35
|
}
|
package/ios/PrintOptions.swift
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import ExpoModulesCore
|
|
2
2
|
|
|
3
|
+
enum PrintOrientation: String {
|
|
4
|
+
case portrait
|
|
5
|
+
case landscape
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
internal struct PrintOptions: Record {
|
|
4
9
|
@Field
|
|
5
10
|
var html: String?
|
|
@@ -35,8 +40,6 @@ internal struct PrintOptions: Record {
|
|
|
35
40
|
var markupFormatterIOS: String?
|
|
36
41
|
|
|
37
42
|
let kLetterPaperSize = CGSize(width: 612, height: 792)
|
|
38
|
-
let kExpoPrintOrientationLandscape = "landscape"
|
|
39
|
-
let kExpoPrintOrientationPortrait = "portrait"
|
|
40
43
|
|
|
41
44
|
func toPageSize() -> CGSize {
|
|
42
45
|
// defaults to pixel size for A4 paper format with 72 PPI
|
|
@@ -81,6 +84,6 @@ internal struct PrintOptions: Record {
|
|
|
81
84
|
}
|
|
82
85
|
|
|
83
86
|
func toUIPrintInfoOrientation() -> UIPrintInfo.Orientation {
|
|
84
|
-
orientation ==
|
|
87
|
+
orientation == PrintOrientation.landscape.rawValue ? UIPrintInfo.Orientation.landscape : UIPrintInfo.Orientation.portrait
|
|
85
88
|
}
|
|
86
89
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-print",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.5.0",
|
|
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": "
|
|
43
|
+
"gitHead": "663654577a7068c641b5e9474efbc502e3f334ea"
|
|
44
44
|
}
|
package/src/Print.ts
CHANGED
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
|
|
13
13
|
export { FilePrintOptions, FilePrintResult, OrientationType, PrintOptions, Printer };
|
|
14
14
|
|
|
15
|
+
let isPrinting = false;
|
|
15
16
|
// @needsAudit @docsMissing
|
|
16
17
|
/**
|
|
17
18
|
* The orientation of the printed content.
|
|
@@ -45,7 +46,16 @@ export async function printAsync(options: PrintOptions): Promise<void> {
|
|
|
45
46
|
if (options.markupFormatterIOS !== undefined) {
|
|
46
47
|
console.warn('The markupFormatterIOS option is deprecated. Use useMarkupFormatter instead.');
|
|
47
48
|
}
|
|
48
|
-
|
|
49
|
+
if (isPrinting) {
|
|
50
|
+
throw new Error('Another print request is already in progress');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
isPrinting = true;
|
|
54
|
+
try {
|
|
55
|
+
return await ExponentPrint.print(options);
|
|
56
|
+
} finally {
|
|
57
|
+
isPrinting = false;
|
|
58
|
+
}
|
|
49
59
|
}
|
|
50
60
|
|
|
51
61
|
// @needsAudit
|