bc-deeplib 1.0.6 → 1.1.0

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.
Files changed (40) hide show
  1. package/CREDITS.md +13 -0
  2. package/LICENSE +21 -21
  3. package/README.md +2 -2
  4. package/dist/3rd_party_types/bcmodsdk.d.ts +184 -0
  5. package/dist/3rd_party_types/declarations.d.ts +4 -0
  6. package/dist/deeplib.d.ts +538 -0
  7. package/dist/deeplib.js +2391 -1714
  8. package/dist/deeplib.js.map +7 -1
  9. package/dist/index.js +2556 -0
  10. package/dist/index.js.map +7 -0
  11. package/dist/public/dl_images/arrow_left.svg +1 -0
  12. package/dist/public/dl_images/arrow_right.svg +1 -0
  13. package/dist/public/dl_images/bug.svg +1 -0
  14. package/dist/public/dl_images/clipboard_export.svg +19 -0
  15. package/dist/public/dl_images/clipboard_import.svg +19 -0
  16. package/dist/public/dl_images/cog.svg +1 -0
  17. package/dist/public/dl_images/exit.svg +1 -0
  18. package/dist/public/dl_images/file_export.svg +12 -0
  19. package/dist/public/dl_images/file_import.svg +12 -0
  20. package/dist/public/dl_images/git.svg +10 -0
  21. package/dist/public/dl_images/notebook.svg +1 -0
  22. package/dist/public/dl_images/round_arrow_left.svg +1 -0
  23. package/dist/public/dl_images/round_arrow_right.svg +1 -0
  24. package/dist/public/dl_images/round_transfer.svg +7 -0
  25. package/dist/public/dl_images/transfer.svg +1 -0
  26. package/dist/public/dl_images/trash_bin.svg +1 -0
  27. package/dist/public/dl_translations/en.lang +17 -0
  28. package/dist/tsconfig.tsbuildinfo +1 -0
  29. package/dist/vendored_types/bcmodsdk.d.ts +184 -0
  30. package/dist/vendored_types/declarations.d.ts +5 -0
  31. package/lib/build.d.ts +32 -0
  32. package/lib/build.js +236 -0
  33. package/package.json +41 -24
  34. package/.types/declarations.d.ts +0 -15
  35. package/.types/elements.d.ts +0 -38
  36. package/.types/type-override.d.ts +0 -3
  37. package/dist/public/styles/DeepLib.css +0 -206
  38. package/dist/public/styles/Gratitude.css +0 -23
  39. package/public/styles/DeepLib.css +0 -206
  40. package/public/styles/Gratitude.css +0 -23
package/lib/build.js ADDED
@@ -0,0 +1,236 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+
4
+ import { exec } from 'child_process';
5
+ import { watch } from 'chokidar';
6
+ import { build } from 'esbuild';
7
+ import progress from 'esbuild-plugin-progress';
8
+ import time from 'esbuild-plugin-time';
9
+ import { existsSync, readFileSync, readdirSync, mkdirSync, copyFileSync } from 'fs';
10
+ import path, { dirname } from 'path';
11
+ import simpleGit from 'simple-git';
12
+ import { fileURLToPath, pathToFileURL } from 'url';
13
+ import { promisify } from 'util';
14
+ import http from 'http';
15
+ import serveStatic from 'serve-static';
16
+ import finalhandler from 'finalhandler';
17
+
18
+ const execAsync = promisify(exec);
19
+
20
+ const __filename = fileURLToPath(import.meta.url);
21
+ const __dirname = dirname(__filename);
22
+
23
+ /**
24
+ * @param {import('./build').BuildConfig} config
25
+ * @returns {Required<import('./build').BuildConfig>}
26
+ */
27
+ export function defineConfig(config) {
28
+ return {
29
+ entry: 'index.ts',
30
+ outfile: 'index.js',
31
+ distDirName: 'dist',
32
+ publicDirName: 'public',
33
+ scripts: [],
34
+ target: [],
35
+ plugins: [],
36
+ defines: {},
37
+ host: 'localhost',
38
+ port: 45000,
39
+ ...config
40
+ };
41
+ }
42
+
43
+ async function runDeeplibBuild() {
44
+ const configPath = path.resolve(process.cwd(), 'deeplib.config.js');
45
+
46
+ if (!existsSync(configPath)) {
47
+ console.error('❌ Missing deeplib.config.js in project root');
48
+ process.exit(1);
49
+ }
50
+
51
+ const { default: config } = await import(pathToFileURL(configPath).toString());
52
+ await buildMod(config);
53
+ }
54
+
55
+ /**
56
+ * @param {Required<import('./build').BuildConfig>} config
57
+ */
58
+ async function buildMod({
59
+ entry,
60
+ outfile,
61
+ globalName,
62
+ distDirName,
63
+ publicDirName,
64
+ scripts,
65
+ prodRemoteURL,
66
+ devRemoteURL,
67
+ target,
68
+ plugins,
69
+ defines,
70
+ host,
71
+ port
72
+ }) {
73
+ const cliLocal = !process.env.environment;
74
+ const cliWatch = process.argv.includes('--watch') || process.argv.includes('-w');
75
+ const cliServe = process.argv.includes('--serve') || process.argv.includes('-s');
76
+ const cliLibLocal = process.argv.includes('--lib-local') || process.argv.includes('-l');
77
+ const cliAllowDebug = process.argv.includes('--debug') || process.argv.includes('-d');
78
+
79
+ const envMode = process.env.environment || 'production';
80
+ const mode = cliLocal ? 'local' : envMode;
81
+
82
+ const isDev = mode === 'development';
83
+ const isLocal = mode === 'local';
84
+ const isWatch = cliWatch;
85
+ const isServe = cliServe;
86
+ const IS_DEVEL = isDev || isLocal;
87
+
88
+ const remotePath = isDev ? devRemoteURL : prodRemoteURL;
89
+ const localPath = `http://${host}:${port}`;
90
+ const PUBLIC_URL = `${isLocal ? localPath : remotePath}/${publicDirName}`;
91
+
92
+ const packageJsonPath = path.resolve(process.cwd(), 'package.json');
93
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
94
+
95
+ const git = simpleGit({ baseDir: process.cwd() });
96
+ const LAST_COMMIT_HASH = await git.log({ maxCount: 1 });
97
+ const VERSION_HASH = LAST_COMMIT_HASH?.latest?.hash.substring(0, 8);
98
+
99
+ /** @type {import('esbuild').BuildOptions} */
100
+ const buildOptions = {
101
+ entryPoints: [`src/${entry}`],
102
+ outfile: `${distDirName}/${outfile}`,
103
+ format: 'iife',
104
+ globalName,
105
+ bundle: true,
106
+ sourcemap: true,
107
+ target,
108
+ treeShaking: true,
109
+ keepNames: true,
110
+ define: {
111
+ PUBLIC_URL: JSON.stringify(PUBLIC_URL),
112
+ MOD_VERSION: JSON.stringify(packageJson.version),
113
+ VERSION_HASH: JSON.stringify(VERSION_HASH),
114
+ IS_DEVEL: JSON.stringify(IS_DEVEL),
115
+ IS_DEBUG: JSON.stringify(cliAllowDebug),
116
+ ...defines
117
+ },
118
+ plugins: [progress(), time(), ...plugins],
119
+ };
120
+
121
+ /** @type {NodeJS.Timeout | null} */
122
+ let buildTimeout = null;
123
+ const DEBOUNCE_MS = 100; // Adjust as needed
124
+
125
+ function debounceRunBuild() {
126
+ if (buildTimeout) clearTimeout(buildTimeout);
127
+ buildTimeout = setTimeout(runBuild, DEBOUNCE_MS);
128
+ }
129
+
130
+ async function runBuild() {
131
+ const assetsSrc = path.resolve(__dirname, '../dist/public');
132
+ const assetsDest = path.resolve(process.cwd(), distDirName, publicDirName);
133
+
134
+ await build(buildOptions);
135
+ copyMatchingFiles(assetsSrc, assetsDest);
136
+
137
+ for (const script of scripts) {
138
+ try {
139
+ const { stdout } = await execAsync(`node ${script}`);
140
+ console.log(stdout);
141
+ } catch (err) {
142
+ console.error(err);
143
+ }
144
+ }
145
+ }
146
+
147
+ await runBuild();
148
+
149
+ if (isLocal) {
150
+
151
+ if (isWatch) {
152
+ const watchDirs = ['./src', `./${publicDirName}`];
153
+ if (cliLibLocal) {
154
+ watchDirs.push('./node_modules/bc-deeplib/dist/deeplib.js');
155
+ watchDirs.push('./node_modules/bc-deeplib/dist/public/**/*');
156
+ }
157
+ const watcher = watch(watchDirs, {
158
+ ignoreInitial: true
159
+ });
160
+ watcher.on('change', debounceRunBuild);
161
+ console.info('🔭 Watching for changes...');
162
+ }
163
+
164
+ if (isServe) {
165
+ try {
166
+ serveWithCORS(distDirName, port, host);
167
+ } catch (err) {
168
+ console.error(err);
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ /**
175
+ * @param {string} dir
176
+ * @param {number} port
177
+ * @param {string} host
178
+ */
179
+ function serveWithCORS(dir, port, host) {
180
+ const serve = serveStatic(dir, {
181
+ setHeaders: (res) => {
182
+ res.setHeader('Access-Control-Allow-Origin', '*');
183
+ }
184
+ });
185
+
186
+ const server = http.createServer((req, res) => {
187
+ serve(req, res, finalhandler(req, res));
188
+ });
189
+
190
+ server.listen(port, host, () => {
191
+ console.log(`🌐 Server running at http://${host}:${port}`);
192
+ });
193
+ }
194
+
195
+ /**
196
+ * @param {string} inputDir
197
+ * @param {string} outputDir
198
+ */
199
+ function copyMatchingFiles(inputDir, outputDir) {
200
+ if (!existsSync(inputDir)) {
201
+ console.warn(`⚠️ ${relativeToProject(inputDir)} is not found.`);
202
+ return;
203
+ }
204
+
205
+ const extensions = ['html', 'js', 'css', 'json', 'png', 'jpg', 'jpeg', 'gif', 'svg', 'lang'];
206
+
207
+ if (!existsSync(outputDir)) {
208
+ mkdirSync(outputDir, { recursive: true });
209
+ }
210
+
211
+ const items = readdirSync(inputDir, { withFileTypes: true });
212
+
213
+ for (const item of items) {
214
+ const srcPath = path.join(inputDir, item.name);
215
+ const destPath = path.join(outputDir, item.name);
216
+
217
+ if (item.isDirectory()) {
218
+ copyMatchingFiles(srcPath, destPath);
219
+ } else if (item.isFile()) {
220
+ const ext = path.extname(item.name).slice(1).toLowerCase();
221
+ if (extensions.includes(ext)) {
222
+ copyFileSync(srcPath, destPath);
223
+ }
224
+ }
225
+ }
226
+ console.info(`📁 Copied assets from ${relativeToProject(inputDir)} to ${relativeToProject(outputDir)}`);
227
+ }
228
+
229
+ /**
230
+ * @param {string} absolutePath
231
+ */
232
+ function relativeToProject(absolutePath) {
233
+ return path.relative(process.cwd(), absolutePath);
234
+ }
235
+
236
+ runDeeplibBuild();
package/package.json CHANGED
@@ -1,40 +1,57 @@
1
1
  {
2
2
  "name": "bc-deeplib",
3
- "version": "1.0.6",
3
+ "version": "1.1.0",
4
4
  "author": "dDeepLb",
5
- "description": "Package for easier development of BC mods without need to repeat myself in every mod",
5
+ "description": "Library for easier development of BC mods, which strives to be a framework :D",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "files": [
9
- ".types",
10
- "public",
11
- "dist"
9
+ "/dist",
10
+ "lib",
11
+ "CREDITS.md",
12
+ "README.md"
12
13
  ],
13
- "main": "./dist/deeplib.js",
14
+ "types": "./dist/deeplib.d.ts",
15
+ "exports": {
16
+ "./deeplib": {
17
+ "import": "./dist/deeplib.js"
18
+ },
19
+ "./build": {
20
+ "import": "./lib/build.js"
21
+ }
22
+ },
23
+ "bin": {
24
+ "deeplib": "./lib/build.js",
25
+ "serve-static": "^2.2.0",
26
+ "simple-git": "^3.28.0",
27
+ "finalhandler": "^2.1.0",
28
+ "fs-extra": "^11.3.0",
29
+ "chokidar": "^4.0.3",
30
+ "esbuild": "^0.25.1",
31
+ "esbuild-plugin-progress": "^1.3.0",
32
+ "esbuild-plugin-time": "^1.0.0",
33
+ "esbuild-sass-plugin": "^3.3.1"
34
+ },
14
35
  "devDependencies": {
15
- "@eslint/js": "^9.16.0",
16
- "@stylistic/eslint-plugin": "^2.11.0",
17
- "@types/node": "^22.5.4",
18
- "bc-stubs": "^110.0.0",
19
- "copy-webpack-plugin": "^12.0.2",
20
- "cross-env": "^7.0.3",
21
- "css-loader": "^7.1.2",
22
- "eslint": "^9.16.0",
23
- "globals": "^15.13.0",
24
- "terser-webpack-plugin": "^5.3.10",
25
- "ts-loader": "^9.5.1",
26
- "typescript": "^5.7.2",
27
- "typescript-eslint": "^8.17.0",
28
- "webpack": "^5.97.1",
29
- "webpack-cli": "^5.1.4",
30
- "webpack-dev-server": "^5.1.0"
36
+ "@eslint/js": "^9.22.0",
37
+ "@stylistic/eslint-plugin": "^4.2.0",
38
+ "@types/node": "^22.13.10",
39
+ "bc-stubs": "117.0.1",
40
+ "eslint": "^9.22.0",
41
+ "globals": "^16.3.0",
42
+ "npm-dts": "^1.3.13",
43
+ "sass": "^1.89.2",
44
+ "typescript": "^5.8.2",
45
+ "typescript-eslint": "^8.26.1"
31
46
  },
32
47
  "dependencies": {
33
48
  "bondage-club-mod-sdk": "^1.2.0"
34
49
  },
35
50
  "scripts": {
51
+ "all": "pnpm build && pnpm type-gen && pnpm asset-copy",
36
52
  "lint": "eslint src/",
37
- "build": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack --env prod --fail-on-warnings",
38
- "dev": "cross-env TS_NODE_PROJECT=\"tsconfig.webpack.json\" webpack serve --progress"
53
+ "build": "node scripts/build.js",
54
+ "type-gen": "node scripts/type_gen.js",
55
+ "asset-copy": "node scripts/asset_copy.js"
39
56
  }
40
57
  }
@@ -1,15 +0,0 @@
1
- interface Window {
2
- RibbonMenuMods?: string[];
3
- }
4
-
5
- declare const serverUrl: string;
6
-
7
- declare module '*.css' {
8
- const value: string;
9
- export = value;
10
- }
11
-
12
- declare module '*.html' {
13
- const value: string;
14
- export = value;
15
- }
@@ -1,38 +0,0 @@
1
- export type SettingElement = Button | Checkbox | Input | Label;
2
-
3
- export type BaseElementModel = {
4
- id: string;
5
- size?: [width: number, height: number];
6
- position?: [x: number, y: number];
7
- disabled?: boolean;
8
- };
9
-
10
- export type Button = BaseElementModel & {
11
- type: 'button';
12
- image?: string;
13
- label?: string;
14
- tooltip?: string;
15
- onClick: () => void;
16
- };
17
-
18
- export type Checkbox = BaseElementModel & {
19
- type: 'checkbox';
20
- label: string;
21
- description: string;
22
- getSettingValue: () => boolean;
23
- setSettingValue: (val: boolean) => void;
24
- };
25
-
26
- export type Input = BaseElementModel & {
27
- type: 'text' | 'number';
28
- label: string;
29
- description: string;
30
- getElementValue: () => string;
31
- setSettingValue: (val: string) => void;
32
- };
33
-
34
- export type Label = BaseElementModel & {
35
- type: 'label';
36
- label: string;
37
- description?: string;
38
- };
@@ -1,3 +0,0 @@
1
- interface PlayerCharacter {
2
- [key: string]: any;
3
- }
@@ -1,206 +0,0 @@
1
- .deeplib-subscreen {
2
- --deeplib-background-color: var(--main, white);
3
- --deeplib-element-color: var(--element, white);
4
- --deeplib-element-hover-color: var(--accentHover, cyan);
5
- --deeplib-text-color: var(--text, black);
6
- --deeplib-icon-color: var(--accent, white);
7
- --deeplib-border-color: var(--accent, black);
8
- }
9
-
10
- /************/
11
- /* ELEMENTS */
12
- /************/
13
-
14
- .deeplib-text {
15
- color: var(--deeplib-text-color);
16
- }
17
-
18
- .deeplib-subscreen {
19
- padding: 0;
20
- margin: 0;
21
- }
22
-
23
- .deeplib-subscreen * {
24
- box-sizing: border-box;
25
- }
26
-
27
- .deeplib-settings {
28
- display: flex;
29
- flex-direction: column;
30
- padding: min(1.0dvh, 0.5dvw);
31
- gap: 0.3em;
32
- overflow-y: auto;
33
- }
34
-
35
- .deeplib-misc {
36
- display: flex;
37
- align-items: center;
38
- justify-content: space-between;
39
- flex-direction: column-reverse;
40
- }
41
-
42
- .deeplib-button.button-styling {
43
- border-radius: min(1.0dvh, 0.5dvw);
44
- color: var(--deeplib-text-color);
45
- }
46
-
47
- .deeplib-button.button-styling img {
48
- position: absolute;
49
- top: 0%;
50
- left: 0%;
51
- width: 100%;
52
- height: 100%;
53
- background-position: left;
54
- background-color: var(--deeplib-icon-color);
55
- background-blend-mode: multiply;
56
- background-size: contain;
57
- mask-position: left;
58
- mask-size: contain;
59
- background-repeat: no-repeat;
60
- mask-repeat: no-repeat;
61
- color: transparent;
62
-
63
- background-image: var(--image);
64
- mask-image: var(--image);
65
- }
66
-
67
- .deeplib-button.button-styling .button-label {
68
- width: 100%;
69
- background-color: transparent;
70
- color: var(--deeplib-text-color);
71
- font-size: min(3.6dvh, 1.8dvw);
72
- }
73
-
74
- #deeplib-subscreen-title {
75
- text-align: center;
76
- color: var(--deeplib-text-color);
77
- }
78
-
79
- #deeplib-reset-button {
80
- background-color: indianred;
81
- }
82
-
83
- #deeplib-wiki-button {
84
- background-color: #BDA203;
85
- }
86
-
87
- #deeplib-support-button {
88
- background-color: #5e4969;
89
- }
90
-
91
- .deeplib-checkbox-container {
92
- display: flex;
93
- flex-direction: row;
94
- align-items: center;
95
- gap: 0.3em;
96
- }
97
-
98
- .deeplib-input {
99
- border-radius: min(1.0dvh, 0.5dvw);
100
- }
101
-
102
- .deeplib-input-container {
103
- position: relative;
104
- margin-top: min(1vh, 0.5vw);
105
- }
106
-
107
- .deeplib-input-container input.deeplib-input {
108
- font-size: 20px;
109
- width: 100%;
110
- padding: 5px 0;
111
- background-color: transparent;
112
- outline: none;
113
- padding-left: min(1vh, 0.5vw);
114
- padding-right: min(1vh, 0.5vw);
115
- }
116
-
117
- .deeplib-input-container label.deeplib-text {
118
- position: absolute;
119
- top: min(0.6vh, 0.3vw);
120
- left: min(0.6vh, 0.3vw);
121
- transition: all 0.3s ease;
122
- pointer-events: none;
123
- }
124
-
125
- .deeplib-input-container input.deeplib-input:focus~label,
126
- .deeplib-input-container input.deeplib-input:not(:placeholder-shown)~label {
127
- font-size: 0.7em;
128
- transform: translate(20%, -70%);
129
- background-color: var(--deeplib-background-color);
130
- padding: 0px min(1vh, 0.5vw);
131
- }
132
-
133
- .deeplib-input-container .deeplib-underline {
134
- position: absolute;
135
- bottom: 0;
136
- left: 0;
137
- height: 2px;
138
- width: 100%;
139
- background-color: var(--deeplib-element-hover-color);
140
- transform: scaleX(0);
141
- transition: all 0.3s ease;
142
- }
143
-
144
- .deeplib-input-container input.deeplib-input:focus~.deeplib-underline,
145
- .deeplib-input-container input.deeplib-input:not(:placeholder-shown)~.deeplib-underline {
146
- transform: scaleX(0.98);
147
- }
148
-
149
- .deeplib-tooltip {
150
- background-color: var(--deeplib-element-color);
151
- color: var(--deeplib-text-color);
152
- display: flex;
153
- align-items: center;
154
- justify-content: center;
155
- border-radius: min(1.0dvh, 0.5dvw);
156
- padding: min(1vh, 0.5vw);
157
- font-size: 0.8em;
158
- border: min(0.2vh, 0.1vw) solid var(--deeplib-border-color);
159
- }
160
-
161
- input::-webkit-outer-spin-button,
162
- input::-webkit-inner-spin-button {
163
- -webkit-appearance: none;
164
- margin: 0;
165
- }
166
-
167
- input[type=number] {
168
- appearance: textfield;
169
- -moz-appearance: textfield;
170
- }
171
-
172
- /*************/
173
- /* MESSAGES */
174
- /*************/
175
-
176
- .deeplib-highlight-text {
177
- font-weight: bold;
178
- color: rgb(203, 185, 23);
179
- }
180
-
181
- #TextAreaChatLog[data-colortheme='dark'] div.ChatMessage.deeplib-message,
182
- #TextAreaChatLog[data-colortheme='dark2'] div.ChatMessage.deeplib-message {
183
- background-color: var(--deeplib-element-color);
184
- border: min(0.2dvh, 0.1dvw) solid var(--deeplib-border-color);
185
- color: var(--deeplib-text-color);
186
- }
187
-
188
- #TextAreaChatLog div.ChatMessage.deeplib-message {
189
- background-color: #eee;
190
- border: min(0.2dvh, 0.1dvw) solid #440171;
191
- color: #111;
192
- padding-left: min(0.6dvh, 0.3dvw);
193
- display: block;
194
- white-space: normal;
195
- }
196
-
197
- #TextAreaChatLog[data-colortheme='dark'] div.ChatMessage.deeplib-message a,
198
- #TextAreaChatLog[data-colortheme='dark2'] div.ChatMessage.deeplib-message a {
199
- color: var(--deeplib-text-color);
200
- }
201
-
202
- #TextAreaChatLog div.ChatMessage.deeplib-message a {
203
- cursor: pointer;
204
- font-weight: bold;
205
- color: #111;
206
- }
@@ -1,23 +0,0 @@
1
- #deeplib-gratitude {
2
- position: fixed;
3
- width: 25%;
4
- height: 50%;
5
- top: 15%;
6
- left: 50%;
7
- }
8
-
9
- #deeplib-gratitude h1 {
10
- font-size: 1em;
11
- color: var(--text, #333);
12
- }
13
-
14
- #deeplib-gratitude p {
15
- font-size: 0.6em;
16
- color: var(--text, #555);
17
- line-height: 1.5;
18
- }
19
-
20
- #deeplib-gratitude p:last-child {
21
- font-size: 0.8em;
22
- color: var(--text, #ff69b4);
23
- }