Skip to content

Commit 31f5edb

Browse files
committed
feat(temp):add stencil js
1 parent a0913a2 commit 31f5edb

29 files changed

+436
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pnpm-lock.yaml
1515
build
1616
types
1717
index.js
18+
!**/index.js
1819

1920
# ignore ide settings
2021
.idea

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Summary
99
5. version timestamp follow the yyyy.MM.dd format
1010
```
1111

12+
## 0.8.1 [2022.09.09]
13+
14+
- docs: add zn_CN readme
15+
1216
## 0.8.0 [2022.09.05]
1317

1418
- remove: qwik framework boilerplate

README_zh.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Create Chrome Extension (.crx)
2+
3+
![crx-preview](./docs/crx-preview.png)
4+
5+
[![OSCS Status](https://www.oscs1024.com/platform/badge/guocaoyi/create-chrome-ext.svg?size=small)](https://www.oscs1024.com/project/guocaoyi/create-chrome-ext?ref=badge_small)
6+
[![npm](https://img.shields.io/npm/v/create-chrome-ext?logo=npm)](https://www.npmjs.com/package/create-chrome-ext)
7+
[![npm-download](https://img.shields.io/npm/dw/create-chrome-ext)](https://www.npmjs.com/package/create-chrome-ext)
8+
![GitHub Language Count](https://img.shields.io/github/languages/count/guocaoyi/create-chrome-ext)
9+
[![npm publish](https://github.com/guocaoyi/create-chrome-ext/actions/workflows/npm-publish.yml/badge.svg)](https://github.com/guocaoyi/create-chrome-ext/actions/workflows/npm-publish.yml)
10+
11+
> Chrome 插件生成器,支持多种框架模板!
12+
13+
- 🚀 敏捷的热更能力(采用 [Vite2](https://vitejs.dev))
14+
- 🥡 开箱即用
15+
- 🌈 多种前端框架支撑 (9+)
16+
- 🥢 支撑 TypeScript 以及 JavaScript
17+
- 🌗 明亮以及暗黑模式
18+
19+
[EN](./README.md) · [中文](./README_zh.md)
20+
21+
## 安装
22+
23+
> Node >= 14.18.0
24+
25+
```bash
26+
# 使用 npm create 命令
27+
λ npm create chrome-ext
28+
29+
# 或者使用 npx 命令
30+
λ npx create-chrome-ext
31+
32+
# 或者使用 npm init 命令
33+
λ npm init chrome-ext
34+
```
35+
36+
## 用例
37+
38+
您还可以通过其他命令行配置直接指定项目名称和要使用的模板。比如 Vite + Svelte 项目,运行:
39+
40+
```bash
41+
# npm 6.x
42+
λ npm create chrome-ext@latest my-crx-app --template svelte-js
43+
44+
# npm 版本 7 以上, 注意 -- 命令选项
45+
λ npm create chrome-ext@latest my-crx-app -- --template react-ts
46+
47+
# or yarn
48+
λ yarn create chrome-ext my-crx-app --template vue-ts
49+
50+
# or pnpm
51+
λ pnpm create chrome-ext my-crx-app --template vanilla-ts
52+
```
53+
54+
You can also generator the project with `crx` cli, run:
55+
56+
```bash
57+
λ npm install create-chrome-ext --global
58+
59+
# and then
60+
λ crx my-crx-app
61+
# or
62+
λ crx my-crx-app --template preact-js
63+
# or use create-chrome-exe (global env)
64+
λ create-chrome-ext my-crx-app
65+
```
66+
67+
## 模板
68+
69+
预置的前端架构:
70+
71+
[React](https://reactjs.org) · [Vue](https://vuejs.org) · [Svelte](https://svelte.dev) · [Preact](https://preactjs.com) · [Solid](https://www.solidjs.com) · [Alpine](https://alpinejs.dev) · [Lit](https://lit.dev) · [Inferno](https://www.infernojs.org) · [Stencil](https://stenciljs.com) · [Vanilla](http://vanilla-js.com)
72+
73+
语言支持:
74+
75+
[JavaScript](https://www.javascript.com/) · [TypeScript](https://www.typescriptlang.org/)
76+
77+
## 预览
78+
79+
![crx-run](./docs/crx-run.png)
80+
![crx-install](./docs/crx-install.png)
81+
![crx-build](./docs/crx-build.png)

bin.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env node
2+
3+
import './index.js'

index.d.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
#!/usr/bin/env node
2-
3-
// @ts-check
41
import * as fs from 'fs'
52
import * as path from 'path'
63
import minimist from 'minimist'

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
22
"name": "create-chrome-ext",
3-
"version": "0.8.0",
3+
"version": "0.8.1",
44
"type": "module",
55
"description": "Scaffolding your chrome extension, multiple boilerplates supported!",
66
"author": "yalda",
77
"license": "MIT",
8-
"main": "index.js",
8+
"main": "bin.js",
99
"bin": {
1010
"create-chrome-ext": "index.js",
1111
"crx": "index.js"

template-stencil-js/package.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"name": "chrome-extension-stencil-js",
3+
"version": "0.0.0",
4+
"author": "",
5+
"description": "",
6+
"type": "module",
7+
"license": "MIT",
8+
"keywords": [
9+
"chrome-extension",
10+
"stencil",
11+
"vite",
12+
"create-chrome-ext"
13+
],
14+
"engines": {
15+
"node": ">=14.18.0"
16+
},
17+
"scripts": {
18+
"s:build": "stencil build",
19+
"s:start": "stencil build --dev --watch --serve",
20+
"s:test": "stencil test --spec --e2e",
21+
"s:test.watch": "stencil test --spec --e2e --watchAll",
22+
"s:generate": "stencil generate",
23+
"dev": "vite",
24+
"build": "vite build",
25+
"build.client": "vite build --outDir server/public",
26+
"preview": "vite preview",
27+
"fmt": "prettier --write '**/*.{jsx,js,json,css,md}'"
28+
},
29+
"devDependencies": {
30+
"@crxjs/vite-plugin": "^1.0.12",
31+
"@stencil/core": "2.13.0",
32+
"express": "4.17.2",
33+
"prettier": "^2.7.1",
34+
"vite": "^2.9.13"
35+
}
36+
}
4.18 KB
Binary file not shown.
Lines changed: 2 additions & 0 deletions
Loading
3.01 KB
Loading
449 Bytes
Loading
827 Bytes
Loading
1.21 KB
Loading
7.73 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.info('chrome-ext template-stencil-js background script')
2+
3+
export {}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
main {
2+
text-align: center;
3+
padding: 1em;
4+
margin: 0 auto;
5+
}
6+
7+
h3 {
8+
color: #673ab8;
9+
text-transform: uppercase;
10+
font-size: 1.5rem;
11+
font-weight: 200;
12+
line-height: 1.2rem;
13+
margin: 2rem auto;
14+
}
15+
16+
h6 {
17+
font-size: 0.5rem;
18+
color: #333333;
19+
margin: 0.5rem;
20+
}
21+
22+
a {
23+
font-size: 0.5rem;
24+
margin: 0.5rem;
25+
color: #cccccc;
26+
text-decoration: none;
27+
}
28+
29+
@media (min-width: 480px) {
30+
h3 {
31+
max-width: none;
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Component, Prop, h } from '@stencil/core'
2+
3+
@Component({
4+
tag: 'app-options',
5+
styleUrl: 'app-options.css',
6+
})
7+
export class AppOptions {
8+
@Prop() crx: string = ''
9+
10+
render() {
11+
return (
12+
<main>
13+
<h3>Options Page!</h3>
14+
15+
<h6>v 0.0.0</h6>
16+
17+
<a href="https://www.npmjs.com/package/create-chrome-ext" target="_blank">
18+
Power by {this.crx}
19+
</a>
20+
</main>
21+
)
22+
}
23+
}
24+
25+
export default AppOptions
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
main {
2+
text-align: center;
3+
padding: 1em;
4+
margin: 0 auto;
5+
}
6+
7+
h3 {
8+
color: #673ab8;
9+
text-transform: uppercase;
10+
font-size: 1.5rem;
11+
font-weight: 200;
12+
line-height: 1.2rem;
13+
margin: 2rem auto;
14+
}
15+
16+
h6 {
17+
font-size: 0.5rem;
18+
color: #333333;
19+
margin: 0.5rem;
20+
}
21+
22+
a {
23+
font-size: 0.5rem;
24+
margin: 0.5rem;
25+
color: #cccccc;
26+
text-decoration: none;
27+
}
28+
29+
@media (min-width: 480px) {
30+
h3 {
31+
max-width: none;
32+
}
33+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { Component, Prop, h } from '@stencil/core'
2+
3+
@Component({
4+
tag: 'app-popup',
5+
styleUrl: 'app-popup.css',
6+
})
7+
export class AppPopup {
8+
@Prop() crx: string = ''
9+
10+
render() {
11+
return (
12+
<main>
13+
<h3>Popup Page!</h3>
14+
15+
<h6>v 0.0.0</h6>
16+
17+
<a href="https://www.npmjs.com/package/create-chrome-ext" target="_blank">
18+
Power by {this.crx}
19+
</a>
20+
</main>
21+
)
22+
}
23+
}
24+
25+
export default AppPopup
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
console.info('chrome-ext template-stencil-js content script')
2+
3+
export {}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
Global App CSS
3+
----------------------
4+
Use this file for styles that should be applied to all components.
5+
For example, "font-family" within the "body" selector is a CSS property
6+
most apps will want applied to all components.
7+
8+
Any global CSS variables should also be applied here.
9+
*/
10+
11+
:root {
12+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell,
13+
'Open Sans', 'Helvetica Neue', sans-serif;
14+
font-size: 16px;
15+
line-height: 24px;
16+
font-weight: 400;
17+
18+
color-scheme: light dark;
19+
color: rgba(255, 255, 255, 0.87);
20+
background-color: #242424;
21+
22+
font-synthesis: none;
23+
text-rendering: optimizeLegibility;
24+
-webkit-font-smoothing: antialiased;
25+
-moz-osx-font-smoothing: grayscale;
26+
-webkit-text-size-adjust: 100%;
27+
}
28+
29+
@media (prefers-color-scheme: light) {
30+
:root {
31+
color: #213547;
32+
background-color: #ffffff;
33+
}
34+
a:hover {
35+
color: #747bff;
36+
}
37+
}
38+
39+
body {
40+
min-width: 20rem;
41+
margin: 0px;
42+
padding: 0px;
43+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif,
44+
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
45+
}

template-stencil-js/src/global/app.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default async () => {
2+
/**
3+
* The code to be executed should be placed within a default function that is
4+
* exported by the global script. Ensure all of the code in the global script
5+
* is wrapped in the function() that is exported.
6+
*/
7+
};

template-stencil-js/src/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { Components, JSX } from './components';
2+
import '@stencil-community/router';

template-stencil-js/src/manifest.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { defineManifest } from '@crxjs/vite-plugin'
2+
3+
export default defineManifest({
4+
name: 'create-chrome-ext',
5+
description: '',
6+
version: '0.0.0',
7+
manifest_version: 3,
8+
icons: {
9+
16: 'img/logo-16.png',
10+
32: 'img/logo-34.png',
11+
48: 'img/logo-48.png',
12+
128: 'img/logo-128.png',
13+
},
14+
action: {
15+
default_popup: 'popup.html',
16+
default_icon: 'img/logo-48.png',
17+
},
18+
options_page: 'options.html',
19+
background: {
20+
service_worker: 'src/background/index.js',
21+
type: 'module',
22+
},
23+
content_scripts: [
24+
{
25+
matches: ['http://*/*', 'https://*/*'],
26+
js: ['src/content/index.js'],
27+
},
28+
],
29+
web_accessible_resources: [
30+
{
31+
resources: ['img/logo-16.png', 'img/logo-34.png', 'img/logo-48.png', 'img/logo-128.png'],
32+
matches: [],
33+
},
34+
],
35+
permissions: [],
36+
})

0 commit comments

Comments
 (0)