@cloudcare/cocos-sdk 0.1.1-alpha.1 → 0.1.1-alpha.2
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/README.md +35 -6
- package/bin/cli.cjs +42 -5
- package/bin/project-configuration.cjs +135 -0
- package/bin/web-assets.cjs +32 -0
- package/dist/creator2/core/auto-tracking.js.map +1 -1
- package/dist/creator2/core/client.d.ts +1 -0
- package/dist/creator2/core/client.d.ts.map +1 -1
- package/dist/creator2/core/client.js +13 -0
- package/dist/creator2/core/client.js.map +1 -1
- package/dist/creator2/core/index.js.map +1 -1
- package/dist/creator2/core/modules.js.map +1 -1
- package/dist/creator2/core/platform-client.d.ts +46 -0
- package/dist/creator2/core/platform-client.d.ts.map +1 -0
- package/dist/creator2/core/platform-client.js +195 -0
- package/dist/creator2/core/platform-client.js.map +1 -0
- package/dist/creator2/core/platform-options.d.ts +30 -0
- package/dist/creator2/core/platform-options.d.ts.map +1 -0
- package/dist/creator2/core/platform-options.js +3 -0
- package/dist/creator2/core/platform-options.js.map +1 -0
- package/dist/creator2/core/platform-runtime.d.ts +59 -0
- package/dist/creator2/core/platform-runtime.d.ts.map +1 -0
- package/dist/creator2/core/platform-runtime.js +36 -0
- package/dist/creator2/core/platform-runtime.js.map +1 -0
- package/dist/creator2/core/plugin-api.d.ts +1 -1
- package/dist/creator2/core/plugin-api.d.ts.map +1 -1
- package/dist/creator2/core/plugin-api.js.map +1 -1
- package/dist/creator2/core/transport.d.ts +1 -1
- package/dist/creator2/core/transport.d.ts.map +1 -1
- package/dist/creator2/core/transport.js.map +1 -1
- package/dist/creator2/core/types.js.map +1 -1
- package/dist/creator2/core/validation.js.map +1 -1
- package/dist/creator2/core/version.d.ts +1 -1
- package/dist/creator2/core/version.js +1 -1
- package/dist/creator2/core/version.js.map +1 -1
- package/dist/creator2/creator2/auto.js.map +1 -1
- package/dist/creator2/creator2/index.d.ts +6 -3
- package/dist/creator2/creator2/index.d.ts.map +1 -1
- package/dist/creator2/creator2/index.js +12 -8
- package/dist/creator2/creator2/index.js.map +1 -1
- package/dist/creator2/creator2/transport.js.map +1 -1
- package/dist/creator2/native/bootstrap.d.ts +2 -0
- package/dist/creator2/native/bootstrap.d.ts.map +1 -0
- package/dist/creator2/native/bootstrap.js +34 -0
- package/dist/creator2/native/bootstrap.js.map +1 -0
- package/dist/creator2/web/bootstrap.d.ts +3 -0
- package/dist/creator2/web/bootstrap.d.ts.map +1 -0
- package/dist/creator2/web/bootstrap.js +15 -0
- package/dist/creator2/web/bootstrap.js.map +1 -0
- package/dist/creator2/web/client.d.ts +60 -0
- package/dist/creator2/web/client.d.ts.map +1 -0
- package/dist/creator2/web/client.js +293 -0
- package/dist/creator2/web/client.js.map +1 -0
- package/dist/creator2/web/creator2.d.ts +5 -0
- package/dist/creator2/web/creator2.d.ts.map +1 -0
- package/dist/creator2/web/creator2.js +27 -0
- package/dist/creator2/web/creator2.js.map +1 -0
- package/dist/creator2/web/privacy.d.ts +3 -0
- package/dist/creator2/web/privacy.d.ts.map +1 -0
- package/dist/creator2/web/privacy.js +39 -0
- package/dist/creator2/web/privacy.js.map +1 -0
- package/dist/creator2/web/runtime.d.ts +23 -0
- package/dist/creator2/web/runtime.d.ts.map +1 -0
- package/dist/creator2/web/runtime.js +265 -0
- package/dist/creator2/web/runtime.js.map +1 -0
- package/dist/creator2/web/types.d.ts +91 -0
- package/dist/creator2/web/types.d.ts.map +1 -0
- package/dist/creator2/web/types.js +3 -0
- package/dist/creator2/web/types.js.map +1 -0
- package/dist/creator3/core/client.d.ts +1 -0
- package/dist/creator3/core/client.d.ts.map +1 -1
- package/dist/creator3/core/client.js +5 -0
- package/dist/creator3/core/client.js.map +1 -1
- package/dist/creator3/core/platform-client.d.ts +46 -0
- package/dist/creator3/core/platform-client.d.ts.map +1 -0
- package/dist/creator3/core/platform-client.js +135 -0
- package/dist/creator3/core/platform-client.js.map +1 -0
- package/dist/creator3/core/platform-options.d.ts +30 -0
- package/dist/creator3/core/platform-options.d.ts.map +1 -0
- package/dist/creator3/core/platform-options.js +2 -0
- package/dist/creator3/core/platform-options.js.map +1 -0
- package/dist/creator3/core/platform-runtime.d.ts +59 -0
- package/dist/creator3/core/platform-runtime.d.ts.map +1 -0
- package/dist/creator3/core/platform-runtime.js +29 -0
- package/dist/creator3/core/platform-runtime.js.map +1 -0
- package/dist/creator3/core/plugin-api.d.ts +1 -1
- package/dist/creator3/core/plugin-api.d.ts.map +1 -1
- package/dist/creator3/core/transport.d.ts +1 -1
- package/dist/creator3/core/transport.d.ts.map +1 -1
- package/dist/creator3/core/version.d.ts +1 -1
- package/dist/creator3/core/version.js +1 -1
- package/dist/creator3/creator3/index.d.ts +6 -3
- package/dist/creator3/creator3/index.d.ts.map +1 -1
- package/dist/creator3/creator3/index.js +13 -8
- package/dist/creator3/creator3/index.js.map +1 -1
- package/dist/creator3/native/bootstrap.d.ts +2 -0
- package/dist/creator3/native/bootstrap.d.ts.map +1 -0
- package/dist/creator3/native/bootstrap.js +32 -0
- package/dist/creator3/native/bootstrap.js.map +1 -0
- package/dist/creator3/web/bootstrap.d.ts +3 -0
- package/dist/creator3/web/bootstrap.d.ts.map +1 -0
- package/dist/creator3/web/bootstrap.js +11 -0
- package/dist/creator3/web/bootstrap.js.map +1 -0
- package/dist/creator3/web/client.d.ts +60 -0
- package/dist/creator3/web/client.d.ts.map +1 -0
- package/dist/creator3/web/client.js +255 -0
- package/dist/creator3/web/client.js.map +1 -0
- package/dist/creator3/web/creator3.d.ts +5 -0
- package/dist/creator3/web/creator3.d.ts.map +1 -0
- package/dist/creator3/web/creator3.js +11 -0
- package/dist/creator3/web/creator3.js.map +1 -0
- package/dist/creator3/web/privacy.d.ts +3 -0
- package/dist/creator3/web/privacy.d.ts.map +1 -0
- package/dist/creator3/web/privacy.js +26 -0
- package/dist/creator3/web/privacy.js.map +1 -0
- package/dist/creator3/web/runtime.d.ts +23 -0
- package/dist/creator3/web/runtime.d.ts.map +1 -0
- package/dist/creator3/web/runtime.js +267 -0
- package/dist/creator3/web/runtime.js.map +1 -0
- package/dist/creator3/web/types.d.ts +91 -0
- package/dist/creator3/web/types.d.ts.map +1 -0
- package/dist/creator3/web/types.js +2 -0
- package/dist/creator3/web/types.js.map +1 -0
- package/extensions/creator2/install-web.cjs +69 -0
- package/extensions/creator2/main.js +19 -2
- package/extensions/creator2/project-configuration.cjs +135 -0
- package/extensions/creator3/dist/hooks.js +13 -0
- package/extensions/creator3/install-web.cjs +69 -0
- package/extensions/creator3/project-configuration.cjs +135 -0
- package/native/ios/FTCocosBridge.podspec +1 -1
- package/package.json +19 -3
- package/runtime/native.js +1191 -0
- package/web/bootstrap/package.json +4 -0
- package/web/bootstrap.js +1042 -0
- package/web/bootstrap.js.map +7 -0
- package/web/creator2/package.json +4 -0
- package/web/creator3/package.json +4 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runtime.js","sourceRoot":"","sources":["../../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACzE,OAAO,EAAE,4BAA4B,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAGlH,MAAM,WAAW,GAAG;IAClB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,QAAQ,EAAE,kBAAkB,EAAE,sBAAsB;IAC3F,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,EAAE,QAAQ;CAC9E,CAAC;AAEF,yFAAyF;AACzF,MAAM,OAAO,YAAY;IAQvB,YAAqB,MAAwB,EAAE,MAAmB,EAAE,YAAY,GAAG,KAAK;;QAAnE,WAAM,GAAN,MAAM,CAAkB;QAPpC,aAAQ,GAAG,CAAU,CAAC;QAGvB,kBAAa,GAAG,KAAK,CAAC;QAK5B,6EAA6E;QAC7E,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC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0,0 +1,91 @@
|
|
|
1
|
+
import type { FTAttributes, FTAutoTrackingConfig, FTCocosConfig, FTCocosHybridConfig } from '../core/types.js';
|
|
2
|
+
/** Public Browser SDK surface consumed by the adapter. Bundles are loaded outside Creator's module graph. */
|
|
3
|
+
export interface FTBrowserRum {
|
|
4
|
+
init(config: Record<string, unknown>): void;
|
|
5
|
+
getInitConfiguration(): Record<string, unknown> | undefined;
|
|
6
|
+
startView(options: {
|
|
7
|
+
name: string;
|
|
8
|
+
context?: FTAttributes;
|
|
9
|
+
}): void;
|
|
10
|
+
addTypeAction(name: string, type: string, context?: FTAttributes): void;
|
|
11
|
+
addError(error: Error, context?: FTAttributes): void;
|
|
12
|
+
setUser(user: Record<string, unknown>): void;
|
|
13
|
+
clearUser(): void;
|
|
14
|
+
setGlobalContextProperty(key: string, value: unknown): void;
|
|
15
|
+
startSessionReplayRecording(): void;
|
|
16
|
+
stopSessionReplayRecording(): void;
|
|
17
|
+
isRecording(): boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface FTBrowserLogs {
|
|
20
|
+
init(config: Record<string, unknown>): void;
|
|
21
|
+
getInitConfiguration(): Record<string, unknown> | undefined;
|
|
22
|
+
setUser(user: Record<string, unknown>): void;
|
|
23
|
+
clearUser(): void;
|
|
24
|
+
setGlobalContextProperty(key: string, value: unknown): void;
|
|
25
|
+
logger: {
|
|
26
|
+
log(message: string, context?: FTAttributes, status?: string): void;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export interface FTBrowserGlobals {
|
|
30
|
+
DATAFLUX_RUM?: FTBrowserRum;
|
|
31
|
+
DATAFLUX_LOGS?: FTBrowserLogs;
|
|
32
|
+
DATAFLUX_RUM_WEBGL?: {
|
|
33
|
+
webglReplayPlugin(): unknown;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export interface FTWebReplayConfig {
|
|
37
|
+
/** Explicit opt-in. Requires the full Browser RUM and WebGL bundles before engine boot. */
|
|
38
|
+
enabled: true;
|
|
39
|
+
sessionReplaySamplingRate?: number;
|
|
40
|
+
sessionReplayOnErrorSamplingRate?: number;
|
|
41
|
+
/** Whole-canvas capture is blocked by default. Node masks cannot be rendered by Browser Replay. */
|
|
42
|
+
canvasPrivacy?: 'block' | 'allow';
|
|
43
|
+
/** Only this canvas may be captured. @defaultValue 'GameCanvas' */
|
|
44
|
+
canvasId?: string;
|
|
45
|
+
/** Integer frames per second, from 1 to 5. @defaultValue 1 */
|
|
46
|
+
captureFps?: number;
|
|
47
|
+
/** Maximum frame edge, from 1 to 2048. @defaultValue 720 */
|
|
48
|
+
maxImageDimension?: number;
|
|
49
|
+
/** Browser encoder quality or preset. Presets do not change explicit captureFps. */
|
|
50
|
+
quality?: number | 'low' | 'medium' | 'high';
|
|
51
|
+
/** Maximum encoded image bytes, from 1024 to 1048576. Oversized frames may be reduced or dropped. */
|
|
52
|
+
maxFrameBytes?: number;
|
|
53
|
+
}
|
|
54
|
+
export interface FTWebConfig {
|
|
55
|
+
/** Separate Web RUM application ID. Never inferred from Android/iOS IDs. */
|
|
56
|
+
applicationId?: string;
|
|
57
|
+
/** Explicit Browser reporting origin. Native endpoint settings are not reused. */
|
|
58
|
+
datakitOrigin?: string;
|
|
59
|
+
/** Public Browser reporting site, used together with clientToken. */
|
|
60
|
+
site?: string;
|
|
61
|
+
clientToken?: string;
|
|
62
|
+
/** View started by stopView/leaveCocos/detach. @defaultValue 'CocosInactive' */
|
|
63
|
+
outsideViewName?: string;
|
|
64
|
+
allowedTracingUrls?: string[];
|
|
65
|
+
trackLongTasks?: boolean;
|
|
66
|
+
replay?: FTWebReplayConfig;
|
|
67
|
+
}
|
|
68
|
+
export interface FTCocosWebConfig extends Omit<FTCocosConfig, 'sdk'> {
|
|
69
|
+
sdk?: FTCocosConfig['sdk'];
|
|
70
|
+
web: FTWebConfig;
|
|
71
|
+
}
|
|
72
|
+
export interface FTCocosWebAttachConfig extends FTCocosHybridConfig {
|
|
73
|
+
/** Optional assertion when attaching to a page bootstrapped by this adapter. */
|
|
74
|
+
applicationId?: string;
|
|
75
|
+
}
|
|
76
|
+
export interface FTWebPageRuntime {
|
|
77
|
+
readonly protocol: 1;
|
|
78
|
+
readonly config: FTCocosWebConfig;
|
|
79
|
+
invoke<T>(method: string, payload?: unknown): T | undefined;
|
|
80
|
+
claim(owner: object): void;
|
|
81
|
+
release(owner: object): void;
|
|
82
|
+
setPrivacyCheck(owner: object, check: (() => boolean) | undefined): void;
|
|
83
|
+
startReplay(): void;
|
|
84
|
+
stopReplay(): void;
|
|
85
|
+
isRecording(): boolean;
|
|
86
|
+
}
|
|
87
|
+
export interface FTWebWindow extends FTBrowserGlobals {
|
|
88
|
+
__FT_COCOS_WEB__?: FTWebPageRuntime;
|
|
89
|
+
}
|
|
90
|
+
export type FTWebTrackingConfig = FTAutoTrackingConfig;
|
|
91
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAE/G,6GAA6G;AAC7G,MAAM,WAAW,YAAY;IAC3B,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;IAC5C,oBAAoB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAAC;IAC5D,SAAS,CAAC,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,YAAY,CAAA;KAAE,GAAG,IAAI,CAAC;IACnE,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;IACxE,QAAQ,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CA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AM,GAAG,IAAI,CAAC;IAC3B,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS,GAAG,IAAI,CAAC;IACzE,WAAW,IAAI,IAAI,CAAC;IACpB,UAAU,IAAI,IAAI,CAAC;IACnB,WAAW,IAAI,OAAO,CAAC;CACxB;AACD,MAAM,WAAW,WAAY,SAAQ,gBAAgB;IACnD,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;CACrC;AACD,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../src/web/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { syncManagedDirectory } = require('./managed-assets.cjs');
|
|
6
|
+
const { resolveWebConfiguration } = require('./project-configuration.cjs');
|
|
7
|
+
const BEGIN = '<!-- COCOS_SDK_WEB_BEGIN -->';
|
|
8
|
+
const END = '<!-- COCOS_SDK_WEB_END -->';
|
|
9
|
+
|
|
10
|
+
function isWebBuild(options) {
|
|
11
|
+
return options && ['web-mobile', 'web-desktop'].includes(options.platform);
|
|
12
|
+
}
|
|
13
|
+
function readWebConfig(extensionRoot) {
|
|
14
|
+
const project = path.resolve(extensionRoot, '..', '..');
|
|
15
|
+
const file = path.join(project, 'cocos-sdk.config.json');
|
|
16
|
+
const projectConfig = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
17
|
+
const config = resolveWebConfiguration(projectConfig);
|
|
18
|
+
if (!config) return undefined;
|
|
19
|
+
if (!config || !config.web || (!config.rum && !config.logger)) {
|
|
20
|
+
throw new Error('Set web.configuration in cocos-sdk.config.json with explicit web reporting settings and rum or logger');
|
|
21
|
+
}
|
|
22
|
+
// The runtime performs detailed API validation. Build validation detects missing assets/configuration early.
|
|
23
|
+
if (config.rum && !config.web.applicationId) throw new Error('web.configuration.web.applicationId is required');
|
|
24
|
+
if (!config.web.datakitOrigin && !(config.web.site && config.web.clientToken)) throw new Error('Configure the Web reporting origin');
|
|
25
|
+
for (const file of requiredFiles(config)) {
|
|
26
|
+
if (!fs.existsSync(path.join(extensionRoot, 'web', file))) throw new Error(`Missing Web asset ${file}; rerun the installer with --web`);
|
|
27
|
+
}
|
|
28
|
+
return config;
|
|
29
|
+
}
|
|
30
|
+
function requiredFiles(config) {
|
|
31
|
+
return [
|
|
32
|
+
...(config.rum ? ['rum.js'] : []),
|
|
33
|
+
...(config.logger ? ['logs.js'] : []),
|
|
34
|
+
...(config.web.replay ? ['webgl.js'] : []),
|
|
35
|
+
'bootstrap.js',
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function installWeb(buildRoot, extensionRoot) {
|
|
39
|
+
const config = readWebConfig(extensionRoot);
|
|
40
|
+
if (!config) {
|
|
41
|
+
const htmlFile = buildRoot && path.join(buildRoot, 'index.html');
|
|
42
|
+
if (htmlFile && fs.existsSync(htmlFile)) {
|
|
43
|
+
const original = fs.readFileSync(htmlFile, 'utf8');
|
|
44
|
+
const clean = original.replace(/<!-- COCOS_SDK_WEB_BEGIN -->[\s\S]*?<!-- COCOS_SDK_WEB_END -->\s*/g, '');
|
|
45
|
+
if (clean !== original) fs.writeFileSync(htmlFile, clean);
|
|
46
|
+
const managed = path.join(buildRoot, 'cocos-sdk-web');
|
|
47
|
+
if (fs.existsSync(path.join(managed, '.cocos-sdk-managed.json'))) syncManagedDirectory(managed, [], {});
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!buildRoot) throw new Error('Cannot resolve the Web build output directory');
|
|
52
|
+
const htmlFile = path.join(buildRoot, 'index.html');
|
|
53
|
+
if (!fs.existsSync(htmlFile)) throw new Error(`Missing Web build index.html at ${buildRoot}`);
|
|
54
|
+
const original = fs.readFileSync(htmlFile, 'utf8');
|
|
55
|
+
const clean = original.replace(/<!-- COCOS_SDK_WEB_BEGIN -->[\s\S]*?<!-- COCOS_SDK_WEB_END -->\s*/g, '');
|
|
56
|
+
const head = /<head(?:\s[^>]*)?>/i.exec(clean);
|
|
57
|
+
if (!head) throw new Error('Cannot place the Web bootstrap before engine boot: index.html has no head');
|
|
58
|
+
const generated = {};
|
|
59
|
+
requiredFiles(config).forEach(file => { generated[file] = fs.readFileSync(path.join(extensionRoot, 'web', file)); });
|
|
60
|
+
const sourceMap = path.join(extensionRoot, 'web', 'bootstrap.js.map');
|
|
61
|
+
if (fs.existsSync(sourceMap)) generated['bootstrap.js.map'] = fs.readFileSync(sourceMap);
|
|
62
|
+
generated['initialize.js'] = 'CocosWebSDK.bootstrapWeb(' + JSON.stringify(config).replace(/</g, '\\u003c') + ');\n';
|
|
63
|
+
// Dedicated output directory, never change user scripts or the project's node_modules.
|
|
64
|
+
syncManagedDirectory(path.join(buildRoot, 'cocos-sdk-web'), [], generated);
|
|
65
|
+
const scripts = [...requiredFiles(config), 'initialize.js'].map(file => `<script src="cocos-sdk-web/${file}"></script>`).join('\n');
|
|
66
|
+
const index = head.index + head[0].length;
|
|
67
|
+
fs.writeFileSync(htmlFile, clean.slice(0, index) + '\n' + BEGIN + '\n' + scripts + '\n' + END + '\n' + clean.slice(index));
|
|
68
|
+
}
|
|
69
|
+
module.exports = { isWebBuild, readWebConfig, installWeb };
|
|
@@ -1,11 +1,26 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const path = require('path');
|
|
4
3
|
const { installNative } = require('./install-native.cjs');
|
|
5
4
|
|
|
5
|
+
function web() { return require('./install-web.cjs'); }
|
|
6
|
+
|
|
7
|
+
function onBuildStart(options, callback) {
|
|
8
|
+
try {
|
|
9
|
+
const config = require('./project-configuration.cjs');
|
|
10
|
+
config.resolveNativeConfiguration(config.readProject(__dirname));
|
|
11
|
+
if (options && ['web-mobile', 'web-desktop'].includes(options.platform)) web().readWebConfig(__dirname);
|
|
12
|
+
callback();
|
|
13
|
+
} catch (error) { callback(error); }
|
|
14
|
+
}
|
|
15
|
+
|
|
6
16
|
function onBuildFinished(options, callback) {
|
|
7
17
|
try {
|
|
8
|
-
|
|
18
|
+
if (options && ['web-mobile', 'web-desktop'].includes(options.platform)) web().installWeb(options.dest || options.buildPath, __dirname);
|
|
19
|
+
else {
|
|
20
|
+
const root = options && (options.dest || options.buildPath);
|
|
21
|
+
installNative(root, __dirname, Editor);
|
|
22
|
+
require('./project-configuration.cjs').configureNativeBuild(root, __dirname);
|
|
23
|
+
}
|
|
9
24
|
callback();
|
|
10
25
|
} catch (error) {
|
|
11
26
|
Editor.error(`[cocos-sdk] ${error && error.stack ? error.stack : error}`);
|
|
@@ -15,9 +30,11 @@ function onBuildFinished(options, callback) {
|
|
|
15
30
|
|
|
16
31
|
module.exports = {
|
|
17
32
|
load() {
|
|
33
|
+
Editor.Builder.on('build-start', onBuildStart);
|
|
18
34
|
Editor.Builder.on('build-finished', onBuildFinished);
|
|
19
35
|
},
|
|
20
36
|
unload() {
|
|
37
|
+
Editor.Builder.removeListener('build-start', onBuildStart);
|
|
21
38
|
Editor.Builder.removeListener('build-finished', onBuildFinished);
|
|
22
39
|
},
|
|
23
40
|
};
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const NATIVE = ['captureFps', 'maxImageDimension', 'imagePolicy', 'touchPrivacy'];
|
|
6
|
+
const WEB = ['captureFps', 'maxImageDimension', 'quality', 'maxFrameBytes', 'canvasPrivacy', 'canvasId'];
|
|
7
|
+
const SAMPLING = ['sessionReplaySamplingRate', 'sessionReplayOnErrorSamplingRate'];
|
|
8
|
+
function object(value, name) {
|
|
9
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(`${name} must be an object`);
|
|
10
|
+
}
|
|
11
|
+
function keys(value, allowed, name) {
|
|
12
|
+
object(value, name);
|
|
13
|
+
for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new Error(`Unsupported ${name}.${key}`);
|
|
14
|
+
}
|
|
15
|
+
function number(value, min, max, name, integer = true) {
|
|
16
|
+
if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value))) {
|
|
17
|
+
throw new Error(`${name} must be ${integer ? 'an integer' : 'a number'} between ${min} and ${max}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function validateReplay(replay) {
|
|
21
|
+
if (replay === undefined) return;
|
|
22
|
+
keys(replay, ['enabled', ...SAMPLING, 'native', 'web'], 'replay');
|
|
23
|
+
if (replay.enabled !== undefined && typeof replay.enabled !== 'boolean') throw new Error('replay.enabled must be boolean');
|
|
24
|
+
for (const field of SAMPLING) number(replay[field], 0, 100, `replay.${field}`, false);
|
|
25
|
+
for (const platform of ['native', 'web']) {
|
|
26
|
+
const options = replay[platform];
|
|
27
|
+
if (options === undefined || options === false) continue;
|
|
28
|
+
keys(options, platform === 'native' ? NATIVE : WEB, `replay.${platform}`);
|
|
29
|
+
number(options.captureFps, 1, 5, `replay.${platform}.captureFps`);
|
|
30
|
+
number(options.maxImageDimension, 1, 2048, `replay.${platform}.maxImageDimension`);
|
|
31
|
+
if (platform === 'native') {
|
|
32
|
+
if (options.touchPrivacy !== undefined && !['hide', 'show'].includes(options.touchPrivacy)) throw new Error('replay.native.touchPrivacy must be hide or show');
|
|
33
|
+
if (options.imagePolicy !== undefined) {
|
|
34
|
+
keys(options.imagePolicy, ['quality', 'maxFrameBytes'], 'replay.native.imagePolicy');
|
|
35
|
+
if (options.imagePolicy.quality !== undefined && !['low', 'medium', 'high'].includes(options.imagePolicy.quality)) throw new Error('replay.native.imagePolicy.quality must be low, medium, or high');
|
|
36
|
+
number(options.imagePolicy.maxFrameBytes, 1024, 1048576, 'replay.native.imagePolicy.maxFrameBytes');
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
if (options.canvasPrivacy !== undefined && !['block', 'allow'].includes(options.canvasPrivacy)) throw new Error('replay.web.canvasPrivacy must be block or allow');
|
|
40
|
+
if (options.canvasId !== undefined && (typeof options.canvasId !== 'string' || !options.canvasId.trim())) throw new Error('replay.web.canvasId must be a nonempty string');
|
|
41
|
+
if (options.quality !== undefined && !['low', 'medium', 'high'].includes(options.quality)) number(options.quality, 0, 1, 'replay.web.quality', false);
|
|
42
|
+
number(options.maxFrameBytes, 1024, 1048576, 'replay.web.maxFrameBytes');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function unified(project) {
|
|
47
|
+
return project.configuration !== undefined || Object.keys(project.replay || {}).some(key => key !== 'enabled');
|
|
48
|
+
}
|
|
49
|
+
function replayOptions(project, platform) {
|
|
50
|
+
validateReplay(project.replay);
|
|
51
|
+
const replay = project.replay;
|
|
52
|
+
if (!replay?.enabled || replay[platform] === false) return undefined;
|
|
53
|
+
return {
|
|
54
|
+
sessionReplaySamplingRate: replay.sessionReplaySamplingRate ?? 100,
|
|
55
|
+
sessionReplayOnErrorSamplingRate: replay.sessionReplayOnErrorSamplingRate ?? 0,
|
|
56
|
+
...(replay[platform] || {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function nativeReplayEnabled(project) { validateReplay(project.replay); return project.replay?.enabled === true && project.replay.native !== false; }
|
|
60
|
+
function resolveNativeConfiguration(project) {
|
|
61
|
+
validateReplay(project.replay);
|
|
62
|
+
if (project.configuration === undefined) return undefined;
|
|
63
|
+
object(project.configuration, 'configuration');
|
|
64
|
+
const config = JSON.parse(JSON.stringify(project.configuration));
|
|
65
|
+
keys(config, ['sdk', 'rum', 'logger', 'trace', 'autoTrack'], 'configuration');
|
|
66
|
+
object(config.sdk, 'configuration.sdk');
|
|
67
|
+
const replay = replayOptions(project, 'native');
|
|
68
|
+
if (replay) {
|
|
69
|
+
if (!config.rum) throw new Error('Native Replay requires configuration.rum');
|
|
70
|
+
config.replay = replay;
|
|
71
|
+
}
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
function resolveWebConfiguration(project) {
|
|
75
|
+
validateReplay(project.replay);
|
|
76
|
+
if (project.web?.enabled !== true) return undefined;
|
|
77
|
+
const override = project.web.configuration || {};
|
|
78
|
+
object(override, 'web.configuration');
|
|
79
|
+
if (!unified(project)) return override;
|
|
80
|
+
const native = resolveNativeConfiguration(project) || {};
|
|
81
|
+
// Copy only shared Browser settings. Native endpoints and application IDs stay out of Web artifacts.
|
|
82
|
+
const fields = {
|
|
83
|
+
sdk: ['serviceName', 'env', 'globalContext'],
|
|
84
|
+
rum: ['sessionSamplingRate', 'sampleRate', 'sessionOnErrorSamplingRate', 'sessionOnErrorSampleRate', 'globalContext'],
|
|
85
|
+
logger: ['logSamplingRate', 'sampleRate', 'enableCustomLog', 'logLevelFilters', 'globalContext'],
|
|
86
|
+
trace: ['traceSamplingRate', 'sampleRate', 'traceType'],
|
|
87
|
+
};
|
|
88
|
+
const config = {};
|
|
89
|
+
for (const [group, names] of Object.entries(fields)) {
|
|
90
|
+
if (native[group] !== undefined) config[group] = Object.fromEntries(names.filter(key => native[group][key] !== undefined).map(key => [key, native[group][key]]));
|
|
91
|
+
if (override[group] !== undefined) config[group] = { ...config[group], ...override[group] };
|
|
92
|
+
}
|
|
93
|
+
if (native.autoTrack || override.autoTrack) config.autoTrack = { ...native.autoTrack, ...override.autoTrack };
|
|
94
|
+
config.web = { ...override.web };
|
|
95
|
+
if (config.web.replay !== undefined) throw new Error('Configure Replay once at replay.web; remove web.configuration.web.replay');
|
|
96
|
+
const replay = replayOptions(project, 'web');
|
|
97
|
+
if (replay) {
|
|
98
|
+
if (!config.rum) throw new Error('Web Replay requires configuration.rum or web.configuration.rum');
|
|
99
|
+
config.web.replay = { enabled: true, ...replay };
|
|
100
|
+
}
|
|
101
|
+
return config;
|
|
102
|
+
}
|
|
103
|
+
function readProject(extensionRoot) {
|
|
104
|
+
const file = path.resolve(extensionRoot, '..', '..', 'cocos-sdk.config.json');
|
|
105
|
+
return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
106
|
+
}
|
|
107
|
+
function nativeConfigurationScript(configuration) {
|
|
108
|
+
return '\n/* COCOS_PROJECT_CONFIGURATION_BEGIN */\n'
|
|
109
|
+
+ '(typeof window !== "undefined" ? window : globalThis).__FT_COCOS_CONFIGURATION__ = '
|
|
110
|
+
+ (configuration ? JSON.stringify(configuration).replace(/</g, '\\u003c') : 'undefined')
|
|
111
|
+
+ ';\n/* COCOS_PROJECT_CONFIGURATION_END */\n';
|
|
112
|
+
}
|
|
113
|
+
function configureNativeBuild(buildRoot, extensionRoot) {
|
|
114
|
+
if (!buildRoot || !fs.existsSync(buildRoot)) return;
|
|
115
|
+
const config = resolveNativeConfiguration(readProject(extensionRoot));
|
|
116
|
+
let found = false;
|
|
117
|
+
function visit(directory, depth) {
|
|
118
|
+
if (depth > 12) return;
|
|
119
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
120
|
+
if (['node_modules', '.git', 'library', 'temp', 'cocos-sdk-native'].includes(entry.name)) continue;
|
|
121
|
+
const file = path.join(directory, entry.name);
|
|
122
|
+
if (entry.isDirectory()) visit(file, depth + 1);
|
|
123
|
+
else if (entry.isFile() && entry.name.endsWith('.js')) {
|
|
124
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
125
|
+
if (!source.includes('__FT_COCOS_NATIVE_FACTORY__')) continue;
|
|
126
|
+
if (config?.replay && !source.includes('__FT_COCOS_REPLAY_FACTORY__')) throw new Error('Replay was enabled after installation. Rerun the installer with --replay and rebuild.');
|
|
127
|
+
const clean = source.replace(/\n?\/\* COCOS_PROJECT_CONFIGURATION_BEGIN \*\/[\s\S]*?\/\* COCOS_PROJECT_CONFIGURATION_END \*\/\n?/g, '');
|
|
128
|
+
fs.writeFileSync(file, clean + nativeConfigurationScript(config)); found = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
visit(path.resolve(buildRoot), 0);
|
|
133
|
+
if (config && !found) throw new Error('Native SDK runtime was not included in the build. Rerun the installer and rebuild.');
|
|
134
|
+
}
|
|
135
|
+
module.exports = { resolveNativeConfiguration, resolveWebConfiguration, nativeReplayEnabled, readProject, nativeConfigurationScript, configureNativeBuild };
|
|
@@ -65,6 +65,19 @@ exports.onAfterMake = async function onAfterMake(root) {
|
|
|
65
65
|
install(root);
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
exports.onBeforeBuild = async function onBeforeBuild(options) {
|
|
69
|
+
const config = require('../project-configuration.cjs');
|
|
70
|
+
config.resolveNativeConfiguration(config.readProject(path.resolve(__dirname, '..')));
|
|
71
|
+
const web = require('../install-web.cjs');
|
|
72
|
+
if (web.isWebBuild(options)) web.readWebConfig(path.resolve(__dirname, '..'));
|
|
73
|
+
};
|
|
74
|
+
|
|
68
75
|
exports.onAfterBuild = async function onAfterBuild(options, result) {
|
|
76
|
+
if (options && ['web-mobile', 'web-desktop'].includes(options.platform)) {
|
|
77
|
+
const web = require('../install-web.cjs');
|
|
78
|
+
web.installWeb(result && result.dest || options.dest, path.resolve(__dirname, '..'));
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
69
81
|
install(options, result);
|
|
82
|
+
require('../project-configuration.cjs').configureNativeBuild(result && result.dest || options && options.dest, path.resolve(__dirname, '..'));
|
|
70
83
|
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { syncManagedDirectory } = require('./managed-assets.cjs');
|
|
6
|
+
const { resolveWebConfiguration } = require('./project-configuration.cjs');
|
|
7
|
+
const BEGIN = '<!-- COCOS_SDK_WEB_BEGIN -->';
|
|
8
|
+
const END = '<!-- COCOS_SDK_WEB_END -->';
|
|
9
|
+
|
|
10
|
+
function isWebBuild(options) {
|
|
11
|
+
return options && ['web-mobile', 'web-desktop'].includes(options.platform);
|
|
12
|
+
}
|
|
13
|
+
function readWebConfig(extensionRoot) {
|
|
14
|
+
const project = path.resolve(extensionRoot, '..', '..');
|
|
15
|
+
const file = path.join(project, 'cocos-sdk.config.json');
|
|
16
|
+
const projectConfig = fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
17
|
+
const config = resolveWebConfiguration(projectConfig);
|
|
18
|
+
if (!config) return undefined;
|
|
19
|
+
if (!config || !config.web || (!config.rum && !config.logger)) {
|
|
20
|
+
throw new Error('Set web.configuration in cocos-sdk.config.json with explicit web reporting settings and rum or logger');
|
|
21
|
+
}
|
|
22
|
+
// The runtime performs detailed API validation. Build validation detects missing assets/configuration early.
|
|
23
|
+
if (config.rum && !config.web.applicationId) throw new Error('web.configuration.web.applicationId is required');
|
|
24
|
+
if (!config.web.datakitOrigin && !(config.web.site && config.web.clientToken)) throw new Error('Configure the Web reporting origin');
|
|
25
|
+
for (const file of requiredFiles(config)) {
|
|
26
|
+
if (!fs.existsSync(path.join(extensionRoot, 'web', file))) throw new Error(`Missing Web asset ${file}; rerun the installer with --web`);
|
|
27
|
+
}
|
|
28
|
+
return config;
|
|
29
|
+
}
|
|
30
|
+
function requiredFiles(config) {
|
|
31
|
+
return [
|
|
32
|
+
...(config.rum ? ['rum.js'] : []),
|
|
33
|
+
...(config.logger ? ['logs.js'] : []),
|
|
34
|
+
...(config.web.replay ? ['webgl.js'] : []),
|
|
35
|
+
'bootstrap.js',
|
|
36
|
+
];
|
|
37
|
+
}
|
|
38
|
+
function installWeb(buildRoot, extensionRoot) {
|
|
39
|
+
const config = readWebConfig(extensionRoot);
|
|
40
|
+
if (!config) {
|
|
41
|
+
const htmlFile = buildRoot && path.join(buildRoot, 'index.html');
|
|
42
|
+
if (htmlFile && fs.existsSync(htmlFile)) {
|
|
43
|
+
const original = fs.readFileSync(htmlFile, 'utf8');
|
|
44
|
+
const clean = original.replace(/<!-- COCOS_SDK_WEB_BEGIN -->[\s\S]*?<!-- COCOS_SDK_WEB_END -->\s*/g, '');
|
|
45
|
+
if (clean !== original) fs.writeFileSync(htmlFile, clean);
|
|
46
|
+
const managed = path.join(buildRoot, 'cocos-sdk-web');
|
|
47
|
+
if (fs.existsSync(path.join(managed, '.cocos-sdk-managed.json'))) syncManagedDirectory(managed, [], {});
|
|
48
|
+
}
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
if (!buildRoot) throw new Error('Cannot resolve the Web build output directory');
|
|
52
|
+
const htmlFile = path.join(buildRoot, 'index.html');
|
|
53
|
+
if (!fs.existsSync(htmlFile)) throw new Error(`Missing Web build index.html at ${buildRoot}`);
|
|
54
|
+
const original = fs.readFileSync(htmlFile, 'utf8');
|
|
55
|
+
const clean = original.replace(/<!-- COCOS_SDK_WEB_BEGIN -->[\s\S]*?<!-- COCOS_SDK_WEB_END -->\s*/g, '');
|
|
56
|
+
const head = /<head(?:\s[^>]*)?>/i.exec(clean);
|
|
57
|
+
if (!head) throw new Error('Cannot place the Web bootstrap before engine boot: index.html has no head');
|
|
58
|
+
const generated = {};
|
|
59
|
+
requiredFiles(config).forEach(file => { generated[file] = fs.readFileSync(path.join(extensionRoot, 'web', file)); });
|
|
60
|
+
const sourceMap = path.join(extensionRoot, 'web', 'bootstrap.js.map');
|
|
61
|
+
if (fs.existsSync(sourceMap)) generated['bootstrap.js.map'] = fs.readFileSync(sourceMap);
|
|
62
|
+
generated['initialize.js'] = 'CocosWebSDK.bootstrapWeb(' + JSON.stringify(config).replace(/</g, '\\u003c') + ');\n';
|
|
63
|
+
// Dedicated output directory, never change user scripts or the project's node_modules.
|
|
64
|
+
syncManagedDirectory(path.join(buildRoot, 'cocos-sdk-web'), [], generated);
|
|
65
|
+
const scripts = [...requiredFiles(config), 'initialize.js'].map(file => `<script src="cocos-sdk-web/${file}"></script>`).join('\n');
|
|
66
|
+
const index = head.index + head[0].length;
|
|
67
|
+
fs.writeFileSync(htmlFile, clean.slice(0, index) + '\n' + BEGIN + '\n' + scripts + '\n' + END + '\n' + clean.slice(index));
|
|
68
|
+
}
|
|
69
|
+
module.exports = { isWebBuild, readWebConfig, installWeb };
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const NATIVE = ['captureFps', 'maxImageDimension', 'imagePolicy', 'touchPrivacy'];
|
|
6
|
+
const WEB = ['captureFps', 'maxImageDimension', 'quality', 'maxFrameBytes', 'canvasPrivacy', 'canvasId'];
|
|
7
|
+
const SAMPLING = ['sessionReplaySamplingRate', 'sessionReplayOnErrorSamplingRate'];
|
|
8
|
+
function object(value, name) {
|
|
9
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) throw new Error(`${name} must be an object`);
|
|
10
|
+
}
|
|
11
|
+
function keys(value, allowed, name) {
|
|
12
|
+
object(value, name);
|
|
13
|
+
for (const key of Object.keys(value)) if (!allowed.includes(key)) throw new Error(`Unsupported ${name}.${key}`);
|
|
14
|
+
}
|
|
15
|
+
function number(value, min, max, name, integer = true) {
|
|
16
|
+
if (value !== undefined && (typeof value !== 'number' || !Number.isFinite(value) || value < min || value > max || integer && !Number.isInteger(value))) {
|
|
17
|
+
throw new Error(`${name} must be ${integer ? 'an integer' : 'a number'} between ${min} and ${max}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function validateReplay(replay) {
|
|
21
|
+
if (replay === undefined) return;
|
|
22
|
+
keys(replay, ['enabled', ...SAMPLING, 'native', 'web'], 'replay');
|
|
23
|
+
if (replay.enabled !== undefined && typeof replay.enabled !== 'boolean') throw new Error('replay.enabled must be boolean');
|
|
24
|
+
for (const field of SAMPLING) number(replay[field], 0, 100, `replay.${field}`, false);
|
|
25
|
+
for (const platform of ['native', 'web']) {
|
|
26
|
+
const options = replay[platform];
|
|
27
|
+
if (options === undefined || options === false) continue;
|
|
28
|
+
keys(options, platform === 'native' ? NATIVE : WEB, `replay.${platform}`);
|
|
29
|
+
number(options.captureFps, 1, 5, `replay.${platform}.captureFps`);
|
|
30
|
+
number(options.maxImageDimension, 1, 2048, `replay.${platform}.maxImageDimension`);
|
|
31
|
+
if (platform === 'native') {
|
|
32
|
+
if (options.touchPrivacy !== undefined && !['hide', 'show'].includes(options.touchPrivacy)) throw new Error('replay.native.touchPrivacy must be hide or show');
|
|
33
|
+
if (options.imagePolicy !== undefined) {
|
|
34
|
+
keys(options.imagePolicy, ['quality', 'maxFrameBytes'], 'replay.native.imagePolicy');
|
|
35
|
+
if (options.imagePolicy.quality !== undefined && !['low', 'medium', 'high'].includes(options.imagePolicy.quality)) throw new Error('replay.native.imagePolicy.quality must be low, medium, or high');
|
|
36
|
+
number(options.imagePolicy.maxFrameBytes, 1024, 1048576, 'replay.native.imagePolicy.maxFrameBytes');
|
|
37
|
+
}
|
|
38
|
+
} else {
|
|
39
|
+
if (options.canvasPrivacy !== undefined && !['block', 'allow'].includes(options.canvasPrivacy)) throw new Error('replay.web.canvasPrivacy must be block or allow');
|
|
40
|
+
if (options.canvasId !== undefined && (typeof options.canvasId !== 'string' || !options.canvasId.trim())) throw new Error('replay.web.canvasId must be a nonempty string');
|
|
41
|
+
if (options.quality !== undefined && !['low', 'medium', 'high'].includes(options.quality)) number(options.quality, 0, 1, 'replay.web.quality', false);
|
|
42
|
+
number(options.maxFrameBytes, 1024, 1048576, 'replay.web.maxFrameBytes');
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function unified(project) {
|
|
47
|
+
return project.configuration !== undefined || Object.keys(project.replay || {}).some(key => key !== 'enabled');
|
|
48
|
+
}
|
|
49
|
+
function replayOptions(project, platform) {
|
|
50
|
+
validateReplay(project.replay);
|
|
51
|
+
const replay = project.replay;
|
|
52
|
+
if (!replay?.enabled || replay[platform] === false) return undefined;
|
|
53
|
+
return {
|
|
54
|
+
sessionReplaySamplingRate: replay.sessionReplaySamplingRate ?? 100,
|
|
55
|
+
sessionReplayOnErrorSamplingRate: replay.sessionReplayOnErrorSamplingRate ?? 0,
|
|
56
|
+
...(replay[platform] || {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function nativeReplayEnabled(project) { validateReplay(project.replay); return project.replay?.enabled === true && project.replay.native !== false; }
|
|
60
|
+
function resolveNativeConfiguration(project) {
|
|
61
|
+
validateReplay(project.replay);
|
|
62
|
+
if (project.configuration === undefined) return undefined;
|
|
63
|
+
object(project.configuration, 'configuration');
|
|
64
|
+
const config = JSON.parse(JSON.stringify(project.configuration));
|
|
65
|
+
keys(config, ['sdk', 'rum', 'logger', 'trace', 'autoTrack'], 'configuration');
|
|
66
|
+
object(config.sdk, 'configuration.sdk');
|
|
67
|
+
const replay = replayOptions(project, 'native');
|
|
68
|
+
if (replay) {
|
|
69
|
+
if (!config.rum) throw new Error('Native Replay requires configuration.rum');
|
|
70
|
+
config.replay = replay;
|
|
71
|
+
}
|
|
72
|
+
return config;
|
|
73
|
+
}
|
|
74
|
+
function resolveWebConfiguration(project) {
|
|
75
|
+
validateReplay(project.replay);
|
|
76
|
+
if (project.web?.enabled !== true) return undefined;
|
|
77
|
+
const override = project.web.configuration || {};
|
|
78
|
+
object(override, 'web.configuration');
|
|
79
|
+
if (!unified(project)) return override;
|
|
80
|
+
const native = resolveNativeConfiguration(project) || {};
|
|
81
|
+
// Copy only shared Browser settings. Native endpoints and application IDs stay out of Web artifacts.
|
|
82
|
+
const fields = {
|
|
83
|
+
sdk: ['serviceName', 'env', 'globalContext'],
|
|
84
|
+
rum: ['sessionSamplingRate', 'sampleRate', 'sessionOnErrorSamplingRate', 'sessionOnErrorSampleRate', 'globalContext'],
|
|
85
|
+
logger: ['logSamplingRate', 'sampleRate', 'enableCustomLog', 'logLevelFilters', 'globalContext'],
|
|
86
|
+
trace: ['traceSamplingRate', 'sampleRate', 'traceType'],
|
|
87
|
+
};
|
|
88
|
+
const config = {};
|
|
89
|
+
for (const [group, names] of Object.entries(fields)) {
|
|
90
|
+
if (native[group] !== undefined) config[group] = Object.fromEntries(names.filter(key => native[group][key] !== undefined).map(key => [key, native[group][key]]));
|
|
91
|
+
if (override[group] !== undefined) config[group] = { ...config[group], ...override[group] };
|
|
92
|
+
}
|
|
93
|
+
if (native.autoTrack || override.autoTrack) config.autoTrack = { ...native.autoTrack, ...override.autoTrack };
|
|
94
|
+
config.web = { ...override.web };
|
|
95
|
+
if (config.web.replay !== undefined) throw new Error('Configure Replay once at replay.web; remove web.configuration.web.replay');
|
|
96
|
+
const replay = replayOptions(project, 'web');
|
|
97
|
+
if (replay) {
|
|
98
|
+
if (!config.rum) throw new Error('Web Replay requires configuration.rum or web.configuration.rum');
|
|
99
|
+
config.web.replay = { enabled: true, ...replay };
|
|
100
|
+
}
|
|
101
|
+
return config;
|
|
102
|
+
}
|
|
103
|
+
function readProject(extensionRoot) {
|
|
104
|
+
const file = path.resolve(extensionRoot, '..', '..', 'cocos-sdk.config.json');
|
|
105
|
+
return fs.existsSync(file) ? JSON.parse(fs.readFileSync(file, 'utf8')) : {};
|
|
106
|
+
}
|
|
107
|
+
function nativeConfigurationScript(configuration) {
|
|
108
|
+
return '\n/* COCOS_PROJECT_CONFIGURATION_BEGIN */\n'
|
|
109
|
+
+ '(typeof window !== "undefined" ? window : globalThis).__FT_COCOS_CONFIGURATION__ = '
|
|
110
|
+
+ (configuration ? JSON.stringify(configuration).replace(/</g, '\\u003c') : 'undefined')
|
|
111
|
+
+ ';\n/* COCOS_PROJECT_CONFIGURATION_END */\n';
|
|
112
|
+
}
|
|
113
|
+
function configureNativeBuild(buildRoot, extensionRoot) {
|
|
114
|
+
if (!buildRoot || !fs.existsSync(buildRoot)) return;
|
|
115
|
+
const config = resolveNativeConfiguration(readProject(extensionRoot));
|
|
116
|
+
let found = false;
|
|
117
|
+
function visit(directory, depth) {
|
|
118
|
+
if (depth > 12) return;
|
|
119
|
+
for (const entry of fs.readdirSync(directory, { withFileTypes: true })) {
|
|
120
|
+
if (['node_modules', '.git', 'library', 'temp', 'cocos-sdk-native'].includes(entry.name)) continue;
|
|
121
|
+
const file = path.join(directory, entry.name);
|
|
122
|
+
if (entry.isDirectory()) visit(file, depth + 1);
|
|
123
|
+
else if (entry.isFile() && entry.name.endsWith('.js')) {
|
|
124
|
+
const source = fs.readFileSync(file, 'utf8');
|
|
125
|
+
if (!source.includes('__FT_COCOS_NATIVE_FACTORY__')) continue;
|
|
126
|
+
if (config?.replay && !source.includes('__FT_COCOS_REPLAY_FACTORY__')) throw new Error('Replay was enabled after installation. Rerun the installer with --replay and rebuild.');
|
|
127
|
+
const clean = source.replace(/\n?\/\* COCOS_PROJECT_CONFIGURATION_BEGIN \*\/[\s\S]*?\/\* COCOS_PROJECT_CONFIGURATION_END \*\/\n?/g, '');
|
|
128
|
+
fs.writeFileSync(file, clean + nativeConfigurationScript(config)); found = true;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
visit(path.resolve(buildRoot), 0);
|
|
133
|
+
if (config && !found) throw new Error('Native SDK runtime was not included in the build. Rerun the installer and rebuild.');
|
|
134
|
+
}
|
|
135
|
+
module.exports = { resolveNativeConfiguration, resolveWebConfiguration, nativeReplayEnabled, readProject, nativeConfigurationScript, configureNativeBuild };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Pod::Spec.new do |s|
|
|
2
2
|
s.name = 'FTCocosBridge'
|
|
3
|
-
s.version = '0.1.1-alpha.
|
|
3
|
+
s.version = '0.1.1-alpha.2'
|
|
4
4
|
s.summary = 'CloudCare Mobile SDK native bridge for Cocos Creator.'
|
|
5
5
|
s.homepage = 'https://github.com/GuanceCloud/datakit-cocos'
|
|
6
6
|
s.license = { :type => 'Apache-2.0' }
|