@hot-updater/console 0.6.0 → 0.6.1-rc.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.
package/dist/index.cjs CHANGED
@@ -645,8 +645,8 @@ var Context = class {
645
645
  set res(_res) {
646
646
  this.#isFresh = false;
647
647
  if (this.#res && _res) try {
648
- for (const [k, v] of this.#res.headers.entries()){
649
- if ("content-type" !== k) if ("set-cookie" === k) {
648
+ for (const [k, v] of this.#res.headers.entries())if ("content-type" !== k) {
649
+ if ("set-cookie" === k) {
650
650
  const cookies = this.#res.headers.getSetCookie();
651
651
  _res.headers.delete("set-cookie");
652
652
  for (const cookie of cookies)_res.headers.append("set-cookie", cookie);
@@ -2040,29 +2040,33 @@ const bundleSchema = dist_object({
2040
2040
  message: nullable(string())
2041
2041
  });
2042
2042
  let rpc_config = null;
2043
- const rpc = new hono_Hono().get("/loadConfig", async (c)=>{
2044
- rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2045
- return c.json(true);
2046
- }).get("/getConfig", async (c)=>{
2047
- if (!rpc_config) rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2043
+ let rpc_databasePlugin = null;
2044
+ const prepareConfig = async ()=>{
2045
+ if (!rpc_config) {
2046
+ rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2047
+ rpc_databasePlugin = await rpc_config?.database({
2048
+ cwd: plugin_core_namespaceObject.getCwd()
2049
+ }) ?? null;
2050
+ }
2051
+ return {
2052
+ config: rpc_config,
2053
+ databasePlugin: rpc_databasePlugin
2054
+ };
2055
+ };
2056
+ const rpc = new hono_Hono().get("/getConfig", async (c)=>{
2057
+ const { config } = await prepareConfig();
2048
2058
  return c.json({
2049
- console: rpc_config?.console
2059
+ console: config?.console
2050
2060
  });
2051
2061
  }).get("/isConfigLoaded", (c)=>c.json(null !== rpc_config)).get("/getBundles", async (c)=>{
2052
- if (!rpc_config) rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2053
- const databasePlugin = rpc_config?.database({
2054
- cwd: plugin_core_namespaceObject.getCwd()
2055
- });
2056
- const bundles = await databasePlugin?.getBundles();
2062
+ const { databasePlugin } = await prepareConfig();
2063
+ const bundles = await databasePlugin?.getBundles(true);
2057
2064
  return c.json(bundles ?? []);
2058
2065
  }).post("/getBundleById", vValidator("json", dist_object({
2059
2066
  bundleId: string()
2060
2067
  })), async (c)=>{
2061
2068
  const { bundleId } = c.req.valid("json");
2062
- if (!rpc_config) rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2063
- const databasePlugin = rpc_config?.database({
2064
- cwd: plugin_core_namespaceObject.getCwd()
2065
- });
2069
+ const { databasePlugin } = await prepareConfig();
2066
2070
  const bundle = await databasePlugin?.getBundleById(bundleId);
2067
2071
  return c.json(bundle ?? null);
2068
2072
  }).post("/updateBundle", vValidator("json", dist_object({
@@ -2072,10 +2076,7 @@ const rpc = new hono_Hono().get("/loadConfig", async (c)=>{
2072
2076
  ]))
2073
2077
  })), async (c)=>{
2074
2078
  const { targetBundleId, bundle } = c.req.valid("json");
2075
- if (!rpc_config) rpc_config = await (0, plugin_core_namespaceObject.loadConfig)();
2076
- const databasePlugin = rpc_config?.database({
2077
- cwd: plugin_core_namespaceObject.getCwd()
2078
- });
2079
+ const { databasePlugin } = await prepareConfig();
2079
2080
  await databasePlugin?.updateBundle(targetBundleId, bundle);
2080
2081
  await databasePlugin?.commitBundle();
2081
2082
  return c.json(true);
package/dist/index.js CHANGED
@@ -4,7 +4,7 @@ import { fileURLToPath as __webpack_fileURLToPath__ } from "node:url";
4
4
  import { dirname as __webpack_dirname__ } from "node:path";
5
5
  import * as __WEBPACK_EXTERNAL_MODULE_path__ from "path";
6
6
  import * as __WEBPACK_EXTERNAL_MODULE_fs__ from "fs";
7
- import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__ from "@hot-updater/plugin-core";
7
+ import * as __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__ from "@hot-updater/plugin-core";
8
8
  var getFilePath = (options)=>{
9
9
  let filename = options.filename;
10
10
  const defaultDocument = options.defaultDocument || "index.html";
@@ -606,8 +606,8 @@ var Context = class {
606
606
  set res(_res) {
607
607
  this.#isFresh = false;
608
608
  if (this.#res && _res) try {
609
- for (const [k, v] of this.#res.headers.entries()){
610
- if ("content-type" !== k) if ("set-cookie" === k) {
609
+ for (const [k, v] of this.#res.headers.entries())if ("content-type" !== k) {
610
+ if ("set-cookie" === k) {
611
611
  const cookies = this.#res.headers.getSetCookie();
612
612
  _res.headers.delete("set-cookie");
613
613
  for (const cookie of cookies)_res.headers.append("set-cookie", cookie);
@@ -2000,29 +2000,33 @@ const bundleSchema = dist_object({
2000
2000
  message: nullable(string())
2001
2001
  });
2002
2002
  let rpc_config = null;
2003
- const rpc = new hono_Hono().get("/loadConfig", async (c)=>{
2004
- rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.loadConfig)();
2005
- return c.json(true);
2006
- }).get("/getConfig", async (c)=>{
2007
- if (!rpc_config) rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.loadConfig)();
2003
+ let rpc_databasePlugin = null;
2004
+ const prepareConfig = async ()=>{
2005
+ if (!rpc_config) {
2006
+ rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.loadConfig)();
2007
+ rpc_databasePlugin = await rpc_config?.database({
2008
+ cwd: __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core_40c1c502__.getCwd()
2009
+ }) ?? null;
2010
+ }
2011
+ return {
2012
+ config: rpc_config,
2013
+ databasePlugin: rpc_databasePlugin
2014
+ };
2015
+ };
2016
+ const rpc = new hono_Hono().get("/getConfig", async (c)=>{
2017
+ const { config } = await prepareConfig();
2008
2018
  return c.json({
2009
- console: rpc_config?.console
2019
+ console: config?.console
2010
2020
  });
2011
2021
  }).get("/isConfigLoaded", (c)=>c.json(null !== rpc_config)).get("/getBundles", async (c)=>{
2012
- if (!rpc_config) rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.loadConfig)();
2013
- const databasePlugin = rpc_config?.database({
2014
- cwd: __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.getCwd()
2015
- });
2016
- const bundles = await databasePlugin?.getBundles();
2022
+ const { databasePlugin } = await prepareConfig();
2023
+ const bundles = await databasePlugin?.getBundles(true);
2017
2024
  return c.json(bundles ?? []);
2018
2025
  }).post("/getBundleById", vValidator("json", dist_object({
2019
2026
  bundleId: string()
2020
2027
  })), async (c)=>{
2021
2028
  const { bundleId } = c.req.valid("json");
2022
- if (!rpc_config) rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.loadConfig)();
2023
- const databasePlugin = rpc_config?.database({
2024
- cwd: __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.getCwd()
2025
- });
2029
+ const { databasePlugin } = await prepareConfig();
2026
2030
  const bundle = await databasePlugin?.getBundleById(bundleId);
2027
2031
  return c.json(bundle ?? null);
2028
2032
  }).post("/updateBundle", vValidator("json", dist_object({
@@ -2032,10 +2036,7 @@ const rpc = new hono_Hono().get("/loadConfig", async (c)=>{
2032
2036
  ]))
2033
2037
  })), async (c)=>{
2034
2038
  const { targetBundleId, bundle } = c.req.valid("json");
2035
- if (!rpc_config) rpc_config = await (0, __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.loadConfig)();
2036
- const databasePlugin = rpc_config?.database({
2037
- cwd: __WEBPACK_EXTERNAL_MODULE__hot_updater_plugin_core__.getCwd()
2038
- });
2039
+ const { databasePlugin } = await prepareConfig();
2039
2040
  await databasePlugin?.updateBundle(targetBundleId, bundle);
2040
2041
  await databasePlugin?.commitBundle();
2041
2042
  return c.json(true);
@@ -1,13 +1,4 @@
1
1
  export declare const api: {
2
- loadConfig: import("hono/client").ClientRequest<{
3
- $get: {
4
- input: {};
5
- output: true;
6
- outputFormat: "json";
7
- status: import("hono/utils/http-status").StatusCode;
8
- };
9
- }>;
10
- } & {
11
2
  getConfig: import("hono/client").ClientRequest<{
12
3
  $get: {
13
4
  input: {};
@@ -7,13 +7,6 @@ declare const app: Hono<{}, {
7
7
  outputFormat: "text";
8
8
  status: import("hono/utils/http-status").StatusCode;
9
9
  };
10
- } | {
11
- $get: {
12
- input: {};
13
- output: true;
14
- outputFormat: "json";
15
- status: import("hono/utils/http-status").StatusCode;
16
- };
17
10
  } | {
18
11
  $get: {
19
12
  input: {};
@@ -12,15 +12,6 @@ export declare const bundleSchema: v.ObjectSchema<{
12
12
  readonly message: v.NullableSchema<v.StringSchema<undefined>, never>;
13
13
  }, undefined>;
14
14
  export declare const rpc: Hono<import("hono/types").BlankEnv, {
15
- "/loadConfig": {
16
- $get: {
17
- input: {};
18
- output: true;
19
- outputFormat: "json";
20
- status: import("hono/utils/http-status").StatusCode;
21
- };
22
- };
23
- } & {
24
15
  "/getConfig": {
25
16
  $get: {
26
17
  input: {};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hot-updater/console",
3
3
  "type": "module",
4
- "version": "0.6.0",
4
+ "version": "0.6.1-rc.0",
5
5
  "files": [
6
6
  "dist",
7
7
  "package.json"
@@ -49,8 +49,8 @@
49
49
  "valibot": "^0.42.1"
50
50
  },
51
51
  "dependencies": {
52
- "@hot-updater/core": "0.6.0",
53
- "@hot-updater/plugin-core": "0.6.0"
52
+ "@hot-updater/core": "0.6.1-rc.0",
53
+ "@hot-updater/plugin-core": "0.6.1-rc.0"
54
54
  },
55
55
  "scripts": {
56
56
  "build": "rsbuild build && rslib build",