@pronto-tools-and-more/custom-js-functions 10.48.0 → 10.50.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/main.js CHANGED
@@ -480,7 +480,8 @@
480
480
  // src/parts/Globals/Globals.ts
481
481
  var Globals_exports = {};
482
482
  __export(Globals_exports, {
483
- fixRender: () => fixRender
483
+ fixRender: () => fixRender,
484
+ nativeShare: () => nativeShare
484
485
  });
485
486
 
486
487
  // src/parts/FixRender/FixRender.ts
@@ -508,6 +509,73 @@
508
509
  root.replaceWith(realNodes[0]);
509
510
  };
510
511
 
512
+ // node_modules/@lvce-editor/verror/dist/index.js
513
+ var normalizeLine = (line) => {
514
+ if (line.startsWith("Error: ")) {
515
+ return line.slice("Error: ".length);
516
+ }
517
+ if (line.startsWith("VError: ")) {
518
+ return line.slice("VError: ".length);
519
+ }
520
+ return line;
521
+ };
522
+ var getCombinedMessage = (error, message) => {
523
+ const stringifiedError = normalizeLine(`${error}`);
524
+ if (message) {
525
+ return `${message}: ${stringifiedError}`;
526
+ }
527
+ return stringifiedError;
528
+ };
529
+ var NewLine = "\n";
530
+ var getNewLineIndex = (string, startIndex = void 0) => {
531
+ return string.indexOf(NewLine, startIndex);
532
+ };
533
+ var mergeStacks = (parent, child) => {
534
+ if (!child) {
535
+ return parent;
536
+ }
537
+ const parentNewLineIndex = getNewLineIndex(parent);
538
+ const childNewLineIndex = getNewLineIndex(child);
539
+ if (childNewLineIndex === -1) {
540
+ return parent;
541
+ }
542
+ const parentFirstLine = parent.slice(0, parentNewLineIndex);
543
+ const childRest = child.slice(childNewLineIndex);
544
+ const childFirstLine = normalizeLine(child.slice(0, childNewLineIndex));
545
+ if (parentFirstLine.includes(childFirstLine)) {
546
+ return parentFirstLine + childRest;
547
+ }
548
+ return child;
549
+ };
550
+ var VError = class extends Error {
551
+ constructor(error, message) {
552
+ const combinedMessage = getCombinedMessage(error, message);
553
+ super(combinedMessage);
554
+ this.name = "VError";
555
+ if (error instanceof Error) {
556
+ this.stack = mergeStacks(this.stack, error.stack);
557
+ }
558
+ if (error.codeFrame) {
559
+ this.codeFrame = error.codeFrame;
560
+ }
561
+ if (error.code) {
562
+ this.code = error.code;
563
+ }
564
+ }
565
+ };
566
+
567
+ // src/parts/NativeShare/NativeShare.ts
568
+ var nativeShare = async (data) => {
569
+ try {
570
+ await navigator.share(data);
571
+ } catch (error) {
572
+ if (error && error.name === "AbortError") {
573
+ return;
574
+ }
575
+ throw new VError(error, `Failed to share`);
576
+ }
577
+ };
578
+
511
579
  // src/parts/Main/Main.ts
512
580
  var main = () => {
513
581
  const ref = window.$functions || {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pronto-tools-and-more/custom-js-functions",
3
- "version": "10.48.0",
3
+ "version": "10.50.0",
4
4
  "description": "",
5
5
  "main": "dist/main.js",
6
6
  "type": "module",
@@ -23,5 +23,8 @@
23
23
  },
24
24
  "engines": {
25
25
  "node": ">=22"
26
+ },
27
+ "dependencies": {
28
+ "@lvce-editor/verror": "^1.6.0"
26
29
  }
27
30
  }
@@ -1 +1,2 @@
1
1
  export * from "../FixRender/FixRender.ts";
2
+ export * from "../NativeShare/NativeShare.ts";
@@ -0,0 +1,13 @@
1
+ import { VError } from "@lvce-editor/verror";
2
+
3
+ export const nativeShare = async (data: any): Promise<void> => {
4
+ try {
5
+ await navigator.share(data);
6
+ } catch (error) {
7
+ if (error && error.name === "AbortError") {
8
+ // ignore
9
+ return;
10
+ }
11
+ throw new VError(error, `Failed to share`);
12
+ }
13
+ };