spell 0.8.7 → 0.8.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/README-epics.md +96 -36
- package/app/package.json +25 -1
- package/dist/cli/publish/PublishedPackage.d.ts +2 -1
- package/dist/cli/publish/PublishedPackage.js +6 -3
- package/dist/cli/publish/ScratchInstall.d.ts +14 -3
- package/dist/cli/publish/ScratchInstall.js +69 -8
- package/dist/epic/cli/EpicProgram.js +7 -1
- package/dist/epic/cli/epicGroups.js +2 -1
- package/dist/epic/command/BaseBranch.d.ts +35 -0
- package/dist/epic/command/BaseBranch.js +58 -0
- package/dist/epic/command/EpicCheckout.d.ts +1 -1
- package/dist/epic/command/EpicCheckout.js +4 -4
- package/dist/epic/command/EpicGuide.js +3 -2
- package/dist/epic/command/EpicTools.d.ts +5 -0
- package/dist/epic/command/EpicTools.js +14 -3
- package/dist/epic/command/MainMerge.d.ts +26 -15
- package/dist/epic/command/MainMerge.js +60 -16
- package/dist/epic/command/RepoInit.d.ts +116 -8
- package/dist/epic/command/RepoInit.js +308 -13
- package/dist/epic/command/Requests.d.ts +1 -0
- package/dist/epic/command/Requests.js +6 -1
- package/dist/epic/command/SessionMoves.js +2 -1
- package/dist/epic/command/SkillsCheck.js +3 -2
- package/dist/epic/command/Stock.js +3 -1
- package/dist/epic/command/TurnEnd.d.ts +1 -1
- package/dist/epic/command/TurnEnd.js +4 -3
- package/dist/epic/command/Worktrees.d.ts +18 -3
- package/dist/epic/command/Worktrees.js +38 -7
- package/dist/epic/command/command.types.d.ts +3 -0
- package/dist/epic/components/__pack/epics.entry.js +43 -43
- package/dist/epic/components/__pack/epics.pack.js +36 -12794
- package/dist/epic/config/EngineFiles.mjs +60 -0
- package/dist/epic/config/EpicConfig.d.ts +12 -2
- package/dist/epic/config/EpicConfig.js +9 -1
- package/dist/epic/config/GitHub.d.ts +41 -1
- package/dist/epic/config/GitHub.js +75 -3
- package/dist/epic/config/LayeredSettings.js +3 -2
- package/dist/epic/server/EpicServer.d.ts +1 -1
- package/dist/epic/server/EpicServer.js +26 -12
- package/dist/epic/tool/InboxPoller.mjs +2 -1
- package/dist/epic/tool/MigrateCommands.js +6 -8
- package/dist/epic/tool/PlanDocFiles.js +3 -2
- package/dist/epic/tool/ServedFolders.d.ts +1 -1
- package/dist/epic/tool/ServedFolders.js +4 -4
- package/dist/epic/tools/PageInboxes.js +3 -3
- package/dist/epic/tools/_assets/commands.entry.js +149 -68
- package/dist/epic/tools/_assets/commands.js +20 -2073
- package/dist/epic/tools/_assets/core-reference.entry.js +244 -124
- package/dist/epic/tools/_assets/core-reference.js +20 -2142
- package/dist/epic/tools/_assets/emoji/cldr/0.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/a.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/b.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/c.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/d.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/e.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/f.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/g.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/h.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/i.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/j.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/k.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/l.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/m.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/n.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/o.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/p.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/r.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/s.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/t.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/u.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/v.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/w.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/x.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/y.js +2 -2
- package/dist/epic/tools/_assets/emoji/cldr/z.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/0.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/a.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/b.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/c.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/d.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/e.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/f.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/g.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/h.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/i.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/j.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/k.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/l.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/m.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/n.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/o.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/p.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/q.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/r.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/s.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/t.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/u.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/v.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/w.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/x.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/y.js +2 -2
- package/dist/epic/tools/_assets/emoji/fomantic/z.js +2 -2
- package/dist/epic/tools/_assets/goals-live.js +318 -210
- package/dist/epic/tools/_assets/highlight.min.js +5764 -5269
- package/dist/epic/tools/_assets/lazy/code-engine.js +5 -1270
- package/dist/epic/tools/_assets/lazy/markdown-engine.js +67 -1513
- package/dist/epic/tools/_assets/lazy/markdown-sanitizer.js +3 -753
- package/dist/epic/tools/_assets/spell-comments.entry.js +282 -159
- package/dist/epic/tools/_assets/spell-comments.js +24 -3716
- package/dist/epic/tools/_assets/spell-doc-comments.js +1243 -816
- package/dist/epic/tools/_assets/spell-doc-helpers.js +298 -165
- package/dist/epic/tools/_assets/spell-doc-runtime.js +2760 -1415
- package/dist/epic/tools/_assets/spell-doc-toolbar.js +396 -227
- package/dist/epic/tools/_assets/spell-syntax.entry.js +505 -285
- package/dist/epic/tools/_assets/spell-syntax.js +22 -2916
- package/dist/epic/tools/_assets/spell-ui-sources.js +102 -60
- package/dist/epic/tools/_assets/spell-ui.entry.js +108 -40
- package/dist/epic/tools/_assets/spell-ui.js +3131 -46465
- package/dist/epic/tools/pages.d.ts +5 -6
- package/dist/epic/tools/pages.js +7 -6
- package/dist/epic/window.mjs +2 -3
- package/dist/ui/components/ui-accordion/UIAccordion.d.ts +1 -0
- package/dist/ui/components/ui-ad/UIAd.d.ts +1 -0
- package/dist/ui/components/ui-breadcrumbs/UIBreadcrumb.d.ts +1 -0
- package/dist/ui/components/ui-breadcrumbs/UIBreadcrumbs.d.ts +1 -0
- package/dist/ui/components/ui-button/UIButton.d.ts +8 -3
- package/dist/ui/components/ui-button/UIButton.fallback.d.ts +8 -3
- package/dist/ui/components/ui-button/UIButtons.d.ts +1 -0
- package/dist/ui/components/ui-button/UIOr.d.ts +1 -0
- package/dist/ui/components/ui-calendar/UICalendar.d.ts +6 -0
- package/dist/ui/components/ui-calendar/UICalendar.fallback.d.ts +6 -0
- package/dist/ui/components/ui-card/UICards.d.ts +31 -0
- package/dist/ui/components/ui-checkbox/UICheckbox.d.ts +7 -0
- package/dist/ui/components/ui-checkbox/UICheckbox.fallback.d.ts +7 -0
- package/dist/ui/components/ui-comment/UIComment.d.ts +1 -0
- package/dist/ui/components/ui-comment/UIComments.d.ts +1 -0
- package/dist/ui/components/ui-components/UIComponents.d.ts +1 -0
- package/dist/ui/components/ui-dimmer/UIDimmer.d.ts +1 -0
- package/dist/ui/components/ui-divider/UIDivider.d.ts +2 -0
- package/dist/ui/components/ui-dropdown/UIDropdown.d.ts +6 -0
- package/dist/ui/components/ui-dropdown/UIDropdown.fallback.d.ts +6 -0
- package/dist/ui/components/ui-embed/UIEmbed.d.ts +1 -0
- package/dist/ui/components/ui-emoji/UIEmoji.d.ts +1 -0
- package/dist/ui/components/ui-feed/UIFeed.d.ts +1 -0
- package/dist/ui/components/ui-feed/UIFeedEvent.d.ts +1 -0
- package/dist/ui/components/ui-flag/UIFlag.d.ts +1 -0
- package/dist/ui/components/ui-flyout/UIFlyout.d.ts +1 -0
- package/dist/ui/components/ui-form/UIFields.d.ts +1 -0
- package/dist/ui/components/ui-form/UIRepeat.d.ts +1 -0
- package/dist/ui/components/ui-grid/UIColumn.d.ts +1 -0
- package/dist/ui/components/ui-grid/UIGrid.d.ts +1 -0
- package/dist/ui/components/ui-grid/UIRow.d.ts +1 -0
- package/dist/ui/components/ui-icon/UIIcon.d.ts +3 -2
- package/dist/ui/components/ui-icon/UIIcons.d.ts +1 -0
- package/dist/ui/components/ui-icon-picker/UIIconPicker.d.ts +6 -0
- package/dist/ui/components/ui-icon-picker/UIIconPicker.fallback.d.ts +6 -0
- package/dist/ui/components/ui-image/UIImages.d.ts +1 -0
- package/dist/ui/components/ui-include/UIInclude.d.ts +1 -0
- package/dist/ui/components/ui-input/UIInput.fallback.d.ts +9 -2
- package/dist/ui/components/ui-items/UIItems.d.ts +1 -0
- package/dist/ui/components/ui-keys/UIKeys.d.ts +1 -0
- package/dist/ui/components/ui-label/UILabel.d.ts +2 -0
- package/dist/ui/components/ui-label/UILabels.d.ts +1 -0
- package/dist/ui/components/ui-list/UIList.d.ts +2 -0
- package/dist/ui/components/ui-loader/UILoader.d.ts +1 -0
- package/dist/ui/components/ui-message/UIMessage.d.ts +2 -0
- package/dist/ui/components/ui-modal/UIModal.d.ts +1 -0
- package/dist/ui/components/ui-nag/UINag.d.ts +1 -0
- package/dist/ui/components/ui-page/UIPage.d.ts +15 -0
- package/dist/ui/components/ui-page/UIPage.es.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIActions.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIAuthor.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIAvatar.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIContent.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIDate.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIDescription.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIDetail.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIExtra.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIHeader.d.ts +3 -1
- package/dist/ui/components/ui-parts/UIMeta.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIParts.types.d.ts +15 -1
- package/dist/ui/components/ui-parts/UISummary.d.ts +1 -0
- package/dist/ui/components/ui-parts/UITitle.d.ts +1 -0
- package/dist/ui/components/ui-parts/UIValue.d.ts +1 -0
- package/dist/ui/components/ui-placeholder/UIPlaceholder.d.ts +1 -0
- package/dist/ui/components/ui-placeholder/UIPlaceholderHeader.d.ts +1 -0
- package/dist/ui/components/ui-placeholder/UIPlaceholderImage.d.ts +1 -0
- package/dist/ui/components/ui-placeholder/UIPlaceholderLine.d.ts +1 -0
- package/dist/ui/components/ui-placeholder/UIPlaceholderParagraph.d.ts +1 -0
- package/dist/ui/components/ui-progress/UIProgress.d.ts +2 -0
- package/dist/ui/components/ui-quote/UIQuote.d.ts +1 -0
- package/dist/ui/components/ui-rail/UIRail.d.ts +1 -0
- package/dist/ui/components/ui-rating/UIRating.d.ts +6 -0
- package/dist/ui/components/ui-rating/UIRating.fallback.d.ts +6 -0
- package/dist/ui/components/ui-reveal/UIReveal.d.ts +1 -0
- package/dist/ui/components/ui-search/UISearch.fallback.d.ts +13 -1
- package/dist/ui/components/ui-section/UISections.d.ts +1 -0
- package/dist/ui/components/ui-segment/UISegment.d.ts +2 -0
- package/dist/ui/components/ui-segment/UISegments.d.ts +1 -0
- package/dist/ui/components/ui-select/UISelect.d.ts +6 -0
- package/dist/ui/components/ui-select/UISelect.fallback.d.ts +6 -0
- package/dist/ui/components/ui-shape/UISide.d.ts +4 -0
- package/dist/ui/components/ui-sidebar/UIPushable.d.ts +1 -0
- package/dist/ui/components/ui-sidebar/UIPusher.d.ts +1 -0
- package/dist/ui/components/ui-sidebar/UISidebar.d.ts +1 -0
- package/dist/ui/components/ui-sides/UISides.d.ts +6 -0
- package/dist/ui/components/ui-sides/UISides.fallback.d.ts +6 -0
- package/dist/ui/components/ui-slider/UISlider.d.ts +7 -0
- package/dist/ui/components/ui-slider/UISlider.fallback.d.ts +7 -0
- package/dist/ui/components/ui-space/UISpace.d.ts +1 -0
- package/dist/ui/components/ui-statistic/UIStatistic.d.ts +1 -0
- package/dist/ui/components/ui-statistic/UIStatistics.d.ts +1 -0
- package/dist/ui/components/ui-step/UIStep.d.ts +1 -0
- package/dist/ui/components/ui-step/UISteps.d.ts +1 -0
- package/dist/ui/components/ui-table/UICell.d.ts +1 -0
- package/dist/ui/components/ui-terms/UITerm.d.ts +1 -0
- package/dist/ui/components/ui-terms/UITerms.d.ts +1 -0
- package/dist/ui/components/ui-theme-editor/UIColorChip.d.ts +1 -0
- package/dist/ui/components/ui-theme-editor/UIThemeToken.d.ts +1 -0
- package/dist/ui/components/ui-toast/UIToast.d.ts +1 -0
- package/dist/ui/components/ui-toc/UIToc.d.ts +1 -0
- package/dist/ui/components/ui-transition/UITransition.d.ts +1 -0
- package/dist/ui/components/ui-video/UIAudio.d.ts +1 -0
- package/dist/ui/components/ui-video/UIVideo.d.ts +1 -0
- package/dist/ui/components/ui-visibility/UIVisibility.d.ts +1 -0
- package/dist/ui/components/ui-zoom/UIZoom.d.ts +1 -0
- package/dist/util/spell/constants.js +1 -1
- package/epic/.claude-plugin/plugin.json +1 -1
- package/epic/.codex-plugin/plugin.json +1 -1
- package/epic/hooks/handoff.mjs +4 -3
- package/epic/hooks/worktree.mjs +22 -3
- package/epic/package.json +41 -2
- package/epic/skills/details/SKILL.md +2 -1
- package/epic/skills/epic/SKILL.md +7 -1
- package/epic/skills/epic/guide.md +4 -0
- package/epic/skills/isolate/SKILL.md +35 -0
- package/epic/src/AGENTS.md +6 -2
- package/epic/templates/durable.html +1 -1
- package/epic/vscode/package.json +1 -1
- package/epic/vscode/spell-epic.vsix +0 -0
- package/package.json +1 -1
- package/parser/package.json +1 -1
- package/ui/package.json +15 -2
|
@@ -1,100 +1,142 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/*
|
|
2
|
+
* Saving for the docs' source elements (`<ui-include>`, `<ui-code>`, `<ui-markdown>`): `UI.sources.saver`, through
|
|
3
|
+
* the page server's `SPELL_SERVER.saveFile()` (`spell/server`'s live client).
|
|
4
|
+
* Bundled into `spell-ui.js` by `scripts/bundle-spell-ui.js`; side effects only.
|
|
5
|
+
* - Only on a page the page server served (`window.SPELL_SERVER`): from `file://` there's no server, so no saver,
|
|
6
|
+
* and `save()` fails with `no-saver`.
|
|
7
|
+
* - `saveFile` is added by the live client (`/api/server/live.js`, deferred), so it's read when a save happens.
|
|
8
|
+
* - Failures are thrown as `{ kind, message, status }` (a classic script can't import `SourceError`): `conflict`
|
|
9
|
+
* for 409 (the file changed since it was loaded: reload, then save again), `save` otherwise.
|
|
10
|
+
* - And `UI.sources.inlineSaver`, on a page the page server may save (`SPELL_SERVER.writable`): an element's OWN
|
|
11
|
+
* text (a `<ui-markdown>` written in the page) written back into the page's file (epic `epic-engine` P60).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { E, UI } from "spell/ui/core"
|
|
3
15
|
|
|
4
|
-
// src/tools/_assets/spell-ui-sources.js
|
|
5
|
-
import { E, UI } from "spell/ui/core";
|
|
6
16
|
if (window.SPELL_SERVER) {
|
|
7
17
|
void UI.load().then((ui) => {
|
|
8
|
-
ui.sources.saver ??= saveThroughPageServer
|
|
9
|
-
if (window.SPELL_SERVER.writable) ui.sources.inlineSaver ??= saveInlineThroughPageServer
|
|
10
|
-
})
|
|
18
|
+
ui.sources.saver ??= saveThroughPageServer
|
|
19
|
+
if (window.SPELL_SERVER.writable) ui.sources.inlineSaver ??= saveInlineThroughPageServer
|
|
20
|
+
})
|
|
11
21
|
}
|
|
22
|
+
|
|
23
|
+
/** `UI.sources.saver`: `{ url, text, etag, fragment }` to `SPELL_SERVER.saveFile()`, by URL path. */
|
|
12
24
|
async function saveThroughPageServer({ url, text, etag, fragment }) {
|
|
13
|
-
const saveFile = window.SPELL_SERVER?.saveFile
|
|
14
|
-
if (!saveFile) throw { kind: "no-saver", message: "the page server's live client isn't loaded" }
|
|
15
|
-
const answer = await saveFile({ path: decodeURIComponent(new URL(url).pathname), text, etag, fragment })
|
|
16
|
-
if (answer.ok) return { etag: answer.etag }
|
|
17
|
-
const kind = answer.status === 409 || answer.status === 412 ? "conflict" : "save"
|
|
18
|
-
throw { kind, message: answer.error ?? `the server said ${answer.status}`, status: answer.status }
|
|
25
|
+
const saveFile = window.SPELL_SERVER?.saveFile
|
|
26
|
+
if (!saveFile) throw { kind: "no-saver", message: "the page server's live client isn't loaded" }
|
|
27
|
+
const answer = await saveFile({ path: decodeURIComponent(new URL(url).pathname), text, etag, fragment })
|
|
28
|
+
if (answer.ok) return { etag: answer.etag }
|
|
29
|
+
const kind = answer.status === 409 || answer.status === 412 ? "conflict" : "save"
|
|
30
|
+
throw { kind, message: answer.error ?? `the server said ${answer.status}`, status: answer.status }
|
|
19
31
|
}
|
|
20
|
-
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `UI.sources.inlineSaver`: `element`'s own text, `before` as the page has it, swapped for `text` in the page's file.
|
|
35
|
+
* - The nearest element with an `id` around it is read fresh from the file (`SPELL_SERVER.readElement()`), its script
|
|
36
|
+
* holding `before` found (`InlineBlocks`), its text swapped, indented as it was, its tags untouched (r52's one-line
|
|
37
|
+
* tags hold), and the element written back (`editPage()`, `shown`: the page shows it already).
|
|
38
|
+
* - The page's own script then holds the saved text too, so the page and the file agree, and a later live update
|
|
39
|
+
* patches from there.
|
|
40
|
+
* - The file changed between the read and the write: read again, once.
|
|
41
|
+
* - throws `{ kind, message, status }`: `conflict` when `before` isn't in the file (it changed there), `save` when
|
|
42
|
+
* there's no element with an id the file has, `no-saver` without the live client
|
|
43
|
+
*/
|
|
21
44
|
async function saveInlineThroughPageServer({ element, before, text }) {
|
|
22
|
-
const server = window.SPELL_SERVER
|
|
45
|
+
const server = window.SPELL_SERVER
|
|
23
46
|
if (!server?.readElement || !server.editPage)
|
|
24
|
-
throw { kind: "no-saver", message: "the page server's live client isn't loaded" }
|
|
25
|
-
const script = InlineBlocks.scriptOf(element)
|
|
26
|
-
if (!script) throw { kind: "save", message: `<${element.localName}>'s text isn't in a script, so it can't be saved` }
|
|
47
|
+
throw { kind: "no-saver", message: "the page server's live client isn't loaded" }
|
|
48
|
+
const script = InlineBlocks.scriptOf(element)
|
|
49
|
+
if (!script) throw { kind: "save", message: `<${element.localName}>'s text isn't in a script, so it can't be saved` }
|
|
27
50
|
for (let holder = element.parentElement?.closest("[id]"); holder; holder = holder.parentElement?.closest("[id]")) {
|
|
28
51
|
for (let tries = 0; tries < 2; tries++) {
|
|
29
|
-
const read = await server.readElement({ id: holder.id })
|
|
30
|
-
|
|
31
|
-
if (
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
const
|
|
52
|
+
const read = await server.readElement({ id: holder.id })
|
|
53
|
+
// an id the runtime gave it, not the file's: the next one out
|
|
54
|
+
if (read.status === 404) break
|
|
55
|
+
if (!read.ok) throw { kind: "save", message: read.error ?? `the server said ${read.status}`, status: read.status }
|
|
56
|
+
const block = InlineBlocks.find(read.html, before, InlineBlocks.ordinalOf(element, holder))
|
|
57
|
+
if (!block) throw { kind: "conflict", message: "this text changed in the file since the page showed it: reload" }
|
|
58
|
+
const inner = InlineBlocks.reindented(block.inner, text)
|
|
59
|
+
const html = read.html.slice(0, block.start) + inner + read.html.slice(block.end)
|
|
60
|
+
const answer = await server.editPage({ id: holder.id, html, etag: read.etag, shown: true })
|
|
37
61
|
if (answer.ok) {
|
|
38
|
-
script.text = inner
|
|
39
|
-
return { etag: answer.etag }
|
|
62
|
+
script.text = inner
|
|
63
|
+
return { etag: answer.etag }
|
|
40
64
|
}
|
|
41
|
-
const isStale = answer.status === 409 || answer.status === 412
|
|
65
|
+
const isStale = answer.status === 409 || answer.status === 412
|
|
42
66
|
if (!isStale || tries)
|
|
43
|
-
throw { kind: isStale ? "conflict" : "save", message: answer.error ?? `the server said ${answer.status}` }
|
|
67
|
+
throw { kind: isStale ? "conflict" : "save", message: answer.error ?? `the server said ${answer.status}` }
|
|
44
68
|
}
|
|
45
69
|
}
|
|
46
|
-
throw { kind: "save", message: `no element around <${element.localName}> has an id the page's file has` }
|
|
70
|
+
throw { kind: "save", message: `no element around <${element.localName}> has an id the page's file has` }
|
|
47
71
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
72
|
+
|
|
73
|
+
/****************
|
|
74
|
+
* ### `InlineBlocks`
|
|
75
|
+
* The text of a `<script type="text/...">` written in a page, in the page's file: found by what it says, and swapped
|
|
76
|
+
* keeping its indent.
|
|
77
|
+
* - Pure, but `ordinalOf()` (the live DOM)
|
|
78
|
+
****************/
|
|
79
|
+
class InlineBlocks {
|
|
53
80
|
/** `element`'s own text holder: its `<script type="text/...">` child. */
|
|
54
81
|
static scriptOf(element) {
|
|
55
|
-
return [...element.children].find((child) => child.localName === "script" && child.type.startsWith("text/"))
|
|
82
|
+
return [...element.children].find((child) => child.localName === "script" && child.type.startsWith("text/"))
|
|
56
83
|
}
|
|
84
|
+
|
|
57
85
|
/**
|
|
58
86
|
* Which of the blocks saying the same as `element`'s it is, in `holder`: `0` for the first.
|
|
59
87
|
* - So two blocks with the same text are told apart by their order, as the file has them.
|
|
60
88
|
*/
|
|
61
89
|
static ordinalOf(element, holder) {
|
|
62
|
-
const text =
|
|
90
|
+
const text = InlineBlocks.scriptOf(element)?.text
|
|
63
91
|
const same = [...holder.querySelectorAll(element.localName)].filter(
|
|
64
|
-
(each) =>
|
|
65
|
-
)
|
|
66
|
-
return Math.max(0, same.indexOf(element))
|
|
92
|
+
(each) => InlineBlocks.scriptOf(each)?.text === text
|
|
93
|
+
)
|
|
94
|
+
return Math.max(0, same.indexOf(element))
|
|
67
95
|
}
|
|
96
|
+
|
|
68
97
|
/**
|
|
69
98
|
* The `ordinal`th script in `html` whose text, dedented, is `before`: where its text starts and ends, and its text;
|
|
70
99
|
* `undefined` for none.
|
|
71
100
|
*/
|
|
72
101
|
static find(html, before, ordinal) {
|
|
73
|
-
const blocks = []
|
|
102
|
+
const blocks = []
|
|
74
103
|
for (const match of html.matchAll(SCRIPT_BLOCK)) {
|
|
75
|
-
const inner = match[2]
|
|
76
|
-
if (E.LoadableComponent.dedent(inner) !== before) continue
|
|
77
|
-
const start = match.index + match[1].length
|
|
78
|
-
blocks.push({ start, end: start + inner.length, inner })
|
|
104
|
+
const inner = match[2]
|
|
105
|
+
if (E.LoadableComponent.dedent(inner) !== before) continue
|
|
106
|
+
const start = match.index + match[1].length
|
|
107
|
+
blocks.push({ start, end: start + inner.length, inner })
|
|
79
108
|
}
|
|
80
|
-
return blocks[ordinal] ?? blocks[0]
|
|
109
|
+
return blocks[ordinal] ?? blocks[0]
|
|
81
110
|
}
|
|
111
|
+
|
|
82
112
|
/**
|
|
83
113
|
* `text` laid out as `old` was: the same blank lines before and after it (the line end after the opening tag, the
|
|
84
114
|
* indent before the closing one), each line indented as `old`'s were.
|
|
85
115
|
*/
|
|
86
116
|
static reindented(old, text) {
|
|
87
|
-
const lines = old.split("\n")
|
|
88
|
-
const first = lines.findIndex((line) => line.trim())
|
|
89
|
-
if (first < 0) return text
|
|
90
|
-
const last = lines.findLastIndex((line) => line.trim())
|
|
91
|
-
const indent = lines
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
117
|
+
const lines = old.split("\n")
|
|
118
|
+
const first = lines.findIndex((line) => line.trim())
|
|
119
|
+
if (first < 0) return text
|
|
120
|
+
const last = lines.findLastIndex((line) => line.trim())
|
|
121
|
+
const indent = lines
|
|
122
|
+
.filter((line) => line.trim())
|
|
123
|
+
.map((line) => line.slice(0, line.length - line.trimStart().length))
|
|
124
|
+
.reduce((shortest, each) => (each.length < shortest.length ? each : shortest))
|
|
125
|
+
const head = lines
|
|
126
|
+
.slice(0, first)
|
|
127
|
+
.map((line) => `${line}\n`)
|
|
128
|
+
.join("")
|
|
129
|
+
const tail = lines
|
|
130
|
+
.slice(last + 1)
|
|
131
|
+
.map((line) => `\n${line}`)
|
|
132
|
+
.join("")
|
|
133
|
+
const body = text
|
|
134
|
+
.split("\n")
|
|
135
|
+
.map((line) => (line.trim() ? `${indent}${line}` : ""))
|
|
136
|
+
.join("\n")
|
|
137
|
+
return `${head}${body}${tail}`
|
|
98
138
|
}
|
|
99
|
-
}
|
|
100
|
-
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** A `<script type="text/...">` in a page's markup: its opening tag, then its text. */
|
|
142
|
+
const SCRIPT_BLOCK = /(<script\b[^>]*\btype="text\/[^"]*"[^>]*>)([\s\S]*?)<\/script>/g
|
|
@@ -1,27 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Entry of `spell-ui.js`, the ONE classic script a `.html` doc loads -- `file://` blocks ES modules.
|
|
3
|
+
* - Built by `node src/tools/bundle-spell-ui.js`, from spell-epic's root (part of `epic pages update`); edit THIS,
|
|
4
|
+
* never the bundle.
|
|
5
|
+
* - `spell-ui` ~== UI's built `dist/index.js`: every family, each `define()`s its tags as it's imported.
|
|
6
|
+
* Solid comes from UI's `node_modules`, so there's exactly one copy.
|
|
7
|
+
* - Order matters -- imports run top to bottom:
|
|
8
|
+
* - `spell-ui:icons` FIRST: a module the bundler writes, registering the icons our widgets and pages draw
|
|
9
|
+
* with `UI.icons` before any element asks for one (a classic script can't load UI's icon packs)
|
|
10
|
+
* - then UI, which defines -- and so upgrades -- every `ui-*` already in the page
|
|
11
|
+
* - then `spell-ui:lazy`, pointing `<ui-code>` / `<ui-markdown>`'s engine loaders at their lazy scripts (before
|
|
12
|
+
* any element highlights: that waits for `UI.load()`), and the source elements' saver (`spell-ui-sources.js`)
|
|
13
|
+
* - then the page runtime, with every tag defined
|
|
14
|
+
* - then the site header (`spell/server/site`): `defineSite()` runs once every import has, so `<spell-site-header>`
|
|
15
|
+
* upgrades -- and sets `--spell-site-header-height` -- before the runtime first measures its sticky offsets
|
|
16
|
+
* (the runtime waits for the `ui-*` definitions first)
|
|
17
|
+
* - Every import is a package name: Spell UI's from its built `dist/` (`spellUiResolver()`), spell-epic's as their
|
|
18
|
+
* source files (the kit's `sourceNames()`), the rest by their packages' `exports`.
|
|
19
|
+
* - Exports become `window.SpellUI` (`UI`), for the page runtime's checks and for poking in DevTools.
|
|
20
|
+
* - Component packs (epic `epic-components`): `<ui-components source="x.pack.js">` in a `<ui-root>` loads a pack's
|
|
21
|
+
* classic script, which calls `SpellUI.registerPack(pack)` and imports the modules it shares with the page from
|
|
22
|
+
* `SpellUI.packModules` (`spell pack build` maps each of their specifiers there, as written), so a pack never brings a
|
|
23
|
+
* second Solid or Spell UI.
|
|
24
|
+
* - `packModules` is the EXACT specifier a pack's build leaves external => that module's namespace. Add one here
|
|
25
|
+
* AND to the pack build's externals, together.
|
|
26
|
+
* - `import * as` a Solid package, against Spell UI's `AGENTS.md` ("One Solid per page"), on purpose and ONLY
|
|
27
|
+
* here: that rule keeps a library's bundles from pinning all of Solid, but this map exists so a pack can use any
|
|
28
|
+
* export, which no tree-shaker can know ahead. So the whole of `solid-js` / `@solidjs/web` stays in this bundle
|
|
29
|
+
* (`ui`'s own code never holds such a map).
|
|
30
|
+
* - The theme: the ONE the person picked, for every place Spell draws (`ThemePreference`, epic `debut` P21:
|
|
31
|
+
* kept in their space, the editor's and Spell UI's pages' too), applied as soon as the bundle runs;
|
|
32
|
+
* Glass until they pick another
|
|
33
|
+
* - light / dark: part of the same choice (`ColorScheme`)
|
|
34
|
+
* - a theme remembered under an old name comes back as its new one (`studio` as `merlot`)
|
|
35
|
+
* - Spell's sheet adds the brand's roles (`--spell-surface-warm`, `--spell-type-lede` ...), which `spell-doc.css` and
|
|
36
|
+
* the other docs sheets read for eyebrows, ledes, asides and panels; in another theme they're missing, and every
|
|
37
|
+
* sheet that reads one has a fallback
|
|
38
|
+
* - each sheet is inlined like every other `import()`, so it registers a few microtasks after the bundle runs, not
|
|
39
|
+
* a network round trip later; none ships font files
|
|
40
|
+
* - The theme menu (`<ui-theme-menu>`) goes in the site header's `theme` slot, in place of its light / dark button
|
|
41
|
+
* (Q30): the header names no menu, it only gives the page's own a place (`addThemeMenu()`).
|
|
42
|
+
*/
|
|
3
43
|
|
|
4
|
-
|
|
5
|
-
import "spell-ui:
|
|
6
|
-
import "spell
|
|
7
|
-
import
|
|
8
|
-
import * as
|
|
9
|
-
import * as
|
|
10
|
-
import * as
|
|
11
|
-
import * as
|
|
12
|
-
import * as
|
|
13
|
-
import * as
|
|
14
|
-
import * as
|
|
15
|
-
import * as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import "spell-ui
|
|
19
|
-
import "./spell-
|
|
20
|
-
import "
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
44
|
+
import "spell-ui:icons"
|
|
45
|
+
import "spell-ui:emoji"
|
|
46
|
+
import { UI, ThemePreference } from "spell/ui"
|
|
47
|
+
import * as solidH from "@solidjs/h"
|
|
48
|
+
import * as solidWeb from "@solidjs/web"
|
|
49
|
+
import * as solid from "solid-js"
|
|
50
|
+
import * as uiCore from "spell/ui/core"
|
|
51
|
+
import * as uiForms from "spell/ui/forms"
|
|
52
|
+
import * as uiRoot from "spell/ui/components/ui-root"
|
|
53
|
+
import * as uiCode from "spell/ui/components/ui-code"
|
|
54
|
+
import * as uiMarkdown from "spell/ui/components/ui-markdown"
|
|
55
|
+
import * as imageZoom from "spell/ui/components/ui-zoom/ImageZoom"
|
|
56
|
+
import { PackHotSwap } from "spell/ui/hot"
|
|
57
|
+
import "spell-ui:lazy"
|
|
58
|
+
import "./spell-ui-sources.js"
|
|
59
|
+
import "./spell-doc-runtime.js"
|
|
60
|
+
import { defineSite } from "spell/server/site"
|
|
61
|
+
|
|
62
|
+
// a rebuilt pack (a merge) swaps into the live page instead of reloading it (epic `epic-engine` I116):
|
|
63
|
+
// installed now, before any pack defines its tags
|
|
64
|
+
PackHotSwap.install()
|
|
65
|
+
|
|
66
|
+
export { UI }
|
|
67
|
+
export { registerPack } from "spell/ui"
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* What a component pack imports, by the specifier its build leaves external => the page's copy of that module.
|
|
71
|
+
* - The keys are the import names themselves, as every repo's source writes them (epic `repo-split` P14, Q45):
|
|
72
|
+
* the kit's `PACK_MODULES` (`spell/element-tools/packModules`) and spell-app's shared-Solid builds read them.
|
|
73
|
+
* - `spell/element`, what the packs' elements are written on: Spell UI's core module, which carries all of it
|
|
74
|
+
* (`spell/ui/core` re-exports it, and its `E` holds every name spell-element's `E` does), so a page has one.
|
|
75
|
+
* - `spell/ui/components/ui-root` is for `<spell-viewer>` / `<spell-editor>`'s scripts (`spell-solid-shared.js`,
|
|
76
|
+
* spell-app's `app/vite.solid.config.ts`), not for packs: `<spell-viewer>` is a root, a subclass of `UIRoot`.
|
|
77
|
+
* - `@solidjs/h` likewise: what compiled spell draws with (`spell-runtime.js`, through `spell-solid-shared.js`),
|
|
78
|
+
* so a program on a docs page draws with the page's one Solid.
|
|
79
|
+
* - `spell/ui/components/ui-code` and `spell/ui/components/ui-markdown` likewise (epic `repo-split` P2): the families spell's
|
|
80
|
+
* own `<spell-code>` / `<spell-markdown>` (spell-app's app package, `spell-code.js` / `spell-markdown.js`) EXTEND,
|
|
81
|
+
* through `spell-ui-shared.js`, so they extend THIS page's `UICode` / `UIMarkdown`: one Spell UI. Without them
|
|
82
|
+
* those scripts stop with an error saying so. Not packs' externals: the epics pack imports neither.
|
|
83
|
+
* - `spell/ui/components/ui-zoom/ImageZoom`: the page's zoom for its screenshots (epic `ui-gaps` P14), the same one the
|
|
84
|
+
* docs runtime wires up, which `<epic-field>`'s request thumbnails open in.
|
|
85
|
+
*/
|
|
86
|
+
export const packModules = Object.freeze({
|
|
25
87
|
"solid-js": solid,
|
|
26
88
|
"@solidjs/web": solidWeb,
|
|
27
89
|
"@solidjs/h": solidH,
|
|
@@ -32,22 +94,28 @@ var packModules = Object.freeze({
|
|
|
32
94
|
"spell/ui/components/ui-code": uiCode,
|
|
33
95
|
"spell/ui/components/ui-markdown": uiMarkdown,
|
|
34
96
|
"spell/ui/components/ui-zoom/ImageZoom": imageZoom
|
|
35
|
-
})
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Put the theme menu in the site header's `theme` slot, where its light / dark button was (Q30).
|
|
101
|
+
* - Read as the bundle runs, from the end of `<body>`: the page's markup is all there.
|
|
102
|
+
* - A header DOCKED in a page's own chrome: none, the page has its own control.
|
|
103
|
+
* - Before `defineSite()`: the header draws first time without its light / dark button.
|
|
104
|
+
*/
|
|
36
105
|
function addThemeMenu() {
|
|
37
|
-
const header = document.querySelector("spell-site-header:not([docked])")
|
|
38
|
-
if (!header || header.querySelector(":scope > ui-theme-menu")) return
|
|
39
|
-
const menu = document.createElement("ui-theme-menu")
|
|
40
|
-
menu.slot = "theme"
|
|
41
|
-
menu.setAttribute("size", "small")
|
|
42
|
-
header.append(menu)
|
|
106
|
+
const header = document.querySelector("spell-site-header:not([docked])")
|
|
107
|
+
if (!header || header.querySelector(":scope > ui-theme-menu")) return
|
|
108
|
+
const menu = document.createElement("ui-theme-menu")
|
|
109
|
+
menu.slot = "theme"
|
|
110
|
+
menu.setAttribute("size", "small")
|
|
111
|
+
header.append(menu)
|
|
43
112
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Resolves once the page wears its theme (`ThemePreference.restore()`); never rejects.
|
|
116
|
+
* - a live reload's new page waits for it before it shows (the docs runtime's `reveal()`, epic `epic-engine` I164):
|
|
117
|
+
* without it, the reload cross-faded through a frame in Spell UI's plain look (white bands, no Fruity backdrop)
|
|
118
|
+
*/
|
|
119
|
+
export const themed = ThemePreference.restore().catch((error) => console.error("spell-ui: the page's theme", error))
|
|
120
|
+
addThemeMenu()
|
|
121
|
+
defineSite()
|