@poveste/app 0.1.1 → 0.1.3

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 (184) hide show
  1. package/dist/app/assets/poveste-text-dark.svg +15 -0
  2. package/dist/app/assets/poveste-text.svg +15 -0
  3. package/dist/app/assets/poveste.svg +14 -0
  4. package/dist/app/style/floating.pcss +34 -0
  5. package/dist/app/style/main.pcss +100 -0
  6. package/dist/app/style/sandbox.css +24 -0
  7. package/dist/app/style/transitions.pcss +51 -0
  8. package/dist/bundle-index.js +1 -0
  9. package/dist/bundle-main-dev.js +4 -0
  10. package/dist/bundle-main.js +5 -0
  11. package/dist/bundle-sandbox-dev.js +2 -0
  12. package/dist/bundle-sandbox.js +2 -0
  13. package/dist/bundled/App.vue.js +5 -0
  14. package/dist/bundled/App.vue2.js +167 -0
  15. package/dist/bundled/_virtual/_plugin-vue_export-helper.js +10 -0
  16. package/dist/bundled/api.js +12 -0
  17. package/dist/bundled/app.css +116 -0
  18. package/dist/bundled/assets/poveste-text-dark.svg.js +4 -0
  19. package/dist/bundled/assets/poveste-text.svg.js +4 -0
  20. package/dist/bundled/assets/poveste.svg.js +4 -0
  21. package/dist/bundled/components/HomeView.vue.js +5 -0
  22. package/dist/bundled/components/HomeView.vue2.js +66 -0
  23. package/dist/bundled/components/app/AppHeader.vue.js +5 -0
  24. package/dist/bundled/components/app/AppHeader.vue2.js +71 -0
  25. package/dist/bundled/components/app/AppLogo.vue.js +5 -0
  26. package/dist/bundled/components/app/AppLogo.vue2.js +29 -0
  27. package/dist/bundled/components/app/Breadcrumb.vue.js +8 -0
  28. package/dist/bundled/components/app/Breadcrumb.vue2.js +91 -0
  29. package/dist/bundled/components/app/HomeCounter.vue.js +5 -0
  30. package/dist/bundled/components/app/HomeCounter.vue2.js +42 -0
  31. package/dist/bundled/components/app/InitialLoading.vue.js +5 -0
  32. package/dist/bundled/components/app/InitialLoading.vue2.js +51 -0
  33. package/dist/bundled/components/app/MobileOverlay.vue.js +5 -0
  34. package/dist/bundled/components/app/MobileOverlay.vue2.js +45 -0
  35. package/dist/bundled/components/base/BaseButton.vue.js +5 -0
  36. package/dist/bundled/components/base/BaseButton.vue2.js +39 -0
  37. package/dist/bundled/components/base/BaseCheckbox.vue.js +5 -0
  38. package/dist/bundled/components/base/BaseCheckbox.vue2.js +78 -0
  39. package/dist/bundled/components/base/BaseEmpty.vue.js +14 -0
  40. package/dist/bundled/components/base/BaseIcon.vue.js +8 -0
  41. package/dist/bundled/components/base/BaseIcon.vue2.js +29 -0
  42. package/dist/bundled/components/base/BaseKeyboardShortcut.vue.js +5 -0
  43. package/dist/bundled/components/base/BaseKeyboardShortcut.vue2.js +20 -0
  44. package/dist/bundled/components/base/BaseListItem.vue.js +5 -0
  45. package/dist/bundled/components/base/BaseListItem.vue2.js +33 -0
  46. package/dist/bundled/components/base/BaseListItemLink.vue.js +33 -0
  47. package/dist/bundled/components/base/BaseListItemLink.vue2.js +26 -0
  48. package/dist/bundled/components/base/BaseOverflowMenu.vue.js +5 -0
  49. package/dist/bundled/components/base/BaseOverflowMenu.vue2.js +100 -0
  50. package/dist/bundled/components/base/BaseOverflowTab.vue.js +36 -0
  51. package/dist/bundled/components/base/BaseOverflowTab.vue2.js +18 -0
  52. package/dist/bundled/components/base/BaseSelect.vue.js +5 -0
  53. package/dist/bundled/components/base/BaseSelect.vue2.js +77 -0
  54. package/dist/bundled/components/base/BaseSplitPane.vue.js +8 -0
  55. package/dist/bundled/components/base/BaseSplitPane.vue2.js +183 -0
  56. package/dist/bundled/components/base/BaseTab.vue.js +36 -0
  57. package/dist/bundled/components/base/BaseTab.vue2.js +18 -0
  58. package/dist/bundled/components/base/BaseTag.vue.js +13 -0
  59. package/dist/bundled/components/command/CommandPrompts.vue.js +5 -0
  60. package/dist/bundled/components/command/CommandPrompts.vue2.js +91 -0
  61. package/dist/bundled/components/command/CommandPromptsModal.vue.js +5 -0
  62. package/dist/bundled/components/command/CommandPromptsModal.vue2.js +45 -0
  63. package/dist/bundled/components/command/PromptSelect.vue.js +5 -0
  64. package/dist/bundled/components/command/PromptSelect.vue2.js +142 -0
  65. package/dist/bundled/components/command/PromptText.vue.js +5 -0
  66. package/dist/bundled/components/command/PromptText.vue2.js +67 -0
  67. package/dist/bundled/components/misc/CheckerboardPattern.vue.js +40 -0
  68. package/dist/bundled/components/misc/HatchedPattern.vue.js +12 -0
  69. package/dist/bundled/components/panel/ControlsComponentPropItem.vue.js +5 -0
  70. package/dist/bundled/components/panel/ControlsComponentPropItem.vue2.js +72 -0
  71. package/dist/bundled/components/panel/ControlsComponentProps.vue.js +5 -0
  72. package/dist/bundled/components/panel/ControlsComponentProps.vue2.js +45 -0
  73. package/dist/bundled/components/panel/ControlsComponentState.vue.js +5 -0
  74. package/dist/bundled/components/panel/ControlsComponentState.vue2.js +41 -0
  75. package/dist/bundled/components/panel/ControlsComponentStateItem.vue.js +5 -0
  76. package/dist/bundled/components/panel/ControlsComponentStateItem.vue2.js +46 -0
  77. package/dist/bundled/components/panel/PaneTabs.vue.js +5 -0
  78. package/dist/bundled/components/panel/PaneTabs.vue2.js +114 -0
  79. package/dist/bundled/components/panel/StatePresets.vue.js +5 -0
  80. package/dist/bundled/components/panel/StatePresets.vue2.js +193 -0
  81. package/dist/bundled/components/panel/StoryControls.vue.js +5 -0
  82. package/dist/bundled/components/panel/StoryControls.vue2.js +87 -0
  83. package/dist/bundled/components/panel/StoryDocs.vue.js +7 -0
  84. package/dist/bundled/components/panel/StoryDocs.vue2.js +161 -0
  85. package/dist/bundled/components/panel/StoryEvent.vue.js +5 -0
  86. package/dist/bundled/components/panel/StoryEvent.vue2.js +59 -0
  87. package/dist/bundled/components/panel/StoryEvents.vue.js +5 -0
  88. package/dist/bundled/components/panel/StoryEvents.vue2.js +53 -0
  89. package/dist/bundled/components/panel/StorySidePanel.vue.js +5 -0
  90. package/dist/bundled/components/panel/StorySidePanel.vue2.js +83 -0
  91. package/dist/bundled/components/panel/StorySourceCode.vue.js +8 -0
  92. package/dist/bundled/components/panel/StorySourceCode.vue2.js +204 -0
  93. package/dist/bundled/components/search/SearchItem.vue.js +8 -0
  94. package/dist/bundled/components/search/SearchItem.vue2.js +93 -0
  95. package/dist/bundled/components/search/SearchItemContent.vue.js +5 -0
  96. package/dist/bundled/components/search/SearchItemContent.vue2.js +71 -0
  97. package/dist/bundled/components/search/SearchLoading.vue.js +5 -0
  98. package/dist/bundled/components/search/SearchLoading.vue2.js +21 -0
  99. package/dist/bundled/components/search/SearchModal.vue.js +5 -0
  100. package/dist/bundled/components/search/SearchModal.vue2.js +51 -0
  101. package/dist/bundled/components/search/SearchPane.vue.js +5 -0
  102. package/dist/bundled/components/search/SearchPane.vue2.js +272 -0
  103. package/dist/bundled/components/search/search-docs-data.js +11 -0
  104. package/dist/bundled/components/search/search-title-data.js +11 -0
  105. package/dist/bundled/components/story/GenericMountStory.vue.js +5 -0
  106. package/dist/bundled/components/story/GenericMountStory.vue2.js +34 -0
  107. package/dist/bundled/components/story/GenericRenderStory.vue.js +5 -0
  108. package/dist/bundled/components/story/GenericRenderStory.vue2.js +39 -0
  109. package/dist/bundled/components/story/StoryResponsivePreview.vue.js +8 -0
  110. package/dist/bundled/components/story/StoryResponsivePreview.vue2.js +207 -0
  111. package/dist/bundled/components/story/StoryVariantGrid.vue.js +5 -0
  112. package/dist/bundled/components/story/StoryVariantGrid.vue2.js +146 -0
  113. package/dist/bundled/components/story/StoryVariantGridItem.vue.js +8 -0
  114. package/dist/bundled/components/story/StoryVariantGridItem.vue2.js +155 -0
  115. package/dist/bundled/components/story/StoryVariantListItem.vue.js +8 -0
  116. package/dist/bundled/components/story/StoryVariantListItem.vue2.js +55 -0
  117. package/dist/bundled/components/story/StoryVariantSingle.vue.js +8 -0
  118. package/dist/bundled/components/story/StoryVariantSingle.vue2.js +107 -0
  119. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue.js +5 -0
  120. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue2.js +72 -0
  121. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue.js +5 -0
  122. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue2.js +128 -0
  123. package/dist/bundled/components/story/StoryVariantSingleView.vue.js +5 -0
  124. package/dist/bundled/components/story/StoryVariantSingleView.vue2.js +66 -0
  125. package/dist/bundled/components/story/StoryView.vue.js +5 -0
  126. package/dist/bundled/components/story/StoryView.vue2.js +104 -0
  127. package/dist/bundled/components/story/StoryViewer.vue.js +8 -0
  128. package/dist/bundled/components/story/StoryViewer.vue2.js +55 -0
  129. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue.js +5 -0
  130. package/dist/bundled/components/toolbar/DevOnlyToolbarOpenInEditor.vue2.js +31 -0
  131. package/dist/bundled/components/toolbar/ToolbarBackground.vue.js +8 -0
  132. package/dist/bundled/components/toolbar/ToolbarBackground.vue2.js +98 -0
  133. package/dist/bundled/components/toolbar/ToolbarNewTab.vue.js +5 -0
  134. package/dist/bundled/components/toolbar/ToolbarNewTab.vue2.js +36 -0
  135. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue.js +5 -0
  136. package/dist/bundled/components/toolbar/ToolbarResponsiveSize.vue2.js +127 -0
  137. package/dist/bundled/components/toolbar/ToolbarTextDirection.vue.js +5 -0
  138. package/dist/bundled/components/toolbar/ToolbarTextDirection.vue2.js +27 -0
  139. package/dist/bundled/components/toolbar/ToolbarTitle.vue.js +5 -0
  140. package/dist/bundled/components/toolbar/ToolbarTitle.vue2.js +26 -0
  141. package/dist/bundled/components/tree/StoryGroup.vue.js +5 -0
  142. package/dist/bundled/components/tree/StoryGroup.vue2.js +74 -0
  143. package/dist/bundled/components/tree/StoryList.vue.js +5 -0
  144. package/dist/bundled/components/tree/StoryList.vue2.js +41 -0
  145. package/dist/bundled/components/tree/StoryListFolder.vue.js +8 -0
  146. package/dist/bundled/components/tree/StoryListFolder.vue2.js +86 -0
  147. package/dist/bundled/components/tree/StoryListItem.vue.js +8 -0
  148. package/dist/bundled/components/tree/StoryListItem.vue2.js +69 -0
  149. package/dist/bundled/index.js +35 -0
  150. package/dist/bundled/plugin.js +49 -0
  151. package/dist/bundled/router.js +32 -0
  152. package/dist/bundled/sandbox.js +87 -0
  153. package/dist/bundled/stores/command.js +25 -0
  154. package/dist/bundled/stores/events.js +29 -0
  155. package/dist/bundled/stores/folder.js +54 -0
  156. package/dist/bundled/stores/preview-settings.js +19 -0
  157. package/dist/bundled/stores/story.js +43 -0
  158. package/dist/bundled/util/commands.js +57 -0
  159. package/dist/bundled/util/config.js +8 -0
  160. package/dist/bundled/util/const.js +10 -0
  161. package/dist/bundled/util/dark.js +28 -0
  162. package/dist/bundled/util/docs.js +26 -0
  163. package/dist/bundled/util/env.js +4 -0
  164. package/dist/bundled/util/events.js +33 -0
  165. package/dist/bundled/util/keyboard.js +90 -0
  166. package/dist/bundled/util/mapping.js +70 -0
  167. package/dist/bundled/util/open-in-editor.js +6 -0
  168. package/dist/bundled/util/preview-settings.js +22 -0
  169. package/dist/bundled/util/responsive.js +6 -0
  170. package/dist/bundled/util/sandbox.js +11 -0
  171. package/dist/bundled/util/scroll.js +31 -0
  172. package/dist/bundled/util/select.js +28 -0
  173. package/dist/bundled/util/state.js +41 -0
  174. package/dist/bundled/util/tooltip.js +15 -0
  175. package/dist/bundled/util/variant.js +21 -0
  176. package/dist/style.css +2853 -0
  177. package/package.json +8 -4
  178. package/postcss-scope-wrapper.cjs +0 -35
  179. package/postcss.config.cjs +0 -9
  180. package/scripts/copy.mjs +0 -12
  181. package/scripts/watchAndCopy.mjs +0 -15
  182. package/tailwind.config.cjs +0 -137
  183. package/tsconfig.json +0 -53
  184. package/vite.config.ts +0 -88
@@ -0,0 +1,87 @@
1
+ import { applyState } from "@poveste/shared";
2
+ import { createPinia } from "@poveste/vendors/pinia";
3
+ import { files } from "virtual:$poveste-stories";
4
+ import { ref, createApp, h, computed, watch, onMounted } from "@poveste/vendors/vue";
5
+ import { parseQuery } from "@poveste/vendors/vue-router";
6
+ import "./components/story/GenericMountStory.vue.js";
7
+ import "./components/story/GenericRenderStory.vue.js";
8
+ import { setupPluginApi } from "./plugin.js";
9
+ import { povesteConfig } from "./util/config.js";
10
+ import { SANDBOX_READY, STATE_SYNC, PREVIEW_SETTINGS_SYNC } from "./util/const.js";
11
+ import { isDark } from "./util/dark.js";
12
+ import { mapFile } from "./util/mapping.js";
13
+ import { applyPreviewSettings } from "./util/preview-settings.js";
14
+ import { toRawDeep } from "./util/state.js";
15
+ import _sfc_main from "./components/story/GenericMountStory.vue2.js";
16
+ import _sfc_main$1 from "./components/story/GenericRenderStory.vue2.js";
17
+ "use strict";
18
+ const query = parseQuery(window.location.search);
19
+ const file = ref(mapFile(files.find((f) => f.id === query.storyId)));
20
+ const app = createApp({
21
+ name: "SandboxApp",
22
+ setup() {
23
+ const story = computed(() => file.value.story);
24
+ const variant = computed(() => story.value?.variants.find((v) => v.id === query.variantId));
25
+ let synced = false;
26
+ let mounted = false;
27
+ window.addEventListener("message", (event) => {
28
+ if (event.data?.type === STATE_SYNC) {
29
+ if (!mounted) return;
30
+ synced = true;
31
+ applyState(variant.value.state, event.data.state);
32
+ } else if (event.data?.type === PREVIEW_SETTINGS_SYNC) {
33
+ applyPreviewSettings(event.data.settings);
34
+ }
35
+ });
36
+ watch(() => variant.value.state, (value) => {
37
+ if (synced && mounted) {
38
+ synced = false;
39
+ return;
40
+ }
41
+ window.parent?.postMessage({
42
+ type: STATE_SYNC,
43
+ state: toRawDeep(value, true)
44
+ });
45
+ }, {
46
+ deep: true
47
+ });
48
+ onMounted(() => {
49
+ mounted = true;
50
+ });
51
+ return {
52
+ story,
53
+ variant
54
+ };
55
+ },
56
+ render() {
57
+ return [
58
+ h("div", { class: "htw-sandbox-hidden" }, [
59
+ h(_sfc_main, {
60
+ key: file.value.story.id,
61
+ story: file.value.story
62
+ })
63
+ ]),
64
+ this.story && this.variant ? h(_sfc_main$1, { story: this.story, variant: this.variant, onReady: () => {
65
+ window.parent?.postMessage({
66
+ type: SANDBOX_READY
67
+ });
68
+ } }) : null
69
+ ];
70
+ }
71
+ });
72
+ app.use(createPinia());
73
+ app.mount("#app");
74
+ watch(isDark, (value) => {
75
+ if (value) {
76
+ document.documentElement.classList.add(povesteConfig.sandboxDarkClass);
77
+ document.documentElement.classList.add(povesteConfig.theme.darkClass);
78
+ } else {
79
+ document.documentElement.classList.remove(povesteConfig.sandboxDarkClass);
80
+ document.documentElement.classList.remove(povesteConfig.theme.darkClass);
81
+ }
82
+ }, {
83
+ immediate: true
84
+ });
85
+ if (import.meta.hot) {
86
+ /* @__PURE__ */ setupPluginApi();
87
+ }
@@ -0,0 +1,25 @@
1
+ import { defineStore } from "@poveste/vendors/pinia";
2
+ import { ref } from "@poveste/vendors/vue";
3
+ import { getCommandContext, executeCommand } from "../util/commands.js";
4
+ "use strict";
5
+ const useCommandStore = defineStore("command", () => {
6
+ const selectedCommand = ref(null);
7
+ const showPromptsModal = ref(false);
8
+ function activateCommand(command) {
9
+ selectedCommand.value = command;
10
+ if (command.prompts?.length) {
11
+ showPromptsModal.value = true;
12
+ } else {
13
+ const params = command.getParams?.(getCommandContext()) ?? {};
14
+ executeCommand(command, params);
15
+ }
16
+ }
17
+ return {
18
+ selectedCommand,
19
+ showPromptsModal,
20
+ activateCommand
21
+ };
22
+ });
23
+ export {
24
+ useCommandStore
25
+ };
@@ -0,0 +1,29 @@
1
+ import { defineStore } from "@poveste/vendors/pinia";
2
+ import { reactive, ref, watch } from "@poveste/vendors/vue";
3
+ import { useStoryStore } from "./story.js";
4
+ "use strict";
5
+ const useEventsStore = defineStore("events", () => {
6
+ const storyStore = useStoryStore();
7
+ const events = reactive([]);
8
+ const unseen = ref(0);
9
+ function addEvent(event) {
10
+ events.push(event);
11
+ unseen.value++;
12
+ }
13
+ function reset() {
14
+ events.length = 0;
15
+ unseen.value = 0;
16
+ }
17
+ watch(() => storyStore.currentVariant?.id, () => {
18
+ reset();
19
+ });
20
+ return {
21
+ addEvent,
22
+ reset,
23
+ events,
24
+ unseen
25
+ };
26
+ });
27
+ export {
28
+ useEventsStore
29
+ };
@@ -0,0 +1,54 @@
1
+ import { useStorage } from "@poveste/vendors/vue-use";
2
+ import { defineStore } from "@poveste/vendors/pinia";
3
+ import { watch } from "@poveste/vendors/vue";
4
+ import { useStoryStore } from "./story.js";
5
+ "use strict";
6
+ const useFolderStore = defineStore("folder", () => {
7
+ const openedFolders = useStorage(
8
+ "_poveste-tree-state",
9
+ /* @__PURE__ */ new Map()
10
+ );
11
+ function getStringPath(path) {
12
+ return path.join("␜");
13
+ }
14
+ function toggleFolder(path, defaultToggleValue = true) {
15
+ const stringPath = getStringPath(path);
16
+ const currentValue = openedFolders.value.get(stringPath);
17
+ if (currentValue == null) {
18
+ setFolderOpen(stringPath, defaultToggleValue);
19
+ } else if (currentValue) {
20
+ setFolderOpen(stringPath, false);
21
+ } else {
22
+ setFolderOpen(stringPath, true);
23
+ }
24
+ }
25
+ function setFolderOpen(path, value) {
26
+ const stringPath = typeof path === "string" ? path : getStringPath(path);
27
+ openedFolders.value.set(stringPath, value);
28
+ }
29
+ function isFolderOpened(path, defaultValue = false) {
30
+ const value = openedFolders.value.get(getStringPath(path));
31
+ if (value == null) {
32
+ return defaultValue;
33
+ }
34
+ return value;
35
+ }
36
+ function openFileFolders(path) {
37
+ for (let pathLength = 1; pathLength < path.length; pathLength++) {
38
+ setFolderOpen(path.slice(0, pathLength), true);
39
+ }
40
+ }
41
+ const storyStore = useStoryStore();
42
+ watch(() => storyStore.currentStory, (story) => {
43
+ if (story) {
44
+ openFileFolders(story.file.path);
45
+ }
46
+ });
47
+ return {
48
+ isFolderOpened,
49
+ toggleFolder
50
+ };
51
+ });
52
+ export {
53
+ useFolderStore
54
+ };
@@ -0,0 +1,19 @@
1
+ import { useStorage } from "@poveste/vendors/vue-use";
2
+ import { defineStore } from "@poveste/vendors/pinia";
3
+ "use strict";
4
+ const usePreviewSettingsStore = defineStore("preview-settings", () => {
5
+ const currentSettings = useStorage("_poveste-sandbox-settings-v3", {
6
+ responsiveWidth: 720,
7
+ responsiveHeight: null,
8
+ rotate: false,
9
+ backgroundColor: "transparent",
10
+ checkerboard: false,
11
+ textDirection: "ltr"
12
+ });
13
+ return {
14
+ currentSettings
15
+ };
16
+ });
17
+ export {
18
+ usePreviewSettingsStore
19
+ };
@@ -0,0 +1,43 @@
1
+ import { defineStore } from "@poveste/vendors/pinia";
2
+ import { ref, computed } from "@poveste/vendors/vue";
3
+ import { router } from "../router.js";
4
+ "use strict";
5
+ const useStoryStore = defineStore("story", () => {
6
+ const stories = ref([]);
7
+ function setStories(value) {
8
+ stories.value = value;
9
+ }
10
+ const currentStory = computed(() => stories.value.find((s) => s.id === router.currentRoute.value.params.storyId));
11
+ const currentVariant = computed(() => currentStory.value?.variants.find((v) => v.id === router.currentRoute.value.query.variantId));
12
+ const maps = computed(() => {
13
+ const storyMap = /* @__PURE__ */ new Map();
14
+ const variantMap = /* @__PURE__ */ new Map();
15
+ for (const story of stories.value) {
16
+ storyMap.set(story.id, story);
17
+ for (const variant of story.variants) {
18
+ variantMap.set(`${story.id}:${variant.id}`, variant);
19
+ }
20
+ }
21
+ return {
22
+ stories: storyMap,
23
+ variants: variantMap
24
+ };
25
+ });
26
+ function getStoryById(id) {
27
+ return maps.value.stories.get(id);
28
+ }
29
+ function getVariantById(idWithStoryId) {
30
+ return maps.value.variants.get(idWithStoryId);
31
+ }
32
+ return {
33
+ stories,
34
+ setStories,
35
+ currentStory,
36
+ currentVariant,
37
+ getStoryById,
38
+ getVariantById
39
+ };
40
+ });
41
+ export {
42
+ useStoryStore
43
+ };
@@ -0,0 +1,57 @@
1
+ import { router } from "../router.js";
2
+ import { useStoryStore } from "../stores/story.js";
3
+ import { openInEditor } from "./open-in-editor.js";
4
+ "use strict";
5
+ const builtinCommands = [
6
+ {
7
+ id: "builtin:open-in-editor",
8
+ label: "Open file in editor",
9
+ icon: "carbon:script-reference",
10
+ showIf: ({ route }) => route.name === "story" && !!useStoryStore().currentStory,
11
+ getParams: () => {
12
+ const story = useStoryStore().currentStory;
13
+ let file;
14
+ if (story.docsOnly) {
15
+ file = story.file?.docsFilePath ?? story.file?.filePath;
16
+ } else {
17
+ file = story.file?.filePath;
18
+ }
19
+ return {
20
+ file
21
+ };
22
+ },
23
+ clientAction: ({ file }) => {
24
+ openInEditor(file);
25
+ }
26
+ },
27
+ {
28
+ id: "builtin:poveste-docs",
29
+ label: "Open Poveste Documentation",
30
+ icon: "carbon:help",
31
+ clientAction: () => {
32
+ window.open("https://poveste.dev/guide/getting-started.html", "_blank");
33
+ }
34
+ }
35
+ ];
36
+ function executeCommand(command, params) {
37
+ if (import.meta.hot) {
38
+ import.meta.hot.send("poveste:dev-command", {
39
+ id: command.id,
40
+ params
41
+ });
42
+ command.clientAction?.(params, getCommandContext());
43
+ }
44
+ }
45
+ function getCommandContext() {
46
+ const storyStore = useStoryStore();
47
+ return {
48
+ route: router.currentRoute.value,
49
+ currentStory: storyStore.currentStory,
50
+ currentVariant: storyStore.currentVariant
51
+ };
52
+ }
53
+ export {
54
+ builtinCommands,
55
+ executeCommand,
56
+ getCommandContext
57
+ };
@@ -0,0 +1,8 @@
1
+ import { config, logos } from "virtual:$poveste-config";
2
+ "use strict";
3
+ const povesteConfig = config;
4
+ const customLogos = logos;
5
+ export {
6
+ customLogos,
7
+ povesteConfig
8
+ };
@@ -0,0 +1,10 @@
1
+ const STATE_SYNC = "__poveste:state-sync";
2
+ const SANDBOX_READY = "__poveste:sandbox-ready";
3
+ const EVENT_SEND = "__poveste:event";
4
+ const PREVIEW_SETTINGS_SYNC = "__poveste:preview-settings-sync";
5
+ export {
6
+ EVENT_SEND,
7
+ PREVIEW_SETTINGS_SYNC,
8
+ SANDBOX_READY,
9
+ STATE_SYNC
10
+ };
@@ -0,0 +1,28 @@
1
+ import { useDark, useToggle } from "@poveste/vendors/vue-use";
2
+ import { watch } from "@poveste/vendors/vue";
3
+ import { povesteConfig } from "./config.js";
4
+ "use strict";
5
+ const isDark = useDark({
6
+ valueDark: "htw-dark",
7
+ initialValue: povesteConfig.theme.defaultColorScheme,
8
+ storageKey: "poveste-color-scheme",
9
+ storage: povesteConfig.theme.storeColorScheme ? localStorage : sessionStorage
10
+ });
11
+ const toggleDark = useToggle(isDark);
12
+ function applyDarkToControls() {
13
+ window.__hst_controls_dark?.forEach((ref) => {
14
+ ref.value = isDark.value;
15
+ });
16
+ }
17
+ watch(isDark, () => {
18
+ applyDarkToControls();
19
+ }, {
20
+ immediate: true
21
+ });
22
+ window.__hst_controls_dark_ready = () => {
23
+ applyDarkToControls();
24
+ };
25
+ export {
26
+ isDark,
27
+ toggleDark
28
+ };
@@ -0,0 +1,26 @@
1
+ import { unindent } from "@poveste/shared";
2
+ import { clientSupportPlugins } from "virtual:$poveste-support-plugins-client";
3
+ "use strict";
4
+ async function getSourceCode(story, variant) {
5
+ if (variant.source) {
6
+ return variant.source;
7
+ } else if (variant.slots?.().source) {
8
+ const source = variant.slots?.().source()[0].children;
9
+ if (source) {
10
+ return unindent(source);
11
+ }
12
+ } else {
13
+ const clientPlugin = clientSupportPlugins[story.file?.supportPluginId];
14
+ if (clientPlugin) {
15
+ const pluginModule = await clientPlugin();
16
+ return pluginModule.generateSourceCode(variant);
17
+ }
18
+ }
19
+ const sourceLoader = story.file?.source;
20
+ if (sourceLoader) {
21
+ return (await sourceLoader()).default;
22
+ }
23
+ }
24
+ export {
25
+ getSourceCode
26
+ };
@@ -0,0 +1,4 @@
1
+ const isMac = navigator.platform.toLowerCase().includes("mac");
2
+ export {
3
+ isMac
4
+ };
@@ -0,0 +1,33 @@
1
+ import { EVENT_SEND } from "./const.js";
2
+ "use strict";
3
+ async function logEvent(name, argument) {
4
+ console.log("[poveste] Event fired", { name, argument });
5
+ const event = {
6
+ name,
7
+ argument: JSON.parse(stringifyEvent(argument))
8
+ // Needed for HTMLEvent that can't be cloned
9
+ };
10
+ if (location.href.includes("__sandbox")) {
11
+ window.parent?.postMessage({
12
+ type: EVENT_SEND,
13
+ event
14
+ });
15
+ } else {
16
+ const { useEventsStore } = await import("../stores/events.js");
17
+ useEventsStore().addEvent(event);
18
+ }
19
+ }
20
+ function stringifyEvent(e) {
21
+ const obj = {};
22
+ for (const k in e) {
23
+ obj[k] = e[k];
24
+ }
25
+ return JSON.stringify(obj, (k, v) => {
26
+ if (v instanceof Node) return "Node";
27
+ if (v instanceof Window) return "Window";
28
+ return v;
29
+ }, " ");
30
+ }
31
+ export {
32
+ logEvent
33
+ };
@@ -0,0 +1,90 @@
1
+ import { useEventListener } from "@poveste/vendors/vue-use";
2
+ import { isRef } from "@poveste/vendors/vue";
3
+ import { isMac } from "./env.js";
4
+ "use strict";
5
+ function onKeyboardShortcut(shortcut, handler, options = {}) {
6
+ useEventListener(options.event ?? "keydown", (event) => {
7
+ if (isMatchingShortcut(isRef(shortcut) ? shortcut.value : shortcut)) {
8
+ handler(event);
9
+ }
10
+ });
11
+ }
12
+ const modifiers = {
13
+ ctrl: { key: "Control", pressed: false },
14
+ alt: { key: "Alt", pressed: false },
15
+ shift: { key: "Shift", pressed: false },
16
+ meta: { key: "Meta", pressed: false }
17
+ };
18
+ const pressedKeys = /* @__PURE__ */ new Set();
19
+ window.addEventListener("keydown", (event) => {
20
+ for (const i in modifiers) {
21
+ const mod = modifiers[i];
22
+ if (mod.key === event.key) {
23
+ mod.pressed = true;
24
+ return;
25
+ }
26
+ }
27
+ pressedKeys.add(event.key.toLocaleLowerCase());
28
+ });
29
+ window.addEventListener("keyup", (event) => {
30
+ requestAnimationFrame(() => {
31
+ pressedKeys.clear();
32
+ for (const i in modifiers) {
33
+ const mod = modifiers[i];
34
+ if (mod.key === event.key) {
35
+ mod.pressed = false;
36
+ break;
37
+ }
38
+ }
39
+ });
40
+ });
41
+ window.addEventListener("blur", () => {
42
+ pressedKeys.clear();
43
+ for (const i in modifiers) {
44
+ const mod = modifiers[i];
45
+ mod.pressed = false;
46
+ }
47
+ });
48
+ function isMatchingShortcut(shortcut) {
49
+ for (const combination of shortcut) {
50
+ if (isMatchingCombination(combination.toLowerCase())) {
51
+ return true;
52
+ }
53
+ }
54
+ return false;
55
+ }
56
+ function isMatchingCombination(combination) {
57
+ const splitted = combination.split("+").map((key) => key.trim());
58
+ const targetKey = splitted.pop();
59
+ for (const mod in modifiers) {
60
+ const containsMod = splitted.includes(mod);
61
+ const isPressed = modifiers[mod].pressed;
62
+ if (containsMod !== isPressed) {
63
+ return false;
64
+ }
65
+ }
66
+ return pressedKeys.has(targetKey);
67
+ }
68
+ function formatKey(key) {
69
+ key = key.toLowerCase();
70
+ if (key === "ctrl") {
71
+ return isMac ? "^" : "Ctrl";
72
+ }
73
+ if (key === "alt") {
74
+ return isMac ? "⎇" : "Alt";
75
+ }
76
+ if (key === "shift") {
77
+ return "⇧";
78
+ }
79
+ if (key === "meta") {
80
+ return "⌘";
81
+ }
82
+ if (key === "enter") {
83
+ return "⏎";
84
+ }
85
+ return key.charAt(0).toUpperCase() + key.substring(1).toLowerCase();
86
+ }
87
+ export {
88
+ formatKey,
89
+ onKeyboardShortcut
90
+ };
@@ -0,0 +1,70 @@
1
+ import { markRaw, reactive } from "@poveste/vendors/vue";
2
+ "use strict";
3
+ const copiedFromExistingVariant = [
4
+ "state",
5
+ "slots",
6
+ "source",
7
+ "responsiveDisabled",
8
+ "autoPropsDisabled",
9
+ "setupApp",
10
+ "configReady",
11
+ "previewReady"
12
+ ];
13
+ function mapFile(file, existingFile) {
14
+ let result;
15
+ if (existingFile) {
16
+ result = existingFile;
17
+ for (const key in file) {
18
+ if (key === "story") {
19
+ result.story = {
20
+ ...result.story,
21
+ ...file.story,
22
+ file: markRaw(result),
23
+ variants: file.story.variants.map((v) => mapVariant(v, existingFile.story.variants.find((item) => item.id === v.id)))
24
+ };
25
+ } else if (key !== "component") {
26
+ result[key] = file[key];
27
+ }
28
+ }
29
+ } else {
30
+ result = {
31
+ ...file,
32
+ component: markRaw(file.component),
33
+ story: {
34
+ ...file.story,
35
+ title: file.story.title,
36
+ file: markRaw(file),
37
+ variants: file.story.variants.map((v) => mapVariant(v)),
38
+ slots: () => ({})
39
+ }
40
+ };
41
+ }
42
+ return result;
43
+ }
44
+ function mapVariant(variant, existingVariant) {
45
+ let result;
46
+ if (existingVariant) {
47
+ result = existingVariant;
48
+ for (const key in variant) {
49
+ if (!copiedFromExistingVariant.includes(key)) {
50
+ result[key] = variant[key];
51
+ }
52
+ }
53
+ } else {
54
+ result = {
55
+ ...variant,
56
+ state: reactive({
57
+ _hPropState: {},
58
+ _hPropDefs: {}
59
+ }),
60
+ setupApp: null,
61
+ slots: () => ({}),
62
+ previewReady: false
63
+ };
64
+ }
65
+ return result;
66
+ }
67
+ export {
68
+ mapFile,
69
+ mapVariant
70
+ };
@@ -0,0 +1,6 @@
1
+ function openInEditor(file) {
2
+ return fetch(`${import.meta.env.BASE_URL}__open-in-editor?file=${encodeURIComponent(file)}`);
3
+ }
4
+ export {
5
+ openInEditor
6
+ };
@@ -0,0 +1,22 @@
1
+ import { reactive } from "@poveste/vendors/vue";
2
+ import { povesteConfig } from "./config.js";
3
+ "use strict";
4
+ const receivedSettings = reactive({});
5
+ function applyPreviewSettings(settings) {
6
+ Object.assign(receivedSettings, settings);
7
+ document.documentElement.setAttribute("dir", settings.textDirection);
8
+ const contrastColor = getContrastColor(settings);
9
+ document.documentElement.style.setProperty("--poveste-contrast-color", contrastColor);
10
+ document.documentElement.style.setProperty("--histoire-contrast-color", contrastColor);
11
+ if (povesteConfig.autoApplyContrastColor) {
12
+ document.documentElement.style.color = contrastColor;
13
+ }
14
+ }
15
+ function getContrastColor(setting) {
16
+ return povesteConfig.backgroundPresets.find((preset) => preset.color === setting.backgroundColor)?.contrastColor ?? "unset";
17
+ }
18
+ export {
19
+ applyPreviewSettings,
20
+ getContrastColor,
21
+ receivedSettings
22
+ };
@@ -0,0 +1,6 @@
1
+ import { useMediaQuery } from "@poveste/vendors/vue-use";
2
+ "use strict";
3
+ const isMobile = useMediaQuery("(max-width: 640px)");
4
+ export {
5
+ isMobile
6
+ };
@@ -0,0 +1,11 @@
1
+ import { base } from "../router.js";
2
+ "use strict";
3
+ function getSandboxUrl(story, variant) {
4
+ const url = new URLSearchParams();
5
+ url.append("storyId", story.id);
6
+ url.append("variantId", variant.id);
7
+ return `${base}__sandbox.html?${url.toString()}`;
8
+ }
9
+ export {
10
+ getSandboxUrl
11
+ };
@@ -0,0 +1,31 @@
1
+ import scrollIntoView from "@poveste/vendors/scroll";
2
+ import { watch, onMounted } from "@poveste/vendors/vue";
3
+ "use strict";
4
+ function useScrollOnActive(active, el) {
5
+ watch(active, (value) => {
6
+ if (value) {
7
+ autoScroll();
8
+ }
9
+ });
10
+ function autoScroll() {
11
+ if (el.value) {
12
+ scrollIntoView(el.value, {
13
+ scrollMode: "if-needed",
14
+ block: "center",
15
+ inline: "nearest",
16
+ behavior: "smooth"
17
+ });
18
+ }
19
+ }
20
+ onMounted(() => {
21
+ if (active.value) {
22
+ autoScroll();
23
+ }
24
+ });
25
+ return {
26
+ autoScroll
27
+ };
28
+ }
29
+ export {
30
+ useScrollOnActive
31
+ };