Skip to content

Commit 3a4e560

Browse files
committed
initial-commit from new-github-project.sh script
0 parents  commit 3a4e560

35 files changed

+6717
-0
lines changed

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
OUTPUT_FILE_NAME=example.min.js
2+
SEPARATE_CSS=false

.gitignore

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Dependencies
2+
node_modules/
3+
npm-debug.log*
4+
yarn-debug.log*
5+
yarn-error.log*
6+
7+
# Python
8+
__pycache__/
9+
*.py[cod]
10+
*$py.class
11+
*.so
12+
.Python
13+
env/
14+
venv/
15+
ENV/
16+
env.bak/
17+
venv.bak/
18+
19+
# AI/ML Models and Data
20+
*.h5
21+
*.hdf5
22+
*.pb
23+
*.pth
24+
*.pt
25+
*.ckpt
26+
*.safetensors
27+
*.bin
28+
*.onnx
29+
*.tflite
30+
*.mlmodel
31+
*.pkl
32+
*.pickle
33+
*.joblib
34+
*.model
35+
models/
36+
checkpoints/
37+
weights/
38+
data/
39+
datasets/
40+
41+
# TensorFlow
42+
*.tfrecord
43+
*.tfevents.*
44+
logs/
45+
tensorboard/
46+
47+
# Transformers.js cache
48+
.cache/
49+
cache/
50+
51+
# Environment and config
52+
.env
53+
.env.local
54+
.env.*.local
55+
config.json
56+
secrets.json
57+
58+
# IDE and OS
59+
.vscode/
60+
.idea/
61+
*.swp
62+
*.swo
63+
*~
64+
.DS_Store
65+
Thumbs.db
66+
67+
# Build outputs
68+
dist/
69+
build/
70+
*.egg-info/

.npmignore

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Development files
2+
node_modules/
3+
.env*
4+
!.env.example
5+
package-lock.json
6+
prompts/
7+
assets/
8+
dist/index.html
9+
dist/*.gif
10+
dist/*.jpg
11+
dist/*.mp3
12+
dist/*.mp4
13+
dist/*.webp
14+
dist/*.html
15+
dist/*.css
16+
17+
# Version control
18+
.git/
19+
.gitignore
20+
21+
# Documentation
22+
WARP.md
23+
GEMINI.md
24+
25+
# Source files are included, but these are not needed
26+
.DS_Store
27+
*.log

GEMINI.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Please read the LLM.md file for more information.

LLM.md

Lines changed: 161 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
# WARP.md
2+
3+
This is a vanilla js, css and html project. It uses rspack to build the files.
4+
5+
6+
7+
Please use dataroom-js for all custom html elements, and use the above features in dataroom-js. https://github.com/DATAROOM-NETWORK/dataroom.js
8+
9+
Basic Usage
10+
To use DataroomElement, you can either use it directly in your HTML or extend it to create your own custom components.
11+
12+
Extending DataroomElement
13+
import DataroomElement from 'dataroom-js';
14+
15+
class MyComponent extends DataroomElement {
16+
async initialize() {
17+
// Your initialization logic here
18+
}
19+
}
20+
21+
customElements.define('my-component', MyComponent);
22+
Features
23+
create(type, attributes, target_el)
24+
Creates a new HTML element and appends it to the component or a specified target.
25+
26+
Example:
27+
28+
class MyComponent extends DataroomElement {
29+
async initialize() {
30+
const container = this.create('div', { class: 'container' });
31+
this.create('p', { content: 'Hello, World!' }, container);
32+
}
33+
}
34+
event(name, detail)
35+
Emits a custom event from the component.
36+
37+
Example:
38+
39+
class MyComponent extends DataroomElement {
40+
async initialize() {
41+
this.event('my-event', { foo: 'bar' });
42+
}
43+
}
44+
45+
const myComponent = document.querySelector('my-component');
46+
myComponent.addEventListener('my-event', (e) => {
47+
console.log(e.detail); // { foo: 'bar' }
48+
});
49+
on(name, cb) and once(name, cb)
50+
Attaches an event listener to the component. once is a variant that fires the listener only one time.
51+
52+
on Example:
53+
54+
class MyComponent extends DataroomElement {
55+
async initialize() {
56+
this.on('my-event', (detail) => {
57+
console.log('This will be logged every time:', detail);
58+
});
59+
60+
this.event('my-event', { foo: 'bar' });
61+
this.event('my-event', { foo: 'baz' });
62+
}
63+
}
64+
once Example:
65+
66+
class MyComponent extends DataroomElement {
67+
async initialize() {
68+
this.once('one-time-event', (detail) => {
69+
console.log('This will only be logged once:', detail);
70+
});
71+
72+
// Firing the event multiple times
73+
this.event('one-time-event', { attempt: 1 });
74+
this.event('one-time-event', { attempt: 2 });
75+
}
76+
}
77+
call(endpoint, body)
78+
A helper for making fetch requests. It includes features for handling different security schemes and request timeouts.
79+
80+
security-scheme Attribute
81+
Determines the authentication method:
82+
83+
localstorage: (Default) Sends a bearer token from localStorage.
84+
cookie: Relies on the browser to send cookies automatically.
85+
Example:
86+
87+
<my-component security-scheme="localstorage"></my-component>
88+
// In your component
89+
const data = await this.call('/api/data');
90+
call-timeout Attribute
91+
Sets a timeout for the request in milliseconds.
92+
93+
Example:
94+
95+
<my-component call-timeout="5000"></my-component>
96+
getJSON(url)
97+
Fetches a JSON file from a URL, parses it, and returns it as a JavaScript object. It includes robust error handling for network issues, bad HTTP statuses, and JSON parsing errors.
98+
99+
Example:
100+
101+
class JsonComponent extends DataroomElement {
102+
async initialize() {
103+
try {
104+
// Public APIs are great for examples
105+
const data = await this.getJSON('https://jsonplaceholder.typicode.com/users/1');
106+
this.log(`Fetched user: ${data.name}`);
107+
this.innerHTML = `Hello, ${data.name}!`;
108+
} catch (error) {
109+
console.error(error);
110+
this.innerHTML = `Failed to fetch data: ${error.message}`;
111+
}
112+
}
113+
}
114+
log(message)
115+
Logs a message to the console if the verbose attribute is set.
116+
117+
Example:
118+
119+
<my-component verbose="true"></my-component>
120+
class MyComponent extends DataroomElement {
121+
async initialize() {
122+
this.log('Initializing component...');
123+
}
124+
}
125+
Lifecycle Methods
126+
DataroomElement provides several lifecycle methods that you can override to control the component's behavior.
127+
128+
initialize(): Called after the component is connected to the DOM and its attributes are available.
129+
disconnect(): Called when the component is removed from the DOM.
130+
Example:
131+
132+
class MyComponent extends DataroomElement {
133+
async initialize() {
134+
console.log('Component initialized!');
135+
}
136+
137+
async disconnect() {
138+
console.log('Component disconnected!');
139+
}
140+
}
141+
Attribute Observation
142+
DataroomElement automatically observes attribute changes and fires a NODE-CHANGED event.
143+
144+
Example:
145+
146+
class MyComponent extends DataroomElement {
147+
async initialize() {
148+
this.on('NODE-CHANGED', (detail) => {
149+
console.log(detail.attribute, detail.newValue);
150+
});
151+
}
152+
}
153+
154+
const myComponent = document.querySelector('my-component');
155+
myComponent.setAttribute('foo', 'bar'); // Logs: foo bar
156+
157+
We do not use shadowdom.
158+
159+
We do not embedd CSS in our Javascript -- we have separate CSS for that. If you think you need a CSS for a component, create a new CSS file in the styles/ folder with the name of the component and import it via the index.css file.
160+
161+
We use DockBlock style comments for all code.

0 commit comments

Comments
 (0)