@tarojs/plugin-platform-harmony-cpp 4.1.2 → 4.1.3-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ import { HarmonyOS_ArkTS } from '@tarojs/plugin-platform-harmony-ets/dist';
2
+ import { IPluginContext, TConfig } from '@tarojs/service';
3
+ import { IHarmonyConfig } from '@tarojs/taro/types/compile';
4
+
5
+ declare class Harmony extends HarmonyOS_ArkTS {
6
+ option: IOptions;
7
+ platform: string;
8
+ runtimePath: string;
9
+ useETS: boolean;
10
+ useJSON5: boolean;
11
+ get context(): IPluginContext;
12
+ constructor(ctx: IPluginContext, config: TConfig, option: IOptions);
13
+ get harmonyPluginPath(): string;
14
+ get harmonyCppPluginPath(): string;
15
+ get apiLibrary(): string;
16
+ get componentLibrary(): string;
17
+ get runtimeLibrary(): string;
18
+ get runtimeFrameworkLibrary(): string;
19
+ get runtimeFrameworkReconciler(): string;
20
+ modifyPageConfig(): void;
21
+ updateModulePackage(outputRoot: string, ohPackage?: Exclude<IHarmonyConfig['ohPackage'], undefined>, ohpm?: string): void;
22
+ }
23
+
24
+ interface IOptions {
25
+ useConfigName?: string;
26
+ /** @default "local" */
27
+ useChoreLibrary?: 'local' | 'remote' | false | string;
28
+ }
29
+ declare const _default: (ctx: IPluginContext, options?: IOptions) => void;
30
+
31
+ export { Harmony as HarmonyCPP, _default as default };
32
+ export type { IOptions };
package/dist/index.js CHANGED
@@ -15,12 +15,13 @@ var utils = require('@tarojs/vite-runner/dist/utils');
15
15
  var parseCssToStylesheet = require('@tarojs/parse-css-to-stylesheet');
16
16
  var constants = require('@tarojs/vite-runner/dist/harmony/postcss/constants');
17
17
 
18
- var version = "4.1.2";
18
+ var version = "4.1.3-beta.0";
19
19
 
20
20
  const PKG_NAME = '@taro-oh/library';
21
21
  const PKG_VERSION = version;
22
22
  const PROJECT_DEPENDENCIES_NAME = [];
23
23
  const PKG_DEPENDENCIES = {};
24
+ const STATIC_FOLDER_NAME = 'static';
24
25
 
25
26
  /* eslint-disable no-console */
26
27
  const PLATFORM_NAME = 'harmony_cpp';
@@ -169,16 +170,15 @@ function appPlugin () {
169
170
  };
170
171
  }
171
172
 
172
- function injectEnv () {
173
- const that = this;
173
+ function injectEnv (platform) {
174
174
  const packageName = '@tarojs/taro';
175
175
  const bindingName = 'Taro';
176
- const businessId = this.config.defineConstants?.LOCATION_APIKEY?.replace(/^['"]|['"]$/g, '');
176
+ const businessId = platform.getConfig().defineConstants?.LOCATION_APIKEY?.replace(/^['"]|['"]$/g, '');
177
177
  return {
178
178
  name: 'taro:vite-add-method-env',
179
179
  transform(code, id) {
180
180
  const pluginContext = this;
181
- const { runnerUtils } = that.context;
181
+ const { runnerUtils } = platform.context;
182
182
  const { getViteHarmonyCompilerContext } = runnerUtils;
183
183
  const compiler = getViteHarmonyCompilerContext(pluginContext);
184
184
  const exts = Array.from(new Set(compiler?.frameworkExts.concat(helper.SCRIPT_EXT)));
@@ -299,7 +299,15 @@ function pagePlugin () {
299
299
  const pluginContext = this;
300
300
  const { runnerUtils, runOpts } = that.context;
301
301
  const isPureComp = (page) => {
302
- return runOpts?.options?.args.pure || page.config?.entryOption === false;
302
+ if (page instanceof Array)
303
+ return false;
304
+ if (runOpts?.options?.args.pure || page.config?.entryOption === false) {
305
+ page.isPure = true;
306
+ }
307
+ else {
308
+ page.isPure = false;
309
+ }
310
+ return page.isPure;
303
311
  };
304
312
  const { getViteHarmonyCompilerContext } = runnerUtils;
305
313
  const compiler = getViteHarmonyCompilerContext(pluginContext);
@@ -336,7 +344,7 @@ function pagePlugin () {
336
344
  };
337
345
  const oddModifyInstantiate = compiler.loaderMeta.modifyInstantiate;
338
346
  compiler.loaderMeta.modifyInstantiate = function (code = '', type = '', page) {
339
- if (type === 'page') {
347
+ if (type === 'page' && !(page instanceof Array)) {
340
348
  const componentName = page.config?.componentName;
341
349
  if (shared.isString(componentName)) {
342
350
  code = code.replace(/export\sdefault\sstruct\sIndex/, `export struct ${componentName}`);
@@ -349,12 +357,20 @@ function pagePlugin () {
349
357
  config.entryOption = {};
350
358
  }
351
359
  config.modifyPageImport = function (importStr, page) {
352
- if (!isPureComp(page)) {
360
+ function fixPageEntry(meta) {
353
361
  Object.assign(config.entryOption, {
354
- routeName: page.name,
362
+ routeName: meta.name,
355
363
  });
356
- if (shared.isObject(page.config?.entryOption)) {
357
- Object.assign(config.entryOption, page.config.entryOption);
364
+ if (shared.isObject(meta.config?.entryOption)) {
365
+ Object.assign(config.entryOption, meta.config.entryOption);
366
+ }
367
+ }
368
+ if (!isPureComp(page)) {
369
+ if (page instanceof Array) {
370
+ page.forEach(fixPageEntry);
371
+ }
372
+ else {
373
+ fixPageEntry(page);
358
374
  }
359
375
  }
360
376
  importStr.unshift('import { navigateBack } from "@tarojs/taro"');
@@ -372,11 +388,11 @@ function pagePlugin () {
372
388
  type: 'TaroAny',
373
389
  foreach: () => 'null',
374
390
  disabled: !this.buildConfig.isBuildNativeComp && isPure,
375
- }, this.isTabbarPage), this.renderState({
391
+ }, false), this.renderState({
376
392
  name: 'areaChange',
377
393
  type: 'TaroAny',
378
394
  foreach: () => 'null',
379
- }, this.isTabbarPage), this.renderState({
395
+ }, false), this.renderState({
380
396
  name: '__pageName',
381
397
  type: 'TaroAny',
382
398
  foreach: () => 'null',
@@ -387,7 +403,7 @@ function pagePlugin () {
387
403
  type: 'TaroObject',
388
404
  foreach: () => '{}',
389
405
  disabled: !this.buildConfig.isBuildNativeComp && isPure,
390
- }, this.isTabbarPage), this.renderState({
406
+ }, false), this.renderState({
391
407
  decorator: 'State',
392
408
  name: 'statusBarHeight',
393
409
  type: 'number',
@@ -396,9 +412,18 @@ function pagePlugin () {
396
412
  decorator: 'State',
397
413
  name: 'isHideTitleBar',
398
414
  type: 'boolean',
399
- foreach: () => this.appConfig.window?.navigationStyle === 'custom'
400
- ? `config.navigationStyle !== 'default'`
401
- : `config.navigationStyle === 'custom'`,
415
+ foreach: (_, index) => {
416
+ if (this.isTabbarPage) {
417
+ return this.appConfig.window?.navigationStyle === 'custom'
418
+ ? `config${index}.navigationStyle !== 'default'`
419
+ : `config${index}.navigationStyle === 'custom'`;
420
+ }
421
+ else {
422
+ return this.appConfig.window?.navigationStyle === 'custom'
423
+ ? `config.navigationStyle !== 'default'`
424
+ : `config.navigationStyle === 'custom'`;
425
+ }
426
+ },
402
427
  }, this.isTabbarPage), this.renderState({
403
428
  decorator: 'State',
404
429
  name: 'isUseCache',
@@ -455,19 +480,40 @@ function pagePlugin () {
455
480
  ` Current.audioSessionManager = audioManager.getSessionManager()`,
456
481
  `}`,
457
482
  `this.activeAudioSession()`,
458
- `initEtsBuilder('${genUniPageId(page)}')`,
483
+ ...(page instanceof Array ? [
484
+ ...page.map(p => `initEtsBuilder('${genUniPageId(p)}')`),
485
+ ...page.map((p, i) => `this.__pageName[${i}] = '${p.name}'`),
486
+ ] : [
487
+ `initEtsBuilder('${genUniPageId(page)}')`,
488
+ `this.__pageName = '${page.name}'`,
489
+ ]),
459
490
  'this.__layoutSize = this.params._layout_',
460
- `this.__pageName = '${page.name}'`,
461
491
  `systemContext.windowWidth = ${config.config.windowArea?.width || 'this.params._layout_?.width'}`,
462
492
  `systemContext.windowHeight = ${config.config.windowArea?.height || 'this.params._layout_?.height'}`,
463
- `TaroNativeModule.initStylesheet('${genUniPageId(page)}', styleJson, initStyleSheetConfig({ width: systemContext.windowWidth, height: systemContext.windowHeight}, this.getNavHeight()))`,
493
+ ...(page instanceof Array ? [
494
+ ...page.map((p, i) => `TaroNativeModule.initStylesheet('${genUniPageId(p)}', styleJson${i}, initStyleSheetConfig({ width: systemContext.windowWidth, height: systemContext.windowHeight}, this.getNavHeight()))`),
495
+ ] : [
496
+ `TaroNativeModule.initStylesheet('${genUniPageId(page)}', styleJson, initStyleSheetConfig({ width: systemContext.windowWidth, height: systemContext.windowHeight}, this.getNavHeight()))`,
497
+ ]),
464
498
  ];
465
499
  if (!isPure) {
466
500
  appearCode.push('Current.$r = (path: string): Resource => {', ' return $r(path)', '}', 'let currentSplit = false', 'let pendingAreaChange: TaroAny', `const resizeFn = (canSplit: boolean, size: TaroAny, sizeChange: boolean) => {`, ` const _display = display.getDefaultDisplaySync()`, ` const orientation = _display.orientation`, ` const idPortrait = orientation == display.Orientation.PORTRAIT || orientation == display.Orientation.PORTRAIT_INVERTED`, ` const _sysInfo: TaroAny = getSystemInfoSync()`, ` callFn(this.page?.onResize, this, {`, ` size: {`,
467
501
  // @ts-ignore
468
502
  ` windowWidth: ${config.config.windowArea?.width || 'size?.width'},`,
469
503
  // @ts-ignore
470
- ` windowHeight: ${config.config.windowArea?.height || 'size?.height'},`, ` screenWidth: _sysInfo.screenWidth,`, ` screenHeight: _sysInfo.screenHeight,`, ` },`, ` deviceOrientation: idPortrait ? "portrait" : "landscape",`, ` foldDisplayMode: _sysInfo.foldDisplayMode,`, ` canSplit: canSplit,`, ` reason: sizeChange ? "size" : "statusBar"`, ` })`, `}`, `const avoidAreaChange = (res: TaroAny) => {`, ` const statusHeight: number = px2vp(res.area.topRect.height);`, ` this.statusBarHeight = statusHeight;`, ` TaroNativeModule.UpdateEnvRule('${genUniPageId(page)}', initStyleSheetConfig({ width: this.__layoutSize.width, height: this.__layoutSize.height}, this.getNavHeight()), this.node?._nid)`, ` resizeFn(currentSplit, this.__layoutSize, false)`, `}`, `const windowStage: TaroAny = AppStorage.get(WINDOW_STATE);`, 'this.areaChange = (res: TaroAny) => {', ' if (res.type !== oh_window.AvoidAreaType.TYPE_SYSTEM) return;', ' if (!this.isShown) {', ' pendingAreaChange = () => { avoidAreaChange(res) }', ' } else {', ' avoidAreaChange(res)', ' }', '}', `windowStage.getMainWindowSync().on('avoidAreaChange', this.areaChange)`);
504
+ ` windowHeight: ${config.config.windowArea?.height || 'size?.height'},`, ` screenWidth: _sysInfo.screenWidth,`, ` screenHeight: _sysInfo.screenHeight,`, ` },`, ` deviceOrientation: idPortrait ? "portrait" : "landscape",`, ` foldDisplayMode: _sysInfo.foldDisplayMode,`, ` canSplit: canSplit,`, ` reason: sizeChange ? "size" : "statusBar"`, ` })`, `}`, `const avoidAreaChange = (res: TaroAny) => {`, ` const statusHeight: number = px2vp(res.area.topRect.height)`, ...(page instanceof Array
505
+ ? [
506
+ ` this.statusBarHeight = this.statusBarHeight.map(() => statusHeight)`,
507
+ ` this.node.forEach((item: TaroAny, i) => {`,
508
+ ` if (item?._nid) {`,
509
+ ` TaroNativeModule.UpdateEnvRule('${getProjectId()}:' + this.__pageName[i], initStyleSheetConfig({ width: this.__layoutSize.width, height: this.__layoutSize.height}, this.getNavHeight()), item._nid)`,
510
+ ` }`,
511
+ ` })`
512
+ ]
513
+ : [
514
+ ` this.statusBarHeight = statusHeight`,
515
+ ` TaroNativeModule.UpdateEnvRule('${genUniPageId(page)}', initStyleSheetConfig({ width: this.__layoutSize.width, height: this.__layoutSize.height}, this.getNavHeight()), this.node?._nid)`,
516
+ ]), ` resizeFn(currentSplit, this.__layoutSize, false)`, `}`, `const windowStage: TaroAny = AppStorage.get(WINDOW_STATE)`, 'this.areaChange = (res: TaroAny) => {', ' if (res.type !== oh_window.AvoidAreaType.TYPE_SYSTEM) return', ' if (!this.isShown) {', ' pendingAreaChange = () => { avoidAreaChange(res) }', ' } else {', ' avoidAreaChange(res)', ' }', '}', `windowStage.getMainWindowSync().on('avoidAreaChange', this.areaChange)`);
471
517
  }
472
518
  appearCode.push(appearStr);
473
519
  return this.transArr2Str(appearCode.filter(Boolean));
@@ -477,7 +523,7 @@ function pagePlugin () {
477
523
  `this.handlePageDetach()`,
478
524
  'this.deactivateAudioSession()',
479
525
  'if (this.areaChange) {',
480
- ' const windowStage: TaroAny = AppStorage.get(WINDOW_STATE);',
526
+ ' const windowStage: TaroAny = AppStorage.get(WINDOW_STATE)',
481
527
  ` windowStage.getMainWindowSync().off('avoidAreaChange', this.areaChange)`,
482
528
  '}'
483
529
  ]);
@@ -485,8 +531,15 @@ function pagePlugin () {
485
531
  config.modifyPageBuild = function (_, page) {
486
532
  const coreBuildCodeArray = [
487
533
  'Stack() {',
488
- ' if (this.isReady) {',
489
- ' TaroXComponent({ pageId: (this.node as TaroAny)?._nid, data: this.nodeContent })',
534
+ ...(this.isTabbarPage
535
+ ? [
536
+ ' if (this.isReady[index]) {',
537
+ ' TaroXComponent({ pageId: (this.node[index] as TaroAny)?._nid, data: this.nodeContent[index] })',
538
+ ]
539
+ : [
540
+ ' if (this.isReady) {',
541
+ ' TaroXComponent({ pageId: (this.node as TaroAny)?._nid, data: this.nodeContent })',
542
+ ]),
490
543
  ' }',
491
544
  '}',
492
545
  '.align(Alignment.TopStart)',
@@ -497,7 +550,9 @@ function pagePlugin () {
497
550
  '.onDetach(this.handlePageDetach)',
498
551
  ];
499
552
  if (!isPureComp(page)) {
500
- coreBuildCodeArray.push('.backgroundColor(this.pageBackgroundContentColor || this.pageBackgroundColor || "#FFFFFF")');
553
+ coreBuildCodeArray.push(this.isTabbarPage
554
+ ? '.backgroundColor(this.pageBackgroundContentColor[index] || this.pageBackgroundColor[index] || "#FFFFFF")'
555
+ : '.backgroundColor(this.pageBackgroundContentColor || this.pageBackgroundColor || "#FFFFFF")');
501
556
  if (this.enableRefresh === 1) {
502
557
  coreBuildCodeArray.forEach((code, idx) => coreBuildCodeArray.splice(idx, 1, `${' '.repeat(2)}${code}`));
503
558
  coreBuildCodeArray.unshift('Refresh({', ' refreshing: $$this.isRefreshing,', ' builder: this.customRefreshBuilder()', '}) {');
@@ -505,10 +560,17 @@ function pagePlugin () {
505
560
  }
506
561
  coreBuildCodeArray.forEach((code, idx) => coreBuildCodeArray.splice(idx, 1, `${' '.repeat(2)}${code}`));
507
562
  coreBuildCodeArray.unshift('Navigation() {');
508
- coreBuildCodeArray.push('}', `.backgroundColor(this.pageBackgroundColor || '${this.appConfig?.window?.backgroundColor || '#FFFFFF'}')`, `.height('100%')`, `.width('100%')`, `.title({ builder: this.renderTitle, height: this.getNavHeight() })`, `.titleMode(NavigationTitleMode.Mini)`, `.hideTitleBar(this.isHideTitleBar)`, `.hideBackButton(true)`,
563
+ coreBuildCodeArray.push('}', this.isTabbarPage
564
+ ? `.backgroundColor(this.pageBackgroundColor[index] || '${this.appConfig?.window?.backgroundColor || '#FFFFFF'}')`
565
+ : `.backgroundColor(this.pageBackgroundColor || '${this.appConfig?.window?.backgroundColor || '#FFFFFF'}')`, `.height('100%')`, `.width('100%')`, `.title({ builder: this.renderTitle, height: this.getNavHeight() })`, `.titleMode(NavigationTitleMode.Mini)`, this.isTabbarPage ? `.hideTitleBar(this.isHideTitleBar[index])` : `.hideTitleBar(this.isHideTitleBar)`, `.hideBackButton(true)`,
509
566
  // `.expandSafeArea([SafeAreaType.SYSTEM])`,
510
567
  `.mode(NavigationMode.Stack)`);
511
568
  }
569
+ if (this.isTabbarPage) {
570
+ coreBuildCodeArray.forEach((code, idx) => coreBuildCodeArray.splice(idx, 1, `${' '.repeat(6)}${code}`));
571
+ coreBuildCodeArray.unshift('Tabs({', ` barPosition: this.tabBarPosition !== 'top' ? BarPosition.End : BarPosition.Start,`, ' controller: this.tabBarController,', ' index: this.tabBarCurrentIndex,', '}) {', ' ForEach(this.tabBarList, (item: ITabBarItem, index) => {', ' TabContent() {');
572
+ coreBuildCodeArray.push(` }.tabBar(this.renderTabItemBuilder(index, item))`, ` }, (item: ITabBarItem, index) => \`\${item.key || index}\`)`, `}`, `.vertical(false)`, `.barMode(BarMode.Fixed)`, `.barHeight(this.isTabBarShow ? 56 : 0)`, `.animationDuration(this.tabBarAnimationDuration)`, `.onChange((index: number) => {`, ` if (this.tabBarCurrentIndex !== index) {`, ` callFn(this.page?.onHide, this)`, ` this.setTabBarCurrentIndex(index)`, ` }`, ` this.handlePageAppear()`, ` callFn(this.page?.onShow, this)`, `})`, `.backgroundColor(this.tabBarBackgroundColor)`, `.padding({`, ` bottom: px2vp(sysInfo.screenHeight - (sysInfo.safeArea?.bottom || 0)),`, `})`);
573
+ }
512
574
  return this.transArr2Str(coreBuildCodeArray);
513
575
  };
514
576
  config.modifyPageMethods = function (methods, page$1) {
@@ -517,11 +579,18 @@ function pagePlugin () {
517
579
  if (handlePageAppearMethods) {
518
580
  const methodsBodyList = handlePageAppearMethods.body?.split('\n') || [];
519
581
  let insertIndex = methodsBodyList.findIndex((item) => item.startsWith('const params'));
520
- insertIndex = methodsBodyList.findIndex((item) => item.includes('this.node = instance'));
582
+ if (this.isTabbarPage) {
583
+ insertIndex = methodsBodyList.findIndex((item) => item.includes('this.node[index] = instance'));
584
+ }
585
+ else {
586
+ insertIndex = methodsBodyList.findIndex((item) => item.includes('this.node = instance'));
587
+ }
521
588
  if (insertIndex >= 0) {
522
589
  methodsBodyList?.splice(insertIndex + 1, 0, ...[
523
- ' TaroNativeModule.buildTaroNode(this.nodeContent, instance._nid)',
524
- ' this.isReady = true',
590
+ this.isTabbarPage
591
+ ? ' TaroNativeModule.buildTaroNode(this.nodeContent[index], instance._nid)'
592
+ : ' TaroNativeModule.buildTaroNode(this.nodeContent, instance._nid)',
593
+ this.isTabbarPage ? ' this.isReady[index] = true' : ' this.isReady = true',
525
594
  isPure ? ` this.currentRouter = Current.router` : null,
526
595
  isPure ? ` eventCenter.on(this.currentRouter?.getEventName('onResize') || '', this.handlePageResizeEvent)` : null,
527
596
  ].filter(shared.isString));
@@ -552,15 +621,17 @@ function pagePlugin () {
552
621
  });
553
622
  methods.unshift({
554
623
  name: 'getNavHeight',
555
- body: 'return this.isHideTitleBar ? 0 : 48 + this.statusBarHeight',
624
+ body: this.isTabbarPage
625
+ ? 'return this.isHideTitleBar[this.tabBarCurrentIndex] ? 0 : 48 + this.statusBarHeight[this.tabBarCurrentIndex]'
626
+ : 'return this.isHideTitleBar ? 0 : 48 + this.statusBarHeight',
556
627
  });
557
628
  methods.push({
558
629
  name: 'handlePageDetach',
559
630
  type: 'arrow',
560
631
  body: this.transArr2Str([
561
- `if (!this.isReady) return`,
632
+ this.isTabbarPage ? `if (!this.isReady[this.tabBarCurrentIndex]) return` : `if (!this.isReady) return`,
562
633
  '',
563
- `this.isReady = false`,
634
+ this.isTabbarPage ? `this.isReady[this.tabBarCurrentIndex] = false` : `this.isReady = false`,
564
635
  isPure
565
636
  ? `eventCenter.off(this.currentRouter?.getEventName('onResize'), this.handlePageResizeEvent)`
566
637
  : null,
@@ -928,10 +999,20 @@ function stylePlugin () {
928
999
  }
929
1000
  const { outputRoot = 'dist', sourceRoot = 'src' } = this.buildConfig;
930
1001
  const targetRoot = path.resolve(this.appPath, sourceRoot);
931
- const styleName = `${page.originName}_style.json`;
932
- const styleJsonPath = path.resolve(targetRoot, styleName);
933
- importStr.push(`import styleJson from "${styleJsonPath}"`);
934
- PageMap.set(path.resolve(outputRoot, styleName), pluginContext.getModuleInfo(page.id));
1002
+ if (page instanceof Array) {
1003
+ page.forEach((p, i) => {
1004
+ const styleName = `${p.originName}_style.json`;
1005
+ const styleJsonPath = path.resolve(targetRoot, styleName);
1006
+ importStr.push(`import styleJson${i} from "${styleJsonPath}"`);
1007
+ PageMap.set(path.resolve(outputRoot, styleName), pluginContext.getModuleInfo(p.id));
1008
+ });
1009
+ }
1010
+ else {
1011
+ const styleName = `${page.originName}_style.json`;
1012
+ const styleJsonPath = path.resolve(targetRoot, styleName);
1013
+ importStr.push(`import styleJson from "${styleJsonPath}"`);
1014
+ PageMap.set(path.resolve(outputRoot, styleName), pluginContext.getModuleInfo(page.id));
1015
+ }
935
1016
  };
936
1017
  };
937
1018
  compiler?.pages?.forEach?.(modifyPageOrComp);
@@ -1127,10 +1208,9 @@ class Harmony extends dist.HarmonyOS_ArkTS {
1127
1208
  /* eslint-disable no-console */
1128
1209
  const argProjectPath = getProcessArg('lib');
1129
1210
  const argHapName = getProcessArg('hap');
1130
- const staticDirname = 'static';
1131
1211
  let harName = `${PKG_NAME}-${PKG_VERSION}.har`;
1132
- if (!helper.fs.existsSync(path.join(__dirname, '..', staticDirname, harName))) {
1133
- harName = require('fast-glob').sync('**/*.har', { cwd: path.join(__dirname, '..', staticDirname) })[0] || '';
1212
+ if (!helper.fs.existsSync(path.join(__dirname, '..', STATIC_FOLDER_NAME, harName))) {
1213
+ harName = require('fast-glob').sync('**/*.har', { cwd: path.join(__dirname, '..', STATIC_FOLDER_NAME) })[0] || '';
1134
1214
  }
1135
1215
  var index = (ctx, options = {}) => {
1136
1216
  options.useChoreLibrary = options.useChoreLibrary ?? 'local';
@@ -1207,11 +1287,11 @@ var index = (ctx, options = {}) => {
1207
1287
  }
1208
1288
  }
1209
1289
  else if (options.useChoreLibrary === 'local' && harName) {
1210
- const harPath = path.join(argProjectPath || projectPath, staticDirname, harName);
1290
+ const harPath = path.join(argProjectPath || projectPath, STATIC_FOLDER_NAME, harName);
1211
1291
  const harDir = path.dirname(harPath);
1212
1292
  helper.fs.ensureDirSync(harDir);
1213
1293
  helper.fs.emptyDirSync(harDir);
1214
- helper.fs.copyFileSync(path.join(program.harmonyCppPluginPath, staticDirname, harName), harPath);
1294
+ helper.fs.copyFileSync(path.join(program.harmonyCppPluginPath, STATIC_FOLDER_NAME, harName), harPath);
1215
1295
  }
1216
1296
  }
1217
1297
  });
@@ -1233,4 +1313,5 @@ function assertHarmonyConfig(ctx, config) {
1233
1313
  }
1234
1314
  }
1235
1315
 
1316
+ exports.HarmonyCPP = Harmony;
1236
1317
  exports.default = index;