@prozilla-os/media-viewer 1.0.1
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/LICENSE.md +21 -0
- package/README.md +77 -0
- package/dist/assets/main.css +1 -0
- package/dist/main.d.ts +11 -0
- package/dist/main.js +24 -0
- package/dist/main.js.map +1 -0
- package/package.json +47 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Sieben De Beule
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<br />
|
|
3
|
+
<p>
|
|
4
|
+
<a href="https://os.prozilla.dev/"><img src="https://os.prozilla.dev/assets/logo.svg?v=2" height="200" alt="ProzillaOS" /></a>
|
|
5
|
+
</p>
|
|
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>
|
|
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
|
+
</p>
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
## About
|
|
15
|
+
|
|
16
|
+
`@prozilla-os/media-viewer` is a ProzillaOS application for viewing different kinds of media.
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
19
|
+
|
|
20
|
+
`@prozilla-os/core` is required to run this application.
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
$ npm install @prozilla-os/core @prozilla-os/media-viewer
|
|
24
|
+
$ yarn add @prozilla-os/core @prozilla-os/media-viewer
|
|
25
|
+
$ pnpm add @prozilla-os/core @prozilla-os/media-viewer
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
### Basic setup
|
|
31
|
+
|
|
32
|
+
```tsx
|
|
33
|
+
import { Desktop, ModalsView, ProzillaOS, Taskbar, WindowsView, AppsConfig } from "@prozilla-os/core";
|
|
34
|
+
import { mediaViewer } from "@prozilla-os/media-viewer";
|
|
35
|
+
|
|
36
|
+
function App() {
|
|
37
|
+
return (
|
|
38
|
+
<ProzillaOS
|
|
39
|
+
systemName="Example"
|
|
40
|
+
tagLine="Powered by ProzillaOS"
|
|
41
|
+
config={{
|
|
42
|
+
apps: new AppsConfig({
|
|
43
|
+
apps: [ mediaViewer ]
|
|
44
|
+
})
|
|
45
|
+
}}
|
|
46
|
+
>
|
|
47
|
+
<Taskbar/>
|
|
48
|
+
<WindowsView/>
|
|
49
|
+
<ModalsView/>
|
|
50
|
+
<Desktop/>
|
|
51
|
+
</ProzillaOS>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Window options
|
|
57
|
+
|
|
58
|
+
```tsx
|
|
59
|
+
/**
|
|
60
|
+
* A virtual file containing media to open
|
|
61
|
+
*/
|
|
62
|
+
file: VirtualFile;
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Links
|
|
66
|
+
|
|
67
|
+
- [Website/demo][website]
|
|
68
|
+
- [GitHub][github]
|
|
69
|
+
- [npm][npm]
|
|
70
|
+
- [Discord][discord]
|
|
71
|
+
- [Ko-fi][ko-fi]
|
|
72
|
+
|
|
73
|
+
[website]: https://os.prozilla.dev/media-viewer
|
|
74
|
+
[github]: https://github.com/prozilla-os/ProzillaOS/tree/convert-to-monorepo/packages/apps/media-viewer
|
|
75
|
+
[npm]: https://www.npmjs.com/package/@prozilla-os/media-viewer
|
|
76
|
+
[discord]: https://discord.gg/JwbyQP4tdz
|
|
77
|
+
[ko-fi]: https://ko-fi.com/prozilla
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
._MediaViewer_12qrj_1{display:flex;justify-content:center;align-items:center;width:100%;height:100%;padding:2rem}._MediaViewer_12qrj_1 img{width:100%;height:100%;object-fit:contain}
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { App } from '@prozilla-os/core';
|
|
2
|
+
import { VirtualFile } from '@prozilla-os/core';
|
|
3
|
+
import { WindowProps } from '@prozilla-os/core';
|
|
4
|
+
|
|
5
|
+
export declare const mediaViewer: App<MediaViewerProps>;
|
|
6
|
+
|
|
7
|
+
declare interface MediaViewerProps extends WindowProps {
|
|
8
|
+
file?: VirtualFile;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { }
|
package/dist/main.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useSystemManager as p, useWindowsManager as u, AppsConfig as a, IMAGE_EXTENSIONS as t, App as c } from "@prozilla-os/core";
|
|
2
|
+
import { jsx as i } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect as l } from "react";
|
|
4
|
+
import './assets/main.css';const m = "_MediaViewer_12qrj_1", f = {
|
|
5
|
+
MediaViewer: m
|
|
6
|
+
};
|
|
7
|
+
function w({ file: e, close: n, setTitle: r }) {
|
|
8
|
+
const { appsConfig: d } = p(), s = u();
|
|
9
|
+
if (l(() => {
|
|
10
|
+
e != null && (r == null || r(e.id));
|
|
11
|
+
}, [e, r]), e == null) {
|
|
12
|
+
const o = d.getAppByRole(a.APP_ROLES.FileExplorer);
|
|
13
|
+
setTimeout(() => {
|
|
14
|
+
o != null && (s == null || s.open(o.id, { path: "~/Pictures" })), n == null || n();
|
|
15
|
+
}, 10);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
return e.extension == null || !t.includes(e.extension) ? /* @__PURE__ */ i("p", { children: "Invalid file format." }) : e.source == null ? /* @__PURE__ */ i("p", { children: "File failed to load." }) : /* @__PURE__ */ i("div", { className: f.MediaViewer, children: /* @__PURE__ */ i("img", { src: e.source, alt: e.id, draggable: "false" }) });
|
|
19
|
+
}
|
|
20
|
+
const A = new c("Media Viewer", "media-viewer", w).setIconUrl("https://os.prozilla.dev/assets/apps/icons/media-viewer.svg").setRole(a.APP_ROLES.MediaViewer).setAssociatedExtensions(t);
|
|
21
|
+
export {
|
|
22
|
+
A as mediaViewer
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/components/MediaViewer.tsx","../src/main.ts"],"sourcesContent":["import { useEffect } from \"react\";\r\nimport styles from \"./MediaViewer.module.css\";\r\nimport { AppsConfig, IMAGE_EXTENSIONS, useSystemManager, useWindowsManager, VirtualFile, WindowProps } from \"@prozilla-os/core\";\r\n\r\nexport interface MediaViewerProps extends WindowProps {\r\n\tfile?: VirtualFile;\r\n}\r\n\r\nexport function MediaViewer({ file, close, setTitle }: MediaViewerProps) {\r\n\tconst { appsConfig } = useSystemManager();\r\n\tconst windowsManager = useWindowsManager();\r\n\r\n\tuseEffect(() => {\r\n\t\tif (file != null) setTitle?.(file.id);\r\n\t}, [file, setTitle]);\r\n\r\n\tif (file == null) {\r\n\t\tconst fileExplorerApp = appsConfig.getAppByRole(AppsConfig.APP_ROLES.FileExplorer);\r\n\r\n\t\tsetTimeout(() => {\r\n\t\t\tif (fileExplorerApp != null)\r\n\t\t\t\twindowsManager?.open(fileExplorerApp.id, { path: \"~/Pictures\" });\r\n\t\t\tclose?.();\r\n\t\t}, 10);\r\n\t\treturn;\r\n\t}\r\n\r\n\tif (file.extension == null || !IMAGE_EXTENSIONS.includes(file.extension)) return <p>Invalid file format.</p>;\r\n\r\n\tif (file.source == null) return <p>File failed to load.</p>;\r\n\r\n\treturn <div className={styles.MediaViewer}>\r\n\t\t<img src={file.source} alt={file.id} draggable=\"false\"/>\r\n\t</div>;\r\n}","import { App, AppsConfig, IMAGE_EXTENSIONS } from \"@prozilla-os/core\";\r\nimport { MediaViewer, MediaViewerProps } from \"./components/MediaViewer\";\r\n\r\nconst mediaViewer = new App<MediaViewerProps>(\"Media Viewer\", \"media-viewer\", MediaViewer)\r\n\t.setIconUrl(\"https://os.prozilla.dev/assets/apps/icons/media-viewer.svg\")\r\n\t.setRole(AppsConfig.APP_ROLES.MediaViewer)\r\n\t.setAssociatedExtensions(IMAGE_EXTENSIONS);\r\n\r\nexport { mediaViewer };"],"names":["MediaViewer","file","close","setTitle","appsConfig","useSystemManager","windowsManager","useWindowsManager","useEffect","fileExplorerApp","AppsConfig","IMAGE_EXTENSIONS","jsx","styles","mediaViewer","App"],"mappings":";;;;;;AAQO,SAASA,EAAY,EAAE,MAAAC,GAAM,OAAAC,GAAO,UAAAC,KAA8B;AAClE,QAAA,EAAE,YAAAC,MAAeC,KACjBC,IAAiBC;AAMvB,MAJAC,EAAU,MAAM;AACf,IAAIP,KAAQ,SAAiBE,KAAA,QAAAA,EAAAF,EAAK;AAAA,EAAE,GAClC,CAACA,GAAME,CAAQ,CAAC,GAEfF,KAAQ,MAAM;AACjB,UAAMQ,IAAkBL,EAAW,aAAaM,EAAW,UAAU,YAAY;AAEjF,eAAW,MAAM;AAChB,MAAID,KAAmB,SACtBH,KAAA,QAAAA,EAAgB,KAAKG,EAAgB,IAAI,EAAE,MAAM,kBAC1CP,KAAA,QAAAA;AAAA,OACN,EAAE;AACL;AAAA,EACD;AAEA,SAAID,EAAK,aAAa,QAAQ,CAACU,EAAiB,SAASV,EAAK,SAAS,IAAW,gBAAAW,EAAA,KAAA,EAAE,UAAoB,uBAAA,CAAA,IAEpGX,EAAK,UAAU,OAAa,gBAAAW,EAAC,OAAE,UAAoB,uBAAA,CAAA,IAE/C,gBAAAA,EAAA,OAAA,EAAI,WAAWC,EAAO,aAC7B,UAAC,gBAAAD,EAAA,OAAA,EAAI,KAAKX,EAAK,QAAQ,KAAKA,EAAK,IAAI,WAAU,SAAO,EACvD,CAAA;AACD;AC/BA,MAAMa,IAAc,IAAIC,EAAsB,gBAAgB,gBAAgBf,CAAW,EACvF,WAAW,4DAA4D,EACvE,QAAQU,EAAW,UAAU,WAAW,EACxC,wBAAwBC,CAAgB;"}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@prozilla-os/media-viewer",
|
|
3
|
+
"description": "A ProzillaOS application for viewing different kinds of media.",
|
|
4
|
+
"version": "1.0.1",
|
|
5
|
+
"homepage": "https://os.prozilla.dev/media-viewer",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Prozilla",
|
|
8
|
+
"email": "business@prozilla.dev",
|
|
9
|
+
"url": "https://prozilla.dev/"
|
|
10
|
+
},
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "dist/main.js",
|
|
13
|
+
"types": "dist/main.d.ts",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git+https://github.com/prozilla-os/ProzillaOS.git",
|
|
17
|
+
"directory": "packages/apps/media-viewer"
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"react": "^18.3.1",
|
|
22
|
+
"@prozilla-os/core": "1.0.15"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^20.14.5",
|
|
26
|
+
"@types/react": "^18.3.3",
|
|
27
|
+
"@vitejs/plugin-react-swc": "^3.7.0",
|
|
28
|
+
"typescript": "^5.4.5",
|
|
29
|
+
"vite": "^5.3.1",
|
|
30
|
+
"vite-plugin-dts": "^3.9.1",
|
|
31
|
+
"vite-plugin-lib-inject-css": "^2.1.1",
|
|
32
|
+
"@prozilla-os/shared": "1.0.2"
|
|
33
|
+
},
|
|
34
|
+
"files": [
|
|
35
|
+
"dist"
|
|
36
|
+
],
|
|
37
|
+
"sideEffects": [
|
|
38
|
+
"**/*.css"
|
|
39
|
+
],
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"registry": "https://registry.npmjs.org/",
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc && vite build"
|
|
46
|
+
}
|
|
47
|
+
}
|