@valbuild/shared 0.146.0 → 0.146.4

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 CHANGED
@@ -1,5 +1,43 @@
1
1
  # @valbuild/shared
2
2
 
3
+ ## 0.146.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#870](https://github.com/valbuild/val/pull/870) [`81f2e80`](https://github.com/valbuild/val/commit/81f2e803c4cefdf58bbe6856c06e98ace95a8e0b) Thanks [@freekh](https://github.com/freekh)! - The canvas works on a page behind your site's own login.
8
+
9
+ A site with its own sign-in (a dashboard, an intranet, a members' area) can be edited in the canvas. The canvas is a frame on the same origin as the Studio, so it sends your site's cookies like any other tab: if you are signed in to the site, the canvas shows the page signed in as you.
10
+
11
+ If you were not signed in, the site redirected the canvas to its login page, and the canvas then broke. That page mounted Val's whole overlay inside the canvas, a Studio inside the Studio. The canvas stayed on "Preview is not ready yet" through the sign-in and after it, until you pressed Reload. Now a page shown in the Studio's canvas counts as the canvas wherever it navigated to, so you can sign in inside the canvas and keep editing.
12
+
13
+ ## 0.146.2
14
+
15
+ ### Patch Changes
16
+
17
+ - [#871](https://github.com/valbuild/val/pull/871) [`e4913e1`](https://github.com/valbuild/val/commit/e4913e1f1178e09987a7c03fd540909ab4b499b0) Thanks [@freekh](https://github.com/freekh)! - An image, file or video picked from a gallery is checked against the gallery as it is now. Picking one uploaded since the site was built (still unpublished, saved in a proposal, or published without a rebuild) used to fail with "The gallery does not have an image at …" and refuse the save. In a proposal, Save now reads "Fix N" and goes to the validation errors instead of being refused by the server, as Publish does on the site.
18
+
19
+ - [#867](https://github.com/valbuild/val/pull/867) [`04f81ba`](https://github.com/valbuild/val/commit/04f81baeee4a98054c0673ca9fdc34bc5cadacb9) Thanks [@freekh](https://github.com/freekh)! - When a publish breaks a page on a site with proposals, its changes are no longer
20
+ held back on the site: they move into a proposal of their own, with any later
21
+ changes to the same pages, so everyone else keeps publishing. The Studio says
22
+ so — "Publishing broke the site" — and offers **Open the proposal**, where the
23
+ changes can be fixed and published. Sites without proposals hold the changes
24
+ back as before.
25
+
26
+ - [#867](https://github.com/valbuild/val/pull/867) [`04f81ba`](https://github.com/valbuild/val/commit/04f81baeee4a98054c0673ca9fdc34bc5cadacb9) Thanks [@freekh](https://github.com/freekh)! - Publish only some of your changes: tick them in Review and press **Publish
27
+ selected**. On a site with proposals, Val moves them into a proposal of their
28
+ own and publishes it straight away; everything else stays unpublished, as it
29
+ was.
30
+
31
+ Some changes cannot be published apart — two edits to the same list, say — so
32
+ the confirm says what comes with your selection and whose it is before anything
33
+ moves. If the site is published while yours is being prepared, nothing is
34
+ published and you are asked to press it again. If publishing stops after the
35
+ changes have moved, they are safe in their proposal, and Review offers to open
36
+ it as well as to try again.
37
+
38
+ - Updated dependencies [[`e4913e1`](https://github.com/valbuild/val/commit/e4913e1f1178e09987a7c03fd540909ab4b499b0)]:
39
+ - @valbuild/core@0.146.2
40
+
3
41
  ## 0.146.0
4
42
 
5
43
  ### Minor Changes
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getSitemapTree = require('../../dist/getSitemapTree-c732e09a.cjs.dev.js');
5
+ var getSitemapTree = require('../../dist/getSitemapTree-95b00d3f.cjs.dev.js');
6
6
  require('@valbuild/core');
7
7
 
8
8
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var getSitemapTree = require('../../dist/getSitemapTree-0ed3deac.cjs.prod.js');
5
+ var getSitemapTree = require('../../dist/getSitemapTree-b8dce0e2.cjs.prod.js');
6
6
  require('@valbuild/core');
7
7
 
8
8
 
@@ -1,2 +1,2 @@
1
- export { D as DEFAULT_CANVAS_SELECTION, e as DEFAULT_CANVAS_SELECTION_SOFT, b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSourceFolder, m as getPageRouterSitemapTree, k as getPageRouterSourceFolder, n as getPatternFromModuleFilePath, j as getTanStackRouterSourceFolder, l as isTanStackRoutesFolder, g as isValCanvasFrame, i as isValCanvasPageMessage, f as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-6fcdf745.esm.js';
1
+ export { D as DEFAULT_CANVAS_SELECTION, e as DEFAULT_CANVAS_SELECTION_SOFT, b as VAL_AI_SESSION_STORAGE_KEY, d as VAL_CANVAS_MESSAGE, c as VAL_CANVAS_PARAM, V as VAL_CONFIG_SESSION_STORAGE_KEY, a as VAL_THEME_SESSION_STORAGE_KEY, h as getNextAppRouterSourceFolder, m as getPageRouterSitemapTree, k as getPageRouterSourceFolder, n as getPatternFromModuleFilePath, j as getTanStackRouterSourceFolder, l as isTanStackRoutesFolder, g as isValCanvasFrame, i as isValCanvasPageMessage, f as isValCanvasStudioMessage, p as parseRoutePattern, w as withValCanvasParam } from '../../dist/getSitemapTree-e65acefe.esm.js';
2
2
  import '@valbuild/core';
@@ -1147,6 +1147,63 @@ export declare const Api: {
1147
1147
  }, z.core.$strip>]>;
1148
1148
  };
1149
1149
  };
1150
+ /**
1151
+ * Publish selected (`docs/plans/remove-patch-groups.md`, Phase 4), its first
1152
+ * half, on the site's own server: the changes picked in Review, already
1153
+ * closed into whole patch sets (`selectionClosure`), moved into a proposal
1154
+ * of kind `publish` and saved there -- prepared over the site's head, which
1155
+ * the proposal is based on, so a publish landing in between is refused
1156
+ * rather than reverted. The second half is that proposal's Publish, pressed
1157
+ * as any proposal's is (`publishProposal`); this server answers its checks
1158
+ * and press with what the merge moves, as the proposal's own address would.
1159
+ */
1160
+ "/publish-selected": {
1161
+ POST: {
1162
+ req: {
1163
+ body: z.ZodObject<{
1164
+ patchIds: z.ZodArray<z.ZodString & z.ZodType<PatchIdT, string, z.core.$ZodTypeInternals<PatchIdT, string>>>;
1165
+ displayName: z.ZodString;
1166
+ requestId: z.ZodString;
1167
+ }, z.core.$strip>;
1168
+ cookies: {
1169
+ val_session: z.ZodOptional<z.ZodString>;
1170
+ };
1171
+ };
1172
+ res: z.ZodUnion<readonly [z.ZodObject<{
1173
+ status: z.ZodLiteral<401>;
1174
+ json: z.ZodObject<{
1175
+ message: z.ZodString;
1176
+ }, z.core.$strip>;
1177
+ }, z.core.$strip>, z.ZodObject<{
1178
+ status: z.ZodLiteral<400>;
1179
+ json: z.ZodObject<{
1180
+ message: z.ZodString;
1181
+ }, z.core.$strip>;
1182
+ }, z.core.$strip>, z.ZodObject<{
1183
+ status: z.ZodLiteral<409>;
1184
+ json: z.ZodObject<{
1185
+ message: z.ZodString;
1186
+ headMoved: z.ZodOptional<z.ZodLiteral<true>>;
1187
+ }, z.core.$strip>;
1188
+ }, z.core.$strip>, z.ZodObject<{
1189
+ status: z.ZodLiteral<500>;
1190
+ json: z.ZodObject<{
1191
+ message: z.ZodString;
1192
+ }, z.core.$strip>;
1193
+ }, z.core.$strip>, z.ZodObject<{
1194
+ status: z.ZodLiteral<502>;
1195
+ json: z.ZodObject<{
1196
+ message: z.ZodString;
1197
+ proposal: z.ZodString;
1198
+ }, z.core.$strip>;
1199
+ }, z.core.$strip>, z.ZodObject<{
1200
+ status: z.ZodLiteral<200>;
1201
+ json: z.ZodObject<{
1202
+ proposal: z.ZodString;
1203
+ }, z.core.$strip>;
1204
+ }, z.core.$strip>]>;
1205
+ };
1206
+ };
1150
1207
  "/save": {
1151
1208
  POST: {
1152
1209
  req: {
@@ -38,5 +38,6 @@ export * from "./theme/accentRamp.js";
38
38
  export * from "./publish/contentApi.js";
39
39
  export * from "./publish/protocol.js";
40
40
  export * from "./patchSets/PatchSets.js";
41
+ export * from "./patchSets/selectionClosure.js";
41
42
  export * from "./patchSets/schemaTypesOfPath.js";
42
43
  export * from "./proposalMerge/trees.js";
@@ -0,0 +1,23 @@
1
+ import type { PatchId } from "@valbuild/core";
2
+ import type { SerializedPatchSet } from "./PatchSets.js";
3
+ /**
4
+ * Patch sets that share a change become one: a change is never split.
5
+ *
6
+ * Shared by the two places that move changes between branches a whole set at
7
+ * a time -- the merge moving the site's conflicting pending changes
8
+ * (`changesToMove` in `@valbuild/server`) and Publish selected
9
+ * ({@link selectionClosure}) -- so that they agree on what "a whole set" is.
10
+ */
11
+ export declare function joinSharedChanges(sets: PatchId[][]): Set<PatchId>[];
12
+ /**
13
+ * What publishing `selected` publishes: every change in every patch set a
14
+ * selected change is in, sets that share a change joined
15
+ * (valbuild/val `docs/plans/remove-patch-groups.md`, Phase 4, rule 2).
16
+ *
17
+ * A patch set is changes that do not apply without each other, so a selection
18
+ * of part of one cannot be published on its own. What it pulls in is someone
19
+ * else's as often as not; the caller says whose, before anything moves.
20
+ *
21
+ * In the order of `patchIds` -- the chain's -- with nothing that is not in it.
22
+ */
23
+ export declare function selectionClosure(patchSets: SerializedPatchSet, selected: Iterable<PatchId>, patchIds: readonly PatchId[]): PatchId[];
@@ -431,6 +431,16 @@ export type PublishRequestStatus = {
431
431
  actions: ("try-again" | "discard" | "re-run-build")[];
432
432
  /** The job that failed: what Discard is pressed on. */
433
433
  job: string;
434
+ /**
435
+ * Where its changes went, on a project with proposals: off the site,
436
+ * into a proposal of their own, where they are fixed and published.
437
+ * `actions` is then empty -- that proposal's Publish is the Try again.
438
+ */
439
+ movedTo?: {
440
+ proposal: string;
441
+ displayName: string;
442
+ changes: number;
443
+ };
434
444
  } | {
435
445
  kind: "cancelled";
436
446
  } | {
@@ -59,8 +59,9 @@ export declare const SCHEMA_SOURCE_FIXES: ValidationFix[];
59
59
  /** Whether an error is a marker only the whole project can answer. */
60
60
  export declare function isSchemaSourceFixError(error: ValidationError): boolean;
61
61
  /**
62
- * The record a `keyof:check-keys` error resolves against, or null for any other
63
- * error — including a malformed marker, which
62
+ * The record a `keyof:check-keys` error resolves against -- or a gallery
63
+ * marker's (`image:check-gallery` and the rest): its gallery module -- or null
64
+ * for any other error, including a malformed marker, which
64
65
  * {@link resolveSchemaSourceFixForError} reports and this has nothing to say
65
66
  * about.
66
67
  *
@@ -261,12 +261,21 @@ export declare function isValCanvasPageMessage(data: unknown): data is ValCanvas
261
261
  /** Narrow an unknown `event.data` to a message from the studio. */
262
262
  export declare function isValCanvasStudioMessage(data: unknown): data is ValCanvasStudioMessage;
263
263
  /**
264
- * Whether this document was loaded as the studio's canvas frame.
264
+ * Whether this document is showing in the studio's canvas frame.
265
265
  *
266
- * Reads the location directly rather than taking it as an argument, because
267
- * every caller wants the answer for the document it is running in, and passing
268
- * it around is how one of them ends up asking about the wrong one.
266
+ * The parameter marks the document the studio LOADED, and that is not always
267
+ * the document the frame ends up holding. A frame navigates on its own: a site
268
+ * with a login of its own redirects a signed-out canvas to its sign-in page,
269
+ * and the sign-in sends it back to wherever the site chooses. Each of those is
270
+ * a new document without the parameter, and it used to render Val's whole
271
+ * overlay inside the canvas — a studio in the studio, which never told the
272
+ * canvas it was there, so the canvas never went live again until reloaded.
273
+ *
274
+ * So where the frame SITS answers too: a document whose parent is the studio
275
+ * is in the canvas, whatever its own address says. `parentPathname` is that
276
+ * parent's path: `null` for a top-level document, and for a parent on another
277
+ * origin, whose `location` cannot be read and which is not the studio anyway.
269
278
  */
270
- export declare function isValCanvasFrame(search: string): boolean;
279
+ export declare function isValCanvasFrame(search: string, parentPathname?: string | null): boolean;
271
280
  /** Add the canvas marker to a page URL. */
272
281
  export declare function withValCanvasParam(url: string): string;
@@ -121,13 +121,26 @@ function isValCanvasStudioMessage(data) {
121
121
  }
122
122
 
123
123
  /**
124
- * Whether this document was loaded as the studio's canvas frame.
124
+ * Whether this document is showing in the studio's canvas frame.
125
125
  *
126
- * Reads the location directly rather than taking it as an argument, because
127
- * every caller wants the answer for the document it is running in, and passing
128
- * it around is how one of them ends up asking about the wrong one.
126
+ * The parameter marks the document the studio LOADED, and that is not always
127
+ * the document the frame ends up holding. A frame navigates on its own: a site
128
+ * with a login of its own redirects a signed-out canvas to its sign-in page,
129
+ * and the sign-in sends it back to wherever the site chooses. Each of those is
130
+ * a new document without the parameter, and it used to render Val's whole
131
+ * overlay inside the canvas — a studio in the studio, which never told the
132
+ * canvas it was there, so the canvas never went live again until reloaded.
133
+ *
134
+ * So where the frame SITS answers too: a document whose parent is the studio
135
+ * is in the canvas, whatever its own address says. `parentPathname` is that
136
+ * parent's path: `null` for a top-level document, and for a parent on another
137
+ * origin, whose `location` cannot be read and which is not the studio anyway.
129
138
  */
130
139
  function isValCanvasFrame(search) {
140
+ var parentPathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
141
+ if (parentPathname !== null && isValStudioPathname(parentPathname)) {
142
+ return true;
143
+ }
131
144
  try {
132
145
  return new URLSearchParams(search).get(VAL_CANVAS_PARAM) !== null;
133
146
  } catch (_unused) {
@@ -135,6 +148,11 @@ function isValCanvasFrame(search) {
135
148
  }
136
149
  }
137
150
 
151
+ /** Whether a path is the studio's own route, where the canvas lives. */
152
+ function isValStudioPathname(pathname) {
153
+ return pathname === "/val" || pathname.startsWith("/val/");
154
+ }
155
+
138
156
  /** Add the canvas marker to a page URL. */
139
157
  function withValCanvasParam(url) {
140
158
  var separator = url.includes("?") ? "&" : "?";
@@ -121,13 +121,26 @@ function isValCanvasStudioMessage(data) {
121
121
  }
122
122
 
123
123
  /**
124
- * Whether this document was loaded as the studio's canvas frame.
124
+ * Whether this document is showing in the studio's canvas frame.
125
125
  *
126
- * Reads the location directly rather than taking it as an argument, because
127
- * every caller wants the answer for the document it is running in, and passing
128
- * it around is how one of them ends up asking about the wrong one.
126
+ * The parameter marks the document the studio LOADED, and that is not always
127
+ * the document the frame ends up holding. A frame navigates on its own: a site
128
+ * with a login of its own redirects a signed-out canvas to its sign-in page,
129
+ * and the sign-in sends it back to wherever the site chooses. Each of those is
130
+ * a new document without the parameter, and it used to render Val's whole
131
+ * overlay inside the canvas — a studio in the studio, which never told the
132
+ * canvas it was there, so the canvas never went live again until reloaded.
133
+ *
134
+ * So where the frame SITS answers too: a document whose parent is the studio
135
+ * is in the canvas, whatever its own address says. `parentPathname` is that
136
+ * parent's path: `null` for a top-level document, and for a parent on another
137
+ * origin, whose `location` cannot be read and which is not the studio anyway.
129
138
  */
130
139
  function isValCanvasFrame(search) {
140
+ var parentPathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
141
+ if (parentPathname !== null && isValStudioPathname(parentPathname)) {
142
+ return true;
143
+ }
131
144
  try {
132
145
  return new URLSearchParams(search).get(VAL_CANVAS_PARAM) !== null;
133
146
  } catch (_unused) {
@@ -135,6 +148,11 @@ function isValCanvasFrame(search) {
135
148
  }
136
149
  }
137
150
 
151
+ /** Whether a path is the studio's own route, where the canvas lives. */
152
+ function isValStudioPathname(pathname) {
153
+ return pathname === "/val" || pathname.startsWith("/val/");
154
+ }
155
+
138
156
  /** Add the canvas marker to a page URL. */
139
157
  function withValCanvasParam(url) {
140
158
  var separator = url.includes("?") ? "&" : "?";
@@ -119,13 +119,26 @@ function isValCanvasStudioMessage(data) {
119
119
  }
120
120
 
121
121
  /**
122
- * Whether this document was loaded as the studio's canvas frame.
122
+ * Whether this document is showing in the studio's canvas frame.
123
123
  *
124
- * Reads the location directly rather than taking it as an argument, because
125
- * every caller wants the answer for the document it is running in, and passing
126
- * it around is how one of them ends up asking about the wrong one.
124
+ * The parameter marks the document the studio LOADED, and that is not always
125
+ * the document the frame ends up holding. A frame navigates on its own: a site
126
+ * with a login of its own redirects a signed-out canvas to its sign-in page,
127
+ * and the sign-in sends it back to wherever the site chooses. Each of those is
128
+ * a new document without the parameter, and it used to render Val's whole
129
+ * overlay inside the canvas — a studio in the studio, which never told the
130
+ * canvas it was there, so the canvas never went live again until reloaded.
131
+ *
132
+ * So where the frame SITS answers too: a document whose parent is the studio
133
+ * is in the canvas, whatever its own address says. `parentPathname` is that
134
+ * parent's path: `null` for a top-level document, and for a parent on another
135
+ * origin, whose `location` cannot be read and which is not the studio anyway.
127
136
  */
128
137
  function isValCanvasFrame(search) {
138
+ var parentPathname = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
139
+ if (parentPathname !== null && isValStudioPathname(parentPathname)) {
140
+ return true;
141
+ }
129
142
  try {
130
143
  return new URLSearchParams(search).get(VAL_CANVAS_PARAM) !== null;
131
144
  } catch (_unused) {
@@ -133,6 +146,11 @@ function isValCanvasFrame(search) {
133
146
  }
134
147
  }
135
148
 
149
+ /** Whether a path is the studio's own route, where the canvas lives. */
150
+ function isValStudioPathname(pathname) {
151
+ return pathname === "/val" || pathname.startsWith("/val/");
152
+ }
153
+
136
154
  /** Add the canvas marker to a page URL. */
137
155
  function withValCanvasParam(url) {
138
156
  var separator = url.includes("?") ? "&" : "?";