Skip to content

Commit

Permalink
refactor: use *.manifest instead of manifest.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
MaikoTan committed Dec 5, 2024
1 parent 7ea3dfe commit 3379686
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const rules = {
{
'caseSensitive': true,
'ignore': [
'.*manifest\\.txt$',
'.*\\.manifest$',
],
},
],
Expand Down
4 changes: 2 additions & 2 deletions types/manifest.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
declare module '*/raidboss_manifest.txt' {
declare module 'raidboss.manifest' {
const raidbossFileData: import('./trigger').RaidbossFileData;
export default raidbossFileData;
}

declare module '*/oopsy_manifest.txt' {
declare module 'oopsy.manifest' {
const oopsyFileData: import('./oopsy').OopsyFileData;
export default oopsyFileData;
}
3 changes: 2 additions & 1 deletion ui/oopsyraidsy/oopsy_viewer.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import oopsyFileData from 'oopsy.manifest';

import { UnreachableCode } from '../../resources/not_reached';
import { callOverlayHandler } from '../../resources/overlay_plugin_api';
import PartyTracker from '../../resources/party';
import UserConfig from '../../resources/user_config';
import { LocaleText } from '../../types/trigger';

import { DamageTracker, earlyPullTriggerId } from './damage_tracker';
import oopsyFileData from './data/oopsy_manifest.txt';
import { MistakeCollector } from './mistake_collector';
import defaultOptions, { OopsyOptions } from './oopsy_options';
import { OopsySummaryList, OopsySummaryTable } from './oopsy_summary_list';
Expand Down
3 changes: 2 additions & 1 deletion ui/oopsyraidsy/oopsyraidsy.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import oopsyFileData from 'oopsy.manifest';

import { UnreachableCode } from '../../resources/not_reached';
import { addOverlayListener, callOverlayHandler } from '../../resources/overlay_plugin_api';
import PartyTracker from '../../resources/party';
import UserConfig from '../../resources/user_config';
import { OopsyMistakeType } from '../../types/oopsy';

import { DamageTracker } from './damage_tracker';
import oopsyFileData from './data/oopsy_manifest.txt';
import { MistakeCollector } from './mistake_collector';
import { OopsyLiveList } from './oopsy_live_list';
import defaultOptions from './oopsy_options';
Expand Down
3 changes: 2 additions & 1 deletion ui/oopsyraidsy/oopsyraidsy_config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import oopsyFileData from 'oopsy.manifest';

import { UnreachableCode } from '../../resources/not_reached';
import UserConfig, { OptionsTemplate, UserFileCallback } from '../../resources/user_config';
import { BaseOptions } from '../../types/data';
Expand All @@ -10,7 +12,6 @@ import {
} from '../config/config';

import { generateBuffTriggerIds } from './buff_map';
import oopsyFileData from './data/oopsy_manifest.txt';
import { OopsyOptions } from './oopsy_options';

const oopsyHelpers: (keyof LooseOopsyTriggerSet)[] = [
Expand Down
3 changes: 2 additions & 1 deletion ui/raidboss/emulator/data/AnalyzedEncounter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import raidbossFileData from 'raidboss.manifest';

import { UnreachableCode } from '../../../../resources/not_reached';
import Util from '../../../../resources/util';
import { LooseTrigger } from '../../../../types/trigger';
import raidbossFileData from '../../data/raidboss_manifest.txt';
import { PopupTextGenerator, TriggerHelper } from '../../popup-text';
import { RaidbossOptions } from '../../raidboss_options';
import { TimelineLoader } from '../../timeline';
Expand Down
3 changes: 2 additions & 1 deletion ui/raidboss/raidboss.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import raidbossFileData from 'raidboss.manifest';

import { addOverlayListener } from '../../resources/overlay_plugin_api';
import { addRemotePlayerSelectUI } from '../../resources/player_override';
import UserConfig from '../../resources/user_config';

import raidbossFileData from './data/raidboss_manifest.txt';
import { HTMLTimelineUI } from './html_timeline_ui';
import { PopupText, PopupTextGenerator } from './popup-text';
import defaultOptions from './raidboss_options';
Expand Down
3 changes: 2 additions & 1 deletion ui/raidboss/raidboss_config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import raidbossFileData from 'raidboss.manifest';

import { isLang, Lang } from '../../resources/languages';
import { buildNetRegexForTrigger } from '../../resources/netregexes';
import { UnreachableCode } from '../../resources/not_reached';
Expand Down Expand Up @@ -32,7 +34,6 @@ import {
ConfigProcessedFileMap,
} from '../config/config';

import raidbossFileData from './data/raidboss_manifest.txt';
import { RaidbossTriggerField, RaidbossTriggerOutput } from './popup-text';
import raidbossOptions, { RaidbossOptions } from './raidboss_options';
import { TimelineParser } from './timeline_parser';
Expand Down
3 changes: 2 additions & 1 deletion ui/raidboss/raidemulator.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import raidbossFileData from 'raidboss.manifest';

import './raidboss_config';
import DTFuncs from '../../resources/datetime';
import { browserLanguagesToLang, Lang, langMap } from '../../resources/languages';
Expand All @@ -6,7 +8,6 @@ import { callOverlayHandler } from '../../resources/overlay_plugin_api';
import UserConfig from '../../resources/user_config';
import { ConverterWorkerMessage } from '../../types/worker';

import raidbossFileData from './data/raidboss_manifest.txt';
import AnalyzedEncounter from './emulator/data/AnalyzedEncounter';
import CombatantTracker from './emulator/data/CombatantTracker';
import Encounter from './emulator/data/Encounter';
Expand Down
8 changes: 4 additions & 4 deletions vite/manifest-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const recurseDir = (dir: string): string[] => {
});
};

const ignorePathRegexes = [/(?:^|\/)\w*_manifest\.txt$/, /(?:^|\/)readme\.\w*$/i];
const ignorePathRegexes = [/(?:^|\/)\w*\.manifest$/, /(?:^|\/)readme\.\w*$/i];

const findManifestFiles = (dir: string): string[] => {
const actualDir = fs.lstatSync(dir).isFile() ? path.dirname(dir) : dir;
Expand All @@ -41,7 +41,7 @@ export default function manifestLoader(
return [
...manifestFiles.map(({ dir, filename }) =>
virtual({
[`${cwd}/${dir}/${filename}`]: (() => {
[filename]: (() => {
const lines = findManifestFiles(dir);

let importStr = '';
Expand Down Expand Up @@ -84,13 +84,13 @@ export default function manifestLoader(
return {
name: 'timeline-loader',
resolveId(id) {
if (id.startsWith('timeline:') && id.endsWith('.txt') && !id.endsWith('manifest.txt')) {
if (id.startsWith('timeline:') && id.endsWith('.txt')) {
return `\0${id}`;
}
return null;
},
async load(id) {
if (id.startsWith(PREFIX) && id.endsWith('.txt') && !id.endsWith('manifest.txt')) {
if (id.startsWith(PREFIX) && id.endsWith('.txt')) {
const fsPath = id.slice(PREFIX.length);
const content = await readFile(fsPath, 'utf-8');
// watch the file for HMR
Expand Down
4 changes: 2 additions & 2 deletions vite/vite.config.base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ const config: UserConfig = {
],
}),
...manifestLoader([
{ dir: 'ui/raidboss/data', filename: 'raidboss_manifest.txt' },
{ dir: 'ui/oopsyraidsy/data', filename: 'oopsy_manifest.txt' },
{ dir: 'ui/raidboss/data', filename: 'raidboss.manifest' },
{ dir: 'ui/oopsyraidsy/data', filename: 'oopsy.manifest' },
]),
...(isCI ? [] : [checker({ typescript: true })]),
],
Expand Down

0 comments on commit 3379686

Please sign in to comment.