@dexhq/canvas 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/CHANGELOG.md +34 -0
- package/app/canvas/activity-parts.tsx +50 -6
- package/app/canvas/activity.tsx +2 -3
- package/app/canvas/agent-changes.ts +18 -8
- package/app/canvas/anchoring.ts +13 -3
- package/app/canvas/canvas-context.tsx +6 -2
- package/app/canvas/canvas-input.ts +35 -0
- package/app/canvas/canvas-model.ts +2 -2
- package/app/canvas/canvas-scene.ts +243 -24
- package/app/canvas/canvas-ui.ts +11 -2
- package/app/canvas/canvas.css +86 -3
- package/app/canvas/comments.tsx +66 -29
- package/app/canvas/element-link.ts +135 -0
- package/app/canvas/element-picker.ts +23 -0
- package/app/canvas/export-dialog.tsx +265 -0
- package/app/canvas/flow-canvas.tsx +65 -14
- package/app/canvas/frame-context-menu.tsx +61 -7
- package/app/canvas/frame-node.tsx +10 -11
- package/app/canvas/layout.ts +41 -22
- package/app/canvas/linked-element.tsx +196 -0
- package/app/canvas/live-page.ts +14 -0
- package/app/canvas/mentions.tsx +209 -0
- package/app/canvas/picked-box.tsx +21 -0
- package/app/canvas/removed-views-panel.tsx +4 -4
- package/app/canvas/request-node.tsx +151 -0
- package/app/canvas/review-panel.tsx +8 -3
- package/app/canvas/section-node.tsx +4 -133
- package/app/canvas/spec-margin.tsx +4 -1
- package/app/canvas/teammates-layer.tsx +205 -0
- package/app/canvas/text-layer.tsx +103 -17
- package/app/canvas/tool-cursors.ts +7 -6
- package/app/canvas/tool-icons.tsx +24 -56
- package/app/canvas/typing.ts +12 -0
- package/app/canvas/use-agent-changes.tsx +6 -2
- package/app/canvas/use-canvas-editor.ts +4 -2
- package/app/export/player-model.ts +159 -0
- package/app/export/player.tsx +198 -0
- package/app/export.html +31 -0
- package/app/export.tsx +9 -0
- package/app/frame/announce-refreshes.ts +21 -0
- package/app/frame/start-frame.tsx +50 -0
- package/app/frame/view-loads.ts +161 -0
- package/app/frame/views.ts +13 -49
- package/app/frame.tsx +2 -38
- package/app/i18n/locales/en/messages.po +145 -6
- package/app/i18n/locales/en/messages.ts +1 -1
- package/app/i18n/locales/pseudo/messages.po +144 -5
- package/app/i18n/locales/pseudo/messages.ts +1 -1
- package/app/icons/dex-glyphs.tsx +219 -0
- package/app/icons/glyphs.tsx +76 -80
- package/app/kit/use-flow.ts +2 -1
- package/app/live/canvas-teammates.ts +90 -0
- package/app/live/studio-api.ts +30 -20
- package/app/pages/canvas.tsx +18 -6
- package/app/pages/commands-settings.tsx +1 -1
- package/app/pages/render.tsx +39 -11
- package/app/shell/bell.tsx +15 -5
- package/app/shell/presence.tsx +123 -26
- package/app/shell/thread-list.tsx +25 -8
- package/app/shell/working-on.tsx +35 -3
- package/app/ui/prompt-editor.tsx +39 -11
- package/app/ui/reference.tsx +21 -8
- package/bin/sudio.mjs +1 -1
- package/dist/cli/commands/create.d.mts +5 -5
- package/dist/cli/commands/create.mjs +4 -4
- package/dist/cli/commands/export.d.mts +40 -0
- package/dist/cli/commands/export.mjs +66 -0
- package/dist/cli/commands/init.d.mts +2 -2
- package/dist/cli/commands/upgrade.mjs +1 -1
- package/dist/cli/help.d.mts +1 -1
- package/dist/cli/help.mjs +13 -7
- package/dist/cli/main.d.mts +42 -5
- package/dist/cli/main.mjs +1 -0
- package/dist/config/load.mjs +14 -2
- package/dist/config/project-files.d.mts +5 -0
- package/dist/config/project-files.mjs +10 -1
- package/dist/config/renamed.d.mts +7 -0
- package/dist/config/renamed.mjs +13 -1
- package/dist/content/commands.d.mts +11 -9
- package/dist/content/commands.mjs +22 -16
- package/dist/content/comments-log.mjs +2 -1
- package/dist/content/content.d.mts +11 -3
- package/dist/content/content.mjs +49 -15
- package/dist/content/element-words.d.mts +42 -0
- package/dist/content/element-words.mjs +112 -0
- package/dist/content/hosted-person.d.mts +31 -0
- package/dist/content/hosted-person.mjs +68 -0
- package/dist/content/merge-rules.d.mts +5 -0
- package/dist/content/merge-rules.mjs +17 -1
- package/dist/content/screenshot.mjs +9 -0
- package/dist/content/text-edit.d.mts +24 -14
- package/dist/content/text-edit.mjs +92 -81
- package/dist/content/text-replace.mjs +2 -26
- package/dist/content/thread-module.d.mts +2 -4
- package/dist/content/thread-module.mjs +4 -5
- package/dist/server/agents.d.mts +10 -0
- package/dist/server/agents.mjs +21 -6
- package/dist/server/canvas-presence.d.mts +22 -0
- package/dist/server/canvas-presence.mjs +160 -0
- package/dist/server/command-settings.mjs +1 -1
- package/dist/server/comments/actions.d.mts +0 -8
- package/dist/server/comments/actions.mjs +1 -9
- package/dist/server/comments/routes.mjs +10 -31
- package/dist/server/dev-server.mjs +35 -13
- package/dist/server/export/build.d.mts +15 -0
- package/dist/server/export/build.mjs +220 -0
- package/dist/server/export/page.d.mts +25 -0
- package/dist/server/export/page.mjs +40 -0
- package/dist/server/export/plugin.d.mts +31 -0
- package/dist/server/export/plugin.mjs +69 -0
- package/dist/server/export/run.d.mts +9 -0
- package/dist/server/export/run.mjs +61 -0
- package/dist/server/export/save.d.mts +7 -0
- package/dist/server/export/save.mjs +29 -0
- package/dist/server/hosted.d.mts +8 -0
- package/dist/server/hosted.mjs +78 -0
- package/dist/server/live-mirror.mjs +66 -10
- package/dist/server/live.mjs +28 -1
- package/dist/server/mcp.mjs +2 -0
- package/dist/server/me.d.mts +2 -0
- package/dist/server/me.mjs +8 -2
- package/dist/server/notices.d.mts +1 -1
- package/dist/server/notices.mjs +1 -1
- package/dist/server/own-copies.mjs +1 -1
- package/dist/server/people.d.mts +7 -2
- package/dist/server/people.mjs +6 -2
- package/dist/server/pictures.d.mts +1 -1
- package/dist/server/pictures.mjs +2 -2
- package/dist/server/prebundle.d.mts +32 -0
- package/dist/server/prebundle.mjs +115 -0
- package/dist/server/problems.d.mts +8 -0
- package/dist/server/problems.mjs +13 -0
- package/dist/server/requests.mjs +43 -30
- package/dist/server/source-stamp.d.mts +4 -3
- package/dist/server/source-stamp.mjs +60 -31
- package/dist/server/state.d.mts +19 -10
- package/dist/server/state.mjs +27 -18
- package/dist/server/thread-source.d.mts +8 -0
- package/dist/server/thread-source.mjs +24 -5
- package/dist/server/tools/export.d.mts +5 -0
- package/dist/server/tools/export.mjs +35 -0
- package/dist/server/tools/place-frame.mjs +16 -16
- package/dist/server/tools/thread-list.mjs +1 -1
- package/dist/server/vite.d.mts +9 -4
- package/dist/server/vite.mjs +63 -61
- package/dist/server/welcome.mjs +2 -1
- package/dist/setup/apply.d.mts +4 -0
- package/dist/setup/apply.mjs +5 -4
- package/dist/setup/create.mjs +5 -5
- package/dist/setup/design-system-checks.mjs +1 -6
- package/dist/setup/detect/workspace.d.mts +10 -10
- package/dist/setup/detect/workspace.mjs +10 -12
- package/dist/setup/doctor.d.mts +4 -1
- package/dist/setup/doctor.mjs +7 -5
- package/dist/setup/migrate/dex-folder.d.mts +61 -0
- package/dist/setup/migrate/dex-folder.mjs +544 -0
- package/dist/setup/migrate/files-folder.mjs +1 -1
- package/dist/setup/migrate/guides.mjs +1 -1
- package/dist/setup/migrate/migrations.mjs +4 -0
- package/dist/setup/migrate/setup-files.d.mts +5 -0
- package/dist/setup/migrate/setup-files.mjs +115 -0
- package/dist/setup/migrate/studio-state.d.mts +2 -2
- package/dist/setup/migrate/studio-state.mjs +4 -4
- package/dist/setup/placement.d.mts +1 -1
- package/dist/setup/placement.mjs +5 -4
- package/dist/setup/plan.d.mts +5 -5
- package/dist/setup/plan.mjs +8 -12
- package/dist/setup/project.mjs +1 -1
- package/dist/setup/prompts.d.mts +2 -1
- package/dist/setup/prompts.mjs +4 -3
- package/dist/setup/questions.mjs +3 -2
- package/dist/setup/starters.d.mts +1 -1
- package/dist/setup/starters.mjs +2 -2
- package/dist/setup/write.d.mts +15 -3
- package/dist/setup/write.mjs +23 -3
- package/dist/shared/canvas-core.d.mts +22 -7
- package/dist/shared/canvas-core.mjs +38 -10
- package/dist/shared/comments/routes.d.mts +3 -1
- package/dist/shared/comments/routes.mjs +4 -2
- package/dist/shared/export-core.d.mts +62 -0
- package/dist/shared/export-core.mjs +101 -0
- package/dist/shared/live-core.d.mts +2 -0
- package/dist/shared/live-core.mjs +6 -1
- package/dist/shared/live-presence.d.mts +57 -2
- package/dist/shared/live-presence.mjs +90 -4
- package/dist/shared/page-messages.d.mts +14 -1
- package/dist/shared/page-messages.mjs +30 -3
- package/dist/shared/people-core.d.mts +28 -0
- package/dist/shared/people-core.mjs +27 -1
- package/dist/shared/presence-core.d.mts +2 -0
- package/dist/shared/references-core.d.mts +4 -0
- package/dist/shared/references-core.mjs +12 -4
- package/dist/shared/studio-files.d.mts +9 -0
- package/dist/shared/studio-files.mjs +11 -2
- package/dist/shared/studio-routes.d.mts +13 -1
- package/dist/shared/threads-core.d.mts +27 -4
- package/dist/shared/threads-core.mjs +67 -12
- package/extension/dist/feedback.js +104 -294
- package/extension/dist/manifest.json +1 -1
- package/extension/dist/picker.js +104 -294
- package/package.json +2 -2
- package/src/cli/commands/create.ts +4 -4
- package/src/cli/commands/export.ts +78 -0
- package/src/cli/commands/upgrade.ts +1 -1
- package/src/cli/help.ts +13 -7
- package/src/cli/main.ts +1 -0
- package/src/config/load.ts +26 -2
- package/src/config/project-files.ts +15 -0
- package/src/config/renamed.ts +19 -1
- package/src/content/commands.ts +30 -18
- package/src/content/comments-log.ts +4 -1
- package/src/content/content.ts +64 -16
- package/src/content/element-words.ts +175 -0
- package/src/content/hosted-person.ts +107 -0
- package/src/content/merge-rules.ts +29 -0
- package/src/content/screenshot.ts +14 -0
- package/src/content/text-edit.ts +172 -105
- package/src/content/text-replace.ts +3 -32
- package/src/content/thread-module.ts +2 -4
- package/src/content/trash.ts +1 -1
- package/src/server/agents.ts +48 -17
- package/src/server/canvas-presence.ts +237 -0
- package/src/server/channel.ts +1 -1
- package/src/server/command-settings.ts +1 -1
- package/src/server/comments/actions.ts +0 -19
- package/src/server/comments/routes.ts +9 -54
- package/src/server/dev-server.ts +66 -26
- package/src/server/export/build.ts +310 -0
- package/src/server/export/page.ts +85 -0
- package/src/server/export/plugin.ts +138 -0
- package/src/server/export/run.ts +79 -0
- package/src/server/export/save.ts +38 -0
- package/src/server/hosted.ts +113 -0
- package/src/server/live-mirror.ts +93 -8
- package/src/server/live.ts +46 -1
- package/src/server/machine-update.ts +3 -3
- package/src/server/mcp.ts +2 -0
- package/src/server/me.ts +10 -1
- package/src/server/notices.ts +2 -2
- package/src/server/people.ts +11 -2
- package/src/server/pictures.ts +2 -2
- package/src/server/prebundle.ts +230 -0
- package/src/server/presence.ts +1 -1
- package/src/server/problems.ts +11 -0
- package/src/server/requests.ts +55 -40
- package/src/server/roster.ts +1 -1
- package/src/server/saved.ts +1 -1
- package/src/server/source-stamp.ts +118 -37
- package/src/server/state.ts +53 -31
- package/src/server/thread-source.ts +35 -3
- package/src/server/tools/export.ts +56 -0
- package/src/server/tools/place-frame.ts +23 -15
- package/src/server/tools/thread-list.ts +1 -1
- package/src/server/updates.ts +2 -2
- package/src/server/vite.ts +106 -110
- package/src/server/welcome.ts +3 -1
- package/src/setup/apply.ts +8 -5
- package/src/setup/create.ts +10 -10
- package/src/setup/design-system-checks.ts +1 -6
- package/src/setup/detect/workspace.ts +20 -21
- package/src/setup/doctor.ts +13 -6
- package/src/setup/migrate/dex-folder.ts +842 -0
- package/src/setup/migrate/files-folder.ts +1 -1
- package/src/setup/migrate/guides.ts +3 -1
- package/src/setup/migrate/migrations.ts +8 -2
- package/src/setup/migrate/setup-files.ts +198 -0
- package/src/setup/migrate/studio-state.ts +12 -10
- package/src/setup/own-app.ts +1 -1
- package/src/setup/placement.ts +7 -6
- package/src/setup/plan.ts +13 -18
- package/src/setup/project.ts +2 -2
- package/src/setup/prompts.ts +5 -4
- package/src/setup/questions.ts +6 -3
- package/src/setup/starters.ts +3 -3
- package/src/setup/write.ts +34 -3
- package/src/shared/canvas-core.ts +48 -9
- package/src/shared/comments/routes.ts +3 -1
- package/src/shared/export-core.ts +198 -0
- package/src/shared/live-core.ts +8 -0
- package/src/shared/live-presence.ts +171 -2
- package/src/shared/page-messages.ts +38 -2
- package/src/shared/people-core.ts +44 -0
- package/src/shared/presence-core.ts +2 -0
- package/src/shared/references-core.ts +22 -3
- package/src/shared/studio-files.ts +15 -1
- package/src/shared/studio-routes.ts +11 -1
- package/src/shared/threads-core.ts +132 -10
- package/templates/methods/explore.md +1 -1
- package/templates/methods/handoff.md +1 -1
- package/templates/methods/review.md +2 -1
- package/templates/rules/canvas-frames.md +6 -3
- package/templates/rules/commands.md +1 -0
- package/templates/rules/prototypes.md +1 -1
- package/templates/rules/studio.md +17 -11
- package/templates/skills/comprehend/SKILL.md +56 -0
- package/templates/skills/distill/SKILL.md +172 -0
- package/templates/skills/export-prototype/SKILL.md +35 -0
- package/templates/skills/riff/SKILL.md +21 -0
- package/templates/skills/riff-deep/SKILL.md +40 -0
- package/templates/skills/riff-max/SKILL.md +46 -0
- package/templates/skills/riff-state/SKILL.md +45 -0
- package/templates/skills/riff-up/SKILL.md +38 -0
- package/templates/skills/riff-wide/SKILL.md +40 -0
- package/templates/starters/standalone/README.md +1 -1
- package/templates/starters/turborepo/README.md +2 -2
- package/templates/starters/turborepo/apps/web/src/app.tsx +2 -2
- package/templates/starters/vite/README.md +1 -1
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Where an exported prototype's player is, and where a step takes it: Play's
|
|
2
|
+
// own model (canvas-model.ts), over the sections the export took, so the
|
|
3
|
+
// export steps through rows, stacked frames and sections as Play does.
|
|
4
|
+
|
|
5
|
+
import { frameTitle, VIEWPORTS } from "../../src/shared/canvas-core.ts";
|
|
6
|
+
import type { Section } from "../../src/shared/canvas-file.ts";
|
|
7
|
+
import {
|
|
8
|
+
type ExportData,
|
|
9
|
+
type ExportedFrame,
|
|
10
|
+
exportedPath,
|
|
11
|
+
} from "../../src/shared/export-core.ts";
|
|
12
|
+
import {
|
|
13
|
+
adjacentRow,
|
|
14
|
+
playFrames,
|
|
15
|
+
playSteps,
|
|
16
|
+
stepIndex,
|
|
17
|
+
} from "../canvas/canvas-model";
|
|
18
|
+
|
|
19
|
+
/** A row of a section the player plays, and which of its steps it shows. */
|
|
20
|
+
export interface PlayerAt {
|
|
21
|
+
index: number;
|
|
22
|
+
/** None for the section's first row. */
|
|
23
|
+
row?: string;
|
|
24
|
+
section: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** A row that plays, as the flows menu lists it. */
|
|
28
|
+
export interface PlayerFlow {
|
|
29
|
+
row?: string;
|
|
30
|
+
section: string;
|
|
31
|
+
title: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const sectionsOf = (data: ExportData) => data.sections as Section[];
|
|
35
|
+
|
|
36
|
+
const sectionOf = (data: ExportData, id: string) =>
|
|
37
|
+
sectionsOf(data).find((section) => section.id === id);
|
|
38
|
+
|
|
39
|
+
/** The frames a row plays, in order. */
|
|
40
|
+
export const stepsAt = (
|
|
41
|
+
data: ExportData,
|
|
42
|
+
at: Pick<PlayerAt, "row" | "section">
|
|
43
|
+
): ExportedFrame[] => {
|
|
44
|
+
const section = sectionOf(data, at.section);
|
|
45
|
+
return section
|
|
46
|
+
? playSteps(section, at.row).map(({ frame }) => frame as ExportedFrame)
|
|
47
|
+
: [];
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
/** Every row that plays, section by section. */
|
|
51
|
+
export const flowsOf = (data: ExportData): PlayerFlow[] =>
|
|
52
|
+
sectionsOf(data).flatMap((section, sectionIndex) => {
|
|
53
|
+
const rows = [...new Set(playFrames(section).map((frame) => frame.row))];
|
|
54
|
+
return rows.map((row, rowIndex) => {
|
|
55
|
+
const name = section.title ?? `Flow ${sectionIndex + 1}`;
|
|
56
|
+
const rowTitle =
|
|
57
|
+
section.rows.find((entry) => entry.id === row)?.title ??
|
|
58
|
+
`Row ${rowIndex + 1}`;
|
|
59
|
+
return {
|
|
60
|
+
section: section.id,
|
|
61
|
+
...(row ? { row } : {}),
|
|
62
|
+
title: rows.length > 1 ? `${name} · ${rowTitle}` : name,
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
/** Where the player starts: the first row that plays, at its first step. */
|
|
68
|
+
export const firstAt = (data: ExportData): PlayerAt | undefined => {
|
|
69
|
+
const [flow] = flowsOf(data);
|
|
70
|
+
return flow && { section: flow.section, row: flow.row, index: 0 };
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
/** The frame the player shows. */
|
|
74
|
+
export const frameAt = (
|
|
75
|
+
data: ExportData,
|
|
76
|
+
at: PlayerAt
|
|
77
|
+
): ExportedFrame | undefined => stepsAt(data, at)[at.index];
|
|
78
|
+
|
|
79
|
+
/** The page address of the frame the player shows. */
|
|
80
|
+
export const pathAt = (data: ExportData, at: PlayerAt): string | undefined => {
|
|
81
|
+
const frame = frameAt(data, at);
|
|
82
|
+
return frame && exportedPath(data.slug, frame);
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* One step on, or back: within the row, then on into the next row and
|
|
87
|
+
* section, as Play runs through the canvas. Where it is at either end of
|
|
88
|
+
* everything, it stays.
|
|
89
|
+
*/
|
|
90
|
+
export const step = (
|
|
91
|
+
data: ExportData,
|
|
92
|
+
at: PlayerAt,
|
|
93
|
+
direction: "back" | "next"
|
|
94
|
+
): PlayerAt => {
|
|
95
|
+
const steps = stepsAt(data, at);
|
|
96
|
+
const index = at.index + (direction === "next" ? 1 : -1);
|
|
97
|
+
if (index >= 0 && index < steps.length) {
|
|
98
|
+
return { ...at, index };
|
|
99
|
+
}
|
|
100
|
+
const target = adjacentRow(
|
|
101
|
+
{ sections: sectionsOf(data) },
|
|
102
|
+
{ section: at.section, row: at.row },
|
|
103
|
+
direction
|
|
104
|
+
);
|
|
105
|
+
if (!target) {
|
|
106
|
+
return at;
|
|
107
|
+
}
|
|
108
|
+
const next = { section: target.section.id, row: target.row };
|
|
109
|
+
return {
|
|
110
|
+
...next,
|
|
111
|
+
index: stepIndex(playSteps(target.section, target.row), target.step),
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Where the page's address is in the export, when a view moved there itself
|
|
117
|
+
* (a link): in the row the player is in when it can be, else the first row
|
|
118
|
+
* that shows it.
|
|
119
|
+
*/
|
|
120
|
+
export const locate = (
|
|
121
|
+
data: ExportData,
|
|
122
|
+
path: string,
|
|
123
|
+
current?: PlayerAt
|
|
124
|
+
): PlayerAt | undefined => {
|
|
125
|
+
const flows = flowsOf(data);
|
|
126
|
+
const ordered = current
|
|
127
|
+
? [
|
|
128
|
+
...flows.filter(
|
|
129
|
+
(flow) => flow.section === current.section && flow.row === current.row
|
|
130
|
+
),
|
|
131
|
+
...flows,
|
|
132
|
+
]
|
|
133
|
+
: flows;
|
|
134
|
+
for (const flow of ordered) {
|
|
135
|
+
const index = stepsAt(data, flow).findIndex(
|
|
136
|
+
(frame) => exportedPath(data.slug, frame) === path
|
|
137
|
+
);
|
|
138
|
+
if (index >= 0) {
|
|
139
|
+
return { section: flow.section, row: flow.row, index };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return;
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
/** How wide a frame shows: its own size, else its device's; none for desktop. */
|
|
146
|
+
export const widthOf = (frame: ExportedFrame): number | undefined => {
|
|
147
|
+
if (frame.size) {
|
|
148
|
+
return frame.size.width;
|
|
149
|
+
}
|
|
150
|
+
return frame.viewport && frame.viewport !== "desktop"
|
|
151
|
+
? VIEWPORTS[frame.viewport].width
|
|
152
|
+
: undefined;
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
/** The frame's name, for the player to say where it is. */
|
|
156
|
+
export const titleAt = (data: ExportData, at: PlayerAt): string => {
|
|
157
|
+
const frame = frameAt(data, at);
|
|
158
|
+
return frame ? frameTitle(frame) : "";
|
|
159
|
+
};
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { type CSSProperties, useCallback, useEffect, useState } from "react";
|
|
2
|
+
import { createPortal } from "react-dom";
|
|
3
|
+
import {
|
|
4
|
+
EXPORT_GLOBAL,
|
|
5
|
+
type ExportData,
|
|
6
|
+
} from "../../src/shared/export-core.ts";
|
|
7
|
+
import { hearOwnPage } from "../../src/shared/page-messages.ts";
|
|
8
|
+
import { hashPath } from "../frame/frame-history";
|
|
9
|
+
import {
|
|
10
|
+
firstAt,
|
|
11
|
+
flowsOf,
|
|
12
|
+
frameAt,
|
|
13
|
+
locate,
|
|
14
|
+
type PlayerAt,
|
|
15
|
+
pathAt,
|
|
16
|
+
step,
|
|
17
|
+
stepsAt,
|
|
18
|
+
titleAt,
|
|
19
|
+
widthOf,
|
|
20
|
+
} from "./player-model";
|
|
21
|
+
|
|
22
|
+
// The player of an exported prototype: Play's stepping without Dex around it.
|
|
23
|
+
// It moves the frame by its hash, as Play moves a frame, so links in views
|
|
24
|
+
// work as they do in Dex; a view's useFlow() steps it (tellStudio tells a
|
|
25
|
+
// page on its own itself); and a small bar,
|
|
26
|
+
// drawn in a shadow root so none of its styles reach the design, steps it
|
|
27
|
+
// too and, when the export lets people, switches flows.
|
|
28
|
+
|
|
29
|
+
const readData = (): ExportData | undefined =>
|
|
30
|
+
(window as unknown as Record<string, ExportData | undefined>)[EXPORT_GLOBAL];
|
|
31
|
+
|
|
32
|
+
/** A node in a shadow root on the page, for the bar to render into. */
|
|
33
|
+
const useShadowHost = () => {
|
|
34
|
+
const [host, setHost] = useState<HTMLElement>();
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
const outer = document.createElement("div");
|
|
37
|
+
outer.setAttribute("data-dex-player", "");
|
|
38
|
+
document.body.append(outer);
|
|
39
|
+
const inner = document.createElement("div");
|
|
40
|
+
outer.attachShadow({ mode: "open" }).append(inner);
|
|
41
|
+
setHost(inner);
|
|
42
|
+
return () => outer.remove();
|
|
43
|
+
}, []);
|
|
44
|
+
return host;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const BAR: CSSProperties = {
|
|
48
|
+
position: "fixed",
|
|
49
|
+
bottom: 16,
|
|
50
|
+
left: "50%",
|
|
51
|
+
transform: "translateX(-50%)",
|
|
52
|
+
zIndex: 2_147_483_647,
|
|
53
|
+
display: "flex",
|
|
54
|
+
alignItems: "center",
|
|
55
|
+
gap: 4,
|
|
56
|
+
padding: 4,
|
|
57
|
+
borderRadius: 999,
|
|
58
|
+
background: "rgba(24, 24, 27, 0.9)",
|
|
59
|
+
color: "#fafafa",
|
|
60
|
+
font: "500 13px/1 system-ui, -apple-system, sans-serif",
|
|
61
|
+
boxShadow: "0 4px 16px rgba(0, 0, 0, 0.2)",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const BUTTON: CSSProperties = {
|
|
65
|
+
all: "unset",
|
|
66
|
+
cursor: "pointer",
|
|
67
|
+
width: 28,
|
|
68
|
+
height: 28,
|
|
69
|
+
borderRadius: 999,
|
|
70
|
+
display: "grid",
|
|
71
|
+
placeItems: "center",
|
|
72
|
+
fontSize: 16,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const SELECT: CSSProperties = {
|
|
76
|
+
font: "inherit",
|
|
77
|
+
color: "inherit",
|
|
78
|
+
background: "transparent",
|
|
79
|
+
border: "none",
|
|
80
|
+
maxWidth: 220,
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const flowKey = (at: Pick<PlayerAt, "row" | "section">) =>
|
|
84
|
+
`${at.section}/${at.row ?? ""}`;
|
|
85
|
+
|
|
86
|
+
const Player = ({ data }: { data: ExportData }) => {
|
|
87
|
+
const host = useShadowHost();
|
|
88
|
+
const [at, setAt] = useState<PlayerAt | undefined>(
|
|
89
|
+
() => locate(data, hashPath()) ?? firstAt(data)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// The frame shows where the player is.
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
const path = at && pathAt(data, at);
|
|
95
|
+
if (path && hashPath() !== path) {
|
|
96
|
+
window.location.hash = path;
|
|
97
|
+
}
|
|
98
|
+
}, [data, at]);
|
|
99
|
+
|
|
100
|
+
const move = useCallback(
|
|
101
|
+
(direction: "back" | "next") =>
|
|
102
|
+
setAt((current) => current && step(data, current, direction)),
|
|
103
|
+
[data]
|
|
104
|
+
);
|
|
105
|
+
const follow = useCallback(
|
|
106
|
+
(path: string) =>
|
|
107
|
+
setAt((current) => locate(data, path, current) ?? current),
|
|
108
|
+
[data]
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
// A view's useFlow() steps the player; a view that moved itself (a link)
|
|
112
|
+
// moves the player along with it, as does an address typed in.
|
|
113
|
+
useEffect(
|
|
114
|
+
() =>
|
|
115
|
+
hearOwnPage(window, (message) => {
|
|
116
|
+
if (message.type === "studio:flow") {
|
|
117
|
+
move(message.direction);
|
|
118
|
+
} else if (message.type === "studio:navigate") {
|
|
119
|
+
follow(message.path);
|
|
120
|
+
}
|
|
121
|
+
}),
|
|
122
|
+
[move, follow]
|
|
123
|
+
);
|
|
124
|
+
useEffect(() => {
|
|
125
|
+
const onHash = () => follow(hashPath());
|
|
126
|
+
window.addEventListener("hashchange", onHash);
|
|
127
|
+
return () => window.removeEventListener("hashchange", onHash);
|
|
128
|
+
}, [follow]);
|
|
129
|
+
|
|
130
|
+
// A frame drawn at a device's width shows at that width.
|
|
131
|
+
const frame = at && frameAt(data, at);
|
|
132
|
+
const width = frame && widthOf(frame);
|
|
133
|
+
useEffect(() => {
|
|
134
|
+
const root = document.getElementById("root");
|
|
135
|
+
if (!root) {
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
root.style.maxWidth = width ? `${width}px` : "";
|
|
139
|
+
root.style.margin = width ? "0 auto" : "";
|
|
140
|
+
}, [width]);
|
|
141
|
+
|
|
142
|
+
if (!(host && at)) {
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const steps = stepsAt(data, at);
|
|
146
|
+
const flows = flowsOf(data);
|
|
147
|
+
return createPortal(
|
|
148
|
+
<nav aria-label={data.title} style={BAR}>
|
|
149
|
+
<button
|
|
150
|
+
aria-label="Back"
|
|
151
|
+
onClick={() => move("back")}
|
|
152
|
+
style={BUTTON}
|
|
153
|
+
type="button"
|
|
154
|
+
>
|
|
155
|
+
‹
|
|
156
|
+
</button>
|
|
157
|
+
{data.flows && flows.length > 1 ? (
|
|
158
|
+
<select
|
|
159
|
+
aria-label="Flow"
|
|
160
|
+
onChange={(event) => {
|
|
161
|
+
const flow = flows.find(
|
|
162
|
+
(entry) => flowKey(entry) === event.target.value
|
|
163
|
+
);
|
|
164
|
+
if (flow) {
|
|
165
|
+
setAt({ section: flow.section, row: flow.row, index: 0 });
|
|
166
|
+
}
|
|
167
|
+
}}
|
|
168
|
+
style={SELECT}
|
|
169
|
+
value={flowKey(at)}
|
|
170
|
+
>
|
|
171
|
+
{flows.map((flow) => (
|
|
172
|
+
<option key={flowKey(flow)} value={flowKey(flow)}>
|
|
173
|
+
{flow.title}
|
|
174
|
+
</option>
|
|
175
|
+
))}
|
|
176
|
+
</select>
|
|
177
|
+
) : null}
|
|
178
|
+
<span title={titleAt(data, at)}>
|
|
179
|
+
{at.index + 1} / {steps.length}
|
|
180
|
+
</span>
|
|
181
|
+
<button
|
|
182
|
+
aria-label="Next"
|
|
183
|
+
onClick={() => move("next")}
|
|
184
|
+
style={BUTTON}
|
|
185
|
+
type="button"
|
|
186
|
+
>
|
|
187
|
+
›
|
|
188
|
+
</button>
|
|
189
|
+
</nav>,
|
|
190
|
+
host
|
|
191
|
+
);
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
/** The player, on a page an export made; nothing anywhere else. */
|
|
195
|
+
export const ExportPlayer = () => {
|
|
196
|
+
const [data] = useState(readData);
|
|
197
|
+
return data ? <Player data={data} /> : null;
|
|
198
|
+
};
|
package/app/export.html
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8">
|
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
6
|
+
<meta name="color-scheme" content="light dark">
|
|
7
|
+
<title>Dex</title>
|
|
8
|
+
<script>
|
|
9
|
+
"use strict";
|
|
10
|
+
// Apply the theme before the first paint, so frames do not flash light
|
|
11
|
+
// before switching to dark. Same key as next-themes; index.html too.
|
|
12
|
+
const studioStoredTheme = (() => {
|
|
13
|
+
try {
|
|
14
|
+
return localStorage.getItem("theme");
|
|
15
|
+
} catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
})();
|
|
19
|
+
const studioDark =
|
|
20
|
+
studioStoredTheme === "dark" ||
|
|
21
|
+
((!studioStoredTheme || studioStoredTheme === "system") &&
|
|
22
|
+
matchMedia("(prefers-color-scheme: dark)").matches);
|
|
23
|
+
document.documentElement.classList.toggle("dark", studioDark);
|
|
24
|
+
document.documentElement.style.colorScheme = studioDark ? "dark" : "light";
|
|
25
|
+
</script>
|
|
26
|
+
</head>
|
|
27
|
+
<body>
|
|
28
|
+
<div id="root"></div>
|
|
29
|
+
<script type="module" src="/export.tsx"></script>
|
|
30
|
+
</body>
|
|
31
|
+
</html>
|
package/app/export.tsx
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// An exported prototype (export.html, built by src/server/export/): the frame
|
|
2
|
+
// page, with a player that steps through the exported frames as Play does.
|
|
3
|
+
// It opens from a zip by double-click, so the build makes it one classic
|
|
4
|
+
// script.
|
|
5
|
+
import "@studio-frame.css";
|
|
6
|
+
import { ExportPlayer } from "./export/player";
|
|
7
|
+
import { startFrame } from "./frame/start-frame";
|
|
8
|
+
|
|
9
|
+
startFrame(<ExportPlayer />);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { PAGE_REFRESH } from "../../src/shared/page-messages.ts";
|
|
2
|
+
|
|
3
|
+
/** What @vitejs/plugin-react's refresh runtime adds to a page in development. */
|
|
4
|
+
interface RefreshRuntime {
|
|
5
|
+
/** Calls `hook` in the same task as each refresh, just before it. */
|
|
6
|
+
__registerBeforePerformReactRefresh?: (hook: () => void) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Fires PAGE_REFRESH on the page's document just before each refresh of its
|
|
11
|
+
* view with changed code, so the canvas around it can tell an agent's change
|
|
12
|
+
* from the page's own (app/shell/presence.tsx). A built page has no refresh
|
|
13
|
+
* runtime, and nothing to announce.
|
|
14
|
+
*/
|
|
15
|
+
export const announceRefreshes = (
|
|
16
|
+
win: Window & typeof globalThis & RefreshRuntime
|
|
17
|
+
): void => {
|
|
18
|
+
win.__registerBeforePerformReactRefresh?.(() => {
|
|
19
|
+
win.document.dispatchEvent(new win.Event(PAGE_REFRESH));
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type ReactNode, StrictMode } from "react";
|
|
2
|
+
import { createRoot } from "react-dom/client";
|
|
3
|
+
import { viewAt } from "../../src/shared/prototypes-core.ts";
|
|
4
|
+
import { refuseStrayFileDrops } from "../ui/file-drop";
|
|
5
|
+
import { StudioThemeProvider } from "../ui/theme-provider";
|
|
6
|
+
import { announceRefreshes } from "./announce-refreshes";
|
|
7
|
+
import { FrameApp } from "./frame-app";
|
|
8
|
+
import { hashPath } from "./frame-history";
|
|
9
|
+
import { holdWindowFocus } from "./hold-window-focus";
|
|
10
|
+
import { preloadView } from "./views";
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Show the view the page's hash names, as the frame page (frame.tsx) and an
|
|
14
|
+
* exported prototype (export.tsx) both do; `around` renders beside it.
|
|
15
|
+
*/
|
|
16
|
+
export function startFrame(around?: ReactNode) {
|
|
17
|
+
// Before the view, so its listeners come after this one.
|
|
18
|
+
holdWindowFocus(window);
|
|
19
|
+
// A file dropped on the view where nothing in it takes the file is never
|
|
20
|
+
// opened in place of it, nor of the studio around a live frame. What the
|
|
21
|
+
// view takes, on its own elements or its window, it still takes.
|
|
22
|
+
refuseStrayFileDrops(window);
|
|
23
|
+
// An agent's presence lights its change on the page, and only that: what
|
|
24
|
+
// changes as the view refreshes with new code, not as it animates.
|
|
25
|
+
announceRefreshes(window);
|
|
26
|
+
|
|
27
|
+
const root = document.getElementById("root");
|
|
28
|
+
if (!root) {
|
|
29
|
+
throw new Error("Dex needs a #root element in the page.");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const render = () =>
|
|
33
|
+
createRoot(root).render(
|
|
34
|
+
<StrictMode>
|
|
35
|
+
<StudioThemeProvider>
|
|
36
|
+
<FrameApp />
|
|
37
|
+
{around}
|
|
38
|
+
</StudioThemeProvider>
|
|
39
|
+
</StrictMode>
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
// The view the page opens on is loaded first, so it is there in the first
|
|
43
|
+
// render (see preloadView).
|
|
44
|
+
const first = viewAt(hashPath());
|
|
45
|
+
if (first) {
|
|
46
|
+
preloadView(first.slug, first.view).then(render, render);
|
|
47
|
+
} else {
|
|
48
|
+
render();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import type { ComponentType } from "react";
|
|
2
|
+
import type { FileError } from "../../src/shared/file-errors.ts";
|
|
3
|
+
|
|
4
|
+
// How the frame page loads a view, and loads it again once it failed. A
|
|
5
|
+
// view that failed to load (conflict markers, a file half written, a throw
|
|
6
|
+
// as it loads) is tried again, at a new address, after each change, so
|
|
7
|
+
// fixing the file brings it back without loading the page again.
|
|
8
|
+
//
|
|
9
|
+
// The browser keeps a module it couldn't fetch as failed for as long as the
|
|
10
|
+
// page is open, and that includes the files a view imports: a design-system
|
|
11
|
+
// component, a bundled library, a file of the prototype's. A new address
|
|
12
|
+
// for the view fetches the view again. What it imports is fetched again
|
|
13
|
+
// only at a new address of its own, which Vite gives a file when it changes.
|
|
14
|
+
// So when one of those failed once and hasn't changed since (a library Vite
|
|
15
|
+
// answered 504 for while it bundled again, a connection lost), the view
|
|
16
|
+
// fails at every address. Only a new page fetches that module again.
|
|
17
|
+
//
|
|
18
|
+
// So when a view tried again after a hot update fails to load again, the
|
|
19
|
+
// page asks the server which files it can't read. The server lists a file
|
|
20
|
+
// before it answers for it (src/server/file-errors.ts), so the answer names
|
|
21
|
+
// the file that failed. If that is the view, or a file of its prototype
|
|
22
|
+
// that isn't another view (its data, a part), the view waits for that file
|
|
23
|
+
// to change. Otherwise the page loads again.
|
|
24
|
+
//
|
|
25
|
+
// Only after a hot update: by then Vite has given each changed file its new
|
|
26
|
+
// address. A view tried as a file leaves the server's list can still import
|
|
27
|
+
// that file at its old address. And not when a file leaves the list as the
|
|
28
|
+
// server answers: that file is tried in its own turn. So the page loads
|
|
29
|
+
// again at most once a change, and never as it first loads. A design-system
|
|
30
|
+
// file still half written is on no list: frames stuck on it load again
|
|
31
|
+
// with each change until it is whole.
|
|
32
|
+
|
|
33
|
+
/** What loads a view's module, as import.meta.glob writes it. */
|
|
34
|
+
export type Load = () => Promise<{ default: ComponentType }>;
|
|
35
|
+
|
|
36
|
+
/** What made the page try its failed views again. */
|
|
37
|
+
export type Change = "hot update" | "file left the list";
|
|
38
|
+
|
|
39
|
+
/** A view's prototype and name, matched from the end of its path, wherever it is. */
|
|
40
|
+
export const VIEW_FILE_RE =
|
|
41
|
+
/files\/([^/]+)\/people\/[^/]+\/views\/([^/]+)\.tsx$/;
|
|
42
|
+
|
|
43
|
+
// How each browser says a module couldn't be fetched: Chromium, Firefox,
|
|
44
|
+
// Safari.
|
|
45
|
+
const LOAD_FAILED_RE =
|
|
46
|
+
/dynamically imported module|Importing a module script failed/;
|
|
47
|
+
/** The address a loader Vite wrote imports. */
|
|
48
|
+
const IMPORTED_RE = /import\(\s*["']([^"']+)["']/;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Whether a view failed to load because a module it needs couldn't be
|
|
52
|
+
* fetched, rather than threw as it ran: one that threw runs again at its new
|
|
53
|
+
* address, or once its code changes.
|
|
54
|
+
*/
|
|
55
|
+
export const isLoadFailure = (error: unknown): boolean =>
|
|
56
|
+
error instanceof Error && LOAD_FAILED_RE.test(error.message);
|
|
57
|
+
|
|
58
|
+
export interface ViewLoads {
|
|
59
|
+
/**
|
|
60
|
+
* Takes the server's list of the files it can't read, each time it sends
|
|
61
|
+
* it. True when a file left the list, which may be fixed.
|
|
62
|
+
*/
|
|
63
|
+
hearUnreadable: (list: readonly FileError[]) => boolean;
|
|
64
|
+
/** Loads the view at `path`, at a new address when it is tried again. */
|
|
65
|
+
load: (path: string, load: Load) => ReturnType<Load>;
|
|
66
|
+
/** After a change: the views that failed since the last, to load again. */
|
|
67
|
+
tryAgain: (change: Change) => string[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function viewLoads({
|
|
71
|
+
ask,
|
|
72
|
+
importAt = (address) => import(/* @vite-ignore */ address),
|
|
73
|
+
now = Date.now,
|
|
74
|
+
reload,
|
|
75
|
+
}: {
|
|
76
|
+
/** Asks the server for its list of files it can't read, for `hearUnreadable`. */
|
|
77
|
+
ask: () => void;
|
|
78
|
+
/** Imports a view at a new address. */
|
|
79
|
+
importAt?: (address: string) => ReturnType<Load>;
|
|
80
|
+
now?: () => number;
|
|
81
|
+
/** Loads the page again. */
|
|
82
|
+
reload: () => void;
|
|
83
|
+
}): ViewLoads {
|
|
84
|
+
/** Views that failed to load since the last change, by path. */
|
|
85
|
+
const failed = new Set<string>();
|
|
86
|
+
/** When each view that failed was last tried again, by path. */
|
|
87
|
+
const retried = new Map<string, number>();
|
|
88
|
+
/** Views tried again after a hot update, whose next load decides. */
|
|
89
|
+
const deciding = new Set<string>();
|
|
90
|
+
/** Views that failed to load again after a hot update, until the server says why. */
|
|
91
|
+
const unexplained = new Set<string>();
|
|
92
|
+
/** The files the server can't read now, by path. */
|
|
93
|
+
let unreadable = new Set<string>();
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Whether the server can't read a file the view waits on: the view
|
|
97
|
+
* itself, or a file of its prototype that isn't another view.
|
|
98
|
+
*/
|
|
99
|
+
const waitsOnFile = (path: string): boolean => {
|
|
100
|
+
const [, slug] = VIEW_FILE_RE.exec(path) ?? [];
|
|
101
|
+
return [...unreadable].some(
|
|
102
|
+
(file) =>
|
|
103
|
+
file.startsWith(`files/${slug}/`) &&
|
|
104
|
+
(path.endsWith(file) || !VIEW_FILE_RE.test(file))
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* How to load the view at `path`: as matched, or once tried again, at its
|
|
110
|
+
* address with a new stamp, as Vite's own client loads a changed module.
|
|
111
|
+
* The address is the one the matched loader imports: in development, Vite
|
|
112
|
+
* writes each as `() => import("/@fs/…/views/home.tsx")`.
|
|
113
|
+
*/
|
|
114
|
+
const loaderOf = (path: string, load: Load): Load => {
|
|
115
|
+
const stamp = retried.get(path);
|
|
116
|
+
const [, address] = IMPORTED_RE.exec(String(load)) ?? [];
|
|
117
|
+
if (stamp === undefined || !address) {
|
|
118
|
+
return load;
|
|
119
|
+
}
|
|
120
|
+
const again = `${address}${address.includes("?") ? "&" : "?"}t=${stamp}`;
|
|
121
|
+
return () => importAt(again);
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
hearUnreadable: (list) => {
|
|
126
|
+
const listed = new Set(list.map(({ path }) => path));
|
|
127
|
+
const fileLeft = [...unreadable].some((path) => !listed.has(path));
|
|
128
|
+
unreadable = listed;
|
|
129
|
+
const stuck = [...unexplained].some((path) => !waitsOnFile(path));
|
|
130
|
+
unexplained.clear();
|
|
131
|
+
if (stuck && !fileLeft) {
|
|
132
|
+
reload();
|
|
133
|
+
}
|
|
134
|
+
return fileLeft;
|
|
135
|
+
},
|
|
136
|
+
load: (path, load) => {
|
|
137
|
+
const decides = deciding.delete(path);
|
|
138
|
+
return loaderOf(path, load)().catch((error: unknown) => {
|
|
139
|
+
failed.add(path);
|
|
140
|
+
if (decides && isLoadFailure(error)) {
|
|
141
|
+
unexplained.add(path);
|
|
142
|
+
ask();
|
|
143
|
+
}
|
|
144
|
+
throw error;
|
|
145
|
+
});
|
|
146
|
+
},
|
|
147
|
+
tryAgain: (change) => {
|
|
148
|
+
const paths = [...failed];
|
|
149
|
+
for (const path of paths) {
|
|
150
|
+
retried.set(path, now());
|
|
151
|
+
if (change === "hot update") {
|
|
152
|
+
deciding.add(path);
|
|
153
|
+
} else {
|
|
154
|
+
deciding.delete(path);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
failed.clear();
|
|
158
|
+
return paths;
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
}
|