@inpageedit/core 0.14.3 → 0.14.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{PluginStoreApp-qiSVtnBy.js → PluginStoreApp-MbC3G9tu.js} +88 -84
- package/dist/PluginStoreApp-MbC3G9tu.js.map +1 -0
- package/dist/{index-DVOc6fB6.js → index-7R2LfhNn.js} +62 -53
- package/dist/index-7R2LfhNn.js.map +1 -0
- package/dist/{index-DrIf5j8O.js → index-B3jld2sl.js} +2 -2
- package/dist/{index-DrIf5j8O.js.map → index-B3jld2sl.js.map} +1 -1
- package/dist/{index-MgXERLzL.js → index-DxaqNWv4.js} +4 -4
- package/dist/{index-MgXERLzL.js.map → index-DxaqNWv4.js.map} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -2
- package/dist/plugins/index.js +2 -2
- package/dist/services/index.js +1 -1
- package/dist/style.css +1 -1
- package/lib/index.umd.js +10 -10
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +1 -1
- package/dist/PluginStoreApp-qiSVtnBy.js.map +0 -1
- package/dist/index-DVOc6fB6.js.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { j as p } from "./index-CM_6yF2v.js";
|
|
2
|
-
import { I as
|
|
3
|
-
import { B as
|
|
4
|
-
import { I as
|
|
5
|
-
var
|
|
2
|
+
import { I as C, R as D, S as m } from "./Preferences-C10tZMl1.js";
|
|
3
|
+
import { B as $ } from "./BasePlugin-DD7l-5Xw.js";
|
|
4
|
+
import { I as P } from "./IconQuickEdit-CMCQncyj.js";
|
|
5
|
+
var R = Object.create, g = Object.defineProperty, j = Object.getOwnPropertyDescriptor, E = (t, e) => (e = Symbol[t]) ? e : Symbol.for("Symbol." + t), y = (t) => {
|
|
6
6
|
throw TypeError(t);
|
|
7
|
-
},
|
|
8
|
-
for (var
|
|
7
|
+
}, N = (t, e, i) => e in t ? g(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i, Q = (t, e) => g(t, "name", { value: e, configurable: !0 }), T = (t) => [, , , R(t?.[E("metadata")] ?? null)], B = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], I = (t) => t !== void 0 && typeof t != "function" ? y("Function expected") : t, O = (t, e, i, r, n) => ({ kind: B[t], name: e, metadata: r, addInitializer: (o) => i._ ? y("Already initialized") : n.push(I(o || null)) }), W = (t, e) => N(e, E("metadata"), t[3]), z = (t, e, i, r) => {
|
|
8
|
+
for (var n = 0, o = t[e >> 1], s = o && o.length; n < s; n++) o[n].call(i);
|
|
9
9
|
return r;
|
|
10
|
-
}, F = (t, e,
|
|
11
|
-
var s, a, d,
|
|
12
|
-
|
|
10
|
+
}, F = (t, e, i, r, n, o) => {
|
|
11
|
+
var s, a, d, l = e & 7, c = !1, f = 0, u = t[f] || (t[f] = []), h = l && (n = n.prototype, l < 5 && (l > 3 || !c) && j(n, i));
|
|
12
|
+
Q(n, i);
|
|
13
13
|
for (var k = r.length - 1; k >= 0; k--)
|
|
14
|
-
d =
|
|
15
|
-
return
|
|
16
|
-
},
|
|
17
|
-
|
|
14
|
+
d = O(l, i, a = {}, t[3], u), s = (0, r[k])(n, d), a._ = 1, I(s) && (n = s);
|
|
15
|
+
return W(t, n), h && g(n, i, h), c ? l ^ 4 ? o : h : n;
|
|
16
|
+
}, q, _, L;
|
|
17
|
+
q = [C(["wiki", "wikiTitle", "preferences", "$"]), D(
|
|
18
18
|
m.object({
|
|
19
19
|
"inArticleLinks.enable": m.boolean().description("Whether to enable in-article links").default(!0),
|
|
20
20
|
"inArticleLinks.quickDiff.enable": m.boolean().description("Whether to enable in-article links for quick diff").default(!0),
|
|
@@ -22,7 +22,7 @@ y = [D(["wiki", "wikiTitle", "preferences", "$"]), C(
|
|
|
22
22
|
"inArticleLinks.quickEdit.redlinks": m.boolean().description("Whether to show quick edit button for redlinks").default(!0)
|
|
23
23
|
}).description("In-article links preferences").extra("category", "in-article-links")
|
|
24
24
|
)];
|
|
25
|
-
class
|
|
25
|
+
class v extends (L = $) {
|
|
26
26
|
constructor(e) {
|
|
27
27
|
super(
|
|
28
28
|
e,
|
|
@@ -31,11 +31,11 @@ class g extends (L = P) {
|
|
|
31
31
|
},
|
|
32
32
|
"InArticleLinks"
|
|
33
33
|
), this._cachedAnchorInfo = /* @__PURE__ */ new WeakMap(), this.ctx.set("inArticleLinks", this);
|
|
34
|
-
const
|
|
34
|
+
const i = this.ctx.$;
|
|
35
35
|
this.ctx.preferences.defineCategory({
|
|
36
36
|
name: "in-article-links",
|
|
37
|
-
label:
|
|
38
|
-
description:
|
|
37
|
+
label: i`prefs.inArticleLinks.label`,
|
|
38
|
+
description: i`prefs.inArticleLinks.$`,
|
|
39
39
|
index: 9
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -54,21 +54,21 @@ class g extends (L = P) {
|
|
|
54
54
|
parseAnchor(e) {
|
|
55
55
|
if (!(e instanceof HTMLAnchorElement))
|
|
56
56
|
return null;
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
return
|
|
57
|
+
const i = this._cachedAnchorInfo.get(e);
|
|
58
|
+
if (i)
|
|
59
|
+
return i;
|
|
60
60
|
const r = e.getAttribute("href") || "";
|
|
61
61
|
if (!this.ctx.wikiTitle.validateHrefAttr(r))
|
|
62
62
|
return null;
|
|
63
|
-
const
|
|
64
|
-
if (!
|
|
63
|
+
const n = e.href || "", o = this.ctx.wikiTitle.parseWikiLink(n);
|
|
64
|
+
if (!o)
|
|
65
65
|
return null;
|
|
66
66
|
const s = {
|
|
67
67
|
$el: e,
|
|
68
68
|
kind: e.closest('[typeof^="mw:File"]') ? "mw:File" : "normal",
|
|
69
69
|
external: e.classList.contains("external") || !!r.startsWith("http"),
|
|
70
|
-
redlink: e.classList.contains("new") ||
|
|
71
|
-
...
|
|
70
|
+
redlink: e.classList.contains("new") || o.params.has("redlink"),
|
|
71
|
+
...o
|
|
72
72
|
};
|
|
73
73
|
return this._cachedAnchorInfo.set(e, s), this.ctx.emit("in-article-links/anchor-parsed", {
|
|
74
74
|
ctx: this.ctx,
|
|
@@ -76,42 +76,51 @@ class g extends (L = P) {
|
|
|
76
76
|
info: s
|
|
77
77
|
}), s;
|
|
78
78
|
}
|
|
79
|
-
scanAnchors(e,
|
|
79
|
+
scanAnchors(e, i) {
|
|
80
80
|
const r = e.querySelectorAll("a[href]");
|
|
81
|
-
return Array.from(r).map((
|
|
82
|
-
(
|
|
81
|
+
return Array.from(r).map((n) => this.parseAnchor(n)).filter(
|
|
82
|
+
(n) => n !== null && (!i || i(n))
|
|
83
83
|
);
|
|
84
84
|
}
|
|
85
|
+
onContentReady(e) {
|
|
86
|
+
const i = () => {
|
|
87
|
+
if (!window.mw) return;
|
|
88
|
+
window.mw.hook("wikipage.content").add(e);
|
|
89
|
+
const r = window.$?.("#mw-content-text");
|
|
90
|
+
r?.length && e(r);
|
|
91
|
+
};
|
|
92
|
+
window.mw && typeof window.mw.hook == "function" ? i() : (window.RLQ = window.RLQ || [], window.RLQ.push(["mediawiki.base", i]));
|
|
93
|
+
}
|
|
85
94
|
async handleQuickEdit() {
|
|
86
95
|
let e = !1;
|
|
87
|
-
const
|
|
96
|
+
const i = await this.ctx.preferences.get("inArticleLinks.quickEdit.redlinks");
|
|
88
97
|
this.ctx.inject(["quickEdit"], (r) => {
|
|
89
98
|
e = !0, r.on("dispose", () => {
|
|
90
99
|
e = !1;
|
|
91
|
-
}),
|
|
100
|
+
}), this.onContentReady((n) => {
|
|
92
101
|
if (!e)
|
|
93
102
|
return;
|
|
94
|
-
this.scanAnchors(
|
|
95
|
-
const { $el: a, title: d, pageId:
|
|
103
|
+
this.scanAnchors(n.get(0), ({ action: s, title: a, redlink: d }) => i || !d ? ["edit", "create"].includes(s) ? !0 : a?.isSpecial("edit") || a?.isSpecial("newsection") ? a.getMainText().split("/").length >= 2 : !1 : !1).forEach((s) => {
|
|
104
|
+
const { $el: a, title: d, pageId: l, params: c } = s;
|
|
96
105
|
if (a.dataset.ipeEditMounted)
|
|
97
106
|
return;
|
|
98
107
|
if (a.dataset.ipeEditMounted = "1", c.has("preload") || c.has("redo"))
|
|
99
108
|
return this.ctx.logger.debug(a, "Not compatible with quick edit");
|
|
100
|
-
const u = d?.getPrefixedDBKey() || "", h = c.get("section")?.replace(/^T-/, "") || void 0, k = c.get("oldid"),
|
|
101
|
-
let
|
|
102
|
-
h === "new" || d?.isSpecial("newsection") ?
|
|
103
|
-
const S = k ? parseInt(k, 10) : void 0,
|
|
109
|
+
const u = d?.getPrefixedDBKey() || "", h = c.get("section")?.replace(/^T-/, "") || void 0, k = c.get("oldid"), x = c.has("redlink");
|
|
110
|
+
let w;
|
|
111
|
+
h === "new" || d?.isSpecial("newsection") ? w = "new" : h && /^\d+$/.test(h) && (w = parseInt(h, 10));
|
|
112
|
+
const S = k ? parseInt(k, 10) : void 0, b = {
|
|
104
113
|
title: u,
|
|
105
|
-
pageId:
|
|
106
|
-
section:
|
|
114
|
+
pageId: l || void 0,
|
|
115
|
+
section: w,
|
|
107
116
|
revision: S,
|
|
108
|
-
createOnly:
|
|
117
|
+
createOnly: x
|
|
109
118
|
}, M = /* @__PURE__ */ p(
|
|
110
119
|
"a",
|
|
111
120
|
{
|
|
112
121
|
href: "#ipe://quick-edit/",
|
|
113
|
-
dataset:
|
|
114
|
-
className: `${this.config.linkClassName} ipe-quick-edit ${
|
|
122
|
+
dataset: b,
|
|
123
|
+
className: `${this.config.linkClassName} ipe-quick-edit ${x ? "ipe-quick-edit--create-only" : ""}`,
|
|
115
124
|
style: {
|
|
116
125
|
userSelect: "none",
|
|
117
126
|
marginLeft: "0.2em"
|
|
@@ -123,9 +132,9 @@ class g extends (L = P) {
|
|
|
123
132
|
info: s,
|
|
124
133
|
event: A,
|
|
125
134
|
action: "quickEdit"
|
|
126
|
-
}), r.quickEdit.showModal(
|
|
135
|
+
}), r.quickEdit.showModal(b);
|
|
127
136
|
},
|
|
128
|
-
children: /* @__PURE__ */ p(
|
|
137
|
+
children: /* @__PURE__ */ p(P, { className: "ipe-icon" })
|
|
129
138
|
}
|
|
130
139
|
);
|
|
131
140
|
a.insertAdjacentElement("afterend", M);
|
|
@@ -135,23 +144,23 @@ class g extends (L = P) {
|
|
|
135
144
|
}
|
|
136
145
|
handleQuickDiff() {
|
|
137
146
|
let e = !1;
|
|
138
|
-
const
|
|
147
|
+
const i = (r) => ["prev", "next", "cur"].includes(r);
|
|
139
148
|
this.ctx.inject(["quickDiff"], (r) => {
|
|
140
149
|
e = !0, r.on("dispose", () => {
|
|
141
150
|
e = !1;
|
|
142
|
-
}),
|
|
151
|
+
}), this.onContentReady((n) => {
|
|
143
152
|
if (!e)
|
|
144
153
|
return;
|
|
145
|
-
this.scanAnchors(
|
|
146
|
-
const { $el: a, title: d, params:
|
|
154
|
+
this.scanAnchors(n.get(0), ({ params: s, title: a }) => !!(s.has("diff") || a?.isSpecial("diff"))).forEach((s) => {
|
|
155
|
+
const { $el: a, title: d, params: l } = s;
|
|
147
156
|
if (a.dataset.ipeDiffMounted)
|
|
148
157
|
return;
|
|
149
158
|
a.dataset.ipeDiffMounted = "1";
|
|
150
159
|
let c, f;
|
|
151
|
-
if (d?.getNamespaceId() === -1 ? ([, f, c] = d.getMainDBKey().split("/"), c || (c = "prev")) : (c =
|
|
160
|
+
if (d?.getNamespaceId() === -1 ? ([, f, c] = d.getMainDBKey().split("/"), c || (c = "prev")) : (c = l.get("diff"), f = l.get("oldid")), !c || !f)
|
|
152
161
|
return;
|
|
153
162
|
const u = {};
|
|
154
|
-
|
|
163
|
+
i(c) ? (u.fromrev = parseInt(f), u.torelative = c) : (u.fromrev = parseInt(f), u.torev = parseInt(c));
|
|
155
164
|
const h = /* @__PURE__ */ p(
|
|
156
165
|
"a",
|
|
157
166
|
{
|
|
@@ -202,10 +211,10 @@ class g extends (L = P) {
|
|
|
202
211
|
});
|
|
203
212
|
}
|
|
204
213
|
}
|
|
205
|
-
_ =
|
|
206
|
-
|
|
207
|
-
|
|
214
|
+
_ = T(L);
|
|
215
|
+
v = F(_, 0, "PluginInArticleLinks", q, v);
|
|
216
|
+
z(_, 1, v);
|
|
208
217
|
export {
|
|
209
|
-
|
|
218
|
+
v as PluginInArticleLinks
|
|
210
219
|
};
|
|
211
|
-
//# sourceMappingURL=index-
|
|
220
|
+
//# sourceMappingURL=index-7R2LfhNn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-7R2LfhNn.js","sources":["../src/plugins/in-article-links/index.tsx"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport { CompareApiRequestOptions } from '../quick-diff/index.js'\nimport { QuickEditOptions } from '../quick-edit/index.js'\nimport { WikiLinkMetadata } from '@/services/WikiTitleService.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n inArticleLinks: PluginInArticleLinks\n }\n interface Events {\n 'in-article-links/anchor-parsed'(payload: {\n ctx: InPageEdit\n anchor: HTMLAnchorElement\n info: InArticleWikiAnchorMetadata\n }): void\n 'in-article-links/anchor-clicked'(payload: {\n ctx: InPageEdit\n anchor: HTMLAnchorElement\n info: InArticleWikiAnchorMetadata\n event: MouseEvent\n action: 'quickEdit' | 'quickDiff'\n }): void\n }\n interface PreferencesMap {\n 'inArticleLinks.quickEdit.enable': boolean\n 'inArticleLinks.quickDiff.enable': boolean\n 'inArticleLinks.quickEdit.redlinks': boolean\n }\n}\n\nexport interface InArticleWikiAnchorMetadata extends WikiLinkMetadata {\n $el: HTMLAnchorElement\n kind: 'normal' | 'mw:File'\n external: boolean\n redlink: boolean\n}\n\n@Inject(['wiki', 'wikiTitle', 'preferences', '$'])\n@RegisterPreferences(\n Schema.object({\n 'inArticleLinks.enable': Schema.boolean()\n .description('Whether to enable in-article links')\n .default(true),\n 'inArticleLinks.quickDiff.enable': Schema.boolean()\n .description('Whether to enable in-article links for quick diff')\n .default(true),\n 'inArticleLinks.quickEdit.enable': Schema.boolean()\n .description('Whether to enable in-article links for quick edit')\n .default(true),\n 'inArticleLinks.quickEdit.redlinks': Schema.boolean()\n .description('Whether to show quick edit button for redlinks')\n .default(true),\n })\n .description('In-article links preferences')\n .extra('category', 'in-article-links')\n)\nexport class PluginInArticleLinks extends BasePlugin<{\n linkClassName: string\n}> {\n constructor(ctx: InPageEdit) {\n super(\n ctx,\n {\n linkClassName: 'ipe__in-article-link',\n },\n 'InArticleLinks'\n )\n this.ctx.set('inArticleLinks', this)\n const $ = this.ctx.$\n\n this.ctx.preferences.defineCategory({\n name: 'in-article-links',\n label: $`prefs.inArticleLinks.label`,\n description: $`prefs.inArticleLinks.$`,\n index: 9,\n })\n }\n\n protected async start() {\n // TODO: 这些都不应该硬编码,暂时先这样\n if (await this.ctx.preferences.get('inArticleLinks.quickEdit.enable')) {\n this.handleQuickEdit()\n }\n if (await this.ctx.preferences.get('inArticleLinks.quickDiff.enable')) {\n this.handleQuickDiff()\n }\n }\n\n protected async stop() {\n Array.from(\n document.getElementsByClassName(this.config.linkClassName) as HTMLCollectionOf<HTMLElement>\n ).forEach((el) => {\n el.remove()\n })\n document.querySelectorAll<HTMLElement>('[data-ipe-edit-mounted]').forEach((el) => {\n el.dataset.ipeEditMounted = undefined\n })\n }\n\n private _cachedAnchorInfo = new WeakMap<HTMLAnchorElement, InArticleWikiAnchorMetadata>()\n parseAnchor(anchor: HTMLAnchorElement): InArticleWikiAnchorMetadata | null {\n // 不是链接元素\n if (!(anchor instanceof HTMLAnchorElement)) {\n return null\n }\n\n const cached = this._cachedAnchorInfo.get(anchor)\n if (cached) {\n return cached\n }\n\n const attrHref = anchor.getAttribute('href') || ''\n if (!this.ctx.wikiTitle.validateHrefAttr(attrHref)) {\n return null\n }\n const href = anchor.href || ''\n const linkInfo = this.ctx.wikiTitle.parseWikiLink(href)\n if (!linkInfo) {\n return null\n }\n\n const info: InArticleWikiAnchorMetadata = {\n $el: anchor,\n kind: anchor.closest('[typeof^=\"mw:File\"]') ? 'mw:File' : 'normal',\n external: anchor.classList.contains('external') || !!attrHref.startsWith('http'),\n redlink: anchor.classList.contains('new') || linkInfo.params.has('redlink'),\n ...linkInfo,\n }\n this._cachedAnchorInfo.set(anchor, info)\n this.ctx.emit('in-article-links/anchor-parsed', {\n ctx: this.ctx,\n anchor,\n info,\n })\n return info\n }\n\n scanAnchors(\n parent: HTMLElement,\n filter?: (info: InArticleWikiAnchorMetadata) => boolean\n ): InArticleWikiAnchorMetadata[] {\n const anchors = parent.querySelectorAll<HTMLAnchorElement>('a[href]')\n return Array.from(anchors)\n .map((anchor) => this.parseAnchor(anchor))\n .filter(\n (anchor) => anchor !== null && (!filter || filter(anchor))\n ) as InArticleWikiAnchorMetadata[]\n }\n\n private onContentReady(callback: ($content: JQuery<HTMLElement>) => void) {\n const register = () => {\n if (!window.mw) return\n window.mw.hook('wikipage.content').add(callback)\n const $content = (window as any).$?.('#mw-content-text')\n if ($content?.length) callback($content)\n }\n\n if (window.mw && typeof window.mw.hook === 'function') {\n register()\n } else {\n window.RLQ = window.RLQ || ([] as any)\n window.RLQ.push(['mediawiki.base', register])\n }\n }\n\n async handleQuickEdit() {\n let enable = false\n const showButtonOnRedlinks = await this.ctx.preferences.get('inArticleLinks.quickEdit.redlinks')\n\n this.ctx.inject(['quickEdit'], (ctx) => {\n enable = true\n ctx.on('dispose', () => {\n enable = false\n })\n\n this.onContentReady(($content) => {\n if (!enable) {\n return\n }\n const anchors = this.scanAnchors($content.get(0)!, ({ action, title, redlink }) => {\n const enabled = showButtonOnRedlinks || !redlink\n if (!enabled) {\n return false\n }\n const isActionEdit = ['edit', 'create'].includes(action)\n if (isActionEdit) {\n return true\n }\n const isSpecialEdit = title?.isSpecial('edit') || title?.isSpecial('newsection')\n if (isSpecialEdit) {\n return title!.getMainText().split('/').length >= 2\n }\n return false\n })\n anchors.forEach((info) => {\n const { $el, title, pageId, params } = info\n if ($el.dataset.ipeEditMounted) {\n return\n }\n $el.dataset.ipeEditMounted = '1'\n\n const notCompatible = params.has('preload') || params.has('redo')\n if (notCompatible) {\n return this.ctx.logger.debug($el, `Not compatible with quick edit`)\n }\n\n const titleText = title?.getPrefixedDBKey() || ''\n const sectionRaw = params.get('section')?.replace(/^T-/, '') || undefined\n const revisionRaw = params.get('oldid')\n const createOnly = params.has('redlink')\n\n let section: 'new' | number | undefined = undefined\n if (sectionRaw === 'new' || title?.isSpecial('newsection')) {\n section = 'new'\n } else if (sectionRaw && /^\\d+$/.test(sectionRaw)) {\n section = parseInt(sectionRaw, 10)\n }\n\n const revision = revisionRaw ? parseInt(revisionRaw, 10) : undefined\n\n const payload: Partial<QuickEditOptions> = {\n title: titleText,\n pageId: pageId || undefined,\n section,\n revision,\n createOnly,\n }\n\n const link = (\n <a\n href={`#ipe://quick-edit/`}\n dataset={payload as any}\n className={`${this.config.linkClassName} ipe-quick-edit ${createOnly ? 'ipe-quick-edit--create-only' : ''}`}\n style={{\n userSelect: 'none',\n marginLeft: '0.2em',\n }}\n onClick={(e) => {\n e.preventDefault()\n this.ctx.emit('in-article-links/anchor-clicked', {\n ctx: this.ctx,\n anchor: $el,\n info,\n event: e,\n action: 'quickEdit',\n })\n ctx.quickEdit.showModal(payload)\n }}\n >\n <IconQuickEdit className=\"ipe-icon\" />\n </a>\n )\n\n $el.insertAdjacentElement('afterend', link)\n })\n })\n })\n }\n\n handleQuickDiff() {\n let enable = false\n const isRelative = (str: string): str is 'prev' | 'next' | 'cur' =>\n ['prev', 'next', 'cur'].includes(str)\n\n this.ctx.inject(['quickDiff'], (ctx) => {\n enable = true\n ctx.on('dispose', () => {\n enable = false\n })\n\n this.onContentReady(($content) => {\n if (!enable) {\n return\n }\n const anchors = this.scanAnchors($content.get(0)!, ({ params, title }) => {\n return !!(params.has('diff') || title?.isSpecial('diff'))\n })\n anchors.forEach((info) => {\n const { $el, title, params } = info\n if ($el.dataset.ipeDiffMounted) {\n return\n }\n $el.dataset.ipeDiffMounted = '1'\n\n let diff: string | null\n let oldid: string | null\n if (title?.getNamespaceId() === -1) {\n // prettier-ignore\n ;[/** special page name */, oldid, diff] = title.getMainDBKey().split('/')\n if (!diff) {\n diff = 'prev'\n }\n } else {\n diff = params.get('diff')\n oldid = params.get('oldid')\n }\n if (!diff || !oldid) {\n return\n }\n\n const compare: Partial<CompareApiRequestOptions> = {}\n if (isRelative(diff)) {\n compare.fromrev = parseInt(oldid)\n compare.torelative = diff\n } else {\n compare.fromrev = parseInt(oldid)\n compare.torev = parseInt(diff)\n }\n\n const link = (\n <a\n href={`#ipe://quick-diff/`}\n dataset={compare as any}\n className={`${this.config.linkClassName} ipe-quick-diff`}\n style={{\n userSelect: 'none',\n marginLeft: '0.2em',\n }}\n onClick={(e) => {\n e.preventDefault()\n this.ctx.emit('in-article-links/anchor-clicked', {\n ctx: this.ctx,\n anchor: $el,\n info,\n event: e,\n action: 'quickDiff',\n })\n ctx.quickDiff.comparePages(compare)\n }}\n >\n <svg\n xmlns=\"http://www.w3.org/2000/svg\"\n width=\"24\"\n height=\"24\"\n viewBox=\"0 0 24 24\"\n fill=\"none\"\n stroke=\"currentColor\"\n stroke-width=\"2\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n class=\"icon icon-tabler icons-tabler-outline icon-tabler-file-diff ipe-icon\"\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M14 3v4a1 1 0 0 0 1 1h4\" />\n <path d=\"M17 21h-10a2 2 0 0 1 -2 -2v-14a2 2 0 0 1 2 -2h7l5 5v11a2 2 0 0 1 -2 2z\" />\n <path d=\"M12 10l0 4\" />\n <path d=\"M10 12l4 0\" />\n <path d=\"M10 17l4 0\" />\n </svg>\n </a>\n )\n\n $el.insertAdjacentElement('afterend', link)\n })\n })\n })\n }\n}\n"],"names":["_PluginInArticleLinks_decorators","_init","_a","Inject","RegisterPreferences","Schema","PluginInArticleLinks","BasePlugin","ctx","$","el","anchor","cached","attrHref","href","linkInfo","info","parent","filter","anchors","callback","register","$content","enable","showButtonOnRedlinks","action","title","redlink","$el","pageId","params","titleText","sectionRaw","revisionRaw","createOnly","section","revision","payload","link","jsx","e","IconQuickEdit","isRelative","str","diff","oldid","compare","jsxs","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAqCAF,IAAA,CAACG,EAAO,CAAC,QAAQ,aAAa,eAAe,GAAG,CAAC,GAChDC;AAAA,EACCC,EAAO,OAAO;AAAA,IACZ,yBAAyBA,EAAO,QAAA,EAC7B,YAAY,oCAAoC,EAChD,QAAQ,EAAI;AAAA,IACf,mCAAmCA,EAAO,QAAA,EACvC,YAAY,mDAAmD,EAC/D,QAAQ,EAAI;AAAA,IACf,mCAAmCA,EAAO,QAAA,EACvC,YAAY,mDAAmD,EAC/D,QAAQ,EAAI;AAAA,IACf,qCAAqCA,EAAO,QAAA,EACzC,YAAY,gDAAgD,EAC5D,QAAQ,EAAI;AAAA,EAAA,CAChB,EACE,YAAY,8BAA8B,EAC1C,MAAM,YAAY,kBAAkB;AACzC,CAAA;AACO,MAAMC,WAA6BJ,IAAAK,GAEvC;AAAA,EACD,YAAYC,GAAiB;AAC3B;AAAA,MACEA;AAAA,MACA;AAAA,QACE,eAAe;AAAA,MAAA;AAAA,MAEjB;AAAA,IAAA,GAkCJ,KAAQ,wCAAwB,QAAA,GAhC9B,KAAK,IAAI,IAAI,kBAAkB,IAAI;AACnC,UAAMC,IAAI,KAAK,IAAI;AAEnB,SAAK,IAAI,YAAY,eAAe;AAAA,MAClC,MAAM;AAAA,MACN,OAAOA;AAAA,MACP,aAAaA;AAAA,MACb,OAAO;AAAA,IAAA,CACR;AAAA,EACH;AAAA,EAEA,MAAgB,QAAQ;AAEtB,IAAI,MAAM,KAAK,IAAI,YAAY,IAAI,iCAAiC,KAClE,KAAK,gBAAA,GAEH,MAAM,KAAK,IAAI,YAAY,IAAI,iCAAiC,KAClE,KAAK,gBAAA;AAAA,EAET;AAAA,EAEA,MAAgB,OAAO;AACrB,UAAM;AAAA,MACJ,SAAS,uBA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registry, t.id, t.source, "user-preference");
|
|
112
112
|
}
|
|
113
113
|
async _createManagementApp() {
|
|
114
|
-
const e = await this.ctx.withInject(["store"]), t = F(() => import("./PluginStoreApp-
|
|
114
|
+
const e = await this.ctx.withInject(["store"]), t = F(() => import("./PluginStoreApp-MbC3G9tu.js"));
|
|
115
115
|
return O(e, t);
|
|
116
116
|
}
|
|
117
117
|
async _injectPreferenceUI() {
|
|
@@ -388,4 +388,4 @@ let X = w;
|
|
|
388
388
|
export {
|
|
389
389
|
X as PluginPluginStore
|
|
390
390
|
};
|
|
391
|
-
//# sourceMappingURL=index-
|
|
391
|
+
//# sourceMappingURL=index-B3jld2sl.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-DrIf5j8O.js","sources":["../src/plugins/plugin-store/schema.ts","../src/plugins/plugin-store/index.tsx"],"sourcesContent":["import Schema from 'schemastery'\n\nexport const PLUGIN_STORE_REGISTRY_MANIFEST_VERSION = 1\n\nexport interface PluginStoreRegistry {\n manifest_version: number\n name: string\n base_url: string\n homepage?: string\n maintainers?: PluginStoreRegistryMaintainer[]\n repository?: PluginStoreRegistryRepository\n packages: PluginStorePackage[]\n}\n\nexport interface PluginStoreRegistryMaintainer {\n name: string\n email?: string\n}\n\nexport interface PluginStoreRegistryRepository {\n type: string\n url: string\n}\n\nexport interface PluginStorePackage {\n id: string\n name: string\n version: string\n description?: string\n author?: string\n license?: string\n loader: PluginStorePackageLoader\n}\n\nexport interface PluginStorePackageLoader {\n kind: 'autoload' | 'module' | 'umd' | 'styles'\n entry?: string\n styles?: string[]\n main_export?: string\n}\n\nexport namespace PluginStoreSchemas {\n export const PackageLoader = new Schema<PluginStorePackageLoader>(\n Schema.object({\n kind: Schema.union(['autoload', 'module', 'umd', 'styles']).required().default('autoload'),\n entry: Schema.string(),\n styles: Schema.array(Schema.string()),\n main_export: Schema.string(),\n })\n )\n\n export const Package = new Schema<PluginStorePackage>(\n Schema.object({\n id: Schema.string().required(),\n name: Schema.string().required(),\n version: Schema.string().required(),\n description: Schema.string(),\n author: Schema.string(),\n license: Schema.string(),\n loader: PackageLoader.required(),\n })\n )\n\n export const RegistryMaintainer = new Schema<PluginStoreRegistryMaintainer>(\n Schema.object({\n name: Schema.string().required(),\n email: Schema.string(),\n })\n )\n\n export const RegistryRepository = new Schema<PluginStoreRegistryRepository>(\n Schema.object({\n type: Schema.string().required(),\n url: Schema.string().required(),\n })\n )\n\n export const Registry = new Schema<PluginStoreRegistry>(\n Schema.object({\n manifest_version: Schema.number().min(PLUGIN_STORE_REGISTRY_MANIFEST_VERSION).required(),\n name: Schema.string().required(),\n base_url: Schema.string().required(),\n homepage: Schema.string(),\n maintainers: Schema.array(RegistryMaintainer),\n repository: RegistryRepository,\n packages: Schema.array(Package).required(),\n })\n )\n}\n","import { InPageEdit, Schema } from '@/InPageEdit'\nimport { ForkScope, Inject } from '@cordisjs/core'\nimport { defineAsyncComponent, type App as VueApp } from 'vue'\nimport { PluginStoreRegistry, PluginStoreSchemas } from './schema'\nimport { AbstractIPEStorageManager } from '@/services/storage/index.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n store: PluginPluginStore\n }\n interface PreferencesMap {\n 'pluginStore.registries': string[]\n 'pluginStore.plugins': { source?: 'online_manifest' | 'npm'; registry: string; id: string }[]\n 'pluginStore.cdnForNpm': string\n }\n interface Events {\n 'plugin-store/registry-fetched'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n }): void\n 'plugin-store/registry-not-found'(payload: { ctx: InPageEdit; registryUrl: string }): void\n 'plugin-store/registry-removed'(payload: { ctx: InPageEdit; registryUrl: string }): void\n 'plugin-store/plugin-installed'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n id: string\n // 新安装 or 通过用户配置加载\n by: 'new-added' | 'user-preference'\n }): void\n 'plugin-store/plugin-uninstalled'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n id: string\n }): void\n }\n}\n\nexport type PluginStoreRegistrySource = 'online_manifest' | 'npm'\n\nconst tryGetGlobalPlugin = (main_export: string) => {\n if (!main_export) return null\n try {\n return main_export\n .split('.')\n .reduce<any>((acc, key) => (acc == null ? acc : acc[key]), globalThis as any)\n } catch {\n return null\n }\n}\n\n/**\n * 解析资源URL\n * @param resourcePath - entry或style路径,可能是相对路径或完整URL\n * @param baseUrl - registry中的base_url,可能是完整URL或相对路径\n * @param registryUrl - registry的URL(必须是绝对URL,作为相对baseUrl时的基准)\n * @returns 解析后的完整URL\n */\nconst resolveResourceUrl = (resourcePath: string, baseUrl: string, registryUrl: string): string => {\n // 完整URL:直接返回\n if (/^https?:\\/\\//i.test(resourcePath)) return resourcePath\n\n // 兜底:规范化一个“带尾斜杠”的 helper\n const ensureSlash = (s: string) => (s.endsWith('/') ? s : s + '/')\n\n // 如果 baseUrl 是完整URL:直接用它当基准(并确保目录语义)\n if (/^https?:\\/\\//i.test(baseUrl)) {\n const normalizedBase = ensureSlash(baseUrl)\n return new URL(resourcePath, normalizedBase).href\n }\n\n // baseUrl 是相对路径(如 './' 或 '/plugins')\n // 先把 baseUrl 相对于 registryUrl 解析成绝对URL\n // 注意:当 baseUrl 是 '/plugins' 这种根相对路径时,new URL 会以 registryUrl 的 origin 作为根。\n const registryAbs = (() => {\n try {\n return new URL(registryUrl).href\n } catch {\n // 极端情况(开发环境传了相对 registry),用页面 origin 兜底\n return new URL(registryUrl, location.origin).href\n }\n })()\n\n const resolvedBaseUrl = new URL(ensureSlash(baseUrl), registryAbs).href\n return new URL(resourcePath, resolvedBaseUrl).href\n}\n\n@Inject(['storage', 'preferences', 'resourceLoader', '$'])\nexport class PluginPluginStore extends BasePlugin {\n // re-export for external usage\n static readonly PluginStoreSchemas = PluginStoreSchemas\n static REGISTRY_INFO_CACHE_TTL = 1000 * 60 * 60 * 24 // 1 day\n static REGISTRY_INFO_STORAGE_NAME = 'plugin-store-registry'\n static REGISTRY_ETAG_STORAGE_NAME = 'psreg-etag'\n private regInfoDB: AbstractIPEStorageManager<PluginStoreRegistry>\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'plugin-store')\n ctx.set('store', this)\n this.regInfoDB = ctx.storage.createDatabase<PluginStoreRegistry>(\n PluginPluginStore.REGISTRY_INFO_STORAGE_NAME,\n PluginPluginStore.REGISTRY_INFO_CACHE_TTL,\n 1,\n 'indexedDB'\n )\n }\n\n protected async start() {\n this._installUserPlugins()\n this._injectPreferenceUI()\n }\n\n private async _installUserPlugins() {\n const prefs = await this.ctx.preferences.get('pluginStore.plugins', [])\n if (!prefs?.length) {\n return\n }\n for (const pref of prefs) {\n this.install(pref.registry, pref.id, pref.source, 'user-preference')\n }\n }\n\n private async _createManagementApp() {\n const ctx = await this.ctx.withInject(['store'])\n const PluginStoreApp = defineAsyncComponent(() => import('./components/PluginStoreApp.vue'))\n const app = createVueAppWithIPE(ctx, PluginStoreApp)\n return app\n }\n\n private async _injectPreferenceUI() {\n const ctx = this.ctx\n const $ = ctx.$\n\n ctx.preferences.defineCategory({\n name: 'plugin-store',\n label: $`Plugin Store`,\n description: $`Plugin Store`,\n index: 90,\n autoGenerateForm: false,\n customRenderer: async ({ onUnmount }) => {\n const container = <div id=\"ipe-plugin-store-preferences-vue\"></div>\n const app = await this._createManagementApp()\n app.mount(container)\n\n onUnmount(() => {\n app.unmount()\n this.ctx.logger.debug('Plugin Store preferences app unmounted')\n })\n\n return (\n <section>\n {container}\n {/* <div className=\"theme-ipe-prose\">\n <hr />\n <div style={{ textAlign: 'center', marginBottom: '1em', fontSize: '0.8em' }}>\n 🚫 DO NOT edit fields below manually 🚫\n </div>\n </div> */}\n </section>\n )\n },\n })\n\n ctx.preferences.registerCustomConfig(\n 'plugin-store',\n Schema.object({\n 'pluginStore.registries': Schema.array(Schema.string())\n .default([\n import.meta.env.PROD\n ? Endpoints.PLUGIN_REGISTRY_URL\n : import.meta.resolve('/src/__mock__/plugin-registry/index.json'),\n ])\n .description($`Registry URLs`)\n .hidden(),\n 'pluginStore.cdnForNpm': Schema.string()\n .description($`CDN to install packages from npm`)\n .default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? \"@\" + version : \"\" }}')\n .hidden(),\n 'pluginStore.plugins': Schema.array(\n Schema.object({\n source: Schema.union(['online_manifest', 'npm']).default('online_manifest'),\n registry: Schema.string().required(),\n id: Schema.string().required(),\n })\n )\n .description($`Installed plugins`)\n .default([])\n .hidden(),\n }),\n 'plugin-store'\n )\n }\n\n async showModal() {\n const modal = this.ctx.modal.show({\n title: $`Plugin Store`,\n sizeClass: 'small',\n })\n const container = <section id=\"ipe-plugin-store-vue\"></section>\n modal.setContent(container)\n const app = await this._createManagementApp()\n app.mount(container)\n modal.on(modal.Event.Close, () => {\n app.unmount()\n })\n return modal\n }\n\n private _installedPlugins = new Map<string, Promise<ForkScope<InPageEdit> | null>>()\n async install(\n registry: string,\n id: string,\n source: PluginStoreRegistrySource = 'online_manifest',\n _by: 'new-added' | 'user-preference' = 'new-added'\n ): Promise<ForkScope<InPageEdit> | null> {\n const registryInfo = await this.getRegistryInfo(registry, source)\n if (!registryInfo) {\n this.ctx.logger.warn(`Registry ${registry} not found`)\n return null\n }\n const key = `${registry}#${id}`\n if (this._installedPlugins.has(key)) {\n return (await this._installedPlugins.get(key)) ?? null\n }\n // 2) 把 registry 原始 URL 传进去,供 URL 解析使用\n const scope = this._installOneByRegistryInfo(registry, registryInfo, id)\n this._installedPlugins.set(key, scope)\n const fork = await scope\n if (fork) {\n this.ctx.emit('plugin-store/plugin-installed', {\n ctx: this.ctx,\n registry: registryInfo,\n id,\n by: _by,\n })\n }\n return fork\n }\n async uninstall(registry: string, id: string): Promise<boolean> {\n const promise = this._installedPlugins.get(`${registry}#${id}`)\n if (promise === void 0) {\n return true // not installed or already uninstalled\n }\n this._installedPlugins.delete(`${registry}#${id}`)\n const scope = await promise\n if (scope) {\n const disposed = scope.dispose?.() ?? true // disposed successfully\n try {\n const registryInfo =\n (await this.getRegistryCache(registry)) ||\n (await this.getRegistryInfo(registry).catch(() => null))\n if (registryInfo) {\n this.ctx.emit('plugin-store/plugin-uninstalled', {\n ctx: this.ctx,\n registry: registryInfo,\n id,\n })\n }\n } catch {}\n return disposed\n }\n return true // not a plugin, just removed from the list\n }\n\n async addToPreferences(registry: string, id: string) {\n let prefs =\n (await this.ctx.preferences.get<{ registry: string; id: string }[]>('pluginStore.plugins')) ||\n []\n const existed = prefs.some((p) => p.registry === registry && p.id === id)\n if (existed) {\n return true\n }\n prefs.push({ registry, id })\n await this.ctx.preferences.set('pluginStore.plugins', prefs)\n return true\n }\n async removeFromPreferences(registry: string, id: string) {\n let prefs =\n (await this.ctx.preferences.get<{ registry: string; id: string }[]>('pluginStore.plugins')) ||\n []\n prefs = prefs.filter((p) => p.registry !== registry || p.id !== id)\n await this.ctx.preferences.set('pluginStore.plugins', prefs)\n return true\n }\n\n async installAndSetPreference(registry: string, id: string) {\n await this.addToPreferences(registry, id)\n return this.install(registry, id, 'online_manifest', 'new-added')\n }\n async uninstallAndRemovePreference(registry: string, id: string) {\n await this.removeFromPreferences(registry, id)\n return this.uninstall(registry, id)\n }\n\n // 3) 增加 registryUrl 参数\n private async _installOneByRegistryInfo(\n registryUrl: string,\n registryInfo: PluginStoreRegistry,\n id: string\n ): Promise<ForkScope<InPageEdit> | null> {\n const baseUrl = registryInfo.base_url\n const pkg = registryInfo.packages.find((p) => p.id === id)\n if (!pkg) {\n this.ctx.logger.warn(`Package ${id} not found in registry ${registryUrl}`)\n return null\n }\n\n const loader = pkg.loader\n const { kind, entry = 'index.js', styles = [], main_export = null } = loader\n\n // 4) 统一用 resolveResourceUrl 解析入口\n let entryUrl: string | null = null\n if (kind !== 'styles') {\n if (!entry) {\n this.ctx.logger.warn(`Entry url missing for ${id}`, loader)\n return null\n }\n try {\n entryUrl = resolveResourceUrl(entry, baseUrl, registryUrl)\n } catch (e) {\n this.ctx.logger.warn(\n `Failed to resolve entry \"${entry}\" with base \"${baseUrl}\" and registry \"${registryUrl}\"`,\n e\n )\n return null\n }\n }\n\n const datasets = {\n 'data-plugin-registry': registryUrl,\n 'data-plugin-id': id,\n }\n\n let fork: ForkScope<InPageEdit> | null = null\n\n switch (kind) {\n case 'autoload': {\n fork = this.ctx.plugin({\n inject: ['resourceLoader'],\n name: `plugin-store-${registryUrl}-${id}`,\n apply: (ctx) => {\n if (!entryUrl) return\n ctx.resourceLoader.loadScript(entryUrl, { ...datasets })\n },\n })\n break\n }\n case 'module': {\n if (!entryUrl) {\n this.ctx.logger.warn(`Entry url missing for module kind, package ${id}`)\n return null\n }\n const apply = await import(/* @vite-ignore */ entryUrl).then(\n (m) => (main_export ? m[main_export] : m.default) ?? m\n )\n if (!apply) {\n this.ctx.logger.warn(`Main export ${main_export} not found in module ${entryUrl}`)\n return null\n }\n fork = this.ctx.plugin(apply)\n break\n }\n case 'umd': {\n let apply = tryGetGlobalPlugin(main_export!)\n if (!apply) {\n if (!entryUrl) {\n this.ctx.logger.warn(`Entry url missing for umd kind, package ${id}`)\n return null\n }\n await this.ctx.resourceLoader.loadScript(entryUrl, { ...datasets })\n apply = tryGetGlobalPlugin(main_export!)\n }\n if (!apply) {\n this.ctx.logger.warn(\n `Main export ${main_export} not found on globalThis after loading ${entryUrl}`\n )\n return null\n }\n fork = this.ctx.plugin(apply)\n break\n }\n case 'styles': {\n // 没有脚本,仅样式。下面统一样式注入逻辑会覆盖\n break\n }\n }\n\n // 5) 统一解析并注入样式(兼容绝对URL与相对 + base_url 的组合)\n if (styles && styles.length > 0) {\n let urls: string[] = []\n try {\n urls = styles.map((u) => resolveResourceUrl(u, baseUrl, registryUrl)).filter(Boolean)\n } catch (e) {\n this.ctx.logger.warn(`Failed to resolve styles for ${id}`, styles, e)\n }\n\n // 确保存在父 fork\n fork ||= this.ctx.plugin({ name: `plugin-store-${registryUrl}-${id}`, apply() {} })\n\n // 在子插件里加载样式,并在卸载时清理\n fork.ctx.plugin({\n inject: ['resourceLoader'],\n name: `plugin-store-${registryUrl}-${id}-styles`,\n apply: (ctx) => {\n urls.forEach((u) => ctx.resourceLoader.loadStyle(u, { ...datasets }))\n ctx.on('dispose', () => {\n try {\n urls.forEach((u) => ctx.resourceLoader.removeStyle(u))\n } catch (e) {\n console.info('styles cleanup failed', e)\n }\n })\n },\n })\n }\n\n return fork\n }\n\n validateRegistry(data: any): PluginStoreRegistry {\n return PluginStoreSchemas.Registry(data)\n }\n\n async getRegistryInfo(\n registry: string,\n source: PluginStoreRegistrySource = 'online_manifest',\n noCache = false\n ): Promise<PluginStoreRegistry> {\n try {\n let info: PluginStoreRegistry\n switch (source) {\n case 'online_manifest': {\n info = await this._fetchOnlineRegistryInfo(registry, noCache)\n this.logger.debug('Fetched registry info from online manifest', info)\n this.setRegistryCache(registry, info)\n break\n }\n default: {\n throw new Error(`Unsupported registry source: ${source}`)\n }\n }\n\n return info\n } catch (e) {\n this.ctx.logger.warn('Failed to fetch registry info', e)\n }\n\n const info = await this.getRegistryCache(registry)\n if (!info) {\n this.ctx.emit('plugin-store/registry-not-found', {\n ctx: this.ctx,\n registryUrl: registry,\n })\n throw new Error(`Failed to fetch registry info: ${registry}`)\n }\n return info\n }\n\n private _onlineRegistryQueries = new Map<string, Promise<PluginStoreRegistry>>()\n private async _fetchOnlineRegistryInfo(\n registry: string,\n noCache = false\n ): Promise<PluginStoreRegistry> {\n if (!noCache && this._onlineRegistryQueries.has(registry)) {\n return await this._onlineRegistryQueries.get(registry)!\n }\n const task = async () => {\n const payload: RequestInit = {\n method: 'GET',\n }\n if (noCache) {\n payload.cache = 'no-store'\n }\n const response = await fetch(registry, payload)\n const data = await response.json()\n const validated = this.validateRegistry(data)\n // 成功在线获取并校验后触发事件\n this.ctx.emit('plugin-store/registry-fetched', {\n ctx: this.ctx,\n registry: validated,\n })\n return validated\n }\n const promise = task()\n this._onlineRegistryQueries.set(registry, promise)\n return await promise\n }\n\n private async getRegistryCache(registry: string) {\n const data = await this.regInfoDB.get(registry)\n if (data) {\n try {\n const validated = this.validateRegistry(data)\n return validated\n } catch (e) {\n this.ctx.logger.warn('Invalid cached registry', e, data)\n this.regInfoDB.delete(registry)\n }\n }\n return null\n }\n private async setRegistryCache(registry: string, data: PluginStoreRegistry) {\n return this.regInfoDB.set(registry, data)\n }\n private async deleteRegistryCache(registry: string) {\n await this.regInfoDB.delete(registry)\n this.ctx.emit('plugin-store/registry-removed', {\n ctx: this.ctx,\n registryUrl: registry,\n })\n }\n async clearAllRegistryCaches() {\n await this.regInfoDB.clear()\n this.ctx.logger.debug('All registry caches cleared')\n }\n\n /**\n * 刷新指定 registry 的缓存(重新从网络获取)\n */\n async refreshRegistryCache(registry: string): Promise<PluginStoreRegistry> {\n const data = await this.getRegistryInfo(registry, 'online_manifest', true)\n if (!data) {\n throw new Error(`Failed to refresh registry cache: ${registry}`)\n }\n this.ctx.logger.debug('Registry cache refreshed:', registry)\n return data\n }\n\n /**\n * 刷新所有已配置的 registry 缓存\n */\n async refreshAllRegistryCaches(): Promise<Record<string, PluginStoreRegistry | null>> {\n const registryUrls = (await this.ctx.preferences.get('pluginStore.registries')) || []\n const responses = await Promise.allSettled(\n registryUrls.map((url) => this.refreshRegistryCache(url))\n )\n const results: Record<string, PluginStoreRegistry | null> = {}\n for (const [index, response] of responses.entries()) {\n if (response.status === 'fulfilled') {\n results[registryUrls[index]] = response.value\n } else {\n results[registryUrls[index]] = null\n }\n }\n return results\n }\n}\n"],"names":["PLUGIN_STORE_REGISTRY_MANIFEST_VERSION","PluginStoreSchemas","Schema","_PluginPluginStore_decorators","_init","_a","tryGetGlobalPlugin","main_export","acc","key","resolveResourceUrl","resourcePath","baseUrl","registryUrl","ensureSlash","s","normalizedBase","registryAbs","resolvedBaseUrl","Inject","_PluginPluginStore","BasePlugin","ctx","prefs","pref","PluginStoreApp","defineAsyncComponent","createVueAppWithIPE","$","onUnmount","container","jsx","app","Endpoints","modal","registry","id","source","_by","registryInfo","scope","fork","promise","disposed","p","pkg","loader","kind","entry","styles","entryUrl","e","datasets","apply","m","urls","u","data","noCache","info","payload","validated","registryUrls","responses","url","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I,YAAY,IAAI,wBAAwB,KAAM,CAAA,GAC7EC,IAAY,MAAM,QAAQ;AAAA,MAC9BD,EAAa,IAAI,CAACE,MAAQ,KAAK,qBAAqBA,CAAG,CAAC;AAAA,IAAA,GAEpDC,IAAsD,CAAA;AAC5D,eAAW,CAACC,GAAOC,CAAQ,KAAKJ,EAAU;AACxC,MAAII,EAAS,WAAW,cACtBF,EAAQH,EAAaI,CAAK,CAAC,IAAIC,EAAS,QAExCF,EAAQH,EAAaI,CAAK,CAAC,IAAI;AAGnC,WAAOD;AAAA,EACT;AACF;AA1cO7D,IAAAgE,EAAA/D,CAAA;AAAMe,IAANiD,6BADPlE,GACaiB,CAAA;AAANkD,EAAAlE,GAAA,GAAMgB,CAAA;AAAN,IAAMmD,IAANnD;"}
|
|
1
|
+
{"version":3,"file":"index-B3jld2sl.js","sources":["../src/plugins/plugin-store/schema.ts","../src/plugins/plugin-store/index.tsx"],"sourcesContent":["import Schema from 'schemastery'\n\nexport const PLUGIN_STORE_REGISTRY_MANIFEST_VERSION = 1\n\nexport interface PluginStoreRegistry {\n manifest_version: number\n name: string\n base_url: string\n homepage?: string\n maintainers?: PluginStoreRegistryMaintainer[]\n repository?: PluginStoreRegistryRepository\n packages: PluginStorePackage[]\n}\n\nexport interface PluginStoreRegistryMaintainer {\n name: string\n email?: string\n}\n\nexport interface PluginStoreRegistryRepository {\n type: string\n url: string\n}\n\nexport interface PluginStorePackage {\n id: string\n name: string\n version: string\n description?: string\n author?: string\n license?: string\n loader: PluginStorePackageLoader\n}\n\nexport interface PluginStorePackageLoader {\n kind: 'autoload' | 'module' | 'umd' | 'styles'\n entry?: string\n styles?: string[]\n main_export?: string\n}\n\nexport namespace PluginStoreSchemas {\n export const PackageLoader = new Schema<PluginStorePackageLoader>(\n Schema.object({\n kind: Schema.union(['autoload', 'module', 'umd', 'styles']).required().default('autoload'),\n entry: Schema.string(),\n styles: Schema.array(Schema.string()),\n main_export: Schema.string(),\n })\n )\n\n export const Package = new Schema<PluginStorePackage>(\n Schema.object({\n id: Schema.string().required(),\n name: Schema.string().required(),\n version: Schema.string().required(),\n description: Schema.string(),\n author: Schema.string(),\n license: Schema.string(),\n loader: PackageLoader.required(),\n })\n )\n\n export const RegistryMaintainer = new Schema<PluginStoreRegistryMaintainer>(\n Schema.object({\n name: Schema.string().required(),\n email: Schema.string(),\n })\n )\n\n export const RegistryRepository = new Schema<PluginStoreRegistryRepository>(\n Schema.object({\n type: Schema.string().required(),\n url: Schema.string().required(),\n })\n )\n\n export const Registry = new Schema<PluginStoreRegistry>(\n Schema.object({\n manifest_version: Schema.number().min(PLUGIN_STORE_REGISTRY_MANIFEST_VERSION).required(),\n name: Schema.string().required(),\n base_url: Schema.string().required(),\n homepage: Schema.string(),\n maintainers: Schema.array(RegistryMaintainer),\n repository: RegistryRepository,\n packages: Schema.array(Package).required(),\n })\n )\n}\n","import { InPageEdit, Schema } from '@/InPageEdit'\nimport { ForkScope, Inject } from '@cordisjs/core'\nimport { defineAsyncComponent, type App as VueApp } from 'vue'\nimport { PluginStoreRegistry, PluginStoreSchemas } from './schema'\nimport { AbstractIPEStorageManager } from '@/services/storage/index.js'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n store: PluginPluginStore\n }\n interface PreferencesMap {\n 'pluginStore.registries': string[]\n 'pluginStore.plugins': { source?: 'online_manifest' | 'npm'; registry: string; id: string }[]\n 'pluginStore.cdnForNpm': string\n }\n interface Events {\n 'plugin-store/registry-fetched'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n }): void\n 'plugin-store/registry-not-found'(payload: { ctx: InPageEdit; registryUrl: string }): void\n 'plugin-store/registry-removed'(payload: { ctx: InPageEdit; registryUrl: string }): void\n 'plugin-store/plugin-installed'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n id: string\n // 新安装 or 通过用户配置加载\n by: 'new-added' | 'user-preference'\n }): void\n 'plugin-store/plugin-uninstalled'(payload: {\n ctx: InPageEdit\n registry: PluginStoreRegistry\n id: string\n }): void\n }\n}\n\nexport type PluginStoreRegistrySource = 'online_manifest' | 'npm'\n\nconst tryGetGlobalPlugin = (main_export: string) => {\n if (!main_export) return null\n try {\n return main_export\n .split('.')\n .reduce<any>((acc, key) => (acc == null ? acc : acc[key]), globalThis as any)\n } catch {\n return null\n }\n}\n\n/**\n * 解析资源URL\n * @param resourcePath - entry或style路径,可能是相对路径或完整URL\n * @param baseUrl - registry中的base_url,可能是完整URL或相对路径\n * @param registryUrl - registry的URL(必须是绝对URL,作为相对baseUrl时的基准)\n * @returns 解析后的完整URL\n */\nconst resolveResourceUrl = (resourcePath: string, baseUrl: string, registryUrl: string): string => {\n // 完整URL:直接返回\n if (/^https?:\\/\\//i.test(resourcePath)) return resourcePath\n\n // 兜底:规范化一个“带尾斜杠”的 helper\n const ensureSlash = (s: string) => (s.endsWith('/') ? s : s + '/')\n\n // 如果 baseUrl 是完整URL:直接用它当基准(并确保目录语义)\n if (/^https?:\\/\\//i.test(baseUrl)) {\n const normalizedBase = ensureSlash(baseUrl)\n return new URL(resourcePath, normalizedBase).href\n }\n\n // baseUrl 是相对路径(如 './' 或 '/plugins')\n // 先把 baseUrl 相对于 registryUrl 解析成绝对URL\n // 注意:当 baseUrl 是 '/plugins' 这种根相对路径时,new URL 会以 registryUrl 的 origin 作为根。\n const registryAbs = (() => {\n try {\n return new URL(registryUrl).href\n } catch {\n // 极端情况(开发环境传了相对 registry),用页面 origin 兜底\n return new URL(registryUrl, location.origin).href\n }\n })()\n\n const resolvedBaseUrl = new URL(ensureSlash(baseUrl), registryAbs).href\n return new URL(resourcePath, resolvedBaseUrl).href\n}\n\n@Inject(['storage', 'preferences', 'resourceLoader', '$'])\nexport class PluginPluginStore extends BasePlugin {\n // re-export for external usage\n static readonly PluginStoreSchemas = PluginStoreSchemas\n static REGISTRY_INFO_CACHE_TTL = 1000 * 60 * 60 * 24 // 1 day\n static REGISTRY_INFO_STORAGE_NAME = 'plugin-store-registry'\n static REGISTRY_ETAG_STORAGE_NAME = 'psreg-etag'\n private regInfoDB: AbstractIPEStorageManager<PluginStoreRegistry>\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'plugin-store')\n ctx.set('store', this)\n this.regInfoDB = ctx.storage.createDatabase<PluginStoreRegistry>(\n PluginPluginStore.REGISTRY_INFO_STORAGE_NAME,\n PluginPluginStore.REGISTRY_INFO_CACHE_TTL,\n 1,\n 'indexedDB'\n )\n }\n\n protected async start() {\n this._installUserPlugins()\n this._injectPreferenceUI()\n }\n\n private async _installUserPlugins() {\n const prefs = await this.ctx.preferences.get('pluginStore.plugins', [])\n if (!prefs?.length) {\n return\n }\n for (const pref of prefs) {\n this.install(pref.registry, pref.id, pref.source, 'user-preference')\n }\n }\n\n private async _createManagementApp() {\n const ctx = await this.ctx.withInject(['store'])\n const PluginStoreApp = defineAsyncComponent(() => import('./components/PluginStoreApp.vue'))\n const app = createVueAppWithIPE(ctx, PluginStoreApp)\n return app\n }\n\n private async _injectPreferenceUI() {\n const ctx = this.ctx\n const $ = ctx.$\n\n ctx.preferences.defineCategory({\n name: 'plugin-store',\n label: $`Plugin Store`,\n description: $`Plugin Store`,\n index: 90,\n autoGenerateForm: false,\n customRenderer: async ({ onUnmount }) => {\n const container = <div id=\"ipe-plugin-store-preferences-vue\"></div>\n const app = await this._createManagementApp()\n app.mount(container)\n\n onUnmount(() => {\n app.unmount()\n this.ctx.logger.debug('Plugin Store preferences app unmounted')\n })\n\n return (\n <section>\n {container}\n {/* <div className=\"theme-ipe-prose\">\n <hr />\n <div style={{ textAlign: 'center', marginBottom: '1em', fontSize: '0.8em' }}>\n 🚫 DO NOT edit fields below manually 🚫\n </div>\n </div> */}\n </section>\n )\n },\n })\n\n ctx.preferences.registerCustomConfig(\n 'plugin-store',\n Schema.object({\n 'pluginStore.registries': Schema.array(Schema.string())\n .default([\n import.meta.env.PROD\n ? Endpoints.PLUGIN_REGISTRY_URL\n : import.meta.resolve('/src/__mock__/plugin-registry/index.json'),\n ])\n .description($`Registry URLs`)\n .hidden(),\n 'pluginStore.cdnForNpm': Schema.string()\n .description($`CDN to install packages from npm`)\n .default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? \"@\" + version : \"\" }}')\n .hidden(),\n 'pluginStore.plugins': Schema.array(\n Schema.object({\n source: Schema.union(['online_manifest', 'npm']).default('online_manifest'),\n registry: Schema.string().required(),\n id: Schema.string().required(),\n })\n )\n .description($`Installed plugins`)\n .default([])\n .hidden(),\n }),\n 'plugin-store'\n )\n }\n\n async showModal() {\n const modal = this.ctx.modal.show({\n title: $`Plugin Store`,\n sizeClass: 'small',\n })\n const container = <section id=\"ipe-plugin-store-vue\"></section>\n modal.setContent(container)\n const app = await this._createManagementApp()\n app.mount(container)\n modal.on(modal.Event.Close, () => {\n app.unmount()\n })\n return modal\n }\n\n private _installedPlugins = new Map<string, Promise<ForkScope<InPageEdit> | null>>()\n async install(\n registry: string,\n id: string,\n source: PluginStoreRegistrySource = 'online_manifest',\n _by: 'new-added' | 'user-preference' = 'new-added'\n ): Promise<ForkScope<InPageEdit> | null> {\n const registryInfo = await this.getRegistryInfo(registry, source)\n if (!registryInfo) {\n this.ctx.logger.warn(`Registry ${registry} not found`)\n return null\n }\n const key = `${registry}#${id}`\n if (this._installedPlugins.has(key)) {\n return (await this._installedPlugins.get(key)) ?? null\n }\n // 2) 把 registry 原始 URL 传进去,供 URL 解析使用\n const scope = this._installOneByRegistryInfo(registry, registryInfo, id)\n this._installedPlugins.set(key, scope)\n const fork = await scope\n if (fork) {\n this.ctx.emit('plugin-store/plugin-installed', {\n ctx: this.ctx,\n registry: registryInfo,\n id,\n by: _by,\n })\n }\n return fork\n }\n async uninstall(registry: string, id: string): Promise<boolean> {\n const promise = this._installedPlugins.get(`${registry}#${id}`)\n if (promise === void 0) {\n return true // not installed or already uninstalled\n }\n this._installedPlugins.delete(`${registry}#${id}`)\n const scope = await promise\n if (scope) {\n const disposed = scope.dispose?.() ?? true // disposed successfully\n try {\n const registryInfo =\n (await this.getRegistryCache(registry)) ||\n (await this.getRegistryInfo(registry).catch(() => null))\n if (registryInfo) {\n this.ctx.emit('plugin-store/plugin-uninstalled', {\n ctx: this.ctx,\n registry: registryInfo,\n id,\n })\n }\n } catch {}\n return disposed\n }\n return true // not a plugin, just removed from the list\n }\n\n async addToPreferences(registry: string, id: string) {\n let prefs =\n (await this.ctx.preferences.get<{ registry: string; id: string }[]>('pluginStore.plugins')) ||\n []\n const existed = prefs.some((p) => p.registry === registry && p.id === id)\n if (existed) {\n return true\n }\n prefs.push({ registry, id })\n await this.ctx.preferences.set('pluginStore.plugins', prefs)\n return true\n }\n async removeFromPreferences(registry: string, id: string) {\n let prefs =\n (await this.ctx.preferences.get<{ registry: string; id: string }[]>('pluginStore.plugins')) ||\n []\n prefs = prefs.filter((p) => p.registry !== registry || p.id !== id)\n await this.ctx.preferences.set('pluginStore.plugins', prefs)\n return true\n }\n\n async installAndSetPreference(registry: string, id: string) {\n await this.addToPreferences(registry, id)\n return this.install(registry, id, 'online_manifest', 'new-added')\n }\n async uninstallAndRemovePreference(registry: string, id: string) {\n await this.removeFromPreferences(registry, id)\n return this.uninstall(registry, id)\n }\n\n // 3) 增加 registryUrl 参数\n private async _installOneByRegistryInfo(\n registryUrl: string,\n registryInfo: PluginStoreRegistry,\n id: string\n ): Promise<ForkScope<InPageEdit> | null> {\n const baseUrl = registryInfo.base_url\n const pkg = registryInfo.packages.find((p) => p.id === id)\n if (!pkg) {\n this.ctx.logger.warn(`Package ${id} not found in registry ${registryUrl}`)\n return null\n }\n\n const loader = pkg.loader\n const { kind, entry = 'index.js', styles = [], main_export = null } = loader\n\n // 4) 统一用 resolveResourceUrl 解析入口\n let entryUrl: string | null = null\n if (kind !== 'styles') {\n if (!entry) {\n this.ctx.logger.warn(`Entry url missing for ${id}`, loader)\n return null\n }\n try {\n entryUrl = resolveResourceUrl(entry, baseUrl, registryUrl)\n } catch (e) {\n this.ctx.logger.warn(\n `Failed to resolve entry \"${entry}\" with base \"${baseUrl}\" and registry \"${registryUrl}\"`,\n e\n )\n return null\n }\n }\n\n const datasets = {\n 'data-plugin-registry': registryUrl,\n 'data-plugin-id': id,\n }\n\n let fork: ForkScope<InPageEdit> | null = null\n\n switch (kind) {\n case 'autoload': {\n fork = this.ctx.plugin({\n inject: ['resourceLoader'],\n name: `plugin-store-${registryUrl}-${id}`,\n apply: (ctx) => {\n if (!entryUrl) return\n ctx.resourceLoader.loadScript(entryUrl, { ...datasets })\n },\n })\n break\n }\n case 'module': {\n if (!entryUrl) {\n this.ctx.logger.warn(`Entry url missing for module kind, package ${id}`)\n return null\n }\n const apply = await import(/* @vite-ignore */ entryUrl).then(\n (m) => (main_export ? m[main_export] : m.default) ?? m\n )\n if (!apply) {\n this.ctx.logger.warn(`Main export ${main_export} not found in module ${entryUrl}`)\n return null\n }\n fork = this.ctx.plugin(apply)\n break\n }\n case 'umd': {\n let apply = tryGetGlobalPlugin(main_export!)\n if (!apply) {\n if (!entryUrl) {\n this.ctx.logger.warn(`Entry url missing for umd kind, package ${id}`)\n return null\n }\n await this.ctx.resourceLoader.loadScript(entryUrl, { ...datasets })\n apply = tryGetGlobalPlugin(main_export!)\n }\n if (!apply) {\n this.ctx.logger.warn(\n `Main export ${main_export} not found on globalThis after loading ${entryUrl}`\n )\n return null\n }\n fork = this.ctx.plugin(apply)\n break\n }\n case 'styles': {\n // 没有脚本,仅样式。下面统一样式注入逻辑会覆盖\n break\n }\n }\n\n // 5) 统一解析并注入样式(兼容绝对URL与相对 + base_url 的组合)\n if (styles && styles.length > 0) {\n let urls: string[] = []\n try {\n urls = styles.map((u) => resolveResourceUrl(u, baseUrl, registryUrl)).filter(Boolean)\n } catch (e) {\n this.ctx.logger.warn(`Failed to resolve styles for ${id}`, styles, e)\n }\n\n // 确保存在父 fork\n fork ||= this.ctx.plugin({ name: `plugin-store-${registryUrl}-${id}`, apply() {} })\n\n // 在子插件里加载样式,并在卸载时清理\n fork.ctx.plugin({\n inject: ['resourceLoader'],\n name: `plugin-store-${registryUrl}-${id}-styles`,\n apply: (ctx) => {\n urls.forEach((u) => ctx.resourceLoader.loadStyle(u, { ...datasets }))\n ctx.on('dispose', () => {\n try {\n urls.forEach((u) => ctx.resourceLoader.removeStyle(u))\n } catch (e) {\n console.info('styles cleanup failed', e)\n }\n })\n },\n })\n }\n\n return fork\n }\n\n validateRegistry(data: any): PluginStoreRegistry {\n return PluginStoreSchemas.Registry(data)\n }\n\n async getRegistryInfo(\n registry: string,\n source: PluginStoreRegistrySource = 'online_manifest',\n noCache = false\n ): Promise<PluginStoreRegistry> {\n try {\n let info: PluginStoreRegistry\n switch (source) {\n case 'online_manifest': {\n info = await this._fetchOnlineRegistryInfo(registry, noCache)\n this.logger.debug('Fetched registry info from online manifest', info)\n this.setRegistryCache(registry, info)\n break\n }\n default: {\n throw new Error(`Unsupported registry source: ${source}`)\n }\n }\n\n return info\n } catch (e) {\n this.ctx.logger.warn('Failed to fetch registry info', e)\n }\n\n const info = await this.getRegistryCache(registry)\n if (!info) {\n this.ctx.emit('plugin-store/registry-not-found', {\n ctx: this.ctx,\n registryUrl: registry,\n })\n throw new Error(`Failed to fetch registry info: ${registry}`)\n }\n return info\n }\n\n private _onlineRegistryQueries = new Map<string, Promise<PluginStoreRegistry>>()\n private async _fetchOnlineRegistryInfo(\n registry: string,\n noCache = false\n ): Promise<PluginStoreRegistry> {\n if (!noCache && this._onlineRegistryQueries.has(registry)) {\n return await this._onlineRegistryQueries.get(registry)!\n }\n const task = async () => {\n const payload: RequestInit = {\n method: 'GET',\n }\n if (noCache) {\n payload.cache = 'no-store'\n }\n const response = await fetch(registry, payload)\n const data = await response.json()\n const validated = this.validateRegistry(data)\n // 成功在线获取并校验后触发事件\n this.ctx.emit('plugin-store/registry-fetched', {\n ctx: this.ctx,\n registry: validated,\n })\n return validated\n }\n const promise = task()\n this._onlineRegistryQueries.set(registry, promise)\n return await promise\n }\n\n private async getRegistryCache(registry: string) {\n const data = await this.regInfoDB.get(registry)\n if (data) {\n try {\n const validated = this.validateRegistry(data)\n return validated\n } catch (e) {\n this.ctx.logger.warn('Invalid cached registry', e, data)\n this.regInfoDB.delete(registry)\n }\n }\n return null\n }\n private async setRegistryCache(registry: string, data: PluginStoreRegistry) {\n return this.regInfoDB.set(registry, data)\n }\n private async deleteRegistryCache(registry: string) {\n await this.regInfoDB.delete(registry)\n this.ctx.emit('plugin-store/registry-removed', {\n ctx: this.ctx,\n registryUrl: registry,\n })\n }\n async clearAllRegistryCaches() {\n await this.regInfoDB.clear()\n this.ctx.logger.debug('All registry caches cleared')\n }\n\n /**\n * 刷新指定 registry 的缓存(重新从网络获取)\n */\n async refreshRegistryCache(registry: string): Promise<PluginStoreRegistry> {\n const data = await this.getRegistryInfo(registry, 'online_manifest', true)\n if (!data) {\n throw new Error(`Failed to refresh registry cache: ${registry}`)\n }\n this.ctx.logger.debug('Registry cache refreshed:', registry)\n return data\n }\n\n /**\n * 刷新所有已配置的 registry 缓存\n */\n async refreshAllRegistryCaches(): Promise<Record<string, PluginStoreRegistry | null>> {\n const registryUrls = (await this.ctx.preferences.get('pluginStore.registries')) || []\n const responses = await Promise.allSettled(\n registryUrls.map((url) => this.refreshRegistryCache(url))\n )\n const results: Record<string, PluginStoreRegistry | null> = {}\n for (const [index, response] of responses.entries()) {\n if (response.status === 'fulfilled') {\n results[registryUrls[index]] = response.value\n } else {\n results[registryUrls[index]] = null\n }\n }\n return results\n }\n}\n"],"names":["PLUGIN_STORE_REGISTRY_MANIFEST_VERSION","PluginStoreSchemas","Schema","_PluginPluginStore_decorators","_init","_a","tryGetGlobalPlugin","main_export","acc","key","resolveResourceUrl","resourcePath","baseUrl","registryUrl","ensureSlash","s","normalizedBase","registryAbs","resolvedBaseUrl","Inject","_PluginPluginStore","BasePlugin","ctx","prefs","pref","PluginStoreApp","defineAsyncComponent","createVueAppWithIPE","$","onUnmount","container","jsx","app","Endpoints","modal","registry","id","source","_by","registryInfo","scope","fork","promise","disposed","p","pkg","loader","kind","entry","styles","entryUrl","e","datasets","apply","m","urls","u","data","noCache","info","payload","validated","registryUrls","responses","url","results","index","response","__decoratorStart","__decorateElement","__runInitializers","PluginPluginStore"],"mappings":";;;;AAEO,MAAMA,IAAyC;AAuC/C,IAAUC;AAAA,CAAV,CAAUA,MAAV;AACQA,EAAAA,EAAA,gBAAgB,IAAIC;AAAA,IAC/BA,EAAO,OAAO;AAAA,MACZ,MAAMA,EAAO,MAAM,CAAC,YAAY,UAAU,OAAO,QAAQ,CAAC,EAAE,WAAW,QAAQ,UAAU;AAAA,MACzF,OAAOA,EAAO,OAAA;AAAA,MACd,QAAQA,EAAO,MAAMA,EAAO,QAAQ;AAAA,MACpC,aAAaA,EAAO,OAAA;AAAA,IAAO,CAC5B;AAAA,EAAA,GAGUD,EAAA,UAAU,IAAIC;AAAA,IACzBA,EAAO,OAAO;AAAA,MACZ,IAAIA,EAAO,OAAA,EAAS,SAAA;AAAA,MACpB,MAAMA,EAAO,OAAA,EAAS,SAAA;AAAA,MACtB,SAASA,EAAO,OAAA,EAAS,SAAA;AAAA,MACzB,aAAaA,EAAO,OAAA;AAAA,MACpB,QAAQA,EAAO,OAAA;AAAA,MACf,SAASA,EAAO,OAAA;AAAA,MAChB,QAAQD,EAAA,cAAc,SAAA;AAAA,IAAS,CAChC;AAAA,EAAA,GAGUA,EAAA,qBAAqB,IAAIC;AAAA,IACpCA,EAAO,OAAO;AAAA,MACZ,MAAMA,EAAO,OAAA,EAAS,SAAA;AAAA,MACtB,OAAOA,EAAO,OAAA;AAAA,IAAO,CACtB;AAAA,EAAA,GAGUD,EAAA,qBAAqB,IAAIC;AAAA,IACpCA,EAAO,OAAO;AAAA,MACZ,MAAMA,EAAO,OAAA,EAAS,SAAA;AAAA,MACtB,KAAKA,EAAO,OAAA,EAAS,SAAA;AAAA,IAAS,CAC/B;AAAA,EAAA,GAGUD,EAAA,WAAW,IAAIC;AAAA,IAC1BA,EAAO,OAAO;AAAA,MACZ,kBAAkBA,EAAO,OAAA,EAAS,IAAIF,CAAsC,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BAAgF;AACpF,UAAMK,IAAgB,MAAM,KAAK,IAAI,YAAY,IAAI,wBAAwB,KAAM,CAAA,GAC7EC,IAAY,MAAM,QAAQ;AAAA,MAC9BD,EAAa,IAAI,CAACE,MAAQ,KAAK,qBAAqBA,CAAG,CAAC;AAAA,IAAA,GAEpDC,IAAsD,CAAA;AAC5D,eAAW,CAACC,GAAOC,CAAQ,KAAKJ,EAAU;AACxC,MAAII,EAAS,WAAW,cACtBF,EAAQH,EAAaI,CAAK,CAAC,IAAIC,EAAS,QAExCF,EAAQH,EAAaI,CAAK,CAAC,IAAI;AAGnC,WAAOD;AAAA,EACT;AACF;AA1cO7D,IAAAgE,EAAA/D,CAAA;AAAMe,IAANiD,6BADPlE,GACaiB,CAAA;AAANkD,EAAAlE,GAAA,GAAMgB,CAAA;AAAN,IAAMmD,IAANnD;"}
|
|
@@ -2984,7 +2984,7 @@ class K extends lt {
|
|
|
2984
2984
|
constructor(e) {
|
|
2985
2985
|
super({
|
|
2986
2986
|
name: "InPageEdit"
|
|
2987
|
-
}), this.version = "0.14.
|
|
2987
|
+
}), this.version = "0.14.5", this.Endpoints = ke, this.schema = p, this.config = ct(K.DEFAULT_CONFIG, e), this.logger = gt({
|
|
2988
2988
|
name: "IPE",
|
|
2989
2989
|
color: "#33aaff",
|
|
2990
2990
|
level: this.config.logLevel
|
|
@@ -3035,10 +3035,10 @@ class K extends lt {
|
|
|
3035
3035
|
async #s() {
|
|
3036
3036
|
[
|
|
3037
3037
|
import("./index-BanevHQ2.js").then(({ PluginAnalytics: t }) => t),
|
|
3038
|
-
import("./index-
|
|
3038
|
+
import("./index-7R2LfhNn.js").then(
|
|
3039
3039
|
({ PluginInArticleLinks: t }) => t
|
|
3040
3040
|
),
|
|
3041
|
-
import("./index-
|
|
3041
|
+
import("./index-B3jld2sl.js").then(({ PluginPluginStore: t }) => t),
|
|
3042
3042
|
import("./index-DKCZDN-Q.js").then(
|
|
3043
3043
|
({ PluginPreferencesUI: t }) => t
|
|
3044
3044
|
),
|
|
@@ -3087,4 +3087,4 @@ export {
|
|
|
3087
3087
|
ce as e,
|
|
3088
3088
|
te as m
|
|
3089
3089
|
};
|
|
3090
|
-
//# sourceMappingURL=index-
|
|
3090
|
+
//# sourceMappingURL=index-DxaqNWv4.js.map
|