初始化项目, 添加TDesign等包
This commit is contained in:
20
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/calendar/index.d.ts
vendored
Normal file
20
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/calendar/index.d.ts
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
import type { TDate, TCalendarType, TCalendarValue } from './type';
|
||||
export default class TCalendar {
|
||||
firstDayOfWeek: number;
|
||||
value: TCalendarValue | TCalendarValue[];
|
||||
type: TCalendarType;
|
||||
minDate: Date;
|
||||
maxDate: Date;
|
||||
allowSameDay: Boolean;
|
||||
format: (day: TDate) => TDate;
|
||||
constructor(options?: {});
|
||||
getTrimValue(): Date | Date[];
|
||||
getDays(weekdays: string[]): any[];
|
||||
getMonths(): any[];
|
||||
select({ cellType, year, month, date }: {
|
||||
cellType: any;
|
||||
year: any;
|
||||
month: any;
|
||||
date: any;
|
||||
}): Date | TCalendarValue[];
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
import{getDateRect,isSameDate,getMonthDateRect,isValidDate,getDate}from"../date";export default class TCalendar{constructor(e={}){this.type="single",Object.assign(this,e),this.minDate||(this.minDate=getDate()),this.maxDate||(this.maxDate=getDate(6))}getTrimValue(){const{value:e,type:t}=this,a=e=>e instanceof Date?e:"number"==typeof e?new Date(e):new Date;if("single"===t&&isValidDate(e))return a(e);if("multiple"===t||"range"===t){if(Array.isArray(e)){return e.every(e=>isValidDate(e))?e.map(e=>a(e)):[]}return[]}}getDays(e){const t=[];let a=this.firstDayOfWeek%7;for(;t.length<7;)t.push(e[a]),a=(a+1)%7;return t}getMonths(){const e=[],t=this.getTrimValue(),{minDate:a,maxDate:i,type:r,allowSameDay:s,format:n}=this,m=getDateRect(a);let{year:l,month:o}=m;const{time:D}=m,{year:h,month:u,time:y}=getDateRect(i),c=(e,a,i)=>{const n=new Date(e,a,i,23,59,59);if("single"===r&&t&&isSameDate({year:e,month:a,date:i},t))return"selected";if("multiple"===r&&t){if(t.some(t=>isSameDate({year:e,month:a,date:i},t)))return"selected"}if("range"===r&&t&&Array.isArray(t)){const[r,m]=t,l=r&&isSameDate({year:e,month:a,date:i},r),o=m&&isSameDate({year:e,month:a,date:i},m);if(l&&o&&s)return"start-end";if(l)return"start";if(o)return"end";if(r&&m&&n.getTime()>r.getTime()&&n.getTime()<m.getTime())return"centre"}const m=new Date(e,a,i,0,0,0);return n.getTime()<D||m.getTime()>y?"disabled":""};for(;l<h||l===h&&o<=u;){const t=getMonthDateRect(new Date(l,o,1)),a=[];for(let e=1;e<=31&&!(e>t.lastDate);e+=1){const t={date:new Date(l,o,e),day:e,type:c(l,o,e)};a.push(n?n(t):t)}e.push({year:l,month:o,months:a,weekdayOfFirstDay:t.weekdayOfFirstDay});const i=getDateRect(new Date(l,o+1,1));l=i.year,o=i.month}return e}select({cellType:e,year:t,month:a,date:i}){const{type:r}=this,s=this.getTrimValue();if("disabled"===e)return;const n=new Date(t,a,i);if(this.value=n,"range"===r&&Array.isArray(s))1===s.length&&n>=s[0]?this.value=[s[0],n]:this.value=[n];else if("multiple"===r&&Array.isArray(s)){const e=[...s],t=s.findIndex(e=>isSameDate(e,n));t>-1?e.splice(t,1):e.push(n),this.value=e}return this.value}}
|
||||
11
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/calendar/type.d.ts
vendored
Normal file
11
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/calendar/type.d.ts
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
export declare type TCalendarValue = number | Date;
|
||||
export declare type TDateType = 'selected' | 'disabled' | 'start-end' | 'start' | 'centre' | 'end' | '';
|
||||
export declare type TCalendarType = 'single' | 'multiple' | 'range';
|
||||
export interface TDate {
|
||||
date: Date;
|
||||
day: number;
|
||||
type: TDateType;
|
||||
className?: string;
|
||||
prefix?: string;
|
||||
suffix?: string;
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
7
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/cmyk.d.ts
vendored
Normal file
7
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/cmyk.d.ts
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
export declare const rgb2cmyk: (red: number, green: number, blue: number) => number[];
|
||||
export declare const cmyk2rgb: (cyan: number, magenta: number, yellow: number, black: number) => {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
};
|
||||
export declare const cmykInputToColor: (input: string) => string;
|
||||
@@ -0,0 +1 @@
|
||||
export const rgb2cmyk=(t,r,e)=>{let n=0,o=0,c=0,a=0;const s=parseInt(`${t}`.replace(/\s/g,""),10),m=parseInt(`${r}`.replace(/\s/g,""),10),u=parseInt(`${e}`.replace(/\s/g,""),10);if(0===s&&0===m&&0===u)return a=1,[0,0,0,1];n=1-s/255,o=1-m/255,c=1-u/255;const p=Math.min(n,Math.min(o,c));return n=(n-p)/(1-p),o=(o-p)/(1-p),c=(c-p)/(1-p),a=p,[n,o,c,a]};export const cmyk2rgb=(t,r,e,n)=>{let o=t/100,c=r/100,a=e/100;const s=n/100;o=o*(1-s)+s,c=c*(1-s)+s,a=a*(1-s)+s;let m=1-o,u=1-c,p=1-a;return m=Math.round(255*m),u=Math.round(255*u),p=Math.round(255*p),{r:m,g:u,b:p}};const REG_CMYK_STRING=/cmyk\((\d+%?),(\d+%?),(\d+%?),(\d+%?)\)/,toNumber=t=>Math.max(0,Math.min(255,parseInt(t,10)));export const cmykInputToColor=t=>{if(/cmyk/i.test(t)){const r=t.replace(/\s/g,"").match(REG_CMYK_STRING),e=toNumber(r[1]),n=toNumber(r[2]),o=toNumber(r[3]),c=toNumber(r[4]),{r:a,g:s,b:m}=cmyk2rgb(e,n,o,c);return`rgb(${a}, ${s}, ${m})`}return t};
|
||||
107
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/color.d.ts
vendored
Normal file
107
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/color.d.ts
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
import tinyColor from 'tinycolor2/esm/tinycolor';
|
||||
import { GradientColors, GradientColorPoint } from './gradient';
|
||||
export interface ColorObject {
|
||||
alpha: number;
|
||||
css: string;
|
||||
hex: string;
|
||||
hex8: string;
|
||||
hsl: string;
|
||||
hsla: string;
|
||||
hsv: string;
|
||||
hsva: string;
|
||||
rgb: string;
|
||||
rgba: string;
|
||||
saturation: number;
|
||||
value: number;
|
||||
isGradient: boolean;
|
||||
linearGradient?: string;
|
||||
}
|
||||
interface ColorStates {
|
||||
s: number;
|
||||
v: number;
|
||||
h: number;
|
||||
a: number;
|
||||
}
|
||||
interface GradientStates {
|
||||
colors: GradientColorPoint[];
|
||||
degree: number;
|
||||
selectedId: string;
|
||||
css?: string;
|
||||
}
|
||||
export declare const gradientColors2string: (object: GradientColors) => string;
|
||||
export declare const getColorWithoutAlpha: (color: string) => any;
|
||||
export declare const genId: () => string;
|
||||
export declare const genGradientPoint: (left: number, color: string) => GradientColorPoint;
|
||||
export declare class Color {
|
||||
states: ColorStates;
|
||||
originColor: string;
|
||||
isGradient: boolean;
|
||||
gradientStates: GradientStates;
|
||||
constructor(input: string);
|
||||
update(input: string): void;
|
||||
get saturation(): number;
|
||||
set saturation(value: number);
|
||||
get value(): number;
|
||||
set value(value: number);
|
||||
get hue(): number;
|
||||
set hue(value: number);
|
||||
get alpha(): number;
|
||||
set alpha(value: number);
|
||||
get rgb(): string;
|
||||
get rgba(): string;
|
||||
get hsv(): string;
|
||||
get hsva(): string;
|
||||
get hsl(): string;
|
||||
get hsla(): string;
|
||||
get hex(): any;
|
||||
get hex8(): any;
|
||||
get cmyk(): string;
|
||||
get css(): string;
|
||||
get linearGradient(): string;
|
||||
get gradientColors(): GradientColorPoint[];
|
||||
set gradientColors(colors: GradientColorPoint[]);
|
||||
get gradientSelectedId(): string;
|
||||
set gradientSelectedId(id: string);
|
||||
get gradientDegree(): number;
|
||||
set gradientDegree(degree: number);
|
||||
get gradientSelectedPoint(): GradientColorPoint;
|
||||
getFormatsColorMap(): {
|
||||
HEX: any;
|
||||
CMYK: string;
|
||||
RGB: string;
|
||||
RGBA: string;
|
||||
HSL: string;
|
||||
HSLA: string;
|
||||
HSV: string;
|
||||
HSVA: string;
|
||||
CSS: string;
|
||||
HEX8: any;
|
||||
};
|
||||
updateCurrentGradientColor(): false | this;
|
||||
updateStates(input: string): void;
|
||||
getRgba(): {
|
||||
r: number;
|
||||
g: number;
|
||||
b: number;
|
||||
a: tinyColor.ColorFormats.RGBA;
|
||||
};
|
||||
getCmyk(): {
|
||||
c: number;
|
||||
m: number;
|
||||
y: number;
|
||||
k: number;
|
||||
};
|
||||
getHsva(): tinyColor.ColorFormats.HSVA;
|
||||
getHsla(): tinyColor.ColorFormats.HSLA;
|
||||
equals(color: string): boolean;
|
||||
static isValid(color: string): boolean;
|
||||
static hsva2color(h: number, s: number, v: number, a: number): any;
|
||||
static hsla2color(h: number, s: number, l: number, a: number): any;
|
||||
static rgba2color(r: number, g: number, b: number, a: number): any;
|
||||
static hex2color(hex: string, a: number): any;
|
||||
static object2color(object: any, format: string): any;
|
||||
static isGradientColor: (input: string) => boolean;
|
||||
static compare: (color1: string, color2: string) => boolean;
|
||||
}
|
||||
export declare const getColorObject: (color: Color) => ColorObject;
|
||||
export default Color;
|
||||
File diff suppressed because one or more lines are too long
12
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/gradient.d.ts
vendored
Normal file
12
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/gradient.d.ts
vendored
Normal file
@@ -0,0 +1,12 @@
|
||||
export interface GradientColorPoint {
|
||||
id?: string;
|
||||
color?: string;
|
||||
left?: number;
|
||||
}
|
||||
export interface GradientColors {
|
||||
points: GradientColorPoint[];
|
||||
degree: number;
|
||||
}
|
||||
export declare const isGradientColor: (input: string) => null | RegExpExecArray;
|
||||
export declare const parseGradientString: (input: string) => GradientColors | boolean;
|
||||
export default parseGradientString;
|
||||
@@ -0,0 +1 @@
|
||||
import tinyColor from"tinycolor2/esm/tinycolor";import{isString,isNull}from"../../validator";const combineRegExp=(e,t)=>{let o="";for(let t=0;t<e.length;t+=1)isString(e[t])?o+=e[t]:o+=e[t].source;return new RegExp(o,t)},generateRegExp=()=>{const e=/\s*,\s*/,t=/(?:[+-]?\d*\.?\d+)(?:%|[a-z]+)?/,o=combineRegExp(["(?:",/#(?:[a-f0-9]{6}|[a-f0-9]{3})/,"|","(?:rgb|hsl)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*\)/,"|","(?:rgba|hsla)",/\(\s*(?:\d{1,3}\s*,\s*){2}\d{1,3}\s*,\s*\d*\.?\d+\)/,"|",/[_a-z-][_a-z0-9-]*/,")"],""),r=combineRegExp([o,"(?:\\s+",t,"(?:\\s+",t,")?)?"],""),i=combineRegExp(["(?:",r,e,")*",r],""),n=combineRegExp(["(?:(",/(?:[+-]?\d*\.?\d+)(?:deg|grad|rad|turn)/,")|",/to\s+((?:(?:left|right|top|bottom)(?:\s+(?:top|bottom|left|right))?))/,")"],"");return{gradientSearch:combineRegExp(["(?:(",n,")",e,")?(",i,")"],"gi"),colorStopSearch:combineRegExp(["\\s*(",o,")","(?:\\s+","(",t,"))?","(?:",e,"\\s*)?"],"gi")}},parseGradient=(e,t)=>{let o,r,i;e.gradientSearch.lastIndex=0;const n=e.gradientSearch.exec(t);if(!isNull(n))for(o={original:n[0],colorStopList:[]},n[1]&&(o.line=n[1]),n[2]&&(o.angle=n[2]),n[3]&&(o.sideCorner=n[3]),e.colorStopSearch.lastIndex=0,r=e.colorStopSearch.exec(n[4]);!isNull(r);)i={color:r[1]},r[2]&&(i.position=r[2]),o.colorStopList.push(i),r=e.colorStopSearch.exec(n[4]);return o},REGEXP_LIB=generateRegExp(),REG_GRADIENT=/.*gradient\s*\(((?:\([^)]*\)|[^)(]*)*)\)/gim;export const isGradientColor=e=>(REG_GRADIENT.lastIndex=0,REG_GRADIENT.exec(e));const sideCornerDegreeMap={top:0,right:90,bottom:180,left:270,"top left":225,"left top":225,"top right":135,"right top":135,"bottom left":315,"left bottom":315,"bottom right":45,"right bottom":45};export const parseGradientString=e=>{const t=isGradientColor(e);if(!t)return!1;const o={points:[],degree:0},r=parseGradient(REGEXP_LIB,t[1]);if(r.original.trim()!==t[1].trim())return!1;const i=r.colorStopList.map(({color:e,position:t})=>{const o=Object.create(null);return o.color=tinyColor(e).toRgbString(),o.left=parseFloat(t),o});o.points=i;let n=parseInt(r.angle,10);return Number.isNaN(n)&&(n=sideCornerDegreeMap[r.sideCorner]||90),o.degree=n,o};export default parseGradientString;
|
||||
3
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/index.d.ts
vendored
Normal file
3
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/color-picker/index.d.ts
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export * from './cmyk';
|
||||
export * from './color';
|
||||
export * from './gradient';
|
||||
@@ -0,0 +1 @@
|
||||
export*from"./cmyk";export*from"./color";export*from"./gradient";
|
||||
21
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/date.d.ts
vendored
Normal file
21
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/date.d.ts
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
export declare type CompareDate = Date | number | {
|
||||
year: number;
|
||||
month: number;
|
||||
date: number;
|
||||
};
|
||||
export declare const getDateRect: (date: Date | number) => {
|
||||
year: number;
|
||||
month: number;
|
||||
date: number;
|
||||
day: number;
|
||||
time: number;
|
||||
};
|
||||
export declare const isSameDate: (date1: CompareDate, date2: CompareDate) => Boolean;
|
||||
export declare const getMonthDateRect: (date: Date | number) => {
|
||||
year: number;
|
||||
month: number;
|
||||
weekdayOfFirstDay: number;
|
||||
lastDate: number;
|
||||
};
|
||||
export declare const isValidDate: (val: any) => boolean;
|
||||
export declare const getDate: (...args: any[]) => any;
|
||||
@@ -0,0 +1 @@
|
||||
export const getDateRect=e=>{const t=new Date(e);return{year:t.getFullYear(),month:t.getMonth(),date:t.getDate(),day:t.getDay(),time:t.getTime()}};export const isSameDate=(e,t)=>{(e instanceof Date||"number"==typeof e)&&(e=getDateRect(e)),(t instanceof Date||"number"==typeof t)&&(t=getDateRect(t));return["year","month","date"].every(a=>e[a]===t[a])};export const getMonthDateRect=e=>{const{year:t,month:a}=getDateRect(e);return{year:t,month:a,weekdayOfFirstDay:new Date(t,a,1).getDay(),lastDate:new Date(+new Date(t,a+1,1)-864e5).getDate()}};export const isValidDate=e=>"number"==typeof e||e instanceof Date;export const getDate=(...e)=>{const t=new Date;if(0===e.length)return t;if(1===e.length&&e[0]<=1e3){const{year:a,month:n,date:r}=getDateRect(t);return new Date(a,n+e[0],r)}return Date.apply(null,e)};
|
||||
80
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/qrcodegen.d.ts
vendored
Normal file
80
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/qrcodegen.d.ts
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
export declare class Mode {
|
||||
static readonly NUMERIC: Mode;
|
||||
static readonly ALPHANUMERIC: Mode;
|
||||
static readonly BYTE: Mode;
|
||||
static readonly KANJI: Mode;
|
||||
static readonly ECI: Mode;
|
||||
modeBits: number;
|
||||
private numBitsCharCount;
|
||||
private constructor();
|
||||
numCharCountBits(ver: number): number;
|
||||
}
|
||||
export declare class Ecc {
|
||||
static readonly LOW: Ecc;
|
||||
static readonly MEDIUM: Ecc;
|
||||
static readonly QUARTILE: Ecc;
|
||||
static readonly HIGH: Ecc;
|
||||
ordinal: number;
|
||||
formatBits: number;
|
||||
private constructor();
|
||||
}
|
||||
export declare class QrSegment {
|
||||
static makeBytes(data: Readonly<number[]>): QrSegment;
|
||||
static makeNumeric(digits: string): QrSegment;
|
||||
static makeAlphanumeric(text: string): QrSegment;
|
||||
static makeSegments(text: string): QrSegment[];
|
||||
static makeEci(assignVal: number): QrSegment;
|
||||
static isNumeric(text: string): boolean;
|
||||
static isAlphanumeric(text: string): boolean;
|
||||
mode: Mode;
|
||||
numChars: number;
|
||||
private bitData;
|
||||
constructor(mode: Mode, numChars: number, bitData: number[]);
|
||||
getData(): number[];
|
||||
static getTotalBits(segs: Readonly<QrSegment[]>, version: number): number;
|
||||
private static toUtf8ByteArray;
|
||||
private static readonly NUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_REGEX;
|
||||
private static readonly ALPHANUMERIC_CHARSET;
|
||||
}
|
||||
export declare class QrCode {
|
||||
static encodeText(text: string, ecl: Ecc): QrCode;
|
||||
static encodeBinary(data: Readonly<number[]>, ecl: Ecc): QrCode;
|
||||
static encodeSegments(segs: Readonly<QrSegment[]>, oriEcl: Ecc, minVersion?: number, maxVersion?: number, mask?: number, boostEcl?: boolean): QrCode;
|
||||
readonly size: number;
|
||||
readonly mask: number;
|
||||
private readonly modules;
|
||||
private readonly isFunction;
|
||||
version: number;
|
||||
errorCorrectionLevel: Ecc;
|
||||
constructor(version: number, errorCorrectionLevel: Ecc, dataCodewords: Readonly<number[]>, oriMsk: number);
|
||||
getModule(x: number, y: number): boolean;
|
||||
getModules(): boolean[][];
|
||||
private drawFunctionPatterns;
|
||||
private drawFormatBits;
|
||||
private drawVersion;
|
||||
private drawFinderPattern;
|
||||
private drawAlignmentPattern;
|
||||
private setFunctionModule;
|
||||
private addEccAndInterleave;
|
||||
private drawCodewords;
|
||||
private applyMask;
|
||||
private getPenaltyScore;
|
||||
private getAlignmentPatternPositions;
|
||||
private static getNumRawDataModules;
|
||||
private static getNumDataCodewords;
|
||||
private static reedSolomonComputeDivisor;
|
||||
private static reedSolomonComputeRemainder;
|
||||
private static reedSolomonMultiply;
|
||||
private finderPenaltyCountPatterns;
|
||||
private finderPenaltyTerminateAndCount;
|
||||
private finderPenaltyAddHistory;
|
||||
static readonly MIN_VERSION: number;
|
||||
static readonly MAX_VERSION: number;
|
||||
private static readonly PENALTY_N1;
|
||||
private static readonly PENALTY_N2;
|
||||
private static readonly PENALTY_N3;
|
||||
private static readonly PENALTY_N4;
|
||||
private static readonly ECC_CODEWORDS_PER_BLOCK;
|
||||
private static readonly NUM_ERROR_CORRECTION_BLOCKS;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
23
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/types.d.ts
vendored
Normal file
23
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/types.d.ts
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Ecc, QrCode } from './qrcodegen';
|
||||
export declare type Modules = ReturnType<QrCode['getModules']>;
|
||||
export declare type Excavation = {
|
||||
x: number;
|
||||
y: number;
|
||||
w: number;
|
||||
h: number;
|
||||
};
|
||||
export declare type ErrorCorrectionLevel = 'L' | 'M' | 'Q' | 'H';
|
||||
export declare type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined;
|
||||
export declare type ERROR_LEVEL_MAPPED_TYPE = {
|
||||
[index in ErrorCorrectionLevel]: Ecc;
|
||||
};
|
||||
export declare type ImageSettings = {
|
||||
src: string;
|
||||
height: number;
|
||||
width: number;
|
||||
excavate: boolean;
|
||||
x?: number;
|
||||
y?: number;
|
||||
opacity?: number;
|
||||
crossOrigin?: CrossOrigin;
|
||||
};
|
||||
@@ -0,0 +1 @@
|
||||
export{};
|
||||
24
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/utils.d.ts
vendored
Normal file
24
miniprogram/miniprogram_npm/tdesign-miniprogram/common/shared/qrcode/utils.d.ts
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
import type { CrossOrigin, ERROR_LEVEL_MAPPED_TYPE, ErrorCorrectionLevel, Excavation, ImageSettings } from './types';
|
||||
export declare const ERROR_LEVEL_MAP: ERROR_LEVEL_MAPPED_TYPE;
|
||||
export declare const DEFAULT_SIZE = 160;
|
||||
export declare const DEFAULT_LEVEL: ErrorCorrectionLevel;
|
||||
export declare const DEFAULT_BACKGROUND_COLOR = "#FFFFFF";
|
||||
export declare const DEFAULT_FRONT_COLOR = "#000000";
|
||||
export declare const DEFAULT_NEED_MARGIN = false;
|
||||
export declare const DEFAULT_MINVERSION = 1;
|
||||
export declare const SPEC_MARGIN_SIZE = 4;
|
||||
export declare const DEFAULT_MARGIN_SIZE = 0;
|
||||
export declare const DEFAULT_IMG_SCALE = 0.1;
|
||||
export declare const generatePath: (modules: boolean[][], margin?: number) => string;
|
||||
export declare const excavateModules: (modules: boolean[][], excavation: Excavation) => boolean[][];
|
||||
export declare const getImageSettings: (cells: boolean[][], size: number, margin: number, imageSettings?: ImageSettings) => {
|
||||
x: number;
|
||||
y: number;
|
||||
h: number;
|
||||
w: number;
|
||||
excavation: Excavation | null;
|
||||
opacity: number;
|
||||
crossOrigin: CrossOrigin;
|
||||
};
|
||||
export declare const getMarginSize: (needMargin: boolean, marginSize?: number) => number;
|
||||
export declare const isSupportPath2d: boolean;
|
||||
@@ -0,0 +1 @@
|
||||
import{Ecc}from"./qrcodegen";export const ERROR_LEVEL_MAP={L:Ecc.LOW,M:Ecc.MEDIUM,Q:Ecc.QUARTILE,H:Ecc.HIGH};export const DEFAULT_SIZE=160;export const DEFAULT_LEVEL="M";export const DEFAULT_BACKGROUND_COLOR="#FFFFFF";export const DEFAULT_FRONT_COLOR="#000000";export const DEFAULT_NEED_MARGIN=!1;export const DEFAULT_MINVERSION=1;export const SPEC_MARGIN_SIZE=4;export const DEFAULT_MARGIN_SIZE=0;export const DEFAULT_IMG_SCALE=.1;export const generatePath=(t,o=0)=>{const e=[];return t.forEach((t,n)=>{let r=null;t.forEach((c,l)=>{if(!c&&null!==r)return e.push(`M${r+o} ${n+o}h${l-r}v1H${r+o}z`),void(r=null);if(l!==t.length-1)c&&null===r&&(r=l);else{if(!c)return;null===r?e.push(`M${l+o},${n+o} h1v1H${l+o}z`):e.push(`M${r+o},${n+o} h${l+1-r}v1H${r+o}z`)}})}),e.join("")};export const excavateModules=(t,o)=>t.slice().map((t,e)=>e<o.y||e>=o.y+o.h?t:t.map((t,e)=>(e<o.x||e>=o.x+o.w)&&t));export const getImageSettings=(t,o,e,n)=>{if(null==n)return null;const r=t.length+2*e,c=Math.floor(.1*o),l=r/o,a=(n.width||c)*l,h=(n.height||c)*l,s=null==n.x?t.length/2-a/2:n.x*l,E=null==n.y?t.length/2-h/2:n.y*l,p=null==n.opacity?1:n.opacity;let i=null;if(n.excavate){const t=Math.floor(s),o=Math.floor(E);i={x:t,y:o,w:Math.ceil(a+s-t),h:Math.ceil(h+E-o)}}const{crossOrigin:x}=n;return{x:s,y:E,h:h,w:a,excavation:i,opacity:p,crossOrigin:x}};export const getMarginSize=(t,o)=>null!=o?Math.max(Math.floor(o),0):t?4:0;export const isSupportPath2d=(()=>{try{(new Path2D).addPath(new Path2D)}catch(t){return!1}return!0})();
|
||||
Reference in New Issue
Block a user