-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
…itignore
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: minify-workflow | ||
|
||
on: | ||
# Triggers the workflow on push events but only for the main or dev branch | ||
push: | ||
branches: [ main, dev ] | ||
|
||
# Allows you to run this workflow manually from the Actions tab | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: push | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
|
||
steps: | ||
- name: Set up workspace | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: 16 | ||
|
||
- name: Install dependencies | ||
run: npm i | ||
|
||
- name: Build the packages | ||
run: npm run build | ||
|
||
- name: Auto commit | ||
run: | | ||
git add . | ||
git -c user.name='minify-bot' -c user.email='[email protected]' commit -m "Auto minify" || exit 0 | ||
git push | ||
env: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
package | ||
esbuild-* | ||
.DS_Store | ||
node_modules | ||
dist | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var t={num:{type:"num",match:/(\.e?|\b)\d(e-|[\d.oxa-fA-F_])*(\.|\b)/g},str:{type:"str",match:/(["'])(\\[^]|(?!\1)[^\r\n\\])*\1?/g},strDouble:{type:"str",match:/"((?!")[^\r\n\\]|\\[^])*"?/g}};export{t as default}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Try to find the language the given code belong to | ||
* @param code The code | ||
* @returns The language of the code | ||
*/ | ||
export declare function detectLanguage( | ||
code: string | ||
): Promise<import('.').ShjLanguage> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
/////////// typedef.js /////////// | ||
|
||
/** | ||
* Supported languages. | ||
*/ | ||
export type ShjLanguage = 'asm'|'bash'|'bf'|'c'|'css'|'csv'|'diff'|'docker'|'git'|'go'|'html'|'http'|'ini'|'java'|'js'|'jsdoc'|'json'|'leanpub-md'|'log'|'lua'|'make'|'md'|'pl'|'plain'|'py'|'regex'|'rs'|'sql'|'todo'|'toml'|'ts'|'uri'|'xml'|'yaml'; | ||
|
||
/** | ||
* Themes supported in the browser. | ||
*/ | ||
export type ShjBrowserTheme = 'atom-dark'|'github-dark'|'github-dim'|'dark'|'default'|'github-light'|'visual-studio-dark'; | ||
|
||
/** | ||
* Languages supported in the terminal. | ||
*/ | ||
export type ShjTerminalTheme = 'default'|'atom-dark'; | ||
|
||
/** | ||
* * `inline` inside `code` element | ||
* * `oneline` inside `div` element and containing only one line | ||
* * `multiline` inside `div` element | ||
*/ | ||
export type ShjDisplayMode = 'inline'|'oneline'|'multiline'; | ||
|
||
export type ShjToken = 'deleted'|'err'|'var'|'section'|'kwd'|'class'|'cmnt'|'insert'|'type'|'func'|'bool'|'num'|'oper'|'str'|'esc'; | ||
|
||
export interface ShjOptions { | ||
/** | ||
* Indicates whether to hide line numbers. | ||
* @default false | ||
*/ | ||
hideLineNumbers: boolean; | ||
} | ||
|
||
/////////// Custom Types /////////// | ||
|
||
export type ShjLanguageComponent = | ||
| { type: string; match: RegExp } | ||
| { extand: string } | ||
| { | ||
match: RegExp; | ||
sub: | ||
| string | ||
| ((code: string) => { | ||
type: string; | ||
sub: Array<{ match: RegExp; sub: string | Promise<string> }> | ||
}); | ||
}; | ||
|
||
export type ShjLanguageDefinition = Array<ShjLanguageComponent>; | ||
|
||
/////////// index.js /////////// | ||
|
||
/** | ||
* Find the tokens in the given code and call the callback | ||
* @param src The code | ||
* @param lang The language of the code | ||
* @param callback The callback function | ||
* this function will be given | ||
* * the text of the token | ||
* * the type of the token | ||
*/ | ||
export declare function tokenize<T extends string = ShjLanguage>( | ||
src: string, | ||
lang: T, | ||
callback: (value: string, token: ShjToken) => void | ||
): Promise<void>; | ||
|
||
/** | ||
* Highlight a string passed as argument and return it | ||
* @example | ||
* elm.innerHTML = await highlightText(code, 'js'); | ||
* @param src The code | ||
* @param lang The language of the code | ||
* @param multiline If it is multiline, it will add a wrapper for the line numbering and header | ||
* @param Customization options | ||
* @returns The highlighted string | ||
*/ | ||
export declare function highlightText<T extends string = ShjLanguage>( | ||
src: string, | ||
lang: T, | ||
multiline?: boolean, | ||
opt?: ShjOptions | ||
): Promise<string>; | ||
|
||
/** | ||
* Highlight a DOM element by getting the new innerHTML with highlightText | ||
* @param elm The DOM element | ||
* @param lang The language of the code (seaching by default on `elm` for a 'shj-lang-' class) | ||
* @param mode The display mode (guessed by default) | ||
* @param opt Customization options | ||
*/ | ||
export declare function highlightElement<T extends string = ShjLanguage>( | ||
elm: Element, | ||
lang?: T, | ||
mode?: ShjDisplayMode, | ||
opt?: ShjOptions | ||
): Promise<void>; | ||
|
||
/** | ||
* Call highlightElement on element with a css class starting with `shj-lang-` | ||
* @param opt Customization options | ||
*/ | ||
export declare function highlightAll(opt?: ShjOptions): Promise<void>; | ||
|
||
/** | ||
* Load a language and add it to the langs object | ||
* @param name The name of the language | ||
* @param module Module that has the language as the default export | ||
*/ | ||
export declare function loadLanguage( | ||
name: string, | ||
module: { default: ShjLanguageDefinition } | ||
): void; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var t=[{match:/[^\[\->+.<\]\s].*/g,sub:"todo"},{type:"func",match:/\.+/g},{type:"kwd",match:/[<>]+/g},{type:"oper",match:/[+-]+/g}];export{t as default}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var e=[{expand:"strDouble"},{type:"oper",match:/,/g}];export{e as default}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var t=[{type:"deleted",match:/^[-<].*/gm},{type:"insert",match:/^[+>].*/gm},{type:"kwd",match:/!.*/gm},{type:"section",match:/^@@.*@@$|^\d.*|^([*-+])\1\1.*/gm}];export{t as default}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import E from"./bash.js";var L=[{type:"kwd",match:/^(FROM|RUN|CMD|LABEL|MAINTAINER|EXPOSE|ENV|ADD|COPY|ENTRYPOINT|VOLUME|USER|WORKDIR|ARG|ONBUILD|STOPSIGNAL|HEALTHCHECK|SHELL)\b/gim},...E];export{L as default}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import t from"./diff.js";var m=[{match:/^#.*/gm,sub:"todo"},{expand:"str"},...t,{type:"func",match:/^(\$ )?git(\s.*)?$/gm},{type:"kwd",match:/^commit \w+$/gm}];export{m as default}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var t=[{match:/(^[ \f\t\v]*)[#;].*/gm,sub:"todo"},{type:"str",match:/.*/g},{type:"var",match:/.*(?==)/g},{type:"section",match:/^\s*\[.+\]\s*$/gm},{type:"oper",match:/=/g}];export{t as default}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import t from"./todo.js";var a=[{type:"kwd",match:/@\w+/g},{type:"class",match:/{[\w\s|<>,.@\[\]]+}/g},{type:"var",match:/\[[\w\s="']+\]/g},...t];let e="cmnt";export{a as default,e as type}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var a=[{type:"var",match:/("|')?[a-zA-Z]\w*\1(?=\s*:)/g},{expand:"str"},{expand:"num"},{type:"num",match:/\bnull\b/g},{type:"bool",match:/\b(true|false)\b/g}];export{a as default}; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.