@bytechain.cn/colamd 1.5.0 → 1.5.1-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (193) hide show
  1. package/.trae/specs/optimize-theme-loading/checklist.md +20 -0
  2. package/.trae/specs/optimize-theme-loading/spec.md +103 -0
  3. package/.trae/specs/optimize-theme-loading/tasks.md +40 -0
  4. package/CHANGELOG.md +323 -0
  5. package/CLAUDE.md +56 -0
  6. package/README.md +422 -26
  7. package/README_CN.md +480 -28
  8. package/android/app/build/.npmkeep +0 -0
  9. package/android/app/build.gradle +76 -0
  10. package/android/app/capacitor.build.gradle +24 -0
  11. package/android/app/proguard-rules.pro +21 -0
  12. package/android/app/release.keystore +0 -0
  13. package/android/app/src/androidTest/java/com/getcapacitor/myapp/ExampleInstrumentedTest.java +26 -0
  14. package/android/app/src/main/AndroidManifest.xml +64 -0
  15. package/android/app/src/main/java/cn/bytechain/colamd/MainActivity.java +180 -0
  16. package/android/app/src/main/res/drawable/ic_launcher_background.xml +170 -0
  17. package/android/app/src/main/res/drawable/splash.png +0 -0
  18. package/android/app/src/main/res/drawable-land-hdpi/splash.png +0 -0
  19. package/android/app/src/main/res/drawable-land-mdpi/splash.png +0 -0
  20. package/android/app/src/main/res/drawable-land-xhdpi/splash.png +0 -0
  21. package/android/app/src/main/res/drawable-land-xxhdpi/splash.png +0 -0
  22. package/android/app/src/main/res/drawable-land-xxxhdpi/splash.png +0 -0
  23. package/android/app/src/main/res/drawable-port-hdpi/splash.png +0 -0
  24. package/android/app/src/main/res/drawable-port-mdpi/splash.png +0 -0
  25. package/android/app/src/main/res/drawable-port-xhdpi/splash.png +0 -0
  26. package/android/app/src/main/res/drawable-port-xxhdpi/splash.png +0 -0
  27. package/android/app/src/main/res/drawable-port-xxxhdpi/splash.png +0 -0
  28. package/android/app/src/main/res/drawable-v24/ic_launcher_foreground.xml +34 -0
  29. package/android/app/src/main/res/layout/activity_main.xml +12 -0
  30. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml +5 -0
  31. package/android/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml +5 -0
  32. package/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  33. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_foreground.png +0 -0
  34. package/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  35. package/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  36. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_foreground.png +0 -0
  37. package/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  38. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  39. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_foreground.png +0 -0
  40. package/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  41. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  42. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_foreground.png +0 -0
  43. package/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  44. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  45. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_foreground.png +0 -0
  46. package/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  47. package/android/app/src/main/res/values/ic_launcher_background.xml +4 -0
  48. package/android/app/src/main/res/values/strings.xml +7 -0
  49. package/android/app/src/main/res/values/styles.xml +22 -0
  50. package/android/app/src/main/res/xml/file_paths.xml +5 -0
  51. package/android/app/src/main/res/xml/network_security_config.xml +8 -0
  52. package/android/app/src/test/java/com/getcapacitor/myapp/ExampleUnitTest.java +18 -0
  53. package/android/build.gradle +29 -0
  54. package/android/capacitor.settings.gradle +21 -0
  55. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  56. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  57. package/android/gradle.properties +22 -0
  58. package/android/gradlew +248 -0
  59. package/android/gradlew.bat +92 -0
  60. package/android/settings.gradle +5 -0
  61. package/android/variables.gradle +16 -0
  62. package/bytechain.cn-colamd-1.5.1-beta.2.tgz +0 -0
  63. package/capacitor.config.js +29 -0
  64. package/capacitor.config.ts +30 -0
  65. package/demo.md +191 -484
  66. package/dist/main/index.js +77 -46
  67. package/dist/renderer/assets/{arc-tTbbM8LO.js → arc-CPdeInCG.js} +1 -1
  68. package/dist/renderer/assets/{architectureDiagram-3BPJPVTR-CEgYow6c.js → architectureDiagram-3BPJPVTR-BAbnaR9G.js} +4 -3
  69. package/dist/renderer/assets/{blockDiagram-GPEHLZMM-LHyVtPwW.js → blockDiagram-GPEHLZMM-CYSWjnJg.js} +5 -4
  70. package/dist/renderer/assets/{c4Diagram-AAUBKEIU-C1P1eJrf.js → c4Diagram-AAUBKEIU-Rb1tstnr.js} +3 -2
  71. package/dist/renderer/assets/{channel-upve91Tq.js → channel-DpG2A6fE.js} +1 -1
  72. package/dist/renderer/assets/{chunk-2J33WTMH-lag2vhq9.js → chunk-2J33WTMH-DFc0Jxy_.js} +1 -1
  73. package/dist/renderer/assets/{chunk-4BX2VUAB-BXJ8Ggh-.js → chunk-4BX2VUAB-BhRxDTNn.js} +1 -1
  74. package/dist/renderer/assets/{chunk-55IACEB6-CiBpxRa1.js → chunk-55IACEB6-DEgMVBk8.js} +1 -1
  75. package/dist/renderer/assets/{chunk-727SXJPM-ODeKQFXC.js → chunk-727SXJPM-bjBIfiz8.js} +5 -5
  76. package/dist/renderer/assets/{chunk-AQP2D5EJ-BK7xJolB.js → chunk-AQP2D5EJ-DwQMzTzD.js} +3 -3
  77. package/dist/renderer/assets/{chunk-FMBD7UC4-BxpCZPtz.js → chunk-FMBD7UC4-CkphwJzs.js} +1 -1
  78. package/dist/renderer/assets/{chunk-ND2GUHAM-CqqaU9Ue.js → chunk-ND2GUHAM-oU09z4y4.js} +1 -1
  79. package/dist/renderer/assets/{chunk-QZHKN3VN-Biq_K124.js → chunk-QZHKN3VN-rCbVuPBn.js} +1 -1
  80. package/dist/renderer/assets/{classDiagram-v2-Q7XG4LA2-Cq95X99o.js → classDiagram-4FO5ZUOK-DGS2faoM.js} +7 -6
  81. package/dist/renderer/assets/{classDiagram-4FO5ZUOK-Cq95X99o.js → classDiagram-v2-Q7XG4LA2-DGS2faoM.js} +7 -6
  82. package/dist/renderer/assets/{cose-bilkent-S5V4N54A-XasiD0bu.js → cose-bilkent-S5V4N54A-iqY6-EwA.js} +2 -1
  83. package/dist/renderer/assets/{dagre-BM42HDAG-Nq84Gfx4.js → dagre-BM42HDAG-5t3X5sDa.js} +4 -3
  84. package/dist/renderer/assets/{diagram-2AECGRRQ-DwuB1GWt.js → diagram-2AECGRRQ-DzHiYDPh.js} +4 -3
  85. package/dist/renderer/assets/{diagram-5GNKFQAL-C2tgeI1h.js → diagram-5GNKFQAL-BiNv6Keq.js} +5 -4
  86. package/dist/renderer/assets/{diagram-KO2AKTUF-D5KzjNBc.js → diagram-KO2AKTUF-ClzeDG6f.js} +4 -3
  87. package/dist/renderer/assets/{diagram-LMA3HP47-C12xHS1c.js → diagram-LMA3HP47-CGkw7wII.js} +4 -3
  88. package/dist/renderer/assets/{diagram-OG6HWLK6-CnxI9oEa.js → diagram-OG6HWLK6-Dl-Hyk1_.js} +5 -4
  89. package/dist/renderer/assets/{erDiagram-TEJ5UH35-D_uPaKwn.js → erDiagram-TEJ5UH35-BxUN79Qb.js} +5 -4
  90. package/dist/renderer/assets/{flowDiagram-I6XJVG4X-B6q_1-tE.js → flowDiagram-I6XJVG4X-CzFk-KNI.js} +7 -6
  91. package/dist/renderer/assets/{ganttDiagram-6RSMTGT7-CFo7ifF9.js → ganttDiagram-6RSMTGT7-C2xl6Igx.js} +3 -2
  92. package/dist/renderer/assets/{gitGraphDiagram-PVQCEYII-WSexHTnq.js → gitGraphDiagram-PVQCEYII-_fn7XCa7.js} +5 -4
  93. package/dist/renderer/assets/{graph-DyX_9f6d.js → graph-CDoHYrHm.js} +1 -1
  94. package/dist/renderer/assets/index-B4uDgADr.js +530 -0
  95. package/dist/renderer/assets/index-CBcVpA3d.js +30 -0
  96. package/dist/renderer/assets/index-CGj1spkU.js +27 -0
  97. package/dist/renderer/assets/{index-dyHEFYvY.css → index-CeFpoCKV.css} +443 -400
  98. package/dist/renderer/assets/index-D4CPFkph.js +9 -0
  99. package/dist/renderer/assets/{index-DW7LS8C1.js → index-DAlXyxzt.js} +1183 -346
  100. package/dist/renderer/assets/index-DxOzbfR-.js +110 -0
  101. package/dist/renderer/assets/index-Y89U1ptl.js +9 -0
  102. package/dist/renderer/assets/{infoDiagram-5YYISTIA-DaeJdLRq.js → infoDiagram-5YYISTIA-DL6XIxLz.js} +3 -2
  103. package/dist/renderer/assets/{ishikawaDiagram-YF4QCWOH-DDCZc35f.js → ishikawaDiagram-YF4QCWOH-BUZLjRo-.js} +2 -1
  104. package/dist/renderer/assets/{journeyDiagram-JHISSGLW-BEdmpAgl.js → journeyDiagram-JHISSGLW-C4rH_mQM.js} +5 -4
  105. package/dist/renderer/assets/{kanban-definition-UN3LZRKU-BEFtQcFb.js → kanban-definition-UN3LZRKU-DRbrBcWV.js} +3 -2
  106. package/dist/renderer/assets/{layout-CAJgQHdw.js → layout-DZl4n4qu.js} +2 -2
  107. package/dist/renderer/assets/{linear-B2ggJ8Am.js → linear-B0Krxg21.js} +1 -1
  108. package/dist/renderer/assets/{mindmap-definition-RKZ34NQL-DSxVgHB5.js → mindmap-definition-RKZ34NQL-DdmPsWrn.js} +4 -3
  109. package/dist/renderer/assets/{pieDiagram-4H26LBE5-CwYoJBuL.js → pieDiagram-4H26LBE5-BPZLqwG0.js} +5 -4
  110. package/dist/renderer/assets/preload-helper-tXtZnHb0.js +88 -0
  111. package/dist/renderer/assets/{quadrantDiagram-W4KKPZXB-CST9Fvg9.js → quadrantDiagram-W4KKPZXB-Dr-oWRk9.js} +3 -2
  112. package/dist/renderer/assets/{requirementDiagram-4Y6WPE33-DtrH52jS.js → requirementDiagram-4Y6WPE33-B6QZd0lo.js} +4 -3
  113. package/dist/renderer/assets/{sankeyDiagram-5OEKKPKP-ca1tPzJ_.js → sankeyDiagram-5OEKKPKP-Cyl9ojEt.js} +2 -1
  114. package/dist/renderer/assets/{sequenceDiagram-3UESZ5HK-Dfp1EJZ7.js → sequenceDiagram-3UESZ5HK-D48Yr9T6.js} +4 -3
  115. package/dist/renderer/assets/{stateDiagram-AJRCARHV-Bha2QoNB.js → stateDiagram-AJRCARHV-qyb8ETsa.js} +7 -6
  116. package/dist/renderer/assets/{stateDiagram-v2-BHNVJYJU-DWgFUYu1.js → stateDiagram-v2-BHNVJYJU-DmDOyyrJ.js} +5 -4
  117. package/dist/renderer/assets/{timeline-definition-PNZ67QCA-C3h_-OTj.js → timeline-definition-PNZ67QCA-C-KQxTi1.js} +3 -2
  118. package/dist/renderer/assets/{vennDiagram-CIIHVFJN-DFzjSrZi.js → vennDiagram-CIIHVFJN-BdaZlnH-.js} +2 -1
  119. package/dist/renderer/assets/{wardley-L42UT6IY-Cx-VbqoS.js → wardley-L42UT6IY-b-_GPpqL.js} +1 -1
  120. package/dist/renderer/assets/{wardleyDiagram-YWT4CUSO-S2D9XqX6.js → wardleyDiagram-YWT4CUSO-B2hBE-EE.js} +4 -3
  121. package/dist/renderer/assets/web-BKE0SH0E.js +36 -0
  122. package/dist/renderer/assets/web-CBsFp24u.js +564 -0
  123. package/dist/renderer/assets/web-Dc8YgoHP.js +24 -0
  124. package/dist/renderer/assets/web-TfDzToU7.js +58 -0
  125. package/dist/renderer/assets/{xychartDiagram-2RQKCTM6-Cfxigbts.js → xychartDiagram-2RQKCTM6-CSvswDTY.js} +3 -2
  126. package/dist/renderer/index.html +62 -3
  127. package/docs/academic-demo.md +566 -0
  128. package/docs/demo.html +748 -0
  129. package/docs/demo.md +546 -0
  130. package/docs/demo.pdf +0 -0
  131. package/docs/theme-paradigm.md +658 -0
  132. package/electron-builder.yml +7 -0
  133. package/electron.vite.config.js +31 -0
  134. package/electron.vite.config.ts +1 -1
  135. package/ios/App/App/AppDelegate.swift +49 -0
  136. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
  137. package/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
  138. package/ios/App/App/Assets.xcassets/Contents.json +6 -0
  139. package/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
  140. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
  141. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
  142. package/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
  143. package/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
  144. package/ios/App/App/Base.lproj/Main.storyboard +19 -0
  145. package/ios/App/App/Info.plist +49 -0
  146. package/ios/App/App.xcodeproj/project.pbxproj +408 -0
  147. package/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  148. package/ios/App/Podfile +28 -0
  149. package/package.json +23 -3
  150. package/resources/templates/slides/template-forest-ink.html +540 -0
  151. package/scripts/generate-icons.js +102 -0
  152. package/src/main/index.ts +87 -63
  153. package/src/preload/index.d.ts +51 -0
  154. package/src/preload/index.js +70 -0
  155. package/src/renderer/capacitor-api.ts +713 -0
  156. package/src/renderer/editor/editor.ts +87 -4
  157. package/src/renderer/editor/plugins/index.ts +24 -32
  158. package/src/renderer/editor/plugins/math-plugin.ts +1 -1
  159. package/src/renderer/editor/plugins/mermaid-plugin-custom.css +13 -398
  160. package/src/renderer/editor/plugins/mermaid-plugin.ts +62 -71
  161. package/src/renderer/editor/plugins/themes/base/dark.css +23 -0
  162. package/src/renderer/editor/plugins/themes/base/elegant.css +32 -0
  163. package/src/renderer/editor/plugins/themes/base/light.css +20 -0
  164. package/src/renderer/editor/plugins/themes/base/newsprint.css +27 -0
  165. package/src/renderer/editor/plugins/themes/components/mermaid/academic.css +43 -0
  166. package/src/renderer/editor/plugins/themes/components/mermaid/dark.css +20 -0
  167. package/src/renderer/editor/plugins/themes/components/mermaid/elegant.css +24 -0
  168. package/src/renderer/editor/plugins/themes/components/mermaid/light.css +21 -0
  169. package/src/renderer/editor/plugins/themes/components/mermaid/newsprint.css +26 -0
  170. package/src/renderer/editor/plugins/themes/components/mermaid/variables.css +592 -0
  171. package/src/renderer/editor/plugins/themes/foundation.css +143 -0
  172. package/src/renderer/editor/plugins/themes/theme-manager.ts +92 -0
  173. package/src/renderer/env.d.ts +4 -1
  174. package/src/renderer/index.html +59 -1
  175. package/src/renderer/main.ts +432 -57
  176. package/src/renderer/mobile.css +429 -0
  177. package/themes/README.md +3 -0
  178. package/themes/academic-paper.css +1321 -0
  179. package/themes/elegant.css +14 -7
  180. package/themes/forest-ink.css +664 -0
  181. package/themes/pixso-design.css +1261 -0
  182. package/themes/swiss-design.css +596 -0
  183. package/themes/template.css +498 -0
  184. package/tsconfig.main.json +1 -0
  185. package/tsconfig.main.tsbuildinfo +1 -0
  186. package/tsconfig.preload.json +1 -0
  187. package/tsconfig.preload.tsbuildinfo +1 -0
  188. package/tsconfig.renderer.json +1 -0
  189. package/tsconfig.renderer.tsbuildinfo +1 -0
  190. package/tsconfig.tsbuildinfo +1 -0
  191. package/.trae/documents/fix-mermaid-colors-and-sankey.md +0 -50
  192. package/src/renderer/themes/theme-manager.ts +0 -40
  193. /package/src/renderer/{themes → editor/plugins/themes}/base.css +0 -0
@@ -0,0 +1,564 @@
1
+ import { WebPlugin, buildRequestInit } from "./index-B4uDgADr.js";
2
+ import { Encoding } from "./index-CBcVpA3d.js";
3
+ import "./preload-helper-tXtZnHb0.js";
4
+ function resolve(path) {
5
+ const posix = path.split("/").filter((item) => item !== ".");
6
+ const newPosix = [];
7
+ posix.forEach((item) => {
8
+ if (item === ".." && newPosix.length > 0 && newPosix[newPosix.length - 1] !== "..") {
9
+ newPosix.pop();
10
+ } else {
11
+ newPosix.push(item);
12
+ }
13
+ });
14
+ return newPosix.join("/");
15
+ }
16
+ function isPathParent(parent, children) {
17
+ parent = resolve(parent);
18
+ children = resolve(children);
19
+ const pathsA = parent.split("/");
20
+ const pathsB = children.split("/");
21
+ return parent !== children && pathsA.every((value, index) => value === pathsB[index]);
22
+ }
23
+ class FilesystemWeb extends WebPlugin {
24
+ constructor() {
25
+ super(...arguments);
26
+ this.DB_VERSION = 1;
27
+ this.DB_NAME = "Disc";
28
+ this._writeCmds = ["add", "put", "delete"];
29
+ this.downloadFile = async (options) => {
30
+ var _a, _b;
31
+ const requestInit = buildRequestInit(options, options.webFetchExtra);
32
+ const response = await fetch(options.url, requestInit);
33
+ let blob;
34
+ if (!options.progress)
35
+ blob = await response.blob();
36
+ else if (!(response === null || response === void 0 ? void 0 : response.body))
37
+ blob = new Blob();
38
+ else {
39
+ const reader = response.body.getReader();
40
+ let bytes = 0;
41
+ const chunks = [];
42
+ const contentType = response.headers.get("content-type");
43
+ const contentLength = parseInt(response.headers.get("content-length") || "0", 10);
44
+ while (true) {
45
+ const { done, value } = await reader.read();
46
+ if (done)
47
+ break;
48
+ chunks.push(value);
49
+ bytes += (value === null || value === void 0 ? void 0 : value.length) || 0;
50
+ const status = {
51
+ url: options.url,
52
+ bytes,
53
+ contentLength
54
+ };
55
+ this.notifyListeners("progress", status);
56
+ }
57
+ const allChunks = new Uint8Array(bytes);
58
+ let position = 0;
59
+ for (const chunk of chunks) {
60
+ if (typeof chunk === "undefined")
61
+ continue;
62
+ allChunks.set(chunk, position);
63
+ position += chunk.length;
64
+ }
65
+ blob = new Blob([allChunks.buffer], { type: contentType || void 0 });
66
+ }
67
+ const result = await this.writeFile({
68
+ path: options.path,
69
+ directory: (_a = options.directory) !== null && _a !== void 0 ? _a : void 0,
70
+ recursive: (_b = options.recursive) !== null && _b !== void 0 ? _b : false,
71
+ data: blob
72
+ });
73
+ return { path: result.uri, blob };
74
+ };
75
+ }
76
+ async initDb() {
77
+ if (this._db !== void 0) {
78
+ return this._db;
79
+ }
80
+ if (!("indexedDB" in window)) {
81
+ throw this.unavailable("This browser doesn't support IndexedDB");
82
+ }
83
+ return new Promise((resolve2, reject) => {
84
+ const request = indexedDB.open(this.DB_NAME, this.DB_VERSION);
85
+ request.onupgradeneeded = FilesystemWeb.doUpgrade;
86
+ request.onsuccess = () => {
87
+ this._db = request.result;
88
+ resolve2(request.result);
89
+ };
90
+ request.onerror = () => reject(request.error);
91
+ request.onblocked = () => {
92
+ console.warn("db blocked");
93
+ };
94
+ });
95
+ }
96
+ static doUpgrade(event) {
97
+ const eventTarget = event.target;
98
+ const db = eventTarget.result;
99
+ switch (event.oldVersion) {
100
+ case 0:
101
+ case 1:
102
+ default: {
103
+ if (db.objectStoreNames.contains("FileStorage")) {
104
+ db.deleteObjectStore("FileStorage");
105
+ }
106
+ const store = db.createObjectStore("FileStorage", { keyPath: "path" });
107
+ store.createIndex("by_folder", "folder");
108
+ }
109
+ }
110
+ }
111
+ async dbRequest(cmd, args) {
112
+ const readFlag = this._writeCmds.indexOf(cmd) !== -1 ? "readwrite" : "readonly";
113
+ return this.initDb().then((conn) => {
114
+ return new Promise((resolve2, reject) => {
115
+ const tx = conn.transaction(["FileStorage"], readFlag);
116
+ const store = tx.objectStore("FileStorage");
117
+ const req = store[cmd](...args);
118
+ req.onsuccess = () => resolve2(req.result);
119
+ req.onerror = () => reject(req.error);
120
+ });
121
+ });
122
+ }
123
+ async dbIndexRequest(indexName, cmd, args) {
124
+ const readFlag = this._writeCmds.indexOf(cmd) !== -1 ? "readwrite" : "readonly";
125
+ return this.initDb().then((conn) => {
126
+ return new Promise((resolve2, reject) => {
127
+ const tx = conn.transaction(["FileStorage"], readFlag);
128
+ const store = tx.objectStore("FileStorage");
129
+ const index = store.index(indexName);
130
+ const req = index[cmd](...args);
131
+ req.onsuccess = () => resolve2(req.result);
132
+ req.onerror = () => reject(req.error);
133
+ });
134
+ });
135
+ }
136
+ getPath(directory, uriPath) {
137
+ const cleanedUriPath = uriPath !== void 0 ? uriPath.replace(/^[/]+|[/]+$/g, "") : "";
138
+ let fsPath = "";
139
+ if (directory !== void 0)
140
+ fsPath += "/" + directory;
141
+ if (uriPath !== "")
142
+ fsPath += "/" + cleanedUriPath;
143
+ return fsPath;
144
+ }
145
+ async clear() {
146
+ const conn = await this.initDb();
147
+ const tx = conn.transaction(["FileStorage"], "readwrite");
148
+ const store = tx.objectStore("FileStorage");
149
+ store.clear();
150
+ }
151
+ /**
152
+ * Read a file from disk
153
+ * @param options options for the file read
154
+ * @return a promise that resolves with the read file data result
155
+ */
156
+ async readFile(options) {
157
+ const path = this.getPath(options.directory, options.path);
158
+ const entry = await this.dbRequest("get", [path]);
159
+ if (entry === void 0)
160
+ throw Error("File does not exist.");
161
+ return { data: entry.content ? entry.content : "" };
162
+ }
163
+ /**
164
+ * Write a file to disk in the specified location on device
165
+ * @param options options for the file write
166
+ * @return a promise that resolves with the file write result
167
+ */
168
+ async writeFile(options) {
169
+ const path = this.getPath(options.directory, options.path);
170
+ let data = options.data;
171
+ const encoding = options.encoding;
172
+ const doRecursive = options.recursive;
173
+ const occupiedEntry = await this.dbRequest("get", [path]);
174
+ if (occupiedEntry && occupiedEntry.type === "directory")
175
+ throw Error("The supplied path is a directory.");
176
+ const parentPath = path.substr(0, path.lastIndexOf("/"));
177
+ const parentEntry = await this.dbRequest("get", [parentPath]);
178
+ if (parentEntry === void 0) {
179
+ const subDirIndex = parentPath.indexOf("/", 1);
180
+ if (subDirIndex !== -1) {
181
+ const parentArgPath = parentPath.substr(subDirIndex);
182
+ await this.mkdir({
183
+ path: parentArgPath,
184
+ directory: options.directory,
185
+ recursive: doRecursive
186
+ });
187
+ }
188
+ }
189
+ if (!encoding && !(data instanceof Blob)) {
190
+ data = data.indexOf(",") >= 0 ? data.split(",")[1] : data;
191
+ if (!this.isBase64String(data))
192
+ throw Error("The supplied data is not valid base64 content.");
193
+ }
194
+ const now = Date.now();
195
+ const pathObj = {
196
+ path,
197
+ folder: parentPath,
198
+ type: "file",
199
+ size: data instanceof Blob ? data.size : data.length,
200
+ ctime: now,
201
+ mtime: now,
202
+ content: data
203
+ };
204
+ await this.dbRequest("put", [pathObj]);
205
+ return {
206
+ uri: pathObj.path
207
+ };
208
+ }
209
+ /**
210
+ * Append to a file on disk in the specified location on device
211
+ * @param options options for the file append
212
+ * @return a promise that resolves with the file write result
213
+ */
214
+ async appendFile(options) {
215
+ const path = this.getPath(options.directory, options.path);
216
+ let data = options.data;
217
+ const encoding = options.encoding;
218
+ const parentPath = path.substr(0, path.lastIndexOf("/"));
219
+ const now = Date.now();
220
+ let ctime = now;
221
+ const occupiedEntry = await this.dbRequest("get", [path]);
222
+ if (occupiedEntry && occupiedEntry.type === "directory")
223
+ throw Error("The supplied path is a directory.");
224
+ const parentEntry = await this.dbRequest("get", [parentPath]);
225
+ if (parentEntry === void 0) {
226
+ const subDirIndex = parentPath.indexOf("/", 1);
227
+ if (subDirIndex !== -1) {
228
+ const parentArgPath = parentPath.substr(subDirIndex);
229
+ await this.mkdir({
230
+ path: parentArgPath,
231
+ directory: options.directory,
232
+ recursive: true
233
+ });
234
+ }
235
+ }
236
+ if (!encoding && !this.isBase64String(data))
237
+ throw Error("The supplied data is not valid base64 content.");
238
+ if (occupiedEntry !== void 0) {
239
+ if (occupiedEntry.content instanceof Blob) {
240
+ throw Error("The occupied entry contains a Blob object which cannot be appended to.");
241
+ }
242
+ if (occupiedEntry.content !== void 0 && !encoding) {
243
+ data = btoa(atob(occupiedEntry.content) + atob(data));
244
+ } else {
245
+ data = occupiedEntry.content + data;
246
+ }
247
+ ctime = occupiedEntry.ctime;
248
+ }
249
+ const pathObj = {
250
+ path,
251
+ folder: parentPath,
252
+ type: "file",
253
+ size: data.length,
254
+ ctime,
255
+ mtime: now,
256
+ content: data
257
+ };
258
+ await this.dbRequest("put", [pathObj]);
259
+ }
260
+ /**
261
+ * Delete a file from disk
262
+ * @param options options for the file delete
263
+ * @return a promise that resolves with the deleted file data result
264
+ */
265
+ async deleteFile(options) {
266
+ const path = this.getPath(options.directory, options.path);
267
+ const entry = await this.dbRequest("get", [path]);
268
+ if (entry === void 0)
269
+ throw Error("File does not exist.");
270
+ const entries = await this.dbIndexRequest("by_folder", "getAllKeys", [
271
+ IDBKeyRange.only(path)
272
+ ]);
273
+ if (entries.length !== 0)
274
+ throw Error("Folder is not empty.");
275
+ await this.dbRequest("delete", [path]);
276
+ }
277
+ /**
278
+ * Create a directory.
279
+ * @param options options for the mkdir
280
+ * @return a promise that resolves with the mkdir result
281
+ */
282
+ async mkdir(options) {
283
+ const path = this.getPath(options.directory, options.path);
284
+ const doRecursive = options.recursive;
285
+ const parentPath = path.substr(0, path.lastIndexOf("/"));
286
+ const depth = (path.match(/\//g) || []).length;
287
+ const parentEntry = await this.dbRequest("get", [parentPath]);
288
+ const occupiedEntry = await this.dbRequest("get", [path]);
289
+ if (depth === 1)
290
+ throw Error("Cannot create Root directory");
291
+ if (occupiedEntry !== void 0)
292
+ throw Error("Current directory does already exist.");
293
+ if (!doRecursive && depth !== 2 && parentEntry === void 0)
294
+ throw Error("Parent directory must exist");
295
+ if (doRecursive && depth !== 2 && parentEntry === void 0) {
296
+ const parentArgPath = parentPath.substr(parentPath.indexOf("/", 1));
297
+ await this.mkdir({
298
+ path: parentArgPath,
299
+ directory: options.directory,
300
+ recursive: doRecursive
301
+ });
302
+ }
303
+ const now = Date.now();
304
+ const pathObj = {
305
+ path,
306
+ folder: parentPath,
307
+ type: "directory",
308
+ size: 0,
309
+ ctime: now,
310
+ mtime: now
311
+ };
312
+ await this.dbRequest("put", [pathObj]);
313
+ }
314
+ /**
315
+ * Remove a directory
316
+ * @param options the options for the directory remove
317
+ */
318
+ async rmdir(options) {
319
+ const { path, directory, recursive } = options;
320
+ const fullPath = this.getPath(directory, path);
321
+ const entry = await this.dbRequest("get", [fullPath]);
322
+ if (entry === void 0)
323
+ throw Error("Folder does not exist.");
324
+ if (entry.type !== "directory")
325
+ throw Error("Requested path is not a directory");
326
+ const readDirResult = await this.readdir({ path, directory });
327
+ if (readDirResult.files.length !== 0 && !recursive)
328
+ throw Error("Folder is not empty");
329
+ for (const entry2 of readDirResult.files) {
330
+ const entryPath = `${path}/${entry2.name}`;
331
+ const entryObj = await this.stat({ path: entryPath, directory });
332
+ if (entryObj.type === "file") {
333
+ await this.deleteFile({ path: entryPath, directory });
334
+ } else {
335
+ await this.rmdir({ path: entryPath, directory, recursive });
336
+ }
337
+ }
338
+ await this.dbRequest("delete", [fullPath]);
339
+ }
340
+ /**
341
+ * Return a list of files from the directory (not recursive)
342
+ * @param options the options for the readdir operation
343
+ * @return a promise that resolves with the readdir directory listing result
344
+ */
345
+ async readdir(options) {
346
+ const path = this.getPath(options.directory, options.path);
347
+ const entry = await this.dbRequest("get", [path]);
348
+ if (options.path !== "" && entry === void 0)
349
+ throw Error("Folder does not exist.");
350
+ const entries = await this.dbIndexRequest("by_folder", "getAllKeys", [IDBKeyRange.only(path)]);
351
+ const files = await Promise.all(entries.map(async (e) => {
352
+ let subEntry = await this.dbRequest("get", [e]);
353
+ if (subEntry === void 0) {
354
+ subEntry = await this.dbRequest("get", [e + "/"]);
355
+ }
356
+ return {
357
+ name: e.substring(path.length + 1),
358
+ type: subEntry.type,
359
+ size: subEntry.size,
360
+ ctime: subEntry.ctime,
361
+ mtime: subEntry.mtime,
362
+ uri: subEntry.path
363
+ };
364
+ }));
365
+ return { files };
366
+ }
367
+ /**
368
+ * Return full File URI for a path and directory
369
+ * @param options the options for the stat operation
370
+ * @return a promise that resolves with the file stat result
371
+ */
372
+ async getUri(options) {
373
+ const path = this.getPath(options.directory, options.path);
374
+ let entry = await this.dbRequest("get", [path]);
375
+ if (entry === void 0) {
376
+ entry = await this.dbRequest("get", [path + "/"]);
377
+ }
378
+ return {
379
+ uri: (entry === null || entry === void 0 ? void 0 : entry.path) || path
380
+ };
381
+ }
382
+ /**
383
+ * Return data about a file
384
+ * @param options the options for the stat operation
385
+ * @return a promise that resolves with the file stat result
386
+ */
387
+ async stat(options) {
388
+ const path = this.getPath(options.directory, options.path);
389
+ let entry = await this.dbRequest("get", [path]);
390
+ if (entry === void 0) {
391
+ entry = await this.dbRequest("get", [path + "/"]);
392
+ }
393
+ if (entry === void 0)
394
+ throw Error("Entry does not exist.");
395
+ return {
396
+ type: entry.type,
397
+ size: entry.size,
398
+ ctime: entry.ctime,
399
+ mtime: entry.mtime,
400
+ uri: entry.path
401
+ };
402
+ }
403
+ /**
404
+ * Rename a file or directory
405
+ * @param options the options for the rename operation
406
+ * @return a promise that resolves with the rename result
407
+ */
408
+ async rename(options) {
409
+ await this._copy(options, true);
410
+ return;
411
+ }
412
+ /**
413
+ * Copy a file or directory
414
+ * @param options the options for the copy operation
415
+ * @return a promise that resolves with the copy result
416
+ */
417
+ async copy(options) {
418
+ return this._copy(options, false);
419
+ }
420
+ async requestPermissions() {
421
+ return { publicStorage: "granted" };
422
+ }
423
+ async checkPermissions() {
424
+ return { publicStorage: "granted" };
425
+ }
426
+ /**
427
+ * Function that can perform a copy or a rename
428
+ * @param options the options for the rename operation
429
+ * @param doRename whether to perform a rename or copy operation
430
+ * @return a promise that resolves with the result
431
+ */
432
+ async _copy(options, doRename = false) {
433
+ let { toDirectory } = options;
434
+ const { to, from, directory: fromDirectory } = options;
435
+ if (!to || !from) {
436
+ throw Error("Both to and from must be provided");
437
+ }
438
+ if (!toDirectory) {
439
+ toDirectory = fromDirectory;
440
+ }
441
+ const fromPath = this.getPath(fromDirectory, from);
442
+ const toPath = this.getPath(toDirectory, to);
443
+ if (fromPath === toPath) {
444
+ return {
445
+ uri: toPath
446
+ };
447
+ }
448
+ if (isPathParent(fromPath, toPath)) {
449
+ throw Error("To path cannot contain the from path");
450
+ }
451
+ let toObj;
452
+ try {
453
+ toObj = await this.stat({
454
+ path: to,
455
+ directory: toDirectory
456
+ });
457
+ } catch (e) {
458
+ const toPathComponents = to.split("/");
459
+ toPathComponents.pop();
460
+ const toPath2 = toPathComponents.join("/");
461
+ if (toPathComponents.length > 0) {
462
+ const toParentDirectory = await this.stat({
463
+ path: toPath2,
464
+ directory: toDirectory
465
+ });
466
+ if (toParentDirectory.type !== "directory") {
467
+ throw new Error("Parent directory of the to path is a file");
468
+ }
469
+ }
470
+ }
471
+ if (toObj && toObj.type === "directory") {
472
+ throw new Error("Cannot overwrite a directory with a file");
473
+ }
474
+ const fromObj = await this.stat({
475
+ path: from,
476
+ directory: fromDirectory
477
+ });
478
+ const updateTime = async (path, ctime2, mtime) => {
479
+ const fullPath = this.getPath(toDirectory, path);
480
+ const entry = await this.dbRequest("get", [fullPath]);
481
+ entry.ctime = ctime2;
482
+ entry.mtime = mtime;
483
+ await this.dbRequest("put", [entry]);
484
+ };
485
+ const ctime = fromObj.ctime ? fromObj.ctime : Date.now();
486
+ switch (fromObj.type) {
487
+ // The "from" object is a file
488
+ case "file": {
489
+ const file = await this.readFile({
490
+ path: from,
491
+ directory: fromDirectory
492
+ });
493
+ if (doRename) {
494
+ await this.deleteFile({
495
+ path: from,
496
+ directory: fromDirectory
497
+ });
498
+ }
499
+ let encoding;
500
+ if (!(file.data instanceof Blob) && !this.isBase64String(file.data)) {
501
+ encoding = Encoding.UTF8;
502
+ }
503
+ const writeResult = await this.writeFile({
504
+ path: to,
505
+ directory: toDirectory,
506
+ data: file.data,
507
+ encoding
508
+ });
509
+ if (doRename) {
510
+ await updateTime(to, ctime, fromObj.mtime);
511
+ }
512
+ return writeResult;
513
+ }
514
+ case "directory": {
515
+ if (toObj) {
516
+ throw Error("Cannot move a directory over an existing object");
517
+ }
518
+ try {
519
+ await this.mkdir({
520
+ path: to,
521
+ directory: toDirectory,
522
+ recursive: false
523
+ });
524
+ if (doRename) {
525
+ await updateTime(to, ctime, fromObj.mtime);
526
+ }
527
+ } catch (e) {
528
+ }
529
+ const contents = (await this.readdir({
530
+ path: from,
531
+ directory: fromDirectory
532
+ })).files;
533
+ for (const filename of contents) {
534
+ await this._copy({
535
+ from: `${from}/${filename.name}`,
536
+ to: `${to}/${filename.name}`,
537
+ directory: fromDirectory,
538
+ toDirectory
539
+ }, doRename);
540
+ }
541
+ if (doRename) {
542
+ await this.rmdir({
543
+ path: from,
544
+ directory: fromDirectory
545
+ });
546
+ }
547
+ }
548
+ }
549
+ return {
550
+ uri: toPath
551
+ };
552
+ }
553
+ isBase64String(str) {
554
+ try {
555
+ return btoa(atob(str)) == str;
556
+ } catch (err) {
557
+ return false;
558
+ }
559
+ }
560
+ }
561
+ FilesystemWeb._debug = true;
562
+ export {
563
+ FilesystemWeb
564
+ };
@@ -0,0 +1,24 @@
1
+ import { WebPlugin } from "./index-B4uDgADr.js";
2
+ class ShareWeb extends WebPlugin {
3
+ async canShare() {
4
+ if (typeof navigator === "undefined" || !navigator.share) {
5
+ return { value: false };
6
+ } else {
7
+ return { value: true };
8
+ }
9
+ }
10
+ async share(options) {
11
+ if (typeof navigator === "undefined" || !navigator.share) {
12
+ throw this.unavailable("Share API not available in this browser");
13
+ }
14
+ await navigator.share({
15
+ title: options.title,
16
+ text: options.text,
17
+ url: options.url
18
+ });
19
+ return {};
20
+ }
21
+ }
22
+ export {
23
+ ShareWeb
24
+ };
@@ -0,0 +1,58 @@
1
+ import { WebPlugin } from "./index-B4uDgADr.js";
2
+ import { ImpactStyle, NotificationType } from "./index-CGj1spkU.js";
3
+ import "./preload-helper-tXtZnHb0.js";
4
+ class HapticsWeb extends WebPlugin {
5
+ constructor() {
6
+ super(...arguments);
7
+ this.selectionStarted = false;
8
+ }
9
+ async impact(options) {
10
+ const pattern = this.patternForImpact(options === null || options === void 0 ? void 0 : options.style);
11
+ this.vibrateWithPattern(pattern);
12
+ }
13
+ async notification(options) {
14
+ const pattern = this.patternForNotification(options === null || options === void 0 ? void 0 : options.type);
15
+ this.vibrateWithPattern(pattern);
16
+ }
17
+ async vibrate(options) {
18
+ const duration = (options === null || options === void 0 ? void 0 : options.duration) || 300;
19
+ this.vibrateWithPattern([duration]);
20
+ }
21
+ async selectionStart() {
22
+ this.selectionStarted = true;
23
+ }
24
+ async selectionChanged() {
25
+ if (this.selectionStarted) {
26
+ this.vibrateWithPattern([70]);
27
+ }
28
+ }
29
+ async selectionEnd() {
30
+ this.selectionStarted = false;
31
+ }
32
+ patternForImpact(style = ImpactStyle.Heavy) {
33
+ if (style === ImpactStyle.Medium) {
34
+ return [43];
35
+ } else if (style === ImpactStyle.Light) {
36
+ return [20];
37
+ }
38
+ return [61];
39
+ }
40
+ patternForNotification(type = NotificationType.Success) {
41
+ if (type === NotificationType.Warning) {
42
+ return [30, 40, 30, 50, 60];
43
+ } else if (type === NotificationType.Error) {
44
+ return [27, 45, 50];
45
+ }
46
+ return [35, 65, 21];
47
+ }
48
+ vibrateWithPattern(pattern) {
49
+ if (navigator.vibrate) {
50
+ navigator.vibrate(pattern);
51
+ } else {
52
+ throw this.unavailable("Browser does not support the vibrate API");
53
+ }
54
+ }
55
+ }
56
+ export {
57
+ HapticsWeb
58
+ };
@@ -1,7 +1,8 @@
1
- import { s as setAccDescription, g as getAccDescription, q as getDiagramTitle, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, l as log, I as selectSvgElement, e as configureSvgSize, z as clear, D as getConfig, i as sanitizeText, F as cleanAndMerge, G as defaultConfig_default, K as getThemeVariables3, am as computeDimensionOfText, R as line } from "./index-DW7LS8C1.js";
1
+ import { s as setAccDescription, g as getAccDescription, q as getDiagramTitle, p as setDiagramTitle, a as getAccTitle, b as setAccTitle, _ as __name, l as log, I as selectSvgElement, e as configureSvgSize, z as clear, D as getConfig, i as sanitizeText, F as cleanAndMerge, G as defaultConfig_default, K as getThemeVariables3, am as computeDimensionOfText, R as line } from "./index-DAlXyxzt.js";
2
2
  import { i as initRange } from "./init-ZxktEp_H.js";
3
3
  import { o as ordinal } from "./ordinal-DSZU4PqD.js";
4
- import { l as linear } from "./linear-B2ggJ8Am.js";
4
+ import { l as linear } from "./linear-B0Krxg21.js";
5
+ import "./preload-helper-tXtZnHb0.js";
5
6
  import "./defaultLocale-B2RvLBDe.js";
6
7
  function range(start, stop, step) {
7
8
  start = +start, stop = +stop, step = (n = arguments.length) < 2 ? (stop = start, start = 0, 1) : n < 3 ? 1 : +step;