@poveste/plugin-vue 0.1.0 → 0.1.2

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.
@@ -1,10 +1,10 @@
1
1
  import { omitInheritStoryProps as g } from "@poveste/shared";
2
- import { defineComponent as j, h as $, getCurrentInstance as C, useAttrs as O, computed as P, provide as h, reactive as _, isRef as S, cloneVNode as A } from "vue";
2
+ import { defineComponent as j, h as $, getCurrentInstance as C, useAttrs as O, computed as P, provide as S, reactive as _, isRef as h, cloneVNode as A } from "vue";
3
3
  import { useRenderContext as I } from "./render-context.js";
4
4
  import R from "./Variant.js";
5
5
  const F = j({
6
6
  name: "Story",
7
- __histoireType: "story",
7
+ __povesteType: "story",
8
8
  inheritAttrs: !1,
9
9
  props: {
10
10
  initState: {
@@ -16,47 +16,47 @@ const F = j({
16
16
  default: void 0
17
17
  }
18
18
  },
19
- setup(c) {
20
- const a = C(), n = O(), p = I(), y = P(() => n.story);
21
- h("story", y);
22
- const i = a.parent, d = _({});
19
+ setup(p) {
20
+ const a = C(), n = O(), f = I(), y = P(() => n.story);
21
+ S("story", y);
22
+ const s = a.parent, d = _({});
23
23
  Object.defineProperty(d, "$data", {
24
24
  enumerable: !0,
25
25
  configurable: !0,
26
- get: () => i.data,
26
+ get: () => s.data,
27
27
  set: (t) => {
28
- Object.assign(i.data, t);
28
+ Object.assign(s.data, t);
29
29
  }
30
30
  });
31
31
  function l(t, o) {
32
- const f = t[o];
33
- typeof f == "function" || f?.__file || typeof f?.render == "function" || typeof f?.setup == "function" || Object.defineProperty(d, o, {
32
+ const c = t[o];
33
+ typeof c == "function" || c?.__file || typeof c?.render == "function" || typeof c?.setup == "function" || Object.defineProperty(d, o, {
34
34
  enumerable: !0,
35
35
  configurable: !0,
36
36
  get: () => {
37
37
  const r = t[o];
38
- return S(r) ? r.value : r;
38
+ return h(r) ? r.value : r;
39
39
  },
40
40
  set: (r) => {
41
41
  const e = t[o];
42
- S(e) ? e.value = r : e && typeof e == "object" && r && typeof r == "object" ? Object.assign(e, r) : t[o] = r;
42
+ h(e) ? e.value = r : e && typeof e == "object" && r && typeof r == "object" ? Object.assign(e, r) : t[o] = r;
43
43
  }
44
44
  });
45
45
  }
46
- for (const t in i.exposed)
47
- l(i.exposed, t);
48
- for (const t in i.devtoolsRawSetupState)
49
- l(i.devtoolsRawSetupState, t);
50
- for (const t in i.data)
51
- l(i.data, t);
52
- h("implicitState", () => d);
46
+ for (const t in s.exposed)
47
+ l(s.exposed, t);
48
+ for (const t in s.devtoolsRawSetupState)
49
+ l(s.devtoolsRawSetupState, t);
50
+ for (const t in s.data)
51
+ l(s.data, t);
52
+ S("implicitState", () => d);
53
53
  function v() {
54
- c.meta && (n.story.meta || (n.story.meta = {}), Object.assign(n.story.meta, c.meta)), Object.assign(n.story, {
54
+ p.meta && (n.story.meta || (n.story.meta = {}), Object.assign(n.story.meta, p.meta)), Object.assign(n.story, {
55
55
  slots: () => a.proxy.$slots
56
56
  });
57
57
  }
58
58
  return {
59
- renderContext: p,
59
+ renderContext: f,
60
60
  story: y,
61
61
  renderMountStory: x,
62
62
  renderPreviewStory: b,
@@ -64,21 +64,21 @@ const F = j({
64
64
  };
65
65
  function x() {
66
66
  let t = 0;
67
- const o = (f) => {
67
+ const o = (c) => {
68
68
  const r = [];
69
- for (const e of f) {
70
- if (e.type?.__histoireType === "variant") {
69
+ for (const e of c) {
70
+ if (e.type?.__povesteType === "variant") {
71
71
  const m = n.story.variants[t];
72
72
  if (t++, !m)
73
73
  continue;
74
74
  const u = {
75
75
  variant: m
76
76
  };
77
- !e.props?.initState && !e.props?.["init-state"] && (u.initState = c.initState);
78
- for (const s in a.proxy.$attrs)
79
- typeof e.props?.[s] > "u" && (u[s] = a.proxy.$attrs[s]);
80
- for (const s in n.story)
81
- !g.includes(s) && typeof e.props?.[s] > "u" && (u[s] = n.story[s]);
77
+ !e.props?.initState && !e.props?.["init-state"] && (u.initState = p.initState);
78
+ for (const i in a.proxy.$attrs)
79
+ typeof e.props?.[i] > "u" && (u[i] = a.proxy.$attrs[i]);
80
+ for (const i in n.story)
81
+ !g.includes(i) && typeof e.props?.[i] > "u" && (u[i] = n.story[i]);
82
82
  r.push(A(e, u));
83
83
  continue;
84
84
  }
@@ -89,18 +89,18 @@ const F = j({
89
89
  return o(a.proxy.$slots.default?.() ?? []);
90
90
  }
91
91
  function b() {
92
- p.nextVariantIndex.value = 0;
92
+ f.nextVariantIndex.value = 0;
93
93
  const t = {
94
- state: p.externalState
94
+ state: f.externalState
95
95
  }, o = [];
96
- return p.slotName === "controls" && o.push(...a.proxy.$slots.controls?.(t) ?? []), (p.slotName === "default" || n.story.meta?.hasVariantChildComponents) && o.push(...a.proxy.$slots.default?.(t) ?? []), o;
96
+ return f.slotName === "controls" && o.push(...a.proxy.$slots.controls?.(t) ?? []), (f.slotName === "default" || n.story.meta?.hasVariantChildComponents) && o.push(...a.proxy.$slots.default?.(t) ?? []), o;
97
97
  }
98
98
  },
99
99
  render() {
100
100
  this.updateStory();
101
- const [c] = this.story.variants;
102
- return c?.id === "_default" ? $(R, {
103
- variant: c,
101
+ const [p] = this.story.variants;
102
+ return p?.id === "_default" ? $(R, {
103
+ variant: p,
104
104
  initState: this.initState,
105
105
  implicit: !0,
106
106
  ...this.$attrs
@@ -5,7 +5,7 @@ import { useRenderContext as P } from "./render-context.js";
5
5
  import { toRawDeep as g, syncStateBundledAndExternal as m } from "./util.js";
6
6
  const $ = x({
7
7
  name: "Variant",
8
- __histoireType: "variant",
8
+ __povesteType: "variant",
9
9
  props: {
10
10
  initState: {
11
11
  type: Function,
@@ -1,5 +1,5 @@
1
- import * as a from "virtual:$histoire-generated-global-setup";
2
- import * as i from "virtual:$histoire-setup";
1
+ import * as a from "virtual:$poveste-generated-global-setup";
2
+ import * as i from "virtual:$poveste-setup";
3
3
  import { defineComponent as l, h as o, createApp as y, Suspense as v } from "vue";
4
4
  import { registerGlobalComponents as w } from "./global-components.js";
5
5
  import { provideRenderContext as C } from "./render-context.js";
@@ -1,12 +1,12 @@
1
1
  import { provide as n, inject as r } from "vue";
2
- const e = /* @__PURE__ */ Symbol("histoire-preview-render-context");
2
+ const e = /* @__PURE__ */ Symbol("poveste-preview-render-context");
3
3
  function i(t) {
4
4
  n(e, t);
5
5
  }
6
- function c() {
6
+ function p() {
7
7
  return r(e, null);
8
8
  }
9
9
  export {
10
10
  i as provideRenderContext,
11
- c as useRenderContext
11
+ p as useRenderContext
12
12
  };
@@ -1,5 +1,5 @@
1
- import * as u from "virtual:$histoire-generated-global-setup";
2
- import * as a from "virtual:$histoire-setup";
1
+ import * as u from "virtual:$poveste-generated-global-setup";
2
+ import * as a from "virtual:$poveste-setup";
3
3
  import { createApp as m, h as d } from "vue";
4
4
  import f from "./Story.js";
5
5
  import l from "./Variant.js";
@@ -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: 'histoire:plugin-vue:generate-story',
5
+ id: 'poveste:plugin-vue:generate-story',
6
6
  label: 'Generate Vue 3 story from component',
7
7
  icon: 'https://vuejs.org/logo.svg',
8
8
  searchText: 'generate create',
@@ -19,11 +19,11 @@ export function HstVue() {
19
19
  vite: {
20
20
  plugins: [
21
21
  {
22
- name: 'histoire-plugin-vue',
22
+ name: 'poveste-plugin-vue',
23
23
  enforce: 'post',
24
24
  transform(code, id) {
25
25
  // Remove vue warnings about unknown components
26
- if (this.meta.histoire?.isCollecting && id.endsWith('.vue')) {
26
+ if (this.meta.poveste?.isCollecting && id.endsWith('.vue')) {
27
27
  return `const _stubComponent = (name) => ['Story','Variant'].some(validName => name.toLowerCase() === validName.toLowerCase()) ? _resolveComponent(name) : ({ render: () => null });${code?.replaceAll('_resolveComponent(', '_stubComponent(') ?? ''}`;
28
28
  }
29
29
  },
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@poveste/plugin-vue",
3
3
  "type": "module",
4
- "version": "0.1.0",
4
+ "version": "0.1.2",
5
5
  "description": "Poveste plugin for Vue.js support",
6
6
  "author": {
7
7
  "name": "Sorin Gitlan"
@@ -44,16 +44,16 @@
44
44
  "types": "dist/index.node.d.ts",
45
45
  "peerDependencies": {
46
46
  "vue": "^3.5.26",
47
- "poveste": "^0.1.0"
47
+ "poveste": "^0.1.2"
48
48
  },
49
49
  "dependencies": {
50
50
  "change-case": "^5.4.4",
51
51
  "globby": "^14.0.2",
52
52
  "launch-editor": "^2.9.1",
53
53
  "pathe": "^1.1.2",
54
- "@poveste/controls": "^0.1.0",
55
- "@poveste/vendors": "^0.1.0",
56
- "@poveste/shared": "^0.1.0"
54
+ "@poveste/controls": "^0.1.2",
55
+ "@poveste/vendors": "^0.1.2",
56
+ "@poveste/shared": "^0.1.2"
57
57
  },
58
58
  "devDependencies": {
59
59
  "@types/node": "^22.10.1",
@@ -61,7 +61,7 @@
61
61
  "typescript": "5.6.3",
62
62
  "vite": "^7.3.0",
63
63
  "vue": "^3.5.26",
64
- "poveste": "0.1.0"
64
+ "poveste": "0.1.2"
65
65
  },
66
66
  "scripts": {
67
67
  "build": "rimraf dist && vite build && tsc -d -P tsconfig.build.json && pnpm run build:types",
@@ -8,7 +8,7 @@ import Variant from './Variant'
8
8
  export default defineComponent({
9
9
 
10
10
  name: 'Story',
11
- __histoireType: 'story',
11
+ __povesteType: 'story',
12
12
 
13
13
  inheritAttrs: false,
14
14
 
@@ -120,7 +120,7 @@ export default defineComponent({
120
120
 
121
121
  for (const vnode of vnodes) {
122
122
  // @ts-expect-error custom option
123
- if (vnode.type?.__histoireType === 'variant') {
123
+ if (vnode.type?.__povesteType === 'variant') {
124
124
  const variant = attrs.story.variants[index]
125
125
  index++
126
126
 
@@ -11,7 +11,7 @@ import { syncStateBundledAndExternal, toRawDeep } from './util.js'
11
11
  export default defineComponent({
12
12
 
13
13
  name: 'Variant',
14
- __histoireType: 'variant',
14
+ __povesteType: 'variant',
15
15
 
16
16
  props: {
17
17
  initState: {
@@ -2,9 +2,9 @@ import type { Story, Variant } from '@poveste/shared'
2
2
  import type { App, Component, PropType, VNode } from 'vue'
3
3
  import type { Vue3StorySetupApi, Vue3StorySetupHandler } from '../../helpers.js'
4
4
  // @ts-expect-error virtual module id
5
- import * as generatedSetup from 'virtual:$histoire-generated-global-setup'
5
+ import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
6
6
  // @ts-expect-error virtual module id
7
- import * as setup from 'virtual:$histoire-setup'
7
+ import * as setup from 'virtual:$poveste-setup'
8
8
  import {
9
9
  createApp,
10
10
  defineComponent,
@@ -12,7 +12,7 @@ export interface PreviewRenderContext {
12
12
  }
13
13
  }
14
14
 
15
- const previewRenderContextKey: InjectionKey<PreviewRenderContext> = Symbol('histoire-preview-render-context')
15
+ const previewRenderContextKey: InjectionKey<PreviewRenderContext> = Symbol('poveste-preview-render-context')
16
16
 
17
17
  export function provideRenderContext(value: PreviewRenderContext) {
18
18
  provide(previewRenderContextKey, value)
@@ -1,9 +1,9 @@
1
1
  import type { ServerRunPayload } from '@poveste/shared'
2
2
  import type { Vue3StorySetupApi, Vue3StorySetupHandler } from '../../helpers.js'
3
3
  // @ts-expect-error virtual module id
4
- import * as generatedSetup from 'virtual:$histoire-generated-global-setup'
4
+ import * as generatedSetup from 'virtual:$poveste-generated-global-setup'
5
5
  // @ts-expect-error virtual module id
6
- import * as setup from 'virtual:$histoire-setup'
6
+ import * as setup from 'virtual:$poveste-setup'
7
7
  import { createApp, h } from 'vue'
8
8
  import Story from './Story'
9
9
  import Variant from './Variant'
@@ -4,7 +4,7 @@ import launchEditor from 'launch-editor'
4
4
  import path from 'pathe'
5
5
 
6
6
  export default {
7
- id: 'histoire:plugin-vue:generate-story',
7
+ id: 'poveste:plugin-vue:generate-story',
8
8
  label: 'Generate Vue 3 story from component',
9
9
  icon: 'https://vuejs.org/logo.svg',
10
10
  searchText: 'generate create',
package/src/index.node.ts CHANGED
@@ -24,11 +24,11 @@ export function HstVue(): Plugin {
24
24
  vite: {
25
25
  plugins: [
26
26
  {
27
- name: 'histoire-plugin-vue',
27
+ name: 'poveste-plugin-vue',
28
28
  enforce: 'post',
29
29
  transform(code, id) {
30
30
  // Remove vue warnings about unknown components
31
- if ((this.meta as any).histoire?.isCollecting && id.endsWith('.vue')) {
31
+ if ((this.meta as any).poveste?.isCollecting && id.endsWith('.vue')) {
32
32
  return `const _stubComponent = (name) => ['Story','Variant'].some(validName => name.toLowerCase() === validName.toLowerCase()) ? _resolveComponent(name) : ({ render: () => null });${code?.replaceAll('_resolveComponent(', '_stubComponent(') ?? ''}`
33
33
  }
34
34
  },
package/vite.config.ts CHANGED
@@ -5,7 +5,7 @@ import { defineConfig } from 'vite'
5
5
  export default defineConfig({
6
6
  plugins: [
7
7
  {
8
- name: 'histoire:preserve:import.dynamic',
8
+ name: 'poveste:preserve:import.dynamic',
9
9
  enforce: 'pre',
10
10
  transform(code) {
11
11
  if (code.includes('import(')) {
@@ -40,7 +40,7 @@ export default defineConfig({
40
40
  },
41
41
  rollupOptions: {
42
42
  external: [
43
- /\$histoire/,
43
+ /\$poveste/,
44
44
  /@poveste/,
45
45
  'vue',
46
46
  ],
@@ -1,118 +0,0 @@
1
- const E = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu"), P = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu"), w = new RegExp("(\\d)\\p{Ll}|(\\p{L})\\d", "u"), R = /[^\p{L}\d]+/giu, C = "$1\0$2", x = "";
2
- function h(r) {
3
- let e = r.trim();
4
- e = e.replace(E, C).replace(P, C), e = e.replace(R, "\0");
5
- let t = 0, c = e.length;
6
- for (; e.charAt(t) === "\0"; )
7
- t++;
8
- if (t === c)
9
- return [];
10
- for (; e.charAt(c - 1) === "\0"; )
11
- c--;
12
- return e.slice(t, c).split(/\0/g);
13
- }
14
- function A(r) {
15
- const e = h(r);
16
- for (let t = 0; t < e.length; t++) {
17
- const c = e[t], n = w.exec(c);
18
- if (n) {
19
- const a = n.index + (n[1] ?? n[2]).length;
20
- e.splice(t, 1, c.slice(0, a), c.slice(a));
21
- }
22
- }
23
- return e;
24
- }
25
- function p(r, e) {
26
- const [t, c, n] = u(r, e);
27
- return t + c.map(f(e?.locale)).join(e?.delimiter ?? " ") + n;
28
- }
29
- function g(r, e) {
30
- const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = e?.mergeAmbiguousCharacters ? d(a, s) : _(a, s);
31
- return t + c.map((l, m) => m === 0 ? a(l) : i(l, m)).join(e?.delimiter ?? "") + n;
32
- }
33
- function S(r, e) {
34
- const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = e?.mergeAmbiguousCharacters ? d(a, s) : _(a, s);
35
- return t + c.map(i).join(e?.delimiter ?? "") + n;
36
- }
37
- function T(r, e) {
38
- return L(r, { delimiter: "_", ...e });
39
- }
40
- function L(r, e) {
41
- const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale);
42
- return t + c.map(d(a, s)).join(e?.delimiter ?? " ") + n;
43
- }
44
- function F(r, e) {
45
- const [t, c, n] = u(r, e);
46
- return t + c.map(o(e?.locale)).join(e?.delimiter ?? "_") + n;
47
- }
48
- function U(r, e) {
49
- return p(r, { delimiter: ".", ...e });
50
- }
51
- function I(r, e) {
52
- return p(r, { delimiter: "-", ...e });
53
- }
54
- function b(r, e) {
55
- return p(r, { delimiter: "/", ...e });
56
- }
57
- function j(r, e) {
58
- const [t, c, n] = u(r, e), a = f(e?.locale), s = o(e?.locale), i = d(a, s);
59
- return t + c.map((l, m) => m === 0 ? i(l) : a(l)).join(e?.delimiter ?? " ") + n;
60
- }
61
- function k(r, e) {
62
- return p(r, { delimiter: "_", ...e });
63
- }
64
- function y(r, e) {
65
- return L(r, { delimiter: "-", ...e });
66
- }
67
- function f(r) {
68
- return r === !1 ? (e) => e.toLowerCase() : (e) => e.toLocaleLowerCase(r);
69
- }
70
- function o(r) {
71
- return r === !1 ? (e) => e.toUpperCase() : (e) => e.toLocaleUpperCase(r);
72
- }
73
- function d(r, e) {
74
- return (t) => `${e(t[0])}${r(t.slice(1))}`;
75
- }
76
- function _(r, e) {
77
- return (t, c) => {
78
- const n = t[0];
79
- return (c > 0 && n >= "0" && n <= "9" ? "_" + n : e(n)) + r(t.slice(1));
80
- };
81
- }
82
- function u(r, e = {}) {
83
- const t = e.split ?? (e.separateNumbers ? A : h), c = e.prefixCharacters ?? x, n = e.suffixCharacters ?? x;
84
- let a = 0, s = r.length;
85
- for (; a < r.length; ) {
86
- const i = r.charAt(a);
87
- if (!c.includes(i))
88
- break;
89
- a++;
90
- }
91
- for (; s > a; ) {
92
- const i = s - 1, l = r.charAt(i);
93
- if (!n.includes(l))
94
- break;
95
- s = i;
96
- }
97
- return [
98
- r.slice(0, a),
99
- t(r.slice(a, s)),
100
- r.slice(s)
101
- ];
102
- }
103
- export {
104
- g as camelCase,
105
- L as capitalCase,
106
- F as constantCase,
107
- U as dotCase,
108
- I as kebabCase,
109
- p as noCase,
110
- S as pascalCase,
111
- T as pascalSnakeCase,
112
- b as pathCase,
113
- j as sentenceCase,
114
- k as snakeCase,
115
- h as split,
116
- A as splitSeparateNumbers,
117
- y as trainCase
118
- };