gps-plus-slam-app-framework 1.0.0 → 1.0.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/{app-selectors-DyMzxCEC.d.ts → app-selectors-CHt7DLuq.d.ts} +9 -8
- package/dist/ar/depth-sampler.js +1 -1
- package/dist/ar/tracking-state.js +1 -1
- package/dist/ar/webxr-session.js +1 -1
- package/dist/combined-root-state-B3SvPNjU.d.ts +6 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/create-slam-app-store-DBm7g2Zd.d.ts +85 -0
- package/dist/file-system-DD5TczSO.d.ts +84 -0
- package/dist/geo/h3-proximity.d.ts +2 -0
- package/dist/{ref-points/h3-ref-point.js → geo/h3-proximity.js} +16 -12
- package/dist/geo/index.d.ts +2 -0
- package/dist/geo/index.js +2 -0
- package/dist/gps-anchored-mesh-manager-CovAFK4g.d.ts +56 -0
- package/dist/gps-ar-pose-sampler-D_Zso40V.d.ts +43 -0
- package/dist/{recording-coordinator-DzflP07_.d.ts → gps-event-coordinator-fwvmVfku.d.ts} +6 -5
- package/dist/{h3-ref-point-CFhayNSZ.d.ts → h3-proximity-GwesPTFT.d.ts} +16 -12
- package/dist/index.d.ts +31 -34
- package/dist/index.js +14 -19
- package/dist/{leaflet-map-overlay-CvfQXTye.d.ts → leaflet-map-overlay-CQZcnxbc.d.ts} +10 -6
- package/dist/licensing/index.d.ts +1 -1
- package/dist/licensing/index.js +1 -1
- package/dist/{null-storage-backend-CsWvQwN8.d.ts → null-storage-backend-C0TiwwzQ.d.ts} +4 -2
- package/dist/{opfs-storage-ChOzF_Wp.d.ts → opfs-storage-Dlq1I_Gb.d.ts} +54 -51
- package/dist/opfs-storage-backend-Gt3rd76D.d.ts +13 -0
- package/dist/{persistence-middleware-DrptY02i.d.ts → persistence-middleware-z-75iisb.d.ts} +4 -4
- package/dist/{recording-replayer-oOzPITrd.d.ts → recording-replayer-BFhFs7Mc.d.ts} +2 -2
- package/dist/recording-slice-BiktUIWF.d.ts +28 -0
- package/dist/{replay-engine-DuX316ae.d.ts → replay-engine-B88Va62x.d.ts} +4 -1
- package/dist/sensors/gps-error-handler.d.ts +1 -1
- package/dist/sensors/gps.d.ts +1 -1
- package/dist/sensors/index.d.ts +3 -3
- package/dist/sensors/index.js +1 -1
- package/dist/sensors/permission-checker.d.ts +1 -1
- package/dist/state/app-selectors.d.ts +1 -1
- package/dist/state/create-slam-app-store.d.ts +2 -0
- package/dist/state/create-slam-app-store.js +61 -0
- package/dist/state/gps-ar-pose-sampler.d.ts +4 -0
- package/dist/state/gps-ar-pose-sampler.js +19 -0
- package/dist/state/{recording-coordinator.d.ts → gps-event-coordinator.d.ts} +1 -1
- package/dist/state/{recording-coordinator.js → gps-event-coordinator.js} +3 -4
- package/dist/state/index.d.ts +15 -16
- package/dist/state/index.js +7 -7
- package/dist/state/persistence-middleware.d.ts +1 -1
- package/dist/state/persistence-middleware.js +8 -8
- package/dist/state/recording-replayer.d.ts +3 -2
- package/dist/state/recording-replayer.js +2 -2
- package/dist/state/recording-slice.d.ts +2 -0
- package/dist/state/{recorder-slice.js → recording-slice.js} +7 -15
- package/dist/state/replay-engine.d.ts +1 -1
- package/dist/state/replay-engine.js +3 -3
- package/dist/state/store-subscribers.d.ts +2 -2
- package/dist/state/store-subscribers.js +1 -9
- package/dist/state/subscribe-to-selector.d.ts +1 -1
- package/dist/storage/file-system-utils.d.ts +1 -1
- package/dist/storage/file-system.d.ts +2 -2
- package/dist/storage/file-system.js +103 -94
- package/dist/storage/index.d.ts +9 -11
- package/dist/storage/index.js +5 -7
- package/dist/storage/null-storage-backend.d.ts +1 -1
- package/dist/storage/null-storage-backend.js +7 -0
- package/dist/storage/opfs-storage-backend.d.ts +1 -1
- package/dist/storage/opfs-storage-backend.js +7 -1
- package/dist/storage/opfs-storage.d.ts +2 -2
- package/dist/storage/opfs-storage.js +69 -85
- package/dist/storage/storage-backend.d.ts +2 -2
- package/dist/storage/zip-export.d.ts +2 -2
- package/dist/storage/zip-export.js +55 -62
- package/dist/storage/zip-reader.d.ts +2 -2
- package/dist/storage/zip-reader.js +24 -1
- package/dist/storage-backend-yVnuWGTr.d.ts +28 -0
- package/dist/{store-subscribers-CuoIzB5T.d.ts → store-subscribers-DKKHld49.d.ts} +1 -2
- package/dist/{subscribe-to-selector-UTZ0KkAc.d.ts → subscribe-to-selector-ghDKYtap.d.ts} +1 -1
- package/dist/test-utils/zip-round-trip-helpers.d.ts +1 -1
- package/dist/test-utils/zip-round-trip-helpers.js +4 -4
- package/dist/visualization/gps-anchored-mesh-manager.d.ts +2 -0
- package/dist/visualization/gps-anchored-mesh-manager.js +128 -0
- package/dist/visualization/gps-compass-cubes.d.ts +1 -1
- package/dist/visualization/gps-event-markers.d.ts +1 -1
- package/dist/visualization/index.d.ts +9 -9
- package/dist/visualization/index.js +2 -2
- package/dist/visualization/leaflet-map-overlay.d.ts +1 -1
- package/dist/visualization/leaflet-map-overlay.js +23 -19
- package/dist/visualization/lerp-utils.d.ts +1 -1
- package/dist/visualization/map-overlay.d.ts +1 -1
- package/dist/visualization/three-dispose.d.ts +1 -1
- package/dist/visualization/vis-colors.d.ts +1 -1
- package/dist/{zip-export-Rtpi75JJ.d.ts → zip-export-BjrQPv0X.d.ts} +58 -7
- package/dist/{zip-reader-D7pkpX8K.d.ts → zip-reader-KgJEXbca.d.ts} +33 -1
- package/package.json +15 -4
- package/dist/community-license-key-ChZLCJyO.d.ts +0 -21
- package/dist/file-system-BsQgYCU3.d.ts +0 -128
- package/dist/licensing/community-license-key.d.ts +0 -2
- package/dist/licensing/community-license-key.js +0 -21
- package/dist/opfs-storage-backend-CVcmfJHN.d.ts +0 -11
- package/dist/recorder-slice-fcwAXrsh.d.ts +0 -35
- package/dist/ref-point-importer-B_wn5ABk.d.ts +0 -62
- package/dist/ref-point-loader-Pt1smgHS.d.ts +0 -117
- package/dist/ref-points/h3-ref-point.d.ts +0 -2
- package/dist/ref-points/index.d.ts +0 -2
- package/dist/ref-points/index.js +0 -2
- package/dist/ref-points-slice-tC-Wd6XJ.d.ts +0 -48
- package/dist/reference-points-CFWy8_wj.d.ts +0 -68
- package/dist/routing-slice-BlHTM8eh.d.ts +0 -23
- package/dist/state/recorder-slice.d.ts +0 -2
- package/dist/state/ref-points-slice.d.ts +0 -2
- package/dist/state/ref-points-slice.js +0 -44
- package/dist/state/routing-slice.d.ts +0 -2
- package/dist/state/routing-slice.js +0 -13
- package/dist/state/store.d.ts +0 -9
- package/dist/state/store.js +0 -71
- package/dist/storage/ref-point-importer.d.ts +0 -2
- package/dist/storage/ref-point-importer.js +0 -163
- package/dist/storage/ref-point-loader.d.ts +0 -2
- package/dist/storage/ref-point-loader.js +0 -248
- package/dist/storage/ref-point-recovery.d.ts +0 -28
- package/dist/storage/ref-point-recovery.js +0 -159
- package/dist/storage-backend-BcEItnFr.d.ts +0 -20
- package/dist/store-C7PKOj8S.d.ts +0 -96
- package/dist/visualization/reference-points.d.ts +0 -2
- package/dist/visualization/reference-points.js +0 -160
- /package/dist/{file-system-utils-5cWO8Xyv.d.ts → file-system-utils-BH8FdyIu.d.ts} +0 -0
- /package/dist/{gps-Ddzr2KlX.d.ts → gps-GKc6_Cly.d.ts} +0 -0
- /package/dist/{gps-compass-cubes-C-6JEnpR.d.ts → gps-compass-cubes-jRIJMOuh.d.ts} +0 -0
- /package/dist/{gps-error-handler-VPuNOuf8.d.ts → gps-error-handler-CH1S528z.d.ts} +0 -0
- /package/dist/{gps-event-markers-DpEy2qRd.d.ts → gps-event-markers-sVyO9utS.d.ts} +0 -0
- /package/dist/{lerp-utils-87NWjUOD.d.ts → lerp-utils-CZgQlrmu.d.ts} +0 -0
- /package/dist/{map-overlay-DuiZuCTx.d.ts → map-overlay-C9ifl_4-.d.ts} +0 -0
- /package/dist/{permission-checker-jO2ziCWC.d.ts → permission-checker-Cu3nbH1S.d.ts} +0 -0
- /package/dist/{three-dispose-CCBHjE_a.d.ts → three-dispose-qt_r5wR1.d.ts} +0 -0
- /package/dist/{vis-colors-Qi2vlRGt.d.ts → vis-colors-BKkdTIKb.d.ts} +0 -0
|
@@ -1,15 +1,34 @@
|
|
|
1
1
|
import { createLogger } from "../utils/logger.js";
|
|
2
2
|
import { setFileSystemState } from "../sensors/permission-checker.js";
|
|
3
|
-
import {
|
|
3
|
+
import { formatTimestamp } from "./file-system-utils.js";
|
|
4
|
+
import { createSession, getAppRootHandle, initOpfsStorage, listSessions as listSessions$1, resetOpfsStorage, resetSessionHandles, setSessionHandles, writeAction as writeAction$1, writeFrame as writeFrame$1, writeSessionMetadata as writeSessionMetadata$1 } from "./opfs-storage.js";
|
|
4
5
|
//#region ../src/storage/file-system.ts
|
|
6
|
+
/**
|
|
7
|
+
* File System Storage Module
|
|
8
|
+
*
|
|
9
|
+
* Facade over the OPFS storage module. Provides session lifecycle, write
|
|
10
|
+
* operations, and backwards-compatible scenario management for the recorder.
|
|
11
|
+
*
|
|
12
|
+
* The core OPFS module (opfs-storage.ts) is scenario-free — it manages
|
|
13
|
+
* flat sessions/{timestamp}/ directories. This module bridges the gap by
|
|
14
|
+
* managing scenario directory handles for consumers that still need them
|
|
15
|
+
* (recorder, ref-point loader, etc.) until those are migrated to
|
|
16
|
+
* ScenarioWrappingStorageBackend in later iterations.
|
|
17
|
+
*/
|
|
5
18
|
const log = createLogger("Storage");
|
|
19
|
+
let _currentScenarioName = null;
|
|
6
20
|
let storageInitialized = false;
|
|
21
|
+
let scenariosDir = null;
|
|
22
|
+
let currentScenarioHandle = null;
|
|
7
23
|
/**
|
|
8
24
|
* Reset module state - exported for testing only
|
|
9
25
|
* @internal
|
|
10
26
|
*/
|
|
11
27
|
function resetStorageState() {
|
|
28
|
+
_currentScenarioName = null;
|
|
12
29
|
storageInitialized = false;
|
|
30
|
+
scenariosDir = null;
|
|
31
|
+
currentScenarioHandle = null;
|
|
13
32
|
resetOpfsStorage();
|
|
14
33
|
}
|
|
15
34
|
/**
|
|
@@ -18,25 +37,14 @@ function resetStorageState() {
|
|
|
18
37
|
* Clears scenario/session names and OPFS session handles, but preserves
|
|
19
38
|
* `storageInitialized` and the OPFS root so `initStorage()` doesn't need
|
|
20
39
|
* to be called again.
|
|
21
|
-
*
|
|
22
|
-
* Used during soft reset for new recordings (Issue 4, 2026-02-06 user feedback).
|
|
23
40
|
*/
|
|
24
41
|
function resetForNewSession() {
|
|
42
|
+
_currentScenarioName = null;
|
|
43
|
+
currentScenarioHandle = null;
|
|
25
44
|
resetSessionHandles();
|
|
26
45
|
}
|
|
27
46
|
/**
|
|
28
47
|
* Verify that we have actual write access to a directory.
|
|
29
|
-
*
|
|
30
|
-
* This probes the directory by creating a test file, writing content,
|
|
31
|
-
* and cleaning up. This catches cases where showDirectoryPicker grants
|
|
32
|
-
* a handle but the underlying file system is read-only.
|
|
33
|
-
*
|
|
34
|
-
* User Feedback Issue #1: Even with mode: 'readwrite', Android can
|
|
35
|
-
* return a handle where getFileHandle({create: true}) succeeds but
|
|
36
|
-
* createWritable() fails with NoModificationAllowedError.
|
|
37
|
-
*
|
|
38
|
-
* @param dirHandle - Directory handle to verify
|
|
39
|
-
* @returns Success status and optional error message
|
|
40
48
|
*/
|
|
41
49
|
async function verifyWriteAccess(dirHandle) {
|
|
42
50
|
const testFilename = `.write-test-${Date.now()}`;
|
|
@@ -64,12 +72,27 @@ async function verifyWriteAccess(dirHandle) {
|
|
|
64
72
|
};
|
|
65
73
|
}
|
|
66
74
|
}
|
|
75
|
+
async function ensureScenariosDir() {
|
|
76
|
+
if (scenariosDir) return scenariosDir;
|
|
77
|
+
const appRoot = getAppRootHandle();
|
|
78
|
+
if (!appRoot) return null;
|
|
79
|
+
scenariosDir = await appRoot.getDirectoryHandle("scenarios", { create: true });
|
|
80
|
+
return scenariosDir;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* List all scenario names in OPFS storage.
|
|
84
|
+
* Legacy: scenarios are managed by the recorder, not the framework.
|
|
85
|
+
*/
|
|
86
|
+
async function listScenarios() {
|
|
87
|
+
const dir = await ensureScenariosDir();
|
|
88
|
+
if (!dir) return [];
|
|
89
|
+
const scenarios = [];
|
|
90
|
+
for await (const entry of dir.values()) if (entry.kind === "directory") scenarios.push(entry.name);
|
|
91
|
+
return scenarios;
|
|
92
|
+
}
|
|
67
93
|
/**
|
|
68
94
|
* Initialize storage using OPFS.
|
|
69
95
|
*
|
|
70
|
-
* This replaces the old showDirectoryPicker approach which failed on Android Chrome.
|
|
71
|
-
* OPFS is automatically available and doesn't require user folder selection.
|
|
72
|
-
*
|
|
73
96
|
* @returns List of existing scenario folder names
|
|
74
97
|
* @throws Error if OPFS is not supported
|
|
75
98
|
*/
|
|
@@ -81,6 +104,7 @@ async function initStorage() {
|
|
|
81
104
|
folderSelected: true,
|
|
82
105
|
writeVerified: true
|
|
83
106
|
});
|
|
107
|
+
await ensureScenariosDir();
|
|
84
108
|
const scenarios = await listScenarios();
|
|
85
109
|
log.info("OPFS storage initialized, found scenarios:", scenarios);
|
|
86
110
|
return scenarios;
|
|
@@ -96,24 +120,61 @@ async function initStorage() {
|
|
|
96
120
|
}
|
|
97
121
|
}
|
|
98
122
|
/**
|
|
99
|
-
* Create
|
|
123
|
+
* Create a new session folder.
|
|
100
124
|
*
|
|
101
|
-
*
|
|
125
|
+
* When scenarioName is provided, creates under the scenario directory
|
|
126
|
+
* (legacy scenario layout for the recorder). When omitted, creates under
|
|
127
|
+
* the flat sessions/ directory.
|
|
102
128
|
*
|
|
103
|
-
* @param scenarioName -
|
|
129
|
+
* @param scenarioName - Optional name of the scenario (omit for flat layout)
|
|
104
130
|
*/
|
|
105
131
|
async function startSession(scenarioName) {
|
|
106
132
|
if (!storageInitialized) throw new Error("Storage not initialized. Call initStorage first.");
|
|
107
|
-
|
|
108
|
-
|
|
133
|
+
if (scenarioName) {
|
|
134
|
+
const dir = await ensureScenariosDir();
|
|
135
|
+
if (!dir) throw new Error("Failed to access scenarios directory.");
|
|
136
|
+
const scenarioHandle = await dir.getDirectoryHandle(scenarioName, { create: true });
|
|
137
|
+
currentScenarioHandle = scenarioHandle;
|
|
138
|
+
const sessionName = `recording-${formatTimestamp(/* @__PURE__ */ new Date())}`;
|
|
139
|
+
const sessionHandle = await scenarioHandle.getDirectoryHandle(sessionName, { create: true });
|
|
140
|
+
setSessionHandles(sessionHandle, await sessionHandle.getDirectoryHandle("actions", { create: true }), await sessionHandle.getDirectoryHandle("frames", { create: true }));
|
|
141
|
+
_currentScenarioName = scenarioName;
|
|
142
|
+
log.info("Session started:", `${scenarioName}/${sessionName}`);
|
|
143
|
+
return {
|
|
144
|
+
scenarioPath: scenarioName,
|
|
145
|
+
sessionPath: sessionName
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
const result = await createSession(/* @__PURE__ */ new Date());
|
|
149
|
+
_currentScenarioName = "";
|
|
109
150
|
result.sessionName;
|
|
110
|
-
log.info("Session started:",
|
|
151
|
+
log.info("Session started:", result.sessionName);
|
|
111
152
|
return {
|
|
112
|
-
scenarioPath:
|
|
153
|
+
scenarioPath: "",
|
|
113
154
|
sessionPath: result.sessionName
|
|
114
155
|
};
|
|
115
156
|
}
|
|
116
157
|
/**
|
|
158
|
+
* List all session names.
|
|
159
|
+
* When scenarioName is provided, lists sessions under that scenario.
|
|
160
|
+
* Otherwise lists flat sessions.
|
|
161
|
+
*/
|
|
162
|
+
async function listSessions(scenarioName) {
|
|
163
|
+
if (scenarioName) {
|
|
164
|
+
const dir = await ensureScenariosDir();
|
|
165
|
+
if (!dir) return [];
|
|
166
|
+
try {
|
|
167
|
+
const scenarioHandle = await dir.getDirectoryHandle(scenarioName);
|
|
168
|
+
const sessions = [];
|
|
169
|
+
for await (const entry of scenarioHandle.values()) if (entry.kind === "directory") sessions.push(entry.name);
|
|
170
|
+
return sessions;
|
|
171
|
+
} catch {
|
|
172
|
+
return [];
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return listSessions$1();
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
117
178
|
* Write a Redux action to OPFS as a JSON file.
|
|
118
179
|
*/
|
|
119
180
|
async function writeAction(action, index) {
|
|
@@ -127,82 +188,30 @@ async function writeFrame(blob, index) {
|
|
|
127
188
|
}
|
|
128
189
|
/**
|
|
129
190
|
* Write session metadata (session.json) to OPFS.
|
|
130
|
-
* Contains timing, counts, and user agent for the recording session.
|
|
131
191
|
*/
|
|
132
192
|
async function writeSessionMetadata(metadata) {
|
|
133
193
|
await writeSessionMetadata$1(metadata);
|
|
134
194
|
}
|
|
135
195
|
/**
|
|
136
|
-
* Type guard for reference point actions
|
|
137
|
-
* Exported for testing
|
|
138
|
-
*/
|
|
139
|
-
function isRefPointAction(action) {
|
|
140
|
-
if (typeof action !== "object" || action === null) return false;
|
|
141
|
-
const obj = action;
|
|
142
|
-
const payload = obj.payload;
|
|
143
|
-
return obj.type === "recorder/markRefPoint" && typeof payload === "object" && payload !== null && !Array.isArray(payload);
|
|
144
|
-
}
|
|
145
|
-
/**
|
|
146
|
-
* Parse action files from a session's actions directory
|
|
147
|
-
*/
|
|
148
|
-
async function parseSessionRefPoints(actionsDir, sessionName) {
|
|
149
|
-
const refPoints = [];
|
|
150
|
-
for await (const actionEntry of actionsDir.values()) {
|
|
151
|
-
if (actionEntry.kind !== "file" || !actionEntry.name.endsWith(".json")) continue;
|
|
152
|
-
const text = await (await (await actionsDir.getFileHandle(actionEntry.name)).getFile()).text();
|
|
153
|
-
try {
|
|
154
|
-
const action = JSON.parse(text);
|
|
155
|
-
if (isRefPointAction(action)) refPoints.push({
|
|
156
|
-
id: action.payload.id,
|
|
157
|
-
sessionName,
|
|
158
|
-
gpsPosition: action.payload.gpsPosition,
|
|
159
|
-
arPose: action.payload.arPose
|
|
160
|
-
});
|
|
161
|
-
} catch {}
|
|
162
|
-
}
|
|
163
|
-
return refPoints;
|
|
164
|
-
}
|
|
165
|
-
/**
|
|
166
|
-
* Load existing reference points from a scenario (across all sessions).
|
|
167
|
-
* Now uses OPFS storage backend.
|
|
168
|
-
*/
|
|
169
|
-
async function loadScenarioRefPoints(scenarioName) {
|
|
170
|
-
const scenariosRoot = getScenariosRootHandle();
|
|
171
|
-
if (!scenariosRoot) return [];
|
|
172
|
-
const refPoints = [];
|
|
173
|
-
try {
|
|
174
|
-
const scenarioHandle = await scenariosRoot.getDirectoryHandle(scenarioName);
|
|
175
|
-
for await (const sessionEntry of scenarioHandle.values()) {
|
|
176
|
-
if (sessionEntry.kind !== "directory") continue;
|
|
177
|
-
const sessionHandle = await scenarioHandle.getDirectoryHandle(sessionEntry.name);
|
|
178
|
-
let actionsDir;
|
|
179
|
-
try {
|
|
180
|
-
actionsDir = await sessionHandle.getDirectoryHandle("actions");
|
|
181
|
-
} catch {
|
|
182
|
-
continue;
|
|
183
|
-
}
|
|
184
|
-
const sessionRefPoints = await parseSessionRefPoints(actionsDir, sessionEntry.name);
|
|
185
|
-
refPoints.push(...sessionRefPoints);
|
|
186
|
-
}
|
|
187
|
-
} catch {}
|
|
188
|
-
return refPoints;
|
|
189
|
-
}
|
|
190
|
-
/**
|
|
191
196
|
* Get the current scenario handle (for loading prior sessions).
|
|
192
|
-
*
|
|
197
|
+
* Legacy: uses scenario directory layout.
|
|
193
198
|
*/
|
|
194
199
|
function getCurrentScenarioHandle() {
|
|
195
|
-
|
|
200
|
+
if (!_currentScenarioName) return null;
|
|
201
|
+
return currentScenarioHandle;
|
|
196
202
|
}
|
|
197
203
|
/**
|
|
198
204
|
* Set the current scenario handle (when user selects a scenario).
|
|
199
|
-
*
|
|
205
|
+
* Legacy: uses scenario directory layout.
|
|
200
206
|
*/
|
|
201
207
|
async function setCurrentScenario(scenarioName) {
|
|
202
|
-
const
|
|
203
|
-
if (!
|
|
208
|
+
const scenRoot = await ensureScenariosDir();
|
|
209
|
+
if (!scenRoot) return null;
|
|
204
210
|
try {
|
|
205
|
-
|
|
211
|
+
const handle = await scenRoot.getDirectoryHandle(scenarioName);
|
|
212
|
+
_currentScenarioName = scenarioName;
|
|
213
|
+
currentScenarioHandle = handle;
|
|
214
|
+
return handle;
|
|
206
215
|
} catch {
|
|
207
216
|
log.warn("Scenario not found:", scenarioName);
|
|
208
217
|
return null;
|
|
@@ -210,20 +219,20 @@ async function setCurrentScenario(scenarioName) {
|
|
|
210
219
|
}
|
|
211
220
|
/**
|
|
212
221
|
* Ensure a scenario directory exists in OPFS, creating it if necessary.
|
|
213
|
-
*
|
|
214
|
-
* data is available for restoration.
|
|
215
|
-
*
|
|
216
|
-
* Unlike setCurrentScenario() which only reads, this creates on demand.
|
|
222
|
+
* Legacy: used during OPFS recovery.
|
|
217
223
|
*/
|
|
218
224
|
async function ensureScenarioDirectory(scenarioName) {
|
|
219
|
-
const
|
|
220
|
-
if (!
|
|
225
|
+
const scenRoot = await ensureScenariosDir();
|
|
226
|
+
if (!scenRoot) return null;
|
|
221
227
|
try {
|
|
222
|
-
|
|
228
|
+
const handle = await scenRoot.getDirectoryHandle(scenarioName, { create: true });
|
|
229
|
+
_currentScenarioName = scenarioName;
|
|
230
|
+
currentScenarioHandle = handle;
|
|
231
|
+
return handle;
|
|
223
232
|
} catch (err) {
|
|
224
233
|
log.error("Failed to create scenario directory:", err);
|
|
225
234
|
return null;
|
|
226
235
|
}
|
|
227
236
|
}
|
|
228
237
|
//#endregion
|
|
229
|
-
export { ensureScenarioDirectory, getCurrentScenarioHandle, initStorage,
|
|
238
|
+
export { ensureScenarioDirectory, getCurrentScenarioHandle, initStorage, listSessions, resetForNewSession, resetStorageState, setCurrentScenario, startSession, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata };
|
package/dist/storage/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { a as
|
|
9
|
-
|
|
10
|
-
import { a as syncToExternalZip, i as exportSessionAsZip, n as downloadZip, r as exportAndDownloadSession, t as ZipExportResult } from "../zip-export-Rtpi75JJ.js";
|
|
11
|
-
export { type CreateSessionResult, type Entry, type GpsPathCoord, type ImportedRefPoint, MAX_ACTION_FILE_SIZE, NullStorageBackend, OpfsStorageBackend, type RecordedAction, type RefPointDefinition, type RefPointImportResult, type RefPointMark, type RefPointObservation, type SessionMetadata, type StorageBackend, type WriteAccessResult, type ZipActionEntry, type ZipExportResult, averageGpsPerRefPoint, checkStorageQuota, createSession, downloadZip, exportAndDownloadSession, exportSessionAsZip, flattenRefPointsToMarks, formatActionFilename, formatFrameFilename, formatTimestamp, getCurrentScenarioHandle, getScenarioHandle, getScenariosRootHandle, getSessionHandle, importRefPointsFromFolder, initOpfsStorage, initStorage, isRefPointAction, listRefPointIds, listSessions, loadActionsFromZip, loadAllRefPoints, loadGpsPathFromBlob, loadRefPoint, loadScenarioRefPoints, loadSessionMetadataFromBlob, loadSessionMetadata as loadSessionMetadataFromZip, readZipEntries, resetForNewSession, resetOpfsStorage, resetSessionHandles, resetStorageState, saveRefPointObservation, setCurrentScenario, startSession as startStorageSession, syncToExternalZip, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata as writeSessionMeta, writeSessionMetadata$1 as writeSessionMetadata };
|
|
1
|
+
import { a as getAppRootHandle, c as initOpfsStorage, d as resetSessionHandles, h as writeSessionMetadata$1, i as createSession, l as listSessions, n as SessionMetadata, o as getSessionHandle, r as checkStorageQuota, s as getSessionsRootHandle, u as resetOpfsStorage } from "../opfs-storage-Dlq1I_Gb.js";
|
|
2
|
+
import { n as StorageBackend, t as CreateSessionResult } from "../storage-backend-yVnuWGTr.js";
|
|
3
|
+
import { a as ZipActionEntry, c as loadEntriesFromSubdir, d as loadSessionMetadataFromBlob, f as readZipEntries, i as RecordedAction, l as loadGpsPathFromBlob, n as GpsPathCoord, o as ZipSubdirEntry, r as MAX_ACTION_FILE_SIZE, s as loadActionsFromZip, t as Entry, u as loadSessionMetadata } from "../zip-reader-KgJEXbca.js";
|
|
4
|
+
import { t as NullStorageBackend } from "../null-storage-backend-C0TiwwzQ.js";
|
|
5
|
+
import { t as OpfsStorageBackend } from "../opfs-storage-backend-Gt3rd76D.js";
|
|
6
|
+
import { a as listSessions$1, c as setCurrentScenario, d as writeAction, f as writeFrame, i as initStorage, l as startSession, n as ensureScenarioDirectory, o as resetForNewSession, p as writeSessionMetadata, r as getCurrentScenarioHandle, s as resetStorageState, t as WriteAccessResult, u as verifyWriteAccess } from "../file-system-DD5TczSO.js";
|
|
7
|
+
import { n as formatFrameFilename, r as formatTimestamp, t as formatActionFilename } from "../file-system-utils-BH8FdyIu.js";
|
|
8
|
+
import { a as downloadZip, c as syncToExternalZip, i as ZipExportResult, n as ZipContributorAddFile, o as exportAndDownloadSession, r as ZipExportContributor, s as exportSessionAsZip, t as ExportSessionAsZipOptions } from "../zip-export-BjrQPv0X.js";
|
|
9
|
+
export { type CreateSessionResult, type Entry, type ExportSessionAsZipOptions, type GpsPathCoord, MAX_ACTION_FILE_SIZE, NullStorageBackend, OpfsStorageBackend, type RecordedAction, type SessionMetadata, type StorageBackend, type WriteAccessResult, type ZipActionEntry, type ZipContributorAddFile, type ZipExportContributor, type ZipExportResult, type ZipSubdirEntry, checkStorageQuota, createSession, downloadZip, ensureScenarioDirectory, exportAndDownloadSession, exportSessionAsZip, formatActionFilename, formatFrameFilename, formatTimestamp, getAppRootHandle, getCurrentScenarioHandle, getSessionHandle, getSessionsRootHandle, initOpfsStorage, initStorage, listSessions, listSessions$1 as listSessionsFromFileSystem, loadActionsFromZip, loadEntriesFromSubdir, loadGpsPathFromBlob, loadSessionMetadataFromBlob, loadSessionMetadata as loadSessionMetadataFromZip, readZipEntries, resetForNewSession, resetOpfsStorage, resetSessionHandles, resetStorageState, setCurrentScenario, startSession as startStorageSession, syncToExternalZip, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata as writeSessionMeta, writeSessionMetadata$1 as writeSessionMetadata };
|
package/dist/storage/index.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
+
import { MAX_ACTION_FILE_SIZE, loadActionsFromZip, loadEntriesFromSubdir, loadGpsPathFromBlob, loadSessionMetadata, loadSessionMetadataFromBlob, readZipEntries } from "./zip-reader.js";
|
|
1
2
|
import { formatActionFilename, formatFrameFilename, formatTimestamp } from "./file-system-utils.js";
|
|
2
|
-
import { checkStorageQuota, createSession, getScenarioHandle, getScenariosRootHandle, getSessionHandle, initOpfsStorage, listSessions, resetOpfsStorage, resetSessionHandles, writeSessionMetadata as writeSessionMetadata$1 } from "./opfs-storage.js";
|
|
3
|
-
import { getCurrentScenarioHandle, initStorage, isRefPointAction, loadScenarioRefPoints, resetForNewSession, resetStorageState, setCurrentScenario, startSession, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata } from "./file-system.js";
|
|
4
|
-
import { OpfsStorageBackend } from "./opfs-storage-backend.js";
|
|
5
|
-
import { MAX_ACTION_FILE_SIZE, loadActionsFromZip, loadGpsPathFromBlob, loadSessionMetadata, loadSessionMetadataFromBlob, readZipEntries } from "./zip-reader.js";
|
|
6
3
|
import { NullStorageBackend } from "./null-storage-backend.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
4
|
+
import { checkStorageQuota, createSession, getAppRootHandle, getSessionHandle, getSessionsRootHandle, initOpfsStorage, listSessions, resetOpfsStorage, resetSessionHandles, writeSessionMetadata as writeSessionMetadata$1 } from "./opfs-storage.js";
|
|
5
|
+
import { ensureScenarioDirectory, getCurrentScenarioHandle, initStorage, listSessions as listSessions$1, resetForNewSession, resetStorageState, setCurrentScenario, startSession, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata } from "./file-system.js";
|
|
6
|
+
import { OpfsStorageBackend } from "./opfs-storage-backend.js";
|
|
9
7
|
import { downloadZip, exportAndDownloadSession, exportSessionAsZip, syncToExternalZip } from "./zip-export.js";
|
|
10
|
-
export { MAX_ACTION_FILE_SIZE, NullStorageBackend, OpfsStorageBackend,
|
|
8
|
+
export { MAX_ACTION_FILE_SIZE, NullStorageBackend, OpfsStorageBackend, checkStorageQuota, createSession, downloadZip, ensureScenarioDirectory, exportAndDownloadSession, exportSessionAsZip, formatActionFilename, formatFrameFilename, formatTimestamp, getAppRootHandle, getCurrentScenarioHandle, getSessionHandle, getSessionsRootHandle, initOpfsStorage, initStorage, listSessions, listSessions$1 as listSessionsFromFileSystem, loadActionsFromZip, loadEntriesFromSubdir, loadGpsPathFromBlob, loadSessionMetadataFromBlob, loadSessionMetadata as loadSessionMetadataFromZip, readZipEntries, resetForNewSession, resetOpfsStorage, resetSessionHandles, resetStorageState, setCurrentScenario, startSession as startStorageSession, syncToExternalZip, verifyWriteAccess, writeAction, writeFrame, writeSessionMetadata as writeSessionMeta, writeSessionMetadata$1 as writeSessionMetadata };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as NullStorageBackend } from "../null-storage-backend-
|
|
1
|
+
import { t as NullStorageBackend } from "../null-storage-backend-C0TiwwzQ.js";
|
|
2
2
|
export { NullStorageBackend };
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { formatTimestamp } from "./file-system-utils.js";
|
|
1
2
|
//#region ../src/storage/null-storage-backend.ts
|
|
2
3
|
var NullStorageBackend = class {
|
|
4
|
+
createSession(timestamp, _contextTag) {
|
|
5
|
+
return Promise.resolve({ sessionName: `recording-${formatTimestamp(timestamp)}` });
|
|
6
|
+
}
|
|
7
|
+
listSessions() {
|
|
8
|
+
return Promise.resolve([]);
|
|
9
|
+
}
|
|
3
10
|
async writeAction(_action, _index) {}
|
|
4
11
|
async writeFrame(_blob, _index) {}
|
|
5
12
|
async writeSessionMetadata(_metadata) {}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as OpfsStorageBackend } from "../opfs-storage-backend-
|
|
1
|
+
import { t as OpfsStorageBackend } from "../opfs-storage-backend-Gt3rd76D.js";
|
|
2
2
|
export { OpfsStorageBackend };
|
|
@@ -1,6 +1,12 @@
|
|
|
1
|
-
import { writeAction, writeFrame, writeSessionMetadata } from "./file-system.js";
|
|
1
|
+
import { listSessions, startSession, writeAction, writeFrame, writeSessionMetadata } from "./file-system.js";
|
|
2
2
|
//#region ../src/storage/opfs-storage-backend.ts
|
|
3
3
|
var OpfsStorageBackend = class {
|
|
4
|
+
async createSession(_timestamp, _contextTag) {
|
|
5
|
+
return { sessionName: (await startSession()).sessionPath };
|
|
6
|
+
}
|
|
7
|
+
async listSessions() {
|
|
8
|
+
return listSessions();
|
|
9
|
+
}
|
|
4
10
|
async writeAction(action, index) {
|
|
5
11
|
await writeAction(action, index);
|
|
6
12
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export { CreateSessionResult, SessionMetadata, checkStorageQuota, createSession,
|
|
1
|
+
import { a as getAppRootHandle, c as initOpfsStorage, d as resetSessionHandles, f as setSessionHandles, h as writeSessionMetadata, i as createSession, l as listSessions, m as writeFrame, n as SessionMetadata, o as getSessionHandle, p as writeAction, r as checkStorageQuota, s as getSessionsRootHandle, t as CreateSessionResult, u as resetOpfsStorage } from "../opfs-storage-Dlq1I_Gb.js";
|
|
2
|
+
export { CreateSessionResult, SessionMetadata, checkStorageQuota, createSession, getAppRootHandle, getSessionHandle, getSessionsRootHandle, initOpfsStorage, listSessions, resetOpfsStorage, resetSessionHandles, setSessionHandles, writeAction, writeFrame, writeSessionMetadata };
|
|
@@ -8,26 +8,26 @@ import { formatActionFilename, formatFrameFilename, formatTimestamp } from "./fi
|
|
|
8
8
|
* OPFS works consistently on Desktop Chrome, Android Chrome, and iOS Safari,
|
|
9
9
|
* unlike showDirectoryPicker which has write restrictions on Android.
|
|
10
10
|
*
|
|
11
|
-
* Directory structure:
|
|
12
|
-
* /gps-
|
|
13
|
-
* └──
|
|
14
|
-
* ├──
|
|
15
|
-
* │ ├──
|
|
16
|
-
* │
|
|
17
|
-
* │ │ ├──
|
|
18
|
-
* │ │
|
|
19
|
-
* │
|
|
20
|
-
* │
|
|
21
|
-
* │
|
|
22
|
-
* │ │ └── ...
|
|
23
|
-
* │ └── ...
|
|
11
|
+
* Directory structure (flat sessions — no scenario hierarchy):
|
|
12
|
+
* /gps-plus-slam/
|
|
13
|
+
* └── sessions/
|
|
14
|
+
* ├── recording-YYYY-MM-DD_HH-MM-SSutc/
|
|
15
|
+
* │ ├── session.json
|
|
16
|
+
* │ ├── actions/
|
|
17
|
+
* │ │ ├── 000001.json
|
|
18
|
+
* │ │ └── ...
|
|
19
|
+
* │ └── frames/
|
|
20
|
+
* │ ├── frame-000001.jpg
|
|
21
|
+
* │ └── ...
|
|
24
22
|
* └── ...
|
|
23
|
+
*
|
|
24
|
+
* Scenario grouping (scenarios/{name}/recording-…) is a recorder-only concern,
|
|
25
|
+
* handled by ScenarioWrappingStorageBackend in the recorder app.
|
|
25
26
|
*/
|
|
26
27
|
const log = createLogger("OPFS");
|
|
27
28
|
let opfsRoot = null;
|
|
28
|
-
let
|
|
29
|
-
let
|
|
30
|
-
let currentScenarioHandle = null;
|
|
29
|
+
let gpsPlusSlamDir = null;
|
|
30
|
+
let sessionsDir = null;
|
|
31
31
|
let currentSessionHandle = null;
|
|
32
32
|
let actionsHandle = null;
|
|
33
33
|
let framesHandle = null;
|
|
@@ -37,9 +37,8 @@ let framesHandle = null;
|
|
|
37
37
|
*/
|
|
38
38
|
function resetOpfsStorage() {
|
|
39
39
|
opfsRoot = null;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
currentScenarioHandle = null;
|
|
40
|
+
gpsPlusSlamDir = null;
|
|
41
|
+
sessionsDir = null;
|
|
43
42
|
currentSessionHandle = null;
|
|
44
43
|
actionsHandle = null;
|
|
45
44
|
framesHandle = null;
|
|
@@ -47,14 +46,11 @@ function resetOpfsStorage() {
|
|
|
47
46
|
/**
|
|
48
47
|
* Reset session-level handles only.
|
|
49
48
|
*
|
|
50
|
-
* Preserves opfsRoot/
|
|
51
|
-
* but clears current
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* Used during soft reset for new recordings (Issue 4, 2026-02-06 user feedback).
|
|
49
|
+
* Preserves opfsRoot/gpsPlusSlamDir/sessionsDir (OPFS stays initialized)
|
|
50
|
+
* but clears current session/actions/frames handles so a new session can
|
|
51
|
+
* be started fresh.
|
|
55
52
|
*/
|
|
56
53
|
function resetSessionHandles() {
|
|
57
|
-
currentScenarioHandle = null;
|
|
58
54
|
currentSessionHandle = null;
|
|
59
55
|
actionsHandle = null;
|
|
60
56
|
framesHandle = null;
|
|
@@ -63,8 +59,8 @@ function resetSessionHandles() {
|
|
|
63
59
|
* Initialize OPFS storage by creating the required directory structure.
|
|
64
60
|
*
|
|
65
61
|
* Creates:
|
|
66
|
-
* - /gps-
|
|
67
|
-
* - /gps-
|
|
62
|
+
* - /gps-plus-slam/
|
|
63
|
+
* - /gps-plus-slam/sessions/
|
|
68
64
|
*
|
|
69
65
|
* This is idempotent - calling multiple times is safe.
|
|
70
66
|
*
|
|
@@ -74,65 +70,74 @@ async function initOpfsStorage() {
|
|
|
74
70
|
if (typeof navigator === "undefined" || !navigator.storage || typeof navigator.storage.getDirectory !== "function") throw new Error("OPFS (Origin Private File System) is not supported in this browser. Please use Chrome 86+, Safari 15.2+, or Firefox 111+.");
|
|
75
71
|
opfsRoot = await navigator.storage.getDirectory();
|
|
76
72
|
log.info("OPFS root obtained");
|
|
77
|
-
|
|
78
|
-
|
|
73
|
+
gpsPlusSlamDir = await opfsRoot.getDirectoryHandle("gps-plus-slam", { create: true });
|
|
74
|
+
sessionsDir = await gpsPlusSlamDir.getDirectoryHandle("sessions", { create: true });
|
|
79
75
|
log.info("OPFS storage initialized");
|
|
80
76
|
}
|
|
81
77
|
/**
|
|
82
|
-
*
|
|
78
|
+
* Get the sessions root directory handle.
|
|
79
|
+
* Used by consumers that need direct OPFS access (e.g. ZIP export).
|
|
80
|
+
*/
|
|
81
|
+
function getSessionsRootHandle() {
|
|
82
|
+
return sessionsDir;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Get the app root directory handle (gps-plus-slam/).
|
|
86
|
+
* Used by consumers that need to create additional directories alongside sessions/.
|
|
87
|
+
*/
|
|
88
|
+
function getAppRootHandle() {
|
|
89
|
+
return gpsPlusSlamDir;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Create a new recording session.
|
|
83
93
|
*
|
|
84
94
|
* Creates the directory structure:
|
|
85
|
-
* - /gps-
|
|
86
|
-
* - /gps-
|
|
87
|
-
* - /gps-
|
|
95
|
+
* - /gps-plus-slam/sessions/recording-{timestamp}/
|
|
96
|
+
* - /gps-plus-slam/sessions/recording-{timestamp}/actions/
|
|
97
|
+
* - /gps-plus-slam/sessions/recording-{timestamp}/frames/
|
|
88
98
|
*
|
|
89
|
-
* @param scenarioName - Name of the scenario (creates if doesn't exist)
|
|
90
99
|
* @param timestamp - Session start time (used for folder naming)
|
|
100
|
+
* @param _contextTag - Opaque tag; not used by the flat layout but accepted
|
|
101
|
+
* for interface compatibility with wrapping backends
|
|
91
102
|
* @returns Session information
|
|
92
103
|
* @throws Error if storage not initialized
|
|
93
104
|
*/
|
|
94
|
-
async function createSession(
|
|
95
|
-
if (!
|
|
96
|
-
currentScenarioHandle = await scenariosDir.getDirectoryHandle(scenarioName, { create: true });
|
|
105
|
+
async function createSession(timestamp, _contextTag) {
|
|
106
|
+
if (!sessionsDir) throw new Error("OPFS storage not initialized. Call initOpfsStorage first.");
|
|
97
107
|
const sessionName = `recording-${formatTimestamp(timestamp)}`;
|
|
98
|
-
currentSessionHandle = await
|
|
108
|
+
currentSessionHandle = await sessionsDir.getDirectoryHandle(sessionName, { create: true });
|
|
99
109
|
actionsHandle = await currentSessionHandle.getDirectoryHandle("actions", { create: true });
|
|
100
110
|
framesHandle = await currentSessionHandle.getDirectoryHandle("frames", { create: true });
|
|
101
|
-
log.info("Session created:",
|
|
102
|
-
return {
|
|
103
|
-
scenarioName,
|
|
104
|
-
sessionName
|
|
105
|
-
};
|
|
111
|
+
log.info("Session created:", sessionName);
|
|
112
|
+
return { sessionName };
|
|
106
113
|
}
|
|
107
114
|
/**
|
|
108
115
|
* Get the current session directory handle.
|
|
109
|
-
* Useful for test assertions.
|
|
110
116
|
* @internal
|
|
111
117
|
*/
|
|
112
118
|
function getSessionHandle() {
|
|
113
119
|
return currentSessionHandle;
|
|
114
120
|
}
|
|
115
121
|
/**
|
|
116
|
-
*
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
*
|
|
123
|
-
*
|
|
122
|
+
* Set the active session handles externally.
|
|
123
|
+
*
|
|
124
|
+
* Used by file-system.ts's scenario-based path to reuse opfs-storage's
|
|
125
|
+
* write infrastructure for sessions created outside the flat layout.
|
|
126
|
+
* This is a temporary bridge until the recorder migrates to
|
|
127
|
+
* ScenarioWrappingStorageBackend.
|
|
128
|
+
*
|
|
129
|
+
* @internal
|
|
124
130
|
*/
|
|
125
|
-
function
|
|
126
|
-
|
|
131
|
+
function setSessionHandles(session, actions, frames) {
|
|
132
|
+
currentSessionHandle = session;
|
|
133
|
+
actionsHandle = actions;
|
|
134
|
+
framesHandle = frames;
|
|
127
135
|
}
|
|
128
136
|
/**
|
|
129
137
|
* Safely write data to a file handle with proper cleanup.
|
|
130
138
|
*
|
|
131
139
|
* Uses try/finally to ensure the writable stream is always cleaned up,
|
|
132
140
|
* calling abort() on errors to prevent resource leaks and file locks.
|
|
133
|
-
*
|
|
134
|
-
* @param fileHandle - The file handle to write to
|
|
135
|
-
* @param data - The data to write (string or Blob)
|
|
136
141
|
*/
|
|
137
142
|
async function safeWriteToFile(fileHandle, data) {
|
|
138
143
|
const writable = await fileHandle.createWritable();
|
|
@@ -188,40 +193,19 @@ async function writeSessionMetadata(metadata) {
|
|
|
188
193
|
log.info("Session metadata written");
|
|
189
194
|
}
|
|
190
195
|
/**
|
|
191
|
-
* List all
|
|
192
|
-
*
|
|
193
|
-
* @returns Array of scenario folder names
|
|
194
|
-
*/
|
|
195
|
-
async function listScenarios() {
|
|
196
|
-
if (!scenariosDir) return [];
|
|
197
|
-
const scenarios = [];
|
|
198
|
-
for await (const entry of scenariosDir.values()) if (entry.kind === "directory") scenarios.push(entry.name);
|
|
199
|
-
return scenarios;
|
|
200
|
-
}
|
|
201
|
-
/**
|
|
202
|
-
* List all session names within a scenario.
|
|
196
|
+
* List all session names in OPFS storage.
|
|
203
197
|
*
|
|
204
|
-
* @param scenarioName - Name of the scenario
|
|
205
198
|
* @returns Array of session folder names
|
|
206
199
|
*/
|
|
207
|
-
async function listSessions(
|
|
208
|
-
if (!
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
for await (const entry of scenarioHandle.values()) if (entry.kind === "directory") sessions.push(entry.name);
|
|
213
|
-
return sessions;
|
|
214
|
-
} catch {
|
|
215
|
-
return [];
|
|
216
|
-
}
|
|
200
|
+
async function listSessions() {
|
|
201
|
+
if (!sessionsDir) return [];
|
|
202
|
+
const sessions = [];
|
|
203
|
+
for await (const entry of sessionsDir.values()) if (entry.kind === "directory") sessions.push(entry.name);
|
|
204
|
+
return sessions;
|
|
217
205
|
}
|
|
218
206
|
/**
|
|
219
207
|
* Check storage quota.
|
|
220
208
|
*
|
|
221
|
-
* Note: Prefer calling `initOpfsStorage()` before this function to ensure
|
|
222
|
-
* the Storage API is available. If the Storage Manager API is not supported,
|
|
223
|
-
* returns a safe default of `{ available: 0, used: 0 }`.
|
|
224
|
-
*
|
|
225
209
|
* @returns Available and used storage in bytes
|
|
226
210
|
*/
|
|
227
211
|
async function checkStorageQuota() {
|
|
@@ -239,4 +223,4 @@ async function checkStorageQuota() {
|
|
|
239
223
|
};
|
|
240
224
|
}
|
|
241
225
|
//#endregion
|
|
242
|
-
export { checkStorageQuota, createSession,
|
|
226
|
+
export { checkStorageQuota, createSession, getAppRootHandle, getSessionHandle, getSessionsRootHandle, initOpfsStorage, listSessions, resetOpfsStorage, resetSessionHandles, setSessionHandles, writeAction, writeFrame, writeSessionMetadata };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { StorageBackend };
|
|
1
|
+
import { n as StorageBackend, t as CreateSessionResult } from "../storage-backend-yVnuWGTr.js";
|
|
2
|
+
export { CreateSessionResult, StorageBackend };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as syncToExternalZip, i as
|
|
2
|
-
export { ZipExportResult, downloadZip, exportAndDownloadSession, exportSessionAsZip, syncToExternalZip };
|
|
1
|
+
import { a as downloadZip, c as syncToExternalZip, i as ZipExportResult, n as ZipContributorAddFile, o as exportAndDownloadSession, r as ZipExportContributor, s as exportSessionAsZip, t as ExportSessionAsZipOptions } from "../zip-export-BjrQPv0X.js";
|
|
2
|
+
export { ExportSessionAsZipOptions, ZipContributorAddFile, ZipExportContributor, ZipExportResult, downloadZip, exportAndDownloadSession, exportSessionAsZip, syncToExternalZip };
|