@photon-os/react 1.0.0-alpha.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.
@@ -0,0 +1,26 @@
1
+ import { AppDefinition as AppDefinition$1 } from '@photon-os/sdk';
2
+
3
+ type AppBundleId = string;
4
+ type AppDefinition = {
5
+ bundleId: AppBundleId;
6
+ name: string;
7
+ author: string;
8
+ url: string;
9
+ };
10
+ type RunningAppInstance = {
11
+ definition: AppDefinition;
12
+ startedAt: Date;
13
+ isInBackground: boolean;
14
+ };
15
+
16
+ declare function useInstalledApps(): {
17
+ installedApps: AppDefinition$1[];
18
+ refresh: () => Promise<void>;
19
+ loading: boolean;
20
+ refreshing: boolean;
21
+ error: Error | null;
22
+ };
23
+
24
+ declare const VERSION = "1.0.0";
25
+
26
+ export { type AppBundleId, type AppDefinition, type RunningAppInstance, VERSION, useInstalledApps };
@@ -0,0 +1,26 @@
1
+ import { AppDefinition as AppDefinition$1 } from '@photon-os/sdk';
2
+
3
+ type AppBundleId = string;
4
+ type AppDefinition = {
5
+ bundleId: AppBundleId;
6
+ name: string;
7
+ author: string;
8
+ url: string;
9
+ };
10
+ type RunningAppInstance = {
11
+ definition: AppDefinition;
12
+ startedAt: Date;
13
+ isInBackground: boolean;
14
+ };
15
+
16
+ declare function useInstalledApps(): {
17
+ installedApps: AppDefinition$1[];
18
+ refresh: () => Promise<void>;
19
+ loading: boolean;
20
+ refreshing: boolean;
21
+ error: Error | null;
22
+ };
23
+
24
+ declare const VERSION = "1.0.0";
25
+
26
+ export { type AppBundleId, type AppDefinition, type RunningAppInstance, VERSION, useInstalledApps };
package/dist/index.js ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.tsx
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ VERSION: () => VERSION,
24
+ useInstalledApps: () => useInstalledApps
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+
28
+ // src/hooks/useInstalledApps.ts
29
+ var import_sdk = require("@photon-os/sdk");
30
+ var import_react = require("react");
31
+ function useInstalledApps() {
32
+ const [installedApps, setInstalledApps] = (0, import_react.useState)([]);
33
+ const [loading, setLoading] = (0, import_react.useState)(true);
34
+ const [refreshing, setRefreshing] = (0, import_react.useState)(true);
35
+ const [error, setError] = (0, import_react.useState)(null);
36
+ const os = new import_sdk.OS();
37
+ const refresh = async () => {
38
+ try {
39
+ setError(null);
40
+ setRefreshing(true);
41
+ setInstalledApps(await os.apps.getInstalledApps());
42
+ } catch (err) {
43
+ setError(err);
44
+ } finally {
45
+ setRefreshing(false);
46
+ setLoading(false);
47
+ }
48
+ };
49
+ (0, import_react.useEffect)(() => {
50
+ const interval = setInterval(() => {
51
+ refresh();
52
+ }, 5e3);
53
+ refresh();
54
+ return () => clearInterval(interval);
55
+ }, []);
56
+ return { installedApps, refresh, loading, refreshing, error };
57
+ }
58
+
59
+ // src/index.tsx
60
+ var VERSION = "1.0.0";
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ VERSION,
64
+ useInstalledApps
65
+ });
66
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.tsx","../src/hooks/useInstalledApps.ts"],"sourcesContent":["export const VERSION = \"1.0.0\";\n\nexport * from \"./types/app\";\nexport * from \"./hooks/useInstalledApps\";\n","import { AppDefinition, OS } from \"@photon-os/sdk\";\nimport { useEffect, useState } from \"react\";\n\nexport function useInstalledApps() {\n const [installedApps, setInstalledApps] = useState<AppDefinition[]>([]);\n const [loading, setLoading] = useState(true);\n const [refreshing, setRefreshing] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const os = new OS();\n\n const refresh = async () => {\n try {\n setError(null);\n setRefreshing(true);\n setInstalledApps(await os.apps.getInstalledApps());\n } catch (err) {\n setError(err as Error);\n } finally {\n setRefreshing(false);\n setLoading(false);\n }\n };\n\n useEffect(() => {\n const interval = setInterval(() => {\n refresh();\n }, 5000);\n\n refresh();\n\n return () => clearInterval(interval);\n }, []);\n\n return { installedApps, refresh, loading, refreshing, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,iBAAkC;AAClC,mBAAoC;AAE7B,SAAS,mBAAmB;AACjC,QAAM,CAAC,eAAe,gBAAgB,QAAI,uBAA0B,CAAC,CAAC;AACtE,QAAM,CAAC,SAAS,UAAU,QAAI,uBAAS,IAAI;AAC3C,QAAM,CAAC,YAAY,aAAa,QAAI,uBAAS,IAAI;AACjD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAuB,IAAI;AACrD,QAAM,KAAK,IAAI,cAAG;AAElB,QAAM,UAAU,YAAY;AAC1B,QAAI;AACF,eAAS,IAAI;AACb,oBAAc,IAAI;AAClB,uBAAiB,MAAM,GAAG,KAAK,iBAAiB,CAAC;AAAA,IACnD,SAAS,KAAK;AACZ,eAAS,GAAY;AAAA,IACvB,UAAE;AACA,oBAAc,KAAK;AACnB,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAEA,8BAAU,MAAM;AACd,UAAM,WAAW,YAAY,MAAM;AACjC,cAAQ;AAAA,IACV,GAAG,GAAI;AAEP,YAAQ;AAER,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,eAAe,SAAS,SAAS,YAAY,MAAM;AAC9D;;;ADlCO,IAAM,UAAU;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1,38 @@
1
+ // src/hooks/useInstalledApps.ts
2
+ import { OS } from "@photon-os/sdk";
3
+ import { useEffect, useState } from "react";
4
+ function useInstalledApps() {
5
+ const [installedApps, setInstalledApps] = useState([]);
6
+ const [loading, setLoading] = useState(true);
7
+ const [refreshing, setRefreshing] = useState(true);
8
+ const [error, setError] = useState(null);
9
+ const os = new OS();
10
+ const refresh = async () => {
11
+ try {
12
+ setError(null);
13
+ setRefreshing(true);
14
+ setInstalledApps(await os.apps.getInstalledApps());
15
+ } catch (err) {
16
+ setError(err);
17
+ } finally {
18
+ setRefreshing(false);
19
+ setLoading(false);
20
+ }
21
+ };
22
+ useEffect(() => {
23
+ const interval = setInterval(() => {
24
+ refresh();
25
+ }, 5e3);
26
+ refresh();
27
+ return () => clearInterval(interval);
28
+ }, []);
29
+ return { installedApps, refresh, loading, refreshing, error };
30
+ }
31
+
32
+ // src/index.tsx
33
+ var VERSION = "1.0.0";
34
+ export {
35
+ VERSION,
36
+ useInstalledApps
37
+ };
38
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/hooks/useInstalledApps.ts","../src/index.tsx"],"sourcesContent":["import { AppDefinition, OS } from \"@photon-os/sdk\";\nimport { useEffect, useState } from \"react\";\n\nexport function useInstalledApps() {\n const [installedApps, setInstalledApps] = useState<AppDefinition[]>([]);\n const [loading, setLoading] = useState(true);\n const [refreshing, setRefreshing] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const os = new OS();\n\n const refresh = async () => {\n try {\n setError(null);\n setRefreshing(true);\n setInstalledApps(await os.apps.getInstalledApps());\n } catch (err) {\n setError(err as Error);\n } finally {\n setRefreshing(false);\n setLoading(false);\n }\n };\n\n useEffect(() => {\n const interval = setInterval(() => {\n refresh();\n }, 5000);\n\n refresh();\n\n return () => clearInterval(interval);\n }, []);\n\n return { installedApps, refresh, loading, refreshing, error };\n}\n","export const VERSION = \"1.0.0\";\n\nexport * from \"./types/app\";\nexport * from \"./hooks/useInstalledApps\";\n"],"mappings":";AAAA,SAAwB,UAAU;AAClC,SAAS,WAAW,gBAAgB;AAE7B,SAAS,mBAAmB;AACjC,QAAM,CAAC,eAAe,gBAAgB,IAAI,SAA0B,CAAC,CAAC;AACtE,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,IAAI;AAC3C,QAAM,CAAC,YAAY,aAAa,IAAI,SAAS,IAAI;AACjD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AACrD,QAAM,KAAK,IAAI,GAAG;AAElB,QAAM,UAAU,YAAY;AAC1B,QAAI;AACF,eAAS,IAAI;AACb,oBAAc,IAAI;AAClB,uBAAiB,MAAM,GAAG,KAAK,iBAAiB,CAAC;AAAA,IACnD,SAAS,KAAK;AACZ,eAAS,GAAY;AAAA,IACvB,UAAE;AACA,oBAAc,KAAK;AACnB,iBAAW,KAAK;AAAA,IAClB;AAAA,EACF;AAEA,YAAU,MAAM;AACd,UAAM,WAAW,YAAY,MAAM;AACjC,cAAQ;AAAA,IACV,GAAG,GAAI;AAEP,YAAQ;AAER,WAAO,MAAM,cAAc,QAAQ;AAAA,EACrC,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,eAAe,SAAS,SAAS,YAAY,MAAM;AAC9D;;;AClCO,IAAM,UAAU;","names":[]}
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@photon-os/react",
3
+ "version": "1.0.0-alpha.0",
4
+ "description": "React bindings for Photon OS",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.mts",
12
+ "default": "./dist/index.mjs"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.ts",
16
+ "default": "./dist/index.js"
17
+ }
18
+ }
19
+ },
20
+ "files": [
21
+ "dist"
22
+ ],
23
+ "scripts": {
24
+ "build": "tsup",
25
+ "dev": "tsup --watch",
26
+ "prepublishOnly": "npm run build"
27
+ },
28
+ "keywords": [],
29
+ "author": "",
30
+ "license": "ISC",
31
+ "peerDependencies": {
32
+ "@photon-os/sdk": "^1.0.0-alpha.0",
33
+ "react": ">=18.0.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^19.1.0",
37
+ "react": "^19.1.0",
38
+ "tsup": "^8.5.1",
39
+ "typescript": "^5.9.3"
40
+ }
41
+ }