@poveste/app 0.18.3 → 0.19.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.
Files changed (40) hide show
  1. package/dist/THIRD_PARTY_NOTICES.md +159 -0
  2. package/dist/bundled/app.css +4 -4
  3. package/dist/bundled/components/command/PromptSelect.vue_vue_type_script_setup_true_lang.js +1 -1
  4. package/dist/bundled/components/story/StoryNativeScope.js +14 -0
  5. package/dist/bundled/components/story/StoryVariantGridItem.js +1 -1
  6. package/dist/bundled/components/story/StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js +23 -16
  7. package/dist/bundled/components/story/StoryVariantSinglePreviewNative.vue_vue_type_script_setup_true_lang.js +22 -15
  8. package/dist/bundled/components/story/StoryVariantSinglePreviewRemote.vue_vue_type_script_setup_true_lang.js +8 -2
  9. package/dist/bundled/index.js +12 -3
  10. package/dist/bundled/sandbox.js +32 -2
  11. package/dist/bundled/stores/preview-settings.js +29 -4
  12. package/dist/bundled/util/color-scheme.js +41 -1
  13. package/dist/bundled/util/commands.js +16 -4
  14. package/dist/bundled/util/const.js +2 -1
  15. package/package.json +6 -4
  16. package/src/app/components/command/PromptSelect.vue +2 -1
  17. package/src/app/components/story/StoryNativeScope.vue +23 -0
  18. package/src/app/components/story/StoryVariantGridItem.vue +14 -10
  19. package/src/app/components/story/StoryVariantSinglePreviewNative.vue +15 -10
  20. package/src/app/components/story/StoryVariantSinglePreviewRemote.vue +13 -2
  21. package/src/app/index.ts +14 -2
  22. package/src/app/sandbox.ts +41 -2
  23. package/src/app/stores/preview-settings.ts +48 -10
  24. package/src/app/types.ts +7 -1
  25. package/src/app/util/color-scheme.ts +44 -0
  26. package/src/app/util/commands.ts +19 -7
  27. package/src/app/util/const.ts +1 -0
  28. package/src/__tests__/base-select.spec.ts +0 -25
  29. package/src/__tests__/color-scheme.spec.ts +0 -55
  30. package/src/__tests__/font.spec.ts +0 -76
  31. package/src/__tests__/grid-slots.spec.ts +0 -84
  32. package/src/__tests__/icons.spec.ts +0 -26
  33. package/src/__tests__/postcss-scope-wrapper.spec.ts +0 -65
  34. package/src/__tests__/render-tracker.spec.ts +0 -38
  35. package/src/__tests__/reset.spec.ts +0 -53
  36. package/src/__tests__/source-code.spec.ts +0 -55
  37. package/src/__tests__/state-bridge.spec.ts +0 -155
  38. package/src/__tests__/state-clone.spec.ts +0 -120
  39. package/src/__tests__/state-types.spec.ts +0 -175
  40. package/src/__tests__/uncaught.spec.ts +0 -36
@@ -0,0 +1,159 @@
1
+ # Third-party notices
2
+
3
+ @poveste/app bundles code from the packages below into its `dist`. Each is listed with its version, licence and the licence text it was distributed under.
4
+
5
+ ## @tailwindcss/typography@0.5.20
6
+
7
+ Licence: MIT
8
+
9
+ ```
10
+ MIT License
11
+
12
+ Copyright (c) Tailwind Labs, Inc.
13
+
14
+ Permission is hereby granted, free of charge, to any person obtaining a copy
15
+ of this software and associated documentation files (the "Software"), to deal
16
+ in the Software without restriction, including without limitation the rights
17
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
18
+ copies of the Software, and to permit persons to whom the Software is
19
+ furnished to do so, subject to the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be included in all
22
+ copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
29
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
30
+ SOFTWARE.
31
+ ```
32
+
33
+ ## Noto Sans Display@vendored
34
+
35
+ Licence: OFL-1.1
36
+
37
+ ```
38
+ Copyright 2015 Google Inc. All Rights Reserved. NotoSansDisplay-Italic[wdth,wght].ttf: Copyright 2015 Google Inc. All Rights Reserved.
39
+
40
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
41
+ This license is copied below, and is also available with a FAQ at:
42
+ http://scripts.sil.org/OFL
43
+
44
+
45
+ -----------------------------------------------------------
46
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
47
+ -----------------------------------------------------------
48
+
49
+ PREAMBLE
50
+ The goals of the Open Font License (OFL) are to stimulate worldwide
51
+ development of collaborative font projects, to support the font creation
52
+ efforts of academic and linguistic communities, and to provide a free and
53
+ open framework in which fonts may be shared and improved in partnership
54
+ with others.
55
+
56
+ The OFL allows the licensed fonts to be used, studied, modified and
57
+ redistributed freely as long as they are not sold by themselves. The
58
+ fonts, including any derivative works, can be bundled, embedded,
59
+ redistributed and/or sold with any software provided that any reserved
60
+ names are not used by derivative works. The fonts and derivatives,
61
+ however, cannot be released under any other type of license. The
62
+ requirement for fonts to remain under this license does not apply
63
+ to any document created using the fonts or their derivatives.
64
+
65
+ DEFINITIONS
66
+ "Font Software" refers to the set of files released by the Copyright
67
+ Holder(s) under this license and clearly marked as such. This may
68
+ include source files, build scripts and documentation.
69
+
70
+ "Reserved Font Name" refers to any names specified as such after the
71
+ copyright statement(s).
72
+
73
+ "Original Version" refers to the collection of Font Software components as
74
+ distributed by the Copyright Holder(s).
75
+
76
+ "Modified Version" refers to any derivative made by adding to, deleting,
77
+ or substituting -- in part or in whole -- any of the components of the
78
+ Original Version, by changing formats or by porting the Font Software to a
79
+ new environment.
80
+
81
+ "Author" refers to any designer, engineer, programmer, technical
82
+ writer or other person who contributed to the Font Software.
83
+
84
+ PERMISSION & CONDITIONS
85
+ Permission is hereby granted, free of charge, to any person obtaining
86
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
87
+ redistribute, and sell modified and unmodified copies of the Font
88
+ Software, subject to the following conditions:
89
+
90
+ 1) Neither the Font Software nor any of its individual components,
91
+ in Original or Modified Versions, may be sold by itself.
92
+
93
+ 2) Original or Modified Versions of the Font Software may be bundled,
94
+ redistributed and/or sold with any software, provided that each copy
95
+ contains the above copyright notice and this license. These can be
96
+ included either as stand-alone text files, human-readable headers or
97
+ in the appropriate machine-readable metadata fields within text or
98
+ binary files as long as those fields can be easily viewed by the user.
99
+
100
+ 3) No Modified Version of the Font Software may use the Reserved Font
101
+ Name(s) unless explicit written permission is granted by the corresponding
102
+ Copyright Holder. This restriction only applies to the primary font name as
103
+ presented to the users.
104
+
105
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
106
+ Software shall not be used to promote, endorse or advertise any
107
+ Modified Version, except to acknowledge the contribution(s) of the
108
+ Copyright Holder(s) and the Author(s) or with their explicit written
109
+ permission.
110
+
111
+ 5) The Font Software, modified or unmodified, in part or in whole,
112
+ must be distributed entirely under this license, and must not be
113
+ distributed under any other license. The requirement for fonts to
114
+ remain under this license does not apply to any document created
115
+ using the Font Software.
116
+
117
+ TERMINATION
118
+ This license becomes null and void if any of the above conditions are
119
+ not met.
120
+
121
+ DISCLAIMER
122
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
123
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
124
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
125
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
126
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
127
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
128
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
129
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
130
+ OTHER DEALINGS IN THE FONT SOFTWARE.
131
+ ```
132
+
133
+ ## tailwindcss@4.3.3
134
+
135
+ Licence: MIT
136
+
137
+ ```
138
+ MIT License
139
+
140
+ Copyright (c) Tailwind Labs, Inc.
141
+
142
+ Permission is hereby granted, free of charge, to any person obtaining a copy
143
+ of this software and associated documentation files (the "Software"), to deal
144
+ in the Software without restriction, including without limitation the rights
145
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
146
+ copies of the Software, and to permit persons to whom the Software is
147
+ furnished to do so, subject to the following conditions:
148
+
149
+ The above copyright notice and this permission notice shall be included in all
150
+ copies or substantial portions of the Software.
151
+
152
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
153
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
154
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
155
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
156
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
157
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
158
+ SOFTWARE.
159
+ ```
@@ -170,11 +170,11 @@ from {
170
170
  }
171
171
  }
172
172
  @scope (:root) to (.__poveste-render-story:not(.__poveste-render-custom-controls)) {
173
- .bind-icon-color[data-v-bfa057e9] {
174
- color: var(--v1061c03c);
173
+ .bind-icon-color[data-v-e0e9a8e1] {
174
+ color: var(--v2ce2d009);
175
175
  }
176
- .bind-preview-bg[data-v-bfa057e9] {
177
- background-color: var(--v2d8b4c49);
176
+ .bind-preview-bg[data-v-e0e9a8e1] {
177
+ background-color: var(--v4f3f7242);
178
178
  }
179
179
  }
180
180
  @scope (:root) to (.__poveste-render-story:not(.__poveste-render-custom-controls)) {
@@ -46,7 +46,7 @@ var PromptSelect_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ def
46
46
  if (typeof props.prompt.options === "function") {
47
47
  const rId = ++requestId;
48
48
  const result = await props.prompt.options(search.value, props.answers);
49
- if (rId === requestId) options.value = result;
49
+ if (rId === requestId) options.value = result ?? [];
50
50
  } else options.value = props.prompt.options;
51
51
  });
52
52
  const formattedOptions = computed(() => {
@@ -0,0 +1,14 @@
1
+ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export-helper.js";
2
+ import { createElementBlock, openBlock, renderSlot } from "@poveste/vendors/vue";
3
+ //#region src/app/components/story/StoryNativeScope.vue
4
+ var _sfc_main = {};
5
+ var _hoisted_1 = {
6
+ class: "__poveste-render-story __poveste-render-custom-controls",
7
+ style: { "display": "contents !important" }
8
+ };
9
+ function _sfc_render(_ctx, _cache) {
10
+ return openBlock(), createElementBlock("div", _hoisted_1, [renderSlot(_ctx.$slots, "default")]);
11
+ }
12
+ var StoryNativeScope_default = /*#__PURE__*/ _plugin_vue_export_helper_default(_sfc_main, [["render", _sfc_render]]);
13
+ //#endregion
14
+ export { StoryNativeScope_default as default };
@@ -2,6 +2,6 @@ import _plugin_vue_export_helper_default from "../../_virtual/_plugin-vue_export
2
2
  import StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default from "./StoryVariantGridItem.vue_vue_type_script_setup_true_lang.js";
3
3
  /* empty css */
4
4
  //#region src/app/components/story/StoryVariantGridItem.vue
5
- var StoryVariantGridItem_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-bfa057e9"]]);
5
+ var StoryVariantGridItem_default = /*#__PURE__*/ _plugin_vue_export_helper_default(StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-e0e9a8e1"]]);
6
6
  //#endregion
7
7
  export { StoryVariantGridItem_default as default };
@@ -1,7 +1,7 @@
1
1
  import { povesteConfig } from "../../util/config.js";
2
2
  import { useStoryStore } from "../../stores/story.js";
3
3
  import { useScrollOnActive } from "../../util/scroll.js";
4
- import { previewDarkClasses, usePreviewDark } from "../../util/color-scheme.js";
4
+ import { previewDarkClasses, usePreviewColorScheme, usePreviewDark } from "../../util/color-scheme.js";
5
5
  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";
@@ -9,6 +9,7 @@ import GenericRenderStory_default from "./GenericRenderStory.js";
9
9
  import { useCurrentVariantRoute } from "../../util/variant.js";
10
10
  import { getSourceCode } from "../../util/docs.js";
11
11
  import CheckerboardPattern_default from "../misc/CheckerboardPattern.js";
12
+ import StoryNativeScope_default from "./StoryNativeScope.js";
12
13
  import StoryVariantSinglePreviewRemote_default from "./StoryVariantSinglePreviewRemote.js";
13
14
  import { useResizeObserver } from "@poveste/vendors/vue-use";
14
15
  import { computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, nextTick, normalizeClass, normalizeStyle, openBlock, ref, resolveComponent, toDisplayString, toRefs, unref, useCssVars, watch, withCtx, withModifiers } from "@poveste/vendors/vue";
@@ -34,8 +35,8 @@ var StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default = /*@__PURE
34
35
  emits: { resize: (_width, _height) => true },
35
36
  setup(__props, { emit: __emit }) {
36
37
  useCssVars((_ctx) => ({
37
- "v1061c03c": unref(variant).iconColor,
38
- "v2d8b4c49": unref(settings).backgroundColor
38
+ "v2ce2d009": unref(variant).iconColor,
39
+ "v4f3f7242": unref(settings).backgroundColor
39
40
  }));
40
41
  const props = __props;
41
42
  const emit = __emit;
@@ -67,6 +68,7 @@ var StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default = /*@__PURE
67
68
  });
68
69
  const settings = usePreviewSettingsStore().currentSettings;
69
70
  const previewDark = usePreviewDark(settings);
71
+ const previewColorScheme = usePreviewColorScheme(settings);
70
72
  const contrastColor = computed(() => getContrastColor(settings));
71
73
  const autoApplyContrastColor = computed(() => !!povesteConfig.autoApplyContrastColor);
72
74
  const useIframe = computed(() => {
@@ -131,19 +133,24 @@ var StoryVariantGridItem_vue_vue_type_script_setup_true_lang_default = /*@__PURE
131
133
  variant: unref(variant),
132
134
  "auto-height": "",
133
135
  responsive: false
134
- }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(GenericRenderStory_default, {
135
- key: `${__props.story.id}-${unref(variant).id}`,
136
- variant: unref(variant),
137
- story: __props.story,
138
- dir: unref(settings).textDirection,
139
- class: normalizeClass(unref(previewDark) ? unref(previewDarkClasses)() : void 0),
140
- onReady
141
- }, null, 8, [
142
- "variant",
143
- "story",
144
- "dir",
145
- "class"
146
- ]))], 4)
136
+ }, null, 8, ["story", "variant"])) : (openBlock(), createBlock(StoryNativeScope_default, { key: 1 }, {
137
+ default: withCtx(() => [(openBlock(), createBlock(GenericRenderStory_default, {
138
+ key: `${__props.story.id}-${unref(variant).id}`,
139
+ variant: unref(variant),
140
+ story: __props.story,
141
+ dir: unref(settings).textDirection,
142
+ class: normalizeClass(unref(previewDark) ? unref(previewDarkClasses)() : void 0),
143
+ style: normalizeStyle({ "--poveste-color-scheme": unref(previewColorScheme) }),
144
+ onReady
145
+ }, null, 8, [
146
+ "variant",
147
+ "story",
148
+ "dir",
149
+ "class",
150
+ "style"
151
+ ]))]),
152
+ _: 1
153
+ }))], 4)
147
154
  ], 34)], 512);
148
155
  };
149
156
  }
@@ -1,11 +1,12 @@
1
1
  import { povesteConfig } from "../../util/config.js";
2
2
  import { useStoryStore } from "../../stores/story.js";
3
- import { previewDarkClasses, usePreviewDark } from "../../util/color-scheme.js";
3
+ import { previewDarkClasses, usePreviewColorScheme, usePreviewDark } from "../../util/color-scheme.js";
4
4
  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
+ import StoryNativeScope_default from "./StoryNativeScope.js";
7
8
  import StoryResponsivePreview_default from "./StoryResponsivePreview.js";
8
- import { computed, createBlock, createElementVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, unref, watch, withCtx } from "@poveste/vendors/vue";
9
+ import { computed, createBlock, createElementVNode, createVNode, defineComponent, normalizeClass, normalizeStyle, openBlock, unref, watch, withCtx } from "@poveste/vendors/vue";
9
10
  //#region src/app/components/story/StoryVariantSinglePreviewNative.vue?vue&type=script&setup=true&lang.ts
10
11
  var StoryVariantSinglePreviewNative_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
11
12
  __name: "StoryVariantSinglePreviewNative",
@@ -25,6 +26,7 @@ var StoryVariantSinglePreviewNative_vue_vue_type_script_setup_true_lang_default
25
26
  }
26
27
  const settings = usePreviewSettingsStore().currentSettings;
27
28
  const previewDark = usePreviewDark(settings);
29
+ const previewColorScheme = usePreviewColorScheme(settings);
28
30
  const contrastColor = computed(() => getContrastColor(settings));
29
31
  const autoApplyContrastColor = computed(() => !!povesteConfig.autoApplyContrastColor);
30
32
  return (_ctx, _cache) => {
@@ -46,19 +48,24 @@ var StoryVariantSinglePreviewNative_vue_vue_type_script_setup_true_lang_default
46
48
  }]),
47
49
  class: "relative",
48
50
  "data-testid": "sandbox-render"
49
- }, [(openBlock(), createBlock(GenericRenderStory_default, {
50
- key: `${__props.story.id}-${__props.variant.id}`,
51
- variant: __props.variant,
52
- story: __props.story,
53
- class: normalizeClass(["h-full", unref(previewDark) ? unref(previewDarkClasses)() : void 0]),
54
- dir: unref(settings).textDirection,
55
- onReady
56
- }, null, 8, [
57
- "variant",
58
- "story",
59
- "class",
60
- "dir"
61
- ]))], 4)]),
51
+ }, [createVNode(StoryNativeScope_default, null, {
52
+ default: withCtx(() => [(openBlock(), createBlock(GenericRenderStory_default, {
53
+ key: `${__props.story.id}-${__props.variant.id}`,
54
+ variant: __props.variant,
55
+ story: __props.story,
56
+ class: normalizeClass(["h-full", unref(previewDark) ? unref(previewDarkClasses)() : void 0]),
57
+ style: normalizeStyle({ "--poveste-color-scheme": unref(previewColorScheme) }),
58
+ dir: unref(settings).textDirection,
59
+ onReady
60
+ }, null, 8, [
61
+ "variant",
62
+ "story",
63
+ "class",
64
+ "style",
65
+ "dir"
66
+ ]))]),
67
+ _: 1
68
+ })], 4)]),
62
69
  _: 1
63
70
  }, 8, ["variant"]);
64
71
  };
@@ -1,7 +1,8 @@
1
- import { EVENT_SEND, PREVIEW_SETTINGS_REQUEST, PREVIEW_SETTINGS_SYNC, SANDBOX_HEIGHT, SANDBOX_READY, SANDBOX_RETARGET, STATE_SYNC } from "../../util/const.js";
1
+ import { EVENT_SEND, PREVIEW_SETTINGS_REQUEST, PREVIEW_SETTINGS_SYNC, SANDBOX_COLOR_SCHEME, SANDBOX_HEIGHT, SANDBOX_READY, SANDBOX_RETARGET, STATE_SYNC } from "../../util/const.js";
2
2
  import { trackWindow } from "../../util/keyboard.js";
3
3
  import { useStoryStore } from "../../stores/story.js";
4
4
  import { useStoryErrorStore } from "../../stores/story-errors.js";
5
+ import { usePreviewColorScheme } from "../../util/color-scheme.js";
5
6
  import { usePreviewSettingsStore } from "../../stores/preview-settings.js";
6
7
  import { getSandboxUrl } from "../../util/sandbox.js";
7
8
  import { createStateBridge } from "../../util/state-bridge.js";
@@ -48,6 +49,8 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
48
49
  setup(__props) {
49
50
  const props = __props;
50
51
  const settings = usePreviewSettingsStore().currentSettings;
52
+ const previewColorScheme = usePreviewColorScheme(settings);
53
+ const sandboxColorScheme = ref(null);
51
54
  const errorStore = useStoryErrorStore();
52
55
  const storyError = computed(() => errorStore.forVariant(props.story.id, props.variant.id));
53
56
  const render = createRenderTracker();
@@ -103,6 +106,9 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
103
106
  case PREVIEW_SETTINGS_REQUEST:
104
107
  syncSettings();
105
108
  break;
109
+ case SANDBOX_COLOR_SCHEME:
110
+ if (typeof event.data.scheme === "string") sandboxColorScheme.value = event.data.scheme;
111
+ break;
106
112
  case SANDBOX_HEIGHT:
107
113
  if (!fromCurrentOccupant(event.data)) break;
108
114
  if (typeof event.data.h === "number" && event.data.h >= MIN_HEIGHT) {
@@ -196,7 +202,7 @@ var StoryVariantSinglePreviewRemote_vue_vue_type_script_setup_true_lang_default
196
202
  immediate: true
197
203
  });
198
204
  function previewStyle(isResponsiveEnabled, finalWidth, finalHeight) {
199
- const style = {};
205
+ const style = { colorScheme: sandboxColorScheme.value ?? previewColorScheme.value };
200
206
  if (isResponsiveEnabled) {
201
207
  if (finalWidth) style["width"] = `${finalWidth}px`;
202
208
  if (finalHeight) style["height"] = `${finalHeight}px`;
@@ -1,8 +1,10 @@
1
+ import { isDark } from "./util/dark.js";
1
2
  import { router } from "./router.js";
3
+ import { installRenderRootColorScheme } from "./util/color-scheme.js";
2
4
  import App_default from "./App.js";
3
- import "./plugin.js";
5
+ import { setupPluginApi } from "./plugin.js";
4
6
  import { iconCollections } from "./util/icons.generated.js";
5
- import { createApp } from "@poveste/vendors/vue";
7
+ import { createApp, watch } from "@poveste/vendors/vue";
6
8
  import { addCollection } from "@poveste/vendors/iconify";
7
9
  import { createPinia } from "@poveste/vendors/pinia";
8
10
  import { generation } from "virtual:$poveste-stories";
@@ -10,11 +12,18 @@ import "virtual:$poveste-theme";
10
12
  //#region src/app/index.ts
11
13
  async function mountMainApp() {
12
14
  for (const collection of iconCollections) addCollection(collection);
15
+ watch(isDark, (dark) => {
16
+ document.documentElement.style.colorScheme = dark ? "dark" : "light";
17
+ }, { immediate: true });
18
+ installRenderRootColorScheme();
13
19
  const app = createApp(App_default);
14
20
  app.use(createPinia());
15
21
  app.use(router);
16
22
  app.mount("#app");
17
- if (import.meta.hot) import.meta.hot.send("poveste:mount", { generation });
23
+ if (import.meta.hot) {
24
+ import.meta.hot.send("poveste:mount", { generation });
25
+ setupPluginApi();
26
+ }
18
27
  }
19
28
  //#endregion
20
29
  export { mountMainApp };
@@ -1,16 +1,18 @@
1
1
  import { isDark } from "./util/dark.js";
2
- import { PREVIEW_SETTINGS_REQUEST, SANDBOX_HEIGHT, SANDBOX_READY, STATE_SYNC } from "./util/const.js";
2
+ import { PREVIEW_SETTINGS_REQUEST, SANDBOX_COLOR_SCHEME, SANDBOX_HEIGHT, SANDBOX_READY, STATE_SYNC } from "./util/const.js";
3
3
  import { occupant } from "./util/occupant.js";
4
- import { previewDarkClasses, resolvePreviewDark } from "./util/color-scheme.js";
4
+ import { lowPriorityColorScheme, previewColorScheme, previewDarkClasses, resolvePreviewDark } from "./util/color-scheme.js";
5
5
  import { applyPreviewSettings, loadStoredPreviewSettings, receivedSettings } from "./util/preview-settings.js";
6
6
  import GenericMountStory_default from "./components/story/GenericMountStory.js";
7
7
  import { mapFile } from "./util/mapping.js";
8
+ import { iconCollections } from "./util/icons.generated.js";
8
9
  import GenericRenderStory_default from "./components/story/GenericRenderStory.js";
9
10
  import { createStateBridge } from "./util/state-bridge.js";
10
11
  import { toRawDeep } from "./util/state.js";
11
12
  import { isBenignResizeObserverEvent } from "./util/uncaught.js";
12
13
  import { usePreferredDark } from "@poveste/vendors/vue-use";
13
14
  import { computed, createApp, h, onMounted, ref, watch, watchEffect } from "@poveste/vendors/vue";
15
+ import { addCollection } from "@poveste/vendors/iconify";
14
16
  import { createPinia } from "@poveste/vendors/pinia";
15
17
  import { files, onUpdate } from "virtual:$poveste-stories";
16
18
  import { parseQuery } from "@poveste/vendors/vue-router";
@@ -55,8 +57,35 @@ watch(previewDark, (value) => {
55
57
  for (const className of previewDarkClasses()) el.classList.toggle(className, value);
56
58
  }
57
59
  }, { immediate: true });
60
+ var reportedColorScheme = "";
61
+ function reportColorScheme() {
62
+ if (window.parent === window) return;
63
+ const scheme = getComputedStyle(document.documentElement).colorScheme;
64
+ if (scheme === reportedColorScheme) return;
65
+ reportedColorScheme = scheme;
66
+ window.parent.postMessage({
67
+ type: SANDBOX_COLOR_SCHEME,
68
+ scheme
69
+ }, window.location.origin);
70
+ }
71
+ new MutationObserver(reportColorScheme).observe(document.head, {
72
+ childList: true,
73
+ subtree: true,
74
+ characterData: true
75
+ });
76
+ new MutationObserver(reportColorScheme).observe(document.documentElement, {
77
+ attributes: true,
78
+ attributeFilter: ["class", "style"]
79
+ });
80
+ document.addEventListener("load", reportColorScheme, true);
81
+ var setRootColorScheme = lowPriorityColorScheme(":root");
82
+ watch(() => previewColorScheme(receivedSettings.colorScheme, isDark.value), (value) => {
83
+ setRootColorScheme(value);
84
+ reportColorScheme();
85
+ }, { immediate: true });
58
86
  var pendingFrame = null;
59
87
  var lastReportedHeight = -1;
88
+ for (const collection of iconCollections) addCollection(collection);
60
89
  var app = createApp({
61
90
  name: "SandboxApp",
62
91
  setup() {
@@ -125,6 +154,7 @@ app.mount("#app");
125
154
  document.body.classList.add("__poveste-render-story", "__poveste-render-custom-controls");
126
155
  function reportHeight() {
127
156
  pendingFrame = null;
157
+ reportColorScheme();
128
158
  const renderRoot = document.querySelector(".__poveste-render-story");
129
159
  const h = renderRoot ? Math.ceil(renderRoot.getBoundingClientRect().height) : Math.ceil(document.body.scrollHeight);
130
160
  if (h === lastReportedHeight) return;
@@ -2,21 +2,46 @@ import { povesteConfig } from "../util/config.js";
2
2
  import { defaultPreviewColorScheme } from "../util/color-scheme.js";
3
3
  import { PREVIEW_SETTINGS_STORAGE_KEY } from "../util/preview-settings.js";
4
4
  import { useStorage } from "@poveste/vendors/vue-use";
5
+ import { watch } from "@poveste/vendors/vue";
5
6
  import { defineStore } from "@poveste/vendors/pinia";
6
7
  //#region src/app/stores/preview-settings.ts
8
+ var UNITS = [
9
+ ["responsiveWidth", "responsiveHeight"],
10
+ ["backgroundColor"],
11
+ ["rotate"],
12
+ ["checkerboard"],
13
+ ["textDirection"]
14
+ ];
15
+ /** The book's `preview` config, with the deprecated `defaultBackgroundColor` under it. */
16
+ function configured() {
17
+ const legacy = povesteConfig.defaultBackgroundColor;
18
+ return {
19
+ ...legacy === void 0 ? {} : { backgroundColor: legacy },
20
+ ...povesteConfig.preview
21
+ };
22
+ }
7
23
  var usePreviewSettingsStore = defineStore("preview-settings", () => {
24
+ const book = configured();
8
25
  const currentSettings = useStorage(PREVIEW_SETTINGS_STORAGE_KEY, {
9
26
  responsiveWidth: 720,
10
27
  responsiveHeight: null,
11
28
  rotate: false,
12
- backgroundColor: povesteConfig.defaultBackgroundColor ?? "transparent",
29
+ backgroundColor: "transparent",
13
30
  backgroundColorPicked: false,
14
31
  checkerboard: false,
15
32
  textDirection: "ltr",
16
- colorScheme: defaultPreviewColorScheme
33
+ colorScheme: defaultPreviewColorScheme,
34
+ ...book
35
+ });
36
+ const picked = new Set(currentSettings.value.picked ?? []);
37
+ if (currentSettings.value.backgroundColorPicked) picked.add("backgroundColor");
38
+ for (const unit of UNITS) {
39
+ if (picked.has(unit[0])) continue;
40
+ for (const key of unit) if (book[key] !== void 0) Object.assign(currentSettings.value, { [key]: book[key] });
41
+ }
42
+ for (const unit of UNITS) watch(() => unit.map((key) => currentSettings.value[key]), () => {
43
+ currentSettings.value.picked = [.../* @__PURE__ */ new Set([...currentSettings.value.picked ?? [], unit[0]])];
17
44
  });
18
- const configBg = povesteConfig.defaultBackgroundColor;
19
- if (configBg && !currentSettings.value.backgroundColorPicked) currentSettings.value.backgroundColor = configBg;
20
45
  currentSettings.value.colorScheme ??= defaultPreviewColorScheme;
21
46
  function setBackgroundColor(color) {
22
47
  currentSettings.value.backgroundColor = color;
@@ -23,6 +23,46 @@ function resolvePreviewDark(colorScheme, prefersDark, chromeDark) {
23
23
  }
24
24
  }
25
25
  /**
26
+ * The CSS `color-scheme` a preview declares, from the same inputs as the class.
27
+ *
28
+ * The class tells the book's CSS; this tells the browser, which paints native
29
+ * widgets, scrollbars and the canvas itself and reads no class (#991). `auto`
30
+ * becomes `light dark`, so the browser follows the OS preference on its own
31
+ * rather than being told the answer `prefersDark` already computed.
32
+ */
33
+ function previewColorScheme(colorScheme, chromeDark) {
34
+ switch (colorScheme) {
35
+ case "light": return "light";
36
+ case "dark": return "dark";
37
+ case "auto": return "light dark";
38
+ default: return chromeDark ? "dark" : "light";
39
+ }
40
+ }
41
+ /**
42
+ * Declares `color-scheme` on `selector` beneath any rule a book writes: in the
43
+ * first cascade layer of the document, at zero specificity. Set inline, it beat
44
+ * a book's own `:root { color-scheme }` on every render path (#1167).
45
+ */
46
+ function lowPriorityColorScheme(selector) {
47
+ const style = document.createElement("style");
48
+ document.head.prepend(style);
49
+ return (value) => {
50
+ style.textContent = `@layer poveste-color-scheme { :where(${selector}) { color-scheme: ${value}; } }`;
51
+ };
52
+ }
53
+ /**
54
+ * Previews the app renders itself carry their scheme as a custom property, which
55
+ * this applies to their root at the same low priority. Style isolation moves a
56
+ * book's own `:root` rule onto that root, so it wins.
57
+ */
58
+ function installRenderRootColorScheme() {
59
+ lowPriorityColorScheme(".__poveste-render-story")("var(--poveste-color-scheme)");
60
+ }
61
+ /** `previewColorScheme`, for previews rendered by the app itself. */
62
+ function usePreviewColorScheme(settings) {
63
+ return computed(() => previewColorScheme(settings.colorScheme, isDark.value));
64
+ }
65
+ /**
26
66
  * Whether the story preview should be rendered dark, for previews rendered by
27
67
  * the app itself. The sandbox resolves the same thing from the settings it
28
68
  * receives over `PREVIEW_SETTINGS_SYNC`.
@@ -42,4 +82,4 @@ function previewDarkClasses() {
42
82
  return [.../* @__PURE__ */ new Set([darkClass, legacy])].filter((name) => !!name);
43
83
  }
44
84
  //#endregion
45
- export { defaultPreviewColorScheme, previewDarkClasses, resolvePreviewDark, usePreviewDark };
85
+ export { defaultPreviewColorScheme, installRenderRootColorScheme, lowPriorityColorScheme, previewColorScheme, previewDarkClasses, resolvePreviewDark, usePreviewColorScheme, usePreviewDark };
@@ -36,14 +36,26 @@ var builtinCommands = [{
36
36
  window.open("https://poveste.dev/guide/getting-started", "_blank");
37
37
  }
38
38
  }];
39
- function executeCommand(command, params) {
40
- if (import.meta.hot) {
41
- import.meta.hot.send("poveste:dev-command", {
39
+ async function executeCommand(command, params) {
40
+ const hot = import.meta.hot;
41
+ if (!hot) return;
42
+ const result = await new Promise((resolve) => {
43
+ const listener = (data) => {
44
+ if (data.id !== command.id) return;
45
+ hot.off("poveste:dev-command-result", listener);
46
+ resolve(data);
47
+ };
48
+ hot.on("poveste:dev-command-result", listener);
49
+ hot.send("poveste:dev-command", {
42
50
  id: command.id,
43
51
  params
44
52
  });
45
- command.clientAction?.(params, getCommandContext());
53
+ });
54
+ if (result.error) {
55
+ console.error(`[poveste] ${command.label}: ${result.error}`);
56
+ return;
46
57
  }
58
+ command.clientAction?.(params, getCommandContext());
47
59
  }
48
60
  function getCommandContext() {
49
61
  const storyStore = useStoryStore();
@@ -6,5 +6,6 @@ var PREVIEW_SETTINGS_SYNC = "__poveste:preview-settings-sync";
6
6
  var PREVIEW_SETTINGS_REQUEST = "__poveste:preview-settings-request";
7
7
  var SANDBOX_HEIGHT = "__poveste:sandbox-height";
8
8
  var SANDBOX_RETARGET = "__poveste:sandbox-retarget";
9
+ var SANDBOX_COLOR_SCHEME = "__poveste:sandbox-color-scheme";
9
10
  //#endregion
10
- export { EVENT_SEND, PREVIEW_SETTINGS_REQUEST, PREVIEW_SETTINGS_SYNC, SANDBOX_HEIGHT, SANDBOX_READY, SANDBOX_RETARGET, STATE_SYNC };
11
+ export { EVENT_SEND, PREVIEW_SETTINGS_REQUEST, PREVIEW_SETTINGS_SYNC, SANDBOX_COLOR_SCHEME, SANDBOX_HEIGHT, SANDBOX_READY, SANDBOX_RETARGET, STATE_SYNC };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poveste/app",
3
3
  "type": "module",
4
- "version": "0.18.3",
4
+ "version": "0.19.0",
5
5
  "description": "Pre-bundled UI for Poveste",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan",
@@ -27,6 +27,8 @@
27
27
  "./*": "./*"
28
28
  },
29
29
  "files": [
30
+ "!src/**/*.spec.ts",
31
+ "!src/**/__tests__",
30
32
  "dist",
31
33
  "src"
32
34
  ],
@@ -34,9 +36,9 @@
34
36
  "node": ">=22.22.2"
35
37
  },
36
38
  "dependencies": {
37
- "@poveste/controls": "^0.18.3",
38
- "@poveste/shared": "^0.18.3",
39
- "@poveste/vendors": "^0.18.3",
39
+ "@poveste/controls": "^0.19.0",
40
+ "@poveste/shared": "^0.19.0",
41
+ "@poveste/vendors": "^0.19.0",
40
42
  "fuse.js": "^7.0.0",
41
43
  "shiki": "^4.4.3"
42
44
  },