poveste 0.1.2 → 0.2.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 (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
@@ -165,7 +165,7 @@ export default {
165
165
  getName: key => '@mq.' + key,
166
166
  colSize: 180,
167
167
  }, ({ token }) => h('div', {
168
- class: '__hst-drop-shadow',
168
+ class: '__pvt-drop-shadow',
169
169
  }))),
170
170
  },
171
171
  {
@@ -178,7 +178,7 @@ export default {
178
178
  getName: shade => '{colors.' + key + '.' + shade + '}',
179
179
  search: search.value,
180
180
  }, ({ color}) => h('div', {
181
- class: '__hst-shade',
181
+ class: '__pvt-shade',
182
182
  style: {
183
183
  backgroundColor: color,
184
184
  },
@@ -200,13 +200,13 @@ export default {
200
200
  tokens: flattenTokens(config.space),
201
201
  getName: key => '{space.' + key + '}',
202
202
  }, ({ token }) => h('div', {
203
- class: '__hst-spaces',
203
+ class: '__pvt-spaces',
204
204
  style: {
205
205
  padding: token.value,
206
206
  },
207
207
  }, [
208
208
  h('div', {
209
- class: '__hst-spaces-box',
209
+ class: '__pvt-spaces-box',
210
210
  }),
211
211
  ]))),
212
212
  },
@@ -219,10 +219,10 @@ export default {
219
219
  tokens: flattenTokens(config.size),
220
220
  getName: key => '{size.' + key + '}',
221
221
  }, ({ token }) => h('div', {
222
- class: '__hst-width',
222
+ class: '__pvt-width',
223
223
  }, [
224
224
  h('div', {
225
- class: '__hst-width-box',
225
+ class: '__pvt-width-box',
226
226
  style: {
227
227
  width: token.value,
228
228
  },
@@ -238,7 +238,7 @@ export default {
238
238
  tokens: flattenTokens(config.fontSizes),
239
239
  getName: key => '{fontSizes.' + key + '}',
240
240
  }, ({ token }) => h('div', {
241
- class: '__hst-truncate',
241
+ class: '__pvt-truncate',
242
242
  style: {
243
243
  fontSize: token.value,
244
244
  },
@@ -261,7 +261,7 @@ export default {
261
261
  tokens: flattenTokens(config.fontWeights),
262
262
  getName: key => '{fontWeights.' + key + '}',
263
263
  }, ({ token }) => h('div', {
264
- class: '__hst-truncate',
264
+ class: '__pvt-truncate',
265
265
  style: {
266
266
  fontWeight: token.value,
267
267
  fontSize: \`\${fontSize.value}px\`,
@@ -291,7 +291,7 @@ export default {
291
291
  tokens: flattenTokens(config.fonts),
292
292
  getName: key => '{fonts.' + key + '}',
293
293
  }, ({ token }) => h('div', {
294
- class: '__hst-truncate',
294
+ class: '__pvt-truncate',
295
295
  style: {
296
296
  fontFamily: token.value,
297
297
  fontSize: \`\${fontSize.value}px\`,
@@ -321,7 +321,7 @@ export default {
321
321
  tokens: flattenTokens(config.letterSpacings),
322
322
  getName: key => '{letterSpacings.' + key + '}',
323
323
  }, ({ token }) => h('div', {
324
- class: '__hst-truncate',
324
+ class: '__pvt-truncate',
325
325
  style: {
326
326
  letterSpacing: token.value,
327
327
  fontSize: \`\${fontSize.value}px\`,
@@ -375,7 +375,7 @@ export default {
375
375
  getName: key => '{shadows.' + key + '}',
376
376
  colSize: 180,
377
377
  }, ({ token }) => h('div', {
378
- class: '__hst-drop-shadow',
378
+ class: '__pvt-drop-shadow',
379
379
  style: 'box-shadow:' + token.value,
380
380
  }))),
381
381
  },
@@ -389,7 +389,7 @@ export default {
389
389
  getName: key => '{opacity.' + key + '}',
390
390
  colSize: 180,
391
391
  }, ({ token }) => h('div', {
392
- class: '__hst-drop-shadow',
392
+ class: '__pvt-drop-shadow',
393
393
  style: 'opacity:' + token.value,
394
394
  }))),
395
395
  },
@@ -403,7 +403,7 @@ export default {
403
403
  getName: key => '{radii.' + key + '}',
404
404
  colSize: 180,
405
405
  }, ({ token }) => h('div', {
406
- class: '__hst-border-radius',
406
+ class: '__pvt-border-radius',
407
407
  style: {
408
408
  borderRadius: token.value,
409
409
  },
@@ -419,7 +419,7 @@ export default {
419
419
  getName: key => '{borderWidths.' + key + '}',
420
420
  colSize: 180,
421
421
  }, ({ token }) => h('div', {
422
- class: '__hst-border-width',
422
+ class: '__pvt-border-width',
423
423
  style: {
424
424
  borderWidth: token.value,
425
425
  },
@@ -436,86 +436,86 @@ export default {
436
436
  }`
437
437
  }
438
438
 
439
- const css = `.__hst-shade {
439
+ const css = `.__pvt-shade {
440
440
  height: 80px;
441
441
  border-radius: 4px;
442
442
  }
443
443
 
444
- .__hst-text {
444
+ .__pvt-text {
445
445
  font-size: 4rem;
446
446
  display: flex;
447
447
  align-items: flex-end;
448
448
  }
449
449
 
450
- .__hst-border {
450
+ .__pvt-border {
451
451
  border-style: solid;
452
452
  border-width: 2px;
453
453
  }
454
454
 
455
- .__hst-spaces {
455
+ .__pvt-spaces {
456
456
  background-color: rgb(113 113 122 / 0.1);
457
457
  width: min-content;
458
458
  }
459
459
 
460
- .__hst-margin {
460
+ .__pvt-margin {
461
461
  border: dashed 1px rgb(113 113 122 / 0.5);
462
462
  width: min-content;
463
463
  }
464
464
 
465
- .__hst-spaces-box,
466
- .__hst-margin-box {
465
+ .__pvt-spaces-box,
466
+ .__pvt-margin-box {
467
467
  width: 5rem;
468
468
  height: 5rem;
469
469
  background-color: rgb(113 113 122 / 0.5);
470
470
  }
471
471
 
472
- .__hst-spaces,
473
- .__hst-spaces-box,
474
- .__hst-margin,
475
- .__hst-margin-box,
476
- .__hst-drop-shadow {
472
+ .__pvt-spaces,
473
+ .__pvt-spaces-box,
474
+ .__pvt-margin,
475
+ .__pvt-margin-box,
476
+ .__pvt-drop-shadow {
477
477
  border-radius: 4px;
478
478
  }
479
479
 
480
- .__hst-truncate {
480
+ .__pvt-truncate {
481
481
  overflow: hidden;
482
482
  text-overflow: ellipsis;
483
483
  white-space: nowrap;
484
484
  }
485
485
 
486
- .__hst-drop-shadow {
486
+ .__pvt-drop-shadow {
487
487
  width: 8rem;
488
488
  height: 8rem;
489
489
  background: white;
490
490
  margin-bottom: 0.5rem;
491
491
  }
492
492
 
493
- .__hst-drop-shadow {
493
+ .__pvt-drop-shadow {
494
494
  background: #4e4e57;
495
495
  }
496
496
 
497
- .__hst-border-radius {
497
+ .__pvt-border-radius {
498
498
  width: 8rem;
499
499
  height: 8rem;
500
500
  background-color: rgb(113 113 122 / 0.5);
501
501
  }
502
502
 
503
- .__hst-border-width {
503
+ .__pvt-border-width {
504
504
  width: 8rem;
505
505
  height: 8rem;
506
506
  border-color: rgb(113 113 122 / 0.5);
507
507
  background-color: rgb(113 113 122 / 0.1);
508
508
  }
509
509
 
510
- .__hst-width {
510
+ .__pvt-width {
511
511
  background-color: rgb(113 113 122 / 0.1);
512
512
  }
513
513
 
514
- .__hst-width-box,
515
- .__hst-height {
514
+ .__pvt-width-box,
515
+ .__pvt-height {
516
516
  background-color: rgb(113 113 122 / 0.5);
517
517
  }
518
518
 
519
- .__hst-width-box {
519
+ .__pvt-width-box {
520
520
  height: 5rem;
521
521
  }`
@@ -137,7 +137,7 @@ export default {
137
137
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`bg-\${key}\` : \`bg-\${key}-\${shade}\`),
138
138
  search: search.value,
139
139
  }, ({ color}) => h('div', {
140
- class: '__hst-shade',
140
+ class: '__pvt-shade',
141
141
  style: {
142
142
  backgroundColor: color.replace('<alpha-value>', 1),
143
143
  },
@@ -160,7 +160,7 @@ export default {
160
160
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`text-\${key}\` : \`text-\${key}-\${shade}\`),
161
161
  search: search.value,
162
162
  }, ({ color}) => h('div', {
163
- class: '__hst-shade __hst-text',
163
+ class: '__pvt-shade __pvt-text',
164
164
  style: {
165
165
  color: color.replace('<alpha-value>', 1),
166
166
  },
@@ -183,7 +183,7 @@ export default {
183
183
  getName: shade => (config.prefix ?? '') + (shade === 'DEFAULT' ? \`border-\${key}\` : \`border-\${key}-\${shade}\`),
184
184
  search: search.value,
185
185
  }, ({ color}) => h('div', {
186
- class: '__hst-shade __hst-border',
186
+ class: '__pvt-shade __pvt-border',
187
187
  style: {
188
188
  borderColor: color.replace('<alpha-value>', 1),
189
189
  },
@@ -204,13 +204,13 @@ export default {
204
204
  tokens: config.theme.padding,
205
205
  getName: key => \`\${config.prefix ?? ''}p-\${key}\`,
206
206
  }, ({ token }) => h('div', {
207
- class: '__hst-padding',
207
+ class: '__pvt-padding',
208
208
  style: {
209
209
  padding: token.value,
210
210
  },
211
211
  }, [
212
212
  h('div', {
213
- class: '__hst-padding-box',
213
+ class: '__pvt-padding-box',
214
214
  }),
215
215
  ]))),
216
216
  },
@@ -222,10 +222,10 @@ export default {
222
222
  tokens: config.theme.margin,
223
223
  getName: key => \`\${config.prefix ?? ''}m-\${key}\`,
224
224
  }, ({ token }) => h('div', {
225
- class: '__hst-margin',
225
+ class: '__pvt-margin',
226
226
  }, [
227
227
  h('div', {
228
- class: '__hst-margin-box',
228
+ class: '__pvt-margin-box',
229
229
  style: {
230
230
  margin: token.value,
231
231
  },
@@ -240,7 +240,7 @@ export default {
240
240
  tokens: config.theme.fontSize,
241
241
  getName: key => \`\${config.prefix ?? ''}text-\${key}\`,
242
242
  }, ({ token }) => h('div', {
243
- class: '__hst-truncate',
243
+ class: '__pvt-truncate',
244
244
  style: {
245
245
  fontSize: Array.isArray(token.value) ? token.value[0] : token.value,
246
246
  ...(Array.isArray(token.value) && typeof token.value[1] === "object" ? token.value[1] : { lineHeight: token.value[1] })
@@ -263,7 +263,7 @@ export default {
263
263
  tokens: config.theme.fontWeight,
264
264
  getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
265
265
  }, ({ token }) => h('div', {
266
- class: '__hst-truncate',
266
+ class: '__pvt-truncate',
267
267
  style: {
268
268
  fontWeight: token.value,
269
269
  fontSize: \`\${fontSize.value}px\`,
@@ -292,7 +292,7 @@ export default {
292
292
  tokens: config.theme.fontFamily,
293
293
  getName: key => \`\${config.prefix ?? ''}font-\${key}\`,
294
294
  }, ({ token }) => h('div', {
295
- class: '__hst-truncate',
295
+ class: '__pvt-truncate',
296
296
  style: {
297
297
  fontFamily: token.value,
298
298
  fontSize: \`\${fontSize.value}px\`,
@@ -321,7 +321,7 @@ export default {
321
321
  tokens: config.theme.letterSpacing,
322
322
  getName: key => \`\${config.prefix ?? ''}tracking-\${key}\`,
323
323
  }, ({ token }) => h('div', {
324
- class: '__hst-truncate',
324
+ class: '__pvt-truncate',
325
325
  style: {
326
326
  letterSpacing: token.value,
327
327
  fontSize: \`\${fontSize.value}px\`,
@@ -373,7 +373,7 @@ export default {
373
373
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'drop-shadow' : \`drop-shadow-\${key}\`),
374
374
  colSize: 180,
375
375
  }, ({ token }) => h('div', {
376
- class: '__hst-drop-shadow',
376
+ class: '__pvt-drop-shadow',
377
377
  style: {
378
378
  filter: \`\${(Array.isArray(token.value) ? token.value : [token.value]).map(v => \`drop-shadow(\${v})\`).join(' ')}\`,
379
379
  },
@@ -388,7 +388,7 @@ export default {
388
388
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'rounded' : \`rounded-\${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
  },
@@ -403,7 +403,7 @@ export default {
403
403
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'border' : \`border-\${key}\`),
404
404
  colSize: 180,
405
405
  }, ({ token }) => h('div', {
406
- class: '__hst-border-width',
406
+ class: '__pvt-border-width',
407
407
  style: {
408
408
  borderWidth: token.value,
409
409
  },
@@ -417,10 +417,10 @@ export default {
417
417
  tokens: config.theme.width,
418
418
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'w' : \`w-\${key}\`),
419
419
  }, ({ token }) => h('div', {
420
- class: '__hst-width',
420
+ class: '__pvt-width',
421
421
  }, [
422
422
  h('div', {
423
- class: '__hst-width-box',
423
+ class: '__pvt-width-box',
424
424
  style: {
425
425
  width: token.value,
426
426
  },
@@ -435,7 +435,7 @@ export default {
435
435
  tokens: config.theme.height,
436
436
  getName: key => (config.prefix ?? '') + (key === 'DEFAULT' ? 'h' : \`h-\${key}\`),
437
437
  }, ({ token }) => h('div', {
438
- class: '__hst-height',
438
+ class: '__pvt-height',
439
439
  style: {
440
440
  height: token.value,
441
441
  },
@@ -451,86 +451,86 @@ export default {
451
451
  }`
452
452
  }
453
453
 
454
- const css = `.__hst-shade {
454
+ const css = `.__pvt-shade {
455
455
  height: 80px;
456
456
  border-radius: 4px;
457
457
  }
458
458
 
459
- .__hst-text {
459
+ .__pvt-text {
460
460
  font-size: 4rem;
461
461
  display: flex;
462
462
  align-items: flex-end;
463
463
  }
464
464
 
465
- .__hst-border {
465
+ .__pvt-border {
466
466
  border-style: solid;
467
467
  border-width: 2px;
468
468
  }
469
469
 
470
- .__hst-padding {
470
+ .__pvt-padding {
471
471
  background-color: rgb(113 113 122 / 0.1);
472
472
  width: min-content;
473
473
  }
474
474
 
475
- .__hst-margin {
475
+ .__pvt-margin {
476
476
  border: dashed 1px rgb(113 113 122 / 0.5);
477
477
  width: min-content;
478
478
  }
479
479
 
480
- .__hst-padding-box,
481
- .__hst-margin-box {
480
+ .__pvt-padding-box,
481
+ .__pvt-margin-box {
482
482
  width: 5rem;
483
483
  height: 5rem;
484
484
  background-color: rgb(113 113 122 / 0.5);
485
485
  }
486
486
 
487
- .__hst-padding,
488
- .__hst-padding-box,
489
- .__hst-margin,
490
- .__hst-margin-box,
491
- .__hst-drop-shadow {
487
+ .__pvt-padding,
488
+ .__pvt-padding-box,
489
+ .__pvt-margin,
490
+ .__pvt-margin-box,
491
+ .__pvt-drop-shadow {
492
492
  border-radius: 4px;
493
493
  }
494
494
 
495
- .__hst-truncate {
495
+ .__pvt-truncate {
496
496
  overflow: hidden;
497
497
  text-overflow: ellipsis;
498
498
  white-space: nowrap;
499
499
  }
500
500
 
501
- .__hst-drop-shadow {
501
+ .__pvt-drop-shadow {
502
502
  width: 8rem;
503
503
  height: 8rem;
504
504
  background: white;
505
505
  margin-bottom: 0.5rem;
506
506
  }
507
507
 
508
- .__hst-drop-shadow {
508
+ .__pvt-drop-shadow {
509
509
  background: #4e4e57;
510
510
  }
511
511
 
512
- .__hst-border-radius {
512
+ .__pvt-border-radius {
513
513
  width: 8rem;
514
514
  height: 8rem;
515
515
  background-color: rgb(113 113 122 / 0.5);
516
516
  }
517
517
 
518
- .__hst-border-width {
518
+ .__pvt-border-width {
519
519
  width: 8rem;
520
520
  height: 8rem;
521
521
  border-color: rgb(113 113 122 / 0.5);
522
522
  background-color: rgb(113 113 122 / 0.1);
523
523
  }
524
524
 
525
- .__hst-width {
525
+ .__pvt-width {
526
526
  background-color: rgb(113 113 122 / 0.1);
527
527
  }
528
528
 
529
- .__hst-width-box,
530
- .__hst-height {
529
+ .__pvt-width-box,
530
+ .__pvt-height {
531
531
  background-color: rgb(113 113 122 / 0.5);
532
532
  }
533
533
 
534
- .__hst-width-box {
534
+ .__pvt-width-box {
535
535
  height: 5rem;
536
536
  }`
@@ -1,6 +1,7 @@
1
1
  import type { Story, Variant } from '@poveste/shared'
2
2
  import type { PropType as _PropType } from '@poveste/vendors/vue'
3
- import type { App, MountApi, VanillaApi } from './types'
3
+ import type { VanillaStorySetupHandler as _VanillaStorySetupHandler, App, MountApi, VanillaApi } from './types'
4
+ import { getSetupHook as _getSetupHook } from '@poveste/shared'
4
5
  import {
5
6
  defineComponent as _defineComponent,
6
7
  h as _h,
@@ -68,16 +69,18 @@ export default _defineComponent({
68
69
  el: document.createElement('div'),
69
70
  }
70
71
 
71
- if (typeof generatedSetup?.setupVanilla === 'function') {
72
- await generatedSetup.setupVanilla({
72
+ const generatedSetupVanilla = _getSetupHook<_VanillaStorySetupHandler>(generatedSetup, 'setupVanilla')
73
+ if (generatedSetupVanilla) {
74
+ await generatedSetupVanilla({
73
75
  app,
74
76
  story: props.story,
75
77
  variant: props.variant,
76
78
  })
77
79
  }
78
80
 
79
- if (typeof setup?.setupVanilla === 'function') {
80
- await setup.setupVanilla({
81
+ const setupVanilla = _getSetupHook<_VanillaStorySetupHandler>(setup, 'setupVanilla')
82
+ if (setupVanilla) {
83
+ await setupVanilla({
81
84
  app,
82
85
  story: props.story,
83
86
  variant: props.variant,
@@ -19,8 +19,10 @@ export interface VanillaApi {
19
19
  onMountControls?: (api: MountApi) => Awaitable<void>
20
20
  }
21
21
 
22
+ export type VanillaStorySetupHandler = (payload: { app: App, story: Story, variant: Variant }) => unknown
23
+
22
24
  interface CommonProps {
23
- setupApp?: (payload: { app: App, story: Story, variant: Variant }) => unknown
25
+ setupApp?: VanillaStorySetupHandler
24
26
  }
25
27
 
26
28
  export type StoryOptions = Omit<StoryProps, 'setupApp'> & CommonProps & ((VanillaApi & {
@@ -1,9 +1,10 @@
1
- import pc from 'picocolors'
2
1
  import { createContext } from '../context.js'
3
2
  import { startPreview } from '../preview.js'
4
3
 
5
4
  export interface PreviewOptions {
6
5
  port?: number
6
+ host?: string | boolean
7
+ open?: boolean
7
8
  }
8
9
 
9
10
  export async function previewCommand(options: PreviewOptions) {
@@ -17,6 +18,10 @@ export async function previewCommand(options: PreviewOptions) {
17
18
  }
18
19
  }
19
20
 
20
- const { baseUrl } = await startPreview(options.port, ctx)
21
- console.log(`Preview server listening on ${pc.cyan(baseUrl)}`)
21
+ const { printUrls } = await startPreview({
22
+ port: options.port,
23
+ host: options.host,
24
+ open: options.open,
25
+ }, ctx)
26
+ printUrls()
22
27
  }
@@ -38,6 +38,7 @@ export function getDefaultConfig(): PovesteConfig {
38
38
  '**/dist/**',
39
39
  ],
40
40
  supportMatch: [],
41
+ isolateStyles: true,
41
42
  tree: {
42
43
  file: 'title',
43
44
  order: 'asc',
@@ -9,7 +9,7 @@ import type {
9
9
  import type { ResolvedConfig } from 'vite'
10
10
  import { resolveConfig as resolveViteConfig } from 'vite'
11
11
  import { processConfig, resolveConfig } from './config.js'
12
- import { mergeHistoireViteConfig } from './vite.js'
12
+ import { mergePovesteViteConfig } from './vite.js'
13
13
 
14
14
  export interface Context {
15
15
  root: string
@@ -45,7 +45,7 @@ export async function createContext(options: CreateContextOptions): Promise<Cont
45
45
  registeredCommands: [],
46
46
  }
47
47
 
48
- ctx.resolvedViteConfig = await mergeHistoireViteConfig(viteConfig as unknown, ctx)
48
+ ctx.resolvedViteConfig = await mergePovesteViteConfig(viteConfig as unknown, ctx)
49
49
 
50
50
  await processConfig(ctx)
51
51
 
@@ -4,6 +4,31 @@ import {
4
4
  } from 'jsdom'
5
5
  import { populateGlobal } from './util.js'
6
6
 
7
+ // jsdom error types — not exported by jsdom.
8
+ const JSDOM_ERROR_CSS_PARSING = 'css-parsing'
9
+ const JSDOM_ERROR_UNHANDLED_EXCEPTION = 'unhandled-exception'
10
+
11
+ // Directives JSDOM's CSS parser doesn't know — Tailwind v4's `@theme` is the
12
+ // common one — make it emit a jsdomError per stylesheet, so collecting stories
13
+ // from a Tailwind app prints "Could not parse CSS stylesheet" over and over.
14
+ // The parser recovers on its own and keeps the valid rules, so the message is
15
+ // pure noise: drop css-parsing errors, mirror jsdom's default forwardTo for
16
+ // the rest.
17
+ function createVirtualConsole(): VirtualConsole | undefined {
18
+ if (!console || !globalThis.console) return undefined
19
+ const virtualConsole = new VirtualConsole().forwardTo(globalThis.console, { jsdomErrors: 'none' })
20
+ virtualConsole.on('jsdomError', (err: Error & { type?: string, cause?: { stack?: string } }) => {
21
+ if (err.type === JSDOM_ERROR_CSS_PARSING) return
22
+ if (err.type === JSDOM_ERROR_UNHANDLED_EXCEPTION) {
23
+ globalThis.console.error(err.cause?.stack ?? err.message)
24
+ }
25
+ else {
26
+ globalThis.console.error(err.message)
27
+ }
28
+ })
29
+ return virtualConsole
30
+ }
31
+
7
32
  export function createDomEnv() {
8
33
  const dom = new JSDOM(
9
34
  '<!DOCTYPE html>',
@@ -11,7 +36,7 @@ export function createDomEnv() {
11
36
  pretendToBeVisual: true,
12
37
  runScripts: 'dangerously',
13
38
  url: 'http://localhost:3000',
14
- virtualConsole: console && globalThis.console ? new VirtualConsole().forwardTo(globalThis.console) : undefined,
39
+ virtualConsole: createVirtualConsole(),
15
40
  includeNodeLocations: false,
16
41
  contentType: 'text/html',
17
42
  },
@@ -35,7 +35,7 @@ export async function createMarkdownRenderer(ctx: Context) {
35
35
  })
36
36
 
37
37
  const md = new MarkdownIt({
38
- highlight: (code, lang) => `<div class="htw-relative htw-not-prose __poveste-code __histoire-code"><div class="htw-absolute htw-top-0 htw-right-0 htw-text-xs htw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
38
+ highlight: (code, lang) => `<div class="ptw-relative ptw-not-prose __poveste-code __histoire-code"><div class="ptw-absolute ptw-top-0 ptw-right-0 ptw-text-xs ptw-text-white/40">${lang}</div>${highlighter.codeToHtml(code, { theme: 'github-dark', lang })}</div>`,
39
39
  linkify: true,
40
40
  html: true,
41
41
  breaks: false,