@inpageedit/core 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/dist/{BasePlugin-Bf2UuIHF.js → BasePlugin-CU8beLYu.js} +17 -26
- package/dist/BasePlugin-CU8beLYu.js.map +1 -0
- package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
- package/dist/InputBox-nQKtiWtZ.js.map +1 -1
- package/dist/{PluginPrefSync-Dn1Xsiqz.js → PluginPrefSync-B-gPsC2n.js} +124 -128
- package/dist/PluginPrefSync-B-gPsC2n.js.map +1 -0
- package/dist/PluginStoreApp-CDteVCBG.js +453 -0
- package/dist/PluginStoreApp-CDteVCBG.js.map +1 -0
- package/dist/{endpoints-DgyuoRZd.js → Preferences-85Q9FAmb.js} +589 -565
- package/dist/Preferences-85Q9FAmb.js.map +1 -0
- package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/{index-BuYNq7f3.js → index-19CgGBI0.js} +1419 -921
- package/dist/index-19CgGBI0.js.map +1 -0
- package/dist/{index-B7c6jL9x.js → index-BKIf3i0I.js} +146 -137
- package/dist/index-BKIf3i0I.js.map +1 -0
- package/dist/{index-CCRMmnwk.js → index-BrtFJ-M0.js} +67 -66
- package/dist/index-BrtFJ-M0.js.map +1 -0
- package/dist/index-CG38LlAh.js.map +1 -1
- package/dist/index-CM_6yF2v.js.map +1 -1
- package/dist/index-CQr1DJ8n.js +173 -0
- package/dist/index-CQr1DJ8n.js.map +1 -0
- package/dist/{index-BQ-cHWkJ.js → index-CVTBg5O9.js} +66 -48
- package/dist/index-CVTBg5O9.js.map +1 -0
- package/dist/index-Ci82vLXg.js +179 -0
- package/dist/index-Ci82vLXg.js.map +1 -0
- package/dist/{index-BwdWyHLe.js → index-D3iZhRMJ.js} +93 -93
- package/dist/index-D3iZhRMJ.js.map +1 -0
- package/dist/index-DD5CVCfD.js.map +1 -1
- package/dist/{index-BJ7_Q1mB.js → index-DGtq21uW.js} +17 -16
- package/dist/index-DGtq21uW.js.map +1 -0
- package/dist/index-DXL7teb0.js +394 -0
- package/dist/index-DXL7teb0.js.map +1 -0
- package/dist/index-DjPpAyfE.js +116 -0
- package/dist/index-DjPpAyfE.js.map +1 -0
- package/dist/{index-eSlbrNqF.js → index-rpiO9fpc.js} +4 -5
- package/dist/{index-eSlbrNqF.js.map → index-rpiO9fpc.js.map} +1 -1
- package/dist/index.d.ts +327 -26
- package/dist/index.js +32 -26
- package/dist/index.js.map +1 -1
- package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
- package/dist/models/index.js +174 -154
- package/dist/models/index.js.map +1 -1
- package/dist/noop-ClDc6zv4.js.map +1 -1
- package/dist/plugins/index.js +10 -10
- package/dist/services/index.js +1 -1
- package/dist/style.css +1 -1
- package/dist/vueHooks-l04s8cIl.js.map +1 -1
- package/lib/index.umd.js +20 -12
- package/lib/index.umd.js.map +1 -1
- package/lib/style.css +1 -1
- package/package.json +4 -4
- package/dist/BasePlugin-Bf2UuIHF.js.map +0 -1
- package/dist/PluginPrefSync-Dn1Xsiqz.js.map +0 -1
- package/dist/PluginStoreApp-CpOLArL7.js +0 -452
- package/dist/PluginStoreApp-CpOLArL7.js.map +0 -1
- package/dist/Preferences-DS4-CFWe.js +0 -9
- package/dist/Preferences-DS4-CFWe.js.map +0 -1
- package/dist/endpoints-DgyuoRZd.js.map +0 -1
- package/dist/index-2RfILgXm.js +0 -180
- package/dist/index-2RfILgXm.js.map +0 -1
- package/dist/index-B7c6jL9x.js.map +0 -1
- package/dist/index-BJ7_Q1mB.js.map +0 -1
- package/dist/index-BNh95-x2.js +0 -115
- package/dist/index-BNh95-x2.js.map +0 -1
- package/dist/index-BQ-cHWkJ.js.map +0 -1
- package/dist/index-BuYNq7f3.js.map +0 -1
- package/dist/index-BwdWyHLe.js.map +0 -1
- package/dist/index-CCRMmnwk.js.map +0 -1
- package/dist/index-CnIpUF9x.js +0 -173
- package/dist/index-CnIpUF9x.js.map +0 -1
- package/dist/index-CyG7_IYz.js +0 -394
- package/dist/index-CyG7_IYz.js.map +0 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 dragon-fish
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 dragon-fish
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
|
@@ -1,36 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
function l(t) {
|
|
8
|
-
return c(t).replace(/-/g, "_").replace(/.[A-Z]+/g, (e) => e[0] + "_" + e.slice(1).toLowerCase());
|
|
9
|
-
}
|
|
10
|
-
class d {
|
|
11
|
-
constructor(e, r = void 0, h) {
|
|
12
|
-
this.ctx = e, this.disposeHandlers = [], this.name = h || "", this.config = r || {};
|
|
13
|
-
const { promise: i, resolve: o, reject: a } = Promise.withResolvers();
|
|
1
|
+
import { f as n } from "./Preferences-85Q9FAmb.js";
|
|
2
|
+
class l {
|
|
3
|
+
constructor(e, t = void 0, h) {
|
|
4
|
+
this.ctx = e, this.disposeHandlers = [], this.name = h || "", this.config = t || {};
|
|
5
|
+
const { promise: r, resolve: i, reject: o } = Promise.withResolvers();
|
|
14
6
|
queueMicrotask(() => {
|
|
15
7
|
this.name || (this.name = this.constructor.name);
|
|
16
8
|
try {
|
|
17
9
|
const s = this.start();
|
|
18
|
-
s && typeof s.then == "function" ? s.then(() =>
|
|
19
|
-
this.logger.error("start() returns a rejected promise",
|
|
20
|
-
}) :
|
|
10
|
+
s && typeof s.then == "function" ? s.then(() => i()).catch((a) => {
|
|
11
|
+
this.logger.error("start() returns a rejected promise", a), o(a);
|
|
12
|
+
}) : i();
|
|
21
13
|
} catch (s) {
|
|
22
|
-
this.logger.error("start() threw synchronously", s),
|
|
14
|
+
this.logger.error("start() threw synchronously", s), o(s);
|
|
23
15
|
}
|
|
24
|
-
|
|
16
|
+
r.then(() => {
|
|
25
17
|
this.logger.debug("started");
|
|
26
|
-
}),
|
|
18
|
+
}), r.catch((s) => {
|
|
27
19
|
this.logger.error("start failed", s), this.ctx.scope.dispose();
|
|
28
20
|
});
|
|
29
21
|
}), this.ctx.once("dispose", () => {
|
|
30
22
|
this.disposeHandlers.forEach((s) => s(this.ctx)), this.stop(), this.logger.debug("disposed");
|
|
31
23
|
});
|
|
32
24
|
}
|
|
33
|
-
#
|
|
25
|
+
#s;
|
|
34
26
|
static {
|
|
35
27
|
this.inject = [];
|
|
36
28
|
}
|
|
@@ -45,20 +37,19 @@ class d {
|
|
|
45
37
|
this.disposeHandlers.push(e);
|
|
46
38
|
}
|
|
47
39
|
removeDisposeHandler(e) {
|
|
48
|
-
this.disposeHandlers = this.disposeHandlers.filter((
|
|
40
|
+
this.disposeHandlers = this.disposeHandlers.filter((t) => t !== e);
|
|
49
41
|
}
|
|
50
42
|
set name(e) {
|
|
51
|
-
this.#
|
|
43
|
+
this.#s = n(e).toUpperCase();
|
|
52
44
|
}
|
|
53
45
|
get name() {
|
|
54
|
-
return this.#
|
|
46
|
+
return this.#s;
|
|
55
47
|
}
|
|
56
48
|
get logger() {
|
|
57
49
|
return this.ctx.logger(this.name);
|
|
58
50
|
}
|
|
59
51
|
}
|
|
60
52
|
export {
|
|
61
|
-
|
|
62
|
-
p
|
|
53
|
+
l as B
|
|
63
54
|
};
|
|
64
|
-
//# sourceMappingURL=BasePlugin-
|
|
55
|
+
//# sourceMappingURL=BasePlugin-CU8beLYu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BasePlugin-CU8beLYu.js","sources":["../src/plugins/BasePlugin.ts"],"sourcesContent":["import { Inject, InPageEdit, Schema } from '@/InPageEdit'\nimport type { Logger } from '@inpageedit/logger'\nimport { snakeCase } from '@/utils/string'\n\ninterface DisposeHandler {\n (ctx: InPageEdit): Promise<void> | void\n}\n\nexport default class BasePlugin<ConfigType extends unknown = any> {\n #name!: string\n public config: ConfigType\n private disposeHandlers: DisposeHandler[] = []\n /** 依赖注入 */\n static inject?: Inject = []\n /** 可重用? */\n static reusable = false\n /** 插件的偏好设置模式 */\n static PreferencesSchema?: Schema\n\n constructor(\n public ctx: InPageEdit,\n config: ConfigType = undefined as unknown as ConfigType,\n name?: string\n ) {\n this.name = name || ''\n this.config = config || ({} as ConfigType)\n const { promise, resolve, reject } = Promise.withResolvers<void>()\n queueMicrotask(() => {\n if (!this.name) {\n this.name = this.constructor.name\n }\n try {\n const ret = this.start()\n if (ret && typeof (ret as Promise<unknown>).then === 'function') {\n ;(ret as Promise<unknown>)\n .then(() => resolve())\n .catch((err) => {\n this.logger.error('start() returns a rejected promise', err)\n reject(err)\n })\n } else {\n resolve()\n }\n } catch (err) {\n this.logger.error('start() threw synchronously', err)\n reject(err)\n }\n\n promise.then(() => {\n this.logger.debug('started')\n })\n promise.catch((e) => {\n this.logger.error('start failed', e)\n this.ctx.scope.dispose()\n })\n })\n this.ctx.once('dispose', () => {\n this.disposeHandlers.forEach((fn) => fn(this.ctx))\n this.stop()\n this.logger.debug('disposed')\n })\n }\n\n protected start(): Promise<void> | void {}\n protected stop(): Promise<void> | void {}\n protected addDisposeHandler(fn: DisposeHandler): void {\n this.disposeHandlers.push(fn)\n }\n protected removeDisposeHandler(fn: DisposeHandler): void {\n this.disposeHandlers = this.disposeHandlers.filter((f) => f !== fn)\n }\n\n set name(name: string) {\n this.#name = snakeCase(name).toUpperCase()\n }\n get name(): string {\n return this.#name\n }\n\n get logger(): Logger {\n return this.ctx.logger(this.name)\n }\n}\n"],"names":["BasePlugin","ctx","config","name","promise","resolve","reject","ret","err","e","fn","#name","f","snakeCase"],"mappings":";AAQA,MAAqBA,EAA6C;AAAA,EAWhE,YACSC,GACPC,IAAqB,QACrBC,GACA;AAHO,SAAA,MAAAF,GATT,KAAQ,kBAAoC,CAAA,GAa1C,KAAK,OAAOE,KAAQ,IACpB,KAAK,SAASD,KAAW,CAAA;AACzB,UAAM,EAAE,SAAAE,GAAS,SAAAC,GAAS,QAAAC,EAAA,IAAW,QAAQ,cAAA;AAC7C,mBAAe,MAAM;AACnB,MAAK,KAAK,SACR,KAAK,OAAO,KAAK,YAAY;AAE/B,UAAI;AACF,cAAMC,IAAM,KAAK,MAAA;AACjB,QAAIA,KAAO,OAAQA,EAAyB,QAAS,aACjDA,EACC,KAAK,MAAMF,EAAA,CAAS,EACpB,MAAM,CAACG,MAAQ;AACd,eAAK,OAAO,MAAM,sCAAsCA,CAAG,GAC3DF,EAAOE,CAAG;AAAA,QACZ,CAAC,IAEHH,EAAA;AAAA,MAEJ,SAASG,GAAK;AACZ,aAAK,OAAO,MAAM,+BAA+BA,CAAG,GACpDF,EAAOE,CAAG;AAAA,MACZ;AAEA,MAAAJ,EAAQ,KAAK,MAAM;AACjB,aAAK,OAAO,MAAM,SAAS;AAAA,MAC7B,CAAC,GACDA,EAAQ,MAAM,CAACK,MAAM;AACnB,aAAK,OAAO,MAAM,gBAAgBA,CAAC,GACnC,KAAK,IAAI,MAAM,QAAA;AAAA,MACjB,CAAC;AAAA,IACH,CAAC,GACD,KAAK,IAAI,KAAK,WAAW,MAAM;AAC7B,WAAK,gBAAgB,QAAQ,CAACC,MAAOA,EAAG,KAAK,GAAG,CAAC,GACjD,KAAK,KAAA,GACL,KAAK,OAAO,MAAM,UAAU;AAAA,IAC9B,CAAC;AAAA,EACH;AAAA,EApDAC;AAAA,EAIA,OAAA;AAAA,SAAO,SAAkB,CAAA;AAAA,EAAC;AAAA,EAE1B,OAAA;AAAA,SAAO,WAAW;AAAA,EAAA;AAAA,EAgDR,QAA8B;AAAA,EAAC;AAAA,EAC/B,OAA6B;AAAA,EAAC;AAAA,EAC9B,kBAAkBD,GAA0B;AACpD,SAAK,gBAAgB,KAAKA,CAAE;AAAA,EAC9B;AAAA,EACU,qBAAqBA,GAA0B;AACvD,SAAK,kBAAkB,KAAK,gBAAgB,OAAO,CAACE,MAAMA,MAAMF,CAAE;AAAA,EACpE;AAAA,EAEA,IAAI,KAAKP,GAAc;AACrB,SAAKQ,KAAQE,EAAUV,CAAI,EAAE,YAAA;AAAA,EAC/B;AAAA,EACA,IAAI,OAAe;AACjB,WAAO,KAAKQ;AAAA,EACd;AAAA,EAEA,IAAI,SAAiB;AACnB,WAAO,KAAK,IAAI,OAAO,KAAK,IAAI;AAAA,EAClC;AACF;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IconQuickEdit-CMCQncyj.js","sources":["../src/components/Icon/IconQuickEdit.tsx"],"sourcesContent":["import { SVGProps } from 'jsx-dom'\
|
|
1
|
+
{"version":3,"file":"IconQuickEdit-CMCQncyj.js","sources":["../src/components/Icon/IconQuickEdit.tsx"],"sourcesContent":["import { SVGProps } from 'jsx-dom'\n\nexport const IconQuickEdit = (props: SVGProps<SVGSVGElement>) => (\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 {...props}\n class={`icon icon-tabler icons-tabler-outline icon-tabler-pencil-bolt ${props.className || ''}`}\n >\n <path stroke=\"none\" d=\"M0 0h24v24H0z\" fill=\"none\" />\n <path d=\"M4 20h4l10.5 -10.5a2.828 2.828 0 1 0 -4 -4l-10.5 10.5v4\" />\n <path d=\"M13.5 6.5l4 4\" />\n <path d=\"M19 16l-2 3h4l-2 3\" />\n </svg>\n)\n"],"names":["IconQuickEdit","props","jsxs","jsx"],"mappings":";AAEO,MAAMA,IAAgB,CAACC,MAC5BC,gBAAAA;AAAAA,EAAC;AAAA,EAAA;AAAA,IACC,OAAM;AAAA,IACN,OAAM;AAAA,IACN,QAAO;AAAA,IACP,SAAQ;AAAA,IACR,MAAK;AAAA,IACL,QAAO;AAAA,IACP,gBAAa;AAAA,IACb,kBAAe;AAAA,IACf,mBAAgB;AAAA,IACf,GAAGD;AAAA,IACJ,OAAO,iEAAiEA,EAAM,aAAa,EAAE;AAAA,IAE7F,UAAA;AAAA,MAAA,gBAAAE,EAAC,UAAK,QAAO,QAAO,GAAE,iBAAgB,MAAK,QAAO;AAAA,MAClD,gBAAAA,EAAC,QAAA,EAAK,GAAE,0DAAA,CAA0D;AAAA,MAClE,gBAAAA,EAAC,QAAA,EAAK,GAAE,gBAAA,CAAgB;AAAA,MACxB,gBAAAA,EAAC,QAAA,EAAK,GAAE,qBAAA,CAAqB;AAAA,IAAA;AAAA,EAAA;AAC/B;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputBox-nQKtiWtZ.js","sources":["../src/components/CheckBox.tsx","../src/components/InputBox.tsx"],"sourcesContent":["import { JSX } from 'jsx-dom'\n\nexport type CheckBoxProps = {\n id?: string\n name: string\n label?: string | HTMLElement\n checked?: boolean\n inputProps?: JSX.IntrinsicElements['input']\n labelProps?: JSX.IntrinsicElements['span']\n} & JSX.IntrinsicElements['label']\n\nexport const CheckBox = (props: CheckBoxProps) => {\n const { id, name, label, checked, inputProps, labelProps, children, ...rest } = props\n return (\n <label className=\"theme-ipe ipe-checkbox\" {...rest}>\n <input type=\"checkbox\" id={id} name={name} checked={checked} {...inputProps} />\n <span className=\"ipe-checkbox-box\"></span>\n <span {...labelProps}>{label || children}</span>\n </label>\n )\n}\n","import { JSX } from 'jsx-dom'\
|
|
1
|
+
{"version":3,"file":"InputBox-nQKtiWtZ.js","sources":["../src/components/CheckBox.tsx","../src/components/InputBox.tsx"],"sourcesContent":["import { JSX } from 'jsx-dom'\n\nexport type CheckBoxProps = {\n id?: string\n name: string\n label?: string | HTMLElement\n checked?: boolean\n inputProps?: JSX.IntrinsicElements['input']\n labelProps?: JSX.IntrinsicElements['span']\n} & JSX.IntrinsicElements['label']\n\nexport const CheckBox = (props: CheckBoxProps) => {\n const { id, name, label, checked, inputProps, labelProps, children, ...rest } = props\n return (\n <label className=\"theme-ipe ipe-checkbox\" {...rest}>\n <input type=\"checkbox\" id={id} name={name} checked={checked} {...inputProps} />\n <span className=\"ipe-checkbox-box\"></span>\n <span {...labelProps}>{label || children}</span>\n </label>\n )\n}\n","import { JSX } from 'jsx-dom'\n\nexport type InputBoxProps = {\n label: string\n id?: string\n name: string\n value?: string\n disabled?: boolean\n labelProps?: JSX.IntrinsicElements['label']\n inputProps?: JSX.IntrinsicElements['input']\n} & JSX.IntrinsicElements['div']\n\nexport const InputBox = (props: InputBoxProps) => {\n const { label, id, name, value, disabled, labelProps, inputProps, ...rest } = props\n return (\n <div className=\"theme-ipe ipe-input-box\" {...rest}>\n <label htmlFor={id} style={{ display: 'block' }} {...labelProps}>\n {label}\n </label>\n <input\n id={id}\n name={name}\n value={value}\n disabled={disabled}\n style={{ width: '100%' }}\n {...inputProps}\n />\n </div>\n )\n}\n"],"names":["CheckBox","props","id","name","label","checked","inputProps","labelProps","children","rest","jsxs","jsx","InputBox","value","disabled"],"mappings":";AAWO,MAAMA,IAAW,CAACC,MAAyB;AAChD,QAAM,EAAE,IAAAC,GAAI,MAAAC,GAAM,OAAAC,GAAO,SAAAC,GAAS,YAAAC,GAAY,YAAAC,GAAY,UAAAC,GAAU,GAAGC,EAAA,IAASR;AAChF,SACES,gBAAAA,EAAC,SAAA,EAAM,WAAU,0BAA0B,GAAGD,GAC5C,UAAA;AAAA,IAAA,gBAAAE,EAAC,WAAM,MAAK,YAAW,IAAAT,GAAQ,MAAAC,GAAY,SAAAE,GAAmB,GAAGC,GAAY;AAAA,IAC7E,gBAAAK,EAAC,QAAA,EAAK,WAAU,mBAAA,CAAmB;AAAA,IACnC,gBAAAA,EAAC,QAAA,EAAM,GAAGJ,GAAa,eAASC,EAAA,CAAS;AAAA,EAAA,GAC3C;AAEJ,GCRaI,IAAW,CAACX,MAAyB;AAChD,QAAM,EAAE,OAAAG,GAAO,IAAAF,GAAI,MAAAC,GAAM,OAAAU,GAAO,UAAAC,GAAU,YAAAP,GAAY,YAAAD,GAAY,GAAGG,EAAA,IAASR;AAC9E,SACES,gBAAAA,EAAC,OAAA,EAAI,WAAU,2BAA2B,GAAGD,GAC3C,UAAA;AAAA,IAAA,gBAAAE,EAAC,SAAA,EAAM,SAAST,GAAI,OAAO,EAAE,SAAS,QAAA,GAAY,GAAGK,GAClD,UAAAH,EAAA,CACH;AAAA,IACA,gBAAAO;AAAA,MAAC;AAAA,MAAA;AAAA,QACC,IAAAT;AAAA,QACA,MAAAC;AAAA,QACA,OAAAU;AAAA,QACA,UAAAC;AAAA,QACA,OAAO,EAAE,OAAO,OAAA;AAAA,QACf,GAAGR;AAAA,MAAA;AAAA,IAAA;AAAA,EACN,GACF;AAEJ;"}
|
|
@@ -1,63 +1,63 @@
|
|
|
1
1
|
import { j as r } from "./index-CM_6yF2v.js";
|
|
2
2
|
import { W as k } from "./WatchlistAction-BbNAyryN.js";
|
|
3
|
-
import { B as I } from "./BasePlugin-
|
|
4
|
-
import { A as
|
|
5
|
-
import { I as U } from "./
|
|
6
|
-
var L = Object.create,
|
|
7
|
-
throw TypeError(
|
|
8
|
-
}, E = (
|
|
9
|
-
for (var
|
|
10
|
-
return
|
|
11
|
-
}, R = (
|
|
12
|
-
var
|
|
13
|
-
F(
|
|
14
|
-
for (var
|
|
15
|
-
|
|
16
|
-
return D(
|
|
3
|
+
import { B as I } from "./BasePlugin-CU8beLYu.js";
|
|
4
|
+
import { A as f } from "./ActionButton-CRjo_l3y.js";
|
|
5
|
+
import { I as U } from "./Preferences-85Q9FAmb.js";
|
|
6
|
+
var L = Object.create, w = Object.defineProperty, C = Object.getOwnPropertyDescriptor, v = (i, e) => (e = Symbol[i]) ? e : Symbol.for("Symbol." + i), x = (i) => {
|
|
7
|
+
throw TypeError(i);
|
|
8
|
+
}, E = (i, e, t) => e in i ? w(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t, F = (i, e) => w(i, "name", { value: e, configurable: !0 }), T = (i) => [, , , L(i?.[v("metadata")] ?? null)], j = ["class", "method", "getter", "setter", "accessor", "field", "value", "get", "set"], S = (i) => i !== void 0 && typeof i != "function" ? x("Function expected") : i, M = (i, e, t, s, n) => ({ kind: j[i], name: e, metadata: s, addInitializer: (o) => t._ ? x("Already initialized") : n.push(S(o || null)) }), D = (i, e) => E(e, v("metadata"), i[3]), O = (i, e, t, s) => {
|
|
9
|
+
for (var n = 0, o = i[e >> 1], a = o && o.length; n < a; n++) o[n].call(t);
|
|
10
|
+
return s;
|
|
11
|
+
}, R = (i, e, t, s, n, o) => {
|
|
12
|
+
var a, l, d, c = e & 7, p = !1, h = 0, P = i[h] || (i[h] = []), u = c && (n = n.prototype, c < 5 && (c > 3 || !p) && C(n, t));
|
|
13
|
+
F(n, t);
|
|
14
|
+
for (var g = s.length - 1; g >= 0; g--)
|
|
15
|
+
d = M(c, t, l = {}, i[3], P), a = (0, s[g])(n, d), l._ = 1, S(a) && (n = a);
|
|
16
|
+
return D(i, n), u && w(n, t, u), p ? c ^ 4 ? o : u : n;
|
|
17
17
|
}, b, y, _;
|
|
18
|
-
b = [U(["preferences", "wikiPage", "wikiTitle", "modal", "preferencesUI"])];
|
|
19
|
-
class
|
|
18
|
+
b = [U(["preferences", "wiki", "wikiPage", "wikiTitle", "modal", "preferencesUI", "$"])];
|
|
19
|
+
class m extends (_ = I) {
|
|
20
20
|
constructor(e) {
|
|
21
21
|
super(e, {}, "pref-sync"), this.ctx = e, e.set("prefSync", this);
|
|
22
22
|
}
|
|
23
23
|
start() {
|
|
24
|
-
const e = this.ctx
|
|
24
|
+
const e = this.ctx, t = e.$;
|
|
25
25
|
e.preferences.defineCategory({
|
|
26
26
|
name: "pref-sync",
|
|
27
|
-
label:
|
|
28
|
-
description:
|
|
27
|
+
label: t`Sync`,
|
|
28
|
+
description: t`Import and export preferences`,
|
|
29
29
|
index: 98,
|
|
30
30
|
customRenderer: () => {
|
|
31
|
-
const
|
|
31
|
+
const s = this.getUserPrefsPageTitle();
|
|
32
32
|
return /* @__PURE__ */ r("div", { className: "theme-ipe-prose", children: [
|
|
33
|
-
|
|
34
|
-
/* @__PURE__ */ r("h3", { children:
|
|
35
|
-
/* @__PURE__ */ r("p", { children: /* @__PURE__ */ r("a", { href:
|
|
36
|
-
|
|
33
|
+
s && /* @__PURE__ */ r("section", { children: [
|
|
34
|
+
/* @__PURE__ */ r("h3", { children: t`Backup your preferences via user page` }),
|
|
35
|
+
/* @__PURE__ */ r("p", { children: /* @__PURE__ */ r("a", { href: s?.getURL().toString(), target: "_blank", children: [
|
|
36
|
+
s?.getPrefixedText(),
|
|
37
37
|
" →"
|
|
38
38
|
] }) }),
|
|
39
39
|
/* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
40
40
|
/* @__PURE__ */ r(
|
|
41
|
-
|
|
41
|
+
f,
|
|
42
42
|
{
|
|
43
43
|
type: "primary",
|
|
44
|
-
onClick: (
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
44
|
+
onClick: (n) => {
|
|
45
|
+
n.preventDefault();
|
|
46
|
+
const o = n.target;
|
|
47
|
+
o.disabled = !0;
|
|
48
|
+
const a = e.preferencesUI.getCurrentModal();
|
|
49
|
+
a?.setLoadingState(!0), this.exportToUserPage().then((l) => {
|
|
50
50
|
e.modal.notify("success", {
|
|
51
|
-
title:
|
|
51
|
+
title: t`Preferences Exported`,
|
|
52
52
|
content: /* @__PURE__ */ r("p", { children: [
|
|
53
53
|
"Your preferences have been exported to",
|
|
54
54
|
" ",
|
|
55
|
-
/* @__PURE__ */ r("a", { href:
|
|
55
|
+
/* @__PURE__ */ r("a", { href: l.getURL().toString(), target: "_blank", children: l.getPrefixedText() }),
|
|
56
56
|
"."
|
|
57
57
|
] })
|
|
58
58
|
});
|
|
59
59
|
}).finally(() => {
|
|
60
|
-
|
|
60
|
+
o.disabled = !1, a?.setLoadingState(!1);
|
|
61
61
|
});
|
|
62
62
|
},
|
|
63
63
|
children: [
|
|
@@ -83,20 +83,20 @@ class g extends (_ = I) {
|
|
|
83
83
|
}
|
|
84
84
|
),
|
|
85
85
|
" ",
|
|
86
|
-
|
|
86
|
+
t`Backup`
|
|
87
87
|
]
|
|
88
88
|
}
|
|
89
89
|
),
|
|
90
90
|
/* @__PURE__ */ r(
|
|
91
|
-
|
|
91
|
+
f,
|
|
92
92
|
{
|
|
93
|
-
onClick: (
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
this.notifyImportSuccess(
|
|
93
|
+
onClick: (n) => {
|
|
94
|
+
n.preventDefault();
|
|
95
|
+
const o = e.preferencesUI.getCurrentModal(), a = n.target;
|
|
96
|
+
a.disabled = !0, o?.setLoadingState(!0), this.importFromUserPage().then((l) => {
|
|
97
|
+
this.notifyImportSuccess(l);
|
|
98
98
|
}).finally(() => {
|
|
99
|
-
|
|
99
|
+
a.disabled = !1, o?.setLoadingState(!1);
|
|
100
100
|
});
|
|
101
101
|
},
|
|
102
102
|
children: [
|
|
@@ -122,69 +122,69 @@ class g extends (_ = I) {
|
|
|
122
122
|
}
|
|
123
123
|
),
|
|
124
124
|
" ",
|
|
125
|
-
|
|
125
|
+
t`Restore`
|
|
126
126
|
]
|
|
127
127
|
}
|
|
128
128
|
)
|
|
129
129
|
] })
|
|
130
130
|
] }),
|
|
131
131
|
/* @__PURE__ */ r("section", { children: [
|
|
132
|
-
/* @__PURE__ */ r("h3", { children:
|
|
132
|
+
/* @__PURE__ */ r("h3", { children: t`Import and export preferences` }),
|
|
133
133
|
/* @__PURE__ */ r("div", { style: { display: "flex", flexDirection: "column", gap: "1rem" }, children: [
|
|
134
134
|
/* @__PURE__ */ r(
|
|
135
|
-
|
|
135
|
+
f,
|
|
136
136
|
{
|
|
137
|
-
onClick: (
|
|
138
|
-
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
let
|
|
144
|
-
const
|
|
145
|
-
|
|
137
|
+
onClick: (n) => {
|
|
138
|
+
n.preventDefault();
|
|
139
|
+
const o = e.preferencesUI.getCurrentModal();
|
|
140
|
+
o?.setLoadingState(!0);
|
|
141
|
+
const a = document.createElement("input");
|
|
142
|
+
a.type = "file", a.accept = "application/json";
|
|
143
|
+
let l = !1;
|
|
144
|
+
const d = () => {
|
|
145
|
+
l || o?.setLoadingState(!1), window.removeEventListener("focus", d);
|
|
146
146
|
};
|
|
147
|
-
window.addEventListener("focus",
|
|
148
|
-
|
|
147
|
+
window.addEventListener("focus", d, { once: !0 }), a.addEventListener("change", async (c) => {
|
|
148
|
+
l = !0;
|
|
149
149
|
try {
|
|
150
|
-
const
|
|
151
|
-
if (!
|
|
150
|
+
const p = c.target.files?.[0];
|
|
151
|
+
if (!p)
|
|
152
152
|
return;
|
|
153
|
-
const
|
|
154
|
-
this.notifyImportSuccess(
|
|
155
|
-
} catch (
|
|
153
|
+
const h = await this.importFromFile(p);
|
|
154
|
+
this.notifyImportSuccess(h);
|
|
155
|
+
} catch (p) {
|
|
156
156
|
e.modal.notify("error", {
|
|
157
157
|
title: "Import failed",
|
|
158
|
-
content:
|
|
158
|
+
content: p instanceof Error ? p.message : String(p)
|
|
159
159
|
});
|
|
160
160
|
} finally {
|
|
161
|
-
|
|
161
|
+
o?.setLoadingState(!1);
|
|
162
162
|
}
|
|
163
|
-
}),
|
|
163
|
+
}), a.click();
|
|
164
164
|
},
|
|
165
|
-
children:
|
|
165
|
+
children: t`Import from file`
|
|
166
166
|
}
|
|
167
167
|
),
|
|
168
168
|
/* @__PURE__ */ r(
|
|
169
|
-
|
|
169
|
+
f,
|
|
170
170
|
{
|
|
171
|
-
onClick: (
|
|
172
|
-
|
|
173
|
-
const
|
|
171
|
+
onClick: (n) => {
|
|
172
|
+
n.preventDefault();
|
|
173
|
+
const o = /* @__PURE__ */ r("input", { type: "url", style: { width: "100%" } }), a = e.preferencesUI.getCurrentModal();
|
|
174
174
|
e.modal.confirm(
|
|
175
175
|
{
|
|
176
|
-
title:
|
|
177
|
-
content: /* @__PURE__ */ r("div", { children: [
|
|
178
|
-
/* @__PURE__ */ r("label", { htmlFor: "url-input", children:
|
|
179
|
-
|
|
176
|
+
title: t`Import from URL`,
|
|
177
|
+
content: /* @__PURE__ */ r("div", { className: "ipe-input-box", children: [
|
|
178
|
+
/* @__PURE__ */ r("label", { htmlFor: "url-input", children: t`Enter the URL of the preferences JSON file:` }),
|
|
179
|
+
o
|
|
180
180
|
] })
|
|
181
181
|
},
|
|
182
|
-
async (
|
|
183
|
-
const
|
|
184
|
-
if (!(!
|
|
182
|
+
async (l) => {
|
|
183
|
+
const d = o.value.trim();
|
|
184
|
+
if (!(!l || !d))
|
|
185
185
|
try {
|
|
186
|
-
|
|
187
|
-
const c = await this.importFromUrl(
|
|
186
|
+
a?.setLoadingState(!0);
|
|
187
|
+
const c = await this.importFromUrl(d);
|
|
188
188
|
this.notifyImportSuccess(c);
|
|
189
189
|
} catch (c) {
|
|
190
190
|
e.modal.notify("error", {
|
|
@@ -192,32 +192,32 @@ class g extends (_ = I) {
|
|
|
192
192
|
content: c instanceof Error ? c.message : String(c)
|
|
193
193
|
});
|
|
194
194
|
} finally {
|
|
195
|
-
|
|
195
|
+
a?.setLoadingState(!1);
|
|
196
196
|
}
|
|
197
197
|
}
|
|
198
198
|
);
|
|
199
199
|
},
|
|
200
|
-
children:
|
|
200
|
+
children: t`Import from URL`
|
|
201
201
|
}
|
|
202
202
|
),
|
|
203
203
|
/* @__PURE__ */ r(
|
|
204
|
-
|
|
204
|
+
f,
|
|
205
205
|
{
|
|
206
|
-
onClick: async (
|
|
207
|
-
|
|
208
|
-
const
|
|
206
|
+
onClick: async (n) => {
|
|
207
|
+
n.preventDefault(), await e.preferencesUI.dispatchFormSave();
|
|
208
|
+
const o = await e.preferences.getExportableRecord(), a = JSON.stringify(o, null, 2);
|
|
209
209
|
e.modal.dialog(
|
|
210
210
|
{
|
|
211
|
-
title:
|
|
211
|
+
title: t`Save to file`,
|
|
212
212
|
content: /* @__PURE__ */ r("div", { children: [
|
|
213
|
-
/* @__PURE__ */ r("label", { htmlFor: "data", children:
|
|
213
|
+
/* @__PURE__ */ r("label", { htmlFor: "data", children: t`Your InPageEdit preferences:` }),
|
|
214
214
|
/* @__PURE__ */ r(
|
|
215
215
|
"textarea",
|
|
216
216
|
{
|
|
217
217
|
name: "data",
|
|
218
218
|
id: "data",
|
|
219
219
|
rows: 10,
|
|
220
|
-
value:
|
|
220
|
+
value: a,
|
|
221
221
|
readOnly: !0,
|
|
222
222
|
style: { width: "100%" }
|
|
223
223
|
}
|
|
@@ -226,17 +226,17 @@ class g extends (_ = I) {
|
|
|
226
226
|
buttons: [
|
|
227
227
|
{
|
|
228
228
|
label: "Copy",
|
|
229
|
-
method: (
|
|
230
|
-
navigator.clipboard.writeText(
|
|
231
|
-
content:
|
|
232
|
-
}),
|
|
229
|
+
method: (l, d) => {
|
|
230
|
+
navigator.clipboard.writeText(a), e.modal.notify("success", {
|
|
231
|
+
content: t`Copied to clipboard`
|
|
232
|
+
}), d.close();
|
|
233
233
|
}
|
|
234
234
|
},
|
|
235
235
|
{
|
|
236
|
-
label:
|
|
237
|
-
method: (
|
|
236
|
+
label: t`Download`,
|
|
237
|
+
method: (l, d) => {
|
|
238
238
|
const c = document.createElement("a");
|
|
239
|
-
c.href = `data:text/json;charset=utf-8,${encodeURIComponent(
|
|
239
|
+
c.href = `data:text/json;charset=utf-8,${encodeURIComponent(a)}`, c.download = `ipe-prefs-${(/* @__PURE__ */ new Date()).toISOString()}.json`, c.click(), d.close();
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
]
|
|
@@ -245,7 +245,7 @@ class g extends (_ = I) {
|
|
|
245
245
|
}
|
|
246
246
|
);
|
|
247
247
|
},
|
|
248
|
-
children:
|
|
248
|
+
children: t`Save as file`
|
|
249
249
|
}
|
|
250
250
|
)
|
|
251
251
|
] })
|
|
@@ -275,67 +275,63 @@ class g extends (_ = I) {
|
|
|
275
275
|
if (!e)
|
|
276
276
|
return this.logger.debug("Cannot get user page title, skipping load"), {};
|
|
277
277
|
try {
|
|
278
|
-
const
|
|
279
|
-
return this.logger.info("Loaded preferences from user page:", e),
|
|
280
|
-
} catch (
|
|
281
|
-
return this.logger.error("Failed to load preferences from user page:",
|
|
278
|
+
const t = e.getURL({ action: "raw", ctype: "application/json" }), s = await this.importFromUrl(t.toString());
|
|
279
|
+
return this.logger.info("Loaded preferences from user page:", e), s;
|
|
280
|
+
} catch (t) {
|
|
281
|
+
return this.logger.error("Failed to load preferences from user page:", t), {};
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
/**
|
|
285
285
|
* 导出配置到用户页
|
|
286
286
|
*/
|
|
287
287
|
async exportToUserPage() {
|
|
288
|
-
const e = this.ctx,
|
|
289
|
-
if (!
|
|
288
|
+
const e = this.ctx, t = this.getUserPrefsPageTitle();
|
|
289
|
+
if (!t)
|
|
290
290
|
throw new Error("Cannot get user page title");
|
|
291
291
|
await e.preferencesUI.dispatchFormSave();
|
|
292
|
-
const
|
|
292
|
+
const s = await e.preferences.getExportableRecord(), n = JSON.stringify(s, null, 2);
|
|
293
293
|
try {
|
|
294
294
|
return await this.ctx.wikiPage.newBlankPage({
|
|
295
|
-
title:
|
|
295
|
+
title: t.toString(),
|
|
296
296
|
ns: 2
|
|
297
297
|
// User namespace
|
|
298
298
|
}).edit({
|
|
299
|
-
text:
|
|
299
|
+
text: n,
|
|
300
300
|
summary: "Update InPageEdit preferences",
|
|
301
301
|
watchlist: k.nochange
|
|
302
|
-
}), this.logger.info("Exported preferences to user page:",
|
|
303
|
-
} catch (
|
|
304
|
-
throw this.logger.error("Failed to export preferences to user page:",
|
|
302
|
+
}), this.logger.info("Exported preferences to user page:", t), t;
|
|
303
|
+
} catch (o) {
|
|
304
|
+
throw this.logger.error("Failed to export preferences to user page:", o), o;
|
|
305
305
|
}
|
|
306
306
|
}
|
|
307
307
|
async importFromUrl(e) {
|
|
308
|
-
const
|
|
309
|
-
if (!
|
|
310
|
-
throw new Error(`HTTP ${
|
|
311
|
-
const
|
|
312
|
-
return await this.importFromFile(
|
|
308
|
+
const t = await fetch(e);
|
|
309
|
+
if (!t.ok)
|
|
310
|
+
throw new Error(`HTTP ${t.status}: ${t.statusText}`);
|
|
311
|
+
const s = await t.blob();
|
|
312
|
+
return await this.importFromFile(s);
|
|
313
313
|
}
|
|
314
314
|
async importFromFile(e) {
|
|
315
|
-
const
|
|
316
|
-
return await this.ctx.preferences.setMany(
|
|
315
|
+
const t = await e.text(), s = JSON.parse(t);
|
|
316
|
+
return await this.ctx.preferences.setMany(s);
|
|
317
317
|
}
|
|
318
318
|
notifyImportSuccess(e) {
|
|
319
|
-
const
|
|
319
|
+
const t = this.ctx.$, s = Object.keys(e ?? {}), n = s.length;
|
|
320
320
|
return this.ctx.modal.notify("success", {
|
|
321
|
-
title:
|
|
321
|
+
title: t`Preferences Imported`,
|
|
322
322
|
content: /* @__PURE__ */ r("section", { children: [
|
|
323
|
-
/* @__PURE__ */ r("p", { children:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
o !== 1 ? "settings" : "setting",
|
|
328
|
-
":"
|
|
329
|
-
] }),
|
|
330
|
-
/* @__PURE__ */ r("ol", { style: { listStyle: "auto", paddingLeft: "1em" }, children: n.map((t) => /* @__PURE__ */ r("li", { children: t }, t)) })
|
|
323
|
+
/* @__PURE__ */ r("p", { children: t({
|
|
324
|
+
count: n
|
|
325
|
+
})`Successfully imported {{ count }} {{ count > 1 ? "settings" : "setting" }}:` }),
|
|
326
|
+
/* @__PURE__ */ r("ol", { style: { listStyle: "auto", paddingLeft: "1em" }, children: s.map((o) => /* @__PURE__ */ r("li", { children: o }, o)) })
|
|
331
327
|
] })
|
|
332
328
|
});
|
|
333
329
|
}
|
|
334
330
|
}
|
|
335
331
|
y = T(_);
|
|
336
|
-
|
|
337
|
-
O(y, 1,
|
|
332
|
+
m = R(y, 0, "PluginPrefSync", b, m);
|
|
333
|
+
O(y, 1, m);
|
|
338
334
|
export {
|
|
339
|
-
|
|
335
|
+
m as PluginPrefSync
|
|
340
336
|
};
|
|
341
|
-
//# sourceMappingURL=PluginPrefSync-
|
|
337
|
+
//# sourceMappingURL=PluginPrefSync-B-gPsC2n.js.map
|