@inpageedit/core 0.14.1 → 0.14.2

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.
@@ -3,15 +3,15 @@ import { S as g, E as b, p as A, d as x, I as P } from "./Preferences-BF2fcXrn.j
3
3
  import { B as U } from "./BasePlugin-YOi2_vUo.js";
4
4
  var B = Object.create, f = Object.defineProperty, q = Object.getOwnPropertyDescriptor, v = (i, e) => (e = Symbol[i]) ? e : Symbol.for("Symbol." + i), w = (i) => {
5
5
  throw TypeError(i);
6
- }, L = (i, e, t) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, N = (i, e) => f(i, "name", { value: e, configurable: !0 }), T = (i) => [, , , B(i?.[v("metadata")] ?? null)], D = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], k = (i) => i !== void 0 && typeof i != "function" ? w("Function expected") : i, O = (i, e, t, a, s) => ({ kind: D[i], name: e, metadata: a, addInitializer: (r) => t._ ? w("Already initialized") : s.push(k(r || null)) }), j = (i, e) => L(e, v("metadata"), i[3]), C = (i, e, t, a) => {
6
+ }, L = (i, e, t) => e in i ? f(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, N = (i, e) => f(i, "name", { value: e, configurable: !0 }), $ = (i) => [, , , B(i?.[v("metadata")] ?? null)], T = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], k = (i) => i !== void 0 && typeof i != "function" ? w("Function expected") : i, D = (i, e, t, a, s) => ({ kind: T[i], name: e, metadata: a, addInitializer: (r) => t._ ? w("Already initialized") : s.push(k(r || null)) }), O = (i, e) => L(e, v("metadata"), i[3]), j = (i, e, t, a) => {
7
7
  for (var s = 0, r = i[e >> 1], o = r && r.length; s < o; s++) r[s].call(t);
8
8
  return a;
9
- }, $ = (i, e, t, a, s, r) => {
10
- var o, d, h, c = e & 7, l = !1, y = 0, I = i[y] || (i[y] = []), u = c && (s = s.prototype, c < 5 && (c > 3 || !l) && q(s, t));
9
+ }, C = (i, e, t, a, s, r) => {
10
+ var o, c, h, d = e & 7, l = !1, y = 0, I = i[y] || (i[y] = []), u = d && (s = s.prototype, d < 5 && (d > 3 || !l) && q(s, t));
11
11
  N(s, t);
12
12
  for (var p = a.length - 1; p >= 0; p--)
13
- h = O(c, t, d = {}, i[3], I), o = (0, a[p])(s, h), d._ = 1, k(o) && (s = o);
14
- return j(i, s), u && f(s, t, u), l ? c ^ 4 ? r : u : s;
13
+ h = D(d, t, c = {}, i[3], I), o = (0, a[p])(s, h), c._ = 1, k(o) && (s = o);
14
+ return O(i, s), u && f(s, t, u), l ? d ^ 4 ? r : u : s;
15
15
  }, E, _, S;
16
16
  E = [P(["wiki", "preferences", "$"])];
17
17
  class m extends (S = U) {
@@ -150,10 +150,14 @@ class m extends (S = U) {
150
150
  this.addEvent("quick-edit", void 0, t.wikiPage.title);
151
151
  }), e.on("quick-edit/submit", (t) => {
152
152
  this.addEvent("quick-edit", "submit", t.wikiPage.title);
153
- }), e.on("quick-move/submit", (t) => {
153
+ }), e.on("quick-move/submit", () => {
154
154
  this.addEvent("quick-move", "submit");
155
- }), e.on("toolbox/button-clicked", (t) => {
155
+ }), e.on("toolbox/button-clicked", ({ payload: t }) => {
156
156
  this.addEvent("toolbox", `button-clicked#${t.id || "unknown"}`);
157
+ }), e.on("plugin-store/plugin-installed", ({ registry: t, id: a, by: s }) => {
158
+ s === "new-added" && this.addEvent("plugin-store", "plugin-installed", `${t.name}#${a}`);
159
+ }), e.on("plugin-store/plugin-uninstalled", ({ registry: t, id: a }) => {
160
+ this.addEvent("plugin-store", "plugin-uninstalled", `${t.name}#${a}`);
157
161
  });
158
162
  }
159
163
  addEvent(e, t, a) {
@@ -182,18 +186,18 @@ class m extends (S = U) {
182
186
  return this.logger.debug("Beacon sent successfully", a), !0;
183
187
  {
184
188
  this.logger.debug("Beacon failed, sending via XMLHttpRequest");
185
- const { promise: d, resolve: h, reject: c } = x();
189
+ const { promise: c, resolve: h, reject: d } = x();
186
190
  try {
187
191
  const l = new XMLHttpRequest();
188
192
  l.open("POST", r, !0), l.setRequestHeader("Content-Type", "application/json"), l.send(s), l.onload = () => {
189
193
  this.logger.debug("Beacon sent successfully via XMLHttpRequest", a), h(l.status >= 200 && l.status < 300);
190
194
  }, l.onerror = () => {
191
- c(new Error("Failed to send beacon"));
195
+ d(new Error("Failed to send beacon"));
192
196
  };
193
197
  } catch (l) {
194
- c(l);
198
+ d(l);
195
199
  }
196
- return d;
200
+ return c;
197
201
  }
198
202
  }
199
203
  /**
@@ -203,10 +207,10 @@ class m extends (S = U) {
203
207
  this._timer !== null && (clearInterval(this._timer), this._timer = null), this._usages.length > 0 && this.sendBeacon();
204
208
  }
205
209
  }
206
- _ = T(S);
207
- m = $(_, 0, "PluginAnalytics", E, m);
208
- C(_, 1, m);
210
+ _ = $(S);
211
+ m = C(_, 0, "PluginAnalytics", E, m);
212
+ j(_, 1, m);
209
213
  export {
210
214
  m as PluginAnalytics
211
215
  };
212
- //# sourceMappingURL=index-Bb0FiU2c.js.map
216
+ //# sourceMappingURL=index-Dclp60EO.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index-Dclp60EO.js","sources":["../src/plugins/analytics/index.tsx"],"sourcesContent":["import { Endpoints } from '@/constants/endpoints.js'\nimport { Inject, InPageEdit, Schema } from '@/InPageEdit'\n\ndeclare module '@/InPageEdit' {\n interface InPageEdit {\n analytics: PluginAnalytics\n }\n}\n\nexport interface IPEBeaconPayload {\n siteApi: string\n siteName?: string\n userId: number\n userName: string\n version?: string\n usages: IPEBeaconUsage[]\n}\n\nexport interface IPEBeaconUsage {\n ts: number\n feature: string\n subtype?: string\n page?: string\n}\n\n@Inject(['wiki', 'preferences', '$'])\nexport class PluginAnalytics extends BasePlugin {\n private _usages: IPEBeaconUsage[] = []\n private _timer: ReturnType<typeof setInterval> | null = null\n private readonly MAX_QUEUE_SIZE = 50\n private readonly INTERVAL_MS = 60 * 1000 // 1分钟\n\n constructor(public ctx: InPageEdit) {\n super(ctx, {}, 'analytics')\n this._setupTimer()\n this._registerUnloadHandler()\n this._showConfirmNotify()\n this._initPluginListeners()\n ctx.set('analytics', this)\n }\n\n protected start(): Promise<void> | void {\n const ctx = this.ctx\n const $ = ctx.$\n ctx.preferences.registerCustomConfig(\n 'analytics',\n Schema.object({\n 'analytics._intro': Schema.const(\n <section>\n <h3>{$`InPageEdit Analytics`}</h3>\n <p>\n {$`InPageEdit Analytics is the companion analytics platform for the InPageEdit NEXT project. By collecting and displaying usage data from around the world, it helps developers and the community better understand how the tool is used, optimize feature design, and enhance user experience.`}\n </p>\n <h4>{$`What data will be collected?`}</h4>\n <ol style={{ listStyle: 'number', paddingLeft: '1em' }}>\n <li>\n <strong>{$`Usage data`}</strong>:{' '}\n {$`When and which features you use, what pages you edit, etc.`}\n </li>\n <li>\n <strong>{$`User information`}</strong>: {$`Your user name and user ID.`}\n </li>\n <li>\n <strong>{$`Site information`}</strong>: {$`This wiki's url and site name.`}\n </li>\n </ol>\n <p>\n <strong>{$`NO sensitive data will be collected.`}</strong>\n </p>\n <div style={{ display: 'grid', gap: '0.5rem' }}>\n <a href={this.analyticsDashUrl} target=\"_blank\" rel=\"noopener noreferrer\">\n <button className=\"btn\" style={{ width: '100%' }}>\n {$`Analytics Platform`}\n </button>\n </a>\n <a\n href={`${this.analyticsDashUrl}/_redirect/user?${new URLSearchParams({\n siteApi: this.ctx.wiki.getSciprtUrl('api'),\n mwUserId: this.ctx.wiki.userInfo.id.toString(),\n }).toString()}`}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n <button className=\"btn\" style={{ width: '100%' }}>\n {$`View My Data`}\n </button>\n </a>\n </div>\n </section>\n ).role('raw-html'),\n 'analytics.enabled': Schema.boolean()\n .description($`prefs.analytics.enabled`)\n .default(false),\n }).description($`prefs.analytics.$`),\n 'general'\n )\n }\n\n private get analyticsDashUrl() {\n return import.meta.env.PROD ? Endpoints.ANALYTICS_DASH_URL : 'http://localhost:20105'\n }\n private get analyticsApiBase() {\n return import.meta.env.PROD ? Endpoints.ANALYTICS_API_BASE : 'http://localhost:20105/api/v6'\n }\n\n private _setupTimer() {\n this._timer = setInterval(() => {\n if (this._usages.length > 0) {\n this.sendBeacon()\n }\n }, this.INTERVAL_MS)\n }\n\n private _registerUnloadHandler() {\n const handleUnload = () => {\n if (this._usages.length > 0) {\n this.sendBeacon()\n }\n }\n\n window.addEventListener('visibilitychange', () => {\n if (document.visibilityState === 'hidden') {\n handleUnload()\n }\n })\n\n window.addEventListener('pagehide', handleUnload)\n window.addEventListener('beforeunload', handleUnload)\n }\n\n private async _showConfirmNotify() {\n const $ = this.ctx.$\n this.ctx.inject(['modal', 'storage'], async (ctx) => {\n const key = 'analytics/confirm-shown'\n const shown = await ctx.storage.simpleKV.get(key)\n const enabled = await ctx.preferences.get('analytics.enabled')\n if (shown || enabled) {\n return\n }\n ctx.modal.notify(\n 'confirm',\n {\n title: $`Enable Analytics`,\n content: (\n <div>\n <p>{$`Help us improve InPageEdit by sharing your usage data with us.`}</p>\n <p>{$`What data will be collected?`}</p>\n <ul style={{ listStyle: 'auto', paddingLeft: '1.5em' }}>\n <li>\n {$`Usage data`}: {$`When and which features you use, what pages you edit, etc.`}\n </li>\n <li>\n {$`User information`}: {$`Your user name and user ID.`}\n </li>\n <li>\n {$`Site information`}: {$`This wiki's url and site name.`}\n </li>\n </ul>\n <p>\n <strong>{$`NO sensitive data will be collected.`}</strong>\n </p>\n </div>\n ),\n okBtn: {\n label: $`Enable`,\n },\n cancelBtn: {\n label: $`Disable`,\n },\n closeAfter: 0,\n onClose: () => {\n this.ctx.storage.simpleKV.set(key, 1)\n },\n },\n (result) => {\n ctx.preferences.set('analytics.enabled', result)\n if (result) {\n this.addEvent('analytics', 'enabled')\n }\n }\n )\n })\n }\n\n private _initPluginListeners() {\n const ctx = this.ctx\n ctx.on('in-article-links/anchor-clicked', (payload) => {\n this.addEvent('in-article-links', paramCase(payload.action))\n })\n ctx.on('quick-diff/loaded', (payload) => {\n this.addEvent('quick-diff', 'loaded', payload.compare.fromtitle)\n })\n ctx.on('quick-redirect/submit', (payload) => {\n this.addEvent('quick-redirect', 'submit', payload.payload.to || undefined)\n })\n ctx.on('quick-preview/loaded', (payload) => {\n this.addEvent('quick-preview', 'loaded', payload.wikiPage.title)\n })\n ctx.on('quick-edit/wiki-page', (payload) => {\n this.addEvent('quick-edit', undefined, payload.wikiPage.title)\n })\n ctx.on('quick-edit/submit', (payload) => {\n this.addEvent('quick-edit', 'submit', payload.wikiPage.title)\n })\n ctx.on('quick-move/submit', () => {\n this.addEvent('quick-move', 'submit')\n })\n ctx.on('toolbox/button-clicked', ({ payload }) => {\n this.addEvent('toolbox', `button-clicked#${payload.id || 'unknown'}`)\n })\n ctx.on('plugin-store/plugin-installed', ({ registry, id, by }) => {\n if (by === 'new-added') {\n this.addEvent('plugin-store', 'plugin-installed', `${registry.name}#${id}`)\n }\n })\n ctx.on('plugin-store/plugin-uninstalled', ({ registry, id }) => {\n this.addEvent('plugin-store', 'plugin-uninstalled', `${registry.name}#${id}`)\n })\n }\n\n public addEvent(feature: string, subtype?: string, page?: string) {\n const usage: IPEBeaconUsage = {\n ts: Date.now(),\n feature,\n subtype,\n page,\n }\n this._usages.push(usage)\n\n // 如果usages数组超过50个,立即发送\n if (this._usages.length >= this.MAX_QUEUE_SIZE) {\n this.sendBeacon()\n }\n\n return this\n }\n\n private async sendBeacon() {\n if (this._usages.length === 0) {\n return true\n }\n\n const enabled = await this.ctx.preferences.get<boolean>('analytics.enabled', false)\n if (!enabled) {\n this.logger.debug('Analytics disabled, skipping')\n return true\n }\n\n const usages = this._usages.splice(0, this._usages.length)\n const payload: IPEBeaconPayload = {\n siteApi: this.ctx.wiki.getSciprtUrl('api'),\n siteName: this.ctx.wiki.siteInfo.general.sitename,\n userId: this.ctx.wiki.userInfo.id,\n userName: this.ctx.wiki.userInfo.name,\n version: this.ctx.version.split('-')[0],\n usages,\n }\n const body = JSON.stringify(payload)\n\n const endpoint = `${this.analyticsApiBase}/submit`\n\n const beaconOK = navigator?.sendBeacon?.(endpoint, body)\n if (beaconOK) {\n this.logger.debug('Beacon sent successfully', payload)\n return true\n } else {\n this.logger.debug('Beacon failed, sending via XMLHttpRequest')\n const { promise, resolve, reject } = promiseWithResolvers<boolean>()\n try {\n const xhr = new XMLHttpRequest()\n xhr.open('POST', endpoint, true)\n xhr.setRequestHeader('Content-Type', 'application/json')\n xhr.send(body)\n xhr.onload = () => {\n this.logger.debug('Beacon sent successfully via XMLHttpRequest', payload)\n resolve(xhr.status >= 200 && xhr.status < 300)\n }\n xhr.onerror = () => {\n reject(new Error('Failed to send beacon'))\n }\n } catch (error) {\n reject(error)\n }\n return promise\n }\n }\n\n /**\n * 清理资源\n */\n protected stop() {\n if (this._timer !== null) {\n clearInterval(this._timer)\n this._timer = null\n }\n // 在销毁前发送剩余的数据\n if (this._usages.length > 0) {\n this.sendBeacon()\n }\n }\n}\n"],"names":["_PluginAnalytics_decorators","_init","_a","Inject","PluginAnalytics","BasePlugin","ctx","$","Schema","jsx","jsxs","Endpoints","handleUnload","key","shown","enabled","result","payload","paramCase","registry","id","by","feature","subtype","page","usage","usages","body","endpoint","promise","resolve","reject","promiseWithResolvers","xhr","error","__decoratorStart","__decorateElement","__runInitializers"],"mappings":";;;;;;;;;;;;;;GAAAA,GAAAC,GAAAC;AAyBAF,IAAA,CAACG,EAAO,CAAC,QAAQ,eAAe,GAAG,CAAC,CAAA;AAC7B,MAAMC,WAAwBF,IAAAG,GAAW;AAAA;AAAA,EAM9C,YAAmBC,GAAiB;AAClC,UAAMA,GAAK,CAAA,GAAI,WAAW,GADT,KAAA,MAAAA,GALnB,KAAQ,UAA4B,CAAA,GACpC,KAAQ,SAAgD,MACxD,KAAiB,iBAAiB,IAClC,KAAiB,cAAc,KAAK,KAIlC,KAAK,YAAA,GACL,KAAK,uBAAA,GACL,KAAK,mBAAA,GACL,KAAK,qBAAA,GACLA,EAAI,IAAI,aAAa,IA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AI,SAAS,MAAM;AACjB,eAAK,OAAO,MAAM,+CAA+ChB,CAAO,GACxEa,EAAQG,EAAI,UAAU,OAAOA,EAAI,SAAS,GAAG;AAAA,QAC/C,GACAA,EAAI,UAAU,MAAM;AAClB,UAAAF,EAAO,IAAI,MAAM,uBAAuB,CAAC;AAAA,QAC3C;AAAA,MACF,SAASG,GAAO;AACd,QAAAH,EAAOG,CAAK;AAAA,MACd;AACA,aAAOL;AAAA,IACT;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKU,OAAO;AACf,IAAI,KAAK,WAAW,SAClB,cAAc,KAAK,MAAM,GACzB,KAAK,SAAS,OAGZ,KAAK,QAAQ,SAAS,KACxB,KAAK,WAAA;AAAA,EAET;AACF;AAlRO5B,IAAAkC,EAAAjC,CAAA;AAAME,IAANgC,2BADPpC,GACaI,CAAA;AAANiC,EAAApC,GAAA,GAAMG,CAAA;"}
@@ -1,60 +1,60 @@
1
1
  import { j as R } from "./index-CM_6yF2v.js";
2
- import { S as i, E as C, I as j } from "./Preferences-BF2fcXrn.js";
2
+ import { S as s, E as C, I as j } from "./Preferences-BF2fcXrn.js";
3
3
  import { B as L } from "./BasePlugin-YOi2_vUo.js";
4
4
  import { c as O, d as F } from "./vueHooks-l04s8cIl.js";
5
5
  const G = 1;
6
6
  var m;
7
7
  ((n) => {
8
- n.PackageLoader = new i(
9
- i.object({
10
- kind: i.union(["autoload", "module", "umd", "styles"]).required().default("autoload"),
11
- entry: i.string(),
12
- styles: i.array(i.string()),
13
- main_export: i.string()
8
+ n.PackageLoader = new s(
9
+ s.object({
10
+ kind: s.union(["autoload", "module", "umd", "styles"]).required().default("autoload"),
11
+ entry: s.string(),
12
+ styles: s.array(s.string()),
13
+ main_export: s.string()
14
14
  })
15
- ), n.Package = new i(
16
- i.object({
17
- id: i.string().required(),
18
- name: i.string().required(),
19
- version: i.string().required(),
20
- description: i.string(),
21
- author: i.string(),
22
- license: i.string(),
15
+ ), n.Package = new s(
16
+ s.object({
17
+ id: s.string().required(),
18
+ name: s.string().required(),
19
+ version: s.string().required(),
20
+ description: s.string(),
21
+ author: s.string(),
22
+ license: s.string(),
23
23
  loader: n.PackageLoader.required()
24
24
  })
25
- ), n.RegistryMaintainer = new i(
26
- i.object({
27
- name: i.string().required(),
28
- email: i.string()
25
+ ), n.RegistryMaintainer = new s(
26
+ s.object({
27
+ name: s.string().required(),
28
+ email: s.string()
29
29
  })
30
- ), n.RegistryRepository = new i(
31
- i.object({
32
- type: i.union(["git"]).required().default("git"),
33
- url: i.string().required()
30
+ ), n.RegistryRepository = new s(
31
+ s.object({
32
+ type: s.string().required(),
33
+ url: s.string().required()
34
34
  })
35
- ), n.Registry = new i(
36
- i.object({
37
- manifest_version: i.number().min(G).required(),
38
- name: i.string().required(),
39
- base_url: i.string().required(),
40
- homepage: i.string(),
41
- maintainers: i.array(n.RegistryMaintainer),
35
+ ), n.Registry = new s(
36
+ s.object({
37
+ manifest_version: s.number().min(G).required(),
38
+ name: s.string().required(),
39
+ base_url: s.string().required(),
40
+ homepage: s.string(),
41
+ maintainers: s.array(n.RegistryMaintainer),
42
42
  repository: n.RegistryRepository,
43
- packages: i.array(n.Package).required()
43
+ packages: s.array(n.Package).required()
44
44
  })
45
45
  );
46
46
  })(m || (m = {}));
47
- var B = Object.create, x = Object.defineProperty, M = Object.getOwnPropertyDescriptor, S = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), b = (n) => {
47
+ var B = Object.create, v = Object.defineProperty, M = Object.getOwnPropertyDescriptor, S = (n, e) => (e = Symbol[n]) ? e : Symbol.for("Symbol." + n), b = (n) => {
48
48
  throw TypeError(n);
49
- }, q = (n, e, t) => e in n ? x(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, N = (n, e) => x(n, "name", { value: e, configurable: !0 }), D = (n) => [, , , B(n?.[S("metadata")] ?? null)], U = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], k = (n) => n !== void 0 && typeof n != "function" ? b("Function expected") : n, Y = (n, e, t, r, s) => ({ kind: U[n], name: e, metadata: r, addInitializer: (a) => t._ ? b("Already initialized") : s.push(k(a || null)) }), z = (n, e) => q(e, S("metadata"), n[3]), Q = (n, e, t, r) => {
50
- for (var s = 0, a = n[e >> 1], l = a && a.length; s < l; s++) a[s].call(t);
49
+ }, q = (n, e, t) => e in n ? v(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t, N = (n, e) => v(n, "name", { value: e, configurable: !0 }), D = (n) => [, , , B(n?.[S("metadata")] ?? null)], U = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], k = (n) => n !== void 0 && typeof n != "function" ? b("Function expected") : n, Y = (n, e, t, r, i) => ({ kind: U[n], name: e, metadata: r, addInitializer: (a) => t._ ? b("Already initialized") : i.push(k(a || null)) }), z = (n, e) => q(e, S("metadata"), n[3]), Q = (n, e, t, r) => {
50
+ for (var i = 0, a = n[e >> 1], o = a && a.length; i < o; i++) a[i].call(t);
51
51
  return r;
52
- }, H = (n, e, t, r, s, a) => {
53
- var l, f, h, g = e & 7, p = !1, c = 0, y = n[c] || (n[c] = []), d = g && (s = s.prototype, g < 5 && (g > 3 || !p) && M(s, t));
54
- N(s, t);
55
- for (var o = r.length - 1; o >= 0; o--)
56
- h = Y(g, t, f = {}, n[3], y), l = (0, r[o])(s, h), f._ = 1, k(l) && (s = l);
57
- return z(n, s), d && x(s, t, d), p ? g ^ 4 ? a : d : s;
52
+ }, H = (n, e, t, r, i, a) => {
53
+ var o, d, c, p = e & 7, f = !1, u = 0, y = n[u] || (n[u] = []), h = p && (i = i.prototype, p < 5 && (p > 3 || !f) && M(i, t));
54
+ N(i, t);
55
+ for (var l = r.length - 1; l >= 0; l--)
56
+ c = Y(p, t, d = {}, n[3], y), o = (0, r[l])(i, c), d._ = 1, k(o) && (i = o);
57
+ return z(n, i), h && v(i, t, h), f ? p ^ 4 ? a : h : i;
58
58
  }, A, I, T;
59
59
  const P = (n) => {
60
60
  if (!n) return null;
@@ -65,26 +65,26 @@ const P = (n) => {
65
65
  }
66
66
  }, E = (n, e, t) => {
67
67
  if (/^https?:\/\//i.test(n)) return n;
68
- const r = (l) => l.endsWith("/") ? l : l + "/";
68
+ const r = (o) => o.endsWith("/") ? o : o + "/";
69
69
  if (/^https?:\/\//i.test(e)) {
70
- const l = r(e);
71
- return new URL(n, l).href;
70
+ const o = r(e);
71
+ return new URL(n, o).href;
72
72
  }
73
- const s = (() => {
73
+ const i = (() => {
74
74
  try {
75
75
  return new URL(t).href;
76
76
  } catch {
77
77
  return new URL(t, location.origin).href;
78
78
  }
79
- })(), a = new URL(r(e), s).href;
79
+ })(), a = new URL(r(e), i).href;
80
80
  return new URL(n, a).href;
81
81
  };
82
82
  A = [j(["storage", "preferences", "resourceLoader", "$"])];
83
- let w = class v extends (T = L) {
83
+ let w = class x extends (T = L) {
84
84
  constructor(e) {
85
85
  super(e, {}, "plugin-store"), this.ctx = e, this.regInfoDB = void 0, this._installedPlugins = /* @__PURE__ */ new Map(), this._onlineRegistryQueries = /* @__PURE__ */ new Map(), e.set("store", this), this.regInfoDB = e.storage.createDatabase(
86
- v.REGISTRY_INFO_STORAGE_NAME,
87
- v.REGISTRY_INFO_CACHE_TTL,
86
+ x.REGISTRY_INFO_STORAGE_NAME,
87
+ x.REGISTRY_INFO_CACHE_TTL,
88
88
  1,
89
89
  "indexedDB"
90
90
  );
@@ -108,7 +108,7 @@ let w = class v extends (T = L) {
108
108
  const e = await this.ctx.preferences.get("pluginStore.plugins", []);
109
109
  if (e?.length)
110
110
  for (const t of e)
111
- this.install(t.registry, t.id, t.source);
111
+ this.install(t.registry, t.id, t.source, "user-preference");
112
112
  }
113
113
  async _createManagementApp() {
114
114
  const e = await this.ctx.withInject(["store"]), t = F(() => import("./PluginStoreApp-CGNxKXAN.js"));
@@ -123,23 +123,23 @@ let w = class v extends (T = L) {
123
123
  index: 90,
124
124
  autoGenerateForm: !1,
125
125
  customRenderer: async ({ onUnmount: r }) => {
126
- const s = /* @__PURE__ */ R("div", { id: "ipe-plugin-store-preferences-vue" }), a = await this._createManagementApp();
127
- return a.mount(s), r(() => {
126
+ const i = /* @__PURE__ */ R("div", { id: "ipe-plugin-store-preferences-vue" }), a = await this._createManagementApp();
127
+ return a.mount(i), r(() => {
128
128
  a.unmount(), this.ctx.logger.debug("Plugin Store preferences app unmounted");
129
- }), /* @__PURE__ */ R("section", { children: s });
129
+ }), /* @__PURE__ */ R("section", { children: i });
130
130
  }
131
131
  }), e.preferences.registerCustomConfig(
132
132
  "plugin-store",
133
- i.object({
134
- "pluginStore.registries": i.array(i.string()).default([
133
+ s.object({
134
+ "pluginStore.registries": s.array(s.string()).default([
135
135
  C.PLUGIN_REGISTRY_URL
136
136
  ]).description(t`Registry URLs`).hidden(),
137
- "pluginStore.cdnForNpm": i.string().description(t`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),
138
- "pluginStore.plugins": i.array(
139
- i.object({
140
- source: i.union(["online_manifest", "npm"]).default("online_manifest"),
141
- registry: i.string().required(),
142
- id: i.string().required()
137
+ "pluginStore.cdnForNpm": s.string().description(t`CDN to install packages from npm`).default('https://cdn.jsdelivr.net/npm/{{ package }}{{ version ? "@" + version : "" }}').hidden(),
138
+ "pluginStore.plugins": s.array(
139
+ s.object({
140
+ source: s.union(["online_manifest", "npm"]).default("online_manifest"),
141
+ registry: s.string().required(),
142
+ id: s.string().required()
143
143
  })
144
144
  ).description(t`Installed plugins`).default([]).hidden()
145
145
  }),
@@ -157,23 +157,43 @@ let w = class v extends (T = L) {
157
157
  r.unmount();
158
158
  }), e;
159
159
  }
160
- async install(e, t, r = "online_manifest") {
161
- const s = await this.getRegistryInfo(e, r);
162
- if (!s)
160
+ async install(e, t, r = "online_manifest", i = "new-added") {
161
+ const a = await this.getRegistryInfo(e, r);
162
+ if (!a)
163
163
  return this.ctx.logger.warn(`Registry ${e} not found`), null;
164
- const a = `${e}#${t}`;
165
- if (this._installedPlugins.has(a))
166
- return await this._installedPlugins.get(a) ?? null;
167
- const l = this._installOneByRegistryInfo(e, s, t);
168
- return this._installedPlugins.set(a, l), await l;
164
+ const o = `${e}#${t}`;
165
+ if (this._installedPlugins.has(o))
166
+ return await this._installedPlugins.get(o) ?? null;
167
+ const d = this._installOneByRegistryInfo(e, a, t);
168
+ this._installedPlugins.set(o, d);
169
+ const c = await d;
170
+ return c && this.ctx.emit("plugin-store/plugin-installed", {
171
+ ctx: this.ctx,
172
+ registry: a,
173
+ id: t,
174
+ by: i
175
+ }), c;
169
176
  }
170
177
  async uninstall(e, t) {
171
178
  const r = this._installedPlugins.get(`${e}#${t}`);
172
179
  if (r === void 0)
173
180
  return !0;
174
181
  this._installedPlugins.delete(`${e}#${t}`);
175
- const s = await r;
176
- return s ? s.dispose?.() ?? !0 : !0;
182
+ const i = await r;
183
+ if (i) {
184
+ const a = i.dispose?.() ?? !0;
185
+ try {
186
+ const o = await this.getRegistryCache(e) || await this.getRegistryInfo(e).catch(() => null);
187
+ o && this.ctx.emit("plugin-store/plugin-uninstalled", {
188
+ ctx: this.ctx,
189
+ registry: o,
190
+ id: t
191
+ });
192
+ } catch {
193
+ }
194
+ return a;
195
+ }
196
+ return !0;
177
197
  }
178
198
  async addToPreferences(e, t) {
179
199
  let r = await this.ctx.preferences.get("pluginStore.plugins") || [];
@@ -181,30 +201,30 @@ let w = class v extends (T = L) {
181
201
  }
182
202
  async removeFromPreferences(e, t) {
183
203
  let r = await this.ctx.preferences.get("pluginStore.plugins") || [];
184
- return r = r.filter((s) => s.registry !== e || s.id !== t), await this.ctx.preferences.set("pluginStore.plugins", r), !0;
204
+ return r = r.filter((i) => i.registry !== e || i.id !== t), await this.ctx.preferences.set("pluginStore.plugins", r), !0;
185
205
  }
186
206
  async installAndSetPreference(e, t) {
187
- return await this.addToPreferences(e, t), this.install(e, t);
207
+ return await this.addToPreferences(e, t), this.install(e, t, "online_manifest", "new-added");
188
208
  }
189
209
  async uninstallAndRemovePreference(e, t) {
190
210
  return await this.removeFromPreferences(e, t), this.uninstall(e, t);
191
211
  }
192
212
  // 3) 增加 registryUrl 参数
193
213
  async _installOneByRegistryInfo(e, t, r) {
194
- const s = t.base_url, a = t.packages.find((o) => o.id === r);
214
+ const i = t.base_url, a = t.packages.find((l) => l.id === r);
195
215
  if (!a)
196
216
  return this.ctx.logger.warn(`Package ${r} not found in registry ${e}`), null;
197
- const l = a.loader, { kind: f, entry: h = "index.js", styles: g = [], main_export: p = null } = l;
198
- let c = null;
199
- if (f !== "styles") {
200
- if (!h)
201
- return this.ctx.logger.warn(`Entry url missing for ${r}`, l), null;
217
+ const o = a.loader, { kind: d, entry: c = "index.js", styles: p = [], main_export: f = null } = o;
218
+ let u = null;
219
+ if (d !== "styles") {
220
+ if (!c)
221
+ return this.ctx.logger.warn(`Entry url missing for ${r}`, o), null;
202
222
  try {
203
- c = E(h, s, e);
204
- } catch (o) {
223
+ u = E(c, i, e);
224
+ } catch (l) {
205
225
  return this.ctx.logger.warn(
206
- `Failed to resolve entry "${h}" with base "${s}" and registry "${e}"`,
207
- o
226
+ `Failed to resolve entry "${c}" with base "${i}" and registry "${e}"`,
227
+ l
208
228
  ), null;
209
229
  }
210
230
  }
@@ -212,69 +232,69 @@ let w = class v extends (T = L) {
212
232
  "data-plugin-registry": e,
213
233
  "data-plugin-id": r
214
234
  };
215
- let d = null;
216
- switch (f) {
235
+ let h = null;
236
+ switch (d) {
217
237
  case "autoload": {
218
- d = this.ctx.plugin({
238
+ h = this.ctx.plugin({
219
239
  inject: ["resourceLoader"],
220
240
  name: `plugin-store-${e}-${r}`,
221
- apply: (o) => {
222
- c && o.resourceLoader.loadScript(c, { ...y });
241
+ apply: (l) => {
242
+ u && l.resourceLoader.loadScript(u, { ...y });
223
243
  }
224
244
  });
225
245
  break;
226
246
  }
227
247
  case "module": {
228
- if (!c)
248
+ if (!u)
229
249
  return this.ctx.logger.warn(`Entry url missing for module kind, package ${r}`), null;
230
- const o = await import(
250
+ const l = await import(
231
251
  /* @vite-ignore */
232
- c
252
+ u
233
253
  ).then(
234
- (u) => (p ? u[p] : u.default) ?? u
254
+ (g) => (f ? g[f] : g.default) ?? g
235
255
  );
236
- if (!o)
237
- return this.ctx.logger.warn(`Main export ${p} not found in module ${c}`), null;
238
- d = this.ctx.plugin(o);
256
+ if (!l)
257
+ return this.ctx.logger.warn(`Main export ${f} not found in module ${u}`), null;
258
+ h = this.ctx.plugin(l);
239
259
  break;
240
260
  }
241
261
  case "umd": {
242
- let o = P(p);
243
- if (!o) {
244
- if (!c)
262
+ let l = P(f);
263
+ if (!l) {
264
+ if (!u)
245
265
  return this.ctx.logger.warn(`Entry url missing for umd kind, package ${r}`), null;
246
- await this.ctx.resourceLoader.loadScript(c, { ...y }), o = P(p);
266
+ await this.ctx.resourceLoader.loadScript(u, { ...y }), l = P(f);
247
267
  }
248
- if (!o)
268
+ if (!l)
249
269
  return this.ctx.logger.warn(
250
- `Main export ${p} not found on globalThis after loading ${c}`
270
+ `Main export ${f} not found on globalThis after loading ${u}`
251
271
  ), null;
252
- d = this.ctx.plugin(o);
272
+ h = this.ctx.plugin(l);
253
273
  break;
254
274
  }
255
275
  }
256
- if (g && g.length > 0) {
257
- let o = [];
276
+ if (p && p.length > 0) {
277
+ let l = [];
258
278
  try {
259
- o = g.map((u) => E(u, s, e)).filter(Boolean);
260
- } catch (u) {
261
- this.ctx.logger.warn(`Failed to resolve styles for ${r}`, g, u);
279
+ l = p.map((g) => E(g, i, e)).filter(Boolean);
280
+ } catch (g) {
281
+ this.ctx.logger.warn(`Failed to resolve styles for ${r}`, p, g);
262
282
  }
263
- d ||= this.ctx.plugin({ name: `plugin-store-${e}-${r}`, apply() {
264
- } }), d.ctx.plugin({
283
+ h ||= this.ctx.plugin({ name: `plugin-store-${e}-${r}`, apply() {
284
+ } }), h.ctx.plugin({
265
285
  inject: ["resourceLoader"],
266
286
  name: `plugin-store-${e}-${r}-styles`,
267
- apply: (u) => {
268
- o.forEach((_) => u.resourceLoader.loadStyle(_, { ...y })), u.on("dispose", () => {
287
+ apply: (g) => {
288
+ l.forEach((_) => g.resourceLoader.loadStyle(_, { ...y })), g.on("dispose", () => {
269
289
  try {
270
- o.forEach((_) => u.resourceLoader.removeStyle(_));
290
+ l.forEach((_) => g.resourceLoader.removeStyle(_));
271
291
  } catch {
272
292
  }
273
293
  });
274
294
  }
275
295
  });
276
296
  }
277
- return d;
297
+ return h;
278
298
  }
279
299
  validateRegistry(e) {
280
300
  return m.Registry(e);
@@ -294,23 +314,29 @@ let w = class v extends (T = L) {
294
314
  } catch (a) {
295
315
  this.ctx.logger.warn("Failed to fetch registry info", a);
296
316
  }
297
- const s = await this.getRegistryCache(e);
298
- if (!s)
299
- throw new Error(`Failed to fetch registry info: ${e}`);
300
- return s;
317
+ const i = await this.getRegistryCache(e);
318
+ if (!i)
319
+ throw this.ctx.emit("plugin-store/registry-not-found", {
320
+ ctx: this.ctx,
321
+ registryUrl: e
322
+ }), new Error(`Failed to fetch registry info: ${e}`);
323
+ return i;
301
324
  }
302
325
  async _fetchOnlineRegistryInfo(e, t = !1) {
303
326
  if (!t && this._onlineRegistryQueries.has(e))
304
327
  return await this._onlineRegistryQueries.get(e);
305
- const s = (async () => {
328
+ const i = (async () => {
306
329
  const a = {
307
330
  method: "GET"
308
331
  };
309
332
  t && (a.cache = "no-store");
310
- const f = await (await fetch(e, a)).json();
311
- return this.validateRegistry(f);
333
+ const d = await (await fetch(e, a)).json(), c = this.validateRegistry(d);
334
+ return this.ctx.emit("plugin-store/registry-fetched", {
335
+ ctx: this.ctx,
336
+ registry: c
337
+ }), c;
312
338
  })();
313
- return this._onlineRegistryQueries.set(e, s), await s;
339
+ return this._onlineRegistryQueries.set(e, i), await i;
314
340
  }
315
341
  async getRegistryCache(e) {
316
342
  const t = await this.regInfoDB.get(e);
@@ -326,7 +352,10 @@ let w = class v extends (T = L) {
326
352
  return this.regInfoDB.set(e, t);
327
353
  }
328
354
  async deleteRegistryCache(e) {
329
- await this.regInfoDB.delete(e);
355
+ await this.regInfoDB.delete(e), this.ctx.emit("plugin-store/registry-removed", {
356
+ ctx: this.ctx,
357
+ registryUrl: e
358
+ });
330
359
  }
331
360
  async clearAllRegistryCaches() {
332
361
  await this.regInfoDB.clear(), this.ctx.logger.debug("All registry caches cleared");
@@ -345,10 +374,10 @@ let w = class v extends (T = L) {
345
374
  */
346
375
  async refreshAllRegistryCaches() {
347
376
  const e = await this.ctx.preferences.get("pluginStore.registries") || [], t = await Promise.allSettled(
348
- e.map((s) => this.refreshRegistryCache(s))
377
+ e.map((i) => this.refreshRegistryCache(i))
349
378
  ), r = {};
350
- for (const [s, a] of t.entries())
351
- a.status === "fulfilled" ? r[e[s]] = a.value : r[e[s]] = null;
379
+ for (const [i, a] of t.entries())
380
+ a.status === "fulfilled" ? r[e[i]] = a.value : r[e[i]] = null;
352
381
  return r;
353
382
  }
354
383
  };
@@ -359,4 +388,4 @@ let X = w;
359
388
  export {
360
389
  X as PluginPluginStore
361
390
  };
362
- //# sourceMappingURL=index-DTHY5rAO.js.map
391
+ //# sourceMappingURL=index-QtEF2mzS.js.map