@prozilla-os/dev-tools 1.1.14 → 1.1.17

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 CHANGED
@@ -4,9 +4,9 @@
4
4
  <a href="https://os.prozilla.dev/"><img src="https://os.prozilla.dev/assets/logo.svg?v=2" height="200" alt="ProzillaOS" /></a>
5
5
  </p>
6
6
  <p>
7
- <a href="https://github.com/prozilla-os/ProzillaOS/blob/main/LICENSE.md"><img alt="License" src="https://img.shields.io/github/license/Prozilla/ProzillaOS?style=flat-square&color=FF4D5B&label=License"></a>
8
- <a href="https://github.com/prozilla-os/ProzillaOS"><img alt="Stars" src="https://img.shields.io/github/stars/Prozilla/ProzillaOS?style=flat-square&color=FED24C&label=%E2%AD%90"></a>
9
- <a href="https://github.com/prozilla-os/ProzillaOS"><img alt="Forks" src="https://img.shields.io/github/forks/Prozilla/ProzillaOS?style=flat-square&color=4D9CFF&label=Forks&logo=github"></a>
7
+ <a href="https://github.com/prozilla-os/ProzillaOS/blob/main/LICENSE"><img alt="License" src="https://img.shields.io/github/license/prozilla-os/ProzillaOS?style=flat-square&color=FF4D5B&label=License"></a>
8
+ <a href="https://github.com/prozilla-os/ProzillaOS"><img alt="Stars" src="https://img.shields.io/github/stars/prozilla-os/ProzillaOS?style=flat-square&color=FED24C&label=%E2%AD%90"></a>
9
+ <a href="https://github.com/prozilla-os/ProzillaOS"><img alt="Forks" src="https://img.shields.io/github/forks/prozilla-os/ProzillaOS?style=flat-square&color=4D9CFF&label=Forks&logo=github"></a>
10
10
  <a href="https://www.npmjs.com/package/prozilla-os"><img alt="NPM Version" src="https://img.shields.io/npm/v/prozilla-os?logo=npm&style=flat-square&label=prozilla-os&color=FF4D5B"></a>
11
11
  </p>
12
12
  </div>
package/dist/main.d.ts CHANGED
@@ -1,185 +1,53 @@
1
- import { FC } from 'react';
2
- import { JSX as JSX_2 } from 'react/jsx-runtime';
3
- import { Plugin as Plugin_2 } from 'rollup';
4
- import { Plugin as Plugin_3 } from 'vite';
1
+ import { AppsConfig } from '@prozilla-os/core';
2
+ import { Plugin as Plugin_2 } from 'vite';
3
+ import { PluginOption } from 'vite';
5
4
  import { TestAPI } from 'vitest';
6
5
  import { UserConfig } from 'vite';
7
6
 
8
7
  /**
9
- * An application that can be ran by ProzillaOS.
10
- *
11
- * Applications can be installed by adding them to {@link AppsConfig.apps}.
12
- * @typeParam AppProps - The props of the {@link windowContent} of this app.
8
+ * Vite plugin that automatically adds metadata to ProzillaOS apps.
13
9
  */
14
- declare class App<AppProps extends WindowProps = WindowProps> {
15
- /**
16
- * The display name of this application.
17
- */
18
- name: string;
19
- /**
20
- * The unique ID of this application.
21
- */
22
- id: string;
23
- /**
24
- * Main component that renders this app inside a window.
25
- */
26
- windowContent: FC<AppProps> | null;
27
- /**
28
- * Default options that get passed to the {@link App.windowContent} component.
29
- */
30
- windowOptions?: Partial<AppProps> & DefaultWindowOptions;
31
- /**
32
- * Description of this application.
33
- */
34
- description: string | null;
35
- /**
36
- * URL of the icon of this application.
37
- */
38
- iconUrl: string | null;
39
- /**
40
- * Defines what the app can handle and how it can be used elsewhere in the system.
41
- */
42
- role: string | null;
43
- /**
44
- * An array of file extensions that this application can interpret.
45
- */
46
- associatedExtensions: string[];
47
- /**
48
- * Determines whether the app is pinned by default.
49
- * @default true
50
- */
51
- pinnedByDefault: boolean;
52
- /**
53
- * Determines whether the app is launched at startup.
54
- * @default false
55
- */
56
- launchAtStartup: boolean;
57
- /**
58
- * The category the app belongs to.
59
- */
60
- category: typeof APP_CATEGORIES[number] | null;
61
- /**
62
- * Metadata of the app's package.
63
- */
64
- metadata: AppMetadata | null;
65
- /**
66
- * Determines whether a desktop icon is added to the default data.
67
- * @default false
68
- */
69
- showDesktopIcon: boolean;
70
- isActive: boolean;
71
- isPinned?: boolean;
72
- isInstalled: boolean;
73
- constructor(name: App["name"], id: App["id"], windowContent: App<AppProps>["windowContent"], windowOptions?: Partial<AppProps> & DefaultWindowOptions);
74
- /**
75
- * Returns the component that renders the content of a window for this app.
76
- */
77
- WindowContent: (props: AppProps) => JSX_2.Element | null;
78
- /**
79
- * Sets the display name of this application.
80
- */
81
- setName(name: string): this;
82
- /**
83
- * Sets the description of this application.
84
- */
85
- setDescription(description: App["description"]): this;
86
- /**
87
- * Sets the URL of the icon of this application.
88
- */
89
- setIconUrl(iconUrl: App["iconUrl"]): this;
90
- /**
91
- * Sets the role of this application.
92
- */
93
- setRole(role: string | null): this;
94
- /**
95
- * Sets the associated extensions of this application.
96
- */
97
- setAssociatedExtensions(extensions: string[] | null): this;
98
- /**
99
- * Changes whether this application is pinned by default or not.
100
- */
101
- setPinnedByDefault(pinnedByDefault: boolean): this;
102
- /**
103
- * Changes whether this application is launched at startup or not.
104
- */
105
- setLaunchAtStartup(launchAtStartup: boolean): this;
106
- /**
107
- * Changes whether this application is installed by default or not.
108
- */
109
- setInstalled(installed: boolean): this;
110
- /**
111
- * Sets the category this application belongs to.
112
- */
113
- setCategory(category: typeof APP_CATEGORIES[number] | null): this;
114
- /**
115
- * Sets the metadata for this application.
116
- */
117
- setMetadata(metadata: AppMetadata | null): this;
118
- /**
119
- * Changes whether this application has a desktop icon in the default data.
120
- */
121
- setShowDesktopIcon(showDesktopIcon: boolean): this;
122
- /**
123
- * Sets the default options for the {@link App.windowContent} component.
124
- */
125
- setWindowOptions(windowOptions: Partial<AppProps> & DefaultWindowOptions): this;
126
- }
10
+ export declare function appMetadataPlugin({ entryPath, appClass }: AppMetadataPluginOptions): Plugin_2;
127
11
 
128
- declare const APP_CATEGORIES: readonly ["Business", "Developer tools", "Education", "Entertainment", "Food & dining", "Health & fitness", "Kids & family", "Lifestyle", "Media", "Medical", "Multimedia design", "Music", "Navigation & maps", "News & weather", "Personal finance", "Personalization", "Photo & video", "Productivity", "Security", "Shopping", "Social", "Sports", "Travel", "Utilities & tools"];
129
-
130
- declare interface AppMetadata {
131
- name: string;
132
- version: `${number}.${number}.${number}`;
133
- author: string;
134
- }
135
-
136
- export declare function appMetadataPlugin({ entryPath, appClass }: AppMetadataPluginOptions): Plugin_3;
137
-
138
- declare interface AppMetadataPluginOptions {
12
+ export declare interface AppMetadataPluginOptions {
13
+ /** Path to the app's entry file, relative to the project root. */
139
14
  entryPath: string;
15
+ /** Name of the app class. Defaults to `"App"`. */
140
16
  appClass?: string;
141
17
  }
142
18
 
143
- declare class AppsConfig {
144
- apps: AppsConfigOptions["apps"];
145
- static APP_ROLES: {
146
- fileExplorer: string;
147
- terminal: string;
148
- textEditor: string;
149
- settings: string;
150
- mediaViewer: string;
151
- browser: string;
152
- };
153
- constructor(options?: Partial<AppsConfigOptions>);
154
- get installedApps(): App<WindowProps>[];
155
- /**
156
- * @param id - The ID of the app.
157
- * @param includeUninstalled - Include apps that are not currently installed.
158
- */
159
- getAppById(id: string, includeUninstalled?: boolean): App | null;
160
- /**
161
- * Get the app associated with a file extension.
162
- */
163
- getAppByFileExtension(fileExtension: string): App | null;
164
- /**
165
- * Get the app with a specific role.
166
- */
167
- getAppByRole(role: string): App | null;
168
- /**
169
- * Get all applications (including uninstalled apps) that belong to a category.
170
- */
171
- getAppsByCategory(category: typeof APP_CATEGORIES[number]): App[];
172
- }
19
+ /**
20
+ * Vite plugin for building ProzillaOS apps.
21
+ * @example
22
+ * ```ts
23
+ * import { defineConfig } from "vite";
24
+ * import { appPlugin } from "@prozilla-os/dev-tools";
25
+ *
26
+ * export default defineConfig({
27
+ * plugins: [appPlugin({ entryPath: "src/main.ts" })],
28
+ * });
29
+ * ```
30
+ */
31
+ export declare function appPlugin(options: AppPluginOptions): PluginOption[];
173
32
 
174
- declare interface AppsConfigOptions {
175
- /**
176
- * An array of applications.
177
- */
178
- apps: App<WindowProps>[];
33
+ export declare interface AppPluginOptions {
34
+ /** Path to the app's entry file, relative to the project root. */
35
+ entryPath: string;
36
+ /** CSS class name for the app's root element. */
37
+ appClass?: string;
38
+ /** Path to the TypeScript config for the build. Defaults to `"tsconfig.build.json"`. */
39
+ tsconfigPath?: string;
40
+ /** Shared packages to mark as external. Defaults to {@link DEFAULT_SHARED_PACKAGES}. */
41
+ sharedPackages?: SharedPackage[];
42
+ /** Additional external patterns (strings or RegExps) beyond the shared package specifiers. */
43
+ externalPatterns?: (string | RegExp)[];
179
44
  }
180
45
 
181
46
  /**
182
47
  * Creates a Vite configuration for ProzillaOS apps.
48
+ *
49
+ * @deprecated Use {@link appPlugin} instead.
50
+ *
183
51
  * @param basePath - The path of the base directory.
184
52
  * @param entryPath - The path of the library entry.
185
53
  * @returns The Vite configuration.
@@ -192,10 +60,7 @@ export declare interface CustomTestAPI {
192
60
  cases: <A extends unknown[] = [], R = undefined>(func: (...args: A) => R, cases: [A, R][]) => void;
193
61
  }
194
62
 
195
- declare interface DefaultWindowOptions {
196
- size?: Vector2;
197
- [key: string]: unknown;
198
- }
63
+ export declare const DEFAULT_SHARED_PACKAGES: SharedPackage[];
199
64
 
200
65
  /**
201
66
  * Extends Vitest's {@link TestAPI} with functions from the {@link CustomTestAPI}.
@@ -211,11 +76,47 @@ export declare function extend(test: TestAPI): ExtendedTestAPI;
211
76
  export declare type ExtendedTestAPI = TestAPI & CustomTestAPI;
212
77
 
213
78
  /**
214
- * @deprecated Use {@link Logger} instead.
79
+ * Vite plugin that generates an import map in order to support dynamically installing apps into ProzillaOS.
80
+ */
81
+ export declare function importMapPlugin(options?: ImportMapPluginOptions): PluginOption;
82
+
83
+ export declare interface ImportMapPluginOptions {
84
+ /** Packages to expose via import map. Defaults to {@link DEFAULT_SHARED_PACKAGES}. */
85
+ sharedPackages?: SharedPackage[];
86
+ /** Dev-mode import map overrides for packages not handled by CommonJS shims. */
87
+ devImports?: Record<string, string>;
88
+ }
89
+
90
+ /**
91
+ * @deprecated Use {@link @prozilla-os/shared!Logger | Logger} instead.
215
92
  */
216
93
  declare function print_2(message: string, status?: Status, newLine?: boolean): void;
217
94
  export { print_2 as print }
218
95
 
96
+ export declare interface SharedPackage {
97
+ /** Package specifier (e.g. `"react"`, `"@prozilla-os/core"`). */
98
+ specifier: string;
99
+ /**
100
+ * When set, the package is treated as a manual chunk with this name.
101
+ * When omitted, the package's pre-built entry file is emitted as a
102
+ * static asset for the import map. Chunk-name packages are bundled
103
+ * naturally by Rollup in the site build; asset packages are served
104
+ * directly from disk to dynamically-loaded apps.
105
+ */
106
+ chunkName?: string;
107
+ /** When `true`, a CJS-to-ESM shim is generated for the package's chunk. */
108
+ isCommonJS?: boolean;
109
+ }
110
+
111
+ /**
112
+ * Vite plugin that combines `@vitejs/plugin-react-swc`, {@link importMapPlugin} and {@link stageSitePlugin}.
113
+ *
114
+ * This plugin can be used to build a website with ProzillaOS.
115
+ */
116
+ export declare function sitePlugin(options: SitePluginOptions): PluginOption[];
117
+
118
+ export declare type SitePluginOptions = StageOptions & ImportMapPluginOptions;
119
+
219
120
  export declare interface StageOptions {
220
121
  appsConfig: AppsConfig;
221
122
  /**
@@ -245,98 +146,11 @@ export declare interface StageOptions {
245
146
  imageUrls?: string[];
246
147
  }
247
148
 
149
+ /**
150
+ * Vite plugin that prepares the build of a website that uses ProzillaOS.
151
+ */
248
152
  export declare function stageSitePlugin(options: StageOptions): Plugin_2;
249
153
 
250
154
  export declare type Status = "error" | "info" | "file" | "success" | "start";
251
155
 
252
- declare class Vector2 {
253
- x: number;
254
- y: number;
255
- constructor(xy: number);
256
- constructor(x: number, y?: number);
257
- static get ZERO(): Vector2;
258
- get clone(): Vector2;
259
- get magnitude(): number;
260
- setX(x: number): this;
261
- setY(y: number): this;
262
- set(x: number, y: number): this;
263
- round(): this;
264
- normalize(): this;
265
- scale(scalar: number): this;
266
- getDistanceSquared(x: number, y?: number): number;
267
- getDistanceSquared(vector2: Vector2): number;
268
- getDistance(x: number, y?: number): number;
269
- getDistance(vector2: Vector2): number;
270
- add(x: number, y?: number): this;
271
- add(vector2: Vector2): this;
272
- subtract(x: number, y?: number): this;
273
- subtract(vector2: Vector2): this;
274
- multiply(x: number, y?: number): this;
275
- multiply(vector2: Vector2): this;
276
- divide(x: number, y?: number): this;
277
- divide(vector2: Vector2): this;
278
- lerp(vector2: Vector2, t: number): this;
279
- static sum(vector2A: Vector2, vector2B: Vector2): Vector2;
280
- static difference(vector2A: Vector2, vector2B: Vector2): Vector2;
281
- static product(vector2A: Vector2, vector2B: Vector2): Vector2;
282
- static division(vector2A: Vector2, vector2B: Vector2): Vector2;
283
- static scale(vector2: Vector2, scalar: number): Vector2;
284
- static normalize(vector2: Vector2): Vector2;
285
- static lerp(vector2A: Vector2, vector2B: Vector2, t: number): Vector2;
286
- static from({ x, y }: {
287
- x: number;
288
- y: number;
289
- }): Vector2;
290
- static parseVector(x: number | Vector2, y?: number): {
291
- x: number;
292
- y: number;
293
- };
294
- }
295
-
296
- declare interface WindowOptions {
297
- /** The ID of the window. */
298
- id?: string;
299
- /** The app associated with the window. */
300
- app?: App;
301
- /**
302
- * The size of the window.
303
- * @default new Vector2(700, 400)
304
- */
305
- size?: Vector2;
306
- /** The position of the window. */
307
- position?: Vector2;
308
- fullscreen?: boolean | string;
309
- options?: object;
310
- isFocused?: boolean;
311
- lastInteraction?: number;
312
- minimized?: boolean;
313
- [key: string]: unknown;
314
- }
315
-
316
- declare interface WindowProps extends WindowOptions {
317
- /**
318
- * Whether to start the window in fullscreen mode.
319
- * @default false
320
- */
321
- fullscreen?: boolean;
322
- /** Function that sets the title of the window. */
323
- setTitle?: React.Dispatch<React.SetStateAction<string>>;
324
- /** Function that sets the icon URL of the window. */
325
- setIconUrl?: React.Dispatch<React.SetStateAction<string>>;
326
- /** Function that closes the window. */
327
- close?: (event?: Event | React.UIEvent<HTMLElement>) => void;
328
- /** Function that brings the window in focus. */
329
- focus?: (event?: Event | React.UIEvent<HTMLElement>, force?: boolean) => void;
330
- /** Whether the window is currently focused and should allow interactions. */
331
- active?: boolean;
332
- /** Whether to start the window in minimized mode. */
333
- minimized?: boolean;
334
- /** Function that toggles the minimized mode of the window. */
335
- toggleMinimized?: (event?: Event) => void;
336
- /** The depth value of the window. */
337
- index?: number;
338
- /** Whether the window is in standalone mode. */
339
- standalone?: boolean;
340
- }
341
-
342
156
  export { }