@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.
Files changed (74) hide show
  1. package/LICENSE +20 -20
  2. package/dist/{BasePlugin-Bf2UuIHF.js → BasePlugin-CU8beLYu.js} +17 -26
  3. package/dist/BasePlugin-CU8beLYu.js.map +1 -0
  4. package/dist/IconQuickEdit-CMCQncyj.js.map +1 -1
  5. package/dist/InputBox-nQKtiWtZ.js.map +1 -1
  6. package/dist/{PluginPrefSync-Dn1Xsiqz.js → PluginPrefSync-B-gPsC2n.js} +124 -128
  7. package/dist/PluginPrefSync-B-gPsC2n.js.map +1 -0
  8. package/dist/PluginStoreApp-CDteVCBG.js +453 -0
  9. package/dist/PluginStoreApp-CDteVCBG.js.map +1 -0
  10. package/dist/{endpoints-DgyuoRZd.js → Preferences-85Q9FAmb.js} +589 -565
  11. package/dist/Preferences-85Q9FAmb.js.map +1 -0
  12. package/dist/WatchlistAction-BbNAyryN.js.map +1 -1
  13. package/dist/components/index.js.map +1 -1
  14. package/dist/{index-BuYNq7f3.js → index-19CgGBI0.js} +1419 -921
  15. package/dist/index-19CgGBI0.js.map +1 -0
  16. package/dist/{index-B7c6jL9x.js → index-BKIf3i0I.js} +146 -137
  17. package/dist/index-BKIf3i0I.js.map +1 -0
  18. package/dist/{index-CCRMmnwk.js → index-BrtFJ-M0.js} +67 -66
  19. package/dist/index-BrtFJ-M0.js.map +1 -0
  20. package/dist/index-CG38LlAh.js.map +1 -1
  21. package/dist/index-CM_6yF2v.js.map +1 -1
  22. package/dist/index-CQr1DJ8n.js +173 -0
  23. package/dist/index-CQr1DJ8n.js.map +1 -0
  24. package/dist/{index-BQ-cHWkJ.js → index-CVTBg5O9.js} +66 -48
  25. package/dist/index-CVTBg5O9.js.map +1 -0
  26. package/dist/index-Ci82vLXg.js +179 -0
  27. package/dist/index-Ci82vLXg.js.map +1 -0
  28. package/dist/{index-BwdWyHLe.js → index-D3iZhRMJ.js} +93 -93
  29. package/dist/index-D3iZhRMJ.js.map +1 -0
  30. package/dist/index-DD5CVCfD.js.map +1 -1
  31. package/dist/{index-BJ7_Q1mB.js → index-DGtq21uW.js} +17 -16
  32. package/dist/index-DGtq21uW.js.map +1 -0
  33. package/dist/index-DXL7teb0.js +394 -0
  34. package/dist/index-DXL7teb0.js.map +1 -0
  35. package/dist/index-DjPpAyfE.js +116 -0
  36. package/dist/index-DjPpAyfE.js.map +1 -0
  37. package/dist/{index-eSlbrNqF.js → index-rpiO9fpc.js} +4 -5
  38. package/dist/{index-eSlbrNqF.js.map → index-rpiO9fpc.js.map} +1 -1
  39. package/dist/index.d.ts +327 -26
  40. package/dist/index.js +32 -26
  41. package/dist/index.js.map +1 -1
  42. package/dist/makeCallable-LDU0xZMJ.js.map +1 -1
  43. package/dist/models/index.js +174 -154
  44. package/dist/models/index.js.map +1 -1
  45. package/dist/noop-ClDc6zv4.js.map +1 -1
  46. package/dist/plugins/index.js +10 -10
  47. package/dist/services/index.js +1 -1
  48. package/dist/style.css +1 -1
  49. package/dist/vueHooks-l04s8cIl.js.map +1 -1
  50. package/lib/index.umd.js +20 -12
  51. package/lib/index.umd.js.map +1 -1
  52. package/lib/style.css +1 -1
  53. package/package.json +4 -4
  54. package/dist/BasePlugin-Bf2UuIHF.js.map +0 -1
  55. package/dist/PluginPrefSync-Dn1Xsiqz.js.map +0 -1
  56. package/dist/PluginStoreApp-CpOLArL7.js +0 -452
  57. package/dist/PluginStoreApp-CpOLArL7.js.map +0 -1
  58. package/dist/Preferences-DS4-CFWe.js +0 -9
  59. package/dist/Preferences-DS4-CFWe.js.map +0 -1
  60. package/dist/endpoints-DgyuoRZd.js.map +0 -1
  61. package/dist/index-2RfILgXm.js +0 -180
  62. package/dist/index-2RfILgXm.js.map +0 -1
  63. package/dist/index-B7c6jL9x.js.map +0 -1
  64. package/dist/index-BJ7_Q1mB.js.map +0 -1
  65. package/dist/index-BNh95-x2.js +0 -115
  66. package/dist/index-BNh95-x2.js.map +0 -1
  67. package/dist/index-BQ-cHWkJ.js.map +0 -1
  68. package/dist/index-BuYNq7f3.js.map +0 -1
  69. package/dist/index-BwdWyHLe.js.map +0 -1
  70. package/dist/index-CCRMmnwk.js.map +0 -1
  71. package/dist/index-CnIpUF9x.js +0 -173
  72. package/dist/index-CnIpUF9x.js.map +0 -1
  73. package/dist/index-CyG7_IYz.js +0 -394
  74. package/dist/index-CyG7_IYz.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { Context, Events as Events$1, ForkScope, Inject, Inject as Inject$1, Service } from "@cordisjs/core";
1
+ import { Context, CordisError, EffectScope, Events as Events$1, ForkScope, ForkScope as ForkScope$1, Inject, Inject as Inject$1, Lifecycle, MainScope, Plugin, Registry, ScopeStatus, Service, symbols as CordisSymbols } from "@cordisjs/core";
2
2
  import * as _inpageedit_logger0 from "@inpageedit/logger";
3
3
  import { Logger } from "@inpageedit/logger";
4
- import * as wiki_saikou0 from "wiki-saikou";
4
+ import * as wiki_saikou1 from "wiki-saikou";
5
5
  import { FexiosConfigs, MwApiParams } from "wiki-saikou";
6
6
  import { FexiosFinalContext, MediaWikiApi, MwApi, MwApiParams as MwApiParams$1, MwApiResponse } from "wiki-saikou/browser";
7
7
  import { IPEModal, IPEModalEvent, IPEModalOptions } from "@inpageedit/modal";
@@ -13,7 +13,7 @@ import * as jsx_dom0 from "jsx-dom";
13
13
  import { JSX, ReactElement, ReactNode } from "jsx-dom";
14
14
  import { JSX as JSX$1 } from "jsx-dom/jsx-runtime";
15
15
  import { JSX as JSX$2 } from "vue/jsx-runtime";
16
- import PreferencesApp from "./plugins/preferences-ui/components/PreferencesApp.vue";
16
+ import * as vue0 from "vue";
17
17
  import { App } from "vue";
18
18
  import "./plugins/toolbox/styles.scss";
19
19
  export * from "@inpageedit/logger";
@@ -337,10 +337,10 @@ declare class LocalStorageManager<T = unknown> implements AbstractIPEStorageMana
337
337
  dbName?: string | undefined;
338
338
  readonly storeName?: string | undefined;
339
339
  ttl: number;
340
- version?: number | undefined;
340
+ version?: number | string | undefined;
341
341
  engine: 'localStorage' | 'sessionStorage' | 'memory';
342
342
  private db;
343
- constructor(dbName?: string | undefined, storeName?: string | undefined, ttl?: number, version?: number | undefined, engine?: 'localStorage' | 'sessionStorage' | 'memory');
343
+ constructor(dbName?: string | undefined, storeName?: string | undefined, ttl?: number, version?: number | string | undefined, engine?: 'localStorage' | 'sessionStorage' | 'memory');
344
344
  private makeKey;
345
345
  private load;
346
346
  private getRaw;
@@ -365,12 +365,12 @@ declare class IDBStorageManager<T = unknown> implements AbstractIPEStorageManage
365
365
  readonly dbName: string;
366
366
  readonly storeName: string;
367
367
  ttl: number;
368
- version?: number | undefined;
368
+ version?: number | string | undefined;
369
369
  readonly db: IDBPlus<string, TypedStorageEntry<T>>;
370
370
  keys: () => AsyncIterable<string>;
371
371
  values: () => AsyncIterable<TypedStorageEntry<T>>;
372
372
  entries: () => AsyncIterable<[string, TypedStorageEntry<T>]>;
373
- constructor(dbName: string, storeName: string, ttl?: number, version?: number | undefined);
373
+ constructor(dbName: string, storeName: string, ttl?: number, version?: number | string | undefined);
374
374
  private _clearExpiredEntries;
375
375
  get(key: string, ttl?: number, setter?: () => Promise<T> | T): Promise<T | null>;
376
376
  set(key: string, value: null | undefined): Promise<void>;
@@ -404,7 +404,7 @@ declare class StorageService extends Service<StorageServiceConfig> {
404
404
  readonly simpleKV: LocalStorageManager<any>;
405
405
  readonly memoryKV: LocalStorageManager<any>;
406
406
  constructor(ctx: InPageEdit, config: StorageServiceConfig);
407
- createDatabase<T = any>(storeName: string, ttl?: number, version?: number, engine?: 'indexedDB' | 'localStorage' | 'sessionStorage' | 'memory'): AbstractIPEStorageManager<T>;
407
+ createDatabase<T = any>(storeName: string, ttl?: number, version?: number | string, engine?: 'indexedDB' | 'localStorage' | 'sessionStorage' | 'memory'): AbstractIPEStorageManager<T>;
408
408
  }
409
409
  interface TypedStorageEntry<T = any> {
410
410
  /** last update time */
@@ -412,7 +412,7 @@ interface TypedStorageEntry<T = any> {
412
412
  /** stored value */
413
413
  value: T;
414
414
  /** version */
415
- version?: number;
415
+ version?: number | string;
416
416
  }
417
417
  interface AbstractIPEStorageManager<T = unknown> {
418
418
  get(key: string, ttl?: number, setter?: () => Promise<any> | any): Promise<T | null>;
@@ -881,6 +881,299 @@ declare class PreferencesService extends Service {
881
881
  private _migrageFromLegacyMasterDB;
882
882
  }
883
883
  //#endregion
884
+ //#region src/services/i18n/interpolate.d.ts
885
+ /**
886
+ * 创建带有“全局可用函数/变量”的插值函数。
887
+ * - 传入的 globals 会作为模板可用的全局,只在上下文未提供同名键时生效(上下文优先)。
888
+ * - 返回的函数与 interpolate 具有相同签名。
889
+ *
890
+ * 示例:
891
+ * ```ts
892
+ * const interpolate = createInterpolate({ getUrl })
893
+ * interpolate('url is: {{ getUrl(title) }}', { title: 'foo' })
894
+ * ```
895
+ */
896
+ type Interpolator = {
897
+ (template: string): string;
898
+ (template: string, context: Record<string, unknown>): string;
899
+ (template: string, ...numricContext: string[]): string;
900
+ (template: string, numricContext: string[]): string;
901
+ };
902
+ //#endregion
903
+ //#region src/services/i18n/I18nManager.d.ts
904
+ declare class I18nManager {
905
+ private languages;
906
+ private currentLanguage;
907
+ private missingKeys;
908
+ private usedKeys;
909
+ interpolate: Interpolator;
910
+ constructor(init?: Record<string, any>, options?: {
911
+ language?: string;
912
+ globals?: Record<string, unknown>;
913
+ });
914
+ setGlobals(globals: Record<string, unknown>): this;
915
+ /**
916
+ * ```
917
+ * { foo: 'foo', bar: { baz: 'qux' } }
918
+ * ```
919
+ * will be merged into
920
+ * ```
921
+ * { foo: 'foo', 'bar.baz': 'qux' }
922
+ * ```
923
+ */
924
+ set(key: string, value: string): this;
925
+ set(data: Record<string, any>): this;
926
+ setLanguageData(language: string, data: Record<string, any>): this;
927
+ setLanguage(language: string): this;
928
+ getLanguage(): string;
929
+ hasLanguage(language: string): boolean | undefined;
930
+ private toStringRecord;
931
+ has(key: string): boolean;
932
+ get(key: string): string | undefined;
933
+ /**
934
+ * [payload as template] Interpolate a message with optional arguments
935
+ * @example
936
+ * ```
937
+ * i18n.msg('Hello, {{ name }}', 'dragon')
938
+ * // good: "你好,dragon"
939
+ * // missing: "Hello, dragon"
940
+ * ```
941
+ */
942
+ translate(msg: string): string;
943
+ translate(msg: string, context: Record<string, unknown>): string;
944
+ translate(msg: string, ...numricContext: string[]): string;
945
+ translate(msg: string, numricContext: string[]): string;
946
+ /**
947
+ * $ => translate
948
+ * @example
949
+ * ```
950
+ * $`hello, world` // "你好,世界"
951
+ * $('dragon')`hello, {{ $1 }}` // "你好,dragon"
952
+ */
953
+ $(context: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => string;
954
+ $(...numricContext: string[]): (strings: TemplateStringsArray, ...values: unknown[]) => string;
955
+ $(strings: TemplateStringsArray, ...values: unknown[]): string;
956
+ /**
957
+ * [payload as template] Return the raw message without interpolation
958
+ * @example
959
+ * ```
960
+ * i18n.rawMsg('Hello, {{ name }}')
961
+ * // good: "你好,{{ name }}"
962
+ * // missing: "Hello, {{ name }}"
963
+ * ```
964
+ */
965
+ translateRaw(msg: string): string;
966
+ /**
967
+ * $raw => translateRaw
968
+ * @example
969
+ * ```
970
+ * $raw`hello, {{ $1 }}`
971
+ * // good: "你好,{{ $1 }}"
972
+ * // missing: "hello, {{ $1 }}"
973
+ * ```
974
+ */
975
+ $raw(_context: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => string;
976
+ $raw(..._numricContext: string[]): (strings: TemplateStringsArray, ...values: unknown[]) => string;
977
+ $raw(strings: TemplateStringsArray, ...values: unknown[]): string;
978
+ /**
979
+ * [payload as key] Interpolate a message by key with optional arguments
980
+ * @example
981
+ * ```
982
+ * i18n.strictMsg('greeting', 'dragon')
983
+ * // good: "你好,dragon"
984
+ * // missing: "(greeting)"
985
+ * ```
986
+ */
987
+ message(key: string): string;
988
+ message(key: string, context: Record<string, unknown>): string;
989
+ message(key: string, ...numricContext: string[]): string;
990
+ message(key: string, numricContext: string[]): string;
991
+ /**
992
+ * $$ => message
993
+ * @example
994
+ * ```
995
+ * $$`hello`
996
+ * // good: "你好"
997
+ * // missing: "(hello)"
998
+ * $$('dragon')`greeting`
999
+ * // good: "你好,dragon"
1000
+ * // missing: "(greeting)"
1001
+ * ```
1002
+ */
1003
+ $$(context: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => string;
1004
+ $$(...numricContext: string[]): (strings: TemplateStringsArray, ...values: unknown[]) => string;
1005
+ $$(strings: TemplateStringsArray, ...values: unknown[]): string;
1006
+ /**
1007
+ * [payload as key] Return the raw message without interpolation
1008
+ * @example
1009
+ * ```
1010
+ * i18n.rawMsg('greeting')
1011
+ * // good: "你好,{{ name }}"
1012
+ * // missing: "(greeting)"
1013
+ * ```
1014
+ */
1015
+ messageRaw(key: string): string;
1016
+ /**
1017
+ * $$raw => messageRaw
1018
+ * @example
1019
+ * ```
1020
+ * $$raw`greeting`
1021
+ * // good: "你好,{{ name }}"
1022
+ * // missing: "(greeting)"
1023
+ * ```
1024
+ */
1025
+ $$raw(_context: Record<string, unknown>): (strings: TemplateStringsArray, ...values: unknown[]) => string;
1026
+ $$raw(..._numricContext: string[]): (strings: TemplateStringsArray, ...values: unknown[]) => string;
1027
+ $$raw(strings: TemplateStringsArray, ...values: unknown[]): string;
1028
+ getAvailableLanguages(): string[];
1029
+ private ensureLanguageMap;
1030
+ private resolveLanguageOrder;
1031
+ /**
1032
+ * 获取缺失键报告:
1033
+ * { foo: ['zh', 'zh-hans', 'en'] }
1034
+ */
1035
+ getMissingReport(): {
1036
+ [k: string]: string[];
1037
+ };
1038
+ /**
1039
+ * 清空缺失键记录
1040
+ */
1041
+ clearMissingReport(): void;
1042
+ private recordMissing;
1043
+ private recordUsedKey;
1044
+ private getUsedKeys;
1045
+ private generateBlankKeyRecord;
1046
+ }
1047
+ //#endregion
1048
+ //#region src/services/i18n/index.d.ts
1049
+ interface I18nIndexV1 {
1050
+ manifest_version: 1;
1051
+ base_language: string;
1052
+ last_modified: string;
1053
+ languages: Record<string, I18nIndexLanguage>;
1054
+ }
1055
+ interface I18nIndexLanguage {
1056
+ file: string;
1057
+ fallback?: string;
1058
+ data?: Record<string, any>;
1059
+ }
1060
+ // ↓ '@/InPageEdit'
1061
+ declare module '.' {
1062
+ interface InPageEdit {
1063
+ i18n: I18nService;
1064
+ /**
1065
+ * $ => translate [payload as template]
1066
+ * @example
1067
+ * ```
1068
+ * $`hello, world`
1069
+ * // good: "你好,世界"
1070
+ * // missing: "hello, world"
1071
+ * $('dragon')`hello, {{ $1 }}`
1072
+ * // good: "你好,dragon"
1073
+ * // missing: "hello, dragon"
1074
+ * ```
1075
+ */
1076
+ $: I18nManager['$'];
1077
+ /**
1078
+ * $raw => translateRaw [payload as template]
1079
+ * @example
1080
+ * ```
1081
+ * $raw`hello, {{ $1 }}`
1082
+ * // good: "你好,{{ $1 }}"
1083
+ * // missing: "hello, {{ $1 }}"
1084
+ * ```
1085
+ */
1086
+ $raw: I18nManager['$raw'];
1087
+ /**
1088
+ * $$ => message [payload as key]
1089
+ * @example
1090
+ * ```
1091
+ * $$`hello`
1092
+ * // good: "你好"
1093
+ * // missing: "(hello)"
1094
+ * $$('dragon')`greeting`
1095
+ * // good: "你好,dragon"
1096
+ * // missing: "(greeting)"
1097
+ * ```
1098
+ */
1099
+ $$: I18nManager['$$'];
1100
+ /**
1101
+ * $$raw => messageRaw [payload as key]
1102
+ * @example
1103
+ * ```
1104
+ * $$raw`greeting`
1105
+ * // good: "你好,{{ name }}"
1106
+ * // missing: "(greeting)"
1107
+ * ```
1108
+ */
1109
+ $$raw: I18nManager['$$raw'];
1110
+ }
1111
+ interface PreferencesMap {
1112
+ language: string;
1113
+ 'i18n.index_url': string;
1114
+ }
1115
+ interface Events {
1116
+ 'i18n/changed'(payload: {
1117
+ ctx: InPageEdit;
1118
+ language: string;
1119
+ }): void;
1120
+ }
1121
+ }
1122
+ declare class I18nService extends Service {
1123
+ readonly ctx: InPageEdit;
1124
+ private readonly logger;
1125
+ private _indexUrl;
1126
+ private _indexCache;
1127
+ readonly manager: I18nManager;
1128
+ private i18nIndexDB;
1129
+ private i18nDataDB;
1130
+ $: I18nManager['$'];
1131
+ $raw: I18nManager['$raw'];
1132
+ $$: I18nManager['$$'];
1133
+ $$raw: I18nManager['$$raw'];
1134
+ constructor(ctx: InPageEdit);
1135
+ protected start(): Promise<void>;
1136
+ private setupShortcuts;
1137
+ private normalizeLanguageCode;
1138
+ get language(): string;
1139
+ /**
1140
+ * 主动设置偏好值(会触发 preferences/changed,从而热切换)
1141
+ */
1142
+ setLanguagePreference(value: '@user' | '@site' | string): Promise<void>;
1143
+ /**
1144
+ * 直接切换到具体语言(不修改偏好值)
1145
+ */
1146
+ switchLanguage(language: string): Promise<void>;
1147
+ /**
1148
+ * 为指定语言注册(或合并)消息。
1149
+ * - 推荐加命名空间避免冲突:{ myPlugin: { key: 'value' } }
1150
+ * - 若 language 为当前语言,将立即可用;必要时你可以手动触发 UI 刷新或监听 i18n/changed。
1151
+ */
1152
+ registerMessages(language: string, data: Record<string, any>, options?: {
1153
+ namespace?: string;
1154
+ }): Promise<void>;
1155
+ /**
1156
+ * 列出可用语言与文件(来源于 index.json)
1157
+ */
1158
+ getAvailableLanguageCodes(): string[];
1159
+ private findLanguageMeta;
1160
+ getI18nIndex(url: string, noCache?: boolean): Promise<I18nIndexV1>;
1161
+ private fetchI18nIndex;
1162
+ private ensureLanguageLoaded;
1163
+ getLanguageData(language: string, noCache?: boolean): Promise<Record<string, string>>;
1164
+ /**
1165
+ * 获取缺失键报告,形如:
1166
+ * { foo: ['zh', 'zh-hans', 'en'] }
1167
+ */
1168
+ getMissingReport(): {
1169
+ [k: string]: string[];
1170
+ };
1171
+ /**
1172
+ * 清空缺失键记录
1173
+ */
1174
+ clearMissingReport(): void;
1175
+ }
1176
+ //#endregion
884
1177
  //#region src/InPageEdit.d.ts
885
1178
  interface InPageEditCoreConfig {
886
1179
  apiConfigs: Partial<FexiosConfigs>;
@@ -913,6 +1206,8 @@ declare class InPageEdit extends Context {
913
1206
  }
914
1207
  interface PreferencesMap {}
915
1208
  interface Events<C extends InPageEdit = InPageEdit> extends Events$1<C> {}
1209
+ type IPEPlugin<C = any> = Plugin<InPageEdit, C>;
1210
+ type IPERegistry = Registry<InPageEdit>;
916
1211
  interface InPageEdit {
917
1212
  [InPageEdit.events]: Events<this>;
918
1213
  }
@@ -922,9 +1217,13 @@ declare enum Endpoints {
922
1217
  ANALYTICS_API_BASE = "https://analytics.ipe.wiki/api/v6",
923
1218
  ANALYTICS_DASH_URL = "https://analytics.ipe.wiki",
924
1219
  GITHUB_URL = "https://github.com/inpageedit/inpageedit-next",
1220
+ GITHUB_OWNER = "inpageedit",
1221
+ GITHUB_REPO = "inpageedit-next",
925
1222
  HOME_URL = "https://www.ipe.wiki/",
926
1223
  UPDATE_LOGS_URL = "https://www.ipe.wiki/changelogs/",
927
1224
  PLUGIN_REGISTRY_URL = "https://registry.ipe.wiki/registry.v1.json",
1225
+ I18N_INDEX_URL = "https://registry.ipe.wiki/i18n/index.json",
1226
+ QQ_GROUP_ID = "1026023666",
928
1227
  }
929
1228
  //#endregion
930
1229
  //#region src/plugins/BasePlugin.d.ts
@@ -964,10 +1263,7 @@ type PreferenceAugmented<D, C extends AnyConstructor> = C & {
964
1263
  * @RegisterPreferences(
965
1264
  * Schema.object({
966
1265
  * foo: Schema.string().description('Foo description'),
967
- * }),
968
- * {
969
- * foo: 'default foo value',
970
- * }
1266
+ * })
971
1267
  * )
972
1268
  * class Foo {}
973
1269
  * ```
@@ -979,9 +1275,6 @@ type PreferenceAugmented<D, C extends AnyConstructor> = C & {
979
1275
  * static ConfigSchema = Schema.object({
980
1276
  * foo: Schema.string().description('Foo description')
981
1277
  * })
982
- * static ConfigDefaults = {
983
- * foo: 'default foo value'
984
- * }
985
1278
  * }
986
1279
  * ```
987
1280
  */
@@ -1278,11 +1571,11 @@ declare class PluginPluginStore extends BasePlugin {
1278
1571
  private _injectPreferenceUI;
1279
1572
  showModal(): Promise<CustomIPEModal>;
1280
1573
  private _installedPlugins;
1281
- install(registry: string, id: string, source?: PluginStoreRegistrySource): Promise<ForkScope<InPageEdit> | null>;
1574
+ install(registry: string, id: string, source?: PluginStoreRegistrySource): Promise<ForkScope$1<InPageEdit> | null>;
1282
1575
  uninstall(registry: string, id: string): Promise<boolean>;
1283
1576
  addToPreferences(registry: string, id: string): Promise<boolean>;
1284
1577
  removeFromPreferences(registry: string, id: string): Promise<boolean>;
1285
- installAndSetPreference(registry: string, id: string): Promise<ForkScope<InPageEdit> | null>;
1578
+ installAndSetPreference(registry: string, id: string): Promise<ForkScope$1<InPageEdit> | null>;
1286
1579
  uninstallAndRemovePreference(registry: string, id: string): Promise<boolean>;
1287
1580
  private _installOneByRegistryInfo;
1288
1581
  validateRegistry(data: any): PluginStoreRegistry;
@@ -1303,6 +1596,14 @@ declare class PluginPluginStore extends BasePlugin {
1303
1596
  refreshAllRegistryCaches(): Promise<Record<string, PluginStoreRegistry | null>>;
1304
1597
  }
1305
1598
  //#endregion
1599
+ //#region src/plugins/preferences-ui/components/PreferencesApp.vue.d.ts
1600
+ declare const __VLS_export: vue0.DefineComponent<{}, {
1601
+ getValue(): any;
1602
+ mergeValue(details: Record<string, unknown>): void;
1603
+ selectTab(name: string): void;
1604
+ }, {}, {}, {}, vue0.ComponentOptionsMixin, vue0.ComponentOptionsMixin, {}, string, vue0.PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, vue0.ComponentProvideOptions, true, {}, any>;
1605
+ declare const _default: typeof __VLS_export;
1606
+ //#endregion
1306
1607
  //#region src/plugins/preferences-ui/index.d.ts
1307
1608
  // ↓ '@/InPageEdit'
1308
1609
  declare module '.' {
@@ -1317,7 +1618,7 @@ declare module '.' {
1317
1618
  'preferences-ui/vue-app-mounted'(payload: {
1318
1619
  ctx: InPageEdit;
1319
1620
  app: App;
1320
- form: InstanceType<typeof PreferencesApp>;
1621
+ form: InstanceType<typeof _default>;
1321
1622
  }): void;
1322
1623
  'preferences-ui/modal-tab-changed'(payload: {
1323
1624
  ctx: InPageEdit;
@@ -1340,11 +1641,11 @@ declare class PluginPreferencesUI extends BasePlugin {
1340
1641
  protected start(): Promise<void>;
1341
1642
  protected stop(): Promise<void> | void;
1342
1643
  _modal: CustomIPEModal | null;
1343
- _form: InstanceType<typeof PreferencesApp> | null;
1644
+ _form: InstanceType<typeof _default> | null;
1344
1645
  showModal(): CustomIPEModal;
1345
1646
  getCurrentModal(): CustomIPEModal | null;
1346
1647
  closeCurrentModal(): CustomIPEModal | undefined;
1347
- dispatchFormSave(form?: InstanceType<typeof PreferencesApp>): Promise<boolean>;
1648
+ dispatchFormSave(form?: InstanceType<typeof _default>): Promise<boolean>;
1348
1649
  getCurrentFormValue(): any;
1349
1650
  mergeFormValue(value: Record<string, unknown>): boolean;
1350
1651
  createPreferencesUIApp(): any;
@@ -1499,7 +1800,7 @@ declare class PluginQuickEdit extends BasePlugin {
1499
1800
  constructor(ctx: InPageEdit);
1500
1801
  protected start(): Promise<void> | void;
1501
1802
  showModal(payload?: string | Partial<QuickEditOptions>): Promise<void>;
1502
- handleSubmit(payload: QuickEditSubmitPayload): Promise<Required<wiki_saikou0.FexiosContext<wiki_saikou0.MwApiResponse<{
1803
+ handleSubmit(payload: QuickEditSubmitPayload): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
1503
1804
  success: boolean;
1504
1805
  }>>>>;
1505
1806
  static readonly BUILT_IN_FONT_OPTIONS: string[];
@@ -1555,7 +1856,7 @@ declare class PluginQuickMove extends BasePlugin {
1555
1856
  protected start(): Promise<void> | void;
1556
1857
  private injectToolbox;
1557
1858
  showModal(options?: Partial<QuickMoveOptions>): Promise<CustomIPEModal>;
1558
- movePage(options: MovePageOptions): Promise<Required<wiki_saikou0.FexiosContext<wiki_saikou0.MwApiResponse<{
1859
+ movePage(options: MovePageOptions): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
1559
1860
  success: boolean;
1560
1861
  }>>>>;
1561
1862
  }
@@ -1636,7 +1937,7 @@ declare class PluginQuickRedirect extends BasePlugin {
1636
1937
  protected start(): Promise<void> | void;
1637
1938
  protected stop(): Promise<void> | void;
1638
1939
  showModal(options?: Partial<QuickRedirectOptions>): Promise<CustomIPEModal>;
1639
- redirectPage(options: RedirectPageOptions): Promise<Required<wiki_saikou0.FexiosContext<wiki_saikou0.MwApiResponse<{
1940
+ redirectPage(options: RedirectPageOptions): Promise<Required<wiki_saikou1.FexiosContext<wiki_saikou1.MwApiResponse<{
1640
1941
  success: boolean;
1641
1942
  }>>>>;
1642
1943
  }
@@ -1710,7 +2011,7 @@ declare namespace index_d_exports$1 {
1710
2011
  export { AbstractIPEStorageManager, ApiService, ApiServiceOptions, CurrentPageService, CustomIPEModal, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, ModalService, PreferencesService, ResourceLoaderService, StorageService, StorageServiceConfig, TypedStorageEntry, WikiLinkMetadata, WikiMetadataService, WikiPageService, WikiTitleService };
1711
2012
  }
1712
2013
  declare namespace index_d_exports {
1713
- export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CurrentPageService, CustomIPEModal, Endpoints, Events, IPEBeaconPayload, IPEBeaconUsage, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, MBox, MBoxElement, MBoxProps, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
2014
+ export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CordisError, CordisSymbols, CurrentPageService, CustomIPEModal, EffectScope, Endpoints, Events, ForkScope, IPEBeaconPayload, IPEBeaconUsage, IPEPlugin, IPERegistry, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, Lifecycle, MBox, MBoxElement, MBoxProps, MainScope, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, ScopeStatus, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
1714
2015
  }
1715
2016
  declare global {
1716
2017
  const ipe: InPageEdit;
@@ -1746,4 +2047,4 @@ declare global {
1746
2047
  }
1747
2048
  }
1748
2049
  //#endregion
1749
- export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CurrentPageService, CustomIPEModal, Endpoints, Events, IPEBeaconPayload, IPEBeaconUsage, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, MBox, MBoxElement, MBoxProps, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
2050
+ export { AbstractIPEStorageManager, ActionButton, ActionButtonProps, ApiService, ApiServiceOptions, BasePlugin, CheckBox, CheckBoxProps, CompareApiRequestOptions, CompareApiResponse, ContentModelMap, CordisError, CordisSymbols, CurrentPageService, CustomIPEModal, EffectScope, Endpoints, Events, ForkScope, IPEBeaconPayload, IPEBeaconUsage, IPEPlugin, IPERegistry, IWikiPage, IWikiTitle, InArticleWikiAnchorMetadata, InPageEdit, InPageEditCoreConfig, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, Inject, InputBox, InputBoxProps, Lifecycle, MBox, MBoxElement, MBoxProps, MainScope, MemoryStorage, ModalService, MovePageOptions, PageInfo, PageParseData, PluginAnalytics, PluginInArticleLinks, PluginPluginStore, PluginPreferencesUI, PluginQuickDiff, PluginQuickEdit, PluginQuickMove, PluginQuickPreview, PluginQuickRedirect, PluginStoreRegistrySource, PluginToolbox, PreferencesMap, PreferencesService, ProgressBar, QuickEditEventPayload, QuickEditOptions, QuickEditSubmitPayload, QuickMoveOptions, QuickRedirectOptions, RadioBox, RadioBoxProps, RedirectPageOptions, RegisterPreferences, ResourceLoaderService, Schema, ScopeStatus, Service, StorageService, StorageServiceConfig, TabContent, TabLabel, TabView, TabViewLabelOptions, TwinSwapElement, TwinSwapInput, TwinSwapInputInput, TwinSwapInputProps, TypedStorageEntry, WatchlistAction, WikiLinkMetadata, WikiMagicWord, WikiMetadataService, WikiNameSpaceAlias, WikiNamespace, WikiPageConstructor, WikiPageEditPayload, WikiPageService, WikiSiteGeneralInfo, WikiSiteInfo, WikiSpecialPageAlias, WikiTitleConstructor, WikiTitleService, WikiUserBlockInfo, WikiUserInfo, WikiUserOptions, createWikiPageModel, createWikiTitleModel, useMemoryStorage };
package/dist/index.js CHANGED
@@ -1,26 +1,25 @@
1
- import { I as s } from "./index-BuYNq7f3.js";
2
- import { m as l, $ as g, S as m } from "./index-BuYNq7f3.js";
3
- import { E as r } from "./endpoints-DgyuoRZd.js";
4
- import { I as L, S as P, a as U } from "./endpoints-DgyuoRZd.js";
5
- import { B as S } from "./BasePlugin-Bf2UuIHF.js";
6
- import { R as M } from "./Preferences-DS4-CFWe.js";
1
+ import { I as s } from "./index-19CgGBI0.js";
2
+ import { m as l, $ as g, S as m } from "./index-19CgGBI0.js";
3
+ import { E as r } from "./Preferences-85Q9FAmb.js";
4
+ import { C as S, s as I, a as P, F as y, I as U, e as M, M as h, R, S as O, b as D, c as b } from "./Preferences-85Q9FAmb.js";
5
+ import { B as A } from "./BasePlugin-CU8beLYu.js";
7
6
  window.RLQ ||= [];
8
7
  window.__IPE_MODULES__ ||= [];
9
8
  w("InPageEdit#autoload", () => {
10
9
  const _ = a();
11
- _ && c({
10
+ _ && d({
12
11
  baseURL: _,
13
12
  InPageEdit: s
14
13
  });
15
14
  });
16
- async function c(_ = { baseURL: a(), InPageEdit: s }) {
17
- const { baseURL: o, InPageEdit: i } = _;
15
+ async function d(_ = { baseURL: a(), InPageEdit: s }) {
16
+ const { baseURL: n, InPageEdit: i } = _;
18
17
  typeof window?.ipe?.stop == "function" && await window.ipe.stop();
19
- const d = window.InPageEdit || {}, e = new i({
18
+ const c = window.InPageEdit || {}, e = new i({
20
19
  apiConfigs: {
21
- baseURL: o
20
+ baseURL: n
22
21
  },
23
- legacyPreferences: d?.myPreferences || {}
22
+ legacyPreferences: c?.myPreferences || {}
24
23
  });
25
24
  if (window.ipe = e, await e.start(), window.RLQ.push(() => {
26
25
  mw.hook("InPageEdit.ready").fire(e);
@@ -28,13 +27,13 @@ async function c(_ = { baseURL: a(), InPageEdit: s }) {
28
27
  const t = [];
29
28
  for (; window.__IPE_MODULES__.length; )
30
29
  try {
31
- const n = window.__IPE_MODULES__.shift();
32
- typeof n == "function" && n?.(e), t.push(n);
30
+ const o = window.__IPE_MODULES__.shift();
31
+ typeof o == "function" && o?.(e), t.push(o);
33
32
  } catch {
34
33
  }
35
34
  window.__IPE_MODULES__ = {
36
- push: (n) => {
37
- typeof n == "function" && n(e), t.push(n);
35
+ push: (o) => {
36
+ typeof o == "function" && o(e), t.push(o);
38
37
  }
39
38
  }, e.on("dispose", () => {
40
39
  window.__IPE_MODULES__ = t;
@@ -48,29 +47,36 @@ async function c(_ = { baseURL: a(), InPageEdit: s }) {
48
47
  _/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_
49
48
  /___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/
50
49
  /____/ v` + e.version + `
51
- - Wiki API Endpoint: ${o}
50
+ - Wiki API Endpoint: ${n}
52
51
  - Documentation: ${r.HOME_URL}
53
52
  - Bug Reports: ${r.GITHUB_URL}`
54
53
  );
55
54
  }
56
55
  function a() {
57
- const _ = document.querySelector('meta[name="generator"][content^="MediaWiki"]') !== null, o = document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];
58
- return _ && o ? o : void 0;
56
+ const _ = document.querySelector('meta[name="generator"][content^="MediaWiki"]') !== null, n = document.querySelector('link[rel="EditURI"]')?.href?.split("?")[0];
57
+ return _ && n ? n : void 0;
59
58
  }
60
- function w(_, o) {
59
+ function w(_, n) {
61
60
  const i = Symbol.for(_);
62
- return window[i] ? !1 : (window[i] = !0, o(), !0);
61
+ return window[i] ? !1 : (window[i] = !0, n(), !0);
63
62
  }
64
63
  export {
65
- S as BasePlugin,
64
+ A as BasePlugin,
65
+ S as CordisError,
66
+ I as CordisSymbols,
67
+ P as EffectScope,
66
68
  r as Endpoints,
69
+ y as ForkScope,
67
70
  s as InPageEdit,
68
- L as Inject,
71
+ U as Inject,
72
+ M as Lifecycle,
69
73
  l as Logger,
70
74
  g as LoggerLevel,
71
- M as RegisterPreferences,
72
- P as Schema,
73
- U as Service,
75
+ h as MainScope,
76
+ R as RegisterPreferences,
77
+ O as Schema,
78
+ D as ScopeStatus,
79
+ b as Service,
74
80
  m as createLogger
75
81
  };
76
82
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import './polyfills/index.js'\nimport { InPageEdit } from './InPageEdit.js'\nimport { Endpoints } from './constants/endpoints.js'\n\n// 模块重导出\nexport * from './InPageEdit.js'\nexport { default as BasePlugin } from './plugins/BasePlugin.js'\nexport { Endpoints }\nexport { RegisterPreferences } from './decorators/Preferences.js'\n\n// Safe guard\nwindow.RLQ ||= []\nwindow.__IPE_MODULES__ ||= []\n\n// Auto load if the site is MediaWiki\nrunOnce('InPageEdit#autoload', () => {\n const baseURL = detectMediaWikiApiEndpoint()\n if (baseURL) {\n autoload({\n baseURL,\n InPageEdit,\n })\n }\n})\nasync function autoload(\n _overload: {\n baseURL?: string\n InPageEdit: typeof InPageEdit\n } = { baseURL: detectMediaWikiApiEndpoint(), InPageEdit: InPageEdit }\n) {\n const { baseURL, InPageEdit: IPE } = _overload\n\n // 防止多次运行\n if (typeof window?.ipe?.stop === 'function') {\n console.warn('[InPageEdit] Already loaded, disposing...')\n await window.ipe.stop()\n }\n\n const oldGlobalVar: any = (window as any).InPageEdit || {}\n const ipe = new IPE({\n apiConfigs: {\n baseURL,\n },\n legacyPreferences: oldGlobalVar?.myPreferences || {},\n })\n\n // Merge into global variables\n window.ipe = ipe\n\n // Start the App\n await ipe.start()\n\n // Trigger the mw.hook\n window.RLQ.push(() => {\n mw.hook('InPageEdit.ready').fire(ipe)\n })\n\n // Initialize global modules\n if (Array.isArray(window.__IPE_MODULES__)) {\n const installedModules = [] as any[]\n while (window.__IPE_MODULES__.length) {\n try {\n const payload = window.__IPE_MODULES__.shift()\n typeof payload === 'function' && payload?.(ipe)\n installedModules.push(payload)\n } catch (error) {\n console.error('[InPageEdit] Failed to initialize module:', error)\n }\n }\n window.__IPE_MODULES__ = {\n push: (payload) => {\n typeof payload === 'function' && payload(ipe)\n installedModules.push(payload)\n },\n }\n ipe.on('dispose', () => {\n window.__IPE_MODULES__ = installedModules\n })\n }\n\n // 花里胡哨的加载提示\n ipe.logger('AUTOLOAD').info(\n '\\n' +\n ' ____ ____ ______ ___ __ \\n / _/___ / __ \\\\____ _____ ____ / ____/___/ (_) /_\\n / // __ \\\\/ /_/ / __ `/ __ `/ _ \\\\/ __/ / __ / / __/\\n _/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_ \\n/___/_/ /_/_/ \\\\__,_/\\\\__, /\\\\___/_____/\\\\__,_/_/\\\\__/ \\n /____/ v' +\n ipe.version +\n `\n- Wiki API Endpoint: ${baseURL}\n- Documentation: ${Endpoints.HOME_URL}\n- Bug Reports: ${Endpoints.GITHUB_URL}`\n )\n}\n\nfunction detectMediaWikiApiEndpoint(): string | undefined {\n const isMediaWiki =\n document.querySelector('meta[name=\"generator\"][content^=\"MediaWiki\"]') !== null\n const apiBase = document\n .querySelector<HTMLLinkElement>('link[rel=\"EditURI\"]')\n ?.href?.split('?')[0]\n return isMediaWiki && apiBase ? apiBase : undefined\n}\n\nfunction runOnce(key: string, fn: Function) {\n const sym = Symbol.for(key)\n if ((window as any)[sym]) {\n return false\n }\n ;(window as any)[sym] = true\n fn()\n return true\n}\n\n// HMR\nif (import.meta.hot) {\n const SEPARATOR = `\\n${'='.repeat(20)} [InPageEdit] HMR ${'='.repeat(20)}\\n`\n import.meta.hot.accept(async (modules) => {\n const apiBase = detectMediaWikiApiEndpoint()!\n const IPE = modules?.InPageEdit as unknown as typeof InPageEdit\n if (!apiBase || !IPE) {\n console.warn(SEPARATOR.trimStart(), 'missing modules', SEPARATOR.trimEnd())\n location.reload()\n return\n }\n\n console.info(SEPARATOR.trimStart(), \"I'm so hot!\", modules, SEPARATOR.trimEnd())\n await window?.ipe?.stop()\n window.ipe = undefined as any\n autoload({\n baseURL: apiBase,\n InPageEdit: IPE,\n })\n })\n}\n\n// 类型定义\n\n// Global types declaration\ndeclare global {\n const ipe: InPageEdit\n interface Window {\n ipe: InPageEdit\n __IPE_MODULES__: {\n push(payload: (ipe: InPageEdit) => void): void\n }\n }\n}\n\n// MediaWiki ResourceLoader Queue\ndeclare global {\n interface Window {\n RLQ: {\n push(callback: () => void): void\n push(depAndCallback: [string, () => void]): void\n push(depsAndCallback: [string[], () => void]): void\n }\n }\n}\n\n// declare mw.hook\ndeclare global {\n namespace mw {\n /**\n * @see https://doc.wikimedia.org/mediawiki-core/master/js/Hook.html\n * @see https://github.com/wikimedia-gadgets/types-mediawiki/blob/9b4e7c3b9034d64a44a0667229a6d9585fe09b30/mw/hook.d.ts\n */\n interface Hook<T extends any[] = any[]> {\n add(...handler: Array<(...data: T) => any>): this\n deprecate(msg: string): this\n fire(...data: T): this\n remove(...handler: Array<(...data: T) => any>): this\n }\n function hook(name: 'InPageEdit.ready'): Hook<[InPageEdit]>\n }\n}\n\n// 类型重导出\n\n// expose all types\nexport type * from './components/index.js'\nexport type * from './models/index.js'\nexport type * from './plugins/index.js'\nexport type * from './services/index.js'\nexport type * from './types/index.js'\n"],"names":["runOnce","baseURL","detectMediaWikiApiEndpoint","autoload","InPageEdit","_overload","IPE","oldGlobalVar","ipe","installedModules","payload","Endpoints","isMediaWiki","apiBase","key","fn","sym"],"mappings":";;;;;;AAWA,OAAO,QAAQ,CAAA;AACf,OAAO,oBAAoB,CAAA;AAG3BA,EAAQ,uBAAuB,MAAM;AACnC,QAAMC,IAAUC,EAAA;AAChB,EAAID,KACFE,EAAS;AAAA,IACP,SAAAF;AAAA,IACA,YAAAG;AAAA,EAAA,CACD;AAEL,CAAC;AACD,eAAeD,EACbE,IAGI,EAAE,SAASH,EAAA,GAA8B,YAAAE,KAC7C;AACA,QAAM,EAAE,SAAAH,GAAS,YAAYK,EAAA,IAAQD;AAGrC,EAAI,OAAO,QAAQ,KAAK,QAAS,cAE/B,MAAM,OAAO,IAAI,KAAA;AAGnB,QAAME,IAAqB,OAAe,cAAc,CAAA,GAClDC,IAAM,IAAIF,EAAI;AAAA,IAClB,YAAY;AAAA,MACV,SAAAL;AAAA,IAAA;AAAA,IAEF,mBAAmBM,GAAc,iBAAiB,CAAA;AAAA,EAAC,CACpD;AAcD,MAXA,OAAO,MAAMC,GAGb,MAAMA,EAAI,MAAA,GAGV,OAAO,IAAI,KAAK,MAAM;AACpB,OAAG,KAAK,kBAAkB,EAAE,KAAKA,CAAG;AAAA,EACtC,CAAC,GAGG,MAAM,QAAQ,OAAO,eAAe,GAAG;AACzC,UAAMC,IAAmB,CAAA;AACzB,WAAO,OAAO,gBAAgB;AAC5B,UAAI;AACF,cAAMC,IAAU,OAAO,gBAAgB,MAAA;AACvC,eAAOA,KAAY,cAAcA,IAAUF,CAAG,GAC9CC,EAAiB,KAAKC,CAAO;AAAA,MAC/B,QAAgB;AAAA,MAEhB;AAEF,WAAO,kBAAkB;AAAA,MACvB,MAAM,CAACA,MAAY;AACjB,eAAOA,KAAY,cAAcA,EAAQF,CAAG,GAC5CC,EAAiB,KAAKC,CAAO;AAAA,MAC/B;AAAA,IAAA,GAEFF,EAAI,GAAG,WAAW,MAAM;AACtB,aAAO,kBAAkBC;AAAA,IAC3B,CAAC;AAAA,EACH;AAGA,EAAAD,EAAI,OAAO,UAAU,EAAE;AAAA,IACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAEEA,EAAI,UACJ;AAAA,uBACiBP,CAAO;AAAA,uBACPU,EAAU,QAAQ;AAAA,uBAClBA,EAAU,UAAU;AAAA,EAAA;AAE3C;AAEA,SAAST,IAAiD;AACxD,QAAMU,IACJ,SAAS,cAAc,8CAA8C,MAAM,MACvEC,IAAU,SACb,cAA+B,qBAAqB,GACnD,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,SAAOD,KAAeC,IAAUA,IAAU;AAC5C;AAEA,SAASb,EAAQc,GAAaC,GAAc;AAC1C,QAAMC,IAAM,OAAO,IAAIF,CAAG;AAC1B,SAAK,OAAeE,CAAG,IACd,MAEP,OAAeA,CAAG,IAAI,IACxBD,EAAA,GACO;AACT;"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["import './polyfills/index.js'\nimport { InPageEdit } from './InPageEdit.js'\nimport { Endpoints } from './constants/endpoints.js'\n\n// 模块重导出\nexport * from './InPageEdit.js'\nexport { default as BasePlugin } from './plugins/BasePlugin.js'\nexport { Endpoints }\nexport { RegisterPreferences } from './decorators/Preferences.js'\n\n// Safe guard\nwindow.RLQ ||= []\nwindow.__IPE_MODULES__ ||= []\n\n// Auto load if the site is MediaWiki\nrunOnce('InPageEdit#autoload', () => {\n const baseURL = detectMediaWikiApiEndpoint()\n if (baseURL) {\n autoload({\n baseURL,\n InPageEdit,\n })\n }\n})\nasync function autoload(\n _overload: {\n baseURL?: string\n InPageEdit: typeof InPageEdit\n } = { baseURL: detectMediaWikiApiEndpoint(), InPageEdit: InPageEdit }\n) {\n const { baseURL, InPageEdit: IPE } = _overload\n\n // 防止多次运行\n if (typeof window?.ipe?.stop === 'function') {\n console.warn('[InPageEdit] Already loaded, disposing...')\n await window.ipe.stop()\n }\n\n const oldGlobalVar: any = (window as any).InPageEdit || {}\n const ipe = new IPE({\n apiConfigs: {\n baseURL,\n },\n legacyPreferences: oldGlobalVar?.myPreferences || {},\n })\n\n // Merge into global variables\n window.ipe = ipe\n\n // Start the App\n await ipe.start()\n\n // Trigger the mw.hook\n window.RLQ.push(() => {\n mw.hook('InPageEdit.ready').fire(ipe)\n })\n\n // Initialize global modules\n if (Array.isArray(window.__IPE_MODULES__)) {\n const installedModules = [] as any[]\n while (window.__IPE_MODULES__.length) {\n try {\n const payload = window.__IPE_MODULES__.shift()\n typeof payload === 'function' && payload?.(ipe)\n installedModules.push(payload)\n } catch (error) {\n console.error('[InPageEdit] Failed to initialize module:', error)\n }\n }\n window.__IPE_MODULES__ = {\n push: (payload) => {\n typeof payload === 'function' && payload(ipe)\n installedModules.push(payload)\n },\n }\n ipe.on('dispose', () => {\n window.__IPE_MODULES__ = installedModules\n })\n }\n\n // 花里胡哨的加载提示\n ipe.logger('AUTOLOAD').info(\n '\\n' +\n ' ____ ____ ______ ___ __ \\n / _/___ / __ \\\\____ _____ ____ / ____/___/ (_) /_\\n / // __ \\\\/ /_/ / __ `/ __ `/ _ \\\\/ __/ / __ / / __/\\n _/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_ \\n/___/_/ /_/_/ \\\\__,_/\\\\__, /\\\\___/_____/\\\\__,_/_/\\\\__/ \\n /____/ v' +\n ipe.version +\n `\n- Wiki API Endpoint: ${baseURL}\n- Documentation: ${Endpoints.HOME_URL}\n- Bug Reports: ${Endpoints.GITHUB_URL}`\n )\n}\n\nfunction detectMediaWikiApiEndpoint(): string | undefined {\n const isMediaWiki =\n document.querySelector('meta[name=\"generator\"][content^=\"MediaWiki\"]') !== null\n const apiBase = document\n .querySelector<HTMLLinkElement>('link[rel=\"EditURI\"]')\n ?.href?.split('?')[0]\n return isMediaWiki && apiBase ? apiBase : undefined\n}\n\nfunction runOnce(key: string, fn: Function) {\n const sym = Symbol.for(key)\n if ((window as any)[sym]) {\n return false\n }\n ;(window as any)[sym] = true\n fn()\n return true\n}\n\n// HMR\nif (import.meta.hot) {\n const SEPARATOR = `\\n${'='.repeat(20)} [InPageEdit] HMR ${'='.repeat(20)}\\n`\n import.meta.hot.accept(async (modules) => {\n const apiBase = detectMediaWikiApiEndpoint()!\n const IPE = modules?.InPageEdit as unknown as typeof InPageEdit\n if (!apiBase || !IPE) {\n console.warn(SEPARATOR.trimStart(), 'missing modules', SEPARATOR.trimEnd())\n location.reload()\n return\n }\n\n console.info(SEPARATOR.trimStart(), \"I'm so hot!\", modules, SEPARATOR.trimEnd())\n await window?.ipe?.stop()\n window.ipe = undefined as any\n autoload({\n baseURL: apiBase,\n InPageEdit: IPE,\n })\n })\n}\n\n// 类型定义\n\n// Global types declaration\ndeclare global {\n const ipe: InPageEdit\n interface Window {\n ipe: InPageEdit\n __IPE_MODULES__: {\n push(payload: (ipe: InPageEdit) => void): void\n }\n }\n}\n\n// MediaWiki ResourceLoader Queue\ndeclare global {\n interface Window {\n RLQ: {\n push(callback: () => void): void\n push(depAndCallback: [string, () => void]): void\n push(depsAndCallback: [string[], () => void]): void\n }\n }\n}\n\n// declare mw.hook\ndeclare global {\n namespace mw {\n /**\n * @see https://doc.wikimedia.org/mediawiki-core/master/js/Hook.html\n * @see https://github.com/wikimedia-gadgets/types-mediawiki/blob/9b4e7c3b9034d64a44a0667229a6d9585fe09b30/mw/hook.d.ts\n */\n interface Hook<T extends any[] = any[]> {\n add(...handler: Array<(...data: T) => any>): this\n deprecate(msg: string): this\n fire(...data: T): this\n remove(...handler: Array<(...data: T) => any>): this\n }\n function hook(name: 'InPageEdit.ready'): Hook<[InPageEdit]>\n }\n}\n\n// 类型重导出\n\n// expose all types\nexport type * from './components/index.js'\nexport type * from './models/index.js'\nexport type * from './plugins/index.js'\nexport type * from './services/index.js'\nexport type * from './types/index.js'\n"],"names":["runOnce","baseURL","detectMediaWikiApiEndpoint","autoload","InPageEdit","_overload","IPE","oldGlobalVar","ipe","installedModules","payload","Endpoints","isMediaWiki","apiBase","key","fn","sym"],"mappings":";;;;;AAWA,OAAO,QAAQ,CAAA;AACf,OAAO,oBAAoB,CAAA;AAG3BA,EAAQ,uBAAuB,MAAM;AACnC,QAAMC,IAAUC,EAAA;AAChB,EAAID,KACFE,EAAS;AAAA,IACP,SAAAF;AAAA,IACA,YAAAG;AAAA,EAAA,CACD;AAEL,CAAC;AACD,eAAeD,EACbE,IAGI,EAAE,SAASH,EAAA,GAA8B,YAAAE,KAC7C;AACA,QAAM,EAAE,SAAAH,GAAS,YAAYK,EAAA,IAAQD;AAGrC,EAAI,OAAO,QAAQ,KAAK,QAAS,cAE/B,MAAM,OAAO,IAAI,KAAA;AAGnB,QAAME,IAAqB,OAAe,cAAc,CAAA,GAClDC,IAAM,IAAIF,EAAI;AAAA,IAClB,YAAY;AAAA,MACV,SAAAL;AAAA,IAAA;AAAA,IAEF,mBAAmBM,GAAc,iBAAiB,CAAA;AAAA,EAAC,CACpD;AAcD,MAXA,OAAO,MAAMC,GAGb,MAAMA,EAAI,MAAA,GAGV,OAAO,IAAI,KAAK,MAAM;AACpB,OAAG,KAAK,kBAAkB,EAAE,KAAKA,CAAG;AAAA,EACtC,CAAC,GAGG,MAAM,QAAQ,OAAO,eAAe,GAAG;AACzC,UAAMC,IAAmB,CAAA;AACzB,WAAO,OAAO,gBAAgB;AAC5B,UAAI;AACF,cAAMC,IAAU,OAAO,gBAAgB,MAAA;AACvC,eAAOA,KAAY,cAAcA,IAAUF,CAAG,GAC9CC,EAAiB,KAAKC,CAAO;AAAA,MAC/B,QAAgB;AAAA,MAEhB;AAEF,WAAO,kBAAkB;AAAA,MACvB,MAAM,CAACA,MAAY;AACjB,eAAOA,KAAY,cAAcA,EAAQF,CAAG,GAC5CC,EAAiB,KAAKC,CAAO;AAAA,MAC/B;AAAA,IAAA,GAEFF,EAAI,GAAG,WAAW,MAAM;AACtB,aAAO,kBAAkBC;AAAA,IAC3B,CAAC;AAAA,EACH;AAGA,EAAAD,EAAI,OAAO,UAAU,EAAE;AAAA,IACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iDAEEA,EAAI,UACJ;AAAA,uBACiBP,CAAO;AAAA,uBACPU,EAAU,QAAQ;AAAA,uBAClBA,EAAU,UAAU;AAAA,EAAA;AAE3C;AAEA,SAAST,IAAiD;AACxD,QAAMU,IACJ,SAAS,cAAc,8CAA8C,MAAM,MACvEC,IAAU,SACb,cAA+B,qBAAqB,GACnD,MAAM,MAAM,GAAG,EAAE,CAAC;AACtB,SAAOD,KAAeC,IAAUA,IAAU;AAC5C;AAEA,SAASb,EAAQc,GAAaC,GAAc;AAC1C,QAAMC,IAAM,OAAO,IAAIF,CAAG;AAC1B,SAAK,OAAeE,CAAG,IACd,MAEP,OAAeA,CAAG,IAAI,IACxBD,EAAA,GACO;AACT;"}