@valbuild/core 0.138.0 → 0.138.2
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/CHANGELOG.md +13 -0
- package/dist/declarations/src/index.d.ts +2 -0
- package/dist/declarations/src/source/filename.d.ts +37 -0
- package/dist/{index-a25822a3.esm.js → index-36b5e0cb.esm.js} +62 -9
- package/dist/{index-3296fc4f.cjs.prod.js → index-87b5aa27.cjs.prod.js} +62 -9
- package/dist/{index-d3c51a0d.cjs.dev.js → index-8e33ef62.cjs.dev.js} +62 -9
- package/dist/valbuild-core.cjs.dev.js +1 -1
- package/dist/valbuild-core.cjs.prod.js +1 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @valbuild/core
|
|
2
2
|
|
|
3
|
+
## 0.138.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#760](https://github.com/valbuild/val/pull/760) [`cf3bbc8`](https://github.com/valbuild/val/commit/cf3bbc8fc89ff349aac5ab101d0b4f28164583e6) Thanks [@freekh](https://github.com/freekh)! - Files and images can now be renamed in the Studio, for local files and remote ones.
|
|
8
|
+
|
|
9
|
+
- **Rename a file in a gallery** from its properties: click the pencil next to the file name. Every field that uses the file is updated to the new name in the same step, including images inside rich text, and the dialog says how many places will change before you save.
|
|
10
|
+
- **Rename the file of an image or file field** with the new **Rename** button. A field that picks its file from a gallery sends you to the gallery instead, because other fields may use the same file.
|
|
11
|
+
- **You choose the name, Val keeps the rest.** The short hash at the end of the name (`_a1b2c`) and the file extension stay as they are, so two different files can never end up with the same name. The name is cleaned up the same way an upload's is: lower case, and characters that do not belong in a URL are dropped.
|
|
12
|
+
- **Renaming a local file moves it.** The file is saved under the new name and the old file is deleted when you publish, so nothing is left behind to clean up. If another field uses the same file without going through a gallery, pick the file again in that field.
|
|
13
|
+
- **Renaming a remote file is instant.** Remote files are stored by their content, so a published remote file only gets a new address and nothing is uploaded again.
|
|
14
|
+
- **Gallery images used in rich text now count as references.** A gallery file used only inside rich text could be deleted, which left the text pointing at nothing. It is now listed under the file's references and blocks the delete like any other use.
|
|
15
|
+
|
|
3
16
|
## 0.138.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
|
@@ -39,6 +39,7 @@ import { isJson, getJsonImport, resolveJsonValues } from "./source/json.js";
|
|
|
39
39
|
import { isExternal, hasInlineExternalEntries } from "./source/external.js";
|
|
40
40
|
import { createExternalFileRef, splitExternalFileRef, isExternalFileRef } from "./source/externalRef.js";
|
|
41
41
|
import { createRemoteRef } from "./source/remote.js";
|
|
42
|
+
import { createRenamedFilename } from "./source/filename.js";
|
|
42
43
|
import { getValidationBasis, getValidationHash } from "./remote/validationBasis.js";
|
|
43
44
|
import { getFileHash, hashToRemoteFileHash } from "./remote/fileHash.js";
|
|
44
45
|
import { splitRemoteRef } from "./remote/splitRemoteRef.js";
|
|
@@ -233,5 +234,6 @@ declare const Internal: {
|
|
|
233
234
|
VAL_STATE_COOKIE: "val_state";
|
|
234
235
|
VAL_SESSION_COOKIE: "val_session";
|
|
235
236
|
createFilename: (data: string | null, filename: string | null, metadata: FileMetadata | ImageMetadata | undefined, sha256: string) => string | null;
|
|
237
|
+
createRenamedFilename: typeof createRenamedFilename;
|
|
236
238
|
};
|
|
237
239
|
export { Internal };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How Val names a media file: a cleaned-up base name, the first five hex of the
|
|
3
|
+
* content's SHA-256, and the extension — `hero-mountains_a1b2c.jpg`.
|
|
4
|
+
*
|
|
5
|
+
* Two producers need this and must agree: an upload (`createFilename`, which
|
|
6
|
+
* has the bytes) and a rename (`createRenamedFilename`, which keeps the bytes
|
|
7
|
+
* and only changes what is in front of the hash). If they disagreed, renaming a
|
|
8
|
+
* file to the name it was uploaded with would give it a different name.
|
|
9
|
+
*/
|
|
10
|
+
/** The `_a1b2c` a Val filename ends in, before the extension. */
|
|
11
|
+
export declare const FILENAME_HASH_SUFFIX_LENGTH = 5;
|
|
12
|
+
/**
|
|
13
|
+
* The part of a filename a person chose, made safe for a URL path.
|
|
14
|
+
*
|
|
15
|
+
* Lower case, with everything `encodeURIComponent` would escape dropped rather
|
|
16
|
+
* than escaped — a path segment that needs decoding is a path segment that gets
|
|
17
|
+
* decoded twice somewhere. Can return the empty string, for a name made only of
|
|
18
|
+
* such characters; a caller that needs a name has to refuse that.
|
|
19
|
+
*/
|
|
20
|
+
export declare function sanitizeFilenameBase(base: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* `base` with a trailing `_<hashPrefix>` removed, so a name that already carries
|
|
23
|
+
* the hash does not get it twice (`photo_a1b2c` + `a1b2c` → `photo_a1b2c`, not
|
|
24
|
+
* `photo_a1b2c_a1b2c`).
|
|
25
|
+
*/
|
|
26
|
+
export declare function stripHashSuffix(base: string, hashPrefix: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* The name a file gets when it is renamed to `newBase`.
|
|
29
|
+
*
|
|
30
|
+
* The hash and the extension are not the editor's to change: the hash keeps two
|
|
31
|
+
* different files from ever sharing a name, and the extension is part of a
|
|
32
|
+
* remote file's validation hash and of how its bytes are served. So they are
|
|
33
|
+
* passed in, and only the base comes from the person.
|
|
34
|
+
*
|
|
35
|
+
* Returns `null` when nothing usable is left of `newBase` after cleaning it.
|
|
36
|
+
*/
|
|
37
|
+
export declare function createRenamedFilename(newBase: string, sha256: string, ext: string): string | null;
|
|
@@ -13357,6 +13357,63 @@ function createRemoteRef(remoteHost, _ref) {
|
|
|
13357
13357
|
return "".concat(remoteHost, "/file/p/").concat(publicProjectId, "/b/").concat(bucket, "/v/").concat(coreVersion, "/h/").concat(validationHash, "/f/").concat(fileHash, "/p/").concat(filePath);
|
|
13358
13358
|
}
|
|
13359
13359
|
|
|
13360
|
+
/**
|
|
13361
|
+
* How Val names a media file: a cleaned-up base name, the first five hex of the
|
|
13362
|
+
* content's SHA-256, and the extension — `hero-mountains_a1b2c.jpg`.
|
|
13363
|
+
*
|
|
13364
|
+
* Two producers need this and must agree: an upload (`createFilename`, which
|
|
13365
|
+
* has the bytes) and a rename (`createRenamedFilename`, which keeps the bytes
|
|
13366
|
+
* and only changes what is in front of the hash). If they disagreed, renaming a
|
|
13367
|
+
* file to the name it was uploaded with would give it a different name.
|
|
13368
|
+
*/
|
|
13369
|
+
|
|
13370
|
+
/** The `_a1b2c` a Val filename ends in, before the extension. */
|
|
13371
|
+
var FILENAME_HASH_SUFFIX_LENGTH = 5;
|
|
13372
|
+
|
|
13373
|
+
/**
|
|
13374
|
+
* The part of a filename a person chose, made safe for a URL path.
|
|
13375
|
+
*
|
|
13376
|
+
* Lower case, with everything `encodeURIComponent` would escape dropped rather
|
|
13377
|
+
* than escaped — a path segment that needs decoding is a path segment that gets
|
|
13378
|
+
* decoded twice somewhere. Can return the empty string, for a name made only of
|
|
13379
|
+
* such characters; a caller that needs a name has to refuse that.
|
|
13380
|
+
*/
|
|
13381
|
+
function sanitizeFilenameBase(base) {
|
|
13382
|
+
return encodeURIComponent(base).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
13383
|
+
}
|
|
13384
|
+
|
|
13385
|
+
/**
|
|
13386
|
+
* `base` with a trailing `_<hashPrefix>` removed, so a name that already carries
|
|
13387
|
+
* the hash does not get it twice (`photo_a1b2c` + `a1b2c` → `photo_a1b2c`, not
|
|
13388
|
+
* `photo_a1b2c_a1b2c`).
|
|
13389
|
+
*/
|
|
13390
|
+
function stripHashSuffix(base, hashPrefix) {
|
|
13391
|
+
var pos = base.lastIndexOf("_");
|
|
13392
|
+
if (pos !== -1 && base.slice(pos + 1) === hashPrefix) {
|
|
13393
|
+
return base.slice(0, pos);
|
|
13394
|
+
}
|
|
13395
|
+
return base;
|
|
13396
|
+
}
|
|
13397
|
+
|
|
13398
|
+
/**
|
|
13399
|
+
* The name a file gets when it is renamed to `newBase`.
|
|
13400
|
+
*
|
|
13401
|
+
* The hash and the extension are not the editor's to change: the hash keeps two
|
|
13402
|
+
* different files from ever sharing a name, and the extension is part of a
|
|
13403
|
+
* remote file's validation hash and of how its bytes are served. So they are
|
|
13404
|
+
* passed in, and only the base comes from the person.
|
|
13405
|
+
*
|
|
13406
|
+
* Returns `null` when nothing usable is left of `newBase` after cleaning it.
|
|
13407
|
+
*/
|
|
13408
|
+
function createRenamedFilename(newBase, sha256, ext) {
|
|
13409
|
+
var hashPrefix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
13410
|
+
var cleaned = sanitizeFilenameBase(stripHashSuffix(newBase.trim(), hashPrefix));
|
|
13411
|
+
if (cleaned === "") {
|
|
13412
|
+
return null;
|
|
13413
|
+
}
|
|
13414
|
+
return ext === "" ? "".concat(cleaned, "_").concat(hashPrefix) : "".concat(cleaned, "_").concat(hashPrefix, ".").concat(ext);
|
|
13415
|
+
}
|
|
13416
|
+
|
|
13360
13417
|
/**
|
|
13361
13418
|
* The validation basis is used in remote refs to determine if the remote content needs to be re-validated.
|
|
13362
13419
|
*
|
|
@@ -14385,7 +14442,7 @@ function isPageRouter(routerId) {
|
|
|
14385
14442
|
|
|
14386
14443
|
var corePackageJson = {
|
|
14387
14444
|
name: "@valbuild/core",
|
|
14388
|
-
version: "0.138.
|
|
14445
|
+
version: "0.138.2",
|
|
14389
14446
|
"private": false,
|
|
14390
14447
|
description: "Val - supercharged hard-coded content",
|
|
14391
14448
|
repository: {
|
|
@@ -14572,21 +14629,17 @@ var Internal = {
|
|
|
14572
14629
|
if (!data) {
|
|
14573
14630
|
return filename;
|
|
14574
14631
|
}
|
|
14575
|
-
var shaSuffix = sha256.slice(0,
|
|
14632
|
+
var shaSuffix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
14576
14633
|
var mimeType = (_Internal$getMimeType = Internal.getMimeType(data)) !== null && _Internal$getMimeType !== void 0 ? _Internal$getMimeType : "unknown";
|
|
14577
14634
|
var newExt = (_Internal$mimeTypeToF = Internal.mimeTypeToFileExt(mimeType)) !== null && _Internal$mimeTypeToF !== void 0 ? _Internal$mimeTypeToF : "unknown"; // Don't trust the file extension
|
|
14578
14635
|
if (filename) {
|
|
14579
14636
|
var cleanFilename = filename.split(".").slice(0, -1).join(".") || filename; // remove extension if it exists
|
|
14580
|
-
var
|
|
14581
|
-
var currentShaSuffix = cleanFilename.slice(maybeShaSuffixPos + 1, cleanFilename.length);
|
|
14582
|
-
if (currentShaSuffix === shaSuffix) {
|
|
14583
|
-
cleanFilename = cleanFilename.slice(0, maybeShaSuffixPos);
|
|
14584
|
-
}
|
|
14585
|
-
var escapedFilename = encodeURIComponent(cleanFilename).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
14637
|
+
var escapedFilename = sanitizeFilenameBase(stripHashSuffix(cleanFilename, shaSuffix));
|
|
14586
14638
|
return "".concat(escapedFilename, "_").concat(shaSuffix, ".").concat(newExt);
|
|
14587
14639
|
}
|
|
14588
14640
|
return "".concat(sha256, ".").concat(newExt);
|
|
14589
|
-
}
|
|
14641
|
+
},
|
|
14642
|
+
createRenamedFilename: createRenamedFilename
|
|
14590
14643
|
};
|
|
14591
14644
|
function tryJsonParse(str) {
|
|
14592
14645
|
try {
|
|
@@ -13359,6 +13359,63 @@ function createRemoteRef(remoteHost, _ref) {
|
|
|
13359
13359
|
return "".concat(remoteHost, "/file/p/").concat(publicProjectId, "/b/").concat(bucket, "/v/").concat(coreVersion, "/h/").concat(validationHash, "/f/").concat(fileHash, "/p/").concat(filePath);
|
|
13360
13360
|
}
|
|
13361
13361
|
|
|
13362
|
+
/**
|
|
13363
|
+
* How Val names a media file: a cleaned-up base name, the first five hex of the
|
|
13364
|
+
* content's SHA-256, and the extension — `hero-mountains_a1b2c.jpg`.
|
|
13365
|
+
*
|
|
13366
|
+
* Two producers need this and must agree: an upload (`createFilename`, which
|
|
13367
|
+
* has the bytes) and a rename (`createRenamedFilename`, which keeps the bytes
|
|
13368
|
+
* and only changes what is in front of the hash). If they disagreed, renaming a
|
|
13369
|
+
* file to the name it was uploaded with would give it a different name.
|
|
13370
|
+
*/
|
|
13371
|
+
|
|
13372
|
+
/** The `_a1b2c` a Val filename ends in, before the extension. */
|
|
13373
|
+
var FILENAME_HASH_SUFFIX_LENGTH = 5;
|
|
13374
|
+
|
|
13375
|
+
/**
|
|
13376
|
+
* The part of a filename a person chose, made safe for a URL path.
|
|
13377
|
+
*
|
|
13378
|
+
* Lower case, with everything `encodeURIComponent` would escape dropped rather
|
|
13379
|
+
* than escaped — a path segment that needs decoding is a path segment that gets
|
|
13380
|
+
* decoded twice somewhere. Can return the empty string, for a name made only of
|
|
13381
|
+
* such characters; a caller that needs a name has to refuse that.
|
|
13382
|
+
*/
|
|
13383
|
+
function sanitizeFilenameBase(base) {
|
|
13384
|
+
return encodeURIComponent(base).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
13385
|
+
}
|
|
13386
|
+
|
|
13387
|
+
/**
|
|
13388
|
+
* `base` with a trailing `_<hashPrefix>` removed, so a name that already carries
|
|
13389
|
+
* the hash does not get it twice (`photo_a1b2c` + `a1b2c` → `photo_a1b2c`, not
|
|
13390
|
+
* `photo_a1b2c_a1b2c`).
|
|
13391
|
+
*/
|
|
13392
|
+
function stripHashSuffix(base, hashPrefix) {
|
|
13393
|
+
var pos = base.lastIndexOf("_");
|
|
13394
|
+
if (pos !== -1 && base.slice(pos + 1) === hashPrefix) {
|
|
13395
|
+
return base.slice(0, pos);
|
|
13396
|
+
}
|
|
13397
|
+
return base;
|
|
13398
|
+
}
|
|
13399
|
+
|
|
13400
|
+
/**
|
|
13401
|
+
* The name a file gets when it is renamed to `newBase`.
|
|
13402
|
+
*
|
|
13403
|
+
* The hash and the extension are not the editor's to change: the hash keeps two
|
|
13404
|
+
* different files from ever sharing a name, and the extension is part of a
|
|
13405
|
+
* remote file's validation hash and of how its bytes are served. So they are
|
|
13406
|
+
* passed in, and only the base comes from the person.
|
|
13407
|
+
*
|
|
13408
|
+
* Returns `null` when nothing usable is left of `newBase` after cleaning it.
|
|
13409
|
+
*/
|
|
13410
|
+
function createRenamedFilename(newBase, sha256, ext) {
|
|
13411
|
+
var hashPrefix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
13412
|
+
var cleaned = sanitizeFilenameBase(stripHashSuffix(newBase.trim(), hashPrefix));
|
|
13413
|
+
if (cleaned === "") {
|
|
13414
|
+
return null;
|
|
13415
|
+
}
|
|
13416
|
+
return ext === "" ? "".concat(cleaned, "_").concat(hashPrefix) : "".concat(cleaned, "_").concat(hashPrefix, ".").concat(ext);
|
|
13417
|
+
}
|
|
13418
|
+
|
|
13362
13419
|
/**
|
|
13363
13420
|
* The validation basis is used in remote refs to determine if the remote content needs to be re-validated.
|
|
13364
13421
|
*
|
|
@@ -14387,7 +14444,7 @@ function isPageRouter(routerId) {
|
|
|
14387
14444
|
|
|
14388
14445
|
var corePackageJson = {
|
|
14389
14446
|
name: "@valbuild/core",
|
|
14390
|
-
version: "0.138.
|
|
14447
|
+
version: "0.138.2",
|
|
14391
14448
|
"private": false,
|
|
14392
14449
|
description: "Val - supercharged hard-coded content",
|
|
14393
14450
|
repository: {
|
|
@@ -14574,21 +14631,17 @@ var Internal = {
|
|
|
14574
14631
|
if (!data) {
|
|
14575
14632
|
return filename;
|
|
14576
14633
|
}
|
|
14577
|
-
var shaSuffix = sha256.slice(0,
|
|
14634
|
+
var shaSuffix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
14578
14635
|
var mimeType = (_Internal$getMimeType = Internal.getMimeType(data)) !== null && _Internal$getMimeType !== void 0 ? _Internal$getMimeType : "unknown";
|
|
14579
14636
|
var newExt = (_Internal$mimeTypeToF = Internal.mimeTypeToFileExt(mimeType)) !== null && _Internal$mimeTypeToF !== void 0 ? _Internal$mimeTypeToF : "unknown"; // Don't trust the file extension
|
|
14580
14637
|
if (filename) {
|
|
14581
14638
|
var cleanFilename = filename.split(".").slice(0, -1).join(".") || filename; // remove extension if it exists
|
|
14582
|
-
var
|
|
14583
|
-
var currentShaSuffix = cleanFilename.slice(maybeShaSuffixPos + 1, cleanFilename.length);
|
|
14584
|
-
if (currentShaSuffix === shaSuffix) {
|
|
14585
|
-
cleanFilename = cleanFilename.slice(0, maybeShaSuffixPos);
|
|
14586
|
-
}
|
|
14587
|
-
var escapedFilename = encodeURIComponent(cleanFilename).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
14639
|
+
var escapedFilename = sanitizeFilenameBase(stripHashSuffix(cleanFilename, shaSuffix));
|
|
14588
14640
|
return "".concat(escapedFilename, "_").concat(shaSuffix, ".").concat(newExt);
|
|
14589
14641
|
}
|
|
14590
14642
|
return "".concat(sha256, ".").concat(newExt);
|
|
14591
|
-
}
|
|
14643
|
+
},
|
|
14644
|
+
createRenamedFilename: createRenamedFilename
|
|
14592
14645
|
};
|
|
14593
14646
|
function tryJsonParse(str) {
|
|
14594
14647
|
try {
|
|
@@ -13359,6 +13359,63 @@ function createRemoteRef(remoteHost, _ref) {
|
|
|
13359
13359
|
return "".concat(remoteHost, "/file/p/").concat(publicProjectId, "/b/").concat(bucket, "/v/").concat(coreVersion, "/h/").concat(validationHash, "/f/").concat(fileHash, "/p/").concat(filePath);
|
|
13360
13360
|
}
|
|
13361
13361
|
|
|
13362
|
+
/**
|
|
13363
|
+
* How Val names a media file: a cleaned-up base name, the first five hex of the
|
|
13364
|
+
* content's SHA-256, and the extension — `hero-mountains_a1b2c.jpg`.
|
|
13365
|
+
*
|
|
13366
|
+
* Two producers need this and must agree: an upload (`createFilename`, which
|
|
13367
|
+
* has the bytes) and a rename (`createRenamedFilename`, which keeps the bytes
|
|
13368
|
+
* and only changes what is in front of the hash). If they disagreed, renaming a
|
|
13369
|
+
* file to the name it was uploaded with would give it a different name.
|
|
13370
|
+
*/
|
|
13371
|
+
|
|
13372
|
+
/** The `_a1b2c` a Val filename ends in, before the extension. */
|
|
13373
|
+
var FILENAME_HASH_SUFFIX_LENGTH = 5;
|
|
13374
|
+
|
|
13375
|
+
/**
|
|
13376
|
+
* The part of a filename a person chose, made safe for a URL path.
|
|
13377
|
+
*
|
|
13378
|
+
* Lower case, with everything `encodeURIComponent` would escape dropped rather
|
|
13379
|
+
* than escaped — a path segment that needs decoding is a path segment that gets
|
|
13380
|
+
* decoded twice somewhere. Can return the empty string, for a name made only of
|
|
13381
|
+
* such characters; a caller that needs a name has to refuse that.
|
|
13382
|
+
*/
|
|
13383
|
+
function sanitizeFilenameBase(base) {
|
|
13384
|
+
return encodeURIComponent(base).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
13385
|
+
}
|
|
13386
|
+
|
|
13387
|
+
/**
|
|
13388
|
+
* `base` with a trailing `_<hashPrefix>` removed, so a name that already carries
|
|
13389
|
+
* the hash does not get it twice (`photo_a1b2c` + `a1b2c` → `photo_a1b2c`, not
|
|
13390
|
+
* `photo_a1b2c_a1b2c`).
|
|
13391
|
+
*/
|
|
13392
|
+
function stripHashSuffix(base, hashPrefix) {
|
|
13393
|
+
var pos = base.lastIndexOf("_");
|
|
13394
|
+
if (pos !== -1 && base.slice(pos + 1) === hashPrefix) {
|
|
13395
|
+
return base.slice(0, pos);
|
|
13396
|
+
}
|
|
13397
|
+
return base;
|
|
13398
|
+
}
|
|
13399
|
+
|
|
13400
|
+
/**
|
|
13401
|
+
* The name a file gets when it is renamed to `newBase`.
|
|
13402
|
+
*
|
|
13403
|
+
* The hash and the extension are not the editor's to change: the hash keeps two
|
|
13404
|
+
* different files from ever sharing a name, and the extension is part of a
|
|
13405
|
+
* remote file's validation hash and of how its bytes are served. So they are
|
|
13406
|
+
* passed in, and only the base comes from the person.
|
|
13407
|
+
*
|
|
13408
|
+
* Returns `null` when nothing usable is left of `newBase` after cleaning it.
|
|
13409
|
+
*/
|
|
13410
|
+
function createRenamedFilename(newBase, sha256, ext) {
|
|
13411
|
+
var hashPrefix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
13412
|
+
var cleaned = sanitizeFilenameBase(stripHashSuffix(newBase.trim(), hashPrefix));
|
|
13413
|
+
if (cleaned === "") {
|
|
13414
|
+
return null;
|
|
13415
|
+
}
|
|
13416
|
+
return ext === "" ? "".concat(cleaned, "_").concat(hashPrefix) : "".concat(cleaned, "_").concat(hashPrefix, ".").concat(ext);
|
|
13417
|
+
}
|
|
13418
|
+
|
|
13362
13419
|
/**
|
|
13363
13420
|
* The validation basis is used in remote refs to determine if the remote content needs to be re-validated.
|
|
13364
13421
|
*
|
|
@@ -14387,7 +14444,7 @@ function isPageRouter(routerId) {
|
|
|
14387
14444
|
|
|
14388
14445
|
var corePackageJson = {
|
|
14389
14446
|
name: "@valbuild/core",
|
|
14390
|
-
version: "0.138.
|
|
14447
|
+
version: "0.138.2",
|
|
14391
14448
|
"private": false,
|
|
14392
14449
|
description: "Val - supercharged hard-coded content",
|
|
14393
14450
|
repository: {
|
|
@@ -14574,21 +14631,17 @@ var Internal = {
|
|
|
14574
14631
|
if (!data) {
|
|
14575
14632
|
return filename;
|
|
14576
14633
|
}
|
|
14577
|
-
var shaSuffix = sha256.slice(0,
|
|
14634
|
+
var shaSuffix = sha256.slice(0, FILENAME_HASH_SUFFIX_LENGTH);
|
|
14578
14635
|
var mimeType = (_Internal$getMimeType = Internal.getMimeType(data)) !== null && _Internal$getMimeType !== void 0 ? _Internal$getMimeType : "unknown";
|
|
14579
14636
|
var newExt = (_Internal$mimeTypeToF = Internal.mimeTypeToFileExt(mimeType)) !== null && _Internal$mimeTypeToF !== void 0 ? _Internal$mimeTypeToF : "unknown"; // Don't trust the file extension
|
|
14580
14637
|
if (filename) {
|
|
14581
14638
|
var cleanFilename = filename.split(".").slice(0, -1).join(".") || filename; // remove extension if it exists
|
|
14582
|
-
var
|
|
14583
|
-
var currentShaSuffix = cleanFilename.slice(maybeShaSuffixPos + 1, cleanFilename.length);
|
|
14584
|
-
if (currentShaSuffix === shaSuffix) {
|
|
14585
|
-
cleanFilename = cleanFilename.slice(0, maybeShaSuffixPos);
|
|
14586
|
-
}
|
|
14587
|
-
var escapedFilename = encodeURIComponent(cleanFilename).replace(/%[0-9A-Fa-f]{2}/g, "").toLowerCase();
|
|
14639
|
+
var escapedFilename = sanitizeFilenameBase(stripHashSuffix(cleanFilename, shaSuffix));
|
|
14588
14640
|
return "".concat(escapedFilename, "_").concat(shaSuffix, ".").concat(newExt);
|
|
14589
14641
|
}
|
|
14590
14642
|
return "".concat(sha256, ".").concat(newExt);
|
|
14591
|
-
}
|
|
14643
|
+
},
|
|
14644
|
+
createRenamedFilename: createRenamedFilename
|
|
14592
14645
|
};
|
|
14593
14646
|
function tryJsonParse(str) {
|
|
14594
14647
|
try {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { v as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, Y as CODE_LANGUAGES, Z as COLOR_FORMATS, X as CodeSchema, W as ColorSchema, e as DEFAULT_APP_HOST, $ as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, f as DEFAULT_STATIC_HOST, n as DEFAULT_VAL_REMOTE_HOST, t as DateSchema, a0 as DateTimeSchema, a6 as DiscriminatedUnionSchema, a7 as EnumSchema, F as FATAL_ERROR_TYPES, r as FileSchema, G as GenericSelector, q as ImageSchema, I as Internal, a1 as KeyOfSchema, a8 as LiteralSchema, L as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, a5 as RichTextSchema, a4 as RouteSchema, z as SETTINGS_MODULE_CONVENTION, S as Schema, u as SettingsSchema, p as StringSchema, T as THEME_LOGO_DIRECTORY, x as THEME_RADIUS_LENGTHS, w as THEME_RADIUS_STEPS, am as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a2 as ValViewSchema, y as assistantAvailability, j as computeSourcesSha, h as computeValModuleShas, K as declaredKeySetOf, o as derefPatch, ai as describeSchemeRejection, a9 as deserializeSchema, U as discriminatedUnionBranchOf, g as extractValModules, ag as getSourcePathFromRoute, l as hasMediaSchema, k as hasRemoteFileSchema, i as initVal, aj as isCheckableScheme, ab as isInlineRender, ah as isPageRouter, C as isRootModuleFilePath, a3 as isValViewSource, J as localeOfValue, H as localeTagError, Q as missingDeclaredKeys, m as modules, ac as parseNextJsRoutePattern, ad as parseTanStackRoutePattern, aa as previewScope, ak as rejectScheme, E as resolveSettingsModule, al as schemeOf, ae as tanStackSegmentsOfRoutePath, af as validateUrlAgainstPattern } from './index-
|
|
1
|
+
export { v as ASSISTANT_SETTINGS_MAX_LENGTH, A as ArraySchema, B as BooleanSchema, Y as CODE_LANGUAGES, Z as COLOR_FORMATS, X as CodeSchema, W as ColorSchema, e as DEFAULT_APP_HOST, $ as DEFAULT_COLOR_FORMAT, D as DEFAULT_CONTENT_HOST, f as DEFAULT_STATIC_HOST, n as DEFAULT_VAL_REMOTE_HOST, t as DateSchema, a0 as DateTimeSchema, a6 as DiscriminatedUnionSchema, a7 as EnumSchema, F as FATAL_ERROR_TYPES, r as FileSchema, G as GenericSelector, q as ImageSchema, I as Internal, a1 as KeyOfSchema, a8 as LiteralSchema, L as LocaleSchema, M as ModuleFilePathSep, N as NumberSchema, O as ObjectSchema, R as RecordSchema, a5 as RichTextSchema, a4 as RouteSchema, z as SETTINGS_MODULE_CONVENTION, S as Schema, u as SettingsSchema, p as StringSchema, T as THEME_LOGO_DIRECTORY, x as THEME_RADIUS_LENGTHS, w as THEME_RADIUS_STEPS, am as UNSAFE_URL_SCHEMES, V as VAL_EXTENSION, a2 as ValViewSchema, y as assistantAvailability, j as computeSourcesSha, h as computeValModuleShas, K as declaredKeySetOf, o as derefPatch, ai as describeSchemeRejection, a9 as deserializeSchema, U as discriminatedUnionBranchOf, g as extractValModules, ag as getSourcePathFromRoute, l as hasMediaSchema, k as hasRemoteFileSchema, i as initVal, aj as isCheckableScheme, ab as isInlineRender, ah as isPageRouter, C as isRootModuleFilePath, a3 as isValViewSource, J as localeOfValue, H as localeTagError, Q as missingDeclaredKeys, m as modules, ac as parseNextJsRoutePattern, ad as parseTanStackRoutePattern, aa as previewScope, ak as rejectScheme, E as resolveSettingsModule, al as schemeOf, ae as tanStackSegmentsOfRoutePath, af as validateUrlAgainstPattern } from './index-36b5e0cb.esm.js';
|
|
2
2
|
import './result-daff1cae.esm.js';
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-8e33ef62.cjs.dev.js');
|
|
6
6
|
var result = require('../../dist/result-bb1f436e.cjs.dev.js');
|
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var dist_valbuildCore = require('../../dist/index-
|
|
5
|
+
var dist_valbuildCore = require('../../dist/index-87b5aa27.cjs.prod.js');
|
|
6
6
|
var result = require('../../dist/result-787e35f6.cjs.prod.js');
|
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
|
8
8
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-36b5e0cb.esm.js';
|
|
2
|
+
export { P as PatchError } from '../../dist/index-36b5e0cb.esm.js';
|
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-daff1cae.esm.js';
|
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
|
5
5
|
|