Skip to content

Commit

Permalink
(feat): replace the dynamic loader 'fs' with static requires for bett…
Browse files Browse the repository at this point in the history
…er cross compatibility with Bun/Deno (#802)
  • Loading branch information
alanbixby authored May 22, 2024
1 parent 1dba8d2 commit aa07a95
Showing 1 changed file with 187 additions and 16 deletions.
203 changes: 187 additions & 16 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,192 @@
const path = require('path')
const fs = require('fs')
const include = ['cache']

const noblox = {}

function search (dir) {
require('fs').readdirSync(dir).forEach(function (file) {
const stat = fs.statSync(path.join(dir, file))
if (stat.isFile() || include.indexOf(file) !== -1) {
noblox[file.replace('.js', '')] = require(dir + '/' + file)
} else if (stat.isDirectory()) {
search(path.join(dir, file))
}
})
}

search(__dirname)
noblox.getUserSocialLinks = require('./accountinformation/getUserSocialLinks.js')
noblox.block = require('./accountsettings/block.js')
noblox.unblock = require('./accountsettings/unblock.js')
noblox.deleteFromInventory = require('./asset/deleteFromInventory.js')
noblox.getGamePassProductInfo = require('./asset/getGamePassProductInfo.js')
noblox.getProductInfo = require('./asset/getProductInfo.js')
noblox.uploadAnimation = require('./asset/uploadAnimation.js')
noblox.uploadItem = require('./asset/uploadItem.js')
noblox.uploadModel = require('./asset/uploadModel.js')
noblox.avatarRules = require('./avatar/avatarRules.js')
noblox.currentlyWearing = require('./avatar/currentlyWearing.js')
noblox.getAvatar = require('./avatar/getAvatar.js')
noblox.getCurrentAvatar = require('./avatar/getCurrentAvatar.js')
noblox.getRecentItems = require('./avatar/getRecentItems.js')
noblox.outfitDetails = require('./avatar/outfitDetails.js')
noblox.outfits = require('./avatar/outfits.js')
noblox.redrawAvatar = require('./avatar/redrawAvatar.js')
noblox.removeAssetId = require('./avatar/removeAssetId.js')
noblox.setAvatarBodyColors = require('./avatar/setAvatarBodyColors.js')
noblox.setAvatarScales = require('./avatar/setAvatarScales.js')
noblox.setPlayerAvatarType = require('./avatar/setPlayerAvatarType.js')
noblox.setWearingAssets = require('./avatar/setWearingAssets.js')
noblox.wearAssetId = require('./avatar/wearAssetId.js')
noblox.getAwardedTimestamps = require('./badges/getAwardedTimestamps.js')
noblox.getBadgeInfo = require('./badges/getBadgeInfo.js')
noblox.getGameBadges = require('./badges/getGameBadges.js')
noblox.getPlayerBadges = require('./badges/getPlayerBadges.js')
noblox.updateBadgeInfo = require('./badges/updateBadgeInfo.js')
noblox.addUsersToConversation = require('./chat/addUsersToConversation.js')
noblox.chatSettings = require('./chat/chatSettings.js')
noblox.getChatMessages = require('./chat/getChatMessages.js')
noblox.getConversations = require('./chat/getConversations.js')
noblox.getRolloutSettings = require('./chat/getRolloutSettings.js')
noblox.getUnreadConversationCount = require('./chat/getUnreadConversationCount.js')
noblox.getUnreadMessages = require('./chat/getUnreadMessages.js')
noblox.getUserConversations = require('./chat/getUserConversations.js')
noblox.markChatAsRead = require('./chat/markChatAsRead.js')
noblox.markChatAsSeen = require('./chat/markChatAsSeen.js')
noblox.multiGetLatestMessages = require('./chat/multiGetLatestMessages.js')
noblox.onNewConversation = require('./chat/onNewConversation.js')
noblox.onNewMessage = require('./chat/onNewMessage.js')
noblox.onNewMessageBySelf = require('./chat/onNewMessageBySelf.js')
noblox.onUserOnline = require('./chat/onUserOnline.js')
noblox.onUserTyping = require('./chat/onUserTyping.js')
noblox.removeFromGroupConversation = require('./chat/removeFromGroupConversation.js')
noblox.renameGroupConversation = require('./chat/renameGroupConversation.js')
noblox.sendChatMessage = require('./chat/sendChatMessage.js')
noblox.setChatUserTyping = require('./chat/setChatUserTyping.js')
noblox.start121Conversation = require('./chat/start121Conversation.js')
noblox.startCloudEditConversation = require('./chat/startCloudEditConversation.js')
noblox.startGroupConversation = require('./chat/startGroupConversation.js')
noblox.onNotification = require('./client/onNotification.js')
noblox.setAPIKey = require('./client/setAPIKey.js')
noblox.setCookie = require('./client/setCookie.js')
noblox.deleteDatastoreEntry = require('./datastores/deleteDatastoreEntry.js')
noblox.getDatastoreEntry = require('./datastores/getDatastoreEntry.js')
noblox.getDatastoreEntryVersions = require('./datastores/getDatastoreEntryVersions.js')
noblox.getDatastoreKeys = require('./datastores/getDatastoreKeys.js')
noblox.getDatastores = require('./datastores/getDatastores.js')
noblox.incrementDatastoreEntry = require('./datastores/incrementDatastoreEntry.js')
noblox.setDatastoreEntry = require('./datastores/setDatastoreEntry.js')
noblox.canManage = require('./develop/canManage.js')
noblox.configureItem = require('./develop/configureItem.js')
noblox.updateUniverse = require('./develop/updateUniverse.js')
noblox.updateUniverseAccess = require('./develop/updateUniverseAccess.js')
noblox.buy = require('./economy/buy.js')
noblox.getGroupFunds = require('./economy/getGroupFunds.js')
noblox.getGroupRevenueSummary = require('./economy/getGroupRevenueSummary.js')
noblox.getGroupTransactions = require('./economy/getGroupTransactions.js')
noblox.getResaleData = require('./economy/getResaleData.js')
noblox.getResellers = require('./economy/getResellers.js')
noblox.getUserTransactions = require('./economy/getUserTransactions.js')
noblox.onGroupTransaction = require('./economy/onGroupTransaction.js')
noblox.acceptFriendRequest = require('./friends/acceptFriendRequest.js')
noblox.declineAllFriendRequests = require('./friends/declineAllFriendRequests.js')
noblox.declineFriendRequest = require('./friends/declineFriendRequest.js')
noblox.getFollowers = require('./friends/getFollowers.js')
noblox.getFollowings = require('./friends/getFollowings.js')
noblox.getFriendRequests = require('./friends/getFriendRequests.js')
noblox.getFriends = require('./friends/getFriends.js')
noblox.onFriendRequest = require('./friends/onFriendRequest.js')
noblox.removeFriend = require('./friends/removeFriend.js')
noblox.sendFriendRequest = require('./friends/sendFriendRequest.js')
noblox.unfollow = require('./friends/unfollow.js')
noblox.addDeveloperProduct = require('./games/addDeveloperProduct.js')
noblox.checkDeveloperProductName = require('./games/checkDeveloperProductName.js')
noblox.configureGamePass = require('./games/configureGamePass.js')
noblox.getDeveloperProducts = require('./games/getDeveloperProducts.js')
noblox.getGameInstances = require('./games/getGameInstances.js')
noblox.getGamePasses = require('./games/getGamePasses.js')
noblox.getGameRevenue = require('./games/getGameRevenue.js')
noblox.getGameSocialLinks = require('./games/getGameSocialLinks.js')
noblox.getGroupGames = require('./games/getGroupGames.js')
noblox.getPlaceInfo = require('./games/getPlaceInfo.js')
noblox.getUniverseInfo = require('./games/getUniverseInfo.js')
noblox.updateDeveloperProduct = require('./games/updateDeveloperProduct.js')
noblox.changeRank = require('./groups/changeRank.js')
noblox.deleteWallPost = require('./groups/deleteWallPost.js')
noblox.deleteWallPostsByUser = require('./groups/deleteWallPostsByUser.js')
noblox.demote = require('./groups/demote.js')
noblox.exile = require('./groups/exile.js')
noblox.getAuditLog = require('./groups/getAuditLog.js')
noblox.getGroup = require('./groups/getGroup.js')
noblox.getGroupSocialLinks = require('./groups/getGroupSocialLinks.js')
noblox.getGroups = require('./groups/getGroups.js')
noblox.getJoinRequest = require('./groups/getJoinRequest.js')
noblox.getJoinRequests = require('./groups/getJoinRequests.js')
noblox.getPlayers = require('./groups/getPlayers.js')
noblox.getRankInGroup = require('./groups/getRankInGroup.js')
noblox.getRankNameInGroup = require('./groups/getRankNameInGroup.js')
noblox.getRole = require('./groups/getRole.js')
noblox.getRolePermissions = require('./groups/getRolePermissions.js')
noblox.getRoles = require('./groups/getRoles.js')
noblox.getShout = require('./groups/getShout.js')
noblox.getWall = require('./groups/getWall.js')
noblox.groupPayout = require('./groups/groupPayout.js')
noblox.handleJoinRequest = require('./groups/handleJoinRequest.js')
noblox.leaveGroup = require('./groups/leaveGroup.js')
noblox.onAuditLog = require('./groups/onAuditLog.js')
noblox.onJoinRequest = require('./groups/onJoinRequest.js')
noblox.onJoinRequestHandle = require('./groups/onJoinRequestHandle.js')
noblox.onShout = require('./groups/onShout.js')
noblox.onWallPost = require('./groups/onWallPost.js')
noblox.promote = require('./groups/promote.js')
noblox.searchGroups = require('./groups/searchGroups.js')
noblox.setGroupDescription = require('./groups/setGroupDescription.js')
noblox.setGroupName = require('./groups/setGroupName.js')
noblox.setRank = require('./groups/setRank.js')
noblox.shout = require('./groups/shout.js')
noblox.index = require('./index.js')
noblox.levelOneCopy = require('./internal/levelOneCopy.js')
noblox.queue = require('./internal/queue.js')
noblox.timeout = require('./internal/timeout.js')
noblox.wrap = require('./internal/wrap.js')
noblox.getCollectibles = require('./inventory/getCollectibles.js')
noblox.getInventory = require('./inventory/getInventory.js')
noblox.getInventoryById = require('./inventory/getInventoryById.js')
noblox.getOwnership = require('./inventory/getOwnership.js')
noblox.getUAIDs = require('./inventory/getUAIDs.js')
noblox.getGroupAssets = require('./itemconfiguration/getGroupAssets.js')
noblox.options = require('./options.js')
noblox.onPartyDeleted = require('./party/onPartyDeleted.js')
noblox.onPartyInvite = require('./party/onPartyInvite.js')
noblox.onPartyJoinedGame = require('./party/onPartyJoinedGame.js')
noblox.onPartyLeftGame = require('./party/onPartyLeftGame.js')
noblox.onPartySelfJoined = require('./party/onPartySelfJoined.js')
noblox.onPartySelfLeft = require('./party/onPartySelfLeft.js')
noblox.onPartyUserJoined = require('./party/onPartyUserJoined.js')
noblox.onPartyUserLeft = require('./party/onPartyUserLeft.js')
noblox.getPremium = require('./premiumfeatures/getPremium.js')
noblox.getPresences = require('./presence/getPresences.js')
noblox.getMessages = require('./privatemessages/getMessages.js')
noblox.message = require('./privatemessages/message.js')
noblox.onMessage = require('./privatemessages/onMessage.js')
noblox.getLogo = require('./thumbnails/getLogo.js')
noblox.getPlayerThumbnail = require('./thumbnails/getPlayerThumbnail.js')
noblox.getThumbnails = require('./thumbnails/getThumbnails.js')
noblox.acceptTrade = require('./trades/acceptTrade.js')
noblox.canTradeWith = require('./trades/canTradeWith.js')
noblox.counterTrade = require('./trades/counterTrade.js')
noblox.declineTrade = require('./trades/declineTrade.js')
noblox.getTradeInfo = require('./trades/getTradeInfo.js')
noblox.getTrades = require('./trades/getTrades.js')
noblox.sendTrade = require('./trades/sendTrade.js')
noblox.getBlurb = require('./users/getBlurb.js')
noblox.getIdFromUsername = require('./users/getIdFromUsername.js')
noblox.getPlayerInfo = require('./users/getPlayerInfo.js')
noblox.getUsernameFromId = require('./users/getUsernameFromId.js')
noblox.onBlurbChange = require('./users/onBlurbChange.js')
noblox.clearSession = require('./util/clearSession.js')
noblox.generalRequest = require('./util/generalRequest.js')
noblox.getAction = require('./util/getAction.js')
noblox.getCurrentUser = require('./util/getCurrentUser.js')
noblox.getGeneralToken = require('./util/getGeneralToken.js')
noblox.getHash = require('./util/getHash.js')
noblox.getInputs = require('./util/getInputs.js')
noblox.getPageResults = require('./util/getPageResults.js')
noblox.getSenderUserId = require('./util/getSenderUserId.js')
noblox.getSession = require('./util/getSession.js')
noblox.getVerification = require('./util/getVerification.js')
noblox.getVerificationInputs = require('./util/getVerificationInputs.js')
noblox.http = require('./util/http.js')
noblox.jar = require('./util/jar.js')
noblox.refreshCookie = require('./util/refreshCookie.js')
noblox.relog = require('./util/relog.js')
noblox.setOptions = require('./util/setOptions.js')
noblox.shortPoll = require('./util/shortPoll.js')

for (const name in noblox) {
const exporter = noblox[name]
Expand Down

0 comments on commit aa07a95

Please sign in to comment.