Skip to content

Commit

Permalink
prepare for npmjs
Browse files Browse the repository at this point in the history
  • Loading branch information
adbenitez committed Nov 14, 2024
1 parent fa83109 commit d85de87
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 33 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ node_modules
.DS_Store
*~

example/pnpm-lock.yaml
example/pnpm-lock.yaml
example/dist
example/dist-xdc
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# webxdc-scores
# Highscores

Library to facilitate the process of creating score-based webxdc games.
It can handle multiple scoreboards at the same time.

## Install

```
npm install git+https://github.com/webxdc/webxdc-scores.git
npm install @webxdc/highscores
```

## Usage

Import webxdc-scores lib (`webxdc.js` also needs to be included) in your `index.html`:
Import `@webxdc/highscores` lib (`webxdc.js` also needs to be included) in your `index.html`:

```html
<html>
Expand All @@ -20,7 +21,7 @@ Import webxdc-scores lib (`webxdc.js` also needs to be included) in your `index.
<script src="webxdc.js"></script>

<script type="module">
import "webxdc-scores";
import "@webxdc/highscores";
// you can use window.highscores here
</script>
</head>
Expand All @@ -41,14 +42,14 @@ Include webxdc-scores lib (together with `webxdc.js`) in your `index.html`:
<meta name="viewport" content="width=device-width" />

<script src="webxdc.js"></script>
<script src="./node_modules/webxdc-scores/dist/webxdc-scores.umd.js"></script>
<script src="./node_modules/@webxdc/highscores/dist/webxdc-scores.umd.js"></script>
</head>
<body>
...
</body>
</html>
```

Then you will have an scores API via `window.highscores` object, check [dist/webxdc-scores.d.ts](https://github.com/webxdc/webxdc-scores/blob/main/dist/webxdc-scores.d.ts) file for documentation of the available API.
Then you can access the API via `window.highscores` object, check [dist/webxdc-scores.d.ts](https://github.com/webxdc/highscores/blob/main/dist/webxdc-scores.d.ts) file for documentation of the available API.

For a full example check the [example/index.html](https://github.com/webxdc/webxdc-scores/blob/main/example/index.html) file.
For a full example check the [example/index.html](https://github.com/webxdc/highscores/blob/main/example/index.html) file.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions dist/highscores.umd.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion dist/webxdc-scores.umd.js

This file was deleted.

2 changes: 0 additions & 2 deletions example/.gitignore

This file was deleted.

4 changes: 0 additions & 4 deletions example/.prettierignore

This file was deleted.

4 changes: 2 additions & 2 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script src="webxdc.js"></script>
<link
rel="stylesheet"
href="./node_modules/webxdc-scores/dist/webxdc-scores.css"
href="./node_modules/@webxdc/highscores/dist/highscores.css"
/>
<style>
html,
Expand Down Expand Up @@ -36,7 +36,7 @@ <h3>Score: <span id="self-score">0</span></h3>
</p>
<div id="scoreboard"></div>
<script type="module">
import "webxdc-scores";
import "@webxdc/highscores";
const scoreboard = document.getElementById("scoreboard");

await window.highscores.init({
Expand Down
4 changes: 2 additions & 2 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"type": "module",
"scripts": {
"build": "vite build",
"start": "vite --port 3000",
"build": "vite build",
"emulator": "concurrently \"npm run start\" \"webxdc-dev run http://localhost:3000\"",
"fix": "prettier --write .",
"check": "prettier --check ."
Expand All @@ -15,6 +15,6 @@
"webxdc-vite-plugins": "github:webxdc/webxdc-vite-plugins"
},
"dependencies": {
"webxdc-scores": "github:webxdc/webxdc-scores"
"webxdc-scores": "@webxdc/highscores"
}
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "webxdc-scores",
"name": "@webxdc/highscores",
"description": "Highscores API for webxdc apps",
"version": "4.0.1",
"license": "MIT",
Expand All @@ -10,25 +10,25 @@
],
"repository": {
"type": "git",
"url": "https://github.com/webxdc/webxdc-scores.git"
"url": "https://github.com/webxdc/highscores.git"
},
"bugs": {
"url": "https://github.com/webxdc/webxdc-scores/issues"
"url": "https://github.com/webxdc/highscores/issues"
},
"homepage": "https://github.com/webxdc/webxdc-scores",
"main": "./dist/webxdc-scores.umd.js",
"module": "./dist/webxdc-scores.mjs",
"types": "./dist/webxdc-scores.d.ts",
"source": "./src/webxdc-scores.js",
"homepage": "https://github.com/webxdc/highscores",
"main": "./dist/highscores.umd.js",
"module": "./dist/highscores.mjs",
"types": "./dist/highscores.d.ts",
"source": "./src/highscores.js",
"files": [
"dist"
],
"exports": {
".": {
"import": "./dist/webxdc-scores.mjs",
"require": "./dist/webxdc-scores.umd.js"
"import": "./dist/highscores.mjs",
"require": "./dist/highscores.umd.js"
},
"./dist/webxdc-scores.css": "./dist/webxdc-scores.css"
"./dist/highscores.css": "./dist/highscores.css"
},
"scripts": {
"build": "vite build",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ export default defineConfig({
build: {
lib: {
// Could also be a dictionary or array of multiple entry points
entry: resolve(__dirname, "src/webxdc-scores.js"),
name: "webxdc-scores",
entry: resolve(__dirname, "src/highscores.js"),
name: "@webxdc/highscores",
// the proper extensions will be added
fileName: "webxdc-scores",
fileName: "highscores",
},
},
});

0 comments on commit d85de87

Please sign in to comment.