@miaixz/sdk 0.5.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 (244) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +7 -0
  3. package/README.md +412 -0
  4. package/dist/api/client.d.ts +223 -0
  5. package/dist/api/client.d.ts.map +1 -0
  6. package/dist/api/client.js +1069 -0
  7. package/dist/api/client.js.map +1 -0
  8. package/dist/api/endpoint.d.ts +10 -0
  9. package/dist/api/endpoint.d.ts.map +1 -0
  10. package/dist/api/endpoint.js +51 -0
  11. package/dist/api/endpoint.js.map +1 -0
  12. package/dist/api/errors.d.ts +180 -0
  13. package/dist/api/errors.d.ts.map +1 -0
  14. package/dist/api/errors.js +173 -0
  15. package/dist/api/errors.js.map +1 -0
  16. package/dist/api/index.d.ts +6 -0
  17. package/dist/api/index.d.ts.map +1 -0
  18. package/dist/api/index.js +5 -0
  19. package/dist/api/index.js.map +1 -0
  20. package/dist/api/request.d.ts +135 -0
  21. package/dist/api/request.d.ts.map +1 -0
  22. package/dist/api/request.js +2 -0
  23. package/dist/api/request.js.map +1 -0
  24. package/dist/api/response.d.ts +69 -0
  25. package/dist/api/response.d.ts.map +1 -0
  26. package/dist/api/response.js +43 -0
  27. package/dist/api/response.js.map +1 -0
  28. package/dist/api/telemetry.d.ts +139 -0
  29. package/dist/api/telemetry.d.ts.map +1 -0
  30. package/dist/api/telemetry.js +2 -0
  31. package/dist/api/telemetry.js.map +1 -0
  32. package/dist/appearance/appearance.d.ts +161 -0
  33. package/dist/appearance/appearance.d.ts.map +1 -0
  34. package/dist/appearance/appearance.js +614 -0
  35. package/dist/appearance/appearance.js.map +1 -0
  36. package/dist/appearance/index.d.ts +3 -0
  37. package/dist/appearance/index.d.ts.map +1 -0
  38. package/dist/appearance/index.js +3 -0
  39. package/dist/appearance/index.js.map +1 -0
  40. package/dist/auth/auth.d.ts +197 -0
  41. package/dist/auth/auth.d.ts.map +1 -0
  42. package/dist/auth/auth.js +314 -0
  43. package/dist/auth/auth.js.map +1 -0
  44. package/dist/auth/index.d.ts +2 -0
  45. package/dist/auth/index.d.ts.map +1 -0
  46. package/dist/auth/index.js +2 -0
  47. package/dist/auth/index.js.map +1 -0
  48. package/dist/config/config.d.ts +117 -0
  49. package/dist/config/config.d.ts.map +1 -0
  50. package/dist/config/config.js +241 -0
  51. package/dist/config/config.js.map +1 -0
  52. package/dist/config/index.d.ts +2 -0
  53. package/dist/config/index.d.ts.map +1 -0
  54. package/dist/config/index.js +2 -0
  55. package/dist/config/index.js.map +1 -0
  56. package/dist/consts/index.d.ts +35 -0
  57. package/dist/consts/index.d.ts.map +1 -0
  58. package/dist/consts/index.js +35 -0
  59. package/dist/consts/index.js.map +1 -0
  60. package/dist/context/context.d.ts +123 -0
  61. package/dist/context/context.d.ts.map +1 -0
  62. package/dist/context/context.js +252 -0
  63. package/dist/context/context.js.map +1 -0
  64. package/dist/context/index.d.ts +2 -0
  65. package/dist/context/index.d.ts.map +1 -0
  66. package/dist/context/index.js +2 -0
  67. package/dist/context/index.js.map +1 -0
  68. package/dist/contracts/host-context.d.ts +132 -0
  69. package/dist/contracts/host-context.d.ts.map +1 -0
  70. package/dist/contracts/host-context.js +2 -0
  71. package/dist/contracts/host-context.js.map +1 -0
  72. package/dist/contracts/index.d.ts +8 -0
  73. package/dist/contracts/index.d.ts.map +1 -0
  74. package/dist/contracts/index.js +2 -0
  75. package/dist/contracts/index.js.map +1 -0
  76. package/dist/contracts/lifecycle.d.ts +49 -0
  77. package/dist/contracts/lifecycle.d.ts.map +1 -0
  78. package/dist/contracts/lifecycle.js +2 -0
  79. package/dist/contracts/lifecycle.js.map +1 -0
  80. package/dist/contracts/module-manifest.d.ts +110 -0
  81. package/dist/contracts/module-manifest.d.ts.map +1 -0
  82. package/dist/contracts/module-manifest.js +317 -0
  83. package/dist/contracts/module-manifest.js.map +1 -0
  84. package/dist/contracts/navigation.d.ts +36 -0
  85. package/dist/contracts/navigation.d.ts.map +1 -0
  86. package/dist/contracts/navigation.js +11 -0
  87. package/dist/contracts/navigation.js.map +1 -0
  88. package/dist/contracts/permission.d.ts +8 -0
  89. package/dist/contracts/permission.d.ts.map +1 -0
  90. package/dist/contracts/permission.js +14 -0
  91. package/dist/contracts/permission.js.map +1 -0
  92. package/dist/contracts/post-message.d.ts +124 -0
  93. package/dist/contracts/post-message.d.ts.map +1 -0
  94. package/dist/contracts/post-message.js +2 -0
  95. package/dist/contracts/post-message.js.map +1 -0
  96. package/dist/contracts/route.d.ts +45 -0
  97. package/dist/contracts/route.d.ts.map +1 -0
  98. package/dist/contracts/route.js +35 -0
  99. package/dist/contracts/route.js.map +1 -0
  100. package/dist/events/events.d.ts +191 -0
  101. package/dist/events/events.d.ts.map +1 -0
  102. package/dist/events/events.js +486 -0
  103. package/dist/events/events.js.map +1 -0
  104. package/dist/events/index.d.ts +2 -0
  105. package/dist/events/index.d.ts.map +1 -0
  106. package/dist/events/index.js +2 -0
  107. package/dist/events/index.js.map +1 -0
  108. package/dist/files/files.d.ts +138 -0
  109. package/dist/files/files.d.ts.map +1 -0
  110. package/dist/files/files.js +144 -0
  111. package/dist/files/files.js.map +1 -0
  112. package/dist/files/index.d.ts +2 -0
  113. package/dist/files/index.d.ts.map +1 -0
  114. package/dist/files/index.js +2 -0
  115. package/dist/files/index.js.map +1 -0
  116. package/dist/formatters/index.d.ts +44 -0
  117. package/dist/formatters/index.d.ts.map +1 -0
  118. package/dist/formatters/index.js +50 -0
  119. package/dist/formatters/index.js.map +1 -0
  120. package/dist/i18n/default-translator.d.ts +17 -0
  121. package/dist/i18n/default-translator.d.ts.map +1 -0
  122. package/dist/i18n/default-translator.js +19 -0
  123. package/dist/i18n/default-translator.js.map +1 -0
  124. package/dist/i18n/i18n.d.ts +248 -0
  125. package/dist/i18n/i18n.d.ts.map +1 -0
  126. package/dist/i18n/i18n.js +617 -0
  127. package/dist/i18n/i18n.js.map +1 -0
  128. package/dist/i18n/index.d.ts +2 -0
  129. package/dist/i18n/index.d.ts.map +1 -0
  130. package/dist/i18n/index.js +2 -0
  131. package/dist/i18n/index.js.map +1 -0
  132. package/dist/index.d.ts +19 -0
  133. package/dist/index.d.ts.map +1 -0
  134. package/dist/index.js +19 -0
  135. package/dist/index.js.map +1 -0
  136. package/dist/models/index.d.ts +2 -0
  137. package/dist/models/index.d.ts.map +1 -0
  138. package/dist/models/index.js +2 -0
  139. package/dist/models/index.js.map +1 -0
  140. package/dist/permissions/index.d.ts +2 -0
  141. package/dist/permissions/index.d.ts.map +1 -0
  142. package/dist/permissions/index.js +2 -0
  143. package/dist/permissions/index.js.map +1 -0
  144. package/dist/permissions/permissions.d.ts +67 -0
  145. package/dist/permissions/permissions.d.ts.map +1 -0
  146. package/dist/permissions/permissions.js +123 -0
  147. package/dist/permissions/permissions.js.map +1 -0
  148. package/dist/runtime/direct-host-bridge.d.ts +11 -0
  149. package/dist/runtime/direct-host-bridge.d.ts.map +1 -0
  150. package/dist/runtime/direct-host-bridge.js +299 -0
  151. package/dist/runtime/direct-host-bridge.js.map +1 -0
  152. package/dist/runtime/index.d.ts +5 -0
  153. package/dist/runtime/index.d.ts.map +1 -0
  154. package/dist/runtime/index.js +3 -0
  155. package/dist/runtime/index.js.map +1 -0
  156. package/dist/runtime/post-message-bridge.d.ts +20 -0
  157. package/dist/runtime/post-message-bridge.d.ts.map +1 -0
  158. package/dist/runtime/post-message-bridge.js +1115 -0
  159. package/dist/runtime/post-message-bridge.js.map +1 -0
  160. package/dist/sdk.d.ts +177 -0
  161. package/dist/sdk.d.ts.map +1 -0
  162. package/dist/sdk.js +214 -0
  163. package/dist/sdk.js.map +1 -0
  164. package/dist/storage/index.d.ts +2 -0
  165. package/dist/storage/index.d.ts.map +1 -0
  166. package/dist/storage/index.js +2 -0
  167. package/dist/storage/index.js.map +1 -0
  168. package/dist/storage/storage.d.ts +246 -0
  169. package/dist/storage/storage.d.ts.map +1 -0
  170. package/dist/storage/storage.js +358 -0
  171. package/dist/storage/storage.js.map +1 -0
  172. package/dist/types/api.d.ts +82 -0
  173. package/dist/types/api.d.ts.map +1 -0
  174. package/dist/types/api.js +2 -0
  175. package/dist/types/api.js.map +1 -0
  176. package/dist/types/appearance.d.ts +85 -0
  177. package/dist/types/appearance.d.ts.map +1 -0
  178. package/dist/types/appearance.js +48 -0
  179. package/dist/types/appearance.js.map +1 -0
  180. package/dist/types/config.d.ts +49 -0
  181. package/dist/types/config.d.ts.map +1 -0
  182. package/dist/types/config.js +2 -0
  183. package/dist/types/config.js.map +1 -0
  184. package/dist/types/context.d.ts +41 -0
  185. package/dist/types/context.d.ts.map +1 -0
  186. package/dist/types/context.js +2 -0
  187. package/dist/types/context.js.map +1 -0
  188. package/dist/types/file.d.ts +48 -0
  189. package/dist/types/file.d.ts.map +1 -0
  190. package/dist/types/file.js +2 -0
  191. package/dist/types/file.js.map +1 -0
  192. package/dist/types/index.d.ts +12 -0
  193. package/dist/types/index.d.ts.map +1 -0
  194. package/dist/types/index.js +12 -0
  195. package/dist/types/index.js.map +1 -0
  196. package/dist/types/organization.d.ts +56 -0
  197. package/dist/types/organization.d.ts.map +1 -0
  198. package/dist/types/organization.js +2 -0
  199. package/dist/types/organization.js.map +1 -0
  200. package/dist/types/pagination.d.ts +55 -0
  201. package/dist/types/pagination.d.ts.map +1 -0
  202. package/dist/types/pagination.js +13 -0
  203. package/dist/types/pagination.js.map +1 -0
  204. package/dist/types/permissions.d.ts +26 -0
  205. package/dist/types/permissions.d.ts.map +1 -0
  206. package/dist/types/permissions.js +2 -0
  207. package/dist/types/permissions.js.map +1 -0
  208. package/dist/types/space.d.ts +43 -0
  209. package/dist/types/space.d.ts.map +1 -0
  210. package/dist/types/space.js +2 -0
  211. package/dist/types/space.js.map +1 -0
  212. package/dist/types/tenant.d.ts +31 -0
  213. package/dist/types/tenant.d.ts.map +1 -0
  214. package/dist/types/tenant.js +2 -0
  215. package/dist/types/tenant.js.map +1 -0
  216. package/dist/types/user.d.ts +48 -0
  217. package/dist/types/user.d.ts.map +1 -0
  218. package/dist/types/user.js +2 -0
  219. package/dist/types/user.js.map +1 -0
  220. package/dist/utils/date.d.ts +9 -0
  221. package/dist/utils/date.d.ts.map +1 -0
  222. package/dist/utils/date.js +11 -0
  223. package/dist/utils/date.js.map +1 -0
  224. package/dist/utils/index.d.ts +5 -0
  225. package/dist/utils/index.d.ts.map +1 -0
  226. package/dist/utils/index.js +5 -0
  227. package/dist/utils/index.js.map +1 -0
  228. package/dist/utils/number.d.ts +11 -0
  229. package/dist/utils/number.d.ts.map +1 -0
  230. package/dist/utils/number.js +13 -0
  231. package/dist/utils/number.js.map +1 -0
  232. package/dist/utils/object.d.ts +9 -0
  233. package/dist/utils/object.d.ts.map +1 -0
  234. package/dist/utils/object.js +11 -0
  235. package/dist/utils/object.js.map +1 -0
  236. package/dist/utils/string.d.ts +9 -0
  237. package/dist/utils/string.d.ts.map +1 -0
  238. package/dist/utils/string.js +11 -0
  239. package/dist/utils/string.js.map +1 -0
  240. package/dist/validators/index.d.ts +8 -0
  241. package/dist/validators/index.d.ts.map +1 -0
  242. package/dist/validators/index.js +8 -0
  243. package/dist/validators/index.js.map +1 -0
  244. package/package.json +156 -0
@@ -0,0 +1,124 @@
1
+ import type { MiaixzHostAdapter } from "./host-context.js";
2
+ import type { MiaixzModuleManifest } from "./module-manifest.js";
3
+ /**
4
+ * Describes one validated cross-origin Bridge message.
5
+ *
6
+ * @public
7
+ */
8
+ export interface MiaixzBridgeEnvelope {
9
+ /**
10
+ * Identifies the Miaixz Bridge transport.
11
+ */
12
+ readonly channel: "miaixz.bridge";
13
+ /**
14
+ * Identifies the Bridge protocol version.
15
+ */
16
+ readonly protocolVersion: "1.0.0";
17
+ /**
18
+ * Correlates requests, responses, events, and cancellation messages.
19
+ */
20
+ readonly messageId: string;
21
+ /**
22
+ * Identifies the module owning the connection.
23
+ */
24
+ readonly moduleId: string;
25
+ /**
26
+ * Selects the message state-machine branch.
27
+ */
28
+ readonly kind: "request" | "response" | "event" | "cancel";
29
+ /**
30
+ * Identifies the allow-listed Bridge operation.
31
+ */
32
+ readonly method: string;
33
+ /**
34
+ * Contains the validated method payload when present.
35
+ */
36
+ readonly payload?: unknown;
37
+ /**
38
+ * Contains a safe remote SDK error when the request failed.
39
+ */
40
+ readonly error?: Readonly<{
41
+ /**
42
+ * Stable SDK error code.
43
+ */
44
+ code: string;
45
+ /**
46
+ * Registered internationalization message key.
47
+ */
48
+ messageKey: string;
49
+ /**
50
+ * Optional already-redacted diagnostic details.
51
+ */
52
+ details?: unknown;
53
+ }>;
54
+ }
55
+ /**
56
+ * Configures the Host side of one iframe postMessage Bridge.
57
+ *
58
+ * @public
59
+ */
60
+ export interface MiaixzPostMessageHostOptions {
61
+ /**
62
+ * Supplies the validated iframe module manifest.
63
+ */
64
+ readonly manifest: Readonly<MiaixzModuleManifest>;
65
+ /**
66
+ * Supplies the exact iframe content Window receiving Host messages.
67
+ */
68
+ readonly targetWindow: Window;
69
+ /**
70
+ * Supplies the single allowed iframe origin.
71
+ */
72
+ readonly targetOrigin: string;
73
+ /**
74
+ * Supplies the Host capabilities exposed to the iframe.
75
+ */
76
+ readonly adapter: MiaixzHostAdapter;
77
+ /**
78
+ * Overrides the ten-second request and handshake timeout.
79
+ */
80
+ readonly timeoutMs?: number;
81
+ }
82
+ /**
83
+ * Represents the lifecycle of one Host-side postMessage connection.
84
+ *
85
+ * @public
86
+ */
87
+ export interface MiaixzPostMessageHost {
88
+ /**
89
+ * Resolves after an accepted handshake or rejects on startup failure.
90
+ */
91
+ readonly ready: Promise<void>;
92
+ /**
93
+ * Releases the Host listener, subscriptions, and pending work.
94
+ */
95
+ dispose(): void;
96
+ }
97
+ /**
98
+ * Configures the Child side of one iframe postMessage Bridge.
99
+ *
100
+ * @public
101
+ */
102
+ export interface MiaixzPostMessageChildOptions {
103
+ /**
104
+ * Identifies the iframe module opening the connection.
105
+ */
106
+ readonly moduleId: string;
107
+ /**
108
+ * Identifies the complete semantic version of the iframe module.
109
+ */
110
+ readonly moduleVersion: string;
111
+ /**
112
+ * Supplies the exact parent Window receiving Child messages.
113
+ */
114
+ readonly targetWindow: Window;
115
+ /**
116
+ * Supplies the single allowed parent origin.
117
+ */
118
+ readonly targetOrigin: string;
119
+ /**
120
+ * Overrides the ten-second request and handshake timeout.
121
+ */
122
+ readonly timeoutMs?: number;
123
+ }
124
+ //# sourceMappingURL=post-message.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-message.d.ts","sourceRoot":"","sources":["../../src/contracts/post-message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAoB,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,OAAO,CAAC;IAElC;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,UAAU,GAAG,OAAO,GAAG,QAAQ,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAExB;;OAEG;IACH,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAE3B;;OAEG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,QAAQ,CAAC;QACxB;;WAEG;QACH,IAAI,EAAE,MAAM,CAAC;QAEb;;WAEG;QACH,UAAU,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC,CAAC;CACJ;AAED;;;;GAIG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAElD;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,iBAAiB,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAE9B;;OAEG;IACH,OAAO,IAAI,IAAI,CAAC;CACjB;AAED;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAE/B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAE9B;;OAEG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=post-message.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"post-message.js","sourceRoot":"","sources":["../../src/contracts/post-message.ts"],"names":[],"mappings":"","sourcesContent":["import type { MiaixzHostAdapter, MiaixzHostBridge } from \"./host-context.js\";\nimport type { MiaixzModuleManifest } from \"./module-manifest.js\";\n\n/**\n * Describes one validated cross-origin Bridge message.\n *\n * @public\n */\nexport interface MiaixzBridgeEnvelope {\n /**\n * Identifies the Miaixz Bridge transport.\n */\n readonly channel: \"miaixz.bridge\";\n\n /**\n * Identifies the Bridge protocol version.\n */\n readonly protocolVersion: \"1.0.0\";\n\n /**\n * Correlates requests, responses, events, and cancellation messages.\n */\n readonly messageId: string;\n\n /**\n * Identifies the module owning the connection.\n */\n readonly moduleId: string;\n\n /**\n * Selects the message state-machine branch.\n */\n readonly kind: \"request\" | \"response\" | \"event\" | \"cancel\";\n\n /**\n * Identifies the allow-listed Bridge operation.\n */\n readonly method: string;\n\n /**\n * Contains the validated method payload when present.\n */\n readonly payload?: unknown;\n\n /**\n * Contains a safe remote SDK error when the request failed.\n */\n readonly error?: Readonly<{\n /**\n * Stable SDK error code.\n */\n code: string;\n\n /**\n * Registered internationalization message key.\n */\n messageKey: string;\n\n /**\n * Optional already-redacted diagnostic details.\n */\n details?: unknown;\n }>;\n}\n\n/**\n * Configures the Host side of one iframe postMessage Bridge.\n *\n * @public\n */\nexport interface MiaixzPostMessageHostOptions {\n /**\n * Supplies the validated iframe module manifest.\n */\n readonly manifest: Readonly<MiaixzModuleManifest>;\n\n /**\n * Supplies the exact iframe content Window receiving Host messages.\n */\n readonly targetWindow: Window;\n\n /**\n * Supplies the single allowed iframe origin.\n */\n readonly targetOrigin: string;\n\n /**\n * Supplies the Host capabilities exposed to the iframe.\n */\n readonly adapter: MiaixzHostAdapter;\n\n /**\n * Overrides the ten-second request and handshake timeout.\n */\n readonly timeoutMs?: number;\n}\n\n/**\n * Represents the lifecycle of one Host-side postMessage connection.\n *\n * @public\n */\nexport interface MiaixzPostMessageHost {\n /**\n * Resolves after an accepted handshake or rejects on startup failure.\n */\n readonly ready: Promise<void>;\n\n /**\n * Releases the Host listener, subscriptions, and pending work.\n */\n dispose(): void;\n}\n\n/**\n * Configures the Child side of one iframe postMessage Bridge.\n *\n * @public\n */\nexport interface MiaixzPostMessageChildOptions {\n /**\n * Identifies the iframe module opening the connection.\n */\n readonly moduleId: string;\n\n /**\n * Identifies the complete semantic version of the iframe module.\n */\n readonly moduleVersion: string;\n\n /**\n * Supplies the exact parent Window receiving Child messages.\n */\n readonly targetWindow: Window;\n\n /**\n * Supplies the single allowed parent origin.\n */\n readonly targetOrigin: string;\n\n /**\n * Overrides the ten-second request and handshake timeout.\n */\n readonly timeoutMs?: number;\n}\n"]}
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Describes a route contributed by a remotely loaded Miaixz module.
3
+ *
4
+ * @public
5
+ */
6
+ export interface MiaixzModuleRoute {
7
+ /**
8
+ * Module-local route identifier.
9
+ */
10
+ readonly id: string;
11
+ /**
12
+ * Slash-relative path joined to the module base path.
13
+ */
14
+ readonly path: string;
15
+ /**
16
+ * Internationalization key used for the route title.
17
+ */
18
+ readonly titleKey: string;
19
+ /**
20
+ * Optional permissions required before the route is made available.
21
+ */
22
+ readonly requiredPermissions?: readonly string[];
23
+ }
24
+ /**
25
+ * Validates IDs used by modules, routes, and navigation items.
26
+ *
27
+ * @param value - Identifier candidate to inspect.
28
+ * @returns Whether the value satisfies the frozen kebab-case identifier grammar.
29
+ */
30
+ export declare function isMiaixzModuleIdentifier(value: unknown): value is string;
31
+ /**
32
+ * Validates a module base path or slash-relative route path.
33
+ *
34
+ * @param value - Path candidate to inspect.
35
+ * @returns Whether the path is static, absolute-path-shaped, and normalized.
36
+ */
37
+ export declare function isMiaixzModulePath(value: unknown): value is string;
38
+ /**
39
+ * Validates the required-permission list attached to a route or manifest.
40
+ *
41
+ * @param value - Permission-list candidate to inspect.
42
+ * @returns Whether every item is a non-wildcard module permission.
43
+ */
44
+ export declare function isMiaixzModulePermissionList(value: unknown): value is readonly string[];
45
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../src/contracts/route.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAUlE;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,MAAM,EAAE,CAEvF"}
@@ -0,0 +1,35 @@
1
+ import { isMiaixzModulePermission } from "./permission.js";
2
+ /**
3
+ * Validates IDs used by modules, routes, and navigation items.
4
+ *
5
+ * @param value - Identifier candidate to inspect.
6
+ * @returns Whether the value satisfies the frozen kebab-case identifier grammar.
7
+ */
8
+ export function isMiaixzModuleIdentifier(value) {
9
+ return typeof value === "string" && /^[a-z][a-z0-9-]{1,63}$/.test(value);
10
+ }
11
+ /**
12
+ * Validates a module base path or slash-relative route path.
13
+ *
14
+ * @param value - Path candidate to inspect.
15
+ * @returns Whether the path is static, absolute-path-shaped, and normalized.
16
+ */
17
+ export function isMiaixzModulePath(value) {
18
+ return (typeof value === "string" &&
19
+ value.startsWith("/") &&
20
+ !value.startsWith("//") &&
21
+ (value === "/" || !value.endsWith("/")) &&
22
+ !value.includes(":") &&
23
+ !value.includes("?") &&
24
+ !value.includes("#"));
25
+ }
26
+ /**
27
+ * Validates the required-permission list attached to a route or manifest.
28
+ *
29
+ * @param value - Permission-list candidate to inspect.
30
+ * @returns Whether every item is a non-wildcard module permission.
31
+ */
32
+ export function isMiaixzModulePermissionList(value) {
33
+ return Array.isArray(value) && value.every(isMiaixzModulePermission);
34
+ }
35
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../src/contracts/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AA6B3D;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAc;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAAc;IAC/C,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;QACrB,CAAC,KAAK,CAAC,UAAU,CAAC,IAAI,CAAC;QACvB,CAAC,KAAK,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACpB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;QACpB,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CACrB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAAc;IACzD,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;AACvE,CAAC","sourcesContent":["import { isMiaixzModulePermission } from \"./permission.js\";\n\n/**\n * Describes a route contributed by a remotely loaded Miaixz module.\n *\n * @public\n */\nexport interface MiaixzModuleRoute {\n /**\n * Module-local route identifier.\n */\n readonly id: string;\n\n /**\n * Slash-relative path joined to the module base path.\n */\n readonly path: string;\n\n /**\n * Internationalization key used for the route title.\n */\n readonly titleKey: string;\n\n /**\n * Optional permissions required before the route is made available.\n */\n readonly requiredPermissions?: readonly string[];\n}\n\n/**\n * Validates IDs used by modules, routes, and navigation items.\n *\n * @param value - Identifier candidate to inspect.\n * @returns Whether the value satisfies the frozen kebab-case identifier grammar.\n */\nexport function isMiaixzModuleIdentifier(value: unknown): value is string {\n return typeof value === \"string\" && /^[a-z][a-z0-9-]{1,63}$/.test(value);\n}\n\n/**\n * Validates a module base path or slash-relative route path.\n *\n * @param value - Path candidate to inspect.\n * @returns Whether the path is static, absolute-path-shaped, and normalized.\n */\nexport function isMiaixzModulePath(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.startsWith(\"/\") &&\n !value.startsWith(\"//\") &&\n (value === \"/\" || !value.endsWith(\"/\")) &&\n !value.includes(\":\") &&\n !value.includes(\"?\") &&\n !value.includes(\"#\")\n );\n}\n\n/**\n * Validates the required-permission list attached to a route or manifest.\n *\n * @param value - Permission-list candidate to inspect.\n * @returns Whether every item is a non-wildcard module permission.\n */\nexport function isMiaixzModulePermissionList(value: unknown): value is readonly string[] {\n return Array.isArray(value) && value.every(isMiaixzModulePermission);\n}\n"]}
@@ -0,0 +1,191 @@
1
+ import { type MiaixzLocale } from "../i18n/index.js";
2
+ import type { MiaixzAppearancePayload, MiaixzRuntimeContext, MiaixzSdkConfig } from "../types/index.js";
3
+ /**
4
+ * Validates an untrusted event payload before it crosses a browser-context boundary.
5
+ *
6
+ * @public
7
+ */
8
+ export type MiaixzEventValidator = (payload: unknown) => boolean;
9
+ /**
10
+ * Describes the only authentication state that may cross an SDK event channel.
11
+ *
12
+ * @public
13
+ */
14
+ export interface MiaixzAuthStatusEvent {
15
+ /**
16
+ * Reports whether credentials exist without exposing a session or token.
17
+ */
18
+ readonly status: "authenticated" | "anonymous";
19
+ }
20
+ /**
21
+ * Describes a locale change shared between same-origin application instances.
22
+ *
23
+ * @public
24
+ */
25
+ export interface MiaixzLocaleChangedEvent {
26
+ /**
27
+ * Contains the canonical or otherwise valid BCP 47 locale to activate.
28
+ */
29
+ readonly locale: MiaixzLocale;
30
+ }
31
+ /**
32
+ * Maps built-in SDK event names to their payload types.
33
+ *
34
+ * @public
35
+ */
36
+ export interface MiaixzSdkEventMap {
37
+ /**
38
+ * Contains a non-sensitive authentication invalidation signal.
39
+ */
40
+ readonly "auth:changed": Readonly<MiaixzAuthStatusEvent>;
41
+ /**
42
+ * Contains the runtime-context snapshot after it changes.
43
+ */
44
+ readonly "context:changed": Readonly<MiaixzRuntimeContext>;
45
+ /**
46
+ * Contains the versioned appearance snapshot after it changes.
47
+ */
48
+ readonly "appearance:changed": Readonly<MiaixzAppearancePayload>;
49
+ /**
50
+ * Contains the active locale after it changes.
51
+ */
52
+ readonly "locale:changed": Readonly<MiaixzLocaleChangedEvent>;
53
+ /**
54
+ * Contains the SDK configuration snapshot after it changes.
55
+ */
56
+ readonly "config:changed": Readonly<MiaixzSdkConfig>;
57
+ }
58
+ /**
59
+ * Configures local and optional same-origin cross-tab event delivery.
60
+ *
61
+ * @public
62
+ */
63
+ export interface MiaixzEventBusOptions {
64
+ /**
65
+ * Selects a validated BroadcastChannel name, or disables cross-tab delivery.
66
+ *
67
+ * @defaultValue false
68
+ */
69
+ readonly channelName?: string | false;
70
+ /**
71
+ * Supplies runtime validators for application-defined event names.
72
+ */
73
+ readonly validators?: Readonly<Record<string, MiaixzEventValidator>>;
74
+ /**
75
+ * Creates a BroadcastChannel for tests or compatible custom browser runtimes.
76
+ */
77
+ readonly broadcastChannelFactory?: (name: string) => BroadcastChannel;
78
+ }
79
+ /**
80
+ * Defines the only envelope accepted over a Miaixz BroadcastChannel.
81
+ *
82
+ * @public
83
+ */
84
+ export interface MiaixzEventEnvelope {
85
+ /**
86
+ * Identifies the frozen event-envelope schema.
87
+ */
88
+ readonly version: 1;
89
+ /**
90
+ * Uniquely identifies one broadcast operation for deduplication.
91
+ */
92
+ readonly eventId: string;
93
+ /**
94
+ * Identifies the event-bus instance that originated the message.
95
+ */
96
+ readonly sourceId: string;
97
+ /**
98
+ * Names the typed event represented by the payload.
99
+ */
100
+ readonly type: string;
101
+ /**
102
+ * Contains untrusted data that must pass the registered runtime validator.
103
+ */
104
+ readonly payload: unknown;
105
+ }
106
+ /**
107
+ * Configures one event publication.
108
+ *
109
+ * @public
110
+ */
111
+ export interface MiaixzEventEmitOptions {
112
+ /**
113
+ * Indicates whether a locally dispatched event may also cross the configured channel.
114
+ *
115
+ * @defaultValue true
116
+ */
117
+ readonly broadcast?: boolean;
118
+ }
119
+ /**
120
+ * Extracts string event names from an event map.
121
+ *
122
+ * @public
123
+ */
124
+ export type MiaixzEventName<Events extends object> = Extract<keyof Events, string>;
125
+ /**
126
+ * Receives a typed event payload.
127
+ *
128
+ * @public
129
+ */
130
+ export type MiaixzEventListener<T> = (payload: T) => void;
131
+ /**
132
+ * Typed local and optional same-origin cross-tab event bus.
133
+ *
134
+ * @typeParam Events - Event-name map whose values define payload types.
135
+ * @public
136
+ */
137
+ export declare class MiaixzEventBus<Events extends object = MiaixzSdkEventMap> {
138
+ #private;
139
+ /**
140
+ * Creates a local-first event bus and an optional validated BroadcastChannel.
141
+ *
142
+ * @param options - Channel factory and application-defined runtime validators.
143
+ * @throws MiaixzSdkError When an explicit channel name or secure UUID capability is invalid.
144
+ */
145
+ constructor(options?: MiaixzEventBusOptions);
146
+ /**
147
+ * Registers a typed listener and returns its unsubscribe function.
148
+ *
149
+ * @param type - Event name to observe.
150
+ * @param listener - Callback invoked with the typed event payload.
151
+ * @returns Function that unregisters the listener, or a no-op after closure.
152
+ */
153
+ on<Name extends MiaixzEventName<Events>>(type: Name, listener: MiaixzEventListener<Events[Name]>): () => void;
154
+ /**
155
+ * Registers a typed listener that is removed after its first event.
156
+ *
157
+ * @param type - Event name to observe once.
158
+ * @param listener - Callback invoked with the typed event payload.
159
+ * @returns Function that unregisters the listener before delivery.
160
+ */
161
+ once<Name extends MiaixzEventName<Events>>(type: Name, listener: MiaixzEventListener<Events[Name]>): () => void;
162
+ /**
163
+ * Publishes an event synchronously to local listeners before optional cross-tab delivery.
164
+ *
165
+ * @param type - Event name to publish.
166
+ * @param payload - Typed event payload.
167
+ * @param options - Optional cross-tab publication behavior.
168
+ * @throws MiaixzSdkError When the bus is closed, a required validator is missing, cloning fails, or secure UUIDs are unavailable.
169
+ */
170
+ emit<Name extends MiaixzEventName<Events>>(type: Name, payload: Events[Name], options?: Readonly<MiaixzEventEmitOptions>): void;
171
+ /**
172
+ * Removes listeners for one event type or all event types.
173
+ *
174
+ * @param type - Optional event name whose listeners should be removed.
175
+ */
176
+ clear(type?: MiaixzEventName<Events>): void;
177
+ /**
178
+ * Removes listeners and deduplication state, then closes the underlying channel once.
179
+ */
180
+ close(): void;
181
+ }
182
+ /**
183
+ * Creates a typed local-first event bus with optional same-origin cross-tab delivery.
184
+ *
185
+ * @typeParam Events - Event-name map whose values define payload types.
186
+ * @param options - Optional channel and runtime-validator configuration.
187
+ * @returns Configured typed event bus.
188
+ * @public
189
+ */
190
+ export declare function createMiaixzEventBus<Events extends object = MiaixzSdkEventMap>(options?: MiaixzEventBusOptions): MiaixzEventBus<Events>;
191
+ //# sourceMappingURL=events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/events/events.ts"],"names":[],"mappings":"AAIA,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACpB,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC;AAEjE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,WAAW,CAAC;CAChD;AAED;;;;GAIG;AACH,MAAM,WAAW,wBAAwB;IACvC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC;;OAEG;IACH,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,qBAAqB,CAAC,CAAC;IAEzD;;OAEG;IACH,QAAQ,CAAC,iBAAiB,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IAE3D;;OAEG;IACH,QAAQ,CAAC,oBAAoB,EAAE,QAAQ,CAAC,uBAAuB,CAAC,CAAC;IAEjE;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,wBAAwB,CAAC,CAAC;IAE9D;;OAEG;IACH,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;CACtD;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,KAAK,CAAC;IAEtC;;OAEG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC,CAAC;IAErE;;OAEG;IACH,QAAQ,CAAC,uBAAuB,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,gBAAgB,CAAC;CACvE;AAED;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAEpB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;CAC9B;AAED;;;;GAIG;AACH,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,MAAM,IAAI,OAAO,CAAC,MAAM,MAAM,EAAE,MAAM,CAAC,CAAC;AAEnF;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,CAAC;AAiT1D;;;;;GAKG;AACH,qBAAa,cAAc,CAAC,MAAM,SAAS,MAAM,GAAG,iBAAiB;;IASnE;;;;;OAKG;IACH,YAAY,OAAO,GAAE,qBAA0B,EAuC9C;IAED;;;;;;OAMG;IACH,EAAE,CAAC,IAAI,SAAS,eAAe,CAAC,MAAM,CAAC,EACrC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAC1C,MAAM,IAAI,CASZ;IAED;;;;;;OAMG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,CAAC,MAAM,CAAC,EACvC,IAAI,EAAE,IAAI,EACV,QAAQ,EAAE,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAC1C,MAAM,IAAI,CAOZ;IAED;;;;;;;OAOG;IACH,IAAI,CAAC,IAAI,SAAS,eAAe,CAAC,MAAM,CAAC,EACvC,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,EACrB,OAAO,GAAE,QAAQ,CAAC,sBAAsB,CAAM,GAC7C,IAAI,CA4BN;IAED;;;;OAIG;IACH,KAAK,CAAC,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,GAAG,IAAI,CAG1C;IAED;;OAEG;IACH,KAAK,IAAI,IAAI,CASZ;CA8CF;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,SAAS,MAAM,GAAG,iBAAiB,EAC5E,OAAO,CAAC,EAAE,qBAAqB,GAC9B,cAAc,CAAC,MAAM,CAAC,CAExB"}