Skip to content

Commit 60d0fdc

Browse files
authored
Remove deprecated stuff and add extesion properties (#46)
* Add extension properties file * Remove deprecated Service Worker and related files; update README and build scripts for new demo structure. * Update README to enhance clarity on SDK initialization and advertisement implementation steps.
1 parent 25c2160 commit 60d0fdc

File tree

10 files changed

+40
-146
lines changed

10 files changed

+40
-146
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
uses: actions/setup-java@v4
2222
with:
2323
distribution: "temurin"
24-
java-version: "21"
24+
java-version: "25"
2525

2626
- name: Build 🔧
2727
env:
@@ -31,11 +31,6 @@ jobs:
3131
3232
mkdir -p build/bundle/public
3333
34-
# This demo doesn't implement Service Worker and Native Cache, so remove them from the settings:
35-
sed -i 's/service_worker_url = .*//' game.project
36-
sed -i 's/manifest_url = .*//' game.project
37-
rm -rf example/bundle/web
38-
3934
BOB_SHA1=${DEFOLD_BOB_SHA1:-$(curl -s 'https://d.defold.com/stable/info.json' | jq -r .sha1)}
4035
BOB_LOCAL_SHA1=$((java -jar build/bundle/bob.jar --version | cut -d' ' -f6) || true)
4136
if [ "${BOB_LOCAL_SHA1}" != "${BOB_SHA1}" ]; then wget --progress=dot:mega -O build/bundle/bob.jar "https://d.defold.com/archive/${BOB_SHA1}/bob/bob.jar"; fi
@@ -44,13 +39,13 @@ jobs:
4439
TITLE=$(awk -F "=" '/^title/ {gsub(/[ \r\n\t]/, "", $2); print $2}' game.project)
4540
4641
java -jar build/bundle/bob.jar --email foo@bar.com --auth 12345 --texture-compression true --bundle-output build/bundle/js-web --platform js-web --architectures wasm-web --archive --variant release resolve build bundle
47-
(cd build/bundle/js-web/${TITLE} && zip -r ../../public/demo_no-sw_no-native-cache.zip .)
42+
(cd build/bundle/js-web/${TITLE} && zip -r ../../public/demo.zip .)
4843
4944
- name: Upload Result
5045
uses: actions/upload-artifact@v4
5146
with:
5247
name: bundle
53-
path: build/bundle/public/demo_no-sw_no-native-cache.zip
48+
path: build/bundle/public/demo.zip
5449

5550
- name: Deploy to Pages 🚀
5651
if: github.ref == 'refs/heads/master'

README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,25 @@ You can use it in your own project by adding this project as a [Defold library d
2929
- Icon 512 x 512 px.
3030
- Cover 800 x 470 px.
3131
- Screenshots.
32-
4. Add [the extension](https://github.com/indiesoftby/defold-yagames/archive/master.zip) as a Defold library dependency to your project.
33-
5. Enable monetization and earn revenue from placing ad blocks in your game. Ad blocks are available in the following formats:
32+
4. Add [the extension](https://github.com/indiesoftby/defold-yagames/archive/master.zip) as a Defold library dependency to your project.
33+
5. Initialize the SDK in your game - see [Initialization](#-initialization-docs) section below for the API details.
34+
6. Implement advertisement in your game - see [Advertisement](#-advertisement-docs) section below for the API details.
35+
7. Enable monetization and earn revenue from placing ad blocks in your game. Ad blocks are available in the following formats:
3436
- **Interstitial blocks**: ad blocks that completely cover the app background and show up at certain points (for example, when accessing the next game level). *Important: Mute sounds before showing the ad!*
3537
- **Rewarded videos**: blocks with video ads that the user can choose to view and earn a reward or in-game currency. *Important: Mute sounds before showing the ad!*
3638
- **Sticky banners**: banner ads, super easy to setup.
3739
- **In-game purchases**: earn revenue by providing paid services to your users.
38-
5. You can [publish your game on Yandex.Games](https://games.yandex.ru/console/) from this moment.
40+
8. You can [publish your game on Yandex.Games](https://games.yandex.ru/console/) from this moment.
3941

4042
### Best Practices & Tips
4143

4244
1. The YaGames extension imitates a real API on *non-HTML5* platforms. The idea is to allow to you quickly implement API on your favourite platform (macOS, Windows, Linux) and don't spend time on slowly rebuilding/uploading the game to the Yandex.
43-
2. The code from `yagames/manifests/web/engine_template.html` is always added to your HTML5 template. This behaviour can't be disabled. Tip: use Git-branching for every HTML5 platform and do not mix platform-specific code between them.
45+
2. The code from `yagames/manifests/web/engine_template.html` is always added to your HTML5 template. **This behaviour can't be disabled.** Tip: use Git-branching for every HTML5 platform and do not mix platform-specific code between them.
4446
3. You don't need to set up any cache-busting techniques, since Yandex.Games hosts each version of your game in separate paths.
4547

4648
## Code Examples
4749

48-
Take a look at the demo project inside `example` directory. It has quite a few buttons to test all APIs. You can use it in your game as a debug screen or simply [download/upload a pre-built .zip archive](https://github.com/indiesoftby/defold-yagames/blob/gh-pages/demo_no-sw_no-native-cache.zip?raw=true) to make sure that you implemented SDK in the right way.
50+
Take a look at the demo project inside `example` directory. It has quite a few buttons to test all APIs. You can use it in your game as a debug screen or simply [download/upload a pre-built .zip archive](https://github.com/indiesoftby/defold-yagames/blob/gh-pages/demo.zip?raw=true) to make sure that you implemented SDK in the right way.
4951

5052
![YaGames Demo](screenshot.png)
5153

@@ -3212,28 +3214,28 @@ end
32123214
```ini
32133215
[yagames]
32143216
sdk_url = /sdk.js
3215-
sdk_init_options = {}
3216-
sdk_init_snippet = console.log("Yandex Games SDK is ready!");
3217+
sdk_init_options = { signed: false }
3218+
sdk_init_snippet = console.log("Yandex Games SDK is ready!", ysdk);
32173219
service_worker_url = sw.js
32183220
```
32193221

32203222
* `sdk_url` - Sets the URL of the Yandex.Games SDK. In July 2024 the platform changed the URL of its SDK and now it can be of two kinds. First is the local `/sdk.js` for games you upload as an archive (default, **suitable for 99% of games**). The second is for iFrame games - `https://sdk.games.s3.yandex.net/sdk.js`.
3221-
* `sdk_init_options` - JavaScript Object that is passed as-is into the Yandex Games SDK initialization options for [the JS `YaGames.init` function](https://yandex.ru/dev/games/doc/dg/sdk/sdk-about.html?lang=en). Example: `{ orientation: { value: "landscape", lock: true } }`.
3223+
* `sdk_init_options` - JavaScript Object that is passed as-is into the Yandex Games SDK initialization options for [the JS `YaGames.init` function](https://yandex.ru/dev/games/doc/dg/sdk/sdk-about.html?lang=en). Example: `{ signed: true }`.
32223224
* `sdk_init_snippet` - JavaScript code that is passed as-is and called when the `ysdk` variable becomes available. Example: `console.log(ysdk);`. **Use with care, and don't forget to put a semicolon `;` at the end.**
3223-
* `service_worker_url` - Relative URL to the Service Worker file. Usually it's `sw.js`. Set the URL to enable Service Worker.
3225+
* `service_worker_url` - (deprecated) Relative URL to the Service Worker file. Usually it's `sw.js`. Set the URL to enable Service Worker.
32243226

32253227
### Misc
32263228

32273229
> [!TIP]
32283230
> We don't use these features in our games as we don't see any improvements in our games metrics, and the complexity of its integration and support is quite high.
32293231
3230-
#### Service Worker How-To
3232+
#### Service Worker
32313233

3232-
Yandex dropped the Service Worker description page in their docs, but it still allows to integrate Service Worker into your game to be able to run both offline and online.
3234+
Yandex dropped the Service Worker description page in their docs, but it still allows to integrate Service Worker into your game to be able to run both offline and online. This feature is deprecated and will be removed in the future.
32333235

32343236
1. Set the path to the file `sw.js` in the `game.project` settings.
32353237
2. Copy the `yagames/manifests/web/sw.js` file to the root directory of your release build.
3236-
3. Edit the list of all game files inside your `sw.js`. Omit `sw.js` and `yandex-manifest.json`.
3238+
3. Edit the list of all game files inside your `sw.js`. Omit `sw.js`.
32373239
4. You should increment the version inside `sw.js` on every update of your game on Yandex.Games.
32383240

32393241
## Credits

build_example.sh

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@
66
# Immediately exit if any command has a non-zero exit status:
77
set -e
88

9-
# This demo doesn't implement Service Worker and Native Cache, so remove them from the settings:
10-
sed -i 's/service_worker_url = .*//' game.project
11-
sed -i 's/manifest_url = .*//' game.project
12-
139
mkdir -p build/bundle
1410

1511
BOB_SHA1=${BOB_SHA1:-$(curl -s 'https://d.defold.com/stable/info.json' | jq -r .sha1)}
@@ -20,7 +16,6 @@ SETTINGS="--build-server https://build.defold.com --variant debug --email foo@ba
2016
PLATFORM=js-web
2117
ARCHITECTURES=wasm-web
2218
java -jar build/bob.jar ${SETTINGS} --bundle-output build/bundle/${PLATFORM} --platform ${PLATFORM} --architectures ${ARCHITECTURES} --archive resolve build bundle
23-
perl -pi -e "s/cachePrefix \+ \"-v1\"/cachePrefix + \"-v$(date +%s)\"/g" "build/bundle/${PLATFORM}/${TITLE}/sw.js"
2419
2520
if [ $# -eq 1 ]; then
2621
PORT=$1

example/bundle/web/icon/splash.png

-25.9 KB
Binary file not shown.

example/bundle/web/sw.js

Lines changed: 0 additions & 66 deletions
This file was deleted.

example/bundle/web/yandex-manifest.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

game.project

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ high_dpi = 1
1313
title = yagames
1414
version = 0.18.0
1515
developer = Indiesoft LLC
16-
bundle_resources = example/bundle/
1716
dependencies#0 = https://github.com/subsoap/defos/archive/v2.8.3.zip
1817
dependencies#1 = https://github.com/Insality/druid/archive/0.6.0.zip
1918
dependencies#2 = https://github.com/britzl/ludobits/archive/7.1.0.zip

yagames/ext.properties

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[yagames]
2+
title = YaGames
3+
group = Distribution
4+
help = Settings for the YaGames extension
5+
6+
sdk_url.type = string
7+
sdk_url.label = SDK URL
8+
sdk_url.default = /sdk.js
9+
10+
sdk_init_options.type = string
11+
sdk_init_options.label = SDK Init Options
12+
13+
sdk_init_snippet.type = string
14+
sdk_init_snippet.label = SDK Init Snippet
15+
16+
service_worker_url.type = string
17+
service_worker_url.label = Service Worker URL (Deprecated)
18+

yagames/manifests/web/sw.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
// Service Worker was officially supported and recommended for implementation
2+
// on Yandex Games until 2024, but then became optional and was even removed
3+
// from the documentation. This example and connection options are left for
4+
// legacy projects.
5+
16
// 1. Put here the name of your game:
27
const cachePrefix = "your-game-name";
38

yagames/manifests/web/yandex-manifest.json

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)