@novorender/web_app / OfflineScene
Class: OfflineScene
An offline scene.
Remarks
This class supports incremental synchronization between offline and online storage. Error and status updates are reported to the logger property. By default it's undefined, so to display status, events and progress, you must assign your own object implementing the Logger interface.
Accessors
id
get id(): string
Get the scene id.
Returns
string
Defined in
@novorender/offline/scene.ts:33
Constructors
new OfflineScene()
new OfflineScene(
context,
dir,
manifest): OfflineScene
Parameters
Parameter | Type | Description |
---|---|---|
context | OfflineViewState | The offline context for this scene. |
dir | OfflineDirectoryOPFS | The storage directory for this scene. |
manifest | SceneManifest | The file manifest this scene. Remarks Initially, this may be empty or partial. It may change when the scene is synchronized. |
Returns
Defined in
@novorender/offline/scene.ts:19
Methods
delete()
delete(): Promise<void>
Delete all downloaded files for this scene and remove it from the context's list of offline scenes.
Returns
Promise
<void
>
Defined in
@novorender/offline/scene.ts:38
deleteStaleFiles()
deleteStaleFiles(sceneIndexUrl, abortSignal): Promise<boolean>
Delete files which are no longer used by the current manifest
Parameters
Parameter | Type | Description |
---|---|---|
sceneIndexUrl | URL | The url to the scene index.json file, complete with sas key. |
abortSignal | AbortSignal | A signal to abort downloads/synchronization. |
Returns
Promise
<boolean
>
True, if completed successfully, false if not.
Remarks
Errors are logged in the logger.
Defined in
@novorender/offline/scene.ts:116
getUsedSize()
getUsedSize(): Promise<number>
Get total number of used bytes.
Returns
Promise
<number
>
Remarks
This file will scan through all the offline files to sum of their total size, which can take a long time to complete. Use manifest data instead if a valid manifest if available.
Defined in
@novorender/offline/scene.ts:56
readManifest()
readManifest(manifestUrl, abortSignal): Promise<undefined | number>
Reads the manifest file.
Parameters
Parameter | Type | Description |
---|---|---|
manifestUrl | URL | The url to the offline manifest, with sas key. |
abortSignal | AbortSignal | A signal to abort downloads/synchronization. |
Returns
Promise
<undefined
| number
>
Total number of bytes in scene, if it fails it returns undefined
Defined in
@novorender/offline/scene.ts:73
sync()
sync(sceneIndexUrl, abortSignal): Promise<boolean>
Incrementally synchronize scene files with online storage.
Parameters
Parameter | Type | Description |
---|---|---|
sceneIndexUrl | URL | The url to the scene index.json file, complete with sas key. |
abortSignal | AbortSignal | A signal to abort downloads/synchronization. |
Returns
Promise
<boolean
>
True, if completed successfully, false if not.
Remarks
Synchronization may be resumed after an abort/failure. It compares the file manifest of local files with the online version and downloads only the difference. Errors are logged in the logger.
Defined in
@novorender/offline/scene.ts:166
Properties
context
readonly context: OfflineViewState;
The offline context for this scene.
Defined in
@novorender/offline/scene.ts:21
dir
readonly dir: OfflineDirectoryOPFS;
The storage directory for this scene.
Defined in
@novorender/offline/scene.ts:23
logger
logger: undefined | Logger;
Logger for errors and status updates.
Defined in
@novorender/offline/scene.ts:18
manifest
manifest: SceneManifest;
The file manifest this scene.
Remarks
Initially, this may be empty or partial. It may change when the scene is synchronized.