---
url: https://cri-middleware.github.io/SSPlayerForReactNative/api/interfaces/SsRuntime.md
---
# Interface: SsRuntime

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1046](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1046)

The module root. One instance per app.

## Extends

* `HybridObject`<{ `android`: `"c++"`; `ios`: `"c++"`; }>

## Properties

### hasAssetDirectory

> `readonly` **hasAssetDirectory**: `boolean`

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1058](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1058)

Whether this build can read the app's asset directory at all.

Always true on iOS. On Android it stays false until the bootstrap provider
has handed over the `AssetManager`, which turns "the library is not wired
up" into a different message from "that pack is not in the app".

***

### liveHandles

> `readonly` **liveHandles**: [`SsLiveHandles`](SsLiveHandles.md)

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1068](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1068)

Live native handles right now — see `SsLiveHandles`.

Cheap enough to poll: two relaxed atomic loads, no lock and no walk. It is
a diagnostic rather than something an app should branch on, but it is on the
shipping surface deliberately — a leak check that only exists in a debug
build cannot be run on the device where leaks actually matter.

***

### name

> `readonly` **name**: `string`

Defined in: node_modules/.pnpm/nitro-core@0.37.2/node_modules/nitro-core/js/lib/typescript/module/HybridObject.d.ts:52

The `HybridObject`'s name.

#### Inherited from

`HybridObject.name`

***

### version

> `readonly` **version**: `string`

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1049](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1049)

SDK version the linked `libssruntime` reports.

## Methods

### createContext()

> **createContext**(`resource`): [`SsContext`](SsContext.md)

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1103](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1103)

#### Parameters

##### resource

[`SsResource`](SsResource.md)

#### Returns

[`SsContext`](SsContext.md)

***

### createResourceFromAsset()

> **createResourceFromAsset**(`path`): [`SsResource`](SsResource.md)

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1101](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1101)

Loads a `.ssab` out of the app's **asset directory** — the pack tree the
build copied in, addressed as `ss/overall/Basic.ssab`.

This is the route that makes the names a pack carries resolve. Everything a pack
points at — a cellmap's `image_path`, an `external_textures` entry, an
Instance part's external `.ssab`, a `.ssqb`'s `ref_anime_pack` — is a name
relative to the `.ssab`, so it can only be resolved where the whole
directory survives into the app. Metro does not preserve one (it bundles
what a `require()` names, and Android's packager then flattens it into
`res/`), so the directory is copied in out-of-band by the config plugin.

Still no JS heap: iOS opens the file inside the `.app`, Android reads the
APK entry through `AAssetManager`, and either way the bytes go straight to
the Brain.

#### Parameters

##### path

`string`

#### Returns

[`SsResource`](SsResource.md)

***

### createResourceFromBytes()

> **createResourceFromBytes**(`bytes`): [`SsResource`](SsResource.md)

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1083](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1083)

The fallback for sources `fopen` cannot reach: an `http(s)` URL, so a Metro dev server or a CDN. The
bytes pass through the JS heap, which is exactly what the two calls either
side of this one exist to avoid.

#### Parameters

##### bytes

`ArrayBuffer`

#### Returns

[`SsResource`](SsResource.md)

***

### createResourceFromPath()

> **createResourceFromPath**(`path`): [`SsResource`](SsResource.md)

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1076](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1076)

Reads the file natively and hands the bytes straight to the Brain.

The `.ssab` never enters the JS heap. `path` must
already be a filesystem path — resolving one is L3's job.

#### Parameters

##### path

`string`

#### Returns

[`SsResource`](SsResource.md)

***

### decodeImage()

> **decodeImage**(`image`): `Promise`<`void`>

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1136](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1136)

Decodes `image` on a worker thread if it is still encoded, and swaps the
decoded pixels into it.

`Skia.Image.MakeImageFromEncoded` returns an image that decodes the first
time it is drawn, and a large atlas stalls the thread rendering the canvas
for tens of milliseconds. Decoded here, the image keeps its pixels
(width × height × 4 bytes) for as long as it lives. Leave the image alone
until the promise settles.

#### Parameters

##### image

[`SkImageHandle`](../type-aliases/SkImageHandle.md)

#### Returns

`Promise`<`void`>

***

### dispose()

> **dispose**(): `void`

Defined in: node_modules/.pnpm/nitro-core@0.37.2/node_modules/nitro-core/js/lib/typescript/module/HybridObject.d.ts:94

Disposes any resources this `HybridObject` might hold natively,
and releases this `HybridObject`'s `NativeState`.

After calling [`()`](#dispose), this object can no longer be used.

Eagerly disposing a `HybridObject` could be beneficial for a queue-/handler-architecture
where a bunch of Hybrid Objects are allocated, and later deallocated once a callback (e.g. a render function)
completes.

#### Returns

`void`

#### Note

It is **NOT** required to call [`()`](#dispose) manually, as the JavaScript
Garbage Collector automatically disposes and releases any resources when needed.
It is purely optional to eagerly-, and manually-, call [`()`](#dispose) here - **use with caution!**

#### Inherited from

`HybridObject.dispose`

***

### equals()

> **equals**(`other`): `boolean`

Defined in: node_modules/.pnpm/nitro-core@0.37.2/node_modules/nitro-core/js/lib/typescript/module/HybridObject.d.ts:79

Returns whether this `HybridObject` is the same object as `other`.

While two `HybridObject`s might not be equal when compared with `==`, they might still
hold the same underlying `HybridObject`, in which case [`equals(other)`](#equals)
will return `true`.

#### Parameters

##### other

`HybridObject`<{ `android`: `"c++"`; `ios`: `"c++"`; }>

#### Returns

`boolean`

#### Example

```ts
const hybridA = SomeModule.getExistingHybridInstance()
const hybridB = SomeModule.getExistingHybridInstance()
console.log(hybridA.equals(hybridB)) // true
```

#### Inherited from

`HybridObject.equals`

***

### hashString()

> **hashString**(`value`): `number`

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1124](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1124)

The Brain's own FNV-1a (`ss_runtime_hash_string`), the hash `cellmap.name`
and `DrawBatch.texture_hash` are both keyed on.

Exposed rather than reimplemented in TypeScript on purpose: two
implementations of a hash is one more than can be kept in agreement, and a
silent disagreement shows up as a texture that simply never resolves.

#### Parameters

##### value

`string`

#### Returns

`number`

***

### readAsset()

> **readAsset**(`path`): `ArrayBuffer`

Defined in: [packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts:1114](https://github.com/cri-middleware/SSPlayerForReactNative/blob/ddb0878ad347fd4a411e4e2eb0829a948cb07ff8/packages/react-native-spritestudio/src/specs/SsRuntime.nitro.ts#L1114)

An asset's bytes, for the things JS itself has to decode — a texture, on
its way to `Skia.Data.fromBytes`.

`Skia.Data.fromURI` covers `file:` and `http:` but knows nothing about
either platform's asset storage, so this is the seam that keeps "where the
app keeps its assets" a question only C++ has to answer. Throws, naming the
path, rather than returning empty.

#### Parameters

##### path

`string`

#### Returns

`ArrayBuffer`

***

### toString()

> **toString**(): `string`

Defined in: node_modules/.pnpm/nitro-core@0.37.2/node_modules/nitro-core/js/lib/typescript/module/HybridObject.d.ts:64

Returns a string representation of the given `HybridObject`.

Unless overridden by the `HybridObject`, this will return the name of the object.

#### Returns

`string`

#### Example

```ts
const hybridA = SomeModule.getExistingHybridInstance()
console.log(hybridA.toString()) // [HybridObject HybridA]
```

#### Inherited from

`HybridObject.toString`
