@poe-platform/safe-fs 0.1.743 → 0.1.744

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.
@@ -1,4 +1,4 @@
1
- import { posix } from "#safe-fs-platform";
1
+ import { posix } from "#safe-fs-platform-path";
2
2
  export { assertPathWithin, isPathWithin, normalizePath, relativePath, resolvePath, validatePath } from "./virtual-path.js";
3
3
  export declare const posixPath: typeof posix;
4
4
  export declare const basename: typeof posix.basename;
@@ -1,4 +1,4 @@
1
- import { posix } from "#safe-fs-platform";
1
+ import { posix } from "#safe-fs-platform-path";
2
2
  export { assertPathWithin, isPathWithin, normalizePath, relativePath, resolvePath, validatePath } from "./virtual-path.js";
3
3
  export const posixPath = posix;
4
4
  export const basename = posix.basename;
@@ -0,0 +1 @@
1
+ export { posixPath as posix } from "../contracts/portable-path.js";
@@ -0,0 +1 @@
1
+ export { posixPath as posix } from "../contracts/portable-path.js";
@@ -1,4 +1,3 @@
1
- export { posixPath as posix } from "../contracts/portable-path.js";
2
1
  import type { FsOptions } from "../contracts/filesystem.js";
3
2
  import type { ScopedTransportBudgetFrame } from "./transport-budget.js";
4
3
  export type PlatformErrno = number | undefined;
@@ -1,5 +1,4 @@
1
1
  import { FsError } from "../contracts/errors.js";
2
- export { posixPath as posix } from "../contracts/portable-path.js";
3
2
  import { chargeTransportOptions } from "./transport-budget.js";
4
3
  export const platform = Object.freeze({
5
4
  nativeFileSystem: Object.freeze({ open: false, permissions: false, timestamps: false, conditionalChmod: false, trustedOwnedStaging: false, atomicRename: false }),
@@ -0,0 +1 @@
1
+ export { posix } from "node:path";
@@ -0,0 +1 @@
1
+ export { posix } from "node:path";
@@ -1,4 +1,3 @@
1
- export { posix } from "node:path";
2
1
  import type { FsOptions } from "../contracts/filesystem.js";
3
2
  import { type ScopedTransportBudgetFrame } from "./transport-budget.js";
4
3
  export type PlatformErrno = number;
@@ -1,5 +1,4 @@
1
1
  import { AsyncLocalStorage } from "node:async_hooks";
2
- export { posix } from "node:path";
3
2
  import { randomUUID } from "node:crypto";
4
3
  import * as util from "node:util";
5
4
  import { constants } from "node:os";
@@ -42,7 +42,9 @@ function namePart(point) {
42
42
  || (point >= 48 && point <= 57) || (point >= 0x300 && point <= 0x36f)
43
43
  || (point >= 0x203f && point <= 0x2040);
44
44
  }
45
- function qualifiedNameSync(name) {
45
+ function qualifiedNameSync(name, cache) {
46
+ if (cache.name === name)
47
+ return cache.parts;
46
48
  let prefix = "";
47
49
  let start = 0;
48
50
  let first = true;
@@ -64,40 +66,13 @@ function qualifiedNameSync(name) {
64
66
  }
65
67
  if (first)
66
68
  invalid("invalid qualified name");
67
- return [prefix, name.slice(start)];
68
- }
69
- function* qualifiedName(name) {
70
- let prefix = "";
71
- let start = 0;
72
- let first = true;
73
- let work = 0;
74
- for (let offset = 0; offset < name.length;) {
75
- const point = name.codePointAt(offset);
76
- if (point === 58) {
77
- if (start !== 0 || first)
78
- invalid("invalid qualified name");
79
- prefix = name.slice(0, offset);
80
- start = offset + 1;
81
- first = true;
82
- }
83
- else {
84
- if (!(first ? nameStart(point) : namePart(point)))
85
- invalid("invalid qualified name");
86
- first = false;
87
- }
88
- const width = point > 0xffff ? 2 : 1;
89
- offset += width;
90
- work += width;
91
- if (work >= 512) {
92
- yield work;
93
- work = 0;
94
- }
69
+ const parts = [prefix, name.slice(start)];
70
+ // Retain only one short name; namespace resolution still happens per element.
71
+ if (name.length <= 512) {
72
+ cache.name = name;
73
+ cache.parts = parts;
95
74
  }
96
- if (first)
97
- invalid("invalid qualified name");
98
- if (work)
99
- yield work;
100
- return [prefix, name.slice(start)];
75
+ return parts;
101
76
  }
102
77
  function* entities(text) {
103
78
  let result = "";
@@ -274,6 +249,7 @@ export function* parseXmlSteps(input, limits = {}) {
274
249
  let attributeCount = 0;
275
250
  let contentNodes = 0;
276
251
  let previousEmpty;
252
+ const qualifiedNames = { name: undefined, parts: undefined };
277
253
  const admitContent = () => {
278
254
  if (++contentNodes > maxContentNodes)
279
255
  throw new XmlLimitError("maxContentNodes", "XML content node limit exceeded");
@@ -298,7 +274,7 @@ export function* parseXmlSteps(input, limits = {}) {
298
274
  offset++;
299
275
  }
300
276
  const name = source.slice(start, offset);
301
- const [prefix, localName] = qualifiedNameSync(name);
277
+ const [prefix, localName] = qualifiedNameSync(name, qualifiedNames);
302
278
  return [name, prefix, localName, (offset - start) * 2];
303
279
  };
304
280
  while (offset < source.length) {
@@ -475,12 +451,11 @@ export function* parseXmlSteps(input, limits = {}) {
475
451
  yield 512;
476
452
  pendingWork -= 512;
477
453
  }
478
- attributes ??= new Map();
479
- if (attributes.has(attribute))
454
+ if (attributes?.has(attribute))
480
455
  invalid("duplicate attribute");
481
456
  if (++attributeCount > maxAttributes)
482
457
  throw new XmlLimitError("maxAttributes", "XML attribute limit exceeded");
483
- if (attributes.size >= maxAttributesPerElement)
458
+ if ((attributes?.size ?? 0) >= maxAttributesPerElement)
484
459
  throw new XmlLimitError("maxAttributesPerElement", "XML attribute limit exceeded");
485
460
  pendingWork += skipWhitespace();
486
461
  if (source[offset++] !== "=")
@@ -513,7 +488,7 @@ export function* parseXmlSteps(input, limits = {}) {
513
488
  pendingWork -= 512;
514
489
  }
515
490
  admitText(value);
516
- attributes.set(attribute, value);
491
+ (attributes ??= new Map()).set(attribute, value);
517
492
  attrMeta.push([attribute, attrPrefix, attrLocal]);
518
493
  offset = end + 1;
519
494
  if (attribute === "xmlns" || attribute.startsWith("xmlns:")) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@poe-platform/safe-fs",
3
- "version": "0.1.743",
3
+ "version": "0.1.744",
4
4
  "description": "Composable filesystem with a portable core and explicit Node adapters",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -144,6 +144,16 @@
144
144
  "browser": "./dist/safe-fs/platform/browser.js",
145
145
  "default": "./dist/safe-fs/platform/node.js"
146
146
  },
147
+ "#safe-fs-platform-path": {
148
+ "types": {
149
+ "workerd": "./dist/safe-fs/platform/browser-path.d.ts",
150
+ "browser": "./dist/safe-fs/platform/browser-path.d.ts",
151
+ "default": "./dist/safe-fs/platform/node-path.d.ts"
152
+ },
153
+ "workerd": "./dist/safe-fs/platform/browser-path.js",
154
+ "browser": "./dist/safe-fs/platform/browser-path.js",
155
+ "default": "./dist/safe-fs/platform/node-path.js"
156
+ },
147
157
  "#safe-fs-native-seek": {
148
158
  "types": "./dist/safe-fs/native/fs-seek/loader.d.ts",
149
159
  "workerd": "./dist/safe-fs/node/native-seek-unavailable.js",