poveste 0.1.3 → 0.2.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 (92) hide show
  1. package/dist/node/bin.js +3 -1
  2. package/dist/node/build.d.ts.map +1 -1
  3. package/dist/node/build.js +23 -5
  4. package/dist/node/builtin-plugins/pinceau-tokens.js +35 -35
  5. package/dist/node/builtin-plugins/tailwind-tokens.js +38 -38
  6. package/dist/node/builtin-plugins/vanilla-support/RenderStory.d.ts.map +1 -1
  7. package/dist/node/builtin-plugins/vanilla-support/RenderStory.js +7 -4
  8. package/dist/node/builtin-plugins/vanilla-support/types.d.ts +6 -5
  9. package/dist/node/builtin-plugins/vanilla-support/types.d.ts.map +1 -1
  10. package/dist/node/commands/preview.d.ts +2 -0
  11. package/dist/node/commands/preview.d.ts.map +1 -1
  12. package/dist/node/commands/preview.js +6 -3
  13. package/dist/node/config.d.ts.map +1 -1
  14. package/dist/node/config.js +1 -0
  15. package/dist/node/context.js +2 -2
  16. package/dist/node/dom/env.d.ts.map +1 -1
  17. package/dist/node/dom/env.js +26 -1
  18. package/dist/node/markdown.js +1 -1
  19. package/dist/node/preview.d.ts +7 -1
  20. package/dist/node/preview.d.ts.map +1 -1
  21. package/dist/node/preview.js +22 -39
  22. package/dist/node/style-isolation/entry-css-merger.d.ts +9 -0
  23. package/dist/node/style-isolation/entry-css-merger.d.ts.map +1 -0
  24. package/dist/node/style-isolation/entry-css-merger.js +128 -0
  25. package/dist/node/style-isolation/global-styles.d.ts +8 -0
  26. package/dist/node/style-isolation/global-styles.d.ts.map +1 -0
  27. package/dist/node/style-isolation/global-styles.js +31 -0
  28. package/dist/node/style-isolation/index.d.ts +6 -0
  29. package/dist/node/style-isolation/index.d.ts.map +1 -0
  30. package/dist/node/style-isolation/index.js +5 -0
  31. package/dist/node/style-isolation/scope-chrome.d.ts +6 -0
  32. package/dist/node/style-isolation/scope-chrome.d.ts.map +1 -0
  33. package/dist/node/style-isolation/scope-chrome.js +37 -0
  34. package/dist/node/style-isolation/selectors.d.ts +7 -0
  35. package/dist/node/style-isolation/selectors.d.ts.map +1 -0
  36. package/dist/node/style-isolation/selectors.js +15 -0
  37. package/dist/node/style-isolation/transforms.d.ts +11 -0
  38. package/dist/node/style-isolation/transforms.d.ts.map +1 -0
  39. package/dist/node/style-isolation/transforms.js +75 -0
  40. package/dist/node/style-isolation/vite-plugin.d.ts +15 -0
  41. package/dist/node/style-isolation/vite-plugin.d.ts.map +1 -0
  42. package/dist/node/style-isolation/vite-plugin.js +62 -0
  43. package/dist/node/util/head.d.ts +3 -0
  44. package/dist/node/util/head.d.ts.map +1 -0
  45. package/dist/node/util/head.js +10 -0
  46. package/dist/node/virtual/markdown.js +1 -1
  47. package/dist/node/virtual/noop.d.ts +2 -1
  48. package/dist/node/virtual/noop.d.ts.map +1 -1
  49. package/dist/node/virtual/noop.js +7 -1
  50. package/dist/node/virtual/resolved-generated-global-setup.js +3 -3
  51. package/dist/node/virtual/resolved-markdown-files.js +2 -2
  52. package/dist/node/virtual/util.d.ts +15 -0
  53. package/dist/node/virtual/util.d.ts.map +1 -1
  54. package/dist/node/virtual/util.js +18 -0
  55. package/dist/node/virtual/vite-plugin.js +1 -1
  56. package/dist/node/vite.d.ts +1 -1
  57. package/dist/node/vite.d.ts.map +1 -1
  58. package/dist/node/vite.js +51 -9
  59. package/package.json +7 -5
  60. package/src/node/__tests__/dom-env.spec.ts +38 -0
  61. package/src/node/__tests__/head.spec.ts +32 -0
  62. package/src/node/__tests__/virtual-setup.spec.ts +51 -0
  63. package/src/node/bin.ts +3 -1
  64. package/src/node/build.ts +31 -5
  65. package/src/node/builtin-plugins/pinceau-tokens.ts +35 -35
  66. package/src/node/builtin-plugins/tailwind-tokens.ts +38 -38
  67. package/src/node/builtin-plugins/vanilla-support/RenderStory.ts +8 -5
  68. package/src/node/builtin-plugins/vanilla-support/types.ts +3 -1
  69. package/src/node/commands/preview.ts +8 -3
  70. package/src/node/config.ts +1 -0
  71. package/src/node/context.ts +2 -2
  72. package/src/node/dom/env.ts +26 -1
  73. package/src/node/markdown.ts +1 -1
  74. package/src/node/preview.ts +30 -47
  75. package/src/node/style-isolation/__tests__/entry-css-merger.spec.ts +126 -0
  76. package/src/node/style-isolation/__tests__/transforms.spec.ts +92 -0
  77. package/src/node/style-isolation/__tests__/vite-plugin.spec.ts +39 -0
  78. package/src/node/style-isolation/entry-css-merger.ts +133 -0
  79. package/src/node/style-isolation/global-styles.ts +37 -0
  80. package/src/node/style-isolation/index.ts +5 -0
  81. package/src/node/style-isolation/scope-chrome.ts +42 -0
  82. package/src/node/style-isolation/selectors.ts +16 -0
  83. package/src/node/style-isolation/transforms.ts +90 -0
  84. package/src/node/style-isolation/vite-plugin.ts +75 -0
  85. package/src/node/util/head.ts +12 -0
  86. package/src/node/virtual/markdown.ts +1 -1
  87. package/src/node/virtual/noop.ts +9 -1
  88. package/src/node/virtual/resolved-generated-global-setup.ts +3 -3
  89. package/src/node/virtual/resolved-markdown-files.ts +2 -2
  90. package/src/node/virtual/util.ts +22 -0
  91. package/src/node/virtual/vite-plugin.ts +1 -1
  92. package/src/node/vite.ts +57 -9
package/dist/node/bin.js CHANGED
@@ -13,7 +13,7 @@ program.command('dev')
13
13
  .option('-p, --port <port>', 'Listening port of the server')
14
14
  .option('-c, --config <file>', `[string] use specified config file`)
15
15
  .option('--open', 'Open in your default browser')
16
- .option('--host <host>', '[string] specify hostname')
16
+ .option('--host [host]', '[string] specify hostname (omit value or pass `0.0.0.0` to expose to all network interfaces)')
17
17
  .action(async (options) => {
18
18
  const { devCommand } = await import('./commands/dev.js');
19
19
  return devCommand(options);
@@ -28,6 +28,8 @@ program.command('build')
28
28
  program.command('preview')
29
29
  .describe('preview the built directory')
30
30
  .option('-p, --port <port>', 'Listening port of the server')
31
+ .option('--open', 'Open in your default browser')
32
+ .option('--host [host]', '[string] specify hostname (omit value or pass `0.0.0.0` to expose to all network interfaces)')
31
33
  .action(async (options) => {
32
34
  const { previewCommand } = await import('./commands/preview.js');
33
35
  return previewCommand(options);
@@ -1 +1 @@
1
- {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AA+B3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA8MvC"}
1
+ {"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/node/build.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AAqC3C,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,iBA6NvC"}
@@ -12,6 +12,8 @@ import { createMarkdownFilesWatcher } from './markdown.js';
12
12
  import { BuildPluginApi } from './plugin.js';
13
13
  import { startPreview } from './preview.js';
14
14
  import { findAllStories } from './stories.js';
15
+ import { chromeCssScopePlugin, entryCssMergerPlugin, userCssScopePlugin, } from './style-isolation/index.js';
16
+ import { applyHeadTransform } from './util/head.js';
15
17
  import { getViteConfigWithPlugins } from './vite.js';
16
18
  const PRELOAD_MODULES = [
17
19
  'vendor',
@@ -135,7 +137,8 @@ export async function build(ctx) {
135
137
  Object.assign(config.build, {
136
138
  outDir: ctx.config.outDir,
137
139
  emptyOutDir: true,
138
- cssCodeSplit: false,
140
+ // Re-merged per-entry by entry-css-merger.
141
+ cssCodeSplit: true,
139
142
  minify: false,
140
143
  // Don't build in SSR mode
141
144
  ssr: false,
@@ -143,13 +146,22 @@ export async function build(ctx) {
143
146
  config.define.__HST_COLLECT__ = false;
144
147
  },
145
148
  });
149
+ const isolate = ctx.config.isolateStyles !== false;
150
+ buildViteConfig.plugins.push(userCssScopePlugin({ enabled: isolate }));
151
+ buildViteConfig.plugins.push(chromeCssScopePlugin({ enabled: isolate }));
152
+ buildViteConfig.plugins.push(entryCssMergerPlugin({ isolateStyles: isolate }));
146
153
  for (const cb of changeViteConfigCallbacks) {
147
154
  console.log('vite config hook', cb);
148
155
  await cb(buildViteConfig);
149
156
  }
150
157
  const results = await viteBuild(buildViteConfig);
151
158
  const result = Array.isArray(results) ? results[0] : results;
152
- const styleOutput = result.output.find(o => o.name === 'style.css' && o.type === 'asset');
159
+ function findEntryCss(entryName) {
160
+ return result.output.find(o => o.type === 'asset' && o.fileName === `${entryName}.css`);
161
+ }
162
+ const mainStyleOutput = findEntryCss('bundle-main')
163
+ ?? result.output.find(o => o.name === 'style.css' && o.type === 'asset');
164
+ const sandboxStyleOutput = findEntryCss('bundle-sandbox') ?? mainStyleOutput;
153
165
  // Preload
154
166
  const preloadOutputs = result.output.filter(o => PRELOAD_MODULES.includes(o.name) && o.type === 'chunk');
155
167
  const preloadHtml = generateScriptLinks(preloadOutputs.map(o => o.fileName), 'preload', ctx);
@@ -158,13 +170,15 @@ export async function build(ctx) {
158
170
  const prefetchHtml = generateScriptLinks(prefetchOutputs.map(o => o.fileName), 'prefetch', ctx);
159
171
  // Index
160
172
  const indexOutput = result.output.find(o => o.name === 'bundle-main' && o.type === 'chunk');
161
- const indexHtml = generateEntryHtml(indexOutput.fileName, styleOutput.fileName, {
173
+ let indexHtml = generateEntryHtml(indexOutput.fileName, mainStyleOutput.fileName, {
162
174
  HEAD: `${preloadHtml}${prefetchHtml}`,
163
175
  }, ctx);
176
+ indexHtml = await applyHeadTransform(indexHtml, ctx.config.head);
164
177
  await writeFile('index.html', indexHtml, ctx);
165
178
  // Sandbox
166
179
  const sandboxOutput = result.output.find(o => o.name === 'bundle-sandbox' && o.type === 'chunk');
167
- const sandboxHtml = generateEntryHtml(sandboxOutput.fileName, styleOutput.fileName, {}, ctx);
180
+ let sandboxHtml = generateEntryHtml(sandboxOutput.fileName, sandboxStyleOutput.fileName, {}, ctx);
181
+ sandboxHtml = await applyHeadTransform(sandboxHtml, ctx.config.head);
168
182
  await writeFile('__sandbox.html', sandboxHtml, ctx);
169
183
  await writeFile('poveste.json', JSON.stringify(getSerializedStoryData(ctx), null, 2), ctx);
170
184
  const duration = performance.now() - startTime;
@@ -174,7 +188,7 @@ export async function build(ctx) {
174
188
  console.log(pc.green(`✅ Built ${storyCount} stor${storyCount === 1 ? 'y' : 'ies'} (${variantCount} variant${variantCount === 1 ? '' : 's'}) in ${Math.round(duration / 1000 * 100) / 100}s`));
175
189
  // Render
176
190
  if (previewStoryCallbacks.length) {
177
- const { baseUrl, close } = await startPreview(null, ctx);
191
+ const { baseUrl, close } = await startPreview({}, ctx);
178
192
  for (const storyFile of ctx.storyFiles) {
179
193
  const story = storyFile.story;
180
194
  for (const variant of story.variants) {
@@ -207,6 +221,7 @@ function generateBaseHtml(head, body, ctx) {
207
221
  <meta charset="utf-8">
208
222
  <meta name="viewport" content="width=device-width,initial-scale=1">
209
223
  <meta name="description" content="">
224
+ <style>html,body{margin:0;padding:0}</style>
210
225
  ${head}
211
226
  </head>
212
227
  <body>
@@ -226,3 +241,6 @@ async function writeFile(fileName, content, ctx) {
226
241
  function generateScriptLinks(prefetchScripts, rel, ctx) {
227
242
  return prefetchScripts.map(s => `<link rel="${rel}" href="${ctx.resolvedViteConfig.base}${s}" as="script" crossOrigin="anonymous">`).join('');
228
243
  }
244
+ function generateStyleLinks(styleFiles, rel, ctx) {
245
+ return styleFiles.map(s => `<link rel="${rel}" href="${ctx.resolvedViteConfig.base}${s}" as="style">`).join('');
246
+ }
@@ -150,7 +150,7 @@ export default {
150
150
  getName: key => '@mq.' + key,
151
151
  colSize: 180,
152
152
  }, ({ token }) => h('div', {
153
- class: '__hst-drop-shadow',
153
+ class: '__pvt-drop-shadow',
154
154
  }))),
155
155
  },
156
156
  {
@@ -163,7 +163,7 @@ export default {
163
163
  getName: shade => '{colors.' + key + '.' + shade + '}',
164
164
  search: search.value,
165
165
  }, ({ color}) => h('div', {
166
- class: '__hst-shade',
166
+ class: '__pvt-shade',
167
167
  style: {
168
168
  backgroundColor: color,
169
169
  },
@@ -185,13 +185,13 @@ export default {
185
185
  tokens: flattenTokens(config.space),
186
186
  getName: key => '{space.' + key + '}',
187
187
  }, ({ token }) => h('div', {
188
- class: '__hst-spaces',
188
+ class: '__pvt-spaces',
189
189
  style: {
190
190
  padding: token.value,
191
191
  },
192
192
  }, [
193
193
  h('div', {
194
- class: '__hst-spaces-box',
194
+ class: '__pvt-spaces-box',
195
195
  }),
196
196
  ]))),
197
197
  },
@@ -204,10 +204,10 @@ export default {
204
204
  tokens: flattenTokens(config.size),
205
205
  getName: key => '{size.' + key + '}',
206
206
  }, ({ token }) => h('div', {
207
- class: '__hst-width',
207
+ class: '__pvt-width',
208
208
  }, [
209
209
  h('div', {
210
- class: '__hst-width-box',
210
+ class: '__pvt-width-box',
211
211
  style: {
212
212
  width: token.value,
213
213
  },
@@ -223,7 +223,7 @@ export default {
223
223
  tokens: flattenTokens(config.fontSizes),
224
224
  getName: key => '{fontSizes.' + key + '}',
225
225
  }, ({ token }) => h('div', {
226
- class: '__hst-truncate',
226
+ class: '__pvt-truncate',
227
227
  style: {
228
228
  fontSize: token.value,
229
229
  },
@@ -246,7 +246,7 @@ export default {
246
246
  tokens: flattenTokens(config.fontWeights),
247
247
  getName: key => '{fontWeights.' + key + '}',
248
248
  }, ({ token }) => h('div', {
249
- class: '__hst-truncate',
249
+ class: '__pvt-truncate',
250
250
  style: {
251
251
  fontWeight: token.value,
252
252
  fontSize: \`\${fontSize.value}px\`,
@@ -276,7 +276,7 @@ export default {
276
276
  tokens: flattenTokens(config.fonts),
277
277
  getName: key => '{fonts.' + key + '}',
278
278
  }, ({ token }) => h('div', {
279
- class: '__hst-truncate',
279
+ class: '__pvt-truncate',
280
280
  style: {
281
281
  fontFamily: token.value,
282
282
  fontSize: \`\${fontSize.value}px\`,
@@ -306,7 +306,7 @@ export default {
306
306
  tokens: flattenTokens(config.letterSpacings),
307
307
  getName: key => '{letterSpacings.' + key + '}',
308
308
  }, ({ token }) => h('div', {
309
- class: '__hst-truncate',
309
+ class: '__pvt-truncate',
310
310
  style: {
311
311
  letterSpacing: token.value,
312
312
  fontSize: \`\${fontSize.value}px\`,
@@ -360,7 +360,7 @@ export default {
360
360
  getName: key => '{shadows.' + key + '}',
361
361
  colSize: 180,
362
362
  }, ({ token }) => h('div', {
363
- class: '__hst-drop-shadow',
363
+ class: '__pvt-drop-shadow',
364
364
  style: 'box-shadow:' + token.value,
365
365
  }))),
366
366
  },
@@ -374,7 +374,7 @@ export default {
374
374
  getName: key => '{opacity.' + key + '}',
375
375
  colSize: 180,
376
376
  }, ({ token }) => h('div', {
377
- class: '__hst-drop-shadow',
377
+ class: '__pvt-drop-shadow',
378
378
  style: 'opacity:' + token.value,
379
379
  }))),
380
380
  },
@@ -388,7 +388,7 @@ export default {
388
388
  getName: key => '{radii.' + key + '}',
389
389
  colSize: 180,
390
390
  }, ({ token }) => h('div', {
391
- class: '__hst-border-radius',
391
+ class: '__pvt-border-radius',
392
392
  style: {
393
393
  borderRadius: token.value,
394
394
  },
@@ -404,7 +404,7 @@ export default {
404
404
  getName: key => '{borderWidths.' + key + '}',
405
405
  colSize: 180,
406
406
  }, ({ token }) => h('div', {
407
- class: '__hst-border-width',
407
+ class: '__pvt-border-width',
408
408
  style: {
409
409
  borderWidth: token.value,
410
410
  },
@@ -420,86 +420,86 @@ export default {
420
420
  ],
421
421
  }`;
422
422
  }
423
- const css = `.__hst-shade {
423
+ const css = `.__pvt-shade {
424
424
  height: 80px;
425
425
  border-radius: 4px;
426
426
  }
427
427
 
428
- .__hst-text {
428
+ .__pvt-text {
429
429
  font-size: 4rem;
430
430
  display: flex;
431
431
  align-items: flex-end;
432
432
  }
433
433
 
434
- .__hst-border {
434
+ .__pvt-border {
435
435
  border-style: solid;
436
436
  border-width: 2px;
437
437
  }
438
438
 
439
- .__hst-spaces {
439
+ .__pvt-spaces {
440
440
  background-color: rgb(113 113 122 / 0.1);
441
441
  width: min-content;
442
442
  }
443
443
 
444
- .__hst-margin {
444
+ .__pvt-margin {
445
445
  border: dashed 1px rgb(113 113 122 / 0.5);
446
446
  width: min-content;
447
447
  }
448
448
 
449
- .__hst-spaces-box,
450
- .__hst-margin-box {
449
+ .__pvt-spaces-box,
450
+ .__pvt-margin-box {
451
451
  width: 5rem;
452
452
  height: 5rem;
453
453
  background-color: rgb(113 113 122 / 0.5);
454
454
  }
455
455
 
456
- .__hst-spaces,
457
- .__hst-spaces-box,
458
- .__hst-margin,
459
- .__hst-margin-box,
460
- .__hst-drop-shadow {
456
+ .__pvt-spaces,
457
+ .__pvt-spaces-box,
458
+ .__pvt-margin,
459
+ .__pvt-margin-box,
460
+ .__pvt-drop-shadow {
461
461
  border-radius: 4px;
462
462
  }
463
463
 
464
- .__hst-truncate {
464
+ .__pvt-truncate {
465
465
  overflow: hidden;
466
466
  text-overflow: ellipsis;
467
467
  white-space: nowrap;
468
468
  }
469
469
 
470
- .__hst-drop-shadow {
470
+ .__pvt-drop-shadow {
471
471
  width: 8rem;
472
472
  height: 8rem;
473
473
  background: white;
474
474
  margin-bottom: 0.5rem;
475
475
  }
476
476
 
477
- .__hst-drop-shadow {
477
+ .__pvt-drop-shadow {
478
478
  background: #4e4e57;
479
479
  }
480
480
 
481
- .__hst-border-radius {
481
+ .__pvt-border-radius {
482
482
  width: 8rem;
483
483
  height: 8rem;
484
484
  background-color: rgb(113 113 122 / 0.5);
485
485
  }
486
486
 
487
- .__hst-border-width {
487
+ .__pvt-border-width {
488
488
  width: 8rem;
489
489
  height: 8rem;
490
490
  border-color: rgb(113 113 122 / 0.5);
491
491
  background-color: rgb(113 113 122 / 0.1);
492
492
  }
493
493
 
494
- .__hst-width {
494
+ .__pvt-width {
495
495
  background-color: rgb(113 113 122 / 0.1);
496
496
  }
497
497
 
498
- .__hst-width-box,
499
- .__hst-height {
498
+ .__pvt-width-box,
499
+ .__pvt-height {
500
500
  background-color: rgb(113 113 122 / 0.5);
501
501
  }
502
502
 
503
- .__hst-width-box {
503
+ .__pvt-width-box {
504
504
  height: 5rem;
505
505
  }`;
@@ -125,7 +125,7 @@ export default {
125
125
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
126
126
  search: search.value,
127
127
  }, ({ color}) => h('div', {
128
- class: '__hst-shade',
128
+ class: '__pvt-shade',
129
129
  style: {
130
130
  backgroundColor: color.replace('<alpha-value>', 1),
131
131
  },
@@ -148,7 +148,7 @@ export default {
148
148
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
149
149
  search: search.value,
150
150
  }, ({ color}) => h('div', {
151
- class: '__hst-shade __hst-text',
151
+ class: '__pvt-shade __pvt-text',
152
152
  style: {
153
153
  color: color.replace('<alpha-value>', 1),
154
154
  },
@@ -171,7 +171,7 @@ export default {
171
171
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
172
172
  search: search.value,
173
173
  }, ({ color}) => h('div', {
174
- class: '__hst-shade __hst-border',
174
+ class: '__pvt-shade __pvt-border',
175
175
  style: {
176
176
  borderColor: color.replace('<alpha-value>', 1),
177
177
  },
@@ -192,13 +192,13 @@ export default {
192
192
  tokens: config.theme.padding,
193
193
  getName: key => \`\${config.prefix ?? ''}p-\${key}\`,
194
194
  }, ({ token }) => h('div', {
195
- class: '__hst-padding',
195
+ class: '__pvt-padding',
196
196
  style: {
197
197
  padding: token.value,
198
198
  },
199
199
  }, [
200
200
  h('div', {
201
- class: '__hst-padding-box',
201
+ class: '__pvt-padding-box',
202
202
  }),
203
203
  ]))),
204
204
  },
@@ -210,10 +210,10 @@ export default {
210
210
  tokens: config.theme.margin,
211
211
  getName: key => \`\${config.prefix ?? ''}m-\${key}\`,
212
212
  }, ({ token }) => h('div', {
213
- class: '__hst-margin',
213
+ class: '__pvt-margin',
214
214
  }, [
215
215
  h('div', {
216
- class: '__hst-margin-box',
216
+ class: '__pvt-margin-box',
217
217
  style: {
218
218
  margin: token.value,
219
219
  },
@@ -228,7 +228,7 @@ export default {
228
228
  tokens: config.theme.fontSize,
229
229
  getName: key => \`\${config.prefix ?? ''}text-\${key}\`,
230
230
  }, ({ token }) => h('div', {
231
- class: '__hst-truncate',
231
+ class: '__pvt-truncate',
232
232
  style: {
233
233
  fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
234
234
  ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
@@ -251,7 +251,7 @@ export default {
251
251
  tokens: config.theme.fontWeight,
252
252
  getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
253
253
  }, ({ token }) => h('div', {
254
- class: '__hst-truncate',
254
+ class: '__pvt-truncate',
255
255
  style: {
256
256
  fontWeight: token.value,
257
257
  fontSize: \`\${fontSize.value}px\`,
@@ -280,7 +280,7 @@ export default {
280
280
  tokens: config.theme.fontFamily,
281
281
  getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
282
282
  }, ({ token }) => h('div', {
283
- class: '__hst-truncate',
283
+ class: '__pvt-truncate',
284
284
  style: {
285
285
  fontFamily: token.value,
286
286
  fontSize: \`\${fontSize.value}px\`,
@@ -309,7 +309,7 @@ export default {
309
309
  tokens: config.theme.letterSpacing,
310
310
  getName: key => \`\${config.prefix ?? ''}tracking-\${key}\`,
311
311
  }, ({ token }) => h('div', {
312
- class: '__hst-truncate',
312
+ class: '__pvt-truncate',
313
313
  style: {
314
314
  letterSpacing: token.value,
315
315
  fontSize: \`\${fontSize.value}px\`,
@@ -361,7 +361,7 @@ export default {
361
361
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
362
362
  colSize: 180,
363
363
  }, ({ token }) => h('div', {
364
- class: '__hst-drop-shadow',
364
+ class: '__pvt-drop-shadow',
365
365
  style: {
366
366
  filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
367
367
  },
@@ -376,7 +376,7 @@ export default {
376
376
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${key}\`),
377
377
  colSize: 180,
378
378
  }, ({ token }) => h('div', {
379
- class: '__hst-border-radius',
379
+ class: '__pvt-border-radius',
380
380
  style: {
381
381
  borderRadius: token.value,
382
382
  },
@@ -391,7 +391,7 @@ export default {
391
391
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
392
392
  colSize: 180,
393
393
  }, ({ token }) => h('div', {
394
- class: '__hst-border-width',
394
+ class: '__pvt-border-width',
395
395
  style: {
396
396
  borderWidth: token.value,
397
397
  },
@@ -405,10 +405,10 @@ export default {
405
405
  tokens: config.theme.width,
406
406
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
407
407
  }, ({ token }) => h('div', {
408
- class: '__hst-width',
408
+ class: '__pvt-width',
409
409
  }, [
410
410
  h('div', {
411
- class: '__hst-width-box',
411
+ class: '__pvt-width-box',
412
412
  style: {
413
413
  width: token.value,
414
414
  },
@@ -423,7 +423,7 @@ export default {
423
423
  tokens: config.theme.height,
424
424
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
425
425
  }, ({ token }) => h('div', {
426
- class: '__hst-height',
426
+ class: '__pvt-height',
427
427
  style: {
428
428
  height: token.value,
429
429
  },
@@ -438,86 +438,86 @@ export default {
438
438
  ],
439
439
  }`;
440
440
  }
441
- const css = `.__hst-shade {
441
+ const css = `.__pvt-shade {
442
442
  height: 80px;
443
443
  border-radius: 4px;
444
444
  }
445
445
 
446
- .__hst-text {
446
+ .__pvt-text {
447
447
  font-size: 4rem;
448
448
  display: flex;
449
449
  align-items: flex-end;
450
450
  }
451
451
 
452
- .__hst-border {
452
+ .__pvt-border {
453
453
  border-style: solid;
454
454
  border-width: 2px;
455
455
  }
456
456
 
457
- .__hst-padding {
457
+ .__pvt-padding {
458
458
  background-color: rgb(113 113 122 / 0.1);
459
459
  width: min-content;
460
460
  }
461
461
 
462
- .__hst-margin {
462
+ .__pvt-margin {
463
463
  border: dashed 1px rgb(113 113 122 / 0.5);
464
464
  width: min-content;
465
465
  }
466
466
 
467
- .__hst-padding-box,
468
- .__hst-margin-box {
467
+ .__pvt-padding-box,
468
+ .__pvt-margin-box {
469
469
  width: 5rem;
470
470
  height: 5rem;
471
471
  background-color: rgb(113 113 122 / 0.5);
472
472
  }
473
473
 
474
- .__hst-padding,
475
- .__hst-padding-box,
476
- .__hst-margin,
477
- .__hst-margin-box,
478
- .__hst-drop-shadow {
474
+ .__pvt-padding,
475
+ .__pvt-padding-box,
476
+ .__pvt-margin,
477
+ .__pvt-margin-box,
478
+ .__pvt-drop-shadow {
479
479
  border-radius: 4px;
480
480
  }
481
481
 
482
- .__hst-truncate {
482
+ .__pvt-truncate {
483
483
  overflow: hidden;
484
484
  text-overflow: ellipsis;
485
485
  white-space: nowrap;
486
486
  }
487
487
 
488
- .__hst-drop-shadow {
488
+ .__pvt-drop-shadow {
489
489
  width: 8rem;
490
490
  height: 8rem;
491
491
  background: white;
492
492
  margin-bottom: 0.5rem;
493
493
  }
494
494
 
495
- .__hst-drop-shadow {
495
+ .__pvt-drop-shadow {
496
496
  background: #4e4e57;
497
497
  }
498
498
 
499
- .__hst-border-radius {
499
+ .__pvt-border-radius {
500
500
  width: 8rem;
501
501
  height: 8rem;
502
502
  background-color: rgb(113 113 122 / 0.5);
503
503
  }
504
504
 
505
- .__hst-border-width {
505
+ .__pvt-border-width {
506
506
  width: 8rem;
507
507
  height: 8rem;
508
508
  border-color: rgb(113 113 122 / 0.5);
509
509
  background-color: rgb(113 113 122 / 0.1);
510
510
  }
511
511
 
512
- .__hst-width {
512
+ .__pvt-width {
513
513
  background-color: rgb(113 113 122 / 0.1);
514
514
  }
515
515
 
516
- .__hst-width-box,
517
- .__hst-height {
516
+ .__pvt-width-box,
517
+ .__pvt-height {
518
518
  background-color: rgb(113 113 122 / 0.5);
519
519
  }
520
520
 
521
- .__hst-width-box {
521
+ .__pvt-width-box {
522
522
  height: 5rem;
523
523
  }`;
@@ -1 +1 @@
1
- {"version":3,"file":"RenderStory.d.ts","sourceRoot":"","sources":["../../../../src/node/builtin-plugins/vanilla-support/RenderStory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;;;cAoB3C,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;cALhB,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;AAVtC,wBAmJE"}
1
+ {"version":3,"file":"RenderStory.d.ts","sourceRoot":"","sources":["../../../../src/node/builtin-plugins/vanilla-support/RenderStory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,QAAQ,IAAI,SAAS,EAAE,MAAM,sBAAsB,CAAA;;;cAqB3C,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;;cALhB,SAAS,CAAC,OAAO,CAAC;;;;cAKlB,SAAS,CAAC,KAAK,CAAC;;;;;;;;;;;;AAVtC,wBAqJE"}
@@ -1,3 +1,4 @@
1
+ import { getSetupHook as _getSetupHook } from '@poveste/shared';
1
2
  import { defineComponent as _defineComponent, h as _h, onBeforeUnmount as _onBeforeUnmount, onMounted as _onMounted, ref as _ref, watch as _watch, } from '@poveste/vendors/vue';
2
3
  // @ts-expect-error virtual module id
3
4
  import * as generatedSetup from 'virtual:$poveste-generated-global-setup';
@@ -47,15 +48,17 @@ export default _defineComponent({
47
48
  app = {
48
49
  el: document.createElement('div'),
49
50
  };
50
- if (typeof generatedSetup?.setupVanilla === 'function') {
51
- await generatedSetup.setupVanilla({
51
+ const generatedSetupVanilla = _getSetupHook(generatedSetup, 'setupVanilla');
52
+ if (generatedSetupVanilla) {
53
+ await generatedSetupVanilla({
52
54
  app,
53
55
  story: props.story,
54
56
  variant: props.variant,
55
57
  });
56
58
  }
57
- if (typeof setup?.setupVanilla === 'function') {
58
- await setup.setupVanilla({
59
+ const setupVanilla = _getSetupHook(setup, 'setupVanilla');
60
+ if (setupVanilla) {
61
+ await setupVanilla({
59
62
  app,
60
63
  story: props.story,
61
64
  variant: props.variant,
@@ -15,12 +15,13 @@ export interface VanillaApi {
15
15
  onMount?: (api: MountApi) => Awaitable<void>;
16
16
  onMountControls?: (api: MountApi) => Awaitable<void>;
17
17
  }
18
+ export type VanillaStorySetupHandler = (payload: {
19
+ app: App;
20
+ story: Story;
21
+ variant: Variant;
22
+ }) => unknown;
18
23
  interface CommonProps {
19
- setupApp?: (payload: {
20
- app: App;
21
- story: Story;
22
- variant: Variant;
23
- }) => unknown;
24
+ setupApp?: VanillaStorySetupHandler;
24
25
  }
25
26
  export type StoryOptions = Omit<StoryProps, 'setupApp'> & CommonProps & ((VanillaApi & {
26
27
  variants?: never;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/node/builtin-plugins/vanilla-support/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE1F,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,WAAW,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;CACvB;AAED,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,WAAW,CAAA;IACf,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC1B,QAAQ,EAAE,CAAC,EAAE,EAAE,MA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,wBAAgB,WAAW,CAAC,KAAK,EAAE,YAAY,gBAE9C"}
@@ -1,5 +1,7 @@
1
1
  export interface PreviewOptions {
2
2
  port?: number;
3
+ host?: string | boolean;
4
+ open?: boolean;
3
5
  }
4
6
  export declare function previewCommand(options: PreviewOptions): Promise<void>;
5
7
  //# sourceMappingURL=preview.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/node/commands/preview.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,iBAa3D"}
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../src/node/commands/preview.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,IAAI,CAAC,EAAE,OAAO,CAAA;CACf;AAED,wBAAsB,cAAc,CAAC,OAAO,EAAE,cAAc,iBAiB3D"}
@@ -1,4 +1,3 @@
1
- import pc from 'picocolors';
2
1
  import { createContext } from '../context.js';
3
2
  import { startPreview } from '../preview.js';
4
3
  export async function previewCommand(options) {
@@ -10,6 +9,10 @@ export async function previewCommand(options) {
10
9
  await plugin.onPreview();
11
10
  }
12
11
  }
13
- const { baseUrl } = await startPreview(options.port, ctx);
14
- console.log(`Preview server listening on ${pc.cyan(baseUrl)}`);
12
+ const { printUrls } = await startPreview({
13
+ port: options.port,
14
+ host: options.host,
15
+ open: options.open,
16
+ }, ctx);
17
+ printUrls();
15
18
  }