1.0.9 • Published 12 months ago

d2s-ui-react v1.0.9

Weekly downloads
-
License
ISC
Repository
github
Last release
12 months ago

d2s-ui-react

React components based on d2s-ui

Table of contents

Preface

For item images to render, the project needs access to a copy of Diablo II's extracted data. Suggest reading through the next two sections, and checking out the working example, prior to integrating with another project.

Data directory

  • Download Ladik's CASC Viewer
  • Choose "open storage" and select D2R's data directory, e.g...
    • C:\Program Files (x86)\Diablo II Resurrected\Data
  • Right click "data" in the navigation pane, then export
  • When we refer to "d2d" below, we're referring to that exported data directory
-d2d
--global
--local

Working example (clone repo)

git clone git@github.com:d2r-app/d2s-ui-react.git
cd d2s-ui-react
cp -r [your-d2d] svr/d2d
cp [your-hero-save-file] hero.d2s
npm i
node svr/api
(open new terminal)
npm start

If you receive the error sh: 1: sass: not found, then install sass... sudo apt install sass

Example Hero

Integration (install via npm)

Installation

Example project structure with existing API:

```
-project
--src
--svr
---api.js
```
npm i d2s-ui-react
tar xzf node_modules/d2s-ui-react/dist/d2s.tar.gz -C svr
echo "/svr/d2s" >> .gitignore
  • Note the the newly created/ignored d2s directory
    • It contains d2s and a modified d2s-ui API

Usage, client-side

import { Hero } from 'd2s-ui-react';
<Hero hero={parsedSaveFile} onClose={optionalCloseFunction}>

Include onClose for a "close hero" button.

You must also include one of the following two Hero attributes for item images to render:

  • api="/api/d2s/img"
    • Web API for responding to d2s-ui image requests
    • See Express App below
  • handleImgReq={yourAPI.d2sAPI.handleImgReq}
    • Local API for responding to d2s-ui image requests
    • See Native App below

Usage, server-side (Express App)

const d2sAPI = require('./d2s/api');
const yourApp = express();
d2sAPI.init({ app: yourApp });

This configures an Express route for /api/d2s/img

Usage, server-side (Native App)

const d2sAPI = require('./d2s/api');
const yourAPI = {...};
d2sAPI.init({ api: yourAPI });

This exposes d2sAPI's image handler as yourAPI.d2sAPI.handleImgReq

Usage, parsing save files

const d2s = require('./d2s');
const hero = await d2s.read(await fs.promises.readFile('hero.d2s'), d2s.constants));

Dev

To update d2s...

Download d2s.bundle.js and constants_99.bundle.js from a d2s release, then combine:

cd ~/Downloads
rm index.js
for f in d2s.bundle.js constants_99.bundle.js; do (cat ${f}; echo) >> index.js; done
echo -e "\nd2s.constants = constants_99.constants;\nmodule.exports = d2s;\n" >> index.js
cp index.js /d2s-ui-react/svr/d2s/

To build d2s-ui-react...

Execute npm run build (creates dist/)

1.0.9

12 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.3

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.1.70

1 year ago

0.1.71

1 year ago

0.1.66

1 year ago

0.1.67

1 year ago

0.1.68

1 year ago

0.1.69

1 year ago

0.1.63

1 year ago

0.1.64

1 year ago

0.1.65

1 year ago

0.1.61

1 year ago

0.1.62

1 year ago

0.1.58

2 years ago

0.1.59

2 years ago

0.1.60

2 years ago

0.1.57

2 years ago

0.1.56

2 years ago

0.1.55

2 years ago

0.1.54

2 years ago

0.1.53

2 years ago

0.1.52

2 years ago

0.1.51

2 years ago

0.1.50

2 years ago

0.1.49

2 years ago

0.1.48

2 years ago

0.1.47

2 years ago

0.1.46

2 years ago

0.1.45

2 years ago

0.1.44

2 years ago

0.1.43

2 years ago

0.1.42

2 years ago

0.1.41

2 years ago

0.1.40

2 years ago

0.1.39

2 years ago

0.1.38

2 years ago

0.1.37

2 years ago

0.1.36

2 years ago

0.1.35

2 years ago

0.1.34

2 years ago

0.1.33

2 years ago

0.1.32

2 years ago

0.1.31

2 years ago

0.1.30

2 years ago

0.1.29

2 years ago

0.1.28

2 years ago

0.1.27

2 years ago

0.1.26

2 years ago

0.1.25

2 years ago

0.1.24

2 years ago

0.1.22

2 years ago

0.1.21

2 years ago

0.1.20

2 years ago

0.1.19

2 years ago

0.1.18

2 years ago

0.1.17

2 years ago

0.1.16

2 years ago

0.1.15

2 years ago

0.1.14

2 years ago

0.1.13

2 years ago

0.1.12

2 years ago

0.1.11

2 years ago

0.1.10

2 years ago

0.1.9

2 years ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago