@scaffold-ui-kit/preview 0.0.0-stage → 2.3.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/LICENSE +21 -0
- package/README.md +1868 -2
- package/application/host/bootstrap.ts +43 -0
- package/application/host/main.ts +31 -0
- package/application/host/shell-host.ts +47 -0
- package/application/index.html +12 -0
- package/application/lib/base-url.ts +15 -0
- package/application/lib/no-code-block.ts +7 -0
- package/application/lib/no-setup.ts +3 -0
- package/application/lib/no-views.ts +6 -0
- package/application/preview/code/code.html +12 -0
- package/application/preview/code/main.ts +89 -0
- package/application/preview/globals.ts +254 -0
- package/application/preview/html/main.ts +93 -0
- package/application/preview/html/preview.html +12 -0
- package/application/preview/react/main.tsx +146 -0
- package/application/preview/react/preview.html +12 -0
- package/application/preview/svelte/Preview.svelte +104 -0
- package/application/preview/svelte/main.ts +13 -0
- package/application/preview/svelte/preview.html +12 -0
- package/application/preview/svelte/story-props.ts +172 -0
- package/application/preview/view/main.ts +124 -0
- package/application/preview/view/view.html +12 -0
- package/application/preview/vue/main.ts +145 -0
- package/application/preview/vue/preview.html +12 -0
- package/application/shells/charcell/components/Application/index.css +37 -0
- package/application/shells/charcell/components/Application/index.tsx +65 -0
- package/application/shells/charcell/components/Bar/index.css +68 -0
- package/application/shells/charcell/components/Bar/index.tsx +60 -0
- package/application/shells/charcell/components/CodePane/index.css +60 -0
- package/application/shells/charcell/components/CodePane/index.tsx +113 -0
- package/application/shells/charcell/components/ComponentStage/index.css +26 -0
- package/application/shells/charcell/components/ComponentStage/index.tsx +110 -0
- package/application/shells/charcell/components/Control/index.css +20 -0
- package/application/shells/charcell/components/Control/index.tsx +118 -0
- package/application/shells/charcell/components/CopyLink/index.tsx +35 -0
- package/application/shells/charcell/components/Description/index.css +6 -0
- package/application/shells/charcell/components/Description/index.tsx +24 -0
- package/application/shells/charcell/components/EditorAddDialog/index.css +9 -0
- package/application/shells/charcell/components/EditorAddDialog/index.tsx +158 -0
- package/application/shells/charcell/components/EditorPanel/index.css +48 -0
- package/application/shells/charcell/components/EditorPanel/index.tsx +496 -0
- package/application/shells/charcell/components/EventsRow/index.css +42 -0
- package/application/shells/charcell/components/EventsRow/index.tsx +68 -0
- package/application/shells/charcell/components/HeadingRow/index.css +11 -0
- package/application/shells/charcell/components/HeadingRow/index.tsx +16 -0
- package/application/shells/charcell/components/Hint/index.css +16 -0
- package/application/shells/charcell/components/Hint/index.tsx +81 -0
- package/application/shells/charcell/components/HtmlWarnings/index.tsx +45 -0
- package/application/shells/charcell/components/KeyHints/index.css +27 -0
- package/application/shells/charcell/components/KeyHints/index.tsx +106 -0
- package/application/shells/charcell/components/KitCodeBlock/index.css +55 -0
- package/application/shells/charcell/components/KitCodeBlock/index.tsx +18 -0
- package/application/shells/charcell/components/Markdown/index.tsx +16 -0
- package/application/shells/charcell/components/Navigation/index.css +13 -0
- package/application/shells/charcell/components/Navigation/index.tsx +98 -0
- package/application/shells/charcell/components/NavigationSplit/index.css +16 -0
- package/application/shells/charcell/components/NavigationSplit/index.tsx +82 -0
- package/application/shells/charcell/components/OptionControls/index.tsx +93 -0
- package/application/shells/charcell/components/PaneStatus/index.css +7 -0
- package/application/shells/charcell/components/PaneStatus/index.tsx +47 -0
- package/application/shells/charcell/components/PaneWidth/index.tsx +45 -0
- package/application/shells/charcell/components/PreviewGrid/index.css +39 -0
- package/application/shells/charcell/components/PreviewGrid/index.tsx +344 -0
- package/application/shells/charcell/components/PreviewPane/index.css +127 -0
- package/application/shells/charcell/components/PreviewPane/index.tsx +182 -0
- package/application/shells/charcell/components/PromptBar/index.tsx +133 -0
- package/application/shells/charcell/components/ScenarioRow/index.css +36 -0
- package/application/shells/charcell/components/ScenarioRow/index.tsx +71 -0
- package/application/shells/charcell/components/Select/index.tsx +48 -0
- package/application/shells/charcell/components/SlotOutlet/index.css +7 -0
- package/application/shells/charcell/components/SlotOutlet/index.tsx +25 -0
- package/application/shells/charcell/components/StageBar/index.css +7 -0
- package/application/shells/charcell/components/StageBar/index.tsx +109 -0
- package/application/shells/charcell/components/StageSplit/index.css +11 -0
- package/application/shells/charcell/components/StageSplit/index.tsx +99 -0
- package/application/shells/charcell/components/StatusBar/index.tsx +30 -0
- package/application/shells/charcell/components/ViewControls/index.css +15 -0
- package/application/shells/charcell/components/ViewControls/index.tsx +58 -0
- package/application/shells/charcell/components/ViewHeading/index.css +13 -0
- package/application/shells/charcell/components/ViewHeading/index.tsx +8 -0
- package/application/shells/charcell/components/ViewStage/index.css +9 -0
- package/application/shells/charcell/components/ViewStage/index.tsx +25 -0
- package/application/shells/charcell/components/WrapToggle/index.tsx +27 -0
- package/application/shells/charcell/configuration.ts +45 -0
- package/application/shells/charcell/controller-context.ts +27 -0
- package/application/shells/charcell/fit-labels.ts +42 -0
- package/application/shells/charcell/html-warnings.ts +18 -0
- package/application/shells/charcell/index.tsx +82 -0
- package/application/shells/charcell/page-loading.html +57 -0
- package/application/shells/charcell/placement.ts +24 -0
- package/application/shells/charcell/shell-options.ts +23 -0
- package/application/shells/charcell/shell.css +37 -0
- package/application/shells/charcell/shell.tsx +25 -0
- package/application/shells/charcell/split-reset.ts +47 -0
- package/application/shells/charcell/stacked-rows.ts +117 -0
- package/application/shells/charcell/stage-toggles.ts +93 -0
- package/application/types/manifest.d.ts +6 -0
- package/application/types/preview-configuration.d.ts +10 -0
- package/application/types/preview-shell.d.ts +7 -0
- package/application/types/react-registry.d.ts +15 -0
- package/application/types/vue-registry.d.ts +6 -0
- package/dist/build.d.ts +24 -0
- package/dist/build.js +34 -0
- package/dist/check.d.ts +48 -0
- package/dist/check.js +781 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +88 -0
- package/dist/context.d.ts +179 -0
- package/dist/context.js +783 -0
- package/dist/controller/catalog.d.ts +339 -0
- package/dist/controller/catalog.js +367 -0
- package/dist/controller/create-preview-controller.d.ts +532 -0
- package/dist/controller/create-preview-controller.js +1707 -0
- package/dist/controller/editor-tree.d.ts +161 -0
- package/dist/controller/editor-tree.js +373 -0
- package/dist/controller/html-source.d.ts +62 -0
- package/dist/controller/html-source.js +61 -0
- package/dist/controller/index.d.ts +9 -0
- package/dist/controller/index.js +12 -0
- package/dist/controller/persistence.d.ts +191 -0
- package/dist/controller/persistence.js +315 -0
- package/dist/controller/regeneration.d.ts +30 -0
- package/dist/controller/regeneration.js +27 -0
- package/dist/controller/source.d.ts +80 -0
- package/dist/controller/source.js +236 -0
- package/dist/controller/store.d.ts +27 -0
- package/dist/controller/store.js +40 -0
- package/dist/declarations/application/shells/charcell/components/Application/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Bar/index.d.ts +11 -0
- package/dist/declarations/application/shells/charcell/components/CodePane/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/ComponentStage/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Control/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/CopyLink/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/Description/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/EditorAddDialog/index.d.ts +6 -0
- package/dist/declarations/application/shells/charcell/components/EditorPanel/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/EventsRow/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/HeadingRow/index.d.ts +6 -0
- package/dist/declarations/application/shells/charcell/components/Hint/index.d.ts +11 -0
- package/dist/declarations/application/shells/charcell/components/HtmlWarnings/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/KeyHints/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/KitCodeBlock/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/Markdown/index.d.ts +3 -0
- package/dist/declarations/application/shells/charcell/components/Navigation/index.d.ts +8 -0
- package/dist/declarations/application/shells/charcell/components/NavigationSplit/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/OptionControls/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/PaneStatus/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/PaneWidth/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/PreviewGrid/index.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/components/PreviewPane/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/PromptBar/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/ScenarioRow/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/Select/index.d.ts +16 -0
- package/dist/declarations/application/shells/charcell/components/SlotOutlet/index.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/components/StageBar/index.d.ts +2 -0
- package/dist/declarations/application/shells/charcell/components/StageSplit/index.d.ts +17 -0
- package/dist/declarations/application/shells/charcell/components/StatusBar/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/components/ViewControls/index.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/components/ViewHeading/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/ViewStage/index.d.ts +4 -0
- package/dist/declarations/application/shells/charcell/components/WrapToggle/index.d.ts +1 -0
- package/dist/declarations/application/shells/charcell/configuration.d.ts +31 -0
- package/dist/declarations/application/shells/charcell/controller-context.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/fit-labels.d.ts +18 -0
- package/dist/declarations/application/shells/charcell/html-warnings.d.ts +5 -0
- package/dist/declarations/application/shells/charcell/index.d.ts +39 -0
- package/dist/declarations/application/shells/charcell/placement.d.ts +7 -0
- package/dist/declarations/application/shells/charcell/shell-options.d.ts +15 -0
- package/dist/declarations/application/shells/charcell/shell.d.ts +9 -0
- package/dist/declarations/application/shells/charcell/split-reset.d.ts +30 -0
- package/dist/declarations/application/shells/charcell/stacked-rows.d.ts +58 -0
- package/dist/declarations/application/shells/charcell/stage-toggles.d.ts +28 -0
- package/dist/declarations/src/controller/catalog.d.ts +339 -0
- package/dist/declarations/src/controller/create-preview-controller.d.ts +532 -0
- package/dist/declarations/src/controller/editor-tree.d.ts +161 -0
- package/dist/declarations/src/controller/html-source.d.ts +62 -0
- package/dist/declarations/src/controller/index.d.ts +9 -0
- package/dist/declarations/src/controller/persistence.d.ts +191 -0
- package/dist/declarations/src/controller/regeneration.d.ts +30 -0
- package/dist/declarations/src/controller/source.d.ts +80 -0
- package/dist/declarations/src/controller/store.d.ts +27 -0
- package/dist/declarations/src/emit/common.d.ts +103 -0
- package/dist/declarations/src/emit/manifest.d.ts +138 -0
- package/dist/declarations/src/emit/source.d.ts +87 -0
- package/dist/declarations/src/lib/jsx-roots.d.ts +22 -0
- package/dist/declarations/src/lib/module-of-source.d.ts +18 -0
- package/dist/declarations/src/lib/naming.d.ts +29 -0
- package/dist/declarations/src/lib/react-spelling.d.ts +68 -0
- package/dist/declarations/src/lib/scenario-story.d.ts +41 -0
- package/dist/declarations/src/lib/slot-fill.d.ts +15 -0
- package/dist/declarations/src/lib/types.d.ts +741 -0
- package/dist/declarations/src/options.d.ts +224 -0
- package/dist/declarations/src/protocol.d.ts +541 -0
- package/dist/declarations/src/react-view.d.ts +22 -0
- package/dist/declarations/src/react.d.ts +17 -0
- package/dist/declarations/src/shell.d.ts +99 -0
- package/dist/declarations/src/views.d.ts +152 -0
- package/dist/development-server.d.ts +121 -0
- package/dist/development-server.js +331 -0
- package/dist/emit/common.d.ts +103 -0
- package/dist/emit/common.js +170 -0
- package/dist/emit/html-source.d.ts +46 -0
- package/dist/emit/html-source.js +322 -0
- package/dist/emit/manifest.d.ts +138 -0
- package/dist/emit/manifest.js +74 -0
- package/dist/emit/react.d.ts +16 -0
- package/dist/emit/react.js +210 -0
- package/dist/emit/scratch.d.ts +40 -0
- package/dist/emit/scratch.js +116 -0
- package/dist/emit/source.d.ts +87 -0
- package/dist/emit/source.js +789 -0
- package/dist/emit/svelte.d.ts +9 -0
- package/dist/emit/svelte.js +177 -0
- package/dist/emit/vue.d.ts +2 -0
- package/dist/emit/vue.js +152 -0
- package/dist/enumerate.d.ts +2 -0
- package/dist/enumerate.js +162 -0
- package/dist/generate.d.ts +43 -0
- package/dist/generate.js +302 -0
- package/dist/html-stylesheet.d.ts +43 -0
- package/dist/html-stylesheet.js +145 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.js +21 -0
- package/dist/landing.d.ts +16 -0
- package/dist/landing.js +45 -0
- package/dist/lib/exported-types.d.ts +42 -0
- package/dist/lib/exported-types.js +86 -0
- package/dist/lib/html-attributes.d.ts +2 -0
- package/dist/lib/html-attributes.js +111 -0
- package/dist/lib/html-warnings.d.ts +19 -0
- package/dist/lib/html-warnings.js +79 -0
- package/dist/lib/jsx-roots.d.ts +22 -0
- package/dist/lib/jsx-roots.js +243 -0
- package/dist/lib/module-of-source.d.ts +18 -0
- package/dist/lib/module-of-source.js +24 -0
- package/dist/lib/naming.d.ts +29 -0
- package/dist/lib/naming.js +56 -0
- package/dist/lib/parse-type.d.ts +32 -0
- package/dist/lib/parse-type.js +103 -0
- package/dist/lib/react-spelling.d.ts +68 -0
- package/dist/lib/react-spelling.js +197 -0
- package/dist/lib/scenario-story.d.ts +41 -0
- package/dist/lib/scenario-story.js +84 -0
- package/dist/lib/slot-fill.d.ts +15 -0
- package/dist/lib/slot-fill.js +92 -0
- package/dist/lib/template-files.d.ts +14 -0
- package/dist/lib/template-files.js +25 -0
- package/dist/lib/types.d.ts +741 -0
- package/dist/lib/types.js +13 -0
- package/dist/lib/void-elements.d.ts +7 -0
- package/dist/lib/void-elements.js +13 -0
- package/dist/load.d.ts +37 -0
- package/dist/load.js +82 -0
- package/dist/model.d.ts +44 -0
- package/dist/model.js +464 -0
- package/dist/options.d.ts +224 -0
- package/dist/options.js +223 -0
- package/dist/prop-types.d.ts +26 -0
- package/dist/prop-types.js +102 -0
- package/dist/props-from.d.ts +84 -0
- package/dist/props-from.js +510 -0
- package/dist/protocol.d.ts +541 -0
- package/dist/protocol.js +819 -0
- package/dist/react-view.d.ts +22 -0
- package/dist/react-view.js +36 -0
- package/dist/react.d.ts +17 -0
- package/dist/react.js +23 -0
- package/dist/sass-importers.d.ts +26 -0
- package/dist/sass-importers.js +32 -0
- package/dist/shell-acceptance.d.ts +21 -0
- package/dist/shell-acceptance.js +37 -0
- package/dist/shell-page.d.ts +36 -0
- package/dist/shell-page.js +90 -0
- package/dist/shell-peers.d.ts +38 -0
- package/dist/shell-peers.js +61 -0
- package/dist/shell.d.ts +99 -0
- package/dist/shell.js +52 -0
- package/dist/shells/charcell/page.d.ts +8 -0
- package/dist/shells/charcell/page.js +69 -0
- package/dist/story-source.d.ts +113 -0
- package/dist/story-source.js +271 -0
- package/dist/story.d.ts +5 -0
- package/dist/story.js +28 -0
- package/dist/testing.d.ts +218 -0
- package/dist/testing.js +284 -0
- package/dist/views.d.ts +152 -0
- package/dist/views.js +7 -0
- package/dist/vite-configuration.d.ts +114 -0
- package/dist/vite-configuration.js +578 -0
- package/package.json +123 -3
- package/src/build.ts +51 -0
- package/src/check.ts +1062 -0
- package/src/cli.ts +123 -0
- package/src/context.ts +1168 -0
- package/src/controller/catalog.ts +719 -0
- package/src/controller/create-preview-controller.ts +2683 -0
- package/src/controller/editor-tree.ts +530 -0
- package/src/controller/html-source.ts +114 -0
- package/src/controller/index.ts +105 -0
- package/src/controller/persistence.ts +403 -0
- package/src/controller/regeneration.ts +55 -0
- package/src/controller/source.ts +333 -0
- package/src/controller/store.ts +55 -0
- package/src/development-server.ts +442 -0
- package/src/emit/common.ts +201 -0
- package/src/emit/html-source.ts +402 -0
- package/src/emit/manifest.ts +241 -0
- package/src/emit/react.ts +263 -0
- package/src/emit/scratch.ts +175 -0
- package/src/emit/source.ts +1094 -0
- package/src/emit/svelte.ts +230 -0
- package/src/emit/vue.ts +194 -0
- package/src/enumerate.ts +220 -0
- package/src/generate.ts +443 -0
- package/src/html-stylesheet.ts +173 -0
- package/src/index.ts +60 -0
- package/src/landing.ts +58 -0
- package/src/lib/exported-types.ts +114 -0
- package/src/lib/html-attributes.ts +113 -0
- package/src/lib/html-warnings.ts +81 -0
- package/src/lib/jsx-roots.ts +238 -0
- package/src/lib/module-of-source.ts +26 -0
- package/src/lib/naming.ts +65 -0
- package/src/lib/parse-type.ts +143 -0
- package/src/lib/react-spelling.ts +235 -0
- package/src/lib/scenario-story.ts +97 -0
- package/src/lib/slot-fill.ts +102 -0
- package/src/lib/template-files.ts +31 -0
- package/src/lib/types.ts +778 -0
- package/src/lib/void-elements.ts +15 -0
- package/src/load.ts +144 -0
- package/src/model.ts +568 -0
- package/src/options.ts +435 -0
- package/src/prop-types.ts +133 -0
- package/src/props-from.ts +678 -0
- package/src/protocol.ts +1135 -0
- package/src/react-view.ts +45 -0
- package/src/react.ts +34 -0
- package/src/sass-importers.ts +45 -0
- package/src/shell-acceptance.ts +45 -0
- package/src/shell-page.ts +133 -0
- package/src/shell-peers.ts +70 -0
- package/src/shell.ts +194 -0
- package/src/shells/charcell/page.ts +82 -0
- package/src/story-source.ts +391 -0
- package/src/story.ts +42 -0
- package/src/testing.ts +497 -0
- package/src/views.ts +183 -0
- package/src/vite-configuration.ts +675 -0
package/dist/cli.d.ts
ADDED
package/dist/cli.js
ADDED
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// The preview CLI: `scaffold-ui-kit-preview <command>` run from (or pointed at)
|
|
3
|
+
// a kit root whose configuration carries a `preview` block. `dev` is the daily driver:
|
|
4
|
+
// generate, then serve the host + per-target iframes on one Vite server,
|
|
5
|
+
// regenerating as the kit changes.
|
|
6
|
+
import { resolve } from 'node:path';
|
|
7
|
+
import { Command } from 'commander';
|
|
8
|
+
import { buildPreview } from './build.js';
|
|
9
|
+
import { checkPreview } from './check.js';
|
|
10
|
+
import { loadPreviewContext } from './context.js';
|
|
11
|
+
import { generatePreview } from './generate.js';
|
|
12
|
+
import { DEFAULT_PORT } from './vite-configuration.js';
|
|
13
|
+
const program = new Command();
|
|
14
|
+
program
|
|
15
|
+
.name('scaffold-ui-kit-preview')
|
|
16
|
+
.description('Preview for scaffold-ui-kit kits')
|
|
17
|
+
.option('--kit <path>', 'kit root', '.')
|
|
18
|
+
.option('--configuration <path>', "the kit configuration file (default: the one the kit's package.json names, else scaffold-ui-kit.ts or scaffold-ui-kit.json in the kit root)");
|
|
19
|
+
function kitRoot() {
|
|
20
|
+
return resolve(process.cwd(), program.opts().kit);
|
|
21
|
+
}
|
|
22
|
+
/** The kit configuration file `--configuration` names, if any. */
|
|
23
|
+
function configurationOptions() {
|
|
24
|
+
const { configuration } = program.opts();
|
|
25
|
+
return configuration === undefined ? {} : { configuration };
|
|
26
|
+
}
|
|
27
|
+
function context() {
|
|
28
|
+
const loaded = loadPreviewContext(kitRoot(), configurationOptions());
|
|
29
|
+
for (const line of loaded.warnings)
|
|
30
|
+
console.warn(`warning ${line}`);
|
|
31
|
+
return loaded;
|
|
32
|
+
}
|
|
33
|
+
program
|
|
34
|
+
.command('generate')
|
|
35
|
+
.description('one-shot: render the registries + manifest into .preview-generated/')
|
|
36
|
+
.action(async () => {
|
|
37
|
+
await generatePreview(context());
|
|
38
|
+
});
|
|
39
|
+
program
|
|
40
|
+
.command('dev')
|
|
41
|
+
.description('generate, then serve the preview (host + framework iframes), regenerating as the kit changes')
|
|
42
|
+
.option('--port <number>', `dev-server port (default: the kit's configured port, else ${DEFAULT_PORT})`, Number)
|
|
43
|
+
.option('--host [address]', "the address to listen on, or every address without one, so another device on the network can open the preview (default: the kit's configured host, else this machine only)")
|
|
44
|
+
.action(async (options) => {
|
|
45
|
+
const { startDevelopmentServer } = await import('./development-server.js');
|
|
46
|
+
await startDevelopmentServer(kitRoot(), { port: options.port, host: options.host }, configurationOptions());
|
|
47
|
+
});
|
|
48
|
+
program
|
|
49
|
+
.command('check')
|
|
50
|
+
.description('check the story files, the manual specs and the build against the components')
|
|
51
|
+
.option('--strict', 'fail on every warning the check itself raises, such as a select value or boolean no scenario sets')
|
|
52
|
+
.action(async (options) => {
|
|
53
|
+
const report = await checkPreview(kitRoot(), {
|
|
54
|
+
strict: options.strict,
|
|
55
|
+
...configurationOptions(),
|
|
56
|
+
});
|
|
57
|
+
for (const line of report.errors)
|
|
58
|
+
console.error(`error ${line}`);
|
|
59
|
+
for (const line of report.warnings)
|
|
60
|
+
console.warn(`warning ${line}`);
|
|
61
|
+
for (const line of report.hidden)
|
|
62
|
+
console.log(`hidden ${line}`);
|
|
63
|
+
for (const line of report.ungenerated)
|
|
64
|
+
console.log(`ungenerated ${line}`);
|
|
65
|
+
console.log(`[preview:check] ${report.errors.length} errors, ${report.warnings.length} warnings, ${report.hidden.length} hidden props, ${report.ungenerated.length} ungenerated props`);
|
|
66
|
+
if (report.errors.length > 0)
|
|
67
|
+
process.exitCode = 1;
|
|
68
|
+
});
|
|
69
|
+
program
|
|
70
|
+
.command('build')
|
|
71
|
+
.description('check, then generate and build the static preview into .preview-static/; a check error stops it')
|
|
72
|
+
.action(async () => {
|
|
73
|
+
// A check error stops the build, with the errors printed as `check`
|
|
74
|
+
// prints them.
|
|
75
|
+
const { built, errors, warnings } = await buildPreview(kitRoot(), undefined, configurationOptions());
|
|
76
|
+
for (const line of warnings)
|
|
77
|
+
console.warn(`warning ${line}`);
|
|
78
|
+
if (built)
|
|
79
|
+
return;
|
|
80
|
+
for (const line of errors)
|
|
81
|
+
console.error(`error ${line}`);
|
|
82
|
+
console.error(`[preview:build] ${errors.length} ${errors.length === 1 ? 'error' : 'errors'} from the check; the preview is not built`);
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
});
|
|
85
|
+
program.parseAsync().catch((error) => {
|
|
86
|
+
console.error(error instanceof Error ? error.message : error);
|
|
87
|
+
process.exit(1);
|
|
88
|
+
});
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import type { BemOptions } from '@js-template-engine/extension-bem';
|
|
2
|
+
import type { TailwindOptions } from '@js-template-engine/extension-tailwind';
|
|
3
|
+
import type { StylesheetPlacement } from '@js-template-engine/types';
|
|
4
|
+
import type { ConfigurationLookupOptions } from 'scaffold-ui-kit';
|
|
5
|
+
import { type ModuleImporter, type PreviewBrowserConfiguration, type PreviewConfiguration, type PreviewSourceConfiguration, type Target } from './lib/types.js';
|
|
6
|
+
export interface ResolvedSource extends PreviewSourceConfiguration {
|
|
7
|
+
/** Absolute (resolved against the kit root). */
|
|
8
|
+
templatesDirectoryAbsolute?: string;
|
|
9
|
+
manualModuleAbsolute?: string;
|
|
10
|
+
storiesDirectoryAbsolute?: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A package of a kit built into one package per target (the kit
|
|
14
|
+
* configuration's `packages`), other than the kit root's own.
|
|
15
|
+
*/
|
|
16
|
+
export interface KitLayoutPackage {
|
|
17
|
+
/** The target the package is built for, or `styles` for the package of
|
|
18
|
+
* the kit's stylesheets. */
|
|
19
|
+
role: Target | 'styles';
|
|
20
|
+
/** The package name. */
|
|
21
|
+
name: string;
|
|
22
|
+
/** The package's directory, absolute. */
|
|
23
|
+
directoryAbsolute: string;
|
|
24
|
+
}
|
|
25
|
+
export interface PreviewContext {
|
|
26
|
+
/** The kit's root (where its package.json lives). */
|
|
27
|
+
kitRoot: string;
|
|
28
|
+
/**
|
|
29
|
+
* The kit's other packages, when its configuration builds it into one
|
|
30
|
+
* package per target (`packages`): the styles package first,
|
|
31
|
+
* then each target's. Absent for a kit built as one package.
|
|
32
|
+
*/
|
|
33
|
+
kitPackages?: KitLayoutPackage[];
|
|
34
|
+
/** The kit configuration file, absolute. */
|
|
35
|
+
configurationPath: string;
|
|
36
|
+
/** The kit's own modules a `.ts` configuration loaded beside its file. */
|
|
37
|
+
configurationModules: string[];
|
|
38
|
+
/** What reading the kit configuration warns of, such as its old file
|
|
39
|
+
* name. */
|
|
40
|
+
warnings: string[];
|
|
41
|
+
/** The kit's name (the kit configuration's `name`). */
|
|
42
|
+
kitName: string;
|
|
43
|
+
/** The kit's version (its package.json `version`), when it has one. */
|
|
44
|
+
kitVersion?: string;
|
|
45
|
+
/**
|
|
46
|
+
* The scripted targets the kit builds (the kit configuration's `targets`, its
|
|
47
|
+
* `html` target left out), in the preview's order; all three when the kit
|
|
48
|
+
* names none. A component renders only in these, whatever its own targets.
|
|
49
|
+
*/
|
|
50
|
+
targets: Target[];
|
|
51
|
+
/** Whether the kit builds html (`html` among the kit configuration's
|
|
52
|
+
* `targets`), so the preview shows an html pane beside the other targets'. */
|
|
53
|
+
buildsHtml?: boolean;
|
|
54
|
+
/** The mode the kit builds its Svelte target in (the kit configuration's
|
|
55
|
+
* `svelte.mode`), `legacy` when it names none. */
|
|
56
|
+
svelteMode: 'legacy' | 'runes';
|
|
57
|
+
/** The generated tree (`<kitRoot>/.preview-generated`). */
|
|
58
|
+
generatedRoot: string;
|
|
59
|
+
/** The static-build output (`<kitRoot>/.preview-static`). */
|
|
60
|
+
staticRoot: string;
|
|
61
|
+
/** The preview block, with `options` and `themes` defaulted to none and
|
|
62
|
+
* `controlHints.colorTokens`' unset choice as `null`. */
|
|
63
|
+
configuration: PreviewConfiguration & Pick<PreviewBrowserConfiguration, 'options' | 'themes' | 'canvas'>;
|
|
64
|
+
sources: ResolvedSource[];
|
|
65
|
+
/** Absolute path of the kit's custom-views module, when registered. */
|
|
66
|
+
viewsModuleAbsolute?: string;
|
|
67
|
+
/** Absolute path of the kit's code-block module, when it names one. */
|
|
68
|
+
codeBlockModuleAbsolute?: string;
|
|
69
|
+
/** Absolute path of the shell module `preview.shell` names. */
|
|
70
|
+
shellModuleAbsolute: string;
|
|
71
|
+
/** Absolute path of the shell's page module, when it has one: the module
|
|
72
|
+
* `preview.shell.page` names, or the one its package ships. */
|
|
73
|
+
shellPageAbsolute?: string;
|
|
74
|
+
/**
|
|
75
|
+
* Absolute path of the shell shipped with the preview, when the kit's
|
|
76
|
+
* shell is it: named as it is, or through a module of the kit's that
|
|
77
|
+
* imports it to configure it (`charcellShell({ ... })`). Absent under a
|
|
78
|
+
* shell of the kit's own.
|
|
79
|
+
*/
|
|
80
|
+
charcellShellAbsolute?: string;
|
|
81
|
+
/** The kit's `omitPattern`, compiled. */
|
|
82
|
+
omitPattern?: RegExp;
|
|
83
|
+
importModule: ModuleImporter;
|
|
84
|
+
/** The kit's styling settings, which the html source renders with. */
|
|
85
|
+
styling: KitStyling;
|
|
86
|
+
/**
|
|
87
|
+
* The kit's shared modules templates import by specifier (`add.shared`
|
|
88
|
+
* code modules the kit's `package.json` exports), resolved against the
|
|
89
|
+
* kit root. The html
|
|
90
|
+
* source puts their exports in scope, so an expression calling a kit helper
|
|
91
|
+
* evaluates.
|
|
92
|
+
*/
|
|
93
|
+
sharedModulesAbsolute: string[];
|
|
94
|
+
/**
|
|
95
|
+
* The framework-free entries of `@scaffold-ui-kit/helpers` (`/runtime`
|
|
96
|
+
* and `/zag`) as installed for the kit, resolved from the kit root or one
|
|
97
|
+
* of its packages. The html source puts their exports in scope beside the
|
|
98
|
+
* shared modules', so an expression calling a helper evaluates. Empty when
|
|
99
|
+
* the kit does not have the package.
|
|
100
|
+
*/
|
|
101
|
+
helperModulesAbsolute: string[];
|
|
102
|
+
/**
|
|
103
|
+
* The kit's shared modules with the package path its built files import
|
|
104
|
+
* each by (the one the kit's `package.json` exports give it, or an older
|
|
105
|
+
* configuration's `specifier`), the source relative to the kit root as
|
|
106
|
+
* written.
|
|
107
|
+
*/
|
|
108
|
+
sharedSpecifiers: {
|
|
109
|
+
source: string;
|
|
110
|
+
specifier: string;
|
|
111
|
+
}[];
|
|
112
|
+
/**
|
|
113
|
+
* The kit's Sass load paths (the kit configuration's top-level
|
|
114
|
+
* `loadPaths`), resolved against the kit root, which the kit's build
|
|
115
|
+
* compiles its SCSS with.
|
|
116
|
+
*/
|
|
117
|
+
sassLoadPathsAbsolute: string[];
|
|
118
|
+
/**
|
|
119
|
+
* The parts of each compound whose root has no template, such as a
|
|
120
|
+
* hand-written component (the kit configuration's `parts`), by root name.
|
|
121
|
+
*/
|
|
122
|
+
parts: Record<string, string[]>;
|
|
123
|
+
}
|
|
124
|
+
/** The styling keys of the kit configuration the html source reads. */
|
|
125
|
+
export interface KitStyling {
|
|
126
|
+
/** The styling extensions, in configuration order. */
|
|
127
|
+
extensions: Array<'bem' | 'tailwind'>;
|
|
128
|
+
/** Where each component's stylesheet is placed (the kit configuration's
|
|
129
|
+
* `stylesheetPlacement`), `in-file` when it names none. */
|
|
130
|
+
placement: StylesheetPlacement;
|
|
131
|
+
/** The BEM extension's options (the kit configuration's `bem` block). */
|
|
132
|
+
bem?: BemOptions;
|
|
133
|
+
/** The Tailwind extension's options (the kit configuration's `tailwind`
|
|
134
|
+
* block). */
|
|
135
|
+
tailwind?: TailwindOptions;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* What is wrong with a list of pane widths, or nothing: it must be a list of
|
|
139
|
+
* `{ label, width }`, each label a non-empty string and each width a whole
|
|
140
|
+
* number of CSS pixels from 1 to the most a pane is laid out at, no label
|
|
141
|
+
* and no width named twice.
|
|
142
|
+
*
|
|
143
|
+
* @param paneWidths - The list, as the kit gives it.
|
|
144
|
+
* @param name - Where the kit gives it, for the message.
|
|
145
|
+
* @returns The problem, or `undefined` when the list is sound.
|
|
146
|
+
* @example
|
|
147
|
+
* ```ts
|
|
148
|
+
* paneWidthsProblem([{ label: 'small', width: 375 }], 'paneWidths'); // undefined
|
|
149
|
+
* ```
|
|
150
|
+
*/
|
|
151
|
+
export declare function paneWidthsProblem(paneWidths: unknown, name: string): string | undefined;
|
|
152
|
+
/** The shell shipped with the preview, named when a kit configures none. */
|
|
153
|
+
export declare const CHARCELL_SHELL = "@scaffold-ui-kit/preview/shells/charcell";
|
|
154
|
+
/**
|
|
155
|
+
* The problems that keep a value from reaching the browser as JSON, each
|
|
156
|
+
* naming where in the value it sits: a function, `undefined` in a list, a
|
|
157
|
+
* number JSON has no form for, and an object other than a plain one or a
|
|
158
|
+
* list (a regular expression, a date, a map).
|
|
159
|
+
*
|
|
160
|
+
* @param value - The value.
|
|
161
|
+
* @param path - Where the value sits, as `preview.options`.
|
|
162
|
+
* @returns One message per problem.
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* jsonProblems({ apply: () => {} }, 'preview.options[0]');
|
|
166
|
+
* // ["preview.options[0].apply is a function, which can't be sent to the browser as JSON"]
|
|
167
|
+
* ```
|
|
168
|
+
*/
|
|
169
|
+
export declare function jsonProblems(value: unknown, path: string, ancestors?: WeakMap<object, string>): string[];
|
|
170
|
+
/**
|
|
171
|
+
* Finds the kit configuration (`--configuration`, the kit's `package.json`
|
|
172
|
+
* pointer, or `scaffold-ui-kit.ts` or `scaffold-ui-kit.json` at the kit
|
|
173
|
+
* root) and resolves the preview context from its `preview` block.
|
|
174
|
+
*
|
|
175
|
+
* @param kitRoot - The kit root.
|
|
176
|
+
* @param options - The configuration file a command was given, if any.
|
|
177
|
+
* @returns The context.
|
|
178
|
+
*/
|
|
179
|
+
export declare function loadPreviewContext(kitRoot: string, options?: ConfigurationLookupOptions): PreviewContext;
|