xbintsc 0.6.20 → 0.6.22

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 (93) hide show
  1. package/dist/src/cli/help.d.ts +1 -1
  2. package/dist/src/cli/main.js +1 -0
  3. package/dist/src/cli/main.js.map +1 -1
  4. package/dist/src/driver/build-key.d.ts +3 -0
  5. package/dist/src/driver/build-key.js +3 -1
  6. package/dist/src/driver/build-key.js.map +1 -1
  7. package/dist/src/driver/compiler.js +11 -0
  8. package/dist/src/driver/compiler.js.map +1 -1
  9. package/dist/src/driver/config.d.ts +12 -0
  10. package/dist/src/driver/config.js +22 -0
  11. package/dist/src/driver/config.js.map +1 -1
  12. package/dist/src/driver/index.d.ts +2 -1
  13. package/dist/src/driver/index.js +1 -0
  14. package/dist/src/driver/index.js.map +1 -1
  15. package/dist/src/driver/options.d.ts +8 -1
  16. package/dist/src/driver/storage.d.ts +34 -0
  17. package/dist/src/driver/storage.js +67 -0
  18. package/dist/src/driver/storage.js.map +1 -0
  19. package/dist/src/driver/version.d.ts +1 -1
  20. package/dist/src/driver/version.js +1 -1
  21. package/dist/src/extensions/gui/features.d.ts +1 -1
  22. package/dist/src/extensions/gui/features.js +2 -2
  23. package/dist/src/extensions/gui/features.js.map +1 -1
  24. package/dist/src/extensions/gui/index.js +3 -1
  25. package/dist/src/extensions/gui/index.js.map +1 -1
  26. package/dist/src/extensions/registry.d.ts +4 -1
  27. package/dist/src/extensions/registry.js +8 -2
  28. package/dist/src/extensions/registry.js.map +1 -1
  29. package/dist/src/extensions/storage.d.ts +22 -0
  30. package/dist/src/extensions/storage.js +50 -0
  31. package/dist/src/extensions/storage.js.map +1 -0
  32. package/dist/tests/driver/config.test.js +31 -0
  33. package/dist/tests/driver/config.test.js.map +1 -1
  34. package/dist/tests/driver/link-features.test.js +4 -2
  35. package/dist/tests/driver/link-features.test.js.map +1 -1
  36. package/dist/tests/driver/storage.test.d.ts +1 -0
  37. package/dist/tests/driver/storage.test.js +29 -0
  38. package/dist/tests/driver/storage.test.js.map +1 -0
  39. package/dist/tests/e2e/storage.test.d.ts +7 -0
  40. package/dist/tests/e2e/storage.test.js +86 -0
  41. package/dist/tests/e2e/storage.test.js.map +1 -0
  42. package/dist/tests/extensions/gui-features.test.js +1 -1
  43. package/dist/tests/extensions/gui-features.test.js.map +1 -1
  44. package/dist/tests/extensions/storage.test.d.ts +1 -0
  45. package/dist/tests/extensions/storage.test.js +50 -0
  46. package/dist/tests/extensions/storage.test.js.map +1 -0
  47. package/doc/ai/cli.md +2 -0
  48. package/doc/ai/extensions.md +26 -0
  49. package/doc/ai/zh-CN/cli.md +2 -0
  50. package/doc/ai/zh-CN/extensions.md +23 -0
  51. package/doc/gui/build.md +3 -3
  52. package/doc/gui/media.md +4 -4
  53. package/doc/gui.md +2 -2
  54. package/doc/implemented/extensions.md +1 -1
  55. package/doc/implemented/storage.md +64 -0
  56. package/doc/implemented.md +2 -0
  57. package/doc/xbintsc.config.schema.json +16 -1
  58. package/doc/zh-CN/gui/build.md +3 -3
  59. package/doc/zh-CN/gui/media.md +3 -3
  60. package/doc/zh-CN/gui.md +2 -2
  61. package/doc/zh-CN/implemented/extensions.md +1 -1
  62. package/doc/zh-CN/implemented/storage.md +51 -0
  63. package/doc/zh-CN/implemented.md +2 -0
  64. package/package.json +7 -7
  65. package/runtime/ext_gui/dom_api_form.cpp +10 -0
  66. package/runtime/ext_gui/gui_media.cpp +1 -1
  67. package/runtime/ext_gui/media.cpp +1 -1
  68. package/runtime/ext_gui/media_api.h +2 -2
  69. package/runtime/xt_storage/indexed_db.c +408 -0
  70. package/runtime/xt_storage/indexed_db_internal.h +26 -0
  71. package/runtime/xt_storage/indexed_db_store.c +305 -0
  72. package/runtime/xt_storage/sqlite3/sqlite3.c +271131 -0
  73. package/runtime/xt_storage/sqlite3/sqlite3.h +14447 -0
  74. package/runtime/xt_storage/storage.c +209 -0
  75. package/runtime/xt_storage/storage_internal.h +66 -0
  76. package/scripts/build-gui.ts +1 -1
  77. package/scripts/build-media.ts +2 -2
  78. package/scripts/check-file-length.ts +4 -0
  79. package/src/cli/main.ts +1 -0
  80. package/src/driver/build-key.ts +6 -1
  81. package/src/driver/compiler.ts +13 -0
  82. package/src/driver/config.ts +35 -0
  83. package/src/driver/index.ts +8 -0
  84. package/src/driver/options.ts +8 -1
  85. package/src/driver/storage.ts +84 -0
  86. package/src/driver/version.ts +1 -1
  87. package/src/extensions/gui/features.ts +2 -2
  88. package/src/extensions/gui/index.ts +3 -1
  89. package/src/extensions/registry.ts +8 -2
  90. package/src/extensions/storage.ts +57 -0
  91. /package/runtime/{ext_media → xt_media}/decode_audio.cpp +0 -0
  92. /package/runtime/{ext_media → xt_media}/media.cpp +0 -0
  93. /package/runtime/{ext_media → xt_media}/media_bridge.c +0 -0
@@ -0,0 +1,57 @@
1
+ /**
2
+ * SQLite-backed Web Storage and IndexedDB, contributed as a *link feature*.
3
+ *
4
+ * `localStorage`, `sessionStorage` and `indexedDB` are browser globals made
5
+ * available by the always-on `core` extension (`src/extensions/registry.ts`).
6
+ * The SQLite implementation behind them is heavy, so it is a **link feature**:
7
+ * the driver scans the bundled AST and links it only when the program may
8
+ * actually reach one of the three globals — a program that never touches
9
+ * storage pays nothing for SQLite.
10
+ *
11
+ * The backend is selected at build time from `storage` in
12
+ * `xbintsc.config.json` (default: in-memory; `sessionStorage` is always
13
+ * in-memory). `--feature storage` forces the backend on (for storage reached
14
+ * through names the scan cannot see) and `--no-feature storage` keeps it out.
15
+ */
16
+
17
+ import { join } from "node:path";
18
+ import type { GlobalValue } from "./registry.js";
19
+ import type { LinkFeature, ProgramUsage } from "./link-feature.js";
20
+ import { findRuntimeDir } from "../driver/paths.js";
21
+
22
+ /** The browser storage globals resolved by the core extension. */
23
+ export const storageGlobals: Readonly<Record<string, GlobalValue>> = {
24
+ localStorage: { symbol: "xt_storage_local" },
25
+ sessionStorage: { symbol: "xt_storage_session" },
26
+ indexedDB: { symbol: "xt_storage_indexed_db" },
27
+ };
28
+
29
+ /** True when the bundled program may reach a Web Storage or IndexedDB global. */
30
+ export function hasStorageUsage(usage: ProgramUsage): boolean {
31
+ return (
32
+ usage.identifiers.has("localStorage") ||
33
+ usage.identifiers.has("sessionStorage") ||
34
+ usage.identifiers.has("indexedDB")
35
+ );
36
+ }
37
+
38
+ export const storageLinkFeatures: readonly LinkFeature[] = [
39
+ {
40
+ name: "storage",
41
+ description: "SQLite-backed localStorage, sessionStorage and indexedDB",
42
+ /**
43
+ * The full implementation lives here, not in the extension's runtime
44
+ * sources, so it is compiled and linked only when the feature is active.
45
+ * `storage.c` defines the `xt_storage_local` / `xt_storage_session` globals
46
+ * the code generator reaches for, and `indexed_db.c` / `indexed_db_store.c`
47
+ * define `xt_storage_indexed_db`; all three reference the vendored SQLite.
48
+ */
49
+ runtimeSources: () => [
50
+ join(findRuntimeDir(), "xt_storage", "sqlite3", "sqlite3.c"),
51
+ join(findRuntimeDir(), "xt_storage", "storage.c"),
52
+ join(findRuntimeDir(), "xt_storage", "indexed_db.c"),
53
+ join(findRuntimeDir(), "xt_storage", "indexed_db_store.c"),
54
+ ],
55
+ used: hasStorageUsage,
56
+ },
57
+ ];
File without changes
File without changes