@deot/vc 1.0.53 → 1.0.55
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.d.ts +40 -4
- package/dist/index.iife.js +64 -40
- package/dist/index.umd.cjs +64 -40
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -4110,10 +4110,18 @@ export declare const Components: {
|
|
|
4110
4110
|
crossOrigin: {
|
|
4111
4111
|
type: StringConstructor;
|
|
4112
4112
|
default: string;
|
|
4113
|
-
validator: (v:
|
|
4113
|
+
validator: (v: string) => boolean;
|
|
4114
4114
|
};
|
|
4115
4115
|
source: FunctionConstructor;
|
|
4116
4116
|
download: FunctionConstructor;
|
|
4117
|
+
lazy: {
|
|
4118
|
+
type: BooleanConstructor;
|
|
4119
|
+
default: boolean;
|
|
4120
|
+
};
|
|
4121
|
+
showLoading: {
|
|
4122
|
+
type: BooleanConstructor;
|
|
4123
|
+
default: boolean;
|
|
4124
|
+
};
|
|
4117
4125
|
options: {
|
|
4118
4126
|
type: ObjectConstructor;
|
|
4119
4127
|
default: () => {};
|
|
@@ -4126,10 +4134,18 @@ export declare const Components: {
|
|
|
4126
4134
|
crossOrigin: {
|
|
4127
4135
|
type: StringConstructor;
|
|
4128
4136
|
default: string;
|
|
4129
|
-
validator: (v:
|
|
4137
|
+
validator: (v: string) => boolean;
|
|
4130
4138
|
};
|
|
4131
4139
|
source: FunctionConstructor;
|
|
4132
4140
|
download: FunctionConstructor;
|
|
4141
|
+
lazy: {
|
|
4142
|
+
type: BooleanConstructor;
|
|
4143
|
+
default: boolean;
|
|
4144
|
+
};
|
|
4145
|
+
showLoading: {
|
|
4146
|
+
type: BooleanConstructor;
|
|
4147
|
+
default: boolean;
|
|
4148
|
+
};
|
|
4133
4149
|
options: {
|
|
4134
4150
|
type: ObjectConstructor;
|
|
4135
4151
|
default: () => {};
|
|
@@ -4139,7 +4155,9 @@ export declare const Components: {
|
|
|
4139
4155
|
}>, {
|
|
4140
4156
|
tag: string;
|
|
4141
4157
|
options: Record<string, any>;
|
|
4158
|
+
showLoading: boolean;
|
|
4142
4159
|
crossOrigin: string;
|
|
4160
|
+
lazy: boolean;
|
|
4143
4161
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
4144
4162
|
MSnapshot: DefineComponent<ExtractPropTypes< {
|
|
4145
4163
|
tag: {
|
|
@@ -4149,10 +4167,18 @@ export declare const Components: {
|
|
|
4149
4167
|
crossOrigin: {
|
|
4150
4168
|
type: StringConstructor;
|
|
4151
4169
|
default: string;
|
|
4152
|
-
validator: (v:
|
|
4170
|
+
validator: (v: string) => boolean;
|
|
4153
4171
|
};
|
|
4154
4172
|
source: FunctionConstructor;
|
|
4155
4173
|
download: FunctionConstructor;
|
|
4174
|
+
lazy: {
|
|
4175
|
+
type: BooleanConstructor;
|
|
4176
|
+
default: boolean;
|
|
4177
|
+
};
|
|
4178
|
+
showLoading: {
|
|
4179
|
+
type: BooleanConstructor;
|
|
4180
|
+
default: boolean;
|
|
4181
|
+
};
|
|
4156
4182
|
options: {
|
|
4157
4183
|
type: ObjectConstructor;
|
|
4158
4184
|
default: () => {};
|
|
@@ -4165,10 +4191,18 @@ export declare const Components: {
|
|
|
4165
4191
|
crossOrigin: {
|
|
4166
4192
|
type: StringConstructor;
|
|
4167
4193
|
default: string;
|
|
4168
|
-
validator: (v:
|
|
4194
|
+
validator: (v: string) => boolean;
|
|
4169
4195
|
};
|
|
4170
4196
|
source: FunctionConstructor;
|
|
4171
4197
|
download: FunctionConstructor;
|
|
4198
|
+
lazy: {
|
|
4199
|
+
type: BooleanConstructor;
|
|
4200
|
+
default: boolean;
|
|
4201
|
+
};
|
|
4202
|
+
showLoading: {
|
|
4203
|
+
type: BooleanConstructor;
|
|
4204
|
+
default: boolean;
|
|
4205
|
+
};
|
|
4172
4206
|
options: {
|
|
4173
4207
|
type: ObjectConstructor;
|
|
4174
4208
|
default: () => {};
|
|
@@ -4178,7 +4212,9 @@ export declare const Components: {
|
|
|
4178
4212
|
}>, {
|
|
4179
4213
|
tag: string;
|
|
4180
4214
|
options: Record<string, any>;
|
|
4215
|
+
showLoading: boolean;
|
|
4181
4216
|
crossOrigin: string;
|
|
4217
|
+
lazy: boolean;
|
|
4182
4218
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
4183
4219
|
Icon: DefineComponent<ExtractPropTypes< {
|
|
4184
4220
|
type: StringConstructor;
|
package/dist/index.iife.js
CHANGED
|
@@ -9104,6 +9104,7 @@ var Vc = (function (exports, vue) {
|
|
|
9104
9104
|
line: nil
|
|
9105
9105
|
},
|
|
9106
9106
|
Snapshot: {
|
|
9107
|
+
options: nil,
|
|
9107
9108
|
source: nil,
|
|
9108
9109
|
download: nil
|
|
9109
9110
|
}
|
|
@@ -19317,14 +19318,18 @@ var Vc = (function (exports, vue) {
|
|
|
19317
19318
|
}
|
|
19318
19319
|
let { enhancer } = VcInstance.options.Upload || {};
|
|
19319
19320
|
enhancer = props2.enhancer || enhancer || (() => false);
|
|
19320
|
-
const
|
|
19321
|
-
if (
|
|
19322
|
-
|
|
19323
|
-
|
|
19321
|
+
const skip = enhancer(instance);
|
|
19322
|
+
if (skip && skip.then) {
|
|
19323
|
+
let skip$ = false;
|
|
19324
|
+
skip.then((v) => {
|
|
19325
|
+
skip$ = typeof v === "undefined" ? true : !!v;
|
|
19326
|
+
return v;
|
|
19327
|
+
}).finally(() => {
|
|
19328
|
+
skip$ || el2.click?.();
|
|
19324
19329
|
});
|
|
19325
19330
|
return;
|
|
19326
19331
|
}
|
|
19327
|
-
|
|
19332
|
+
skip || el2.click();
|
|
19328
19333
|
};
|
|
19329
19334
|
const handleChange = (e) => {
|
|
19330
19335
|
uploadFiles(e.target.files);
|
|
@@ -20553,6 +20558,14 @@ var Vc = (function (exports, vue) {
|
|
|
20553
20558
|
},
|
|
20554
20559
|
source: Function,
|
|
20555
20560
|
download: Function,
|
|
20561
|
+
lazy: {
|
|
20562
|
+
type: Boolean,
|
|
20563
|
+
default: true
|
|
20564
|
+
},
|
|
20565
|
+
showLoading: {
|
|
20566
|
+
type: Boolean,
|
|
20567
|
+
default: true
|
|
20568
|
+
},
|
|
20556
20569
|
// 传递给snap-dom的配置项
|
|
20557
20570
|
options: {
|
|
20558
20571
|
type: Object,
|
|
@@ -20569,60 +20582,71 @@ var Vc = (function (exports, vue) {
|
|
|
20569
20582
|
slots,
|
|
20570
20583
|
expose
|
|
20571
20584
|
}) {
|
|
20585
|
+
let snapDOM;
|
|
20572
20586
|
const instance = vue.getCurrentInstance();
|
|
20573
20587
|
const current = vue.ref();
|
|
20574
|
-
const
|
|
20588
|
+
const snapshot = vue.ref();
|
|
20575
20589
|
const refresh = async () => {
|
|
20576
|
-
|
|
20577
|
-
|
|
20578
|
-
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20589
|
-
|
|
20590
|
-
image.onload = () => {
|
|
20591
|
-
node.src = image.src;
|
|
20592
|
-
resolve(1);
|
|
20593
|
-
};
|
|
20594
|
-
image.onerror = () => resolve(0);
|
|
20595
|
-
})();
|
|
20596
|
-
});
|
|
20597
|
-
}));
|
|
20590
|
+
await vue.nextTick();
|
|
20591
|
+
snapshot.value = await snapDOM(current.value, {
|
|
20592
|
+
fast: false,
|
|
20593
|
+
// dom太大时会卡死一会儿
|
|
20594
|
+
...VcInstance.options.Snapshot?.options,
|
|
20595
|
+
...props2.options
|
|
20596
|
+
});
|
|
20597
|
+
return snapshot.value;
|
|
20598
|
+
};
|
|
20599
|
+
const onLoad = () => {
|
|
20600
|
+
return props2.showLoading && Message.loading("正在生成...");
|
|
20601
|
+
};
|
|
20602
|
+
const onLoaded = (ctx) => {
|
|
20603
|
+
ctx?.destroy?.();
|
|
20598
20604
|
};
|
|
20599
20605
|
const toDataURL = async () => {
|
|
20606
|
+
const loadContext = onLoad();
|
|
20607
|
+
try {
|
|
20608
|
+
await refresh();
|
|
20609
|
+
return snapshot.value.toRaw();
|
|
20610
|
+
} finally {
|
|
20611
|
+
onLoaded(loadContext);
|
|
20612
|
+
}
|
|
20613
|
+
};
|
|
20614
|
+
const downloadByDefault = async (options) => {
|
|
20600
20615
|
await refresh();
|
|
20601
|
-
return
|
|
20616
|
+
return snapshot.value.download(options);
|
|
20602
20617
|
};
|
|
20603
20618
|
const download = async (options) => {
|
|
20604
|
-
|
|
20605
|
-
const
|
|
20606
|
-
const
|
|
20607
|
-
|
|
20608
|
-
|
|
20609
|
-
|
|
20610
|
-
}
|
|
20619
|
+
const loadContext = onLoad();
|
|
20620
|
+
const downloadByUser = props2.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
20621
|
+
const skip = downloadByUser(instance, options);
|
|
20622
|
+
const done = async (v) => {
|
|
20623
|
+
try {
|
|
20624
|
+
v || await downloadByDefault(options);
|
|
20625
|
+
} finally {
|
|
20626
|
+
onLoaded(loadContext);
|
|
20627
|
+
}
|
|
20628
|
+
};
|
|
20629
|
+
if (skip && skip.then) {
|
|
20630
|
+
let skip$ = false;
|
|
20631
|
+
skip.then((v) => {
|
|
20632
|
+
skip$ = typeof v === "undefined" ? true : !!v;
|
|
20633
|
+
return v;
|
|
20634
|
+
}).finally(() => done(skip$));
|
|
20611
20635
|
return;
|
|
20612
20636
|
}
|
|
20613
|
-
|
|
20637
|
+
done(skip);
|
|
20614
20638
|
};
|
|
20615
20639
|
expose({
|
|
20616
|
-
|
|
20640
|
+
snapshot,
|
|
20617
20641
|
refresh,
|
|
20618
20642
|
toDataURL,
|
|
20619
20643
|
download
|
|
20620
20644
|
});
|
|
20621
20645
|
vue.onMounted(async () => {
|
|
20622
20646
|
try {
|
|
20623
|
-
|
|
20647
|
+
snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
|
|
20624
20648
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
20625
|
-
|
|
20649
|
+
!props2.lazy && await refresh();
|
|
20626
20650
|
emit("ready", {
|
|
20627
20651
|
instance,
|
|
20628
20652
|
dependencies: {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -9107,6 +9107,7 @@
|
|
|
9107
9107
|
line: nil
|
|
9108
9108
|
},
|
|
9109
9109
|
Snapshot: {
|
|
9110
|
+
options: nil,
|
|
9110
9111
|
source: nil,
|
|
9111
9112
|
download: nil
|
|
9112
9113
|
}
|
|
@@ -19320,14 +19321,18 @@
|
|
|
19320
19321
|
}
|
|
19321
19322
|
let { enhancer } = VcInstance.options.Upload || {};
|
|
19322
19323
|
enhancer = props2.enhancer || enhancer || (() => false);
|
|
19323
|
-
const
|
|
19324
|
-
if (
|
|
19325
|
-
|
|
19326
|
-
|
|
19324
|
+
const skip = enhancer(instance);
|
|
19325
|
+
if (skip && skip.then) {
|
|
19326
|
+
let skip$ = false;
|
|
19327
|
+
skip.then((v) => {
|
|
19328
|
+
skip$ = typeof v === "undefined" ? true : !!v;
|
|
19329
|
+
return v;
|
|
19330
|
+
}).finally(() => {
|
|
19331
|
+
skip$ || el2.click?.();
|
|
19327
19332
|
});
|
|
19328
19333
|
return;
|
|
19329
19334
|
}
|
|
19330
|
-
|
|
19335
|
+
skip || el2.click();
|
|
19331
19336
|
};
|
|
19332
19337
|
const handleChange = (e) => {
|
|
19333
19338
|
uploadFiles(e.target.files);
|
|
@@ -20556,6 +20561,14 @@
|
|
|
20556
20561
|
},
|
|
20557
20562
|
source: Function,
|
|
20558
20563
|
download: Function,
|
|
20564
|
+
lazy: {
|
|
20565
|
+
type: Boolean,
|
|
20566
|
+
default: true
|
|
20567
|
+
},
|
|
20568
|
+
showLoading: {
|
|
20569
|
+
type: Boolean,
|
|
20570
|
+
default: true
|
|
20571
|
+
},
|
|
20559
20572
|
// 传递给snap-dom的配置项
|
|
20560
20573
|
options: {
|
|
20561
20574
|
type: Object,
|
|
@@ -20572,60 +20585,71 @@
|
|
|
20572
20585
|
slots,
|
|
20573
20586
|
expose
|
|
20574
20587
|
}) {
|
|
20588
|
+
let snapDOM;
|
|
20575
20589
|
const instance = vue.getCurrentInstance();
|
|
20576
20590
|
const current = vue.ref();
|
|
20577
|
-
const
|
|
20591
|
+
const snapshot = vue.ref();
|
|
20578
20592
|
const refresh = async () => {
|
|
20579
|
-
|
|
20580
|
-
|
|
20581
|
-
|
|
20582
|
-
|
|
20583
|
-
|
|
20584
|
-
|
|
20585
|
-
|
|
20586
|
-
|
|
20587
|
-
|
|
20588
|
-
|
|
20589
|
-
|
|
20590
|
-
|
|
20591
|
-
|
|
20592
|
-
|
|
20593
|
-
image.onload = () => {
|
|
20594
|
-
node.src = image.src;
|
|
20595
|
-
resolve(1);
|
|
20596
|
-
};
|
|
20597
|
-
image.onerror = () => resolve(0);
|
|
20598
|
-
})();
|
|
20599
|
-
});
|
|
20600
|
-
}));
|
|
20593
|
+
await vue.nextTick();
|
|
20594
|
+
snapshot.value = await snapDOM(current.value, {
|
|
20595
|
+
fast: false,
|
|
20596
|
+
// dom太大时会卡死一会儿
|
|
20597
|
+
...VcInstance.options.Snapshot?.options,
|
|
20598
|
+
...props2.options
|
|
20599
|
+
});
|
|
20600
|
+
return snapshot.value;
|
|
20601
|
+
};
|
|
20602
|
+
const onLoad = () => {
|
|
20603
|
+
return props2.showLoading && Message.loading("正在生成...");
|
|
20604
|
+
};
|
|
20605
|
+
const onLoaded = (ctx) => {
|
|
20606
|
+
ctx?.destroy?.();
|
|
20601
20607
|
};
|
|
20602
20608
|
const toDataURL = async () => {
|
|
20609
|
+
const loadContext = onLoad();
|
|
20610
|
+
try {
|
|
20611
|
+
await refresh();
|
|
20612
|
+
return snapshot.value.toRaw();
|
|
20613
|
+
} finally {
|
|
20614
|
+
onLoaded(loadContext);
|
|
20615
|
+
}
|
|
20616
|
+
};
|
|
20617
|
+
const downloadByDefault = async (options) => {
|
|
20603
20618
|
await refresh();
|
|
20604
|
-
return
|
|
20619
|
+
return snapshot.value.download(options);
|
|
20605
20620
|
};
|
|
20606
20621
|
const download = async (options) => {
|
|
20607
|
-
|
|
20608
|
-
const
|
|
20609
|
-
const
|
|
20610
|
-
|
|
20611
|
-
|
|
20612
|
-
|
|
20613
|
-
}
|
|
20622
|
+
const loadContext = onLoad();
|
|
20623
|
+
const downloadByUser = props2.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
20624
|
+
const skip = downloadByUser(instance, options);
|
|
20625
|
+
const done = async (v) => {
|
|
20626
|
+
try {
|
|
20627
|
+
v || await downloadByDefault(options);
|
|
20628
|
+
} finally {
|
|
20629
|
+
onLoaded(loadContext);
|
|
20630
|
+
}
|
|
20631
|
+
};
|
|
20632
|
+
if (skip && skip.then) {
|
|
20633
|
+
let skip$ = false;
|
|
20634
|
+
skip.then((v) => {
|
|
20635
|
+
skip$ = typeof v === "undefined" ? true : !!v;
|
|
20636
|
+
return v;
|
|
20637
|
+
}).finally(() => done(skip$));
|
|
20614
20638
|
return;
|
|
20615
20639
|
}
|
|
20616
|
-
|
|
20640
|
+
done(skip);
|
|
20617
20641
|
};
|
|
20618
20642
|
expose({
|
|
20619
|
-
|
|
20643
|
+
snapshot,
|
|
20620
20644
|
refresh,
|
|
20621
20645
|
toDataURL,
|
|
20622
20646
|
download
|
|
20623
20647
|
});
|
|
20624
20648
|
vue.onMounted(async () => {
|
|
20625
20649
|
try {
|
|
20626
|
-
|
|
20650
|
+
snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
|
|
20627
20651
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
20628
|
-
|
|
20652
|
+
!props2.lazy && await refresh();
|
|
20629
20653
|
emit("ready", {
|
|
20630
20654
|
instance,
|
|
20631
20655
|
dependencies: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deot/vc",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.55",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@deot/vc-components": "^1.0.
|
|
23
|
-
"@deot/vc-hooks": "^1.0.
|
|
24
|
-
"@deot/vc-shared": "^1.0.
|
|
22
|
+
"@deot/vc-components": "^1.0.55",
|
|
23
|
+
"@deot/vc-hooks": "^1.0.55",
|
|
24
|
+
"@deot/vc-shared": "^1.0.55"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
27
|
"vue": "*"
|