@tamer4lynx/cli 0.0.5 → 0.0.6

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -2
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ import path24 from "path";
12
12
  import { program } from "commander";
13
13
 
14
14
  // package.json
15
- var version = "0.0.5";
15
+ var version = "0.0.6";
16
16
 
17
17
  // src/android/create.ts
18
18
  import fs3 from "fs";
@@ -375,6 +375,18 @@ import ${vars.packageName}.generated.GeneratedLynxExtensions;
375
375
  LynxEnv.inst().init(this, null, new TemplateProvider(this), null);
376
376
  }`
377
377
  );
378
+ out = out.replace(
379
+ /LynxServiceCenter\.inst\(\)\.registerService\(LynxLogService\.INSTANCE\);/,
380
+ `try {
381
+ Object logService = Class.forName("com.nanofuxion.tamerdevclient.TamerRelogLogService")
382
+ .getField("INSTANCE")
383
+ .get(null);
384
+ logService.getClass().getMethod("init", android.content.Context.class).invoke(logService, this);
385
+ LynxServiceCenter.inst().registerService((com.lynx.tasm.service.ILynxLogService) logService);
386
+ } catch (Exception ignored) {
387
+ LynxServiceCenter.inst().registerService(LynxLogService.INSTANCE);
388
+ }`
389
+ );
378
390
  return out.replace(/\n{3,}/g, "\n\n");
379
391
  }
380
392
  function getLoadTemplateBody(vars) {
@@ -548,6 +560,8 @@ class DevClientManager(private val context: Context, private val onReload: Runna
548
560
  function getProjectActivity(vars) {
549
561
  const hasDevClient = vars.devMode === "embedded";
550
562
  const devClientInit = hasDevClient ? `
563
+ TamerRelogLogService.init(this)
564
+ TamerRelogLogService.connect()
551
565
  devClientManager = DevClientManager(this) { reloadProjectView() }
552
566
  devClientManager?.connect()
553
567
  ` : "";
@@ -555,9 +569,11 @@ function getProjectActivity(vars) {
555
569
  ` : "";
556
570
  const devClientCleanup = hasDevClient ? `
557
571
  devClientManager?.disconnect()
572
+ TamerRelogLogService.disconnect()
558
573
  ` : "";
559
574
  const devClientImports = hasDevClient ? `
560
- import ${vars.packageName}.DevClientManager` : "";
575
+ import ${vars.packageName}.DevClientManager
576
+ import com.nanofuxion.tamerdevclient.TamerRelogLogService` : "";
561
577
  const reloadMethod = hasDevClient ? `
562
578
  private fun reloadProjectView() {
563
579
  GeneratedActivityLifecycle.onViewDetached()
@@ -1972,6 +1988,30 @@ function readAndSubstituteTemplate2(templatePath, vars) {
1972
1988
  raw
1973
1989
  );
1974
1990
  }
1991
+ function patchAppLogService(appPath) {
1992
+ if (!fs8.existsSync(appPath)) return;
1993
+ const raw = fs8.readFileSync(appPath, "utf-8");
1994
+ const patched = raw.replace(
1995
+ /private void initLynxService\(\)\s*\{[\s\S]*?\n\s*}\s*\n\s*private void initFresco\(\)/,
1996
+ `private void initLynxService() {
1997
+ try {
1998
+ Object logService = Class.forName("com.nanofuxion.tamerdevclient.TamerRelogLogService")
1999
+ .getField("INSTANCE")
2000
+ .get(null);
2001
+ logService.getClass().getMethod("init", android.content.Context.class).invoke(logService, this);
2002
+ LynxServiceCenter.inst().registerService((com.lynx.tasm.service.ILynxLogService) logService);
2003
+ } catch (Exception ignored) {
2004
+ LynxServiceCenter.inst().registerService(LynxLogService.INSTANCE);
2005
+ }
2006
+ LynxServiceCenter.inst().registerService(LynxImageService.getInstance());
2007
+ LynxServiceCenter.inst().registerService(LynxHttpService.INSTANCE);
2008
+ }
2009
+ private void initFresco()`
2010
+ );
2011
+ if (patched !== raw) {
2012
+ fs8.writeFileSync(appPath, patched);
2013
+ }
2014
+ }
1975
2015
  async function syncDevClient(opts) {
1976
2016
  let resolved;
1977
2017
  try {
@@ -2004,6 +2044,7 @@ async function syncDevClient(opts) {
2004
2044
  ]);
2005
2045
  fs8.writeFileSync(path8.join(javaDir, "TemplateProvider.java"), templateProviderSource);
2006
2046
  fs8.writeFileSync(path8.join(kotlinDir, "MainActivity.kt"), getStandaloneMainActivity(vars));
2047
+ patchAppLogService(path8.join(javaDir, "App.java"));
2007
2048
  const appDir = path8.join(rootDir, "app");
2008
2049
  const mainDir = path8.join(appDir, "src", "main");
2009
2050
  const manifestPath = path8.join(mainDir, "AndroidManifest.xml");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamer4lynx/cli",
3
- "version": "0.0.5",
3
+ "version": "0.0.6",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "description": "A CLI tool for managing LynxJS native modules.",