Commit 41843963 authored by lujie's avatar lujie
Browse files

Merge branch 'feat-demo' into 'main'

feat(app): init

See merge request !1
parents 8d522ac0 b8124cc0
/**
* @desc Run on UI/main thread, process message from worker thread and postMessage to worker thread
*/
import worker, { MessageEvents } from '@ohos.worker';
import { Constants } from '../common/Constants';
import { TuanjieLog } from '../common/TuanjieLog';
import { Tuanjie } from '../utils/TuanjieNative';
import { PROCESS_UI_BUILTIN_MESSAGE, PROCESS_UI_HANDLER, PROCESS_UI_MESSAGE, kCustomHandler } from './MessageProcessor';
import "../gen/BuiltinHostMsgRegistration";
export class WorkerProxy {
public threadWorker: worker.ThreadWorker;
public mModules: Record<string, ESObject> = {
};
public mUserExtraModules: Record<string, ESObject> = { };
private constructor() {
TuanjieLog.debug('%{public}s', 'WorkerProxy.constructor');
this.threadWorker = new worker.ThreadWorker("./TuanjieMainWorker.ets");
this.threadWorker.onerror = (e) => {
let msg = e.message;
let filename = e.filename;
let lineno = e.lineno;
let colno = e.colno;
TuanjieLog.error(`TuanjieMainWorker Error ${msg} ${filename} ${lineno} ${colno}`);
}
const self = this;
this.threadWorker.onmessage = (msg) => {
msg.data.src = "Worker.TuanjieMain";
if (msg.data.type == "RUN_ON_UI_THREAD") {
Tuanjie.nativeProcessUIThreadMessage();
} else if (msg.data.type == "RUN_ON_UI_THREAD_JS") {
PROCESS_UI_BUILTIN_MESSAGE(msg.data)
} else if (msg.data.type == "RUN_ON_UI_THREAD_USER_EVENT") {
PROCESS_UI_MESSAGE(msg.data);
} else if (msg.data.type == kCustomHandler) {
PROCESS_UI_HANDLER(msg.data);
} else {
TuanjieLog.warn("Unknown UI message type=%{public}s", msg.type);
}
}
}
public static Instance(): WorkerProxy {
let tuanjieMainWorker = AppStorage.get<WorkerProxy>(Constants.APP_KEY_TUANJIE_MAIN_WORKER);
if (tuanjieMainWorker == null) {
tuanjieMainWorker = new WorkerProxy();
AppStorage.setOrCreate(Constants.APP_KEY_TUANJIE_MAIN_WORKER, tuanjieMainWorker);
}
return tuanjieMainWorker;
}
public static getInstance(): worker.ThreadWorker {
return WorkerProxy.Instance().threadWorker;
}
/**
* post message to worker thread. For now we have only one worker - TuanjieMainWorker
* @param msg
*/
public static postMessage(msg: ESObject, targetWorker: string | undefined) {
if (targetWorker === undefined)
WorkerProxy.Instance().threadWorker.postMessage(msg);
// for now we have only worker
}
}
export function POST_MESSAGE(msg: ESObject) {
POST_MESSAGE_TO_WORKER(msg, undefined)
}
export function POST_MESSAGE_TO_WORKER(msg: ESObject, targetWorker: string | undefined) {
if (!msg.type)
msg.type = "RUN_ON_UI_THREAD_USER_EVENT";
WorkerProxy.postMessage(msg, targetWorker);
}
{
"module": {
"name": "tuanjieLib",
"type": "har",
"description": "$string:module_desc",
"deviceTypes": [
"phone",
"tablet",
"2in1"
],
'abilities': [],
"metadata": [
{
"name": "ArkTSPartialUpdate",
"value": "true"
},
{
"name": "partialUpdateStrictCheck",
"value": "warn"
}
],
"installationFree": false,
"requestPermissions": [
{
"name": "ohos.permission.INTERNET",
"usedScene": {
"abilities": [
"TuanjiePlayerAbility"
],
"when": "always"
},
"reason": "$string:default_reason"
},
{
"name": "ohos.permission.ACCELEROMETER",
"usedScene": {
"abilities": [
"TuanjiePlayerAbility"
],
"when": "always"
},
"reason": "$string:default_reason"
}
]
}
}
\ No newline at end of file
{
"color": [
{
"name": "start_window_background",
"value": "#FF231F20"
}
]
}
\ No newline at end of file
{
"integer": [
{
"name": "ShowStaticSplashScreen",
"value": 0
},
{
"name": "StaticSplashScreenFit",
"value": 0
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "default_reason",
"value": "permission request"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "HonmonyBridge"
},
{
"name": "permission_microphone_reason_desc",
"value": "request microphone permission"
}
]
}
\ No newline at end of file
{
"layeredIcon": {
"foreground": "$media:ic_launcher_foreground",
"background": "$media:ic_launcher_background"
}
}
{
"string": [
{
"name": "module_desc",
"value": "module description"
},
{
"name": "default_reason",
"value": "permission request"
},
{
"name": "EntryAbility_desc",
"value": "description"
},
{
"name": "EntryAbility_label",
"value": "HonmonyBridge"
},
{
"name": "permission_microphone_reason_desc",
"value": "request microphone permission"
}
]
}
\ No newline at end of file
{"root":[{"assemblyName":"Unity.VisualScripting.Core","nameSpace":"Unity.VisualScripting","className":"RuntimeVSUsageUtility","methodName":"RuntimeInitializeOnLoadBeforeSceneLoad","loadTypes":1,"isUnityClass":true}]}
{"names":["UnityEngine.dll","UnityEngine.AIModule.dll","UnityEngine.ARModule.dll","UnityEngine.AccessibilityModule.dll","UnityEngine.AndroidAppViewModule.dll","UnityEngine.AndroidJNIModule.dll","UnityEngine.AnimationModule.dll","UnityEngine.AssetBundleModule.dll","UnityEngine.AudioModule.dll","UnityEngine.AutoStreamingModule.dll","UnityEngine.ClothModule.dll","UnityEngine.ContentLoadModule.dll","UnityEngine.CoreModule.dll","UnityEngine.CrashReportingModule.dll","UnityEngine.DSPGraphModule.dll","UnityEngine.DirectorModule.dll","UnityEngine.GIModule.dll","UnityEngine.GameCenterModule.dll","UnityEngine.GridModule.dll","UnityEngine.HotReloadModule.dll","UnityEngine.IMGUIModule.dll","UnityEngine.ImageConversionModule.dll","UnityEngine.InfinityModule.dll","UnityEngine.InputModule.dll","UnityEngine.InputLegacyModule.dll","UnityEngine.JSONSerializeModule.dll","UnityEngine.LocalizationModule.dll","UnityEngine.OcclusionCullingModule.dll","UnityEngine.OpenHarmonyJSModule.dll","UnityEngine.ParticleSystemModule.dll","UnityEngine.PerformanceReportingModule.dll","UnityEngine.PhysicsModule.dll","UnityEngine.Physics2DModule.dll","UnityEngine.ProfilerModule.dll","UnityEngine.PropertiesModule.dll","UnityEngine.RuntimeInitializeOnLoadManagerInitializerModule.dll","UnityEngine.ScreenCaptureModule.dll","UnityEngine.SharedInternalsModule.dll","UnityEngine.SpriteMaskModule.dll","UnityEngine.SpriteShapeModule.dll","UnityEngine.StreamingModule.dll","UnityEngine.SubstanceModule.dll","UnityEngine.SubsystemsModule.dll","UnityEngine.TLSModule.dll","UnityEngine.TerrainModule.dll","UnityEngine.TerrainPhysicsModule.dll","UnityEngine.TextCoreFontEngineModule.dll","UnityEngine.TextCoreTextEngineModule.dll","UnityEngine.TextRenderingModule.dll","UnityEngine.TextureManagerModule.dll","UnityEngine.TilemapModule.dll","UnityEngine.UIModule.dll","UnityEngine.UIElementsModule.dll","UnityEngine.UmbraModule.dll","UnityEngine.UnityAnalyticsModule.dll","UnityEngine.UnityAnalyticsCommonModule.dll","UnityEngine.UnityConnectModule.dll","UnityEngine.UnityCurlModule.dll","UnityEngine.UnityTestProtocolModule.dll","UnityEngine.UnityWebRequestModule.dll","UnityEngine.UnityWebRequestAssetBundleModule.dll","UnityEngine.UnityWebRequestAudioModule.dll","UnityEngine.UnityWebRequestTextureModule.dll","UnityEngine.UnityWebRequestWWWModule.dll","UnityEngine.VFXModule.dll","UnityEngine.VehiclesModule.dll","UnityEngine.VideoModule.dll","UnityEngine.WindModule.dll","UnityEngine.XRModule.dll","Unity.Timeline.dll","UnityEngine.UI.dll","Unity.TextMeshPro.dll","Unity.VisualScripting.Core.dll","Unity.VisualScripting.State.dll","Unity.VisualScripting.Flow.dll","Unity.VisualScripting.Antlr3.Runtime.dll"],"types":[2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,16,16,16,16,16,16,16]}
\ No newline at end of file
player-connection-mode=Listen
player-connection-guid=2414720699
player-connection-debug=0
player-connection-project-name=HonmonyBridge
player-connection-ip=10.1.70.3
serialized-file-monobehaviour-typetree-only=0
wait-for-native-debugger=0
hdr-display-enabled=0
gc-max-time-slice=3
openHarmonyStartInFullscreen=1
openHarmonyRenderOutsideSafeArea=1
logStartupTiming=0
build-guid=ea302243af7442aab2570797309baf81
45003644-4461-42d6-85b7-1ea8a4313eb6
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment