@celljs/ta-extensions 4.8.0 → 4.9.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/README.en.md +4 -1
- package/README.md +4 -1
- package/host/index.mjs +64 -61
- package/package.json +14 -4
- package/skills/ta-package/SKILL.md +12 -8
- package/web/index.js +488 -120
- package/web-src/actions.ts +0 -204
- package/web-src/archive.spec.ts +0 -101
- package/web-src/archive.ts +0 -229
- package/web-src/context.ts +0 -24
- package/web-src/extensions-util.spec.ts +0 -38
- package/web-src/extensions-util.ts +0 -40
- package/web-src/host.spec.ts +0 -72
- package/web-src/host.ts +0 -115
- package/web-src/i18n.ts +0 -240
- package/web-src/import-dialog.tsx +0 -89
- package/web-src/index.tsx +0 -50
- package/web-src/market-detail.tsx +0 -138
- package/web-src/market-parts.tsx +0 -94
- package/web-src/market-store.ts +0 -116
- package/web-src/market-style.ts +0 -94
- package/web-src/market-util.spec.ts +0 -79
- package/web-src/market-util.ts +0 -239
- package/web-src/market-view.tsx +0 -245
- package/web-src/market.spec.ts +0 -154
- package/web-src/market.ts +0 -232
- package/web-src/page.tsx +0 -278
- package/web-src/pictures.tsx +0 -87
- package/web-src/react.ts +0 -11
- package/web-src/signal.ts +0 -34
- package/web-src/style.ts +0 -92
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { type ExtensionsContext, icon } from './context';
|
|
2
|
-
import { ExtensionWords } from './i18n';
|
|
3
|
-
import { InstallButton, PackageFace, PackageName, useMarketStatus } from './market-parts';
|
|
4
|
-
import { MarketStore } from './market-store';
|
|
5
|
-
import { type MarketDetail, MarketUtil } from './market-util';
|
|
6
|
-
import { React } from './react';
|
|
7
|
-
|
|
8
|
-
export interface MarketDetailProps {
|
|
9
|
-
context: ExtensionsContext;
|
|
10
|
-
name: string;
|
|
11
|
-
onBack(): void;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The page of a package of the market, as a store shows an app: its face, name and numbers, the button
|
|
16
|
-
* to install it (or remove it), where it comes from, its preview of pi's gallery, and its README.
|
|
17
|
-
*/
|
|
18
|
-
export function MarketDetailView({ context, name, onBack }: MarketDetailProps): React.ReactElement {
|
|
19
|
-
const { pi, market, actions } = context;
|
|
20
|
-
const words = actions.words;
|
|
21
|
-
const [detail, setDetail] = React.useState<MarketDetail>();
|
|
22
|
-
const [error, setError] = React.useState<string>();
|
|
23
|
-
const [attempt, setAttempt] = React.useState(0);
|
|
24
|
-
React.useEffect(() => {
|
|
25
|
-
let live = true;
|
|
26
|
-
setError(undefined);
|
|
27
|
-
market.detail(name).then(
|
|
28
|
-
value => live && setDetail(value),
|
|
29
|
-
reason => live && setError(MarketStore.message(reason)),
|
|
30
|
-
);
|
|
31
|
-
return () => {
|
|
32
|
-
live = false;
|
|
33
|
-
};
|
|
34
|
-
}, [market, name, attempt]);
|
|
35
|
-
React.useEffect(() => {
|
|
36
|
-
const onKey = (event: KeyboardEvent) => {
|
|
37
|
-
// Not while a dialog is open or the user types.
|
|
38
|
-
const target = event.target as HTMLElement | null;
|
|
39
|
-
if (event.key === 'Escape' && !document.querySelector('[aria-modal="true"]') && !target?.closest('input, textarea, [contenteditable="true"]')) {
|
|
40
|
-
onBack();
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
document.addEventListener('keydown', onKey);
|
|
44
|
-
return () => document.removeEventListener('keydown', onKey);
|
|
45
|
-
}, [onBack]);
|
|
46
|
-
// What the list knew shows at once; the README follows. The list knows when it was published.
|
|
47
|
-
const listed = market.state.packages?.find(pkg => pkg.name === name);
|
|
48
|
-
const summary = detail ? { ...detail, date: detail.date ?? listed?.date, downloads: detail.downloads ?? listed?.downloads } : listed;
|
|
49
|
-
const status = useMarketStatus(context, name);
|
|
50
|
-
const ArrowLeft = icon(pi, 'ArrowLeft');
|
|
51
|
-
const External = icon(pi, 'ExternalLink');
|
|
52
|
-
const Trash = icon(pi, 'Trash2');
|
|
53
|
-
const Markdown = pi.ui.Markdown;
|
|
54
|
-
const ago = MarketUtil.ago(summary?.date, pi.ui.language);
|
|
55
|
-
const facts = [
|
|
56
|
-
summary?.publisher,
|
|
57
|
-
summary?.version && `v${summary.version}`,
|
|
58
|
-
summary?.downloads ? ExtensionWords.fill(words.perMonth, { count: MarketUtil.compact(summary.downloads) }) : undefined,
|
|
59
|
-
detail?.license,
|
|
60
|
-
ago,
|
|
61
|
-
].filter((fact): fact is string => !!fact);
|
|
62
|
-
const links = [
|
|
63
|
-
{ key: 'npm', label: 'npm', href: summary?.links.npm ?? `https://www.npmjs.com/package/${name}` },
|
|
64
|
-
{ key: 'source', label: words.source, href: summary?.links.repository },
|
|
65
|
-
{ key: 'home', label: words.homepage, href: summary?.links.homepage !== summary?.links.repository ? summary?.links.homepage : undefined },
|
|
66
|
-
].filter((link): link is { key: string; label: string; href: string } => !!link.href && /^https?:\/\//.test(link.href));
|
|
67
|
-
const tags = (detail?.resources.length ? detail.resources : (summary?.kinds ?? [])).map(type =>
|
|
68
|
-
type === 'web' ? words.kinds.web : words.marketKinds[type],
|
|
69
|
-
);
|
|
70
|
-
return (
|
|
71
|
-
<article className="tax-detail" aria-label={name}>
|
|
72
|
-
<button type="button" className="tax-back" onClick={onBack}>
|
|
73
|
-
<ArrowLeft size={15} /> {words.back}
|
|
74
|
-
</button>
|
|
75
|
-
<header className="tax-detail-head">
|
|
76
|
-
<PackageFace name={name} size={72} />
|
|
77
|
-
<div className="tax-detail-title">
|
|
78
|
-
<h1>
|
|
79
|
-
<PackageName name={name} />
|
|
80
|
-
</h1>
|
|
81
|
-
{summary?.description && <p className="tax-detail-description">{summary.description}</p>}
|
|
82
|
-
{(facts.length > 0 || tags.length > 0) && (
|
|
83
|
-
<div className="tax-detail-facts">
|
|
84
|
-
{tags.map(tag => (
|
|
85
|
-
<span key={tag} className="tax-tag">
|
|
86
|
-
{tag}
|
|
87
|
-
</span>
|
|
88
|
-
))}
|
|
89
|
-
{facts.map(fact => (
|
|
90
|
-
<span key={fact} className="tax-fact">
|
|
91
|
-
{fact}
|
|
92
|
-
</span>
|
|
93
|
-
))}
|
|
94
|
-
</div>
|
|
95
|
-
)}
|
|
96
|
-
<div className="tax-detail-actions">
|
|
97
|
-
<InstallButton context={context} name={name} large />
|
|
98
|
-
{status.kind === 'installed' && (
|
|
99
|
-
<button type="button" className="tax-button tax-button-quiet" onClick={() => void actions.remove(status.pkg)}>
|
|
100
|
-
<Trash size={14} /> {words.remove}
|
|
101
|
-
</button>
|
|
102
|
-
)}
|
|
103
|
-
{links.map(link => (
|
|
104
|
-
<a key={link.key} className="tax-button tax-button-quiet" href={link.href} target="_blank" rel="noreferrer noopener">
|
|
105
|
-
{link.label} <External size={13} />
|
|
106
|
-
</a>
|
|
107
|
-
))}
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
</header>
|
|
111
|
-
{detail?.video ? (
|
|
112
|
-
<video className="tax-preview" src={detail.video} controls muted playsInline preload="metadata" />
|
|
113
|
-
) : detail?.image ? (
|
|
114
|
-
<img className="tax-preview" src={detail.image} alt="" loading="lazy" />
|
|
115
|
-
) : null}
|
|
116
|
-
<section className="tax-readme" aria-label={words.readmeTitle}>
|
|
117
|
-
{error ? (
|
|
118
|
-
<div className="tax-empty tax-market-error">
|
|
119
|
-
<span>{error}</span>
|
|
120
|
-
<button type="button" className="tax-button" onClick={() => setAttempt(attempt + 1)}>
|
|
121
|
-
{words.retry}
|
|
122
|
-
</button>
|
|
123
|
-
</div>
|
|
124
|
-
) : !detail ? (
|
|
125
|
-
<div className="tax-readme-loading" aria-busy="true">
|
|
126
|
-
<span />
|
|
127
|
-
<span />
|
|
128
|
-
<span />
|
|
129
|
-
</div>
|
|
130
|
-
) : detail.readme ? (
|
|
131
|
-
<Markdown text={detail.readme} />
|
|
132
|
-
) : (
|
|
133
|
-
<div className="tax-note">{words.noReadme}</div>
|
|
134
|
-
)}
|
|
135
|
-
</section>
|
|
136
|
-
</article>
|
|
137
|
-
);
|
|
138
|
-
}
|
package/web-src/market-parts.tsx
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import type { TaPackageInfo } from '@celljs/ta-protocol';
|
|
2
|
-
import { type ExtensionsContext, icon } from './context';
|
|
3
|
-
import { MarketUtil } from './market-util';
|
|
4
|
-
import { React } from './react';
|
|
5
|
-
|
|
6
|
-
/** Where a package of the market stands on this computer. */
|
|
7
|
-
export type MarketStatus = { kind: 'none' } | { kind: 'installing' } | { kind: 'builtin' } | { kind: 'installed'; pkg: TaPackageInfo };
|
|
8
|
-
|
|
9
|
-
/** A React hook: the status of a package of the market, by the packages Ta loads and what is being installed. */
|
|
10
|
-
export function useMarketStatus(context: ExtensionsContext, name: string): MarketStatus {
|
|
11
|
-
const { packages } = React.useSyncExternalStore(
|
|
12
|
-
listener => context.store.subscribe(listener),
|
|
13
|
-
() => context.store.state,
|
|
14
|
-
);
|
|
15
|
-
const installing = React.useSyncExternalStore(
|
|
16
|
-
listener => context.market.subscribe(listener),
|
|
17
|
-
() => context.market.state.installing.has(name),
|
|
18
|
-
);
|
|
19
|
-
if (installing) {
|
|
20
|
-
return { kind: 'installing' };
|
|
21
|
-
}
|
|
22
|
-
const pkg = packages?.find(candidate => candidate.name === name);
|
|
23
|
-
return !pkg ? { kind: 'none' } : pkg.origin === 'builtin' ? { kind: 'builtin' } : { kind: 'installed', pkg };
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/** The face of a package: its initials on a tint of its own, as npm gives no picture. */
|
|
27
|
-
export function PackageFace({ name, size }: { name: string; size: number }): React.ReactElement {
|
|
28
|
-
const { letters, hue } = MarketUtil.monogram(name);
|
|
29
|
-
return (
|
|
30
|
-
<span className="tax-face" aria-hidden="true" style={{ width: size, height: size, fontSize: Math.round(size * 0.36), ['--tax-hue' as string]: hue }}>
|
|
31
|
-
{letters}
|
|
32
|
-
</span>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/** `@scope/` lighter than the name itself, which is what people tell packages apart by. */
|
|
37
|
-
export function PackageName({ name }: { name: string }): React.ReactNode {
|
|
38
|
-
const slash = name.startsWith('@') ? name.indexOf('/') : -1;
|
|
39
|
-
return slash > 0 ? (
|
|
40
|
-
<>
|
|
41
|
-
<span className="tax-scope">{name.slice(0, slash + 1)}</span>
|
|
42
|
-
{name.slice(slash + 1)}
|
|
43
|
-
</>
|
|
44
|
-
) : (
|
|
45
|
-
name
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export interface InstallButtonProps {
|
|
50
|
-
context: ExtensionsContext;
|
|
51
|
-
name: string;
|
|
52
|
-
/** The larger button of the page of a package. */
|
|
53
|
-
large?: boolean;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Install in one click; then what is: installing, installed, or come with Ta. */
|
|
57
|
-
export function InstallButton({ context, name, large }: InstallButtonProps): React.ReactElement {
|
|
58
|
-
const { pi, actions } = context;
|
|
59
|
-
const words = actions.words;
|
|
60
|
-
const status = useMarketStatus(context, name);
|
|
61
|
-
const size = large ? ' tax-install-large' : '';
|
|
62
|
-
if (status.kind === 'installing') {
|
|
63
|
-
const Loader = icon(pi, 'LoaderCircle');
|
|
64
|
-
return (
|
|
65
|
-
<span className={`tax-install tax-install-busy${size}`} role="status">
|
|
66
|
-
<span className="tax-spin">
|
|
67
|
-
<Loader size={large ? 15 : 13} />
|
|
68
|
-
</span>
|
|
69
|
-
{words.installing}
|
|
70
|
-
</span>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
if (status.kind !== 'none') {
|
|
74
|
-
const Check = icon(pi, 'Check');
|
|
75
|
-
return (
|
|
76
|
-
<span className={`tax-install tax-install-done${size}`}>
|
|
77
|
-
{status.kind === 'installed' && <Check size={large ? 15 : 13} />}
|
|
78
|
-
{status.kind === 'installed' ? words.installedTag : words.builtinTag}
|
|
79
|
-
</span>
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
return (
|
|
83
|
-
<button
|
|
84
|
-
type="button"
|
|
85
|
-
className={`tax-install${size}`}
|
|
86
|
-
onClick={event => {
|
|
87
|
-
event.stopPropagation();
|
|
88
|
-
void actions.installFromMarket(name);
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{words.install}
|
|
92
|
-
</button>
|
|
93
|
-
);
|
|
94
|
-
}
|
package/web-src/market-store.ts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import type { WebExtensionAPI } from '@celljs/ta-web/lib/browser/extension/web-extension-api';
|
|
2
|
-
import type { MarketDetail, MarketPackage, MarketPage } from './market-util';
|
|
3
|
-
|
|
4
|
-
export interface MarketState {
|
|
5
|
-
query: string;
|
|
6
|
-
/** Undefined until the first page of a search came. */
|
|
7
|
-
packages?: MarketPackage[];
|
|
8
|
-
/** How many there are, for a search without words. */
|
|
9
|
-
total?: number;
|
|
10
|
-
/** Where the next page starts; undefined at the end. */
|
|
11
|
-
next?: number;
|
|
12
|
-
/** A search, or its next page, is on its way. */
|
|
13
|
-
loading: boolean;
|
|
14
|
-
error?: string;
|
|
15
|
-
/** Names of the packages being installed. */
|
|
16
|
-
installing: ReadonlySet<string>;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The market as the page shows it: the search and its pages, asked of the host of the package, which
|
|
21
|
-
* asks npm; and what is being installed, which goes on while the user looks elsewhere.
|
|
22
|
-
*/
|
|
23
|
-
export class MarketStore {
|
|
24
|
-
protected current: MarketState = { query: '', loading: false, installing: new Set() };
|
|
25
|
-
protected readonly listeners = new Set<() => void>();
|
|
26
|
-
protected readonly details = new Map<string, Promise<MarketDetail>>();
|
|
27
|
-
/** Each search counts up: the answer of an older one is dropped. */
|
|
28
|
-
protected generation = 0;
|
|
29
|
-
|
|
30
|
-
constructor(protected readonly pi: WebExtensionAPI) {}
|
|
31
|
-
|
|
32
|
-
get state(): MarketState {
|
|
33
|
-
return this.current;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
subscribe(listener: () => void): () => void {
|
|
37
|
-
this.listeners.add(listener);
|
|
38
|
-
return () => this.listeners.delete(listener);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/** Asks again only when the query changed, or the last time failed; the same one on its way is waited for. */
|
|
42
|
-
async search(query: string): Promise<void> {
|
|
43
|
-
const trimmed = query.trim();
|
|
44
|
-
if (trimmed === this.current.query && (this.current.packages || this.current.loading) && !this.current.error) {
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
const generation = ++this.generation;
|
|
48
|
-
this.set({ query: trimmed, loading: true, error: undefined });
|
|
49
|
-
try {
|
|
50
|
-
const page = await this.pi.callHost<MarketPage>('searchMarket', trimmed, 0);
|
|
51
|
-
if (generation === this.generation) {
|
|
52
|
-
this.set({ packages: page.packages, total: page.total, next: page.next, loading: false });
|
|
53
|
-
}
|
|
54
|
-
} catch (error) {
|
|
55
|
-
if (generation === this.generation) {
|
|
56
|
-
this.set({ packages: undefined, total: undefined, next: undefined, loading: false, error: MarketStore.message(error) });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/** The next page, when there is one and none is on its way. */
|
|
62
|
-
async more(): Promise<void> {
|
|
63
|
-
const { packages, next, loading, query } = this.current;
|
|
64
|
-
if (!packages || loading || next === undefined) {
|
|
65
|
-
return;
|
|
66
|
-
}
|
|
67
|
-
const generation = this.generation;
|
|
68
|
-
this.set({ loading: true });
|
|
69
|
-
try {
|
|
70
|
-
const page = await this.pi.callHost<MarketPage>('searchMarket', query, next);
|
|
71
|
-
if (generation === this.generation) {
|
|
72
|
-
const seen = new Set(packages.map(pkg => pkg.name));
|
|
73
|
-
const fresh = page.packages.filter(pkg => !seen.has(pkg.name));
|
|
74
|
-
// npm ranks again between pages: stop when one brings nothing new.
|
|
75
|
-
this.set({ packages: [...packages, ...fresh], next: fresh.length ? page.next : undefined, loading: false });
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
if (generation === this.generation) {
|
|
79
|
-
this.set({ loading: false });
|
|
80
|
-
this.pi.ui.notify(MarketStore.message(error), 'error');
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** Kept for the page: going back and forth does not ask again. */
|
|
86
|
-
detail(name: string): Promise<MarketDetail> {
|
|
87
|
-
let detail = this.details.get(name);
|
|
88
|
-
if (!detail) {
|
|
89
|
-
detail = this.pi.callHost<MarketDetail>('marketPackage', name);
|
|
90
|
-
this.details.set(name, detail);
|
|
91
|
-
detail.catch(() => this.details.delete(name));
|
|
92
|
-
}
|
|
93
|
-
return detail;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
setInstalling(name: string, installing: boolean): void {
|
|
97
|
-
const next = new Set(this.current.installing);
|
|
98
|
-
if (installing) {
|
|
99
|
-
next.add(name);
|
|
100
|
-
} else {
|
|
101
|
-
next.delete(name);
|
|
102
|
-
}
|
|
103
|
-
this.set({ installing: next });
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
protected set(change: Partial<MarketState>): void {
|
|
107
|
-
this.current = { ...this.current, ...change };
|
|
108
|
-
for (const listener of this.listeners) {
|
|
109
|
-
listener();
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
static message(error: unknown): string {
|
|
114
|
-
return error instanceof Error ? error.message : String(error);
|
|
115
|
-
}
|
|
116
|
-
}
|
package/web-src/market-style.ts
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/** The styles of the tabs and the market; as STYLE, only the --ta-* variables of the page. */
|
|
2
|
-
export const MARKET_STYLE = `
|
|
3
|
-
.tax-tabs { display: inline-flex; align-self: flex-start; gap: 2px; margin-bottom: -10px; padding: 3px; border-radius: 10px; background: var(--ta-chip); }
|
|
4
|
-
.tax-tab { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 14px 0 11px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; transition: background 140ms, color 140ms, box-shadow 140ms; }
|
|
5
|
-
.tax-tab:hover { color: var(--ta-text); }
|
|
6
|
-
.tax-tab.tax-active { background: var(--ta-hover-strong); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
|
|
7
|
-
:root[data-theme='light'] .tax-tab.tax-active { background: var(--ta-card); box-shadow: 0 1px 2px rgba(0, 0, 0, .08), 0 0 0 .5px rgba(0, 0, 0, .06); }
|
|
8
|
-
.tax-tab:focus-visible { outline: 2px solid var(--ta-border-focus); outline-offset: 1px; }
|
|
9
|
-
.tax-empty-action { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px; }
|
|
10
|
-
.tax-market { display: flex; flex-direction: column; gap: 14px; }
|
|
11
|
-
.tax-search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 8px 0 15px; border: 1px solid var(--ta-border-field); border-radius: 12px; background: var(--ta-input); color: var(--ta-muted); transition: border-color 140ms, box-shadow 140ms; }
|
|
12
|
-
.tax-search:focus-within { border-color: var(--ta-border-focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ta-border-focus) 16%, transparent); }
|
|
13
|
-
.tax-search input { flex: 1; min-width: 0; height: 100%; padding: 0; border: 0; background: none; color: var(--ta-text); font: inherit; font-size: 14px; outline: none; }
|
|
14
|
-
.tax-search input::placeholder { color: var(--ta-muted); }
|
|
15
|
-
.tax-search input::-webkit-search-cancel-button { display: none; }
|
|
16
|
-
.tax-search-clear { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; flex: none; padding: 0; border: 0; border-radius: 7px; background: none; color: var(--ta-muted); cursor: pointer; }
|
|
17
|
-
.tax-search-clear:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
18
|
-
.tax-topics { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
19
|
-
.tax-topic { height: 28px; padding: 0 12px; border: 1px solid var(--ta-border-muted); border-radius: 14px; background: none; color: var(--ta-secondary); font: inherit; font-size: 12.5px; cursor: pointer; transition: background 120ms, border-color 120ms, color 120ms; }
|
|
20
|
-
.tax-topic:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
21
|
-
.tax-topic.tax-active { border-color: color-mix(in srgb, var(--tax-accent) 55%, transparent); background: color-mix(in srgb, var(--tax-accent) 12%, transparent); color: var(--ta-text); }
|
|
22
|
-
.tax-market .tax-section-head { margin-top: 4px; min-height: 22px; }
|
|
23
|
-
.tax-head-spin { color: var(--ta-muted); }
|
|
24
|
-
.tax-count-note { color: var(--ta-muted); font-size: 12px; }
|
|
25
|
-
.tax-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
26
|
-
@media (max-width: 640px) { .tax-grid { grid-template-columns: minmax(0, 1fr); } }
|
|
27
|
-
.tax-card { display: flex; flex-direction: column; gap: 10px; min-height: 150px; padding: 14px 14px 12px; border: 1px solid var(--ta-border-muted); border-radius: 14px; box-sizing: border-box; cursor: pointer; outline: none; transition: border-color 140ms, background 140ms, box-shadow 180ms, transform 180ms var(--ta-ease); }
|
|
28
|
-
.tax-card:hover { border-color: var(--ta-border); background: color-mix(in srgb, var(--ta-hover) 45%, transparent); box-shadow: 0 8px 24px -14px rgba(0, 0, 0, .35); transform: translateY(-1px); }
|
|
29
|
-
.tax-card:focus-visible { border-color: var(--ta-border-focus); }
|
|
30
|
-
.tax-card:active { transform: scale(.995); }
|
|
31
|
-
.tax-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
|
32
|
-
.tax-card-title { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
|
|
33
|
-
.tax-card-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
34
|
-
.tax-scope { color: var(--ta-muted); font-weight: 500; }
|
|
35
|
-
.tax-card-meta { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ta-muted); font-size: 12px; }
|
|
36
|
-
.tax-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
37
|
-
.tax-downloads { display: inline-flex; align-items: center; gap: 2px; flex: none; }
|
|
38
|
-
.tax-card-description { display: -webkit-box; margin: 0; overflow: hidden; color: var(--ta-secondary); font-size: 12.5px; line-height: 1.55; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
|
|
39
|
-
.tax-card-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; min-height: 17px; }
|
|
40
|
-
.tax-card-time { margin-left: auto; color: var(--ta-muted); font-size: 11.5px; white-space: nowrap; }
|
|
41
|
-
.tax-face { display: inline-flex; align-items: center; justify-content: center; flex: none; border-radius: 26%; background: hsl(var(--tax-hue) 70% 50% / .13); color: hsl(var(--tax-hue) 55% 38%); font-weight: 700; letter-spacing: -.02em; user-select: none; }
|
|
42
|
-
:root:not([data-theme='light']) .tax-face { background: hsl(var(--tax-hue) 60% 55% / .17); color: hsl(var(--tax-hue) 75% 74%); }
|
|
43
|
-
.tax-install { display: inline-flex; align-items: center; justify-content: center; gap: 5px; flex: none; height: 28px; padding: 0 14px; border: 0; border-radius: 14px; background: color-mix(in srgb, var(--ta-green) 14%, transparent); color: color-mix(in srgb, var(--ta-green) 82%, var(--ta-text)); font: inherit; font-size: 12.5px; font-weight: 600; white-space: nowrap; cursor: pointer; transition: background 140ms, color 140ms, transform 120ms var(--ta-ease), filter 140ms; }
|
|
44
|
-
.tax-install:hover { background: color-mix(in srgb, var(--ta-green) 24%, transparent); }
|
|
45
|
-
.tax-install:active { transform: scale(.95); }
|
|
46
|
-
.tax-install:focus-visible { outline: 2px solid var(--ta-border-focus); outline-offset: 2px; }
|
|
47
|
-
.tax-install-done, .tax-install-busy { background: var(--ta-chip); color: var(--ta-muted); font-weight: 500; cursor: default; }
|
|
48
|
-
.tax-install-busy { color: var(--ta-secondary); }
|
|
49
|
-
.tax-install-large { height: 34px; padding: 0 22px; border-radius: 9px; font-size: 13.5px; }
|
|
50
|
-
button.tax-install-large { background: var(--ta-green); color: var(--ta-brand-text); }
|
|
51
|
-
button.tax-install-large:hover { background: var(--ta-green); filter: brightness(1.07); }
|
|
52
|
-
.tax-spin { display: inline-flex; animation: tax-spin 900ms linear infinite; }
|
|
53
|
-
@keyframes tax-spin { to { transform: rotate(360deg); } }
|
|
54
|
-
.tax-skeleton { cursor: default; border-color: transparent; background: linear-gradient(100deg, var(--ta-hover) 40%, var(--ta-hover-strong) 50%, var(--ta-hover) 60%) 0 0 / 200% 100%; animation: tax-shimmer 1.4s linear infinite; opacity: .6; }
|
|
55
|
-
.tax-skeleton:hover { border-color: transparent; box-shadow: none; transform: none; }
|
|
56
|
-
@keyframes tax-shimmer { to { background-position: -200% 0; } }
|
|
57
|
-
.tax-more { padding: 6px 0 2px; color: var(--ta-muted); font-size: 12px; text-align: center; }
|
|
58
|
-
.tax-market-error { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
|
59
|
-
.tax-market-error strong { color: var(--ta-text); font-weight: 600; }
|
|
60
|
-
.tax-market-error span { max-width: 100%; overflow-wrap: anywhere; font-size: 12.5px; }
|
|
61
|
-
.tax-market-note { text-align: center; }
|
|
62
|
-
.tax-detail { display: flex; flex-direction: column; gap: 20px; animation: tax-in 220ms var(--ta-ease); }
|
|
63
|
-
@keyframes tax-in { from { opacity: 0; transform: translateY(6px); } }
|
|
64
|
-
.tax-back { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; height: 28px; margin: 0 0 -6px -8px; padding: 0 10px 0 6px; border: 0; border-radius: 7px; background: none; color: var(--ta-secondary); font: inherit; font-size: 13px; cursor: pointer; }
|
|
65
|
-
.tax-back:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
66
|
-
.tax-detail-head { display: flex; align-items: flex-start; gap: 20px; }
|
|
67
|
-
.tax-detail-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
|
|
68
|
-
.tax-detail-title h1 { margin: 2px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
|
|
69
|
-
.tax-detail-description { margin: 6px 0 0; color: var(--ta-secondary); font-size: 14px; line-height: 1.55; }
|
|
70
|
-
.tax-detail-facts { display: flex; flex-wrap: wrap; align-items: center; row-gap: 4px; margin-top: 10px; color: var(--ta-muted); font-size: 12.5px; }
|
|
71
|
-
.tax-detail-facts .tax-tag { margin-right: 6px; }
|
|
72
|
-
.tax-detail-facts .tax-tag + .tax-fact { margin-left: 4px; }
|
|
73
|
-
.tax-fact + .tax-fact::before { content: '·'; margin: 0 7px; }
|
|
74
|
-
.tax-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
|
|
75
|
-
.tax-button-quiet { height: 34px; color: var(--ta-secondary); text-decoration: none; }
|
|
76
|
-
.tax-button-quiet:hover { color: var(--ta-text); }
|
|
77
|
-
.tax-button-quiet svg { color: var(--ta-muted); }
|
|
78
|
-
.tax-preview { display: block; width: 100%; max-height: 380px; border: 1px solid var(--ta-border-muted); border-radius: 12px; background: var(--ta-raised); object-fit: contain; }
|
|
79
|
-
.tax-readme { padding-top: 20px; border-top: 1px solid var(--ta-border-muted); font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
|
|
80
|
-
.tax-readme img { max-width: 100%; height: auto; }
|
|
81
|
-
.tax-readme-loading { display: flex; flex-direction: column; gap: 12px; }
|
|
82
|
-
.tax-readme-loading span { height: 12px; border-radius: 6px; background: linear-gradient(100deg, var(--ta-hover) 40%, var(--ta-hover-strong) 50%, var(--ta-hover) 60%) 0 0 / 200% 100%; animation: tax-shimmer 1.4s linear infinite; }
|
|
83
|
-
.tax-readme-loading span:nth-child(1) { width: 92%; }
|
|
84
|
-
.tax-readme-loading span:nth-child(2) { width: 78%; }
|
|
85
|
-
.tax-readme-loading span:nth-child(3) { width: 85%; }
|
|
86
|
-
@media (max-width: 640px) {
|
|
87
|
-
.tax-detail-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 14px; }
|
|
88
|
-
.tax-detail-title { display: contents; }
|
|
89
|
-
.tax-detail-title > :not(h1) { grid-column: 1 / -1; }
|
|
90
|
-
.tax-detail-head .tax-face { width: 52px !important; height: 52px !important; font-size: 19px !important; }
|
|
91
|
-
.tax-detail-title h1 { margin: 0; font-size: 19px; }
|
|
92
|
-
.tax-detail-description { margin-top: 12px; }
|
|
93
|
-
}
|
|
94
|
-
`;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'bun:test';
|
|
2
|
-
import { MarketUtil } from './market-util';
|
|
3
|
-
|
|
4
|
-
describe('MarketUtil', () => {
|
|
5
|
-
it('tells the kinds of a package by its keywords, in one order', () => {
|
|
6
|
-
expect(MarketUtil.kindsOf(['pi-package', 'Theme', 'skill', 'pi-extension', 'other'])).toEqual(['extensions', 'skills', 'themes']);
|
|
7
|
-
expect(MarketUtil.kindsOf(undefined)).toEqual([]);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('counts downloads as galleries do', () => {
|
|
11
|
-
expect(MarketUtil.compact(999)).toBe('999');
|
|
12
|
-
expect(MarketUtil.compact(1234)).toBe('1.2K');
|
|
13
|
-
expect(MarketUtil.compact(887_900)).toBe('888K');
|
|
14
|
-
expect(MarketUtil.compact(3_284_659)).toBe('3.3M');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('says how long ago, in the largest unit that fits', () => {
|
|
18
|
-
const now = Date.parse('2026-11-11T00:00:00Z');
|
|
19
|
-
expect(MarketUtil.ago('2026-11-08T00:00:00Z', 'en', now)).toBe('3 days ago');
|
|
20
|
-
expect(MarketUtil.ago('2026-11-10T23:59:30Z', 'en', now)).toBe('this minute');
|
|
21
|
-
expect(MarketUtil.ago('nope', 'en', now)).toBeUndefined();
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it('gives a package the same initials and hue every time', () => {
|
|
25
|
-
expect(MarketUtil.monogram('@you/pi-web-access')).toEqual(MarketUtil.monogram('@you/pi-web-access'));
|
|
26
|
-
expect(MarketUtil.monogram('@you/pi-web-access').letters).toBe('WA');
|
|
27
|
-
expect(MarketUtil.monogram('pomodoro').letters).toBe('PO');
|
|
28
|
-
expect(MarketUtil.shortName('@scope/pi-tools')).toBe('tools');
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('names an owner, not the robot that published', () => {
|
|
32
|
-
expect(MarketUtil.person('GitHub Actions', 'you')).toBe('you');
|
|
33
|
-
expect(MarketUtil.person(undefined, 'you')).toBe('you');
|
|
34
|
-
expect(MarketUtil.person('github-actions', 'renovate[bot]')).toBeUndefined();
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it('finds the page of a repository', () => {
|
|
38
|
-
expect(MarketUtil.repositoryUrl('git+https://github.com/a/b.git')).toBe('https://github.com/a/b');
|
|
39
|
-
expect(MarketUtil.repositoryUrl({ url: 'git://github.com/a/b.git' })).toBe('https://github.com/a/b');
|
|
40
|
-
expect(MarketUtil.repositoryUrl('github:a/b')).toBe('https://github.com/a/b');
|
|
41
|
-
expect(MarketUtil.repositoryUrl('file:../b')).toBeUndefined();
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('matches each word of a search, a plural too', () => {
|
|
45
|
-
const pkg = { name: 'pi-web-search', description: 'Search the web', keywords: ['theme'] };
|
|
46
|
-
expect(MarketUtil.matches(pkg, 'Web search')).toBe(true);
|
|
47
|
-
expect(MarketUtil.matches(pkg, 'themes')).toBe(true);
|
|
48
|
-
expect(MarketUtil.matches(pkg, 'web pomodoro')).toBe(false);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('makes a README readable without HTML, and its relative links point to the repository', () => {
|
|
52
|
-
const readme = [
|
|
53
|
-
'<p align="center"><img src="./banner.png" alt="Banner" width="600"></p>',
|
|
54
|
-
'<!-- hidden -->',
|
|
55
|
-
'[](https://npmjs.com/x) <img src="https://badgen.net/x">',
|
|
56
|
-
'<h2 align="center">Install <b>it</b></h2>',
|
|
57
|
-
'See [the docs](docs/usage.md), <a href="https://pi.dev">pi</a> and .',
|
|
58
|
-
'```html',
|
|
59
|
-
'<div class="kept"><img src="./in-code.png"></div>',
|
|
60
|
-
'```',
|
|
61
|
-
].join('\n');
|
|
62
|
-
const text = MarketUtil.readableReadme(readme, 'https://github.com/a/b');
|
|
63
|
-
expect(text).toContain('');
|
|
64
|
-
expect(text).toContain('## Install it');
|
|
65
|
-
expect(text).toContain('[the docs](https://github.com/a/b/blob/HEAD/docs/usage.md)');
|
|
66
|
-
expect(text).toContain('[pi](https://pi.dev)');
|
|
67
|
-
expect(text).toContain('');
|
|
68
|
-
expect(text).toContain('<div class="kept"><img src="./in-code.png"></div>');
|
|
69
|
-
expect(text).not.toContain('shields.io');
|
|
70
|
-
expect(text).not.toContain('badgen');
|
|
71
|
-
expect(text).not.toContain('hidden');
|
|
72
|
-
expect(text).not.toContain('<p');
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('leaves links alone without a repository on GitHub', () => {
|
|
76
|
-
expect(MarketUtil.readableReadme('[a](docs/a.md)', undefined)).toBe('[a](docs/a.md)');
|
|
77
|
-
expect(MarketUtil.readableReadme('[a](docs/a.md)', 'https://gitlab.com/a/b')).toBe('[a](docs/a.md)');
|
|
78
|
-
});
|
|
79
|
-
});
|