zcw-shared 1.33.0 → 1.35.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.
Files changed (93) hide show
  1. package/README.md +13 -13
  2. package/dist/functions/android/integrateFacebookLogin.d.ts +12 -0
  3. package/dist/functions/android/integrateFacebookLogin.js +91 -0
  4. package/dist/functions/android/integrateFacebookLogin.js.map +1 -0
  5. package/dist/functions/android/integrateGoogleLogin.d.ts +10 -0
  6. package/dist/functions/android/integrateGoogleLogin.js +199 -0
  7. package/dist/functions/android/integrateGoogleLogin.js.map +1 -0
  8. package/dist/functions/android/integrateMiuiLogin.d.ts +13 -0
  9. package/dist/functions/android/integrateMiuiLogin.js +115 -0
  10. package/dist/functions/android/integrateMiuiLogin.js.map +1 -0
  11. package/dist/functions/android/integrateQQLogin.d.ts +12 -0
  12. package/dist/functions/android/integrateQQLogin.js +130 -0
  13. package/dist/functions/android/integrateQQLogin.js.map +1 -0
  14. package/dist/functions/android/integrateShareTrace.d.ts +10 -0
  15. package/dist/functions/android/integrateShareTrace.js +181 -0
  16. package/dist/functions/android/integrateShareTrace.js.map +1 -0
  17. package/dist/functions/android/integrateSinaLogin.d.ts +13 -0
  18. package/dist/functions/android/integrateSinaLogin.js +85 -0
  19. package/dist/functions/android/integrateSinaLogin.js.map +1 -0
  20. package/dist/functions/android/integrateThirdPartyModule.d.ts +46 -0
  21. package/dist/functions/android/integrateThirdPartyModule.js +251 -0
  22. package/dist/functions/android/integrateThirdPartyModule.js.map +1 -0
  23. package/dist/functions/android/integrateUniverifyLogin.d.ts +11 -0
  24. package/dist/functions/android/integrateUniverifyLogin.js +314 -0
  25. package/dist/functions/android/integrateUniverifyLogin.js.map +1 -0
  26. package/dist/functions/android/integrateWechatLogin.d.ts +13 -0
  27. package/dist/functions/android/integrateWechatLogin.js +154 -0
  28. package/dist/functions/android/integrateWechatLogin.js.map +1 -0
  29. package/dist/functions/android/integrateWechatShare.d.ts +13 -0
  30. package/dist/functions/android/integrateWechatShare.js +154 -0
  31. package/dist/functions/android/integrateWechatShare.js.map +1 -0
  32. package/dist/functions/android/modifyManifest.d.ts +7 -0
  33. package/dist/functions/android/modifyManifest.js +24 -0
  34. package/dist/functions/android/modifyManifest.js.map +1 -1
  35. package/dist/functions/async/cancellableFetch.d.ts +12 -0
  36. package/dist/functions/async/cancellableFetch.js +27 -0
  37. package/dist/functions/async/cancellableFetch.js.map +1 -0
  38. package/dist/functions/async/cancellableXHR.d.ts +21 -0
  39. package/dist/functions/async/cancellableXHR.js +96 -0
  40. package/dist/functions/async/cancellableXHR.js.map +1 -0
  41. package/dist/functions/functional/constant.d.ts +1 -0
  42. package/dist/functions/functional/constant.js +4 -0
  43. package/dist/functions/functional/constant.js.map +1 -0
  44. package/dist/functions/functional/identity.d.ts +1 -0
  45. package/dist/functions/functional/identity.js +4 -0
  46. package/dist/functions/functional/identity.js.map +1 -0
  47. package/dist/functions/functional/noop.d.ts +1 -0
  48. package/dist/functions/functional/noop.js +3 -0
  49. package/dist/functions/functional/noop.js.map +1 -0
  50. package/dist/functions/image/compressImageToWidth.d.ts +12 -0
  51. package/dist/functions/image/compressImageToWidth.js +44 -0
  52. package/dist/functions/image/compressImageToWidth.js.map +1 -0
  53. package/dist/functions/image/generateFavIcon.d.ts +8 -0
  54. package/dist/functions/image/generateFavIcon.js +13 -0
  55. package/dist/functions/image/generateFavIcon.js.map +1 -0
  56. package/dist/functions/image/renderBankCard.d.ts +52 -0
  57. package/dist/functions/image/renderBankCard.js +177 -0
  58. package/dist/functions/image/renderBankCard.js.map +1 -0
  59. package/dist/functions/image/renderBusinessLicense.d.ts +47 -0
  60. package/dist/functions/image/renderBusinessLicense.js +187 -0
  61. package/dist/functions/image/renderBusinessLicense.js.map +1 -0
  62. package/dist/functions/image/renderDrivingLicense.d.ts +48 -0
  63. package/dist/functions/image/renderDrivingLicense.js +201 -0
  64. package/dist/functions/image/renderDrivingLicense.js.map +1 -0
  65. package/dist/functions/image/renderLicensePlate.d.ts +47 -0
  66. package/dist/functions/image/renderLicensePlate.js +85 -0
  67. package/dist/functions/image/renderLicensePlate.js.map +1 -0
  68. package/dist/functions/software/publishToPgyer.d.ts +16 -0
  69. package/dist/functions/software/publishToPgyer.js +96 -0
  70. package/dist/functions/software/publishToPgyer.js.map +1 -0
  71. package/dist/functions/tencent-cloud/deploy.tcb.js +1 -1
  72. package/dist/functions/tencent-cloud/deploy.tcb.js.map +1 -1
  73. package/dist/functions/uniapp/app-plus/buildAndroidApp.js +290 -0
  74. package/dist/functions/uniapp/app-plus/buildAndroidApp.js.map +1 -1
  75. package/dist/functions/validation/generateFakeBankCard.d.ts +87 -0
  76. package/dist/functions/validation/generateFakeBankCard.js +152 -0
  77. package/dist/functions/validation/generateFakeBankCard.js.map +1 -0
  78. package/dist/functions/validation/generateFakeBusinessLicense.d.ts +21 -0
  79. package/dist/functions/validation/generateFakeBusinessLicense.js +160 -0
  80. package/dist/functions/validation/generateFakeBusinessLicense.js.map +1 -0
  81. package/dist/functions/validation/generateFakeDrivingLicense.d.ts +31 -0
  82. package/dist/functions/validation/generateFakeDrivingLicense.js +119 -0
  83. package/dist/functions/validation/generateFakeDrivingLicense.js.map +1 -0
  84. package/dist/functions/validation/generateFakeLicensePlate.d.ts +13 -0
  85. package/dist/functions/validation/generateFakeLicensePlate.js +87 -0
  86. package/dist/functions/validation/generateFakeLicensePlate.js.map +1 -0
  87. package/package.json +26 -4
  88. package/references/blob.d.ts +4 -0
  89. package/references/fetch.d.ts +22 -0
  90. package/references/sharp.d.ts +1 -0
  91. package/references/xhr.d.ts +47 -0
  92. package/types/pgyer.d.ts +64 -0
  93. package/types/uniapp-android-build.d.ts +124 -0
@@ -0,0 +1,44 @@
1
+ import { getImageDimensions } from './getImageDimensions';
2
+ export async function compressImageToWidth(file, targetWidth, options = {}, deps) {
3
+ const { quality = 0.9, mimeType = 'image/jpeg' } = options;
4
+ const dimensions = await getImageDimensions(file, {
5
+ Image: deps.Image,
6
+ createObjectURL: deps.createObjectURL
7
+ });
8
+ const originalWidth = dimensions.width;
9
+ const originalHeight = dimensions.height;
10
+ const targetHeight = Math.round((targetWidth / originalWidth) * originalHeight);
11
+ if (originalWidth === targetWidth && originalHeight === targetHeight) {
12
+ return file;
13
+ }
14
+ return new Promise((resolve, reject) => {
15
+ const img = new deps.Image();
16
+ img.onload = () => {
17
+ const canvas = deps.createElement('canvas');
18
+ canvas.width = targetWidth;
19
+ canvas.height = targetHeight;
20
+ const ctx = canvas.getContext('2d');
21
+ if (!ctx) {
22
+ reject(new Error('无法创建canvas上下文'));
23
+ return;
24
+ }
25
+ ctx.drawImage(img, 0, 0, targetWidth, targetHeight);
26
+ canvas.toBlob((blob) => {
27
+ if (!blob) {
28
+ reject(new Error('图片压缩失败'));
29
+ return;
30
+ }
31
+ const newFile = new deps.File([blob], file.name, {
32
+ type: mimeType,
33
+ lastModified: Date.now()
34
+ });
35
+ resolve(newFile);
36
+ }, mimeType, quality);
37
+ };
38
+ img.onerror = () => {
39
+ reject(new Error('图片加载失败'));
40
+ };
41
+ img.src = deps.createObjectURL(file);
42
+ });
43
+ }
44
+ //# sourceMappingURL=compressImageToWidth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compressImageToWidth.js","sourceRoot":"","sources":["../../../src/functions/image/compressImageToWidth.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAA;AAyDzD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,IAAU,EACV,WAAmB,EACnB,UAGI,EAAE,EACN,IAA8B;IAE9B,MAAM,EACJ,OAAO,GAAG,GAAG,EACb,QAAQ,GAAG,YAAY,EACxB,GAAG,OAAO,CAAA;IAEX,MAAM,UAAU,GAAG,MAAM,kBAAkB,CAAC,IAAI,EAAE;QAChD,KAAK,EAAE,IAAI,CAAC,KAAK;QACjB,eAAe,EAAE,IAAI,CAAC,eAAe;KACtC,CAAC,CAAA;IAEF,MAAM,aAAa,GAAG,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EAAE;iBACzB,CAAC,CAAA;gBACF,OAAO,CAAC,OAAO,CAAC,CAAA;YAClB,CAAC,EACD,QAAQ,EACR,OAAO,CACR,CAAA;QACH,CAAC,CAAA;QAED,GAAG,CAAC,OAAO,GAAG,GAAG,EAAE;YACjB,MAAM,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC7B,CAAC,CAAA;QAED,GAAG,CAAC,GAAG,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;IACtC,CAAC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { Buffer, BufferConstructor } from '../../../references/node.d';
2
+ import type { Sharp } from '../../../references/sharp.d';
3
+ export interface GenerateFavIconDeps {
4
+ sharp: Sharp;
5
+ Buffer: BufferConstructor;
6
+ toIco: (buffers: Buffer[]) => Promise<Buffer>;
7
+ }
8
+ export declare function generateFavIcon(input: Buffer, sizes: number[] | undefined, deps: GenerateFavIconDeps): Promise<Buffer>;
@@ -0,0 +1,13 @@
1
+ export async function generateFavIcon(input, sizes = [16, 32], deps) {
2
+ const pngBuffers = [];
3
+ for (const size of sizes) {
4
+ const buffer = await deps.sharp(input)
5
+ .resize(size, size)
6
+ .png()
7
+ .toBuffer();
8
+ pngBuffers.push(buffer);
9
+ }
10
+ const icoBuffer = await deps.toIco(pngBuffers);
11
+ return icoBuffer;
12
+ }
13
+ //# sourceMappingURL=generateFavIcon.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateFavIcon.js","sourceRoot":"","sources":["../../../src/functions/image/generateFavIcon.ts"],"names":[],"mappings":"AAiDA,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,KAAa,EACb,QAAkB,CAAC,EAAE,EAAE,EAAE,CAAC,EAC1B,IAAyB;IAGzB,MAAM,UAAU,GAAa,EAAE,CAAA;IAE/B,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;aACnC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC;aAClB,GAAG,EAAE;aACL,QAAQ,EAAE,CAAA;QACb,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACzB,CAAC;IAGD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,CAAA;IAE9C,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -0,0 +1,52 @@
1
+ import type { GeneratedBankCardProfile } from '../validation/generateFakeBankCard';
2
+ type CanvasTextBaseline = 'top' | 'hanging' | 'middle' | 'alphabetic' | 'ideographic' | 'bottom';
3
+ type CanvasTextAlign = 'left' | 'right' | 'center' | 'start' | 'end';
4
+ export interface RenderBankCardOptions {
5
+ resolution?: 'standard' | 'retina';
6
+ cornerRadius?: number;
7
+ showSignaturePanel?: boolean;
8
+ }
9
+ export interface CanvasGradientLike {
10
+ addColorStop: (offset: number, color: string) => void;
11
+ }
12
+ export interface Canvas2DContextLike {
13
+ fillStyle: string | CanvasGradientLike;
14
+ strokeStyle: string;
15
+ globalAlpha: number;
16
+ lineWidth: number;
17
+ font: string;
18
+ textBaseline: CanvasTextBaseline;
19
+ textAlign: CanvasTextAlign;
20
+ beginPath: () => void;
21
+ moveTo?: (x: number, y: number) => void;
22
+ lineTo?: (x: number, y: number) => void;
23
+ arc: (x: number, y: number, radius: number, startAngle: number, endAngle: number) => void;
24
+ closePath: () => void;
25
+ fill?: () => void;
26
+ stroke?: () => void;
27
+ fillRect: (x: number, y: number, w: number, h: number) => void;
28
+ strokeRect: (x: number, y: number, w: number, h: number) => void;
29
+ drawImage?: (...args: any[]) => void;
30
+ fillText: (text: string, x: number, y: number) => void;
31
+ measureText: (text: string) => {
32
+ width: number;
33
+ };
34
+ createLinearGradient: (x0: number, y0: number, x1: number, y1: number) => CanvasGradientLike;
35
+ save: () => void;
36
+ restore: () => void;
37
+ setLineDash?: (segments: number[]) => void;
38
+ clip?: () => void;
39
+ }
40
+ export interface CanvasLike {
41
+ width: number;
42
+ height: number;
43
+ getContext: (type: '2d') => Canvas2DContextLike;
44
+ }
45
+ export interface RenderBankCardDeps {
46
+ createCanvas: (width: number, height: number) => CanvasLike;
47
+ }
48
+ export interface RenderBankCardResult {
49
+ canvas: CanvasLike;
50
+ }
51
+ export declare function renderBankCard(profile: GeneratedBankCardProfile, deps: RenderBankCardDeps, options?: RenderBankCardOptions): RenderBankCardResult;
52
+ export {};
@@ -0,0 +1,177 @@
1
+ function drawRoundedRect(ctx, x, y, w, h, r) {
2
+ const radius = Math.min(r, Math.min(w, h) / 2);
3
+ ctx.beginPath();
4
+ ctx.moveTo?.(x + radius, y);
5
+ ctx.arc(x + w - radius, y + radius, radius, Math.PI * 1.5, 0);
6
+ ctx.lineTo?.(x + w, y + h - radius);
7
+ ctx.arc(x + w - radius, y + h - radius, radius, 0, Math.PI * 0.5);
8
+ ctx.lineTo?.(x + radius, y + h);
9
+ ctx.arc(x + radius, y + h - radius, radius, Math.PI * 0.5, Math.PI);
10
+ ctx.lineTo?.(x, y + radius);
11
+ ctx.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 1.5);
12
+ ctx.closePath();
13
+ }
14
+ function drawBackground(ctx, width, height, theme, radius) {
15
+ ctx.save();
16
+ drawRoundedRect(ctx, 0, 0, width, height, radius);
17
+ const gradient = ctx.createLinearGradient(0, 0, width, height);
18
+ gradient.addColorStop(0, theme.gradient[0]);
19
+ gradient.addColorStop(1, theme.gradient[1]);
20
+ ctx.fillStyle = gradient;
21
+ ctx.fill?.();
22
+ ctx.restore();
23
+ }
24
+ function drawPattern(ctx, width, height, theme, radius) {
25
+ ctx.save();
26
+ ctx.globalAlpha = 1;
27
+ drawRoundedRect(ctx, 0, 0, width, height, radius);
28
+ ctx.clip?.();
29
+ ctx.strokeStyle = theme.patternColor;
30
+ ctx.lineWidth = 2;
31
+ const spacing = 42;
32
+ for (let i = -width; i < width * 2; i += spacing) {
33
+ ctx.beginPath();
34
+ ctx.moveTo?.(i, -20);
35
+ ctx.lineTo?.(i + height, height + 20);
36
+ ctx.stroke?.();
37
+ }
38
+ ctx.restore();
39
+ }
40
+ function drawChip(ctx, x, y, width, height, style, accentColor) {
41
+ ctx.save();
42
+ ctx.lineWidth = 2;
43
+ const gradient = ctx.createLinearGradient(x, y, x + width, y + height);
44
+ gradient.addColorStop(0, '#eceff4');
45
+ gradient.addColorStop(1, '#cbd5f5');
46
+ ctx.fillStyle = gradient;
47
+ drawRoundedRect(ctx, x, y, width, height, 16);
48
+ ctx.fill?.();
49
+ ctx.strokeStyle = 'rgba(0,0,0,0.2)';
50
+ ctx.stroke?.();
51
+ ctx.strokeStyle = 'rgba(0,0,0,0.35)';
52
+ ctx.lineWidth = 1.2;
53
+ const segments = style === 'minimal' ? 2 : 3;
54
+ for (let i = 1; i <= segments; i++) {
55
+ const offset = (height / (segments + 1)) * i;
56
+ ctx.beginPath();
57
+ ctx.moveTo?.(x + 10, y + offset);
58
+ ctx.lineTo?.(x + width - 10, y + offset);
59
+ ctx.stroke?.();
60
+ }
61
+ ctx.fillStyle = accentColor;
62
+ ctx.fillRect(x + width / 2 - 8, y + height / 2 - 22, 16, 44);
63
+ ctx.restore();
64
+ }
65
+ function drawContactless(ctx, x, y, color) {
66
+ ctx.save();
67
+ ctx.strokeStyle = color;
68
+ ctx.lineWidth = 2;
69
+ for (let i = 0; i < 3; i++) {
70
+ ctx.beginPath();
71
+ ctx.arc(x, y, 10 + i * 6, -Math.PI / 3, Math.PI / 3);
72
+ ctx.stroke?.();
73
+ }
74
+ ctx.restore();
75
+ }
76
+ function drawCardNumber(ctx, value, x, y, theme, width) {
77
+ const segments = value.split(' ');
78
+ ctx.save();
79
+ ctx.font = '600 48px "SF Mono", "JetBrains Mono", "Menlo", monospace';
80
+ ctx.fillStyle = theme.textColor;
81
+ const spacing = (width - x * 2) / segments.length;
82
+ segments.forEach((segment, index) => {
83
+ const text = ctx.measureText(segment);
84
+ const baseX = x + spacing * index + (spacing - text.width) / 2;
85
+ ctx.fillText(segment, baseX, y);
86
+ });
87
+ ctx.restore();
88
+ }
89
+ function drawLabelValue(ctx, label, value, x, y, theme) {
90
+ ctx.save();
91
+ ctx.font = '600 18px "Inter", "PingFang SC", sans-serif';
92
+ ctx.fillStyle = theme.secondaryTextColor;
93
+ ctx.fillText(label.toUpperCase(), x, y);
94
+ ctx.font = '600 30px "Inter", "PingFang SC", sans-serif';
95
+ ctx.fillStyle = theme.textColor;
96
+ ctx.fillText(value, x, y + 42);
97
+ ctx.restore();
98
+ }
99
+ function drawBrandBadge(ctx, brand, x, y, theme) {
100
+ const radius = 42;
101
+ ctx.save();
102
+ ctx.beginPath();
103
+ ctx.arc(x, y, radius, 0, Math.PI * 2);
104
+ ctx.closePath();
105
+ ctx.fillStyle = '#ffffff';
106
+ ctx.globalAlpha = 0.92;
107
+ ctx.fill?.();
108
+ ctx.globalAlpha = 1;
109
+ ctx.strokeStyle = theme.accentColor;
110
+ ctx.lineWidth = 3;
111
+ ctx.stroke?.();
112
+ ctx.fillStyle = theme.baseColor;
113
+ ctx.font = '700 20px "Inter", "PingFang SC", sans-serif';
114
+ ctx.textAlign = 'center';
115
+ ctx.textBaseline = 'middle';
116
+ ctx.fillText(brand, x, y);
117
+ ctx.restore();
118
+ }
119
+ function ensureFormattedNumber(cardNumber, formatted) {
120
+ if (formatted && formatted.trim().length > 0)
121
+ return formatted;
122
+ return cardNumber.replace(/\D/g, '').replace(/(.{4})/g, '$1 ').trim();
123
+ }
124
+ export function renderBankCard(profile, deps, options = {}) {
125
+ const width = options.resolution === 'retina' ? 1280 : 1012;
126
+ const height = Math.round(width * 0.63);
127
+ const cornerRadius = options.cornerRadius ?? 52;
128
+ const canvas = deps.createCanvas(width, height);
129
+ const ctx = canvas.getContext('2d');
130
+ ctx.textBaseline = 'alphabetic';
131
+ ctx.textAlign = 'left';
132
+ drawBackground(ctx, width, height, profile.background, cornerRadius);
133
+ drawPattern(ctx, width, height, profile.background, cornerRadius);
134
+ const padding = Math.round(width * 0.07);
135
+ const chipWidth = 160;
136
+ const chipHeight = 110;
137
+ drawChip(ctx, padding, padding + 40, chipWidth, chipHeight, profile.chipStyle, profile.background.accentColor);
138
+ if (profile.contactless) {
139
+ drawContactless(ctx, padding + chipWidth + 50, padding + chipHeight / 2 + 20, profile.background.secondaryTextColor);
140
+ }
141
+ ctx.save();
142
+ ctx.fillStyle = profile.background.textColor;
143
+ ctx.font = '700 48px "Inter", "PingFang SC", sans-serif';
144
+ ctx.fillText(profile.bankName, padding, padding + 32);
145
+ ctx.font = '400 20px "Inter", "PingFang SC", sans-serif';
146
+ ctx.fillStyle = profile.background.secondaryTextColor;
147
+ ctx.fillText(`${profile.cardType} · ${profile.tagline}`, padding, padding + 72);
148
+ ctx.restore();
149
+ const formattedNumber = ensureFormattedNumber(profile.cardNumber, profile.formattedNumber);
150
+ drawCardNumber(ctx, formattedNumber, padding, height / 2 + 40, profile.background, width - padding * 2);
151
+ drawLabelValue(ctx, 'CARD HOLDER', profile.holderName.toUpperCase(), padding, height - 180, profile.background);
152
+ drawLabelValue(ctx, 'VALID FROM', profile.validFrom, padding + 360, height - 180, profile.background);
153
+ drawLabelValue(ctx, 'VALID THRU', profile.validThru, padding + 620, height - 180, profile.background);
154
+ if (options.showSignaturePanel !== false) {
155
+ ctx.save();
156
+ const panelWidth = width * 0.32;
157
+ const panelHeight = 70;
158
+ const panelX = width - panelWidth - padding;
159
+ const panelY = padding + 30;
160
+ ctx.globalAlpha = 0.25;
161
+ drawRoundedRect(ctx, panelX, panelY, panelWidth, panelHeight, 10);
162
+ ctx.fillStyle = '#ffffff';
163
+ ctx.fill?.();
164
+ ctx.globalAlpha = 1;
165
+ ctx.strokeStyle = 'rgba(255,255,255,0.5)';
166
+ ctx.lineWidth = 1;
167
+ ctx.stroke?.();
168
+ ctx.font = '500 18px "Inter", "PingFang SC", sans-serif';
169
+ ctx.fillStyle = profile.background.baseColor;
170
+ ctx.textAlign = 'right';
171
+ ctx.fillText(profile.bankShortName, panelX + panelWidth - 16, panelY + panelHeight / 2 + 6);
172
+ ctx.restore();
173
+ }
174
+ drawBrandBadge(ctx, profile.cardBrand, width - padding - 64, height - padding - 60, profile.background);
175
+ return { canvas };
176
+ }
177
+ //# sourceMappingURL=renderBankCard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderBankCard.js","sourceRoot":"","sources":["../../../src/functions/image/renderBankCard.ts"],"names":[],"mappings":"AAoEA,SAAS,eAAe,CAAC,GAAwB,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS,EAAE,CAAS;IACtG,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;IAC9C,GAAG,CAAC,SAAS,EAAE,CAAA;IACf,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,CAAC,CAAA;IAC3B,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,CAAC,CAAA;IAC7D,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,CAAA;IACnC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,CAAC,EAAE,GAAG,GAAG,CAAC,CAAA;IACjE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAA;IAC/B,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,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GAAG,OAAO,CAAC,UAAU,CAAC,SAAS,CAAA;QAC5C,GAAG,CAAC,SAAS,GAAG,OAAO,CAAA;QACvB,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,GAAG,UAAU,GAAG,EAAE,EAAE,MAAM,GAAG,WAAW,GAAG,CAAC,GAAG,CAAC,CAAC,CAAA;QAC3F,GAAG,CAAC,OAAO,EAAE,CAAA;IACf,CAAC;IAED,cAAc,CAAC,GAAG,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,GAAG,OAAO,GAAG,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,EAAE,EAAE,OAAO,CAAC,UAAU,CAAC,CAAA;IAEvG,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC"}
@@ -0,0 +1,47 @@
1
+ import type { GeneratedBusinessLicenseProfile } from '../validation/generateFakeBusinessLicense';
2
+ import type { Window } from '../../../references/browser.d';
3
+ export interface RenderBusinessLicenseOptions {
4
+ companyName?: string;
5
+ }
6
+ export interface Canvas2DContextLike {
7
+ fillStyle: string | CanvasGradientLike;
8
+ strokeStyle: string;
9
+ lineWidth: number;
10
+ font: string;
11
+ textBaseline: string;
12
+ textAlign: string;
13
+ moveTo?: (x: number, y: number) => void;
14
+ lineTo?: (x: number, y: number) => void;
15
+ fill?: () => void;
16
+ stroke?: () => void;
17
+ drawImage: (...args: any[]) => void;
18
+ fillRect: (x: number, y: number, w: number, h: number) => void;
19
+ strokeRect: (x: number, y: number, w: number, h: number) => void;
20
+ fillText: (text: string, x: number, y: number) => void;
21
+ measureText: (text: string) => {
22
+ width: number;
23
+ };
24
+ beginPath: () => void;
25
+ arc: (x: number, y: number, r: number, sAngle: number, eAngle: number) => void;
26
+ closePath: () => void;
27
+ clip: () => void;
28
+ save: () => void;
29
+ restore: () => void;
30
+ createLinearGradient: (x0: number, y0: number, x1: number, y1: number) => CanvasGradientLike;
31
+ }
32
+ export interface CanvasGradientLike {
33
+ addColorStop: (offset: number, color: string) => void;
34
+ }
35
+ export interface CanvasLike {
36
+ width: number;
37
+ height: number;
38
+ getContext: (type: '2d') => Canvas2DContextLike;
39
+ }
40
+ export interface RenderBusinessLicenseDeps {
41
+ createCanvas: (width: number, height: number) => CanvasLike;
42
+ Image: Window['Image'];
43
+ }
44
+ export interface RenderBusinessLicenseResult {
45
+ canvas: CanvasLike;
46
+ }
47
+ export declare function renderBusinessLicense(profile: GeneratedBusinessLicenseProfile, deps: RenderBusinessLicenseDeps, options?: RenderBusinessLicenseOptions): RenderBusinessLicenseResult;
@@ -0,0 +1,187 @@
1
+ function drawRoundedRect(ctx, x, y, w, h, r) {
2
+ if (ctx.beginPath) {
3
+ ctx.beginPath();
4
+ }
5
+ ctx.moveTo?.(x + r, y);
6
+ ctx.arc(x + w - r, y + r, r, Math.PI * 1.5, 0);
7
+ ctx.lineTo?.(x + w, y + h - r);
8
+ ctx.arc(x + w - r, y + h - r, r, 0, Math.PI * 0.5);
9
+ ctx.lineTo?.(x + r, y + h);
10
+ ctx.arc(x + r, y + h - r, r, Math.PI * 0.5, Math.PI);
11
+ ctx.lineTo?.(x, y + r);
12
+ ctx.arc(x + r, y + r, r, Math.PI, Math.PI * 1.5);
13
+ if (ctx.closePath) {
14
+ ctx.closePath();
15
+ }
16
+ }
17
+ function drawLabelAndValue(ctx, label, value, x, y, fonts, spacing = 16) {
18
+ ctx.font = fonts.label;
19
+ const labelWidth = ctx.measureText(label).width;
20
+ ctx.fillText(label, x, y);
21
+ ctx.font = fonts.value;
22
+ ctx.fillText(value, x + labelWidth + spacing, y);
23
+ }
24
+ function drawCenteredText(ctx, text, y, font, canvasWidth, xShift = 0) {
25
+ ctx.font = font;
26
+ const w = ctx.measureText(text).width;
27
+ const x = (canvasWidth - w) / 2 + xShift;
28
+ ctx.fillText(text, x, y);
29
+ }
30
+ function drawMultilineText(ctx, text, x, y, maxWidth, lineHeight) {
31
+ const chars = text.split('');
32
+ let line = '';
33
+ let currentY = y;
34
+ for (const ch of chars) {
35
+ const test = line + ch;
36
+ const testWidth = ctx.measureText(test).width;
37
+ if (testWidth > maxWidth && line.length > 0) {
38
+ ctx.fillText(line, x, currentY);
39
+ currentY += lineHeight;
40
+ line = ch;
41
+ }
42
+ else {
43
+ line = test;
44
+ }
45
+ }
46
+ if (line) {
47
+ ctx.fillText(line, x, currentY);
48
+ currentY += lineHeight;
49
+ }
50
+ return currentY;
51
+ }
52
+ function calculateBusinessLicenseHeight(ctx, profile, companyName, padding, titleTopMargin, leftX, labelFont, valueFont, lineHeight) {
53
+ let height = padding + titleTopMargin + 60;
54
+ const borderTopMargin = padding + titleTopMargin + 60;
55
+ let currentY = borderTopMargin + 40;
56
+ currentY += 60;
57
+ currentY += lineHeight + 10 + lineHeight + 10;
58
+ ctx.font = labelFont;
59
+ const addressLabelWidth = ctx.measureText('住所').width;
60
+ ctx.font = valueFont;
61
+ const addressStartX = leftX + addressLabelWidth + 30;
62
+ const addressMaxWidth = 856 - addressStartX - padding - 60;
63
+ const addressHeight = calculateMultilineHeight(ctx, profile.address, addressMaxWidth, lineHeight + 5);
64
+ currentY += Math.max(lineHeight + 10, addressHeight + 15);
65
+ currentY += (lineHeight + 10) * 4;
66
+ ctx.font = labelFont;
67
+ const scopeLabelWidth = ctx.measureText('经营范围').width;
68
+ ctx.font = valueFont;
69
+ const scopeStartX = leftX + scopeLabelWidth + 30;
70
+ const scopeMaxWidth = 856 - scopeStartX - padding - 60;
71
+ const scopeHeight = calculateMultilineHeight(ctx, profile.businessScope, scopeMaxWidth, lineHeight + 5);
72
+ currentY += Math.max(lineHeight + 10, scopeHeight + 15);
73
+ currentY += (lineHeight + 10) * 2;
74
+ height = currentY + padding + 40;
75
+ return height;
76
+ }
77
+ function calculateMultilineHeight(ctx, text, maxWidth, lineHeight) {
78
+ const chars = text.split('');
79
+ let line = '';
80
+ let lines = 0;
81
+ for (const ch of chars) {
82
+ const test = line + ch;
83
+ const testWidth = ctx.measureText(test).width;
84
+ if (testWidth > maxWidth && line.length > 0) {
85
+ lines++;
86
+ line = ch;
87
+ }
88
+ else {
89
+ line = test;
90
+ }
91
+ }
92
+ if (line)
93
+ lines++;
94
+ return lines * lineHeight;
95
+ }
96
+ export function renderBusinessLicense(profile, deps, options = {}) {
97
+ const WIDTH = 856;
98
+ const companyName = options.companyName ?? profile.companyName;
99
+ const tempCanvas = deps.createCanvas(WIDTH, 1000);
100
+ const tempCtx = tempCanvas.getContext('2d');
101
+ const padding = 40;
102
+ const titleTopMargin = 80;
103
+ const leftX = padding + 50;
104
+ const labelFont = 'bold 28px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif';
105
+ const valueFont = '28px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif';
106
+ const lineHeight = 38;
107
+ tempCtx.font = valueFont;
108
+ const calculatedHeight = calculateBusinessLicenseHeight(tempCtx, profile, companyName, padding, titleTopMargin, leftX, labelFont, valueFont, lineHeight);
109
+ const HEIGHT = Math.max(800, Math.ceil(calculatedHeight));
110
+ const canvas = deps.createCanvas(WIDTH, HEIGHT);
111
+ const ctx = canvas.getContext('2d');
112
+ ctx.textBaseline = 'alphabetic';
113
+ ctx.textAlign = 'left';
114
+ ctx.fillStyle = '#f8f9fa';
115
+ ctx.fillRect(0, 0, WIDTH, HEIGHT);
116
+ ctx.save();
117
+ drawRoundedRect(ctx, padding, padding, WIDTH - padding * 2, HEIGHT - padding * 2, 8);
118
+ ctx.fillStyle = '#ffffff';
119
+ if (ctx.fill) {
120
+ ctx.fill();
121
+ }
122
+ ctx.restore();
123
+ ctx.fillStyle = '#000000';
124
+ ctx.font = 'bold 48px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif';
125
+ drawCenteredText(ctx, '营业执照', padding + titleTopMargin, 'bold 48px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", sans-serif', WIDTH);
126
+ ctx.strokeStyle = '#b0b0b0';
127
+ ctx.lineWidth = 3;
128
+ const innerPadding = padding + 20;
129
+ const borderTopMargin = padding + titleTopMargin + 60;
130
+ const borderHeight = HEIGHT - borderTopMargin - padding - 30;
131
+ ctx.strokeRect(innerPadding, borderTopMargin, WIDTH - innerPadding * 2, borderHeight);
132
+ const yOffset = borderTopMargin + 40;
133
+ let currentY = yOffset;
134
+ ctx.fillStyle = '#000000';
135
+ ctx.font = 'bold 28px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", monospace';
136
+ ctx.fillText('统一社会信用代码', leftX, currentY);
137
+ ctx.font = 'bold 30px "Microsoft YaHei", "SimHei", "PingFang SC", "Hiragino Sans GB", "WenQuanYi Micro Hei", monospace';
138
+ const creditCodeX = leftX + 280;
139
+ ctx.fillText(profile.creditCode, creditCodeX, currentY);
140
+ currentY += 60;
141
+ ctx.strokeStyle = '#e0e0e0';
142
+ ctx.lineWidth = 1;
143
+ if (ctx.beginPath && ctx.moveTo && ctx.lineTo && ctx.stroke) {
144
+ ctx.beginPath();
145
+ ctx.moveTo(leftX, currentY - 10);
146
+ ctx.lineTo(WIDTH - padding - 20, currentY - 10);
147
+ ctx.stroke();
148
+ }
149
+ currentY += 20;
150
+ ctx.fillStyle = '#000000';
151
+ drawLabelAndValue(ctx, '名称', companyName, leftX, currentY, { label: labelFont, value: valueFont }, 30);
152
+ currentY += lineHeight + 10;
153
+ drawLabelAndValue(ctx, '类型', profile.companyType, leftX, currentY, { label: labelFont, value: valueFont }, 30);
154
+ currentY += lineHeight + 10;
155
+ ctx.font = labelFont;
156
+ const addressLabel = '住所';
157
+ const addressLabelWidth = ctx.measureText(addressLabel).width;
158
+ ctx.fillText(addressLabel, leftX, currentY);
159
+ ctx.font = valueFont;
160
+ const addressStartX = leftX + addressLabelWidth + 30;
161
+ const addressMaxWidth = WIDTH - addressStartX - padding - 20;
162
+ currentY = drawMultilineText(ctx, profile.address, addressStartX, currentY, addressMaxWidth, lineHeight + 5);
163
+ currentY += 15;
164
+ drawLabelAndValue(ctx, '法定代表人', profile.legalRepresentative, leftX, currentY, { label: labelFont, value: valueFont }, 30);
165
+ currentY += lineHeight + 10;
166
+ drawLabelAndValue(ctx, '注册资本', profile.registeredCapital, leftX, currentY, { label: labelFont, value: valueFont }, 30);
167
+ currentY += lineHeight + 10;
168
+ drawLabelAndValue(ctx, '成立日期', profile.establishDate, leftX, currentY, { label: labelFont, value: valueFont }, 30);
169
+ currentY += lineHeight + 10;
170
+ drawLabelAndValue(ctx, '营业期限', profile.businessTerm, leftX, currentY, { label: labelFont, value: valueFont }, 30);
171
+ currentY += lineHeight + 10;
172
+ ctx.font = labelFont;
173
+ const scopeLabel = '经营范围';
174
+ const scopeLabelWidth = ctx.measureText(scopeLabel).width;
175
+ ctx.fillText(scopeLabel, leftX, currentY);
176
+ ctx.font = valueFont;
177
+ const scopeStartX = leftX + scopeLabelWidth + 30;
178
+ const scopeMaxWidth = WIDTH - scopeStartX - padding - 20;
179
+ currentY = drawMultilineText(ctx, profile.businessScope, scopeStartX, currentY, scopeMaxWidth, lineHeight + 5);
180
+ currentY += 15;
181
+ drawLabelAndValue(ctx, '登记机关', profile.registrationAuthority, leftX, currentY, { label: labelFont, value: valueFont }, 30);
182
+ currentY += lineHeight + 10;
183
+ drawLabelAndValue(ctx, '登记日期', profile.registrationDate, leftX, currentY, { label: labelFont, value: valueFont }, 30);
184
+ currentY += lineHeight + 10;
185
+ return { canvas };
186
+ }
187
+ //# sourceMappingURL=renderBusinessLicense.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderBusinessLicense.js","sourceRoot":"","sources":["../../../src/functions/image/renderBusinessLicense.ts"],"names":[],"mappings":"AAiEA,SAAS,eAAe,CACtB,GAAwB,EACxB,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS,EACT,CAAS;IAET,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;QACl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GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,gBAAgB,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,CAAA;IACrH,QAAQ,IAAI,UAAU,GAAG,EAAE,CAAA;IAE3B,OAAO,EAAE,MAAM,EAAE,CAAA;AACnB,CAAC"}
@@ -0,0 +1,48 @@
1
+ import type { GeneratedDrivingLicenseProfile } from '../validation/generateFakeDrivingLicense';
2
+ import type { Window } from '../../../references/browser.d';
3
+ export interface RenderDrivingLicenseOptions {
4
+ owner?: string;
5
+ }
6
+ export interface Canvas2DContextLike {
7
+ fillStyle: string | CanvasGradientLike;
8
+ strokeStyle: string;
9
+ lineWidth: number;
10
+ font: string;
11
+ textBaseline: string;
12
+ textAlign: string;
13
+ moveTo?: (x: number, y: number) => void;
14
+ lineTo?: (x: number, y: number) => void;
15
+ fill?: () => void;
16
+ stroke?: () => void;
17
+ drawImage: (...args: any[]) => void;
18
+ fillRect: (x: number, y: number, w: number, h: number) => void;
19
+ strokeRect: (x: number, y: number, w: number, h: number) => void;
20
+ fillText: (text: string, x: number, y: number) => void;
21
+ measureText: (text: string) => {
22
+ width: number;
23
+ };
24
+ beginPath: () => void;
25
+ arc: (x: number, y: number, r: number, sAngle: number, eAngle: number) => void;
26
+ closePath: () => void;
27
+ clip: () => void;
28
+ save: () => void;
29
+ restore: () => void;
30
+ createLinearGradient: (x0: number, y0: number, x1: number, y1: number) => CanvasGradientLike;
31
+ }
32
+ export interface CanvasGradientLike {
33
+ addColorStop: (offset: number, color: string) => void;
34
+ }
35
+ export interface CanvasLike {
36
+ width: number;
37
+ height: number;
38
+ getContext: (type: '2d') => Canvas2DContextLike;
39
+ }
40
+ export interface RenderDrivingLicenseDeps {
41
+ createCanvas: (width: number, height: number) => CanvasLike;
42
+ Image: Window['Image'];
43
+ }
44
+ export interface RenderDrivingLicenseResult {
45
+ front: CanvasLike;
46
+ back: CanvasLike;
47
+ }
48
+ export declare function renderDrivingLicense(profile: GeneratedDrivingLicenseProfile, deps: RenderDrivingLicenseDeps, options?: RenderDrivingLicenseOptions): RenderDrivingLicenseResult;