@tomorrowos/sdk 0.1.4 → 0.1.6
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/dist/cli.js
CHANGED
|
@@ -6,6 +6,24 @@ function packageRoot() {
|
|
|
6
6
|
const here = path.dirname(fileURLToPath(import.meta.url));
|
|
7
7
|
return path.resolve(here, "..");
|
|
8
8
|
}
|
|
9
|
+
function getSdkVersion() {
|
|
10
|
+
const pkgPath = path.join(packageRoot(), "package.json");
|
|
11
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
12
|
+
return pkg.version ?? "0.0.0";
|
|
13
|
+
}
|
|
14
|
+
/** Align generated cms-starter package.json with the installed SDK version. */
|
|
15
|
+
function patchStarterPackageJson(destDir) {
|
|
16
|
+
const pkgPath = path.join(path.resolve(destDir), "package.json");
|
|
17
|
+
if (!fs.existsSync(pkgPath))
|
|
18
|
+
return;
|
|
19
|
+
const ver = getSdkVersion();
|
|
20
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8"));
|
|
21
|
+
pkg.version = ver;
|
|
22
|
+
if (pkg.dependencies?.["@tomorrowos/sdk"]) {
|
|
23
|
+
pkg.dependencies["@tomorrowos/sdk"] = `^${ver}`;
|
|
24
|
+
}
|
|
25
|
+
fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
26
|
+
}
|
|
9
27
|
function copyStarter(destDir, force) {
|
|
10
28
|
const src = path.join(packageRoot(), "templates", "cms-starter");
|
|
11
29
|
if (!fs.existsSync(src)) {
|
|
@@ -24,7 +42,10 @@ function copyStarter(destDir, force) {
|
|
|
24
42
|
fs.mkdirSync(resolved, { recursive: true });
|
|
25
43
|
}
|
|
26
44
|
fs.cpSync(src, resolved, { recursive: true });
|
|
45
|
+
patchStarterPackageJson(resolved);
|
|
46
|
+
const sdkVer = getSdkVersion();
|
|
27
47
|
console.log(`[tomorrowos] Created CMS project at ${resolved}`);
|
|
48
|
+
console.log(`[tomorrowos] @tomorrowos/sdk dependency: ^${sdkVer}`);
|
|
28
49
|
console.log("Next: cd there, run npm install, then npm run dev");
|
|
29
50
|
}
|
|
30
51
|
function cmdBuild(argv) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tomorrowos/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "TomorrowOS CMS server SDK — WebSocket transport, pairing, device commands, optional static CMS UI. Includes CLI (tomorrowos init / build) and starter templates.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-cms",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.6",
|
|
4
4
|
"description": "CMS server on @tomorrowos/sdk. Add your UI (React, static files, etc.) alongside this server.",
|
|
5
5
|
"private": true,
|
|
6
6
|
"type": "module",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"build-player": "tomorrowos build --platform tizen"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@tomorrowos/sdk": "^0.1.
|
|
13
|
+
"@tomorrowos/sdk": "^0.1.6"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
16
|
"@types/node": "^20.0.0",
|
|
@@ -1,3 +1,26 @@
|
|
|
1
|
+
const PANEL_DEVICE_ID_KEY = "tomorrowos.panel.deviceId";
|
|
2
|
+
|
|
3
|
+
function getPanelDeviceId() {
|
|
4
|
+
return (
|
|
5
|
+
document.getElementById("deviceId")?.value?.trim() ||
|
|
6
|
+
localStorage.getItem(PANEL_DEVICE_ID_KEY) ||
|
|
7
|
+
""
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function setPanelDeviceId(deviceId) {
|
|
12
|
+
const id = String(deviceId || "").trim();
|
|
13
|
+
const el = document.getElementById("deviceId");
|
|
14
|
+
if (el) el.value = id;
|
|
15
|
+
if (id) localStorage.setItem(PANEL_DEVICE_ID_KEY, id);
|
|
16
|
+
else localStorage.removeItem(PANEL_DEVICE_ID_KEY);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
20
|
+
const saved = localStorage.getItem(PANEL_DEVICE_ID_KEY);
|
|
21
|
+
if (saved) setPanelDeviceId(saved);
|
|
22
|
+
});
|
|
23
|
+
|
|
1
24
|
async function verify() {
|
|
2
25
|
const code = document.getElementById("code").value;
|
|
3
26
|
|
|
@@ -12,12 +35,12 @@ async function verify() {
|
|
|
12
35
|
document.getElementById("result").textContent = JSON.stringify(data, null, 2);
|
|
13
36
|
|
|
14
37
|
if (data.deviceId) {
|
|
15
|
-
|
|
38
|
+
setPanelDeviceId(data.deviceId);
|
|
16
39
|
}
|
|
17
40
|
}
|
|
18
41
|
|
|
19
42
|
async function getInfo() {
|
|
20
|
-
const deviceId =
|
|
43
|
+
const deviceId = getPanelDeviceId();
|
|
21
44
|
|
|
22
45
|
if (!deviceId) {
|
|
23
46
|
alert("Please pair a device first.");
|
|
@@ -34,7 +57,7 @@ async function getInfo() {
|
|
|
34
57
|
}
|
|
35
58
|
|
|
36
59
|
async function getCapabilities() {
|
|
37
|
-
const deviceId =
|
|
60
|
+
const deviceId = getPanelDeviceId();
|
|
38
61
|
|
|
39
62
|
if (!deviceId) {
|
|
40
63
|
alert("Please pair a device first.");
|
|
@@ -50,7 +73,7 @@ async function getCapabilities() {
|
|
|
50
73
|
}
|
|
51
74
|
|
|
52
75
|
async function reboot() {
|
|
53
|
-
const deviceId =
|
|
76
|
+
const deviceId = getPanelDeviceId();
|
|
54
77
|
|
|
55
78
|
if (!deviceId) {
|
|
56
79
|
alert("Please pair a device first.");
|
|
@@ -71,7 +94,7 @@ async function reboot() {
|
|
|
71
94
|
}
|
|
72
95
|
|
|
73
96
|
async function setContent() {
|
|
74
|
-
const deviceId =
|
|
97
|
+
const deviceId = getPanelDeviceId();
|
|
75
98
|
const policyJsonText = document.getElementById("policyJson")?.value?.trim();
|
|
76
99
|
|
|
77
100
|
if (!deviceId) {
|
|
@@ -108,7 +131,7 @@ async function setContent() {
|
|
|
108
131
|
}
|
|
109
132
|
|
|
110
133
|
async function clearContent() {
|
|
111
|
-
const deviceId =
|
|
134
|
+
const deviceId = getPanelDeviceId();
|
|
112
135
|
|
|
113
136
|
if (!deviceId) {
|
|
114
137
|
alert("Please pair a device first.");
|