visualcopium 1.0.8 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +61 -0
- package/dist/dom.d.ts +40 -0
- package/dist/index.d.ts +60 -0
- package/dist/index.js +2 -3
- package/dist/index.js.map +1 -1
- package/dist/typing.d.ts +27 -0
- package/package.json +1 -1
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>Visualcopium</h1>
|
|
3
|
+
<p>Copium for visual programmers!</p>
|
|
4
|
+
</div>
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
You don't need a silly custom language, you don't need Scratch. You need a brittle cross between semi-real code (aka JavaScript, but how real is that?) and visualness!
|
|
9
|
+
|
|
10
|
+
[(skip to installation)](#installation)
|
|
11
|
+
|
|
12
|
+
**Visualcopium** does just that! We provide separate "blocks" for both the web and Node.js/Bun, but also some generic ones. And to prove its amazingness, here's some examples:
|
|
13
|
+
|
|
14
|
+
Repeating is fun!
|
|
15
|
+
|
|
16
|
+
```javascript
|
|
17
|
+
Repeat(10 /*times*/, () => {
|
|
18
|
+
// some code that does stuff 10 times :)
|
|
19
|
+
var message = Ask("Do you wanna? ") // you can ask the user stuff!
|
|
20
|
+
Say("Here's a number anyways! " + PickRandom(1, 100)) // you can say stuff back!
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
var canBeFalseIdfk = true
|
|
24
|
+
RepeatWhile(() => canBeFalseIdfk, () => {
|
|
25
|
+
canBeFalseIdfk = false
|
|
26
|
+
Say("Yay canBeFalseIdfk is now false!")
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
RepeatWhile(false, () => { // Your condition can also directly be a boolean! Or a number, anything except 0 becomes true.
|
|
30
|
+
SayError("Bro if you can see this your computer might be broken :(")
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
Forever(() => {
|
|
34
|
+
// dude this'll NEVER stop :sob:
|
|
35
|
+
SayError("Why did you finish already? Here's an error you ajfojafjiwaifju!!")
|
|
36
|
+
|
|
37
|
+
if (KeyPressed("Escape")) {
|
|
38
|
+
SayError("There is no escape!")
|
|
39
|
+
}
|
|
40
|
+
})
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Installation
|
|
44
|
+
|
|
45
|
+
And if you're a silly person, there's an optional block that waits for this supposed page to load:
|
|
46
|
+
|
|
47
|
+
```javascript
|
|
48
|
+
WhenFlagClicked(() => {
|
|
49
|
+
// some code that does stuff AFTER the page loads...
|
|
50
|
+
})
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can either install our JavaScript (NPM) package globally, or make a lil project folder. Either way!
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npm install -g visualcopium
|
|
57
|
+
|
|
58
|
+
# ORRRR make your own lil project folder :)
|
|
59
|
+
npm init
|
|
60
|
+
npm install visualcopium
|
|
61
|
+
```
|
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Vec2n } from "./typing.js";
|
|
2
|
+
export type BrowserKey = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" | "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "Space" | "Enter" | "Backspace" | "Tab" | "Escape" | "Shift" | "Ctrl" | "Alt" | "Up Arrow" | "Down Arrow" | "Left Arrow" | "Right Arrow" | "Caps Lock" | "Delete" | "Home" | "End" | "Page Up" | "Page Down" | "Insert" | "F1" | "F2" | "F3" | "F4" | "F5" | "F6" | "F7" | "F8" | "F9" | "F10" | "F11" | "F12" | "`" | "-" | "=" | "[" | "]" | "\\" | ";" | "'" | "," | "." | "/";
|
|
3
|
+
/**
|
|
4
|
+
* Code will run once the page finishes loading.
|
|
5
|
+
* @param callback Code block/function
|
|
6
|
+
*/
|
|
7
|
+
export declare function WhenFlagClicked(callback: () => void): void;
|
|
8
|
+
/**
|
|
9
|
+
* Code will run when a specific key is pressed.
|
|
10
|
+
* @param key Key to look for
|
|
11
|
+
* @param callback Code block/function
|
|
12
|
+
*/
|
|
13
|
+
export declare function WhenKeyPressed(key: BrowserKey, callback: () => void): void;
|
|
14
|
+
/**
|
|
15
|
+
* Returns whether a specific key is pressed.
|
|
16
|
+
* @param key Key to look for
|
|
17
|
+
* @returns Whether a specific key is pressed
|
|
18
|
+
*/
|
|
19
|
+
export declare function KeyPressed(key: BrowserKey): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns whether the mouse is pressed down.
|
|
22
|
+
* @returns Whether the mouse is pressed down
|
|
23
|
+
*/
|
|
24
|
+
export declare function MouseDown(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Returns the mouse's position as a vector object. Use `MouseX();` and `MouseY();` for simplified return values!
|
|
27
|
+
* @returns Mouse's position (Vec2n)
|
|
28
|
+
*/
|
|
29
|
+
export declare function MousePosition(): Vec2n;
|
|
30
|
+
/**
|
|
31
|
+
* Return's the mouse's X position.
|
|
32
|
+
* @returns Mouse's X position
|
|
33
|
+
*/
|
|
34
|
+
export declare function MouseX(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Return's the mouse's Y position.
|
|
37
|
+
* @returns Mouse's Y position
|
|
38
|
+
*/
|
|
39
|
+
export declare function MouseY(): number;
|
|
40
|
+
//# sourceMappingURL=dom.d.ts.map
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Condition } from "./typing.js";
|
|
2
|
+
declare global {
|
|
3
|
+
interface Window {
|
|
4
|
+
VC_pressedKeys: Set<String>;
|
|
5
|
+
VC_keyPressListeners: Map<string, (() => void)[]>;
|
|
6
|
+
VC_mouseDown: boolean;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Repeats the code block/function a number of times.
|
|
11
|
+
* @param times Number of times to repeat
|
|
12
|
+
* @param callback Code block/function
|
|
13
|
+
*/
|
|
14
|
+
export declare function Repeat(times: number, callback: () => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* Repeats the code block/function until a condition is finally true.
|
|
17
|
+
* @param condition Either a code block/function that returns a boolean or an expression that evaluates to one.
|
|
18
|
+
* @param callback Code block/function
|
|
19
|
+
*/
|
|
20
|
+
export declare function RepeatUntil(condition: Condition, callback: () => void): void;
|
|
21
|
+
/**
|
|
22
|
+
* Repeats the code block/function until a condition is no longer true.
|
|
23
|
+
* @param condition Either a code block/function that returns a boolean or an expression that evaluates to one.
|
|
24
|
+
* @param callback Code block/function
|
|
25
|
+
*/
|
|
26
|
+
export declare function RepeatWhile(condition: Condition, callback: () => void): void;
|
|
27
|
+
/**
|
|
28
|
+
* Repeats the code block/function forever. Everything after will now continue while this repeats!
|
|
29
|
+
* @param callback Code block/function
|
|
30
|
+
*/
|
|
31
|
+
export declare function Forever(callback: () => void): void;
|
|
32
|
+
/**
|
|
33
|
+
* Picks random integer between a minimum and maximum (inclusive)
|
|
34
|
+
* @param minimum Minimum integer
|
|
35
|
+
* @param maximum Maximum integer
|
|
36
|
+
* @returns Random integer
|
|
37
|
+
*/
|
|
38
|
+
export declare function PickRandom(minimum: number, maximum: number): number;
|
|
39
|
+
/**
|
|
40
|
+
* Asks the user a question and waits for a response.
|
|
41
|
+
* @param message Question/message to ask
|
|
42
|
+
* @returns User's response
|
|
43
|
+
*/
|
|
44
|
+
export declare function Ask(message: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* Says a message.
|
|
47
|
+
* @param message Message to say
|
|
48
|
+
*/
|
|
49
|
+
export declare function Say(message: string): void;
|
|
50
|
+
/**
|
|
51
|
+
* Says a message in the form of a warning.
|
|
52
|
+
* @param warning Warning message to say
|
|
53
|
+
*/
|
|
54
|
+
export declare function SayWarning(warning: string): void;
|
|
55
|
+
/**
|
|
56
|
+
* Says a message in the form of an error.
|
|
57
|
+
* @param error Error message to say
|
|
58
|
+
*/
|
|
59
|
+
export declare function SayError(error: string): void;
|
|
60
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -35,12 +35,11 @@ export function RepeatWhile(condition, callback) {
|
|
|
35
35
|
callback();
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
|
-
* Repeats the code block/function forever.
|
|
38
|
+
* Repeats the code block/function forever. Everything after will now continue while this repeats!
|
|
39
39
|
* @param callback Code block/function
|
|
40
40
|
*/
|
|
41
41
|
export function Forever(callback) {
|
|
42
|
-
|
|
43
|
-
callback();
|
|
42
|
+
setInterval(callback, 0);
|
|
44
43
|
}
|
|
45
44
|
// Math
|
|
46
45
|
/**
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,UAAU;AAEV;;;;GAIG;AACH,MAAM,UAAU,MAAM,CAAC,KAAa,EAAE,QAAoB;IACzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE;QAAE,QAAQ,EAAE,CAAA;AAC3C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAoB,EAAE,QAAoB;IACrE,OACC,CAAC,CAAC,GAAG,EAAE,CACN,OAAO,SAAS,IAAI,QAAQ;QAC3B,CAAC,CAAC,SAAS,IAAI,CAAC;QAChB,CAAC,CAAC,OAAO,SAAS,IAAI,SAAS;YAC9B,CAAC,CAAC,SAAS;YACX,CAAC,CAAC,SAAS,EAAE,CAAC,EAAE;QAEnB,QAAQ,EAAE,CAAA;AACZ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,WAAW,CAAC,SAAoB,EAAE,QAAoB;IACrE,OACC,CAAC,GAAG,EAAE,CACL,OAAO,SAAS,IAAI,QAAQ;QAC3B,CAAC,CAAC,SAAS,IAAI,CAAC;QAChB,C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U,UAAU,CAAC,OAAe,EAAE,OAAe;IAC1D,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;IAC9B,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAA;AACzE,CAAC;AAED,MAAM;AAEN;;;;GAIG;AACH,MAAM,UAAU,GAAG,CAAC,OAAe;IAClC,IAAI,CAAC,OAAO,MAAM,IAAI,WAAW,IAAI,OAAO,GAAG,IAAI,WAAW,CAAC,IAAI,OAAO,MAAM,IAAI,UAAU;QAC7F,OAAO,MAAM,CAAC,OAAO,EAAE,EAAE,CAAE,CAAA;IAE5B,GAAG,CACF,2GAA2G,CAC3G,CAAA;IAED,OAAO,EAAE,CAAA;AACV,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,GAAG,CAAC,OAAe;IAClC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;AACrB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACzC,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;AACtB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAa;IACrC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AACrB,CAAC"}
|
package/dist/typing.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Defines either a code block/function that returns a boolean or an expression that evaluates to one.
|
|
3
|
+
*/
|
|
4
|
+
export type Condition = (() => boolean) | boolean | 0 | 1;
|
|
5
|
+
/**
|
|
6
|
+
* Defines a generic object type which can store two values of the same type. Look into `Vec2n` for the strictly numerical variant!
|
|
7
|
+
*/
|
|
8
|
+
export type Vec2<T> = {
|
|
9
|
+
x: T;
|
|
10
|
+
y: T;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Defines an object type containing two numbers.
|
|
14
|
+
*/
|
|
15
|
+
export type Vec2n = Vec2<number>;
|
|
16
|
+
/**
|
|
17
|
+
* Defines a generic object type which can store three values of the same type. Look into `Vec3n` for the strictly numerical variant!
|
|
18
|
+
*/
|
|
19
|
+
export type Vec3<T> = {
|
|
20
|
+
x: T;
|
|
21
|
+
y: T;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Defines an object type containing three numbers.
|
|
25
|
+
*/
|
|
26
|
+
export type Vec3n = Vec2<number>;
|
|
27
|
+
//# sourceMappingURL=typing.d.ts.map
|