docs: Added Vector2 class page

This commit is contained in:
Prozilla 2024-07-09 18:06:32 +02:00
parent 522612148c
commit 308a42976e
No known key found for this signature in database
GPG key ID: 5858DFE71CAF31EE
14 changed files with 324 additions and 28 deletions

3
.npmrc
View file

@ -1,2 +1,3 @@
git-checks=false
node-linker=hoisted
node-linker=hoisted
ignore-workspace-root-check=true

View file

@ -15,6 +15,7 @@
"build": "pnpm run packages:build && pnpm run docs:build && pnpm run site:build",
"predeploy": "rimraf dist",
"deploy": "pnpm run docs:build && pnpm run docs:stage && pnpm run site:deploy",
"publish": "pnpm vite-node packages/demo/scripts/deploy",
"site:start": "pnpm --filter prozilla-os-demo run start",
"site:build": "pnpm --filter prozilla-os-demo run build",
"site:preview": "pnpm --filter prozilla-os-demo run preview",
@ -38,6 +39,9 @@
"type": "git",
"url": "git+https://github.com/Prozilla/ProzillaOS.git"
},
"dependencies": {
"pnpm": "^9.5.0"
},
"devDependencies": {
"@changesets/cli": "^2.27.5",
"@eslint/js": "^9.5.0",
@ -67,5 +71,5 @@
"last 1 safari version"
]
},
"packageManager": "pnpm@9.1.4"
"packageManager": "pnpm@9.5.0"
}

View file

@ -1,10 +1,14 @@
import { defineConfig } from "vitepress";
import { defineConfig, HeadConfig } from "vitepress";
const TITLE = "ProzillaOS Docs";
const DESCRIPTION = "Documentation for ProzillaOS and its packages.";
const LOCALE = "en_US";
const IMAGE = "https://os.prozilla.dev/assets/logo.png";
// https://vitepress.dev/reference/site-config
export default defineConfig({
title: "ProzillaOS Docs",
description: "Documentation for ProzillaOS and its packages.",
title: TITLE,
description: DESCRIPTION,
srcDir: "src",
@ -50,8 +54,7 @@ export default defineConfig({
base: "/reference/",
items: [
{
text: "Reference",
collapsed: false,
text: "Overview",
items: [
{ text: "Configuration", link: "/configuration" },
]
@ -64,6 +67,7 @@ export default defineConfig({
{
text: "System",
base: "/reference/classes/system/",
collapsed: true,
items: [
{ text: "App", link: "app" },
{ text: "AppsConfig", link: "apps-config" },
@ -76,6 +80,14 @@ export default defineConfig({
{ text: "WindowsConfig", link: "windows-config" },
]
},
{
text: "Utils",
base: "/reference/classes/utils/",
collapsed: true,
items: [
{ text: "Vector2", link: "vector2" },
]
},
]
}
]
@ -90,9 +102,17 @@ export default defineConfig({
editLink: {
pattern: "https://github.com/prozilla-os/ProzillaOS/edit/main/packages/docs/src/:path",
text: "Edit this page on GitHub"
text: "Suggest changes to this page"
},
// lastUpdated: {
// text: "Updated at",
// formatOptions: {
// dateStyle: "short",
// timeStyle: "short"
// }
// },
socialLinks: [
{ icon: "github", link: "https://github.com/prozilla-os/ProzillaOS" },
{ icon: "discord", link: "https://discord.gg/JwbyQP4tdz" },
@ -110,5 +130,37 @@ export default defineConfig({
message: "Built by <strong><a href=\"https://prozilla.dev/\" target=\"_blank\">Prozilla</a></strong>",
copyright: "Copyright &copy; 2023-present Prozilla"
},
}
},
transformPageData(pageData) {
pageData.frontmatter.head ??= [] as HeadConfig[];
const head = pageData.frontmatter.head as HeadConfig[];
const title = pageData.frontmatter.layout === "home"
? TITLE
: `${pageData.title} | ${TITLE}`;
head.push(["meta", { name: "og:title", content: title }]);
head.push(["meta", { name: "twitter:title", content: title }]);
const description = pageData.frontmatter.description as string ?? DESCRIPTION;
head.push(["meta", { name: "og:description", content: description }]);
head.push(["meta", { name: "twitter:description", content: description }]);
const canonicalUrl = `https://os.prozilla.dev/docs/${pageData.relativePath}`
.replace(/index\.md$/, "")
.replace(/\.(md|html)$/, "");
head.push(["link", { rel: "canonical", href: canonicalUrl }]);
head.push(["meta", { name: "og:url", content: canonicalUrl }]);
head.push(["meta", { name: "twitter:url", content: canonicalUrl }]);
const locale = LOCALE;
head.push(["meta", { name: "og:locale", content: locale }]);
const image = pageData.frontmatter.image as string ?? IMAGE;
head.push(["meta", { name: "og:image", content: image }]);
head.push(["meta", { name: "twitter:image", content: image }]);
// Other meta data
head.push(["meta", { name: "og:type", content: "website" }]);
},
});

View file

@ -272,6 +272,10 @@
* Custom styles
* -------------------------------------------------------------------------- */
.custom-block {
border: none;
border-left: 5px solid;
}
.custom-block > .custom-block-title {
display: flex;
@ -308,3 +312,12 @@
.custom-block.warning {
--icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z'/%3E%3C/svg%3E")
}
.VPTeamMembers.center {
display: flex;
justify-content: center;
}
.VPTeamMembers.center .container {
flex: 1;
}

View file

@ -0,0 +1,98 @@
import { ANSI } from "../../core/src/constants";
import { name } from "../package.json";
import { resolve } from "node:path";
import fs from "node:fs";
const OUTPUT_DIR = "cache";
function getItemType(key: string, value: unknown): string | null {
if (/^[A-Z_]+$/.test(key))
return "Constant";
if (typeof value === "function") {
if (/^use([A-Z][a-z]*)+$/.test(key)) {
return "Hook";
} else if (/^[a-z]+([A-Z][a-z]*)+$/.test(key)) {
return "Function";
} else if (/^([A-Z][a-z]*)+$/.test(key)) {
return "Class";
}
}
return null;
}
function generateContent(key: string, value: unknown, type: string): string {
const content = [
"---",
"outline: deep",
"---"
];
content.push(`\n# ${type}`);
return content.join("\n");
}
function generateReferencePage(key: string, value: unknown) {
const type = getItemType(key, value);
if (type == null) return;
let directory = "/";
switch (type) {
case "Constant":
directory = "/constants";
break;
case "Hook":
directory = "/hooks";
break;
case "Function":
directory = "/functions";
break;
case "Class":
directory = "/classes";
break;
}
try {
const path = resolve(__dirname, OUTPUT_DIR, directory);
if (!fs.existsSync(path)){
fs.mkdirSync(path, { recursive: true });
}
// fs.writeFileSync(path, generateContent(key, value, type), { flag: "w+" });
console.log(`- ${ANSI.fg.cyan}${path}${ANSI.reset}`);
} catch (error) {
console.log(`${ANSI.fg.red}⚠ Failed to generate page: ${key}${ANSI.reset}`);
}
}
async function generateReferencePages() {
try {
console.log(`Context: ${ANSI.decoration.bold}${name}${ANSI.reset}\n`);
console.log(`${ANSI.fg.yellow}Generating reference pages...${ANSI.reset}`);
const items = await import("packages/core/src/main");
for (const key in module) {
if (module.hasOwnProperty(key)) {
const item = module[key];
console.log(`Name: ${key}, Type: ${typeof item}, Source: ${modulePath}`);
}
}
// for (const [key, value] of Object.entries(items)) {
// generateReferencePage(key, value);
// }
console.log(`\n${ANSI.fg.green}✓ Completed generating reference pages${ANSI.reset}`);
} catch (error) {
console.error(error);
console.log(`${ANSI.fg.red}⚠ Reference pages generation failed${ANSI.reset}`);
process.exit(1);
}
}
generateReferencePages();

View file

@ -21,7 +21,7 @@ hero:
features:
- title: TypeScript
details: ProzillaOS is powered by TypeScript's type-safety.
details: ProzillaOS is powered by TypeScript"s type-safety.
icon: <svg fill="none" height="26" viewBox="0 0 27 26" width="27" xmlns="http://www.w3.org/2000/svg"><path clip-rule="evenodd" d="m.98608 0h24.32332c.5446 0 .9861.436522.9861.975v24.05c0 .5385-.4415.975-.9861.975h-24.32332c-.544597 0-.98608-.4365-.98608-.975v-24.05c0-.538478.441483-.975.98608-.975zm13.63142 13.8324v-2.1324h-9.35841v2.1324h3.34111v9.4946h2.6598v-9.4946zm1.0604 9.2439c.4289.2162.9362.3784 1.5218.4865.5857.1081 1.2029.1622 1.8518.1622.6324 0 1.2331-.0595 1.8023-.1784.5691-.1189 1.0681-.3149 1.497-.5879s.7685-.6297 1.0187-1.0703.3753-.9852.3753-1.6339c0-.4703-.0715-.8824-.2145-1.2365-.1429-.3541-.3491-.669-.6186-.9447-.2694-.2757-.5925-.523-.9692-.7419s-.8014-.4257-1.2743-.6203c-.3465-.1406-.6572-.2771-.9321-.4095-.275-.1324-.5087-.2676-.7011-.4054-.1925-.1379-.3409-.2838-.4454-.4379-.1045-.154-.1567-.3284-.1567-.523 0-.1784.0467-.3392.1402-.4824.0935-.1433.2254-.2663.3959-.369s.3794-.1824.6269-.2392c.2474-.0567.5224-.0851.8248-.0851.22 0 .4523.0162.697.0486.2447.0325.4908.0825.7382.15.2475.0676.4881.1527.7218.2555.2337.1027.4495.2216.6475.3567v-2.4244c-.4015-.1514-.84-.2636-1.3157-.3365-.4756-.073-1.0214-.1095-1.6373-.1095-.6268 0-1.2207.0662-1.7816.1987-.5609.1324-1.0544.3392-1.4806.6203s-.763.6392-1.0104 1.0743c-.2475.4352-.3712.9555-.3712 1.5609 0 .7731.2268 1.4326.6805 1.9785.4537.546 1.1424 1.0082 2.0662 1.3866.363.146.7011.2892 1.0146.4298.3134.1405.5842.2865.8124.4378.2282.1514.4083.3162.5403.4946s.198.3811.198.6082c0 .1676-.0413.323-.1238.4662-.0825.1433-.2076.2676-.3753.373s-.3766.1879-.6268.2473c-.2502.0595-.5431.0892-.8785.0892-.5719 0-1.1383-.0986-1.6992-.2959-.5608-.1973-1.0805-.4933-1.5589-.8879z" fill="var(--vp-c-text-1)" fill-rule="evenodd"></path></svg>
- title: Modular
details: ProzillaOS can be installed as separate modules with extensive customization.
@ -33,3 +33,33 @@ features:
linkText: Learn more
---
<script setup>
import {
VPTeamPage,
VPTeamPageTitle,
VPTeamMembers,
VPTeamPageSection
} from "vitepress/theme"
const developers = [
{
avatar: "https://prozilla.dev/media/Prozilla.svg",
name: "Prozilla",
title: "Creator",
links: [
{ icon: "twitter", link: "https://twitter.com/prozilladev" },
{ icon: "linkedin", link: "https://linkedin.com/in/sieben-de-beule" },
{ icon: "instagram", link: "https://instagram.com/prozilladev" },
{ icon: "youtube", link: "https://www.youtube.com/c/prozilla" },
],
sponsor: "https://ko-fi.com/prozilla"
},
]
</script>
<VPTeamPage>
<VPTeamPageTitle>
<template #title>Developers</template>
</VPTeamPageTitle>
<VPTeamMembers class="center" size="small" :members="developers" />
</VPTeamPage>

View file

@ -1,5 +1,6 @@
---
outline: deep
description: "An application that can be run by ProzillaOS"
---
# Class [`App`](https://github.com/prozilla-os/ProzillaOS/blob/main/packages/core/src/features/system/configs/app.tsx)
@ -24,9 +25,9 @@ Applications can be installed by adding them to the `apps` array in [`AppsConfig
- **windowContent** : `React.FC<AppProps>`
- **windowOptions** : `object`
- **windowOptions** : `object` (optional)
- windowOptions.size : `Vector2`
- windowOptions.size : [`Vector2`](/reference/classes/utils/vector2)
## Properties
@ -63,7 +64,7 @@ You can extend this object with any properties
#### Properties
- windowOptions.size : `Vector2`
- windowOptions.size : [`Vector2`](/reference/classes/utils/vector2)
### description : `string | null` {#description}

View file

@ -14,12 +14,12 @@ outline: deep
#### options
- options.defaultDialogSize : `Vector2`
- options.defaultFileSelectorSize : `Vector2`
- options.defaultDialogSize : [`Vector2`](/reference/classes/utils/vector2)
- options.defaultFileSelectorSize : [`Vector2`](/reference/classes/utils/vector2)
## Properties
### defaultDialogSize : `Vector2` {#default-dialog-size}
### defaultDialogSize : [`Vector2`](/reference/classes/utils/vector2) {#default-dialog-size}
Default size of a dialog box
@ -29,7 +29,7 @@ Default size of a dialog box
> new Vector2(400, 200)
> ```
### defaultFileSelectorSize : `Vector2` {#default-file-selector-size}
### defaultFileSelectorSize : [`Vector2`](/reference/classes/utils/vector2) {#default-file-selector-size}
Default size of a file selector

View file

@ -16,7 +16,7 @@ outline: deep
- options.screenMargin : `number`
- options.titleSeparator : `string`
- options.minScreenSize : `Vector2`
- options.minScreenSize : [`Vector2`](/reference/classes/utils/vector2)
## Properties
@ -38,7 +38,7 @@ A string that is placed between different parts of a window title
> "-"
> ```
### minScreenSize : `Vector2` {#min-screen-size}
### minScreenSize : [`Vector2`](/reference/classes/utils/vector2) {#min-screen-size}
If the user's screen is smaller than these values, windows will always be maximized

View file

@ -0,0 +1,83 @@
---
outline: deep
---
# Class [`Vector2`](https://github.com/prozilla-os/ProzillaOS/blob/main/packages/core/src/features/math/vector2.ts)
## Constructor
> `new Vector2(x, y)`
### Parameters
- **x** : `number`
- **y** : `number` (optional)
> [!TIP]
> If you leave out the parameter `y`, the properties `x` and `y` will be set to the same value, e.g.:
>
> ```ts
> new Vector2(10) --> new Vector2(10, 10)
> ```
## Properties
### x : `number` {#x}
### y : `number` {#y}
### ZERO : `Vector2` <Badge type="info" text="static"/> {#zero}
Returns a vector with each value set to zero
> ```ts
> Vector2.ZERO --> new Vector2(0, 0)
> ```
### clone : `Vector2` {#clone}
Returns a clone of this vector
## Methods
### round () => `this` {#round}
Round the values of this vector to full numbers
> ```ts
> new Vector2(3.6, 1.3) --> new Vector2(4, 1)
> ```
### getDistance (x : `number`, y : `number`) => `number` {#get-distance}
### getDistance (vector2 : `Vector2`) => `number`
Get the distance between this vector and another
### add (vector2A : `Vector2`, vector2B: `Vector2`) => `Vector2` <Badge type="info" text="static"/> {#add}
Add two vectors together
### subtract (vector2A : `Vector2`, vector2B: `Vector2`) => `Vector2` <Badge type="info" text="static"/> {#subtract}
Subtract two vectors
### scale (vector2 : `Vector2`, scalar: `number`) => `Vector2` <Badge type="info" text="static"/> {#scale}
Scale a vector
### magnitude (vector2 : `Vector2`) => `number` <Badge type="info" text="static"/> {#magnitude}
Get the magnitude of a vector
### normalize (vector2 : `Vector2`) => `Vector2` <Badge type="info" text="static"/> {#normalize}
Get the magnitude of a vector
### sqrDistance (vector2A : `Vector2`, vector2B : `Vector2`) => `number` <Badge type="info" text="static"/> {#sqr-distance}
Get the square distance of two vectors
### lerp (vector2A : `Vector2`, vector2B : `Vector2`, t : `number`) => `Vector2` <Badge type="info" text="static"/> {#lerp}
Lerp between two vectors

View file

@ -6,9 +6,9 @@ outline: deep
To configure ProzillaOS, pass the following properties inside to the `config` prop on the `<ProzillaOS>` component.
## `<ProzillaOS>` props
## `<ProzillaOS>` props {#prozillaos}
### systemName : `string`
### systemName : `string` {#system-name}
<br>
@ -18,7 +18,7 @@ To configure ProzillaOS, pass the following properties inside to the `config` pr
> "ProzillaOS"
> ```
### tagLine : `string`
### tagLine : `string` {#tag-line}
<br>

View file

@ -0,0 +1,8 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "../..",
},
"include": ["src", ".vitepress", "scripts", "vite.config.ts"],
"exclude": ["node_modules"]
}

View file

@ -1,5 +0,0 @@
{
"entryPoints": ["../core/src/main.ts"],
"out": "cache",
"plugin": ["typedoc-plugin-markdown"],
}

View file

@ -7,6 +7,10 @@ settings:
importers:
.:
dependencies:
pnpm:
specifier: ^9.5.0
version: 9.5.0
devDependencies:
'@changesets/cli':
specifier: ^2.27.5
@ -3129,6 +3133,11 @@ packages:
resolution: {integrity: sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==}
engines: {node: '>=8'}
pnpm@9.5.0:
resolution: {integrity: sha512-FAA2gwEkYY1iSiGHtQ0EKJ1aCH8ybJ7fwMzXM9dsT1LDoxPU/BSHlKKp2BVTAWAE5nQujPhQZwJopzh/wiDJAw==}
engines: {node: '>=18.12'}
hasBin: true
possible-typed-array-names@1.0.0:
resolution: {integrity: sha512-d7Uw+eZoloe0EHDIYoe+bQ5WXnGMOpmiZFTuMWCwpjzzkL2nTjcKiAk4hh8TjnGye2TwWOk3UXucZ+3rbmBa8Q==}
engines: {node: '>= 0.4'}
@ -6758,6 +6767,8 @@ snapshots:
dependencies:
find-up: 4.1.0
pnpm@9.5.0: {}
possible-typed-array-names@1.0.0: {}
postcss-resolve-nested-selector@0.1.1: {}