@alodi/site 0.3.1 → 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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## [0.3.1](https://git.lodiops.com/bag_web/lodi-site/compare/v0.3.0...v0.3.1) (2026-08-04)
3
+ # [1.1.0](https://git.lodiops.com/bag_web/lodi-figma/compare/v0.4.0...v1.1.0) (2026-08-17)
4
+
5
+ - 与 monorepo 其他包统一发布版本 `1.1.0`
6
+
7
+ # [0.4.0](https://git.lodiops.com/bag_web/lodi-site/compare/v0.3.0...v0.4.0) (2026-08-07)
4
8
 
5
9
 
6
10
  ### Features
@@ -15,11 +19,11 @@ All notable changes to this project will be documented in this file. Dates are d
15
19
 
16
20
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
17
21
 
18
- #### [v0.3.1](https://github.com/hoolodi/lodi-site/compare/v0.3.0...v0.3.1)
22
+ #### [v0.4.0](https://github.com/hoolodi/lodi-site/compare/v0.3.0...v0.4.0)
19
23
 
20
- - build: trade rename trading [`1a29037`](https://github.com/hoolodi/lodi-site/commit/1a29037591c2d82a44f07a8bc1eb65bd9866ddf1)
21
- - chore(release): v0.2.1-beta.0 [`b74c007`](https://github.com/hoolodi/lodi-site/commit/b74c007aebeb056dbdec234c6606bb6dfffa965b)
22
- - chore(release): v0.2.1-alpha.2 [`246f01e`](https://github.com/hoolodi/lodi-site/commit/246f01ee4200ee18ad161975f21c3a226d8e2145)
24
+ - build: xx [`4ec706f`](https://github.com/hoolodi/lodi-site/commit/4ec706f5d802f0bab655f8ce046854b1ac25a6d0)
25
+ - build: xx [`2c9420a`](https://github.com/hoolodi/lodi-site/commit/2c9420adb0386e2f5ec4805e0d9b750cd69c16a0)
26
+ - chore(release): v0.3.1 [`d5b4cc2`](https://github.com/hoolodi/lodi-site/commit/d5b4cc228a06590078b1e0bad1ed9d792bf5c221)
23
27
 
24
28
  #### [v0.3.0](https://github.com/hoolodi/lodi-site/compare/v0.1.4...v0.3.0)
25
29
 
package/dist/argv.d.ts CHANGED
@@ -39,3 +39,4 @@ type ParseArgvOption = {
39
39
  };
40
40
  export declare function siteArgv({ argv, option }?: ParseArgvOption): import("yargs").Argv<{}>;
41
41
  export {};
42
+ //# sourceMappingURL=argv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv.d.ts","sourceRoot":"","sources":["argv.ts"],"names":[],"mappings":";AAIA,QAAA,MAAM,OAAO;;;;;;;;;yBAWG,MAAM;;;;;;;;;;;;;;;;;EA2BZ,CAAC;AACX,KAAK,eAAe,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CACd,MAAM,CACJ,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAC9B;QACE,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACD,KAAK,CACR,CACF,CAAC;CACH,CAAC;AACF,wBAAgB,QAAQ,CAAC,EAAE,IAAmB,EAAE,MAAW,EAAE,GAAE,eAAoB,4BAiBlF"}
package/dist/argv.js CHANGED
@@ -9,22 +9,13 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
9
9
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
10
10
  import { hideBin } from 'yargs/helpers';
11
11
  import yargs from 'yargs/yargs';
12
- import { SITE } from "./index";
13
- // import { COUNTRY } from './index';
14
-
12
+ import { SITE } from "./site";
15
13
  var options = [{
16
14
  name: 'platform',
17
15
  describe: '指定平台',
18
16
  choices: ['ios', 'android'],
19
17
  demandOption: true
20
- },
21
- // {
22
- // name: 'country',
23
- // describe: '指定国家',
24
- // choices: Object.values(COUNTRY),
25
- // demandOption: true,
26
- // },
27
- {
18
+ }, {
28
19
  name: 'site',
29
20
  describe: '指定站点',
30
21
  choices: Object.values(SITE),
@@ -39,3 +39,4 @@ type ParseArgvOption = {
39
39
  };
40
40
  export declare function siteArgv({ argv, option }?: ParseArgvOption): import("yargs").Argv<{}>;
41
41
  export {};
42
+ //# sourceMappingURL=argv.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"argv.d.ts","sourceRoot":"","sources":["argv.ts"],"names":[],"mappings":";AAIA,QAAA,MAAM,OAAO;;;;;;;;;yBAWG,MAAM;;;;;;;;;;;;;;;;;EA2BZ,CAAC;AACX,KAAK,eAAe,GAAG;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CACd,MAAM,CACJ,CAAC,OAAO,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAC9B;QACE,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;QACnB,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,GACD,KAAK,CACR,CACF,CAAC;CACH,CAAC;AACF,wBAAgB,QAAQ,CAAC,EAAE,IAAmB,EAAE,MAAW,EAAE,GAAE,eAAoB,4BAiBlF"}
package/dist/cjs/argv.js CHANGED
@@ -34,7 +34,7 @@ __export(argv_exports, {
34
34
  module.exports = __toCommonJS(argv_exports);
35
35
  var import_helpers = require("yargs/helpers");
36
36
  var import_yargs = __toESM(require("yargs/yargs"));
37
- var import_index = require("./index");
37
+ var import_site = require("./site");
38
38
  var options = [
39
39
  {
40
40
  name: "platform",
@@ -42,25 +42,19 @@ var options = [
42
42
  choices: ["ios", "android"],
43
43
  demandOption: true
44
44
  },
45
- // {
46
- // name: 'country',
47
- // describe: '指定国家',
48
- // choices: Object.values(COUNTRY),
49
- // demandOption: true,
50
- // },
51
45
  {
52
46
  name: "site",
53
47
  describe: "指定站点",
54
- choices: Object.values(import_index.SITE),
48
+ choices: Object.values(import_site.SITE),
55
49
  coerce: (s) => {
56
50
  if (s === "aura69")
57
- return import_index.SITE.PG_91;
51
+ return import_site.SITE.PG_91;
58
52
  if (s === "aura88")
59
- return import_index.SITE.PG_82;
53
+ return import_site.SITE.PG_82;
60
54
  if (s === "waspwin")
61
- return import_index.SITE.ZAPP_SPIN;
55
+ return import_site.SITE.ZAPP_SPIN;
62
56
  if (s === "so99")
63
- return import_index.SITE.SORTE_WIN;
57
+ return import_site.SITE.SORTE_WIN;
64
58
  return s;
65
59
  },
66
60
  demandOption: true
@@ -0,0 +1,174 @@
1
+ /// <reference types="node" />
2
+ import { type SiteName } from './site';
3
+ export declare const PLATFORMS: readonly ["ios", "android"];
4
+ export type PlatformName = (typeof PLATFORMS)[number];
5
+ export declare const ENVS: readonly ["dev", "test", "beta", "prod"];
6
+ export type EnvName = (typeof ENVS)[number];
7
+ export declare const SITE_ALIASES: Record<string, SiteName>;
8
+ export declare const DEFAULT_ENV_KEYS: {
9
+ readonly platform: "BIU_PLATFORM";
10
+ readonly site: "BIU_SITE";
11
+ readonly api: "BIU_API";
12
+ readonly ws: "BIU_WS";
13
+ readonly env: "BIU_ENV";
14
+ };
15
+ export type OptionName = keyof typeof DEFAULT_ENV_KEYS;
16
+ export type OptionConfig = {
17
+ enable?: boolean;
18
+ /** 自定义环境变量名,默认 BIU_PLATFORM / BIU_SITE / BIU_API / BIU_WS / BIU_ENV */
19
+ envKey?: string;
20
+ demandOption?: boolean;
21
+ choices?: readonly string[];
22
+ };
23
+ export type ResolvedOptionConfig = {
24
+ enable: false;
25
+ } | {
26
+ enable: true;
27
+ envKey: string;
28
+ demandOption: boolean;
29
+ choices?: readonly string[];
30
+ };
31
+ export type ParseEnvOption = {
32
+ env?: NodeJS.ProcessEnv;
33
+ option?: Partial<Record<OptionName, OptionConfig | false>>;
34
+ };
35
+ export type SiteEnv = {
36
+ platform: PlatformName;
37
+ site: SiteName;
38
+ api: string;
39
+ ws: string;
40
+ env: EnvName;
41
+ };
42
+ /** 解析站点值,支持别名 */
43
+ export declare function resolveSite(value: string): SiteName;
44
+ /** 读取环境变量;demand 为 true 且缺失时抛错 */
45
+ export declare function readEnvValue(env: NodeJS.ProcessEnv, key: string, demand?: boolean): string | undefined;
46
+ /** 校验取值是否在可选列表中 */
47
+ export declare function assertEnvChoice<T extends string>(value: string, choices: readonly T[], key: string): T;
48
+ /** 解析单个字段的 option 配置 */
49
+ export declare function resolveOptionConfig(conf: OptionConfig | false | undefined, defaultEnvKey: string): ResolvedOptionConfig;
50
+ type ReadEnvFieldOptions<T> = {
51
+ env?: NodeJS.ProcessEnv;
52
+ envKey: string;
53
+ demandOption?: boolean;
54
+ choices?: readonly string[];
55
+ /** 原始字符串转换;默认原样返回 */
56
+ parse?: (raw: string) => T;
57
+ };
58
+ /**
59
+ * 读取并解析单个环境变量字段,便于扩展自定义配置。
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const cdn = readEnvField({
64
+ * envKey: 'BIU_CDN',
65
+ * demandOption: false,
66
+ * });
67
+ * ```
68
+ */
69
+ export declare function readEnvField<T = string>({ env, envKey, demandOption, choices, parse, }: ReadEnvFieldOptions<T>): T | undefined;
70
+ /**
71
+ * 结合 option 配置读取字段;enable 为 false 时返回 undefined。
72
+ *
73
+ * @example
74
+ * ```ts
75
+ * const base = siteEnv({ env, option });
76
+ * const cdn = readEnvOption(env, resolveOptionConfig(option.cdn, 'BIU_CDN'));
77
+ * return { ...base, cdn };
78
+ * ```
79
+ */
80
+ export declare function readEnvOption<T = string>(env: NodeJS.ProcessEnv, conf: ResolvedOptionConfig, parse?: (raw: string) => T): T | undefined;
81
+ /**
82
+ * 从环境变量读取站点构建配置。
83
+ *
84
+ * 默认环境变量:
85
+ * - `BIU_PLATFORM` = ios | android
86
+ * - `BIU_SITE` = 291jili | ...(兼容 aura69 / aura88 / waspwin / so99)
87
+ * - `BIU_API` = https://...
88
+ * - `BIU_WS` = wss://...
89
+ * - `BIU_ENV` = dev | test | beta | prod
90
+ *
91
+ * @example
92
+ * ```bash
93
+ * BIU_PLATFORM=ios BIU_SITE=291jili BIU_API=https://api.example.com BIU_WS=wss://ws.example.com BIU_ENV=prod node build.js
94
+ * ```
95
+ *
96
+ * @example
97
+ * ```ts
98
+ * import { siteEnv, readEnvOption, resolveOptionConfig } from '@alodi/site/env';
99
+ *
100
+ * const { platform, site, api, ws, env } = siteEnv();
101
+ *
102
+ * // 扩展自定义字段
103
+ * const cdn = readEnvOption(process.env, resolveOptionConfig(undefined, 'BIU_CDN'));
104
+ * ```
105
+ */
106
+ export declare function siteEnv({ env, option }?: ParseEnvOption): Partial<SiteEnv>;
107
+ type SiteEnvKeyMap = Partial<Record<OptionName, string>> & Record<string, string>;
108
+ /**
109
+ * 将 siteEnv 结果(及扩展字段)转换成可注入的环境变量字典。
110
+ * 默认字段走 DEFAULT_ENV_KEYS;额外字段可用 keys 映射,或直接传完整 envKey。
111
+ *
112
+ * @example
113
+ * ```ts
114
+ * const values = { ...siteEnv(), cdn: 'https://cdn.example.com' };
115
+ * const env = siteEnvToProcessEnv(values, { cdn: 'BIU_CDN' });
116
+ * ```
117
+ */
118
+ export declare function siteEnvToProcessEnv(values: Partial<SiteEnv> & Record<string, string | undefined>, keys?: SiteEnvKeyMap): NodeJS.ProcessEnv;
119
+ /**
120
+ * 把解析后的配置写回目标 env(默认 process.env),供后续子进程继承。
121
+ *
122
+ * 注意:`node pre.js && vite` 这种 shell 串联时,pre 脚本改动的 process.env
123
+ * 不会影响后续 vite;请在 pre 脚本内 spawn/exec Vite。
124
+ *
125
+ * @example 推荐:预处理后 spawn Vite,复用同一份环境
126
+ * ```ts
127
+ * // scripts/build.mts
128
+ * import { spawnSync } from 'node:child_process';
129
+ * import {
130
+ * siteEnv,
131
+ * applySiteEnv,
132
+ * readEnvOption,
133
+ * resolveOptionConfig,
134
+ * } from '@alodi/site/env';
135
+ *
136
+ * // 1. 解析并校验 BIU_*(含 site 别名归一化)
137
+ * const base = siteEnv();
138
+ *
139
+ * // 2. 按需扩展字段
140
+ * const cdn = readEnvOption(process.env, resolveOptionConfig(undefined, 'BIU_CDN'));
141
+ *
142
+ * // 3. 写回 process.env,供子进程继承
143
+ * applySiteEnv({ ...base, ...(cdn ? { cdn } : {}) }, process.env, {
144
+ * cdn: 'BIU_CDN',
145
+ * });
146
+ *
147
+ * // 4. 在同一进程链路中启动 Vite(不要用 `node pre && vite`)
148
+ * const result = spawnSync('vite', ['build'], {
149
+ * stdio: 'inherit',
150
+ * env: process.env,
151
+ * shell: true,
152
+ * });
153
+ * process.exit(result.status ?? 1);
154
+ * ```
155
+ *
156
+ * @example package.json
157
+ * ```json
158
+ * {
159
+ * "scripts": {
160
+ * "build": "tsx scripts/build.mts"
161
+ * }
162
+ * }
163
+ * ```
164
+ *
165
+ * @example 启动命令
166
+ * ```bash
167
+ * BIU_PLATFORM=ios BIU_SITE=291jili BIU_API=https://api.example.com BIU_WS=wss://ws.example.com BIU_ENV=prod BIU_CDN=https://cdn.example.com npm run build
168
+ * ```
169
+ */
170
+ export declare function applySiteEnv(values: Partial<SiteEnv> & Record<string, string | undefined>, target?: NodeJS.ProcessEnv, keys?: SiteEnvKeyMap): NodeJS.ProcessEnv;
171
+ /** 将 env 字典格式化为 dotenv 文本,便于 Vite 读取 */
172
+ export declare function formatDotEnv(env: Record<string, string | undefined>): string;
173
+ export {};
174
+ //# sourceMappingURL=env.d.ts.map
@@ -0,0 +1 @@
1
+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IAAI,EAAE,oBAAoB,EAC1B,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,CAAC,GACzB,CAAC,GAAG,SAAS,CASf;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,OAAO,CAAC,EAAE,GAAiB,EAAE,MAAW,EAAE,GAAE,cAAmB,GAAG,OAAO,CAAC,OAAO,CAAC,CA+BjG;AAED,KAAK,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAElF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC7D,IAAI,GAAE,aAAgC,GACrC,MAAM,CAAC,UAAU,CAiBnB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,EAC7D,MAAM,GAAE,MAAM,CAAC,UAAwB,EACvC,IAAI,GAAE,aAAgC,GACrC,MAAM,CAAC,UAAU,CAEnB;AASD,wCAAwC;AACxC,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,GAAG,MAAM,CAK5E"}
@@ -0,0 +1,190 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // src/env.ts
20
+ var env_exports = {};
21
+ __export(env_exports, {
22
+ DEFAULT_ENV_KEYS: () => DEFAULT_ENV_KEYS,
23
+ ENVS: () => ENVS,
24
+ PLATFORMS: () => PLATFORMS,
25
+ SITE_ALIASES: () => SITE_ALIASES,
26
+ applySiteEnv: () => applySiteEnv,
27
+ assertEnvChoice: () => assertEnvChoice,
28
+ formatDotEnv: () => formatDotEnv,
29
+ readEnvField: () => readEnvField,
30
+ readEnvOption: () => readEnvOption,
31
+ readEnvValue: () => readEnvValue,
32
+ resolveOptionConfig: () => resolveOptionConfig,
33
+ resolveSite: () => resolveSite,
34
+ siteEnv: () => siteEnv,
35
+ siteEnvToProcessEnv: () => siteEnvToProcessEnv
36
+ });
37
+ module.exports = __toCommonJS(env_exports);
38
+ var import_site = require("./site");
39
+ var PLATFORMS = ["ios", "android"];
40
+ var ENVS = ["dev", "test", "beta", "prod"];
41
+ var SITE_ALIASES = {
42
+ aura69: import_site.SITE.PG_91,
43
+ aura88: import_site.SITE.PG_82,
44
+ waspwin: import_site.SITE.ZAPP_SPIN,
45
+ so99: import_site.SITE.SORTE_WIN
46
+ };
47
+ var DEFAULT_ENV_KEYS = {
48
+ platform: "BIU_PLATFORM",
49
+ site: "BIU_SITE",
50
+ api: "BIU_API",
51
+ ws: "BIU_WS",
52
+ env: "BIU_ENV"
53
+ };
54
+ function resolveSite(value) {
55
+ const site = SITE_ALIASES[value] ?? value;
56
+ if (!Object.values(import_site.SITE).includes(site)) {
57
+ throw new Error(
58
+ `Invalid SITE "${value}", expected one of: ${Object.values(import_site.SITE).join(", ")} (aliases: ${Object.keys(SITE_ALIASES).join(", ")})`
59
+ );
60
+ }
61
+ return site;
62
+ }
63
+ function readEnvValue(env, key, demand = true) {
64
+ var _a;
65
+ const value = (_a = env[key]) == null ? void 0 : _a.trim();
66
+ if (!value) {
67
+ if (demand)
68
+ throw new Error(`Missing required env ${key}`);
69
+ return void 0;
70
+ }
71
+ return value;
72
+ }
73
+ function assertEnvChoice(value, choices, key) {
74
+ if (!choices.includes(value)) {
75
+ throw new Error(`Invalid ${key} "${value}", expected one of: ${choices.join(", ")}`);
76
+ }
77
+ return value;
78
+ }
79
+ function resolveOptionConfig(conf, defaultEnvKey) {
80
+ if (conf === false)
81
+ return { enable: false };
82
+ return {
83
+ enable: (conf == null ? void 0 : conf.enable) !== false,
84
+ envKey: (conf == null ? void 0 : conf.envKey) ?? defaultEnvKey,
85
+ demandOption: (conf == null ? void 0 : conf.demandOption) ?? true,
86
+ choices: conf == null ? void 0 : conf.choices
87
+ };
88
+ }
89
+ function readEnvField({
90
+ env = process.env,
91
+ envKey,
92
+ demandOption = true,
93
+ choices,
94
+ parse
95
+ }) {
96
+ const raw = readEnvValue(env, envKey, demandOption);
97
+ if (raw === void 0)
98
+ return void 0;
99
+ if (choices)
100
+ assertEnvChoice(raw, choices, envKey);
101
+ return parse ? parse(raw) : raw;
102
+ }
103
+ function readEnvOption(env, conf, parse) {
104
+ if (!conf.enable)
105
+ return void 0;
106
+ return readEnvField({
107
+ env,
108
+ envKey: conf.envKey,
109
+ demandOption: conf.demandOption,
110
+ choices: conf.choices,
111
+ parse
112
+ });
113
+ }
114
+ function siteEnv({ env = process.env, option = {} } = {}) {
115
+ const result = {};
116
+ {
117
+ const conf = resolveOptionConfig(option.platform, DEFAULT_ENV_KEYS.platform);
118
+ const platform = readEnvOption(env, conf.enable ? { ...conf, choices: conf.choices ?? PLATFORMS } : conf);
119
+ if (platform !== void 0)
120
+ result.platform = platform;
121
+ }
122
+ {
123
+ const site = readEnvOption(env, resolveOptionConfig(option.site, DEFAULT_ENV_KEYS.site), resolveSite);
124
+ if (site !== void 0)
125
+ result.site = site;
126
+ }
127
+ {
128
+ const api = readEnvOption(env, resolveOptionConfig(option.api, DEFAULT_ENV_KEYS.api));
129
+ if (api !== void 0)
130
+ result.api = api;
131
+ }
132
+ {
133
+ const ws = readEnvOption(env, resolveOptionConfig(option.ws, DEFAULT_ENV_KEYS.ws));
134
+ if (ws !== void 0)
135
+ result.ws = ws;
136
+ }
137
+ {
138
+ const conf = resolveOptionConfig(option.env, DEFAULT_ENV_KEYS.env);
139
+ const buildEnv = readEnvOption(env, conf.enable ? { ...conf, choices: conf.choices ?? ENVS } : conf);
140
+ if (buildEnv !== void 0)
141
+ result.env = buildEnv;
142
+ }
143
+ return result;
144
+ }
145
+ function siteEnvToProcessEnv(values, keys = DEFAULT_ENV_KEYS) {
146
+ const out = {};
147
+ const known = ["platform", "site", "api", "ws", "env"];
148
+ for (const name of known) {
149
+ const value = values[name];
150
+ if (value === void 0)
151
+ continue;
152
+ out[keys[name] ?? DEFAULT_ENV_KEYS[name]] = value;
153
+ }
154
+ for (const [name, value] of Object.entries(values)) {
155
+ if (value === void 0 || known.includes(name))
156
+ continue;
157
+ const envKey = keys[name] ?? name;
158
+ out[envKey] = value;
159
+ }
160
+ return out;
161
+ }
162
+ function applySiteEnv(values, target = process.env, keys = DEFAULT_ENV_KEYS) {
163
+ return Object.assign(target, siteEnvToProcessEnv(values, keys));
164
+ }
165
+ function stringifyDotEnvValue(value) {
166
+ if (/[\s#"']/.test(value)) {
167
+ return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
168
+ }
169
+ return value;
170
+ }
171
+ function formatDotEnv(env) {
172
+ return Object.entries(env).filter((entry) => entry[1] !== void 0).map(([key, value]) => `${key}=${stringifyDotEnvValue(value)}`).join("\n");
173
+ }
174
+ // Annotate the CommonJS export names for ESM import in node:
175
+ 0 && (module.exports = {
176
+ DEFAULT_ENV_KEYS,
177
+ ENVS,
178
+ PLATFORMS,
179
+ SITE_ALIASES,
180
+ applySiteEnv,
181
+ assertEnvChoice,
182
+ formatDotEnv,
183
+ readEnvField,
184
+ readEnvOption,
185
+ readEnvValue,
186
+ resolveOptionConfig,
187
+ resolveSite,
188
+ siteEnv,
189
+ siteEnvToProcessEnv
190
+ });
@@ -1,39 +1,2 @@
1
- type ValueType<T extends object> = T[keyof T];
2
- export declare const COUNTRY: {
3
- readonly PHL: "PHL";
4
- readonly THA: "THA";
5
- readonly VNM: "VNM";
6
- readonly BRA: "BRA";
7
- };
8
- export type CountryName = ValueType<typeof COUNTRY>;
9
- export declare const SITE: {
10
- readonly JILI_291: "291jili";
11
- readonly SUPER_291: "super291";
12
- readonly JILI_646: "646jili";
13
- readonly LODI_291: "lodi291";
14
- readonly TOP_646: "top646";
15
- readonly JILI_80: "80jili";
16
- readonly PH_646: "ph646";
17
- readonly ACE_291: "ace291";
18
- readonly HOT_646: "hot646";
19
- readonly LODI_646: "lodi646";
20
- readonly LODI_GAME: "lodigame";
21
- readonly LOL_646: "lol646";
22
- readonly LODI_777: "lodi777";
23
- readonly YDG_777: "ydg777";
24
- } & {
25
- readonly WASP: "wasp";
26
- readonly PG_82: "82pg";
27
- readonly PG_91: "91pg";
28
- readonly ZAPP_SPIN: "zappspin";
29
- readonly WASP_SPIN: "waspspin";
30
- readonly HAA_555: "haa555";
31
- readonly TRADING: "trading";
32
- } & {
33
- readonly VANG_WIN: "vangwin";
34
- } & {
35
- readonly SORTE_WIN: "sortewin";
36
- };
37
- export type SiteName = ValueType<typeof SITE>;
38
- export declare const getSiteCountry: (site: SiteName) => "PHL" | "THA" | "VNM" | "BRA" | undefined;
39
- export {};
1
+ export * from './site';
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC"}
package/dist/cjs/index.js CHANGED
@@ -2,10 +2,6 @@ var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
3
  var __getOwnPropNames = Object.getOwnPropertyNames;
4
4
  var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
5
  var __copyProps = (to, from, except, desc) => {
10
6
  if (from && typeof from === "object" || typeof from === "function") {
11
7
  for (let key of __getOwnPropNames(from))
@@ -14,69 +10,14 @@ var __copyProps = (to, from, except, desc) => {
14
10
  }
15
11
  return to;
16
12
  };
13
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
17
14
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
15
 
19
16
  // src/index.ts
20
17
  var src_exports = {};
21
- __export(src_exports, {
22
- COUNTRY: () => COUNTRY,
23
- SITE: () => SITE,
24
- getSiteCountry: () => getSiteCountry
25
- });
26
18
  module.exports = __toCommonJS(src_exports);
27
- var COUNTRY = {
28
- PHL: "PHL",
29
- THA: "THA",
30
- VNM: "VNM",
31
- BRA: "BRA"
32
- };
33
- var SITE_MAP = {
34
- [COUNTRY.PHL]: {
35
- JILI_291: "291jili",
36
- SUPER_291: "super291",
37
- JILI_646: "646jili",
38
- LODI_291: "lodi291",
39
- TOP_646: "top646",
40
- JILI_80: "80jili",
41
- PH_646: "ph646",
42
- ACE_291: "ace291",
43
- HOT_646: "hot646",
44
- LODI_646: "lodi646",
45
- LODI_GAME: "lodigame",
46
- LOL_646: "lol646",
47
- LODI_777: "lodi777",
48
- YDG_777: "ydg777"
49
- },
50
- [COUNTRY.THA]: {
51
- WASP: "wasp",
52
- PG_82: "82pg",
53
- PG_91: "91pg",
54
- ZAPP_SPIN: "zappspin",
55
- WASP_SPIN: "waspspin",
56
- HAA_555: "haa555",
57
- TRADING: "trading"
58
- },
59
- [COUNTRY.VNM]: {
60
- VANG_WIN: "vangwin"
61
- },
62
- [COUNTRY.BRA]: {
63
- SORTE_WIN: "sortewin"
64
- }
65
- };
66
- var SITE = Object.keys(SITE_MAP).reduce(
67
- (acc, cur) => ({ ...acc, ...SITE_MAP[cur] }),
68
- {}
69
- );
70
- var getSiteCountry = (site) => {
71
- for (const country of Object.keys(SITE_MAP)) {
72
- if (Object.values(SITE_MAP[country]).some((_) => _ === site)) {
73
- return country;
74
- }
75
- }
76
- };
19
+ __reExport(src_exports, require("./site"), module.exports);
77
20
  // Annotate the CommonJS export names for ESM import in node:
78
21
  0 && (module.exports = {
79
- COUNTRY,
80
- SITE,
81
- getSiteCountry
22
+ ...require("./site")
82
23
  });