@powerlines/plugin-webpack 0.5.132 → 0.5.134

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 (130) hide show
  1. package/dist/_virtual/rolldown_runtime.cjs +29 -0
  2. package/dist/helpers/index.cjs +2 -3
  3. package/dist/helpers/index.d.cts +1 -3
  4. package/dist/helpers/index.d.mts +1 -3
  5. package/dist/helpers/index.mjs +1 -2
  6. package/dist/helpers/unplugin.cjs +11 -2
  7. package/dist/helpers/unplugin.d.cts +6 -2
  8. package/dist/helpers/unplugin.d.mts +6 -2
  9. package/dist/helpers/unplugin.mjs +9 -1
  10. package/dist/index.cjs +8 -50
  11. package/dist/index.d.cts +3 -4
  12. package/dist/index.d.mts +5 -5
  13. package/dist/index.mjs +3 -46
  14. package/dist/powerlines/schemas/fs.cjs +226 -0
  15. package/dist/powerlines/schemas/fs.mjs +224 -0
  16. package/dist/powerlines/src/api.cjs +580 -0
  17. package/dist/powerlines/src/api.mjs +578 -0
  18. package/dist/powerlines/src/internal/babel/module-resolver-plugin.cjs +86 -0
  19. package/dist/powerlines/src/internal/babel/module-resolver-plugin.mjs +84 -0
  20. package/dist/powerlines/src/internal/helpers/environment.cjs +52 -0
  21. package/dist/powerlines/src/internal/helpers/environment.mjs +48 -0
  22. package/dist/powerlines/src/internal/helpers/generate-types.cjs +51 -0
  23. package/dist/powerlines/src/internal/helpers/generate-types.mjs +49 -0
  24. package/dist/powerlines/src/internal/helpers/hooks.cjs +63 -0
  25. package/dist/powerlines/src/internal/helpers/hooks.mjs +61 -0
  26. package/dist/powerlines/src/internal/helpers/install-dependencies.cjs +25 -0
  27. package/dist/powerlines/src/internal/helpers/install-dependencies.mjs +24 -0
  28. package/dist/powerlines/src/internal/helpers/install.cjs +37 -0
  29. package/dist/powerlines/src/internal/helpers/install.mjs +36 -0
  30. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.cjs +98 -0
  31. package/dist/powerlines/src/internal/helpers/resolve-tsconfig.mjs +94 -0
  32. package/dist/powerlines/src/internal/helpers/resolver.cjs +43 -0
  33. package/dist/powerlines/src/internal/helpers/resolver.mjs +41 -0
  34. package/dist/powerlines/src/lib/build/webpack.cjs +47 -0
  35. package/dist/powerlines/src/lib/build/webpack.mjs +45 -0
  36. package/dist/powerlines/src/lib/config-file.cjs +79 -0
  37. package/dist/powerlines/src/lib/config-file.mjs +76 -0
  38. package/dist/powerlines/src/lib/contexts/api-context.cjs +184 -0
  39. package/dist/powerlines/src/lib/contexts/api-context.mjs +182 -0
  40. package/dist/powerlines/src/lib/contexts/context.cjs +933 -0
  41. package/dist/powerlines/src/lib/contexts/context.mjs +931 -0
  42. package/dist/powerlines/src/lib/contexts/environment-context.cjs +160 -0
  43. package/dist/powerlines/src/lib/contexts/environment-context.mjs +159 -0
  44. package/dist/powerlines/src/lib/contexts/plugin-context.cjs +75 -0
  45. package/dist/powerlines/src/lib/contexts/plugin-context.mjs +74 -0
  46. package/dist/powerlines/src/lib/entry.cjs +69 -0
  47. package/dist/powerlines/src/lib/entry.mjs +67 -0
  48. package/dist/powerlines/src/lib/fs/helpers.cjs +85 -0
  49. package/dist/powerlines/src/lib/fs/helpers.mjs +81 -0
  50. package/dist/powerlines/src/lib/fs/storage/base.cjs +196 -0
  51. package/dist/powerlines/src/lib/fs/storage/base.mjs +195 -0
  52. package/dist/powerlines/src/lib/fs/storage/file-system.cjs +170 -0
  53. package/dist/powerlines/src/lib/fs/storage/file-system.mjs +169 -0
  54. package/dist/powerlines/src/lib/fs/storage/virtual.cjs +88 -0
  55. package/dist/powerlines/src/lib/fs/storage/virtual.mjs +87 -0
  56. package/dist/powerlines/src/lib/fs/vfs.cjs +830 -0
  57. package/dist/powerlines/src/lib/fs/vfs.mjs +828 -0
  58. package/dist/powerlines/src/lib/logger.cjs +58 -0
  59. package/dist/powerlines/src/lib/logger.mjs +55 -0
  60. package/dist/powerlines/src/lib/typescript/ts-morph.cjs +104 -0
  61. package/dist/powerlines/src/lib/typescript/ts-morph.mjs +102 -0
  62. package/dist/powerlines/src/lib/typescript/tsconfig.cjs +149 -0
  63. package/dist/powerlines/src/lib/typescript/tsconfig.mjs +144 -0
  64. package/dist/powerlines/src/lib/unplugin/factory.cjs +6 -0
  65. package/dist/powerlines/src/lib/unplugin/factory.mjs +8 -0
  66. package/dist/powerlines/src/lib/unplugin/helpers.cjs +17 -0
  67. package/dist/powerlines/src/lib/unplugin/helpers.mjs +16 -0
  68. package/dist/powerlines/src/lib/unplugin/index.cjs +3 -0
  69. package/dist/powerlines/src/lib/unplugin/index.mjs +5 -0
  70. package/dist/powerlines/src/lib/unplugin/plugin.cjs +128 -0
  71. package/dist/powerlines/src/lib/unplugin/plugin.mjs +127 -0
  72. package/dist/powerlines/src/lib/utilities/file-header.cjs +22 -0
  73. package/dist/powerlines/src/lib/utilities/file-header.mjs +21 -0
  74. package/dist/powerlines/src/lib/utilities/meta.cjs +45 -0
  75. package/dist/powerlines/src/lib/utilities/meta.mjs +41 -0
  76. package/dist/powerlines/src/lib/utilities/source-file.cjs +22 -0
  77. package/dist/powerlines/src/lib/utilities/source-file.mjs +21 -0
  78. package/dist/powerlines/src/plugin-utils/helpers.cjs +148 -0
  79. package/dist/powerlines/src/plugin-utils/helpers.mjs +138 -0
  80. package/dist/powerlines/src/plugin-utils/paths.cjs +36 -0
  81. package/dist/powerlines/src/plugin-utils/paths.mjs +35 -0
  82. package/dist/powerlines/src/types/babel.d.mts +4 -0
  83. package/dist/powerlines/src/types/build.cjs +15 -0
  84. package/dist/powerlines/src/types/build.d.cts +149 -0
  85. package/dist/powerlines/src/types/build.d.mts +149 -0
  86. package/dist/powerlines/src/types/build.mjs +14 -0
  87. package/dist/powerlines/src/types/commands.cjs +16 -0
  88. package/dist/powerlines/src/types/commands.d.cts +8 -0
  89. package/dist/powerlines/src/types/commands.d.mts +9 -0
  90. package/dist/powerlines/src/types/commands.mjs +15 -0
  91. package/dist/powerlines/src/types/config.d.cts +377 -0
  92. package/dist/powerlines/src/types/config.d.mts +379 -0
  93. package/dist/powerlines/src/types/context.d.cts +403 -0
  94. package/dist/powerlines/src/types/context.d.mts +405 -0
  95. package/dist/powerlines/src/types/fs.d.cts +486 -0
  96. package/dist/powerlines/src/types/fs.d.mts +486 -0
  97. package/dist/powerlines/src/types/hooks.d.mts +2 -0
  98. package/dist/powerlines/src/types/plugin.cjs +32 -0
  99. package/dist/powerlines/src/types/plugin.d.cts +231 -0
  100. package/dist/powerlines/src/types/plugin.d.mts +231 -0
  101. package/dist/powerlines/src/types/plugin.mjs +31 -0
  102. package/dist/powerlines/src/types/resolved.d.cts +82 -0
  103. package/dist/powerlines/src/types/resolved.d.mts +83 -0
  104. package/dist/powerlines/src/types/tsconfig.d.cts +69 -0
  105. package/dist/powerlines/src/types/tsconfig.d.mts +69 -0
  106. package/dist/types/index.cjs +0 -2
  107. package/dist/types/index.d.cts +1 -2
  108. package/dist/types/index.d.mts +1 -2
  109. package/dist/types/index.mjs +0 -3
  110. package/dist/types/plugin.cjs +0 -1
  111. package/dist/types/plugin.d.cts +12 -1
  112. package/dist/types/plugin.d.mts +12 -1
  113. package/dist/types/plugin.mjs +0 -2
  114. package/package.json +5 -5
  115. package/dist/helpers-B15z10jN.mjs +0 -1
  116. package/dist/helpers-LF26RHol.cjs +0 -0
  117. package/dist/index-9iG2qHLe.d.mts +0 -1
  118. package/dist/index-D4ELpJXS.d.cts +0 -1
  119. package/dist/index-D6CnpA_r.d.cts +0 -1
  120. package/dist/index-DL0uimUT.d.mts +0 -1
  121. package/dist/plugin-C5bG6Zu0.d.mts +0 -1772
  122. package/dist/plugin-Cl1J-dKa.d.cts +0 -1769
  123. package/dist/plugin-ifZVa20V.mjs +0 -1
  124. package/dist/plugin-pBKbb5K9.cjs +0 -0
  125. package/dist/types-U3zd8PTP.mjs +0 -1
  126. package/dist/types-o3zWarRp.cjs +0 -0
  127. package/dist/unplugin-Bo9KoKSB.d.cts +0 -7
  128. package/dist/unplugin-Ct4wZxE5.d.mts +0 -7
  129. package/dist/unplugin-GJmHohOE.mjs +0 -4617
  130. package/dist/unplugin-bKYETUU8.cjs +0 -4661
@@ -0,0 +1,170 @@
1
+ const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_helpers = require('../helpers.cjs');
3
+ const require_base = require('./base.cjs');
4
+ let __stryke_fs_helpers = require("@stryke/fs/helpers");
5
+ let __stryke_fs_list_files = require("@stryke/fs/list-files");
6
+ let __stryke_fs_exists = require("@stryke/fs/exists");
7
+ let __stryke_fs_is_file = require("@stryke/fs/is-file");
8
+ let __stryke_fs_read_file = require("@stryke/fs/read-file");
9
+ let __stryke_fs_write_file = require("@stryke/fs/write-file");
10
+ let node_fs = require("node:fs");
11
+ let node_fs_promises = require("node:fs/promises");
12
+
13
+ //#region ../powerlines/src/lib/fs/storage/file-system.ts
14
+ /**
15
+ * File system storage adapter implementation.
16
+ */
17
+ var FileSystemStorageAdapter = class extends require_base.BaseStorageAdapter {
18
+ /**
19
+ * A name identifying the storage adapter type.
20
+ */
21
+ name = "file-system";
22
+ /**
23
+ * The storage preset for the adapter.
24
+ *
25
+ * @remarks
26
+ * This can be used as an alternate way to identify the type of storage being used.
27
+ */
28
+ preset = "fs";
29
+ /**
30
+ * Constructor for the FileSystemStorageAdapter.
31
+ *
32
+ * @param options - Configuration options for the storage adapter.
33
+ */
34
+ constructor(options) {
35
+ super(options);
36
+ }
37
+ /**
38
+ * Synchronously checks if a key exists in the storage.
39
+ *
40
+ * @param key - The key to check for existence.
41
+ * @returns Returns `true` if the key exists, otherwise `false`.
42
+ */
43
+ existsSync(key) {
44
+ return (0, __stryke_fs_exists.existsSync)(this.resolve(key));
45
+ }
46
+ /**
47
+ * Asynchronously checks if a key exists in the storage.
48
+ *
49
+ * @param key - The key to check for existence.
50
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
51
+ */
52
+ async exists(key) {
53
+ return (0, __stryke_fs_exists.exists)(this.resolve(key));
54
+ }
55
+ /**
56
+ * Synchronously retrieves the value associated with a given key.
57
+ *
58
+ * @param key - The key whose value is to be retrieved.
59
+ * @returns The value associated with the key, or `null` if the key does not exist.
60
+ */
61
+ getSync(key) {
62
+ return (0, __stryke_fs_read_file.readFileSync)(this.resolve(key));
63
+ }
64
+ /**
65
+ * Asynchronously retrieves the value associated with a given key.
66
+ *
67
+ * @param key - The key whose value is to be retrieved.
68
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
69
+ */
70
+ async get(key) {
71
+ return (0, __stryke_fs_read_file.readFile)(this.resolve(key));
72
+ }
73
+ /**
74
+ * Synchronously sets the value for a given key.
75
+ *
76
+ * @param key - The key to set the value for.
77
+ * @param value - The value to set.
78
+ */
79
+ setSync(key, value) {
80
+ if (!this.options.isReadOnly) return (0, __stryke_fs_write_file.writeFileSync)(this.resolve(key), value);
81
+ }
82
+ /**
83
+ * Asynchronously sets the value for a given key.
84
+ *
85
+ * @param key - The key to set the value for.
86
+ * @param value - The value to set.
87
+ */
88
+ async set(key, value) {
89
+ if (!this.options.isReadOnly) return (0, __stryke_fs_write_file.writeFile)(this.resolve(key), value);
90
+ }
91
+ /**
92
+ * Synchronously removes a key from the storage.
93
+ *
94
+ * @param key - The key to remove.
95
+ */
96
+ removeSync(key) {
97
+ if (!this.options.isReadOnly) try {
98
+ return (0, node_fs.unlinkSync)(this.resolve(key));
99
+ } catch (err) {
100
+ return require_helpers.ignoreNotfound(err);
101
+ }
102
+ }
103
+ /**
104
+ * Asynchronously removes a key from the storage.
105
+ *
106
+ * @param key - The key to remove.
107
+ */
108
+ async remove(key) {
109
+ if (!this.options.isReadOnly) return (0, node_fs_promises.unlink)(this.resolve(key)).catch(require_helpers.ignoreNotfound);
110
+ }
111
+ /**
112
+ * Synchronously creates a directory at the specified path.
113
+ *
114
+ * @param dirPath - The path of the directory to create.
115
+ */
116
+ mkdirSync(dirPath) {
117
+ (0, __stryke_fs_helpers.createDirectorySync)(this.resolve(dirPath));
118
+ }
119
+ /**
120
+ * Creates a directory at the specified path.
121
+ *
122
+ * @param dirPath - The path of the directory to create.
123
+ */
124
+ async mkdir(dirPath) {
125
+ await (0, __stryke_fs_helpers.createDirectory)(this.resolve(dirPath));
126
+ }
127
+ /**
128
+ * Lists all keys under a given base path synchronously.
129
+ *
130
+ * @param base - The base path to list keys from.
131
+ * @returns An array of keys under the specified base path.
132
+ */
133
+ listSync(base) {
134
+ try {
135
+ return (0, __stryke_fs_list_files.listFilesSync)(this.resolve(base), { ignore: this.options.ignore });
136
+ } catch (err) {
137
+ return require_helpers.ignoreNotfound(err) ?? [];
138
+ }
139
+ }
140
+ /**
141
+ * Asynchronously lists all keys under a given base path.
142
+ *
143
+ * @param base - The base path to list keys from.
144
+ * @returns A promise that resolves to an array of keys under the specified base path.
145
+ */
146
+ async list(base) {
147
+ return (0, __stryke_fs_list_files.listFiles)(this.resolve(base), { ignore: this.options.ignore }).catch(require_helpers.ignoreNotfound).then((r) => r || []);
148
+ }
149
+ /**
150
+ * Synchronously checks if the given key is a directory.
151
+ *
152
+ * @param key - The key to check.
153
+ * @returns `true` if the key is a directory, otherwise `false`.
154
+ */
155
+ isDirectorySync(key) {
156
+ return (0, __stryke_fs_is_file.isDirectory)(this.resolve(key));
157
+ }
158
+ /**
159
+ * Synchronously checks if the given key is a file.
160
+ *
161
+ * @param key - The key to check.
162
+ * @returns `true` if the key is a file, otherwise `false`.
163
+ */
164
+ isFileSync(key) {
165
+ return !(0, __stryke_fs_is_file.isFile)(this.resolve(key));
166
+ }
167
+ };
168
+
169
+ //#endregion
170
+ exports.FileSystemStorageAdapter = FileSystemStorageAdapter;
@@ -0,0 +1,169 @@
1
+ import { ignoreNotfound } from "../helpers.mjs";
2
+ import { BaseStorageAdapter } from "./base.mjs";
3
+ import { createDirectory, createDirectorySync } from "@stryke/fs/helpers";
4
+ import { listFiles, listFilesSync } from "@stryke/fs/list-files";
5
+ import { exists, existsSync } from "@stryke/fs/exists";
6
+ import { isDirectory, isFile } from "@stryke/fs/is-file";
7
+ import { readFile, readFileSync } from "@stryke/fs/read-file";
8
+ import { writeFile, writeFileSync } from "@stryke/fs/write-file";
9
+ import { unlinkSync } from "node:fs";
10
+ import { unlink } from "node:fs/promises";
11
+
12
+ //#region ../powerlines/src/lib/fs/storage/file-system.ts
13
+ /**
14
+ * File system storage adapter implementation.
15
+ */
16
+ var FileSystemStorageAdapter = class extends BaseStorageAdapter {
17
+ /**
18
+ * A name identifying the storage adapter type.
19
+ */
20
+ name = "file-system";
21
+ /**
22
+ * The storage preset for the adapter.
23
+ *
24
+ * @remarks
25
+ * This can be used as an alternate way to identify the type of storage being used.
26
+ */
27
+ preset = "fs";
28
+ /**
29
+ * Constructor for the FileSystemStorageAdapter.
30
+ *
31
+ * @param options - Configuration options for the storage adapter.
32
+ */
33
+ constructor(options) {
34
+ super(options);
35
+ }
36
+ /**
37
+ * Synchronously checks if a key exists in the storage.
38
+ *
39
+ * @param key - The key to check for existence.
40
+ * @returns Returns `true` if the key exists, otherwise `false`.
41
+ */
42
+ existsSync(key) {
43
+ return existsSync(this.resolve(key));
44
+ }
45
+ /**
46
+ * Asynchronously checks if a key exists in the storage.
47
+ *
48
+ * @param key - The key to check for existence.
49
+ * @returns A promise that resolves to `true` if the key exists, otherwise `false`.
50
+ */
51
+ async exists(key) {
52
+ return exists(this.resolve(key));
53
+ }
54
+ /**
55
+ * Synchronously retrieves the value associated with a given key.
56
+ *
57
+ * @param key - The key whose value is to be retrieved.
58
+ * @returns The value associated with the key, or `null` if the key does not exist.
59
+ */
60
+ getSync(key) {
61
+ return readFileSync(this.resolve(key));
62
+ }
63
+ /**
64
+ * Asynchronously retrieves the value associated with a given key.
65
+ *
66
+ * @param key - The key whose value is to be retrieved.
67
+ * @returns A promise that resolves to the value associated with the key, or `null` if the key does not exist.
68
+ */
69
+ async get(key) {
70
+ return readFile(this.resolve(key));
71
+ }
72
+ /**
73
+ * Synchronously sets the value for a given key.
74
+ *
75
+ * @param key - The key to set the value for.
76
+ * @param value - The value to set.
77
+ */
78
+ setSync(key, value) {
79
+ if (!this.options.isReadOnly) return writeFileSync(this.resolve(key), value);
80
+ }
81
+ /**
82
+ * Asynchronously sets the value for a given key.
83
+ *
84
+ * @param key - The key to set the value for.
85
+ * @param value - The value to set.
86
+ */
87
+ async set(key, value) {
88
+ if (!this.options.isReadOnly) return writeFile(this.resolve(key), value);
89
+ }
90
+ /**
91
+ * Synchronously removes a key from the storage.
92
+ *
93
+ * @param key - The key to remove.
94
+ */
95
+ removeSync(key) {
96
+ if (!this.options.isReadOnly) try {
97
+ return unlinkSync(this.resolve(key));
98
+ } catch (err) {
99
+ return ignoreNotfound(err);
100
+ }
101
+ }
102
+ /**
103
+ * Asynchronously removes a key from the storage.
104
+ *
105
+ * @param key - The key to remove.
106
+ */
107
+ async remove(key) {
108
+ if (!this.options.isReadOnly) return unlink(this.resolve(key)).catch(ignoreNotfound);
109
+ }
110
+ /**
111
+ * Synchronously creates a directory at the specified path.
112
+ *
113
+ * @param dirPath - The path of the directory to create.
114
+ */
115
+ mkdirSync(dirPath) {
116
+ createDirectorySync(this.resolve(dirPath));
117
+ }
118
+ /**
119
+ * Creates a directory at the specified path.
120
+ *
121
+ * @param dirPath - The path of the directory to create.
122
+ */
123
+ async mkdir(dirPath) {
124
+ await createDirectory(this.resolve(dirPath));
125
+ }
126
+ /**
127
+ * Lists all keys under a given base path synchronously.
128
+ *
129
+ * @param base - The base path to list keys from.
130
+ * @returns An array of keys under the specified base path.
131
+ */
132
+ listSync(base) {
133
+ try {
134
+ return listFilesSync(this.resolve(base), { ignore: this.options.ignore });
135
+ } catch (err) {
136
+ return ignoreNotfound(err) ?? [];
137
+ }
138
+ }
139
+ /**
140
+ * Asynchronously lists all keys under a given base path.
141
+ *
142
+ * @param base - The base path to list keys from.
143
+ * @returns A promise that resolves to an array of keys under the specified base path.
144
+ */
145
+ async list(base) {
146
+ return listFiles(this.resolve(base), { ignore: this.options.ignore }).catch(ignoreNotfound).then((r) => r || []);
147
+ }
148
+ /**
149
+ * Synchronously checks if the given key is a directory.
150
+ *
151
+ * @param key - The key to check.
152
+ * @returns `true` if the key is a directory, otherwise `false`.
153
+ */
154
+ isDirectorySync(key) {
155
+ return isDirectory(this.resolve(key));
156
+ }
157
+ /**
158
+ * Synchronously checks if the given key is a file.
159
+ *
160
+ * @param key - The key to check.
161
+ * @returns `true` if the key is a file, otherwise `false`.
162
+ */
163
+ isFileSync(key) {
164
+ return !isFile(this.resolve(key));
165
+ }
166
+ };
167
+
168
+ //#endregion
169
+ export { FileSystemStorageAdapter };
@@ -0,0 +1,88 @@
1
+ const require_rolldown_runtime = require('../../../../../_virtual/rolldown_runtime.cjs');
2
+ const require_base = require('./base.cjs');
3
+ let __stryke_path_is_parent_path = require("@stryke/path/is-parent-path");
4
+
5
+ //#region ../powerlines/src/lib/fs/storage/virtual.ts
6
+ /**
7
+ * Virtual/in-memory storage adapter implementation.
8
+ */
9
+ var VirtualStorageAdapter = class extends require_base.BaseStorageAdapter {
10
+ /**
11
+ * A name identifying the storage adapter type.
12
+ */
13
+ name = "virtual";
14
+ /**
15
+ * The storage preset for the adapter.
16
+ *
17
+ * @remarks
18
+ * This can be used as an alternate way to identify the type of storage being used.
19
+ */
20
+ preset = "virtual";
21
+ /**
22
+ * In-memory data storage.
23
+ */
24
+ data = /* @__PURE__ */ new Map();
25
+ /**
26
+ * Constructor for the VirtualStorageAdapter.
27
+ *
28
+ * @param options - Configuration options for the storage adapter.
29
+ */
30
+ constructor(options) {
31
+ super(options);
32
+ }
33
+ /**
34
+ * Synchronously checks if a key exists in the storage.
35
+ *
36
+ * @param key - The key to check for existence.
37
+ * @returns Returns `true` if the key exists, otherwise `false`.
38
+ */
39
+ existsSync(key) {
40
+ return this.data.has(this.resolve(key));
41
+ }
42
+ /**
43
+ * Synchronously retrieves the value associated with a given key.
44
+ *
45
+ * @param key - The key whose value is to be retrieved.
46
+ * @returns The value associated with the key, or `null` if the key does not exist.
47
+ */
48
+ getSync(key) {
49
+ return this.data.get(this.resolve(key)) ?? null;
50
+ }
51
+ /**
52
+ * Synchronously sets the value for a given key.
53
+ *
54
+ * @param key - The key to set the value for.
55
+ * @param value - The value to set.
56
+ */
57
+ setSync(key, value) {
58
+ if (!this.options.isReadOnly) this.data.set(this.resolve(key), value);
59
+ }
60
+ /**
61
+ * Synchronously removes a key from the storage.
62
+ *
63
+ * @param key - The key to remove.
64
+ */
65
+ removeSync(key) {
66
+ if (!this.options.isReadOnly) this.data.delete(this.resolve(key));
67
+ }
68
+ /**
69
+ * Lists all keys under a given base path synchronously.
70
+ *
71
+ * @param base - The base path to list keys from.
72
+ * @returns An array of keys under the specified base path.
73
+ */
74
+ listSync(base) {
75
+ return [...this.data.keys().filter((key) => !base ? true : (0, __stryke_path_is_parent_path.isParentPath)(key, this.resolve(base)))];
76
+ }
77
+ /**
78
+ * Disposes of the storage adapter, releasing any held resources.
79
+ *
80
+ * @returns A promise that resolves when the disposal is complete.
81
+ */
82
+ async dispose() {
83
+ return this.clear();
84
+ }
85
+ };
86
+
87
+ //#endregion
88
+ exports.VirtualStorageAdapter = VirtualStorageAdapter;
@@ -0,0 +1,87 @@
1
+ import { BaseStorageAdapter } from "./base.mjs";
2
+ import { isParentPath } from "@stryke/path/is-parent-path";
3
+
4
+ //#region ../powerlines/src/lib/fs/storage/virtual.ts
5
+ /**
6
+ * Virtual/in-memory storage adapter implementation.
7
+ */
8
+ var VirtualStorageAdapter = class extends BaseStorageAdapter {
9
+ /**
10
+ * A name identifying the storage adapter type.
11
+ */
12
+ name = "virtual";
13
+ /**
14
+ * The storage preset for the adapter.
15
+ *
16
+ * @remarks
17
+ * This can be used as an alternate way to identify the type of storage being used.
18
+ */
19
+ preset = "virtual";
20
+ /**
21
+ * In-memory data storage.
22
+ */
23
+ data = /* @__PURE__ */ new Map();
24
+ /**
25
+ * Constructor for the VirtualStorageAdapter.
26
+ *
27
+ * @param options - Configuration options for the storage adapter.
28
+ */
29
+ constructor(options) {
30
+ super(options);
31
+ }
32
+ /**
33
+ * Synchronously checks if a key exists in the storage.
34
+ *
35
+ * @param key - The key to check for existence.
36
+ * @returns Returns `true` if the key exists, otherwise `false`.
37
+ */
38
+ existsSync(key) {
39
+ return this.data.has(this.resolve(key));
40
+ }
41
+ /**
42
+ * Synchronously retrieves the value associated with a given key.
43
+ *
44
+ * @param key - The key whose value is to be retrieved.
45
+ * @returns The value associated with the key, or `null` if the key does not exist.
46
+ */
47
+ getSync(key) {
48
+ return this.data.get(this.resolve(key)) ?? null;
49
+ }
50
+ /**
51
+ * Synchronously sets the value for a given key.
52
+ *
53
+ * @param key - The key to set the value for.
54
+ * @param value - The value to set.
55
+ */
56
+ setSync(key, value) {
57
+ if (!this.options.isReadOnly) this.data.set(this.resolve(key), value);
58
+ }
59
+ /**
60
+ * Synchronously removes a key from the storage.
61
+ *
62
+ * @param key - The key to remove.
63
+ */
64
+ removeSync(key) {
65
+ if (!this.options.isReadOnly) this.data.delete(this.resolve(key));
66
+ }
67
+ /**
68
+ * Lists all keys under a given base path synchronously.
69
+ *
70
+ * @param base - The base path to list keys from.
71
+ * @returns An array of keys under the specified base path.
72
+ */
73
+ listSync(base) {
74
+ return [...this.data.keys().filter((key) => !base ? true : isParentPath(key, this.resolve(base)))];
75
+ }
76
+ /**
77
+ * Disposes of the storage adapter, releasing any held resources.
78
+ *
79
+ * @returns A promise that resolves when the disposal is complete.
80
+ */
81
+ async dispose() {
82
+ return this.clear();
83
+ }
84
+ };
85
+
86
+ //#endregion
87
+ export { VirtualStorageAdapter };