keytops-game-framework 1.0.2 → 1.0.4
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/app/module/net/server/IServer.d.ts +7 -45
- package/dist/app/module/remoteConfig/BaseOnlineConfig.d.ts +18 -13
- package/dist/app/module/remoteConfig/IRemoteConfigStore.d.ts +6 -5
- package/dist/app/module/remoteConfig/LevelOnlineConfig.d.ts +7 -10
- package/dist/app/module/remoteConfig/RemoteConfigDefinitions.d.ts +5 -5
- package/dist/app/module/remoteConfig/RemoteConfigRegistry.d.ts +10 -0
- package/dist/app/module/remoteConfig/RemoteConfigService.d.ts +11 -18
- package/dist/app/module/remoteConfig/RemoteConfigStore.d.ts +10 -8
- package/dist/app/module/remoteConfig/SystemOnlineConfig.d.ts +2 -10
- package/dist/index.js +358 -389
- package/package.json +1 -1
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { ConfigResolveMeta } from "../../analytics/AnalyticsAbleConst";
|
|
2
2
|
export interface OnlineConfig extends Record<string, any> {
|
|
3
|
+
buildRequestData?(request?: ServerParamStruct | undefined): ServerParamStruct | undefined;
|
|
4
|
+
extractPayloads?(response: ServerResponseStruct): Record<string, any> | undefined;
|
|
5
|
+
merge?(target: this, payloads?: Record<string, any>): this;
|
|
3
6
|
}
|
|
4
7
|
export type ServerResponseStruct = {
|
|
5
8
|
timestamp?: number;
|
|
@@ -10,57 +13,16 @@ type BaseValueType = string | number | boolean;
|
|
|
10
13
|
export type ServerParamStruct = {
|
|
11
14
|
[key: string]: BaseValueType | BaseValueType[] | ServerParamStruct;
|
|
12
15
|
};
|
|
13
|
-
export type RemoteConfigScope = {
|
|
14
|
-
gameFlag?: string;
|
|
15
|
-
[key: string]: BaseValueType | undefined;
|
|
16
|
-
};
|
|
17
16
|
export type RemoteConfigRequestOptions = {
|
|
18
17
|
refresh?: boolean;
|
|
19
18
|
debug?: boolean;
|
|
20
19
|
};
|
|
21
|
-
export interface RemoteConfigDefinition<TConfig extends OnlineConfig = OnlineConfig, TQuery extends ServerParamStruct | undefined = ServerParamStruct> {
|
|
22
|
-
/**
|
|
23
|
-
* 配置端口名称,内置system\config\level
|
|
24
|
-
*/
|
|
25
|
-
method: string;
|
|
26
|
-
/**
|
|
27
|
-
* 创建该配置类型的默认实例。
|
|
28
|
-
* 未请求远端时,snapshot 也必须能返回一个可用对象,所以这里不能省略。
|
|
29
|
-
*/
|
|
30
|
-
createDefault(): TConfig;
|
|
31
|
-
/**
|
|
32
|
-
* 把业务侧传入的 request 参数转换成服务器协议需要的 data 字段。
|
|
33
|
-
* 公共字段由 IServer 实现补齐,这里只负责当前配置类型自己的请求载荷。
|
|
34
|
-
*/
|
|
35
|
-
buildRequestData(request?: TQuery, scope?: RemoteConfigScope): ServerParamStruct | undefined;
|
|
36
|
-
/**
|
|
37
|
-
* 从统一的服务器响应中抽出当前配置真正关心的 payload 部分。
|
|
38
|
-
* 如果后续不同配置类型的响应结构不一致,这里就是第一层适配点。
|
|
39
|
-
*/
|
|
40
|
-
extractPayloads(response: ServerResponseStruct): Record<string, any> | undefined;
|
|
41
|
-
/**
|
|
42
|
-
* 定义当前配置的装配策略。
|
|
43
|
-
* 可按字段 merge,也可整体替换,RemoteConfigStore 不关心具体策略,只调用这里。
|
|
44
|
-
*/
|
|
45
|
-
merge(target: TConfig, payloads?: Record<string, any>): TConfig;
|
|
46
|
-
}
|
|
47
|
-
/**
|
|
48
|
-
* definition 的公共抽象基类。
|
|
49
|
-
* interface 负责定义框架契约,abstract class 负责沉淀共用实现。
|
|
50
|
-
*/
|
|
51
|
-
export declare abstract class AbstractRemoteConfigDefinition<TConfig extends OnlineConfig = OnlineConfig, TQuery extends ServerParamStruct | undefined = ServerParamStruct> implements RemoteConfigDefinition<TConfig, TQuery> {
|
|
52
|
-
abstract method: string;
|
|
53
|
-
abstract createDefault(): TConfig;
|
|
54
|
-
abstract merge(target: TConfig, payloads?: Record<string, any>): TConfig;
|
|
55
|
-
protected mergeConfigField(target: OnlineConfig, key: string, payload: unknown): void;
|
|
56
|
-
protected mergeObjectConfig<T extends OnlineConfig>(target: T, payloads?: Record<string, any>): T;
|
|
57
|
-
buildRequestData(request?: TQuery, _scope?: RemoteConfigScope): ServerParamStruct | undefined;
|
|
58
|
-
extractPayloads(response: ServerResponseStruct): Record<string, any> | undefined;
|
|
59
|
-
}
|
|
60
20
|
export interface ServerRequestContext<TConfig extends OnlineConfig = OnlineConfig, TQuery extends ServerParamStruct | undefined = ServerParamStruct> {
|
|
61
|
-
|
|
62
|
-
|
|
21
|
+
method: string;
|
|
22
|
+
gameFlag: string;
|
|
23
|
+
config: TConfig;
|
|
63
24
|
request?: TQuery;
|
|
25
|
+
requestData?: ServerParamStruct;
|
|
64
26
|
options?: RemoteConfigRequestOptions;
|
|
65
27
|
}
|
|
66
28
|
export interface IServer {
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
3
|
-
|
|
1
|
+
import type { OnlineConfig, ServerParamStruct, ServerResponseStruct } from "../net/server/IServer";
|
|
2
|
+
export type RemoteConfigRequest = ServerParamStruct | undefined;
|
|
3
|
+
export declare class BaseOnlineConfig<TRequest extends RemoteConfigRequest = ServerParamStruct> implements OnlineConfig {
|
|
4
|
+
protected mergeConfigField(target: OnlineConfig, key: string, payload: unknown): void;
|
|
5
|
+
protected mergeObjectConfig<T extends OnlineConfig>(target: T, payloads?: Record<string, any>): T;
|
|
6
|
+
buildRequestData(request?: TRequest): ServerParamStruct | undefined;
|
|
7
|
+
extractPayloads(response: ServerResponseStruct): Record<string, any> | undefined;
|
|
8
|
+
merge(target: this, payloads?: Record<string, any>): this;
|
|
4
9
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare class BaseRemoteConfigDefinitionClass extends AbstractRemoteConfigDefinition<BaseOnlineConfig, ServerParamStruct> {
|
|
10
|
+
export type RemoteConfigClass<TConfig extends BaseOnlineConfig<any> = BaseOnlineConfig<any>> = {
|
|
11
|
+
new (): TConfig;
|
|
12
|
+
};
|
|
13
|
+
export type RemoteConfigRequestOf<TConfigClass extends RemoteConfigClass> = InstanceType<TConfigClass> extends BaseOnlineConfig<infer TRequest> ? TRequest : ServerParamStruct;
|
|
14
|
+
export type RemoteConfigMeta<TConfigClass extends RemoteConfigClass = RemoteConfigClass> = {
|
|
11
15
|
method: string;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
gameFlag: string;
|
|
17
|
+
key: string;
|
|
18
|
+
injectorKey: string;
|
|
19
|
+
configClass: TConfigClass;
|
|
20
|
+
};
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ConfigResolveMeta } from "../analytics/AnalyticsAbleConst";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServerResponseStruct } from "../net/server/IServer";
|
|
3
|
+
import type { RemoteConfigClass } from "./BaseOnlineConfig";
|
|
3
4
|
export interface IRemoteConfigStore {
|
|
4
|
-
snapshot<
|
|
5
|
-
apply<
|
|
6
|
-
getResolveMeta<
|
|
7
|
-
isLoaded<
|
|
5
|
+
snapshot<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): InstanceType<TConfigClass>;
|
|
6
|
+
apply<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass, response: ServerResponseStruct): InstanceType<TConfigClass>;
|
|
7
|
+
getResolveMeta<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): ConfigResolveMeta | undefined;
|
|
8
|
+
isLoaded<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): boolean;
|
|
8
9
|
clear(): void;
|
|
9
10
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { BaseOnlineConfig } from "./BaseOnlineConfig";
|
|
2
|
+
type LevelConfigRequest = {
|
|
3
|
+
id: string;
|
|
4
|
+
};
|
|
5
|
+
export declare class LevelOnlineConfig extends BaseOnlineConfig<LevelConfigRequest> {
|
|
5
6
|
info: {
|
|
6
7
|
id: string;
|
|
7
8
|
repeat: 0 | 1;
|
|
8
9
|
[key: string]: any;
|
|
9
10
|
};
|
|
11
|
+
merge(_target: this, payloads?: Record<string, any>): this;
|
|
10
12
|
}
|
|
11
|
-
export
|
|
12
|
-
method: string;
|
|
13
|
-
createDefault(): LevelOnlineConfig;
|
|
14
|
-
merge(_target: LevelOnlineConfig, payloads?: Record<string, any>): LevelOnlineConfig;
|
|
15
|
-
}
|
|
16
|
-
export declare const LevelRemoteConfigDefinition: LevelRemoteConfigDefinitionClass;
|
|
13
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
export { remoteConfig, type IRemoteConfigRegistry, } from "./RemoteConfigRegistry";
|
|
2
|
+
export { type RemoteConfigClass, type RemoteConfigMeta, type RemoteConfigRequestOf, } from "./BaseOnlineConfig";
|
|
2
3
|
export declare const INTERNAL_METHODS: {
|
|
3
|
-
readonly CONFIG:
|
|
4
|
-
readonly SYSTEM:
|
|
5
|
-
readonly LEVEL:
|
|
4
|
+
readonly CONFIG: "config";
|
|
5
|
+
readonly SYSTEM: "system";
|
|
6
|
+
readonly LEVEL: "level";
|
|
6
7
|
};
|
|
7
|
-
export declare function getRemoteConfigDefinition(method: string): RemoteConfigDefinition<OnlineConfig, ServerParamStruct>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type RemoteConfigClass, type RemoteConfigMeta } from "./BaseOnlineConfig";
|
|
2
|
+
export interface IRemoteConfigRegistry {
|
|
3
|
+
register<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass, method: string, gameFlag?: string, injectorKey?: string): void;
|
|
4
|
+
getMeta<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): RemoteConfigMeta<TConfigClass>;
|
|
5
|
+
getActiveMeta<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): RemoteConfigMeta;
|
|
6
|
+
create<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): InstanceType<TConfigClass>;
|
|
7
|
+
createKey(method: string, gameFlag?: string): string;
|
|
8
|
+
}
|
|
9
|
+
export declare function getRemoteConfigRegistry(): IRemoteConfigRegistry;
|
|
10
|
+
export declare function remoteConfig(method: string, gameFlag?: string, injectorKey?: string): ClassDecorator;
|
|
@@ -1,46 +1,39 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IRemoteConfigStore } from "./IRemoteConfigStore";
|
|
2
|
+
import type { RemoteConfigRequestOptions } from "../net/server/IServer";
|
|
2
3
|
import { ConfigResolveMeta } from "../analytics/AnalyticsAbleConst";
|
|
4
|
+
import type { RemoteConfigClass, RemoteConfigRequestOf } from "./BaseOnlineConfig";
|
|
3
5
|
export declare class RemoteConfigService {
|
|
4
6
|
private _store;
|
|
7
|
+
private _registry;
|
|
5
8
|
/**
|
|
6
9
|
* 统一暴露给测试和少量编排场景的 server 门面。
|
|
7
10
|
* 真正的协议实现仍然隐藏在 server 内部注入链路后面。
|
|
8
11
|
*/
|
|
9
12
|
get server(): import("../net/server/Server").Server;
|
|
13
|
+
private get registry();
|
|
10
14
|
/**
|
|
11
15
|
* store 只负责快照/持久化/resolveMeta,不负责发请求。
|
|
12
16
|
* 这样请求协议切换时,不需要改缓存与装配逻辑。
|
|
13
17
|
*/
|
|
14
|
-
|
|
18
|
+
get store(): IRemoteConfigStore;
|
|
15
19
|
/**
|
|
16
20
|
* 请求并应用远程配置,返回已装配的快照。
|
|
17
|
-
* @param
|
|
21
|
+
* @param configClass 配置类
|
|
18
22
|
* @param request 请求参数
|
|
19
|
-
* @param scope 作用域
|
|
20
23
|
* @param options 请求选项
|
|
21
24
|
* @returns 装配后的配置快照
|
|
22
25
|
*/
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* 与旧调用习惯兼容的主入口。
|
|
26
|
-
* 语义上等价于 refresh:必要时请求远端,失败时回退本地快照。
|
|
27
|
-
*/
|
|
28
|
-
resolve<TConfig extends OnlineConfig, TQuery extends ServerParamStruct | undefined>(definition: RemoteConfigDefinition<TConfig, TQuery>, request?: TQuery, scope?: RemoteConfigScope, options?: RemoteConfigRequestOptions): Promise<TConfig>;
|
|
26
|
+
fetch<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass, request?: RemoteConfigRequestOf<TConfigClass>, options?: RemoteConfigRequestOptions): Promise<InstanceType<TConfigClass>>;
|
|
29
27
|
/**
|
|
30
28
|
* 获取配置。
|
|
31
|
-
* @param
|
|
32
|
-
* @param scope 作用域
|
|
29
|
+
* @param configClass 配置类
|
|
33
30
|
* @returns 配置
|
|
34
31
|
*/
|
|
35
|
-
config<
|
|
36
|
-
/**
|
|
37
|
-
* 与旧调用习惯兼容的只读快照接口。
|
|
38
|
-
*/
|
|
39
|
-
snapshot<TConfig extends OnlineConfig>(definition: RemoteConfigDefinition<TConfig, any>, scope?: RemoteConfigScope): TConfig;
|
|
32
|
+
config<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): InstanceType<TConfigClass>;
|
|
40
33
|
/**
|
|
41
34
|
* 读取最近一次成功命中的 resolve 元信息。
|
|
42
35
|
*/
|
|
43
|
-
resolveMeta<
|
|
36
|
+
resolveMeta<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): ConfigResolveMeta | undefined;
|
|
44
37
|
/**
|
|
45
38
|
* system URL 统一从这里解析,避免调用方直接依赖 helper 或拼接规则。
|
|
46
39
|
*/
|
|
@@ -1,20 +1,22 @@
|
|
|
1
1
|
import type { IRemoteConfigStore } from "./IRemoteConfigStore";
|
|
2
|
-
import type {
|
|
2
|
+
import type { ServerResponseStruct } from "../net/server/IServer";
|
|
3
3
|
import { ConfigResolveMeta } from "../analytics/AnalyticsAbleConst";
|
|
4
|
+
import type { RemoteConfigClass } from "./BaseOnlineConfig";
|
|
5
|
+
import type { IRemoteConfigRegistry } from "./RemoteConfigRegistry";
|
|
4
6
|
export declare class RemoteConfigStore implements IRemoteConfigStore {
|
|
7
|
+
private _registry;
|
|
5
8
|
static KEY: string;
|
|
6
9
|
private _snapshots;
|
|
7
10
|
private _loadedKeys;
|
|
8
11
|
private _contexts;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
constructor(_registry: IRemoteConfigRegistry);
|
|
13
|
+
snapshot<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): InstanceType<TConfigClass>;
|
|
14
|
+
apply<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass, response: ServerResponseStruct): InstanceType<TConfigClass>;
|
|
15
|
+
getResolveMeta<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): ConfigResolveMeta | undefined;
|
|
16
|
+
isLoaded<TConfigClass extends RemoteConfigClass>(configClass: TConfigClass): boolean;
|
|
13
17
|
clear(): void;
|
|
14
18
|
private ensureContexts;
|
|
15
|
-
private
|
|
16
|
-
private createScopedKey;
|
|
17
|
-
private getScopeKey;
|
|
19
|
+
private getConfigKey;
|
|
18
20
|
private getStorageKey;
|
|
19
21
|
private setResolveMeta;
|
|
20
22
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import type { AliAnalyticsConfig } from "../analytics/ALiAnalyticsSender";
|
|
2
2
|
import type { KeytopsAnalyticsConfig } from "../analytics/KeytopsAnalyticsSender";
|
|
3
3
|
import { ADConfig } from "../publisher/IADAble";
|
|
4
|
-
import {
|
|
5
|
-
import { BaseRemoteConfigDefinitionClass } from "./BaseOnlineConfig";
|
|
4
|
+
import { BaseOnlineConfig } from "./BaseOnlineConfig";
|
|
6
5
|
export type RelayAnalyticsConfig = Partial<AliAnalyticsConfig> & KeytopsAnalyticsConfig;
|
|
7
6
|
/**
|
|
8
7
|
* system 端口默认配置,承载 SDK 基础运行时能力。
|
|
9
8
|
*/
|
|
10
|
-
export declare class SystemOnlineConfig
|
|
11
|
-
static KEY: string;
|
|
9
|
+
export declare class SystemOnlineConfig extends BaseOnlineConfig {
|
|
12
10
|
url: {
|
|
13
11
|
domain: string;
|
|
14
12
|
configAPI: string;
|
|
@@ -32,10 +30,4 @@ export declare class SystemOnlineConfig implements OnlineConfig {
|
|
|
32
30
|
toString(): string;
|
|
33
31
|
resolveSystemUrl(path?: string): string;
|
|
34
32
|
}
|
|
35
|
-
export declare class SystemRemoteConfigDefinitionClass extends BaseRemoteConfigDefinitionClass {
|
|
36
|
-
method: string;
|
|
37
|
-
createDefault(): SystemOnlineConfig;
|
|
38
|
-
merge(target: SystemOnlineConfig, payloads?: Record<string, any>): SystemOnlineConfig;
|
|
39
|
-
}
|
|
40
|
-
export declare const SystemRemoteConfigDefinition: SystemRemoteConfigDefinitionClass;
|
|
41
33
|
export declare function resolveSystemUrl(path?: string, config?: SystemOnlineConfig): string;
|
package/dist/index.js
CHANGED
|
@@ -2923,11 +2923,7 @@ Server.KEY = "Server";
|
|
|
2923
2923
|
*/
|
|
2924
2924
|
const server = new Server();
|
|
2925
2925
|
|
|
2926
|
-
|
|
2927
|
-
* definition 的公共抽象基类。
|
|
2928
|
-
* interface 负责定义框架契约,abstract class 负责沉淀共用实现。
|
|
2929
|
-
*/
|
|
2930
|
-
class AbstractRemoteConfigDefinition {
|
|
2926
|
+
class BaseOnlineConfig {
|
|
2931
2927
|
mergeConfigField(target, key, payload) {
|
|
2932
2928
|
const current = target[key];
|
|
2933
2929
|
if (current &&
|
|
@@ -2947,48 +2943,77 @@ class AbstractRemoteConfigDefinition {
|
|
|
2947
2943
|
});
|
|
2948
2944
|
return target;
|
|
2949
2945
|
}
|
|
2950
|
-
buildRequestData(request
|
|
2946
|
+
buildRequestData(request) {
|
|
2951
2947
|
return request;
|
|
2952
2948
|
}
|
|
2953
2949
|
extractPayloads(response) {
|
|
2954
2950
|
return response.payloads || {};
|
|
2955
2951
|
}
|
|
2956
|
-
|
|
2957
|
-
|
|
2958
|
-
requestConfig(_context) {
|
|
2959
|
-
return Promise.resolve({ payloads: {} });
|
|
2952
|
+
merge(target, payloads) {
|
|
2953
|
+
return this.mergeObjectConfig(target, payloads);
|
|
2960
2954
|
}
|
|
2961
2955
|
}
|
|
2962
|
-
NoRequestServer.KEY = "Server";
|
|
2963
2956
|
|
|
2964
|
-
class
|
|
2965
|
-
}
|
|
2966
|
-
BaseOnlineConfig.KEY = "OnlineConfig_config_default";
|
|
2967
|
-
/**
|
|
2968
|
-
* Base/config 端口的内建定义。
|
|
2969
|
-
* 后续新增 activity / dungeon 等远程配置时,直接新增新的 definition 即可,
|
|
2970
|
-
* 不需要再回到 Server.ts 里扩展 method 分支。
|
|
2971
|
-
*/
|
|
2972
|
-
class BaseRemoteConfigDefinitionClass extends AbstractRemoteConfigDefinition {
|
|
2957
|
+
class RemoteConfigRegistry {
|
|
2973
2958
|
constructor() {
|
|
2974
|
-
|
|
2975
|
-
this.
|
|
2959
|
+
this._classMeta = new Map();
|
|
2960
|
+
this._keyClass = new Map();
|
|
2976
2961
|
}
|
|
2977
|
-
|
|
2978
|
-
|
|
2962
|
+
register(configClass, method, gameFlag = "default", injectorKey) {
|
|
2963
|
+
if (!(configClass.prototype instanceof BaseOnlineConfig) && configClass !== BaseOnlineConfig) {
|
|
2964
|
+
throw new Error(`远程配置${configClass.name || method}必须继承BaseOnlineConfig`);
|
|
2965
|
+
}
|
|
2966
|
+
const normalizedGameFlag = gameFlag || "default";
|
|
2967
|
+
const key = this.createKey(method, normalizedGameFlag);
|
|
2968
|
+
const resolvedInjectorKey = injectorKey || `OnlineConfig_${method}_${normalizedGameFlag}_class`;
|
|
2969
|
+
const meta = {
|
|
2970
|
+
method,
|
|
2971
|
+
gameFlag: normalizedGameFlag,
|
|
2972
|
+
key,
|
|
2973
|
+
injectorKey: resolvedInjectorKey,
|
|
2974
|
+
configClass,
|
|
2975
|
+
};
|
|
2976
|
+
this._classMeta.set(configClass, meta);
|
|
2977
|
+
this._keyClass.set(key, configClass);
|
|
2978
|
+
Injector.inject(resolvedInjectorKey, configClass);
|
|
2979
2979
|
}
|
|
2980
|
-
|
|
2981
|
-
|
|
2980
|
+
getMeta(configClass) {
|
|
2981
|
+
const meta = this._classMeta.get(configClass);
|
|
2982
|
+
if (!meta) {
|
|
2983
|
+
throw new Error(`远程配置${configClass.name}未注册`);
|
|
2984
|
+
}
|
|
2985
|
+
return meta;
|
|
2986
|
+
}
|
|
2987
|
+
getActiveMeta(configClass) {
|
|
2988
|
+
const meta = this.getMeta(configClass);
|
|
2989
|
+
const activeClass = this._keyClass.get(meta.key) || configClass;
|
|
2990
|
+
return this.getMeta(activeClass);
|
|
2991
|
+
}
|
|
2992
|
+
create(configClass) {
|
|
2993
|
+
const meta = this.getActiveMeta(configClass);
|
|
2994
|
+
return Injector.getInjectAlone(meta.injectorKey, meta.configClass);
|
|
2995
|
+
}
|
|
2996
|
+
createKey(method, gameFlag = "default") {
|
|
2997
|
+
return `${method}:${gameFlag || "default"}`;
|
|
2982
2998
|
}
|
|
2983
2999
|
}
|
|
2984
|
-
const
|
|
2985
|
-
|
|
3000
|
+
const remoteConfigRegistry = new RemoteConfigRegistry();
|
|
3001
|
+
function getRemoteConfigRegistry() {
|
|
3002
|
+
return remoteConfigRegistry;
|
|
3003
|
+
}
|
|
3004
|
+
function remoteConfig(method, gameFlag = "default", injectorKey) {
|
|
3005
|
+
return function (target) {
|
|
3006
|
+
remoteConfigRegistry.register(target, method, gameFlag, injectorKey);
|
|
3007
|
+
};
|
|
3008
|
+
}
|
|
3009
|
+
remoteConfigRegistry.register(BaseOnlineConfig, "config", "default");
|
|
2986
3010
|
|
|
2987
3011
|
/**
|
|
2988
3012
|
* system 端口默认配置,承载 SDK 基础运行时能力。
|
|
2989
3013
|
*/
|
|
2990
|
-
class SystemOnlineConfig {
|
|
3014
|
+
let SystemOnlineConfig = class SystemOnlineConfig extends BaseOnlineConfig {
|
|
2991
3015
|
constructor() {
|
|
3016
|
+
super(...arguments);
|
|
2992
3017
|
this.url = {
|
|
2993
3018
|
domain: "https://api.kktgame.com",
|
|
2994
3019
|
configAPI: "/v2/config/{appid}/resolve",
|
|
@@ -3072,22 +3097,10 @@ class SystemOnlineConfig {
|
|
|
3072
3097
|
const normalizedPath = resolvedPath.startsWith("/") ? resolvedPath : `/${resolvedPath}`;
|
|
3073
3098
|
return `${normalizedDomain}${normalizedPath}`;
|
|
3074
3099
|
}
|
|
3075
|
-
}
|
|
3076
|
-
SystemOnlineConfig
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
constructor() {
|
|
3080
|
-
super(...arguments);
|
|
3081
|
-
this.method = "system";
|
|
3082
|
-
}
|
|
3083
|
-
createDefault() {
|
|
3084
|
-
return Injector.getInjectAlone(SystemOnlineConfig.KEY, SystemOnlineConfig);
|
|
3085
|
-
}
|
|
3086
|
-
merge(target, payloads) {
|
|
3087
|
-
return this.mergeObjectConfig(target, payloads);
|
|
3088
|
-
}
|
|
3089
|
-
}
|
|
3090
|
-
const SystemRemoteConfigDefinition = new SystemRemoteConfigDefinitionClass();
|
|
3100
|
+
};
|
|
3101
|
+
SystemOnlineConfig = __decorate([
|
|
3102
|
+
remoteConfig("system")
|
|
3103
|
+
], SystemOnlineConfig);
|
|
3091
3104
|
function resolveSystemUrl(path = "", config = new SystemOnlineConfig()) {
|
|
3092
3105
|
const urlConfig = config.url;
|
|
3093
3106
|
const resolvedPath = path.replace(/\{appid\}/g, publisher.appId);
|
|
@@ -3105,6 +3118,277 @@ function resolveSystemUrl(path = "", config = new SystemOnlineConfig()) {
|
|
|
3105
3118
|
return `${normalizedDomain}${normalizedPath}`;
|
|
3106
3119
|
}
|
|
3107
3120
|
|
|
3121
|
+
const RESOLVE_META_STORAGE_KEY = "ONLINE_CONFIG_CONTEXTS";
|
|
3122
|
+
class RemoteConfigStore {
|
|
3123
|
+
constructor(_registry) {
|
|
3124
|
+
this._registry = _registry;
|
|
3125
|
+
// 运行时快照:给业务读配置时尽量返回稳定对象实例,减少外部感知到的替换。
|
|
3126
|
+
this._snapshots = {};
|
|
3127
|
+
this._loadedKeys = {};
|
|
3128
|
+
this._contexts = null;
|
|
3129
|
+
}
|
|
3130
|
+
snapshot(configClass) {
|
|
3131
|
+
const configKey = this.getConfigKey(configClass);
|
|
3132
|
+
if (!this._snapshots[configKey]) {
|
|
3133
|
+
const config = this._registry.create(configClass);
|
|
3134
|
+
const persisted = storage.getGValue(this.getStorageKey(configClass), undefined);
|
|
3135
|
+
// 首次读取时先构造默认对象,再把本地持久化内容 merge 回来,保证未请求时也能正常工作。
|
|
3136
|
+
this._snapshots[configKey] = persisted ? config.merge(config, persisted) : config;
|
|
3137
|
+
}
|
|
3138
|
+
return this._snapshots[configKey];
|
|
3139
|
+
}
|
|
3140
|
+
apply(configClass, response) {
|
|
3141
|
+
const configKey = this.getConfigKey(configClass);
|
|
3142
|
+
const behavior = this._registry.create(configClass);
|
|
3143
|
+
const payloads = behavior.extractPayloads(response) || {};
|
|
3144
|
+
// merge 策略完全交给配置类,这里不关心是对象合并还是整体替换。
|
|
3145
|
+
const snapshot = behavior.merge(this.snapshot(configClass), payloads);
|
|
3146
|
+
this._snapshots[configKey] = snapshot;
|
|
3147
|
+
this._loadedKeys[configKey] = true;
|
|
3148
|
+
storage.setGValue(this.getStorageKey(configClass), snapshot);
|
|
3149
|
+
this.setResolveMeta(configKey, response.resolveMeta);
|
|
3150
|
+
return snapshot;
|
|
3151
|
+
}
|
|
3152
|
+
getResolveMeta(configClass) {
|
|
3153
|
+
this.ensureContexts();
|
|
3154
|
+
return this._contexts[this.getConfigKey(configClass)];
|
|
3155
|
+
}
|
|
3156
|
+
isLoaded(configClass) {
|
|
3157
|
+
return !!this._loadedKeys[this.getConfigKey(configClass)];
|
|
3158
|
+
}
|
|
3159
|
+
clear() {
|
|
3160
|
+
this._snapshots = {};
|
|
3161
|
+
this._loadedKeys = {};
|
|
3162
|
+
this._contexts = {};
|
|
3163
|
+
storage.setGValue(RESOLVE_META_STORAGE_KEY, {});
|
|
3164
|
+
}
|
|
3165
|
+
ensureContexts() {
|
|
3166
|
+
if (this._contexts == null) {
|
|
3167
|
+
this._contexts = storage.getGValue(RESOLVE_META_STORAGE_KEY, {}) || {};
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
getConfigKey(configClass) {
|
|
3171
|
+
const meta = this._registry.getActiveMeta(configClass);
|
|
3172
|
+
return `OnlineConfig_${meta.method}_${meta.gameFlag}`;
|
|
3173
|
+
}
|
|
3174
|
+
getStorageKey(configClass) {
|
|
3175
|
+
return this.getConfigKey(configClass);
|
|
3176
|
+
}
|
|
3177
|
+
setResolveMeta(configKey, resolveMeta) {
|
|
3178
|
+
this.ensureContexts();
|
|
3179
|
+
if (resolveMeta) {
|
|
3180
|
+
this._contexts[configKey] = resolveMeta;
|
|
3181
|
+
}
|
|
3182
|
+
else {
|
|
3183
|
+
delete this._contexts[configKey];
|
|
3184
|
+
}
|
|
3185
|
+
// resolveMeta 单独存一份,避免把命中信息混进真实配置 payload。
|
|
3186
|
+
storage.setGValue(RESOLVE_META_STORAGE_KEY, this._contexts);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
RemoteConfigStore.KEY = "RemoteConfigStore";
|
|
3190
|
+
|
|
3191
|
+
class RemoteConfigService {
|
|
3192
|
+
/**
|
|
3193
|
+
* 统一暴露给测试和少量编排场景的 server 门面。
|
|
3194
|
+
* 真正的协议实现仍然隐藏在 server 内部注入链路后面。
|
|
3195
|
+
*/
|
|
3196
|
+
get server() {
|
|
3197
|
+
return server;
|
|
3198
|
+
}
|
|
3199
|
+
get registry() {
|
|
3200
|
+
if (!this._registry) {
|
|
3201
|
+
this._registry = getRemoteConfigRegistry();
|
|
3202
|
+
}
|
|
3203
|
+
return this._registry;
|
|
3204
|
+
}
|
|
3205
|
+
/**
|
|
3206
|
+
* store 只负责快照/持久化/resolveMeta,不负责发请求。
|
|
3207
|
+
* 这样请求协议切换时,不需要改缓存与装配逻辑。
|
|
3208
|
+
*/
|
|
3209
|
+
get store() {
|
|
3210
|
+
if (!this._store) {
|
|
3211
|
+
this._store = new RemoteConfigStore(this.registry);
|
|
3212
|
+
}
|
|
3213
|
+
return this._store;
|
|
3214
|
+
}
|
|
3215
|
+
/**
|
|
3216
|
+
* 请求并应用远程配置,返回已装配的快照。
|
|
3217
|
+
* @param configClass 配置类
|
|
3218
|
+
* @param request 请求参数
|
|
3219
|
+
* @param options 请求选项
|
|
3220
|
+
* @returns 装配后的配置快照
|
|
3221
|
+
*/
|
|
3222
|
+
fetch(configClass, request, options) {
|
|
3223
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
3224
|
+
const meta = this.registry.getActiveMeta(configClass);
|
|
3225
|
+
const config = this.registry.create(configClass);
|
|
3226
|
+
const requestData = config.buildRequestData(request);
|
|
3227
|
+
// 非强刷时,优先复用当前已加载快照,避免重复触发同一配置请求。
|
|
3228
|
+
if (!(options === null || options === void 0 ? void 0 : options.refresh) && this.store.isLoaded(configClass)) {
|
|
3229
|
+
return this.config(configClass);
|
|
3230
|
+
}
|
|
3231
|
+
const response = yield this.server.requestConfig({
|
|
3232
|
+
method: meta.method,
|
|
3233
|
+
gameFlag: meta.gameFlag,
|
|
3234
|
+
config,
|
|
3235
|
+
request,
|
|
3236
|
+
requestData,
|
|
3237
|
+
options,
|
|
3238
|
+
});
|
|
3239
|
+
// 远端失败时退回本地快照,保持“配置可读”优先于“请求必须成功”。
|
|
3240
|
+
if (!response) {
|
|
3241
|
+
return this.config(configClass);
|
|
3242
|
+
}
|
|
3243
|
+
const snapshot = this.store.apply(configClass, response);
|
|
3244
|
+
this.applyResolveSideEffects(meta.method, response.resolveMeta, request);
|
|
3245
|
+
return snapshot;
|
|
3246
|
+
});
|
|
3247
|
+
}
|
|
3248
|
+
/**
|
|
3249
|
+
* 获取配置。
|
|
3250
|
+
* @param configClass 配置类
|
|
3251
|
+
* @returns 配置
|
|
3252
|
+
*/
|
|
3253
|
+
config(configClass) {
|
|
3254
|
+
return this.store.snapshot(configClass);
|
|
3255
|
+
}
|
|
3256
|
+
/**
|
|
3257
|
+
* 读取最近一次成功命中的 resolve 元信息。
|
|
3258
|
+
*/
|
|
3259
|
+
resolveMeta(configClass) {
|
|
3260
|
+
return this.store.getResolveMeta(configClass);
|
|
3261
|
+
}
|
|
3262
|
+
/**
|
|
3263
|
+
* system URL 统一从这里解析,避免调用方直接依赖 helper 或拼接规则。
|
|
3264
|
+
*/
|
|
3265
|
+
getSystemUrl(path = "") {
|
|
3266
|
+
return this.config(SystemOnlineConfig).resolveSystemUrl(path);
|
|
3267
|
+
}
|
|
3268
|
+
applyResolveSideEffects(method, resolveMeta, request) {
|
|
3269
|
+
// system 配置本身承担基础设施能力,不需要重复记录 resolve_key / assignment 事件。
|
|
3270
|
+
if (!resolveMeta || method === "system") {
|
|
3271
|
+
return;
|
|
3272
|
+
}
|
|
3273
|
+
analytics.base.setProperty(`${method}_resolve_key`, resolveMeta.resolveKey);
|
|
3274
|
+
const reportAssignments = analytics.reportAssignments;
|
|
3275
|
+
if (typeof reportAssignments === "function") {
|
|
3276
|
+
reportAssignments.call(analytics, resolveMeta, this.getLevelId(request));
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
getLevelId(request) {
|
|
3280
|
+
var _a, _b;
|
|
3281
|
+
if (!request) {
|
|
3282
|
+
return undefined;
|
|
3283
|
+
}
|
|
3284
|
+
const levelId = (_b = (_a = request.levelid) !== null && _a !== void 0 ? _a : request.level_id) !== null && _b !== void 0 ? _b : request.id;
|
|
3285
|
+
return levelId === undefined || levelId === null ? undefined : String(levelId);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
const remoteConfigService = new RemoteConfigService();
|
|
3289
|
+
|
|
3290
|
+
let LevelOnlineConfig = class LevelOnlineConfig extends BaseOnlineConfig {
|
|
3291
|
+
merge(_target, payloads) {
|
|
3292
|
+
return (payloads || {});
|
|
3293
|
+
}
|
|
3294
|
+
};
|
|
3295
|
+
LevelOnlineConfig = __decorate([
|
|
3296
|
+
remoteConfig("level")
|
|
3297
|
+
], LevelOnlineConfig);
|
|
3298
|
+
|
|
3299
|
+
var GameLeaveType;
|
|
3300
|
+
(function (GameLeaveType) {
|
|
3301
|
+
GameLeaveType["success"] = "lv_success";
|
|
3302
|
+
GameLeaveType["fail"] = "lv_fail";
|
|
3303
|
+
GameLeaveType["leave"] = "lv_leave";
|
|
3304
|
+
GameLeaveType["skip"] = "lv_skip";
|
|
3305
|
+
GameLeaveType["revive"] = "lv_revive";
|
|
3306
|
+
GameLeaveType["break"] = "lv_break";
|
|
3307
|
+
GameLeaveType["retry"] = "lv_retry";
|
|
3308
|
+
})(GameLeaveType || (GameLeaveType = {}));
|
|
3309
|
+
/**
|
|
3310
|
+
* 关卡行为自动上报器
|
|
3311
|
+
* 只依赖 GameDimension 的只读会话上下文,不维护独立状态。
|
|
3312
|
+
*/
|
|
3313
|
+
class LevelBehaviorReporter {
|
|
3314
|
+
constructor(_game, baseAble) {
|
|
3315
|
+
this._game = _game;
|
|
3316
|
+
this.baseAble = baseAble;
|
|
3317
|
+
}
|
|
3318
|
+
start() {
|
|
3319
|
+
const context = this._getContext();
|
|
3320
|
+
if (!context) {
|
|
3321
|
+
return;
|
|
3322
|
+
}
|
|
3323
|
+
this.reset();
|
|
3324
|
+
this._setTimers();
|
|
3325
|
+
App.onHide(this._leaveApp, this);
|
|
3326
|
+
this.baseAble.report("lv_enter", context);
|
|
3327
|
+
}
|
|
3328
|
+
end(type, data) {
|
|
3329
|
+
const context = this._getContext();
|
|
3330
|
+
if (!context) {
|
|
3331
|
+
this.reset();
|
|
3332
|
+
return;
|
|
3333
|
+
}
|
|
3334
|
+
const levelsession = this._game.getCurrentLevelSession();
|
|
3335
|
+
// 有效操作的平均思考时间
|
|
3336
|
+
const time = levelsession.stepsUsed > 0 ? Math.floor(levelsession.thinkTimeTotal / levelsession.stepsUsed) : 0;
|
|
3337
|
+
this.baseAble.report(type, Object.assign(Object.assign(Object.assign({}, context), data), { time }));
|
|
3338
|
+
this.reset();
|
|
3339
|
+
}
|
|
3340
|
+
reportLeave(data) {
|
|
3341
|
+
const context = this._getContext();
|
|
3342
|
+
if (!context) {
|
|
3343
|
+
return;
|
|
3344
|
+
}
|
|
3345
|
+
this.baseAble.report(GameLeaveType.leave, Object.assign(Object.assign(Object.assign({}, context), { name: "切出游戏" }), data));
|
|
3346
|
+
}
|
|
3347
|
+
reportTimeout(data) {
|
|
3348
|
+
const context = this._getContext();
|
|
3349
|
+
if (!context) {
|
|
3350
|
+
return;
|
|
3351
|
+
}
|
|
3352
|
+
this.baseAble.report("lv_timeout", Object.assign(Object.assign(Object.assign({}, context), { name: "超时" }), data));
|
|
3353
|
+
}
|
|
3354
|
+
reportItem(name, data) {
|
|
3355
|
+
const context = this._getContext();
|
|
3356
|
+
if (!context) {
|
|
3357
|
+
return;
|
|
3358
|
+
}
|
|
3359
|
+
this.baseAble.report("lv_item", Object.assign(Object.assign(Object.assign({}, context), { name: name.toLocaleLowerCase() }), data));
|
|
3360
|
+
}
|
|
3361
|
+
reset() {
|
|
3362
|
+
this.baseAble.cancelTime(GameLeaveType.success);
|
|
3363
|
+
this.baseAble.cancelTime(GameLeaveType.leave);
|
|
3364
|
+
this.baseAble.cancelTime(GameLeaveType.fail);
|
|
3365
|
+
this.baseAble.cancelTime(GameLeaveType.skip);
|
|
3366
|
+
this.baseAble.cancelTime(GameLeaveType.revive);
|
|
3367
|
+
this.baseAble.cancelTime(GameLeaveType.break);
|
|
3368
|
+
this.baseAble.cancelTime(GameLeaveType.retry);
|
|
3369
|
+
this.baseAble.cancelTime("lv_timeout");
|
|
3370
|
+
this.baseAble.cancelTime("ad");
|
|
3371
|
+
App.offHide(this._leaveApp, this);
|
|
3372
|
+
}
|
|
3373
|
+
_leaveApp() {
|
|
3374
|
+
this.reportLeave();
|
|
3375
|
+
}
|
|
3376
|
+
_setTimers() {
|
|
3377
|
+
this.baseAble.time(GameLeaveType.success, false);
|
|
3378
|
+
this.baseAble.time(GameLeaveType.leave, false);
|
|
3379
|
+
this.baseAble.time(GameLeaveType.fail, false);
|
|
3380
|
+
this.baseAble.time(GameLeaveType.skip, false);
|
|
3381
|
+
this.baseAble.time(GameLeaveType.revive, false);
|
|
3382
|
+
this.baseAble.time(GameLeaveType.break, false);
|
|
3383
|
+
this.baseAble.time(GameLeaveType.retry, false);
|
|
3384
|
+
this.baseAble.time("lv_timeout", false);
|
|
3385
|
+
this.baseAble.time("ad", false);
|
|
3386
|
+
}
|
|
3387
|
+
_getContext() {
|
|
3388
|
+
return this._game.getCurrentBehaviorContext();
|
|
3389
|
+
}
|
|
3390
|
+
}
|
|
3391
|
+
|
|
3108
3392
|
const LEVEL_STATS_NAME = "LEVEL_STATS";
|
|
3109
3393
|
const LEVEL_STATS_METRIC_ORDER_V1 = [
|
|
3110
3394
|
'LEVEL_STATS.launch_avg_enters_ma',
|
|
@@ -4012,296 +4296,6 @@ class GameDimension extends BaseDimension {
|
|
|
4012
4296
|
}
|
|
4013
4297
|
}
|
|
4014
4298
|
|
|
4015
|
-
const RESOLVE_META_STORAGE_KEY = "ONLINE_CONFIG_CONTEXTS";
|
|
4016
|
-
class RemoteConfigStore {
|
|
4017
|
-
constructor() {
|
|
4018
|
-
// 运行时快照:给业务读配置时尽量返回稳定对象实例,减少外部感知到的替换。
|
|
4019
|
-
this._snapshots = {};
|
|
4020
|
-
this._loadedKeys = {};
|
|
4021
|
-
this._contexts = null;
|
|
4022
|
-
}
|
|
4023
|
-
snapshot(definition, scope) {
|
|
4024
|
-
const scopeKey = this.getScopeKey(definition, scope);
|
|
4025
|
-
if (!this._snapshots[scopeKey]) {
|
|
4026
|
-
const config = definition.createDefault();
|
|
4027
|
-
const persisted = storage.getGValue(this.getStorageKey(definition, scope), undefined);
|
|
4028
|
-
// 首次读取时先构造默认对象,再把本地持久化内容 merge 回来,保证未请求时也能正常工作。
|
|
4029
|
-
this._snapshots[scopeKey] = persisted ? definition.merge(config, persisted) : config;
|
|
4030
|
-
}
|
|
4031
|
-
return this._snapshots[scopeKey];
|
|
4032
|
-
}
|
|
4033
|
-
apply(definition, scope, response) {
|
|
4034
|
-
const scopeKey = this.getScopeKey(definition, scope);
|
|
4035
|
-
const payloads = definition.extractPayloads(response) || {};
|
|
4036
|
-
// merge 策略完全交给 definition,这里不关心是对象合并还是整体替换。
|
|
4037
|
-
const snapshot = definition.merge(this.snapshot(definition, scope), payloads);
|
|
4038
|
-
this._snapshots[scopeKey] = snapshot;
|
|
4039
|
-
this._loadedKeys[scopeKey] = true;
|
|
4040
|
-
storage.setGValue(this.getStorageKey(definition, scope), snapshot);
|
|
4041
|
-
this.setResolveMeta(scopeKey, response.resolveMeta);
|
|
4042
|
-
return snapshot;
|
|
4043
|
-
}
|
|
4044
|
-
getResolveMeta(definition, scope) {
|
|
4045
|
-
this.ensureContexts();
|
|
4046
|
-
return this._contexts[this.getScopeKey(definition, scope)];
|
|
4047
|
-
}
|
|
4048
|
-
isLoaded(definition, scope) {
|
|
4049
|
-
return !!this._loadedKeys[this.getScopeKey(definition, scope)];
|
|
4050
|
-
}
|
|
4051
|
-
clear() {
|
|
4052
|
-
this._snapshots = {};
|
|
4053
|
-
this._loadedKeys = {};
|
|
4054
|
-
this._contexts = {};
|
|
4055
|
-
storage.setGValue(RESOLVE_META_STORAGE_KEY, {});
|
|
4056
|
-
}
|
|
4057
|
-
ensureContexts() {
|
|
4058
|
-
if (this._contexts == null) {
|
|
4059
|
-
this._contexts = storage.getGValue(RESOLVE_META_STORAGE_KEY, {}) || {};
|
|
4060
|
-
}
|
|
4061
|
-
}
|
|
4062
|
-
getScopeGameFlag(scope) {
|
|
4063
|
-
return (scope === null || scope === void 0 ? void 0 : scope.gameFlag) || DEFAULT_GAME_FLAG;
|
|
4064
|
-
}
|
|
4065
|
-
createScopedKey(method, scope) {
|
|
4066
|
-
return `OnlineConfig_${method}_${this.getScopeGameFlag(scope)}`;
|
|
4067
|
-
}
|
|
4068
|
-
getScopeKey(definition, scope) {
|
|
4069
|
-
return this.createScopedKey(definition.method, scope);
|
|
4070
|
-
}
|
|
4071
|
-
getStorageKey(definition, scope) {
|
|
4072
|
-
return this.createScopedKey(definition.method, scope);
|
|
4073
|
-
}
|
|
4074
|
-
setResolveMeta(scopeKey, resolveMeta) {
|
|
4075
|
-
this.ensureContexts();
|
|
4076
|
-
if (resolveMeta) {
|
|
4077
|
-
this._contexts[scopeKey] = resolveMeta;
|
|
4078
|
-
}
|
|
4079
|
-
else {
|
|
4080
|
-
delete this._contexts[scopeKey];
|
|
4081
|
-
}
|
|
4082
|
-
// resolveMeta 单独存一份,避免把命中信息混进真实配置 payload。
|
|
4083
|
-
storage.setGValue(RESOLVE_META_STORAGE_KEY, this._contexts);
|
|
4084
|
-
}
|
|
4085
|
-
}
|
|
4086
|
-
RemoteConfigStore.KEY = "RemoteConfigStore";
|
|
4087
|
-
|
|
4088
|
-
class RemoteConfigService {
|
|
4089
|
-
/**
|
|
4090
|
-
* 统一暴露给测试和少量编排场景的 server 门面。
|
|
4091
|
-
* 真正的协议实现仍然隐藏在 server 内部注入链路后面。
|
|
4092
|
-
*/
|
|
4093
|
-
get server() {
|
|
4094
|
-
return server;
|
|
4095
|
-
}
|
|
4096
|
-
/**
|
|
4097
|
-
* store 只负责快照/持久化/resolveMeta,不负责发请求。
|
|
4098
|
-
* 这样请求协议切换时,不需要改缓存与装配逻辑。
|
|
4099
|
-
*/
|
|
4100
|
-
get store() {
|
|
4101
|
-
if (!this._store) {
|
|
4102
|
-
this._store = Injector.getInject(RemoteConfigStore.KEY);
|
|
4103
|
-
}
|
|
4104
|
-
return this._store;
|
|
4105
|
-
}
|
|
4106
|
-
/**
|
|
4107
|
-
* 请求并应用远程配置,返回已装配的快照。
|
|
4108
|
-
* @param definition 配置定义
|
|
4109
|
-
* @param request 请求参数
|
|
4110
|
-
* @param scope 作用域
|
|
4111
|
-
* @param options 请求选项
|
|
4112
|
-
* @returns 装配后的配置快照
|
|
4113
|
-
*/
|
|
4114
|
-
refresh(definition, request, scope, options) {
|
|
4115
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4116
|
-
// 非强刷时,优先复用当前已加载快照,避免重复触发同一配置请求。
|
|
4117
|
-
if (!(options === null || options === void 0 ? void 0 : options.refresh) && this.store.isLoaded(definition, scope)) {
|
|
4118
|
-
return this.config(definition, scope);
|
|
4119
|
-
}
|
|
4120
|
-
const response = yield this.server.requestConfig({
|
|
4121
|
-
definition,
|
|
4122
|
-
request,
|
|
4123
|
-
scope,
|
|
4124
|
-
options,
|
|
4125
|
-
});
|
|
4126
|
-
// 远端失败时退回本地快照,保持“配置可读”优先于“请求必须成功”。
|
|
4127
|
-
if (!response) {
|
|
4128
|
-
return this.config(definition, scope);
|
|
4129
|
-
}
|
|
4130
|
-
const snapshot = this.store.apply(definition, scope, response);
|
|
4131
|
-
this.applyResolveSideEffects(definition, response.resolveMeta, request);
|
|
4132
|
-
return snapshot;
|
|
4133
|
-
});
|
|
4134
|
-
}
|
|
4135
|
-
/**
|
|
4136
|
-
* 与旧调用习惯兼容的主入口。
|
|
4137
|
-
* 语义上等价于 refresh:必要时请求远端,失败时回退本地快照。
|
|
4138
|
-
*/
|
|
4139
|
-
resolve(definition, request, scope, options) {
|
|
4140
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4141
|
-
return this.refresh(definition, request, scope, options);
|
|
4142
|
-
});
|
|
4143
|
-
}
|
|
4144
|
-
/**
|
|
4145
|
-
* 获取配置。
|
|
4146
|
-
* @param definition 配置定义
|
|
4147
|
-
* @param scope 作用域
|
|
4148
|
-
* @returns 配置
|
|
4149
|
-
*/
|
|
4150
|
-
config(definition, scope) {
|
|
4151
|
-
return this.store.snapshot(definition, scope);
|
|
4152
|
-
}
|
|
4153
|
-
/**
|
|
4154
|
-
* 与旧调用习惯兼容的只读快照接口。
|
|
4155
|
-
*/
|
|
4156
|
-
snapshot(definition, scope) {
|
|
4157
|
-
return this.config(definition, scope);
|
|
4158
|
-
}
|
|
4159
|
-
/**
|
|
4160
|
-
* 读取最近一次成功命中的 resolve 元信息。
|
|
4161
|
-
*/
|
|
4162
|
-
resolveMeta(definition, scope) {
|
|
4163
|
-
return this.store.getResolveMeta(definition, scope);
|
|
4164
|
-
}
|
|
4165
|
-
/**
|
|
4166
|
-
* system URL 统一从这里解析,避免调用方直接依赖 helper 或拼接规则。
|
|
4167
|
-
*/
|
|
4168
|
-
getSystemUrl(path = "") {
|
|
4169
|
-
return resolveSystemUrl(path, this.snapshot(SystemRemoteConfigDefinition));
|
|
4170
|
-
}
|
|
4171
|
-
applyResolveSideEffects(definition, resolveMeta, request) {
|
|
4172
|
-
// system 配置本身承担基础设施能力,不需要重复记录 resolve_key / assignment 事件。
|
|
4173
|
-
if (!resolveMeta || definition.method === SystemRemoteConfigDefinition.method) {
|
|
4174
|
-
return;
|
|
4175
|
-
}
|
|
4176
|
-
analytics.base.setProperty(`${definition.method}_resolve_key`, resolveMeta.resolveKey);
|
|
4177
|
-
const reportAssignments = analytics.reportAssignments;
|
|
4178
|
-
if (typeof reportAssignments === "function") {
|
|
4179
|
-
reportAssignments.call(analytics, resolveMeta, this.getLevelId(request));
|
|
4180
|
-
}
|
|
4181
|
-
}
|
|
4182
|
-
getLevelId(request) {
|
|
4183
|
-
var _a, _b;
|
|
4184
|
-
if (!request) {
|
|
4185
|
-
return undefined;
|
|
4186
|
-
}
|
|
4187
|
-
const levelId = (_b = (_a = request.levelid) !== null && _a !== void 0 ? _a : request.level_id) !== null && _b !== void 0 ? _b : request.id;
|
|
4188
|
-
return levelId === undefined || levelId === null ? undefined : String(levelId);
|
|
4189
|
-
}
|
|
4190
|
-
}
|
|
4191
|
-
Injector.inject(RemoteConfigStore.KEY, RemoteConfigStore);
|
|
4192
|
-
const remoteConfigService = new RemoteConfigService();
|
|
4193
|
-
|
|
4194
|
-
class LevelOnlineConfig {
|
|
4195
|
-
}
|
|
4196
|
-
LevelOnlineConfig.KEY = "OnlineConfig_level_default";
|
|
4197
|
-
Injector.inject(LevelOnlineConfig.KEY, LevelOnlineConfig);
|
|
4198
|
-
class LevelRemoteConfigDefinitionClass extends BaseRemoteConfigDefinitionClass {
|
|
4199
|
-
constructor() {
|
|
4200
|
-
super(...arguments);
|
|
4201
|
-
this.method = "level";
|
|
4202
|
-
}
|
|
4203
|
-
createDefault() {
|
|
4204
|
-
return Injector.getInjectAlone(LevelOnlineConfig.KEY, LevelOnlineConfig);
|
|
4205
|
-
}
|
|
4206
|
-
merge(_target, payloads) {
|
|
4207
|
-
return (payloads || {});
|
|
4208
|
-
}
|
|
4209
|
-
}
|
|
4210
|
-
const LevelRemoteConfigDefinition = new LevelRemoteConfigDefinitionClass();
|
|
4211
|
-
|
|
4212
|
-
var GameLeaveType;
|
|
4213
|
-
(function (GameLeaveType) {
|
|
4214
|
-
GameLeaveType["success"] = "lv_success";
|
|
4215
|
-
GameLeaveType["fail"] = "lv_fail";
|
|
4216
|
-
GameLeaveType["leave"] = "lv_leave";
|
|
4217
|
-
GameLeaveType["skip"] = "lv_skip";
|
|
4218
|
-
GameLeaveType["revive"] = "lv_revive";
|
|
4219
|
-
GameLeaveType["break"] = "lv_break";
|
|
4220
|
-
GameLeaveType["retry"] = "lv_retry";
|
|
4221
|
-
})(GameLeaveType || (GameLeaveType = {}));
|
|
4222
|
-
/**
|
|
4223
|
-
* 关卡行为自动上报器
|
|
4224
|
-
* 只依赖 GameDimension 的只读会话上下文,不维护独立状态。
|
|
4225
|
-
*/
|
|
4226
|
-
class LevelBehaviorReporter {
|
|
4227
|
-
constructor(_game, baseAble) {
|
|
4228
|
-
this._game = _game;
|
|
4229
|
-
this.baseAble = baseAble;
|
|
4230
|
-
}
|
|
4231
|
-
start() {
|
|
4232
|
-
const context = this._getContext();
|
|
4233
|
-
if (!context) {
|
|
4234
|
-
return;
|
|
4235
|
-
}
|
|
4236
|
-
this.reset();
|
|
4237
|
-
this._setTimers();
|
|
4238
|
-
App.onHide(this._leaveApp, this);
|
|
4239
|
-
this.baseAble.report("lv_enter", context);
|
|
4240
|
-
}
|
|
4241
|
-
end(type, data) {
|
|
4242
|
-
const context = this._getContext();
|
|
4243
|
-
if (!context) {
|
|
4244
|
-
this.reset();
|
|
4245
|
-
return;
|
|
4246
|
-
}
|
|
4247
|
-
const levelsession = this._game.getCurrentLevelSession();
|
|
4248
|
-
// 有效操作的平均思考时间
|
|
4249
|
-
const time = levelsession.stepsUsed > 0 ? Math.floor(levelsession.thinkTimeTotal / levelsession.stepsUsed) : 0;
|
|
4250
|
-
this.baseAble.report(type, Object.assign(Object.assign(Object.assign({}, context), data), { time }));
|
|
4251
|
-
this.reset();
|
|
4252
|
-
}
|
|
4253
|
-
reportLeave(data) {
|
|
4254
|
-
const context = this._getContext();
|
|
4255
|
-
if (!context) {
|
|
4256
|
-
return;
|
|
4257
|
-
}
|
|
4258
|
-
this.baseAble.report(GameLeaveType.leave, Object.assign(Object.assign(Object.assign({}, context), { name: "切出游戏" }), data));
|
|
4259
|
-
}
|
|
4260
|
-
reportTimeout(data) {
|
|
4261
|
-
const context = this._getContext();
|
|
4262
|
-
if (!context) {
|
|
4263
|
-
return;
|
|
4264
|
-
}
|
|
4265
|
-
this.baseAble.report("lv_timeout", Object.assign(Object.assign(Object.assign({}, context), { name: "超时" }), data));
|
|
4266
|
-
}
|
|
4267
|
-
reportItem(name, data) {
|
|
4268
|
-
const context = this._getContext();
|
|
4269
|
-
if (!context) {
|
|
4270
|
-
return;
|
|
4271
|
-
}
|
|
4272
|
-
this.baseAble.report("lv_item", Object.assign(Object.assign(Object.assign({}, context), { name: name.toLocaleLowerCase() }), data));
|
|
4273
|
-
}
|
|
4274
|
-
reset() {
|
|
4275
|
-
this.baseAble.cancelTime(GameLeaveType.success);
|
|
4276
|
-
this.baseAble.cancelTime(GameLeaveType.leave);
|
|
4277
|
-
this.baseAble.cancelTime(GameLeaveType.fail);
|
|
4278
|
-
this.baseAble.cancelTime(GameLeaveType.skip);
|
|
4279
|
-
this.baseAble.cancelTime(GameLeaveType.revive);
|
|
4280
|
-
this.baseAble.cancelTime(GameLeaveType.break);
|
|
4281
|
-
this.baseAble.cancelTime(GameLeaveType.retry);
|
|
4282
|
-
this.baseAble.cancelTime("lv_timeout");
|
|
4283
|
-
this.baseAble.cancelTime("ad");
|
|
4284
|
-
App.offHide(this._leaveApp, this);
|
|
4285
|
-
}
|
|
4286
|
-
_leaveApp() {
|
|
4287
|
-
this.reportLeave();
|
|
4288
|
-
}
|
|
4289
|
-
_setTimers() {
|
|
4290
|
-
this.baseAble.time(GameLeaveType.success, false);
|
|
4291
|
-
this.baseAble.time(GameLeaveType.leave, false);
|
|
4292
|
-
this.baseAble.time(GameLeaveType.fail, false);
|
|
4293
|
-
this.baseAble.time(GameLeaveType.skip, false);
|
|
4294
|
-
this.baseAble.time(GameLeaveType.revive, false);
|
|
4295
|
-
this.baseAble.time(GameLeaveType.break, false);
|
|
4296
|
-
this.baseAble.time(GameLeaveType.retry, false);
|
|
4297
|
-
this.baseAble.time("lv_timeout", false);
|
|
4298
|
-
this.baseAble.time("ad", false);
|
|
4299
|
-
}
|
|
4300
|
-
_getContext() {
|
|
4301
|
-
return this._game.getCurrentBehaviorContext();
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
|
|
4305
4299
|
class LevelAnalyticsAble {
|
|
4306
4300
|
constructor(baseAble) {
|
|
4307
4301
|
this._games = {};
|
|
@@ -4353,7 +4347,7 @@ class LevelAnalyticsAble {
|
|
|
4353
4347
|
onStart(id, index, gameFlag = DEFAULT_GAME_FLAG, data) {
|
|
4354
4348
|
return __awaiter(this, void 0, void 0, function* () {
|
|
4355
4349
|
this._currentGame = this._game(gameFlag);
|
|
4356
|
-
const levelInfo = (yield remoteConfigService.
|
|
4350
|
+
const levelInfo = (yield remoteConfigService.fetch(LevelOnlineConfig, { id }, { refresh: true })).info;
|
|
4357
4351
|
if (levelInfo) {
|
|
4358
4352
|
data = Object.assign(Object.assign({}, levelInfo), data);
|
|
4359
4353
|
}
|
|
@@ -6572,7 +6566,7 @@ class AnalyticsManager {
|
|
|
6572
6566
|
return !!String(config && config.project || "").trim() && !!String(config && config.logstore || "").trim();
|
|
6573
6567
|
}
|
|
6574
6568
|
createBehaviorSenders() {
|
|
6575
|
-
const analyticsConfig = remoteConfigService.config(
|
|
6569
|
+
const analyticsConfig = remoteConfigService.config(SystemOnlineConfig).getAnalyticsConfig();
|
|
6576
6570
|
if (this.hasRelayUrl(analyticsConfig)) {
|
|
6577
6571
|
return [new KeytopsAnalyticsSender(analyticsConfig)];
|
|
6578
6572
|
}
|
|
@@ -6680,7 +6674,7 @@ class AnalyticsManager {
|
|
|
6680
6674
|
}
|
|
6681
6675
|
get assignmentSender() {
|
|
6682
6676
|
if (!this._assignmentSender) {
|
|
6683
|
-
const analyticsConfig = remoteConfigService.config(
|
|
6677
|
+
const analyticsConfig = remoteConfigService.config(SystemOnlineConfig).getAssignmentConfig();
|
|
6684
6678
|
this._assignmentSender = this.hasRelayUrl(analyticsConfig)
|
|
6685
6679
|
? new KeytopsAnalyticsSender(analyticsConfig, analyticsConfig.exclude || ["view"])
|
|
6686
6680
|
: new EmptyAnalyticsSender();
|
|
@@ -9071,15 +9065,14 @@ const ab = new ABTesting();
|
|
|
9071
9065
|
|
|
9072
9066
|
class KKTServer {
|
|
9073
9067
|
requestConfig(context) {
|
|
9074
|
-
var _a, _b
|
|
9075
|
-
const gameFlag =
|
|
9068
|
+
var _a, _b;
|
|
9069
|
+
const gameFlag = context.gameFlag || DEFAULT_GAME_FLAG;
|
|
9076
9070
|
// KKT 协议始终把“通用维度 + 当前玩法关卡维度”一起带上,保持现有服务端分流能力。
|
|
9077
|
-
const gameMetrics = ((
|
|
9071
|
+
const gameMetrics = ((_a = analytics.level) === null || _a === void 0 ? void 0 : _a.getGameMetrics)
|
|
9078
9072
|
? analytics.level.getGameMetrics(gameFlag)
|
|
9079
9073
|
: {};
|
|
9080
|
-
//
|
|
9081
|
-
const
|
|
9082
|
-
const params = this.getRequestParams(context.definition.method, gameFlag, gameMetrics, requestData, (_c = context.options) === null || _c === void 0 ? void 0 : _c.debug);
|
|
9074
|
+
// 每种配置类只负责自己的业务参数,KKT 公共协议字段由这里统一补齐。
|
|
9075
|
+
const params = this.getRequestParams(context.method, gameFlag, gameMetrics, context.requestData, (_b = context.options) === null || _b === void 0 ? void 0 : _b.debug);
|
|
9083
9076
|
return this.sentRequest(this.getResolveUrl(), params).then((response) => this.normalizeResponse(response));
|
|
9084
9077
|
}
|
|
9085
9078
|
getRequestParams(method, gameFlag, gameMetrics, data, isDebug) {
|
|
@@ -9105,7 +9098,7 @@ class KKTServer {
|
|
|
9105
9098
|
}
|
|
9106
9099
|
getResolveUrl() {
|
|
9107
9100
|
// resolve URL 仍然来自 system 配置快照,这样协议实现不直接持有配置缓存状态。
|
|
9108
|
-
const systemConfig = remoteConfigService.config(
|
|
9101
|
+
const systemConfig = remoteConfigService.config(SystemOnlineConfig);
|
|
9109
9102
|
return systemConfig.resolveSystemUrl(systemConfig.url.configAPI || `/v2/config/${publisher.appId}/resolve`);
|
|
9110
9103
|
}
|
|
9111
9104
|
normalizeResponse(response) {
|
|
@@ -9143,6 +9136,13 @@ class KKTServer {
|
|
|
9143
9136
|
}
|
|
9144
9137
|
Injector.inject("Server", KKTServer);
|
|
9145
9138
|
|
|
9139
|
+
class NoRequestServer {
|
|
9140
|
+
requestConfig(_context) {
|
|
9141
|
+
return Promise.resolve({ payloads: {} });
|
|
9142
|
+
}
|
|
9143
|
+
}
|
|
9144
|
+
NoRequestServer.KEY = "Server";
|
|
9145
|
+
|
|
9146
9146
|
let handlerMap = new Map();
|
|
9147
9147
|
/**
|
|
9148
9148
|
* socket response 处理装饰器
|
|
@@ -10540,7 +10540,7 @@ class KSLogin extends ILoginAble {
|
|
|
10540
10540
|
return super.init(type);
|
|
10541
10541
|
}
|
|
10542
10542
|
login(caller, onSuccess, onFail) {
|
|
10543
|
-
const secret = (remoteConfigService.
|
|
10543
|
+
const secret = (remoteConfigService.config(BaseOnlineConfig)['secret'] || []).join("");
|
|
10544
10544
|
this._ks.login({
|
|
10545
10545
|
force: true,
|
|
10546
10546
|
success: (res) => {
|
|
@@ -11712,7 +11712,7 @@ class TTLogin extends ILoginAble {
|
|
|
11712
11712
|
force: true,
|
|
11713
11713
|
success: (res) => {
|
|
11714
11714
|
console.log(`tt.login 调用成功${res.code} ${res.anonymousCode}`);
|
|
11715
|
-
const systemConfig = remoteConfigService.
|
|
11715
|
+
const systemConfig = remoteConfigService.config(SystemOnlineConfig);
|
|
11716
11716
|
net.http.post(remoteConfigService.getSystemUrl(systemConfig.url.loginAPI), {
|
|
11717
11717
|
data: {
|
|
11718
11718
|
appid: publisher.appId,
|
|
@@ -11970,7 +11970,7 @@ class WXLogin extends ILoginAble {
|
|
|
11970
11970
|
success: (res) => {
|
|
11971
11971
|
if (res.code) {
|
|
11972
11972
|
// this._code = res.code;
|
|
11973
|
-
const systemConfig = remoteConfigService.
|
|
11973
|
+
const systemConfig = remoteConfigService.config(SystemOnlineConfig);
|
|
11974
11974
|
net.http.post(remoteConfigService.getSystemUrl(systemConfig.url.loginAPI), {
|
|
11975
11975
|
data: {
|
|
11976
11976
|
appid: publisher.appId,
|
|
@@ -12078,7 +12078,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12078
12078
|
}
|
|
12079
12079
|
_enableWeb() {
|
|
12080
12080
|
const TYPE = IPublisher.TYPE_H5;
|
|
12081
|
-
this.enableAdAble(TYPE, IADAble, remoteConfigService.
|
|
12081
|
+
this.enableAdAble(TYPE, IADAble, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12082
12082
|
return true;
|
|
12083
12083
|
}
|
|
12084
12084
|
_initTT() {
|
|
@@ -12098,7 +12098,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12098
12098
|
return false;
|
|
12099
12099
|
}
|
|
12100
12100
|
const TYPE = IPublisher.TYPE_TT;
|
|
12101
|
-
this.enableAdAble(TYPE, TTAd, remoteConfigService.
|
|
12101
|
+
this.enableAdAble(TYPE, TTAd, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12102
12102
|
return true;
|
|
12103
12103
|
}
|
|
12104
12104
|
_initWX() {
|
|
@@ -12117,7 +12117,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12117
12117
|
return false;
|
|
12118
12118
|
}
|
|
12119
12119
|
const TYPE = "WX";
|
|
12120
|
-
this.enableAdAble(TYPE, WXAd, remoteConfigService.
|
|
12120
|
+
this.enableAdAble(TYPE, WXAd, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12121
12121
|
return true;
|
|
12122
12122
|
}
|
|
12123
12123
|
_initKS() {
|
|
@@ -12137,7 +12137,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12137
12137
|
return false;
|
|
12138
12138
|
}
|
|
12139
12139
|
const TYPE = "KS";
|
|
12140
|
-
this.enableAdAble(TYPE, KSAd, remoteConfigService.
|
|
12140
|
+
this.enableAdAble(TYPE, KSAd, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12141
12141
|
return true;
|
|
12142
12142
|
}
|
|
12143
12143
|
_initMY() {
|
|
@@ -12156,7 +12156,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12156
12156
|
return false;
|
|
12157
12157
|
}
|
|
12158
12158
|
const TYPE = "MY";
|
|
12159
|
-
this.enableAdAble(TYPE, MYAd, remoteConfigService.
|
|
12159
|
+
this.enableAdAble(TYPE, MYAd, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12160
12160
|
return true;
|
|
12161
12161
|
}
|
|
12162
12162
|
_initNative() {
|
|
@@ -12177,7 +12177,7 @@ class PublisherManagerImpl extends IPublisherManager {
|
|
|
12177
12177
|
return false;
|
|
12178
12178
|
}
|
|
12179
12179
|
const TYPE = "native";
|
|
12180
|
-
this.enableAdAble(TYPE, NativeAd, remoteConfigService.
|
|
12180
|
+
this.enableAdAble(TYPE, NativeAd, remoteConfigService.config(SystemOnlineConfig).ad);
|
|
12181
12181
|
return true;
|
|
12182
12182
|
}
|
|
12183
12183
|
}
|
|
@@ -12717,42 +12717,11 @@ class TTAnalyticsSender extends EmptyAnalyticsSender {
|
|
|
12717
12717
|
}
|
|
12718
12718
|
}
|
|
12719
12719
|
|
|
12720
|
-
const definitionCache = new Map();
|
|
12721
|
-
class DynamicRemoteConfigDefinition extends AbstractRemoteConfigDefinition {
|
|
12722
|
-
constructor(method) {
|
|
12723
|
-
super();
|
|
12724
|
-
this.method = method;
|
|
12725
|
-
}
|
|
12726
|
-
createDefault() {
|
|
12727
|
-
return {};
|
|
12728
|
-
}
|
|
12729
|
-
merge(target, payloads) {
|
|
12730
|
-
return this.mergeObjectConfig(target, payloads);
|
|
12731
|
-
}
|
|
12732
|
-
}
|
|
12733
12720
|
const INTERNAL_METHODS = {
|
|
12734
|
-
CONFIG:
|
|
12735
|
-
SYSTEM:
|
|
12736
|
-
LEVEL:
|
|
12721
|
+
CONFIG: "config",
|
|
12722
|
+
SYSTEM: "system",
|
|
12723
|
+
LEVEL: "level",
|
|
12737
12724
|
};
|
|
12738
|
-
function getRemoteConfigDefinition(method) {
|
|
12739
|
-
if (method === BaseRemoteConfigDefinition.method) {
|
|
12740
|
-
return BaseRemoteConfigDefinition;
|
|
12741
|
-
}
|
|
12742
|
-
if (method === SystemRemoteConfigDefinition.method) {
|
|
12743
|
-
return SystemRemoteConfigDefinition;
|
|
12744
|
-
}
|
|
12745
|
-
if (method === LevelRemoteConfigDefinition.method) {
|
|
12746
|
-
return LevelRemoteConfigDefinition;
|
|
12747
|
-
}
|
|
12748
|
-
const cached = definitionCache.get(method);
|
|
12749
|
-
if (cached) {
|
|
12750
|
-
return cached;
|
|
12751
|
-
}
|
|
12752
|
-
const dynamicDefinition = new DynamicRemoteConfigDefinition(method);
|
|
12753
|
-
definitionCache.set(method, dynamicDefinition);
|
|
12754
|
-
return dynamicDefinition;
|
|
12755
|
-
}
|
|
12756
12725
|
|
|
12757
12726
|
/**
|
|
12758
12727
|
* 掩码
|
|
@@ -15169,4 +15138,4 @@ TipsView = __decorate([
|
|
|
15169
15138
|
menu("基础视图/TipsView")
|
|
15170
15139
|
], TipsView);
|
|
15171
15140
|
|
|
15172
|
-
export { ADAnalyticsAble, ADBehaviorReporter, ADEvent, ADType, AD_METRIC_ORDER_V1, ALiAnalyticsSender,
|
|
15141
|
+
export { ADAnalyticsAble, ADBehaviorReporter, ADEvent, ADType, AD_METRIC_ORDER_V1, ALiAnalyticsSender, AdDimension, AnalyticsAble, App, Application, Async, AudioBusiness, BaseDimension, BaseOnlineConfig, BaseProtocolHelper, BusinessCenter, ByteView, CCPViewLoader, CCSceneLoader, CocosNativeHelper, CocosStorageUtils, CocosViewManager, Component, ConfigHelper, DEFAULT_GAME_FLAG, Dictionary, DimensionType, ECS, EffectAudioSourceProxy, EmptyAnalyticsSender, EmptyLink, EnterOptionParser, Event$2 as Event, EventDispatcher, Fsm, FsmBase, GameDimension, GameLeaveType, GeometryUtils, Handler, HttpNode, HttpRequest, IADAble, IDevice, IGameUpdateAble, ILoginAble, INTERNAL_METHODS, INativeHelper, IPayAble, IPublisher, IPublisherManager, IRecordAble, IShareAble, IViewLoader, Injector, Json, KKTServer, KSAd, KSDevice, KSLogin, KSPublisher, KSRecorder, KSShare, KeytopsAnalyticsSender, LEVEL_STATS_METRIC_ORDER_V1, LaunchAnalyticsAble, LevelAnalyticsAble, LevelBehaviorReporter, LevelOnlineConfig, LevelStatsDimension, Link, List, LogType, Logger, MYAd, MYDevice, MYLogin, MYPublisher, Mask, MathUtils, MemeryStorage, NativeAd, NativeAnalyticsSender, NativeDevice, NativeHelper, NativeLogin, NativePay, NativePublisher, NativeRecorder, NativeShare, NativeUtils, NetManager, NoRequestServer, PLAYER_ABILITY_METRIC_ORDER_V1, PlayerAbilityDimension, Pool, PromiseUtils, PropSupport, PublisherManager, PublisherManagerImpl, RemoteConfigService, RemoteConfigStore, ResourceManager, RewardVideoMaskBusiness, RuntimeApplicationImpl, Scene, Server, SessionAnalyticsAble, SessionDimension, SocialAnalyticsAble, SocialDimension, Socket, SocketLogType, SocketNode, Storage, StorageImpl, StringUtils, System, SystemOnlineConfig, TKAd, TKAnalyticsSender, TKDevice, TKLogin, TKPublisher, TTAd, TTAnalyticsSender, TTDevice, TTGameUpdater, TTLogin, TTPay, TTPublisher, TTRecorder, TTShare, Task, TaskQueue, TaskSequence, Timer, TimerImpl, TipsType, TipsView, View, ViewControl, ViewLevel, ViewManager, WXAd, WXAnalyticsSender, WXDevice, WXGameUpdater, WXLogin, WXPay, WXPublisher, WXShare, ab, analytics, audio, bidding, businessCenter, cmd, component, eventCenter, fsmManager, manager, md5, net, publisher, remoteConfig, remoteConfigService, res, resolveSystemUrl, server, storage, system, timer, version, viewAnalytics, viewClass, viewManager };
|