@kong/spec-renderer 1.117.5-pr.1073.764ab9e.0 → 1.117.5
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/dist/cli/index.js +0 -0
- package/dist/cli/preview-page/client.js +72 -94
- package/dist/cli/preview-page/client.js.map +1 -1
- package/dist/cli/preview-page/preview-state.js +9 -12
- package/dist/cli/preview-page/preview-state.js.map +1 -1
- package/dist/cli/resolve-render-options.js +4 -5
- package/dist/cli/resolve-render-options.js.map +1 -1
- package/dist/cli/server.js +21 -15
- package/dist/cli/server.js.map +1 -1
- package/dist/kongctl-ext-spec-preview-universal.tar.gz +0 -0
- package/package.json +27 -26
package/dist/cli/index.js
CHANGED
|
File without changes
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { nodePathFromUrl, parseSavedScrollPosition, SCROLL_STORAGE_KEY, } from './preview-state.js';
|
|
2
2
|
const SCROLL_POLL_INTERVAL_MS = 100;
|
|
3
3
|
/**
|
|
4
|
-
* The first restore can
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* after this delay, then reveal the page - everything is hidden until then,
|
|
9
|
-
* so none of these movements are visible.
|
|
4
|
+
* The first restore can trigger more `scrollY` shifts: the renderer lazily
|
|
5
|
+
* mounts sections around the viewport, and the browser's scroll anchoring
|
|
6
|
+
* compensates. Re-assert the offset once more after this delay, then reveal
|
|
7
|
+
* the page. Everything is hidden until then.
|
|
10
8
|
*/
|
|
11
9
|
const SCROLL_REASSERT_DELAY_MS = 800;
|
|
12
10
|
/**
|
|
13
|
-
* Give up on restoring after this long
|
|
14
|
-
* offset
|
|
11
|
+
* Give up on restoring after this long. The spec can shrink below the
|
|
12
|
+
* saved offset.
|
|
15
13
|
*/
|
|
16
14
|
const SCROLL_RESTORE_TIMEOUT_MS = 4000;
|
|
17
15
|
/**
|
|
18
|
-
* Set by the `path-not-found` handler
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
16
|
+
* Set by the `path-not-found` handler. The saved position belongs to a
|
|
17
|
+
* section the latest spec edit removed, so a running restore must stop.
|
|
18
|
+
* A scroll-driven hash update must not set this flag. Only a removed
|
|
19
|
+
* section does.
|
|
22
20
|
*/
|
|
23
21
|
let scrollRestoreCancelled = false;
|
|
24
22
|
function readSavedScrollPosition() {
|
|
@@ -30,10 +28,8 @@ function readSavedScrollPosition() {
|
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
/**
|
|
33
|
-
*
|
|
34
|
-
* `
|
|
35
|
-
* mounted set depends on how the page was scrolled). Anchoring to the
|
|
36
|
-
* section the viewport was in, at an offset within it, survives that.
|
|
31
|
+
* Finds the section the viewport is in, plus the offset within it. See
|
|
32
|
+
* `SavedSection` for why the anchor is needed.
|
|
37
33
|
*/
|
|
38
34
|
function findActiveSection() {
|
|
39
35
|
const root = document.getElementById('preview')?.shadowRoot;
|
|
@@ -65,13 +61,12 @@ function rememberScrollPosition() {
|
|
|
65
61
|
}));
|
|
66
62
|
}
|
|
67
63
|
catch {
|
|
68
|
-
// sessionStorage is unavailable (
|
|
64
|
+
// Skip when sessionStorage is unavailable (Safari private mode).
|
|
69
65
|
}
|
|
70
66
|
}
|
|
71
67
|
/**
|
|
72
|
-
* Finds the saved section
|
|
73
|
-
*
|
|
74
|
-
* edit added/removed sections and shifted indices.
|
|
68
|
+
* Finds the saved section again: by id when the spec is unchanged, else by
|
|
69
|
+
* heading text when a spec edit shifted the indices.
|
|
75
70
|
*/
|
|
76
71
|
function findSavedSection(savedSection) {
|
|
77
72
|
const root = document.getElementById('preview')?.shadowRoot;
|
|
@@ -93,11 +88,9 @@ function findSavedSection(savedSection) {
|
|
|
93
88
|
}
|
|
94
89
|
/**
|
|
95
90
|
* Where to scroll to: the saved section's live position plus the offset
|
|
96
|
-
* within it, measured at call time
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* raw saved `y` when the section can't be found again (e.g. the spec edit
|
|
100
|
-
* removed it - though that case usually goes through `path-not-found`).
|
|
91
|
+
* within it, measured at call time. The offset within a section always
|
|
92
|
+
* points at the same content. Falls back to the raw `y` when the section
|
|
93
|
+
* is gone.
|
|
101
94
|
*/
|
|
102
95
|
function scrollTarget(saved) {
|
|
103
96
|
if (saved.section === undefined) {
|
|
@@ -110,33 +103,28 @@ function scrollTarget(saved) {
|
|
|
110
103
|
return section.getBoundingClientRect().top + window.scrollY + saved.section.offsetIn;
|
|
111
104
|
}
|
|
112
105
|
/**
|
|
113
|
-
* Restores the scroll offset saved by `rememberScrollPosition`.
|
|
114
|
-
*
|
|
115
|
-
* The
|
|
116
|
-
*
|
|
117
|
-
* Several scrolls happen in sequence while settling into the saved offset:
|
|
118
|
-
* the renderer's own initial section scroll, our restore, and layout
|
|
119
|
-
* adjustments triggered by the renderer lazily (un)mounting sections around
|
|
120
|
-
* the viewport (which the browser's scroll anchoring compensates for).
|
|
121
|
-
* Rather than show that as visible jumping, the caller hides the renderer
|
|
122
|
-
* before its content renders and it is only revealed once the offset is
|
|
123
|
-
* final.
|
|
106
|
+
* Restores the scroll offset saved by `rememberScrollPosition`. The content
|
|
107
|
+
* renders asynchronously, so the browser's own scroll restoration cannot
|
|
108
|
+
* work. The settling moves the page several times, so the caller keeps the
|
|
109
|
+
* renderer hidden until the offset is final.
|
|
124
110
|
*/
|
|
125
111
|
function restoreScrollPosition(el) {
|
|
126
112
|
const saved = readSavedScrollPosition();
|
|
127
|
-
// The saved entry must belong to the
|
|
128
|
-
//
|
|
129
|
-
// earlier session's scroll offset.
|
|
113
|
+
// The saved entry must belong to the current URL. A deep link must not
|
|
114
|
+
// inherit an older scroll offset.
|
|
130
115
|
if (!saved || saved.href !== location.href) {
|
|
116
|
+
// The caller hides the element when the entry matches at hide time.
|
|
117
|
+
// The URL can move on during the load, so reveal here. The page must
|
|
118
|
+
// never stay hidden.
|
|
119
|
+
el.style.visibility = '';
|
|
131
120
|
return;
|
|
132
121
|
}
|
|
133
122
|
let hasInteracted = false;
|
|
134
123
|
const reveal = () => {
|
|
135
124
|
el.style.visibility = '';
|
|
136
125
|
};
|
|
137
|
-
//
|
|
138
|
-
//
|
|
139
|
-
// already reading/scrolling.
|
|
126
|
+
// User input wins over the restore. Reveal the page and do not move it
|
|
127
|
+
// while the user reads or scrolls.
|
|
140
128
|
for (const type of ['pointerdown', 'wheel', 'keydown', 'touchstart']) {
|
|
141
129
|
window.addEventListener(type, () => {
|
|
142
130
|
hasInteracted = true;
|
|
@@ -152,27 +140,24 @@ function restoreScrollPosition(el) {
|
|
|
152
140
|
const startedAt = performance.now();
|
|
153
141
|
let hasRendered = false;
|
|
154
142
|
const poll = () => {
|
|
155
|
-
// The
|
|
156
|
-
//
|
|
143
|
+
// The URL-restored path is invalid. The fallback handler already reset
|
|
144
|
+
// the URL and remounted the overview.
|
|
157
145
|
if (scrollRestoreCancelled) {
|
|
158
146
|
reveal();
|
|
159
147
|
return;
|
|
160
148
|
}
|
|
161
|
-
// Gate on
|
|
162
|
-
//
|
|
163
|
-
//
|
|
164
|
-
//
|
|
165
|
-
// good restore. The target is re-measured live, so sections that
|
|
166
|
-
// haven't rendered yet keep falling back to the raw `y`.
|
|
149
|
+
// Gate on the anchored target, or on the raw `y` when no anchor applies.
|
|
150
|
+
// A spec edit can shrink the document above the section. Then the raw
|
|
151
|
+
// `y` is unreachable, but the target is fine. The target is measured
|
|
152
|
+
// live, so sections not yet rendered still fall back to the raw `y`.
|
|
167
153
|
const isRendered = document.documentElement.scrollHeight > Math.min(scrollTarget(saved), saved.y);
|
|
168
154
|
if (isRendered) {
|
|
169
155
|
hasRendered = true;
|
|
170
156
|
}
|
|
171
157
|
if (hasRendered) {
|
|
172
|
-
// Restore
|
|
173
|
-
//
|
|
174
|
-
// target
|
|
175
|
-
// self-correct - and only then show the page.
|
|
158
|
+
// Restore, wait out the adjustments (see SCROLL_REASSERT_DELAY_MS),
|
|
159
|
+
// then re-assert and show the page. Each re-assert measures the
|
|
160
|
+
// target live, so virtualization differences self-correct.
|
|
176
161
|
restore();
|
|
177
162
|
setTimeout(() => {
|
|
178
163
|
restore();
|
|
@@ -183,9 +168,9 @@ function restoreScrollPosition(el) {
|
|
|
183
168
|
setTimeout(poll, SCROLL_POLL_INTERVAL_MS);
|
|
184
169
|
}
|
|
185
170
|
else {
|
|
186
|
-
// Best effort
|
|
187
|
-
//
|
|
188
|
-
//
|
|
171
|
+
// Best effort after `SCROLL_RESTORE_TIMEOUT_MS`. When the document
|
|
172
|
+
// never rendered past the target, leave the viewport where the
|
|
173
|
+
// renderer put it.
|
|
189
174
|
if (isRendered) {
|
|
190
175
|
restore();
|
|
191
176
|
}
|
|
@@ -220,41 +205,37 @@ async function loadAndApply() {
|
|
|
220
205
|
for (const [key, value] of Object.entries(config)) {
|
|
221
206
|
el[key] = value;
|
|
222
207
|
}
|
|
223
|
-
//
|
|
208
|
+
// Narrow the parsed JSON instead of trusting its shape.
|
|
224
209
|
const navigationType = config.navigationType === 'path' ? 'path' : 'hash';
|
|
225
|
-
//
|
|
226
|
-
//
|
|
227
|
-
// page is always served from `/`)...
|
|
210
|
+
// Builds the URL for a node path, the same way the component does (no
|
|
211
|
+
// `basePath`, because the preview page is always served from `/`)...
|
|
228
212
|
const toAddressBarUrl = (path) => navigationType === 'hash' ? `#${path}` : path;
|
|
229
|
-
// ...and `nodePathFromUrl` is
|
|
230
|
-
// back out of the URL after a reload.
|
|
231
|
-
//
|
|
232
|
-
//
|
|
233
|
-
// The URL wins over the `--path` flag: it is the user's latest location,
|
|
234
|
-
// and the flag is only the first load's starting point.
|
|
213
|
+
// ...and `nodePathFromUrl` is the inverse: it reads the user's last
|
|
214
|
+
// location back out of the URL after a reload.
|
|
215
|
+
// The URL holds the user's latest location. The `--path` flag only sets
|
|
216
|
+
// the first load's starting point.
|
|
235
217
|
const urlPath = nodePathFromUrl(navigationType, location);
|
|
236
218
|
const flagPath = typeof config.currentPath === 'string' ? config.currentPath : undefined;
|
|
237
219
|
const requestedPath = urlPath ?? flagPath;
|
|
238
220
|
const pathSource = urlPath === undefined ? 'flag' : 'url';
|
|
239
|
-
// `config`
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
|
|
221
|
+
// `config` carries `currentPath` only when `--path` was passed. A URL
|
|
222
|
+
// path must be set on the element itself before registration. This
|
|
223
|
+
// includes the overview: the config loop above already set the flag
|
|
224
|
+
// value, so a skipped assignment lets a stale `--path` outlive a click
|
|
225
|
+
// on "Overview".
|
|
226
|
+
if (urlPath !== undefined) {
|
|
244
227
|
el.currentPath = urlPath;
|
|
245
228
|
}
|
|
246
229
|
if (requestedPath && requestedPath !== '/') {
|
|
247
|
-
// The component only
|
|
248
|
-
//
|
|
249
|
-
//
|
|
250
|
-
// actually rendered. A URL-supplied path is already in the address bar.
|
|
230
|
+
// The component reflects only its own navigation into the address bar,
|
|
231
|
+
// not an initial `currentPath` prop. Reflect a flag path here. A URL
|
|
232
|
+
// path is already in the address bar.
|
|
251
233
|
if (pathSource === 'flag') {
|
|
252
234
|
history.replaceState({}, '', toAddressBarUrl(requestedPath));
|
|
253
235
|
}
|
|
254
|
-
// The path
|
|
255
|
-
// (`/operations/{operationId}`, `/schemas/{SchemaName}`), not the raw
|
|
256
|
-
// path
|
|
257
|
-
// loudly rather than silently rendering a blank document pane.
|
|
236
|
+
// The path must match the library's node URI scheme
|
|
237
|
+
// (`/operations/{operationId}`, `/schemas/{SchemaName}`), not the raw
|
|
238
|
+
// OAS path. Warn loudly. A wrong path otherwise renders a blank pane.
|
|
258
239
|
el.addEventListener('path-not-found', ((event) => {
|
|
259
240
|
const requested = String(event.detail?.[0] ?? requestedPath);
|
|
260
241
|
const source = pathSource === 'url'
|
|
@@ -263,13 +244,13 @@ async function loadAndApply() {
|
|
|
263
244
|
console.warn(`[kong-spec-renderer] ${source}` +
|
|
264
245
|
'Expected format: "/operations/{operationId}" or "/schemas/{SchemaName}" - check the spec\'s operationId/schema names, not its raw OAS paths. ' +
|
|
265
246
|
'Falling back to the overview.');
|
|
266
|
-
// The saved
|
|
267
|
-
//
|
|
247
|
+
// The saved offset belongs to the invalid section. Cancel its
|
|
248
|
+
// restore, so it cannot move the page during the fallback.
|
|
268
249
|
scrollRestoreCancelled = true;
|
|
269
250
|
history.replaceState({}, '', '/');
|
|
270
|
-
// `currentPath`
|
|
271
|
-
//
|
|
272
|
-
//
|
|
251
|
+
// The component reads `currentPath` only once, at setup. An invalid
|
|
252
|
+
// path cannot be fixed in place, so replace the element with a fresh
|
|
253
|
+
// one.
|
|
273
254
|
const fallback = document.createElement(el.tagName);
|
|
274
255
|
fallback.id = el.id;
|
|
275
256
|
fallback.spec = spec;
|
|
@@ -279,11 +260,9 @@ async function loadAndApply() {
|
|
|
279
260
|
el.replaceWith(fallback);
|
|
280
261
|
}));
|
|
281
262
|
}
|
|
282
|
-
// A matching saved
|
|
283
|
-
//
|
|
284
|
-
//
|
|
285
|
-
// renders so the settling isn't visible, and reveal it only once the
|
|
286
|
-
// offset is final (see restoreScrollPosition).
|
|
263
|
+
// A matching saved offset means this load settles mid-document. Hide the
|
|
264
|
+
// renderer before its content renders. Reveal it once the offset is final
|
|
265
|
+
// (see `restoreScrollPosition`).
|
|
287
266
|
if (readSavedScrollPosition()?.href === location.href) {
|
|
288
267
|
el.style.visibility = 'hidden';
|
|
289
268
|
}
|
|
@@ -296,16 +275,15 @@ async function loadAndApply() {
|
|
|
296
275
|
registerKongSpecRenderer();
|
|
297
276
|
}
|
|
298
277
|
catch (error) {
|
|
299
|
-
//
|
|
300
|
-
// bundle load must not leave a permanently blank page.
|
|
278
|
+
// A failed bundle load must not leave the hidden page blank forever.
|
|
301
279
|
el.style.visibility = '';
|
|
302
280
|
console.error(`[kong-spec-renderer] Failed to load the renderer bundle: ${error instanceof Error ? error.message : String(error)}`);
|
|
303
281
|
return;
|
|
304
282
|
}
|
|
305
283
|
restoreScrollPosition(el);
|
|
306
284
|
}
|
|
307
|
-
// The renderer renders asynchronously, so the browser's own scroll
|
|
308
|
-
//
|
|
285
|
+
// The renderer renders asynchronously, so the browser's own scroll
|
|
286
|
+
// restoration cannot work across reloads. Take it over manually.
|
|
309
287
|
history.scrollRestoration = 'manual';
|
|
310
288
|
window.addEventListener('pagehide', rememberScrollPosition);
|
|
311
289
|
void loadAndApply();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../cli/preview-page/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,kBAAkB,GAGnB,MAAM,oBAAoB,CAAA;AAO3B,MAAM,uBAAuB,GAAG,GAAG,CAAA;AACnC
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../cli/preview-page/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,kBAAkB,GAGnB,MAAM,oBAAoB,CAAA;AAO3B,MAAM,uBAAuB,GAAG,GAAG,CAAA;AACnC;;;;;GAKG;AACH,MAAM,wBAAwB,GAAG,GAAG,CAAA;AACpC;;;GAGG;AACH,MAAM,yBAAyB,GAAG,IAAI,CAAA;AAEtC;;;;;GAKG;AACH,IAAI,sBAAsB,GAAG,KAAK,CAAA;AAElC,SAAS,uBAAuB;IAC9B,IAAI,CAAC;QACH,OAAO,wBAAwB,CAAC,cAAc,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC,CAAA;IAC7E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,SAAS,iBAAiB;IACxB,MAAM,IAAI,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,UAAU,CAAA;IAE3D,IAAI,CAAC,IAAI,EAAE,CAAC;QACV,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAA;IACxB,IAAI,MAA+B,CAAA;IAEnC,KAAK,MAAM,EAAE,IAA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M,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAc,CAAqB,CAAA;QAEpE,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC9B,QAAQ,CAAC,MAAM,EAAE,CAAA;QACnB,CAAC;IACH,CAAC,CAAC,CAAA;IAEF,MAAM,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;QACpC,UAAU,CAAC,OAAO,EAAE,kBAAkB,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC;AAED,OAAO,EAAE,CAAA"}
|
|
@@ -13,10 +13,9 @@ function isSavedSection(value) {
|
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
15
|
* Parses the saved scroll position from its sessionStorage form. Returns
|
|
16
|
-
* `undefined` when the entry is absent, malformed, or
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* than invalidating the whole entry.
|
|
16
|
+
* `undefined` when the entry is absent, malformed, or not restorable (`y`
|
|
17
|
+
* must be past the top). A malformed `section` drops only the anchor. The
|
|
18
|
+
* entry then still restores by its raw `y`.
|
|
20
19
|
*/
|
|
21
20
|
export function parseSavedScrollPosition(raw) {
|
|
22
21
|
let saved;
|
|
@@ -47,13 +46,11 @@ export function safeDecode(value) {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
|
-
* Reads the node path back out of the URL,
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* live-reload and a manual refresh, so it holds the user's last location.
|
|
49
|
+
* Reads the node path back out of the URL, the inverse of the component's
|
|
50
|
+
* address-bar updates. The URL holds the user's last location, because it
|
|
51
|
+
* survives both live reload and a manual refresh.
|
|
54
52
|
*
|
|
55
|
-
* Returns `undefined` when the URL holds no node path
|
|
56
|
-
* mode, or the overview in path mode).
|
|
53
|
+
* Returns `undefined` when the URL holds no node path.
|
|
57
54
|
*/
|
|
58
55
|
export function nodePathFromUrl(navigationType, url) {
|
|
59
56
|
let raw;
|
|
@@ -67,8 +64,8 @@ export function nodePathFromUrl(navigationType, url) {
|
|
|
67
64
|
return undefined;
|
|
68
65
|
}
|
|
69
66
|
const path = safeDecode(raw);
|
|
70
|
-
// The component
|
|
71
|
-
//
|
|
67
|
+
// The component writes node URIs with a leading `/`. Accept one without
|
|
68
|
+
// (from a hand-edited URL) instead of failing to match.
|
|
72
69
|
return path.startsWith('/') ? path : `/${path}`;
|
|
73
70
|
}
|
|
74
71
|
//# sourceMappingURL=preview-state.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preview-state.js","sourceRoot":"","sources":["../../../cli/preview-page/preview-state.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,oCAAoC,CAAA;
|
|
1
|
+
{"version":3,"file":"preview-state.js","sourceRoot":"","sources":["../../../cli/preview-page/preview-state.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,oCAAoC,CAAA;AAsBtE,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,KAAgC,CAAA;IAElE,OAAO,OAAO,EAAE,KAAK,QAAQ;WACxB,OAAO,OAAO,KAAK,QAAQ;WAC3B,OAAO,QAAQ,KAAK,QAAQ;WAC5B,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC;WACzB,QAAQ,IAAI,CAAC,CAAA;AACpB,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB,CAAC,GAAkB;IACzD,IAAI,KAAc,CAAA;IAElB,IAAI,CAAC;QACH,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC,CAAA;IACjC,CAAC;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CAAC;QACtB,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,MAAM,IAAI,GAAG,UAAU,CAAC,GAAG,CAAC,CAAA;IAE5B,wEAAwE;IACxE,wDAAwD;IACxD,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAA;AACjD,CAAC"}
|
|
@@ -4,11 +4,10 @@
|
|
|
4
4
|
*
|
|
5
5
|
* `controlAddressBar` is always hardcoded true - the CLI, not the user, owns
|
|
6
6
|
* the single-page preview environment that prop governs. `navigationType`
|
|
7
|
-
* defaults to `'hash'
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `
|
|
11
|
-
* preview page is served statically. `showPoweredBy` defaults to `true` here
|
|
7
|
+
* defaults to `'hash'`, not the component's own `'path'` default. The
|
|
8
|
+
* server serves the preview page for unknown non-asset routes, so both modes
|
|
9
|
+
* refresh at a deep link. `hash` also works under static hosting.
|
|
10
|
+
* `showPoweredBy` defaults to `true` here
|
|
12
11
|
* even though the component prop itself defaults to `false` - the CLI wants
|
|
13
12
|
* branding visible unless a user opts out with `--hide-powered-by`.
|
|
14
13
|
* `hideNavigationButtons` defaults to `true` (hidden), matching the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-render-options.js","sourceRoot":"","sources":["../../cli/resolve-render-options.ts"],"names":[],"mappings":"AA0DA
|
|
1
|
+
{"version":3,"file":"resolve-render-options.js","sourceRoot":"","sources":["../../cli/resolve-render-options.ts"],"names":[],"mappings":"AA0DA;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,oBAAoB,CAAC,KAAsB;IACzD,OAAO;QACL,YAAY,EAAE,KAAK,CAAC,YAAY,IAAI,KAAK;QACzC,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,KAAK;QAC7C,WAAW,EAAE,KAAK,CAAC,WAAW,IAAI,KAAK;QACvC,SAAS,EAAE,KAAK,CAAC,SAAS,IAAI,KAAK;QACnC,iBAAiB,EAAE,KAAK,CAAC,iBAAiB,IAAI,KAAK;QACnD,GAAG,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC7F,YAAY,EAAE,CAAC,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,KAAK,CAAC;QACvE,eAAe,EAAE,KAAK,CAAC,eAAe,IAAI,KAAK;QAC/C,qBAAqB,EAAE,KAAK,CAAC,qBAAqB,IAAI,IAAI;QAC1D,oBAAoB,EAAE,KAAK,CAAC,eAAe,IAAI,IAAI;QACnD,qBAAqB,EAAE,CAAC,CAAC,KAAK,CAAC,qBAAqB,IAAI,KAAK,CAAC;QAC9D,kBAAkB,EAAE,KAAK,CAAC,kBAAkB,IAAI,KAAK;QACrD,oBAAoB,EAAE,KAAK,CAAC,oBAAoB,IAAI,KAAK;QACzD,aAAa,EAAE,CAAC,KAAK,CAAC,aAAa;QACnC,cAAc,EAAE,KAAK,CAAC,cAAc,IAAI,MAAM;QAC9C,iBAAiB,EAAE,IAAI;QACvB,GAAG,CAAC,KAAK,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC;KAC/E,CAAA;AACH,CAAC"}
|
package/dist/cli/server.js
CHANGED
|
@@ -16,12 +16,6 @@ const CONTENT_TYPES = {
|
|
|
16
16
|
'.wasm': 'application/wasm',
|
|
17
17
|
'.json': 'application/json',
|
|
18
18
|
};
|
|
19
|
-
/**
|
|
20
|
-
* The preview page's modules, compiled into `preview-page/` alongside each
|
|
21
|
-
* other - the browser resolves client.js's relative imports against its own
|
|
22
|
-
* top-level path, so each module is served at `/<file>`.
|
|
23
|
-
*/
|
|
24
|
-
const CLIENT_MODULE_FILES = ['client.js', 'preview-state.js'];
|
|
25
19
|
/**
|
|
26
20
|
* Resolves an `/assets/*` request path against `distDir`, returning
|
|
27
21
|
* `undefined` if the path would escape it.
|
|
@@ -122,8 +116,17 @@ async function handleRequest(url, options, distDir, previewPageDir) {
|
|
|
122
116
|
const body = await readFile(join(previewPageDir, 'index.html'), 'utf-8');
|
|
123
117
|
return { status: 200, body, contentType: 'text/html; charset=utf-8' };
|
|
124
118
|
}
|
|
125
|
-
|
|
126
|
-
|
|
119
|
+
// The compiled client modules, served through literal branches: the
|
|
120
|
+
// request URL is only compared, never used as a path. Aikido taints every
|
|
121
|
+
// `readFile` in a function that holds the request URL, so these reads
|
|
122
|
+
// carry a `// nosec` false-positive suppression. Do not make these paths
|
|
123
|
+
// request-derived. The suppression will hide a real vulnerability then.
|
|
124
|
+
if (url === '/client.js') {
|
|
125
|
+
const body = await readFile(join(previewPageDir, 'client.js')); // nosec
|
|
126
|
+
return { status: 200, body, contentType: 'text/javascript' };
|
|
127
|
+
}
|
|
128
|
+
if (url === '/preview-state.js') {
|
|
129
|
+
const body = await readFile(join(previewPageDir, 'preview-state.js')); // nosec
|
|
127
130
|
return { status: 200, body, contentType: 'text/javascript' };
|
|
128
131
|
}
|
|
129
132
|
if (url?.startsWith('/assets/')) {
|
|
@@ -137,15 +140,18 @@ async function handleRequest(url, options, distDir, previewPageDir) {
|
|
|
137
140
|
// Fall through to 404 below - e.g. the file doesn't exist.
|
|
138
141
|
}
|
|
139
142
|
}
|
|
140
|
-
// A missing asset
|
|
141
|
-
//
|
|
142
|
-
|
|
143
|
+
// A missing asset must stay a 404. The fallback below serves HTML as
|
|
144
|
+
// JavaScript and hides the failure.
|
|
145
|
+
return { status: 404, body: 'Not found', contentType: 'text/plain' };
|
|
146
|
+
}
|
|
147
|
+
// The browser requests /favicon.ico on every load. It is not a document,
|
|
148
|
+
// so answer 404. The fallback would serve HTML that fails to decode as
|
|
149
|
+
// an image.
|
|
150
|
+
if (url === '/favicon.ico') {
|
|
143
151
|
return { status: 404, body: 'Not found', contentType: 'text/plain' };
|
|
144
152
|
}
|
|
145
|
-
//
|
|
146
|
-
//
|
|
147
|
-
// `--navigation-type path`) reaches the page - the client reads the path
|
|
148
|
-
// back out of the URL.
|
|
153
|
+
// Any remaining route serves the single preview page. The client reads
|
|
154
|
+
// the node path back out of the URL, so deep links survive a refresh.
|
|
149
155
|
const body = await readFile(join(previewPageDir, 'index.html'), 'utf-8');
|
|
150
156
|
return { status: 200, body, contentType: 'text/html; charset=utf-8' };
|
|
151
157
|
}
|
package/dist/cli/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../cli/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAA6B,MAAM,WAAW,CAAA;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAA;AAExC,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAA;AAGpC,MAAM,UAAU,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;AAC1D,uFAAuF;AACvF,mEAAmE;AACnE,MAAM,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAC5C,MAAM,wBAAwB,GAAG,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAA;AAEjE,MAAM,aAAa,GAA2B;IAC5C,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,iBAAiB;IACzB,MAAM,EAAE,UAAU;IAClB,MAAM,EAAE,kBAAkB;IAC1B,OAAO,EAAE,kBAAkB;IAC3B,OAAO,EAAE,kBAAkB;CAC5B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AA;YAC5G,CAAC;YAAC,MAAM,CAAC;gBACP,2DAA2D;YAC7D,CAAC;QACH,CAAC;QAED,qEAAqE;QACrE,oCAAoC;QACpC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA;IACtE,CAAC;IAED,yEAAyE;IACzE,uEAAuE;IACvE,YAAY;IACZ,IAAI,GAAG,KAAK,cAAc,EAAE,CAAC;QAC3B,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,CAAA;IACtE,CAAC;IAED,uEAAuE;IACvE,sEAAsE;IACtE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,cAAc,EAAE,YAAY,CAAC,EAAE,OAAO,CAAC,CAAA;IAExE,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAA;AACvE,CAAC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kong/spec-renderer",
|
|
3
|
-
"version": "1.117.5
|
|
3
|
+
"version": "1.117.5",
|
|
4
4
|
"description": "Kong's open-source spec renderer",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
@@ -32,6 +32,30 @@
|
|
|
32
32
|
"publishConfig": {
|
|
33
33
|
"access": "public"
|
|
34
34
|
},
|
|
35
|
+
"scripts": {
|
|
36
|
+
"dev": "cross-env USE_SANDBOX=true vite",
|
|
37
|
+
"build": "pnpm run typecheck && pnpm run build:package && pnpm run build:webcomponent && pnpm run build:types && pnpm run build:aliases && pnpm run build:cli",
|
|
38
|
+
"build:package": "vite build -m production",
|
|
39
|
+
"build:webcomponent": "cross-env VITE_AS_WEB_COMPONENT='true' vite build -m production",
|
|
40
|
+
"build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
|
|
41
|
+
"build:aliases": "tsc-alias -p './tsconfig.build.json'",
|
|
42
|
+
"build:cli": "tsc -p './tsconfig.cli.build.json' && node ./scripts/build-cli-assets.js && node ./scripts/generate-kongctl-manifest.mjs",
|
|
43
|
+
"generate:kongctl-manifest": "pnpm run build:cli",
|
|
44
|
+
"build:analyzer": "BUILD_VISUALIZER='true' vite build -m production",
|
|
45
|
+
"build:sandbox": "cross-env USE_SANDBOX=true vite build -m production",
|
|
46
|
+
"preview": "pnpm run build:sandbox && cross-env USE_SANDBOX=true vite preview",
|
|
47
|
+
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit && pnpm run typecheck:cli && pnpm run typecheck:scripts",
|
|
48
|
+
"typecheck:cli": "tsc -p './tsconfig.cli.json' --noEmit",
|
|
49
|
+
"typecheck:scripts": "tsc -p './tsconfig.scripts.json' --noEmit",
|
|
50
|
+
"stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,vue}'",
|
|
51
|
+
"stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,vue}' --fix",
|
|
52
|
+
"lint": "eslint",
|
|
53
|
+
"lint:fix": "eslint --fix",
|
|
54
|
+
"test": "cross-env FORCE_COLOR=1 vitest run",
|
|
55
|
+
"test:open": "cross-env FORCE_COLOR=1 vitest --ui",
|
|
56
|
+
"semantic-release": "semantic-release",
|
|
57
|
+
"commit": "cz"
|
|
58
|
+
},
|
|
35
59
|
"peerDependencies": {
|
|
36
60
|
"vue": ">= 3.3.13 < 4"
|
|
37
61
|
},
|
|
@@ -202,28 +226,5 @@
|
|
|
202
226
|
"jiraAppend": "]"
|
|
203
227
|
}
|
|
204
228
|
},
|
|
205
|
-
"
|
|
206
|
-
|
|
207
|
-
"build": "pnpm run typecheck && pnpm run build:package && pnpm run build:webcomponent && pnpm run build:types && pnpm run build:aliases && pnpm run build:cli",
|
|
208
|
-
"build:package": "vite build -m production",
|
|
209
|
-
"build:webcomponent": "cross-env VITE_AS_WEB_COMPONENT='true' vite build -m production",
|
|
210
|
-
"build:types": "vue-tsc -p './tsconfig.build.json' --emitDeclarationOnly",
|
|
211
|
-
"build:aliases": "tsc-alias -p './tsconfig.build.json'",
|
|
212
|
-
"build:cli": "tsc -p './tsconfig.cli.build.json' && node ./scripts/build-cli-assets.js && node ./scripts/generate-kongctl-manifest.mjs",
|
|
213
|
-
"generate:kongctl-manifest": "pnpm run build:cli",
|
|
214
|
-
"build:analyzer": "BUILD_VISUALIZER='true' vite build -m production",
|
|
215
|
-
"build:sandbox": "cross-env USE_SANDBOX=true vite build -m production",
|
|
216
|
-
"preview": "pnpm run build:sandbox && cross-env USE_SANDBOX=true vite preview",
|
|
217
|
-
"typecheck": "vue-tsc -p './tsconfig.build.json' --noEmit && pnpm run typecheck:cli && pnpm run typecheck:scripts",
|
|
218
|
-
"typecheck:cli": "tsc -p './tsconfig.cli.json' --noEmit",
|
|
219
|
-
"typecheck:scripts": "tsc -p './tsconfig.scripts.json' --noEmit",
|
|
220
|
-
"stylelint": "stylelint --allow-empty-input './src/**/*.{css,scss,vue}'",
|
|
221
|
-
"stylelint:fix": "stylelint --allow-empty-input './src/**/*.{css,scss,sass,vue}' --fix",
|
|
222
|
-
"lint": "eslint",
|
|
223
|
-
"lint:fix": "eslint --fix",
|
|
224
|
-
"test": "cross-env FORCE_COLOR=1 vitest run",
|
|
225
|
-
"test:open": "cross-env FORCE_COLOR=1 vitest --ui",
|
|
226
|
-
"semantic-release": "semantic-release",
|
|
227
|
-
"commit": "cz"
|
|
228
|
-
}
|
|
229
|
-
}
|
|
229
|
+
"packageManager": "pnpm@12.12.0"
|
|
230
|
+
}
|