histoire 0.7.2 → 0.7.5

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 (112) hide show
  1. package/client.d.ts +1 -1
  2. package/dist/bundled/StoryView.js +22 -19
  3. package/dist/bundled/dark.js +4 -0
  4. package/dist/bundled/index.js +0 -1
  5. package/dist/bundled/index2.js +6 -6
  6. package/dist/bundled/mapping.js +78 -0
  7. package/dist/bundled/sandbox.js +7 -6
  8. package/dist/bundled/state.js +13 -44
  9. package/dist/bundled/style.css +3 -3
  10. package/dist/client/app/App.vue +2 -2
  11. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  12. package/dist/client/app/components/panel/ControlsComponentProps.vue +2 -1
  13. package/dist/client/app/components/panel/StatePresets.vue +2 -1
  14. package/dist/client/app/components/panel/StoryControls.vue +1 -1
  15. package/dist/client/app/components/panel/StorySourceCode.vue +2 -2
  16. package/dist/client/app/components/story/StoryVariantGridItem.vue +1 -1
  17. package/dist/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  18. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  19. package/dist/client/app/components/story/StoryVariantSingleView.vue +1 -1
  20. package/dist/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  21. package/dist/client/app/components/tree/StoryGroup.vue +1 -1
  22. package/dist/client/app/index.js +0 -2
  23. package/dist/client/app/sandbox.js +4 -5
  24. package/dist/client/app/types.d.ts +1 -52
  25. package/dist/client/app/util/mapping.d.ts +1 -1
  26. package/dist/client/app/util/mapping.js +50 -36
  27. package/dist/client/app/{components/sandbox/lib.d.ts → util/sandbox.d.ts} +1 -1
  28. package/dist/client/app/{components/sandbox/lib.js → util/sandbox.js} +1 -1
  29. package/dist/client/app/util/state.d.ts +1 -5
  30. package/dist/client/app/util/state.js +12 -44
  31. package/dist/node/collect/index.d.ts +2 -2
  32. package/dist/node/collect/index.js +3 -0
  33. package/dist/node/collect/run.d.ts +2 -0
  34. package/dist/{client/server/index.js → node/collect/run.js} +1 -1
  35. package/dist/node/collect/worker.d.ts +3 -3
  36. package/dist/node/collect/worker.js +4 -1
  37. package/dist/node/config.d.ts +3 -3
  38. package/dist/node/context.d.ts +2 -2
  39. package/dist/node/plugin.d.ts +3 -3
  40. package/dist/node/stories.d.ts +4 -4
  41. package/dist/node/tree.d.ts +3 -22
  42. package/dist/node/vite.js +1 -0
  43. package/dist/style.css +76 -0
  44. package/package.json +4 -2
  45. package/src/client/app/App.vue +2 -2
  46. package/src/client/app/components/panel/ControlsComponentPropItem.vue +13 -6
  47. package/src/client/app/components/panel/ControlsComponentProps.vue +2 -1
  48. package/src/client/app/components/panel/StatePresets.vue +2 -1
  49. package/src/client/app/components/panel/StoryControls.vue +1 -1
  50. package/src/client/app/components/panel/StorySourceCode.vue +2 -2
  51. package/src/client/app/components/story/StoryVariantGridItem.vue +1 -1
  52. package/src/client/app/components/story/StoryVariantSinglePreviewNative.vue +1 -1
  53. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +3 -2
  54. package/src/client/app/components/story/StoryVariantSingleView.vue +1 -1
  55. package/src/client/app/components/toolbar/StoryVariantNewTab.vue +1 -1
  56. package/src/client/app/components/tree/StoryGroup.vue +1 -1
  57. package/src/client/app/index.ts +0 -2
  58. package/src/client/app/sandbox.ts +4 -5
  59. package/src/client/app/types.ts +6 -57
  60. package/src/client/app/util/mapping.ts +47 -34
  61. package/src/client/app/{components/sandbox/lib.ts → util/sandbox.ts} +2 -2
  62. package/src/client/app/util/state.ts +15 -44
  63. package/src/node/collect/index.ts +5 -2
  64. package/src/node/collect/run.ts +13 -0
  65. package/src/node/collect/worker.ts +8 -6
  66. package/src/node/config.ts +3 -3
  67. package/src/node/context.ts +2 -2
  68. package/src/node/plugin.ts +2 -2
  69. package/src/node/server.ts +2 -2
  70. package/src/node/stories.ts +4 -4
  71. package/src/node/tree.ts +7 -31
  72. package/src/node/vite.ts +1 -0
  73. package/vite.config.ts +12 -7
  74. package/dist/bundled/SandboxVue3.js +0 -706
  75. package/dist/bundled/global-components.js +0 -213
  76. package/dist/client/app/codegen/const.d.ts +0 -1
  77. package/dist/client/app/codegen/const.js +0 -3
  78. package/dist/client/app/codegen/serialize-js.d.ts +0 -1
  79. package/dist/client/app/codegen/serialize-js.js +0 -113
  80. package/dist/client/app/codegen/util.d.ts +0 -10
  81. package/dist/client/app/codegen/util.js +0 -70
  82. package/dist/client/app/codegen/vue3.d.ts +0 -4
  83. package/dist/client/app/codegen/vue3.js +0 -357
  84. package/dist/client/app/components/exposed/Story.vue +0 -106
  85. package/dist/client/app/components/exposed/Variant.vue +0 -78
  86. package/dist/client/app/components/sandbox/RouterLinkStub.d.ts +0 -21
  87. package/dist/client/app/components/sandbox/RouterLinkStub.js +0 -43
  88. package/dist/client/app/components/sandbox/SandboxVue3.vue +0 -185
  89. package/dist/client/app/global-components.d.ts +0 -2
  90. package/dist/client/app/global-components.js +0 -10
  91. package/dist/client/server/index.d.ts +0 -7
  92. package/dist/client/server/vue3/Story.vue +0 -120
  93. package/dist/client/server/vue3/Variant.vue +0 -52
  94. package/dist/client/server/vue3/run.d.ts +0 -2
  95. package/dist/client/server/vue3/run.js +0 -45
  96. package/dist/node/types.d.ts +0 -50
  97. package/dist/node/types.js +0 -1
  98. package/src/client/app/codegen/const.ts +0 -3
  99. package/src/client/app/codegen/serialize-js.ts +0 -119
  100. package/src/client/app/codegen/util.ts +0 -79
  101. package/src/client/app/codegen/vue3.ts +0 -361
  102. package/src/client/app/components/exposed/Story.vue +0 -106
  103. package/src/client/app/components/exposed/Variant.vue +0 -78
  104. package/src/client/app/components/sandbox/RouterLinkStub.ts +0 -49
  105. package/src/client/app/components/sandbox/SandboxVue3.vue +0 -185
  106. package/src/client/app/global-components.ts +0 -13
  107. package/src/client/server/index.ts +0 -19
  108. package/src/client/server/vue3/Story.vue +0 -120
  109. package/src/client/server/vue3/Variant.vue +0 -52
  110. package/src/client/server/vue3/run.ts +0 -55
  111. package/src/components.d.ts +0 -143
  112. package/src/node/types.ts +0 -53
package/src/node/tree.ts CHANGED
@@ -1,32 +1,8 @@
1
1
  import pc from 'picocolors'
2
+ import type { ServerStoryFile, ServerTree, ServerTreeFile } from '@histoire/shared'
2
3
  import type { HistoireConfig, TreeGroupConfig } from './config.js'
3
- import type { StoryFile } from './types.js'
4
4
 
5
- export interface TreeFile {
6
- title: string
7
- path: string
8
- }
9
-
10
- export interface TreeLeaf {
11
- title: string
12
- index: number
13
- }
14
-
15
- export interface TreeFolder {
16
- title: string
17
- children: (TreeFolder | TreeLeaf)[]
18
- }
19
-
20
- export interface TreeGroup {
21
- group: true
22
- id: string
23
- title: string
24
- children: (TreeFolder | TreeLeaf)[]
25
- }
26
-
27
- export type Tree = (TreeGroup | TreeFolder | TreeLeaf)[]
28
-
29
- export function createPath (config: HistoireConfig, file: TreeFile) {
5
+ export function createPath (config: HistoireConfig, file: ServerTreeFile) {
30
6
  if (config.tree.file === 'title') {
31
7
  return file.title.split('/')
32
8
  }
@@ -41,7 +17,7 @@ export function createPath (config: HistoireConfig, file: TreeFile) {
41
17
  return config.tree.file(file)
42
18
  }
43
19
 
44
- export function makeTree (config: HistoireConfig, files: StoryFile[]) {
20
+ export function makeTree (config: HistoireConfig, files: ServerStoryFile[]) {
45
21
  interface ITreeObject {
46
22
  [index: string]: number | ITreeObject
47
23
  }
@@ -71,7 +47,7 @@ export function makeTree (config: HistoireConfig, files: StoryFile[]) {
71
47
  sortingFunction = config.tree.order
72
48
  }
73
49
 
74
- const result: Tree = []
50
+ const result: ServerTree = []
75
51
 
76
52
  for (const group of groups) {
77
53
  if (group === defaultGroup) {
@@ -88,7 +64,7 @@ export function makeTree (config: HistoireConfig, files: StoryFile[]) {
88
64
 
89
65
  return result
90
66
 
91
- function getGroup (file: StoryFile): ITreeGroup {
67
+ function getGroup (file: ServerStoryFile): ITreeGroup {
92
68
  if (file.story?.group) {
93
69
  const group = groups.find(g => g.groupConfig?.id === file.story.group)
94
70
  if (group) {
@@ -142,8 +118,8 @@ export function makeTree (config: HistoireConfig, files: StoryFile[]) {
142
118
  }
143
119
  }
144
120
 
145
- function buildTree (treeObject: ITreeObject): Tree {
146
- const tree: Tree = []
121
+ function buildTree (treeObject: ITreeObject): ServerTree {
122
+ const tree: ServerTree = []
147
123
 
148
124
  for (const [key, element] of Object.entries(treeObject)) {
149
125
  if (Number.isInteger(element)) {
package/src/node/vite.ts CHANGED
@@ -87,6 +87,7 @@ export async function getViteConfigWithPlugins (server: boolean, ctx: Context):
87
87
  ],
88
88
  exclude: [
89
89
  'histoire',
90
+ '@histoire',
90
91
  ],
91
92
  },
92
93
  server: {
package/vite.config.ts CHANGED
@@ -17,15 +17,19 @@ export default defineConfig({
17
17
  }
18
18
  },
19
19
  closeBundle () {
20
- const files = fs.readdirSync('./dist/bundled')
21
- for (const file of files) {
22
- if (file.endsWith('.js')) {
23
- const filePath = path.join('./dist/bundled', file)
24
- const content = fs.readFileSync(filePath, 'utf-8')
25
- if (content.includes('import__meta')) {
26
- fs.writeFileSync(filePath, content.replace(/import__meta/g, 'import.meta'), 'utf-8')
20
+ try {
21
+ const files = fs.readdirSync('./dist/bundled')
22
+ for (const file of files) {
23
+ if (file.endsWith('.js')) {
24
+ const filePath = path.join('./dist/bundled', file)
25
+ const content = fs.readFileSync(filePath, 'utf-8')
26
+ if (content.includes('import__meta')) {
27
+ fs.writeFileSync(filePath, content.replace(/import__meta/g, 'import.meta'), 'utf-8')
28
+ }
27
29
  }
28
30
  }
31
+ } catch (e) {
32
+ console.error(e)
29
33
  }
30
34
  },
31
35
  },
@@ -41,6 +45,7 @@ export default defineConfig({
41
45
  rollupOptions: {
42
46
  external: [
43
47
  /\$histoire/,
48
+ /@histoire/,
44
49
  /@vue\/*/,
45
50
  // eslint-disable-next-line @typescript-eslint/no-var-requires
46
51
  ...Object.keys(require('./package.json').dependencies),