@pdfme/generator 1.0.18 → 1.1.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.
Files changed (47) hide show
  1. package/dist/cjs/__tests__/assets/templates/index.js +111 -0
  2. package/dist/cjs/__tests__/assets/templates/index.js.map +1 -0
  3. package/dist/cjs/__tests__/generate.test.js +362 -0
  4. package/dist/cjs/__tests__/generate.test.js.map +1 -0
  5. package/dist/cjs/__tests__/helper.test.js +53 -0
  6. package/dist/cjs/__tests__/helper.test.js.map +1 -0
  7. package/dist/cjs/src/constants.js +5 -0
  8. package/dist/cjs/src/constants.js.map +1 -0
  9. package/dist/cjs/src/generate.js +75 -0
  10. package/dist/cjs/src/generate.js.map +1 -0
  11. package/dist/cjs/src/helper.js +296 -0
  12. package/dist/cjs/src/helper.js.map +1 -0
  13. package/dist/cjs/src/index.js +20 -0
  14. package/dist/cjs/src/index.js.map +1 -0
  15. package/dist/esm/__tests__/assets/templates/index.js +109 -0
  16. package/dist/esm/__tests__/assets/templates/index.js.map +1 -0
  17. package/dist/esm/__tests__/generate.test.js +334 -0
  18. package/dist/esm/__tests__/generate.test.js.map +1 -0
  19. package/dist/esm/__tests__/helper.test.js +48 -0
  20. package/dist/esm/__tests__/helper.test.js.map +1 -0
  21. package/dist/esm/src/constants.js +2 -0
  22. package/dist/esm/src/constants.js.map +1 -0
  23. package/dist/esm/src/generate.js +70 -0
  24. package/dist/esm/src/generate.js.map +1 -0
  25. package/dist/esm/src/helper.js +285 -0
  26. package/dist/esm/src/helper.js.map +1 -0
  27. package/dist/esm/src/index.js +4 -0
  28. package/dist/esm/src/index.js.map +1 -0
  29. package/dist/types/__tests__/assets/templates/index.d.ts +1563 -0
  30. package/dist/types/__tests__/generate.test.d.ts +1 -0
  31. package/dist/types/__tests__/helper.test.d.ts +1 -0
  32. package/dist/types/{constants.d.ts → src/constants.d.ts} +0 -0
  33. package/dist/types/{generate.d.ts → src/generate.d.ts} +0 -0
  34. package/dist/types/{helper.d.ts → src/helper.d.ts} +1 -0
  35. package/dist/types/{index.d.ts → src/index.d.ts} +1 -1
  36. package/package.json +18 -12
  37. package/src/generate.ts +2 -2
  38. package/src/helper.ts +3 -5
  39. package/src/index.ts +1 -1
  40. package/tsconfig.cjs.json +9 -0
  41. package/tsconfig.esm.json +9 -0
  42. package/declaration.d.ts +0 -3
  43. package/dist/index.js +0 -3
  44. package/dist/index.js.LICENSE.txt +0 -43
  45. package/dist/index.js.map +0 -1
  46. package/tsconfig.json +0 -21
  47. package/webpack.config.js +0 -59
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
File without changes
@@ -1,3 +1,4 @@
1
+ /// <reference types="node" />
1
2
  import { PDFPage, PDFFont, PDFDocument, PDFImage, PDFEmbeddedPage } from 'pdf-lib';
2
3
  import { Schema, Font, BasePdf, BarCodeType } from '@pdfme/common';
3
4
  export interface InputImageCache {
@@ -1,4 +1,4 @@
1
- import generate from './generate';
1
+ import generate from './generate.js';
2
2
  export { generate };
3
3
  export type { Lang, Size, Alignment, SchemaType, BarCodeType, TextSchema, ImageSchema, BarcodeSchema, Schema, SchemaForUI, Font, BasePdf, Template, CommonProps, GeneratorOptions, GenerateProps, UIOptions, UIProps, PreviewProps, DesignerProps, } from '@pdfme/common';
4
4
  export { BLANK_PDF, isTextSchema, isImageSchema, isBarcodeSchema, checkTemplate, checkUIProps, checkPreviewProps, checkDesignerProps, checkGenerateProps, validateBarcodeInput, } from '@pdfme/common';
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@pdfme/generator",
3
- "version": "1.0.18",
3
+ "version": "1.1.1",
4
+ "sideEffects": false,
4
5
  "author": "hand-dot",
5
6
  "license": "MIT",
6
7
  "keywords": [
@@ -20,15 +21,23 @@
20
21
  "bugs": {
21
22
  "url": "https://github.com/pdfme/pdfme/issues"
22
23
  },
23
- "main": "dist/index.js",
24
- "module": "dist/index.js",
25
- "types": "dist/types/index.d.ts",
24
+ "main": "dist/cjs/src/index.js",
25
+ "module": "dist/esm/src/index.js",
26
+ "types": "dist/types/src/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "import": "./dist/esm/src/index.js",
30
+ "require": "./dist/cjs/src/index.js"
31
+ }
32
+ },
26
33
  "engines": {
27
34
  "node": ">=14"
28
35
  },
29
36
  "scripts": {
30
- "develop": "webpack --watch --mode development",
31
- "build": "NODE_ENV=production webpack --mode production",
37
+ "develop": "tsc -w",
38
+ "build": "npm run build:cjs && npm run build:esm",
39
+ "build:cjs": "tsc -p tsconfig.cjs.json",
40
+ "build:esm": "tsc -p tsconfig.esm.json",
32
41
  "clean": "rimraf dist",
33
42
  "lint": "tsc --noEmit",
34
43
  "test": "jest",
@@ -40,21 +49,18 @@
40
49
  "@pdf-lib/fontkit": "^1.1.1",
41
50
  "@pdfme/common": "^1.0.0",
42
51
  "atob": "^2.1.2",
43
- "bwip-js": "^2.1.3",
52
+ "bwip-js": "^3.2.2",
44
53
  "pdf-lib": "^1.17.1"
45
54
  },
46
55
  "devDependencies": {
47
56
  "@types/bwip-js": "^3.0.0",
48
57
  "@types/pngjs": "^6.0.1",
49
58
  "jsqr": "^1.4.0",
50
- "node-polyfill-webpack-plugin": "^1.1.4",
51
59
  "pdf2json": "^2.0.0",
52
60
  "pngjs": "^6.0.0"
53
61
  },
54
62
  "jest": {
55
- "moduleNameMapper": {
56
- "\\.(ttf)$": "<rootDir>/../../fontTransformer.js"
57
- },
63
+ "resolver": "ts-jest-resolver",
58
64
  "moduleFileExtensions": [
59
65
  "js",
60
66
  "ts"
@@ -64,7 +70,7 @@
64
70
  },
65
71
  "globals": {
66
72
  "ts-jest": {
67
- "tsconfig": "tsconfig.json"
73
+ "tsconfig": "tsconfig.esm.json"
68
74
  }
69
75
  },
70
76
  "testMatch": [
package/src/generate.ts CHANGED
@@ -8,8 +8,8 @@ import {
8
8
  drawEmbeddedPage,
9
9
  embedAndGetFontObj,
10
10
  InputImageCache,
11
- } from './helper';
12
- import { TOOL_NAME } from './constants';
11
+ } from './helper.js';
12
+ import { TOOL_NAME } from './constants.js';
13
13
 
14
14
  const preprocessing = async (arg: {
15
15
  inputs: { [key: string]: string }[];
package/src/helper.ts CHANGED
@@ -9,9 +9,7 @@ import {
9
9
  setCharacterSpacing,
10
10
  TransformationMatrix,
11
11
  } from 'pdf-lib';
12
- import { ToBufferOptions } from 'bwip-js';
13
- import bwipjsNode from 'bwip-js/dist/node-bwipjs';
14
- import bwipjsBrowser from 'bwip-js/dist/bwip-js';
12
+ import bwipjs, { ToBufferOptions } from 'bwip-js';
15
13
  import {
16
14
  getB64BasePdf,
17
15
  b64toUint8Array,
@@ -60,11 +58,11 @@ export const createBarCode = async (arg: {
60
58
 
61
59
  if (typeof window !== 'undefined') {
62
60
  const canvas = document.createElement('canvas');
63
- bwipjsBrowser.toCanvas(canvas, bwipjsArg);
61
+ bwipjs.toCanvas(canvas, bwipjsArg);
64
62
  const dataUrl = canvas.toDataURL('image/png');
65
63
  res = b64toUint8Array(dataUrl).buffer as Buffer;
66
64
  } else {
67
- res = await bwipjsNode.toBuffer(bwipjsArg);
65
+ res = await bwipjs.toBuffer(bwipjsArg);
68
66
  }
69
67
 
70
68
  return res;
package/src/index.ts CHANGED
@@ -1,4 +1,4 @@
1
- import generate from './generate';
1
+ import generate from './generate.js';
2
2
 
3
3
  export { generate };
4
4
 
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base",
3
+ "compilerOptions": {
4
+ "module": "commonjs",
5
+ "outDir": "./dist/cjs",
6
+ "declaration": true,
7
+ "declarationDir": "dist/types"
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "extends": "../../tsconfig.base",
3
+ "compilerOptions": {
4
+ "module": "ESNext",
5
+ "outDir": "./dist/esm",
6
+ "declaration": true,
7
+ "declarationDir": "dist/types"
8
+ }
9
+ }
package/declaration.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare module '*.ttf';
2
- declare module 'bwip-js/dist/node-bwipjs';
3
- declare module 'bwip-js/dist/bwip-js';