@valbuild/core 0.136.8 → 0.138.0
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 +52 -0
- package/dist/declarations/src/externalUrlSchemes.d.ts +66 -0
- package/dist/declarations/src/index.d.ts +18 -3
- package/dist/declarations/src/router.d.ts +36 -1
- package/dist/declarations/src/schema/record.d.ts +9 -0
- package/dist/declarations/src/source/settings.d.ts +14 -0
- package/dist/{index-2545d3b4.cjs.prod.js → index-3296fc4f.cjs.prod.js} +237 -35
- package/dist/{index-962a8ac3.esm.js → index-a25822a3.esm.js} +233 -36
- package/dist/{index-afbcf0ca.cjs.dev.js → index-d3c51a0d.cjs.dev.js} +237 -35
- package/dist/valbuild-core.cjs.dev.js +6 -1
- package/dist/valbuild-core.cjs.prod.js +6 -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,57 @@
|
|
|
1
1
|
# @valbuild/core
|
|
2
2
|
|
|
3
|
+
## 0.138.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#751](https://github.com/valbuild/val/pull/751) [`5876fe0`](https://github.com/valbuild/val/commit/5876fe075fdee1f76f1cdaa2488ac52c58c894a8) Thanks [@freekh](https://github.com/freekh)! - Publishing no longer asks for a commit message by default.
|
|
8
|
+
|
|
9
|
+
- **Publish publishes.** In HTTP mode, pressing Publish goes straight to publishing, just as Save already did in local development. Where an AI model is available it writes the commit message (the button reads "Preparing" meanwhile, for up to 15 seconds). Otherwise the message is built from what changed, and names the exact path when a single field changed, e.g. `Update hero.title in /content/home.val.ts`. When several things changed, the message body lists the changed modules and their fields: up to six modules and five fields each, then how many more.
|
|
10
|
+
- **`studio.commitMessage: "required"`** in `s.settings()` brings the box back, redesigned. Editors can turn it on from the Studio too: Settings → Studio → "Ask for a commit message". It opens empty rather than pre-filled, so a message cannot be published unread. The AI fills it in when it can, and Publish stays disabled until there is a message. Nothing publishes on its own: the countdown that published while the AI was still writing is gone.
|
|
11
|
+
- **The overlay menu stays open** while the commit message popover is open, or a publish is under way. Before, moving onto the popover collapsed the menu and the popover moved with it.
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- [#752](https://github.com/valbuild/val/pull/752) [`57af895`](https://github.com/valbuild/val/commit/57af8959cc46519a405b1ed7441623f8bf2e6d27) Thanks [@freekh](https://github.com/freekh)! - `s.date()` now reports a value that is not a real `YYYY-MM-DD` day as a validation error. It used to check only `from` / `to`, and compared those as plain strings, so a typo like `"19f81-12-30"` passed a `.from("1900-01-01").to("2024-01-01")` range without a word. Impossible days such as `"2023-02-29"` are rejected too, and a `from` / `to` bound that is not a valid date is reported as a schema error.
|
|
16
|
+
|
|
17
|
+
The Studio's date field no longer shows a year below 100 (`"0050-01-01"`) as empty: it was read as 1950 and discarded.
|
|
18
|
+
|
|
19
|
+
## 0.137.0
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- [#676](https://github.com/valbuild/val/pull/676) [`43b58f2`](https://github.com/valbuild/val/commit/43b58f2962840883badf91950da2c51b89d1c7cb) Thanks [@freekh](https://github.com/freekh)! - External page keys are now validated, and `mailto:` and `tel:` are allowed.
|
|
24
|
+
|
|
25
|
+
`externalPageRouter` documented a rule — a key must start with `https://` or
|
|
26
|
+
`http://` — and never enforced it: the validator collected the errors and then
|
|
27
|
+
returned an empty list, so a key like `discord.gg/val` or `/about` was accepted
|
|
28
|
+
in silence and behaved as a relative link on the site.
|
|
29
|
+
|
|
30
|
+
Fixing that made the rule itself worth looking at, because it was a rule about
|
|
31
|
+
the protocol standing in for a rule about links. A contact page's email address
|
|
32
|
+
and phone number are external pages to whoever maintains the list, and they
|
|
33
|
+
were refused. So the rule that is now enforced is a deny list rather than an
|
|
34
|
+
allow list: a key must have a scheme, and the scheme must not be one of
|
|
35
|
+
`javascript:`, `data:`, `vbscript:`, `file:` or `blob:` — which are not links
|
|
36
|
+
at all. An external page key ends up in an `href` in your site's own markup, so
|
|
37
|
+
those stay refused however the router is configured.
|
|
38
|
+
|
|
39
|
+
A project that wants to be stricter says so:
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
s.record(item).router(externalPageRouter({ schemes: ["https", "mailto"] }));
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`initVal()` from `@valbuild/next` and `@valbuild/tanstack` hands you the
|
|
46
|
+
callable form, so the narrowed version typechecks in an app.
|
|
47
|
+
|
|
48
|
+
Val Studio applies the same rule while you type — it calls the same function —
|
|
49
|
+
and shows a narrowed project's own list in the message.
|
|
50
|
+
|
|
51
|
+
If your project has a key with no scheme at all, it will start showing a
|
|
52
|
+
validation error on that entry. Give it one, or move it out of the external
|
|
53
|
+
router.
|
|
54
|
+
|
|
3
55
|
## 0.136.8
|
|
4
56
|
|
|
5
57
|
### Patch Changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Which URL schemes an external page key may use.
|
|
3
|
+
*
|
|
4
|
+
* External pages are the URLs a site links OUT to, and a link is not only a web
|
|
5
|
+
* page: `mailto:` on a contact page and `tel:` on a phone number are the same
|
|
6
|
+
* kind of thing to whoever maintains the list, and were refused outright.
|
|
7
|
+
*
|
|
8
|
+
* So the default is a deny list rather than an allow list — anything with a
|
|
9
|
+
* scheme, except the handful that are not links at all. Listing every scheme
|
|
10
|
+
* worth linking to is a list that is wrong the moment someone wants
|
|
11
|
+
* `whatsapp:` or `msteams:`, and being wrong that way means an editor cannot
|
|
12
|
+
* store a URL their site genuinely uses.
|
|
13
|
+
*
|
|
14
|
+
* A project that wants to be stricter says so:
|
|
15
|
+
*
|
|
16
|
+
* ```ts
|
|
17
|
+
* s.router(externalPageRouter({ schemes: ["https", "mailto"] }), item)
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
/**
|
|
21
|
+
* The schemes that are refused however wide the policy is.
|
|
22
|
+
*
|
|
23
|
+
* Not a style preference. An external page key ends up in an `href` in the
|
|
24
|
+
* consuming site's own markup, so `javascript:` there is stored XSS on that
|
|
25
|
+
* site, and `data:` is the same trick wearing a document. `vbscript:` is the
|
|
26
|
+
* historical spelling of the first. `file:` and `blob:` address the visitor's
|
|
27
|
+
* own machine rather than anywhere on the internet.
|
|
28
|
+
*
|
|
29
|
+
* These stay refused even when a project lists them in `schemes`: a config
|
|
30
|
+
* option is not a good enough reason to let content inject script into the
|
|
31
|
+
* page that renders it.
|
|
32
|
+
*/
|
|
33
|
+
export declare const UNSAFE_URL_SCHEMES: readonly ["javascript", "data", "vbscript", "file", "blob"];
|
|
34
|
+
export type ExternalUrlSchemePolicy = {
|
|
35
|
+
/**
|
|
36
|
+
* The only schemes allowed, without the colon: `["https", "mailto"]`.
|
|
37
|
+
*
|
|
38
|
+
* Absent means the wide default — anything but {@link UNSAFE_URL_SCHEMES}.
|
|
39
|
+
*/
|
|
40
|
+
schemes?: readonly string[];
|
|
41
|
+
};
|
|
42
|
+
/** The scheme of a URL, lowercased and without the colon, or null. */
|
|
43
|
+
export declare function schemeOf(url: string): string | null;
|
|
44
|
+
export type SchemeRejection = {
|
|
45
|
+
reason: "no-scheme";
|
|
46
|
+
} | {
|
|
47
|
+
reason: "unsafe";
|
|
48
|
+
scheme: string;
|
|
49
|
+
} | {
|
|
50
|
+
reason: "not-allowed";
|
|
51
|
+
scheme: string;
|
|
52
|
+
allowed: readonly string[];
|
|
53
|
+
};
|
|
54
|
+
/** `null` when the URL's scheme is acceptable under `policy`. */
|
|
55
|
+
export declare function rejectScheme(url: string, policy?: ExternalUrlSchemePolicy): SchemeRejection | null;
|
|
56
|
+
/** What to tell whoever wrote the key. */
|
|
57
|
+
export declare function describeSchemeRejection(rejection: SchemeRejection): string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a link check can open this URL.
|
|
60
|
+
*
|
|
61
|
+
* Separate from whether it is ALLOWED, and the two are not the same question:
|
|
62
|
+
* `mailto:` is a perfectly good external page and there is no request to make
|
|
63
|
+
* of it. A URL that cannot be opened is reported as not checked, never as
|
|
64
|
+
* broken.
|
|
65
|
+
*/
|
|
66
|
+
export declare function isCheckableScheme(url: string): boolean;
|
|
@@ -54,7 +54,7 @@ export { type SerializedImageSchema, ImageSchema } from "./schema/image.js";
|
|
|
54
54
|
export { type SerializedFileSchema, FileSchema } from "./schema/file.js";
|
|
55
55
|
export { type SerializedDateSchema, DateSchema } from "./schema/date.js";
|
|
56
56
|
export { type SerializedSettingsSchema, SettingsSchema, } from "./schema/settings.js";
|
|
57
|
-
export { type SettingsSource, type AssistantSettingsSource, type LocalesSettingsSource, type AssistantAvailability, type ThemeSettingsSource, type StudioSettingsSource, type ThemeRadius, ASSISTANT_SETTINGS_MAX_LENGTH, THEME_LOGO_DIRECTORY, THEME_RADIUS_STEPS, THEME_RADIUS_LENGTHS, assistantAvailability, } from "./source/settings.js";
|
|
57
|
+
export { type SettingsSource, type AssistantSettingsSource, type LocalesSettingsSource, type AssistantAvailability, type ThemeSettingsSource, type StudioSettingsSource, type StudioCommitMessageMode, type ThemeRadius, ASSISTANT_SETTINGS_MAX_LENGTH, THEME_LOGO_DIRECTORY, THEME_RADIUS_STEPS, THEME_RADIUS_LENGTHS, assistantAvailability, } from "./source/settings.js";
|
|
58
58
|
export { type ResolvedSettingsModule, SETTINGS_MODULE_CONVENTION, isRootModuleFilePath, resolveSettingsModule, } from "./settingsModule.js";
|
|
59
59
|
export { type Locale, localeTagError, localeOfValue } from "./locale.js";
|
|
60
60
|
export { type SerializedLocaleSchema, LocaleSchema } from "./schema/locale.js";
|
|
@@ -79,9 +79,19 @@ export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js
|
|
|
79
79
|
export { deserializeSchema } from "./schema/deserialize.js";
|
|
80
80
|
export { type PreviewItem, type ItemPreviewInput, type RecordPreview, type ArrayPreview, type ReifiedPreview, type PreviewScope, previewScope, } from "./preview.js";
|
|
81
81
|
export { type InlineRender, type FieldRender, isInlineRender } from "./render.js";
|
|
82
|
-
export type { ValRouter, RouteValidationError } from "./router.js";
|
|
82
|
+
export type { ValRouter, ExternalPageRouter, RouteValidationError, } from "./router.js";
|
|
83
83
|
export { parseNextJsRoutePattern, parseTanStackRoutePattern, tanStackSegmentsOfRoutePath, validateUrlAgainstPattern, } from "./router.js";
|
|
84
84
|
export { getSourcePathFromRoute, isPageRouter } from "./getSourcePathFromRoute.js";
|
|
85
|
+
/**
|
|
86
|
+
* Which URL schemes an external page key may carry.
|
|
87
|
+
*
|
|
88
|
+
* Exported from the package root rather than only through `Internal` because
|
|
89
|
+
* the Studio has to apply the same rule the router does, while the key is
|
|
90
|
+
* being typed - one implementation, two callers, no second copy to drift.
|
|
91
|
+
*/
|
|
92
|
+
export { describeSchemeRejection, isCheckableScheme, rejectScheme, schemeOf, UNSAFE_URL_SCHEMES, } from "./externalUrlSchemes.js";
|
|
93
|
+
export type { ExternalUrlSchemePolicy, SchemeRejection, } from "./externalUrlSchemes.js";
|
|
94
|
+
import { describeSchemeRejection, isCheckableScheme, rejectScheme, schemeOf } from "./externalUrlSchemes.js";
|
|
85
95
|
export declare const FATAL_ERROR_TYPES: readonly ["no-schema", "no-source", "invalid-id", "no-module", "invalid-patch"];
|
|
86
96
|
export type FatalErrorType = (typeof FATAL_ERROR_TYPES)[number];
|
|
87
97
|
export declare const DEFAULT_CONTENT_HOST = "https://content.val.build";
|
|
@@ -138,7 +148,12 @@ declare const Internal: {
|
|
|
138
148
|
joinModuleFilePathAndModulePath: typeof joinModuleFilePathAndModulePath;
|
|
139
149
|
nextAppRouter: import("./router.js").ValRouter;
|
|
140
150
|
tanstackRouter: import("./router.js").ValRouter;
|
|
141
|
-
externalPageRouter: import("./router.js").
|
|
151
|
+
externalPageRouter: import("./router.js").ExternalPageRouter;
|
|
152
|
+
describeSchemeRejection: typeof describeSchemeRejection;
|
|
153
|
+
isCheckableScheme: typeof isCheckableScheme;
|
|
154
|
+
rejectScheme: typeof rejectScheme;
|
|
155
|
+
schemeOf: typeof schemeOf;
|
|
156
|
+
UNSAFE_URL_SCHEMES: readonly ["javascript", "data", "vbscript", "file", "blob"];
|
|
142
157
|
color: {
|
|
143
158
|
parseColor: typeof parseColor;
|
|
144
159
|
formatColor: typeof formatColor;
|
|
@@ -1,5 +1,31 @@
|
|
|
1
1
|
import { ModuleFilePath } from "./val/index.js";
|
|
2
|
-
|
|
2
|
+
import { ExternalUrlSchemePolicy } from "./externalUrlSchemes.js";
|
|
3
|
+
/**
|
|
4
|
+
* The router whose keys are URLs to somewhere else.
|
|
5
|
+
*
|
|
6
|
+
* Used directly for the wide default, or called to narrow it:
|
|
7
|
+
*
|
|
8
|
+
* ```ts
|
|
9
|
+
* s.router(externalPageRouter, item) // anything safe
|
|
10
|
+
* s.router(externalPageRouter({ schemes: ["https"] }), item) // https only
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Its one rule is that a key has a scheme, and that the scheme is not one of
|
|
14
|
+
* the handful that are not links at all - see `externalUrlSchemes.ts`. That
|
|
15
|
+
* rule was WRITTEN here from the start and never enforced: the errors were
|
|
16
|
+
* collected into a list and then `return []` threw them away, so every key was
|
|
17
|
+
* accepted however it was spelled.
|
|
18
|
+
*
|
|
19
|
+
* `expectedPath` is null because there is nothing to suggest: a key that is
|
|
20
|
+
* not a URL could have been meant as any URL, and guessing `https://` in front
|
|
21
|
+
* of it would propose a different site as often as the right one.
|
|
22
|
+
*/
|
|
23
|
+
export declare const externalPageRouter: ExternalPageRouter;
|
|
24
|
+
/**
|
|
25
|
+
* Callable AND a router, so `externalPageRouter` keeps working unchanged
|
|
26
|
+
* where nobody needs to configure it - which is almost everywhere.
|
|
27
|
+
*/
|
|
28
|
+
export type ExternalPageRouter = ValRouter & ((policy: ExternalUrlSchemePolicy) => ValRouter);
|
|
3
29
|
export type RouteValidationError = {
|
|
4
30
|
error: {
|
|
5
31
|
message: string;
|
|
@@ -70,5 +96,14 @@ export declare function tanStackSegmentsOfRoutePath(routePath: string): string[]
|
|
|
70
96
|
export declare const tanstackRouter: ValRouter;
|
|
71
97
|
export interface ValRouter {
|
|
72
98
|
getRouterId(): string;
|
|
99
|
+
/**
|
|
100
|
+
* Which URL schemes this router's keys may use, where it restricts them.
|
|
101
|
+
*
|
|
102
|
+
* Serialized alongside the router id so the Studio can apply the SAME rule
|
|
103
|
+
* while someone types, rather than accepting a key and reporting it as a
|
|
104
|
+
* validation error afterwards. Absent on routers whose keys are paths rather
|
|
105
|
+
* than URLs, which is every other one.
|
|
106
|
+
*/
|
|
107
|
+
getUrlSchemePolicy?(): ExternalUrlSchemePolicy;
|
|
73
108
|
validate(moduleFilePath: ModuleFilePath, urlPaths: string[]): RouteValidationError[];
|
|
74
109
|
}
|
|
@@ -31,6 +31,15 @@ export type SerializedRecordSchema = {
|
|
|
31
31
|
/** Static layout config, carried whole in the serialized schema — see `render.ts`. */
|
|
32
32
|
render?: FieldRender;
|
|
33
33
|
router?: string;
|
|
34
|
+
/**
|
|
35
|
+
* The URL schemes this router's keys may use, where it restricts them.
|
|
36
|
+
*
|
|
37
|
+
* Carried so the Studio can apply the router's OWN rule while someone types
|
|
38
|
+
* rather than accepting a key and reporting it afterwards. Absent both when
|
|
39
|
+
* the router has no scheme rule (every path router) and when it allows the
|
|
40
|
+
* wide default, which the Studio knows on its own.
|
|
41
|
+
*/
|
|
42
|
+
routerSchemes?: string[];
|
|
34
43
|
customValidate?: boolean;
|
|
35
44
|
mediaType?: "files" | "images";
|
|
36
45
|
accept?: string;
|
|
@@ -52,7 +52,21 @@ export type StudioSettingsSource = {
|
|
|
52
52
|
* that browser and is not here.
|
|
53
53
|
*/
|
|
54
54
|
tour?: boolean | null;
|
|
55
|
+
/**
|
|
56
|
+
* Whether publishing asks for a commit message.
|
|
57
|
+
*
|
|
58
|
+
* Unset means `"automatic"`: pressing Publish publishes, with a summary the
|
|
59
|
+
* AI writes where one is available and one assembled from what changed where
|
|
60
|
+
* it is not. Nobody is shown a box. `"required"` opens the box on every
|
|
61
|
+
* publish and will not publish it empty — the AI still fills it in, where
|
|
62
|
+
* there is one, but a person has to read it and press Publish.
|
|
63
|
+
*
|
|
64
|
+
* Only the HTTP (remote) mode commits, so this changes nothing in local
|
|
65
|
+
* development, where Save writes to disk.
|
|
66
|
+
*/
|
|
67
|
+
commitMessage?: StudioCommitMessageMode | null;
|
|
55
68
|
};
|
|
69
|
+
export type StudioCommitMessageMode = "automatic" | "required";
|
|
56
70
|
/**
|
|
57
71
|
* How the Studio looks in this project.
|
|
58
72
|
*
|
|
@@ -5632,6 +5632,21 @@ function missingDeclaredKeys(declared, present) {
|
|
|
5632
5632
|
});
|
|
5633
5633
|
}
|
|
5634
5634
|
|
|
5635
|
+
/**
|
|
5636
|
+
* A router's scheme restriction, as a spreadable fragment.
|
|
5637
|
+
*
|
|
5638
|
+
* Spread rather than assigned so an unrestricted router adds no key at all:
|
|
5639
|
+
* `routerSchemes: undefined` would serialize as an explicit `undefined` and
|
|
5640
|
+
* show up in every schema diff for no reason.
|
|
5641
|
+
*/
|
|
5642
|
+
function routerSchemes(router) {
|
|
5643
|
+
var _router$getUrlSchemeP;
|
|
5644
|
+
var schemes = router === null || router === void 0 || (_router$getUrlSchemeP = router.getUrlSchemePolicy) === null || _router$getUrlSchemeP === void 0 ? void 0 : _router$getUrlSchemeP.call(router).schemes;
|
|
5645
|
+
return schemes === undefined ? {} : {
|
|
5646
|
+
routerSchemes: _toConsumableArray(schemes)
|
|
5647
|
+
};
|
|
5648
|
+
}
|
|
5649
|
+
|
|
5635
5650
|
/**
|
|
5636
5651
|
* The source type of a `.jsonValues()` record: every entry value is EITHER a
|
|
5637
5652
|
* lazily loaded {@link JsonSource} whose resolved content is the (loosened, see
|
|
@@ -6448,21 +6463,22 @@ var RecordSchema = /*#__PURE__*/function (_Schema) {
|
|
|
6448
6463
|
key: "executeSerialize",
|
|
6449
6464
|
value: function executeSerialize() {
|
|
6450
6465
|
var _this$renderInput, _this$keySchema, _this$currentRouter, _this$customValidateF, _this$externalLabel;
|
|
6451
|
-
var result = {
|
|
6466
|
+
var result = _objectSpread2(_objectSpread2({
|
|
6452
6467
|
type: "record",
|
|
6453
6468
|
render: (_this$renderInput = this.renderInput) !== null && _this$renderInput !== void 0 ? _this$renderInput : undefined,
|
|
6454
6469
|
item: this.item["executeSerialize"](),
|
|
6455
6470
|
key: (_this$keySchema = this.keySchema) === null || _this$keySchema === void 0 ? void 0 : _this$keySchema["executeSerialize"](),
|
|
6456
6471
|
opt: this.opt,
|
|
6457
6472
|
preview: this.previewInput ? true : undefined,
|
|
6458
|
-
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId()
|
|
6473
|
+
router: (_this$currentRouter = this.currentRouter) === null || _this$currentRouter === void 0 ? void 0 : _this$currentRouter.getRouterId()
|
|
6474
|
+
}, routerSchemes(this.currentRouter)), {}, {
|
|
6459
6475
|
customValidate: this.customValidateFunctions && ((_this$customValidateF = this.customValidateFunctions) === null || _this$customValidateF === void 0 ? void 0 : _this$customValidateF.length) > 0,
|
|
6460
6476
|
jsonValues: this.isJsonValues ? true : undefined,
|
|
6461
6477
|
external: (_this$externalLabel = this.externalLabel) !== null && _this$externalLabel !== void 0 ? _this$externalLabel : undefined,
|
|
6462
6478
|
readonly: this.isReadonly,
|
|
6463
6479
|
hidden: this.isHidden,
|
|
6464
6480
|
description: this.description
|
|
6465
|
-
};
|
|
6481
|
+
});
|
|
6466
6482
|
if (this.mediaOptions) {
|
|
6467
6483
|
result.mediaType = this.mediaOptions.type;
|
|
6468
6484
|
result.accept = this.mediaOptions.accept;
|
|
@@ -8742,7 +8758,8 @@ function settings() {
|
|
|
8742
8758
|
}).nullable().describe("The project's own mark, shown where Val's is in the Studio. A square-ish mark rather than a wordmark: the slot is 32px wide.")
|
|
8743
8759
|
}),
|
|
8744
8760
|
studio: new SettingsSchema({
|
|
8745
|
-
tour: _boolean().nullable().describe("Whether editors are offered the guided tour of the Studio. Unset means yes. Off hides the offer for everyone on this project — the tour stays in Quick actions for anyone who wants it.")
|
|
8761
|
+
tour: _boolean().nullable().describe("Whether editors are offered the guided tour of the Studio. Unset means yes. Off hides the offer for everyone on this project — the tour stays in Quick actions for anyone who wants it."),
|
|
8762
|
+
commitMessage: enumSchema("automatic", "required").nullable().describe("Whether publishing asks for a commit message. Unset is the same as 'automatic': Publish publishes straight away, with a message the AI writes (or one listing what changed). 'required' asks every time, and will not publish an empty one.")
|
|
8746
8763
|
}),
|
|
8747
8764
|
locales: new SettingsSchema({
|
|
8748
8765
|
// Nullable because the source type is, and because the Studio writes
|
|
@@ -10914,7 +10931,7 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10914
10931
|
}, {
|
|
10915
10932
|
key: "executeValidate",
|
|
10916
10933
|
value: function executeValidate(path, src) {
|
|
10917
|
-
var _this$options, _this$options2, _this$options3, _this$options4;
|
|
10934
|
+
var _this$options, _this$options2, _this$options3, _this$options4, _this$options5, _this$options6;
|
|
10918
10935
|
var errors = this.executeCustomValidateFunctions(src, this.customValidateFunctions, {
|
|
10919
10936
|
path: path
|
|
10920
10937
|
});
|
|
@@ -10928,7 +10945,31 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10928
10945
|
});
|
|
10929
10946
|
return _defineProperty({}, path, errors);
|
|
10930
10947
|
}
|
|
10931
|
-
|
|
10948
|
+
// The bounds below are compared as strings, which only orders days when
|
|
10949
|
+
// every side is a real `YYYY-MM-DD`: "19f81-12-30" sorts between
|
|
10950
|
+
// "1900-01-01" and "2024-01-01" and would pass them.
|
|
10951
|
+
if (!isCalendarDay(src)) {
|
|
10952
|
+
errors.push({
|
|
10953
|
+
message: "Value '".concat(src, "' is not a valid date (expected YYYY-MM-DD)"),
|
|
10954
|
+
value: src
|
|
10955
|
+
});
|
|
10956
|
+
return _defineProperty({}, path, errors);
|
|
10957
|
+
}
|
|
10958
|
+
var bounds = [["From", (_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.from], ["To", (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.to]];
|
|
10959
|
+
for (var _i = 0, _bounds = bounds; _i < _bounds.length; _i++) {
|
|
10960
|
+
var _bounds$_i = _slicedToArray(_bounds[_i], 2),
|
|
10961
|
+
name = _bounds$_i[0],
|
|
10962
|
+
bound = _bounds$_i[1];
|
|
10963
|
+
if (bound !== undefined && !isCalendarDay(bound)) {
|
|
10964
|
+
errors.push({
|
|
10965
|
+
message: "".concat(name, " date '").concat(bound, "' is not a valid date (expected YYYY-MM-DD)"),
|
|
10966
|
+
value: src,
|
|
10967
|
+
typeError: true
|
|
10968
|
+
});
|
|
10969
|
+
return _defineProperty({}, path, errors);
|
|
10970
|
+
}
|
|
10971
|
+
}
|
|
10972
|
+
if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.from && (_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.to) {
|
|
10932
10973
|
if (this.options.from > this.options.to) {
|
|
10933
10974
|
errors.push({
|
|
10934
10975
|
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
|
@@ -10941,14 +10982,14 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
10941
10982
|
value: src
|
|
10942
10983
|
});
|
|
10943
10984
|
}
|
|
10944
|
-
} else if ((_this$
|
|
10985
|
+
} else if ((_this$options5 = this.options) !== null && _this$options5 !== void 0 && _this$options5.from) {
|
|
10945
10986
|
if (src < this.options.from) {
|
|
10946
10987
|
errors.push({
|
|
10947
10988
|
message: "Date is before the minimum date ".concat(this.options.from),
|
|
10948
10989
|
value: src
|
|
10949
10990
|
});
|
|
10950
10991
|
}
|
|
10951
|
-
} else if ((_this$
|
|
10992
|
+
} else if ((_this$options6 = this.options) !== null && _this$options6 !== void 0 && _this$options6.to) {
|
|
10952
10993
|
if (src > this.options.to) {
|
|
10953
10994
|
errors.push({
|
|
10954
10995
|
message: "Date is after the maximum date ".concat(this.options.to),
|
|
@@ -11118,6 +11159,27 @@ var DateSchema = /*#__PURE__*/function (_Schema) {
|
|
|
11118
11159
|
}
|
|
11119
11160
|
}]);
|
|
11120
11161
|
}(Schema);
|
|
11162
|
+
var CALENDAR_DAY = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
11163
|
+
|
|
11164
|
+
/**
|
|
11165
|
+
* Whether `value` is a `YYYY-MM-DD` day that exists on the calendar — so
|
|
11166
|
+
* "2023-02-29" and "2024-13-01" are not, even though they have the shape.
|
|
11167
|
+
*/
|
|
11168
|
+
function isCalendarDay(value) {
|
|
11169
|
+
var match = CALENDAR_DAY.exec(value);
|
|
11170
|
+
if (!match) {
|
|
11171
|
+
return false;
|
|
11172
|
+
}
|
|
11173
|
+
var year = Number(match[1]);
|
|
11174
|
+
var month = Number(match[2]);
|
|
11175
|
+
var day = Number(match[3]);
|
|
11176
|
+
// Out-of-range fields roll over (Feb 30 -> Mar 2) instead of failing, so a
|
|
11177
|
+
// day is real only if it survives the round trip. setUTCFullYear, not
|
|
11178
|
+
// Date.UTC: the latter maps years 0-99 to 1900-1999.
|
|
11179
|
+
var date = new Date(0);
|
|
11180
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
11181
|
+
return date.getUTCFullYear() === year && date.getUTCMonth() === month - 1 && date.getUTCDate() === day;
|
|
11182
|
+
}
|
|
11121
11183
|
var date = function date(options) {
|
|
11122
11184
|
return new DateSchema(options);
|
|
11123
11185
|
};
|
|
@@ -13767,35 +13829,165 @@ function isInlineRender(schema) {
|
|
|
13767
13829
|
return false;
|
|
13768
13830
|
}
|
|
13769
13831
|
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
|
|
13785
|
-
|
|
13786
|
-
|
|
13787
|
-
|
|
13788
|
-
|
|
13832
|
+
/**
|
|
13833
|
+
* Which URL schemes an external page key may use.
|
|
13834
|
+
*
|
|
13835
|
+
* External pages are the URLs a site links OUT to, and a link is not only a web
|
|
13836
|
+
* page: `mailto:` on a contact page and `tel:` on a phone number are the same
|
|
13837
|
+
* kind of thing to whoever maintains the list, and were refused outright.
|
|
13838
|
+
*
|
|
13839
|
+
* So the default is a deny list rather than an allow list — anything with a
|
|
13840
|
+
* scheme, except the handful that are not links at all. Listing every scheme
|
|
13841
|
+
* worth linking to is a list that is wrong the moment someone wants
|
|
13842
|
+
* `whatsapp:` or `msteams:`, and being wrong that way means an editor cannot
|
|
13843
|
+
* store a URL their site genuinely uses.
|
|
13844
|
+
*
|
|
13845
|
+
* A project that wants to be stricter says so:
|
|
13846
|
+
*
|
|
13847
|
+
* ```ts
|
|
13848
|
+
* s.router(externalPageRouter({ schemes: ["https", "mailto"] }), item)
|
|
13849
|
+
* ```
|
|
13850
|
+
*/
|
|
13851
|
+
|
|
13852
|
+
/**
|
|
13853
|
+
* The schemes that are refused however wide the policy is.
|
|
13854
|
+
*
|
|
13855
|
+
* Not a style preference. An external page key ends up in an `href` in the
|
|
13856
|
+
* consuming site's own markup, so `javascript:` there is stored XSS on that
|
|
13857
|
+
* site, and `data:` is the same trick wearing a document. `vbscript:` is the
|
|
13858
|
+
* historical spelling of the first. `file:` and `blob:` address the visitor's
|
|
13859
|
+
* own machine rather than anywhere on the internet.
|
|
13860
|
+
*
|
|
13861
|
+
* These stay refused even when a project lists them in `schemes`: a config
|
|
13862
|
+
* option is not a good enough reason to let content inject script into the
|
|
13863
|
+
* page that renders it.
|
|
13864
|
+
*/
|
|
13865
|
+
var UNSAFE_URL_SCHEMES = ["javascript", "data", "vbscript", "file", "blob"];
|
|
13866
|
+
/** The scheme of a URL, lowercased and without the colon, or null. */
|
|
13867
|
+
function schemeOf(url) {
|
|
13868
|
+
var match = /^([a-zA-Z][a-zA-Z0-9+.-]*):/.exec(url.trim());
|
|
13869
|
+
return match === null ? null : match[1].toLowerCase();
|
|
13870
|
+
}
|
|
13871
|
+
/** `null` when the URL's scheme is acceptable under `policy`. */
|
|
13872
|
+
function rejectScheme(url) {
|
|
13873
|
+
var policy = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13874
|
+
var scheme = schemeOf(url);
|
|
13875
|
+
if (scheme === null) {
|
|
13876
|
+
return {
|
|
13877
|
+
reason: "no-scheme"
|
|
13878
|
+
};
|
|
13879
|
+
}
|
|
13880
|
+
if (UNSAFE_URL_SCHEMES.includes(scheme)) {
|
|
13881
|
+
return {
|
|
13882
|
+
reason: "unsafe",
|
|
13883
|
+
scheme: scheme
|
|
13884
|
+
};
|
|
13885
|
+
}
|
|
13886
|
+
if (policy.schemes !== undefined) {
|
|
13887
|
+
var allowed = policy.schemes.map(function (s) {
|
|
13888
|
+
return s.toLowerCase();
|
|
13889
|
+
});
|
|
13890
|
+
if (!allowed.includes(scheme)) {
|
|
13891
|
+
return {
|
|
13892
|
+
reason: "not-allowed",
|
|
13893
|
+
scheme: scheme,
|
|
13894
|
+
allowed: policy.schemes
|
|
13895
|
+
};
|
|
13896
|
+
}
|
|
13897
|
+
}
|
|
13898
|
+
return null;
|
|
13899
|
+
}
|
|
13900
|
+
|
|
13901
|
+
/** What to tell whoever wrote the key. */
|
|
13902
|
+
function describeSchemeRejection(rejection) {
|
|
13903
|
+
switch (rejection.reason) {
|
|
13904
|
+
case "no-scheme":
|
|
13905
|
+
return "Must start with a scheme, like https:// or mailto:.";
|
|
13906
|
+
case "unsafe":
|
|
13907
|
+
return "\"".concat(rejection.scheme, ":\" cannot be used in a link: it runs code or reads the visitor's own machine rather than pointing at somewhere on the internet.");
|
|
13908
|
+
case "not-allowed":
|
|
13909
|
+
return "\"".concat(rejection.scheme, ":\" is not one of the schemes this router allows (").concat(rejection.allowed.join(", "), ").");
|
|
13910
|
+
}
|
|
13911
|
+
}
|
|
13912
|
+
|
|
13913
|
+
/**
|
|
13914
|
+
* Whether a link check can open this URL.
|
|
13915
|
+
*
|
|
13916
|
+
* Separate from whether it is ALLOWED, and the two are not the same question:
|
|
13917
|
+
* `mailto:` is a perfectly good external page and there is no request to make
|
|
13918
|
+
* of it. A URL that cannot be opened is reported as not checked, never as
|
|
13919
|
+
* broken.
|
|
13920
|
+
*/
|
|
13921
|
+
function isCheckableScheme(url) {
|
|
13922
|
+
var scheme = schemeOf(url);
|
|
13923
|
+
return scheme === "http" || scheme === "https";
|
|
13924
|
+
}
|
|
13925
|
+
|
|
13926
|
+
/**
|
|
13927
|
+
* The router whose keys are URLs to somewhere else.
|
|
13928
|
+
*
|
|
13929
|
+
* Used directly for the wide default, or called to narrow it:
|
|
13930
|
+
*
|
|
13931
|
+
* ```ts
|
|
13932
|
+
* s.router(externalPageRouter, item) // anything safe
|
|
13933
|
+
* s.router(externalPageRouter({ schemes: ["https"] }), item) // https only
|
|
13934
|
+
* ```
|
|
13935
|
+
*
|
|
13936
|
+
* Its one rule is that a key has a scheme, and that the scheme is not one of
|
|
13937
|
+
* the handful that are not links at all - see `externalUrlSchemes.ts`. That
|
|
13938
|
+
* rule was WRITTEN here from the start and never enforced: the errors were
|
|
13939
|
+
* collected into a list and then `return []` threw them away, so every key was
|
|
13940
|
+
* accepted however it was spelled.
|
|
13941
|
+
*
|
|
13942
|
+
* `expectedPath` is null because there is nothing to suggest: a key that is
|
|
13943
|
+
* not a URL could have been meant as any URL, and guessing `https://` in front
|
|
13944
|
+
* of it would propose a different site as often as the right one.
|
|
13945
|
+
*/
|
|
13946
|
+
var externalPageRouter = Object.assign(function (policy) {
|
|
13947
|
+
return createExternalPageRouter(policy);
|
|
13948
|
+
}, createExternalPageRouter());
|
|
13949
|
+
|
|
13950
|
+
/**
|
|
13951
|
+
* Callable AND a router, so `externalPageRouter` keeps working unchanged
|
|
13952
|
+
* where nobody needs to configure it - which is almost everywhere.
|
|
13953
|
+
*/
|
|
13954
|
+
|
|
13955
|
+
function createExternalPageRouter() {
|
|
13956
|
+
var policy = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13957
|
+
return {
|
|
13958
|
+
getRouterId: function getRouterId() {
|
|
13959
|
+
return "external-url-router";
|
|
13960
|
+
},
|
|
13961
|
+
getUrlSchemePolicy: function getUrlSchemePolicy() {
|
|
13962
|
+
return policy;
|
|
13963
|
+
},
|
|
13964
|
+
validate: function validate(_moduleFilePath, urlPaths) {
|
|
13965
|
+
var errors = [];
|
|
13966
|
+
var _iterator = result._createForOfIteratorHelper(urlPaths),
|
|
13967
|
+
_step;
|
|
13968
|
+
try {
|
|
13969
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
13970
|
+
var urlPath = _step.value;
|
|
13971
|
+
var rejection = rejectScheme(urlPath, policy);
|
|
13972
|
+
if (rejection !== null) {
|
|
13973
|
+
errors.push({
|
|
13974
|
+
error: {
|
|
13975
|
+
message: "URL \"".concat(urlPath, "\" cannot be used here. ").concat(describeSchemeRejection(rejection)),
|
|
13976
|
+
expectedPath: null,
|
|
13977
|
+
urlPath: urlPath
|
|
13978
|
+
}
|
|
13979
|
+
});
|
|
13980
|
+
}
|
|
13789
13981
|
}
|
|
13982
|
+
} catch (err) {
|
|
13983
|
+
_iterator.e(err);
|
|
13984
|
+
} finally {
|
|
13985
|
+
_iterator.f();
|
|
13790
13986
|
}
|
|
13791
|
-
|
|
13792
|
-
_iterator.e(err);
|
|
13793
|
-
} finally {
|
|
13794
|
-
_iterator.f();
|
|
13987
|
+
return errors;
|
|
13795
13988
|
}
|
|
13796
|
-
|
|
13797
|
-
|
|
13798
|
-
};
|
|
13989
|
+
};
|
|
13990
|
+
}
|
|
13799
13991
|
// Helper function to validate a URL path against a route pattern
|
|
13800
13992
|
function validateUrlAgainstPattern(urlPath, routePattern) {
|
|
13801
13993
|
// Remove leading slash and split URL path
|
|
@@ -14195,7 +14387,7 @@ function isPageRouter(routerId) {
|
|
|
14195
14387
|
|
|
14196
14388
|
var corePackageJson = {
|
|
14197
14389
|
name: "@valbuild/core",
|
|
14198
|
-
version: "0.
|
|
14390
|
+
version: "0.138.0",
|
|
14199
14391
|
"private": false,
|
|
14200
14392
|
description: "Val - supercharged hard-coded content",
|
|
14201
14393
|
repository: {
|
|
@@ -14309,6 +14501,11 @@ var Internal = {
|
|
|
14309
14501
|
nextAppRouter: nextAppRouter,
|
|
14310
14502
|
tanstackRouter: tanstackRouter,
|
|
14311
14503
|
externalPageRouter: externalPageRouter,
|
|
14504
|
+
describeSchemeRejection: describeSchemeRejection,
|
|
14505
|
+
isCheckableScheme: isCheckableScheme,
|
|
14506
|
+
rejectScheme: rejectScheme,
|
|
14507
|
+
schemeOf: schemeOf,
|
|
14508
|
+
UNSAFE_URL_SCHEMES: UNSAFE_URL_SCHEMES,
|
|
14312
14509
|
color: {
|
|
14313
14510
|
parseColor: parseColor,
|
|
14314
14511
|
formatColor: formatColor,
|
|
@@ -14439,6 +14636,7 @@ exports.StringSchema = StringSchema;
|
|
|
14439
14636
|
exports.THEME_LOGO_DIRECTORY = THEME_LOGO_DIRECTORY;
|
|
14440
14637
|
exports.THEME_RADIUS_LENGTHS = THEME_RADIUS_LENGTHS;
|
|
14441
14638
|
exports.THEME_RADIUS_STEPS = THEME_RADIUS_STEPS;
|
|
14639
|
+
exports.UNSAFE_URL_SCHEMES = UNSAFE_URL_SCHEMES;
|
|
14442
14640
|
exports.VAL_EXTENSION = VAL_EXTENSION;
|
|
14443
14641
|
exports.ValViewSchema = ValViewSchema;
|
|
14444
14642
|
exports._classCallCheck = _classCallCheck;
|
|
@@ -14451,6 +14649,7 @@ exports.computeSourcesSha = computeSourcesSha;
|
|
|
14451
14649
|
exports.computeValModuleShas = computeValModuleShas;
|
|
14452
14650
|
exports.declaredKeySetOf = declaredKeySetOf;
|
|
14453
14651
|
exports.derefPatch = derefPatch;
|
|
14652
|
+
exports.describeSchemeRejection = describeSchemeRejection;
|
|
14454
14653
|
exports.deserializeSchema = deserializeSchema;
|
|
14455
14654
|
exports.discriminatedUnionBranchOf = discriminatedUnionBranchOf;
|
|
14456
14655
|
exports.extractValModules = extractValModules;
|
|
@@ -14458,6 +14657,7 @@ exports.getSourcePathFromRoute = getSourcePathFromRoute;
|
|
|
14458
14657
|
exports.hasMediaSchema = hasMediaSchema;
|
|
14459
14658
|
exports.hasRemoteFileSchema = hasRemoteFileSchema;
|
|
14460
14659
|
exports.initVal = initVal;
|
|
14660
|
+
exports.isCheckableScheme = isCheckableScheme;
|
|
14461
14661
|
exports.isInlineRender = isInlineRender;
|
|
14462
14662
|
exports.isPageRouter = isPageRouter;
|
|
14463
14663
|
exports.isRootModuleFilePath = isRootModuleFilePath;
|
|
@@ -14469,7 +14669,9 @@ exports.modules = modules;
|
|
|
14469
14669
|
exports.parseNextJsRoutePattern = parseNextJsRoutePattern;
|
|
14470
14670
|
exports.parseTanStackRoutePattern = parseTanStackRoutePattern;
|
|
14471
14671
|
exports.previewScope = previewScope;
|
|
14672
|
+
exports.rejectScheme = rejectScheme;
|
|
14472
14673
|
exports.resolveSettingsModule = resolveSettingsModule;
|
|
14674
|
+
exports.schemeOf = schemeOf;
|
|
14473
14675
|
exports.splitModuleFilePathAndModulePath = splitModuleFilePathAndModulePath;
|
|
14474
14676
|
exports.tanStackSegmentsOfRoutePath = tanStackSegmentsOfRoutePath;
|
|
14475
14677
|
exports.validateUrlAgainstPattern = validateUrlAgainstPattern;
|