squishjs

1.3.6 • Public • Published

Squish

This repo contains the game library used by homegames-core and homegames-web to efficiently serialize & deserialize game data.

squish/unsquish

This is just serialization/deserialization. Conceptually similar to protobufs, squish contains schema definitions shared by the server and client that lets us transmit game data as efficiently as possible.

const { squish, unsquish, Colors, GameNode, Shapes, ShapeUtils } = require('squish-1006');
const node = new GameNode.Shape({
  shapeType: Shapes.POLYGON,
  fill: Colors.COLORS.RED,
  coordinates2d: ShapeUtils.rectangle(20, 20, 10, 10)
});

const squished = squish(node);
[
  3,           0,            0,            53,
  2,           43,           0,            11,
  [Number: 0], [Number: 0],  [Number: 32], [Number: 61],
  [Number: 3], [Number: 90], [Number: 63], [Number: 44],
  44,          0,            3,            53,
  0,           7,            255,          0,
  0,           255,          55,           0,
  4,           3,            52,           0,
  23,          20,           0,            20,
  0,           30,           0,            20,
  0,           30,           0,            30,
  0,           20,           0,            30,
  0,           20,           0,            20,
  0
]

const unsquished = unsquish(squished);
Shape {
  node: InternalGameNode {
    id: [Number: 326103906344],
    children: [],
    color: undefined,
    handleClick: undefined,
    coordinates2d: [ [Array], [Array], [Array], [Array], [Array] ],
    border: undefined,
    fill: [ 255, 0, 0, 255 ],
    text: undefined,
    asset: undefined,
    effects: null,
    input: null,
    listeners: Set(0) {},
    playerIds: [],
    subType: 3
  },
  id: [Number: 326103906344]
}

Game

The Game class is a base class that allows external components (eg. a Squisher) to listen to state updates. All games in Homegames extend the Game class.

Versioning

Homegames core & web use multiple versions of squish. This allows games using older versions of squish to remain compatible with newer versions of Homegames.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.3.63latest

Version History

VersionDownloads (Last 7 Days)Published
1.3.63
1.3.50
1.3.20
1.3.10
1.3.00
1.2.00
1.1.30
1.1.20
1.1.10
1.1.00
1.0.110
1.0.101
1.0.91
1.0.81
1.0.72
1.0.63
1.0.53
1.0.421
1.0.30
1.0.20
1.0.10
1.0.00
0.7.670
0.7.660
0.7.651
0.7.621
0.7.610
0.7.600
0.7.562
0.7.550
0.7.541
0.7.530
0.7.520
0.7.511
0.7.51
0.7.40
0.7.30
0.7.20
0.7.11
0.6.430
0.6.420
0.6.410
0.6.400
0.6.330
0.6.320
0.6.310
0.6.30
0.6.20
0.6.10
0.5.30
0.5.20
0.5.10
0.5.00
0.4.90
0.4.240
0.4.230
0.4.210
0.4.200

Package Sidebar

Install

npm i squishjs

Homepage

homegames.io

Weekly Downloads

40

Version

1.3.6

License

ISC

Unpacked Size

147 kB

Total Files

48

Last publish

Collaborators

  • yazeedloonat
  • prosif