@celljs/ta-extensions 4.6.1 → 4.8.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 +27 -0
- package/README.md +10 -3
- package/host/index.mjs +331 -1
- package/package.json +3 -3
- package/skills/ta-package/SKILL.md +3 -2
- package/web/index.js +937 -54
- package/web-src/actions.ts +20 -0
- package/web-src/context.ts +24 -0
- package/web-src/host.ts +16 -2
- package/web-src/i18n.ts +85 -2
- package/web-src/index.tsx +26 -22
- package/web-src/market-detail.tsx +138 -0
- package/web-src/market-parts.tsx +94 -0
- package/web-src/market-store.ts +116 -0
- package/web-src/market-style.ts +94 -0
- package/web-src/market-util.spec.ts +79 -0
- package/web-src/market-util.ts +239 -0
- package/web-src/market-view.tsx +245 -0
- package/web-src/market.spec.ts +154 -0
- package/web-src/market.ts +232 -0
- package/web-src/page.tsx +124 -92
- package/web-src/signal.ts +34 -0
- package/web-src/style.ts +4 -2
package/web/index.js
CHANGED
|
@@ -43,7 +43,45 @@ var EN = {
|
|
|
43
43
|
changeTitle: "Change {name}",
|
|
44
44
|
changePlaceholder: "What should it do differently?",
|
|
45
45
|
mine: "Yours",
|
|
46
|
-
mineEmpty: "None yet: say what you want above.",
|
|
46
|
+
mineEmpty: "None yet: say what you want above, or find one in the marketplace.",
|
|
47
|
+
tabMine: "Mine",
|
|
48
|
+
tabMarket: "Marketplace",
|
|
49
|
+
browseMarket: "Browse the marketplace",
|
|
50
|
+
marketSearch: "Search extensions, for example web search, mcp",
|
|
51
|
+
marketClear: "Clear",
|
|
52
|
+
marketPopular: "Most used",
|
|
53
|
+
marketResults: "Results",
|
|
54
|
+
marketCount: "{count} in all",
|
|
55
|
+
marketNote: "Pi packages from npm. An extension runs code on this computer: read what it does before installing it.",
|
|
56
|
+
marketEmpty: "Nothing matches “{query}”. Try other words.",
|
|
57
|
+
marketError: "The marketplace cannot be reached",
|
|
58
|
+
retry: "Try again",
|
|
59
|
+
installing: "Installing…",
|
|
60
|
+
installedTag: "Installed",
|
|
61
|
+
builtinTag: "Built in",
|
|
62
|
+
perMonth: "{count}/mo",
|
|
63
|
+
by: "by {name}",
|
|
64
|
+
back: "Back",
|
|
65
|
+
source: "Source",
|
|
66
|
+
homepage: "Homepage",
|
|
67
|
+
noReadme: "It says nothing more about itself.",
|
|
68
|
+
readmeTitle: "Details",
|
|
69
|
+
loadingMore: "Loading more…",
|
|
70
|
+
allShown: "That is all of them.",
|
|
71
|
+
topics: [
|
|
72
|
+
{ label: "Web search", query: "web search" },
|
|
73
|
+
{ label: "MCP", query: "mcp" },
|
|
74
|
+
{ label: "Subagents", query: "subagent" },
|
|
75
|
+
{ label: "Memory", query: "memory" },
|
|
76
|
+
{ label: "Browser", query: "browser" },
|
|
77
|
+
{ label: "Themes", query: "theme" }
|
|
78
|
+
],
|
|
79
|
+
marketKinds: {
|
|
80
|
+
extensions: "Extension",
|
|
81
|
+
skills: "Skill",
|
|
82
|
+
prompts: "Prompts",
|
|
83
|
+
themes: "Theme"
|
|
84
|
+
},
|
|
47
85
|
installed: "Installed",
|
|
48
86
|
import: "Import",
|
|
49
87
|
export: "Export",
|
|
@@ -117,7 +155,45 @@ var ZH = {
|
|
|
117
155
|
changeTitle: "修改 {name}",
|
|
118
156
|
changePlaceholder: "想让它有什么不同?",
|
|
119
157
|
mine: "我的扩展",
|
|
120
|
-
mineEmpty: "
|
|
158
|
+
mineEmpty: "还没有。在上面说一句就能做一个,也可以去市场找找。",
|
|
159
|
+
tabMine: "我的",
|
|
160
|
+
tabMarket: "市场",
|
|
161
|
+
browseMarket: "去市场看看",
|
|
162
|
+
marketSearch: "用英文搜索扩展,例如 web search、mcp",
|
|
163
|
+
marketClear: "清除",
|
|
164
|
+
marketPopular: "最常用",
|
|
165
|
+
marketResults: "搜索结果",
|
|
166
|
+
marketCount: "共 {count} 个",
|
|
167
|
+
marketNote: "来自 npm 上的 pi 包。扩展会在这台电脑上运行代码,安装前可以先看看介绍。",
|
|
168
|
+
marketEmpty: "没有找到“{query}”相关的扩展,换个词试试。",
|
|
169
|
+
marketError: "暂时连不上扩展市场",
|
|
170
|
+
retry: "重试",
|
|
171
|
+
installing: "安装中…",
|
|
172
|
+
installedTag: "已安装",
|
|
173
|
+
builtinTag: "内置",
|
|
174
|
+
perMonth: "{count}/月",
|
|
175
|
+
by: "{name}",
|
|
176
|
+
back: "返回",
|
|
177
|
+
source: "源代码",
|
|
178
|
+
homepage: "主页",
|
|
179
|
+
noReadme: "作者没有写更多介绍。",
|
|
180
|
+
readmeTitle: "介绍",
|
|
181
|
+
loadingMore: "正在加载更多…",
|
|
182
|
+
allShown: "已经到底了",
|
|
183
|
+
topics: [
|
|
184
|
+
{ label: "网页搜索", query: "web search" },
|
|
185
|
+
{ label: "MCP", query: "mcp" },
|
|
186
|
+
{ label: "子 Agent", query: "subagent" },
|
|
187
|
+
{ label: "记忆", query: "memory" },
|
|
188
|
+
{ label: "浏览器", query: "browser" },
|
|
189
|
+
{ label: "主题", query: "theme" }
|
|
190
|
+
],
|
|
191
|
+
marketKinds: {
|
|
192
|
+
extensions: "扩展",
|
|
193
|
+
skills: "技能",
|
|
194
|
+
prompts: "提示模板",
|
|
195
|
+
themes: "主题"
|
|
196
|
+
},
|
|
121
197
|
installed: "安装的扩展",
|
|
122
198
|
import: "导入",
|
|
123
199
|
export: "导出",
|
|
@@ -216,9 +292,11 @@ class PackagesStore {
|
|
|
216
292
|
class ExtensionActions {
|
|
217
293
|
pi;
|
|
218
294
|
store;
|
|
219
|
-
|
|
295
|
+
market;
|
|
296
|
+
constructor(pi, store, market) {
|
|
220
297
|
this.pi = pi;
|
|
221
298
|
this.store = store;
|
|
299
|
+
this.market = market;
|
|
222
300
|
}
|
|
223
301
|
get words() {
|
|
224
302
|
return ExtensionWords.of(this.pi.ui.language);
|
|
@@ -311,6 +389,22 @@ class ExtensionActions {
|
|
|
311
389
|
return true;
|
|
312
390
|
});
|
|
313
391
|
}
|
|
392
|
+
async installFromMarket(name) {
|
|
393
|
+
if (this.market.state.installing.has(name)) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
this.market.setInstalling(name, true);
|
|
397
|
+
try {
|
|
398
|
+
return await this.guard(async () => {
|
|
399
|
+
await this.pi.packages.installPackage(`npm:${name}`, "user");
|
|
400
|
+
await this.changed();
|
|
401
|
+
this.pi.ui.notify(ExtensionWords.fill(this.words.installedOk, { name }));
|
|
402
|
+
return true;
|
|
403
|
+
});
|
|
404
|
+
} finally {
|
|
405
|
+
this.market.setInstalling(name, false);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
314
408
|
async changed() {
|
|
315
409
|
await this.pi.reloadExtensions();
|
|
316
410
|
await this.store.load();
|
|
@@ -334,6 +428,96 @@ class ExtensionActions {
|
|
|
334
428
|
}
|
|
335
429
|
}
|
|
336
430
|
|
|
431
|
+
// web-src/market-store.ts
|
|
432
|
+
class MarketStore {
|
|
433
|
+
pi;
|
|
434
|
+
current = { query: "", loading: false, installing: new Set };
|
|
435
|
+
listeners = new Set;
|
|
436
|
+
details = new Map;
|
|
437
|
+
generation = 0;
|
|
438
|
+
constructor(pi) {
|
|
439
|
+
this.pi = pi;
|
|
440
|
+
}
|
|
441
|
+
get state() {
|
|
442
|
+
return this.current;
|
|
443
|
+
}
|
|
444
|
+
subscribe(listener) {
|
|
445
|
+
this.listeners.add(listener);
|
|
446
|
+
return () => this.listeners.delete(listener);
|
|
447
|
+
}
|
|
448
|
+
async search(query) {
|
|
449
|
+
const trimmed = query.trim();
|
|
450
|
+
if (trimmed === this.current.query && (this.current.packages || this.current.loading) && !this.current.error) {
|
|
451
|
+
return;
|
|
452
|
+
}
|
|
453
|
+
const generation = ++this.generation;
|
|
454
|
+
this.set({ query: trimmed, loading: true, error: undefined });
|
|
455
|
+
try {
|
|
456
|
+
const page = await this.pi.callHost("searchMarket", trimmed, 0);
|
|
457
|
+
if (generation === this.generation) {
|
|
458
|
+
this.set({ packages: page.packages, total: page.total, next: page.next, loading: false });
|
|
459
|
+
}
|
|
460
|
+
} catch (error) {
|
|
461
|
+
if (generation === this.generation) {
|
|
462
|
+
this.set({ packages: undefined, total: undefined, next: undefined, loading: false, error: MarketStore.message(error) });
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
async more() {
|
|
467
|
+
const { packages, next, loading, query } = this.current;
|
|
468
|
+
if (!packages || loading || next === undefined) {
|
|
469
|
+
return;
|
|
470
|
+
}
|
|
471
|
+
const generation = this.generation;
|
|
472
|
+
this.set({ loading: true });
|
|
473
|
+
try {
|
|
474
|
+
const page = await this.pi.callHost("searchMarket", query, next);
|
|
475
|
+
if (generation === this.generation) {
|
|
476
|
+
const seen = new Set(packages.map((pkg) => pkg.name));
|
|
477
|
+
const fresh = page.packages.filter((pkg) => !seen.has(pkg.name));
|
|
478
|
+
this.set({ packages: [...packages, ...fresh], next: fresh.length ? page.next : undefined, loading: false });
|
|
479
|
+
}
|
|
480
|
+
} catch (error) {
|
|
481
|
+
if (generation === this.generation) {
|
|
482
|
+
this.set({ loading: false });
|
|
483
|
+
this.pi.ui.notify(MarketStore.message(error), "error");
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
detail(name) {
|
|
488
|
+
let detail = this.details.get(name);
|
|
489
|
+
if (!detail) {
|
|
490
|
+
detail = this.pi.callHost("marketPackage", name);
|
|
491
|
+
this.details.set(name, detail);
|
|
492
|
+
detail.catch(() => this.details.delete(name));
|
|
493
|
+
}
|
|
494
|
+
return detail;
|
|
495
|
+
}
|
|
496
|
+
setInstalling(name, installing) {
|
|
497
|
+
const next = new Set(this.current.installing);
|
|
498
|
+
if (installing) {
|
|
499
|
+
next.add(name);
|
|
500
|
+
} else {
|
|
501
|
+
next.delete(name);
|
|
502
|
+
}
|
|
503
|
+
this.set({ installing: next });
|
|
504
|
+
}
|
|
505
|
+
set(change) {
|
|
506
|
+
this.current = { ...this.current, ...change };
|
|
507
|
+
for (const listener of this.listeners) {
|
|
508
|
+
listener();
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
static message(error) {
|
|
512
|
+
return error instanceof Error ? error.message : String(error);
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
// web-src/context.ts
|
|
517
|
+
function icon(pi, name, fallback = "Square") {
|
|
518
|
+
return pi.ui.icons[name] ?? pi.ui.icons[fallback] ?? (() => null);
|
|
519
|
+
}
|
|
520
|
+
|
|
337
521
|
// web-src/react.ts
|
|
338
522
|
var React;
|
|
339
523
|
function bind(react) {
|
|
@@ -415,6 +599,546 @@ function ImportDialog({ pi, actions, onClose }) {
|
|
|
415
599
|
}, words.trust)));
|
|
416
600
|
}
|
|
417
601
|
|
|
602
|
+
// web-src/market-util.ts
|
|
603
|
+
var KIND_WORDS = {
|
|
604
|
+
extension: "extensions",
|
|
605
|
+
extensions: "extensions",
|
|
606
|
+
"pi-extension": "extensions",
|
|
607
|
+
skill: "skills",
|
|
608
|
+
skills: "skills",
|
|
609
|
+
"pi-skill": "skills",
|
|
610
|
+
prompt: "prompts",
|
|
611
|
+
prompts: "prompts",
|
|
612
|
+
"pi-prompt": "prompts",
|
|
613
|
+
"prompt-template": "prompts",
|
|
614
|
+
theme: "themes",
|
|
615
|
+
themes: "themes",
|
|
616
|
+
"pi-theme": "themes"
|
|
617
|
+
};
|
|
618
|
+
var KIND_ORDER = ["extensions", "skills", "prompts", "themes"];
|
|
619
|
+
var MarketUtil;
|
|
620
|
+
((MarketUtil) => {
|
|
621
|
+
function kindsOf(keywords) {
|
|
622
|
+
const found = new Set;
|
|
623
|
+
for (const keyword of Array.isArray(keywords) ? keywords : []) {
|
|
624
|
+
const kind = typeof keyword === "string" ? KIND_WORDS[keyword.toLowerCase()] : undefined;
|
|
625
|
+
if (kind) {
|
|
626
|
+
found.add(kind);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
return KIND_ORDER.filter((kind) => found.has(kind));
|
|
630
|
+
}
|
|
631
|
+
MarketUtil.kindsOf = kindsOf;
|
|
632
|
+
function compact(count) {
|
|
633
|
+
const units = [
|
|
634
|
+
[1e9, "B"],
|
|
635
|
+
[1e6, "M"],
|
|
636
|
+
[1000, "K"]
|
|
637
|
+
];
|
|
638
|
+
for (const [size, unit] of units) {
|
|
639
|
+
if (count >= size) {
|
|
640
|
+
const value = count / size;
|
|
641
|
+
return `${value >= 100 ? Math.round(value) : Number(value.toFixed(1))}${unit}`;
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return String(count);
|
|
645
|
+
}
|
|
646
|
+
MarketUtil.compact = compact;
|
|
647
|
+
function ago(iso, language, now = Date.now()) {
|
|
648
|
+
const time = iso ? Date.parse(iso) : Number.NaN;
|
|
649
|
+
if (Number.isNaN(time)) {
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
const seconds = Math.round((time - now) / 1000);
|
|
653
|
+
const steps = [
|
|
654
|
+
["year", 31536000],
|
|
655
|
+
["month", 2592000],
|
|
656
|
+
["week", 604800],
|
|
657
|
+
["day", 86400],
|
|
658
|
+
["hour", 3600],
|
|
659
|
+
["minute", 60]
|
|
660
|
+
];
|
|
661
|
+
const format = new Intl.RelativeTimeFormat(language, { numeric: "auto" });
|
|
662
|
+
for (const [unit, size] of steps) {
|
|
663
|
+
if (Math.abs(seconds) >= size) {
|
|
664
|
+
return format.format(Math.round(seconds / size), unit);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return format.format(0, "minute");
|
|
668
|
+
}
|
|
669
|
+
MarketUtil.ago = ago;
|
|
670
|
+
function person(...names) {
|
|
671
|
+
return names.find((name) => !!name && !/^github[ -]actions$|\[bot\]$|^npm-?bot$/i.test(name)) ?? undefined;
|
|
672
|
+
}
|
|
673
|
+
MarketUtil.person = person;
|
|
674
|
+
function shortName(name) {
|
|
675
|
+
const plain = name.slice(name.lastIndexOf("/") + 1);
|
|
676
|
+
return plain.replace(/^pi-(?=.)/, "");
|
|
677
|
+
}
|
|
678
|
+
MarketUtil.shortName = shortName;
|
|
679
|
+
function monogram(name) {
|
|
680
|
+
const words = shortName(name).split(/[-_.\s]+/).filter(Boolean);
|
|
681
|
+
const letters = (words.length > 1 ? words[0][0] + words[1][0] : (words[0] ?? name).slice(0, 2)).toUpperCase();
|
|
682
|
+
let hash = 0;
|
|
683
|
+
for (let i = 0;i < name.length; i++) {
|
|
684
|
+
hash = hash * 31 + name.charCodeAt(i) | 0;
|
|
685
|
+
}
|
|
686
|
+
return { letters, hue: Math.abs(hash) % 360 };
|
|
687
|
+
}
|
|
688
|
+
MarketUtil.monogram = monogram;
|
|
689
|
+
function repositoryUrl(repository) {
|
|
690
|
+
const raw = typeof repository === "string" ? repository : repository?.url;
|
|
691
|
+
if (typeof raw !== "string") {
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
const github = /^github:(.+)$/.exec(raw) ?? /^([\w.-]+\/[\w.-]+)$/.exec(raw);
|
|
695
|
+
const url = github ? `https://github.com/${github[1]}` : raw.replace(/^git\+/, "").replace(/^git:\/\//, "https://").replace(/^ssh:\/\/git@/, "https://");
|
|
696
|
+
return /^https?:\/\//.test(url) ? url.replace(/\.git$/, "").replace(/\/$/, "") : undefined;
|
|
697
|
+
}
|
|
698
|
+
MarketUtil.repositoryUrl = repositoryUrl;
|
|
699
|
+
function matches(pkg, query) {
|
|
700
|
+
const text = [pkg.name, pkg.description ?? "", ...pkg.keywords ?? []].join(" ").toLowerCase();
|
|
701
|
+
return query.toLowerCase().split(/\s+/).filter(Boolean).every((word) => text.includes(word) || word.length > 3 && word.endsWith("s") && text.includes(word.slice(0, -1)));
|
|
702
|
+
}
|
|
703
|
+
MarketUtil.matches = matches;
|
|
704
|
+
function readableReadme(readme, repository) {
|
|
705
|
+
const parts = readme.split(/(^[ \t]*(?:```|~~~)[^\n]*\n[\s\S]*?^[ \t]*(?:```|~~~)[ \t]*$)/m);
|
|
706
|
+
return parts.map((part, index) => index % 2 === 1 ? part : absoluteReadme(fromHtml(part), repository).replace(/\n{3,}/g, `
|
|
707
|
+
|
|
708
|
+
`)).join("").trim();
|
|
709
|
+
}
|
|
710
|
+
MarketUtil.readableReadme = readableReadme;
|
|
711
|
+
function attribute(tag, name) {
|
|
712
|
+
return new RegExp(`\\b${name}\\s*=\\s*(["'])(.*?)\\1`, "i").exec(tag)?.[2];
|
|
713
|
+
}
|
|
714
|
+
function isBadge(src) {
|
|
715
|
+
return /shields\.io|badgen\.net|badge/i.test(src);
|
|
716
|
+
}
|
|
717
|
+
function fromHtml(text) {
|
|
718
|
+
return text.replace(/<!--[\s\S]*?-->/g, "").replace(/<(source|meta|link)\b[^>]*>/gi, "").replace(/<img\b[^>]*>/gi, (tag) => {
|
|
719
|
+
const src = attribute(tag, "src");
|
|
720
|
+
return src && !isBadge(src) ? `
|
|
721
|
+
|
|
722
|
+

|
|
723
|
+
|
|
724
|
+
` : "";
|
|
725
|
+
}).replace(/!\[[^\]]*\]\(([^)\s]+)[^)]*\)/g, (whole, src) => isBadge(src) ? "" : whole).replace(/<a\b[^>]*>([\s\S]*?)<\/a>/gi, (tag, inner) => {
|
|
726
|
+
const href = attribute(tag, "href");
|
|
727
|
+
const label = inner.trim();
|
|
728
|
+
return !label ? "" : href && !label.includes("` : label;
|
|
729
|
+
}).replace(/\[\s*\]\([^)]*\)/g, "").replace(/<h([1-6])\b[^>]*>([\s\S]*?)<\/h\1>/gi, (_whole, level, inner) => `
|
|
730
|
+
|
|
731
|
+
${"#".repeat(Number(level))} ${inner.replace(/<[^>]+>/g, "").trim()}
|
|
732
|
+
|
|
733
|
+
`).replace(/<br\s*\/?>/gi, `
|
|
734
|
+
`).replace(/<\/?(p|div|span|center|picture|details|summary|b|strong|em|i|u|sub|sup|kbd|small|big|font|table|thead|tbody|tr|td|th|hr|section|article|figure|figcaption)\b[^>]*>/gi, "").replace(/^[ \t]+$/gm, "");
|
|
735
|
+
}
|
|
736
|
+
function absoluteReadme(readme, repository) {
|
|
737
|
+
const github = repository ? /^https:\/\/github\.com\/([^/]+\/[^/#?]+)/.exec(repository)?.[1] : undefined;
|
|
738
|
+
if (!github) {
|
|
739
|
+
return readme;
|
|
740
|
+
}
|
|
741
|
+
const resolve = (target, image) => {
|
|
742
|
+
if (/^([a-z][a-z0-9+.-]*:|#|\/\/)/i.test(target)) {
|
|
743
|
+
return target;
|
|
744
|
+
}
|
|
745
|
+
const path = target.replace(/^\.?\//, "");
|
|
746
|
+
return image ? `https://raw.githubusercontent.com/${github}/HEAD/${path}` : `https://github.com/${github}/blob/HEAD/${path}`;
|
|
747
|
+
};
|
|
748
|
+
return readme.replace(/(!?)\[([^\]]*)\]\(\s*<?([^)\s>]+)>?(\s+"[^"]*")?\s*\)/g, (_whole, bang, text, target, title = "") => {
|
|
749
|
+
return `${bang}[${text}](${resolve(target, bang === "!")}${title})`;
|
|
750
|
+
}).replace(/(<img\b[^>]*\bsrc=)(["'])([^"']+)\2/gi, (_whole, head, quote, target) => `${head}${quote}${resolve(target, true)}${quote}`);
|
|
751
|
+
}
|
|
752
|
+
MarketUtil.absoluteReadme = absoluteReadme;
|
|
753
|
+
})(MarketUtil ||= {});
|
|
754
|
+
|
|
755
|
+
// web-src/market-parts.tsx
|
|
756
|
+
function useMarketStatus(context, name) {
|
|
757
|
+
const { packages } = React.useSyncExternalStore((listener) => context.store.subscribe(listener), () => context.store.state);
|
|
758
|
+
const installing = React.useSyncExternalStore((listener) => context.market.subscribe(listener), () => context.market.state.installing.has(name));
|
|
759
|
+
if (installing) {
|
|
760
|
+
return { kind: "installing" };
|
|
761
|
+
}
|
|
762
|
+
const pkg = packages?.find((candidate) => candidate.name === name);
|
|
763
|
+
return !pkg ? { kind: "none" } : pkg.origin === "builtin" ? { kind: "builtin" } : { kind: "installed", pkg };
|
|
764
|
+
}
|
|
765
|
+
function PackageFace({ name, size }) {
|
|
766
|
+
const { letters, hue } = MarketUtil.monogram(name);
|
|
767
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
768
|
+
className: "tax-face",
|
|
769
|
+
"aria-hidden": "true",
|
|
770
|
+
style: { width: size, height: size, fontSize: Math.round(size * 0.36), ["--tax-hue"]: hue }
|
|
771
|
+
}, letters);
|
|
772
|
+
}
|
|
773
|
+
function PackageName({ name }) {
|
|
774
|
+
const slash = name.startsWith("@") ? name.indexOf("/") : -1;
|
|
775
|
+
return slash > 0 ? /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("span", {
|
|
776
|
+
className: "tax-scope"
|
|
777
|
+
}, name.slice(0, slash + 1)), name.slice(slash + 1)) : name;
|
|
778
|
+
}
|
|
779
|
+
function InstallButton({ context, name, large }) {
|
|
780
|
+
const { pi, actions } = context;
|
|
781
|
+
const words = actions.words;
|
|
782
|
+
const status = useMarketStatus(context, name);
|
|
783
|
+
const size = large ? " tax-install-large" : "";
|
|
784
|
+
if (status.kind === "installing") {
|
|
785
|
+
const Loader = icon(pi, "LoaderCircle");
|
|
786
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
787
|
+
className: `tax-install tax-install-busy${size}`,
|
|
788
|
+
role: "status"
|
|
789
|
+
}, /* @__PURE__ */ React.createElement("span", {
|
|
790
|
+
className: "tax-spin"
|
|
791
|
+
}, /* @__PURE__ */ React.createElement(Loader, {
|
|
792
|
+
size: large ? 15 : 13
|
|
793
|
+
})), words.installing);
|
|
794
|
+
}
|
|
795
|
+
if (status.kind !== "none") {
|
|
796
|
+
const Check = icon(pi, "Check");
|
|
797
|
+
return /* @__PURE__ */ React.createElement("span", {
|
|
798
|
+
className: `tax-install tax-install-done${size}`
|
|
799
|
+
}, status.kind === "installed" && /* @__PURE__ */ React.createElement(Check, {
|
|
800
|
+
size: large ? 15 : 13
|
|
801
|
+
}), status.kind === "installed" ? words.installedTag : words.builtinTag);
|
|
802
|
+
}
|
|
803
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
804
|
+
type: "button",
|
|
805
|
+
className: `tax-install${size}`,
|
|
806
|
+
onClick: (event) => {
|
|
807
|
+
event.stopPropagation();
|
|
808
|
+
actions.installFromMarket(name);
|
|
809
|
+
}
|
|
810
|
+
}, words.install);
|
|
811
|
+
}
|
|
812
|
+
|
|
813
|
+
// web-src/market-detail.tsx
|
|
814
|
+
function MarketDetailView({ context, name, onBack }) {
|
|
815
|
+
const { pi, market, actions } = context;
|
|
816
|
+
const words = actions.words;
|
|
817
|
+
const [detail, setDetail] = React.useState();
|
|
818
|
+
const [error, setError] = React.useState();
|
|
819
|
+
const [attempt, setAttempt] = React.useState(0);
|
|
820
|
+
React.useEffect(() => {
|
|
821
|
+
let live = true;
|
|
822
|
+
setError(undefined);
|
|
823
|
+
market.detail(name).then((value) => live && setDetail(value), (reason) => live && setError(MarketStore.message(reason)));
|
|
824
|
+
return () => {
|
|
825
|
+
live = false;
|
|
826
|
+
};
|
|
827
|
+
}, [market, name, attempt]);
|
|
828
|
+
React.useEffect(() => {
|
|
829
|
+
const onKey = (event) => {
|
|
830
|
+
const target = event.target;
|
|
831
|
+
if (event.key === "Escape" && !document.querySelector('[aria-modal="true"]') && !target?.closest('input, textarea, [contenteditable="true"]')) {
|
|
832
|
+
onBack();
|
|
833
|
+
}
|
|
834
|
+
};
|
|
835
|
+
document.addEventListener("keydown", onKey);
|
|
836
|
+
return () => document.removeEventListener("keydown", onKey);
|
|
837
|
+
}, [onBack]);
|
|
838
|
+
const listed = market.state.packages?.find((pkg) => pkg.name === name);
|
|
839
|
+
const summary = detail ? { ...detail, date: detail.date ?? listed?.date, downloads: detail.downloads ?? listed?.downloads } : listed;
|
|
840
|
+
const status = useMarketStatus(context, name);
|
|
841
|
+
const ArrowLeft = icon(pi, "ArrowLeft");
|
|
842
|
+
const External = icon(pi, "ExternalLink");
|
|
843
|
+
const Trash = icon(pi, "Trash2");
|
|
844
|
+
const Markdown = pi.ui.Markdown;
|
|
845
|
+
const ago = MarketUtil.ago(summary?.date, pi.ui.language);
|
|
846
|
+
const facts = [
|
|
847
|
+
summary?.publisher,
|
|
848
|
+
summary?.version && `v${summary.version}`,
|
|
849
|
+
summary?.downloads ? ExtensionWords.fill(words.perMonth, { count: MarketUtil.compact(summary.downloads) }) : undefined,
|
|
850
|
+
detail?.license,
|
|
851
|
+
ago
|
|
852
|
+
].filter((fact) => !!fact);
|
|
853
|
+
const links = [
|
|
854
|
+
{ key: "npm", label: "npm", href: summary?.links.npm ?? `https://www.npmjs.com/package/${name}` },
|
|
855
|
+
{ key: "source", label: words.source, href: summary?.links.repository },
|
|
856
|
+
{ key: "home", label: words.homepage, href: summary?.links.homepage !== summary?.links.repository ? summary?.links.homepage : undefined }
|
|
857
|
+
].filter((link) => !!link.href && /^https?:\/\//.test(link.href));
|
|
858
|
+
const tags = ((detail?.resources.length) ? detail.resources : summary?.kinds ?? []).map((type) => type === "web" ? words.kinds.web : words.marketKinds[type]);
|
|
859
|
+
return /* @__PURE__ */ React.createElement("article", {
|
|
860
|
+
className: "tax-detail",
|
|
861
|
+
"aria-label": name
|
|
862
|
+
}, /* @__PURE__ */ React.createElement("button", {
|
|
863
|
+
type: "button",
|
|
864
|
+
className: "tax-back",
|
|
865
|
+
onClick: onBack
|
|
866
|
+
}, /* @__PURE__ */ React.createElement(ArrowLeft, {
|
|
867
|
+
size: 15
|
|
868
|
+
}), " ", words.back), /* @__PURE__ */ React.createElement("header", {
|
|
869
|
+
className: "tax-detail-head"
|
|
870
|
+
}, /* @__PURE__ */ React.createElement(PackageFace, {
|
|
871
|
+
name,
|
|
872
|
+
size: 72
|
|
873
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
874
|
+
className: "tax-detail-title"
|
|
875
|
+
}, /* @__PURE__ */ React.createElement("h1", null, /* @__PURE__ */ React.createElement(PackageName, {
|
|
876
|
+
name
|
|
877
|
+
})), summary?.description && /* @__PURE__ */ React.createElement("p", {
|
|
878
|
+
className: "tax-detail-description"
|
|
879
|
+
}, summary.description), (facts.length > 0 || tags.length > 0) && /* @__PURE__ */ React.createElement("div", {
|
|
880
|
+
className: "tax-detail-facts"
|
|
881
|
+
}, tags.map((tag) => /* @__PURE__ */ React.createElement("span", {
|
|
882
|
+
key: tag,
|
|
883
|
+
className: "tax-tag"
|
|
884
|
+
}, tag)), facts.map((fact) => /* @__PURE__ */ React.createElement("span", {
|
|
885
|
+
key: fact,
|
|
886
|
+
className: "tax-fact"
|
|
887
|
+
}, fact))), /* @__PURE__ */ React.createElement("div", {
|
|
888
|
+
className: "tax-detail-actions"
|
|
889
|
+
}, /* @__PURE__ */ React.createElement(InstallButton, {
|
|
890
|
+
context,
|
|
891
|
+
name,
|
|
892
|
+
large: true
|
|
893
|
+
}), status.kind === "installed" && /* @__PURE__ */ React.createElement("button", {
|
|
894
|
+
type: "button",
|
|
895
|
+
className: "tax-button tax-button-quiet",
|
|
896
|
+
onClick: () => void actions.remove(status.pkg)
|
|
897
|
+
}, /* @__PURE__ */ React.createElement(Trash, {
|
|
898
|
+
size: 14
|
|
899
|
+
}), " ", words.remove), links.map((link) => /* @__PURE__ */ React.createElement("a", {
|
|
900
|
+
key: link.key,
|
|
901
|
+
className: "tax-button tax-button-quiet",
|
|
902
|
+
href: link.href,
|
|
903
|
+
target: "_blank",
|
|
904
|
+
rel: "noreferrer noopener"
|
|
905
|
+
}, link.label, " ", /* @__PURE__ */ React.createElement(External, {
|
|
906
|
+
size: 13
|
|
907
|
+
})))))), detail?.video ? /* @__PURE__ */ React.createElement("video", {
|
|
908
|
+
className: "tax-preview",
|
|
909
|
+
src: detail.video,
|
|
910
|
+
controls: true,
|
|
911
|
+
muted: true,
|
|
912
|
+
playsInline: true,
|
|
913
|
+
preload: "metadata"
|
|
914
|
+
}) : detail?.image ? /* @__PURE__ */ React.createElement("img", {
|
|
915
|
+
className: "tax-preview",
|
|
916
|
+
src: detail.image,
|
|
917
|
+
alt: "",
|
|
918
|
+
loading: "lazy"
|
|
919
|
+
}) : null, /* @__PURE__ */ React.createElement("section", {
|
|
920
|
+
className: "tax-readme",
|
|
921
|
+
"aria-label": words.readmeTitle
|
|
922
|
+
}, error ? /* @__PURE__ */ React.createElement("div", {
|
|
923
|
+
className: "tax-empty tax-market-error"
|
|
924
|
+
}, /* @__PURE__ */ React.createElement("span", null, error), /* @__PURE__ */ React.createElement("button", {
|
|
925
|
+
type: "button",
|
|
926
|
+
className: "tax-button",
|
|
927
|
+
onClick: () => setAttempt(attempt + 1)
|
|
928
|
+
}, words.retry)) : !detail ? /* @__PURE__ */ React.createElement("div", {
|
|
929
|
+
className: "tax-readme-loading",
|
|
930
|
+
"aria-busy": "true"
|
|
931
|
+
}, /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", null), /* @__PURE__ */ React.createElement("span", null)) : detail.readme ? /* @__PURE__ */ React.createElement(Markdown, {
|
|
932
|
+
text: detail.readme
|
|
933
|
+
}) : /* @__PURE__ */ React.createElement("div", {
|
|
934
|
+
className: "tax-note"
|
|
935
|
+
}, words.noReadme)));
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
// web-src/market-view.tsx
|
|
939
|
+
var DEBOUNCE = 300;
|
|
940
|
+
function MarketView({ context }) {
|
|
941
|
+
const { market, selected } = context;
|
|
942
|
+
const name = selected.use();
|
|
943
|
+
const list = React.useRef(null);
|
|
944
|
+
const scroll = React.useRef(0);
|
|
945
|
+
const scroller = () => list.current?.closest(".tax-page") ?? undefined;
|
|
946
|
+
const open = (next) => {
|
|
947
|
+
scroll.current = scroller()?.scrollTop ?? 0;
|
|
948
|
+
selected.set(next);
|
|
949
|
+
};
|
|
950
|
+
React.useLayoutEffect(() => {
|
|
951
|
+
const element = scroller();
|
|
952
|
+
if (element) {
|
|
953
|
+
element.scrollTop = name ? 0 : scroll.current;
|
|
954
|
+
}
|
|
955
|
+
}, [name]);
|
|
956
|
+
React.useEffect(() => {
|
|
957
|
+
market.search(market.state.query);
|
|
958
|
+
}, [market]);
|
|
959
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
960
|
+
ref: list,
|
|
961
|
+
hidden: !!name
|
|
962
|
+
}, /* @__PURE__ */ React.createElement(MarketList, {
|
|
963
|
+
context,
|
|
964
|
+
onOpen: open
|
|
965
|
+
})), name && /* @__PURE__ */ React.createElement(MarketDetailView, {
|
|
966
|
+
key: name,
|
|
967
|
+
context,
|
|
968
|
+
name,
|
|
969
|
+
onBack: () => selected.set(undefined)
|
|
970
|
+
}));
|
|
971
|
+
}
|
|
972
|
+
function MarketList({ context, onOpen }) {
|
|
973
|
+
const { pi, market, actions } = context;
|
|
974
|
+
const words = actions.words;
|
|
975
|
+
const state = React.useSyncExternalStore((listener) => market.subscribe(listener), () => market.state);
|
|
976
|
+
const [text, setText] = React.useState(state.query);
|
|
977
|
+
const input = React.useRef(null);
|
|
978
|
+
React.useEffect(() => {
|
|
979
|
+
const timer = setTimeout(() => void market.search(text), DEBOUNCE);
|
|
980
|
+
return () => clearTimeout(timer);
|
|
981
|
+
}, [market, text]);
|
|
982
|
+
const pick = (query2) => {
|
|
983
|
+
setText(query2);
|
|
984
|
+
market.search(query2);
|
|
985
|
+
};
|
|
986
|
+
const Search = icon(pi, "Search");
|
|
987
|
+
const X = icon(pi, "X");
|
|
988
|
+
const { packages, loading, error, query, total, next } = state;
|
|
989
|
+
const count = query ? next === undefined ? packages?.length : undefined : total;
|
|
990
|
+
const first = loading && !packages;
|
|
991
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
992
|
+
className: "tax-market"
|
|
993
|
+
}, /* @__PURE__ */ React.createElement("form", {
|
|
994
|
+
className: "tax-search",
|
|
995
|
+
onSubmit: (event) => {
|
|
996
|
+
event.preventDefault();
|
|
997
|
+
market.search(text);
|
|
998
|
+
}
|
|
999
|
+
}, /* @__PURE__ */ React.createElement(Search, {
|
|
1000
|
+
size: 16
|
|
1001
|
+
}), /* @__PURE__ */ React.createElement("input", {
|
|
1002
|
+
ref: input,
|
|
1003
|
+
type: "search",
|
|
1004
|
+
value: text,
|
|
1005
|
+
placeholder: words.marketSearch,
|
|
1006
|
+
"aria-label": words.marketSearch,
|
|
1007
|
+
spellCheck: false,
|
|
1008
|
+
onChange: (event) => setText(event.target.value),
|
|
1009
|
+
onKeyDown: (event) => {
|
|
1010
|
+
if (event.key === "Escape" && text) {
|
|
1011
|
+
event.preventDefault();
|
|
1012
|
+
pick("");
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
}), text && /* @__PURE__ */ React.createElement("button", {
|
|
1016
|
+
type: "button",
|
|
1017
|
+
className: "tax-search-clear",
|
|
1018
|
+
"aria-label": words.marketClear,
|
|
1019
|
+
title: words.marketClear,
|
|
1020
|
+
onClick: () => {
|
|
1021
|
+
pick("");
|
|
1022
|
+
input.current?.focus();
|
|
1023
|
+
}
|
|
1024
|
+
}, /* @__PURE__ */ React.createElement(X, {
|
|
1025
|
+
size: 14
|
|
1026
|
+
}))), /* @__PURE__ */ React.createElement("div", {
|
|
1027
|
+
className: "tax-topics"
|
|
1028
|
+
}, words.topics.map((topic) => /* @__PURE__ */ React.createElement("button", {
|
|
1029
|
+
key: topic.query,
|
|
1030
|
+
type: "button",
|
|
1031
|
+
className: `tax-topic${query === topic.query ? " tax-active" : ""}`,
|
|
1032
|
+
"aria-pressed": query === topic.query,
|
|
1033
|
+
onClick: () => pick(query === topic.query ? "" : topic.query)
|
|
1034
|
+
}, topic.label))), /* @__PURE__ */ React.createElement("div", {
|
|
1035
|
+
className: "tax-section-head"
|
|
1036
|
+
}, /* @__PURE__ */ React.createElement("h2", null, query ? words.marketResults : words.marketPopular, loading && packages && /* @__PURE__ */ React.createElement("span", {
|
|
1037
|
+
className: "tax-spin tax-head-spin"
|
|
1038
|
+
}, React.createElement(icon(pi, "LoaderCircle"), { size: 13 }))), count !== undefined && !error && /* @__PURE__ */ React.createElement("span", {
|
|
1039
|
+
className: "tax-count-note"
|
|
1040
|
+
}, ExtensionWords.fill(words.marketCount, { count: count.toLocaleString(pi.ui.language) }))), error ? /* @__PURE__ */ React.createElement("div", {
|
|
1041
|
+
className: "tax-empty tax-market-error"
|
|
1042
|
+
}, /* @__PURE__ */ React.createElement("strong", null, words.marketError), /* @__PURE__ */ React.createElement("span", null, error), /* @__PURE__ */ React.createElement("button", {
|
|
1043
|
+
type: "button",
|
|
1044
|
+
className: "tax-button",
|
|
1045
|
+
onClick: () => void market.search(text)
|
|
1046
|
+
}, words.retry)) : first ? /* @__PURE__ */ React.createElement("div", {
|
|
1047
|
+
className: "tax-grid",
|
|
1048
|
+
"aria-busy": "true"
|
|
1049
|
+
}, Array.from({ length: 6 }, (_, index) => /* @__PURE__ */ React.createElement("div", {
|
|
1050
|
+
key: index,
|
|
1051
|
+
className: "tax-card tax-skeleton"
|
|
1052
|
+
}))) : packages?.length === 0 ? /* @__PURE__ */ React.createElement("div", {
|
|
1053
|
+
className: "tax-empty"
|
|
1054
|
+
}, ExtensionWords.fill(words.marketEmpty, { query })) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", {
|
|
1055
|
+
className: "tax-grid"
|
|
1056
|
+
}, packages?.map((pkg) => /* @__PURE__ */ React.createElement(MarketCard, {
|
|
1057
|
+
key: pkg.name,
|
|
1058
|
+
context,
|
|
1059
|
+
pkg,
|
|
1060
|
+
onOpen
|
|
1061
|
+
}))), /* @__PURE__ */ React.createElement(MoreSentinel, {
|
|
1062
|
+
context
|
|
1063
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
1064
|
+
className: "tax-note tax-market-note"
|
|
1065
|
+
}, words.marketNote));
|
|
1066
|
+
}
|
|
1067
|
+
function MoreSentinel({ context }) {
|
|
1068
|
+
const { market, actions } = context;
|
|
1069
|
+
const words = actions.words;
|
|
1070
|
+
const state = React.useSyncExternalStore((listener) => market.subscribe(listener), () => market.state);
|
|
1071
|
+
const ref = React.useRef(null);
|
|
1072
|
+
const more = !!state.packages && state.next !== undefined;
|
|
1073
|
+
React.useEffect(() => {
|
|
1074
|
+
const element = ref.current;
|
|
1075
|
+
if (!element || !more) {
|
|
1076
|
+
return;
|
|
1077
|
+
}
|
|
1078
|
+
const observer = new IntersectionObserver((entries) => entries.some((entry) => entry.isIntersecting) && void market.more(), { rootMargin: "480px 0px" });
|
|
1079
|
+
observer.observe(element);
|
|
1080
|
+
return () => observer.disconnect();
|
|
1081
|
+
}, [market, more, state.packages?.length]);
|
|
1082
|
+
if (!state.packages?.length) {
|
|
1083
|
+
return null;
|
|
1084
|
+
}
|
|
1085
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1086
|
+
ref,
|
|
1087
|
+
className: "tax-more"
|
|
1088
|
+
}, more ? words.loadingMore : words.allShown);
|
|
1089
|
+
}
|
|
1090
|
+
function MarketCard({ context, pkg, onOpen }) {
|
|
1091
|
+
const { pi, actions } = context;
|
|
1092
|
+
const words = actions.words;
|
|
1093
|
+
const Down = icon(pi, "ArrowDown");
|
|
1094
|
+
const ago = MarketUtil.ago(pkg.date, pi.ui.language);
|
|
1095
|
+
return /* @__PURE__ */ React.createElement("div", {
|
|
1096
|
+
className: "tax-card",
|
|
1097
|
+
role: "button",
|
|
1098
|
+
tabIndex: 0,
|
|
1099
|
+
"aria-label": pkg.name,
|
|
1100
|
+
onClick: () => onOpen(pkg.name),
|
|
1101
|
+
onKeyDown: (event) => {
|
|
1102
|
+
if (event.target === event.currentTarget && (event.key === "Enter" || event.key === " ")) {
|
|
1103
|
+
event.preventDefault();
|
|
1104
|
+
onOpen(pkg.name);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1108
|
+
className: "tax-card-head"
|
|
1109
|
+
}, /* @__PURE__ */ React.createElement(PackageFace, {
|
|
1110
|
+
name: pkg.name,
|
|
1111
|
+
size: 40
|
|
1112
|
+
}), /* @__PURE__ */ React.createElement("div", {
|
|
1113
|
+
className: "tax-card-title"
|
|
1114
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1115
|
+
className: "tax-card-name",
|
|
1116
|
+
title: pkg.name
|
|
1117
|
+
}, /* @__PURE__ */ React.createElement(PackageName, {
|
|
1118
|
+
name: pkg.name
|
|
1119
|
+
})), /* @__PURE__ */ React.createElement("div", {
|
|
1120
|
+
className: "tax-card-meta"
|
|
1121
|
+
}, pkg.publisher && /* @__PURE__ */ React.createElement("span", {
|
|
1122
|
+
className: "tax-ellipsis"
|
|
1123
|
+
}, ExtensionWords.fill(words.by, { name: pkg.publisher })), pkg.downloads !== undefined && pkg.downloads > 0 && /* @__PURE__ */ React.createElement("span", {
|
|
1124
|
+
className: "tax-downloads"
|
|
1125
|
+
}, /* @__PURE__ */ React.createElement(Down, {
|
|
1126
|
+
size: 11
|
|
1127
|
+
}), ExtensionWords.fill(words.perMonth, { count: MarketUtil.compact(pkg.downloads) })))), /* @__PURE__ */ React.createElement(InstallButton, {
|
|
1128
|
+
context,
|
|
1129
|
+
name: pkg.name
|
|
1130
|
+
})), /* @__PURE__ */ React.createElement("p", {
|
|
1131
|
+
className: "tax-card-description"
|
|
1132
|
+
}, pkg.description), /* @__PURE__ */ React.createElement("div", {
|
|
1133
|
+
className: "tax-card-foot"
|
|
1134
|
+
}, pkg.kinds.map((kind) => /* @__PURE__ */ React.createElement("span", {
|
|
1135
|
+
key: kind,
|
|
1136
|
+
className: "tax-tag"
|
|
1137
|
+
}, words.marketKinds[kind])), ago && /* @__PURE__ */ React.createElement("span", {
|
|
1138
|
+
className: "tax-card-time"
|
|
1139
|
+
}, ago)));
|
|
1140
|
+
}
|
|
1141
|
+
|
|
418
1142
|
// web-src/pictures.tsx
|
|
419
1143
|
var Frame = () => /* @__PURE__ */ React.createElement("rect", {
|
|
420
1144
|
className: "tax-pic-frame",
|
|
@@ -609,31 +1333,19 @@ function KindPicture({ kind }) {
|
|
|
609
1333
|
}
|
|
610
1334
|
|
|
611
1335
|
// web-src/page.tsx
|
|
612
|
-
function icon(pi, name, fallback = "Square") {
|
|
613
|
-
return pi.ui.icons[name] ?? pi.ui.icons[fallback] ?? (() => null);
|
|
614
|
-
}
|
|
615
1336
|
function ExtensionsPage({ context }) {
|
|
616
1337
|
const { pi, store, actions, importing } = context;
|
|
617
1338
|
const words = actions.words;
|
|
618
|
-
const
|
|
619
|
-
const dialog =
|
|
1339
|
+
const tab = context.tab.use();
|
|
1340
|
+
const dialog = importing.use();
|
|
620
1341
|
const [dragging, setDragging] = React.useState(false);
|
|
621
|
-
const [starting, setStarting] = React.useState(false);
|
|
622
1342
|
React.useEffect(() => {
|
|
623
1343
|
store.load();
|
|
624
1344
|
}, [store]);
|
|
625
|
-
const
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
const make = async (text) => {
|
|
630
|
-
setStarting(true);
|
|
631
|
-
try {
|
|
632
|
-
await actions.make(text);
|
|
633
|
-
} finally {
|
|
634
|
-
setStarting(false);
|
|
635
|
-
}
|
|
636
|
-
};
|
|
1345
|
+
const tabs = [
|
|
1346
|
+
{ key: "mine", label: words.tabMine, icon: "Puzzle" },
|
|
1347
|
+
{ key: "market", label: words.tabMarket, icon: "Store" }
|
|
1348
|
+
];
|
|
637
1349
|
const files = (event) => Array.from(event.dataTransfer.types).includes("Files");
|
|
638
1350
|
return /* @__PURE__ */ React.createElement("section", {
|
|
639
1351
|
"aria-label": words.title,
|
|
@@ -661,7 +1373,56 @@ function ExtensionsPage({ context }) {
|
|
|
661
1373
|
}
|
|
662
1374
|
}, /* @__PURE__ */ React.createElement("div", {
|
|
663
1375
|
className: "tax-body"
|
|
664
|
-
}, /* @__PURE__ */ React.createElement("
|
|
1376
|
+
}, /* @__PURE__ */ React.createElement("div", {
|
|
1377
|
+
className: "tax-tabs",
|
|
1378
|
+
role: "tablist",
|
|
1379
|
+
"aria-label": words.title
|
|
1380
|
+
}, tabs.map((item) => {
|
|
1381
|
+
const TabIcon = icon(pi, item.icon, "PackageOpen");
|
|
1382
|
+
return /* @__PURE__ */ React.createElement("button", {
|
|
1383
|
+
key: item.key,
|
|
1384
|
+
type: "button",
|
|
1385
|
+
role: "tab",
|
|
1386
|
+
"aria-selected": tab === item.key,
|
|
1387
|
+
className: `tax-tab${tab === item.key ? " tax-active" : ""}`,
|
|
1388
|
+
onClick: () => {
|
|
1389
|
+
context.tab.set(item.key);
|
|
1390
|
+
context.selected.set(undefined);
|
|
1391
|
+
}
|
|
1392
|
+
}, /* @__PURE__ */ React.createElement(TabIcon, {
|
|
1393
|
+
size: 15
|
|
1394
|
+
}), " ", item.label);
|
|
1395
|
+
})), tab === "market" ? /* @__PURE__ */ React.createElement(MarketView, {
|
|
1396
|
+
context
|
|
1397
|
+
}) : /* @__PURE__ */ React.createElement(MineView, {
|
|
1398
|
+
context
|
|
1399
|
+
})), dragging && /* @__PURE__ */ React.createElement("div", {
|
|
1400
|
+
className: "tax-drop-overlay"
|
|
1401
|
+
}, words.dropToImport), dialog && /* @__PURE__ */ React.createElement(ImportDialog, {
|
|
1402
|
+
pi,
|
|
1403
|
+
actions,
|
|
1404
|
+
onClose: () => importing.set(false)
|
|
1405
|
+
}));
|
|
1406
|
+
}
|
|
1407
|
+
function MineView({ context }) {
|
|
1408
|
+
const { pi, store, actions, importing } = context;
|
|
1409
|
+
const words = actions.words;
|
|
1410
|
+
const { packages } = React.useSyncExternalStore((listener) => store.subscribe(listener), () => store.state);
|
|
1411
|
+
const [starting, setStarting] = React.useState(false);
|
|
1412
|
+
const groups = ExtensionsUtil.group(packages ?? []);
|
|
1413
|
+
const Composer = pi.ui.Composer;
|
|
1414
|
+
const Sparkles = icon(pi, "Sparkles");
|
|
1415
|
+
const Upload = icon(pi, "Upload");
|
|
1416
|
+
const Store = icon(pi, "Store", "PackageOpen");
|
|
1417
|
+
const make = async (text) => {
|
|
1418
|
+
setStarting(true);
|
|
1419
|
+
try {
|
|
1420
|
+
await actions.make(text);
|
|
1421
|
+
} finally {
|
|
1422
|
+
setStarting(false);
|
|
1423
|
+
}
|
|
1424
|
+
};
|
|
1425
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("section", {
|
|
665
1426
|
className: "tax-hero"
|
|
666
1427
|
}, /* @__PURE__ */ React.createElement("h1", null, /* @__PURE__ */ React.createElement(Sparkles, {
|
|
667
1428
|
size: 20
|
|
@@ -689,14 +1450,20 @@ function ExtensionsPage({ context }) {
|
|
|
689
1450
|
}, groups.mine.length)), /* @__PURE__ */ React.createElement("button", {
|
|
690
1451
|
type: "button",
|
|
691
1452
|
className: "tax-button",
|
|
692
|
-
onClick: () => importing.
|
|
1453
|
+
onClick: () => importing.set(true)
|
|
693
1454
|
}, /* @__PURE__ */ React.createElement(Upload, {
|
|
694
1455
|
size: 14
|
|
695
1456
|
}), " ", words.import)), packages === undefined ? /* @__PURE__ */ React.createElement("div", {
|
|
696
1457
|
className: "tax-empty"
|
|
697
1458
|
}, words.loading) : groups.mine.length === 0 ? /* @__PURE__ */ React.createElement("div", {
|
|
698
|
-
className: "tax-empty"
|
|
699
|
-
}, words.mineEmpty)
|
|
1459
|
+
className: "tax-empty tax-empty-action"
|
|
1460
|
+
}, /* @__PURE__ */ React.createElement("span", null, words.mineEmpty), /* @__PURE__ */ React.createElement("button", {
|
|
1461
|
+
type: "button",
|
|
1462
|
+
className: "tax-button",
|
|
1463
|
+
onClick: () => context.tab.set("market")
|
|
1464
|
+
}, /* @__PURE__ */ React.createElement(Store, {
|
|
1465
|
+
size: 14
|
|
1466
|
+
}), " ", words.browseMarket)) : /* @__PURE__ */ React.createElement("div", {
|
|
700
1467
|
className: "tax-list"
|
|
701
1468
|
}, groups.mine.map((pkg) => /* @__PURE__ */ React.createElement(PackageRow, {
|
|
702
1469
|
key: pkg.id,
|
|
@@ -723,13 +1490,7 @@ function ExtensionsPage({ context }) {
|
|
|
723
1490
|
}, /* @__PURE__ */ React.createElement("h2", null, words.shareTitle)), /* @__PURE__ */ React.createElement(ShareSteps, {
|
|
724
1491
|
pi,
|
|
725
1492
|
actions
|
|
726
|
-
})))
|
|
727
|
-
className: "tax-drop-overlay"
|
|
728
|
-
}, words.dropToImport), dialog && /* @__PURE__ */ React.createElement(ImportDialog, {
|
|
729
|
-
pi,
|
|
730
|
-
actions,
|
|
731
|
-
onClose: () => importing.close()
|
|
732
|
-
}));
|
|
1493
|
+
})));
|
|
733
1494
|
}
|
|
734
1495
|
function ShareSteps({ pi, actions }) {
|
|
735
1496
|
const words = actions.words;
|
|
@@ -810,10 +1571,132 @@ function PackageRow({ pi, actions, pkg }) {
|
|
|
810
1571
|
}));
|
|
811
1572
|
}
|
|
812
1573
|
|
|
1574
|
+
// web-src/signal.ts
|
|
1575
|
+
class Signal {
|
|
1576
|
+
value;
|
|
1577
|
+
listeners = new Set;
|
|
1578
|
+
constructor(value) {
|
|
1579
|
+
this.value = value;
|
|
1580
|
+
}
|
|
1581
|
+
get() {
|
|
1582
|
+
return this.value;
|
|
1583
|
+
}
|
|
1584
|
+
set(value) {
|
|
1585
|
+
if (!Object.is(value, this.value)) {
|
|
1586
|
+
this.value = value;
|
|
1587
|
+
for (const listener of this.listeners) {
|
|
1588
|
+
listener();
|
|
1589
|
+
}
|
|
1590
|
+
}
|
|
1591
|
+
}
|
|
1592
|
+
subscribe(listener) {
|
|
1593
|
+
this.listeners.add(listener);
|
|
1594
|
+
return () => this.listeners.delete(listener);
|
|
1595
|
+
}
|
|
1596
|
+
use() {
|
|
1597
|
+
return React.useSyncExternalStore((listener) => this.subscribe(listener), () => this.value);
|
|
1598
|
+
}
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
// web-src/market-style.ts
|
|
1602
|
+
var MARKET_STYLE = `
|
|
1603
|
+
.tax-tabs { display: inline-flex; align-self: flex-start; gap: 2px; margin-bottom: -10px; padding: 3px; border-radius: 10px; background: var(--ta-chip); }
|
|
1604
|
+
.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; }
|
|
1605
|
+
.tax-tab:hover { color: var(--ta-text); }
|
|
1606
|
+
.tax-tab.tax-active { background: var(--ta-hover-strong); color: var(--ta-text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }
|
|
1607
|
+
: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); }
|
|
1608
|
+
.tax-tab:focus-visible { outline: 2px solid var(--ta-border-focus); outline-offset: 1px; }
|
|
1609
|
+
.tax-empty-action { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 22px 16px; }
|
|
1610
|
+
.tax-market { display: flex; flex-direction: column; gap: 14px; }
|
|
1611
|
+
.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; }
|
|
1612
|
+
.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); }
|
|
1613
|
+
.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; }
|
|
1614
|
+
.tax-search input::placeholder { color: var(--ta-muted); }
|
|
1615
|
+
.tax-search input::-webkit-search-cancel-button { display: none; }
|
|
1616
|
+
.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; }
|
|
1617
|
+
.tax-search-clear:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
1618
|
+
.tax-topics { display: flex; flex-wrap: wrap; gap: 6px; }
|
|
1619
|
+
.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; }
|
|
1620
|
+
.tax-topic:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
1621
|
+
.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); }
|
|
1622
|
+
.tax-market .tax-section-head { margin-top: 4px; min-height: 22px; }
|
|
1623
|
+
.tax-head-spin { color: var(--ta-muted); }
|
|
1624
|
+
.tax-count-note { color: var(--ta-muted); font-size: 12px; }
|
|
1625
|
+
.tax-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
|
|
1626
|
+
@media (max-width: 640px) { .tax-grid { grid-template-columns: minmax(0, 1fr); } }
|
|
1627
|
+
.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); }
|
|
1628
|
+
.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); }
|
|
1629
|
+
.tax-card:focus-visible { border-color: var(--ta-border-focus); }
|
|
1630
|
+
.tax-card:active { transform: scale(.995); }
|
|
1631
|
+
.tax-card-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
|
|
1632
|
+
.tax-card-title { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
|
|
1633
|
+
.tax-card-name { overflow: hidden; font-size: 14px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
|
|
1634
|
+
.tax-scope { color: var(--ta-muted); font-weight: 500; }
|
|
1635
|
+
.tax-card-meta { display: flex; align-items: center; gap: 10px; min-width: 0; color: var(--ta-muted); font-size: 12px; }
|
|
1636
|
+
.tax-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
1637
|
+
.tax-downloads { display: inline-flex; align-items: center; gap: 2px; flex: none; }
|
|
1638
|
+
.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; }
|
|
1639
|
+
.tax-card-foot { display: flex; align-items: center; gap: 6px; margin-top: auto; min-height: 17px; }
|
|
1640
|
+
.tax-card-time { margin-left: auto; color: var(--ta-muted); font-size: 11.5px; white-space: nowrap; }
|
|
1641
|
+
.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; }
|
|
1642
|
+
:root:not([data-theme='light']) .tax-face { background: hsl(var(--tax-hue) 60% 55% / .17); color: hsl(var(--tax-hue) 75% 74%); }
|
|
1643
|
+
.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; }
|
|
1644
|
+
.tax-install:hover { background: color-mix(in srgb, var(--ta-green) 24%, transparent); }
|
|
1645
|
+
.tax-install:active { transform: scale(.95); }
|
|
1646
|
+
.tax-install:focus-visible { outline: 2px solid var(--ta-border-focus); outline-offset: 2px; }
|
|
1647
|
+
.tax-install-done, .tax-install-busy { background: var(--ta-chip); color: var(--ta-muted); font-weight: 500; cursor: default; }
|
|
1648
|
+
.tax-install-busy { color: var(--ta-secondary); }
|
|
1649
|
+
.tax-install-large { height: 34px; padding: 0 22px; border-radius: 9px; font-size: 13.5px; }
|
|
1650
|
+
button.tax-install-large { background: var(--ta-green); color: var(--ta-brand-text); }
|
|
1651
|
+
button.tax-install-large:hover { background: var(--ta-green); filter: brightness(1.07); }
|
|
1652
|
+
.tax-spin { display: inline-flex; animation: tax-spin 900ms linear infinite; }
|
|
1653
|
+
@keyframes tax-spin { to { transform: rotate(360deg); } }
|
|
1654
|
+
.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; }
|
|
1655
|
+
.tax-skeleton:hover { border-color: transparent; box-shadow: none; transform: none; }
|
|
1656
|
+
@keyframes tax-shimmer { to { background-position: -200% 0; } }
|
|
1657
|
+
.tax-more { padding: 6px 0 2px; color: var(--ta-muted); font-size: 12px; text-align: center; }
|
|
1658
|
+
.tax-market-error { display: flex; flex-direction: column; align-items: center; gap: 8px; }
|
|
1659
|
+
.tax-market-error strong { color: var(--ta-text); font-weight: 600; }
|
|
1660
|
+
.tax-market-error span { max-width: 100%; overflow-wrap: anywhere; font-size: 12.5px; }
|
|
1661
|
+
.tax-market-note { text-align: center; }
|
|
1662
|
+
.tax-detail { display: flex; flex-direction: column; gap: 20px; animation: tax-in 220ms var(--ta-ease); }
|
|
1663
|
+
@keyframes tax-in { from { opacity: 0; transform: translateY(6px); } }
|
|
1664
|
+
.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; }
|
|
1665
|
+
.tax-back:hover { background: var(--ta-hover); color: var(--ta-text); }
|
|
1666
|
+
.tax-detail-head { display: flex; align-items: flex-start; gap: 20px; }
|
|
1667
|
+
.tax-detail-title { display: flex; flex-direction: column; flex: 1; min-width: 0; }
|
|
1668
|
+
.tax-detail-title h1 { margin: 2px 0 0; font-size: 22px; font-weight: 650; letter-spacing: -.01em; line-height: 1.25; overflow-wrap: anywhere; }
|
|
1669
|
+
.tax-detail-description { margin: 6px 0 0; color: var(--ta-secondary); font-size: 14px; line-height: 1.55; }
|
|
1670
|
+
.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; }
|
|
1671
|
+
.tax-detail-facts .tax-tag { margin-right: 6px; }
|
|
1672
|
+
.tax-detail-facts .tax-tag + .tax-fact { margin-left: 4px; }
|
|
1673
|
+
.tax-fact + .tax-fact::before { content: '·'; margin: 0 7px; }
|
|
1674
|
+
.tax-detail-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 16px; }
|
|
1675
|
+
.tax-button-quiet { height: 34px; color: var(--ta-secondary); text-decoration: none; }
|
|
1676
|
+
.tax-button-quiet:hover { color: var(--ta-text); }
|
|
1677
|
+
.tax-button-quiet svg { color: var(--ta-muted); }
|
|
1678
|
+
.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; }
|
|
1679
|
+
.tax-readme { padding-top: 20px; border-top: 1px solid var(--ta-border-muted); font-size: 14px; min-width: 0; overflow-wrap: anywhere; }
|
|
1680
|
+
.tax-readme img { max-width: 100%; height: auto; }
|
|
1681
|
+
.tax-readme-loading { display: flex; flex-direction: column; gap: 12px; }
|
|
1682
|
+
.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; }
|
|
1683
|
+
.tax-readme-loading span:nth-child(1) { width: 92%; }
|
|
1684
|
+
.tax-readme-loading span:nth-child(2) { width: 78%; }
|
|
1685
|
+
.tax-readme-loading span:nth-child(3) { width: 85%; }
|
|
1686
|
+
@media (max-width: 640px) {
|
|
1687
|
+
.tax-detail-head { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; column-gap: 14px; }
|
|
1688
|
+
.tax-detail-title { display: contents; }
|
|
1689
|
+
.tax-detail-title > :not(h1) { grid-column: 1 / -1; }
|
|
1690
|
+
.tax-detail-head .tax-face { width: 52px !important; height: 52px !important; font-size: 19px !important; }
|
|
1691
|
+
.tax-detail-title h1 { margin: 0; font-size: 19px; }
|
|
1692
|
+
.tax-detail-description { margin-top: 12px; }
|
|
1693
|
+
}
|
|
1694
|
+
`;
|
|
1695
|
+
|
|
813
1696
|
// web-src/style.ts
|
|
814
1697
|
var STYLE = `
|
|
815
1698
|
.tax-page { --tax-accent: var(--ta-green); position: relative; height: 100%; overflow: auto; color: var(--ta-text); font-size: 13.5px; }
|
|
816
|
-
.tax-body { display: flex; flex-direction: column; gap: 32px; max-width: 760px; margin: 0 auto; padding:
|
|
1699
|
+
.tax-body { display: flex; flex-direction: column; gap: 32px; max-width: 760px; margin: 0 auto; padding: 28px 24px 56px; box-sizing: border-box; }
|
|
817
1700
|
.tax-hero { display: flex; flex-direction: column; gap: 10px; }
|
|
818
1701
|
.tax-hero h1 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
|
|
819
1702
|
.tax-hero h1 svg { color: var(--tax-accent); }
|
|
@@ -895,7 +1778,7 @@ var STYLE = `
|
|
|
895
1778
|
function injectStyle() {
|
|
896
1779
|
const style = document.createElement("style");
|
|
897
1780
|
style.dataset.taPackage = "ta-extensions";
|
|
898
|
-
style.textContent = STYLE;
|
|
1781
|
+
style.textContent = STYLE + MARKET_STYLE;
|
|
899
1782
|
document.head.appendChild(style);
|
|
900
1783
|
return () => style.remove();
|
|
901
1784
|
}
|
|
@@ -905,32 +1788,32 @@ function activate(pi) {
|
|
|
905
1788
|
bind(pi.React);
|
|
906
1789
|
const removeStyle = injectStyle();
|
|
907
1790
|
const store = new PackagesStore(pi);
|
|
908
|
-
const
|
|
909
|
-
const
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
}
|
|
1791
|
+
const market = new MarketStore(pi);
|
|
1792
|
+
const context = {
|
|
1793
|
+
pi,
|
|
1794
|
+
store,
|
|
1795
|
+
market,
|
|
1796
|
+
actions: new ExtensionActions(pi, store, market),
|
|
1797
|
+
tab: new Signal("mine"),
|
|
1798
|
+
selected: new Signal(undefined),
|
|
1799
|
+
importing: new Signal(false)
|
|
918
1800
|
};
|
|
919
|
-
|
|
920
|
-
importing.shown = shown;
|
|
921
|
-
for (const listener of listeners) {
|
|
922
|
-
listener();
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
const context = { pi, store, actions, importing };
|
|
926
|
-
const Puzzle = pi.ui.icons.Puzzle ?? pi.ui.icons.Square;
|
|
1801
|
+
const icons = pi.ui.icons;
|
|
927
1802
|
pi.registerView("extensions", {
|
|
928
1803
|
title: () => ExtensionWords.of(pi.ui.language).title,
|
|
929
|
-
icon: Puzzle,
|
|
1804
|
+
icon: icons.Puzzle ?? icons.Square,
|
|
930
1805
|
render: () => /* @__PURE__ */ React.createElement(ExtensionsPage, {
|
|
931
1806
|
context
|
|
932
1807
|
}),
|
|
933
|
-
menu: () =>
|
|
1808
|
+
menu: () => {
|
|
1809
|
+
const words = ExtensionWords.of(pi.ui.language);
|
|
1810
|
+
return [
|
|
1811
|
+
[
|
|
1812
|
+
{ key: "market", label: words.tabMarket, icon: icons.Store ?? icons.PackageOpen, run: () => context.tab.set("market") },
|
|
1813
|
+
{ key: "import", label: words.import, icon: icons.Upload, run: () => context.importing.set(true) }
|
|
1814
|
+
]
|
|
1815
|
+
];
|
|
1816
|
+
},
|
|
934
1817
|
order: 90
|
|
935
1818
|
});
|
|
936
1819
|
pi.on("agent_end", () => void store.load());
|