@poe-platform/safe-fs 0.1.720 → 0.1.722

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 (55) hide show
  1. package/README.md +64 -18
  2. package/dist/safe-fs/bridge/filesystem.d.ts +2 -0
  3. package/dist/safe-fs/bridge/filesystem.js +17 -7
  4. package/dist/safe-fs/bridge/types.d.ts +2 -0
  5. package/dist/safe-fs/contracts/descriptor.d.ts +5 -0
  6. package/dist/safe-fs/contracts/filesystem.d.ts +12 -0
  7. package/dist/safe-fs/contracts/io.d.ts +3 -1
  8. package/dist/safe-fs/contracts/io.js +48 -16
  9. package/dist/safe-fs/core.d.ts +2 -1
  10. package/dist/safe-fs/core.js +1 -1
  11. package/dist/safe-fs/fs/capabilities.js +6 -3
  12. package/dist/safe-fs/fs/descriptor.js +9 -2
  13. package/dist/safe-fs/fs/devices/index.d.ts +1 -0
  14. package/dist/safe-fs/fs/devices/index.js +24 -6
  15. package/dist/safe-fs/fs/memory/index.d.ts +1 -0
  16. package/dist/safe-fs/fs/memory/index.js +75 -3
  17. package/dist/safe-fs/fs/memory/limits.js +6 -4
  18. package/dist/safe-fs/fs/mount/index.d.ts +4 -0
  19. package/dist/safe-fs/fs/mount/index.js +74 -11
  20. package/dist/safe-fs/fs/object-publication/index.js +6 -6
  21. package/dist/safe-fs/fs/overlay/index.d.ts +4 -2
  22. package/dist/safe-fs/fs/overlay/index.js +92 -36
  23. package/dist/safe-fs/fs/quota/index.js +18 -16
  24. package/dist/safe-fs/fs/readonly/index.js +5 -3
  25. package/dist/safe-fs/fs/real/index.d.ts +21 -1
  26. package/dist/safe-fs/fs/real/index.js +266 -22
  27. package/dist/safe-fs/fs/s3/filesystem.d.ts +8 -0
  28. package/dist/safe-fs/fs/s3/filesystem.js +58 -12
  29. package/dist/safe-fs/fs/s3/http/request.d.ts +1 -1
  30. package/dist/safe-fs/fs/s3/http/request.js +1 -1
  31. package/dist/safe-fs/fs/s3/http/transport.js +8 -6
  32. package/dist/safe-fs/fs/s3/http/xml.d.ts +4 -1
  33. package/dist/safe-fs/fs/s3/http/xml.js +6 -2
  34. package/dist/safe-fs/fs/s3/namespace.js +12 -10
  35. package/dist/safe-fs/fs/scoped.d.ts +1 -0
  36. package/dist/safe-fs/fs/scoped.js +54 -35
  37. package/dist/safe-fs/fs/webdav/webdav.d.ts +4 -1
  38. package/dist/safe-fs/fs/webdav/webdav.js +30 -22
  39. package/dist/safe-fs/node/filesystem.d.ts +4 -1
  40. package/dist/safe-fs/node/filesystem.js +7 -1
  41. package/dist/safe-fs/node/host.d.ts +3 -0
  42. package/dist/safe-fs/node/host.js +78 -0
  43. package/dist/safe-fs/node/index.d.ts +2 -1
  44. package/dist/safe-fs/node/index.js +2 -1
  45. package/dist/safe-fs/platform/browser.d.ts +1 -0
  46. package/dist/safe-fs/platform/browser.js +1 -0
  47. package/dist/safe-fs/platform/node.d.ts +1 -0
  48. package/dist/safe-fs/platform/node.js +1 -0
  49. package/dist/safe-fs/python/emscripten.d.ts +1 -0
  50. package/dist/safe-fs/python/emscripten.js +5 -5
  51. package/dist/safe-fs/python/filesystem.js +5 -5
  52. package/dist/safe-fs/python/native.d.ts +1 -0
  53. package/dist/safe-fs/python/native.js +3 -2
  54. package/dist/safe-fs/xml.js +32 -21
  55. package/package.json +1 -1
@@ -185,22 +185,22 @@ function* validDeclaration(content, expectedEncoding) {
185
185
  return offset === content.length;
186
186
  }
187
187
  export function* parseXmlSteps(input, limits = {}) {
188
- const maxDepth = limits.maxDepth ?? 64;
189
- const maxNodes = limits.maxNodes ?? 100_000;
190
- const maxAttributes = limits.maxAttributes ?? 10_000;
188
+ const maxDepth = limits.maxDepth ?? Infinity;
189
+ const maxNodes = limits.maxNodes ?? Infinity;
190
+ const maxAttributes = limits.maxAttributes ?? Infinity;
191
191
  const retainContent = limits.retainContent !== false;
192
- const maxContentNodes = limits.maxContentNodes ?? (retainContent ? 100_000 : maxNodes);
192
+ const maxContentNodes = limits.maxContentNodes ?? Infinity;
193
193
  const emptyContent = Object.freeze([]);
194
194
  const emptyAttributes = Object.freeze([]);
195
195
  const emptyNamespaces = new Map();
196
- const maxAttributesPerElement = limits.maxAttributesPerElement ?? 128;
197
- const maxNamespaces = limits.maxNamespaces ?? 256;
198
- for (const limit of [maxDepth, maxNodes, maxAttributes, maxContentNodes, maxAttributesPerElement, maxNamespaces]) {
199
- if (!Number.isSafeInteger(limit) || limit < 1)
196
+ const maxAttributesPerElement = limits.maxAttributesPerElement ?? Infinity;
197
+ const maxNamespaces = limits.maxNamespaces ?? Infinity;
198
+ for (const limit of [limits.maxDepth, limits.maxNodes, limits.maxAttributes, limits.maxContentNodes, limits.maxAttributesPerElement, limits.maxNamespaces]) {
199
+ if (limit !== undefined && ((limit !== Infinity && !Number.isSafeInteger(limit)) || limit < 1))
200
200
  throw new RangeError("XML limits must be positive integers");
201
201
  }
202
- const maxTextLength = limits.maxTextLength ?? Number.MAX_SAFE_INTEGER;
203
- if (!Number.isSafeInteger(maxTextLength) || maxTextLength < 1)
202
+ const maxTextLength = limits.maxTextLength ?? Infinity;
203
+ if (limits.maxTextLength !== undefined && ((maxTextLength !== Infinity && !Number.isSafeInteger(maxTextLength)) || maxTextLength < 1))
204
204
  throw new RangeError("XML limits must be positive integers");
205
205
  let textLength = 0;
206
206
  const admitText = (text) => {
@@ -209,31 +209,42 @@ export function* parseXmlSteps(input, limits = {}) {
209
209
  textLength += text.length;
210
210
  };
211
211
  const chunks = [];
212
- let chunk = "";
213
- for (let index = input.charCodeAt(0) === 0xfeff ? 1 : 0; index < input.length; index++) {
212
+ const start = input.charCodeAt(0) === 0xfeff ? 1 : 0;
213
+ let chunkStart = start;
214
+ let chunkLength = 0;
215
+ let normalizedChunk = "";
216
+ // Keep validated spans intact; only changed line endings need new strings.
217
+ for (let index = start; index < input.length; index++) {
214
218
  const point = input.codePointAt(index);
215
219
  if (!validCharacter(point))
216
220
  invalid("invalid character");
217
221
  if (point === 13) {
218
- chunk += "\n";
222
+ normalizedChunk += input.slice(chunkStart, index) + "\n";
219
223
  if (input.charCodeAt(index + 1) === 10)
220
224
  index++;
225
+ chunkStart = index + 1;
226
+ chunkLength++;
221
227
  }
222
228
  else {
223
- chunk += String.fromCodePoint(point);
229
+ chunkLength += point > 0xffff ? 2 : 1;
224
230
  if (point > 0xffff)
225
231
  index++;
226
232
  }
227
- if (chunk.length >= 512) {
228
- chunks.push(chunk);
229
- chunk = "";
233
+ if (chunkLength >= 512) {
234
+ if (normalizedChunk) {
235
+ chunks.push(normalizedChunk + input.slice(chunkStart, index + 1));
236
+ normalizedChunk = "";
237
+ chunkStart = index + 1;
238
+ }
239
+ chunkLength = 0;
230
240
  yield 512;
231
241
  }
232
242
  }
233
- chunks.push(chunk);
234
- if (chunk.length)
235
- yield chunk.length;
236
- const source = chunks.join("");
243
+ if (chunkLength)
244
+ yield chunkLength;
245
+ if (chunks.length || normalizedChunk)
246
+ chunks.push(normalizedChunk + input.slice(chunkStart));
247
+ const source = chunks.length ? chunks.join("") : input.slice(start);
237
248
  const stack = [];
238
249
  let root;
239
250
  const prolog = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-fs",
3
- "version": "0.1.720",
3
+ "version": "0.1.722",
4
4
  "description": "Composable filesystem with a portable core and explicit Node adapters",
5
5
  "type": "module",
6
6
  "license": "MIT",