This commit is contained in:
jusax23 2022-11-06 20:39:28 +01:00
commit 5bf0903cf7
22 changed files with 2035 additions and 0 deletions

4
.gitmodules vendored Normal file
View file

@ -0,0 +1,4 @@
[submodule "stear"]
path = stear
url = https://gitlab.com/jusax23/stear.git
branch = submodule

192
README.md Normal file
View file

@ -0,0 +1,192 @@
# Stear
## Introduction
A simple Framework. Combine all Content in one File in an Modular way and native JavaScript.
## Getting started
Download the stear Submodule and add it to your Project.
## Features
### Create Stear Instance
```javascript
import { Stear, SWindow } from "./stear/main.js";
var stear = new Stear(document.querySelector("#stear"));
```
### Addind Windows
```javascript
stear.addElement("connect", connect);
stear.addElement("start", start);
```
Windows don't necessarily have to be add this Way.
An SWindow is an Extendion of the SFrame class. SWindow adds an DIV Element around the page content in Fullscreen.
### Calling Windows
```javascript
import start from "./start.js";
stear.call(stear.g("start"), {});
stear.call(start, {});
```
The first Argument must be an SFrame Instance. The secound Argument can be used to pass Data to the new Window.
This Methode returns a Promise. When the Promise will be resolved, the return Value can be accessed. The Promise can be awaited.
### Creating a Window
```javascript
import { Stear, SWindow, _ } from "../stear/main.js";
const call = async (stear, { find, resolve, render, call, event }, args) => {
return _({
}, [
]);
}
export default new SWindow({ call, preRender:true, backgroundColor: "#dde" });
```
**preRender**: This is set to true by default. When set to true the content will be rendered imidiatly. Atherwise only when called render().
**call**: When calling a Window this function will be called. The first Argument is the used Stear Instance. The secound Argument contains some StearingTools. The third Argument are the Arguments passt in the call request. This function must return the page Content or function which returns the page content.
### Creating Page Content / class_ class
```javascript
_({
find:"someString",
type:"div",
style:{
color:"#fff",
backgroundColor:"black",
},
event: {
click: ()=>{
}
}
//other Attributes
},[
//pass here other class_ Instances or Strings or Language Sentences
//or functions that generats things like this
])
```
The function _(settings, childs) returns an class\_ Instance.
Attributes of the Settings Object while be applyed as HTML-Element Attribute.
Exeptions are find, type, style, event (all can be empty):
**type**: The type Attribute determines the DOMElement Type. The Default is div.
**find**: The find Attribute is an identifier. With find.someString you can get this Element. With find.someString._ you get the underlying DOMElement.
**style**: The content of the style Attribute will be applied as css style.
**event**: The content of the style Attribute will be applied with addEventListener.
Other Methodes:
```javascript
var element = _({},[]);
var newRenderedHTMLElement = await element.build(someArgsInArray); //Executs functions to create dynamic Structures
var newRenderedHTMLElement = element.render ;
var HTMLElement = element._ ; //Same as line befor when Element was completly rendered
element.childs = [
//Overrides the secound Argument
];
element.settings = {
//Overrides first Argument (when possible)
}
```
### Intelligent Content / StearingTools
- find: Contains all Elements labeled with find.
- resolve: This function resolves the call, like a regular Promise. The secound Argument determies wheser the SWindow shut be closed.
- close: This will close the SWindow.
- render: This function, will (re-)render the page content (executes every function in Content Tree (again).)
- call: The way to call an other SWindow/SFrame with an appropriate zIndex.
- event: An objects with callback functions, that can be overriden:
- onloaded: Called after initial Content render.
- onresolve: Will be awaited to execute operations on resolve or to delay it, when async.
- onclose: Will be executed on calling close(). It will delay the closing process if async.
- onBeforRerender: This will be executed befor the (re-)render while called render(). When async the render will be delayed.
- onAfterRerender: This will be executed befor the (re-)render while called render(). When async it will delay the resolve of the render() function.
### Globel functions
#### Adding Global CSS the Oldway
```javascript
Stear.addGlobalStyleText(`
.cssClass {
color: #fff;
background-color:black;
}
`);
```
#### Adding Global CSS the with JSON
```javascript
var name = ".cssClass";
name = Stear.addGlobalStyleJSON({
color: "#fff",
backgroundColor: "black",
},name);
```
The Function can add CSS like CSS can be added to Elements in Pages. When leaving name empty a cssClass will be added with a sortof random name.
#### Adding CSS Animations with JSON
```javascript
var KeyframeName = Stear.addAnimation({
"0%":{
transform: "scale(100%)",
},
"50%": {
transform: "scale(110%)",
},
"100%": {
transform: "scale(100%)",
}
}/*,name*/);
```
#### Language
This Tool can be used in MultiLingual Projects.
Default Schema:
```javascript
const pool = Stear.addLanguagePool("poolname");
const sentences1 = pool.add("sentences1", "Some Text"); //id, default Text
const sentences2 = pool.add("sentences2", "Some {} Text with {}.");
sentences1 // Some Text
sentences2 // Some {} Text with {}.
sentences2.r("nice","a good flavour") // Some nice Text with a good flavour.
```
The Language System is a two level System. It is recomendet, to use the Name of the Window as poolname.
The LanguageString can be used like a normal String. The Methode .r() can repalace "{}" in the Text.
When useing Stear.addLanguagePool or pool.add twise the same instance will be returned.
Other Language functions
```javascript
var someJSON = Stear.getLanguageFile;//contains all Defaults created yet.
Stear.lang = "de"; //change Language
Stear.addLanguageFile(fileJSON/*like someJSON*/,lang); //Language code like.
```
### Utils
#### wait
```javascript
await wait(200);
```
Simpel Methode of Timedelay in an async fcuntion
#### fadein
```javascript
await fadein(elems,ms,force);
await fadeout(elems,ms,force);
```
- **elems**: contains Element to Fade in or an Array of Elements
- **ms** Fade time
- **force** If set to true a alredy invisible/visible Element will be refaded out/in.
### Extras
loading1.js: simple to use Loadinganimation

21
example/menu/apps.jsx Normal file
View file

@ -0,0 +1,21 @@
import { Stear, SWindow, _, s } from "../../stear/main.js";
const call = async (stear, { find, resolve, close, render, call, event }, args) => {
/*event.onloaded = () => { }*/
/*event.onresolve = async () => { }*/
/*event.onclose = async () => { }*/
/*event.onBeforRerender = async () => { }*/
/*event.onAfterRerender = async () => { }*/
return <div style={{
display:"flex",
alignItems: "center",
justifyContent: "center",
height: "100%",
}}>
Appscreen
</div>
}
export default new SWindow({ call, backgroundColor: "#dde" });

56
example/menu/connect.js Normal file
View file

@ -0,0 +1,56 @@
import l1 from "../../stear/extra/Elements/loading1.js";
import showStatus from "../../stear/extra/Pages/showStatus.js";
import { Stear, SWindow, _ } from "../../stear/main.js";
import { fadein, fadeout, wait } from "../../stear/utils.js";
const pool = Stear.addLanguagePool("connect");
const connectingto = pool.add("connectingto", "Connecting to: {} ({})");
const connected = pool.add("connected", "connected");
const connecterror = pool.add("connecterror", "Error while Connecting to: {}");
export const call = async (stear, { find, resolve, render, call, event }, {name,id}) => {
event.onloaded = async ()=>{
await fadein(find.main, 200, true);
//do connection
await wait(1000);
if (Math.random() > 0.25) {
call(showStatus, { text: connected });
return resolve(true);
} else {
call(showStatus, { text: connecterror.r(name), color: "red" });
return resolve(false);
}
};
event.onresolve = async ()=>{
await fadeout(find.main);
}
return _({ find: "main" }, [
_({
type: "p",
style: {
position: "absolute",
minWidth: "90%",
textAlign: "center",
top: "25%",
left: "50%",
transform: "translate(-50%,-50%)",
}
}, connectingto.r(name, id)),
_({
style: {
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
}
}, l1())
]);
}
export default new SWindow({ preRender: true, call, backgroundColor: "#dde" });

19
example/menu/empty.js Normal file
View file

@ -0,0 +1,19 @@
import { Stear, SWindow, _ } from "../../stear/main.js";
const call = async (stear, { find, resolve, close, render, call, event }, args) => {
/*event.onloaded = () => { }*/
/*event.onresolve = async () => { }*/
/*event.onclose = async () => { }*/
/*event.onBeforRerender = async () => { }*/
/*event.onAfterRerender = async () => { }*/
/*event.onParentRender = () => { }*/
return _({
}, [
]);
}
export default new SWindow({ call, backgroundColor: "#dde" });

27
example/menu/index.html Normal file
View file

@ -0,0 +1,27 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Stear</title>
<style>
html,body{
margin: 0;
padding: 0;
height: 100%;
width: 100%;
}
#stear{
height: 100%;
width: 100%;
top: 0;
left:0;
}
</style>
</head>
<body>
<div id="stear"></div>
<script src="index.js" type="module"></script>
</body>
</html>

19
example/menu/index.js Normal file
View file

@ -0,0 +1,19 @@
import { Stear, SWindow } from "../../stear/main.js";
import start from "./start";
var stear = new Stear(document.querySelector("#stear"));
stear.style({
backgroundColor: "#dde",
fontFamily: "Helvetica Neue",
fontWeight: "lighter",
fontSize: "0.9em",
color: "#2a2a2a",
});
/*stear.addElement("connect", connect);
stear.addElement("start", start);*/
stear.call(start, {});

BIN
example/menu/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

69
example/menu/menu.jsx Normal file
View file

@ -0,0 +1,69 @@
import { Stear, SWindow, _, s } from "../../stear/main.js";
import apps from "./apps";
import settings from "./settings";
import splash from "./splash";
const call = async (stear, { find, resolve, close, render, call, include, event }, args) => {
/*event.onloaded = () => { }*/
/*event.onresolve = async () => { }*/
/*event.onclose = async () => { }*/
/*event.onBeforRerender = async () => { }*/
/*event.onAfterRerender = async () => { }*/
let menu = [
include(splash),
include(apps),
include(settings),
];
window.dddd = menu[0];
let show = 0;
return <div style={{
display: "flex",
height: "100%",
width: "100%",
flexDirection: "column",
}}>
<div style={{
position: "relative",
width: "100%",
height: "100%",
}}>{() => {
menu[show].opts.render();
return menu[show].render({
style: {
height: "100%",
width: "100%"
}
});
}}</div>
<div style={{
height: "2rem",
width: "calc(100% - 2rem)",
padding: "1rem",
backgroundColor: "#fee",
display: "flex",
flexDirection: "row",
alignItems: "center",
justifyContent: "space-evenly",
borderRadius: "2rem 2rem 0 0",
}}>
{() => menu.map((m, i) => {
return <div event={{
click: () => {
show = i;
render();
}
}} style={{
height: "1rem",
width: "1rem",
backgroundColor: show == i ? "red" : "green"
}}></div>;
})}
</div>
</div>;
}
export default new SWindow({ call, backgroundColor: "#dde"});

26
example/menu/settings.jsx Normal file
View file

@ -0,0 +1,26 @@
import prompt from "../../stear/extra/Pages/prompt.js";
import { Stear, SWindow, _, s } from "../../stear/main.js";
const call = async (stear, { find, resolve, close, render, call, event }, args) => {
/*event.onloaded = () => { }*/
/*event.onresolve = async () => { }*/
/*event.onclose = async () => { }*/
/*event.onBeforRerender = async () => { }*/
/*event.onAfterRerender = async () => { }*/
/*event.onParentRender = () => { }*/
event.onParentRender = () => call(prompt, { text: "settings" }).then(console.log);
return <div style={{
display:"flex",
alignItems: "center",
justifyContent: "center",
height: "100%",
}}>
Settings
</div>
}
export default new SWindow({ call, backgroundColor: "#dde" });

21
example/menu/splash.jsx Normal file
View file

@ -0,0 +1,21 @@
import { Stear, SWindow, _, s } from "../../stear/main.js";
const call = async (stear, { find, resolve, close, render, call, event }, args) => {
/*event.onloaded = () => { }*/
/*event.onresolve = async () => { }*/
/*event.onclose = async () => { }*/
/*event.onBeforRerender = async () => { }*/
/*event.onAfterRerender = async () => { }*/
return <div style={{
display:"flex",
alignItems: "center",
justifyContent: "center",
height: "100%",
}}>
Splashscreen
</div>
}
export default new SWindow({ call, backgroundColor: "#dde" });

42
example/menu/start.jsx Normal file
View file

@ -0,0 +1,42 @@
import { Stear, SWindow, _,s } from "../../stear/main.js";
import { fadein, fadeout, wait } from "../../stear/utils.js";
//import connect from "./connect.js";
import menu from "./menu";
export const preRender = true;
var wobel = Stear.addAnimation({
"0%": {
transform: "translate(-50%, -50%) scale(100%)"
},
"50%": {
transform: "translate(-50%, -50%) scale(110%)"
},
"100%": {
transform: "translate(-50%, -50%) scale(100%)"
}
});
export const call = (stear, { find, resolve, render, call, event }, args) => {
event.onloaded = async ()=>{
await wait(Math.max(1, 1000 - performance.now()));
await fadeout(find.main);
call(menu/*, { id: "123-456", name: "Device" }*/);
resolve();
}
return <div style={{zIndex:1000}} find="main">
<img src="logo.png" style={{
width: "75vw",
maxWidth: "75vh",
maxHeight: "75vh",
position: "absolute",
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
animation: `${wobel} 1s ease-in-out 0s infinite`,
}}/>
</div>;
}
export default new SWindow({ preRender: true, call, backgroundColor:"#dde"});

591
package-lock.json generated Normal file
View file

@ -0,0 +1,591 @@
{
"name": "stear",
"version": "0.5.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "stear",
"version": "0.5.0",
"license": "UNLICENSED",
"devDependencies": {
"esbuild": "^0.15.12"
}
},
"node_modules/@esbuild/android-arm": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.12.tgz",
"integrity": "sha512-IC7TqIqiyE0MmvAhWkl/8AEzpOtbhRNDo7aph47We1NbE5w2bt/Q+giAhe0YYeVpYnIhGMcuZY92qDK6dQauvA==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/@esbuild/linux-loong64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.12.tgz",
"integrity": "sha512-tZEowDjvU7O7I04GYvWQOS4yyP9E/7YlsB0jjw1Ycukgr2ycEzKyIk5tms5WnLBymaewc6VmRKnn5IJWgK4eFw==",
"cpu": [
"loong64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.12.tgz",
"integrity": "sha512-PcT+/wyDqJQsRVhaE9uX/Oq4XLrFh0ce/bs2TJh4CSaw9xuvI+xFrH2nAYOADbhQjUgAhNWC5LKoUsakm4dxng==",
"dev": true,
"hasInstallScript": true,
"bin": {
"esbuild": "bin/esbuild"
},
"engines": {
"node": ">=12"
},
"optionalDependencies": {
"@esbuild/android-arm": "0.15.12",
"@esbuild/linux-loong64": "0.15.12",
"esbuild-android-64": "0.15.12",
"esbuild-android-arm64": "0.15.12",
"esbuild-darwin-64": "0.15.12",
"esbuild-darwin-arm64": "0.15.12",
"esbuild-freebsd-64": "0.15.12",
"esbuild-freebsd-arm64": "0.15.12",
"esbuild-linux-32": "0.15.12",
"esbuild-linux-64": "0.15.12",
"esbuild-linux-arm": "0.15.12",
"esbuild-linux-arm64": "0.15.12",
"esbuild-linux-mips64le": "0.15.12",
"esbuild-linux-ppc64le": "0.15.12",
"esbuild-linux-riscv64": "0.15.12",
"esbuild-linux-s390x": "0.15.12",
"esbuild-netbsd-64": "0.15.12",
"esbuild-openbsd-64": "0.15.12",
"esbuild-sunos-64": "0.15.12",
"esbuild-windows-32": "0.15.12",
"esbuild-windows-64": "0.15.12",
"esbuild-windows-arm64": "0.15.12"
}
},
"node_modules/esbuild-android-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.12.tgz",
"integrity": "sha512-MJKXwvPY9g0rGps0+U65HlTsM1wUs9lbjt5CU19RESqycGFDRijMDQsh68MtbzkqWSRdEtiKS1mtPzKneaAI0Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-android-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.12.tgz",
"integrity": "sha512-Hc9SEcZbIMhhLcvhr1DH+lrrec9SFTiRzfJ7EGSBZiiw994gfkVV6vG0sLWqQQ6DD7V4+OggB+Hn0IRUdDUqvA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"android"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-darwin-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.12.tgz",
"integrity": "sha512-qkmqrTVYPFiePt5qFjP8w/S+GIUMbt6k8qmiPraECUWfPptaPJUGkCKrWEfYFRWB7bY23FV95rhvPyh/KARP8Q==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-darwin-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.12.tgz",
"integrity": "sha512-z4zPX02tQ41kcXMyN3c/GfZpIjKoI/BzHrdKUwhC/Ki5BAhWv59A9M8H+iqaRbwpzYrYidTybBwiZAIWCLJAkw==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-freebsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.12.tgz",
"integrity": "sha512-XFL7gKMCKXLDiAiBjhLG0XECliXaRLTZh6hsyzqUqPUf/PY4C6EJDTKIeqqPKXaVJ8+fzNek88285krSz1QECw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-freebsd-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.12.tgz",
"integrity": "sha512-jwEIu5UCUk6TjiG1X+KQnCGISI+ILnXzIzt9yDVrhjug2fkYzlLbl0K43q96Q3KB66v6N1UFF0r5Ks4Xo7i72g==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"freebsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-32": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.12.tgz",
"integrity": "sha512-uSQuSEyF1kVzGzuIr4XM+v7TPKxHjBnLcwv2yPyCz8riV8VUCnO/C4BF3w5dHiVpCd5Z1cebBtZJNlC4anWpwA==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.12.tgz",
"integrity": "sha512-QcgCKb7zfJxqT9o5z9ZUeGH1k8N6iX1Y7VNsEi5F9+HzN1OIx7ESxtQXDN9jbeUSPiRH1n9cw6gFT3H4qbdvcA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-arm": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.12.tgz",
"integrity": "sha512-Wf7T0aNylGcLu7hBnzMvsTfEXdEdJY/hY3u36Vla21aY66xR0MS5I1Hw8nVquXjTN0A6fk/vnr32tkC/C2lb0A==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.12.tgz",
"integrity": "sha512-HtNq5xm8fUpZKwWKS2/YGwSfTF+339L4aIA8yphNKYJckd5hVdhfdl6GM2P3HwLSCORS++++7++//ApEwXEuAQ==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-mips64le": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.12.tgz",
"integrity": "sha512-Qol3+AvivngUZkTVFgLpb0H6DT+N5/zM3V1YgTkryPYFeUvuT5JFNDR3ZiS6LxhyF8EE+fiNtzwlPqMDqVcc6A==",
"cpu": [
"mips64el"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-ppc64le": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.12.tgz",
"integrity": "sha512-4D8qUCo+CFKaR0cGXtGyVsOI7w7k93Qxb3KFXWr75An0DHamYzq8lt7TNZKoOq/Gh8c40/aKaxvcZnTgQ0TJNg==",
"cpu": [
"ppc64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-riscv64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.12.tgz",
"integrity": "sha512-G9w6NcuuCI6TUUxe6ka0enjZHDnSVK8bO+1qDhMOCtl7Tr78CcZilJj8SGLN00zO5iIlwNRZKHjdMpfFgNn1VA==",
"cpu": [
"riscv64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-linux-s390x": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.12.tgz",
"integrity": "sha512-Lt6BDnuXbXeqSlVuuUM5z18GkJAZf3ERskGZbAWjrQoi9xbEIsj/hEzVnSAFLtkfLuy2DE4RwTcX02tZFunXww==",
"cpu": [
"s390x"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-netbsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.12.tgz",
"integrity": "sha512-jlUxCiHO1dsqoURZDQts+HK100o0hXfi4t54MNRMCAqKGAV33JCVvMplLAa2FwviSojT/5ZG5HUfG3gstwAG8w==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"netbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-openbsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.12.tgz",
"integrity": "sha512-1o1uAfRTMIWNOmpf8v7iudND0L6zRBYSH45sofCZywrcf7NcZA+c7aFsS1YryU+yN7aRppTqdUK1PgbZVaB1Dw==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"openbsd"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-sunos-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.12.tgz",
"integrity": "sha512-nkl251DpoWoBO9Eq9aFdoIt2yYmp4I3kvQjba3jFKlMXuqQ9A4q+JaqdkCouG3DHgAGnzshzaGu6xofGcXyPXg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"sunos"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-32": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.12.tgz",
"integrity": "sha512-WlGeBZHgPC00O08luIp5B2SP4cNCp/PcS+3Pcg31kdcJPopHxLkdCXtadLU9J82LCfw4TVls21A6lilQ9mzHrw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.12.tgz",
"integrity": "sha512-VActO3WnWZSN//xjSfbiGOSyC+wkZtI8I4KlgrTo5oHJM6z3MZZBCuFaZHd8hzf/W9KPhF0lY8OqlmWC9HO5AA==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
},
"node_modules/esbuild-windows-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.12.tgz",
"integrity": "sha512-Of3MIacva1OK/m4zCNIvBfz8VVROBmQT+gRX6pFTLPngFYcj6TFH/12VveAqq1k9VB2l28EoVMNMUCcmsfwyuA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=12"
}
}
},
"dependencies": {
"@esbuild/android-arm": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.15.12.tgz",
"integrity": "sha512-IC7TqIqiyE0MmvAhWkl/8AEzpOtbhRNDo7aph47We1NbE5w2bt/Q+giAhe0YYeVpYnIhGMcuZY92qDK6dQauvA==",
"dev": true,
"optional": true
},
"@esbuild/linux-loong64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.15.12.tgz",
"integrity": "sha512-tZEowDjvU7O7I04GYvWQOS4yyP9E/7YlsB0jjw1Ycukgr2ycEzKyIk5tms5WnLBymaewc6VmRKnn5IJWgK4eFw==",
"dev": true,
"optional": true
},
"esbuild": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.15.12.tgz",
"integrity": "sha512-PcT+/wyDqJQsRVhaE9uX/Oq4XLrFh0ce/bs2TJh4CSaw9xuvI+xFrH2nAYOADbhQjUgAhNWC5LKoUsakm4dxng==",
"dev": true,
"requires": {
"@esbuild/android-arm": "0.15.12",
"@esbuild/linux-loong64": "0.15.12",
"esbuild-android-64": "0.15.12",
"esbuild-android-arm64": "0.15.12",
"esbuild-darwin-64": "0.15.12",
"esbuild-darwin-arm64": "0.15.12",
"esbuild-freebsd-64": "0.15.12",
"esbuild-freebsd-arm64": "0.15.12",
"esbuild-linux-32": "0.15.12",
"esbuild-linux-64": "0.15.12",
"esbuild-linux-arm": "0.15.12",
"esbuild-linux-arm64": "0.15.12",
"esbuild-linux-mips64le": "0.15.12",
"esbuild-linux-ppc64le": "0.15.12",
"esbuild-linux-riscv64": "0.15.12",
"esbuild-linux-s390x": "0.15.12",
"esbuild-netbsd-64": "0.15.12",
"esbuild-openbsd-64": "0.15.12",
"esbuild-sunos-64": "0.15.12",
"esbuild-windows-32": "0.15.12",
"esbuild-windows-64": "0.15.12",
"esbuild-windows-arm64": "0.15.12"
}
},
"esbuild-android-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-android-64/-/esbuild-android-64-0.15.12.tgz",
"integrity": "sha512-MJKXwvPY9g0rGps0+U65HlTsM1wUs9lbjt5CU19RESqycGFDRijMDQsh68MtbzkqWSRdEtiKS1mtPzKneaAI0Q==",
"dev": true,
"optional": true
},
"esbuild-android-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-android-arm64/-/esbuild-android-arm64-0.15.12.tgz",
"integrity": "sha512-Hc9SEcZbIMhhLcvhr1DH+lrrec9SFTiRzfJ7EGSBZiiw994gfkVV6vG0sLWqQQ6DD7V4+OggB+Hn0IRUdDUqvA==",
"dev": true,
"optional": true
},
"esbuild-darwin-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-darwin-64/-/esbuild-darwin-64-0.15.12.tgz",
"integrity": "sha512-qkmqrTVYPFiePt5qFjP8w/S+GIUMbt6k8qmiPraECUWfPptaPJUGkCKrWEfYFRWB7bY23FV95rhvPyh/KARP8Q==",
"dev": true,
"optional": true
},
"esbuild-darwin-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-darwin-arm64/-/esbuild-darwin-arm64-0.15.12.tgz",
"integrity": "sha512-z4zPX02tQ41kcXMyN3c/GfZpIjKoI/BzHrdKUwhC/Ki5BAhWv59A9M8H+iqaRbwpzYrYidTybBwiZAIWCLJAkw==",
"dev": true,
"optional": true
},
"esbuild-freebsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-64/-/esbuild-freebsd-64-0.15.12.tgz",
"integrity": "sha512-XFL7gKMCKXLDiAiBjhLG0XECliXaRLTZh6hsyzqUqPUf/PY4C6EJDTKIeqqPKXaVJ8+fzNek88285krSz1QECw==",
"dev": true,
"optional": true
},
"esbuild-freebsd-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-freebsd-arm64/-/esbuild-freebsd-arm64-0.15.12.tgz",
"integrity": "sha512-jwEIu5UCUk6TjiG1X+KQnCGISI+ILnXzIzt9yDVrhjug2fkYzlLbl0K43q96Q3KB66v6N1UFF0r5Ks4Xo7i72g==",
"dev": true,
"optional": true
},
"esbuild-linux-32": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-32/-/esbuild-linux-32-0.15.12.tgz",
"integrity": "sha512-uSQuSEyF1kVzGzuIr4XM+v7TPKxHjBnLcwv2yPyCz8riV8VUCnO/C4BF3w5dHiVpCd5Z1cebBtZJNlC4anWpwA==",
"dev": true,
"optional": true
},
"esbuild-linux-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-64/-/esbuild-linux-64-0.15.12.tgz",
"integrity": "sha512-QcgCKb7zfJxqT9o5z9ZUeGH1k8N6iX1Y7VNsEi5F9+HzN1OIx7ESxtQXDN9jbeUSPiRH1n9cw6gFT3H4qbdvcA==",
"dev": true,
"optional": true
},
"esbuild-linux-arm": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm/-/esbuild-linux-arm-0.15.12.tgz",
"integrity": "sha512-Wf7T0aNylGcLu7hBnzMvsTfEXdEdJY/hY3u36Vla21aY66xR0MS5I1Hw8nVquXjTN0A6fk/vnr32tkC/C2lb0A==",
"dev": true,
"optional": true
},
"esbuild-linux-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-arm64/-/esbuild-linux-arm64-0.15.12.tgz",
"integrity": "sha512-HtNq5xm8fUpZKwWKS2/YGwSfTF+339L4aIA8yphNKYJckd5hVdhfdl6GM2P3HwLSCORS++++7++//ApEwXEuAQ==",
"dev": true,
"optional": true
},
"esbuild-linux-mips64le": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-mips64le/-/esbuild-linux-mips64le-0.15.12.tgz",
"integrity": "sha512-Qol3+AvivngUZkTVFgLpb0H6DT+N5/zM3V1YgTkryPYFeUvuT5JFNDR3ZiS6LxhyF8EE+fiNtzwlPqMDqVcc6A==",
"dev": true,
"optional": true
},
"esbuild-linux-ppc64le": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-ppc64le/-/esbuild-linux-ppc64le-0.15.12.tgz",
"integrity": "sha512-4D8qUCo+CFKaR0cGXtGyVsOI7w7k93Qxb3KFXWr75An0DHamYzq8lt7TNZKoOq/Gh8c40/aKaxvcZnTgQ0TJNg==",
"dev": true,
"optional": true
},
"esbuild-linux-riscv64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-riscv64/-/esbuild-linux-riscv64-0.15.12.tgz",
"integrity": "sha512-G9w6NcuuCI6TUUxe6ka0enjZHDnSVK8bO+1qDhMOCtl7Tr78CcZilJj8SGLN00zO5iIlwNRZKHjdMpfFgNn1VA==",
"dev": true,
"optional": true
},
"esbuild-linux-s390x": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-linux-s390x/-/esbuild-linux-s390x-0.15.12.tgz",
"integrity": "sha512-Lt6BDnuXbXeqSlVuuUM5z18GkJAZf3ERskGZbAWjrQoi9xbEIsj/hEzVnSAFLtkfLuy2DE4RwTcX02tZFunXww==",
"dev": true,
"optional": true
},
"esbuild-netbsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-netbsd-64/-/esbuild-netbsd-64-0.15.12.tgz",
"integrity": "sha512-jlUxCiHO1dsqoURZDQts+HK100o0hXfi4t54MNRMCAqKGAV33JCVvMplLAa2FwviSojT/5ZG5HUfG3gstwAG8w==",
"dev": true,
"optional": true
},
"esbuild-openbsd-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-openbsd-64/-/esbuild-openbsd-64-0.15.12.tgz",
"integrity": "sha512-1o1uAfRTMIWNOmpf8v7iudND0L6zRBYSH45sofCZywrcf7NcZA+c7aFsS1YryU+yN7aRppTqdUK1PgbZVaB1Dw==",
"dev": true,
"optional": true
},
"esbuild-sunos-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-sunos-64/-/esbuild-sunos-64-0.15.12.tgz",
"integrity": "sha512-nkl251DpoWoBO9Eq9aFdoIt2yYmp4I3kvQjba3jFKlMXuqQ9A4q+JaqdkCouG3DHgAGnzshzaGu6xofGcXyPXg==",
"dev": true,
"optional": true
},
"esbuild-windows-32": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-32/-/esbuild-windows-32-0.15.12.tgz",
"integrity": "sha512-WlGeBZHgPC00O08luIp5B2SP4cNCp/PcS+3Pcg31kdcJPopHxLkdCXtadLU9J82LCfw4TVls21A6lilQ9mzHrw==",
"dev": true,
"optional": true
},
"esbuild-windows-64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-64/-/esbuild-windows-64-0.15.12.tgz",
"integrity": "sha512-VActO3WnWZSN//xjSfbiGOSyC+wkZtI8I4KlgrTo5oHJM6z3MZZBCuFaZHd8hzf/W9KPhF0lY8OqlmWC9HO5AA==",
"dev": true,
"optional": true
},
"esbuild-windows-arm64": {
"version": "0.15.12",
"resolved": "https://registry.npmjs.org/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.12.tgz",
"integrity": "sha512-Of3MIacva1OK/m4zCNIvBfz8VVROBmQT+gRX6pFTLPngFYcj6TFH/12VveAqq1k9VB2l28EoVMNMUCcmsfwyuA==",
"dev": true,
"optional": true
}
}
}

26
package.json Normal file
View file

@ -0,0 +1,26 @@
{
"name": "stear",
"version": "0.5.0",
"description": "A simple js/jsx based Framework",
"main": "index.js",
"directories": {
"example": "example"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"serveMenu": "esbuild example/menu/index.js --jsx-factory=s --loader:.js=jsx --loader:.html=text --bundle --minify --servedir=example/menu #--sourcemap"
},
"repository": {
"type": "git",
"url": "git+ssh://git@gitlab.com/jusax23/stear.git"
},
"author": "jusax23",
"license": "UNLICENSED",
"bugs": {
"url": "https://gitlab.com/jusax23/stear/issues"
},
"homepage": "https://gitlab.com/jusax23/stear#readme",
"devDependencies": {
"esbuild": "^0.15.12"
}
}

View file

@ -0,0 +1,55 @@
import { class_, Stear, _ } from "../../main.js";
export class loading1 extends class_{
constructor(color){
super({ class: "box" }, [
_({ style: { backgroundColor: color}}),
_({ style: { backgroundColor: color}}),
_({ style: { backgroundColor: color}}),
]);
}
}
export const l1 = (color="black") => new loading1(color);
export default l1;
var animation = Stear.addAnimation({
"0%": { left: "4%", top: "4%" },
"8.33%": { left: "52%", top: "4%" },
"25%": { left: "52%", top: "4%" },
"33.33%": { left: "52%", top: "52%" },
"50%": { left: "52%", top: "52%" },
"58.33%": { left: "4%", top: "52%" },
"75%": { left: "4%", top: "52%" },
"83.33%": { left: "4%", top: "4%" },
"100%": { left: "4%", top: "4%" },
});
Stear.addGlobalStyleJSON({
display: "inline-block",
position: "relative",
width: "80px",
height: "80px",
}, ".box");
Stear.addGlobalStyleJSON({
position: "absolute",
height: "44%",
width: "44%",
borderRadius: "25%",
animation: `${animation} 6s linear infinite`,
}, ".box div");
Stear.addGlobalStyleJSON({
animationDelay: "0s"
}, ".box div:nth-child(1)");
Stear.addGlobalStyleJSON({
animationDelay: "-2s"
}, ".box div:nth-child(2)");
Stear.addGlobalStyleJSON({
animationDelay: "-4s"
}, ".box div:nth-child(3)");

View file

@ -0,0 +1,64 @@
import { SFrame, _ } from "../../main.js";
import { fadein, fadeout, subCancel } from "../../utils.js";
const call = async (stear, { find, resolve, render, call, event }, { text, titel = "" }) => {
event.onloaded = () => {
fadein(find.main, 200, true);
find.btn._.focus();
}
event.onresolve = async () => await fadeout(find.main);
const cancel = subCancel(() => {
resolve(false);
});
return _({
find: "main",
class: "stear_alert",
style: {
position: "fixed",
left: "0",
top: "0",
height: "100%",
width: "100%",
backgroundColor: "rgba(0,0,0,0.5)"
}
}, _({
style: {
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
padding: "1rem",
paddingTop: "0",
position: "absolute",
backgroundColor: "#eee",
minHeight: "4rem",
minWidth: "8rem",
borderRadius: "1rem",
textAlign: "center"
}
}, [
_({ type: "h2", style: { marginBottom: 0 } }, titel),
_({ type: "p" }, text),
_({
type: "button",
find: "btn",
event: {
click: () => {
resolve(true);
cancel();
},
input: (e) => {
console.log(e);
}
},
style: {
borderRadius: "0.5rem",
}
}, "OK"),
]));
}
export default new SFrame({
preRender: true, call
});

View file

@ -0,0 +1,80 @@
import { SFrame, _ } from "../../main.js";
import { fadein, fadeout, subCancel } from "../../utils.js";
const call = async (stear, { find, resolve, render, call, event }, { text, autoFill = "" }) => {
event.onloaded = () => {
fadein(find.main, 200, true);
console.log(find);
find.input._.focus();
}
event.onresolve = async () => await fadeout(find.main);
const cancel = subCancel(() => {
resolve(false);
});
return _({
find: "main",
class: "stear_prompt",
style: {
position: "fixed",
left: "0",
top: "0",
height: "100%",
width: "100%",
backgroundColor: "rgba(0,0,0,0.5)"
}
}, _({
style: {
left: "50%",
top: "50%",
transform: "translate(-50%, -50%)",
padding: "1rem",
paddingTop: "0",
position: "absolute",
backgroundColor: "#eee",
minHeight: "4rem",
minWidth: "8rem",
borderRadius: "1rem",
textAlign: "center",
display: "grid",
gridGap: "0.5rem"
}
}, [
_({ type: "p", style: { gridRow: "1", gridColumn: "1/3", marginBottom: "0" } }, text),
_({
type: "input",
find: "input",
attr: { type: "text" },
event: {
keydown: (e) => {
if(e.code=="Enter")find.btn._.click();
}
},
style: {
height: "1rem",
border: "2px solid",
borderRadius: "0.5rem",
gridRow: "2",
}
}, autoFill),
_({
type: "button",
find: "btn",
event: {
click: () => {
resolve(find.input._.value);
cancel();
}
},
style: {
borderRadius: "0.5rem",
gridRow: "2",
}
}, "OK"),
]));
};
export default new SFrame({
preRender: true, call
});

View file

@ -0,0 +1,177 @@
import { SFrame, Stear, _ } from "../../main.js";
import { fadein, fadeout, wait } from "../../utils.js";
Stear.addGlobalStyleJSON({
position: "fixed",
left: "50%",
bottom: "1rem",
transform: "translate(-50%, -50%)",
textAlign: "center",
border: `2px soild transparent`,
borderRadius: "1rem",
padding: "1rem",
transition: "background-color 200ms",
backgroundColor: "#212121",
color:"#fafafa",
webkitUserSelect: "none",
},".stear_status");
const statusList = [];
var statusActive = false;
const call = async (stear, { find, resolve, render, close, call, event }, { text, color = "grey" }) => {
statusList.push({ text, color, resolve });
if (statusActive) return false;
statusActive = true;;
event.onloaded = () => {
fadein(find.main, 200, true);
};
event.onclose = async() => {
await fadeout(find.main);
};
event.onBeforRerender = async() => {
find.main.settings = { style: { backgroundColor: "#555" } };
await wait(200);
};
event.onAfterRerender = async() => {
find.main.settings = { style: { backgroundColor: "" } };
};
var next = statusList.shift();
var timeoutId = setTimeout(nextMsg,3000);
var inProgress = false;
async function nextMsg(){
if(inProgress)return;
inProgress = true;
if (timeoutId >= 0) clearTimeout(timeoutId);
timeoutId = -1;
next.resolve(null,false);
next = statusList.shift();
if(next == null){
statusActive = false;
close();
return;
}
render(false);
timeoutId = setTimeout(nextMsg, 3000);
inProgress = false;
}
return (first = true)=>_({
find: "main",
class: "stear_status",
style: {
border: "2px solid " + next.color,
backgroundColor: first ? "":"#555"
},
event: { click: nextMsg }
},next.text);
}
/*const call = async (stear, { find, resolve, render, call, event }, { text, color="grey" }) => {
async function loop(){
last = next;
next = statusList.shift();
if (next == null) return finish();
last.resolve(null, false);
find.main.settings = { style: { backgroundColor: "#555" } };
await wait(200);
find.main.settings = {
style: {
backgroundColor: "",
border: "2px solid " + next.color
}
};
find.main._.innerText = next.text;
timeoutId = setTimeout(loop,3000);
}
var timeoutId = setTimeout(loop, 3000);
find.main._.onclick = ()=>{
if(timeoutId<0)return;
clearTimeout(timeoutId);
timeoutId = -1;
loop();
};
async function finish(){
if (timeoutId >= 0)clearTimeout(timeoutId);
timeoutId = -1;
statusActive = false;
await fadeout(find.main._);
last.resolve();
}
}*/
/*const call = async (stear, { find, resolve, render, call, event }, { text, color="grey" }) => {
statusList.push({ text, color, resolve});
if (statusActive) return false;
statusActive = true;
var next = statusList.shift();
var last;
find.main.settings = {style:{
border: "2px solid " + next.color
}};
find.main._.innerText = next.text;
event.onloaded = () => fadein(find.main, 200, true);
//find.main._.style.transition = "";
async function loop(){
last = next;
next = statusList.shift();
if (next == null) return finish();
last.resolve(null, false);
find.main.settings = { style: { backgroundColor: "#555" } };
await wait(200);
find.main.settings = {
style: {
backgroundColor: "",
border: "2px solid " + next.color
}
};
find.main._.innerText = next.text;
timeoutId = setTimeout(loop,3000);
}
var timeoutId = setTimeout(loop, 3000);
find.main._.onclick = ()=>{
if(timeoutId<0)return;
clearTimeout(timeoutId);
timeoutId = -1;
loop();
};
async function finish(){
if (timeoutId >= 0)clearTimeout(timeoutId);
timeoutId = -1;
statusActive = false;
await fadeout(find.main._);
last.resolve();
}
return _({
find: "main",
class: "stear_status",
});
}*/
export default new SFrame({
preRender:true, call
});

View file

@ -0,0 +1,25 @@
import { Stear } from "../../main.js";
export const scrollBarCss1 = ({ size = "5px", background = "transparent", thumbColor = "#33a", hoverColor ="#44f"}) => {
return {
"::-webkit-scrollbar":{
width: size,
height: size,
},
"::-webkit-scrollbar-track":{
background: background,
},
"::-webkit-scrollbar-thumb":{
background: thumbColor,
borderRadius: `calc(${size} / 2)`,
},
"::-webkit-scrollbar-thumb:hover":{
background: hoverColor
}
}
};
export const applyScrollBarCss1 = ({ size = "5px", background = "transparent", thumbColor = "#33a", hoverColor = "#44f" } = {}) => {
Object.entries(scrollBarCss1({ size, background, thumbColor, hoverColor })).forEach(([k,d])=>Stear.addGlobalStyleJSON(d,k));
}

68
stear/language.js Normal file
View file

@ -0,0 +1,68 @@
export class LanguagePool {
#pool = {};
constructor() {
}
addFile(elems, lang) {
Object.entries(elems).forEach(([k, d]) => {
if (typeof this.#pool[k] == "undefined") {
this.#pool[k] = new LanguagePoolString();
}
this.#pool[k].set(d, lang);
});
}
set lang(lang) {
Object.entries(this.#pool).forEach(([k, d]) => {
d.lang = lang;
})
}
get getFile() {
var out = {};
Object.entries(this.#pool).forEach(([k, d]) => {
out[k] = d.get("default");
});
return out;
}
add(tag, defaultText = "") {
let newS = typeof this.#pool[tag] == "undefined" ? new LanguagePoolString() : this.#pool[tag];
this.#pool[tag] = newS;
newS.set(defaultText, "default");
return newS;
}
get(tag) {
return this.#pool[tag];
}
}
export class LanguagePoolString {
#value = {
};
#lang = "en";
constructor() { }
set(v, lang) {
this.#value[lang] = v;
}
get(lang) {
return this.#value[lang];
}
set lang(lang) {
this.#lang = lang;
}
r(...str) {
var out = this.#value[this.#lang] == null ? this.#value.default : this.#value[this.#lang];
for (let i = 0; i < str.length; i++) {
out = out.replace("{}", str[i]);
}
return out;
}
toString() {
return this.#value[this.#lang] == null ? this.#value.default : this.#value[this.#lang];
}
}

378
stear/main.js Normal file
View file

@ -0,0 +1,378 @@
import { LanguagePool, LanguagePoolString } from "./language.js"
var counter = 0;
var globalStyle = document.createElement("style");
document.head.appendChild(globalStyle);
String.prototype.map = Array.prototype.map;
function toCssAttr(txt){
return txt.map(d => (d.toUpperCase() === d && d !== d.toLowerCase()) ? "-" + d.toLowerCase(): d ).join("");
};
class callPromise extends Promise{
#opts = {};
constructor(cb){
super(cb);
};
set opts(opts){
this.#opts = opts;
}
get opts(){
return this.#opts;
}
}
const pools = {
};
export class Stear{
elem;
#childs = {};
constructor(elem){
this.elem = elem;
elem.style.position="relative";
}
style(css){
Object.entries(css).forEach(([k, d]) => {
this.elem.style[k] = d;
});
}
addElement (id,elem){
if(!(elem instanceof SFrame))throw new TypeError("Cannot add Element not extending from SFrame");
this.#childs[id] = elem;
}
getElement (id) {
return this.g(id);
}
g(id){
return this.#childs[id];
}
async call (elem, args, layer = 1){
return await elem.call(this, args, layer);
}
include(elem, args, renderParent, layer = 1){
return elem.call(this, args, layer, renderParent);
}
static addGlobalStyleText(text){
globalStyle.innerHTML+="\n"+text;
}
static addAnimation(steps, name = "stearAnimation_" + counter++){
Stear.addGlobalStyleText(`@keyframes ${name} {
${
Object.entries(steps).map(([k,d])=>
` ${k} {
${Object.entries(d).map(d => " " + toCssAttr(d[0]) + ": " + d[1] + ";").join("\n")}
}`).join("\n")
}
}`);
return name;
}
static addGlobalStyleJSON(json, name = ".stearClass_" + counter++){
Stear.addGlobalStyleText(`
${name} {
${Object.entries(json).map(d => " " + toCssAttr(d[0]) + ": " + d[1] + ";").join("\n")}
}
`)
return name;
}
static addLanguagePool(name){
if(typeof pools[name] == "undefined"){
pools[name] = new LanguagePool();
}
return pools[name];
}
static addLanguageFile(data,lang){
Object.entries(data).forEach(([k,d]) => {
if (typeof pools[k] == "undefined") pools[k] = new LanguagePool();
pools[k].addFile(d,lang);
});
}
static set lang (lang){
Object.entries(pools).forEach(([k, d]) => {
d.lang = lang;
});
}
static get getLanguageFile(){
var out = {};
Object.entries(pools).forEach(([k, d]) => {
out[k] = d.getFile;
});
return out;
}
}
export class SFrame{
#preRender;
#call;
constructor({ call, preRender = true }){
this.#preRender = preRender;
this.#call = call;
}
call(stear, args, layer = 1, renderParent = stear.elem){
let lastRender;
let renderElem;
let event = { onloaded: () => { }, onclose: ()=>{}, onresolve: () => { }, onBeforRerender: () => { }, onAfterRerender: () => { }, onParentRender:()=>{} };
let find = {};
let resolved = false;
async function render(args){
if(!renderElem) return;
if (lastRender) if ([...(renderParent.children)].includes(lastRender._)) renderParent.removeChild(lastRender._);
let now = renderElem;
if(typeof now == "function")now = await now();
if(!(now instanceof class_)) throw new Error("The Element to render is not an instance of class_");
await now.build(args);
renderParent.appendChild(now.render);
lastRender = now;
now._.style.zIndex = layer;
for (var member in find) delete find[member];
Object.assign(find, now.find);
return lastRender;
}
const ppp = new callPromise(async (res,rej)=>{
const options = {
find,
render: async (...args) => {
await event.onBeforRerender(...args);
if (renderElem) await render(args);
firstRender = true;
await event.onAfterRerender(...args);
return find;
},
resolve: async (r, close = true) => {
if (resolved) return;
resolved = true;
await event.onresolve();
if (close && lastRender && [...(renderParent.children)].includes(lastRender._)) renderParent.removeChild(lastRender._);
res(r);
},
call: (elem, args = {}) => {
return stear.call(elem, args, layer + 1);
},
close: async () => {
await event.onclose();
if (close && lastRender && [...(renderParent.children)].includes(lastRender._)) renderParent.removeChild(lastRender._);
},
include: (frame, args = {}) => {
let iFrame = new includeFrame(stear, frame, layer + 1, args);
return iFrame;
},
event,
};
window.queueMicrotask(() => ppp.opts = options);
let firstRender = false;
renderElem = await this.#call(stear, options, args);
if(!renderElem) {
}else{
if (this.#preRender | firstRender) await render([]);
event.onloaded();
}
});
return ppp;
}
}
export class SWindow extends SFrame{
#Frame;
constructor({ call, preRender = true, backgroundColor = "transparent"}){
var Frame = _({
style: {
top: "0px",
left: "0px",
position: "absolute",
height: "100%",
width: "100%",
display: "block",
backgroundColor,
//overflow:"scroll"
},
find:"main"
}, []);
super({
call: async(...args) => _({
style: {
top: "0px",
left: "0px",
position: "absolute",
height: "100%",
width: "100%",
display: "block",
backgroundColor,
//overflow:"scroll"
},
find: "main"
}, await call(...args)),
preRender
});
this.#Frame = Frame;
}
}
export class class_ {
#elem;
#childs;
#build;
#find;
#doBuild;
constructor(settings,childs,doBuild = true){
this.#elem = document.createElement(settings.type ?? "div");
this.#childs = childs;
var keys = Object.keys(settings);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if(key == "type"){} else if (key == "style"){
Object.entries(settings[key]).forEach(([k,d])=>{
this.#elem.style[k] = d;
});
} else if (key == "find"){
this.#find = settings[key];
} else if (key == "event"){
Object.entries(settings[key]).forEach(([k, d]) => {
this.#elem.addEventListener(k,d);
});
} else if (key == "attr"){
Object.entries(settings[key]).forEach(([k, d]) => {
this.#elem.setAttribute(k, d);
});
} else {
this.#elem.setAttribute(key,settings[key]);
}
}
this.#doBuild = doBuild;
}
set childs(childs){
if (!this.#doBuild) return;
this.#childs = Array.isArray(childs) ? childs : [childs];
}
set settings(settings){
var keys = Object.keys(settings);
for (let i = 0; i < keys.length; i++) {
const key = keys[i];
if (key == "type") { } else if (key == "style") {
Object.entries(settings[key]).forEach(([k, d]) => {
this.#elem.style[k] = d;
});
} else if (key == "find") {
this.#find = settings[key];
} else {
this.#elem.setAttribute(key, settings[key]);
}
}
}
async build (args) {
if(!this.#doBuild)return;
this.#build = [];
for (let i = 0; i < this.#childs.length; i++) {
let elem = this.#childs[i];
if (typeof elem == "function") elem = (await elem(...args))??[];
if(Array.isArray(elem)){
for (let j = 0; j < elem.length; j++) {
if (elem[j] instanceof class_) await elem[j].build(args);
}
this.#build.push(...elem);
}else{
if(elem instanceof class_)await elem.build(args);
this.#build.push(elem);
}
}
}
get render (){
if (!this.#doBuild) return this.#elem;
this.#elem.innerHTML = "";
for (let i = 0; i < this.#build.length; i++) {
const elem = this.#build[i];
if (typeof elem == "string" || elem instanceof LanguagePoolString) {
this.#elem.appendChild(document.createTextNode(String(elem)));
} else {
this.#elem.appendChild(elem.render);
}
}
return this.#elem;
}
get _ (){
return this.#elem;
}
get find (){
var out = {};
if (this.#doBuild){
this.#build.forEach(d=>{
Object.assign(out,d.find);
});
}
if (this.#find) out[this.#find]=this;
return out;
}
}
export const _ = (settings = {}, childs = []) => new class_(settings, Array.isArray(childs) ? childs : [childs]);
export const s = (type,settings,...childs)=>new class_(Object.assign(settings,{type}),childs);
class includeFrame{
#elem;
#call;
constructor(stear,frame,layer, args = {}){
this.#elem = new class_({},[],false);
this.#call = stear.include(frame, args, this.#elem._, layer);
this.#call.then(()=>{
})
.catch(()=>{
});
}
get opts(){
return this.#call.opts;
}
close(){
if(this.#call){
this.#call.opts.close();
}
}
render(settings={}){
this.#elem.settings = settings;
this.#call.opts.event.onParentRender();
return this.#elem;
}
};

75
stear/utils.js Normal file
View file

@ -0,0 +1,75 @@
import { class_ } from "./main.js";
export const wait = (ms) => {
return new Promise((res, rej) => {
setTimeout(res, ms);
});
}
export const fadeout = async (Selems, ms = 200, force = false) => {
var oldTrans = [];
if (!Array.isArray(Selems)) Selems = [Selems];
var elems = [];
for (let i = 0; i < Selems.length; i++) {
elems[i] = Selems[i] instanceof class_ ? Selems[i]._ : Selems[i];
oldTrans[i] = elems[i].style.transition;
elems[i].style.transition = `opacity ${ms}ms`;
if(force){
elems[i].style.opacity = "1";
elems[i].style.display = "";
}
}
await wait(10);
for (let i = 0; i < elems.length; i++) {
elems[i].style.opacity = "0";
}
await wait(ms);
for (let i = 0; i < elems.length; i++) {
elems[i].style.display = "none";
elems[i].style.transition = oldTrans[i];
}
}
export const fadein = async (Selems, ms = 200, force = false, display="") => {
var oldTrans = [];
if (!Array.isArray(Selems)) Selems = [Selems];
var elems = [];
for (let i = 0; i < Selems.length; i++) {
elems[i] = (Selems[i] instanceof class_) ? Selems[i]._ : Selems[i];
oldTrans[i] = elems[i].style.transition
elems[i].style.transition = `opacity ${ms}ms`;
elems[i].style.display = display;
if (force) {
elems[i].style.opacity = "0";
}
}
await wait(10);
for (let i = 0; i < elems.length; i++) {
elems[i].style.opacity = "1";
}
await wait(ms+1);
for (let i = 0; i < elems.length; i++) {
elems[i].style.transition = oldTrans[i];
}
}
var bStack = [];
export const subCancel = (callback) => {
bStack.push(callback);
return ()=>{
var id;
if ((id = bStack.indexOf(callback)) >= 0) {
bStack.splice(id, 1);
}
}
}
function back() {
if (bStack.length) {
bStack.pop()();
}
}
document.addEventListener("backbutton", back, false);
document.addEventListener('keyup', (e)=>{
if (e.code == "Escape")back();
});