honeytree 1.2.3 → 1.2.4
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/package.json +1 -1
- package/src/components/ForestApp.js +4 -0
- package/src/plant.js +3 -2
- package/src/sync.js +4 -1
package/package.json
CHANGED
|
@@ -6,6 +6,7 @@ import os from "node:os";
|
|
|
6
6
|
import { execSync } from "node:child_process";
|
|
7
7
|
import { getAuth, isLoggedIn } from "../auth.js";
|
|
8
8
|
import { getRewards, syncRewards, uncelebratedUnlocked, markCelebrated } from "../rewards.js";
|
|
9
|
+
import { syncNow } from "../sync.js";
|
|
9
10
|
import UnlockCelebration from "./UnlockCelebration.js";
|
|
10
11
|
|
|
11
12
|
import ForestScene from "./ForestScene.js";
|
|
@@ -74,6 +75,9 @@ export default function ForestApp() {
|
|
|
74
75
|
useEffect(() => {
|
|
75
76
|
if (!isLoggedIn()) return;
|
|
76
77
|
let cancelled = false;
|
|
78
|
+
// Push the local forest up once on launch so the web mirror catches up
|
|
79
|
+
// even if no new tree gets planted this session.
|
|
80
|
+
syncNow().catch(() => {});
|
|
77
81
|
const pull = () =>
|
|
78
82
|
syncRewards()
|
|
79
83
|
.then((r) => {
|
package/src/plant.js
CHANGED
|
@@ -129,8 +129,9 @@ export async function tick(shape = null) {
|
|
|
129
129
|
if (badgePath) writeBadgeSVG(forest, badgePath);
|
|
130
130
|
} catch {}
|
|
131
131
|
|
|
132
|
-
// Cloud sync every
|
|
133
|
-
|
|
132
|
+
// Cloud sync on every plant (fire-and-forget) so the web dashboard, which
|
|
133
|
+
// polls every 20s, mirrors the terminal in near real time.
|
|
134
|
+
if (isLoggedIn()) {
|
|
134
135
|
syncToCloud(forest).catch(() => {});
|
|
135
136
|
}
|
|
136
137
|
|
package/src/sync.js
CHANGED
|
@@ -7,11 +7,14 @@ export async function syncToCloud(forest) {
|
|
|
7
7
|
const auth = getAuth();
|
|
8
8
|
if (!auth || !auth.access_token) return;
|
|
9
9
|
|
|
10
|
-
// Send tree data
|
|
10
|
+
// Send tree data for rendering on the web. variant ("ancient") and
|
|
11
|
+
// heightBonus must travel too, or gold/tall trees mirror as plain short ones.
|
|
11
12
|
const trees = (forest.trees || []).map((t) => ({
|
|
12
13
|
type: t.type,
|
|
13
14
|
growth: t.growth,
|
|
14
15
|
x: t.x,
|
|
16
|
+
...(t.variant ? { variant: t.variant } : {}),
|
|
17
|
+
...(t.heightBonus ? { heightBonus: t.heightBonus } : {}),
|
|
15
18
|
}));
|
|
16
19
|
|
|
17
20
|
try {
|