@rpg-engine/long-bow 0.8.225 → 0.8.227
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.
- package/dist/components/Marketplace/characterListingUtils.d.ts +3 -0
- package/dist/components/Spellbook/Spell.d.ts +1 -0
- package/dist/components/Store/hooks/useStoreCart.d.ts +1 -1
- package/dist/long-bow.cjs.development.js +75 -51
- package/dist/long-bow.cjs.development.js.map +1 -1
- package/dist/long-bow.cjs.production.min.js +1 -1
- package/dist/long-bow.cjs.production.min.js.map +1 -1
- package/dist/long-bow.esm.js +75 -51
- package/dist/long-bow.esm.js.map +1 -1
- package/package.json +2 -2
- package/src/components/Marketplace/CharacterListingForm.tsx +2 -3
- package/src/components/Marketplace/CharacterListingModal.tsx +7 -5
- package/src/components/Marketplace/MyCharacterListingsPanel.tsx +2 -4
- package/src/components/Marketplace/__test__/characterListingUtils.spec.ts +55 -0
- package/src/components/Marketplace/characterListingUtils.ts +38 -0
- package/src/components/Spellbook/Spell.tsx +5 -1
- package/src/components/Store/Store.tsx +1 -1
- package/src/components/Store/__test__/Store.spec.tsx +16 -0
- package/src/components/Store/__test__/useStoreCart.spec.tsx +98 -0
- package/src/components/Store/hooks/useStoreCart.ts +6 -4
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ICharacter } from '@rpg-engine/shared';
|
|
2
|
+
export declare const isCharacterEligibleForListing: (character: ICharacter) => boolean;
|
|
3
|
+
export declare const getEligibleCharactersForListing: (accountCharacters: ICharacter[], activeCharacterId?: string | undefined) => ICharacter[];
|
|
@@ -9,7 +9,7 @@ interface IUseStoreCart {
|
|
|
9
9
|
isCartOpen: boolean;
|
|
10
10
|
handleAddToCart: (item: IProductBlueprint, quantity: number, metadata?: Record<string, any>) => void;
|
|
11
11
|
handleRemoveFromCart: (itemKey: string) => void;
|
|
12
|
-
handlePurchase: (onPurchase: (purchase: IPurchase) =>
|
|
12
|
+
handlePurchase: (onPurchase: (purchase: IPurchase) => Promise<boolean>) => Promise<boolean>;
|
|
13
13
|
openCart: () => void;
|
|
14
14
|
closeCart: () => void;
|
|
15
15
|
getTotalItems: () => number;
|
|
@@ -13889,6 +13889,29 @@ var EmptyText = /*#__PURE__*/styled__default.span.withConfig({
|
|
|
13889
13889
|
componentId: "sc-1aiauep-17"
|
|
13890
13890
|
})(["font-family:'Press Start 2P',cursive !important;font-size:0.48rem !important;color:#71717a !important;text-transform:uppercase;letter-spacing:1px;"]);
|
|
13891
13891
|
|
|
13892
|
+
var toTimestamp = function toTimestamp(value) {
|
|
13893
|
+
if (!value) return 0;
|
|
13894
|
+
var timestamp = new Date(value).getTime();
|
|
13895
|
+
return Number.isFinite(timestamp) ? timestamp : 0;
|
|
13896
|
+
};
|
|
13897
|
+
var isCharacterEligibleForListing = function isCharacterEligibleForListing(character) {
|
|
13898
|
+
return !character.isListedForSale;
|
|
13899
|
+
};
|
|
13900
|
+
var getEligibleCharactersForListing = function getEligibleCharactersForListing(accountCharacters, activeCharacterId) {
|
|
13901
|
+
return accountCharacters.filter(isCharacterEligibleForListing).sort(function (left, right) {
|
|
13902
|
+
var leftIsActive = !!activeCharacterId && left._id === activeCharacterId;
|
|
13903
|
+
var rightIsActive = !!activeCharacterId && right._id === activeCharacterId;
|
|
13904
|
+
if (leftIsActive !== rightIsActive) {
|
|
13905
|
+
return leftIsActive ? 1 : -1;
|
|
13906
|
+
}
|
|
13907
|
+
var tradedAtDiff = toTimestamp(right.tradedAt) - toTimestamp(left.tradedAt);
|
|
13908
|
+
if (tradedAtDiff !== 0) {
|
|
13909
|
+
return tradedAtDiff;
|
|
13910
|
+
}
|
|
13911
|
+
return 0;
|
|
13912
|
+
});
|
|
13913
|
+
};
|
|
13914
|
+
|
|
13892
13915
|
var CharacterListingModal = function CharacterListingModal(_ref) {
|
|
13893
13916
|
var isOpen = _ref.isOpen,
|
|
13894
13917
|
onClose = _ref.onClose,
|
|
@@ -13913,10 +13936,10 @@ var CharacterListingModal = function CharacterListingModal(_ref) {
|
|
|
13913
13936
|
var stopPropagation = React.useCallback(function (e) {
|
|
13914
13937
|
e.stopPropagation();
|
|
13915
13938
|
}, []);
|
|
13939
|
+
var eligibleCharacters = React.useMemo(function () {
|
|
13940
|
+
return getEligibleCharactersForListing(accountCharacters, activeCharacterId);
|
|
13941
|
+
}, [accountCharacters, activeCharacterId]);
|
|
13916
13942
|
if (!isOpen) return null;
|
|
13917
|
-
var eligibleCharacters = accountCharacters.filter(function (c) {
|
|
13918
|
-
return !c.isListedForSale;
|
|
13919
|
-
});
|
|
13920
13943
|
var isActiveCharacter = function isActiveCharacter(c) {
|
|
13921
13944
|
return !!activeCharacterId && c._id === activeCharacterId;
|
|
13922
13945
|
};
|
|
@@ -14176,9 +14199,7 @@ var MyCharacterListingsPanel = function MyCharacterListingsPanel(_ref) {
|
|
|
14176
14199
|
enableHotkeys == null ? void 0 : enableHotkeys();
|
|
14177
14200
|
}
|
|
14178
14201
|
};
|
|
14179
|
-
var eligibleCount = accountCharacters.
|
|
14180
|
-
return !c.isListedForSale && !c.tradedAt;
|
|
14181
|
-
}).length;
|
|
14202
|
+
var eligibleCount = getEligibleCharactersForListing(accountCharacters).length;
|
|
14182
14203
|
return React__default.createElement(React__default.Fragment, null, delistingId && React__default.createElement(ConfirmModal, {
|
|
14183
14204
|
onClose: function onClose() {
|
|
14184
14205
|
setDelistingId(null);
|
|
@@ -14795,9 +14816,7 @@ var CharacterListingForm = function CharacterListingForm(_ref) {
|
|
|
14795
14816
|
var _useState = React.useState(false),
|
|
14796
14817
|
isModalOpen = _useState[0],
|
|
14797
14818
|
setIsModalOpen = _useState[1];
|
|
14798
|
-
var eligibleCount = accountCharacters.
|
|
14799
|
-
return !c.isListedForSale && !c.tradedAt;
|
|
14800
|
-
}).length;
|
|
14819
|
+
var eligibleCount = getEligibleCharactersForListing(accountCharacters).length;
|
|
14801
14820
|
return React__default.createElement(Wrapper$2, null, React__default.createElement(CharacterListingModal, {
|
|
14802
14821
|
isOpen: isModalOpen,
|
|
14803
14822
|
onClose: function onClose() {
|
|
@@ -16865,6 +16884,7 @@ var Spell = function Spell(_ref) {
|
|
|
16865
16884
|
charMagicLevel = _ref.charMagicLevel,
|
|
16866
16885
|
charSkillLevels = _ref.charSkillLevels,
|
|
16867
16886
|
onPointerUp = _ref.onPointerUp,
|
|
16887
|
+
onClick = _ref.onClick,
|
|
16868
16888
|
isSettingShortcut = _ref.isSettingShortcut,
|
|
16869
16889
|
spell = _ref.spell,
|
|
16870
16890
|
activeCooldown = _ref.activeCooldown;
|
|
@@ -16893,10 +16913,11 @@ var Spell = function Spell(_ref) {
|
|
|
16893
16913
|
height: '32px'
|
|
16894
16914
|
};
|
|
16895
16915
|
var IMAGE_SCALE = 2;
|
|
16916
|
+
var handleClick = onClick != null ? onClick : onPointerUp;
|
|
16896
16917
|
return React__default.createElement(SpellInfoWrapper, {
|
|
16897
16918
|
spell: spell
|
|
16898
16919
|
}, React__default.createElement(Container$J, {
|
|
16899
|
-
|
|
16920
|
+
onClick: handleClick == null ? void 0 : handleClick.bind(null, spellKey),
|
|
16900
16921
|
isSettingShortcut: isSettingShortcut && !disabled,
|
|
16901
16922
|
className: "spell"
|
|
16902
16923
|
}, disabled && React__default.createElement(Overlay$a, null, characterSkillLevel < requiredLevel ? "Low " + getSkillName(attribute || 'magic level') + " level" : manaCost > charMana && 'No mana'), React__default.createElement(SpellImage, null, activeCooldown && activeCooldown > 0 ? React__default.createElement("span", {
|
|
@@ -38159,30 +38180,48 @@ var useStoreCart = function useStoreCart() {
|
|
|
38159
38180
|
});
|
|
38160
38181
|
});
|
|
38161
38182
|
};
|
|
38162
|
-
var handlePurchase = function
|
|
38163
|
-
var
|
|
38164
|
-
|
|
38165
|
-
|
|
38166
|
-
|
|
38167
|
-
|
|
38168
|
-
|
|
38169
|
-
|
|
38170
|
-
|
|
38171
|
-
|
|
38172
|
-
|
|
38173
|
-
|
|
38174
|
-
|
|
38175
|
-
|
|
38176
|
-
|
|
38177
|
-
|
|
38178
|
-
|
|
38183
|
+
var handlePurchase = /*#__PURE__*/function () {
|
|
38184
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(onPurchase) {
|
|
38185
|
+
var purchaseUnits, purchase, success;
|
|
38186
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
38187
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
38188
|
+
case 0:
|
|
38189
|
+
purchaseUnits = cartItems.map(function (cartItem) {
|
|
38190
|
+
return {
|
|
38191
|
+
purchaseKey: cartItem.item.key,
|
|
38192
|
+
qty: cartItem.quantity,
|
|
38193
|
+
type: getPurchaseType(cartItem.item),
|
|
38194
|
+
name: cartItem.item.name,
|
|
38195
|
+
metadata: cartItem.metadata || cartItem.item.metadataConfig
|
|
38196
|
+
};
|
|
38197
|
+
});
|
|
38198
|
+
purchase = {
|
|
38199
|
+
_id: uuidv4(),
|
|
38200
|
+
userId: '1',
|
|
38201
|
+
status: 'pending',
|
|
38202
|
+
createdAt: new Date().toISOString(),
|
|
38203
|
+
updatedAt: new Date().toISOString(),
|
|
38204
|
+
purchases: purchaseUnits
|
|
38205
|
+
};
|
|
38206
|
+
_context2.next = 4;
|
|
38207
|
+
return onPurchase(purchase);
|
|
38208
|
+
case 4:
|
|
38209
|
+
success = _context2.sent;
|
|
38210
|
+
if (success && isMounted.current) {
|
|
38211
|
+
setCartItems([]);
|
|
38212
|
+
setIsCartOpen(false);
|
|
38213
|
+
}
|
|
38214
|
+
return _context2.abrupt("return", success);
|
|
38215
|
+
case 7:
|
|
38216
|
+
case "end":
|
|
38217
|
+
return _context2.stop();
|
|
38218
|
+
}
|
|
38219
|
+
}, _callee2);
|
|
38220
|
+
}));
|
|
38221
|
+
return function handlePurchase(_x4) {
|
|
38222
|
+
return _ref2.apply(this, arguments);
|
|
38179
38223
|
};
|
|
38180
|
-
|
|
38181
|
-
if (isMounted.current) {
|
|
38182
|
-
setCartItems([]);
|
|
38183
|
-
setIsCartOpen(false);
|
|
38184
|
-
}
|
|
38185
|
-
};
|
|
38224
|
+
}();
|
|
38186
38225
|
var openCart = function openCart() {
|
|
38187
38226
|
return setIsCartOpen(true);
|
|
38188
38227
|
};
|
|
@@ -40108,24 +40147,9 @@ var Store = function Store(_ref) {
|
|
|
40108
40147
|
cartItems: cartItems,
|
|
40109
40148
|
onRemoveFromCart: handleRemoveFromCartTracked,
|
|
40110
40149
|
onClose: closeCart,
|
|
40111
|
-
onPurchase: function () {
|
|
40112
|
-
|
|
40113
|
-
|
|
40114
|
-
while (1) switch (_context.prev = _context.next) {
|
|
40115
|
-
case 0:
|
|
40116
|
-
handleCartPurchase(_onPurchase);
|
|
40117
|
-
return _context.abrupt("return", true);
|
|
40118
|
-
case 2:
|
|
40119
|
-
case "end":
|
|
40120
|
-
return _context.stop();
|
|
40121
|
-
}
|
|
40122
|
-
}, _callee);
|
|
40123
|
-
}));
|
|
40124
|
-
function onPurchase() {
|
|
40125
|
-
return _onPurchase2.apply(this, arguments);
|
|
40126
|
-
}
|
|
40127
|
-
return onPurchase;
|
|
40128
|
-
}(),
|
|
40150
|
+
onPurchase: function onPurchase() {
|
|
40151
|
+
return handleCartPurchase(_onPurchase);
|
|
40152
|
+
},
|
|
40129
40153
|
atlasJSON: atlasJSON,
|
|
40130
40154
|
atlasIMG: atlasIMG,
|
|
40131
40155
|
onCheckoutStart: onCheckoutStart,
|