@stage5/lumine 0.2.11 → 0.2.12
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/lib/assets.js +12 -3
- package/lib/thumbnail.js +1 -1
- package/package.json +1 -1
package/lib/assets.js
CHANGED
|
@@ -81,8 +81,17 @@ export function resolveGenerateModel(options) {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
export function formatBatteryPercent(energyUnits, fullBatteryUnits) {
|
|
84
|
-
const total = Number(fullBatteryUnits)
|
|
85
|
-
const
|
|
84
|
+
const total = Number(fullBatteryUnits);
|
|
85
|
+
const units = Number(energyUnits);
|
|
86
|
+
if (
|
|
87
|
+
!Number.isFinite(total) ||
|
|
88
|
+
total <= 0 ||
|
|
89
|
+
!Number.isFinite(units) ||
|
|
90
|
+
units < 0
|
|
91
|
+
) {
|
|
92
|
+
return "unavailable";
|
|
93
|
+
}
|
|
94
|
+
const percent = (units / total) * 100;
|
|
86
95
|
if (percent <= 0) return "~0%";
|
|
87
96
|
if (percent < 1) return "<1%";
|
|
88
97
|
return `~${Math.round(percent)}%`;
|
|
@@ -201,7 +210,7 @@ export async function assetsGenerate(options) {
|
|
|
201
210
|
const remaining = result?.aiUsagePolicy?.energyRemaining;
|
|
202
211
|
if (Number.isFinite(Number(remaining))) {
|
|
203
212
|
console.log(
|
|
204
|
-
`Battery remaining: ${formatBatteryPercent(Number(remaining), result?.aiUsagePolicy?.
|
|
213
|
+
`Battery remaining: ${formatBatteryPercent(Number(remaining), result?.aiUsagePolicy?.baseEnergyUnitsPerDay)}`,
|
|
205
214
|
);
|
|
206
215
|
}
|
|
207
216
|
console.log(
|
package/lib/thumbnail.js
CHANGED
|
@@ -324,7 +324,7 @@ export async function thumbnailGenerate(options) {
|
|
|
324
324
|
const remaining = result?.aiUsagePolicy?.energyRemaining;
|
|
325
325
|
if (Number.isFinite(Number(remaining))) {
|
|
326
326
|
console.log(
|
|
327
|
-
`Battery remaining: ${formatBatteryPercent(Number(remaining), result?.aiUsagePolicy?.
|
|
327
|
+
`Battery remaining: ${formatBatteryPercent(Number(remaining), result?.aiUsagePolicy?.baseEnergyUnitsPerDay)}`,
|
|
328
328
|
);
|
|
329
329
|
}
|
|
330
330
|
}
|