@whzxc/agent-design-gallery 0.15.0 → 0.16.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/README.md +5 -2
- package/package.json +2 -1
- package/public/app.js +602 -64
- package/public/assets.js +25 -10
- package/public/boards.js +8 -3
- package/public/frame-identity.js +25 -12
- package/public/icons.js +7 -0
- package/public/index.html +14 -2
- package/public/motion-flow.js +28 -0
- package/public/motion-identity.js +100 -0
- package/public/motion-paint.js +332 -0
- package/public/motion-scene.js +165 -0
- package/public/motion-specimens.js +335 -0
- package/public/player.css +270 -0
- package/public/player.js +753 -0
- package/public/recent-updates.js +535 -0
- package/public/style.css +17 -2
- package/public/tokens.css +6 -0
- package/public/view-boards.css +131 -0
- package/public/view-boards.js +350 -0
- package/public/view-route.js +1 -1
- package/src/boards/motion-board.mjs +202 -0
- package/src/boards/token-board.mjs +9 -5
- package/src/cli-output.mjs +3 -1
- package/src/cli.mjs +52 -18
- package/src/http.mjs +5 -2
- package/src/recent-frames.mjs +295 -0
- package/src/recent-history.mjs +100 -0
- package/src/recent-job.mjs +63 -0
- package/src/recent-worker.mjs +171 -0
- package/src/server.mjs +229 -18
- package/src/toolkit/arch-git.mjs +8 -14
- package/src/toolkit/browser.mjs +1 -13
- package/src/toolkit/build-store.mjs +9 -1
- package/src/toolkit/build-worker.mjs +6 -0
- package/src/toolkit/build.mjs +22 -16
- package/src/toolkit/commands.mjs +93 -2
- package/src/toolkit/compare.mjs +13 -11
- package/src/toolkit/config.mjs +2 -2
- package/src/toolkit/diff-inputs.mjs +35 -26
- package/src/toolkit/diff.mjs +24 -11
- package/src/toolkit/frame-declarations.mjs +36 -0
- package/src/toolkit/git-blobs.mjs +50 -0
- package/src/toolkit/impact-inputs.mjs +11 -19
- package/src/toolkit/impact-selection.mjs +2 -2
- package/src/toolkit/impact.mjs +17 -3
- package/src/toolkit/implementation-map.mjs +17 -6
- package/src/toolkit/input-generation.mjs +15 -0
- package/src/toolkit/inspect-output.mjs +1 -1
- package/src/toolkit/inspect.d.ts +9 -1
- package/src/toolkit/inspect.mjs +25 -1
- package/src/toolkit/motion-check.mjs +382 -0
- package/src/toolkit/motion-css.mjs +105 -0
- package/src/toolkit/motion-flows.mjs +95 -0
- package/src/toolkit/motion-impact.mjs +87 -0
- package/src/toolkit/motion-inventory.mjs +202 -0
- package/src/toolkit/motion-label.mjs +111 -0
- package/src/toolkit/motion-patterns.mjs +216 -0
- package/src/toolkit/motion-primitives.mjs +94 -0
- package/src/toolkit/motion-queries.mjs +169 -0
- package/src/toolkit/motion.mjs +300 -0
- package/src/toolkit/owner.mjs +19 -6
- package/src/toolkit/play-endpoint.mjs +66 -0
- package/src/toolkit/project-index.mjs +2 -2
- package/src/toolkit/recent-structure.mjs +201 -0
- package/src/toolkit/results.mjs +2 -2
- package/src/toolkit/review-document.mjs +9 -4
- package/src/toolkit/review-embed-document.mjs +671 -0
- package/src/toolkit/review-filmstrip.mjs +76 -0
- package/src/toolkit/review-motion-card.mjs +51 -0
- package/src/toolkit/review-motion.mjs +159 -0
- package/src/toolkit/review-playback.js +123 -0
- package/src/toolkit/review-sheet.mjs +36 -28
- package/src/toolkit/review.mjs +131 -31
- package/src/toolkit/runtime.mjs +7 -1
- package/src/viewer-cache.mjs +48 -12
package/public/app.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
import { recordVisit, createHistoryFilter } from './recent-updates.js';
|
|
1
2
|
import { createContextMenu } from './context-menu.js';
|
|
2
3
|
import { createComments } from './comments.js';
|
|
3
4
|
import { attachComment, commentElement, commentLabel, placeComment } from './comment-anchors.js';
|
|
4
5
|
import { initSwitcher, updateSwitcherLabels } from './switcher.js';
|
|
5
6
|
import { dataFetch, keyURL, isUnauthorized } from './auth.js';
|
|
6
|
-
import { fitArea, fitView } from "./layout.js";
|
|
7
|
+
import { blockForAsset, fitArea, fitView, specimenPaintCrop } from "./layout.js";
|
|
7
8
|
import { icon, hydrateIcons } from "./icons.js";
|
|
8
9
|
hydrateIcons();
|
|
9
|
-
import { prepare, imageURL, arrange, groupAssets, evictPreviews, metadataContext, measuredMetadata, previewAddress, compactPreparedSource, scopeKind, scopeTarget } from "./assets.js";
|
|
10
|
+
import { fetchSource, prepare, imageURL, arrange, groupAssets, evictPreviews, metadataContext, measuredMetadata, previewAddress, compactPreparedSource, scopeKind, scopeTarget } from "./assets.js";
|
|
10
11
|
import { sourceRelationships, relatedSources } from './relationships.js';
|
|
11
12
|
import { contains, hitSelection, frameBox, exportFrames } from './selection.js';
|
|
12
13
|
import { groupTokens, renderTokenTable, tokenBoardSection } from './token-catalog.js';
|
|
13
14
|
import { readViewRoute, viewURL } from './view-route.js';
|
|
14
15
|
import { createBoardLayer } from './boards.js';
|
|
16
|
+
import { installMotionSpecimens } from './motion-specimens.js';
|
|
17
|
+
import { boardElement, createFrameCards, frameKey, placePlayButton, playButton, prototypeFlows, renderPrototype } from './view-boards.js';
|
|
15
18
|
import { createArranger } from './arrangement.js';
|
|
16
19
|
const arranger = createArranger();
|
|
17
20
|
window.addEventListener('pagehide',()=>arranger.close());
|
|
@@ -48,18 +51,21 @@ const boardLayer = createBoardLayer(viewport, (path, title, button) => {
|
|
|
48
51
|
if (item && part) selectFrame(item, part);
|
|
49
52
|
else if (item) selectSource(item);
|
|
50
53
|
},
|
|
51
|
-
onFocusFrame
|
|
52
|
-
const item = assets.find(a => a.path === source && (a.component || a.shown[0]?.name === frameName));
|
|
53
|
-
const part = item?.parts.find(p => p.name === frameName);
|
|
54
|
-
if (item && part) inspectForm(item, part);
|
|
55
|
-
},
|
|
54
|
+
onFocusFrame: locateFrame,
|
|
56
55
|
onCopyError(failure) {
|
|
57
56
|
if (failure) error(`Cannot copy token name: ${failure.message}`);
|
|
58
57
|
else if ($('#error').textContent.startsWith('Cannot copy token name:')) error('');
|
|
59
58
|
},
|
|
60
59
|
});
|
|
60
|
+
installMotionSpecimens($('#board-chrome'));
|
|
61
|
+
function locateFrame(source, frameName) {
|
|
62
|
+
const item = assets.find(a => a.path === source && (a.component || a.shown[0]?.name === frameName));
|
|
63
|
+
const part = item?.parts.find(p => p.name === frameName);
|
|
64
|
+
if (item && part) inspectForm(item, part);
|
|
65
|
+
}
|
|
61
66
|
let manifest,
|
|
62
67
|
catalog = null,
|
|
68
|
+
derivedLanding = false,
|
|
63
69
|
tokenManifest = null,
|
|
64
70
|
tokenCategory = null,
|
|
65
71
|
tokenList = false,
|
|
@@ -110,10 +116,20 @@ function cacheWrite(url,data,raw=false) {
|
|
|
110
116
|
uploadPromises.add(promise);promise.finally(()=>uploadPromises.delete(promise));
|
|
111
117
|
pumpUploads();return promise;
|
|
112
118
|
}
|
|
119
|
+
async function uploadCache(task) {
|
|
120
|
+
const headers = {'Content-Type':task.raw ? 'image/svg+xml' : 'application/json'};
|
|
121
|
+
let body = task.raw ? task.data : JSON.stringify(task.data);
|
|
122
|
+
if (body.length >= 16384 && typeof CompressionStream === 'function') {
|
|
123
|
+
const compressed = new Blob([body]).stream().pipeThrough(new CompressionStream('gzip'));
|
|
124
|
+
body = await new Response(compressed).arrayBuffer();
|
|
125
|
+
headers['Content-Encoding'] = 'gzip';
|
|
126
|
+
}
|
|
127
|
+
return dataFetch(task.url, {method:'POST',headers,body});
|
|
128
|
+
}
|
|
113
129
|
function pumpUploads() {
|
|
114
130
|
while(uploadActive<3&&uploadQueue.length) {
|
|
115
131
|
const task=uploadQueue.shift();uploadActive++;
|
|
116
|
-
|
|
132
|
+
uploadCache(task)
|
|
117
133
|
.then(response=>{if(response.status===409)return false;if(!response.ok)throw Error(`Derived cache HTTP ${response.status}`);return true})
|
|
118
134
|
.catch(()=>{cacheFailures++;return false})
|
|
119
135
|
.then(result=>{uploadActive--;cacheWrites--;task.resolve(result);pumpUploads()});
|
|
@@ -143,6 +159,14 @@ function decorateMetadata(asset,metadata) {
|
|
|
143
159
|
}
|
|
144
160
|
return entry;
|
|
145
161
|
}
|
|
162
|
+
async function readSourceMetadata(asset, theme, signal) {
|
|
163
|
+
if (!asset.hash || !asset.metadataRefs?.[theme]) return;
|
|
164
|
+
const query = new URLSearchParams({ theme, context: metadataContext() });
|
|
165
|
+
const response = await dataFetch(`metadata/${asset.hash}?${query}`, { signal });
|
|
166
|
+
if (!response.ok) return;
|
|
167
|
+
const { metadata, previewIds } = await response.json();
|
|
168
|
+
return decorateMetadata({ ...asset, previewIds: { ...asset.previewIds, [theme]: previewIds } }, metadata);
|
|
169
|
+
}
|
|
146
170
|
function persistSource(entry,theme) {
|
|
147
171
|
if(!entry.hash || entry.onlyFrame)return Promise.resolve(false);
|
|
148
172
|
const query=new URLSearchParams({theme,context:metadataContext()});
|
|
@@ -238,6 +262,7 @@ function back() {
|
|
|
238
262
|
function changeScope(next, entry = null, record = true) {
|
|
239
263
|
const nextFrame = entry?.onlyFrame ?? null;
|
|
240
264
|
if (next === scopeRequest && nextFrame === onlyFrame) return;
|
|
265
|
+
if (frameFilter !== 'all') setFrameFilter('all', false, false);
|
|
241
266
|
const wasOverlay = scopeRequest === 'tokens' || !!tokenManifest;
|
|
242
267
|
const nextOverlay = next === 'tokens';
|
|
243
268
|
const preserveSearch = !fixtureState && !wasOverlay && !nextOverlay && ['all', 'layer'].includes(scopeKind(next)) && !!$("#search").value.trim();
|
|
@@ -283,6 +308,11 @@ function updateChrome() {
|
|
|
283
308
|
updateSwitcherLabels();
|
|
284
309
|
const data = tokenManifest ?? catalog ?? manifest;
|
|
285
310
|
const opened = !!data?.directory;
|
|
311
|
+
$('#app-bar').hidden = !opened;
|
|
312
|
+
$('#frame-filter').hidden=!!tokenManifest || !opened;
|
|
313
|
+
const derived = !tokenManifest && frameFilter !== 'all';
|
|
314
|
+
$('#view-board').hidden = !opened || !derived;
|
|
315
|
+
$('.gallery').classList.toggle('derived-mode', derived);
|
|
286
316
|
const showTokens = !!tokenManifest && tokenList;
|
|
287
317
|
$('#token-list-toggle').hidden = !tokenManifest;
|
|
288
318
|
$('#token-list-toggle').disabled = !tokenManifest?.tokenBoard;
|
|
@@ -309,13 +339,18 @@ function updateChrome() {
|
|
|
309
339
|
isolation.dataset.tooltip = 'Show full layer';
|
|
310
340
|
}
|
|
311
341
|
}
|
|
312
|
-
const canInspect = opened && !showTokens && !!selected;
|
|
342
|
+
const canInspect = opened && !showTokens && !derived && !!selected;
|
|
313
343
|
$('.gallery').classList.toggle('tokens-mode', showTokens);
|
|
314
344
|
$('#token-catalog').hidden = !showTokens;
|
|
315
|
-
viewport.inert = showTokens;
|
|
316
|
-
|
|
345
|
+
viewport.inert = showTokens || derived;
|
|
346
|
+
viewport.setAttribute('aria-hidden', String(derived));
|
|
347
|
+
$('#sidebar').hidden = !opened || !sidebar || derived;
|
|
348
|
+
$('#sidebar-toggle').hidden = derived;
|
|
349
|
+
$('.search-field').hidden = derived;
|
|
350
|
+
$('.search-divider').hidden = derived;
|
|
351
|
+
$('#scope-isolation').hidden ||= derived;
|
|
317
352
|
const allArch = assets.length > 0 && assets.every(a => a.path.endsWith('.mmd'));
|
|
318
|
-
const canComment = opened && !tokenManifest && scopeRequest !== 'layer:arch' && !allArch;
|
|
353
|
+
const canComment = opened && !tokenManifest && !derived && scopeRequest !== 'layer:arch' && !allArch;
|
|
319
354
|
const unavailableReason = canComment ? ''
|
|
320
355
|
: tokenManifest ? 'Tokens take no comments.'
|
|
321
356
|
: scopeRequest === 'layer:arch' || assets.some(a => a.path.endsWith('.mmd')) ? 'Architecture diagrams take no comments.'
|
|
@@ -324,20 +359,26 @@ function updateChrome() {
|
|
|
324
359
|
$('#comment-tool').disabled = !canComment;
|
|
325
360
|
$('#comment-tool').dataset.tooltip = canComment || !unavailableReason ? 'Comment (C)' : unavailableReason;
|
|
326
361
|
commentUI?.setAvailable?.(canComment, unavailableReason);
|
|
327
|
-
$('#app-bar').hidden = !opened;
|
|
328
362
|
if (fixtureState) $('#app-directory .switcher-chevron').hidden = false;
|
|
329
363
|
$('#tools').hidden = !opened;
|
|
330
|
-
$('
|
|
364
|
+
$('#comments-toggle').hidden = derived;
|
|
365
|
+
$('#inspect').hidden = derived;
|
|
366
|
+
$('.zoom').hidden = !opened || showTokens || derived;
|
|
331
367
|
$('#source').hidden = !canInspect || !inspector;
|
|
332
368
|
$('#inspect').disabled = !canInspect;
|
|
333
369
|
$('#inspect').setAttribute('aria-expanded', String(canInspect && inspector));
|
|
334
|
-
$('#arrange').hidden = !!tokenManifest;
|
|
370
|
+
$('#arrange').hidden = !!tokenManifest || derived;
|
|
335
371
|
$('#zoom-fit-group').disabled = !!tokenManifest || active === null || !groups[active];
|
|
336
372
|
$('#zoom-fit-selection').disabled = !!tokenManifest || !selected;
|
|
337
373
|
if (!opened) $('#minimap').hidden = true;
|
|
338
|
-
$('#sidebar-toggle').setAttribute('aria-expanded', String(
|
|
374
|
+
$('#sidebar-toggle').setAttribute('aria-expanded', String(!$('#sidebar').hidden));
|
|
375
|
+
if (derived) positionViewBoard();
|
|
339
376
|
positionZoomMenu();
|
|
340
377
|
}
|
|
378
|
+
function positionViewBoard() {
|
|
379
|
+
$('.gallery').style.setProperty('--view-board-top', ($('#app-bar').getBoundingClientRect().bottom + 10) + 'px');
|
|
380
|
+
}
|
|
381
|
+
new ResizeObserver(() => { if (!$('#view-board').hidden) positionViewBoard(); }).observe($('#app-bar'));
|
|
341
382
|
function positionZoomMenu() {
|
|
342
383
|
const r = $("#zoom-options").getBoundingClientRect();
|
|
343
384
|
$("#zoom-menu").style.left = `${r.x + r.width / 2}px`;
|
|
@@ -348,7 +389,7 @@ const media = matchMedia("(prefers-color-scheme: dark)");
|
|
|
348
389
|
const modifiedDate = new Intl.DateTimeFormat('en-US', {month:'short',day:'numeric',hour:'2-digit',minute:'2-digit',hourCycle:'h23'});
|
|
349
390
|
window.__adg = {
|
|
350
391
|
ready: false,
|
|
351
|
-
get metadataComplete() {return !!tokenManifest || (!!manifest && !manifest.loading);},
|
|
392
|
+
get metadataComplete() {return !!tokenManifest || (!!manifest && !manifest.loading && !derivedLanding);},
|
|
352
393
|
get scope() {return tokenManifest?.scope ?? initializedScope;},
|
|
353
394
|
get cachePending() {return cacheWrites+loading+queued.length;},
|
|
354
395
|
get cacheFlush() {return flushCache();},
|
|
@@ -465,10 +506,16 @@ document.addEventListener('visibilitychange', () => {if (document.hidden) void p
|
|
|
465
506
|
const layoutData = data => onlyFrame ? { ...data, assets: data.assets.map(asset => ({ ...asset, sourceComponent: !!asset.component, component: false, parts: asset.parts.filter(part => part.name === onlyFrame) })) } : data;
|
|
466
507
|
function layout(data, preserve = false, options = {}) {
|
|
467
508
|
const endArrangement = globalThis.__adgTiming?.span('arrangement', undefined, {sources:data.assets.length,provisional:!!options.provisional});
|
|
509
|
+
const activeKey = groups[active]?.key;
|
|
468
510
|
const previousGroups = groups,
|
|
469
511
|
result = arrange(layoutData(data),{...options, previousGroups: preserve ? previousGroups : undefined});
|
|
470
512
|
groups = result.groups;
|
|
513
|
+
if (activeKey) {
|
|
514
|
+
const index = groups.findIndex(group => group.key === activeKey);
|
|
515
|
+
active = index < 0 ? null : index;
|
|
516
|
+
}
|
|
471
517
|
assets = result.items;
|
|
518
|
+
hoveredPlay = null;
|
|
472
519
|
world = result.world;
|
|
473
520
|
if (data.scope === 'all' && data.tokenBoard && tokenHeight) {
|
|
474
521
|
const offset = tokenHeight + 480;
|
|
@@ -480,7 +527,9 @@ function layout(data, preserve = false, options = {}) {
|
|
|
480
527
|
world.height += offset;
|
|
481
528
|
world.width = Math.max(world.width, 1680);
|
|
482
529
|
}
|
|
530
|
+
if(motionProjection!==data.motionFrames)setMotionProjection(data.motionFrames);
|
|
483
531
|
boardLayer.update(groups, assets, data);
|
|
532
|
+
if (frameFilter !== 'all') renderFrameView();
|
|
484
533
|
boardLayer.tokens(data.scope === 'all' ? data.tokenBoard : null, h => {
|
|
485
534
|
if (Math.abs(tokenHeight-h)>1) {
|
|
486
535
|
const firstMeasurement = !tokenHeight;
|
|
@@ -633,7 +682,7 @@ function renderNav() {
|
|
|
633
682
|
} else {
|
|
634
683
|
const slug = tokenBoardSection(category);
|
|
635
684
|
const box = slug && boardLayer.tokenSection(slug);
|
|
636
|
-
if (box) commit(fitView(box, fitArea(width, height, sidebar, false), 24));
|
|
685
|
+
if (box) commit(fitView(slug === 'motion' ? { ...box, height: Math.min(box.height, 650) } : box, fitArea(width, height, sidebar, false), 24));
|
|
637
686
|
else setTokenList(true);
|
|
638
687
|
}
|
|
639
688
|
}
|
|
@@ -645,6 +694,8 @@ function renderNav() {
|
|
|
645
694
|
addCategory('All tokens', 'layout-grid', data.tokenGroups.reduce((total, group) => total + group.rows.length, 0), null);
|
|
646
695
|
const rule = document.createElement('div'); rule.className = 'rule'; nodes.push(rule);
|
|
647
696
|
for (const {label, glyph, rows} of data.tokenGroups) addCategory(label, glyph, rows.length, label);
|
|
697
|
+
if (!tokenList && data.motionPatternCount && !data.tokenGroups.some(group => group.label === 'Motion'))
|
|
698
|
+
addCategory('Motion', 'timer', data.motionPatternCount, 'Motion');
|
|
648
699
|
renderTokenTable($('#token-catalog'), data, tokenCategory, query, copyError => {
|
|
649
700
|
if (copyError) error(`Cannot copy token name: ${copyError.message}`);
|
|
650
701
|
else if ($('#error').textContent.startsWith('Cannot copy token name:')) error('');
|
|
@@ -743,6 +794,297 @@ function renderRelationships(source) {
|
|
|
743
794
|
$('#'+id).replaceChildren(...nodes);
|
|
744
795
|
}
|
|
745
796
|
}
|
|
797
|
+
const playableFrames = new Map();
|
|
798
|
+
let motionProjection;
|
|
799
|
+
const frameViews = { recent: 'Recently updated', playable: 'Playable' };
|
|
800
|
+
const frameViewParams = new URLSearchParams(location.search);
|
|
801
|
+
const requestedFrameView = frameViewParams.get('view');
|
|
802
|
+
let pendingFlow = requestedFrameView === 'playable' ? frameViewParams.get('flow') : null;
|
|
803
|
+
let frameFilter = Object.hasOwn(frameViews, requestedFrameView) && scopeRequest !== 'tokens' ? requestedFrameView : 'all';
|
|
804
|
+
let viewGeneration = 0, historyContext, lastIndexedAssets, references, sourcePaths;
|
|
805
|
+
const derivedBoard = $('#view-board'), viewContent = $('#view-board-content');
|
|
806
|
+
const cards = createFrameCards(derivedBoard, {
|
|
807
|
+
preview: drawCardPreview,
|
|
808
|
+
show(source, frame) {
|
|
809
|
+
setFrameFilter('all', false);
|
|
810
|
+
navigate(() => {
|
|
811
|
+
locateFrame(source, frame);
|
|
812
|
+
viewport.focus({ preventScroll: true });
|
|
813
|
+
});
|
|
814
|
+
},
|
|
815
|
+
play: startFramePlayer,
|
|
816
|
+
playable: (source, frame) => playableFrames.get(source)?.has(frame),
|
|
817
|
+
});
|
|
818
|
+
const recentFilter = createHistoryFilter(() => { if (frameFilter === 'recent') renderFrameView(); });
|
|
819
|
+
function openRecentHistory(data) {
|
|
820
|
+
if (!data?.directory) return false;
|
|
821
|
+
const identity = JSON.stringify([data.directory, data.scope, onlyFrame]);
|
|
822
|
+
if (identity === historyContext) return false;
|
|
823
|
+
historyContext = identity;
|
|
824
|
+
void recentFilter.open(data.directory, data.scope, onlyFrame);
|
|
825
|
+
return true;
|
|
826
|
+
}
|
|
827
|
+
window.addEventListener('pagehide', () => recentFilter.close());
|
|
828
|
+
let playerInvoker, deferredView;
|
|
829
|
+
async function startFramePlayer(source, frame, invoker) {
|
|
830
|
+
if (playerInvoker) return;
|
|
831
|
+
playerInvoker = invoker;
|
|
832
|
+
updateFramePlay();
|
|
833
|
+
try {
|
|
834
|
+
const { openPlayer } = await import('./player.js');
|
|
835
|
+
const opening = openPlayer({ source, frame, theme: effectiveTheme, invoker });
|
|
836
|
+
const dialog = $('#motion-player');
|
|
837
|
+
if (dialog) {
|
|
838
|
+
dialog.addEventListener('close', () => {
|
|
839
|
+
playerInvoker = null;
|
|
840
|
+
if (deferredView) renderFrameView();
|
|
841
|
+
updateFramePlay();
|
|
842
|
+
}, { once: true });
|
|
843
|
+
}
|
|
844
|
+
await opening;
|
|
845
|
+
} catch (failure) {
|
|
846
|
+
error(failure.message);
|
|
847
|
+
} finally {
|
|
848
|
+
if (!$('#motion-player')) {
|
|
849
|
+
playerInvoker = null;
|
|
850
|
+
updateFramePlay();
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
function frameReferences() {
|
|
856
|
+
const inventory = derivedLanding ? catalog.assets : assets;
|
|
857
|
+
if (inventory !== lastIndexedAssets) {
|
|
858
|
+
lastIndexedAssets = inventory;
|
|
859
|
+
references = new Map();
|
|
860
|
+
sourcePaths = new Set();
|
|
861
|
+
if (derivedLanding) {
|
|
862
|
+
const byPath = new Map(inventory.map(asset => [asset.path, asset]));
|
|
863
|
+
sourcePaths = new Set(byPath.keys());
|
|
864
|
+
const get = key => {
|
|
865
|
+
const [source, name] = JSON.parse(key);
|
|
866
|
+
const asset = byPath.get(source);
|
|
867
|
+
if (!asset || (onlyFrame && name !== onlyFrame)) return;
|
|
868
|
+
return { asset, part: { name } };
|
|
869
|
+
};
|
|
870
|
+
references = { get, has: key => !!get(key) };
|
|
871
|
+
} else {
|
|
872
|
+
for (const asset of assets) {
|
|
873
|
+
sourcePaths.add(asset.path);
|
|
874
|
+
for (const part of asset.shown ?? []) references.set(frameKey(asset.path, part.name), { asset, part });
|
|
875
|
+
}
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
return references;
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
function renderFrameView() {
|
|
882
|
+
if (playerInvoker) {
|
|
883
|
+
deferredView = true;
|
|
884
|
+
return;
|
|
885
|
+
}
|
|
886
|
+
deferredView = false;
|
|
887
|
+
const title = frameViews[frameFilter];
|
|
888
|
+
$('#filter-label').textContent = title ?? 'Filter frames';
|
|
889
|
+
$('#filter-toggle').classList.toggle('active', !!title);
|
|
890
|
+
$('#view-board-title').textContent = title ?? '';
|
|
891
|
+
cards.reset();
|
|
892
|
+
delete viewContent.dataset.historyReady;
|
|
893
|
+
if (!title) {
|
|
894
|
+
viewContent.replaceChildren();
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
const focus = viewContent.contains(document.activeElement)
|
|
898
|
+
? {
|
|
899
|
+
label: document.activeElement.getAttribute('aria-label'),
|
|
900
|
+
frame: document.activeElement.closest('.view-frame')?.dataset,
|
|
901
|
+
flow: document.activeElement.closest('[data-flow-key]')?.dataset.flowKey,
|
|
902
|
+
}
|
|
903
|
+
: null;
|
|
904
|
+
const frames = frameReferences();
|
|
905
|
+
if (frameFilter === 'recent') {
|
|
906
|
+
const scope = manifest?.scope;
|
|
907
|
+
const inScope = (source, frame, chapter) => (!onlyFrame || onlyFrame === frame) && (scope === 'all' ||
|
|
908
|
+
sourcePaths.has(source) || scopeKind(scope) === 'group' && (chapter ?? source.split('/').slice(0, -1).join('/')) === scopeTarget(scope) ||
|
|
909
|
+
scopeKind(scope) === 'layer' && source.split('/')[0] === scopeTarget(scope));
|
|
910
|
+
recentFilter.render(viewContent, { relative: designSource, frames, inScope, card: cards.card });
|
|
911
|
+
} else {
|
|
912
|
+
const flows = prototypeFlows(manifest?.motionEdges ?? [], frames, designSource);
|
|
913
|
+
if (flows.length) {
|
|
914
|
+
renderPrototype(viewContent, flows, frames, { card: cards.card, play: startFramePlayer, title: assetTitle });
|
|
915
|
+
const target = pendingFlow && viewContent.querySelector('[data-flow-key="' + CSS.escape(pendingFlow) + '"]');
|
|
916
|
+
if (target) requestAnimationFrame(() => {
|
|
917
|
+
if (!pendingFlow || frameFilter !== 'playable' || !target.isConnected) return;
|
|
918
|
+
pendingFlow = null;
|
|
919
|
+
target.scrollIntoView({ block: 'start', inline: 'nearest' });
|
|
920
|
+
target.querySelector('.view-board-action').focus({ preventScroll: true });
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
else {
|
|
924
|
+
const status = boardElement('p', 'view-board-status', manifest?.loading ? 'Loading frames…' : 'No playable frames in this scope.');
|
|
925
|
+
status.setAttribute('role', 'status');
|
|
926
|
+
viewContent.replaceChildren(status);
|
|
927
|
+
}
|
|
928
|
+
}
|
|
929
|
+
if (focus?.label && document.activeElement === document.body) {
|
|
930
|
+
const replacement = [...viewContent.querySelectorAll('button[aria-label="' + CSS.escape(focus.label) + '"]')].find(button => {
|
|
931
|
+
const frame = button.closest('.view-frame')?.dataset;
|
|
932
|
+
return frame?.frameName === focus.frame?.frameName && frame?.frameSource === focus.frame?.frameSource &&
|
|
933
|
+
button.closest('[data-flow-key]')?.dataset.flowKey === focus.flow;
|
|
934
|
+
});
|
|
935
|
+
(replacement ?? derivedBoard).focus({ preventScroll: true });
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
function setFrameFilter(value, focus = true, loadCanvas = true) {
|
|
939
|
+
closeFilterMenu();
|
|
940
|
+
if (value !== frameFilter) {
|
|
941
|
+
viewGeneration++;
|
|
942
|
+
// Discard queued work belonging to cards on the outgoing derived board.
|
|
943
|
+
queued = queued.filter(entry => {
|
|
944
|
+
if (entry.derived === undefined) return true;
|
|
945
|
+
if (cache.get(entry.key) === entry) cache.delete(entry.key);
|
|
946
|
+
entry.finish();
|
|
947
|
+
return false;
|
|
948
|
+
});
|
|
949
|
+
frameFilter = value;
|
|
950
|
+
const url = new URL(location.href);
|
|
951
|
+
if (value !== 'playable') {
|
|
952
|
+
pendingFlow = null;
|
|
953
|
+
url.searchParams.delete('flow');
|
|
954
|
+
}
|
|
955
|
+
if (value === 'all') url.searchParams.delete('view');
|
|
956
|
+
else url.searchParams.set('view', value);
|
|
957
|
+
window.history.replaceState(window.history.state, '', url);
|
|
958
|
+
if (value === 'recent') {
|
|
959
|
+
if (!openRecentHistory(manifest)) renderFrameView();
|
|
960
|
+
} else {
|
|
961
|
+
recentFilter.close();
|
|
962
|
+
historyContext = null;
|
|
963
|
+
renderFrameView();
|
|
964
|
+
}
|
|
965
|
+
derivedBoard.scrollTop = 0;
|
|
966
|
+
updateChrome();
|
|
967
|
+
if (value === 'all') {
|
|
968
|
+
requestDraw(false, false);
|
|
969
|
+
if (derivedLanding && loadCanvas) void refresh(true);
|
|
970
|
+
}
|
|
971
|
+
}
|
|
972
|
+
if (focus) (value === 'all' ? $('#filter-toggle') : derivedBoard).focus({ preventScroll: true });
|
|
973
|
+
}
|
|
974
|
+
function closeFilterMenu() {
|
|
975
|
+
$('#filter-options').hidden = true;
|
|
976
|
+
$('#filter-toggle').setAttribute('aria-expanded', 'false');
|
|
977
|
+
}
|
|
978
|
+
$('#filter-toggle').onclick = () => {
|
|
979
|
+
const menu = $('#filter-options');
|
|
980
|
+
menu.hidden = !menu.hidden;
|
|
981
|
+
$('#filter-toggle').setAttribute('aria-expanded', String(!menu.hidden));
|
|
982
|
+
for (const b of menu.children) b.setAttribute('aria-pressed', String(b.dataset.filter === frameFilter));
|
|
983
|
+
};
|
|
984
|
+
$('#filter-options').onclick = e => {
|
|
985
|
+
if (e.target.dataset.filter) setFrameFilter(e.target.dataset.filter);
|
|
986
|
+
};
|
|
987
|
+
$('#all-frames').onclick = () => setFrameFilter('all');
|
|
988
|
+
$('#frame-filter').addEventListener('keydown', e => {
|
|
989
|
+
if (e.key !== 'Escape' || $('#filter-options').hidden) return;
|
|
990
|
+
e.stopPropagation();
|
|
991
|
+
e.preventDefault();
|
|
992
|
+
closeFilterMenu();
|
|
993
|
+
$('#filter-toggle').focus();
|
|
994
|
+
});
|
|
995
|
+
document.addEventListener('pointerdown', e => {
|
|
996
|
+
if (!e.target.closest('#frame-filter')) closeFilterMenu();
|
|
997
|
+
});
|
|
998
|
+
|
|
999
|
+
const floatingPlays = new Map();
|
|
1000
|
+
let hoveredPlay;
|
|
1001
|
+
function playablePart(asset) {
|
|
1002
|
+
const part = asset?.shown[0];
|
|
1003
|
+
return playableFrames.get(asset?.path)?.has(part?.name) ? part : null;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
function canvasPlayPosition(asset, part, toolbars) {
|
|
1007
|
+
const content = frameBox(asset, part), scale = view.scale;
|
|
1008
|
+
if (scale < .18 || content.width * scale < 64 || content.height * scale < 40) return;
|
|
1009
|
+
const screen = box => ({
|
|
1010
|
+
x: view.x + box.x * scale, y: view.y + box.y * scale,
|
|
1011
|
+
width: box.width * scale, height: box.height * scale
|
|
1012
|
+
});
|
|
1013
|
+
const card = screen(asset.well ?? content);
|
|
1014
|
+
const size = Math.min(32, Math.max(20, 24 * Math.sqrt(scale)));
|
|
1015
|
+
const position = placePlayButton(card, screen(content), size, { width, height }, toolbars());
|
|
1016
|
+
if (position) return { ...position, size, card };
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
function playHoverAt(x, y) {
|
|
1020
|
+
if (inspection || !playableFrames.size) return;
|
|
1021
|
+
const item = hoveredElement?.asset;
|
|
1022
|
+
if (hoveredElement?.part) {
|
|
1023
|
+
const part = playablePart(item);
|
|
1024
|
+
return part ? { asset: item, part } : null;
|
|
1025
|
+
}
|
|
1026
|
+
if (hoveredPlay) {
|
|
1027
|
+
const position = floatingPlays.get(frameKey(hoveredPlay.asset.path, hoveredPlay.part.name))?.position;
|
|
1028
|
+
if (position?.outside) {
|
|
1029
|
+
const { card, size } = position;
|
|
1030
|
+
const edgeX = Math.max(card.x, Math.min(position.x + size / 2, card.x + card.width));
|
|
1031
|
+
const edgeY = Math.max(card.y, Math.min(position.y + size / 2, card.y + card.height));
|
|
1032
|
+
const bridge = { x: Math.min(position.x, edgeX), y: Math.min(position.y, edgeY),
|
|
1033
|
+
width: Math.max(position.x + size, edgeX) - Math.min(position.x, edgeX),
|
|
1034
|
+
height: Math.max(position.y + size, edgeY) - Math.min(position.y, edgeY) };
|
|
1035
|
+
if (contains(bridge, x, y)) return hoveredPlay;
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
const worldX = (x - view.x) / view.scale, worldY = (y - view.y) / view.scale;
|
|
1039
|
+
const asset = assets.findLast(item => playablePart(item) && contains(item.well ?? item, worldX, worldY));
|
|
1040
|
+
if (asset) return { asset, part: playablePart(asset) };
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
function updateFramePlay() {
|
|
1044
|
+
const next = new Map();
|
|
1045
|
+
let toolbars;
|
|
1046
|
+
const visibleToolbars = () => toolbars ??= [...document.querySelectorAll('.floating[role="toolbar"]:not([hidden])')]
|
|
1047
|
+
.map(element => element.getBoundingClientRect()).filter(rect => rect.width && rect.height);
|
|
1048
|
+
function add(asset, part) {
|
|
1049
|
+
if (!part || !playableFrames.get(asset?.path)?.has(part.name)) return;
|
|
1050
|
+
const position = canvasPlayPosition(asset, part, visibleToolbars);
|
|
1051
|
+
if (position) next.set(frameKey(asset.path, part.name), { asset, part, ...position });
|
|
1052
|
+
}
|
|
1053
|
+
if (frameFilter === 'all' && !tokenManifest && !inspection && !commentUI?.active()) {
|
|
1054
|
+
add(hoveredPlay?.asset, hoveredPlay?.part);
|
|
1055
|
+
const item = currentItem();
|
|
1056
|
+
add(item, item?.parts.find(p => p.id === selectedForm));
|
|
1057
|
+
const focused = [...floatingPlays.values()].find(entry => entry.button === document.activeElement);
|
|
1058
|
+
if (focused) {
|
|
1059
|
+
const asset = assets.find(item => item.id === focused.asset.id);
|
|
1060
|
+
if (asset) add(asset, playablePart(asset));
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
for (const [key, { button }] of floatingPlays) {
|
|
1064
|
+
if (next.has(key) || button === playerInvoker) continue;
|
|
1065
|
+
button.remove();
|
|
1066
|
+
floatingPlays.delete(key);
|
|
1067
|
+
}
|
|
1068
|
+
for (const [key, position] of next) {
|
|
1069
|
+
const { asset, part, x, y, size, outside } = position;
|
|
1070
|
+
let button = floatingPlays.get(key)?.button;
|
|
1071
|
+
if (!button) {
|
|
1072
|
+
button = playButton(part.name, event => startFramePlayer(asset.path, part.name, event.currentTarget));
|
|
1073
|
+
button.addEventListener('pointerdown', event => event.stopPropagation());
|
|
1074
|
+
button.addEventListener('dblclick', event => event.stopPropagation());
|
|
1075
|
+
button.addEventListener('blur', () => queueMicrotask(updateFramePlay));
|
|
1076
|
+
viewport.append(button);
|
|
1077
|
+
}
|
|
1078
|
+
floatingPlays.set(key, { button, asset, position });
|
|
1079
|
+
button.style.cssText = 'right:auto;left:' + x + 'px;top:' + y + 'px;--frame-play-size:' + size + 'px';
|
|
1080
|
+
button.toggleAttribute('data-outside', outside);
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
function setMotionProjection(projection) {
|
|
1084
|
+
motionProjection = projection;
|
|
1085
|
+
playableFrames.clear();
|
|
1086
|
+
for (const [source, names] of Object.entries(projection ?? {})) playableFrames.set(source, new Set(names));
|
|
1087
|
+
}
|
|
746
1088
|
function selection() {
|
|
747
1089
|
hoveredElement=null;
|
|
748
1090
|
if (!selected) inspector = false;
|
|
@@ -817,7 +1159,7 @@ function asScreen(box) {
|
|
|
817
1159
|
return { x: rect.left + view.x + box.x * view.scale, y: rect.top + view.y + box.y * view.scale,
|
|
818
1160
|
width: box.width * view.scale, height: box.height * view.scale };
|
|
819
1161
|
}
|
|
820
|
-
const sourcePrefix = () => manifest?.sourcePrefix ?? '';
|
|
1162
|
+
const sourcePrefix = () => catalog?.sourcePrefix ?? manifest?.sourcePrefix ?? '';
|
|
821
1163
|
const projectSource = source => {
|
|
822
1164
|
const prefix = sourcePrefix();
|
|
823
1165
|
return !prefix || source.startsWith(prefix + '/') ? source : prefix + '/' + source;
|
|
@@ -941,6 +1283,7 @@ $('#comments-toggle').addEventListener('click', () => {
|
|
|
941
1283
|
function updateOutlines() {
|
|
942
1284
|
viewport.dataset.hoverHit = String(!!hoveredElement && !commentUI.active());
|
|
943
1285
|
commentUI.reposition();
|
|
1286
|
+
updateFramePlay();
|
|
944
1287
|
const hover=hoveredElement,origin=hover?.part?frameBox(hover.asset,hover.part):null;
|
|
945
1288
|
const hoverBox=hover?.element?{...hover.element,x:origin.x+hover.element.x,y:origin.y+hover.element.y}:origin;
|
|
946
1289
|
for (const [id,box] of [['selection-outline',selectedBox() ?? (selected ? currentItem() : null)],['hover-outline',hoverBox]]) {
|
|
@@ -949,7 +1292,9 @@ function updateOutlines() {
|
|
|
949
1292
|
}
|
|
950
1293
|
}
|
|
951
1294
|
|
|
952
|
-
function cameraArea() {
|
|
1295
|
+
function cameraArea() {
|
|
1296
|
+
return fitArea(width,height,false,false);
|
|
1297
|
+
}
|
|
953
1298
|
function fitWorld(area, data) {
|
|
954
1299
|
if (scopeKind(data?.scope) !== 'asset' || !assets.length) return fitView(world,area);
|
|
955
1300
|
const x=Math.min(...assets.map(a=>a.x)), y=Math.min(...assets.map(a=>a.y));
|
|
@@ -960,7 +1305,13 @@ function fitWorld(area, data) {
|
|
|
960
1305
|
function frame(box, padding = 0) {
|
|
961
1306
|
const target=box===world?'all':groups.includes(box)?'group':'selection';
|
|
962
1307
|
for(const name of ['all','group','selection']) $("#zoom-fit-"+name).setAttribute('aria-current',String(name===target));
|
|
963
|
-
|
|
1308
|
+
// Fit is a discrete camera placement. Its viewport is already settled.
|
|
1309
|
+
clearTimeout(idleTimer);
|
|
1310
|
+
moving = false;
|
|
1311
|
+
window.__adg.ready = false;
|
|
1312
|
+
view = box===world ? fitWorld(cameraArea(),manifest) : fitView(box, cameraArea(), padding);
|
|
1313
|
+
requestDraw();
|
|
1314
|
+
save();
|
|
964
1315
|
}
|
|
965
1316
|
function fit() {
|
|
966
1317
|
if (tokenManifest) {
|
|
@@ -1042,6 +1393,7 @@ function ensureImage(a, p) {
|
|
|
1042
1393
|
return e;
|
|
1043
1394
|
}
|
|
1044
1395
|
e = { key, asset: a, part: p, theme:effectiveTheme, used: performance.now(), state: "queued" };
|
|
1396
|
+
e.done = new Promise(resolve => { e.finish = resolve; });
|
|
1045
1397
|
cache.set(key, e);
|
|
1046
1398
|
queued.push(e);
|
|
1047
1399
|
queueMicrotask(pump);
|
|
@@ -1050,13 +1402,15 @@ function ensureImage(a, p) {
|
|
|
1050
1402
|
function pump() {
|
|
1051
1403
|
// New vector parsing/decoding waits until the gesture settles. Existing exact
|
|
1052
1404
|
// raster previews continue to move with the camera during interaction.
|
|
1053
|
-
if(moving)return;
|
|
1054
|
-
queued.sort((a,b)=>Number(visible(b.asset))-Number(visible(a.asset))||
|
|
1405
|
+
if(moving || loading >= 3 || !queued.length)return;
|
|
1406
|
+
if (frameFilter === 'all') queued.sort((a,b)=>Number(visible(b.asset))-Number(visible(a.asset))||
|
|
1055
1407
|
Math.hypot(view.x+(a.asset.x+a.asset.width/2)*view.scale-width/2,view.y+(a.asset.y+a.asset.height/2)*view.scale-height/2)-
|
|
1056
1408
|
Math.hypot(view.x+(b.asset.x+b.asset.width/2)*view.scale-width/2,view.y+(b.asset.y+b.asset.height/2)*view.scale-height/2));
|
|
1057
1409
|
while (loading < 3 && queued.length) {
|
|
1058
|
-
const
|
|
1059
|
-
if (
|
|
1410
|
+
const next = frameFilter === 'all' ? 0 : queued.findIndex(entry => entry.derived === viewGeneration);
|
|
1411
|
+
if (next === -1) break;
|
|
1412
|
+
const [e] = queued.splice(next, 1);
|
|
1413
|
+
if (cache.get(e.key) !== e) { e.finish(); continue; }
|
|
1060
1414
|
loading++;e.state='loading';
|
|
1061
1415
|
void loadPreview(e);
|
|
1062
1416
|
}
|
|
@@ -1087,7 +1441,9 @@ async function loadPreview(e) {
|
|
|
1087
1441
|
const decode=async source=>{
|
|
1088
1442
|
if(cache.get(e.key)!==e)return;
|
|
1089
1443
|
while(moving)await new Promise(resolve=>setTimeout(resolve,16));
|
|
1090
|
-
const img=new Image();e.image=img;img.decoding='async';
|
|
1444
|
+
const img=new Image();e.image=img;img.decoding='async';
|
|
1445
|
+
if (e.visiblePriority) img.fetchPriority='high';
|
|
1446
|
+
img.src=source;
|
|
1091
1447
|
const endDecode = globalThis.__adgTiming?.span('decode', e.asset.path, {crop:e.part.id});
|
|
1092
1448
|
try { await img.decode();e.state='ready'; } finally {endDecode?.();}
|
|
1093
1449
|
};
|
|
@@ -1114,14 +1470,66 @@ async function loadPreview(e) {
|
|
|
1114
1470
|
} finally {
|
|
1115
1471
|
endPreview?.({state:e.state});
|
|
1116
1472
|
if(local&&url)URL.revokeObjectURL(url);
|
|
1117
|
-
|
|
1473
|
+
e.finish();
|
|
1474
|
+
loading--;
|
|
1475
|
+
if (frameFilter === 'all') requestDraw(false);
|
|
1476
|
+
pump();
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
|
|
1480
|
+
async function drawCardPreview({ asset, part }, canvas) {
|
|
1481
|
+
const unavailable = () => {
|
|
1482
|
+
canvas.dataset.preview = 'unavailable';
|
|
1483
|
+
canvas.after(boardElement('span', 'view-board-status', 'Preview unavailable'));
|
|
1484
|
+
};
|
|
1485
|
+
// A direct derived-board link initially has a source inventory. Measure only
|
|
1486
|
+
// sources whose cards enter view until the user opens the full canvas.
|
|
1487
|
+
const theme = effectiveTheme, generation = viewGeneration;
|
|
1488
|
+
if (part.id === undefined) {
|
|
1489
|
+
try {
|
|
1490
|
+
const saved = asset.metadata?.[theme] ?? metadataCache.get(sourceKey(asset, theme));
|
|
1491
|
+
const measured = saved ? decorateMetadata(asset, saved)
|
|
1492
|
+
: await readSourceMetadata(asset, theme) ?? await sourceFor(asset, theme);
|
|
1493
|
+
if (generation !== viewGeneration || !canvas.isConnected) return;
|
|
1494
|
+
metadataCache.set(sourceKey(measured, theme), measuredMetadata(measured));
|
|
1495
|
+
part = measured.parts.find(candidate => candidate.name === part.name);
|
|
1496
|
+
if (!part) { unavailable(); return; }
|
|
1497
|
+
asset = { ...measured, previewCrop: blockForAsset(measured).previewCrop ?? specimenPaintCrop(measured, part) };
|
|
1498
|
+
} catch {
|
|
1499
|
+
if (canvas.isConnected) unavailable();
|
|
1500
|
+
return;
|
|
1501
|
+
}
|
|
1502
|
+
}
|
|
1503
|
+
const crop = asset.previewCrop ?? part;
|
|
1504
|
+
const entry = ensureImage(asset, crop);
|
|
1505
|
+
entry.derived = viewGeneration;
|
|
1506
|
+
queueMicrotask(pump);
|
|
1507
|
+
await entry.done;
|
|
1508
|
+
if (!canvas.isConnected) return;
|
|
1509
|
+
if (entry.state !== 'ready') {
|
|
1510
|
+
unavailable();
|
|
1511
|
+
return;
|
|
1512
|
+
}
|
|
1513
|
+
const scale = Math.min(1, 205 / part.width, 124 / part.height);
|
|
1514
|
+
canvas.width = Math.max(1, Math.round(part.width * scale * 2));
|
|
1515
|
+
canvas.height = Math.max(1, Math.round(part.height * scale * 2));
|
|
1516
|
+
canvas.style.width = canvas.width / 2 + 'px';
|
|
1517
|
+
canvas.style.height = canvas.height / 2 + 'px';
|
|
1518
|
+
canvas.style.aspectRatio = part.width + ' / ' + part.height;
|
|
1519
|
+
const sx = entry.image.width / crop.width, sy = entry.image.height / crop.height;
|
|
1520
|
+
canvas.getContext('2d').drawImage(entry.image, (part.x - crop.x) * sx, (part.y - crop.y) * sy,
|
|
1521
|
+
part.width * sx, part.height * sy, 0, 0, canvas.width, canvas.height);
|
|
1522
|
+
canvas.dataset.preview = 'ready';
|
|
1523
|
+
if (cache.size > 100) {
|
|
1524
|
+
const pending = new Set([...cache.values()].filter(e => e.state === 'queued' || e.state === 'loading').map(e => e.key));
|
|
1525
|
+
evictPreviews(cache, pending);
|
|
1118
1526
|
}
|
|
1119
1527
|
}
|
|
1120
1528
|
|
|
1121
1529
|
function thumbnail(e, upgrade = false) {
|
|
1122
1530
|
const scale = Math.min(2, view.scale) * dpr;
|
|
1123
|
-
if (e.bitmap && (!upgrade || e.bitmapScale >= scale)) return e.bitmap;
|
|
1124
1531
|
const limit = Math.min(scale, 4096 / Math.max(e.part.width, e.part.height));
|
|
1532
|
+
if (e.bitmap && (!upgrade || e.bitmapScale >= limit)) return e.bitmap;
|
|
1125
1533
|
const c = document.createElement('canvas');
|
|
1126
1534
|
c.width = Math.max(1, Math.ceil(e.part.width * limit));
|
|
1127
1535
|
c.height = Math.max(1, Math.ceil(e.part.height * limit));
|
|
@@ -1156,6 +1564,14 @@ function draw() {
|
|
|
1156
1564
|
const endDrawing = globalThis.__adgTiming?.span('drawing');
|
|
1157
1565
|
raf = 0;
|
|
1158
1566
|
drawBackground();
|
|
1567
|
+
if (frameFilter !== 'all' && !tokenManifest) {
|
|
1568
|
+
window.__adg.ready = !!manifest && !manifest.loading && !arranger.pending;
|
|
1569
|
+
window.__adg.revision = manifest?.revision;
|
|
1570
|
+
if (window.__adg.ready && manifest?.directory) void recordVisit(manifest.directory);
|
|
1571
|
+
if (!moving && queued.length) pump();
|
|
1572
|
+
endDrawing?.();
|
|
1573
|
+
return;
|
|
1574
|
+
}
|
|
1159
1575
|
if (tokenManifest && tokenList) {
|
|
1160
1576
|
window.__adg.ready = true;
|
|
1161
1577
|
window.__adg.revision = tokenManifest.revision;
|
|
@@ -1180,7 +1596,7 @@ function draw() {
|
|
|
1180
1596
|
Math.abs(dx) <= drawingMargin && Math.abs(dy) <= drawingMargin;
|
|
1181
1597
|
if (!reuse) {
|
|
1182
1598
|
const zooming = moving && drawingView?.scale !== view.scale;
|
|
1183
|
-
drawingMargin = zooming ? 0 : Math.ceil(Math.min(width, height) / 4);
|
|
1599
|
+
drawingMargin = zooming || manifest?.loading ? 0 : Math.ceil(Math.min(width, height) / 4);
|
|
1184
1600
|
const bufferWidth = Math.round((width + drawingMargin * 2) * dpr), bufferHeight = Math.round((height + drawingMargin * 2) * dpr);
|
|
1185
1601
|
if (canvas.width !== bufferWidth || canvas.height !== bufferHeight) {
|
|
1186
1602
|
canvas.width = bufferWidth; canvas.height = bufferHeight;
|
|
@@ -1240,6 +1656,7 @@ function draw() {
|
|
|
1240
1656
|
if (zoomValue.textContent !== percentage) zoomValue.textContent = percentage;
|
|
1241
1657
|
if (zoomOutput.value !== percentage) zoomOutput.value = percentage;
|
|
1242
1658
|
window.__adg.ready = !!manifest && !manifest.loading && manifest.renderTheme === effectiveTheme && drawingReady === drawingCount && !moving && !arranger.pending;
|
|
1659
|
+
if (window.__adg.ready && manifest?.directory) void recordVisit(manifest.directory);
|
|
1243
1660
|
if(fixtureState && fixtureApplied && window.__adg.ready) document.documentElement.dataset.fixtureReady=fixtureState.name;
|
|
1244
1661
|
window.__adg.revision = manifest?.revision;
|
|
1245
1662
|
window.__adg.visibleReady = drawingReady; window.__adg.visibleCount = drawingCount;
|
|
@@ -1351,16 +1768,18 @@ viewport.addEventListener("pointermove", (e) => {
|
|
|
1351
1768
|
const old = pointers.get(e.pointerId);
|
|
1352
1769
|
if (!old) {
|
|
1353
1770
|
if (commentUI.active()) {
|
|
1354
|
-
hoveredElement = null;
|
|
1771
|
+
hoveredElement = hoveredPlay = null;
|
|
1355
1772
|
commentUI.hover(e.clientX, e.clientY, e.altKey);
|
|
1356
1773
|
updateOutlines();
|
|
1357
1774
|
return;
|
|
1358
1775
|
}
|
|
1359
|
-
|
|
1360
|
-
|
|
1776
|
+
if (e.target.closest('.frame-play')) return;
|
|
1777
|
+
const rect = viewport.getBoundingClientRect(), x = e.clientX - rect.left, y = e.clientY - rect.top;
|
|
1778
|
+
hoveredElement = hitSelection(inspection ? [inspection] : assets, (x - view.x) / view.scale, (y - view.y) / view.scale);
|
|
1779
|
+
hoveredPlay = playHoverAt(x, y);
|
|
1361
1780
|
updateOutlines();return;
|
|
1362
1781
|
}
|
|
1363
|
-
hoveredElement=null;commentUI.hover();updateOutlines();
|
|
1782
|
+
hoveredElement=hoveredPlay=null;commentUI.hover();updateOutlines();
|
|
1364
1783
|
const before = [...pointers.values()];
|
|
1365
1784
|
pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
1366
1785
|
if (Math.hypot(e.clientX - gesture.x, e.clientY - gesture.y) > 4)
|
|
@@ -1389,7 +1808,7 @@ viewport.addEventListener("pointermove", (e) => {
|
|
|
1389
1808
|
});
|
|
1390
1809
|
}
|
|
1391
1810
|
});
|
|
1392
|
-
viewport.addEventListener('pointerleave',()=>{hoveredElement=null;commentUI.hover();updateOutlines()});
|
|
1811
|
+
viewport.addEventListener('pointerleave',()=>{hoveredElement=hoveredPlay=null;commentUI.hover();updateOutlines()});
|
|
1393
1812
|
function up(e) {
|
|
1394
1813
|
if (!pointers.delete(e.pointerId)) return;
|
|
1395
1814
|
if (e.type === "pointerup" && !gesture.moved && gesture.button === 0) {
|
|
@@ -1501,7 +1920,7 @@ viewport.addEventListener('contextmenu', e => {
|
|
|
1501
1920
|
});
|
|
1502
1921
|
document.addEventListener('keydown', e => {
|
|
1503
1922
|
if (!(e.key === 'ContextMenu' || (e.key === 'F10' && e.shiftKey))) return;
|
|
1504
|
-
if (tokenManifest || !manifest?.directory || document.querySelector('dialog[open]')) return;
|
|
1923
|
+
if (frameFilter !== 'all' || tokenManifest || !manifest?.directory || document.querySelector('dialog[open]')) return;
|
|
1505
1924
|
e.preventDefault();
|
|
1506
1925
|
const activeEl = document.activeElement;
|
|
1507
1926
|
const box = selectedBox();
|
|
@@ -1515,6 +1934,15 @@ document.addEventListener("keydown", (e) => {
|
|
|
1515
1934
|
(tokenManifest && tokenList) ||
|
|
1516
1935
|
e.target.matches("input,textarea,select,[contenteditable]") ||
|
|
1517
1936
|
document.querySelector("dialog[open], :popover-open")) return;
|
|
1937
|
+
if (frameFilter !== 'all') return;
|
|
1938
|
+
if (!tokenManifest && !e.repeat && e.key.toLowerCase() === 'p') {
|
|
1939
|
+
const item = currentItem(), part = item?.parts.find(p => p.id === selectedForm);
|
|
1940
|
+
if (playableFrames.get(item?.path)?.has(part?.name)) {
|
|
1941
|
+
e.preventDefault();
|
|
1942
|
+
void startFramePlayer(item.path, part.name, document.activeElement);
|
|
1943
|
+
}
|
|
1944
|
+
return;
|
|
1945
|
+
}
|
|
1518
1946
|
const inPanel = !!e.target.closest('#sidebar, #source, #comments-panel, #scope-tabs, #token-catalog');
|
|
1519
1947
|
const v = view;
|
|
1520
1948
|
if (e.key === "Enter") {
|
|
@@ -1560,7 +1988,10 @@ $("#back").onclick = back;
|
|
|
1560
1988
|
$("#scope-isolation").onclick = () => exitIsolation(true);
|
|
1561
1989
|
$("#token-view-toggle").onclick = () => setTokenList(!tokenList);
|
|
1562
1990
|
$("#token-board-button").onclick = () => setTokenList(false);
|
|
1563
|
-
$('#sidebar-toggle').onclick = () =>
|
|
1991
|
+
$('#sidebar-toggle').onclick = () => {
|
|
1992
|
+
if(frameFilter!=='all' && !tokenManifest){setFrameFilter('all');toggleSidebar(true);$('#sidebar-toggle').focus();}
|
|
1993
|
+
else toggleSidebar();
|
|
1994
|
+
};
|
|
1564
1995
|
$('#inspect').onclick = () => {
|
|
1565
1996
|
inspector = !inspector;
|
|
1566
1997
|
if (inspector) commentUI?.closePanel?.();
|
|
@@ -1736,10 +2167,18 @@ function applyTokenManifest(data) {
|
|
|
1736
2167
|
canvas.width = canvas.width;
|
|
1737
2168
|
boardLayer.update([], [], data);
|
|
1738
2169
|
boardLayer.camera(view, false);
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
2170
|
+
let firstMeasurement = true;
|
|
2171
|
+
boardLayer.tokens(data.tokenBoard, boardHeight => {
|
|
2172
|
+
tokenHeight=boardHeight;
|
|
2173
|
+
world={x:0,y:0,width:data.tokenBoard.width,height:boardHeight};
|
|
2174
|
+
if (entering && firstMeasurement) {
|
|
2175
|
+
const query = new URLSearchParams(location.search);
|
|
2176
|
+
const section = data.fixture?.section ?? (query.has('pattern') ? 'motion' : query.get('section'));
|
|
2177
|
+
const box = section === 'motion' && boardLayer.tokenSection(section);
|
|
2178
|
+
if (box) commit(fitView({ ...box, height: Math.min(box.height, 650) }, fitArea(width, height, sidebar, false), 24));
|
|
2179
|
+
else frame(world);
|
|
2180
|
+
}
|
|
2181
|
+
firstMeasurement = false;
|
|
1743
2182
|
requestDraw();
|
|
1744
2183
|
});
|
|
1745
2184
|
scopeRequest = data.scope;
|
|
@@ -1783,12 +2222,28 @@ async function applyManifest(data, force = false) {
|
|
|
1783
2222
|
}
|
|
1784
2223
|
if (changedRoot) {
|
|
1785
2224
|
fixtureState=data.fixture ?? null;
|
|
1786
|
-
|
|
1787
|
-
|
|
2225
|
+
if (!derivedLanding || catalog?.directory !== data.directory) {
|
|
2226
|
+
theme = data.theme;
|
|
2227
|
+
applyTheme();
|
|
2228
|
+
}
|
|
1788
2229
|
if (!leavingOverlayView) sidebar = !!fixtureState?.sidebar;
|
|
1789
2230
|
inspector = !!fixtureState && data.inspector;
|
|
1790
2231
|
history = [];
|
|
1791
2232
|
}
|
|
2233
|
+
if (first && !fixtureState && frameFilter !== 'all' && !initializedDirectory && data.directory) {
|
|
2234
|
+
catalog = manifest = data;
|
|
2235
|
+
derivedLanding = true;
|
|
2236
|
+
scopeRequest = data.scope;
|
|
2237
|
+
setMotionProjection(data.motionFrames);
|
|
2238
|
+
for (const element of document.querySelectorAll('.directory-name')) element.textContent = data.label;
|
|
2239
|
+
$('#app-directory').title = data.directory;
|
|
2240
|
+
document.title = `${data.label} — Agent Design Gallery`;
|
|
2241
|
+
updateChrome();
|
|
2242
|
+
renderScopeTabs(data);
|
|
2243
|
+
if (frameFilter !== 'recent' || !openRecentHistory(data)) renderFrameView();
|
|
2244
|
+
requestDraw();
|
|
2245
|
+
return;
|
|
2246
|
+
}
|
|
1792
2247
|
if (first) {
|
|
1793
2248
|
if (catalog?.directory !== data.directory || catalog?.scope !== data.scope) {
|
|
1794
2249
|
expanded.clear();
|
|
@@ -1821,15 +2276,59 @@ async function applyManifest(data, force = false) {
|
|
|
1821
2276
|
const previous=manifest, results=new Array(data.assets.length), signal=refreshController?.signal;
|
|
1822
2277
|
let next=0,publishFrame=0,streamView=null,streamMoved=false,publishedCount=0,nextPublish=1;
|
|
1823
2278
|
const streaming=first && !leavingOverlayView;
|
|
2279
|
+
let cachedPlacement;
|
|
2280
|
+
const order = data.assets.map((_, i) => i);
|
|
2281
|
+
if (streaming && data.view && data.metadataTheme === versionTheme &&
|
|
2282
|
+
data.assets.length && data.assets.every(a => a.layout)) {
|
|
2283
|
+
// The cached frame bounds determine placement without loading the much larger hit maps.
|
|
2284
|
+
const outlines = data.assets.map(a => decorateMetadata(a, a.layout));
|
|
2285
|
+
if (data.scope === 'all' && data.tokenBoard && !tokenHeight)
|
|
2286
|
+
boardLayer.tokens(data.tokenBoard, height => { tokenHeight = height; });
|
|
2287
|
+
const panel = layoutData({...data,assets:outlines});
|
|
2288
|
+
cachedPlacement = await arranger.arrange(panel, {signal});
|
|
2289
|
+
const priority = new Map();
|
|
2290
|
+
const camera = entry?.view ?? data.view;
|
|
2291
|
+
const items = arrange(panel, {placed:cachedPlacement}).items;
|
|
2292
|
+
const offset = data.scope === 'all' && data.tokenBoard && tokenHeight ? tokenHeight + 480 : 0;
|
|
2293
|
+
const candidates = [];
|
|
2294
|
+
for (const item of items) {
|
|
2295
|
+
const x = camera.x + item.x * camera.scale, y = camera.y + (item.y + offset) * camera.scale;
|
|
2296
|
+
const w = item.width * camera.scale, h = item.height * camera.scale;
|
|
2297
|
+
const distance = Math.hypot(x + w / 2 - width / 2, y + h / 2 - height / 2);
|
|
2298
|
+
priority.set(item.path, Math.min(priority.get(item.path) ?? Infinity, distance));
|
|
2299
|
+
if (x < width && x+w > 0 && y < height && y+h > 0) candidates.push({item,distance});
|
|
2300
|
+
}
|
|
2301
|
+
// Start the actual cached images while their interaction metadata is in flight.
|
|
2302
|
+
// Reuse the same bounded queue when the corresponding specimens are published.
|
|
2303
|
+
const primed = new Set();
|
|
2304
|
+
for (const {item} of candidates.sort((a,b) => a.distance-b.distance)) {
|
|
2305
|
+
const crop = item.previewCrop ?? item.shown[0];
|
|
2306
|
+
const key = assetURL(item,crop);
|
|
2307
|
+
if (primed.has(key) || !item.previewIds?.[versionTheme]?.includes(crop.id)) continue;
|
|
2308
|
+
ensureImage(item,crop).visiblePriority = true;
|
|
2309
|
+
primed.add(key);
|
|
2310
|
+
if (primed.size === 3) break;
|
|
2311
|
+
}
|
|
2312
|
+
pump();
|
|
2313
|
+
order.sort((a,b) => priority.get(data.assets[a].path) - priority.get(data.assets[b].path));
|
|
2314
|
+
}
|
|
2315
|
+
let lastPublish = -Infinity;
|
|
1824
2316
|
const publish=()=>{
|
|
1825
2317
|
publishFrame=0;
|
|
1826
2318
|
if(signal?.aborted||versionTheme!==effectiveTheme)return;
|
|
1827
2319
|
const available=results.filter(Boolean);
|
|
1828
2320
|
if(!available.length)return;
|
|
2321
|
+
lastPublish = performance.now();
|
|
1829
2322
|
publishedCount=available.length;nextPublish=Math.max(publishedCount+1,publishedCount*2);
|
|
1830
2323
|
if(streamView&&view!==streamView)streamMoved=true;
|
|
1831
2324
|
manifest={...data,assets:available,renderTheme:versionTheme,loading:true};
|
|
1832
|
-
|
|
2325
|
+
let placed;
|
|
2326
|
+
if (cachedPlacement) {
|
|
2327
|
+
const paths = new Set(available.map(a => a.path));
|
|
2328
|
+
placed = cachedPlacement.map(board => ({...board, blocks:board.blocks.filter(b => paths.has(b.asset))}))
|
|
2329
|
+
.filter(board => board.blocks.length);
|
|
2330
|
+
}
|
|
2331
|
+
layout(manifest,false,{provisional:true,placed});
|
|
1833
2332
|
if(streaming&&!streamMoved){view=entry?.view??data.view??fitWorld(cameraArea(),data);streamView=view;}
|
|
1834
2333
|
requestDraw();
|
|
1835
2334
|
};
|
|
@@ -1840,19 +2339,32 @@ async function applyManifest(data, force = false) {
|
|
|
1840
2339
|
}
|
|
1841
2340
|
let completed=results.filter(Boolean).length;
|
|
1842
2341
|
if(streaming&&completed&&completed<data.assets.length)publish();
|
|
2342
|
+
// Let the server build the next sources while the browser measures this batch.
|
|
2343
|
+
const prefetched = new Map();
|
|
2344
|
+
let fetchIndex = 0;
|
|
2345
|
+
function prefetch() {
|
|
2346
|
+
while (fetchIndex < data.assets.length && prefetched.size < 4) {
|
|
2347
|
+
const i = order[fetchIndex++], asset = data.assets[i];
|
|
2348
|
+
if (results[i]) continue;
|
|
2349
|
+
const source = asset.metadataRefs?.[versionTheme]
|
|
2350
|
+
? readSourceMetadata(asset, versionTheme, signal)
|
|
2351
|
+
: fetchSource(asset, versionTheme, signal);
|
|
2352
|
+
source.catch(() => {}); // A superseded refresh can abandon this lookahead.
|
|
2353
|
+
prefetched.set(i, source);
|
|
2354
|
+
}
|
|
2355
|
+
}
|
|
2356
|
+
prefetch();
|
|
1843
2357
|
await Promise.all(Array.from({length:4},async()=>{
|
|
1844
2358
|
while(next<data.assets.length) {
|
|
1845
2359
|
signal?.throwIfAborted();
|
|
1846
|
-
const i=next
|
|
2360
|
+
const i=order[next++],a=data.assets[i];
|
|
1847
2361
|
if(results[i])continue;
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
if(response.ok){const saved=await response.json();entry=decorateMetadata({...a,previewIds:{...a.previewIds,[versionTheme]:saved.previewIds}},saved.metadata);}
|
|
1853
|
-
}
|
|
2362
|
+
const source = prefetched.get(i);
|
|
2363
|
+
prefetched.delete(i);
|
|
2364
|
+
prefetch();
|
|
2365
|
+
let entry = a.metadataRefs?.[versionTheme] ? await source : null;
|
|
1854
2366
|
if(!entry) {
|
|
1855
|
-
entry=await prepare(a,versionTheme,{signal});
|
|
2367
|
+
entry=await prepare(a,versionTheme,{signal,source:a.metadataRefs?.[versionTheme] ? undefined : source});
|
|
1856
2368
|
if (a.onlyFrame && !entry.parts.some(part => part.name === a.onlyFrame)) throw Error(`Frame ${a.onlyFrame} does not exist in ${a.path}.`);
|
|
1857
2369
|
Object.assign(a,{hash:entry.hash,version:entry.version});
|
|
1858
2370
|
persistSource(entry,versionTheme);
|
|
@@ -1861,16 +2373,14 @@ async function applyManifest(data, force = false) {
|
|
|
1861
2373
|
const metadata=measuredMetadata(entry);
|
|
1862
2374
|
metadataCache.set(sourceKey(entry,versionTheme,data.directory),metadata);
|
|
1863
2375
|
results[i]=decorateMetadata(a,metadata);completed++;
|
|
1864
|
-
if(streaming&&completed>=nextPublish&&!publishFrame)publishFrame=requestAnimationFrame(publish);
|
|
2376
|
+
if(streaming&&completed>=nextPublish&&!publishFrame&&performance.now()-lastPublish>=100)publishFrame=requestAnimationFrame(publish);
|
|
1865
2377
|
}
|
|
1866
2378
|
}));
|
|
1867
2379
|
if(publishFrame)cancelAnimationFrame(publishFrame);
|
|
1868
2380
|
if(versionTheme!==effectiveTheme){pending=true;return;}
|
|
1869
2381
|
signal?.throwIfAborted();
|
|
1870
2382
|
const complete={...data,assets:results};
|
|
1871
|
-
const placed=await arranger.arrange(layoutData(complete),{signal
|
|
1872
|
-
if(streaming&&completed>publishedCount)publish();
|
|
1873
|
-
}});
|
|
2383
|
+
const placed=await arranger.arrange(layoutData(complete),{signal});
|
|
1874
2384
|
if(versionTheme!==effectiveTheme){pending=true;return;}
|
|
1875
2385
|
signal?.throwIfAborted();
|
|
1876
2386
|
if(streamView&&view!==streamView)streamMoved=true;
|
|
@@ -1883,6 +2393,7 @@ async function applyManifest(data, force = false) {
|
|
|
1883
2393
|
// raster intermediates so the completed world starts at its exact final scale.
|
|
1884
2394
|
if(streaming&&publishedCount)for(const entry of cache.values()){delete entry.bitmap;delete entry.bitmapScale;}
|
|
1885
2395
|
catalog = null;
|
|
2396
|
+
derivedLanding = false;
|
|
1886
2397
|
layout(
|
|
1887
2398
|
manifest,
|
|
1888
2399
|
!first && !!previous &&
|
|
@@ -1894,19 +2405,21 @@ async function applyManifest(data, force = false) {
|
|
|
1894
2405
|
document.title = `${data.label} — Agent Design Gallery`;
|
|
1895
2406
|
if (first || leavingOverlayView) {
|
|
1896
2407
|
const target = entry ? entry.target : link ?? data.selection;
|
|
1897
|
-
if (!fixtureState) restoreSelection(target);
|
|
2408
|
+
if (!fixtureState && !(streaming && (selected || active !== null))) restoreSelection(target);
|
|
1898
2409
|
const saved = data.selection;
|
|
1899
2410
|
const sameSelection = link && saved && (link.path
|
|
1900
2411
|
? link.path === saved.path && link.form === saved.form && link.element?.id === saved.element?.id
|
|
1901
2412
|
: !saved.path && link.group === saved.group);
|
|
1902
2413
|
const reload = performance.getEntriesByType('navigation')[0]?.type === 'reload';
|
|
1903
|
-
if (entry?.view) view=entry.view;
|
|
2414
|
+
if (entry?.view && !streamMoved) view=entry.view;
|
|
1904
2415
|
else if (entry?.target || (link && (onlyFrame || !(reload && sameSelection && data.view)))) {
|
|
1905
2416
|
const target = selectedBox() || currentItem() || groups[active] || world;
|
|
1906
2417
|
frame(target, selected ? 24 : 0);
|
|
1907
2418
|
} else if (leavingOverlayView && previous?.directory === data.directory && previous.scope === data.scope && previous.view) view = previous.view;
|
|
1908
|
-
else if (
|
|
1909
|
-
|
|
2419
|
+
else if (!streamMoved) {
|
|
2420
|
+
if (data.view) view = data.view;
|
|
2421
|
+
else frame(world);
|
|
2422
|
+
}
|
|
1910
2423
|
} else if (groupTitle) {
|
|
1911
2424
|
const index = groups.findIndex(group=>group.title===groupTitle);
|
|
1912
2425
|
active = index < 0 ? null : index;
|
|
@@ -1936,6 +2449,7 @@ async function applyManifest(data, force = false) {
|
|
|
1936
2449
|
initialLink=null;
|
|
1937
2450
|
scopeEntry=null;
|
|
1938
2451
|
selection();
|
|
2452
|
+
if (frameFilter === 'recent') openRecentHistory(data);
|
|
1939
2453
|
if (pendingNavigation) {
|
|
1940
2454
|
const action = pendingNavigation;
|
|
1941
2455
|
pendingNavigation = null;
|
|
@@ -2082,8 +2596,9 @@ async function refresh(force = false) {
|
|
|
2082
2596
|
const query=new URLSearchParams({context:metadataContext(),theme:effectiveTheme,scope:scopeRequest});
|
|
2083
2597
|
if (strictRoute) query.set('strict', '1');
|
|
2084
2598
|
if (onlyFrame) query.set('frame', onlyFrame);
|
|
2085
|
-
if(!manifest)
|
|
2086
|
-
|
|
2599
|
+
if (!manifest) query.set('initial', '1');
|
|
2600
|
+
if (!(frameFilter !== 'all' && (!manifest || derivedLanding)) &&
|
|
2601
|
+
(!manifest || manifest.renderTheme !== effectiveTheme || scopeRequest !== initializedScope)) query.set('metadata', !manifest && !onlyFrame ? 'layout' : '1');
|
|
2087
2602
|
const signal=refreshController.signal, data=await api(`manifest?${query}`,null,false,signal);
|
|
2088
2603
|
signal.throwIfAborted();
|
|
2089
2604
|
data.scope ??= 'all';
|
|
@@ -2109,10 +2624,28 @@ if ((tokenManifest || manifest) && !isUnauthorized()) {
|
|
|
2109
2624
|
const events = new EventSource(keyURL('events'));
|
|
2110
2625
|
const refreshComments = () => commentUI.refresh().catch(err => error(err.message));
|
|
2111
2626
|
events.addEventListener('comments', refreshComments);
|
|
2112
|
-
|
|
2627
|
+
let connectedOnce=false;
|
|
2628
|
+
events.addEventListener('open',()=>{
|
|
2629
|
+
refreshComments();
|
|
2630
|
+
if(connectedOnce)void refresh();
|
|
2631
|
+
connectedOnce=true;
|
|
2632
|
+
});
|
|
2113
2633
|
window.addEventListener('adg-unauthorized', () => events.close(), { once: true });
|
|
2114
|
-
events.onmessage = (e) => {
|
|
2634
|
+
events.onmessage = async (e) => {
|
|
2115
2635
|
const data = JSON.parse(e.data);
|
|
2636
|
+
if (data.changed || data.motionSources) recentFilter.invalidate();
|
|
2637
|
+
if(data.motionSources){
|
|
2638
|
+
if (manifest) {
|
|
2639
|
+
manifest.motionFrames = data.motionFrames;
|
|
2640
|
+
manifest.motionEdges = data.motionEdges;
|
|
2641
|
+
manifest.revision = data.revision;
|
|
2642
|
+
}
|
|
2643
|
+
setMotionProjection(data.motionFrames);
|
|
2644
|
+
if (frameFilter === 'playable') renderFrameView();
|
|
2645
|
+
updateFramePlay();
|
|
2646
|
+
requestDraw();
|
|
2647
|
+
return;
|
|
2648
|
+
}
|
|
2116
2649
|
if (data.error) error(data.error);
|
|
2117
2650
|
else {
|
|
2118
2651
|
void refresh();
|
|
@@ -2138,12 +2671,17 @@ if ((tokenManifest || manifest) && !isUnauthorized()) {
|
|
|
2138
2671
|
document.addEventListener("keydown", (e) => {
|
|
2139
2672
|
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === "f") {
|
|
2140
2673
|
e.preventDefault();
|
|
2141
|
-
$("#search").focus();
|
|
2674
|
+
if (frameFilter === 'all') $("#search").focus();
|
|
2142
2675
|
return;
|
|
2143
2676
|
}
|
|
2144
2677
|
if (e.key !== "Escape" || document.querySelector("dialog[open]")) return;
|
|
2145
2678
|
if (document.querySelector(":popover-open")) return;
|
|
2146
2679
|
if (e.defaultPrevented) return;
|
|
2680
|
+
if (frameFilter !== 'all') {
|
|
2681
|
+
e.preventDefault();
|
|
2682
|
+
setFrameFilter('all');
|
|
2683
|
+
return;
|
|
2684
|
+
}
|
|
2147
2685
|
if (tokenManifest) {
|
|
2148
2686
|
if ($('#search').value) {
|
|
2149
2687
|
e.preventDefault();
|