Commit graph

127 commits

Author SHA1 Message Date
PalmDevs
bd214823d4
fix(lib/modules/finders/get): correct types for getModules with options 2025-09-10 00:52:58 +07:00
PalmDevs
790c30a6d5
fix: debug build flags 2025-09-04 01:29:18 +07:00
PalmDevs
54c6a2ffdd
fix(lib/modules/finders/filters): correctly generate key for relative.withDependencies 2025-09-04 01:29:18 +07:00
PalmDevs
d5a7ab6d7b
fix(lib/modules/finders): early return if non-dynamic filter used on uninitialized module 2025-09-04 01:29:17 +07:00
Palm
5f5fc6f2b2
feat!: module finders refactor (#6)
- Renamed `byX` filters to `withX`.
  It is more correct. For example: You don't lookup, wait for, or get modules **BY** props. You lookup, wait for, and get modules **WITH** props.
- Renamed `*byImportedPath` to `*withImportedPath`
  For consistency with the above change.
- Renamed `getModule` to `getModules`.
  The API allows getting multiple modules and not just a single one. Types are renamed as well.
  `getModuleByImportedPath` remains the same as it only gets one single module with a unique imported path.
- `withX` filter **helpers** removed.
  They can now be replaced with the new capability-based `and` filter.
- `preferExports` and `moduleStateAware` filters removed.
  They can now be replaced with the new capability-based `and` filter.
- Composite finders renamed.
  `some` -> `or`, `every` -> `and`
- Composite finders takes a capability-based approach.
- Filter generators now need to attach runtime flag to let the system know whether the generated filter can be used to filter modules without proper exports or not.

## Misc.

- Removed useless unsub call in Profile Badges
- Use `queueMicrotask` with `asap`

# Features

## Capability-based approach to composite filters

```js
// Old
byProps(...).withDependencies(...)
// Old, same as: preferExports(byProps(...), byDependencies(...))
every(byDependencies(...), byProps(...))
// Old, ordering matters, this would fail unexpectedly!
every(byProps(...), byDependencies(...))

// New
withProps(...).and(withDependencies(...))
// New (as well), ordering doesn't matter, this has the same result as above
withDependencies(...).and(withProps(...))
```
2025-08-30 09:19:57 +07:00
Palm
2d9a791249
feat: fluent interface for finder filters (#5)
* feat(lib/modules/finders/filters): DSL-style filters implementation

* fix(lib/modules/finders/filters): extend helpers with `Function` proto

To not break compatibility with weird usages of existing filters. Allows using `apply`, `call`, etc.

* chore(lib/modules/finders/filters): add examples with helpers
2025-08-25 21:45:42 +07:00
PalmDevs
c33086435e
feat(lib/modules/finders/filters): deprecate undefined and allow null in byDependencies
`null` is more correct semantically (and also shorter to type). `undefined` should only be module IDs that cannot be found, in which case, a warning log has been added.
2025-08-25 21:22:06 +07:00
PalmDevs
63fd1938cf
feat(lib/modules): micro-optimizations + logic fixes
FIXES:
- `getInitializedModuleExports` now returns `undefined` correctly on uninitialized modules instead of empty objects.
- `NotFoundResult` for lookups is now a frozen array
- `lookupModuleByImportedPath` now returns `LookupNotFoundResult` as a union instead of `[]`

PERFORMANCE:
- Optimized Array checks with `byDependencies` filter
- Micro-optimized finders and filters
- `ModuleDefinition`s no longer allocate their `Module` object immediately after defined
2025-08-22 02:32:07 +07:00
PalmDevs
0d370638a5
chore(lib/modules/finders/filters): update key in docs for createFilterGenerator example 2025-08-20 17:28:15 +07:00
PalmDevs
913c987951
fix(lib/modules/finders/filters): generate proper keys for relative.withDependencies 2025-08-20 17:27:36 +07:00
PalmDevs
a0c03057b4
fix(lib/modules/types): correct definition for Metro.ModuleDefinition['publicModule'] 2025-08-19 21:48:38 +07:00
PalmDevs
4ed96c8512
fix(lib/modules/finders/wait): do not log matched cached waits in non-"debug wait" builds 2025-08-19 21:47:43 +07:00
PalmDevs
78ccd4286f
fix(lib/modules/native): match implementation with lastest changes 2025-08-17 03:46:59 +07:00
PalmDevs
b817178e8e
fix(lib/modules/finders/filters): type FilterGenerator without ts-expect-error 2025-08-17 00:56:27 +07:00
PalmDevs
e689976e28
feat(lib/modules/native): API for calling custom native methods 2025-08-17 00:55:42 +07:00
PalmDevs
d8b2d0302d
chore(lib/modules/finders/wait): use existing parameter for exports in waitForModuleByImportedPath 2025-08-13 21:38:02 +07:00
PalmDevs
c2d12321f6
chore(lib/modules): simplify imports 2025-08-13 01:27:49 +07:00
PalmDevs
e0c2ca7d6c
fix(lib/modules/native): getNativeModule should fallback to legacy if turbo module doesn't exist 2025-08-13 01:12:36 +07:00
PalmDevs
02c1c69abc
chore: cleanup 2025-08-09 02:12:29 +07:00
PalmDevs
934b25de08
chore(lib): make assignments more readable 2025-08-05 20:37:37 +07:00
PalmDevs
f1e94fe634
fix(lib/modules/finders/get): undefined unsub function on immediately found lookup 2025-08-03 14:17:47 +07:00
PalmDevs
ab41ec060f
fix(lib/modules/finders/wait): use exports from parameter in cached waits 2025-08-02 17:26:10 +07:00
PalmDevs
1c6da3a376
fix(lib/modules/metro): blacklist turbo modules properly 2025-08-02 17:25:40 +07:00
PalmDevs
3bb2203ff9
fix: get native modules in bridgeless correctly 2025-08-02 17:25:07 +07:00
PalmDevs
578b78dd7e
feat(lib/modules/finders/waits): cached-only waits 2025-07-31 19:15:08 +07:00
PalmDevs
c640a0e5a0
fix(lib/modules/metro/patches): make it work with inlineConst bundler option 2025-07-30 20:17:12 +07:00
PalmDevs
7d7d6a4358
feat(lib): small performance improvements 2025-07-27 17:07:50 +07:00
PalmDevs
3c6aa155ca
feat(lib): switch to typeof for better performance 2025-07-22 19:00:20 +07:00
PalmDevs
30c919a8a9
fix(lib/modules/finders/wait): waitForModuleByImportedPath exports always being bad 2025-07-21 21:28:34 +07:00
PalmDevs
00638ed845
feat(lib/modules/metro): switch to proper objects for storage 2025-07-18 23:43:59 +07:00
PalmDevs
96121e31e0
fix(lib/modules/finders/filters): simplify exports type is object checks 2025-07-18 01:55:16 +07:00
PalmDevs
79ce47c2bc
feat(lib/modules/metro): use Map for storing module dependencies for quicker access, rename file 2025-07-17 16:55:08 +07:00
PalmDevs
c949517e4a
fix(lib/modules/metro): mark module as initializing instead of optimistically marking as initialized during require 2025-07-13 19:22:15 +07:00
PalmDevs
874c074f1e
fix(lib/modules/finders): only run filter again if module is not blacklisted 2025-07-13 19:20:07 +07:00
PalmDevs
6a38136762
fix(lib)!: breaking changes
- Remove `noopFalse` from `@revenge-mod/utils/callback`
- Do not return result from unpatch/undo/unsub functions
- `onSettingsModulesLoaded` from `@revenge-mod/discord/modules/settings` now calls the callback immediately if settings modules are already loaded instead of throwing
2025-07-13 15:53:44 +07:00
PalmDevs
4b2a612374
chore(lib/utils): do not pluralize submodules 2025-07-11 17:33:06 +07:00
PalmDevs
fe97059933
feat(lib/modules): cache blacklisted modules 2025-07-11 17:15:49 +07:00
PalmDevs
f05885e559
feat(lib/modules/metro): blacklist primitives and empty objects for finders 2025-07-11 15:59:35 +07:00
PalmDevs
c66dace21b
chore: cleanup questionable code 2025-07-11 15:53:12 +07:00
PalmDevs
f824778519
fix(lib/modules/metro): improve performance by preallocating 2025-07-11 01:11:06 +07:00
PalmDevs
796f1cf392
feat(lib/modules/metro): patch all primitives to improve perf 2025-07-09 19:08:28 +07:00
PalmDevs
9560a8320b
feat(lib/modules/metro)!: more performance wins 2025-07-09 01:28:44 +07:00
PalmDevs
7645bfdf61
chore: new DEBUG_WAITS build flag, improve DBEUG_LOOKUPS build flag logs, other dev env fixes 2025-07-08 11:24:48 +07:00
PalmDevs
e9fedc8db4
feat: small performance wins
- Delay initializing unimportant parts until index module (ID 0) is required
- Lower memory usage by interacting with Metro's internal module list directly
2025-07-07 20:00:20 +07:00
PalmDevs
c532f5c3fd
fix(lib/modules/metro/subscriptions): run catching subscriptions 2025-07-07 18:59:49 +07:00
PalmDevs
66d95a8c49
fix(lib/modules/finders): correct types for get and lookup 2025-07-05 14:16:37 +07:00
PalmDevs
075f33f6c6
chore: cleanup 2025-07-05 13:56:52 +07:00
PalmDevs
8a7529fdbd
fix(lib/modules/finders/lookup): fix builds with DEBUG_PROXIFIED_VALUES flag on 2025-07-04 22:15:36 +07:00
PalmDevs
c067dc520d
fix(lib/modules/finders): correct filtering logic for prod builds 2025-07-04 22:14:42 +07:00
PalmDevs
2cff8ebf07
feat(lib/modules)!: add new options for lookup finders, include prefix from finders options, make utils functions safe again 2025-07-04 21:38:37 +07:00