create-tampermonkey-typescript 1.2.4 → 1.2.5
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/LICENSE +7 -7
- package/README.md +70 -68
- package/dist/cli.js +55 -23
- package/package.json +5 -3
- package/templates/base/README.md +8 -0
- package/templates/base/src/script.ts +6 -6
- package/templates/base/userscript.txt +7 -7
- package/templates/base/vite.config.ts +73 -60
- package/templates/git/_gitignore +27 -27
- package/templates/github-workflows/.github/workflows/auto-tag.yml +41 -41
- package/templates/github-workflows/.github/workflows/release.yml +56 -56
- package/templates/react/src/global.d.ts +14 -14
- package/templates/react/src/util/react-util.ts +24 -24
- package/templates/tailwindcss/src/styles.css +15 -2
- package/templates/tsconfig.json +16 -16
- package/templates/prettier/_prettierrc +0 -7
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
Copyright (c) 2026 neth392
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
-
|
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
-
|
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2026 neth392
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,69 +1,71 @@
|
|
|
1
|
-
# create-tampermonkey-typescript
|
|
2
|
-
|
|
3
|
-
> A CLI scaffolding tool for creating minimal TamperMonkey userscript projects written in TypeScript.
|
|
4
|
-
|
|
5
|
-
Write your userscripts in TypeScript, organize code across multiple files, and let the toolchain handle the rest
|
|
6
|
-
— bundling, CSS injection, and userscript header generation are all taken care of. The result is a single `.user.js`
|
|
7
|
-
file ready to install in TamperMonkey.
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
## Features
|
|
12
|
-
|
|
13
|
-
📦 **TypeScript with multi-file support** — Structure your project however you like. All source files are bundled into
|
|
14
|
-
a single IIFE-format JavaScript file via [Vite](https://vite.dev/), fully compatible with TamperMonkey.
|
|
15
|
-
|
|
16
|
-
🏷️ **Automatic userscript header** — The `// ==UserScript==` block is generated from a template (`userscript.txt`) and
|
|
17
|
-
prepended to every build. Metadata fields such as name, version, and description are pulled directly from `package.json`,
|
|
18
|
-
keeping a single source of truth.
|
|
19
|
-
|
|
20
|
-
🔧 **Package manager agnostic** — Generated projects are standard Node.js projects. Use npm, yarn, or pnpm —
|
|
21
|
-
whichever you prefer.
|
|
22
|
-
|
|
23
|
-
🎨 **CSS injection** — Import `.css` files from TypeScript as you normally would. At build time, styles are extracted
|
|
24
|
-
and bundled into the output script, then injected into the page at runtime — no manual DOM manipulation required.
|
|
25
|
-
|
|
26
|
-
### Optional Features
|
|
27
|
-
|
|
28
|
-
⚛️ **React** — Scaffold the project with React pre-configured, including type declarations for
|
|
29
|
-
`unsafeWindow.React` and `unsafeWindow.ReactDOM`, and utility functions for accessing them at runtime.
|
|
30
|
-
|
|
31
|
-
🌊 **Tailwind CSS** — Adds Tailwind CSS v4 with the Vite plugin, so utility classes are compiled
|
|
32
|
-
at build time and only the CSS you actually use is injected into your userscript.
|
|
33
|
-
|
|
34
|
-
✨ **Prettier** — Sets up Prettier with a pre-configured `.prettierrc` and `.prettierignore` for consistent formatting.
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
```
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
1
|
+
# create-tampermonkey-typescript
|
|
2
|
+
|
|
3
|
+
> A CLI scaffolding tool for creating minimal TamperMonkey userscript projects written in TypeScript.
|
|
4
|
+
|
|
5
|
+
Write your userscripts in TypeScript, organize code across multiple files, and let the toolchain handle the rest
|
|
6
|
+
— bundling, CSS injection, and userscript header generation are all taken care of. The result is a single `.user.js`
|
|
7
|
+
file ready to install in TamperMonkey.
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
📦 **TypeScript with multi-file support** — Structure your project however you like. All source files are bundled into
|
|
14
|
+
a single IIFE-format JavaScript file via [Vite](https://vite.dev/), fully compatible with TamperMonkey.
|
|
15
|
+
|
|
16
|
+
🏷️ **Automatic userscript header** — The `// ==UserScript==` block is generated from a template (`userscript.txt`) and
|
|
17
|
+
prepended to every build. Metadata fields such as name, version, and description are pulled directly from `package.json`,
|
|
18
|
+
keeping a single source of truth.
|
|
19
|
+
|
|
20
|
+
🔧 **Package manager agnostic** — Generated projects are standard Node.js projects. Use npm, yarn, or pnpm —
|
|
21
|
+
whichever you prefer.
|
|
22
|
+
|
|
23
|
+
🎨 **CSS injection** — Import `.css` files from TypeScript as you normally would. At build time, styles are extracted
|
|
24
|
+
and bundled into the output script, then injected into the page at runtime — no manual DOM manipulation required.
|
|
25
|
+
|
|
26
|
+
### Optional Features
|
|
27
|
+
|
|
28
|
+
⚛️ **React** — Scaffold the project with React pre-configured, including type declarations for
|
|
29
|
+
`unsafeWindow.React` and `unsafeWindow.ReactDOM`, and utility functions for accessing them at runtime.
|
|
30
|
+
|
|
31
|
+
🌊 **Tailwind CSS** — Adds Tailwind CSS v4 with the Vite plugin, so utility classes are compiled
|
|
32
|
+
at build time and only the CSS you actually use is injected into your userscript.
|
|
33
|
+
|
|
34
|
+
✨ **Prettier** — Sets up Prettier with a pre-configured `.prettierrc` and `.prettierignore` for consistent formatting.
|
|
35
|
+
If Tailwind is enabled, there is also a prompt to enable the `prettier-plugin-classnames` and `prettier-plugin-tailwindcss`
|
|
36
|
+
plugins which organize class names and automatically wraps the `className` string if it exceeds print width.
|
|
37
|
+
|
|
38
|
+
🚀 **GitHub Actions workflows** — Includes CI/CD workflows that automatically create Git tags when
|
|
39
|
+
`package.json` version changes, and publish GitHub Releases with the built script attached.
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
### npm
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npx create-tampermonkey-typescript
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### yarn
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
yarn create tampermonkey-typescript
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### pnpm
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
pnpm create tampermonkey-typescript
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
The CLI will walk you through the project configuration — name, version, description, author — and let you
|
|
64
|
+
select optional features (React, Git). The output is your new project folder containing its own `README.md`
|
|
65
|
+
to get you started. You can preview that file here: [Generated Project README](templates/base/README.md)
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## License
|
|
70
|
+
|
|
69
71
|
[MIT](LICENSE)
|
package/dist/cli.js
CHANGED
|
@@ -5,10 +5,10 @@ import prompts from 'prompts';
|
|
|
5
5
|
import kleur from 'kleur';
|
|
6
6
|
import { execSync } from 'node:child_process';
|
|
7
7
|
import { fileURLToPath } from 'url';
|
|
8
|
-
const __FILENAME = fileURLToPath(import.meta.url);
|
|
9
|
-
const __DIRNAME = path.dirname(__FILENAME);
|
|
10
|
-
const TEMPLATES_DIR = path.join(__DIRNAME, '../templates');
|
|
11
|
-
const defaultDevDeps = [
|
|
8
|
+
export const __FILENAME = fileURLToPath(import.meta.url);
|
|
9
|
+
export const __DIRNAME = path.dirname(__FILENAME);
|
|
10
|
+
export const TEMPLATES_DIR = path.join(__DIRNAME, '../templates');
|
|
11
|
+
export const defaultDevDeps = [
|
|
12
12
|
'typescript', //
|
|
13
13
|
'vite',
|
|
14
14
|
'vite-plugin-banner',
|
|
@@ -16,8 +16,8 @@ const defaultDevDeps = [
|
|
|
16
16
|
'ts-node',
|
|
17
17
|
'@types/tampermonkey',
|
|
18
18
|
];
|
|
19
|
-
const defaultDeps = [];
|
|
20
|
-
const baseTsConfig = {
|
|
19
|
+
export const defaultDeps = [];
|
|
20
|
+
export const baseTsConfig = {
|
|
21
21
|
compilerOptions: {
|
|
22
22
|
types: ['vite/client', 'node', 'tampermonkey'],
|
|
23
23
|
target: 'ES2022',
|
|
@@ -37,7 +37,20 @@ const baseTsConfig = {
|
|
|
37
37
|
},
|
|
38
38
|
include: ['src'],
|
|
39
39
|
};
|
|
40
|
-
const
|
|
40
|
+
export const basePrettierRc = {
|
|
41
|
+
trailingComma: 'es5',
|
|
42
|
+
tabWidth: 2,
|
|
43
|
+
semi: false,
|
|
44
|
+
singleQuote: true,
|
|
45
|
+
printWidth: 120,
|
|
46
|
+
plugins: [],
|
|
47
|
+
};
|
|
48
|
+
export const prettierTailwindPlugins = [
|
|
49
|
+
'prettier-plugin-tailwindcss',
|
|
50
|
+
'prettier-plugin-classnames',
|
|
51
|
+
'prettier-plugin-merge',
|
|
52
|
+
];
|
|
53
|
+
export const availableFeatures = [
|
|
41
54
|
{
|
|
42
55
|
name: 'React',
|
|
43
56
|
description: 'Adds react support to the project',
|
|
@@ -55,9 +68,17 @@ const availableFeatures = [
|
|
|
55
68
|
name: 'Prettier',
|
|
56
69
|
description: 'Adds Prettier with default .prettierrc and .prettierignore files',
|
|
57
70
|
directory: path.join(TEMPLATES_DIR, 'prettier'),
|
|
71
|
+
devDependencies: ['prettier'],
|
|
58
72
|
hook: (params) => {
|
|
59
|
-
|
|
60
|
-
|
|
73
|
+
if (params.prettierTailwindPlugins) {
|
|
74
|
+
installDependencies(params, prettierTailwindPlugins, '-D');
|
|
75
|
+
}
|
|
76
|
+
const prettierRc = {
|
|
77
|
+
...basePrettierRc,
|
|
78
|
+
...(params.prettierTailwindPlugins ? { plugins: prettierTailwindPlugins } : {}),
|
|
79
|
+
};
|
|
80
|
+
writeObjectToJsonFile(prettierRc, '.prettierrc', params);
|
|
81
|
+
renameDotFiles(params, 'prettierignore');
|
|
61
82
|
},
|
|
62
83
|
},
|
|
63
84
|
{
|
|
@@ -75,7 +96,7 @@ const availableFeatures = [
|
|
|
75
96
|
directory: path.join(TEMPLATES_DIR, 'github-workflows'),
|
|
76
97
|
},
|
|
77
98
|
];
|
|
78
|
-
const availablePackageManagers = [
|
|
99
|
+
export const availablePackageManagers = [
|
|
79
100
|
{
|
|
80
101
|
name: 'npm',
|
|
81
102
|
exists: () => commandExists('npm --version'),
|
|
@@ -123,7 +144,7 @@ async function main() {
|
|
|
123
144
|
// Initialize package.json
|
|
124
145
|
logWithPrefix(`Creating ${kleur.yellow('package.json')}`);
|
|
125
146
|
const packageJson = createPackageJson(params);
|
|
126
|
-
|
|
147
|
+
writeObjectToJsonFile(packageJson, 'package.json', params);
|
|
127
148
|
// Initialize the lock file
|
|
128
149
|
logWithPrefix(`Initializing lock file`);
|
|
129
150
|
execInProjectDir(`${params.packageManager.installCmd}`, params);
|
|
@@ -134,13 +155,13 @@ async function main() {
|
|
|
134
155
|
if (devDeps.length > 0) {
|
|
135
156
|
logWithPrefix('Installing dev dependencies');
|
|
136
157
|
console.log(` ${kleur.dim(devDeps.join(', '))}`);
|
|
137
|
-
|
|
158
|
+
installDependencies(params, devDeps, '-D');
|
|
138
159
|
}
|
|
139
160
|
// Install dependencies
|
|
140
161
|
if (deps.length > 0) {
|
|
141
162
|
logWithPrefix('Installing dependencies');
|
|
142
163
|
console.log(` ${kleur.dim(deps.join(', '))}`);
|
|
143
|
-
|
|
164
|
+
installDependencies(params, deps, '-D');
|
|
144
165
|
}
|
|
145
166
|
// Handle tsconfig.json
|
|
146
167
|
const tsConfig = { ...baseTsConfig };
|
|
@@ -150,7 +171,7 @@ async function main() {
|
|
|
150
171
|
}
|
|
151
172
|
}
|
|
152
173
|
logWithPrefix(`Creating ${kleur.yellow('tsconfig.json')}`);
|
|
153
|
-
|
|
174
|
+
writeObjectToJsonFile(tsConfig, 'tsconfig.json', params);
|
|
154
175
|
// Copy files
|
|
155
176
|
logWithPrefix('Copying project files');
|
|
156
177
|
// Base files
|
|
@@ -179,7 +200,7 @@ async function main() {
|
|
|
179
200
|
function logWithPrefix(message) {
|
|
180
201
|
console.log(`${kleur.cyan('-')} ${kleur.white(message)}`);
|
|
181
202
|
}
|
|
182
|
-
function commandExists(cmd) {
|
|
203
|
+
export function commandExists(cmd) {
|
|
183
204
|
try {
|
|
184
205
|
execSync(cmd, { stdio: 'ignore' });
|
|
185
206
|
return true;
|
|
@@ -188,7 +209,7 @@ function commandExists(cmd) {
|
|
|
188
209
|
return false;
|
|
189
210
|
}
|
|
190
211
|
}
|
|
191
|
-
function checkCwdAccess() {
|
|
212
|
+
export function checkCwdAccess() {
|
|
192
213
|
try {
|
|
193
214
|
fs.accessSync(process.cwd(), fs.constants.W_OK | fs.constants.R_OK);
|
|
194
215
|
}
|
|
@@ -198,7 +219,7 @@ function checkCwdAccess() {
|
|
|
198
219
|
}
|
|
199
220
|
return true;
|
|
200
221
|
}
|
|
201
|
-
function findValidPackageManager() {
|
|
222
|
+
export function findValidPackageManager() {
|
|
202
223
|
if (!availablePackageManagers.find((pm) => pm.exists())) {
|
|
203
224
|
console.log(kleur.red('Could not find any valid package manager: '));
|
|
204
225
|
console.log(kleur.yellow(`(${availablePackageManagers.map((pm) => pm.name).join(', ')})`));
|
|
@@ -206,7 +227,7 @@ function findValidPackageManager() {
|
|
|
206
227
|
}
|
|
207
228
|
return true;
|
|
208
229
|
}
|
|
209
|
-
function validateProjectName(projectName) {
|
|
230
|
+
export function validateProjectName(projectName) {
|
|
210
231
|
if (!projectName || projectName.length === 0)
|
|
211
232
|
return 'Project name cannot be empty';
|
|
212
233
|
if (projectName.includes(' '))
|
|
@@ -260,11 +281,16 @@ async function promptForParams() {
|
|
|
260
281
|
message: 'Select features:',
|
|
261
282
|
choices: availableFeatures.map((f) => ({ title: f.name, value: f.name, description: f.description })),
|
|
262
283
|
},
|
|
284
|
+
{
|
|
285
|
+
type: (prev) => (prev.includes('Prettier') && prev.includes('TailwindCSS') ? 'confirm' : null),
|
|
286
|
+
name: 'prettierTailwindPlugins',
|
|
287
|
+
message: 'Install prettier-plugin-tailwindcss (auto-sorts classes) and prettier-plugin-classnames (wraps long class strings)?',
|
|
288
|
+
},
|
|
263
289
|
], {
|
|
264
290
|
onCancel: () => process.exit(0),
|
|
265
291
|
});
|
|
266
292
|
}
|
|
267
|
-
async function createProjectDirectory(path) {
|
|
293
|
+
export async function createProjectDirectory(path) {
|
|
268
294
|
try {
|
|
269
295
|
fs.mkdirSync(path, { recursive: true });
|
|
270
296
|
return true;
|
|
@@ -276,7 +302,7 @@ async function createProjectDirectory(path) {
|
|
|
276
302
|
return 'Unknown error.';
|
|
277
303
|
}
|
|
278
304
|
}
|
|
279
|
-
function createPackageJson(params) {
|
|
305
|
+
export function createPackageJson(params) {
|
|
280
306
|
return {
|
|
281
307
|
name: params.projectName,
|
|
282
308
|
description: params.description,
|
|
@@ -289,7 +315,7 @@ function createPackageJson(params) {
|
|
|
289
315
|
},
|
|
290
316
|
};
|
|
291
317
|
}
|
|
292
|
-
function
|
|
318
|
+
export function writeObjectToJsonFile(object, fileName, params) {
|
|
293
319
|
const filePath = path.join(params.projectPath, fileName);
|
|
294
320
|
const jsonString = JSON.stringify(object, null, 2);
|
|
295
321
|
fs.writeFileSync(filePath, jsonString);
|
|
@@ -297,9 +323,15 @@ function writeObjectToFile(object, fileName, params) {
|
|
|
297
323
|
function execInProjectDir(command, params) {
|
|
298
324
|
execSync(command, { stdio: 'inherit', cwd: params.projectPath });
|
|
299
325
|
}
|
|
300
|
-
function
|
|
326
|
+
function installDependencies(params, dependencies, flags = '') {
|
|
327
|
+
execInProjectDir(`${params.packageManager.addDependencyCmd} ${flags} ${dependencies.join(' ')}`, params);
|
|
328
|
+
}
|
|
329
|
+
export function renameDotFiles(params, ...fileNames) {
|
|
301
330
|
for (const fileName of fileNames) {
|
|
302
331
|
fs.renameSync(path.join(params.projectPath, `_${fileName}`), path.join(params.projectPath, `.${fileName}`));
|
|
303
332
|
}
|
|
304
333
|
}
|
|
305
|
-
|
|
334
|
+
const isDirectRun = process.argv[1]?.endsWith('cli.ts') || process.argv[1]?.endsWith('cli.js');
|
|
335
|
+
if (isDirectRun) {
|
|
336
|
+
main().then(() => { }, (e) => console.error(kleur.red(e.message || e)));
|
|
337
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-tampermonkey-typescript",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
4
4
|
"description": "CLI tool for generating a TamperMonkey script project written in typescript which is transpiled to JavaScript to be ran in the browser",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/neth392/create-tampermonkey-typescript",
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
26
|
"build": "tsc",
|
|
27
|
-
"
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest"
|
|
28
29
|
},
|
|
29
30
|
"devDependencies": {
|
|
30
31
|
"@tailwindcss/vite": "^4.1.18",
|
|
@@ -42,7 +43,8 @@
|
|
|
42
43
|
"typescript": "^5.8.3",
|
|
43
44
|
"vite": "^7.0.0",
|
|
44
45
|
"vite-plugin-banner": "^0.8.1",
|
|
45
|
-
"vite-plugin-css-injected-by-js": "^3.5.2"
|
|
46
|
+
"vite-plugin-css-injected-by-js": "^3.5.2",
|
|
47
|
+
"vitest": "^4.1.0"
|
|
46
48
|
},
|
|
47
49
|
"dependencies": {
|
|
48
50
|
"kleur": "^4.1.5",
|
package/templates/base/README.md
CHANGED
|
@@ -86,6 +86,10 @@ You should customize this file to include directives specific to your script, su
|
|
|
86
86
|
- All imported CSS is combined and injected as an inline `<style>` element at runtime
|
|
87
87
|
- The userscript header from `userscript.txt` is prepended
|
|
88
88
|
|
|
89
|
+
### Removing JSDoc/Comments in Final Script
|
|
90
|
+
The `vite.config.ts` file has a section that can be uncommented which will remove JSDoc and comments from the final
|
|
91
|
+
script, reducing the output file size.
|
|
92
|
+
|
|
89
93
|
---
|
|
90
94
|
|
|
91
95
|
## CSS
|
|
@@ -233,6 +237,10 @@ For more information on Tailwind, see the [Tailwind CSS docs](https://tailwindcs
|
|
|
233
237
|
|
|
234
238
|
Prettier is included with a pre-configured `.prettierrc` and `.prettierignore` file. Feel free to change them to best fit your programming style.
|
|
235
239
|
|
|
240
|
+
### Prettier & Tailwind
|
|
241
|
+
Optionally enabled are the `prettier-plugin-tailwindcss` and `prettier-plugin-classnames` plugins to assist in
|
|
242
|
+
formatting when using class names. `prettier-plugin-merge` is used to fix incompatibility between the two.
|
|
243
|
+
|
|
236
244
|
---
|
|
237
245
|
|
|
238
246
|
## GitHub Workflows
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
This file is the entry point to your script.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
// Imports your styles. Can be removed if no CSS is used.
|
|
6
|
-
import '@/styles.css'
|
|
1
|
+
/**
|
|
2
|
+
This file is the entry point to your script.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
// Imports your styles. Can be removed if no CSS is used.
|
|
6
|
+
import '@/styles.css'
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
// ==UserScript==
|
|
2
|
-
// @name <name>
|
|
3
|
-
// @version <version>
|
|
4
|
-
// @description <description>
|
|
5
|
-
// @author <author>
|
|
6
|
-
// @namespace <homepage>
|
|
7
|
-
// @homepage <homepage>
|
|
1
|
+
// ==UserScript==
|
|
2
|
+
// @name <name>
|
|
3
|
+
// @version <version>
|
|
4
|
+
// @description <description>
|
|
5
|
+
// @author <author>
|
|
6
|
+
// @namespace <homepage>
|
|
7
|
+
// @homepage <homepage>
|
|
8
8
|
// ==/UserScript==
|
|
@@ -1,60 +1,73 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Configured by create-tampermonkey-typescript to combine your entire codebase into a single TamperMonkey-ready script.
|
|
3
|
-
* You can modify it as you like.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
import { defineConfig } from 'vite'
|
|
7
|
-
import { resolve, dirname } from 'path'
|
|
8
|
-
import { fileURLToPath } from 'url'
|
|
9
|
-
import fs from 'fs'
|
|
10
|
-
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
|
11
|
-
import banner from 'vite-plugin-banner'
|
|
12
|
-
|
|
13
|
-
const __filename = fileURLToPath(import.meta.url)
|
|
14
|
-
const __dirname = dirname(__filename)
|
|
15
|
-
|
|
16
|
-
const pkg = JSON.parse(fs.readFileSync(resolve(__dirname, 'package.json'), 'utf8'))
|
|
17
|
-
const hasReact = pkg.devDependencies?.react || pkg.dependencies?.react
|
|
18
|
-
const hasTailwind = pkg.devDependencies?.['@tailwindcss/vite'] || pkg.dependencies?.['@tailwindcss/vite']
|
|
19
|
-
|
|
20
|
-
// Replaced in the script's header to keep package.json as the source of truth.
|
|
21
|
-
const metaTags = {
|
|
22
|
-
'<name>': pkg.name,
|
|
23
|
-
'<version>': pkg.version,
|
|
24
|
-
'<description>': pkg.description,
|
|
25
|
-
'<author>': pkg.author,
|
|
26
|
-
'<homepage>': pkg.homepage,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let meta = fs.readFileSync(resolve(__dirname, 'userscript.txt'), 'utf8')
|
|
30
|
-
|
|
31
|
-
for (const [tagName, tagValue] of Object.entries(metaTags).filter(([_, v]) => v)) {
|
|
32
|
-
meta = meta.replaceAll(tagName, tagValue)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export default defineConfig({
|
|
36
|
-
resolve: {
|
|
37
|
-
alias: {
|
|
38
|
-
'@': resolve(__dirname, 'src'),
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
plugins: [
|
|
42
|
-
...(hasTailwind
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Configured by create-tampermonkey-typescript to combine your entire codebase into a single TamperMonkey-ready script.
|
|
3
|
+
* You can modify it as you like.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { defineConfig } from 'vite'
|
|
7
|
+
import { resolve, dirname } from 'path'
|
|
8
|
+
import { fileURLToPath } from 'url'
|
|
9
|
+
import fs from 'fs'
|
|
10
|
+
import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
|
|
11
|
+
import banner from 'vite-plugin-banner'
|
|
12
|
+
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url)
|
|
14
|
+
const __dirname = dirname(__filename)
|
|
15
|
+
|
|
16
|
+
const pkg = JSON.parse(fs.readFileSync(resolve(__dirname, 'package.json'), 'utf8'))
|
|
17
|
+
const hasReact = pkg.devDependencies?.react || pkg.dependencies?.react
|
|
18
|
+
const hasTailwind = pkg.devDependencies?.['@tailwindcss/vite'] || pkg.dependencies?.['@tailwindcss/vite']
|
|
19
|
+
|
|
20
|
+
// Replaced in the script's header to keep package.json as the source of truth.
|
|
21
|
+
const metaTags = {
|
|
22
|
+
'<name>': pkg.name,
|
|
23
|
+
'<version>': pkg.version,
|
|
24
|
+
'<description>': pkg.description,
|
|
25
|
+
'<author>': pkg.author,
|
|
26
|
+
'<homepage>': pkg.homepage,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let meta = fs.readFileSync(resolve(__dirname, 'userscript.txt'), 'utf8')
|
|
30
|
+
|
|
31
|
+
for (const [tagName, tagValue] of Object.entries(metaTags).filter(([_, v]) => v)) {
|
|
32
|
+
meta = meta.replaceAll(tagName, tagValue)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default defineConfig({
|
|
36
|
+
resolve: {
|
|
37
|
+
alias: {
|
|
38
|
+
'@': resolve(__dirname, 'src'),
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
plugins: [
|
|
42
|
+
...(hasTailwind
|
|
43
|
+
? [
|
|
44
|
+
(await import('@tailwindcss/vite')).default({
|
|
45
|
+
optimize: { minify: true },
|
|
46
|
+
}),
|
|
47
|
+
]
|
|
48
|
+
: []),
|
|
49
|
+
cssInjectedByJsPlugin({ topExecutionPriority: true }),
|
|
50
|
+
banner({ content: meta, verify: false }),
|
|
51
|
+
// Uncomment below to remove comments & JSDoc from the final script.
|
|
52
|
+
// {
|
|
53
|
+
// name: 'strip-comments',
|
|
54
|
+
// renderChunk(code) {
|
|
55
|
+
// return code.replace(/\/\*\*[\s\S]*?\*\//g, '').replace(/\/\*[^!][\s\S]*?\*\//g, '')
|
|
56
|
+
// },
|
|
57
|
+
// },
|
|
58
|
+
],
|
|
59
|
+
build: {
|
|
60
|
+
cssCodeSplit: false,
|
|
61
|
+
lib: {
|
|
62
|
+
entry: resolve(__dirname, 'src/script.ts'),
|
|
63
|
+
name: pkg.name.replace(/[^a-zA-Z0-9]/g, '_'),
|
|
64
|
+
formats: ['iife'],
|
|
65
|
+
fileName: () => `script.user.js`,
|
|
66
|
+
},
|
|
67
|
+
rollupOptions: {
|
|
68
|
+
...(hasReact ? { external: ['react', 'react-dom/client'] } : {}),
|
|
69
|
+
},
|
|
70
|
+
outDir: 'dist',
|
|
71
|
+
minify: false,
|
|
72
|
+
},
|
|
73
|
+
})
|
package/templates/git/_gitignore
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
# Project Specific
|
|
2
|
-
dist/
|
|
3
|
-
|
|
4
|
-
# Node
|
|
5
|
-
node_modules/
|
|
6
|
-
.vite/
|
|
7
|
-
|
|
8
|
-
# Logs
|
|
9
|
-
npm-debug.log*
|
|
10
|
-
yarn-debug.log*
|
|
11
|
-
yarn-error.log*
|
|
12
|
-
pnpm-debug.log*
|
|
13
|
-
|
|
14
|
-
# OS-specific
|
|
15
|
-
.DS_Store
|
|
16
|
-
Thumbs.db
|
|
17
|
-
|
|
18
|
-
# VSCode
|
|
19
|
-
.vscode/
|
|
20
|
-
|
|
21
|
-
# Webstorm
|
|
22
|
-
.idea
|
|
23
|
-
|
|
24
|
-
# TypeScript
|
|
25
|
-
*.tsbuildinfo
|
|
26
|
-
|
|
27
|
-
# Prettier/Editor
|
|
1
|
+
# Project Specific
|
|
2
|
+
dist/
|
|
3
|
+
|
|
4
|
+
# Node
|
|
5
|
+
node_modules/
|
|
6
|
+
.vite/
|
|
7
|
+
|
|
8
|
+
# Logs
|
|
9
|
+
npm-debug.log*
|
|
10
|
+
yarn-debug.log*
|
|
11
|
+
yarn-error.log*
|
|
12
|
+
pnpm-debug.log*
|
|
13
|
+
|
|
14
|
+
# OS-specific
|
|
15
|
+
.DS_Store
|
|
16
|
+
Thumbs.db
|
|
17
|
+
|
|
18
|
+
# VSCode
|
|
19
|
+
.vscode/
|
|
20
|
+
|
|
21
|
+
# Webstorm
|
|
22
|
+
.idea
|
|
23
|
+
|
|
24
|
+
# TypeScript
|
|
25
|
+
*.tsbuildinfo
|
|
26
|
+
|
|
27
|
+
# Prettier/Editor
|
|
28
28
|
.prettiercache/
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
# .github/workflows/auto-tag.yml
|
|
2
|
-
name: Auto Tag from package.json
|
|
3
|
-
|
|
4
|
-
permissions:
|
|
5
|
-
contents: write
|
|
6
|
-
|
|
7
|
-
on:
|
|
8
|
-
push:
|
|
9
|
-
branches:
|
|
10
|
-
- master
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
tag:
|
|
14
|
-
runs-on: ubuntu-latest
|
|
15
|
-
steps:
|
|
16
|
-
- name: Checkout code
|
|
17
|
-
uses: actions/checkout@v4
|
|
18
|
-
with:
|
|
19
|
-
fetch-depth: 0 # Required to push tags
|
|
20
|
-
|
|
21
|
-
- name: Setup Node
|
|
22
|
-
uses: actions/setup-node@v4
|
|
23
|
-
with:
|
|
24
|
-
node-version: '20'
|
|
25
|
-
|
|
26
|
-
- name: Read version from package.json
|
|
27
|
-
id: pkg
|
|
28
|
-
run: |
|
|
29
|
-
VERSION=$(node -p "require('./package.json').version")
|
|
30
|
-
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
|
|
31
|
-
echo "TAG_NAME=v$VERSION" >> $GITHUB_ENV
|
|
32
|
-
|
|
33
|
-
- name: Create tag if not exists
|
|
34
|
-
run: |
|
|
35
|
-
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
|
36
|
-
echo "Tag $TAG_NAME already exists. Skipping."
|
|
37
|
-
else
|
|
38
|
-
git config user.name "github-actions[bot]"
|
|
39
|
-
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
40
|
-
git tag $TAG_NAME
|
|
41
|
-
git push origin $TAG_NAME
|
|
1
|
+
# .github/workflows/auto-tag.yml
|
|
2
|
+
name: Auto Tag from package.json
|
|
3
|
+
|
|
4
|
+
permissions:
|
|
5
|
+
contents: write
|
|
6
|
+
|
|
7
|
+
on:
|
|
8
|
+
push:
|
|
9
|
+
branches:
|
|
10
|
+
- master
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
tag:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
fetch-depth: 0 # Required to push tags
|
|
20
|
+
|
|
21
|
+
- name: Setup Node
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '20'
|
|
25
|
+
|
|
26
|
+
- name: Read version from package.json
|
|
27
|
+
id: pkg
|
|
28
|
+
run: |
|
|
29
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
30
|
+
echo "PACKAGE_VERSION=$VERSION" >> $GITHUB_ENV
|
|
31
|
+
echo "TAG_NAME=v$VERSION" >> $GITHUB_ENV
|
|
32
|
+
|
|
33
|
+
- name: Create tag if not exists
|
|
34
|
+
run: |
|
|
35
|
+
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
|
|
36
|
+
echo "Tag $TAG_NAME already exists. Skipping."
|
|
37
|
+
else
|
|
38
|
+
git config user.name "github-actions[bot]"
|
|
39
|
+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
|
|
40
|
+
git tag $TAG_NAME
|
|
41
|
+
git push origin $TAG_NAME
|
|
42
42
|
fi
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
name: Build & Release Tampermonkey Script
|
|
2
|
-
|
|
3
|
-
permissions:
|
|
4
|
-
contents: write
|
|
5
|
-
|
|
6
|
-
on:
|
|
7
|
-
workflow_run:
|
|
8
|
-
workflows: ["Auto Tag from package.json"]
|
|
9
|
-
types:
|
|
10
|
-
- completed
|
|
11
|
-
|
|
12
|
-
jobs:
|
|
13
|
-
release:
|
|
14
|
-
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
|
|
17
|
-
steps:
|
|
18
|
-
- name: Checkout code
|
|
19
|
-
uses: actions/checkout@v4
|
|
20
|
-
with:
|
|
21
|
-
fetch-depth: 0
|
|
22
|
-
fetch-tags: true
|
|
23
|
-
|
|
24
|
-
- name: Set up Node.js
|
|
25
|
-
uses: actions/setup-node@v4
|
|
26
|
-
with:
|
|
27
|
-
check-latest: true
|
|
28
|
-
|
|
29
|
-
- name: Install dependencies
|
|
30
|
-
run: npm ci
|
|
31
|
-
|
|
32
|
-
- name: Build script
|
|
33
|
-
run: npm run build
|
|
34
|
-
|
|
35
|
-
- name: Get package name
|
|
36
|
-
id: pkg
|
|
37
|
-
run: |
|
|
38
|
-
NAME=$(node -p "require('./package.json').name")
|
|
39
|
-
echo "PACKAGE_NAME=$NAME" >> $GITHUB_ENV
|
|
40
|
-
|
|
41
|
-
- name: Get latest tag from Git
|
|
42
|
-
id: tag
|
|
43
|
-
run: |
|
|
44
|
-
git fetch --tags
|
|
45
|
-
TAG=$(git describe --tags --abbrev=0)
|
|
46
|
-
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
|
|
47
|
-
echo "Latest tag: $TAG"
|
|
48
|
-
|
|
49
|
-
- name: Create GitHub Release
|
|
50
|
-
uses: softprops/action-gh-release@v2
|
|
51
|
-
with:
|
|
52
|
-
name: ${{ env.PACKAGE_NAME }} ${{ env.TAG_NAME }}
|
|
53
|
-
tag_name: ${{ env.TAG_NAME }}
|
|
54
|
-
files: dist/script.user.js
|
|
55
|
-
env:
|
|
56
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
1
|
+
name: Build & Release Tampermonkey Script
|
|
2
|
+
|
|
3
|
+
permissions:
|
|
4
|
+
contents: write
|
|
5
|
+
|
|
6
|
+
on:
|
|
7
|
+
workflow_run:
|
|
8
|
+
workflows: ["Auto Tag from package.json"]
|
|
9
|
+
types:
|
|
10
|
+
- completed
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
fetch-tags: true
|
|
23
|
+
|
|
24
|
+
- name: Set up Node.js
|
|
25
|
+
uses: actions/setup-node@v4
|
|
26
|
+
with:
|
|
27
|
+
check-latest: true
|
|
28
|
+
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: npm ci
|
|
31
|
+
|
|
32
|
+
- name: Build script
|
|
33
|
+
run: npm run build
|
|
34
|
+
|
|
35
|
+
- name: Get package name
|
|
36
|
+
id: pkg
|
|
37
|
+
run: |
|
|
38
|
+
NAME=$(node -p "require('./package.json').name")
|
|
39
|
+
echo "PACKAGE_NAME=$NAME" >> $GITHUB_ENV
|
|
40
|
+
|
|
41
|
+
- name: Get latest tag from Git
|
|
42
|
+
id: tag
|
|
43
|
+
run: |
|
|
44
|
+
git fetch --tags
|
|
45
|
+
TAG=$(git describe --tags --abbrev=0)
|
|
46
|
+
echo "TAG_NAME=$TAG" >> $GITHUB_ENV
|
|
47
|
+
echo "Latest tag: $TAG"
|
|
48
|
+
|
|
49
|
+
- name: Create GitHub Release
|
|
50
|
+
uses: softprops/action-gh-release@v2
|
|
51
|
+
with:
|
|
52
|
+
name: ${{ env.PACKAGE_NAME }} ${{ env.TAG_NAME }}
|
|
53
|
+
tag_name: ${{ env.TAG_NAME }}
|
|
54
|
+
files: dist/script.user.js
|
|
55
|
+
env:
|
|
56
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A reference to the global `window` object, extended with additional properties
|
|
3
|
-
* for React and ReactDOM.
|
|
4
|
-
*
|
|
5
|
-
* @type {Window & {React: typeof import('react'), ReactDOM: typeof import('react-dom/client')}}
|
|
6
|
-
* @property {typeof import('react')} React - The React library, providing tools
|
|
7
|
-
* for building user interfaces.
|
|
8
|
-
* @property {typeof import('react-dom/client')} ReactDOM - The ReactDOM library,
|
|
9
|
-
* allowing React components to be rendered into the DOM.
|
|
10
|
-
*/
|
|
11
|
-
declare const unsafeWindow: Window & {
|
|
12
|
-
React: typeof import('react')
|
|
13
|
-
ReactDOM: typeof import('react-dom/client')
|
|
14
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* A reference to the global `window` object, extended with additional properties
|
|
3
|
+
* for React and ReactDOM.
|
|
4
|
+
*
|
|
5
|
+
* @type {Window & {React: typeof import('react'), ReactDOM: typeof import('react-dom/client')}}
|
|
6
|
+
* @property {typeof import('react')} React - The React library, providing tools
|
|
7
|
+
* for building user interfaces.
|
|
8
|
+
* @property {typeof import('react-dom/client')} ReactDOM - The ReactDOM library,
|
|
9
|
+
* allowing React components to be rendered into the DOM.
|
|
10
|
+
*/
|
|
11
|
+
declare const unsafeWindow: Window & {
|
|
12
|
+
React: typeof import('react')
|
|
13
|
+
ReactDOM: typeof import('react-dom/client')
|
|
14
|
+
}
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Optional utility file for easily accessing the React & ReactDOM objects at runtime.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
import type React from 'react'
|
|
6
|
-
import type ReactDOM from 'react-dom/client'
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Retrieves the React object from the global `unsafeWindow` scope.
|
|
10
|
-
*
|
|
11
|
-
* @return {typeof React} The React object from the global scope.
|
|
12
|
-
*/
|
|
13
|
-
export function getReact(): typeof React {
|
|
14
|
-
return unsafeWindow.React
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Retrieves the ReactDOM object from the global `unsafeWindow` object.
|
|
19
|
-
*
|
|
20
|
-
* @return {typeof ReactDOM} The ReactDOM reference from the global scope.
|
|
21
|
-
*/
|
|
22
|
-
export function getReactDOM(): typeof ReactDOM {
|
|
23
|
-
return unsafeWindow.ReactDOM
|
|
24
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Optional utility file for easily accessing the React & ReactDOM objects at runtime.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import type React from 'react'
|
|
6
|
+
import type ReactDOM from 'react-dom/client'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the React object from the global `unsafeWindow` scope.
|
|
10
|
+
*
|
|
11
|
+
* @return {typeof React} The React object from the global scope.
|
|
12
|
+
*/
|
|
13
|
+
export function getReact(): typeof React {
|
|
14
|
+
return unsafeWindow.React
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the ReactDOM object from the global `unsafeWindow` object.
|
|
19
|
+
*
|
|
20
|
+
* @return {typeof ReactDOM} The ReactDOM reference from the global scope.
|
|
21
|
+
*/
|
|
22
|
+
export function getReactDOM(): typeof ReactDOM {
|
|
23
|
+
return unsafeWindow.ReactDOM
|
|
24
|
+
}
|
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
/* Add all styles
|
|
2
|
-
@import 'tailwindcss';
|
|
1
|
+
/* Add all styles in this file, or create multiple files and be sure to import them all in your script. */
|
|
2
|
+
@import 'tailwindcss';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
/* (For Tailwind v4) If just using tailwind utilities, it is recommended to replace the above with this. */
|
|
6
|
+
/* It will prevent tailwind's preflight from breaking the css of the page outside of your script's scope. */
|
|
7
|
+
/* Simply delete the above, uncomment below, and replace #your-root-element-id with your own. */
|
|
8
|
+
|
|
9
|
+
/*@layer theme, base, components, utilities;*/
|
|
10
|
+
/*@import "tailwindcss/theme.css" layer(theme);*/
|
|
11
|
+
/*@custom-variant dark (&:is(.dark-mode *));*/
|
|
12
|
+
|
|
13
|
+
/*#your-root-element-id {*/
|
|
14
|
+
/* @tailwind utilities;*/
|
|
15
|
+
/*}*/
|
package/templates/tsconfig.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"jsx": "react-jsx",
|
|
4
|
-
"types": ["vite/client", "node"],
|
|
5
|
-
"target": "ES2022",
|
|
6
|
-
"module": "ESNext",
|
|
7
|
-
"moduleResolution": "nodenext",
|
|
8
|
-
"strict": true,
|
|
9
|
-
"esModuleInterop": true,
|
|
10
|
-
"forceConsistentCasingInFileNames": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"resolveJsonModule": true,
|
|
13
|
-
"lib": ["ES2022", "dom", "dom.iterable"]
|
|
14
|
-
},
|
|
15
|
-
"include": ["template/src", "react"]
|
|
16
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"jsx": "react-jsx",
|
|
4
|
+
"types": ["vite/client", "node"],
|
|
5
|
+
"target": "ES2022",
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"moduleResolution": "nodenext",
|
|
8
|
+
"strict": true,
|
|
9
|
+
"esModuleInterop": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"skipLibCheck": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"lib": ["ES2022", "dom", "dom.iterable"]
|
|
14
|
+
},
|
|
15
|
+
"include": ["template/src", "react"]
|
|
16
|
+
}
|