@deot/vc 1.0.52 → 1.0.53

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 {
@@ -20547,7 +20551,8 @@ var Vc = (function (exports, vue) {
20547
20551
  default: "anonymous",
20548
20552
  validator: (v) => /^(|anonymous|use-credentials)$/.test(v)
20549
20553
  },
20550
- transformSource: Function,
20554
+ source: Function,
20555
+ download: Function,
20551
20556
  // 传递给snap-dom的配置项
20552
20557
  options: {
20553
20558
  type: Object,
@@ -20564,17 +20569,18 @@ var Vc = (function (exports, vue) {
20564
20569
  slots,
20565
20570
  expose
20566
20571
  }) {
20572
+ const instance = vue.getCurrentInstance();
20567
20573
  const current = vue.ref();
20568
- const instance = vue.ref();
20574
+ const snapdom = vue.ref();
20569
20575
  const refresh = async () => {
20570
20576
  if (!props2.crossOrigin) return;
20571
- const transformSource = props2.transformSource || VcInstance.options.Snapshot?.transformSource || ((v) => v);
20577
+ const transformSource = props2.source || VcInstance.options.Snapshot?.source || ((v) => v);
20572
20578
  return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20573
20579
  return new Promise((resolve) => {
20574
20580
  (async () => {
20575
20581
  let url;
20576
20582
  try {
20577
- url = await transformSource(node.src);
20583
+ url = await transformSource(node.src, "image");
20578
20584
  } catch (e) {
20579
20585
  console.error(e);
20580
20586
  }
@@ -20592,22 +20598,22 @@ var Vc = (function (exports, vue) {
20592
20598
  };
20593
20599
  const toDataURL = async () => {
20594
20600
  await refresh();
20595
- return instance.value.toRaw();
20601
+ return snapdom.value.toRaw();
20596
20602
  };
20597
20603
  const download = async (options) => {
20598
20604
  await refresh();
20599
- const _download = VcInstance.options.Snapshot?.download || (() => false);
20600
- const allow = _download(options);
20605
+ const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20606
+ const allow = _download(instance, options);
20601
20607
  if (allow && allow.then) {
20602
20608
  allow.catch(() => {
20603
- instance.value.download(options);
20609
+ snapdom.value.download(options);
20604
20610
  });
20605
20611
  return;
20606
20612
  }
20607
- allow || instance.value.download(options);
20613
+ allow || snapdom.value.download(options);
20608
20614
  };
20609
20615
  expose({
20610
- instance,
20616
+ snapdom,
20611
20617
  refresh,
20612
20618
  toDataURL,
20613
20619
  download
@@ -20616,9 +20622,9 @@ var Vc = (function (exports, vue) {
20616
20622
  try {
20617
20623
  let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20618
20624
  snapDOM = snapDOM.snapdom || snapDOM;
20619
- instance.value = await snapDOM(current.value, props2.options);
20625
+ snapdom.value = await snapDOM(current.value, props2.options);
20620
20626
  emit("ready", {
20621
- instance: instance.value,
20627
+ instance,
20622
20628
  dependencies: {
20623
20629
  snapDOM
20624
20630
  }
@@ -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 {
@@ -20550,7 +20554,8 @@
20550
20554
  default: "anonymous",
20551
20555
  validator: (v) => /^(|anonymous|use-credentials)$/.test(v)
20552
20556
  },
20553
- transformSource: Function,
20557
+ source: Function,
20558
+ download: Function,
20554
20559
  // 传递给snap-dom的配置项
20555
20560
  options: {
20556
20561
  type: Object,
@@ -20567,17 +20572,18 @@
20567
20572
  slots,
20568
20573
  expose
20569
20574
  }) {
20575
+ const instance = vue.getCurrentInstance();
20570
20576
  const current = vue.ref();
20571
- const instance = vue.ref();
20577
+ const snapdom = vue.ref();
20572
20578
  const refresh = async () => {
20573
20579
  if (!props2.crossOrigin) return;
20574
- const transformSource = props2.transformSource || VcInstance.options.Snapshot?.transformSource || ((v) => v);
20580
+ const transformSource = props2.source || VcInstance.options.Snapshot?.source || ((v) => v);
20575
20581
  return Promise.all(Array.from(current.value.querySelectorAll("img")).map((node) => {
20576
20582
  return new Promise((resolve) => {
20577
20583
  (async () => {
20578
20584
  let url;
20579
20585
  try {
20580
- url = await transformSource(node.src);
20586
+ url = await transformSource(node.src, "image");
20581
20587
  } catch (e) {
20582
20588
  console.error(e);
20583
20589
  }
@@ -20595,22 +20601,22 @@
20595
20601
  };
20596
20602
  const toDataURL = async () => {
20597
20603
  await refresh();
20598
- return instance.value.toRaw();
20604
+ return snapdom.value.toRaw();
20599
20605
  };
20600
20606
  const download = async (options) => {
20601
20607
  await refresh();
20602
- const _download = VcInstance.options.Snapshot?.download || (() => false);
20603
- const allow = _download(options);
20608
+ const _download = props2.download || VcInstance.options.Snapshot?.download || (() => false);
20609
+ const allow = _download(instance, options);
20604
20610
  if (allow && allow.then) {
20605
20611
  allow.catch(() => {
20606
- instance.value.download(options);
20612
+ snapdom.value.download(options);
20607
20613
  });
20608
20614
  return;
20609
20615
  }
20610
- allow || instance.value.download(options);
20616
+ allow || snapdom.value.download(options);
20611
20617
  };
20612
20618
  expose({
20613
- instance,
20619
+ snapdom,
20614
20620
  refresh,
20615
20621
  toDataURL,
20616
20622
  download
@@ -20619,9 +20625,9 @@
20619
20625
  try {
20620
20626
  let snapDOM = window.snapdom || await Promise.resolve().then(() => snapdom$1);
20621
20627
  snapDOM = snapDOM.snapdom || snapDOM;
20622
- instance.value = await snapDOM(current.value, props2.options);
20628
+ snapdom.value = await snapDOM(current.value, props2.options);
20623
20629
  emit("ready", {
20624
- instance: instance.value,
20630
+ instance,
20625
20631
  dependencies: {
20626
20632
  snapDOM
20627
20633
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deot/vc",
3
- "version": "1.0.52",
3
+ "version": "1.0.53",
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.53",
23
+ "@deot/vc-hooks": "^1.0.53",
24
+ "@deot/vc-shared": "^1.0.53"
25
25
  },
26
26
  "peerDependencies": {
27
27
  "vue": "*"