@valbuild/shared 0.146.2 → 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,15 @@
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
+
3
13
  ## 0.146.2
4
14
 
5
15
  ### Patch 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';
@@ -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("?") ? "&" : "?";
@@ -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
  var core = require('@valbuild/core');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
@@ -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
  var core = require('@valbuild/core');
7
7
  var zod = require('zod');
8
8
  var zodValidationError = require('zod-validation-error');
@@ -1,5 +1,5 @@
1
- import { _ as _createForOfIteratorHelper, o as _objectSpread2, q as _arrayLikeToArray, r as _unsupportedIterableToArray, s as _typeof, t as _defineProperty, u as _toPropertyKey } from '../../dist/getSitemapTree-6fcdf745.esm.js';
2
- 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
+ import { _ as _createForOfIteratorHelper, o as _objectSpread2, q as _arrayLikeToArray, r as _unsupportedIterableToArray, s as _typeof, t as _defineProperty, u as _toPropertyKey } from '../../dist/getSitemapTree-e65acefe.esm.js';
2
+ 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';
3
3
  import { Internal, CODE_LANGUAGES, resolveSettingsModule, missingDeclaredKeys, localeOfValue, discriminatedUnionBranchOf, DEFAULT_COLOR_FORMAT, declaredKeySetOf } from '@valbuild/core';
4
4
  import { z } from 'zod';
5
5
  import { fromError } from 'zod-validation-error';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@valbuild/shared",
3
- "version": "0.146.2",
3
+ "version": "0.146.4",
4
4
  "private": false,
5
5
  "description": "Val shared types and utilities",
6
6
  "repository": {