@spicemod/creator 0.0.31 → 0.0.33

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/dist/bin.mjs CHANGED
@@ -145,7 +145,7 @@ const injectCSSFilePath = dist("templates/injectCSS.js", import.meta.url);
145
145
  //#endregion
146
146
  //#region package.json
147
147
  var name = "@spicemod/creator";
148
- var version = "0.0.31";
148
+ var version = "0.0.33";
149
149
 
150
150
  //#endregion
151
151
  //#region src/utils/common.ts
@@ -343,7 +343,7 @@ const CUSTOM_APP_NAME_LOCALES = [
343
343
  //#region src/config/schema.ts
344
344
  const ServerConfigSchema = v.object({
345
345
  port: v.optional(v.number()),
346
- serveDir: v.string(),
346
+ serveDir: v.optional(v.string()),
347
347
  hmrPath: v.optional(v.string())
348
348
  });
349
349
  const EntryFileSchema = v.string();
@@ -594,11 +594,22 @@ async function loadConfig(cb) {
594
594
  defaults: CONFIG_DEFAULTS,
595
595
  configFileRequired: true,
596
596
  packageJson: true,
597
- async onUpdate({ newConfig }) {
597
+ async onUpdate({ oldConfig, newConfig }) {
598
598
  try {
599
- await runCb(await getResolvedConfig(newConfig.config, { exitOnError: false }), true);
600
- } catch {
599
+ logger$1.debug("Config update triggered", {
600
+ oldConfig,
601
+ newConfig
602
+ });
603
+ const resolved = await getResolvedConfig(newConfig.config, { exitOnError: false });
604
+ logger$1.debug("Resolved config", { resolved });
605
+ try {
606
+ await runCb(resolved, true);
607
+ } catch (error) {
608
+ logger$1.error(error);
609
+ }
610
+ } catch (err) {
601
611
  logger$1.error(pc.red("Config validation failed, keeping previous configuration"));
612
+ if (err instanceof Error) logger$1.error(pc.dim(" └─ ") + err.message);
602
613
  }
603
614
  }
604
615
  });
@@ -1047,7 +1058,6 @@ function wrapWithLoader({ config, cache, outFiles, server, dev = false, logger =
1047
1058
  const outdir = resolve(build$3.initialOptions.outdir || "./dist");
1048
1059
  const bundledCss = getBundledCss(res.outputFiles, outdir, type, dev);
1049
1060
  const minify = build$3.initialOptions.minify;
1050
- const slug = varSlugify(`${name}_${version}`);
1051
1061
  const currentFilePaths = /* @__PURE__ */ new Set();
1052
1062
  for (const file of res.outputFiles) {
1053
1063
  const isJs = file.path.endsWith(".js");
@@ -1146,7 +1156,6 @@ function wrapWithLoader({ config, cache, outFiles, server, dev = false, logger =
1146
1156
  define: {
1147
1157
  __ESBUILD__HAS_CSS: JSON.stringify(type !== "theme" && bundledCss.length !== 0),
1148
1158
  __ESBUILD__INJECTED_CSS: JSON.stringify(bundledCss),
1149
- __ESBUILD__APP_SLUG: JSON.stringify(slug),
1150
1159
  __ESBUILD__APP_TYPE: JSON.stringify(type),
1151
1160
  __ESBUILD__APP_ID: JSON.stringify(varSlugify(name)),
1152
1161
  __ESBUILD__APP_VERSION: JSON.stringify(version)
@@ -2095,14 +2104,16 @@ async function createHmrServer(config, logger = createLogger("hmrServer")) {
2095
2104
  });
2096
2105
  }),
2097
2106
  stop: async () => new Promise((resolve, reject) => {
2098
- if (!isRunning) return resolve();
2099
- for (const client of clients) client.terminate();
2100
- clients.clear();
2101
- wss.close();
2102
- if ("closeAllConnections" in httpServer) httpServer.closeAllConnections();
2107
+ if (!isRunning || !httpServer.listening) {
2108
+ isRunning = false;
2109
+ return resolve();
2110
+ }
2103
2111
  httpServer.close((err) => {
2104
- if (err) return reject(err);
2105
2112
  isRunning = false;
2113
+ if (err) {
2114
+ if (err.code === "ERR_SERVER_NOT_RUNNING") return resolve();
2115
+ return reject(err);
2116
+ }
2106
2117
  logger.debug(`${pc.yellow("! ")} ${pc.gray("HTTP server stopped")}`);
2107
2118
  resolve();
2108
2119
  });
@@ -2263,6 +2274,8 @@ async function dev$1(options) {
2263
2274
  if (isNewUpdate) {
2264
2275
  logger$2.clear();
2265
2276
  logger$2.info(pc.green("Config updated, reloading..."));
2277
+ await server?.stop();
2278
+ server = void 0;
2266
2279
  }
2267
2280
  try {
2268
2281
  server = await createHmrServer({
@@ -2314,8 +2327,7 @@ function getJSDevOptions(config, options) {
2314
2327
  minify,
2315
2328
  buildOptions: {
2316
2329
  copy: true,
2317
- apply: false,
2318
- applyOnce: false,
2330
+ apply: true,
2319
2331
  remove: config.template !== "custom-app",
2320
2332
  outDir
2321
2333
  },
package/dist/index.d.mts CHANGED
@@ -15,12 +15,12 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
15
15
  readonly esbuildOptions: v.GenericSchema<ESBuildOptions>;
16
16
  readonly serverConfig: Omit<v.ObjectSchema<{
17
17
  readonly port: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
18
- readonly serveDir: v.StringSchema<undefined>;
18
+ readonly serveDir: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
19
19
  readonly hmrPath: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
20
20
  }, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
21
21
  readonly entries: {
22
22
  readonly port: v.OptionalSchema<v.OptionalSchema<v.NumberSchema<undefined>, undefined>, undefined>;
23
- readonly serveDir: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
23
+ readonly serveDir: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
24
24
  readonly hmrPath: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
25
25
  };
26
26
  readonly "~standard": v.StandardProps<{
@@ -61,12 +61,12 @@ declare const FileOptionsSchema: v.IntersectSchema<[Omit<v.ObjectSchema<{
61
61
  readonly esbuildOptions: v.OptionalSchema<v.GenericSchema<ESBuildOptions>, undefined>;
62
62
  readonly serverConfig: v.OptionalSchema<Omit<v.ObjectSchema<{
63
63
  readonly port: v.OptionalSchema<v.NumberSchema<undefined>, undefined>;
64
- readonly serveDir: v.StringSchema<undefined>;
64
+ readonly serveDir: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
65
65
  readonly hmrPath: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
66
66
  }, undefined>, "~types" | "~run" | "~standard" | "entries"> & {
67
67
  readonly entries: {
68
68
  readonly port: v.OptionalSchema<v.OptionalSchema<v.NumberSchema<undefined>, undefined>, undefined>;
69
- readonly serveDir: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
69
+ readonly serveDir: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
70
70
  readonly hmrPath: v.OptionalSchema<v.OptionalSchema<v.StringSchema<undefined>, undefined>, undefined>;
71
71
  };
72
72
  readonly "~standard": v.StandardProps<{
@@ -6,16 +6,9 @@ __ESBUILD__HAS_CSS &&
6
6
  style.setAttribute("data-app", __ESBUILD__APP_ID);
7
7
  style.textContent = css;
8
8
  document.head.appendChild(style);
9
- } catch {}
9
+ } catch { }
10
10
  })();
11
11
  (async () => {
12
- const _ID = `${__ESBUILD__APP_SLUG}-${__ESBUILD__APP_TYPE}`;
13
- if (!window.SpiceGlobals) window.SpiceGlobals = {};
14
- window.SpiceGlobals[_ID] = {
15
- id: __ESBUILD__APP_ID,
16
- version: __ESBUILD__APP_VERSION,
17
- };
18
- const { id: appId, version: v } = window.SpiceGlobals[_ID];
19
12
  const _wait = (p, a = 0) =>
20
13
  new Promise((res, rej) => {
21
14
  const i = setInterval(() => {
@@ -29,7 +22,7 @@ __ESBUILD__HAS_CSS &&
29
22
  if (S.Events?.webpackLoaded?.on) await new Promise((r) => S.Events.webpackLoaded.on(r));
30
23
  await _wait(() => S?.React && S?.ReactJSX && S?.ReactDOM && S?.Platform && S?.Player);
31
24
  // oxfmt-ignore
32
- console.info(`%c[${appId}] %cv${v} %cinitialized`, "color: #1DB954; font-weight: bold", "color: #888", "color: unset");
25
+ console.info(`%c[${__ESBUILD__APP_ID}:${__ESBUILD__APP_TYPE}] %cv${__ESBUILD__APP_VERSION} %cinitialized`, "color: #1DB954; font-weight: bold", "color: #888", "color: unset");
33
26
  // oxfmt-ignore
34
27
  "{{INJECT_START_COMMENT}}"
35
28
  (async function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spicemod/creator",
3
- "version": "0.0.31",
3
+ "version": "0.0.33",
4
4
  "description": "Easily make Spicetify extensions and themes",
5
5
  "keywords": [
6
6
  "cli",
@@ -58,6 +58,7 @@
58
58
  "esbuild-plugin-sass": "^1.0.1",
59
59
  "esbuild-sass-plugin": "^3.6.0",
60
60
  "ini": "^6.0.0",
61
+ "lodash-es": "^4.17.23",
61
62
  "nanostores": "^1.1.0",
62
63
  "picocolors": "^1.1.1",
63
64
  "postcss": "^8.5.6",
@@ -70,6 +71,7 @@
70
71
  },
71
72
  "devDependencies": {
72
73
  "@types/ini": "^4.1.1",
74
+ "@types/lodash-es": "^4.17.12",
73
75
  "@types/node": "^25.2.0",
74
76
  "@types/postcss-import": "^14.0.3",
75
77
  "@types/ws": "^8.18.1",
@@ -6,16 +6,9 @@ __ESBUILD__HAS_CSS &&
6
6
  style.setAttribute("data-app", __ESBUILD__APP_ID);
7
7
  style.textContent = css;
8
8
  document.head.appendChild(style);
9
- } catch {}
9
+ } catch { }
10
10
  })();
11
11
  (async () => {
12
- const _ID = `${__ESBUILD__APP_SLUG}-${__ESBUILD__APP_TYPE}`;
13
- if (!window.SpiceGlobals) window.SpiceGlobals = {};
14
- window.SpiceGlobals[_ID] = {
15
- id: __ESBUILD__APP_ID,
16
- version: __ESBUILD__APP_VERSION,
17
- };
18
- const { id: appId, version: v } = window.SpiceGlobals[_ID];
19
12
  const _wait = (p, a = 0) =>
20
13
  new Promise((res, rej) => {
21
14
  const i = setInterval(() => {
@@ -29,7 +22,7 @@ __ESBUILD__HAS_CSS &&
29
22
  if (S.Events?.webpackLoaded?.on) await new Promise((r) => S.Events.webpackLoaded.on(r));
30
23
  await _wait(() => S?.React && S?.ReactJSX && S?.ReactDOM && S?.Platform && S?.Player);
31
24
  // oxfmt-ignore
32
- console.info(`%c[${appId}] %cv${v} %cinitialized`, "color: #1DB954; font-weight: bold", "color: #888", "color: unset");
25
+ console.info(`%c[${__ESBUILD__APP_ID}:${__ESBUILD__APP_TYPE}] %cv${__ESBUILD__APP_VERSION} %cinitialized`, "color: #1DB954; font-weight: bold", "color: #888", "color: unset");
33
26
  // oxfmt-ignore
34
27
  "{{INJECT_START_COMMENT}}"
35
28
  (async function () {