react-grab 0.0.15 → 0.0.16
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 +11 -1
- package/dist/index.global.js +63 -3339
- package/dist/plugins/vite.cjs +46 -0
- package/dist/plugins/vite.d.cts +14 -0
- package/dist/plugins/vite.d.ts +14 -0
- package/dist/plugins/vite.js +44 -0
- package/package.json +12 -2
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @license MIT
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2025 Aiden Bai
|
|
7
|
+
*
|
|
8
|
+
* This source code is licensed under the MIT license found in the
|
|
9
|
+
* LICENSE file in the root directory of this source tree.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
// src/plugins/vite.ts
|
|
13
|
+
var reactGrab = (options = {}) => {
|
|
14
|
+
const {
|
|
15
|
+
adapter,
|
|
16
|
+
enabled = true
|
|
17
|
+
} = options;
|
|
18
|
+
const dataAttrs = [];
|
|
19
|
+
if (enabled !== void 0) {
|
|
20
|
+
dataAttrs.push(`data-enabled="${enabled}"`);
|
|
21
|
+
}
|
|
22
|
+
if (adapter !== void 0) {
|
|
23
|
+
dataAttrs.push(`data-adapter="${adapter}"`);
|
|
24
|
+
}
|
|
25
|
+
const scriptTag = `<script
|
|
26
|
+
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
27
|
+
crossorigin="anonymous"
|
|
28
|
+
${dataAttrs.join("\n ")}
|
|
29
|
+
><\/script>`;
|
|
30
|
+
return {
|
|
31
|
+
apply: "serve",
|
|
32
|
+
name: "vite-plugin-react-grab",
|
|
33
|
+
transformIndexHtml: {
|
|
34
|
+
handler(html) {
|
|
35
|
+
return html.replace(
|
|
36
|
+
"<head>",
|
|
37
|
+
`<head>
|
|
38
|
+
${scriptTag}`
|
|
39
|
+
);
|
|
40
|
+
},
|
|
41
|
+
order: "pre"
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.reactGrab = reactGrab;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ReactGrabPluginOptions {
|
|
2
|
+
adapter?: "cursor";
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const reactGrab: (options?: ReactGrabPluginOptions) => {
|
|
6
|
+
apply: "serve";
|
|
7
|
+
name: string;
|
|
8
|
+
transformIndexHtml: {
|
|
9
|
+
handler(html: string): string;
|
|
10
|
+
order: "pre";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { type ReactGrabPluginOptions, reactGrab };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface ReactGrabPluginOptions {
|
|
2
|
+
adapter?: "cursor";
|
|
3
|
+
enabled?: boolean;
|
|
4
|
+
}
|
|
5
|
+
declare const reactGrab: (options?: ReactGrabPluginOptions) => {
|
|
6
|
+
apply: "serve";
|
|
7
|
+
name: string;
|
|
8
|
+
transformIndexHtml: {
|
|
9
|
+
handler(html: string): string;
|
|
10
|
+
order: "pre";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
export { type ReactGrabPluginOptions, reactGrab };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license MIT
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2025 Aiden Bai
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the MIT license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
// src/plugins/vite.ts
|
|
11
|
+
var reactGrab = (options = {}) => {
|
|
12
|
+
const {
|
|
13
|
+
adapter,
|
|
14
|
+
enabled = true
|
|
15
|
+
} = options;
|
|
16
|
+
const dataAttrs = [];
|
|
17
|
+
if (enabled !== void 0) {
|
|
18
|
+
dataAttrs.push(`data-enabled="${enabled}"`);
|
|
19
|
+
}
|
|
20
|
+
if (adapter !== void 0) {
|
|
21
|
+
dataAttrs.push(`data-adapter="${adapter}"`);
|
|
22
|
+
}
|
|
23
|
+
const scriptTag = `<script
|
|
24
|
+
src="//unpkg.com/react-grab/dist/index.global.js"
|
|
25
|
+
crossorigin="anonymous"
|
|
26
|
+
${dataAttrs.join("\n ")}
|
|
27
|
+
><\/script>`;
|
|
28
|
+
return {
|
|
29
|
+
apply: "serve",
|
|
30
|
+
name: "vite-plugin-react-grab",
|
|
31
|
+
transformIndexHtml: {
|
|
32
|
+
handler(html) {
|
|
33
|
+
return html.replace(
|
|
34
|
+
"<head>",
|
|
35
|
+
`<head>
|
|
36
|
+
${scriptTag}`
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
order: "pre"
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { reactGrab };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-grab",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.16",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"homepage": "https://github.com/aidenybai/react-grab#readme",
|
|
@@ -29,6 +29,16 @@
|
|
|
29
29
|
"default": "./dist/index.cjs"
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
|
+
"./plugins/vite": {
|
|
33
|
+
"import": {
|
|
34
|
+
"types": "./dist/plugins/vite.d.ts",
|
|
35
|
+
"default": "./dist/plugins/vite.js"
|
|
36
|
+
},
|
|
37
|
+
"require": {
|
|
38
|
+
"types": "./dist/plugins/vite.d.cts",
|
|
39
|
+
"default": "./dist/plugins/vite.cjs"
|
|
40
|
+
}
|
|
41
|
+
},
|
|
32
42
|
"./dist/*": "./dist/*.js",
|
|
33
43
|
"./dist/*.js": "./dist/*.js",
|
|
34
44
|
"./dist/*.cjs": "./dist/*.cjs",
|
|
@@ -60,7 +70,7 @@
|
|
|
60
70
|
"bippy": "^0.3.31"
|
|
61
71
|
},
|
|
62
72
|
"scripts": {
|
|
63
|
-
"build": "tsup",
|
|
73
|
+
"build": "NODE_ENV=production tsup",
|
|
64
74
|
"dev": "tsup --watch --ignore-watch dist",
|
|
65
75
|
"lint": "eslint src/**/*.ts",
|
|
66
76
|
"lint:fix": "eslint src/**/*.ts --fix",
|