grab 0.1.0-beta.7 → 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/{chunk-Z222RUIV.cjs → chunk-JA5IN6QI.cjs} +2 -2
- package/dist/{chunk-CGXPSYN4.js → chunk-NK2BNSLR.js} +2 -2
- package/dist/cli.cjs +86 -2
- package/dist/core/index.cjs +1 -1
- package/dist/core/index.js +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.global.js +2 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli.cjs
CHANGED
|
@@ -1,3 +1,87 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
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();
|
package/dist/core/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var
|
|
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}});
|
package/dist/core/index.js
CHANGED
|
@@ -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-
|
|
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
|
|
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=
|
|
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;
|