@deot/vc 1.0.52 → 1.0.54

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 CHANGED
@@ -4112,7 +4112,8 @@ export declare const Components: {
4112
4112
  default: string;
4113
4113
  validator: (v: any) => boolean;
4114
4114
  };
4115
- transformSource: FunctionConstructor;
4115
+ source: FunctionConstructor;
4116
+ download: FunctionConstructor;
4116
4117
  options: {
4117
4118
  type: ObjectConstructor;
4118
4119
  default: () => {};
@@ -4127,7 +4128,8 @@ export declare const Components: {
4127
4128
  default: string;
4128
4129
  validator: (v: any) => boolean;
4129
4130
  };
4130
- transformSource: FunctionConstructor;
4131
+ source: FunctionConstructor;
4132
+ download: FunctionConstructor;
4131
4133
  options: {
4132
4134
  type: ObjectConstructor;
4133
4135
  default: () => {};
@@ -4149,7 +4151,8 @@ export declare const Components: {
4149
4151
  default: string;
4150
4152
  validator: (v: any) => boolean;
4151
4153
  };
4152
- transformSource: FunctionConstructor;
4154
+ source: FunctionConstructor;
4155
+ download: FunctionConstructor;
4153
4156
  options: {
4154
4157
  type: ObjectConstructor;
4155
4158
  default: () => {};
@@ -4164,7 +4167,8 @@ export declare const Components: {
4164
4167
  default: string;
4165
4168
  validator: (v: any) => boolean;
4166
4169
  };
4167
- transformSource: FunctionConstructor;
4170
+ source: FunctionConstructor;
4171
+ download: FunctionConstructor;
4168
4172
  options: {
4169
4173
  type: ObjectConstructor;
4170
4174
  default: () => {};
@@ -9102,6 +9102,10 @@ var Vc = (function (exports, vue) {
9102
9102
  },
9103
9103
  TableColumn: {
9104
9104
  line: nil
9105
+ },
9106
+ Snapshot: {
9107
+ source: nil,
9108
+ download: nil
9105
9109
  }
9106
9110
  };
9107
9111
  class Instance {
@@ -19313,14 +19317,18 @@ var Vc = (function (exports, vue) {
19313
19317
  }
19314
19318
  let { enhancer } = VcInstance.options.Upload || {};
19315
19319
  enhancer = props2.enhancer || enhancer || (() => false);
19316
- const allow = enhancer(instance);
19317
- if (allow && allow.then) {
19318
- allow.catch(() => {
19319
- el2.click?.();
19320
+ const skip = enhancer(instance);
19321
+ if (skip && skip.then) {
19322
+ let skip$ = false;
19323
+ skip.then((v) => {
19324
+ skip$ = typeof v === "undefined" ? true : !!v;
19325
+ return v;
19326
+ }).finally(() => {
19327
+ skip$ || el2.click?.();
19320
19328
  });
19321
19329
  return;
19322
19330
  }
19323
- allow || el2.click();
19331
+ skip || el2.click();
19324
19332
  };
19325
19333
  const handleChange = (e) => {
19326
19334
  uploadFiles(e.target.files);
@@ -20547,7 +20555,8 @@ var Vc = (function (exports, vue) {
20547
20555
  default: "anonymous",
20548
20556
  validator: (v) => /^(|anonymous|use-credentials)$/.test(v)
20549
20557
  },
20550
- transformSource: Function,
20558
+ source: Function,
20559
+ download: Function,
20551
20560
  // 传递给snap-dom的配置项
20552
20561
  options: {
20553
20562
  type: Object,
@@ -20564,61 +20573,48 @@ var Vc = (function (exports, vue) {
20564
20573
  slots,
20565
20574
  expose
20566
20575
  }) {
20576
+ let snapDOM;
20577
+ const instance = vue.getCurrentInstance();
20567
20578
  const current = vue.ref();
20568
- const instance = vue.ref();
20579
+ const snapdom = vue.ref();
20569
20580
  const refresh = async () => {
20570
- if (!props2.crossOrigin) return;
20571
- const transformSource = props2.transformSource || VcInstance.options.Snapshot?.transformSource || ((v) => v);
20572
- return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20573
- return new Promise((resolve) => {
20574
- (async () => {
20575
- let url;
20576
- try {
20577
- url = await transformSource(node.src);
20578
- } catch (e) {
20579
- console.error(e);
20580
- }
20581
- const image = new Image();
20582
- image.crossOrigin = props2.crossOrigin;
20583
- image.src = `${url}?=${(/* @__PURE__ */ new Date()).getTime()}`;
20584
- image.onload = () => {
20585
- node.src = image.src;
20586
- resolve(1);
20587
- };
20588
- image.onerror = () => resolve(0);
20589
- })();
20590
- });
20591
- }));
20581
+ await vue.nextTick();
20582
+ snapdom.value = await snapDOM(current.value, props2.options);
20583
+ return snapdom.value;
20592
20584
  };
20593
20585
  const toDataURL = async () => {
20594
20586
  await refresh();
20595
- return instance.value.toRaw();
20587
+ return snapdom.value.toRaw();
20596
20588
  };
20597
20589
  const download = async (options) => {
20598
20590
  await refresh();
20599
- const _download = VcInstance.options.Snapshot?.download || (() => false);
20600
- const allow = _download(options);
20601
- if (allow && allow.then) {
20602
- allow.catch(() => {
20603
- instance.value.download(options);
20591
+ const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20592
+ const skip = _download(instance, options);
20593
+ if (skip && skip.then) {
20594
+ let skip$ = false;
20595
+ skip.then((v) => {
20596
+ skip$ = typeof v === "undefined" ? true : !!v;
20597
+ return v;
20598
+ }).finally(() => {
20599
+ skip$ || snapdom.value.download(options);
20604
20600
  });
20605
20601
  return;
20606
20602
  }
20607
- allow || instance.value.download(options);
20603
+ skip || snapdom.value.download(options);
20608
20604
  };
20609
20605
  expose({
20610
- instance,
20606
+ snapdom,
20611
20607
  refresh,
20612
20608
  toDataURL,
20613
20609
  download
20614
20610
  });
20615
20611
  vue.onMounted(async () => {
20616
20612
  try {
20617
- let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20613
+ snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20618
20614
  snapDOM = snapDOM.snapdom || snapDOM;
20619
- instance.value = await snapDOM(current.value, props2.options);
20615
+ await refresh();
20620
20616
  emit("ready", {
20621
- instance: instance.value,
20617
+ instance,
20622
20618
  dependencies: {
20623
20619
  snapDOM
20624
20620
  }
@@ -9105,6 +9105,10 @@
9105
9105
  },
9106
9106
  TableColumn: {
9107
9107
  line: nil
9108
+ },
9109
+ Snapshot: {
9110
+ source: nil,
9111
+ download: nil
9108
9112
  }
9109
9113
  };
9110
9114
  class Instance {
@@ -19316,14 +19320,18 @@
19316
19320
  }
19317
19321
  let { enhancer } = VcInstance.options.Upload || {};
19318
19322
  enhancer = props2.enhancer || enhancer || (() => false);
19319
- const allow = enhancer(instance);
19320
- if (allow && allow.then) {
19321
- allow.catch(() => {
19322
- el2.click?.();
19323
+ const skip = enhancer(instance);
19324
+ if (skip && skip.then) {
19325
+ let skip$ = false;
19326
+ skip.then((v) => {
19327
+ skip$ = typeof v === "undefined" ? true : !!v;
19328
+ return v;
19329
+ }).finally(() => {
19330
+ skip$ || el2.click?.();
19323
19331
  });
19324
19332
  return;
19325
19333
  }
19326
- allow || el2.click();
19334
+ skip || el2.click();
19327
19335
  };
19328
19336
  const handleChange = (e) => {
19329
19337
  uploadFiles(e.target.files);
@@ -20550,7 +20558,8 @@
20550
20558
  default: "anonymous",
20551
20559
  validator: (v) => /^(|anonymous|use-credentials)$/.test(v)
20552
20560
  },
20553
- transformSource: Function,
20561
+ source: Function,
20562
+ download: Function,
20554
20563
  // 传递给snap-dom的配置项
20555
20564
  options: {
20556
20565
  type: Object,
@@ -20567,61 +20576,48 @@
20567
20576
  slots,
20568
20577
  expose
20569
20578
  }) {
20579
+ let snapDOM;
20580
+ const instance = vue.getCurrentInstance();
20570
20581
  const current = vue.ref();
20571
- const instance = vue.ref();
20582
+ const snapdom = vue.ref();
20572
20583
  const refresh = async () => {
20573
- if (!props2.crossOrigin) return;
20574
- const transformSource = props2.transformSource || VcInstance.options.Snapshot?.transformSource || ((v) => v);
20575
- return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20576
- return new Promise((resolve) => {
20577
- (async () => {
20578
- let url;
20579
- try {
20580
- url = await transformSource(node.src);
20581
- } catch (e) {
20582
- console.error(e);
20583
- }
20584
- const image = new Image();
20585
- image.crossOrigin = props2.crossOrigin;
20586
- image.src = `${url}?=${(/* @__PURE__ */ new Date()).getTime()}`;
20587
- image.onload = () => {
20588
- node.src = image.src;
20589
- resolve(1);
20590
- };
20591
- image.onerror = () => resolve(0);
20592
- })();
20593
- });
20594
- }));
20584
+ await vue.nextTick();
20585
+ snapdom.value = await snapDOM(current.value, props2.options);
20586
+ return snapdom.value;
20595
20587
  };
20596
20588
  const toDataURL = async () => {
20597
20589
  await refresh();
20598
- return instance.value.toRaw();
20590
+ return snapdom.value.toRaw();
20599
20591
  };
20600
20592
  const download = async (options) => {
20601
20593
  await refresh();
20602
- const _download = VcInstance.options.Snapshot?.download || (() => false);
20603
- const allow = _download(options);
20604
- if (allow && allow.then) {
20605
- allow.catch(() => {
20606
- instance.value.download(options);
20594
+ const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20595
+ const skip = _download(instance, options);
20596
+ if (skip && skip.then) {
20597
+ let skip$ = false;
20598
+ skip.then((v) => {
20599
+ skip$ = typeof v === "undefined" ? true : !!v;
20600
+ return v;
20601
+ }).finally(() => {
20602
+ skip$ || snapdom.value.download(options);
20607
20603
  });
20608
20604
  return;
20609
20605
  }
20610
- allow || instance.value.download(options);
20606
+ skip || snapdom.value.download(options);
20611
20607
  };
20612
20608
  expose({
20613
- instance,
20609
+ snapdom,
20614
20610
  refresh,
20615
20611
  toDataURL,
20616
20612
  download
20617
20613
  });
20618
20614
  vue.onMounted(async () => {
20619
20615
  try {
20620
- let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20616
+ snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20621
20617
  snapDOM = snapDOM.snapdom || snapDOM;
20622
- instance.value = await snapDOM(current.value, props2.options);
20618
+ await refresh();
20623
20619
  emit("ready", {
20624
- instance: instance.value,
20620
+ instance,
20625
20621
  dependencies: {
20626
20622
  snapDOM
20627
20623
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/vc",
3
- "version": "1.0.52",
3
+ "version": "1.0.54",
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.52",
23
- "@deot/vc-hooks": "^1.0.52",
24
- "@deot/vc-shared": "^1.0.52"
22
+ "@deot/vc-components": "^1.0.54",
23
+ "@deot/vc-hooks": "^1.0.54",
24
+ "@deot/vc-shared": "^1.0.54"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "vue": "*"