@1agh/maude 2.0.4 → 2.0.8
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/apps/hub/src/project-transactions/kernel.mjs +10 -1
- package/apps/studio/access/closure.ts +156 -16
- package/apps/studio/access/filters.ts +39 -5
- package/apps/studio/access/known-canvases.ts +24 -1
- package/apps/studio/access/refused-inputs.ts +89 -0
- package/apps/studio/actions/agents.ts +59 -0
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/app.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +13 -0
- package/apps/studio/actions/defs/view.ts +59 -3
- package/apps/studio/actions/keymap.gen.ts +35 -0
- package/apps/studio/actions/menu.ts +2 -0
- package/apps/studio/actions/types.ts +3 -1
- package/apps/studio/actions.manifest.json +148 -1
- package/apps/studio/actions.parity.json +31 -1
- package/apps/studio/annotations/ui/ai-seen.tsx +4 -3
- package/apps/studio/annotations/ui/element-node.tsx +139 -54
- package/apps/studio/annotations/ui/lod.tsx +1 -1
- package/apps/studio/annotations/ui/ride.ts +2 -1
- package/apps/studio/annotations/ui/text-style.ts +1 -1
- package/apps/studio/annotations-context-toolbar.tsx +5 -4
- package/apps/studio/annotations-layer.tsx +4 -15
- package/apps/studio/api.ts +425 -128
- package/apps/studio/artboard-activity-overlay.tsx +4 -4
- package/apps/studio/artboard-ai-copies.tsx +4 -4
- package/apps/studio/artboard-freeze.ts +108 -0
- package/apps/studio/artboard-live-gate.tsx +636 -0
- package/apps/studio/artboard-live.ts +831 -0
- package/apps/studio/artboard-placeholder.ts +197 -0
- package/apps/studio/artboard-still-raster.ts +485 -0
- package/apps/studio/artboard-still-warmup.ts +221 -0
- package/apps/studio/artboard-still.ts +1188 -0
- package/apps/studio/artboard-webgl.ts +669 -0
- package/apps/studio/asset-placeholder.tsx +237 -132
- package/apps/studio/asset-upload-bars.tsx +4 -4
- package/apps/studio/bin/_agent-browser-bin.mjs +8 -0
- package/apps/studio/bin/_agent-browser-safe.mjs +2 -1
- package/apps/studio/bin/_canvas-reasons.mjs +34 -0
- package/apps/studio/bin/_ds-check-live.mjs +37 -0
- package/apps/studio/bin/_ds-check.mjs +4 -1
- package/apps/studio/bin/_ds-prove-judge.mjs +167 -0
- package/apps/studio/bin/_ds-prove-playwright.mjs +183 -105
- package/apps/studio/bin/_import-asset.mjs +2 -1
- package/apps/studio/bin/_perf-probe-open.mjs +364 -0
- package/apps/studio/bin/_perf-probe.mjs +2 -1
- package/apps/studio/bin/_perf-shared.mjs +12 -7
- package/apps/studio/bin/_pw-launch.mjs +26 -1
- package/apps/studio/bin/_studio-verb.mjs +24 -3
- package/apps/studio/bin/_thumb-blank.mjs +70 -0
- package/apps/studio/bin/_thumb-cover.mjs +35 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +89 -12
- package/apps/studio/bin/ds-check.sh +5 -1
- package/apps/studio/bin/perf.sh +30 -1
- package/apps/studio/bin/server-up.sh +7 -2
- package/apps/studio/bin/smoke.sh +19 -0
- package/apps/studio/bridge/dgn-protocol.ts +35 -0
- package/apps/studio/canvas-build-sandbox.ts +69 -13
- package/apps/studio/canvas-camera.ts +90 -0
- package/apps/studio/canvas-comment-mount.tsx +9 -9
- package/apps/studio/canvas-lib.tsx +289 -44
- package/apps/studio/canvas-pages-view.tsx +465 -0
- package/apps/studio/canvas-pages.ts +305 -0
- package/apps/studio/canvas-rows.ts +62 -0
- package/apps/studio/canvas-shell.tsx +62 -16
- package/apps/studio/canvas-theme-icons.tsx +41 -0
- package/apps/studio/canvas-theme-pill.tsx +15 -6
- package/apps/studio/canvas-theme.ts +12 -11
- package/apps/studio/client/app.jsx +7 -0
- package/apps/studio/client/canvas-url.js +36 -1
- package/apps/studio/client/home/HomeAccounts.jsx +262 -0
- package/apps/studio/client/home/Shelves.jsx +4 -3
- package/apps/studio/client/home/home-accounts-model.js +121 -0
- package/apps/studio/client/home/home-api.js +6 -0
- package/apps/studio/client/home/home-app.jsx +141 -40
- package/apps/studio/client/home/home-model.js +172 -6
- package/apps/studio/client/home/home.css +169 -5
- package/apps/studio/client/home/shell-mode.js +8 -1
- package/apps/studio/client/hooks/canvas-origin-probe.js +34 -0
- package/apps/studio/client/hooks/use-action-keys.jsx +3 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +1 -1
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +23 -6
- package/apps/studio/client/hooks/use-photo-and-timeline.jsx +16 -8
- package/apps/studio/client/hooks/use-project-data.jsx +13 -2
- package/apps/studio/client/hooks/use-shell-core.jsx +19 -9
- package/apps/studio/client/index-loader.ts +41 -21
- package/apps/studio/client/inspector/inspector-panel.jsx +35 -14
- package/apps/studio/client/panels/ChatPanel.jsx +27 -20
- package/apps/studio/client/panels/CreateProject.jsx +19 -5
- package/apps/studio/client/panels/caps-cache.js +46 -0
- package/apps/studio/client/shell/viewport.jsx +66 -22
- package/apps/studio/client/tree/tree.jsx +17 -0
- package/apps/studio/client/v2/access/access-client.js +2 -0
- package/apps/studio/client/v2/access/access-host.jsx +12 -1
- package/apps/studio/client/v2/access/trashed-banner.jsx +6 -3
- package/apps/studio/client/v2/ai/Advanced.jsx +12 -0
- package/apps/studio/client/v2/ai/Composer.jsx +27 -10
- package/apps/studio/client/v2/canvases/canvases-panel.jsx +24 -0
- package/apps/studio/client/v2/canvases/use-canvas-index.js +24 -1
- package/apps/studio/client/v2/code/canvas-error-card.jsx +14 -2
- package/apps/studio/client/v2/code/canvas-imports-card.jsx +19 -14
- package/apps/studio/client/v2/code/canvas-imports-words.js +60 -0
- package/apps/studio/client/v2/code/canvas-waiting-card.jsx +59 -5
- package/apps/studio/client/v2/code/canvas-waiting.js +18 -1
- package/apps/studio/client/v2/code/code-bus.js +5 -0
- package/apps/studio/client/v2/code/code-consent-sheet.jsx +87 -0
- package/apps/studio/client/v2/code/code-consent.js +67 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +62 -10
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +314 -5
- package/apps/studio/client/v2/ds/advanced-host.jsx +11 -26
- package/apps/studio/client/v2/ds/ds-refresh.js +161 -0
- package/apps/studio/client/v2/ds/library-host.jsx +45 -45
- package/apps/studio/client/v2/ds/make-host.jsx +13 -15
- package/apps/studio/client/v2/ds/off-system-host.jsx +18 -19
- package/apps/studio/client/v2/ds/review-host.jsx +7 -1
- package/apps/studio/client/v2/ds/truth-host.jsx +15 -17
- package/apps/studio/client/v2/ds/upgrade-host.jsx +26 -10
- package/apps/studio/client/v2/history/branch-actions.js +13 -9
- package/apps/studio/client/v2/history/git-advanced.jsx +8 -1
- package/apps/studio/client/v2/history/git-model.js +3 -1
- package/apps/studio/client/v2/history/git-parts.jsx +16 -1
- package/apps/studio/client/v2/layers/artboard-layers.jsx +24 -5
- package/apps/studio/client/v2/layers/layers-request.js +49 -0
- package/apps/studio/client/v2/left-panel/canvases-pinned.jsx +93 -3
- package/apps/studio/client/v2/left-panel/ds-boards.js +39 -0
- package/apps/studio/client/v2/left-panel/left-panel-model.js +13 -0
- package/apps/studio/client/v2/left-panel/left-panel.css +24 -0
- package/apps/studio/client/v2/presence/faces.jsx +42 -14
- package/apps/studio/client/v2/shell/account-card.jsx +10 -4
- package/apps/studio/client/v2/shell/canvas-crash-guard.js +172 -0
- package/apps/studio/client/v2/shell/canvas-mode.js +17 -1
- package/apps/studio/client/v2/shell/floating-panels.css +37 -1
- package/apps/studio/client/v2/shell/github-signin-host.jsx +42 -0
- package/apps/studio/client/v2/shell/menu-runner.js +11 -0
- package/apps/studio/client/v2/shell/mode-switch.jsx +14 -3
- package/apps/studio/client/v2/shell/opening-skeleton.js +118 -0
- package/apps/studio/client/v2/shell/opening-skeleton.jsx +103 -0
- package/apps/studio/client/v2/shell/pages-pick.js +49 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +203 -0
- package/apps/studio/client/v2/shell/project-account-model.js +182 -0
- package/apps/studio/client/v2/shell/project-menu-model.js +3 -0
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +140 -11
- package/apps/studio/client/v2/shell/share-cluster.css +58 -0
- package/apps/studio/client/v2/shell/share-cluster.jsx +26 -7
- package/apps/studio/client/v2/shell/shell-parity.json +8 -0
- package/apps/studio/client/v2/shell/team-switch.js +94 -0
- package/apps/studio/client/v2/shell/too-heavy-card.jsx +38 -0
- package/apps/studio/client/v2/shell/use-account.js +8 -1
- package/apps/studio/client/v2/shell/use-canvas-mode-lane.js +30 -0
- package/apps/studio/collab/persistence.ts +9 -1
- package/apps/studio/collab/registry.ts +32 -0
- package/apps/studio/collab/room.ts +8 -0
- package/apps/studio/comments-overlay.tsx +12 -11
- package/apps/studio/config-reload-wire.ts +56 -0
- package/apps/studio/config.schema.json +6 -0
- package/apps/studio/context.ts +37 -1
- package/apps/studio/dist/client.bundle.js +1198 -1198
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/ds/board/board.css +6 -0
- package/apps/studio/ds/board/ds-bar.tsx +21 -3
- package/apps/studio/ds/board/specimen.tsx +16 -2
- package/apps/studio/ds/board/template.ts +39 -19
- package/apps/studio/ds/canvas-cli.ts +58 -2
- package/apps/studio/ds/check.ts +26 -1
- package/apps/studio/ds/cli.ts +14 -4
- package/apps/studio/ds/component-list.ts +2 -1
- package/apps/studio/ds/convert.ts +34 -6
- package/apps/studio/ds/default.ts +6 -1
- package/apps/studio/ds/ds-resolver.ts +58 -8
- package/apps/studio/ds/ds-verb.ts +13 -0
- package/apps/studio/ds/engine.ts +3 -1
- package/apps/studio/ds/folder-systems.ts +199 -0
- package/apps/studio/ds/pairing-css.ts +2 -1
- package/apps/studio/ds/post-build.ts +38 -0
- package/apps/studio/ds/rename.ts +10 -3
- package/apps/studio/ds/shell-fallbacks.ts +2 -1
- package/apps/studio/ds/upgrade-apply.ts +27 -5
- package/apps/studio/ds/upgrade-cli.ts +22 -2
- package/apps/studio/ds/upgrade-prove.ts +198 -15
- package/apps/studio/ds/upgrade-stage.ts +10 -3
- package/apps/studio/editing/ai-point-ring.tsx +4 -4
- package/apps/studio/editing/ai-scope-outline.tsx +4 -4
- package/apps/studio/editing/align-bar.tsx +4 -4
- package/apps/studio/editing/anchor-report.ts +3 -2
- package/apps/studio/editing/artboard-handles.tsx +4 -4
- package/apps/studio/editing/corner-dots.tsx +4 -4
- package/apps/studio/editing/crop-mode.tsx +4 -4
- package/apps/studio/editing/drop-chip.tsx +4 -4
- package/apps/studio/editing/empty-report.ts +3 -2
- package/apps/studio/editing/focus-model.tsx +4 -4
- package/apps/studio/editing/gap-bands.tsx +3 -3
- package/apps/studio/editing/hold-rings.tsx +4 -4
- package/apps/studio/editing/lock-badge.tsx +3 -3
- package/apps/studio/editing/long-page.ts +23 -1
- package/apps/studio/editing/nudge.tsx +2 -2
- package/apps/studio/editing/page-activity.ts +4 -3
- package/apps/studio/editing/paste-bar.tsx +4 -4
- package/apps/studio/editing/pen/overlay.tsx +4 -3
- package/apps/studio/editing/place-freely.tsx +3 -3
- package/apps/studio/editing/reorder-slot.tsx +3 -3
- package/apps/studio/editing/selection.tsx +4 -4
- package/apps/studio/editing/size-ghost.tsx +4 -4
- package/apps/studio/editing/tab-order.tsx +4 -4
- package/apps/studio/editing/text-in-place.tsx +4 -4
- package/apps/studio/editing/undo-preview.tsx +3 -3
- package/apps/studio/equal-spacing-handles.tsx +3 -3
- package/apps/studio/frame-clock.ts +89 -0
- package/apps/studio/history/trash.ts +6 -0
- package/apps/studio/home/accounts.ts +87 -0
- package/apps/studio/home/index-reader.ts +24 -2
- package/apps/studio/home/routes.ts +19 -0
- package/apps/studio/http.ts +80 -34
- package/apps/studio/index/ds-usage.ts +4 -1
- package/apps/studio/index-cache.ts +272 -0
- package/apps/studio/inspect-overlay.tsx +4 -3
- package/apps/studio/inspect.ts +7 -2
- package/apps/studio/link-chip-overlay.tsx +4 -3
- package/apps/studio/measure-overlay.tsx +4 -3
- package/apps/studio/present/pointer-dot.tsx +3 -2
- package/apps/studio/present/present-media.ts +6 -2
- package/apps/studio/present/present-stage.tsx +3 -2
- package/apps/studio/preview/preview-camera.tsx +3 -2
- package/apps/studio/routes/ds-convert.ts +18 -0
- package/apps/studio/routes/sync.ts +176 -0
- package/apps/studio/routes/trash.ts +16 -1
- package/apps/studio/safe-zones-overlay.tsx +3 -2
- package/apps/studio/server.ts +8 -10
- package/apps/studio/skip-dirs.ts +103 -47
- package/apps/studio/studio-page-host.ts +70 -0
- package/apps/studio/sync/accepted-cold-start.ts +28 -13
- package/apps/studio/sync/asset-push.ts +146 -23
- package/apps/studio/sync/asset-state.ts +3 -2
- package/apps/studio/sync/code-module-consent.ts +86 -0
- package/apps/studio/sync/file-ledger.ts +24 -0
- package/apps/studio/sync/file-membership.ts +28 -3
- package/apps/studio/sync/file-plane.ts +497 -61
- package/apps/studio/sync/file-pull.ts +304 -33
- package/apps/studio/sync/held-deletes.ts +230 -0
- package/apps/studio/sync/hub-link.ts +1 -2
- package/apps/studio/sync/hubs-config.ts +59 -2
- package/apps/studio/sync/index.ts +405 -163
- package/apps/studio/sync/journal-client.ts +94 -5
- package/apps/studio/sync/pending-deletes.ts +100 -0
- package/apps/studio/sync/projection.ts +77 -12
- package/apps/studio/sync/seed-progress.ts +104 -3
- package/apps/studio/sync/settings.ts +36 -1
- package/apps/studio/sync/status.ts +17 -1
- package/apps/studio/sync/writer-registry.ts +5 -0
- package/apps/studio/text-caret.ts +5 -3
- package/apps/studio/thumbs/service.ts +12 -2
- package/apps/studio/thumbs/validate.ts +7 -0
- package/apps/studio/toolbars/toolbar-rect.ts +3 -2
- package/apps/studio/ui-prefs-migrate.ts +4 -0
- package/apps/studio/use-annotation-resize.tsx +4 -3
- package/apps/studio/use-artboard-drag.tsx +3 -2
- package/apps/studio/use-element-resize.tsx +7 -6
- package/apps/studio/use-grid-track-handles.tsx +5 -4
- package/apps/studio/use-selection-set.tsx +64 -4
- package/apps/studio/use-spacing-handles.tsx +7 -6
- package/apps/studio/video-comp.tsx +75 -39
- package/apps/studio/video-play-overlay.tsx +4 -3
- package/apps/studio/whats-new.json +99 -0
- package/cli/commands/design.mjs +5 -2
- package/cli/commands/hub.mjs +10 -1
- package/cli/lib/bash-guard.mjs +27 -1
- package/cli/lib/design-help.gen.mjs +1 -1
- package/cli/lib/design-hook.mjs +20 -0
- package/cli/lib/design-link.mjs +42 -17
- package/cli/lib/hub-purge.mjs +183 -0
- package/cli/lib/studio-locate.mjs +35 -10
- package/package.json +8 -8
- package/plugins/design/templates/_shell.html +164 -1
|
@@ -23,6 +23,7 @@ import { type RefObject, useEffect, useLayoutEffect, useRef, useSyncExternalStor
|
|
|
23
23
|
import { canvasModeStore, reportPresentPosition } from '../bridge/canvas-mode-store.ts';
|
|
24
24
|
import type { ArtboardRect } from '../canvas-lib.tsx';
|
|
25
25
|
import { togglePlayback } from '../editing/video-play.ts';
|
|
26
|
+
import { frameCafOn, frameRafOn } from '../frame-clock.ts';
|
|
26
27
|
import { resolveBleedMm, resolveMmPx } from '../print/units.ts';
|
|
27
28
|
import {
|
|
28
29
|
type AwarenessChanges,
|
|
@@ -734,8 +735,8 @@ export function usePresentStage(opts: UsePresentStageOptions): void {
|
|
|
734
735
|
readMeta: () =>
|
|
735
736
|
(win as unknown as { __canvas_meta__?: { present?: PresentMeta } }).__canvas_meta__
|
|
736
737
|
?.present,
|
|
737
|
-
raf: (cb) => win
|
|
738
|
-
caf: (id) => win
|
|
738
|
+
raf: (cb) => frameRafOn(win, cb),
|
|
739
|
+
caf: (id) => frameCafOn(win, id),
|
|
739
740
|
now: () => (typeof performance !== 'undefined' ? performance.now() : Date.now()),
|
|
740
741
|
reducedMotion: () => reducedMotion(win),
|
|
741
742
|
liftMs: () => cssMs(win),
|
|
@@ -19,6 +19,7 @@ import { type RefObject, useEffect, useRef, useSyncExternalStore } from 'react';
|
|
|
19
19
|
import { canvasModeStore } from '../bridge/canvas-mode-store.ts';
|
|
20
20
|
import type { CanvasModeV2 } from '../bridge/canvas-modes.ts';
|
|
21
21
|
import { type Insets, visibleRect, ZERO_INSETS } from '../bridge/occlusion.ts';
|
|
22
|
+
import { frameCafOn, frameRafOn } from '../frame-clock.ts';
|
|
22
23
|
|
|
23
24
|
export interface Camera {
|
|
24
25
|
x: number;
|
|
@@ -385,8 +386,8 @@ export function usePreviewCamera<T extends BoardRect>(opts: UsePreviewCameraOpti
|
|
|
385
386
|
fit: (rect) => optsRef.current.fit(rect as T),
|
|
386
387
|
holdOverview: () =>
|
|
387
388
|
optsRef.current.artboards.length > 1 && !win.document.querySelector('[data-cd-link]'),
|
|
388
|
-
raf: (cb) => win
|
|
389
|
-
caf: (id) => win
|
|
389
|
+
raf: (cb) => frameRafOn(win, cb),
|
|
390
|
+
caf: (id) => frameCafOn(win, id),
|
|
390
391
|
now: () => (typeof performance !== 'undefined' ? performance.now() : Date.now()),
|
|
391
392
|
reducedMotion: () => reducedMotion(win),
|
|
392
393
|
durationMs: () => cssTokenMs(win),
|
|
@@ -9,10 +9,27 @@
|
|
|
9
9
|
// Permissions (S10 Q15, V2-1.6 §5.12, rule 12): convert and Restore need Can edit on the WHOLE
|
|
10
10
|
// project; a canvas-scoped grant is refused, the dry run included (it lists every system).
|
|
11
11
|
|
|
12
|
+
import { canvasSlugFromRel } from '../canvas-slug.ts';
|
|
12
13
|
import { createDsConvert, DsConvertError } from '../ds/convert.ts';
|
|
14
|
+
import { DS_CANVAS } from '../ds/engine.ts';
|
|
13
15
|
import type { DsOpAnswer, DsOpContext } from './ds.ts';
|
|
14
16
|
|
|
15
17
|
const invalid = (m: string) => new DsConvertError('ds-convert-usage', m);
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* fix/ds-convert-hooks-cli #7 — Restore moved the Design system canvas to the Trash: say so the way
|
|
21
|
+
* the canvas delete route does. `canvas-deleted` is what sync turns into a project deletion (a
|
|
22
|
+
* tombstone); a bare rename is only "gone from this disk", and the hub brought the canvas straight
|
|
23
|
+
* back (and with it, on the next convert, `ds-convert-exists`).
|
|
24
|
+
*/
|
|
25
|
+
function noteDsCanvasTrashed(c: DsOpContext, system: string): void {
|
|
26
|
+
const s = c.engine.systems().find((x) => x.name === system);
|
|
27
|
+
if (!s || !c.emit) return;
|
|
28
|
+
const rel = `${s.path}/${DS_CANVAS}`;
|
|
29
|
+
const slug = canvasSlugFromRel(rel, '');
|
|
30
|
+
c.emit('canvas-list-update', { action: 'removed', rel, slug });
|
|
31
|
+
c.emit('canvas-deleted', { slug });
|
|
32
|
+
}
|
|
16
33
|
const NAME_RE = /^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/;
|
|
17
34
|
|
|
18
35
|
export async function runConvertOp(
|
|
@@ -33,6 +50,7 @@ export async function runConvertOp(
|
|
|
33
50
|
const r = await cv.restore({ ds: input.restore, by: c.by });
|
|
34
51
|
c.outside?.invalidate(r.system);
|
|
35
52
|
c.emit?.('ds:changed', { system: r.system });
|
|
53
|
+
if (r.moved.includes(DS_CANVAS)) noteDsCanvasTrashed(c, r.system);
|
|
36
54
|
return { status: 200, body: { format: 'maude.ds-result', v: 1, ...r } };
|
|
37
55
|
}
|
|
38
56
|
let systems: string[] | undefined;
|
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
//
|
|
3
3
|
// POST /_api/sync/resync → { ok, sync, resync? } · 409 busy · 200 { ok:false, reason } when there
|
|
4
4
|
// is nothing to restart · 403 { ok:false, reason, detail } at the gates
|
|
5
|
+
// GET /_api/sync/code-consent → { consent: CodeConsentView | null } (fix/207)
|
|
6
|
+
// POST /_api/sync/code-consent/set { allow } → { ok, consent } · 403 window-only / read-only ·
|
|
7
|
+
// 409 not-linked / not-signed-in / cell
|
|
8
|
+
// POST /_api/sync/held-deletes { answer: delete|keep, folder? } → { ok, how, count } · 403
|
|
9
|
+
// window-only / read-only / not-owner · 409 not-linked / nothing-held / busy
|
|
5
10
|
//
|
|
6
11
|
// MAIN ORIGIN ONLY (never `origin: 'canvas'`): resync re-handshakes every document against the
|
|
7
12
|
// person's own hub and re-runs a whole-project comparison — an amplification primitive a canvas must
|
|
@@ -21,6 +26,8 @@
|
|
|
21
26
|
|
|
22
27
|
import { currentAccess, notInScopeResponse } from '../access/request.ts';
|
|
23
28
|
import type { Access } from '../access/scope.ts';
|
|
29
|
+
import type { CodeConsentControl } from '../sync/code-module-consent.ts';
|
|
30
|
+
import type { HeldDeletesControl } from '../sync/held-deletes.ts';
|
|
24
31
|
import type { LinkGate } from '../sync/link-consent.ts';
|
|
25
32
|
import type { ResyncTrace } from '../sync/resync-trace.ts';
|
|
26
33
|
import type { RouteSpec } from './table.ts';
|
|
@@ -29,8 +36,21 @@ import type { RouteSpec } from './table.ts';
|
|
|
29
36
|
export interface SyncControlLike {
|
|
30
37
|
busy?(): boolean;
|
|
31
38
|
restart(): Promise<{ syncing: boolean; canvases?: number; reason?: string; detail?: string }>;
|
|
39
|
+
/** fix/207 — the running runtime: its shared-code consent and its "pass now". */
|
|
40
|
+
current?(): unknown;
|
|
32
41
|
}
|
|
33
42
|
|
|
43
|
+
/** fix/207 — the slice of the running runtime the consent routes use (sync/index.ts SyncRuntime). */
|
|
44
|
+
interface ConsentRuntime {
|
|
45
|
+
codeConsent?(): CodeConsentControl | null;
|
|
46
|
+
heldDeletes?(): HeldDeletesControl | null;
|
|
47
|
+
pullRemoteNow?(): Promise<void>;
|
|
48
|
+
}
|
|
49
|
+
const consentRuntime = (c: SyncControlLike | null | undefined): ConsentRuntime | null => {
|
|
50
|
+
const r = c?.current?.();
|
|
51
|
+
return r && typeof r === 'object' ? (r as ConsentRuntime) : null;
|
|
52
|
+
};
|
|
53
|
+
|
|
34
54
|
export interface SyncRouteDeps {
|
|
35
55
|
/** `ctx.syncControl` — a LIVE view: server.ts attaches it after the table is built. */
|
|
36
56
|
control: () => SyncControlLike | null | undefined;
|
|
@@ -138,6 +158,162 @@ export function createSyncRoutes(deps: SyncRouteDeps): RouteSpec[] {
|
|
|
138
158
|
return json(r.ok ? 200 : r.reason === 'nothing-pending' ? 409 : 500, r);
|
|
139
159
|
},
|
|
140
160
|
},
|
|
161
|
+
// fix/207 — may the linked hub deliver SHARED CODE (`.ts`/`.js` modules) to this Mac? The answer
|
|
162
|
+
// the consent sheet shows (Sync details' held row, the canvas-waiting card). MAIN ORIGIN ONLY: a
|
|
163
|
+
// canvas never learns whether code would reach this Mac. Names the host and the answer, nothing
|
|
164
|
+
// else (no token, no account).
|
|
165
|
+
{
|
|
166
|
+
method: 'GET',
|
|
167
|
+
path: '/_api/sync/code-consent',
|
|
168
|
+
origin: 'main',
|
|
169
|
+
readOnly: 'allowed',
|
|
170
|
+
handle: async () => {
|
|
171
|
+
if (!access().can('read', null)) return notInScopeResponse();
|
|
172
|
+
const consent = consentRuntime(deps.control())?.codeConsent?.() ?? null;
|
|
173
|
+
return json(200, { consent: consent ? consent.view() : null });
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
// fix/207 — the person's answer: "Allow shared code from <host>" / "Stop allowing shared code".
|
|
177
|
+
// Code modules land OUTSIDE the sandboxed canvas origin — the agent and every `maude design *`
|
|
178
|
+
// helper read them (DDR-054) — so this is the same class of act as Connect: the person's, in the
|
|
179
|
+
// Maude window. Gates, in order: the table's CSRF + DNS-rebind (`guardTableRoute`), then
|
|
180
|
+
// `Sec-Fetch-Site: same-origin` (window-only, routes/cloud-move.ts), then Can edit (a signed-in
|
|
181
|
+
// member of that hub; the role is this Mac's stored one), then a signed-in record for the hub
|
|
182
|
+
// the RUNTIME dials (never a body field). Never canvas-safe; refused in a cell (studio-manifest);
|
|
183
|
+
// the agent never reaches it (human 'consent'; cli/lib/bash-guard.mjs human-only).
|
|
184
|
+
{
|
|
185
|
+
method: 'POST',
|
|
186
|
+
path: '/_api/sync/code-consent/set',
|
|
187
|
+
origin: 'main',
|
|
188
|
+
readOnly: 'refused',
|
|
189
|
+
refuse: (reason) => {
|
|
190
|
+
(deps.warn ?? ((m: string) => console.warn(m)))(
|
|
191
|
+
`[sync] ${reason} request to the shared-code consent route — refused.`
|
|
192
|
+
);
|
|
193
|
+
return json(403, {
|
|
194
|
+
ok: false,
|
|
195
|
+
reason,
|
|
196
|
+
detail:
|
|
197
|
+
reason === 'cross-origin'
|
|
198
|
+
? 'Answer this from Maude itself, not from inside a canvas.'
|
|
199
|
+
: "Answer this from the Maude app or this machine's own browser tab.",
|
|
200
|
+
});
|
|
201
|
+
},
|
|
202
|
+
async handle(req) {
|
|
203
|
+
if (req.headers.get('sec-fetch-site') !== 'same-origin') {
|
|
204
|
+
return json(403, {
|
|
205
|
+
ok: false,
|
|
206
|
+
reason: 'window-only',
|
|
207
|
+
detail: 'Answer this in Sync details in the Maude window.',
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
if (!access().can('edit', null)) {
|
|
211
|
+
return json(403, {
|
|
212
|
+
error: 'read-only',
|
|
213
|
+
reason: 'not-allowed',
|
|
214
|
+
message: 'Ask the owner to change this.',
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
let body: unknown = null;
|
|
218
|
+
try {
|
|
219
|
+
body = await req.json();
|
|
220
|
+
} catch {
|
|
221
|
+
body = null;
|
|
222
|
+
}
|
|
223
|
+
const allow = (body as { allow?: unknown } | null)?.allow;
|
|
224
|
+
if (typeof allow !== 'boolean') {
|
|
225
|
+
return json(400, { ok: false, reason: 'bad-request', detail: 'Say yes or no.' });
|
|
226
|
+
}
|
|
227
|
+
const runtime = consentRuntime(deps.control());
|
|
228
|
+
const consent = runtime?.codeConsent?.() ?? null;
|
|
229
|
+
if (!consent) {
|
|
230
|
+
return json(409, {
|
|
231
|
+
ok: false,
|
|
232
|
+
reason: 'not-linked',
|
|
233
|
+
detail: 'This project isn’t syncing with a hub right now.',
|
|
234
|
+
});
|
|
235
|
+
}
|
|
236
|
+
const r = consent.set(allow);
|
|
237
|
+
if (!r.ok) {
|
|
238
|
+
return json(409, {
|
|
239
|
+
ok: false,
|
|
240
|
+
reason: r.reason,
|
|
241
|
+
detail:
|
|
242
|
+
r.reason === 'cell'
|
|
243
|
+
? 'Shared code is always allowed on the project’s own server.'
|
|
244
|
+
: 'Sign in to this project’s hub first.',
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
// Held rows are admitted on the very next pass — start it now rather than in 20 s.
|
|
248
|
+
if (r.changed && allow) void runtime?.pullRemoteNow?.().catch(() => {});
|
|
249
|
+
return json(200, { ok: true, consent: r.view });
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
// Issue #207 (7b) — the answer to "Deleted on this Mac, held": `{ answer: 'delete' | 'keep',
|
|
253
|
+
// folder? }`. Delete sends the held deletes as one confirmed batch (the hub's door, or the owner's
|
|
254
|
+
// confirmed purge past its budget — sync/held-deletes.ts); Keep leaves them on the hub. The same
|
|
255
|
+
// class of act as the shared-code answer: the person's, in the Maude window (window-only, Can edit;
|
|
256
|
+
// never canvas-safe; refused in a cell; human 'hub-link').
|
|
257
|
+
{
|
|
258
|
+
method: 'POST',
|
|
259
|
+
path: '/_api/sync/held-deletes',
|
|
260
|
+
origin: 'main',
|
|
261
|
+
readOnly: 'refused',
|
|
262
|
+
refuse: (reason) => {
|
|
263
|
+
(deps.warn ?? ((m: string) => console.warn(m)))(
|
|
264
|
+
`[sync] ${reason} request to the held-deletes route — refused.`
|
|
265
|
+
);
|
|
266
|
+
return json(403, {
|
|
267
|
+
ok: false,
|
|
268
|
+
reason,
|
|
269
|
+
detail:
|
|
270
|
+
reason === 'cross-origin'
|
|
271
|
+
? 'Answer this from Maude itself, not from inside a canvas.'
|
|
272
|
+
: "Answer this from the Maude app or this machine's own browser tab.",
|
|
273
|
+
});
|
|
274
|
+
},
|
|
275
|
+
async handle(req) {
|
|
276
|
+
if (req.headers.get('sec-fetch-site') !== 'same-origin') {
|
|
277
|
+
return json(403, {
|
|
278
|
+
ok: false,
|
|
279
|
+
reason: 'window-only',
|
|
280
|
+
detail: 'Answer this in Sync details in the Maude window.',
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
if (!access().can('edit', null)) {
|
|
284
|
+
return json(403, {
|
|
285
|
+
error: 'read-only',
|
|
286
|
+
reason: 'not-allowed',
|
|
287
|
+
message: 'Ask the owner to change this.',
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
let body: unknown = null;
|
|
291
|
+
try {
|
|
292
|
+
body = await req.json();
|
|
293
|
+
} catch {
|
|
294
|
+
body = null;
|
|
295
|
+
}
|
|
296
|
+
const answer = (body as { answer?: unknown } | null)?.answer;
|
|
297
|
+
const folder = (body as { folder?: unknown } | null)?.folder ?? null;
|
|
298
|
+
if (
|
|
299
|
+
(answer !== 'delete' && answer !== 'keep') ||
|
|
300
|
+
(folder !== null && (typeof folder !== 'string' || folder.length > 1024))
|
|
301
|
+
) {
|
|
302
|
+
return json(400, { ok: false, reason: 'bad-request', detail: 'Say delete or keep.' });
|
|
303
|
+
}
|
|
304
|
+
const control = consentRuntime(deps.control())?.heldDeletes?.() ?? null;
|
|
305
|
+
if (!control) {
|
|
306
|
+
return json(409, {
|
|
307
|
+
ok: false,
|
|
308
|
+
reason: 'not-linked',
|
|
309
|
+
detail: 'This project isn’t syncing with a hub right now.',
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
const r = await control.answer(answer, folder as string | null);
|
|
313
|
+
if (r.ok) return json(200, r);
|
|
314
|
+
return json(r.reason === 'not-owner' ? 403 : 409, r);
|
|
315
|
+
},
|
|
316
|
+
},
|
|
141
317
|
{
|
|
142
318
|
method: 'POST',
|
|
143
319
|
path: '/_api/sync/resync',
|
|
@@ -276,10 +276,25 @@ export function createTrashRoutes(deps: TrashRouteDeps): RouteSpec[] {
|
|
|
276
276
|
if (!runtime?.acceptedTrash) return null;
|
|
277
277
|
const listing = await runtime.acceptedTrash().catch(() => undefined);
|
|
278
278
|
if (!listing) return listing;
|
|
279
|
-
|
|
279
|
+
const items = visibleTrash(
|
|
280
280
|
deriveTrash(listing, { readSource: deps.readSource, now: deps.now?.() }),
|
|
281
281
|
access
|
|
282
282
|
);
|
|
283
|
+
// 2.0.5: which canvas items sit at the path of a LIVE canvas (the same test the write stop uses) —
|
|
284
|
+
// they are older copies, never "the canvas you have open, moved to the trash".
|
|
285
|
+
const linkDocs = (
|
|
286
|
+
runtime as {
|
|
287
|
+
acceptedLinkDocs?(): Promise<{ path: string | null; retired: boolean }[] | null>;
|
|
288
|
+
}
|
|
289
|
+
).acceptedLinkDocs;
|
|
290
|
+
const docs = linkDocs ? await linkDocs.call(runtime).catch(() => null) : null;
|
|
291
|
+
if (!docs) return items;
|
|
292
|
+
const live = new Set(
|
|
293
|
+
docs.filter((d) => !d.retired && d.path).map((d) => canvasStemOf(d.path as string))
|
|
294
|
+
);
|
|
295
|
+
return items.map((i) =>
|
|
296
|
+
i.kind === 'canvas' ? { ...i, liveAtPath: live.has(canvasStemOf(i.path)) } : i
|
|
297
|
+
);
|
|
283
298
|
}
|
|
284
299
|
|
|
285
300
|
return [
|
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
21
|
import { type ReactNode, useEffect, useMemo, useState } from 'react';
|
|
22
|
+
import { frameCaf, frameRaf } from './frame-clock.ts';
|
|
22
23
|
|
|
23
24
|
import {
|
|
24
25
|
type BandRect,
|
|
@@ -156,7 +157,7 @@ function useUnderFlags(artboardId: string | undefined, bands: BandRect[], w: num
|
|
|
156
157
|
);
|
|
157
158
|
};
|
|
158
159
|
const schedule = () => {
|
|
159
|
-
if (!frame) frame =
|
|
160
|
+
if (!frame) frame = frameRaf(run);
|
|
160
161
|
};
|
|
161
162
|
schedule();
|
|
162
163
|
const body = document.querySelector(`[data-dc-screen="${escapeId(artboardId)}"]`);
|
|
@@ -166,7 +167,7 @@ function useUnderFlags(artboardId: string | undefined, bands: BandRect[], w: num
|
|
|
166
167
|
mo.observe(body, { subtree: true, childList: true, characterData: true, attributes: true });
|
|
167
168
|
}
|
|
168
169
|
return () => {
|
|
169
|
-
if (frame)
|
|
170
|
+
if (frame) frameCaf(frame);
|
|
170
171
|
mo?.disconnect();
|
|
171
172
|
};
|
|
172
173
|
}, [artboardId, bands, w]);
|
package/apps/studio/server.ts
CHANGED
|
@@ -49,7 +49,8 @@ import { type AiActivityEntry, createAiActivity } from './collab/ai-activity.ts'
|
|
|
49
49
|
import { createGitLifecycle } from './collab/git-lifecycle.ts';
|
|
50
50
|
import { personHoldsOf } from './collab/holds.ts';
|
|
51
51
|
import { createCollab } from './collab/index.ts';
|
|
52
|
-
import {
|
|
52
|
+
import { wireConfigReload } from './config-reload-wire.ts';
|
|
53
|
+
import { createContext } from './context.ts';
|
|
53
54
|
import { installLogRing } from './debug-bundle.ts';
|
|
54
55
|
import { initDiagnostics, registerStatus, stopDiagnostics } from './diagnostics/store.ts';
|
|
55
56
|
import { parseEmbedOrigins } from './embed-origins.ts';
|
|
@@ -1127,18 +1128,15 @@ const canvasListWatch = createCanvasListWatch(ctx);
|
|
|
1127
1128
|
// canvasListWatch's set-diff emit `canvas-list-update` for canvases the new
|
|
1128
1129
|
// groups uncover, and tell shells to refetch /_config.
|
|
1129
1130
|
// RCA: .ai/logs/rca/issue-ds-scaffold-files-not-in-filetree-stale-config.md
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
configReloadTimer = setTimeout(() => {
|
|
1136
|
-
configReloadTimer = null;
|
|
1137
|
-
if (!reloadConfig(ctx)) return;
|
|
1131
|
+
// A cell child has no watcher, so a peer's config.json write arrives as
|
|
1132
|
+
// `fs:any` only (journal heal) — wireConfigReload listens on both events
|
|
1133
|
+
// behind one debounce (#205, config-reload-wire.ts).
|
|
1134
|
+
wireConfigReload(ctx, {
|
|
1135
|
+
onReloaded: () => {
|
|
1138
1136
|
console.log(' config.json changed — reloaded live.');
|
|
1139
1137
|
void canvasListWatch.refresh();
|
|
1140
1138
|
ctx.bus.emit('config-updated');
|
|
1141
|
-
},
|
|
1139
|
+
},
|
|
1142
1140
|
});
|
|
1143
1141
|
|
|
1144
1142
|
// Phase 9 Task 4 — bidirectional sync agent. No-op when the project isn't
|
package/apps/studio/skip-dirs.ts
CHANGED
|
@@ -79,44 +79,92 @@ export function isCanvasRelInGroups(
|
|
|
79
79
|
return isInCanvasGroup(groups, rel) && !isComponentRel(rel, componentDir);
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
// 2.0.7 (#207) — the scan writes into a UTF-16 buffer and every look-back reads that buffer, so a
|
|
83
|
+
// scan is linear in the source. It used to grow a string with `+=` and test the whole string at
|
|
84
|
+
// every literal (a `$`-anchored regex, `out[k]` on a rope): quadratic, ~3 s for one 1 MB canvas, and
|
|
85
|
+
// `/_index-data` ran it for every file every canvas reaches. Same output, character for character
|
|
86
|
+
// (pinned against the old implementation in test/import-scan-linear.test.ts).
|
|
87
|
+
const WS_RE = /\s/;
|
|
88
|
+
/** `/\s/` on one UTF-16 code unit (`undefined` = before the start). */
|
|
89
|
+
function isWs(c: number | undefined): boolean {
|
|
90
|
+
if (c === undefined) return false;
|
|
91
|
+
if (c < 128) return c === 32 || (c >= 9 && c <= 13);
|
|
92
|
+
return WS_RE.test(String.fromCharCode(c));
|
|
93
|
+
}
|
|
94
|
+
/** `/[\w$]/` on one UTF-16 code unit. */
|
|
95
|
+
function isIdent(c: number | undefined): boolean {
|
|
96
|
+
if (c === undefined) return false;
|
|
97
|
+
return (
|
|
98
|
+
(c >= 48 && c <= 57) || (c >= 65 && c <= 90) || (c >= 97 && c <= 122) || c === 95 || c === 36
|
|
99
|
+
);
|
|
100
|
+
}
|
|
84
101
|
|
|
85
|
-
/** `
|
|
86
|
-
function wordEndsAt(
|
|
87
|
-
if (k < w.length
|
|
88
|
-
|
|
102
|
+
/** `buf[..k)` ends in the whole word `w`; `ci` compares ASCII letters case-insensitively. */
|
|
103
|
+
function wordEndsAt(buf: Uint16Array, k: number, w: string, ci = false): boolean {
|
|
104
|
+
if (k < w.length) return false;
|
|
105
|
+
const at = k - w.length;
|
|
106
|
+
for (let t = 0; t < w.length; t++) {
|
|
107
|
+
let c = buf[at + t] as number;
|
|
108
|
+
if (ci && c >= 65 && c <= 90) c += 32;
|
|
109
|
+
if (c !== w.charCodeAt(t)) return false;
|
|
110
|
+
}
|
|
111
|
+
return !isIdent(at > 0 ? buf[at - 1] : undefined);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** Skip whitespace backwards from `k` (exclusive) in `buf`. */
|
|
115
|
+
function skipWsBack(buf: Uint16Array, k: number): number {
|
|
116
|
+
while (k > 0 && isWs(buf[k - 1])) k--;
|
|
117
|
+
return k;
|
|
89
118
|
}
|
|
90
119
|
|
|
91
120
|
/**
|
|
92
|
-
* gate-b-c4l — does the text written so far end in a module-specifier lead: `from`,
|
|
93
|
-
* `import(` or `require(`, with ANY whitespace between (a comment is already blanked to
|
|
94
|
-
* there, whatever its length)? c4e looked back a fixed 32 characters, and a longer comment
|
|
95
|
-
* `from` and the string hid the import.
|
|
121
|
+
* gate-b-c4l — does the text written so far (`buf[..len)`) end in a module-specifier lead: `from`,
|
|
122
|
+
* `import`, `import(` or `require(`, with ANY whitespace between (a comment is already blanked to
|
|
123
|
+
* spaces there, whatever its length)? c4e looked back a fixed 32 characters, and a longer comment
|
|
124
|
+
* between `from` and the string hid the import.
|
|
96
125
|
*/
|
|
97
|
-
function endsInSpecifierLead(
|
|
98
|
-
let k =
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
k
|
|
102
|
-
while (k > 0 && isWs(out[k - 1])) k--;
|
|
103
|
-
return wordEndsAt(out, k, 'import') || wordEndsAt(out, k, 'require');
|
|
126
|
+
function endsInSpecifierLead(buf: Uint16Array, len: number): boolean {
|
|
127
|
+
let k = skipWsBack(buf, len);
|
|
128
|
+
if (k > 0 && buf[k - 1] === 40 /* ( */) {
|
|
129
|
+
k = skipWsBack(buf, k - 1);
|
|
130
|
+
return wordEndsAt(buf, k, 'import') || wordEndsAt(buf, k, 'require');
|
|
104
131
|
}
|
|
105
|
-
return wordEndsAt(
|
|
132
|
+
return wordEndsAt(buf, k, 'from') || wordEndsAt(buf, k, 'import');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/** Does `buf[..len)` end in `import(` / `require(` (whitespace allowed)? */
|
|
136
|
+
function endsInCallLead(buf: Uint16Array, len: number): boolean {
|
|
137
|
+
let k = skipWsBack(buf, len);
|
|
138
|
+
if (k === 0 || buf[k - 1] !== 40 /* ( */) return false;
|
|
139
|
+
k = skipWsBack(buf, k - 1);
|
|
140
|
+
return wordEndsAt(buf, k, 'import') || wordEndsAt(buf, k, 'require');
|
|
106
141
|
}
|
|
107
142
|
|
|
108
|
-
/**
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
143
|
+
/**
|
|
144
|
+
* CSS: does `buf[..len)` end in the lead of `@import url("./x.css")` — `/@import\s+url\(\s*$/i`
|
|
145
|
+
* (ASCII case-insensitive: without the `u` flag a non-ASCII letter never folds to an ASCII one)?
|
|
146
|
+
*/
|
|
147
|
+
function endsInCssImportUrlLead(buf: Uint16Array, len: number): boolean {
|
|
148
|
+
let k = skipWsBack(buf, len);
|
|
149
|
+
if (k === 0 || buf[k - 1] !== 40 /* ( */) return false;
|
|
113
150
|
k--;
|
|
114
|
-
|
|
115
|
-
|
|
151
|
+
// `url` right before `(`; the `\s+` before it keeps the word check below honest
|
|
152
|
+
if (!wordEndsAt(buf, k, 'url', true)) return false;
|
|
153
|
+
k -= 3;
|
|
154
|
+
const before = k;
|
|
155
|
+
k = skipWsBack(buf, k);
|
|
156
|
+
if (k === before) return false; // `\s+`
|
|
157
|
+
return wordEndsAt(buf, k, 'import', true) && k >= 7 && buf[k - 7] === 64; /* @ */
|
|
116
158
|
}
|
|
117
159
|
|
|
118
|
-
/**
|
|
119
|
-
|
|
160
|
+
/** `buf[..len)` as a string, in chunks (`fromCharCode.apply` caps its argument count). */
|
|
161
|
+
function bufText(buf: Uint16Array, len: number): string {
|
|
162
|
+
const CHUNK = 8192;
|
|
163
|
+
const parts: string[] = [];
|
|
164
|
+
for (let a = 0; a < len; a += CHUNK)
|
|
165
|
+
parts.push(String.fromCharCode.apply(null, buf.subarray(a, Math.min(len, a + CHUNK)) as never));
|
|
166
|
+
return parts.join('');
|
|
167
|
+
}
|
|
120
168
|
|
|
121
169
|
/**
|
|
122
170
|
* gate-b-c4e — `source` as the import scanner may read it: comments blanked and every string
|
|
@@ -130,54 +178,62 @@ const CSS_IMPORT_URL_LEAD_RE = /@import\s+url\(\s*$/i;
|
|
|
130
178
|
* spaces, newlines kept), so an offset in the result is an offset in `source`.
|
|
131
179
|
*/
|
|
132
180
|
export function importScanText(source: string, css = false): string {
|
|
133
|
-
let out = '';
|
|
134
|
-
let i = 0;
|
|
135
181
|
const n = source.length;
|
|
182
|
+
const buf = new Uint16Array(n);
|
|
183
|
+
let len = 0;
|
|
184
|
+
/** blank `source[a..b)` into the buffer: every code unit but `\n` becomes a space */
|
|
185
|
+
const blank = (a: number, b: number) => {
|
|
186
|
+
for (let k = a; k < b; k++) buf[len++] = source.charCodeAt(k) === 10 ? 10 : 32;
|
|
187
|
+
};
|
|
188
|
+
let i = 0;
|
|
136
189
|
while (i < n) {
|
|
137
|
-
const c = source
|
|
138
|
-
const next = source
|
|
139
|
-
if (c ===
|
|
190
|
+
const c = source.charCodeAt(i);
|
|
191
|
+
const next = i + 1 < n ? source.charCodeAt(i + 1) : -1;
|
|
192
|
+
if (c === 47 /* / */ && next === 42 /* * */) {
|
|
140
193
|
const end = source.indexOf('*/', i + 2);
|
|
141
194
|
const stop = end === -1 ? n : end + 2;
|
|
142
|
-
|
|
195
|
+
blank(i, stop);
|
|
143
196
|
i = stop;
|
|
144
197
|
continue;
|
|
145
198
|
}
|
|
146
|
-
if (!css && c ===
|
|
199
|
+
if (!css && c === 47 && next === 47) {
|
|
147
200
|
const end = source.indexOf('\n', i);
|
|
148
201
|
const stop = end === -1 ? n : end;
|
|
149
|
-
|
|
202
|
+
for (let k = i; k < stop; k++) buf[len++] = 32;
|
|
150
203
|
i = stop;
|
|
151
204
|
continue;
|
|
152
205
|
}
|
|
153
|
-
if (c ===
|
|
206
|
+
if (c === 34 /* " */ || c === 39 /* ' */ || (!css && c === 96) /* ` */) {
|
|
154
207
|
let j = i + 1;
|
|
155
208
|
while (j < n) {
|
|
156
|
-
const d = source
|
|
157
|
-
if (d ===
|
|
209
|
+
const d = source.charCodeAt(j);
|
|
210
|
+
if (d === 92 /* \ */) {
|
|
158
211
|
j += 2;
|
|
159
212
|
continue;
|
|
160
213
|
}
|
|
161
214
|
if (d === c) break;
|
|
162
|
-
if (d ===
|
|
215
|
+
if (d === 10 && c !== 96) break; // an unterminated string ends with its line
|
|
163
216
|
j++;
|
|
164
217
|
}
|
|
165
218
|
const stop = Math.min(j, n);
|
|
166
|
-
const
|
|
219
|
+
const closed = j < n && source.charCodeAt(j) === c;
|
|
167
220
|
// gate-b-c4m (defender L-B) — a template with no substitution after `import(` / `require(`
|
|
168
221
|
// is a module specifier Bun resolves at build time; in CSS, the string of `@import url("…")`.
|
|
169
222
|
const keep =
|
|
170
|
-
c ===
|
|
171
|
-
? !
|
|
172
|
-
: endsInSpecifierLead(
|
|
173
|
-
|
|
174
|
-
|
|
223
|
+
c === 96
|
|
224
|
+
? !source.slice(i + 1, stop).includes('${') && endsInCallLead(buf, len)
|
|
225
|
+
: endsInSpecifierLead(buf, len) || (css && endsInCssImportUrlLead(buf, len));
|
|
226
|
+
buf[len++] = c;
|
|
227
|
+
if (keep) for (let k = i + 1; k < stop; k++) buf[len++] = source.charCodeAt(k);
|
|
228
|
+
else blank(i + 1, stop);
|
|
229
|
+
if (closed) buf[len++] = c;
|
|
230
|
+
i = closed ? j + 1 : stop;
|
|
175
231
|
continue;
|
|
176
232
|
}
|
|
177
|
-
|
|
233
|
+
buf[len++] = c;
|
|
178
234
|
i++;
|
|
179
235
|
}
|
|
180
|
-
return
|
|
236
|
+
return bufText(buf, len);
|
|
181
237
|
}
|
|
182
238
|
|
|
183
239
|
/**
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// 2.0.7 — the studio page and its canvas frames must be on ONE site.
|
|
2
|
+
//
|
|
3
|
+
// Each canvas frame proves which canvas it was opened for with its `fc` capability (gate-b-c4,
|
|
4
|
+
// access/frame.ts). The shell puts `fc` on the frame's own URL; everything the canvas loads by
|
|
5
|
+
// itself (an `<img>`, a CSS `url()`, a font) carries it only in the Referer. WebKit — Safari and
|
|
6
|
+
// Playwright's WebKit — cuts the Referer of EVERY request a frame makes down to the bare origin when
|
|
7
|
+
// that frame is on another site than the top page, whatever Referrer-Policy the page sets. So with
|
|
8
|
+
// the studio on `127.0.0.1:<port>` and the canvas origin on `localhost:<port>` (two sites), every
|
|
9
|
+
// picture lost its capability and got the frame-less answer (403): "Picture not found".
|
|
10
|
+
//
|
|
11
|
+
// The desktop app, `maude design browse` and every printed address use `localhost`, the same site
|
|
12
|
+
// as the canvas origin, so they never hit this; a cell and a self-hosted workspace must already put
|
|
13
|
+
// the canvas domain on the studio's site (its session cookie needs it). What is left is a person
|
|
14
|
+
// (or a harness) typing `127.0.0.1` or `[::1]`. Their browser's own top-level navigation to the
|
|
15
|
+
// studio page is sent to the same port on `localhost`, where the frames are same-site again.
|
|
16
|
+
//
|
|
17
|
+
// Rejected: a Referrer-Policy (WebKit ignores it here, measured); a cookie (blocked in a
|
|
18
|
+
// third-party frame); `fc` in a path prefix (absolute asset paths drop it); answering frame-less
|
|
19
|
+
// media (widens C4). The capability check itself is unchanged.
|
|
20
|
+
|
|
21
|
+
/** A browser's own top-level navigation: Fetch Metadata says `navigate` + `document`. */
|
|
22
|
+
function isTopLevelNavigation(req: Request): boolean {
|
|
23
|
+
return (
|
|
24
|
+
req.method === 'GET' &&
|
|
25
|
+
req.headers.get('sec-fetch-mode') === 'navigate' &&
|
|
26
|
+
req.headers.get('sec-fetch-dest') === 'document'
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface StudioPageHostOpts {
|
|
31
|
+
/** `ctx.canvasOrigin` — the interactive canvas origin, when the split is on. */
|
|
32
|
+
canvasOrigin?: string;
|
|
33
|
+
/** `ctx.mainOrigin` — the space-separated origins this studio page is served on. */
|
|
34
|
+
mainOrigin?: string;
|
|
35
|
+
/** A cell / workspace: public names come from configuration, never rewritten here. */
|
|
36
|
+
workspace: boolean;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A 307 to the same port on `localhost` for a browser's top-level navigation to the studio page
|
|
41
|
+
* on a loopback IP literal, when the canvas frames live on `localhost`; otherwise null (serve the
|
|
42
|
+
* page). The port must be the one this studio is bound on (`mainOrigin`), so the redirect never
|
|
43
|
+
* names a listener that is not ours, and the target host is fixed — nothing from the request but
|
|
44
|
+
* the port (checked), the path and the query is carried over.
|
|
45
|
+
*/
|
|
46
|
+
export function studioPageHostRedirect(req: Request, opts: StudioPageHostOpts): Response | null {
|
|
47
|
+
if (opts.workspace || !opts.canvasOrigin || !opts.mainOrigin) return null;
|
|
48
|
+
if (!isTopLevelNavigation(req)) return null;
|
|
49
|
+
let canvasHost: string;
|
|
50
|
+
let url: URL;
|
|
51
|
+
try {
|
|
52
|
+
canvasHost = new URL(opts.canvasOrigin).hostname;
|
|
53
|
+
url = new URL(req.url);
|
|
54
|
+
} catch {
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
if (canvasHost !== 'localhost') return null;
|
|
58
|
+
if (url.protocol !== 'http:') return null;
|
|
59
|
+
if (url.hostname !== '127.0.0.1' && url.hostname !== '[::1]') return null;
|
|
60
|
+
// The port this studio is bound on: `mainOrigin` lists it on BOTH loopback names (server.ts);
|
|
61
|
+
// an extra shell origin naming only `localhost:<other>` never qualifies.
|
|
62
|
+
const target = `http://localhost:${url.port}`;
|
|
63
|
+
const ours = opts.mainOrigin.split(/\s+/);
|
|
64
|
+
if (!url.port || !ours.includes(target) || !ours.includes(`http://127.0.0.1:${url.port}`))
|
|
65
|
+
return null;
|
|
66
|
+
return new Response(null, {
|
|
67
|
+
status: 307,
|
|
68
|
+
headers: { Location: `${target}${url.pathname}${url.search}`, 'Cache-Control': 'no-store' },
|
|
69
|
+
});
|
|
70
|
+
}
|