Menu

flipnote.js

Index

Loader Type aliases

LoaderDefinitionList

LoaderDefinitionList: LoaderDefinition<any>[]

A list of LoaderDefinition items to use when attempting to load a Flipnote. Loaders are tried in sequence until a matching one is found for the requested input.

LoaderReject

LoaderReject: (err?: any) => void

Rejection function passed to a loader's load method. Call when a Flipnote couldn't be loaded.

Type declaration

    • (err?: any): void
    • Parameters

      • Optional err: any

      Returns void

LoaderResolve

LoaderResolve: (result: ArrayBuffer) => void

Resolution function passed to a loader's load method. Call when a Flipnote has been loaded successfully. The result should be Flipnote file data as an ArrayBuffer.

Type declaration

    • (result: ArrayBuffer): void
    • Parameters

      • result: ArrayBuffer

      Returns void

Other Type aliases

Flipnote

Flipnote type. An object with this type is guranteed to implement the {@link FlipnoteParser} API.

FlipnoteLayerVisibility

FlipnoteLayerVisibility: Record<number, boolean>

Flipnote layer visibility

FlipnotePaletteColor

FlipnotePaletteColor: [number, number, number, number]

RGBA color

FlipnotePaletteDefinition

FlipnotePaletteDefinition: Record<string, FlipnotePaletteColor>

Defines the colors used for a given Flipnote format

FlipnoteParserSettings

FlipnoteParserSettings: Partial<PpmParserSettings & KwzParserSettings>

Optional settings to pass to a Flipnote parser instance. See PpmParserSettings and KwzParserSettings

FlipnoteSoundEffectFlags

FlipnoteSoundEffectFlags: Record<FlipnoteSoundEffectTrack, boolean>

Flipnote sound flags, indicating which sound effect tracks are used on a given frame

FlipnoteSource

FlipnoteSource: string | ArrayBuffer | Buffer | File

Source to load a Flipnote from. Depending on the operating envionment, this can be:

  • A string representing a web URL
  • An ArrayBuffer
  • A File object (Browser only)
  • A Buffer object (NodeJS only)

FlipnoteSourceParser

FlipnoteSourceParser<S, D>: (source: S, parserConfig?: Partial<FlipnoteParserSettings>, loaders?: LoaderDefinitionList) => Promise<D>

Implements loading a Flipnote from a given source type, and returns a promise which resolves to a Flipnote parser instance.

Type parameters

  • S

  • D

Type declaration

FlipnoteThumbImage

FlipnoteThumbImage: { data: ArrayBuffer; format: FlipnoteThumbImageFormat; height: number; width: number }

Represents a decoded Flipnote thumbnail image

Type declaration

  • data: ArrayBuffer

    Image data

  • format: FlipnoteThumbImageFormat
  • height: number

    Image height in pixels

  • width: number

    Image width in pixels

GifPaletteColor

GifPaletteColor: [number, number, number, number]

GIF RGBA palette color definition

KwzParserSettings

KwzParserSettings: { borderCrop: boolean; dsiLibraryNote: boolean; guessInitialBgmState: boolean; initialBgmPredictor: number | null; initialBgmStepIndex: number | null; initialSePredictors: number[] | null; initialSeStepIndices: number[] | null; quickMeta: boolean }

KWZ parser options for enabling optimizations and other extra features

Type declaration

  • borderCrop: boolean

    Automatically crop out the border around any frames

  • dsiLibraryNote: boolean

    Apply special cases for DSi library notes

  • guessInitialBgmState: boolean

    Nintendo messed up the initial adpcm state for a bunch of the PPM to KWZ conversions on DSi Library. They are effectively random. By default flipnote.js will try to make a best guess, but you can disable this and provide your own state values

    This is only enabled if dsiLibraryNote is also set to true

  • initialBgmPredictor: number | null

    Manually provide the initial adpcm predictor for the BGM track.

    This is only enabled if dsiLibraryNote is also set to true

  • initialBgmStepIndex: number | null

    Manually provide the initial adpcm step index for the BGM track.

    This is only enabled if dsiLibraryNote is also set to true

  • initialSePredictors: number[] | null

    Manually provide an initial adpcm predictor for each sound effect track.

    This is only enabled if dsiLibraryNote is also set to true

  • initialSeStepIndices: number[] | null

    Manually provide an initial adpcm step index for each sound effect track.

    This is only enabled if dsiLibraryNote is also set to true

  • quickMeta: boolean

    Skip full metadata parsing for quickness

PcmAudioBuffer

PcmAudioBuffer: Int16Array | Float32Array

PCM audio buffer types. Supports s16_le, or float32_le with a range of -1.0 to 1.0

PlayerLayerVisibility

PlayerLayerVisibility: Record<number, boolean>

PpmParserSettings

PpmParserSettings: {}

PPM parser options for enabling optimizations and other extra features. None are currently implemented

Type declaration

UniversalCanvasOptions

UniversalCanvasOptions: WebglCanvasOptions & Html5CanvasOptions

WavSampleBuffer

WavSampleBuffer: Int16Array | Float32Array

Loader Variables

Const DEFAULT_LOADERS

DEFAULT_LOADERS: LoaderDefinitionList = [webUrlLoader,nodeUrlLoader,fileLoader,blobLoader,nodeBufferLoader,arrayBufferLoader]

Other Variables

Const KWZ_FRAMERATES

KWZ_FRAMERATES: number[] = [.2, .5, 1, 2, 4, 6, 8, 12, 20, 24, 30]

KWZ framerates in frames per second, indexed by the in-app frame speed

Const KWZ_PUBLIC_KEY

KWZ_PUBLIC_KEY: string = `-----BEGIN PUBLIC KEY-----MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAuv+zHAXXvbbtRqxADDeJArX2b9RMxj3T+qpRg3FnIE/jeU3tj7eoDzsMduY+D/UT9CSnP+QHYY/vf0n5lqX9s6ljoZAmyUuruyj1e5Bg+fkDEu/yPEPQjqhbyywCyYL4TEAOJveopUBx9fdQxUJ6J4J5oCE/Im1kFrlGW+puARiHmt3mmUyNzO8bI/Jx3cGSfoOHJG1foEaQsI5aaKqApBqxtzvwqMhudcZtAWSyRMBMlndvkRnVTDNTfTXLOYdHShCIgnKULCTH87uLBIP/nsmr4/bnQz8q2rp/HyVO+0yjR6mVr0NX5APJQ+6riJmGg3t3VOldhKP7aTHDUW+hkQIDAQAB-----END PUBLIC KEY-----`

RSA public key used to verify that the KWZ file signature is genuine.

This cannot be used to resign Flipnotes, it can only verify that they are valid

Const PPM_FRAMERATES

PPM_FRAMERATES: number[] = [0.5, 0.5, 1, 2, 4, 6, 12, 20, 30]

PPM framerates in frames per second, indexed by the in-app frame speed. Frame speed 0 is never normally used

Const PPM_PUBLIC_KEY

PPM_PUBLIC_KEY: string = `-----BEGIN PUBLIC KEY-----MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDCPLwTL6oSflv+gjywi/sM0TUB90xqOvuCpjduETjPoN2FwMebxNjdKIqHUyDu4AvrQ6BDJc6gKUbZ1E27BGZoCPH49zQRb+zAM6M9EjHwQ6BABr0u2TcF7xGg2uQ9MBWz9AfbVQ91NjfrNWo0f7UPmffv1VvixmTk1BCtavZxBwIDAQAB-----END PUBLIC KEY-----`

RSA public key used to verify that the PPM file signature is genuine.

This cannot be used to resign Flipnotes, it can only verify that they are valid

Const version

version: string = FLIPNOTEJS_VERSION

flipnote.js library version (exported as flipnote.version). You can find the latest version on the project's NPM page.

Functions

convertKwzFsidToPpmFsid

  • convertKwzFsidToPpmFsid(fsid: string): string
  • Convert a KWZ Flipnote Studio ID (from a Nintendo DSi Library Flipnote) to the format used by PPM Flipnote Studio IDs. Will return null if the conversion could not be made.

    Parameters

    • fsid: string

    Returns string

convertPpmFsidToKwzFsidSuffix

  • convertPpmFsidToKwzFsidSuffix(fsid: string): string
  • Convert a PPM Flipnote Studio ID to the format used by KWZ Flipnote Studio IDs (as seen in Nintendo DSi Library Flipnotes). Will return null if the conversion could not be made.

    NOTE: KWZ Flipnote Studio IDs contain an extra two characters at the beginning. It is not possible to resolve these from a PPM Flipnote Studio ID.

    Parameters

    • fsid: string

    Returns string

convertPpmFsidToPossibleKwzFsids

  • convertPpmFsidToPossibleKwzFsids(fsid: string): string[]
  • Convert a PPM Flipnote Studio ID to an array of all possible matching KWZ Flipnote Studio IDs (as seen in Nintendo DSi Library Flipnotes). Will return null if the conversion could not be made.

    Parameters

    • fsid: string

    Returns string[]

getFsidRegion

getKwzFsidRegion

  • Get the region for any valid Flipnote Studio 3D user ID. NOTE: This may be incorrect for IDs that are not from the DSi Library.

    Parameters

    • fsid: string

    Returns FlipnoteRegion

getPpmFsidRegion

isFsid

  • isFsid(fsid: string): boolean
  • Indicates whether the input is a valid Flipnote Studio or Flipnote Studio 3D user ID

    Parameters

    • fsid: string

    Returns boolean

isKwzDsiLibraryFsid

  • isKwzDsiLibraryFsid(fsid: string): boolean
  • Indicates whether the input is a valid DSi Library user ID

    Parameters

    • fsid: string

    Returns boolean

isKwzFsid

  • isKwzFsid(fsid: string): boolean
  • Indicates whether the input is a valid Flipnote Studio 3D user ID

    Parameters

    • fsid: string

    Returns boolean

isPpmFsid

  • isPpmFsid(fsid: string): boolean
  • Indicates whether the input is a valid Flipnote Studio user ID

    Parameters

    • fsid: string

    Returns boolean

Const parseSource

  • Load a Flipnote from a given source, returning a promise with a parser object. It will auto-detect the Flipnote format and return either a PpmParser or KwzParser accordingly.

    Parameters

    • source: FlipnoteSource

      Source to load a Flipnote from. Depending on the operating environment, this can be:

      • A string representing a web URL
      • An ArrayBuffer
      • A File object (Browser only)
      • A Buffer object (NodeJS only) You can also pass your own list of loaders to support your own source types.
    • Optional parserConfig: Partial<Partial<KwzParserSettings>>

      Config settings to pass to the parser, see FlipnoteParserSettings

    • Optional loaders: LoaderDefinitionList

      Optional list of file loaders (LoaderDefinition) when attempting to load a Flipnote. Loaders are tried in sequence until a matching one is found for the requested input.

    Returns Promise<FlipnoteParserBase>

testKwzFsidMatchesPpmFsid

  • testKwzFsidMatchesPpmFsid(kwzFsid: string, ppmFsid: string): boolean
  • Tests if a KWZ Flipnote Studio ID (from a Nintendo DSi Library Flipnote) matches a given PPM-formatted Flipnote Studio ID.

    Parameters

    • kwzFsid: string
    • ppmFsid: string

    Returns boolean

Loader Object literals

Const arrayBufferLoader

arrayBufferLoader: object

Loader for ArrayBuffer objects

load

matches

  • matches(source: any): boolean

Const blobLoader

blobLoader: object

Loader for Blob objects (browser only)

load

matches

  • matches(source: any): boolean

Const fileLoader

fileLoader: object

Loader for File objects (browser only)

load

matches

  • matches(source: any): boolean

Const nodeBufferLoader

nodeBufferLoader: object

Loader for Buffer objects (Node only)

load

matches

  • matches(source: any): boolean

Const nodeUrlLoader

nodeUrlLoader: object

Loader for web url strings (Node only)

load

matches

  • matches(source: any): boolean

Const webUrlLoader

webUrlLoader: object

Loader for web url strings (Browser only)

load

matches

  • matches(source: any): boolean

Other Object literals

Const KWZ_PALETTE

KWZ_PALETTE: object

KWZ color defines (red, green, blue, alpha)

BLACK

BLACK: [number, number, number, number] = [0x10, 0x10, 0x10, 0xff]

BLUE

BLUE: [number, number, number, number] = [0x00, 0x38, 0xce, 0xff]

GREEN

GREEN: [number, number, number, number] = [0x00, 0x86, 0x31, 0xff]

NONE

NONE: [number, number, number, number] = [0xff, 0xff, 0xff, 0x00]

RED

RED: [number, number, number, number] = [0xff, 0x10, 0x10, 0xff]

WHITE

WHITE: [number, number, number, number] = [0xff, 0xff, 0xff, 0xff]

YELLOW

YELLOW: [number, number, number, number] = [0xff, 0xe7, 0x00, 0xff]

Const PPM_PALETTE

PPM_PALETTE: object

PPM frame color defines (red, green, blue, alpha)

BLACK

BLACK: [number, number, number, number] = [0x0e, 0x0e, 0x0e, 0xff]

BLUE

BLUE: [number, number, number, number] = [0x0a, 0x39, 0xff, 0xff]

RED

RED: [number, number, number, number] = [0xff, 0x2a, 0x2a, 0xff]

WHITE

WHITE: [number, number, number, number] = [0xff, 0xff, 0xff, 0xff]