@poveste/plugin-svelte 0.1.0 → 0.1.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.
- package/dist/client/mount.js +1 -1
- package/dist/client/render.js +1 -1
- package/dist/collect/index.js +1 -1
- package/dist/commands/generate-story.server.js +1 -1
- package/dist/index.node.js +3 -3
- package/dist/util/story-hmr.js +3 -3
- package/package.json +6 -6
- package/src/client/mount.ts +2 -2
- package/src/client/render.ts +2 -2
- package/src/collect/index.ts +2 -2
- package/src/commands/generate-story.server.ts +1 -1
- package/src/index.node.ts +3 -3
- package/src/util/story-hmr.ts +4 -4
- package/vite.config.ts +1 -1
- /package/assets/{histoire-svelte-text.svg → poveste-svelte-text.svg} +0 -0
- /package/assets/{histoire-svelte.svg → poveste-svelte.svg} +0 -0
package/dist/client/mount.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./MountVariant.svelte";import r from"./MountStory.svelte";import i from"./Stub.svelte";import{components as a}from"@poveste/controls";import{defineComponent as o,h as s,onMounted as c,onUnmounted as l,ref as u,watch as d}from"@poveste/vendors/vue";import*as f from"virtual:$
|
|
1
|
+
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./MountVariant.svelte";import r from"./MountStory.svelte";import i from"./Stub.svelte";import{components as a}from"@poveste/controls";import{defineComponent as o,h as s,onMounted as c,onUnmounted as l,ref as u,watch as d}from"@poveste/vendors/vue";import*as f from"virtual:$poveste-generated-global-setup";import*as p from"virtual:$poveste-setup";var m=o({name:`MountStory`,props:{story:{type:Object,required:!0}},setup(i){let a=u(),o,s,m=null;async function g(){s=document.createElement(`div`),a.value.appendChild(s);let c=await t(i.story.file.component,{target:s,props:{Hst:{Story:r,Variant:n,...h()}},context:new Map(Object.entries({__hstStory:i.story}))},`client`);o=c.app,m=c.destroy,await e(f,p,{app:o,story:i.story,variant:null})}function _(){m?.(),m=null,s&&=(s.parentNode?.removeChild(s),null),o=null}return d(()=>i.story.id,async()=>{_(),await g()}),c(async()=>{await g()}),l(()=>{_()}),{el:a}},render(){return s(`div`,{ref:`el`})}});function h(){let e={};for(let t in a)e[t.substring(3)]=i;return e}export{m as default};
|
package/dist/client/render.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,createWrappedComponent as t,getLegacyStateApi as n,mountSvelteComponent as r}from"../util/svelte.js";import i from"./RenderStory.svelte";import a from"./RenderVariant.svelte";import{syncState as o}from"./util.js";import s from"./Wrap.svelte";import{components as c}from"@poveste/controls";import{defineComponent as l,h as u,onMounted as d,onUnmounted as f,ref as p,watch as m}from"@poveste/vendors/vue";import*as h from"virtual:$
|
|
1
|
+
import{callSetupFunctions as e,createWrappedComponent as t,getLegacyStateApi as n,mountSvelteComponent as r}from"../util/svelte.js";import i from"./RenderStory.svelte";import a from"./RenderVariant.svelte";import{syncState as o}from"./util.js";import s from"./Wrap.svelte";import{components as c}from"@poveste/controls";import{defineComponent as l,h as u,onMounted as d,onUnmounted as f,ref as p,watch as m}from"@poveste/vendors/vue";import*as h from"virtual:$poveste-generated-global-setup";import*as g from"virtual:$poveste-setup";var _=l({name:`RenderStory`,props:{variant:{type:Object,required:!0},story:{type:Object,required:!0},slotName:{type:String,default:`default`}},setup(t,{emit:s}){let c=p(),l,u,_=[];function y(e,t){document.addEventListener(e,t);let n=()=>document.removeEventListener(e,t);return _.push(n),{off:n}}async function b(){u=document.createElement(`div`),c.value.appendChild(u);let d=[],{off:f}=y(`SvelteRegisterComponent`,e=>{let{component:t}=e.detail;d.push(t)}),p=await r(t.story.file.component,{target:u,props:{Hst:{Story:i,Variant:a,...v()}},context:new Map(Object.entries({__hstStory:t.story,__hstVariant:t.variant,__hstSlot:t.slotName}))},`client`);l=p.app,_.push(()=>{p.destroy()});let m=d.find(e=>e.$$&&l?.$$&&e.$$===l.$$)??l;f(),d=[];function b(){let e=m?.$replace;e&&(m.$replace=(...t)=>{let n=e.apply(m,t);return m=n??m,n})}b();let x=n(m);if(x){let{apply:e,stop:n}=o(t.variant.state,e=>{x.injectState(e)});_.push(n);let r,i=()=>{e(x.captureState()),r=requestAnimationFrame(i)};r=requestAnimationFrame(i),_.push(()=>{cancelAnimationFrame(r)}),e(x.captureState())}await e(h,g,{app:l,story:t.story,variant:t.variant},t.variant.setupApp),s(`ready`)}function x(){_.forEach(e=>e()),_=[],u&&=(u.parentNode?.removeChild(u),null),l=null}return m(()=>t.story.id,async()=>{x(),await b()}),d(async()=>{await b()}),f(()=>{x()}),{el:c}},render(){return u(`div`,{ref:`el`})}});function v(){let e={};for(let t in c)e[t.substring(3)]=y(c[t]);return e}function y(e){return t(s,e)}export{_ as default};
|
package/dist/collect/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./Story.svelte";import r from"./Variant.svelte";import*as i from"virtual:$
|
|
1
|
+
import{callSetupFunctions as e,mountSvelteComponent as t}from"../util/svelte.js";import n from"./Story.svelte";import r from"./Variant.svelte";import*as i from"virtual:$poveste-generated-global-setup";import*as a from"virtual:$poveste-setup";import{tick as o}from"svelte";async function s({file:s,el:c,storyData:l}){let{default:u}=await import(/* @vite-ignore */s.moduleId),d=await t(u,{target:c,props:{Hst:{Story:n,Variant:r}},context:new Map(Object.entries({__hstAddStory(e){l.push(e)},__hstStoryFile:s}))},`client`);await e(i,a,{app:d.app,story:null,variant:null}),await o(),l[0]?.variants.length||l[0].variants.push({id:`_default`,title:`default`}),d.destroy()}export{s as run};
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import launchEditor from 'launch-editor';
|
|
3
3
|
import path from 'pathe';
|
|
4
4
|
export default {
|
|
5
|
-
id: '
|
|
5
|
+
id: 'poveste:plugin-svelte:generate-story',
|
|
6
6
|
label: 'Generate Svelte story from component',
|
|
7
7
|
icon: 'https://svelte.dev/favicon.png',
|
|
8
8
|
searchText: 'generate create',
|
package/dist/index.node.js
CHANGED
|
@@ -23,9 +23,9 @@ export function HstSvelte() {
|
|
|
23
23
|
primary: defaultColors.orange,
|
|
24
24
|
},
|
|
25
25
|
logo: {
|
|
26
|
-
square: '@poveste/plugin-svelte/assets/
|
|
27
|
-
light: '@poveste/plugin-svelte/assets/
|
|
28
|
-
dark: '@poveste/plugin-svelte/assets/
|
|
26
|
+
square: '@poveste/plugin-svelte/assets/poveste-svelte.svg',
|
|
27
|
+
light: '@poveste/plugin-svelte/assets/poveste-svelte-text.svg',
|
|
28
|
+
dark: '@poveste/plugin-svelte/assets/poveste-svelte-text.svg',
|
|
29
29
|
},
|
|
30
30
|
},
|
|
31
31
|
viteIgnorePlugins: [
|
package/dist/util/story-hmr.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
const storyFileRE = /\.story\.svelte$/;
|
|
2
2
|
export function disableStoryComponentHmr() {
|
|
3
3
|
return {
|
|
4
|
-
name: '
|
|
4
|
+
name: 'poveste:svelte-story-hmr',
|
|
5
5
|
apply: 'serve',
|
|
6
6
|
configResolved(config) {
|
|
7
7
|
for (const plugin of config.plugins) {
|
|
8
|
-
if (plugin.name !== 'vite-plugin-svelte:config' || plugin.
|
|
8
|
+
if (plugin.name !== 'vite-plugin-svelte:config' || plugin.__povesteStoryHmrPatched) {
|
|
9
9
|
continue;
|
|
10
10
|
}
|
|
11
11
|
const options = plugin.api?.options;
|
|
@@ -23,7 +23,7 @@ export function disableStoryComponentHmr() {
|
|
|
23
23
|
hmr: false,
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
-
plugin.
|
|
26
|
+
plugin.__povesteStoryHmrPatched = true;
|
|
27
27
|
}
|
|
28
28
|
},
|
|
29
29
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@poveste/plugin-svelte",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"description": "Poveste plugin for Svelte 4/5 and SvelteKit support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Sorin Gitlan"
|
|
@@ -26,16 +26,16 @@
|
|
|
26
26
|
"types": "./dist/index.node.d.ts",
|
|
27
27
|
"peerDependencies": {
|
|
28
28
|
"svelte": "^4.0.0 || ^5.0.0",
|
|
29
|
-
"poveste": "^0.1.
|
|
29
|
+
"poveste": "^0.1.1"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"change-case": "^5.4.4",
|
|
33
33
|
"globby": "^14.0.2",
|
|
34
34
|
"launch-editor": "^2.9.1",
|
|
35
35
|
"pathe": "^1.1.2",
|
|
36
|
-
"@poveste/
|
|
37
|
-
"@poveste/
|
|
38
|
-
"@poveste/vendors": "^0.1.
|
|
36
|
+
"@poveste/controls": "^0.1.1",
|
|
37
|
+
"@poveste/shared": "^0.1.1",
|
|
38
|
+
"@poveste/vendors": "^0.1.1"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@sveltejs/vite-plugin-svelte": "^7.0.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"svelte-preprocess": "^6.0.3",
|
|
48
48
|
"typescript": "5.6.3",
|
|
49
49
|
"vite": "^8.0.0",
|
|
50
|
-
"poveste": "0.1.
|
|
50
|
+
"poveste": "0.1.1"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
|
package/src/client/mount.ts
CHANGED
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
watch as _watch,
|
|
14
14
|
} from '@poveste/vendors/vue'
|
|
15
15
|
// @ts-expect-error virtual module id
|
|
16
|
-
import * as generatedSetup from 'virtual:$
|
|
16
|
+
import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
17
17
|
// @ts-expect-error virtual module id
|
|
18
|
-
import * as setup from 'virtual:$
|
|
18
|
+
import * as setup from 'virtual:$poveste-setup'
|
|
19
19
|
import {
|
|
20
20
|
callSetupFunctions,
|
|
21
21
|
mountSvelteComponent,
|
package/src/client/render.ts
CHANGED
|
@@ -13,9 +13,9 @@ import {
|
|
|
13
13
|
watch as _watch,
|
|
14
14
|
} from '@poveste/vendors/vue'
|
|
15
15
|
// @ts-expect-error virtual module id
|
|
16
|
-
import * as generatedSetup from 'virtual:$
|
|
16
|
+
import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
17
17
|
// @ts-expect-error virtual module id
|
|
18
|
-
import * as setup from 'virtual:$
|
|
18
|
+
import * as setup from 'virtual:$poveste-setup'
|
|
19
19
|
import {
|
|
20
20
|
callSetupFunctions,
|
|
21
21
|
createWrappedComponent,
|
package/src/collect/index.ts
CHANGED
|
@@ -2,9 +2,9 @@ import type { ServerRunPayload } from '@poveste/shared'
|
|
|
2
2
|
import type { SvelteStorySetupApi } from '../helpers.js'
|
|
3
3
|
import { tick } from 'svelte'
|
|
4
4
|
// @ts-expect-error virtual module id
|
|
5
|
-
import * as generatedSetup from 'virtual:$
|
|
5
|
+
import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
|
|
6
6
|
// @ts-expect-error virtual module id
|
|
7
|
-
import * as setup from 'virtual:$
|
|
7
|
+
import * as setup from 'virtual:$poveste-setup'
|
|
8
8
|
import {
|
|
9
9
|
callSetupFunctions,
|
|
10
10
|
mountSvelteComponent,
|
|
@@ -4,7 +4,7 @@ import launchEditor from 'launch-editor'
|
|
|
4
4
|
import path from 'pathe'
|
|
5
5
|
|
|
6
6
|
export default {
|
|
7
|
-
id: '
|
|
7
|
+
id: 'poveste:plugin-svelte:generate-story',
|
|
8
8
|
label: 'Generate Svelte story from component',
|
|
9
9
|
icon: 'https://svelte.dev/favicon.png',
|
|
10
10
|
searchText: 'generate create',
|
package/src/index.node.ts
CHANGED
|
@@ -27,9 +27,9 @@ export function HstSvelte(): Plugin {
|
|
|
27
27
|
primary: defaultColors.orange,
|
|
28
28
|
},
|
|
29
29
|
logo: {
|
|
30
|
-
square: '@poveste/plugin-svelte/assets/
|
|
31
|
-
light: '@poveste/plugin-svelte/assets/
|
|
32
|
-
dark: '@poveste/plugin-svelte/assets/
|
|
30
|
+
square: '@poveste/plugin-svelte/assets/poveste-svelte.svg',
|
|
31
|
+
light: '@poveste/plugin-svelte/assets/poveste-svelte-text.svg',
|
|
32
|
+
dark: '@poveste/plugin-svelte/assets/poveste-svelte-text.svg',
|
|
33
33
|
},
|
|
34
34
|
},
|
|
35
35
|
viteIgnorePlugins: [
|
package/src/util/story-hmr.ts
CHANGED
|
@@ -15,16 +15,16 @@ interface SveltePluginApi {
|
|
|
15
15
|
interface SvelteConfigPlugin {
|
|
16
16
|
name: string
|
|
17
17
|
api?: SveltePluginApi
|
|
18
|
-
|
|
18
|
+
__povesteStoryHmrPatched?: boolean
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export function disableStoryComponentHmr() {
|
|
22
22
|
return {
|
|
23
|
-
name: '
|
|
23
|
+
name: 'poveste:svelte-story-hmr',
|
|
24
24
|
apply: 'serve' as const,
|
|
25
25
|
configResolved(config: { readonly plugins: readonly unknown[] }) {
|
|
26
26
|
for (const plugin of config.plugins as SvelteConfigPlugin[]) {
|
|
27
|
-
if (plugin.name !== 'vite-plugin-svelte:config' || plugin.
|
|
27
|
+
if (plugin.name !== 'vite-plugin-svelte:config' || plugin.__povesteStoryHmrPatched) {
|
|
28
28
|
continue
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -45,7 +45,7 @@ export function disableStoryComponentHmr() {
|
|
|
45
45
|
hmr: false,
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
-
plugin.
|
|
48
|
+
plugin.__povesteStoryHmrPatched = true
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
}
|
package/vite.config.ts
CHANGED
|
File without changes
|
|
File without changes
|