@poveste/app 0.12.3 → 0.13.1

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.
Files changed (71) hide show
  1. package/dist/app/style/font.css +11 -7
  2. package/dist/app/style/fonts/LICENSE +93 -0
  3. package/dist/app/style/fonts/noto-sans-display-cyrillic-400-normal.woff2 +0 -0
  4. package/dist/app/style/fonts/noto-sans-display-cyrillic-ext-400-normal.woff2 +0 -0
  5. package/dist/app/style/fonts/noto-sans-display-greek-400-normal.woff2 +0 -0
  6. package/dist/app/style/fonts/noto-sans-display-greek-ext-400-normal.woff2 +0 -0
  7. package/dist/app/style/fonts/noto-sans-display-latin-400-normal.woff2 +0 -0
  8. package/dist/app/style/fonts/noto-sans-display-latin-ext-400-normal.woff2 +0 -0
  9. package/dist/app/style/fonts/noto-sans-display-vietnamese-400-normal.woff2 +0 -0
  10. package/dist/bundled/App.vue_vue_type_script_setup_true_lang.js +30 -38
  11. package/dist/bundled/app.css +11 -17
  12. package/dist/bundled/components/base/BaseListItemLink.js +6 -3
  13. package/dist/bundled/components/base/BaseListItemLink.vue_vue_type_script_lang.js +10 -4
  14. package/dist/bundled/components/base/BaseOverflowTab.js +6 -3
  15. package/dist/bundled/components/base/BaseOverflowTab.vue_vue_type_script_lang.js +4 -0
  16. package/dist/bundled/components/base/BaseSplitPane.js +1 -1
  17. package/dist/bundled/components/base/BaseSplitPane.vue_vue_type_script_setup_true_lang.js +67 -29
  18. package/dist/bundled/components/base/BaseTab.js +6 -3
  19. package/dist/bundled/components/base/BaseTab.vue_vue_type_script_lang.js +4 -0
  20. package/dist/bundled/components/panel/PaneTabs.vue_vue_type_script_setup_true_lang.js +4 -4
  21. package/dist/bundled/components/panel/StorySourceCode.js +1 -1
  22. package/dist/bundled/components/panel/StorySourceCode.vue_vue_type_script_setup_true_lang.js +3 -3
  23. package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js +1 -1
  24. package/dist/bundled/components/story/StoryVariantSingle.js +1 -1
  25. package/dist/bundled/components/story/StoryVariantSingle.vue_vue_type_script_setup_true_lang.js +28 -43
  26. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue_vue_type_script_setup_true_lang.js +5 -2
  27. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue_vue_type_script_setup_true_lang.js +4 -0
  28. package/dist/bundled/components/story/StoryVariantSingleView.vue_vue_type_script_setup_true_lang.js +23 -13
  29. package/dist/bundled/components/story/StoryView.vue_vue_type_script_setup_true_lang.js +8 -11
  30. package/dist/bundled/components/toolbar/ToolbarBackground.js +1 -3
  31. package/dist/bundled/components/toolbar/ToolbarBackground.vue_vue_type_script_setup_true_lang.js +1 -5
  32. package/dist/bundled/sandbox.js +6 -1
  33. package/dist/bundled/util/events.js +4 -1
  34. package/dist/bundled/util/highlighter.js +11 -4
  35. package/dist/bundled/util/mapping.js +5 -1
  36. package/dist/bundled/util/occupant.js +16 -0
  37. package/dist/bundled/util/variant.js +12 -1
  38. package/dist/style.css +18 -6
  39. package/package.json +8 -6
  40. package/src/__tests__/font.spec.ts +48 -2
  41. package/src/app/App.vue +77 -63
  42. package/src/app/components/base/BaseListItemLink.vue +12 -1
  43. package/src/app/components/base/BaseOverflowTab.vue +12 -1
  44. package/src/app/components/base/BaseSplitPane.vue +95 -29
  45. package/src/app/components/base/BaseTab.vue +12 -1
  46. package/src/app/components/command/CommandPrompts.vue +9 -1
  47. package/src/app/components/panel/PaneTabs.vue +4 -4
  48. package/src/app/components/panel/StorySourceCode.vue +5 -5
  49. package/src/app/components/story/StoryVariantSingle.vue +65 -67
  50. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +13 -2
  51. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +8 -0
  52. package/src/app/components/story/StoryVariantSingleView.vue +59 -13
  53. package/src/app/components/story/StoryView.vue +17 -17
  54. package/src/app/components/toolbar/ToolbarBackground.vue +0 -7
  55. package/src/app/components/tree/StoryGroup.vue +1 -1
  56. package/src/app/sandbox.ts +9 -1
  57. package/src/app/style/font.css +11 -7
  58. package/src/app/style/fonts/LICENSE +93 -0
  59. package/src/app/style/fonts/noto-sans-display-cyrillic-400-normal.woff2 +0 -0
  60. package/src/app/style/fonts/noto-sans-display-cyrillic-ext-400-normal.woff2 +0 -0
  61. package/src/app/style/fonts/noto-sans-display-greek-400-normal.woff2 +0 -0
  62. package/src/app/style/fonts/noto-sans-display-greek-ext-400-normal.woff2 +0 -0
  63. package/src/app/style/fonts/noto-sans-display-latin-400-normal.woff2 +0 -0
  64. package/src/app/style/fonts/noto-sans-display-latin-ext-400-normal.woff2 +0 -0
  65. package/src/app/style/fonts/noto-sans-display-vietnamese-400-normal.woff2 +0 -0
  66. package/src/app/util/events.ts +3 -0
  67. package/src/app/util/highlighter.ts +24 -9
  68. package/src/app/util/mapping.ts +5 -1
  69. package/src/app/util/occupant.ts +13 -0
  70. package/src/app/util/variant.ts +13 -1
  71. package/LICENSE +0 -22
@@ -3,6 +3,10 @@ import { defineComponent } from "@poveste/vendors/vue";
3
3
  var BaseTab_vue_vue_type_script_lang_default = defineComponent({
4
4
  inheritAttrs: false,
5
5
  props: {
6
+ to: {
7
+ type: [String, Object],
8
+ required: true
9
+ },
6
10
  exact: {
7
11
  type: Boolean,
8
12
  default: false
@@ -43,7 +43,7 @@ var PaneTabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
43
43
  }
44
44
  },
45
45
  matched: _ctx.$route.query.tab === "docs",
46
- class: normalizeClass({ "opacity-50": !unref(renderedDoc) })
46
+ class: normalizeClass({ "opacity-70": !unref(renderedDoc) })
47
47
  }, {
48
48
  default: withCtx(() => [..._cache[4] || (_cache[4] = [createTextVNode(" Docs ", -1)])]),
49
49
  _: 1
@@ -61,7 +61,7 @@ var PaneTabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
61
61
  }
62
62
  },
63
63
  matched: _ctx.$route.query.tab === "events",
64
- class: normalizeClass({ "opacity-50": !hasEvents.value })
64
+ class: normalizeClass({ "opacity-70": !hasEvents.value })
65
65
  }, {
66
66
  default: withCtx(() => [_cache[5] || (_cache[5] = createTextVNode(" Events ", -1)), unref(eventsStore).unseen ? (openBlock(), createBlock(BaseTag_default, { key: 0 }, {
67
67
  default: withCtx(() => [createTextVNode(toDisplayString(unref(eventsStore).unseen <= 99 ? unref(eventsStore).unseen : "99+"), 1)]),
@@ -97,7 +97,7 @@ var PaneTabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
97
97
  }
98
98
  },
99
99
  matched: _ctx.$route.query.tab === "docs",
100
- class: normalizeClass({ "opacity-50": !unref(renderedDoc) })
100
+ class: normalizeClass({ "opacity-70": !unref(renderedDoc) })
101
101
  }, {
102
102
  default: withCtx(() => [..._cache[1] || (_cache[1] = [createTextVNode(" Docs ", -1)])]),
103
103
  _: 1
@@ -115,7 +115,7 @@ var PaneTabs_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineC
115
115
  }
116
116
  },
117
117
  matched: _ctx.$route.query.tab === "events",
118
- class: normalizeClass({ "opacity-50": !hasEvents.value })
118
+ class: normalizeClass({ "opacity-70": !hasEvents.value })
119
119
  }, {
120
120
  default: withCtx(() => [_cache[2] || (_cache[2] = createTextVNode(" Events ", -1)), unref(eventsStore).unseen ? (openBlock(), createBlock(BaseTag_default, { key: 0 }, {
121
121
  default: withCtx(() => [createTextVNode(toDisplayString(unref(eventsStore).unseen <= 99 ? unref(eventsStore).unseen : "99+"), 1)]),
@@ -2,6 +2,6 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
2
2
  import StorySourceCode_vue_vue_type_script_setup_true_lang_default from "./StorySourceCode.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/app/components/panel/StorySourceCode.vue
5
- var StorySourceCode_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StorySourceCode_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-3d88bdb3"]]);
5
+ var StorySourceCode_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StorySourceCode_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-6de9e107"]]);
6
6
  //#endregion
7
7
  export { StorySourceCode_default as default };
@@ -77,7 +77,7 @@ var StorySourceCode_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
77
77
  });
78
78
  const sourceHtml = computed(() => displayedSourceCode.value ? highlighter.value?.codeToHtml(displayedSourceCode.value, {
79
79
  lang: "html",
80
- theme: isDark.value ? "github-dark" : "github-light"
80
+ theme: isDark.value ? "github-dark" : "github-light-high-contrast"
81
81
  }) : "");
82
82
  let lastScroll = 0;
83
83
  watch(() => props.variant, () => {
@@ -97,13 +97,13 @@ var StorySourceCode_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/
97
97
  _cache[2] || (_cache[2] = createElementVNode("div", { class: "text-gray-900 dark:text-gray-100" }, " Source ", -1)),
98
98
  _cache[3] || (_cache[3] = createElementVNode("div", { class: "flex-1" }, null, -1)),
99
99
  createElementVNode("div", _hoisted_3, [withDirectives((openBlock(), createElementBlock("button", {
100
- class: normalizeClass(["flex items-center gap-1 h-full px-1 bg-gray-500/10 rounded-l transition-all ease-[cubic-bezier(0,1,.6,1)] duration-300 overflow-hidden", [displayedSource.value !== "dynamic" ? "max-w-6 opacity-70" : "max-w-[82px] text-primary-600 dark:text-primary-400", dynamicSourceCode.value ? "cursor-pointer hover:bg-gray-500/30 active:bg-gray-600/50" : "opacity-50"]]),
100
+ class: normalizeClass(["flex items-center gap-1 h-full px-1 bg-gray-500/10 rounded-l transition-all ease-[cubic-bezier(0,1,.6,1)] duration-300 overflow-hidden", [displayedSource.value !== "dynamic" ? "max-w-6 opacity-70" : "max-w-[82px] text-primary-800 dark:text-primary-400", dynamicSourceCode.value ? "cursor-pointer hover:bg-gray-500/30 active:bg-gray-600/50" : "opacity-50"]]),
101
101
  onClick: _cache[0] || (_cache[0] = ($event) => dynamicSourceCode.value && (displayedSource.value = "dynamic"))
102
102
  }, [createVNode(unref(Icon), {
103
103
  icon: "carbon:flash",
104
104
  class: "w-4 h-4 flex-none"
105
105
  }), createElementVNode("span", { class: normalizeClass(["transition-opacity duration-300", { "opacity-0": displayedSource.value !== "dynamic" }]) }, " Dynamic ", 2)], 2)), [[_directive_tooltip, !dynamicSourceCode.value ? "Dynamic source code is not available" : displayedSource.value !== "dynamic" ? "Switch to dynamic source" : null]]), withDirectives((openBlock(), createElementBlock("button", {
106
- class: normalizeClass(["flex items-center gap-1 h-full px-1 bg-gray-500/10 rounded-r transition-all ease-[cubic-bezier(0,1,.6,1)] duration-300 overflow-hidden", [displayedSource.value !== "static" ? "max-w-6 opacity-70" : "max-w-[63px] text-primary-600 dark:text-primary-400", staticSourceCode.value ? "cursor-pointer hover:bg-gray-500/30 active:bg-gray-600/50" : "opacity-50"]]),
106
+ class: normalizeClass(["flex items-center gap-1 h-full px-1 bg-gray-500/10 rounded-r transition-all ease-[cubic-bezier(0,1,.6,1)] duration-300 overflow-hidden", [displayedSource.value !== "static" ? "max-w-6 opacity-70" : "max-w-[63px] text-primary-800 dark:text-primary-400", staticSourceCode.value ? "cursor-pointer hover:bg-gray-500/30 active:bg-gray-600/50" : "opacity-50"]]),
107
107
  onClick: _cache[1] || (_cache[1] = ($event) => staticSourceCode.value && (displayedSource.value = "static"))
108
108
  }, [createVNode(unref(Icon), {
109
109
  icon: "carbon:document",
@@ -6,8 +6,8 @@ import { getContrastColor } from "../../util/preview-settings.js";
6
6
  import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
7
7
  import ToolbarNewTab_default from "../toolbar/ToolbarNewTab.js";
8
8
  import GenericRenderStory_default from "./GenericRenderStory.js";
9
- import { getSourceCode } from "../../util/docs.js";
10
9
  import { useCurrentVariantRoute } from "../../util/variant.js";
10
+ import { getSourceCode } from "../../util/docs.js";
11
11
  import CheckerboardPattern_default from "../misc/CheckerboardPattern.js";
12
12
  import StoryVariantSinglePreviewRemote_default from "./StoryVariantSinglePreviewRemote.js";
13
13
  import { useResizeObserver } from "@poveste/vendors/vue-use";
@@ -2,6 +2,6 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
2
2
  import StoryVariantSingle_vue_vue_type_script_setup_true_lang_default from "./StoryVariantSingle.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/app/components/story/StoryVariantSingle.vue
5
- var StoryVariantSingle_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StoryVariantSingle_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-db50bc8f"]]);
5
+ var StoryVariantSingle_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StoryVariantSingle_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-6b31fb1b"]]);
6
6
  //#endregion
7
7
  export { StoryVariantSingle_default as default };
@@ -1,74 +1,59 @@
1
1
  import { isMobile } from "../../util/responsive.js";
2
2
  import { useStoryStore } from "../../stores/story.js";
3
3
  import BaseSplitPane_default from "../base/BaseSplitPane.js";
4
+ import { autoSelectsVariant } from "../../util/variant.js";
4
5
  import StoryVariantListItem_default from "./StoryVariantListItem.js";
5
6
  import StoryVariantSingleView_default from "./StoryVariantSingleView.js";
6
7
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, openBlock, renderList, toDisplayString, unref, useCssVars, withCtx } from "@poveste/vendors/vue";
7
8
  import { Icon } from "@poveste/vendors/iconify";
8
9
  //#region src/app/components/story/StoryVariantSingle.vue?vue&type=script&setup=true&lang.ts
9
- var _hoisted_1 = {
10
- key: 0,
11
- class: "poveste-story-variant-single p-2 h-full __poveste-pane-shadow-from-right"
12
- };
10
+ var _hoisted_1 = { class: "h-full overflow-y-auto" };
13
11
  var _hoisted_2 = {
14
- key: 0,
15
- class: "divide-y divide-gray-100 dark:divide-gray-800 h-full flex flex-col"
16
- };
17
- var _hoisted_3 = {
18
- key: 0,
19
- class: "p-2 h-full"
20
- };
21
- var _hoisted_4 = { class: "h-full overflow-y-auto" };
22
- var _hoisted_5 = {
23
- key: 0,
24
- class: "p-2 h-full __poveste-pane-shadow-from-right"
12
+ key: 1,
13
+ class: "poveste-story-variant-single p-2 h-full __poveste-pane-shadow-from-right"
25
14
  };
26
15
  var StoryVariantSingle_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
27
16
  __name: "StoryVariantSingle",
28
17
  emits: { openVariantMenu: () => true },
29
18
  setup(__props) {
30
- useCssVars((_ctx) => ({ "dd8d1ad8": variant.value?.iconColor }));
19
+ useCssVars((_ctx) => ({ "v0fc28fe3": variant.value?.iconColor }));
31
20
  const storyStore = useStoryStore();
32
21
  const hasSingleVariant = computed(() => storyStore.currentStory?.variants.length === 1);
33
- const variant = computed(() => storyStore.currentVariant);
22
+ const variant = computed(() => storyStore.currentVariant ?? null);
23
+ const showsPreview = computed(() => !!variant.value || autoSelectsVariant(storyStore.currentStory));
34
24
  return (_ctx, _cache) => {
35
- return hasSingleVariant.value && variant.value ? (openBlock(), createElementBlock("div", _hoisted_1, [createVNode(StoryVariantSingleView_default, {
36
- variant: variant.value,
37
- story: unref(storyStore).currentStory
38
- }, null, 8, ["variant", "story"])])) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [unref(isMobile) ? (openBlock(), createElementBlock("div", _hoisted_2, [createElementVNode("a", {
39
- class: "px-6 h-12 hover:text-primary-500 dark:hover:text-primary-400 cursor-pointer flex gap-2 flex-wrap w-full items-center flex-none",
40
- onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("openVariantMenu"))
41
- }, [variant.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(Icon), {
42
- icon: variant.value.icon ?? "carbon:cube",
43
- class: normalizeClass(["w-5 h-5 flex-none", {
44
- "text-gray-500": !variant.value.iconColor,
45
- "bind-icon-color": variant.value.iconColor
46
- }])
47
- }, null, 8, ["icon", "class"]), createTextVNode(" " + toDisplayString(variant.value.title), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" Select a variant... ")], 64)), createVNode(unref(Icon), {
48
- icon: "carbon:chevron-sort",
49
- class: "w-5 h-5 shrink-0 ml-auto"
50
- })]), unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(StoryVariantSingleView_default, {
51
- variant: unref(storyStore).currentVariant,
52
- story: unref(storyStore).currentStory
53
- }, null, 8, ["variant", "story"])])) : createCommentVNode("", true)])) : (openBlock(), createBlock(BaseSplitPane_default, {
54
- key: 1,
25
+ return openBlock(), createBlock(BaseSplitPane_default, {
55
26
  "save-id": "story-single-main-split",
56
27
  min: 5,
57
28
  max: 40,
58
- "default-split": 17
29
+ "default-split": 17,
30
+ "show-first": !unref(isMobile) && !hasSingleVariant.value
59
31
  }, {
60
- first: withCtx(() => [createElementVNode("div", _hoisted_4, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory.variants, (v, index) => {
32
+ first: withCtx(() => [createElementVNode("div", _hoisted_1, [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(storyStore).currentStory?.variants ?? [], (v, index) => {
61
33
  return openBlock(), createBlock(StoryVariantListItem_default, {
62
34
  key: index,
63
35
  variant: v
64
36
  }, null, 8, ["variant"]);
65
37
  }), 128))])]),
66
- last: withCtx(() => [unref(storyStore).currentVariant ? (openBlock(), createElementBlock("div", _hoisted_5, [createVNode(StoryVariantSingleView_default, {
67
- variant: unref(storyStore).currentVariant,
38
+ last: withCtx(() => [createElementVNode("div", { class: normalizeClass(["h-full flex flex-col", { "divide-y divide-gray-100 dark:divide-gray-800": unref(isMobile) }]) }, [unref(isMobile) && (!hasSingleVariant.value || !variant.value) ? (openBlock(), createElementBlock("a", {
39
+ key: 0,
40
+ class: "px-6 h-12 hover:text-primary-500 dark:hover:text-primary-400 cursor-pointer flex gap-2 flex-wrap w-full items-center flex-none",
41
+ onClick: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("openVariantMenu"))
42
+ }, [variant.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [createVNode(unref(Icon), {
43
+ icon: variant.value.icon ?? "carbon:cube",
44
+ class: normalizeClass(["w-5 h-5 flex-none", {
45
+ "text-gray-500": !variant.value.iconColor,
46
+ "bind-icon-color": variant.value.iconColor
47
+ }])
48
+ }, null, 8, ["icon", "class"]), createTextVNode(" " + toDisplayString(variant.value.title), 1)], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [createTextVNode(" Select a variant... ")], 64)), createVNode(unref(Icon), {
49
+ icon: "carbon:chevron-sort",
50
+ class: "w-5 h-5 shrink-0 ml-auto"
51
+ })])) : createCommentVNode("", true), showsPreview.value ? (openBlock(), createElementBlock("div", _hoisted_2, [createVNode(StoryVariantSingleView_default, {
52
+ variant: variant.value,
68
53
  story: unref(storyStore).currentStory
69
- }, null, 8, ["variant", "story"])])) : createCommentVNode("", true)]),
54
+ }, null, 8, ["variant", "story"])])) : createCommentVNode("", true)], 2)]),
70
55
  _: 1
71
- }))], 64));
56
+ }, 8, ["show-first"]);
72
57
  };
73
58
  }
74
59
  });
@@ -5,7 +5,7 @@ import { getContrastColor } from "../../util/preview-settings.js";
5
5
  import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
6
6
  import GenericRenderStory_default from "./GenericRenderStory.js";
7
7
  import StoryResponsivePreview_default from "./StoryResponsivePreview.js";
8
- import { computed, createBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, unref, withCtx } from "@poveste/vendors/vue";
8
+ import { computed, createBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, unref, watch, withCtx } from "@poveste/vendors/vue";
9
9
  //#region src/app/components/story/StoryVariantSinglePreviewNative.vue?vue&type=script&setup=true&lang.ts
10
10
  var StoryVariantSinglePreviewNative_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
11
11
  __name: "StoryVariantSinglePreviewNative",
@@ -16,7 +16,10 @@ var StoryVariantSinglePreviewNative_vue_vue_type_script_setup_true_lang_default
16
16
  setup(__props) {
17
17
  const props = __props;
18
18
  const storyStore = useStoryStore();
19
- storyStore.setPreviewReady(props.variant, false);
19
+ watch(() => props.variant, (variant, previous) => {
20
+ if (previous) storyStore.setPreviewReady(previous, false);
21
+ storyStore.setPreviewReady(variant, false);
22
+ }, { immediate: true });
20
23
  function onReady() {
21
24
  storyStore.setPreviewReady(props.variant, true);
22
25
  }
@@ -83,6 +83,7 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
83
83
  updateVariantState(event.data.state);
84
84
  break;
85
85
  case EVENT_SEND:
86
+ if (!fromCurrentOccupant(event.data)) break;
86
87
  logEvent(event.data.event);
87
88
  break;
88
89
  case SANDBOX_READY:
@@ -134,6 +135,7 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
134
135
  const isIframeLoaded = ref(false);
135
136
  let retargets = 0;
136
137
  let servedStory = props.story;
138
+ let servedVariant = props.variant;
137
139
  let stopTrackKeyboard;
138
140
  let unmounted = false;
139
141
  function reload(url) {
@@ -150,6 +152,8 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
150
152
  }
151
153
  watch(sandboxUrl, (url) => {
152
154
  bridge = createStateBridge(postState);
155
+ if (servedVariant && servedVariant !== props.variant) storyStore.setPreviewReady(servedVariant, false);
156
+ servedVariant = props.variant;
153
157
  storyStore.setPreviewReady(props.variant, false);
154
158
  const reuse = props.story.layout?.isolate !== true && servedStory.layout?.isolate !== true;
155
159
  const target = iframe.value?.contentWindow;
@@ -1,28 +1,38 @@
1
+ import { autoSelectsVariant } from "../../util/variant.js";
1
2
  import StoryVariantSinglePreviewRemote_default from "./StoryVariantSinglePreviewRemote.js";
2
3
  import StoryVariantSinglePreviewNative_default from "./StoryVariantSinglePreviewNative.js";
3
- import { createBlock, createElementBlock, defineComponent, openBlock } from "@poveste/vendors/vue";
4
+ import { Fragment, createBlock, createCommentVNode, createElementBlock, defineComponent, normalizeClass, openBlock, shallowRef, watchEffect } from "@poveste/vendors/vue";
4
5
  //#region src/app/components/story/StoryVariantSingleView.vue?vue&type=script&setup=true&lang.ts
5
- var _hoisted_1 = {
6
- class: "poveste-story-variant-single-view h-full flex flex-col",
7
- "data-testid": "story-variant-single-view"
8
- };
9
6
  var StoryVariantSingleView_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
10
7
  __name: "StoryVariantSingleView",
11
8
  props: {
12
- variant: {},
13
- story: {}
9
+ story: {},
10
+ variant: {}
14
11
  },
15
12
  setup(__props) {
13
+ const props = __props;
14
+ const shown = shallowRef(null);
15
+ watchEffect(() => {
16
+ const story = props.story;
17
+ if (story && props.variant) shown.value = {
18
+ story,
19
+ variant: props.variant
20
+ };
21
+ else if (shown.value && shown.value.story !== story && !autoSelectsVariant(story)) shown.value = null;
22
+ });
16
23
  return (_ctx, _cache) => {
17
- return openBlock(), createElementBlock("div", _hoisted_1, [__props.story.layout?.iframe === false ? (openBlock(), createBlock(StoryVariantSinglePreviewNative_default, {
24
+ return openBlock(), createElementBlock("div", {
25
+ class: normalizeClass(["poveste-story-variant-single-view h-full flex flex-col", { invisible: !__props.variant }]),
26
+ "data-testid": "story-variant-single-view"
27
+ }, [shown.value ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [shown.value.story.layout?.type === "single" && shown.value.story.layout.iframe === false ? (openBlock(), createBlock(StoryVariantSinglePreviewNative_default, {
18
28
  key: 0,
19
- story: __props.story,
20
- variant: __props.variant
29
+ story: shown.value.story,
30
+ variant: shown.value.variant
21
31
  }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(StoryVariantSinglePreviewRemote_default, {
22
32
  key: 1,
23
- story: __props.story,
24
- variant: __props.variant
25
- }, null, 8, ["story", "variant"]))]);
33
+ story: shown.value.story,
34
+ variant: shown.value.variant
35
+ }, null, 8, ["story", "variant"]))], 64)) : createCommentVNode("", true)], 2);
26
36
  };
27
37
  }
28
38
  });
@@ -3,6 +3,7 @@ import { useStoryStore } from "../../stores/story.js";
3
3
  import BaseSplitPane_default from "../base/BaseSplitPane.js";
4
4
  import { useLayoutStore } from "../../stores/layout.js";
5
5
  import BaseEmpty_default from "../base/BaseEmpty.js";
6
+ import { autoSelectsVariant } from "../../util/variant.js";
6
7
  import StoryDocs_default from "../panel/StoryDocs.js";
7
8
  import StorySidePanel_default from "../panel/StorySidePanel.js";
8
9
  import StoryViewer_default from "./StoryViewer.js";
@@ -19,7 +20,7 @@ var StoryView_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
19
20
  setup(__props) {
20
21
  const storyStore = useStoryStore();
21
22
  const layoutStore = useLayoutStore();
22
- const effectiveStoryOptionsVisible = computed(() => storyStore.currentStory?.meta?.storyOptions ?? layoutStore.settings.storyOptionsVisible);
23
+ const effectiveStoryOptionsVisible = computed(() => !!(storyStore.currentStory?.meta?.storyOptions ?? layoutStore.settings.storyOptionsVisible));
23
24
  const placement = computed(() => layoutStore.settings.storyOptionsPlacement);
24
25
  const splitOrientation = computed(() => placement.value === "bottom" ? "portrait" : "landscape");
25
26
  const splitDefaultSplit = computed(() => placement.value === "bottom" ? 60 : 75);
@@ -29,13 +30,7 @@ var StoryView_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
29
30
  if (value) storyStore.currentStory.lastSelectedVariant = value;
30
31
  }, { immediate: true });
31
32
  watch(() => [storyStore.currentStory, storyStore.currentVariant], () => {
32
- if (!storyStore.currentVariant) {
33
- if (storyStore.currentStory?.lastSelectedVariant) {
34
- setVariant(storyStore.currentStory.lastSelectedVariant.id);
35
- return;
36
- }
37
- if (storyStore.currentStory?.variants.length === 1) setVariant(storyStore.currentStory.variants[0].id);
38
- }
33
+ if (!storyStore.currentVariant && autoSelectsVariant(storyStore.currentStory)) setVariant((storyStore.currentStory.lastSelectedVariant ?? storyStore.currentStory.variants[0]).id);
39
34
  }, { immediate: true });
40
35
  function setVariant(variantId) {
41
36
  router.replace({
@@ -70,14 +65,15 @@ var StoryView_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
70
65
  standalone: "",
71
66
  class: "md:p-12 w-full md:max-w-[600px] lg:max-w-[800px] xl:max-w-[900px]",
72
67
  onScrollTop: _cache[0] || (_cache[0] = ($event) => scrollDocsToTop())
73
- }, null, 8, ["story"])], 512)) : unref(isMobile) ? (openBlock(), createBlock(StoryViewer_default, { key: 1 })) : !effectiveStoryOptionsVisible.value ? (openBlock(), createBlock(StoryViewer_default, { key: 2 })) : (openBlock(), createBlock(BaseSplitPane_default, {
74
- key: 3,
68
+ }, null, 8, ["story"])], 512)) : (openBlock(), createBlock(BaseSplitPane_default, {
69
+ key: 1,
75
70
  "save-id": `story-main-${placement.value}`,
76
71
  orientation: splitOrientation.value,
77
72
  min: 30,
78
73
  max: 95,
79
74
  "default-split": splitDefaultSplit.value,
80
75
  "show-divider": false,
76
+ "show-last": !unref(isMobile) && effectiveStoryOptionsVisible.value,
81
77
  class: "h-full"
82
78
  }, {
83
79
  first: withCtx(() => [createVNode(StoryViewer_default)]),
@@ -86,7 +82,8 @@ var StoryView_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ define
86
82
  }, 8, [
87
83
  "save-id",
88
84
  "orientation",
89
- "default-split"
85
+ "default-split",
86
+ "show-last"
90
87
  ]))]));
91
88
  };
92
89
  }
@@ -1,7 +1,5 @@
1
- import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export-helper.js";
2
1
  import ToolbarBackground_vue_vue_type_script_setup_true_lang_default from "./ToolbarBackground.vue_vue_type_script_setup_true_lang.js";
3
- /* empty css */
4
2
  //#region src/app/components/toolbar/ToolbarBackground.vue
5
- var ToolbarBackground_default = /*#__PURE__*/ _plugin_vue_export_helper_default(ToolbarBackground_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-ed785ad4"]]);
3
+ var ToolbarBackground_default = ToolbarBackground_vue_vue_type_script_setup_true_lang_default;
6
4
  //#endregion
7
5
  export { ToolbarBackground_default as default };
@@ -1,7 +1,7 @@
1
1
  import { povesteConfig } from "../../util/config.js";
2
2
  import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
3
3
  import BaseCheckbox_default from "../base/BaseCheckbox.js";
4
- import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderList, resolveComponent, resolveDirective, toDisplayString, unref, useCssVars, withCtx, withDirectives } from "@poveste/vendors/vue";
4
+ import { Fragment, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, renderList, resolveComponent, resolveDirective, toDisplayString, unref, withCtx, withDirectives } from "@poveste/vendors/vue";
5
5
  import { Icon } from "@poveste/vendors/iconify";
6
6
  //#region src/app/components/toolbar/ToolbarBackground.vue?vue&type=script&setup=true&lang.ts
7
7
  var _hoisted_1 = { class: "flex items-center gap-1 px-2.5 py-1.5 hover:bg-white/50 dark:hover:bg-white/10 hover:text-primary-500 dark:hover:text-primary-400 cursor-pointer text-gray-900 dark:text-gray-100 transition-colors group" };
@@ -22,10 +22,6 @@ var _hoisted_8 = { key: 0 };
22
22
  var ToolbarBackground_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
23
23
  __name: "ToolbarBackground",
24
24
  setup(__props) {
25
- useCssVars((_ctx) => ({
26
- "ca113a48": unref(settings).backgroundColor,
27
- "v0083f4ef": _ctx.contrastColor
28
- }));
29
25
  const previewSettings = usePreviewSettingsStore();
30
26
  const settings = previewSettings.currentSettings;
31
27
  const colorSchemeOptions = [
@@ -1,5 +1,6 @@
1
1
  import { isDark } from "./util/dark.js";
2
2
  import { PREVIEW_SETTINGS_REQUEST, SANDBOX_HEIGHT, SANDBOX_READY, STATE_SYNC } from "./util/const.js";
3
+ import { occupant } from "./util/occupant.js";
3
4
  import { previewDarkClasses, resolvePreviewDark } from "./util/color-scheme.js";
4
5
  import { applyPreviewSettings, loadStoredPreviewSettings, receivedSettings } from "./util/preview-settings.js";
5
6
  import GenericMountStory_default from "./components/story/GenericMountStory.js";
@@ -9,7 +10,7 @@ import { createStateBridge } from "./util/state-bridge.js";
9
10
  import { toRawDeep } from "./util/state.js";
10
11
  import { isBenignResizeObserverEvent } from "./util/uncaught.js";
11
12
  import { usePreferredDark } from "@poveste/vendors/vue-use";
12
- import { computed, createApp, h, onMounted, ref, watch } from "@poveste/vendors/vue";
13
+ import { computed, createApp, h, onMounted, ref, watch, watchEffect } from "@poveste/vendors/vue";
13
14
  import { createPinia } from "@poveste/vendors/pinia";
14
15
  import { files, onUpdate } from "virtual:$poveste-stories";
15
16
  import { parseQuery } from "@poveste/vendors/vue-router";
@@ -18,6 +19,10 @@ import { reportStoryError } from "@poveste/shared";
18
19
  var query = parseQuery(window.location.search);
19
20
  var storyId = ref(typeof query.storyId === "string" ? query.storyId : null);
20
21
  var variantId = ref(typeof query.variantId === "string" ? query.variantId : null);
22
+ watchEffect(() => {
23
+ occupant.storyId = storyId.value;
24
+ occupant.variantId = variantId.value;
25
+ });
21
26
  var file = ref(null);
22
27
  function resolveFile(list = files) {
23
28
  const found = list.find((f) => f.id === storyId.value);
@@ -1,4 +1,5 @@
1
1
  import { EVENT_SEND } from "./const.js";
2
+ import { occupant } from "./occupant.js";
2
3
  //#region src/app/util/events.ts
3
4
  async function logEvent(name, argument) {
4
5
  const event = {
@@ -7,7 +8,9 @@ async function logEvent(name, argument) {
7
8
  };
8
9
  if (location.href.includes("__sandbox")) window.parent?.postMessage({
9
10
  type: EVENT_SEND,
10
- event
11
+ event,
12
+ storyId: occupant.storyId,
13
+ variantId: occupant.variantId
11
14
  });
12
15
  else {
13
16
  const { useEventsStore } = await import("../stores/events.js");
@@ -1,4 +1,5 @@
1
- import { createHighlighter } from "shiki";
1
+ import { createHighlighterCore } from "shiki/core";
2
+ import { createOnigurumaEngine } from "shiki/engine/oniguruma";
2
3
  //#region src/app/util/highlighter.ts
3
4
  /**
4
5
  * Shiki is meant to be used as a singleton: each instance carries its own WASM
@@ -9,10 +10,16 @@ import { createHighlighter } from "shiki";
9
10
  * The langs and themes are fixed, so one shared instance is always correct.
10
11
  */
11
12
  var highlighterPromise;
13
+ /**
14
+ * `shiki/core`, not `shiki`: the latter is the full-bundle entry and ships every
15
+ * grammar and theme whatever the options ask for — 10 MB a book (#304). The
16
+ * dynamic imports are the interface, not a lazy-loading choice.
17
+ */
12
18
  function getHighlighter() {
13
- highlighterPromise ??= createHighlighter({
14
- langs: ["html", "jsx"],
15
- themes: ["github-light", "github-dark"]
19
+ highlighterPromise ??= createHighlighterCore({
20
+ langs: [import("shiki/langs/html.mjs"), import("shiki/langs/jsx.mjs")],
21
+ themes: [import("shiki/themes/github-light-high-contrast.mjs"), import("shiki/themes/github-dark.mjs")],
22
+ engine: createOnigurumaEngine(import("shiki/wasm"))
16
23
  }).catch((e) => {
17
24
  highlighterPromise = void 0;
18
25
  throw e;
@@ -46,7 +46,11 @@ function mapVariant(variant, existingVariant) {
46
46
  _hPropDefs: {}
47
47
  }),
48
48
  setupApp: null,
49
- slots: () => ({}),
49
+ slots: () => ({
50
+ default: void 0,
51
+ controls: void 0,
52
+ source: void 0
53
+ }),
50
54
  previewReady: false
51
55
  };
52
56
  return result;
@@ -0,0 +1,16 @@
1
+ //#region src/app/util/occupant.ts
2
+ /**
3
+ * What the sandbox realm is currently showing.
4
+ *
5
+ * The realm is reused: a `SANDBOX_RETARGET` hands it another story rather than
6
+ * booting a new document, so a message can outlive the occupant that queued it.
7
+ * Every message `sandbox.ts` posts already carries these ids for that reason;
8
+ * this module exists so `logEvent` — which posts from wherever a story calls it,
9
+ * not from `sandbox.ts` — can carry them too (#328).
10
+ */
11
+ var occupant = {
12
+ storyId: null,
13
+ variantId: null
14
+ };
15
+ //#endregion
16
+ export { occupant };
@@ -1,6 +1,17 @@
1
1
  import { computed } from "@poveste/vendors/vue";
2
2
  import { useRoute } from "@poveste/vendors/vue-router";
3
3
  //#region src/app/util/variant.ts
4
+ /**
5
+ * Whether opening this story will put a variant in the route by itself.
6
+ *
7
+ * `StoryView` resolves the variant one tick after the story, so anything that
8
+ * has to tell "a variant is on its way" from "this story is waiting for the
9
+ * reader to pick one" needs the same answer it will give — hence one predicate
10
+ * rather than two copies of the condition (#328).
11
+ */
12
+ function autoSelectsVariant(story) {
13
+ return !!story && (!!story.lastSelectedVariant || story.variants.length === 1);
14
+ }
4
15
  function useCurrentVariantRoute(variant) {
5
16
  const route = useRoute();
6
17
  return {
@@ -15,4 +26,4 @@ function useCurrentVariantRoute(variant) {
15
26
  };
16
27
  }
17
28
  //#endregion
18
- export { useCurrentVariantRoute };
29
+ export { autoSelectsVariant, useCurrentVariantRoute };
package/dist/style.css CHANGED
@@ -174,10 +174,6 @@
174
174
  .bind-col-size {
175
175
  grid-template-columns: repeat(auto-fill, minmax(var(--poveste-col-size), 1fr));
176
176
  }
177
- .__poveste-json-code[data-v-e4c89a1b] .cm-editor {
178
- min-width: 280px;
179
- height: 100%;
180
- }
181
177
  .v-popper {
182
178
  line-height: 0;
183
179
  }
@@ -278,6 +274,10 @@
278
274
  inherits: false;
279
275
  initial-value: solid;
280
276
  }
277
+ .__poveste-json-code[data-v-e4c89a1b] .cm-editor {
278
+ min-width: 280px;
279
+ height: 100%;
280
+ }
281
281
  .v-popper {
282
282
  line-height: 0;
283
283
  }
@@ -1625,6 +1625,9 @@
1625
1625
  background-color: color-mix(in oklab, var(--color-primary-500) 25%, transparent);
1626
1626
  }
1627
1627
  }
1628
+ .bg-primary-700 {
1629
+ background-color: var(--color-primary-700);
1630
+ }
1628
1631
  .bg-transparent {
1629
1632
  background-color: transparent;
1630
1633
  }
@@ -1861,8 +1864,8 @@
1861
1864
  .text-primary-500 {
1862
1865
  color: var(--color-primary-500);
1863
1866
  }
1864
- .text-primary-600 {
1865
- color: var(--color-primary-600);
1867
+ .text-primary-700 {
1868
+ color: var(--color-primary-700);
1866
1869
  }
1867
1870
  .text-primary-800 {
1868
1871
  color: var(--color-primary-800);
@@ -2130,6 +2133,9 @@
2130
2133
  .hover\:bg-primary-600:hover {
2131
2134
  background-color: var(--color-primary-600);
2132
2135
  }
2136
+ .hover\:bg-primary-800:hover {
2137
+ background-color: var(--color-primary-800);
2138
+ }
2133
2139
  .hover\:bg-white\/50:hover {
2134
2140
  background-color: color-mix(in srgb, #fff 50%, transparent);
2135
2141
  }
@@ -2288,6 +2294,9 @@
2288
2294
  .dark\:bg-primary-400:where(.ptw-dark, .ptw-dark *) {
2289
2295
  background-color: var(--color-primary-400);
2290
2296
  }
2297
+ .dark\:bg-primary-500:where(.ptw-dark, .ptw-dark *) {
2298
+ background-color: var(--color-primary-500);
2299
+ }
2291
2300
  .dark\:bg-primary-600:where(.ptw-dark, .ptw-dark *) {
2292
2301
  background-color: var(--color-primary-600);
2293
2302
  }
@@ -2385,6 +2394,9 @@
2385
2394
  .dark\:hover\:bg-gray-800:where(.ptw-dark, .ptw-dark *):hover {
2386
2395
  background-color: var(--color-gray-800);
2387
2396
  }
2397
+ .dark\:hover\:bg-primary-600:where(.ptw-dark, .ptw-dark *):hover {
2398
+ background-color: var(--color-primary-600);
2399
+ }
2388
2400
  .dark\:hover\:bg-primary-700:where(.ptw-dark, .ptw-dark *):hover {
2389
2401
  background-color: var(--color-primary-700);
2390
2402
  }