@pdfme/common 1.0.0-beta.7 → 1.0.0-beta.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.
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/schema.d.ts +2 -2
- package/package.json +7 -4
- package/src/helper.ts +9 -4
- package/src/schema.ts +0 -2
- package/tsconfig.json +1 -1
- package/webpack.config.js +0 -1
package/dist/types/schema.d.ts
CHANGED
@@ -2149,8 +2149,8 @@ export declare const PreviewProps: z.ZodObject<z.extendShape<z.extendShape<{
|
|
2149
2149
|
}>[];
|
2150
2150
|
basePdf: string | ArrayBuffer | Uint8Array;
|
2151
2151
|
};
|
2152
|
-
domContainer: HTMLElement;
|
2153
2152
|
inputs: Record<string, string>[];
|
2153
|
+
domContainer: HTMLElement;
|
2154
2154
|
}, {
|
2155
2155
|
options?: {
|
2156
2156
|
font?: Record<string, {
|
@@ -2200,8 +2200,8 @@ export declare const PreviewProps: z.ZodObject<z.extendShape<z.extendShape<{
|
|
2200
2200
|
}>[];
|
2201
2201
|
basePdf: string | ArrayBuffer | Uint8Array;
|
2202
2202
|
};
|
2203
|
-
domContainer: HTMLElement;
|
2204
2203
|
inputs: Record<string, string>[];
|
2204
|
+
domContainer: HTMLElement;
|
2205
2205
|
}>;
|
2206
2206
|
export declare const PreviewReactProps: z.ZodObject<z.extendShape<{
|
2207
2207
|
options: z.ZodOptional<z.ZodObject<z.extendShape<{
|
package/package.json
CHANGED
@@ -1,11 +1,14 @@
|
|
1
1
|
{
|
2
2
|
"name": "@pdfme/common",
|
3
|
-
"version": "1.0.0-beta.
|
3
|
+
"version": "1.0.0-beta.8",
|
4
4
|
"author": "hand-dot",
|
5
5
|
"license": "MIT",
|
6
6
|
"description": "TypeScript base PDF generator and React base UI. Open source, developed by the community, and completely free to use under the MIT license!",
|
7
7
|
"homepage": "https://pdfme.com",
|
8
|
-
"repository":
|
8
|
+
"repository": {
|
9
|
+
"type": "git",
|
10
|
+
"url": "git@github.com:pdfme/pdfme.git"
|
11
|
+
},
|
9
12
|
"bugs": {
|
10
13
|
"url": "https://github.com/pdfme/pdfme/issues"
|
11
14
|
},
|
@@ -16,7 +19,7 @@
|
|
16
19
|
"node": ">=14"
|
17
20
|
},
|
18
21
|
"scripts": {
|
19
|
-
"develop": "webpack
|
22
|
+
"develop": "webpack --watch --mode development",
|
20
23
|
"build": "NODE_ENV=production webpack --mode production",
|
21
24
|
"clean": "rimraf dist",
|
22
25
|
"lint": "tsc --noEmit",
|
@@ -51,4 +54,4 @@
|
|
51
54
|
"publishConfig": {
|
52
55
|
"access": "public"
|
53
56
|
}
|
54
|
-
}
|
57
|
+
}
|
package/src/helper.ts
CHANGED
@@ -40,13 +40,18 @@ export const getB64BasePdf = (basePdf: BasePdf) => {
|
|
40
40
|
return basePdf as string;
|
41
41
|
};
|
42
42
|
|
43
|
+
const getByteString = (base64: string) => {
|
44
|
+
if (typeof window !== 'undefined' && window.atob) {
|
45
|
+
return window.atob(base64);
|
46
|
+
} else {
|
47
|
+
return Buffer.from(base64, 'base64').toString('binary');
|
48
|
+
}
|
49
|
+
};
|
50
|
+
|
43
51
|
export const b64toUint8Array = (base64: string) => {
|
44
52
|
const data = base64.split(';base64,')[1] ? base64.split(';base64,')[1] : base64;
|
45
53
|
|
46
|
-
const byteString =
|
47
|
-
typeof window !== 'undefined'
|
48
|
-
? window.atob(data)
|
49
|
-
: Buffer.from(data, 'base64').toString('binary');
|
54
|
+
const byteString = getByteString(data);
|
50
55
|
|
51
56
|
const unit8arr = new Uint8Array(byteString.length);
|
52
57
|
for (let i = 0; i < byteString.length; i += 1) {
|
package/src/schema.ts
CHANGED
@@ -37,10 +37,8 @@ export const TextSchema = CommonSchema.extend({
|
|
37
37
|
});
|
38
38
|
|
39
39
|
export const ImageSchema = CommonSchema.extend({ type: z.literal(SchemaType.Enum.image) });
|
40
|
-
type ImageSchema = z.infer<typeof ImageSchema>;
|
41
40
|
|
42
41
|
export const BarcodeSchema = CommonSchema.extend({ type: BarcodeSchemaType });
|
43
|
-
type BarcodeSchema = z.infer<typeof BarcodeSchema>;
|
44
42
|
|
45
43
|
export const Schema = z.union([TextSchema, ImageSchema, BarcodeSchema]);
|
46
44
|
|
package/tsconfig.json
CHANGED