@edhspace/api 0.0.0-stage → 0.1.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.
- package/LICENSE +14 -0
- package/README.md +36 -2
- package/dist/chunk-HL56LR6P.cjs +311 -0
- package/dist/chunk-LBLXK5J2.js +311 -0
- package/dist/client-CSAi6AFj.d.ts +136 -0
- package/dist/client-DKX6ZfiJ.d.cts +136 -0
- package/dist/contracts-r8d4RACz.d.cts +474 -0
- package/dist/contracts-r8d4RACz.d.ts +474 -0
- package/dist/host.cjs +356 -0
- package/dist/host.d.cts +57 -0
- package/dist/host.d.ts +57 -0
- package/dist/host.js +356 -0
- package/dist/index.cjs +234 -0
- package/dist/index.d.cts +148 -0
- package/dist/index.d.ts +148 -0
- package/dist/index.js +234 -0
- package/dist/math.cjs +107 -0
- package/dist/math.d.cts +70 -0
- package/dist/math.d.ts +70 -0
- package/dist/math.js +107 -0
- package/dist/react.cjs +69 -0
- package/dist/react.d.cts +177 -0
- package/dist/react.d.ts +177 -0
- package/dist/react.js +69 -0
- package/package.json +76 -5
package/dist/math.d.cts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { j as ExtensionCard } from './contracts-r8d4RACz.cjs';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
declare function drawProbability(model: {
|
|
5
|
+
population: number;
|
|
6
|
+
successes: number;
|
|
7
|
+
draws: number;
|
|
8
|
+
atLeast: number;
|
|
9
|
+
}): number;
|
|
10
|
+
declare function manaCurve(cards: readonly ExtensionCard[]): {
|
|
11
|
+
manaValue: string;
|
|
12
|
+
count: number;
|
|
13
|
+
}[];
|
|
14
|
+
/**
|
|
15
|
+
* Calculate hypergeometric probability
|
|
16
|
+
*
|
|
17
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
18
|
+
* @param successesInPopulation - Number of success cards in deck (K) - e.g., number of lands
|
|
19
|
+
* @param sampleSize - Number of cards drawn (n) - e.g., opening hand of 7
|
|
20
|
+
* @param successesInSample - Exact number of successes you want (k) - e.g., exactly 3 lands
|
|
21
|
+
* @returns Probability of drawing exactly k successes
|
|
22
|
+
*/
|
|
23
|
+
declare function hypergeometric(populationSize: number, successesInPopulation: number, sampleSize: number, successesInSample: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Calculate probability of drawing AT LEAST k successes
|
|
26
|
+
*
|
|
27
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
28
|
+
* @param successesInPopulation - Number of success cards in deck (K)
|
|
29
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
30
|
+
* @param minSuccesses - Minimum number of successes you want (k or more)
|
|
31
|
+
* @returns Probability of drawing at least k successes
|
|
32
|
+
*/
|
|
33
|
+
declare function hypergeometricAtLeast(populationSize: number, successesInPopulation: number, sampleSize: number, minSuccesses: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Calculate probability of drawing AT MOST k successes
|
|
36
|
+
*
|
|
37
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
38
|
+
* @param successesInPopulation - Number of success cards in deck (K)
|
|
39
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
40
|
+
* @param maxSuccesses - Maximum number of successes you want (k or fewer)
|
|
41
|
+
* @returns Probability of drawing at most k successes
|
|
42
|
+
*/
|
|
43
|
+
declare function hypergeometricAtMost(populationSize: number, successesInPopulation: number, sampleSize: number, maxSuccesses: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate probability of drawing BETWEEN k1 and k2 successes (inclusive)
|
|
46
|
+
*/
|
|
47
|
+
declare function hypergeometricBetween(populationSize: number, successesInPopulation: number, sampleSize: number, minSuccesses: number, maxSuccesses: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Card group for multivariate hypergeometric calculation
|
|
50
|
+
*/
|
|
51
|
+
interface CardGroup {
|
|
52
|
+
count: number;
|
|
53
|
+
min?: number;
|
|
54
|
+
max?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Calculate probability of drawing specific amounts from multiple card groups
|
|
58
|
+
* Uses multivariate hypergeometric distribution
|
|
59
|
+
*
|
|
60
|
+
* Example: "What's the probability of drawing at least 1 Sanguine Bond effect (3 in deck)
|
|
61
|
+
* AND at least 1 Exquisite Blood effect (2 in deck) in 15 cards?"
|
|
62
|
+
*
|
|
63
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
64
|
+
* @param groups - Array of card groups with their counts and constraints
|
|
65
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
66
|
+
* @returns Probability of meeting all group constraints simultaneously
|
|
67
|
+
*/
|
|
68
|
+
declare function multivariateHypergeometric(populationSize: number, groups: CardGroup[], sampleSize: number): number;
|
|
69
|
+
|
|
70
|
+
export { type CardGroup, drawProbability, hypergeometric, hypergeometricAtLeast, hypergeometricAtMost, hypergeometricBetween, manaCurve, multivariateHypergeometric };
|
package/dist/math.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { j as ExtensionCard } from './contracts-r8d4RACz.js';
|
|
2
|
+
import 'zod';
|
|
3
|
+
|
|
4
|
+
declare function drawProbability(model: {
|
|
5
|
+
population: number;
|
|
6
|
+
successes: number;
|
|
7
|
+
draws: number;
|
|
8
|
+
atLeast: number;
|
|
9
|
+
}): number;
|
|
10
|
+
declare function manaCurve(cards: readonly ExtensionCard[]): {
|
|
11
|
+
manaValue: string;
|
|
12
|
+
count: number;
|
|
13
|
+
}[];
|
|
14
|
+
/**
|
|
15
|
+
* Calculate hypergeometric probability
|
|
16
|
+
*
|
|
17
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
18
|
+
* @param successesInPopulation - Number of success cards in deck (K) - e.g., number of lands
|
|
19
|
+
* @param sampleSize - Number of cards drawn (n) - e.g., opening hand of 7
|
|
20
|
+
* @param successesInSample - Exact number of successes you want (k) - e.g., exactly 3 lands
|
|
21
|
+
* @returns Probability of drawing exactly k successes
|
|
22
|
+
*/
|
|
23
|
+
declare function hypergeometric(populationSize: number, successesInPopulation: number, sampleSize: number, successesInSample: number): number;
|
|
24
|
+
/**
|
|
25
|
+
* Calculate probability of drawing AT LEAST k successes
|
|
26
|
+
*
|
|
27
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
28
|
+
* @param successesInPopulation - Number of success cards in deck (K)
|
|
29
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
30
|
+
* @param minSuccesses - Minimum number of successes you want (k or more)
|
|
31
|
+
* @returns Probability of drawing at least k successes
|
|
32
|
+
*/
|
|
33
|
+
declare function hypergeometricAtLeast(populationSize: number, successesInPopulation: number, sampleSize: number, minSuccesses: number): number;
|
|
34
|
+
/**
|
|
35
|
+
* Calculate probability of drawing AT MOST k successes
|
|
36
|
+
*
|
|
37
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
38
|
+
* @param successesInPopulation - Number of success cards in deck (K)
|
|
39
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
40
|
+
* @param maxSuccesses - Maximum number of successes you want (k or fewer)
|
|
41
|
+
* @returns Probability of drawing at most k successes
|
|
42
|
+
*/
|
|
43
|
+
declare function hypergeometricAtMost(populationSize: number, successesInPopulation: number, sampleSize: number, maxSuccesses: number): number;
|
|
44
|
+
/**
|
|
45
|
+
* Calculate probability of drawing BETWEEN k1 and k2 successes (inclusive)
|
|
46
|
+
*/
|
|
47
|
+
declare function hypergeometricBetween(populationSize: number, successesInPopulation: number, sampleSize: number, minSuccesses: number, maxSuccesses: number): number;
|
|
48
|
+
/**
|
|
49
|
+
* Card group for multivariate hypergeometric calculation
|
|
50
|
+
*/
|
|
51
|
+
interface CardGroup {
|
|
52
|
+
count: number;
|
|
53
|
+
min?: number;
|
|
54
|
+
max?: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Calculate probability of drawing specific amounts from multiple card groups
|
|
58
|
+
* Uses multivariate hypergeometric distribution
|
|
59
|
+
*
|
|
60
|
+
* Example: "What's the probability of drawing at least 1 Sanguine Bond effect (3 in deck)
|
|
61
|
+
* AND at least 1 Exquisite Blood effect (2 in deck) in 15 cards?"
|
|
62
|
+
*
|
|
63
|
+
* @param populationSize - Total number of cards in deck (N)
|
|
64
|
+
* @param groups - Array of card groups with their counts and constraints
|
|
65
|
+
* @param sampleSize - Number of cards drawn (n)
|
|
66
|
+
* @returns Probability of meeting all group constraints simultaneously
|
|
67
|
+
*/
|
|
68
|
+
declare function multivariateHypergeometric(populationSize: number, groups: CardGroup[], sampleSize: number): number;
|
|
69
|
+
|
|
70
|
+
export { type CardGroup, drawProbability, hypergeometric, hypergeometricAtLeast, hypergeometricAtMost, hypergeometricBetween, manaCurve, multivariateHypergeometric };
|
package/dist/math.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
// src/math.ts
|
|
2
|
+
function drawProbability(model) {
|
|
3
|
+
const { population, successes, draws, atLeast } = model;
|
|
4
|
+
if (![population, successes, draws, atLeast].every(Number.isInteger) || population < 1 || population > 1e3 || successes < 0 || successes > population || draws < 0 || draws > population || atLeast < 0 || atLeast > draws)
|
|
5
|
+
throw new RangeError(
|
|
6
|
+
"Use whole numbers: library 1-1000, targets and draws within the library, and minimum within the draw."
|
|
7
|
+
);
|
|
8
|
+
return hypergeometricAtLeast(population, successes, draws, atLeast);
|
|
9
|
+
}
|
|
10
|
+
function manaCurve(cards) {
|
|
11
|
+
const bins = /* @__PURE__ */ new Map();
|
|
12
|
+
for (const card of cards) {
|
|
13
|
+
if (card.commander || /\bLand\b/.test(card.typeLine?.split(/\s*\/\/\s*/)[0] ?? ""))
|
|
14
|
+
continue;
|
|
15
|
+
const bin = card.manaValue === void 0 ? "Unknown" : card.manaValue >= 7 ? "7+" : String(card.manaValue);
|
|
16
|
+
bins.set(bin, (bins.get(bin) ?? 0) + card.quantity);
|
|
17
|
+
}
|
|
18
|
+
return [...bins].sort(
|
|
19
|
+
([a], [b]) => (a === "Unknown" ? Infinity : parseFloat(a)) - (b === "Unknown" ? Infinity : parseFloat(b))
|
|
20
|
+
).map(([manaValue, count]) => ({ manaValue, count }));
|
|
21
|
+
}
|
|
22
|
+
function binomialCoefficient(n, k) {
|
|
23
|
+
if (k > n || k < 0) return 0;
|
|
24
|
+
if (k === 0 || k === n) return 1;
|
|
25
|
+
k = Math.min(k, n - k);
|
|
26
|
+
let result = 1;
|
|
27
|
+
for (let i = 0; i < k; i++) {
|
|
28
|
+
result *= n - i;
|
|
29
|
+
result /= i + 1;
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
function hypergeometric(populationSize, successesInPopulation, sampleSize, successesInSample) {
|
|
34
|
+
const numerator = binomialCoefficient(successesInPopulation, successesInSample) * binomialCoefficient(populationSize - successesInPopulation, sampleSize - successesInSample);
|
|
35
|
+
const denominator = binomialCoefficient(populationSize, sampleSize);
|
|
36
|
+
return numerator / denominator;
|
|
37
|
+
}
|
|
38
|
+
function hypergeometricAtLeast(populationSize, successesInPopulation, sampleSize, minSuccesses) {
|
|
39
|
+
let probability = 0;
|
|
40
|
+
for (let k = minSuccesses; k <= Math.min(sampleSize, successesInPopulation); k++) {
|
|
41
|
+
probability += hypergeometric(populationSize, successesInPopulation, sampleSize, k);
|
|
42
|
+
}
|
|
43
|
+
return probability;
|
|
44
|
+
}
|
|
45
|
+
function hypergeometricAtMost(populationSize, successesInPopulation, sampleSize, maxSuccesses) {
|
|
46
|
+
let probability = 0;
|
|
47
|
+
for (let k = 0; k <= Math.min(maxSuccesses, sampleSize, successesInPopulation); k++) {
|
|
48
|
+
probability += hypergeometric(populationSize, successesInPopulation, sampleSize, k);
|
|
49
|
+
}
|
|
50
|
+
return probability;
|
|
51
|
+
}
|
|
52
|
+
function hypergeometricBetween(populationSize, successesInPopulation, sampleSize, minSuccesses, maxSuccesses) {
|
|
53
|
+
let probability = 0;
|
|
54
|
+
for (let k = minSuccesses; k <= Math.min(maxSuccesses, sampleSize, successesInPopulation); k++) {
|
|
55
|
+
probability += hypergeometric(populationSize, successesInPopulation, sampleSize, k);
|
|
56
|
+
}
|
|
57
|
+
return probability;
|
|
58
|
+
}
|
|
59
|
+
function multivariateHypergeometric(populationSize, groups, sampleSize) {
|
|
60
|
+
const totalGroupCards = groups.reduce((sum, g) => sum + g.count, 0);
|
|
61
|
+
if (totalGroupCards > populationSize) {
|
|
62
|
+
throw new Error("Total group cards exceeds population size");
|
|
63
|
+
}
|
|
64
|
+
const otherCards = populationSize - totalGroupCards;
|
|
65
|
+
let probability = 0;
|
|
66
|
+
function generateCombinations(groupIndex, currentCounts, remainingDraw) {
|
|
67
|
+
if (groupIndex === groups.length) {
|
|
68
|
+
let valid = true;
|
|
69
|
+
for (let i = 0; i < groups.length; i++) {
|
|
70
|
+
const min = groups[i].min ?? 1;
|
|
71
|
+
const max = groups[i].max ?? sampleSize;
|
|
72
|
+
if (currentCounts[i] < min || currentCounts[i] > max) {
|
|
73
|
+
valid = false;
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
if (!valid) return;
|
|
78
|
+
let numerator = 1;
|
|
79
|
+
for (let i = 0; i < groups.length; i++) {
|
|
80
|
+
numerator *= binomialCoefficient(groups[i].count, currentCounts[i]);
|
|
81
|
+
}
|
|
82
|
+
const otherDrawn = remainingDraw;
|
|
83
|
+
numerator *= binomialCoefficient(otherCards, otherDrawn);
|
|
84
|
+
const denominator = binomialCoefficient(populationSize, sampleSize);
|
|
85
|
+
probability += numerator / denominator;
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
const group = groups[groupIndex];
|
|
89
|
+
const minDraw = Math.max(0, group.min ?? 0);
|
|
90
|
+
const maxDraw = Math.min(group.count, remainingDraw, group.max ?? sampleSize);
|
|
91
|
+
for (let count = minDraw; count <= maxDraw; count++) {
|
|
92
|
+
currentCounts[groupIndex] = count;
|
|
93
|
+
generateCombinations(groupIndex + 1, currentCounts, remainingDraw - count);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
generateCombinations(0, [], sampleSize);
|
|
97
|
+
return probability;
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
drawProbability,
|
|
101
|
+
hypergeometric,
|
|
102
|
+
hypergeometricAtLeast,
|
|
103
|
+
hypergeometricAtMost,
|
|
104
|
+
hypergeometricBetween,
|
|
105
|
+
manaCurve,
|
|
106
|
+
multivariateHypergeometric
|
|
107
|
+
};
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/react.tsx
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
var _react = require('react');
|
|
10
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
11
|
+
var Context = _react.createContext.call(void 0, void 0);
|
|
12
|
+
function ExtensionProvider({
|
|
13
|
+
api,
|
|
14
|
+
revision,
|
|
15
|
+
children
|
|
16
|
+
}) {
|
|
17
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, Context.Provider, { value: { api, revision }, children });
|
|
18
|
+
}
|
|
19
|
+
function useContextValue() {
|
|
20
|
+
const context = _react.useContext.call(void 0, Context);
|
|
21
|
+
if (!context) throw new Error("Render this extension inside an EDHspace ExtensionProvider.");
|
|
22
|
+
return context;
|
|
23
|
+
}
|
|
24
|
+
function useExtension() {
|
|
25
|
+
return useContextValue().api;
|
|
26
|
+
}
|
|
27
|
+
function useResource(load, revision) {
|
|
28
|
+
const generation = _react.useRef.call(void 0, 0);
|
|
29
|
+
const [data, setData] = _react.useState.call(void 0, );
|
|
30
|
+
const [error, setError] = _react.useState.call(void 0, );
|
|
31
|
+
const [loading, setLoading] = _react.useState.call(void 0, true);
|
|
32
|
+
const refresh = _react.useCallback.call(void 0, async () => {
|
|
33
|
+
const current = ++generation.current;
|
|
34
|
+
setLoading(true);
|
|
35
|
+
setError(void 0);
|
|
36
|
+
try {
|
|
37
|
+
const result = await load();
|
|
38
|
+
if (generation.current === current) setData(result);
|
|
39
|
+
} catch (error2) {
|
|
40
|
+
if (generation.current === current)
|
|
41
|
+
setError(
|
|
42
|
+
error2 instanceof Error ? error2 : new Error("Extension data could not be read.")
|
|
43
|
+
);
|
|
44
|
+
} finally {
|
|
45
|
+
if (generation.current === current) setLoading(false);
|
|
46
|
+
}
|
|
47
|
+
}, [load]);
|
|
48
|
+
_react.useEffect.call(void 0, () => {
|
|
49
|
+
void refresh();
|
|
50
|
+
return () => {
|
|
51
|
+
generation.current++;
|
|
52
|
+
};
|
|
53
|
+
}, [refresh, revision]);
|
|
54
|
+
return { data, error, loading, refresh };
|
|
55
|
+
}
|
|
56
|
+
function useActiveDeck() {
|
|
57
|
+
const { api, revision } = useContextValue();
|
|
58
|
+
return useResource(api.deck.read, revision);
|
|
59
|
+
}
|
|
60
|
+
function useSelectedCards() {
|
|
61
|
+
const { api, revision } = useContextValue();
|
|
62
|
+
return useResource(api.selection.read, revision);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
exports.ExtensionProvider = ExtensionProvider; exports.useActiveDeck = useActiveDeck; exports.useExtension = useExtension; exports.useSelectedCards = useSelectedCards;
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { D as DeckOperation, o as NetworkRequest, a as ExtensionArguments } from './contracts-r8d4RACz.cjs';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { E as ExtensionClient } from './client-DKX6ZfiJ.cjs';
|
|
6
|
+
|
|
7
|
+
declare function ExtensionProvider({ api, revision, children, }: {
|
|
8
|
+
api: ExtensionClient;
|
|
9
|
+
revision: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): react.JSX.Element;
|
|
12
|
+
declare function useExtension(): {
|
|
13
|
+
permissions: readonly ("deck.read" | "selection.read" | "deck.propose" | "cards.inspect" | "cards.search" | "workspace.open" | "notifications.show" | "storage.read" | "storage.write" | "preferences.read" | "preferences.write" | "network.request")[];
|
|
14
|
+
deck: {
|
|
15
|
+
read: () => Promise<{
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
format: string;
|
|
19
|
+
revision: string;
|
|
20
|
+
cards: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
quantity: number;
|
|
24
|
+
manaCost?: string | undefined;
|
|
25
|
+
manaValue?: number | undefined;
|
|
26
|
+
typeLine?: string | undefined;
|
|
27
|
+
commander?: boolean | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
propose: (operations: DeckOperation[]) => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
status: "pending" | "dismissed";
|
|
33
|
+
revision?: string | undefined;
|
|
34
|
+
undoId?: string | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
id: string;
|
|
37
|
+
status: "applied";
|
|
38
|
+
revision: string;
|
|
39
|
+
undoId: string;
|
|
40
|
+
}>;
|
|
41
|
+
addCard: (cardId: string, category: string, quantity?: number) => Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
status: "pending" | "dismissed";
|
|
44
|
+
revision?: string | undefined;
|
|
45
|
+
undoId?: string | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
id: string;
|
|
48
|
+
status: "applied";
|
|
49
|
+
revision: string;
|
|
50
|
+
undoId: string;
|
|
51
|
+
}>;
|
|
52
|
+
removeCard: (cardId: string, quantity?: number) => Promise<{
|
|
53
|
+
id: string;
|
|
54
|
+
status: "pending" | "dismissed";
|
|
55
|
+
revision?: string | undefined;
|
|
56
|
+
undoId?: string | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
id: string;
|
|
59
|
+
status: "applied";
|
|
60
|
+
revision: string;
|
|
61
|
+
undoId: string;
|
|
62
|
+
}>;
|
|
63
|
+
applyTags: (cardIds: string[], tags: string[]) => Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
status: "pending" | "dismissed";
|
|
66
|
+
revision?: string | undefined;
|
|
67
|
+
undoId?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
id: string;
|
|
70
|
+
status: "applied";
|
|
71
|
+
revision: string;
|
|
72
|
+
undoId: string;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
selection: {
|
|
76
|
+
read: () => Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
quantity: number;
|
|
80
|
+
manaCost?: string | undefined;
|
|
81
|
+
manaValue?: number | undefined;
|
|
82
|
+
typeLine?: string | undefined;
|
|
83
|
+
commander?: boolean | undefined;
|
|
84
|
+
}[]>;
|
|
85
|
+
};
|
|
86
|
+
network: {
|
|
87
|
+
request: (request: NetworkRequest) => Promise<{
|
|
88
|
+
status: number;
|
|
89
|
+
data: zod.JSONType;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
cards: {
|
|
93
|
+
inspect: (cardId: string) => Promise<{
|
|
94
|
+
opened: true;
|
|
95
|
+
}>;
|
|
96
|
+
search: (query: string, page?: number) => Promise<{
|
|
97
|
+
cards: {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
quantity: number;
|
|
101
|
+
manaCost?: string | undefined;
|
|
102
|
+
manaValue?: number | undefined;
|
|
103
|
+
typeLine?: string | undefined;
|
|
104
|
+
commander?: boolean | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
nextPage?: number | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
getByName: (name: string) => Promise<{
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
quantity: number;
|
|
112
|
+
manaCost?: string | undefined;
|
|
113
|
+
manaValue?: number | undefined;
|
|
114
|
+
typeLine?: string | undefined;
|
|
115
|
+
commander?: boolean | undefined;
|
|
116
|
+
} | null>;
|
|
117
|
+
};
|
|
118
|
+
workspace: {
|
|
119
|
+
openPanel: (panelId: string, location?: "workspace" | "sidebar") => Promise<{
|
|
120
|
+
panelId: string;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
notifications: {
|
|
124
|
+
show: (message: string, kind?: "info" | "success" | "error") => Promise<{
|
|
125
|
+
shown: true;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
storage: {
|
|
129
|
+
get: (key: string) => Promise<zod.JSONType>;
|
|
130
|
+
set: (key: string, value: ExtensionArguments["storage.set"]["value"]) => Promise<{
|
|
131
|
+
saved: true;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
preferences: {
|
|
135
|
+
get: () => Promise<Record<string, zod.JSONType>>;
|
|
136
|
+
set: (key: string, value: ExtensionArguments["preferences.set"]["value"]) => Promise<{
|
|
137
|
+
saved: true;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
dispose: () => void;
|
|
141
|
+
};
|
|
142
|
+
declare function useActiveDeck(): {
|
|
143
|
+
data: {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
format: string;
|
|
147
|
+
revision: string;
|
|
148
|
+
cards: {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
quantity: number;
|
|
152
|
+
manaCost?: string | undefined;
|
|
153
|
+
manaValue?: number | undefined;
|
|
154
|
+
typeLine?: string | undefined;
|
|
155
|
+
commander?: boolean | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
} | undefined;
|
|
158
|
+
error: Error | undefined;
|
|
159
|
+
loading: boolean;
|
|
160
|
+
refresh: () => Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
declare function useSelectedCards(): {
|
|
163
|
+
data: {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
quantity: number;
|
|
167
|
+
manaCost?: string | undefined;
|
|
168
|
+
manaValue?: number | undefined;
|
|
169
|
+
typeLine?: string | undefined;
|
|
170
|
+
commander?: boolean | undefined;
|
|
171
|
+
}[] | undefined;
|
|
172
|
+
error: Error | undefined;
|
|
173
|
+
loading: boolean;
|
|
174
|
+
refresh: () => Promise<void>;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export { ExtensionProvider, useActiveDeck, useExtension, useSelectedCards };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import * as zod from 'zod';
|
|
2
|
+
import { D as DeckOperation, o as NetworkRequest, a as ExtensionArguments } from './contracts-r8d4RACz.js';
|
|
3
|
+
import * as react from 'react';
|
|
4
|
+
import { ReactNode } from 'react';
|
|
5
|
+
import { E as ExtensionClient } from './client-CSAi6AFj.js';
|
|
6
|
+
|
|
7
|
+
declare function ExtensionProvider({ api, revision, children, }: {
|
|
8
|
+
api: ExtensionClient;
|
|
9
|
+
revision: string;
|
|
10
|
+
children: ReactNode;
|
|
11
|
+
}): react.JSX.Element;
|
|
12
|
+
declare function useExtension(): {
|
|
13
|
+
permissions: readonly ("deck.read" | "selection.read" | "deck.propose" | "cards.inspect" | "cards.search" | "workspace.open" | "notifications.show" | "storage.read" | "storage.write" | "preferences.read" | "preferences.write" | "network.request")[];
|
|
14
|
+
deck: {
|
|
15
|
+
read: () => Promise<{
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
format: string;
|
|
19
|
+
revision: string;
|
|
20
|
+
cards: {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
quantity: number;
|
|
24
|
+
manaCost?: string | undefined;
|
|
25
|
+
manaValue?: number | undefined;
|
|
26
|
+
typeLine?: string | undefined;
|
|
27
|
+
commander?: boolean | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
}>;
|
|
30
|
+
propose: (operations: DeckOperation[]) => Promise<{
|
|
31
|
+
id: string;
|
|
32
|
+
status: "pending" | "dismissed";
|
|
33
|
+
revision?: string | undefined;
|
|
34
|
+
undoId?: string | undefined;
|
|
35
|
+
} | {
|
|
36
|
+
id: string;
|
|
37
|
+
status: "applied";
|
|
38
|
+
revision: string;
|
|
39
|
+
undoId: string;
|
|
40
|
+
}>;
|
|
41
|
+
addCard: (cardId: string, category: string, quantity?: number) => Promise<{
|
|
42
|
+
id: string;
|
|
43
|
+
status: "pending" | "dismissed";
|
|
44
|
+
revision?: string | undefined;
|
|
45
|
+
undoId?: string | undefined;
|
|
46
|
+
} | {
|
|
47
|
+
id: string;
|
|
48
|
+
status: "applied";
|
|
49
|
+
revision: string;
|
|
50
|
+
undoId: string;
|
|
51
|
+
}>;
|
|
52
|
+
removeCard: (cardId: string, quantity?: number) => Promise<{
|
|
53
|
+
id: string;
|
|
54
|
+
status: "pending" | "dismissed";
|
|
55
|
+
revision?: string | undefined;
|
|
56
|
+
undoId?: string | undefined;
|
|
57
|
+
} | {
|
|
58
|
+
id: string;
|
|
59
|
+
status: "applied";
|
|
60
|
+
revision: string;
|
|
61
|
+
undoId: string;
|
|
62
|
+
}>;
|
|
63
|
+
applyTags: (cardIds: string[], tags: string[]) => Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
status: "pending" | "dismissed";
|
|
66
|
+
revision?: string | undefined;
|
|
67
|
+
undoId?: string | undefined;
|
|
68
|
+
} | {
|
|
69
|
+
id: string;
|
|
70
|
+
status: "applied";
|
|
71
|
+
revision: string;
|
|
72
|
+
undoId: string;
|
|
73
|
+
}>;
|
|
74
|
+
};
|
|
75
|
+
selection: {
|
|
76
|
+
read: () => Promise<{
|
|
77
|
+
id: string;
|
|
78
|
+
name: string;
|
|
79
|
+
quantity: number;
|
|
80
|
+
manaCost?: string | undefined;
|
|
81
|
+
manaValue?: number | undefined;
|
|
82
|
+
typeLine?: string | undefined;
|
|
83
|
+
commander?: boolean | undefined;
|
|
84
|
+
}[]>;
|
|
85
|
+
};
|
|
86
|
+
network: {
|
|
87
|
+
request: (request: NetworkRequest) => Promise<{
|
|
88
|
+
status: number;
|
|
89
|
+
data: zod.JSONType;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
cards: {
|
|
93
|
+
inspect: (cardId: string) => Promise<{
|
|
94
|
+
opened: true;
|
|
95
|
+
}>;
|
|
96
|
+
search: (query: string, page?: number) => Promise<{
|
|
97
|
+
cards: {
|
|
98
|
+
id: string;
|
|
99
|
+
name: string;
|
|
100
|
+
quantity: number;
|
|
101
|
+
manaCost?: string | undefined;
|
|
102
|
+
manaValue?: number | undefined;
|
|
103
|
+
typeLine?: string | undefined;
|
|
104
|
+
commander?: boolean | undefined;
|
|
105
|
+
}[];
|
|
106
|
+
nextPage?: number | undefined;
|
|
107
|
+
}>;
|
|
108
|
+
getByName: (name: string) => Promise<{
|
|
109
|
+
id: string;
|
|
110
|
+
name: string;
|
|
111
|
+
quantity: number;
|
|
112
|
+
manaCost?: string | undefined;
|
|
113
|
+
manaValue?: number | undefined;
|
|
114
|
+
typeLine?: string | undefined;
|
|
115
|
+
commander?: boolean | undefined;
|
|
116
|
+
} | null>;
|
|
117
|
+
};
|
|
118
|
+
workspace: {
|
|
119
|
+
openPanel: (panelId: string, location?: "workspace" | "sidebar") => Promise<{
|
|
120
|
+
panelId: string;
|
|
121
|
+
}>;
|
|
122
|
+
};
|
|
123
|
+
notifications: {
|
|
124
|
+
show: (message: string, kind?: "info" | "success" | "error") => Promise<{
|
|
125
|
+
shown: true;
|
|
126
|
+
}>;
|
|
127
|
+
};
|
|
128
|
+
storage: {
|
|
129
|
+
get: (key: string) => Promise<zod.JSONType>;
|
|
130
|
+
set: (key: string, value: ExtensionArguments["storage.set"]["value"]) => Promise<{
|
|
131
|
+
saved: true;
|
|
132
|
+
}>;
|
|
133
|
+
};
|
|
134
|
+
preferences: {
|
|
135
|
+
get: () => Promise<Record<string, zod.JSONType>>;
|
|
136
|
+
set: (key: string, value: ExtensionArguments["preferences.set"]["value"]) => Promise<{
|
|
137
|
+
saved: true;
|
|
138
|
+
}>;
|
|
139
|
+
};
|
|
140
|
+
dispose: () => void;
|
|
141
|
+
};
|
|
142
|
+
declare function useActiveDeck(): {
|
|
143
|
+
data: {
|
|
144
|
+
id: string;
|
|
145
|
+
name: string;
|
|
146
|
+
format: string;
|
|
147
|
+
revision: string;
|
|
148
|
+
cards: {
|
|
149
|
+
id: string;
|
|
150
|
+
name: string;
|
|
151
|
+
quantity: number;
|
|
152
|
+
manaCost?: string | undefined;
|
|
153
|
+
manaValue?: number | undefined;
|
|
154
|
+
typeLine?: string | undefined;
|
|
155
|
+
commander?: boolean | undefined;
|
|
156
|
+
}[];
|
|
157
|
+
} | undefined;
|
|
158
|
+
error: Error | undefined;
|
|
159
|
+
loading: boolean;
|
|
160
|
+
refresh: () => Promise<void>;
|
|
161
|
+
};
|
|
162
|
+
declare function useSelectedCards(): {
|
|
163
|
+
data: {
|
|
164
|
+
id: string;
|
|
165
|
+
name: string;
|
|
166
|
+
quantity: number;
|
|
167
|
+
manaCost?: string | undefined;
|
|
168
|
+
manaValue?: number | undefined;
|
|
169
|
+
typeLine?: string | undefined;
|
|
170
|
+
commander?: boolean | undefined;
|
|
171
|
+
}[] | undefined;
|
|
172
|
+
error: Error | undefined;
|
|
173
|
+
loading: boolean;
|
|
174
|
+
refresh: () => Promise<void>;
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
export { ExtensionProvider, useActiveDeck, useExtension, useSelectedCards };
|