@tokenoftrust/storefront-runner 7.10.0 → 7.10.1
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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "7.10.
|
|
3
|
+
"version": "7.10.1",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|
|
@@ -579,30 +579,39 @@ export function createCaptureArtifactRewriter(rewrites: readonly CaptureRewrite[
|
|
|
579
579
|
// once, at each `/`, to find the only rewrites with a needle that can occur in it: wherever a needle
|
|
580
580
|
// occurs, a `/` is followed by its anchor. A rewrite with a needle lacking an anchor (no slash, or
|
|
581
581
|
// fewer characters after it) is always tried.
|
|
582
|
+
// A file name shorter than the anchor length is its own anchor (its whole text), so short names
|
|
583
|
+
// such as `2-4.avif` are indexed rather than always tried. `anchorLengths` records the distinct
|
|
584
|
+
// anchor lengths in use, and an artifact is probed once per length at each `/`.
|
|
582
585
|
const anchored = new Map<string, number[]>();
|
|
586
|
+
const anchorLengths = new Set<number>();
|
|
583
587
|
const always: number[] = [];
|
|
584
588
|
prepared.forEach(({ needles }, index) => {
|
|
585
589
|
const anchors = new Set<string>();
|
|
586
590
|
for (const needle of needles) {
|
|
587
591
|
const slash = needle.lastIndexOf("/");
|
|
588
|
-
if (slash < 0 || needle.length -
|
|
592
|
+
if (slash < 0 || slash === needle.length - 1) {
|
|
589
593
|
always.push(index);
|
|
590
594
|
return;
|
|
591
595
|
}
|
|
592
|
-
|
|
596
|
+
const anchor = needle.substr(slash + 1, REWRITE_ANCHOR_LENGTH);
|
|
597
|
+
anchors.add(anchor);
|
|
593
598
|
}
|
|
594
599
|
for (const anchor of anchors) {
|
|
600
|
+
anchorLengths.add(anchor.length);
|
|
595
601
|
const list = anchored.get(anchor);
|
|
596
602
|
if (list) list.push(index);
|
|
597
603
|
else anchored.set(anchor, [index]);
|
|
598
604
|
}
|
|
599
605
|
});
|
|
606
|
+
const lengths = [...anchorLengths].sort((a, b) => a - b);
|
|
600
607
|
const candidatesIn = (content: string): number[] => {
|
|
601
608
|
if (anchored.size === 0) return always;
|
|
602
609
|
const found = new Set<number>(always);
|
|
603
610
|
for (let at = content.indexOf("/"); at !== -1; at = content.indexOf("/", at + 1)) {
|
|
604
|
-
|
|
605
|
-
|
|
611
|
+
for (const length of lengths) {
|
|
612
|
+
const list = anchored.get(content.substr(at + 1, length));
|
|
613
|
+
if (list) for (const index of list) found.add(index);
|
|
614
|
+
}
|
|
606
615
|
}
|
|
607
616
|
return [...found].sort((a, b) => a - b);
|
|
608
617
|
};
|