@inpageedit/core 0.13.1 → 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-DqA6EAM6.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 +318 -25
  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-BwdWyHLe.js.map +0 -1
  69. package/dist/index-CCRMmnwk.js.map +0 -1
  70. package/dist/index-CnIpUF9x.js +0 -173
  71. package/dist/index-CnIpUF9x.js.map +0 -1
  72. package/dist/index-CyG7_IYz.js +0 -394
  73. package/dist/index-CyG7_IYz.js.map +0 -1
  74. package/dist/index-DqA6EAM6.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
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
4
  import * as wiki_saikou1 from "wiki-saikou";
@@ -9,7 +9,7 @@ import "@inpageedit/modal/style.css";
9
9
  import { IDBPlus } from "idb-plus";
10
10
  import "@/styles/index.scss";
11
11
  import Schema, { default as Schema$1 } from "schemastery";
12
- import * as jsx_dom1 from "jsx-dom";
12
+ 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";
@@ -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
  */
@@ -1022,21 +1315,21 @@ declare function TabView({
1022
1315
  content: ReactNode;
1023
1316
  })[];
1024
1317
  defaultActiveIndex?: number;
1025
- }): jsx_dom1.ReactElement;
1318
+ }): jsx_dom0.ReactElement;
1026
1319
  declare function TabLabel({
1027
1320
  name,
1028
1321
  children
1029
1322
  }: {
1030
1323
  name: string;
1031
1324
  children: ReactNode;
1032
- }): jsx_dom1.ReactElement;
1325
+ }): jsx_dom0.ReactElement;
1033
1326
  declare function TabContent({
1034
1327
  name,
1035
1328
  children
1036
1329
  }: {
1037
1330
  name: string;
1038
1331
  children: ReactNode;
1039
- }): jsx_dom1.ReactElement;
1332
+ }): jsx_dom0.ReactElement;
1040
1333
  //#endregion
1041
1334
  //#region src/components/TwinSwapInput/index.d.ts
1042
1335
  type TwinSwapInputProps = {
@@ -1081,7 +1374,7 @@ type CheckBoxProps = {
1081
1374
  inputProps?: JSX.IntrinsicElements['input'];
1082
1375
  labelProps?: JSX.IntrinsicElements['span'];
1083
1376
  } & JSX.IntrinsicElements['label'];
1084
- declare const CheckBox: (props: CheckBoxProps) => jsx_dom1.ReactElement;
1377
+ declare const CheckBox: (props: CheckBoxProps) => jsx_dom0.ReactElement;
1085
1378
  //#endregion
1086
1379
  //#region src/components/InputBox.d.ts
1087
1380
  type InputBoxProps = {
@@ -1093,7 +1386,7 @@ type InputBoxProps = {
1093
1386
  labelProps?: JSX.IntrinsicElements['label'];
1094
1387
  inputProps?: JSX.IntrinsicElements['input'];
1095
1388
  } & JSX.IntrinsicElements['div'];
1096
- declare const InputBox: (props: InputBoxProps) => jsx_dom1.ReactElement;
1389
+ declare const InputBox: (props: InputBoxProps) => jsx_dom0.ReactElement;
1097
1390
  //#endregion
1098
1391
  //#region src/components/RadioBox.d.ts
1099
1392
  type RadioBoxProps = {
@@ -1104,7 +1397,7 @@ type RadioBoxProps = {
1104
1397
  inputProps?: JSX.IntrinsicElements['input'];
1105
1398
  labelProps?: JSX.IntrinsicElements['span'];
1106
1399
  } & JSX.IntrinsicElements['label'];
1107
- declare const RadioBox: (props: RadioBoxProps) => jsx_dom1.ReactElement;
1400
+ declare const RadioBox: (props: RadioBoxProps) => jsx_dom0.ReactElement;
1108
1401
  //#endregion
1109
1402
  //#region src/models/MemoryStorage.d.ts
1110
1403
  declare class MemoryStorage implements Storage {
@@ -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;
@@ -1718,7 +2011,7 @@ declare namespace index_d_exports$1 {
1718
2011
  export { AbstractIPEStorageManager, ApiService, ApiServiceOptions, CurrentPageService, CustomIPEModal, InPageEditPreferenceUICategory, InPageEditPreferenceUIRegistryItem, ModalService, PreferencesService, ResourceLoaderService, StorageService, StorageServiceConfig, TypedStorageEntry, WikiLinkMetadata, WikiMetadataService, WikiPageService, WikiTitleService };
1719
2012
  }
1720
2013
  declare namespace index_d_exports {
1721
- 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 };
1722
2015
  }
1723
2016
  declare global {
1724
2017
  const ipe: InPageEdit;
@@ -1754,4 +2047,4 @@ declare global {
1754
2047
  }
1755
2048
  }
1756
2049
  //#endregion
1757
- 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-DqA6EAM6.js";
2
- import { m as l, $ as g, S as m } from "./index-DqA6EAM6.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,Y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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,EAA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b,EAAQc,GAAaC,GAAc;AAC1C,QAAMC,IAAM,OAAO,IAAIF,CAAG;AAC1B,SAAK,OAAeE,CAAG,IACd,MAEP,OAAeA,CAAG,IAAI,IACxBD,EAAA,GACO;AACT;"}
@@ -1 +1 @@
1
- {"version":3,"file":"makeCallable-LDU0xZMJ.js","sources":["../src/utils/makeCallable.ts"],"sourcesContent":["export const CALLABLE_APPLY_SYMBOL = Symbol('@@apply')\r\nexport const CALLABLE_CTOR_SYMBOL = Symbol('@@ctor')\r\nexport function makeCallable<C extends object, M extends keyof C>(\r\n instance: C,\r\n method: M\r\n): C &\r\n ((\r\n ...args: C[M] extends (...a: infer P) => any ? P : never\r\n ) => C[M] extends (...a: any[]) => infer R ? R : never) {\r\n if (typeof instance !== 'object' || instance === null || Array.isArray(instance)) {\r\n throw new TypeError('instance is not an object')\r\n }\r\n\r\n const apply: any = (...args: any[]) => {\r\n const fn = (instance as any)[method]\r\n if (typeof fn !== 'function') {\r\n throw new TypeError(`Property \"${String(method)}\" is not a function`)\r\n }\r\n return fn.apply(instance, args)\r\n }\r\n apply[CALLABLE_APPLY_SYMBOL] = apply\r\n apply[CALLABLE_CTOR_SYMBOL] = instance\r\n\r\n const ctorName = (instance as any)?.constructor?.name\r\n if (ctorName) (apply as any)[Symbol.toStringTag] = ctorName\r\n\r\n const proxy = new Proxy(apply, {\r\n get(_, p, receiver) {\r\n if (p === 'prototype') return Reflect.get(apply, p, receiver)\r\n return Reflect.get(instance as any, p, instance)\r\n },\r\n set(_, p, v) {\r\n return Reflect.set(instance as any, p, v)\r\n },\r\n has(_, p) {\r\n return Reflect.has(instance as any, p)\r\n },\r\n deleteProperty(_, p) {\r\n return Reflect.deleteProperty(instance as any, p)\r\n },\r\n ownKeys() {\r\n return Reflect.ownKeys(instance as any)\r\n },\r\n getOwnPropertyDescriptor(_, p) {\r\n return Object.getOwnPropertyDescriptor(instance as any, p)\r\n },\r\n defineProperty(_, p, desc) {\r\n return Object.defineProperty(instance as any, p, desc)\r\n },\r\n })\r\n\r\n return proxy as unknown as any\r\n}\r\n"],"names":["CALLABLE_APPLY_SYMBOL","CALLABLE_CTOR_SYMBOL","makeCallable","instance","method","apply","args","fn","ctorName","_","p","receiver","v","desc"],"mappings":"AAAO,MAAMA,IAAwB,OAAO,SAAS,GACxCC,IAAuB,OAAO,QAAQ;AAC5C,SAASC,EACdC,GACAC,GAIwD;AACxD,MAAI,OAAOD,KAAa,YAAYA,MAAa,QAAQ,MAAM,QAAQA,CAAQ;AAC7E,UAAM,IAAI,UAAU,2BAA2B;AAGjD,QAAME,IAAa,IAAIC,MAAgB;AACrC,UAAMC,IAAMJ,EAAiBC,CAAM;AACnC,QAAI,OAAOG,KAAO;AAChB,YAAM,IAAI,UAAU,aAAa,OAAOH,CAAM,CAAC,qBAAqB;AAEtE,WAAOG,EAAG,MAAMJ,GAAUG,CAAI;AAAA,EAChC;AACA,EAAAD,EAAML,CAAqB,IAAIK,GAC/BA,EAAMJ,CAAoB,IAAIE;AAE9B,QAAMK,IAAYL,GAAkB,aAAa;AACjD,SAAIK,MAAWH,EAAc,OAAO,WAAW,IAAIG,IAErC,IAAI,MAAMH,GAAO;AAAA,IAC7B,IAAII,GAAGC,GAAGC,GAAU;AAClB,aAAID,MAAM,cAAoB,QAAQ,IAAIL,GAAOK,GAAGC,CAAQ,IACrD,QAAQ,IAAIR,GAAiBO,GAAGP,CAAQ;AAAA,IACjD;AAAA,IACA,IAAIM,GAAGC,GAAGE,GAAG;AACX,aAAO,QAAQ,IAAIT,GAAiBO,GAAGE,CAAC;AAAA,IAC1C;AAAA,IACA,IAAIH,GAAGC,GAAG;AACR,aAAO,QAAQ,IAAIP,GAAiBO,CAAC;AAAA,IACvC;AAAA,IACA,eAAeD,GAAGC,GAAG;AACnB,aAAO,QAAQ,eAAeP,GAAiBO,CAAC;AAAA,IAClD;AAAA,IACA,UAAU;AACR,aAAO,QAAQ,QAAQP,CAAe;AAAA,IACxC;AAAA,IACA,yBAAyBM,GAAGC,GAAG;AAC7B,aAAO,OAAO,yBAAyBP,GAAiBO,CAAC;AAAA,IAC3D;AAAA,IACA,eAAeD,GAAGC,GAAGG,GAAM;AACzB,aAAO,OAAO,eAAeV,GAAiBO,GAAGG,CAAI;AAAA,IACvD;AAAA,EAAA,CACD;AAGH;"}
1
+ {"version":3,"file":"makeCallable-LDU0xZMJ.js","sources":["../src/utils/makeCallable.ts"],"sourcesContent":["export const CALLABLE_APPLY_SYMBOL = Symbol('@@apply')\nexport const CALLABLE_CTOR_SYMBOL = Symbol('@@ctor')\nexport function makeCallable<C extends object, M extends keyof C>(\n instance: C,\n method: M\n): C &\n ((\n ...args: C[M] extends (...a: infer P) => any ? P : never\n ) => C[M] extends (...a: any[]) => infer R ? R : never) {\n if (typeof instance !== 'object' || instance === null || Array.isArray(instance)) {\n throw new TypeError('instance is not an object')\n }\n\n const apply: any = (...args: any[]) => {\n const fn = (instance as any)[method]\n if (typeof fn !== 'function') {\n throw new TypeError(`Property \"${String(method)}\" is not a function`)\n }\n return fn.apply(instance, args)\n }\n apply[CALLABLE_APPLY_SYMBOL] = apply\n apply[CALLABLE_CTOR_SYMBOL] = instance\n\n const ctorName = (instance as any)?.constructor?.name\n if (ctorName) (apply as any)[Symbol.toStringTag] = ctorName\n\n const proxy = new Proxy(apply, {\n get(_, p, receiver) {\n if (p === 'prototype') return Reflect.get(apply, p, receiver)\n return Reflect.get(instance as any, p, instance)\n },\n set(_, p, v) {\n return Reflect.set(instance as any, p, v)\n },\n has(_, p) {\n return Reflect.has(instance as any, p)\n },\n deleteProperty(_, p) {\n return Reflect.deleteProperty(instance as any, p)\n },\n ownKeys() {\n return Reflect.ownKeys(instance as any)\n },\n getOwnPropertyDescriptor(_, p) {\n return Object.getOwnPropertyDescriptor(instance as any, p)\n },\n defineProperty(_, p, desc) {\n return Object.defineProperty(instance as any, p, desc)\n },\n })\n\n return proxy as unknown as any\n}\n"],"names":["CALLABLE_APPLY_SYMBOL","CALLABLE_CTOR_SYMBOL","makeCall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