grab 0.1.0-beta.6 → 0.1.0-beta.8

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/cli.cjs CHANGED
@@ -1,3 +1,87 @@
1
1
  #!/usr/bin/env node
2
- 'use strict';var child_process=require('child_process');var e="0.1.0-beta.5",t=`grab@${e}`,p=()=>{try{let r=child_process.execSync("grab --version",{encoding:"utf-8"}).match(/(\d+\.\d+\.\d+)/);return r?r[1]:null}catch{return null}},m=()=>{let n=p();return n?/^\d+\.\d+\.\d+$/.test(e)?n!==e:false:true},u=()=>{let n=["pnpm","yarn","bun"];for(let r of n)try{return child_process.execSync(`${r} --version`,{stdio:"ignore"}),r}catch{continue}return "npm"},b=()=>{let n=u(),r={npm:"npm install -g",yarn:"yarn global add",pnpm:"pnpm add -g",bun:"bun add -g"},l={npm:"npm install -D",yarn:"yarn add -D",pnpm:"pnpm add -D",bun:"bun add -D"},c=r[n],i=l[n];console.log(`Installing ${t}\u2026`),child_process.execSync(`${c} ${t}`,{stdio:"inherit"});try{child_process.execSync(`${i} ${t}`,{stdio:"pipe"});}catch(d){let a=d.stderr?.toString().trim();console.error(a?`Failed to install ${t} locally:
3
- ${a}`:`Failed to install ${t} locally`);}};m()&&b();var o=child_process.spawnSync("grab",process.argv.slice(2),{stdio:"inherit",shell:process.platform==="win32"});o.error&&(console.error(`Failed to execute grab: ${o.error.message}`),process.exit(1));process.exit(o.status??0);
2
+ 'use strict';
3
+
4
+ var child_process = require('child_process');
5
+ var fs = require('fs');
6
+
7
+ var cliPackage = "@react-grab/cli" ;
8
+ var withLoader = (fn) => {
9
+ const frames = ["|", "/", "-", "\\"];
10
+ let i = 0;
11
+ process.stdout.write(frames[0]);
12
+ const interval = setInterval(() => {
13
+ i = (i + 1) % frames.length;
14
+ process.stdout.write(`\r${frames[i]}`);
15
+ }, 80);
16
+ return fn().finally(() => {
17
+ clearInterval(interval);
18
+ process.stdout.write("\r \r");
19
+ });
20
+ };
21
+ var getGlobalRoot = () => {
22
+ try {
23
+ return child_process.execSync("npm root -g", { encoding: "utf-8" }).trim();
24
+ } catch {
25
+ return null;
26
+ }
27
+ };
28
+ var getGlobalCliPath = (globalRoot) => {
29
+ if (!globalRoot) return null;
30
+ const cliPath = `${globalRoot}/@react-grab/cli/dist/cli.js`;
31
+ return fs.existsSync(cliPath) ? cliPath : null;
32
+ };
33
+ var getInstalledVersion = (globalRoot) => {
34
+ if (!globalRoot) return null;
35
+ const pkgPath = `${globalRoot}/@react-grab/cli/package.json`;
36
+ if (!fs.existsSync(pkgPath)) return null;
37
+ try {
38
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
39
+ return pkg.version;
40
+ } catch {
41
+ return null;
42
+ }
43
+ };
44
+ var installCli = () => {
45
+ return new Promise((resolve, reject) => {
46
+ const child = child_process.spawn("npm", ["install", "-g", cliPackage], {
47
+ stdio: "pipe"
48
+ });
49
+ child.on(
50
+ "close",
51
+ (code) => code === 0 ? resolve() : reject(new Error("Install failed"))
52
+ );
53
+ child.on("error", (err) => reject(err));
54
+ });
55
+ };
56
+ var main = async () => {
57
+ const globalRoot = getGlobalRoot();
58
+ let cliPath = getGlobalCliPath(globalRoot);
59
+ if (!cliPath) {
60
+ try {
61
+ await withLoader(installCli);
62
+ } catch {
63
+ console.error("Setup failed. Please try again.");
64
+ process.exit(1);
65
+ }
66
+ cliPath = getGlobalCliPath(getGlobalRoot());
67
+ } else {
68
+ getInstalledVersion(globalRoot);
69
+ }
70
+ if (!cliPath) {
71
+ console.error("Setup failed. Please try again.");
72
+ process.exit(1);
73
+ }
74
+ const result = child_process.spawnSync(
75
+ process.execPath,
76
+ [cliPath, ...process.argv.slice(2)],
77
+ {
78
+ stdio: "inherit"
79
+ }
80
+ );
81
+ if (result.error) {
82
+ console.error("Setup failed. Please try again.");
83
+ process.exit(1);
84
+ }
85
+ process.exit(result.status ?? 0);
86
+ };
87
+ void main();
@@ -1 +1 @@
1
- 'use strict';var chunk3DQ3Y6WE_cjs=require('../chunk-3DQ3Y6WE.cjs');Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.j}});Object.defineProperty(exports,"copyContent",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.e}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.b}});
1
+ 'use strict';var chunkJA5IN6QI_cjs=require('../chunk-JA5IN6QI.cjs');Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.j}});Object.defineProperty(exports,"copyContent",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.e}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.b}});
@@ -1 +1 @@
1
- export{j as DEFAULT_THEME,e as copyContent,d as formatElementInfo,f as generateSnippet,c as getStack,k as init,b as isInstrumentationActive}from'../chunk-626KVKD4.js';
1
+ export{j as DEFAULT_THEME,e as copyContent,d as formatElementInfo,f as generateSnippet,c as getStack,k as init,b as isInstrumentationActive}from'../chunk-NK2BNSLR.js';
package/dist/index.cjs CHANGED
@@ -1,4 +1,4 @@
1
- 'use strict';var chunk3DQ3Y6WE_cjs=require('./chunk-3DQ3Y6WE.cjs');/**
1
+ 'use strict';var chunkJA5IN6QI_cjs=require('./chunk-JA5IN6QI.cjs');/**
2
2
  * @license MIT
3
3
  *
4
4
  * Copyright (c) 2025 Aiden Bai
@@ -6,4 +6,4 @@
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
- var e=null,c=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,f=t=>{e=t,typeof window<"u"&&(t?window.__REACT_GRAB__=t:delete window.__REACT_GRAB__);};typeof window<"u"&&(window.__REACT_GRAB__?e=window.__REACT_GRAB__:(e=chunk3DQ3Y6WE_cjs.k(),window.__REACT_GRAB__=e),window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e})));Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.j}});Object.defineProperty(exports,"captureElementScreenshot",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.h}});Object.defineProperty(exports,"combineBounds",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.g}});Object.defineProperty(exports,"copyImageToClipboard",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.i}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.b}});Object.defineProperty(exports,"isScreenshotSupported",{enumerable:true,get:function(){return chunk3DQ3Y6WE_cjs.a}});exports.getGlobalApi=c;exports.setGlobalApi=f;
9
+ var e=null,c=()=>typeof window>"u"?e:window.__REACT_GRAB__??e??null,f=t=>{e=t,typeof window<"u"&&(t?window.__REACT_GRAB__=t:delete window.__REACT_GRAB__);};typeof window<"u"&&(window.__REACT_GRAB__?e=window.__REACT_GRAB__:(e=chunkJA5IN6QI_cjs.k(),window.__REACT_GRAB__=e),window.dispatchEvent(new CustomEvent("react-grab:init",{detail:e})));Object.defineProperty(exports,"DEFAULT_THEME",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.j}});Object.defineProperty(exports,"captureElementScreenshot",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.h}});Object.defineProperty(exports,"combineBounds",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.g}});Object.defineProperty(exports,"copyImageToClipboard",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.i}});Object.defineProperty(exports,"formatElementInfo",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.d}});Object.defineProperty(exports,"generateSnippet",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.f}});Object.defineProperty(exports,"getStack",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.c}});Object.defineProperty(exports,"init",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.k}});Object.defineProperty(exports,"isInstrumentationActive",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.b}});Object.defineProperty(exports,"isScreenshotSupported",{enumerable:true,get:function(){return chunkJA5IN6QI_cjs.a}});exports.getGlobalApi=c;exports.setGlobalApi=f;