@deot/vc-components 1.0.54 → 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.cjs CHANGED
@@ -75,6 +75,7 @@ const defaults$2 = {
75
75
  line: nil
76
76
  },
77
77
  Snapshot: {
78
+ options: nil,
78
79
  source: nil,
79
80
  download: nil
80
81
  }
@@ -12132,6 +12133,14 @@ const props$H = {
12132
12133
  },
12133
12134
  source: Function,
12134
12135
  download: Function,
12136
+ lazy: {
12137
+ type: Boolean,
12138
+ default: true
12139
+ },
12140
+ showLoading: {
12141
+ type: Boolean,
12142
+ default: true
12143
+ },
12135
12144
  // 传递给snap-dom的配置项
12136
12145
  options: {
12137
12146
  type: Object,
@@ -12154,34 +12163,59 @@ const Snapshot = /* @__PURE__ */ vue.defineComponent({
12154
12163
  let snapDOM;
12155
12164
  const instance = vue.getCurrentInstance();
12156
12165
  const current = vue.ref();
12157
- const snapdom = vue.ref();
12166
+ const snapshot = vue.ref();
12158
12167
  const refresh = async () => {
12159
12168
  await vue.nextTick();
12160
- snapdom.value = await snapDOM(current.value, props.options);
12161
- return snapdom.value;
12169
+ snapshot.value = await snapDOM(current.value, {
12170
+ fast: false,
12171
+ // dom太大时会卡死一会儿
12172
+ ...VcInstance.options.Snapshot?.options,
12173
+ ...props.options
12174
+ });
12175
+ return snapshot.value;
12176
+ };
12177
+ const onLoad = () => {
12178
+ return props.showLoading && Message.loading('正在生成...');
12179
+ };
12180
+ const onLoaded = ctx => {
12181
+ ctx?.destroy?.();
12162
12182
  };
12163
12183
  const toDataURL = async () => {
12184
+ const loadContext = onLoad();
12185
+ try {
12186
+ await refresh();
12187
+ return snapshot.value.toRaw();
12188
+ } finally {
12189
+ onLoaded(loadContext);
12190
+ }
12191
+ };
12192
+ const downloadByDefault = async options => {
12164
12193
  await refresh();
12165
- return snapdom.value.toRaw();
12194
+ return snapshot.value.download(options);
12166
12195
  };
12167
12196
  const download = async options => {
12168
- await refresh();
12169
- const _download = props.download || VcInstance.options.Snapshot?.download || (() => false);
12170
- const skip = _download(instance, options);
12197
+ const loadContext = onLoad();
12198
+ const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
12199
+ const skip = downloadByUser(instance, options);
12200
+ const done = async v => {
12201
+ try {
12202
+ v || (await downloadByDefault(options));
12203
+ } finally {
12204
+ onLoaded(loadContext);
12205
+ }
12206
+ };
12171
12207
  if (skip && skip.then) {
12172
12208
  let skip$ = false;
12173
12209
  skip.then(v => {
12174
12210
  skip$ = typeof v === 'undefined' ? true : !!v;
12175
12211
  return v;
12176
- }).finally(() => {
12177
- skip$ || snapdom.value.download(options);
12178
- });
12212
+ }).finally(() => done(skip$));
12179
12213
  return;
12180
12214
  }
12181
- skip || snapdom.value.download(options);
12215
+ done(skip);
12182
12216
  };
12183
12217
  expose({
12184
- snapdom,
12218
+ snapshot,
12185
12219
  refresh,
12186
12220
  toDataURL,
12187
12221
  download
@@ -12190,7 +12224,7 @@ const Snapshot = /* @__PURE__ */ vue.defineComponent({
12190
12224
  try {
12191
12225
  snapDOM = window.snapdom || (await import('@zumer/snapdom'));
12192
12226
  snapDOM = snapDOM.snapdom || snapDOM;
12193
- await refresh();
12227
+ !props.lazy && (await refresh());
12194
12228
  emit('ready', {
12195
12229
  instance,
12196
12230
  dependencies: {
package/dist/index.d.ts CHANGED
@@ -8425,10 +8425,18 @@ default: string;
8425
8425
  crossOrigin: {
8426
8426
  type: StringConstructor;
8427
8427
  default: string;
8428
- validator: (v: any) => boolean;
8428
+ validator: (v: string) => boolean;
8429
8429
  };
8430
8430
  source: FunctionConstructor;
8431
8431
  download: FunctionConstructor;
8432
+ lazy: {
8433
+ type: BooleanConstructor;
8434
+ default: boolean;
8435
+ };
8436
+ showLoading: {
8437
+ type: BooleanConstructor;
8438
+ default: boolean;
8439
+ };
8432
8440
  options: {
8433
8441
  type: ObjectConstructor;
8434
8442
  default: () => {};
@@ -8441,10 +8449,18 @@ default: string;
8441
8449
  crossOrigin: {
8442
8450
  type: StringConstructor;
8443
8451
  default: string;
8444
- validator: (v: any) => boolean;
8452
+ validator: (v: string) => boolean;
8445
8453
  };
8446
8454
  source: FunctionConstructor;
8447
8455
  download: FunctionConstructor;
8456
+ lazy: {
8457
+ type: BooleanConstructor;
8458
+ default: boolean;
8459
+ };
8460
+ showLoading: {
8461
+ type: BooleanConstructor;
8462
+ default: boolean;
8463
+ };
8448
8464
  options: {
8449
8465
  type: ObjectConstructor;
8450
8466
  default: () => {};
@@ -8454,7 +8470,9 @@ onReady?: ((...args: any[]) => any) | undefined;
8454
8470
  }>, {
8455
8471
  tag: string;
8456
8472
  options: Record<string, any>;
8473
+ showLoading: boolean;
8457
8474
  crossOrigin: string;
8475
+ lazy: boolean;
8458
8476
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
8459
8477
 
8460
8478
  export declare const MSortList: DefineComponent<ExtractPropTypes< {
@@ -13308,10 +13326,18 @@ default: string;
13308
13326
  crossOrigin: {
13309
13327
  type: StringConstructor;
13310
13328
  default: string;
13311
- validator: (v: any) => boolean;
13329
+ validator: (v: string) => boolean;
13312
13330
  };
13313
13331
  source: FunctionConstructor;
13314
13332
  download: FunctionConstructor;
13333
+ lazy: {
13334
+ type: BooleanConstructor;
13335
+ default: boolean;
13336
+ };
13337
+ showLoading: {
13338
+ type: BooleanConstructor;
13339
+ default: boolean;
13340
+ };
13315
13341
  options: {
13316
13342
  type: ObjectConstructor;
13317
13343
  default: () => {};
@@ -13324,10 +13350,18 @@ default: string;
13324
13350
  crossOrigin: {
13325
13351
  type: StringConstructor;
13326
13352
  default: string;
13327
- validator: (v: any) => boolean;
13353
+ validator: (v: string) => boolean;
13328
13354
  };
13329
13355
  source: FunctionConstructor;
13330
13356
  download: FunctionConstructor;
13357
+ lazy: {
13358
+ type: BooleanConstructor;
13359
+ default: boolean;
13360
+ };
13361
+ showLoading: {
13362
+ type: BooleanConstructor;
13363
+ default: boolean;
13364
+ };
13331
13365
  options: {
13332
13366
  type: ObjectConstructor;
13333
13367
  default: () => {};
@@ -13337,7 +13371,9 @@ onReady?: ((...args: any[]) => any) | undefined;
13337
13371
  }>, {
13338
13372
  tag: string;
13339
13373
  options: Record<string, any>;
13374
+ showLoading: boolean;
13340
13375
  crossOrigin: string;
13376
+ lazy: boolean;
13341
13377
  }, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
13342
13378
 
13343
13379
  export declare const SortList: DefineComponent<ExtractPropTypes< {
@@ -37,6 +37,7 @@ var VcComponents = (function (exports, vue) {
37
37
  line: nil
38
38
  },
39
39
  Snapshot: {
40
+ options: nil,
40
41
  source: nil,
41
42
  download: nil
42
43
  }
@@ -20675,6 +20676,14 @@ var VcComponents = (function (exports, vue) {
20675
20676
  },
20676
20677
  source: Function,
20677
20678
  download: Function,
20679
+ lazy: {
20680
+ type: Boolean,
20681
+ default: true
20682
+ },
20683
+ showLoading: {
20684
+ type: Boolean,
20685
+ default: true
20686
+ },
20678
20687
  // 传递给snap-dom的配置项
20679
20688
  options: {
20680
20689
  type: Object,
@@ -20697,34 +20706,59 @@ var VcComponents = (function (exports, vue) {
20697
20706
  let snapDOM;
20698
20707
  const instance = vue.getCurrentInstance();
20699
20708
  const current = vue.ref();
20700
- const snapdom = vue.ref();
20709
+ const snapshot = vue.ref();
20701
20710
  const refresh = async () => {
20702
20711
  await vue.nextTick();
20703
- snapdom.value = await snapDOM(current.value, props.options);
20704
- return snapdom.value;
20712
+ snapshot.value = await snapDOM(current.value, {
20713
+ fast: false,
20714
+ // dom太大时会卡死一会儿
20715
+ ...VcInstance.options.Snapshot?.options,
20716
+ ...props.options
20717
+ });
20718
+ return snapshot.value;
20719
+ };
20720
+ const onLoad = () => {
20721
+ return props.showLoading && Message.loading('正在生成...');
20722
+ };
20723
+ const onLoaded = ctx => {
20724
+ ctx?.destroy?.();
20705
20725
  };
20706
20726
  const toDataURL = async () => {
20727
+ const loadContext = onLoad();
20728
+ try {
20729
+ await refresh();
20730
+ return snapshot.value.toRaw();
20731
+ } finally {
20732
+ onLoaded(loadContext);
20733
+ }
20734
+ };
20735
+ const downloadByDefault = async options => {
20707
20736
  await refresh();
20708
- return snapdom.value.toRaw();
20737
+ return snapshot.value.download(options);
20709
20738
  };
20710
20739
  const download = async options => {
20711
- await refresh();
20712
- const _download = props.download || VcInstance.options.Snapshot?.download || (() => false);
20713
- const skip = _download(instance, options);
20740
+ const loadContext = onLoad();
20741
+ const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
20742
+ const skip = downloadByUser(instance, options);
20743
+ const done = async v => {
20744
+ try {
20745
+ v || (await downloadByDefault(options));
20746
+ } finally {
20747
+ onLoaded(loadContext);
20748
+ }
20749
+ };
20714
20750
  if (skip && skip.then) {
20715
20751
  let skip$ = false;
20716
20752
  skip.then(v => {
20717
20753
  skip$ = typeof v === 'undefined' ? true : !!v;
20718
20754
  return v;
20719
- }).finally(() => {
20720
- skip$ || snapdom.value.download(options);
20721
- });
20755
+ }).finally(() => done(skip$));
20722
20756
  return;
20723
20757
  }
20724
- skip || snapdom.value.download(options);
20758
+ done(skip);
20725
20759
  };
20726
20760
  expose({
20727
- snapdom,
20761
+ snapshot,
20728
20762
  refresh,
20729
20763
  toDataURL,
20730
20764
  download
@@ -20733,7 +20767,7 @@ var VcComponents = (function (exports, vue) {
20733
20767
  try {
20734
20768
  snapDOM = window.snapdom || (await Promise.resolve().then(() => snapdom$1));
20735
20769
  snapDOM = snapDOM.snapdom || snapDOM;
20736
- await refresh();
20770
+ !props.lazy && (await refresh());
20737
20771
  emit('ready', {
20738
20772
  instance,
20739
20773
  dependencies: {
package/dist/index.js CHANGED
@@ -53,6 +53,7 @@ const defaults$2 = {
53
53
  line: nil
54
54
  },
55
55
  Snapshot: {
56
+ options: nil,
56
57
  source: nil,
57
58
  download: nil
58
59
  }
@@ -12110,6 +12111,14 @@ const props$H = {
12110
12111
  },
12111
12112
  source: Function,
12112
12113
  download: Function,
12114
+ lazy: {
12115
+ type: Boolean,
12116
+ default: true
12117
+ },
12118
+ showLoading: {
12119
+ type: Boolean,
12120
+ default: true
12121
+ },
12113
12122
  // 传递给snap-dom的配置项
12114
12123
  options: {
12115
12124
  type: Object,
@@ -12132,34 +12141,59 @@ const Snapshot = /* @__PURE__ */ defineComponent({
12132
12141
  let snapDOM;
12133
12142
  const instance = getCurrentInstance();
12134
12143
  const current = ref();
12135
- const snapdom = ref();
12144
+ const snapshot = ref();
12136
12145
  const refresh = async () => {
12137
12146
  await nextTick();
12138
- snapdom.value = await snapDOM(current.value, props.options);
12139
- return snapdom.value;
12147
+ snapshot.value = await snapDOM(current.value, {
12148
+ fast: false,
12149
+ // dom太大时会卡死一会儿
12150
+ ...VcInstance.options.Snapshot?.options,
12151
+ ...props.options
12152
+ });
12153
+ return snapshot.value;
12154
+ };
12155
+ const onLoad = () => {
12156
+ return props.showLoading && Message.loading('正在生成...');
12157
+ };
12158
+ const onLoaded = ctx => {
12159
+ ctx?.destroy?.();
12140
12160
  };
12141
12161
  const toDataURL = async () => {
12162
+ const loadContext = onLoad();
12163
+ try {
12164
+ await refresh();
12165
+ return snapshot.value.toRaw();
12166
+ } finally {
12167
+ onLoaded(loadContext);
12168
+ }
12169
+ };
12170
+ const downloadByDefault = async options => {
12142
12171
  await refresh();
12143
- return snapdom.value.toRaw();
12172
+ return snapshot.value.download(options);
12144
12173
  };
12145
12174
  const download = async options => {
12146
- await refresh();
12147
- const _download = props.download || VcInstance.options.Snapshot?.download || (() => false);
12148
- const skip = _download(instance, options);
12175
+ const loadContext = onLoad();
12176
+ const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
12177
+ const skip = downloadByUser(instance, options);
12178
+ const done = async v => {
12179
+ try {
12180
+ v || (await downloadByDefault(options));
12181
+ } finally {
12182
+ onLoaded(loadContext);
12183
+ }
12184
+ };
12149
12185
  if (skip && skip.then) {
12150
12186
  let skip$ = false;
12151
12187
  skip.then(v => {
12152
12188
  skip$ = typeof v === 'undefined' ? true : !!v;
12153
12189
  return v;
12154
- }).finally(() => {
12155
- skip$ || snapdom.value.download(options);
12156
- });
12190
+ }).finally(() => done(skip$));
12157
12191
  return;
12158
12192
  }
12159
- skip || snapdom.value.download(options);
12193
+ done(skip);
12160
12194
  };
12161
12195
  expose({
12162
- snapdom,
12196
+ snapshot,
12163
12197
  refresh,
12164
12198
  toDataURL,
12165
12199
  download
@@ -12168,7 +12202,7 @@ const Snapshot = /* @__PURE__ */ defineComponent({
12168
12202
  try {
12169
12203
  snapDOM = window.snapdom || (await import('@zumer/snapdom'));
12170
12204
  snapDOM = snapDOM.snapdom || snapDOM;
12171
- await refresh();
12205
+ !props.lazy && (await refresh());
12172
12206
  emit('ready', {
12173
12207
  instance,
12174
12208
  dependencies: {
@@ -40,6 +40,7 @@
40
40
  line: nil
41
41
  },
42
42
  Snapshot: {
43
+ options: nil,
43
44
  source: nil,
44
45
  download: nil
45
46
  }
@@ -20678,6 +20679,14 @@
20678
20679
  },
20679
20680
  source: Function,
20680
20681
  download: Function,
20682
+ lazy: {
20683
+ type: Boolean,
20684
+ default: true
20685
+ },
20686
+ showLoading: {
20687
+ type: Boolean,
20688
+ default: true
20689
+ },
20681
20690
  // 传递给snap-dom的配置项
20682
20691
  options: {
20683
20692
  type: Object,
@@ -20700,34 +20709,59 @@
20700
20709
  let snapDOM;
20701
20710
  const instance = vue.getCurrentInstance();
20702
20711
  const current = vue.ref();
20703
- const snapdom = vue.ref();
20712
+ const snapshot = vue.ref();
20704
20713
  const refresh = async () => {
20705
20714
  await vue.nextTick();
20706
- snapdom.value = await snapDOM(current.value, props.options);
20707
- return snapdom.value;
20715
+ snapshot.value = await snapDOM(current.value, {
20716
+ fast: false,
20717
+ // dom太大时会卡死一会儿
20718
+ ...VcInstance.options.Snapshot?.options,
20719
+ ...props.options
20720
+ });
20721
+ return snapshot.value;
20722
+ };
20723
+ const onLoad = () => {
20724
+ return props.showLoading && Message.loading('正在生成...');
20725
+ };
20726
+ const onLoaded = ctx => {
20727
+ ctx?.destroy?.();
20708
20728
  };
20709
20729
  const toDataURL = async () => {
20730
+ const loadContext = onLoad();
20731
+ try {
20732
+ await refresh();
20733
+ return snapshot.value.toRaw();
20734
+ } finally {
20735
+ onLoaded(loadContext);
20736
+ }
20737
+ };
20738
+ const downloadByDefault = async options => {
20710
20739
  await refresh();
20711
- return snapdom.value.toRaw();
20740
+ return snapshot.value.download(options);
20712
20741
  };
20713
20742
  const download = async options => {
20714
- await refresh();
20715
- const _download = props.download || VcInstance.options.Snapshot?.download || (() => false);
20716
- const skip = _download(instance, options);
20743
+ const loadContext = onLoad();
20744
+ const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
20745
+ const skip = downloadByUser(instance, options);
20746
+ const done = async v => {
20747
+ try {
20748
+ v || (await downloadByDefault(options));
20749
+ } finally {
20750
+ onLoaded(loadContext);
20751
+ }
20752
+ };
20717
20753
  if (skip && skip.then) {
20718
20754
  let skip$ = false;
20719
20755
  skip.then(v => {
20720
20756
  skip$ = typeof v === 'undefined' ? true : !!v;
20721
20757
  return v;
20722
- }).finally(() => {
20723
- skip$ || snapdom.value.download(options);
20724
- });
20758
+ }).finally(() => done(skip$));
20725
20759
  return;
20726
20760
  }
20727
- skip || snapdom.value.download(options);
20761
+ done(skip);
20728
20762
  };
20729
20763
  expose({
20730
- snapdom,
20764
+ snapshot,
20731
20765
  refresh,
20732
20766
  toDataURL,
20733
20767
  download
@@ -20736,7 +20770,7 @@
20736
20770
  try {
20737
20771
  snapDOM = window.snapdom || (await Promise.resolve().then(() => snapdom$1));
20738
20772
  snapDOM = snapDOM.snapdom || snapDOM;
20739
- await refresh();
20773
+ !props.lazy && (await refresh());
20740
20774
  emit('ready', {
20741
20775
  instance,
20742
20776
  dependencies: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/vc-components",
3
- "version": "1.0.54",
3
+ "version": "1.0.55",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",