@deot/vc 1.0.53 → 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.
@@ -19317,14 +19317,18 @@ var Vc = (function (exports, vue) {
19317
19317
  }
19318
19318
  let { enhancer } = VcInstance.options.Upload || {};
19319
19319
  enhancer = props2.enhancer || enhancer || (() => false);
19320
- const allow = enhancer(instance);
19321
- if (allow && allow.then) {
19322
- allow.catch(() => {
19323
- 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?.();
19324
19328
  });
19325
19329
  return;
19326
19330
  }
19327
- allow || el2.click();
19331
+ skip || el2.click();
19328
19332
  };
19329
19333
  const handleChange = (e) => {
19330
19334
  uploadFiles(e.target.files);
@@ -20569,32 +20573,14 @@ var Vc = (function (exports, vue) {
20569
20573
  slots,
20570
20574
  expose
20571
20575
  }) {
20576
+ let snapDOM;
20572
20577
  const instance = vue.getCurrentInstance();
20573
20578
  const current = vue.ref();
20574
20579
  const snapdom = vue.ref();
20575
20580
  const refresh = async () => {
20576
- if (!props2.crossOrigin) return;
20577
- const transformSource = props2.source || VcInstance.options.Snapshot?.source || ((v) => v);
20578
- return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20579
- return new Promise((resolve) => {
20580
- (async () => {
20581
- let url;
20582
- try {
20583
- url = await transformSource(node.src, "image");
20584
- } catch (e) {
20585
- console.error(e);
20586
- }
20587
- const image = new Image();
20588
- image.crossOrigin = props2.crossOrigin;
20589
- image.src = `${url}?=${(/* @__PURE__ */ new Date()).getTime()}`;
20590
- image.onload = () => {
20591
- node.src = image.src;
20592
- resolve(1);
20593
- };
20594
- image.onerror = () => resolve(0);
20595
- })();
20596
- });
20597
- }));
20581
+ await vue.nextTick();
20582
+ snapdom.value = await snapDOM(current.value, props2.options);
20583
+ return snapdom.value;
20598
20584
  };
20599
20585
  const toDataURL = async () => {
20600
20586
  await refresh();
@@ -20603,14 +20589,18 @@ var Vc = (function (exports, vue) {
20603
20589
  const download = async (options) => {
20604
20590
  await refresh();
20605
20591
  const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20606
- const allow = _download(instance, options);
20607
- if (allow && allow.then) {
20608
- allow.catch(() => {
20609
- snapdom.value.download(options);
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);
20610
20600
  });
20611
20601
  return;
20612
20602
  }
20613
- allow || snapdom.value.download(options);
20603
+ skip || snapdom.value.download(options);
20614
20604
  };
20615
20605
  expose({
20616
20606
  snapdom,
@@ -20620,9 +20610,9 @@ var Vc = (function (exports, vue) {
20620
20610
  });
20621
20611
  vue.onMounted(async () => {
20622
20612
  try {
20623
- let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20613
+ snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20624
20614
  snapDOM = snapDOM.snapdom || snapDOM;
20625
- snapdom.value = await snapDOM(current.value, props2.options);
20615
+ await refresh();
20626
20616
  emit("ready", {
20627
20617
  instance,
20628
20618
  dependencies: {
@@ -19320,14 +19320,18 @@
19320
19320
  }
19321
19321
  let { enhancer } = VcInstance.options.Upload || {};
19322
19322
  enhancer = props2.enhancer || enhancer || (() => false);
19323
- const allow = enhancer(instance);
19324
- if (allow && allow.then) {
19325
- allow.catch(() => {
19326
- 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?.();
19327
19331
  });
19328
19332
  return;
19329
19333
  }
19330
- allow || el2.click();
19334
+ skip || el2.click();
19331
19335
  };
19332
19336
  const handleChange = (e) => {
19333
19337
  uploadFiles(e.target.files);
@@ -20572,32 +20576,14 @@
20572
20576
  slots,
20573
20577
  expose
20574
20578
  }) {
20579
+ let snapDOM;
20575
20580
  const instance = vue.getCurrentInstance();
20576
20581
  const current = vue.ref();
20577
20582
  const snapdom = vue.ref();
20578
20583
  const refresh = async () => {
20579
- if (!props2.crossOrigin) return;
20580
- const transformSource = props2.source || VcInstance.options.Snapshot?.source || ((v) => v);
20581
- return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20582
- return new Promise((resolve) => {
20583
- (async () => {
20584
- let url;
20585
- try {
20586
- url = await transformSource(node.src, "image");
20587
- } catch (e) {
20588
- console.error(e);
20589
- }
20590
- const image = new Image();
20591
- image.crossOrigin = props2.crossOrigin;
20592
- image.src = `${url}?=${(/* @__PURE__ */ new Date()).getTime()}`;
20593
- image.onload = () => {
20594
- node.src = image.src;
20595
- resolve(1);
20596
- };
20597
- image.onerror = () => resolve(0);
20598
- })();
20599
- });
20600
- }));
20584
+ await vue.nextTick();
20585
+ snapdom.value = await snapDOM(current.value, props2.options);
20586
+ return snapdom.value;
20601
20587
  };
20602
20588
  const toDataURL = async () => {
20603
20589
  await refresh();
@@ -20606,14 +20592,18 @@
20606
20592
  const download = async (options) => {
20607
20593
  await refresh();
20608
20594
  const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20609
- const allow = _download(instance, options);
20610
- if (allow && allow.then) {
20611
- allow.catch(() => {
20612
- snapdom.value.download(options);
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);
20613
20603
  });
20614
20604
  return;
20615
20605
  }
20616
- allow || snapdom.value.download(options);
20606
+ skip || snapdom.value.download(options);
20617
20607
  };
20618
20608
  expose({
20619
20609
  snapdom,
@@ -20623,9 +20613,9 @@
20623
20613
  });
20624
20614
  vue.onMounted(async () => {
20625
20615
  try {
20626
- let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20616
+ snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20627
20617
  snapDOM = snapDOM.snapdom || snapDOM;
20628
- snapdom.value = await snapDOM(current.value, props2.options);
20618
+ await refresh();
20629
20619
  emit("ready", {
20630
20620
  instance,
20631
20621
  dependencies: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/vc",
3
- "version": "1.0.53",
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.53",
23
- "@deot/vc-hooks": "^1.0.53",
24
- "@deot/vc-shared": "^1.0.53"
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": "*"