-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,4 @@ package-lock.json | |
yarn.lock | ||
yarn-error.log | ||
/coverage/ | ||
/dist/ | ||
/publish/ |
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,85 @@ | ||
import { emptyDir, ensureDir } from "https://deno.land/[email protected]/fs/mod.ts"; | ||
import * as esbuild from 'https://deno.land/x/[email protected]/mod.js' | ||
|
||
async function createFolderStructure() { | ||
await ensureDir("./dist"); | ||
await emptyDir("./dist"); | ||
} | ||
|
||
async function packageDirectory(def, loader, format, minified) { | ||
for (const dir of def.dir) { | ||
for await (const dirEntry of Deno.readDir(dir)) { | ||
if (dirEntry.isDirectory) { | ||
continue; | ||
} | ||
|
||
const sourceFile = `${dir}/${dirEntry.name}`; | ||
|
||
let targetFile = `${def.target}${dir}/${dirEntry.name}`; | ||
let keys = Object.keys(def.replace || {}); | ||
for (const key of keys) { | ||
targetFile = targetFile.replace(key, def.replace[key]); | ||
} | ||
|
||
await packageFile(sourceFile, targetFile, loader, format, minified); | ||
} | ||
} | ||
} | ||
|
||
async function packageFiles(def, loader, format, minified) { | ||
for (const file of def.files) { | ||
const target = file.replace("./src", "./dist"); | ||
await packageFile(file, target, loader, format, minified); | ||
} | ||
} | ||
|
||
async function packageFile(sourceFile, targetFile, loader, format, minified) { | ||
const src = await Deno.readTextFile(sourceFile); | ||
const result = await esbuild.transform(src, { loader: loader, minify: minified, format: format }); | ||
await Deno.writeTextFile(targetFile, result.code); | ||
} | ||
|
||
/** | ||
* Save the html/css/json file to the target and minify it if required | ||
* @param sourceFile | ||
* @param targetFile | ||
* @param minified | ||
* @returns {Promise<void>} | ||
*/ | ||
async function packageMarkup(sourceFile, targetFile, minified) { | ||
let src = await Deno.readTextFile(sourceFile); | ||
|
||
if (minified == true) { | ||
src = src | ||
.split(" ").join("") | ||
.split("\t").join("") | ||
.split("\r").join("") | ||
.split("\n").join(""); | ||
} | ||
|
||
await Deno.writeTextFile(targetFile, src); | ||
} | ||
|
||
async function bundle(file, output) { | ||
const result = await esbuild.build({ | ||
entryPoints: [file], | ||
bundle: true, | ||
outfile: output, | ||
format: "esm", | ||
minify: true | ||
}) | ||
|
||
console.log(result); | ||
} | ||
|
||
|
||
await createFolderStructure(); | ||
|
||
await packageMarkup("./src/crs-loader.html", "./dist/crs-loader.html", true); | ||
await packageFile("./src/crs-loader.js", "./dist/crs-loader.js", "js", "esm", true); | ||
await packageFile("./src/crs-router.js", "./dist/crs-router.js", "js", "esm", true); | ||
await packageFile("./src/crs-static-provider.js", "./dist/crs-static-provider.js", "js", "esm", true); | ||
await packageFile("./src/crs-url-provider.js", "./dist/crs-url-provider.js", "js", "esm", true); | ||
await packageFile("./src/crs-utils.js", "./dist/crs-utils.js", "js", "esm", true); | ||
|
||
Deno.exit(0); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<style>crs-loader{--path:#2F3545;--dot:#ff0080;--duration:2s;position:fixed;display:flex;flex-direction:column;justify-content:center;width:60px;height:60px;}crs-loader.text{color:var(--dot);}crs-loader.loader{width:44px;height:44px;position:relative;}crs-loader.loader:before{content:'';width:5px;height:5px;border-radius:50%;position:absolute;display:block;background:var(--dot);top:37px;}crs-loader.loadersvg{display:block;width:100%;height:100%;}crs-loader.loadersvgpolygon{fill:none;stroke:var(--path);stroke-width:10px;stroke-linejoin:round;stroke-linecap:round;stroke-dasharray:1457614576;stroke-dashoffset:0;animation:pathTrianglevar(--duration)cubic-bezier(0.785,0.135,0.15,0.86)infinite;}crs-loader.triangle:before{left:21px;transform:translate(-10px,-18px);animation:dotTrianglevar(--duration)cubic-bezier(0.785,0.135,0.15,0.86)infinite;}@keyframespathTriangle{33%{stroke-dashoffset:74;}66%{stroke-dashoffset:147;}100%{stroke-dashoffset:221;}}@keyframesdotTriangle{33%{transform:translate(0,0);}66%{transform:translate(10px,-18px);}100%{transform:translate(-10px,-18px);}}</style><divclass="loadertriangle"><svgviewBox="008680"><polygonpoints="4387972772"></polygon></svg></div><divclass="text">Loading</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
class t extends HTMLElement{connectedCallback(){fetch(import.meta.url.replace(".js",".html")).then(e=>e.text()).then(e=>this.innerHTML=e)}}customElements.define("crs-loader",t);export{t as Loader}; |
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.