@glassly/engine 0.3.5-beta.760 → 0.3.5-beta.775
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/build/engine.d.ts +3 -0
- package/build/engine.d.ts.map +1 -1
- package/build/facades/memory.d.ts +10 -2
- package/build/facades/memory.d.ts.map +1 -1
- package/build/facades/memory.js +10 -0
- package/build/facades/memory.js.map +1 -1
- package/build/generated/releaseMetadata.js +3 -3
- package/build/generated/releaseMetadata.js.map +1 -1
- package/build/services/BlobStore.js +3 -3
- package/build/services/BlobStore.js.map +1 -1
- package/build/services/ForegroundLocationPermission.d.ts +1 -1
- package/build/services/ForegroundLocationPermission.d.ts.map +1 -1
- package/build/services/ForegroundLocationPermission.js.map +1 -1
- package/build/services/LocalMiniappRuntime.d.ts +4 -2
- package/build/services/LocalMiniappRuntime.d.ts.map +1 -1
- package/build/services/LocalMiniappRuntime.js +51 -11
- package/build/services/LocalMiniappRuntime.js.map +1 -1
- package/build/services/MemoryStore.d.ts +13 -1
- package/build/services/MemoryStore.d.ts.map +1 -1
- package/build/services/MemoryStore.js +98 -1
- package/build/services/MemoryStore.js.map +1 -1
- package/build/services/manifestActions.d.ts +1 -1
- package/build/services/manifestActions.d.ts.map +1 -1
- package/build/services/manifestActions.js +3 -2
- package/build/services/manifestActions.js.map +1 -1
- package/build/services/memoryBackupFile.d.ts +9 -0
- package/build/services/memoryBackupFile.d.ts.map +1 -0
- package/build/services/memoryBackupFile.js +47 -0
- package/build/services/memoryBackupFile.js.map +1 -0
- package/build/services/widgetPlacements.d.ts +8 -7
- package/build/services/widgetPlacements.d.ts.map +1 -1
- package/build/services/widgetPlacements.js +7 -6
- package/build/services/widgetPlacements.js.map +1 -1
- package/build/types/applet.d.ts +3 -1
- package/build/types/applet.d.ts.map +1 -1
- package/build/types/applet.js.map +1 -1
- package/package.json +9 -9
- package/src/facades/memory.ts +11 -2
- package/src/generated/releaseMetadata.ts +3 -3
- package/src/services/BlobStore.ts +3 -3
- package/src/services/ForegroundLocationPermission.ts +1 -1
- package/src/services/LocalMiniappRuntime.ts +56 -11
- package/src/services/MemoryStore.ts +111 -2
- package/src/services/manifestActions.ts +10 -3
- package/src/services/memoryBackupFile.ts +50 -0
- package/src/services/widgetPlacements.ts +23 -9
- package/src/types/applet.ts +3 -1
|
@@ -96,6 +96,8 @@ import { listPhoneCalendarEvents, PhoneCalendarError } from "./PhoneCalendarServ
|
|
|
96
96
|
import { LocalMiniappStorage } from "./LocalMiniappStorage";
|
|
97
97
|
import { captureDecisionFor } from "./MemoryCapture";
|
|
98
98
|
import { memoryStore } from "./memoryStoreInstance";
|
|
99
|
+
import { exportMemoryFile, importMemoryFile } from "./memoryBackupFile";
|
|
100
|
+
import { MemoryBackupError } from "./MemoryStore";
|
|
99
101
|
import { speakerProfileStore } from "./speakerProfileStoreInstance";
|
|
100
102
|
/** Streams that carry speech text and so have a cloud route and an on-device route. */
|
|
101
103
|
const isSpeechTextStream = (stream) => stream.startsWith("transcription:") || stream.startsWith("translation:");
|
|
@@ -1317,6 +1319,8 @@ class LocalMiniappRuntime {
|
|
|
1317
1319
|
case MiniappRequestType.MEMORY_QUERY:
|
|
1318
1320
|
case MiniappRequestType.MEMORY_WINDOW:
|
|
1319
1321
|
case MiniappRequestType.MEMORY_EXPORT_TEXT:
|
|
1322
|
+
case MiniappRequestType.MEMORY_EXPORT_FILE:
|
|
1323
|
+
case MiniappRequestType.MEMORY_IMPORT_FILE:
|
|
1320
1324
|
case MiniappRequestType.MEMORY_SUMMARY_ADD:
|
|
1321
1325
|
case MiniappRequestType.MEMORY_SUMMARY_LIST:
|
|
1322
1326
|
case MiniappRequestType.MEMORY_PENDING_SUMMARY_HOUR:
|
|
@@ -3463,6 +3467,14 @@ class LocalMiniappRuntime {
|
|
|
3463
3467
|
this.sendResult(packageName, requestId, true, { text: await memoryStore.exportText(scope, num(payload.at)) });
|
|
3464
3468
|
return;
|
|
3465
3469
|
}
|
|
3470
|
+
case MiniappRequestType.MEMORY_EXPORT_FILE: {
|
|
3471
|
+
this.sendResult(packageName, requestId, true, await exportMemoryFile());
|
|
3472
|
+
return;
|
|
3473
|
+
}
|
|
3474
|
+
case MiniappRequestType.MEMORY_IMPORT_FILE: {
|
|
3475
|
+
this.sendResult(packageName, requestId, true, { imported: await importMemoryFile() });
|
|
3476
|
+
return;
|
|
3477
|
+
}
|
|
3466
3478
|
case MiniappRequestType.MEMORY_SUMMARY_ADD: {
|
|
3467
3479
|
const hourStart = num(payload.hourStart);
|
|
3468
3480
|
if (hourStart == null || typeof payload.text !== "string") {
|
|
@@ -3499,6 +3511,13 @@ class LocalMiniappRuntime {
|
|
|
3499
3511
|
}
|
|
3500
3512
|
}
|
|
3501
3513
|
catch (err) {
|
|
3514
|
+
if (err instanceof MemoryBackupError) {
|
|
3515
|
+
this.sendResult(packageName, requestId, false, undefined, {
|
|
3516
|
+
code: MiniappErrorCode.INVALID_ARGUMENT,
|
|
3517
|
+
message: err.message,
|
|
3518
|
+
});
|
|
3519
|
+
return;
|
|
3520
|
+
}
|
|
3502
3521
|
console.error(`${LOG_TAG}: ${requestType} error:`, err);
|
|
3503
3522
|
this.sendResult(packageName, requestId, false, undefined, {
|
|
3504
3523
|
code: MiniappErrorCode.INTERNAL,
|
|
@@ -4015,7 +4034,7 @@ class LocalMiniappRuntime {
|
|
|
4015
4034
|
if (base64) {
|
|
4016
4035
|
// File share via base64 — write to temp file then share
|
|
4017
4036
|
const tempFile = new File(Paths.cache, filename || "shared_file");
|
|
4018
|
-
tempFile.
|
|
4037
|
+
tempFile.writeSync(base64, { encoding: "base64" });
|
|
4019
4038
|
await Share.open({
|
|
4020
4039
|
url: tempFile.uri,
|
|
4021
4040
|
type: mimeType || "application/octet-stream",
|
|
@@ -4085,7 +4104,7 @@ class LocalMiniappRuntime {
|
|
|
4085
4104
|
let file;
|
|
4086
4105
|
if (base64) {
|
|
4087
4106
|
file = new File(Paths.cache, name);
|
|
4088
|
-
file.
|
|
4107
|
+
file.writeSync(base64, { encoding: "base64" });
|
|
4089
4108
|
}
|
|
4090
4109
|
else if (url) {
|
|
4091
4110
|
file = await File.downloadFileAsync(url, new File(Paths.cache, name), { idempotent: true });
|
|
@@ -5493,6 +5512,8 @@ class LocalMiniappRuntime {
|
|
|
5493
5512
|
widgetCallSeq = 0;
|
|
5494
5513
|
/** Elements per widget frame; a card is small, and the link is slow. */
|
|
5495
5514
|
static WIDGET_FRAME_ELEMENT_CAP = 64;
|
|
5515
|
+
/** Elements per expanded widget frame: the full screen, on the same link. */
|
|
5516
|
+
static WIDGET_EXPANDED_FRAME_ELEMENT_CAP = 128;
|
|
5496
5517
|
requireWidgetHost(packageName, requestId, op) {
|
|
5497
5518
|
return this.requirePermission(packageName, requestId, "HOST_WIDGETS", `to ${op} widgets`);
|
|
5498
5519
|
}
|
|
@@ -5535,6 +5556,7 @@ class LocalMiniappRuntime {
|
|
|
5535
5556
|
name: widget.name,
|
|
5536
5557
|
sizes: widget.sizes,
|
|
5537
5558
|
defaultSize: widget.defaultSize,
|
|
5559
|
+
expandable: widget.expandable,
|
|
5538
5560
|
running: app.running,
|
|
5539
5561
|
compatible: app.compatibility?.isCompatible !== false,
|
|
5540
5562
|
});
|
|
@@ -5546,7 +5568,7 @@ class LocalMiniappRuntime {
|
|
|
5546
5568
|
const box = raw;
|
|
5547
5569
|
if (!box || typeof box !== "object")
|
|
5548
5570
|
return null;
|
|
5549
|
-
if (box.size !== "XS" && box.size !== "SM" && box.size !== "MD" && box.size !== "LG")
|
|
5571
|
+
if (box.size !== "XS" && box.size !== "XSM" && box.size !== "SM" && box.size !== "MD" && box.size !== "LG")
|
|
5550
5572
|
return null;
|
|
5551
5573
|
const width = Number(box.width);
|
|
5552
5574
|
const height = Number(box.height);
|
|
@@ -5568,7 +5590,7 @@ class LocalMiniappRuntime {
|
|
|
5568
5590
|
/**
|
|
5569
5591
|
* session.widgets.place: record the host's box, wake the provider in widget
|
|
5570
5592
|
* mode when it is not running, hand it the box, and answer with the last
|
|
5571
|
-
*
|
|
5593
|
+
* card and expanded frames the provider pushed for the widget.
|
|
5572
5594
|
*/
|
|
5573
5595
|
async handleWidgetPlace(hostPackageName, payload, requestId) {
|
|
5574
5596
|
if (!this.requireWidgetHost(hostPackageName, requestId, "place"))
|
|
@@ -5617,7 +5639,10 @@ class LocalMiniappRuntime {
|
|
|
5617
5639
|
if (placementOf(this.widgetPlacements, hostPackageName, provider, widgetId) && this.connectedApps.has(provider)) {
|
|
5618
5640
|
this.sendWidgetCall(provider, widgetId, { kind: "box", box });
|
|
5619
5641
|
}
|
|
5620
|
-
this.sendResult(hostPackageName, requestId, true, {
|
|
5642
|
+
this.sendResult(hostPackageName, requestId, true, {
|
|
5643
|
+
frame: widgetFrameOf(this.widgetPlacements, provider, widgetId),
|
|
5644
|
+
expandedFrame: widgetFrameOf(this.widgetPlacements, provider, widgetId, "expanded"),
|
|
5645
|
+
});
|
|
5621
5646
|
}
|
|
5622
5647
|
async handleWidgetUnplace(hostPackageName, payload, requestId) {
|
|
5623
5648
|
if (!this.requireWidgetHost(hostPackageName, requestId, "unplace"))
|
|
@@ -5734,22 +5759,37 @@ class LocalMiniappRuntime {
|
|
|
5734
5759
|
this.sendResult(pending.hostPackageName, pending.hostRequestId, false, undefined, error);
|
|
5735
5760
|
}
|
|
5736
5761
|
}
|
|
5737
|
-
/** Provider → host, one-shot: cache the frame and push it to every host holding the widget. */
|
|
5762
|
+
/** Provider → host, one-shot: cache the frame for its view and push it to every host holding the widget. */
|
|
5738
5763
|
handleWidgetUpdate(providerPackageName, payload) {
|
|
5739
5764
|
const widgetId = payload.widgetId;
|
|
5740
5765
|
const elements = payload.elements;
|
|
5741
5766
|
if (!widgetId || !Array.isArray(elements))
|
|
5742
5767
|
return;
|
|
5743
5768
|
const app = this.interopApps().find((a) => a.packageName === providerPackageName);
|
|
5744
|
-
|
|
5769
|
+
const widget = app ? this.declaredWidget(app, widgetId) : undefined;
|
|
5770
|
+
if (!widget)
|
|
5745
5771
|
return;
|
|
5746
|
-
|
|
5747
|
-
|
|
5772
|
+
const view = payload.view === "expanded" ? "expanded" : "card";
|
|
5773
|
+
if (view === "expanded" && !widget.expandable) {
|
|
5774
|
+
console.warn(`${LOG_TAG}: dropping expanded frame from ${providerPackageName}/${widgetId}: not declared expandable`);
|
|
5748
5775
|
return;
|
|
5749
5776
|
}
|
|
5750
|
-
|
|
5777
|
+
const cap = view === "expanded"
|
|
5778
|
+
? LocalMiniappRuntime.WIDGET_EXPANDED_FRAME_ELEMENT_CAP
|
|
5779
|
+
: LocalMiniappRuntime.WIDGET_FRAME_ELEMENT_CAP;
|
|
5780
|
+
if (elements.length > cap || this.actionPayloadTooLarge(elements)) {
|
|
5781
|
+
console.warn(`${LOG_TAG}: dropping oversized ${view} widget frame from ${providerPackageName}/${widgetId}`);
|
|
5782
|
+
return;
|
|
5783
|
+
}
|
|
5784
|
+
this.widgetPlacements = setWidgetFrame(this.widgetPlacements, providerPackageName, widgetId, elements, view);
|
|
5751
5785
|
for (const host of widgetHostsOf(this.widgetPlacements, providerPackageName, widgetId)) {
|
|
5752
|
-
this.sendToMiniapp(host, {
|
|
5786
|
+
this.sendToMiniapp(host, {
|
|
5787
|
+
type: MiniappResponseType.WIDGET_FRAME,
|
|
5788
|
+
packageName: providerPackageName,
|
|
5789
|
+
widgetId,
|
|
5790
|
+
elements,
|
|
5791
|
+
...(view === "expanded" ? { view } : {}),
|
|
5792
|
+
});
|
|
5753
5793
|
}
|
|
5754
5794
|
}
|
|
5755
5795
|
/** A miniapp disconnected: as a host its placements go, as a provider its boxes are forgotten and its frames kept. */
|