@dchighs/dc-assets 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Marcuth
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,16 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type DragonFlashAnimationDownloaderOptions = {
3
+ imageName: string;
4
+ phase: number;
5
+ skin?: string;
6
+ platformPrefix?: string;
7
+ };
8
+ export declare class DragonFlashAnimationDownloader extends StaticFileDownloader {
9
+ readonly imageName: string;
10
+ readonly phase: number;
11
+ readonly skin?: string;
12
+ readonly platformPrefix?: string;
13
+ readonly url: string;
14
+ constructor({ imageName, phase, skin, platformPrefix, }: DragonFlashAnimationDownloaderOptions);
15
+ download(filePath: string): Promise<string>;
16
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DragonFlashAnimationDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class DragonFlashAnimationDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageName, phase, skin, platformPrefix, }) {
8
+ var _a;
9
+ super();
10
+ this.imageName = imageName;
11
+ this.phase = phase;
12
+ this.skin = skin;
13
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
14
+ const adjustedSkin = (_a = this.skin) !== null && _a !== void 0 ? _a : "";
15
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/assets/sprites/${this.imageName}${adjustedSkin}_${this.phase}.swf`;
16
+ }
17
+ async download(filePath) {
18
+ return await super.download(this.url, filePath);
19
+ }
20
+ }
21
+ exports.DragonFlashAnimationDownloader = DragonFlashAnimationDownloader;
@@ -0,0 +1,20 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type DragonSpineAnimationDownloaderOptions = {
3
+ imageName: string;
4
+ phase: number;
5
+ skin?: string;
6
+ textureCompressionFormat?: string;
7
+ platformPrefix?: string;
8
+ useNewUrlFormat?: boolean;
9
+ };
10
+ export declare class DragonSpineAnimationDownloader extends StaticFileDownloader {
11
+ readonly imageName: string;
12
+ readonly phase: number;
13
+ readonly skin?: string;
14
+ readonly textureCompressionFormat: string;
15
+ readonly platformPrefix: string;
16
+ readonly useNewUrlFormat: boolean;
17
+ readonly url: string;
18
+ constructor({ imageName, phase, skin, textureCompressionFormat, platformPrefix, useNewUrlFormat }: DragonSpineAnimationDownloaderOptions);
19
+ download(filePath: string): Promise<string>;
20
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DragonSpineAnimationDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class DragonSpineAnimationDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageName, phase, skin, textureCompressionFormat, platformPrefix, useNewUrlFormat }) {
8
+ var _a;
9
+ super();
10
+ this.imageName = imageName;
11
+ this.phase = phase;
12
+ this.skin = skin;
13
+ this.textureCompressionFormat = textureCompressionFormat || dc_core_1.TextureCompressionFormat.Default;
14
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
15
+ this.useNewUrlFormat = useNewUrlFormat !== null && useNewUrlFormat !== void 0 ? useNewUrlFormat : true;
16
+ const adjustedSkin = (_a = this.skin) !== null && _a !== void 0 ? _a : "";
17
+ if (this.useNewUrlFormat) {
18
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/engine/version_1_1/dragons/${this.imageName}${adjustedSkin}_${this.phase}/${this.imageName}${adjustedSkin}_${this.phase}_HD_tweened_${this.textureCompressionFormat}.zip`;
19
+ }
20
+ else {
21
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/engine/version_1_1/dragons/${this.imageName}${adjustedSkin}_${this.phase}/basic_${this.imageName}${skin}_${phase}_HD_spine-3-8-59_${this.textureCompressionFormat}.zip`;
22
+ }
23
+ }
24
+ async download(filePath) {
25
+ return await super.download(this.url, filePath);
26
+ }
27
+ }
28
+ exports.DragonSpineAnimationDownloader = DragonSpineAnimationDownloader;
@@ -0,0 +1,18 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type DragonSpriteDownloaderOptions = {
3
+ imageQuality?: string;
4
+ imageName: string;
5
+ phase: number;
6
+ skin?: string;
7
+ platformPrefix?: string;
8
+ };
9
+ export declare class DragonSpriteDownloader extends StaticFileDownloader {
10
+ readonly platformPrefix: string;
11
+ readonly imageQuality: string;
12
+ readonly imageName: string;
13
+ readonly phase: number;
14
+ readonly skin?: string;
15
+ readonly url: string;
16
+ constructor({ imageQuality, imageName, phase, skin, platformPrefix, }: DragonSpriteDownloaderOptions);
17
+ download(filePath: string): Promise<string>;
18
+ }
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DragonSpriteDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class DragonSpriteDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageQuality, imageName, phase, skin, platformPrefix, }) {
8
+ var _a;
9
+ super();
10
+ this.imageName = imageName;
11
+ this.imageQuality = imageQuality !== null && imageQuality !== void 0 ? imageQuality : dc_core_1.DragonSpriteQuality.Default;
12
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
13
+ this.phase = phase;
14
+ this.skin = skin;
15
+ const adjustedSkin = (_a = this.skin) !== null && _a !== void 0 ? _a : "";
16
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/ui_${this.imageName}${adjustedSkin}_${this.phase}${this.imageQuality}.png`;
17
+ }
18
+ async download(filePath) {
19
+ return await super.download(this.url, filePath);
20
+ }
21
+ }
22
+ exports.DragonSpriteDownloader = DragonSpriteDownloader;
@@ -0,0 +1,16 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type DragonThumbnailDownloaderOptions = {
3
+ imageName: string;
4
+ phase: number;
5
+ skin?: string;
6
+ platformPrefix?: string;
7
+ };
8
+ export declare class DragonThumbnailDownloader extends StaticFileDownloader {
9
+ readonly platformPrefix: string;
10
+ readonly imageName: string;
11
+ readonly phase: number;
12
+ readonly skin?: string;
13
+ readonly url: string;
14
+ constructor({ imageName, phase, skin, platformPrefix }: DragonThumbnailDownloaderOptions);
15
+ download(filePath: string): Promise<string>;
16
+ }
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DragonThumbnailDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class DragonThumbnailDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ imageName, phase, skin, platformPrefix }) {
8
+ var _a;
9
+ super();
10
+ this.imageName = imageName;
11
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
12
+ this.phase = phase;
13
+ this.skin = skin;
14
+ const adjustedSkin = (_a = this.skin) !== null && _a !== void 0 ? _a : "";
15
+ this.url = `https://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/ui/dragons/HD/thumb_${this.imageName}_${this.phase}${adjustedSkin}.png`;
16
+ }
17
+ async download(filePath) {
18
+ return await super.download(this.url, filePath);
19
+ }
20
+ }
21
+ exports.DragonThumbnailDownloader = DragonThumbnailDownloader;
@@ -0,0 +1,29 @@
1
+ import { DragonFlashAnimationDownloader, DragonFlashAnimationDownloaderOptions } from "./dragon-flash-animation-downloader";
2
+ import { DragonSpineAnimationDownloader, DragonSpineAnimationDownloaderOptions } from "./dragon-spine-animation-downloader";
3
+ import { DragonSpriteDownloader, DragonSpriteDownloaderOptions } from "./dragon-sprite-downloader";
4
+ import { DragonThumbnailDownloader, DragonThumbnailDownloaderOptions } from "./dragon-thumbnail-downloader";
5
+ import { IslandPackageDownloader, IslandPackageDownloaderOptions } from "./island-package-downloader";
6
+ import { MusicDownloader, MusicDownloaderOptions } from "./music-downloader";
7
+ declare const dcAssets: {
8
+ dragons: {
9
+ animations: {
10
+ flash: (options: DragonFlashAnimationDownloaderOptions) => DragonFlashAnimationDownloader;
11
+ spine: (options: DragonSpineAnimationDownloaderOptions) => DragonSpineAnimationDownloader;
12
+ };
13
+ sprite: (options: DragonSpriteDownloaderOptions) => DragonSpriteDownloader;
14
+ thumbnail: (options: DragonThumbnailDownloaderOptions) => DragonThumbnailDownloader;
15
+ };
16
+ islands: {
17
+ package: (options: IslandPackageDownloaderOptions) => IslandPackageDownloader;
18
+ };
19
+ sounds: {
20
+ music: (options: MusicDownloaderOptions) => MusicDownloader;
21
+ };
22
+ };
23
+ export * from "./dragon-flash-animation-downloader";
24
+ export * from "./static-file-downloader";
25
+ export * from "./dragon-spine-animation-downloader";
26
+ export * from "./dragon-sprite-downloader";
27
+ export * from "./island-package-downloader";
28
+ export * from "./music-downloader";
29
+ export default dcAssets;
package/dist/index.js ADDED
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ const dragon_flash_animation_downloader_1 = require("./dragon-flash-animation-downloader");
18
+ const dragon_spine_animation_downloader_1 = require("./dragon-spine-animation-downloader");
19
+ const dragon_sprite_downloader_1 = require("./dragon-sprite-downloader");
20
+ const dragon_thumbnail_downloader_1 = require("./dragon-thumbnail-downloader");
21
+ const island_package_downloader_1 = require("./island-package-downloader");
22
+ const music_downloader_1 = require("./music-downloader");
23
+ const dcAssets = {
24
+ dragons: {
25
+ animations: {
26
+ flash: (options) => new dragon_flash_animation_downloader_1.DragonFlashAnimationDownloader(options),
27
+ spine: (options) => new dragon_spine_animation_downloader_1.DragonSpineAnimationDownloader(options)
28
+ },
29
+ sprite: (options) => new dragon_sprite_downloader_1.DragonSpriteDownloader(options),
30
+ thumbnail: (options) => new dragon_thumbnail_downloader_1.DragonThumbnailDownloader(options),
31
+ },
32
+ islands: {
33
+ package: (options) => new island_package_downloader_1.IslandPackageDownloader(options)
34
+ },
35
+ sounds: {
36
+ music: (options) => new music_downloader_1.MusicDownloader(options)
37
+ }
38
+ };
39
+ __exportStar(require("./dragon-flash-animation-downloader"), exports);
40
+ __exportStar(require("./static-file-downloader"), exports);
41
+ __exportStar(require("./dragon-spine-animation-downloader"), exports);
42
+ __exportStar(require("./dragon-sprite-downloader"), exports);
43
+ __exportStar(require("./island-package-downloader"), exports);
44
+ __exportStar(require("./music-downloader"), exports);
45
+ exports.default = dcAssets;
@@ -0,0 +1,11 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type IslandPackageDownloaderOptions = {
3
+ islandType?: string;
4
+ fileName?: string;
5
+ path?: string;
6
+ };
7
+ export declare class IslandPackageDownloader extends StaticFileDownloader {
8
+ readonly url: string;
9
+ constructor({ fileName, path, islandType }: IslandPackageDownloaderOptions);
10
+ download(filePath: string): Promise<string>;
11
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IslandPackageDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class IslandPackageDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ fileName, path, islandType }) {
8
+ super();
9
+ if (!path && !islandType && !fileName) {
10
+ throw new Error("Either path, islandType or fileName must be provided.");
11
+ }
12
+ if (path) {
13
+ const items = path.split("/");
14
+ islandType = items[3];
15
+ fileName = items[4];
16
+ }
17
+ if (islandType === dc_core_1.IslandType.GridIslands && !fileName.endsWith("_optim.zip")) {
18
+ fileName = fileName.replace(".zip", "_optim.zip");
19
+ }
20
+ this.url = `https://www.socialpointgames.com/static/dragoncity/mobile/ui/${islandType === dc_core_1.IslandType.HeroicRaces ? "heroicraces_islands" : "islands"}/HD/dxt5/${fileName}`;
21
+ }
22
+ async download(filePath) {
23
+ return await super.download(this.url, filePath);
24
+ }
25
+ }
26
+ exports.IslandPackageDownloader = IslandPackageDownloader;
@@ -0,0 +1,12 @@
1
+ import { StaticFileDownloader } from "./static-file-downloader";
2
+ export type MusicDownloaderOptions = {
3
+ platformPrefix?: string;
4
+ keyName: string;
5
+ };
6
+ export declare class MusicDownloader extends StaticFileDownloader {
7
+ readonly platformPrefix: string;
8
+ readonly keyName: string;
9
+ readonly url: string;
10
+ constructor({ platformPrefix, keyName }: MusicDownloaderOptions);
11
+ download(filePath: string): Promise<string>;
12
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MusicDownloader = void 0;
4
+ const dc_core_1 = require("@dchighs/dc-core");
5
+ const static_file_downloader_1 = require("./static-file-downloader");
6
+ class MusicDownloader extends static_file_downloader_1.StaticFileDownloader {
7
+ constructor({ platformPrefix, keyName }) {
8
+ super();
9
+ this.keyName = keyName;
10
+ this.platformPrefix = platformPrefix || dc_core_1.StaticFileUrlPlatformPrefix.Default;
11
+ this.url = `http://${this.platformPrefix}-static-s1.socialpointgames.com/static/dragoncity/mobile/sounds/music/${this.keyName}.mp3`;
12
+ }
13
+ async download(filePath) {
14
+ return await super.download(this.url, filePath);
15
+ }
16
+ }
17
+ exports.MusicDownloader = MusicDownloader;
@@ -0,0 +1,3 @@
1
+ export declare class StaticFileDownloader {
2
+ download(url: string, filePath: string): Promise<string>;
3
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.StaticFileDownloader = void 0;
7
+ const axios_1 = __importDefault(require("axios"));
8
+ const node_fs_1 = __importDefault(require("node:fs"));
9
+ class StaticFileDownloader {
10
+ async download(url, filePath) {
11
+ const response = await axios_1.default.get(url, { responseType: "arraybuffer" });
12
+ await node_fs_1.default.promises.writeFile(filePath, response.data);
13
+ return filePath;
14
+ }
15
+ }
16
+ exports.StaticFileDownloader = StaticFileDownloader;
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@dchighs/dc-assets",
3
+ "version": "0.0.1",
4
+ "description": "Library focused on downloading static files from the Dragon City server.",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "files": [
9
+ "dist/*",
10
+ "!/**/__tests__"
11
+ ],
12
+ "scripts": {
13
+ "test": "jest",
14
+ "build": "tsc"
15
+ },
16
+ "keywords": [
17
+ "dragon city",
18
+ "dc",
19
+ "core",
20
+ "dc highs"
21
+ ],
22
+ "author": "Marcutyh",
23
+ "license": "MIT",
24
+ "type": "commonjs",
25
+ "devDependencies": {
26
+ "@types/jest": "^30.0.0",
27
+ "@types/node": "^25.0.3",
28
+ "ts-jest": "^29.4.6",
29
+ "ts-node": "^10.9.2",
30
+ "typescript": "^5.9.3"
31
+ },
32
+ "dependencies": {
33
+ "axios": "^1.13.2"
34
+ },
35
+ "peerDependencies": {
36
+ "@dchighs/dc-core": "^0.0.2"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "https://github.com/DC-Highs/dc-assets.git"
41
+ }
42
+ }