histoire 0.4.4 → 0.5.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 (77) hide show
  1. package/dist/bundled/HomeView.js +1 -0
  2. package/dist/bundled/MobileOverlay.js +3 -1
  3. package/dist/bundled/SandboxVue3.js +649 -0
  4. package/dist/bundled/SearchPane.js +2 -0
  5. package/dist/bundled/StoryView.js +551 -622
  6. package/dist/bundled/global-components.js +16 -6
  7. package/dist/bundled/index2.js +114 -43
  8. package/dist/bundled/sandbox.js +3 -11
  9. package/dist/bundled/state.js +55 -0
  10. package/dist/bundled/story.js +1 -1
  11. package/dist/client/app/App.vue +18 -0
  12. package/dist/client/app/codegen/serialize-js.js +1 -1
  13. package/dist/client/app/codegen/vue3.d.ts +2 -0
  14. package/dist/client/app/codegen/vue3.js +37 -12
  15. package/dist/client/app/components/app/InitialLoading.vue +46 -0
  16. package/dist/client/app/components/app/MobileOverlay.vue +1 -1
  17. package/dist/client/app/components/base/BaseSelect.vue +72 -0
  18. package/dist/client/app/components/exposed/Story.vue +2 -1
  19. package/dist/client/app/components/exposed/Variant.vue +4 -4
  20. package/dist/client/app/components/panel/ControlsComponentPropItem.vue +96 -0
  21. package/dist/client/app/components/panel/ControlsComponentProps.vue +33 -0
  22. package/dist/client/app/components/panel/StatePresets.vue +195 -0
  23. package/dist/client/app/components/panel/StoryControls.vue +31 -2
  24. package/dist/client/app/components/sandbox/SandboxVue3.vue +70 -2
  25. package/dist/client/app/components/story/StoryVariantSinglePreviewRemote.vue +2 -14
  26. package/dist/client/app/index.js +5 -0
  27. package/dist/client/app/sandbox.js +2 -11
  28. package/dist/client/app/style/transitions.pcss +12 -0
  29. package/dist/client/app/types.d.ts +11 -0
  30. package/dist/client/app/util/mapping.js +11 -1
  31. package/dist/client/app/util/state.d.ts +5 -0
  32. package/dist/client/app/util/state.js +55 -0
  33. package/dist/client/app/util/variant.d.ts +1 -1
  34. package/dist/node/build.js +4 -6
  35. package/dist/node/collect/index.js +6 -0
  36. package/dist/node/collect/worker.js +0 -4
  37. package/dist/node/commands/preview.js +1 -1
  38. package/dist/node/config.d.ts +23 -23
  39. package/dist/node/plugin.d.ts +2 -2
  40. package/dist/node/server.js +66 -47
  41. package/dist/node/vite.d.ts +1 -1
  42. package/dist/node/vite.js +10 -2
  43. package/dist/style.css +162 -50
  44. package/package.json +4 -4
  45. package/src/client/app/App.vue +18 -0
  46. package/src/client/app/codegen/serialize-js.ts +1 -1
  47. package/src/client/app/codegen/vue3.ts +40 -12
  48. package/src/client/app/components/app/InitialLoading.vue +46 -0
  49. package/src/client/app/components/app/MobileOverlay.vue +1 -1
  50. package/src/client/app/components/base/BaseSelect.vue +72 -0
  51. package/src/client/app/components/exposed/Story.vue +2 -1
  52. package/src/client/app/components/exposed/Variant.vue +4 -4
  53. package/src/client/app/components/panel/ControlsComponentPropItem.vue +96 -0
  54. package/src/client/app/components/panel/ControlsComponentProps.vue +33 -0
  55. package/src/client/app/components/panel/StatePresets.vue +195 -0
  56. package/src/client/app/components/panel/StoryControls.vue +31 -2
  57. package/src/client/app/components/sandbox/SandboxVue3.vue +70 -2
  58. package/src/client/app/components/story/StoryVariantSinglePreviewRemote.vue +2 -14
  59. package/src/client/app/index.ts +6 -0
  60. package/src/client/app/sandbox.ts +2 -10
  61. package/src/client/app/style/transitions.pcss +12 -0
  62. package/src/client/app/types.ts +13 -0
  63. package/src/client/app/util/mapping.ts +12 -1
  64. package/src/client/app/util/state.ts +61 -0
  65. package/src/client/app/util/variant.ts +1 -1
  66. package/src/node/build.ts +4 -6
  67. package/src/node/collect/index.ts +7 -0
  68. package/src/node/collect/worker.ts +0 -4
  69. package/src/node/commands/preview.ts +1 -1
  70. package/src/node/server.ts +72 -49
  71. package/src/node/vite.ts +11 -2
  72. package/vite.config.ts +25 -0
  73. package/dist/bundled/dark.js +0 -4
  74. package/dist/bundled/reactivity.js +0 -96
  75. package/dist/client/app/util/reactivity.d.ts +0 -1
  76. package/dist/client/app/util/reactivity.js +0 -16
  77. package/src/client/app/util/reactivity.ts +0 -22
@@ -81,3 +81,16 @@ export interface PreviewSettings {
81
81
  backgroundColor: string
82
82
  checkerboard: boolean
83
83
  }
84
+
85
+ export interface PropDefinition {
86
+ name: string
87
+ types?: string[]
88
+ required?: boolean
89
+ default?: any
90
+ }
91
+
92
+ export interface AutoPropComponentDefinition {
93
+ name: string
94
+ index: number
95
+ props: PropDefinition[]
96
+ }
@@ -1,6 +1,17 @@
1
1
  import { markRaw } from 'vue'
2
2
  import type { StoryFile, Variant } from '../types'
3
3
 
4
+ const copiedFromExistingVariant = [
5
+ 'state',
6
+ 'slots',
7
+ 'initState',
8
+ 'source',
9
+ 'responsiveDisabled',
10
+ 'setupApp',
11
+ 'configReady',
12
+ 'previewReady',
13
+ ]
14
+
4
15
  export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
5
16
  const result: StoryFile = {
6
17
  ...file,
@@ -19,7 +30,7 @@ export function mapFile (file: StoryFile, existingFile?: StoryFile): StoryFile {
19
30
  const variant = result.story.variants[index]
20
31
  const existingVariant = existingFile.story.variants[index]
21
32
  if (existingVariant) {
22
- for (const key in existingVariant) {
33
+ for (const key of copiedFromExistingVariant) {
23
34
  if (typeof existingVariant[key] !== 'undefined') {
24
35
  if (key === 'state') {
25
36
  variant.state = existingVariant.state
@@ -0,0 +1,61 @@
1
+ import { unref, isRef } from 'vue'
2
+ import type { Variant } from '../types'
3
+
4
+ const isObject = (val) => val !== null && typeof val === 'object'
5
+
6
+ export function toRawDeep (val) {
7
+ const unwrappedValue = isRef(val) ? unref(val) : val
8
+
9
+ if (!isObject(unwrappedValue)) {
10
+ return unwrappedValue
11
+ }
12
+
13
+ if (Array.isArray(unwrappedValue)) {
14
+ return unwrappedValue.map(toRawDeep)
15
+ }
16
+
17
+ return toRawObject(unwrappedValue)
18
+ }
19
+
20
+ const toRawObject = (obj: Record<any, any>) => Object.keys(obj).reduce((raw, key) => {
21
+ raw[key] = toRawDeep(obj[key])
22
+ return raw
23
+ }, {})
24
+
25
+ export function clone (data) {
26
+ try {
27
+ return structuredClone(data)
28
+ } catch (e) {
29
+ console.warn(e, `Fallback to JSON cloning`)
30
+ try {
31
+ return JSON.parse(JSON.stringify(data))
32
+ } catch (e) {
33
+ console.error(e)
34
+ }
35
+ return data
36
+ }
37
+ }
38
+
39
+ export function omit (data, keys: string[]) {
40
+ const copy = {}
41
+ for (const key in data) {
42
+ if (!keys.includes(key)) {
43
+ copy[key] = data[key]
44
+ }
45
+ }
46
+ return copy
47
+ }
48
+
49
+ export function applyStateToVariant (variant: Variant, state: any) {
50
+ if (variant.state) {
51
+ for (const key in state) {
52
+ if (variant.state[key] && !key.startsWith('_h') && typeof variant.state[key] === 'object' && !Array.isArray(variant.state[key])) {
53
+ Object.assign(variant.state[key], state[key])
54
+ } else {
55
+ variant.state[key] = state[key]
56
+ }
57
+ }
58
+ } else {
59
+ variant.state = state
60
+ }
61
+ }
@@ -1,6 +1,6 @@
1
1
  import { computed, Ref } from 'vue'
2
2
  import { useRoute } from 'vue-router'
3
- import { Variant } from '../types'
3
+ import type { Variant } from '../types'
4
4
 
5
5
  export function useCurrentVariantRoute (variant: Ref<Variant>) {
6
6
  const route = useRoute()
package/src/node/build.ts CHANGED
@@ -29,7 +29,7 @@ export async function build (ctx: Context) {
29
29
  await findAllStories(ctx)
30
30
 
31
31
  const server = await createViteServer({
32
- plugins: await createVitePlugins(ctx),
32
+ plugins: await createVitePlugins(true, ctx),
33
33
  })
34
34
  await server.pluginContainer.buildStart({})
35
35
 
@@ -53,9 +53,7 @@ export async function build (ctx: Context) {
53
53
  server,
54
54
  throws: true,
55
55
  }, ctx)
56
- for (const storyFile of ctx.storyFiles) {
57
- await executeStoryFile(storyFile)
58
- }
56
+ await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile)))
59
57
  await destroyCollectStories()
60
58
 
61
59
  const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0)
@@ -63,7 +61,7 @@ export async function build (ctx: Context) {
63
61
  const emptyStoryCount = ctx.storyFiles.length - storyCount
64
62
 
65
63
  const results = await viteBuild({
66
- plugins: await createVitePlugins(ctx),
64
+ plugins: await createVitePlugins(false, ctx),
67
65
  build: {
68
66
  rollupOptions: {
69
67
  input: [
@@ -87,7 +85,7 @@ export async function build (ctx: Context) {
87
85
  const result = Array.isArray(results) ? results[0] : results as RollupOutput
88
86
 
89
87
  const resolvedViteConfig = await resolveViteConfig({
90
- plugins: await createVitePlugins(ctx),
88
+ plugins: await createVitePlugins(false, ctx),
91
89
  }, 'build')
92
90
 
93
91
  const styleOutput = result.output.find(o => o.name === 'style.css' && o.type === 'asset')
@@ -6,6 +6,7 @@ import { relative } from 'pathe'
6
6
  import pc from 'picocolors'
7
7
  import Tinypool from 'tinypool'
8
8
  import { createBirpc } from 'birpc'
9
+ import { cpus } from 'os'
9
10
  import type { StoryFile } from '../types.js'
10
11
  import { createPath } from '../tree.js'
11
12
  import type { Context } from '../context.js'
@@ -27,10 +28,16 @@ export function useCollectStories (options: UseCollectStoriesOptions, ctx: Conte
27
28
  },
28
29
  })
29
30
 
31
+ const threadsCount = ctx.mode === 'dev'
32
+ ? Math.max(cpus().length / 2, 1)
33
+ : Math.max(cpus().length - 1, 1)
34
+
30
35
  const threadPool = new Tinypool({
31
36
  filename: new URL('./worker.js', import.meta.url).href,
32
37
  // WebContainer compatibility (Stackblitz)
33
38
  useAtomics: typeof process.versions.webcontainer !== 'string',
39
+ maxThreads: threadsCount,
40
+ minThreads: threadsCount,
34
41
  })
35
42
 
36
43
  function clearCache () {
@@ -34,10 +34,6 @@ export default async (payload: Payload): Promise<ReturnData> => {
34
34
  root: payload.root,
35
35
  base: payload.base,
36
36
  fetchModule (id) {
37
- // Alias
38
- if (id.endsWith('vue.runtime.esm-bundler.js')) {
39
- id = 'vue'
40
- }
41
37
  return rpc.fetchModule(id)
42
38
  },
43
39
  resolveId (id, importer) {
@@ -13,7 +13,7 @@ export async function previewCommand (options: PreviewOptions) {
13
13
  mode: 'build',
14
14
  })
15
15
  const viteConfig = await resolveViteConfig({
16
- plugins: await createVitePlugins(ctx),
16
+ plugins: await createVitePlugins(false, ctx),
17
17
  }, 'build')
18
18
 
19
19
  const { baseUrl } = await startPreview(viteConfig, options.port, ctx)
@@ -9,17 +9,17 @@ import { useModuleLoader } from './load.js'
9
9
 
10
10
  export async function createServer (ctx: Context, port: number) {
11
11
  const server = await createViteServer({
12
- plugins: await createVitePlugins(ctx),
13
- server: {
14
- watch: {
15
- usePolling: true,
16
- },
17
- },
12
+ plugins: await createVitePlugins(false, ctx),
18
13
  })
19
14
  await server.pluginContainer.buildStart({})
20
15
 
16
+ const nodeServer = await createViteServer({
17
+ plugins: await createVitePlugins(true, ctx),
18
+ })
19
+ await nodeServer.pluginContainer.buildStart({})
20
+
21
21
  const moduleLoader = useModuleLoader({
22
- server,
22
+ server: nodeServer,
23
23
  })
24
24
 
25
25
  const pluginOnCleanups: (() => void | Promise<void>)[] = []
@@ -43,7 +43,7 @@ export async function createServer (ctx: Context, port: number) {
43
43
  executeStoryFile,
44
44
  destroy: destroyCollectStories,
45
45
  } = useCollectStories({
46
- server,
46
+ server: nodeServer,
47
47
  }, ctx)
48
48
 
49
49
  // onStoryChange debouncing
@@ -51,11 +51,44 @@ export async function createServer (ctx: Context, port: number) {
51
51
  let queueResolve: () => void
52
52
  let queued = false
53
53
  let queuedFiles: StoryFile[] = []
54
+ let queuedAll = false
55
+ let didAllStoriesYet = false
56
+
57
+ // Invalidate modules
58
+ const invalidateModule = (id: string) => {
59
+ const mod = server.moduleGraph.getModuleById(id)
60
+ if (!mod) {
61
+ return
62
+ }
63
+ server.moduleGraph.invalidateModule(mod)
64
+
65
+ // Send HMR update
66
+ const timestamp = Date.now()
67
+ mod.lastHMRTimestamp = timestamp
68
+ server.ws.send({
69
+ type: 'update',
70
+ updates: [
71
+ {
72
+ type: 'js-update',
73
+ acceptedPath: mod.url,
74
+ path: mod.url,
75
+ timestamp: timestamp,
76
+ },
77
+ ],
78
+ })
79
+ }
54
80
 
55
81
  onStoryChange(async (changedFile) => {
82
+ if (changedFile && !didAllStoriesYet) {
83
+ return
84
+ }
56
85
  if (queue) {
57
- if (queued && changedFile) {
58
- queuedFiles.push(changedFile)
86
+ if (queued) {
87
+ if (changedFile) {
88
+ queuedFiles.push(changedFile)
89
+ } else {
90
+ queuedAll = true
91
+ }
59
92
  return
60
93
  } else {
61
94
  queued = true
@@ -70,47 +103,44 @@ export async function createServer (ctx: Context, port: number) {
70
103
 
71
104
  clearCache()
72
105
 
73
- if (changedFile) {
106
+ console.log('Collect stories start', changedFile?.path ?? 'all')
107
+ const time = Date.now()
108
+ if (changedFile && !queuedAll) {
74
109
  // Granular update
75
110
  await executeStoryFile(changedFile)
111
+
112
+ // Queued updates
113
+ await Promise.all(queuedFiles.map(storyFile => executeStoryFile(storyFile)))
76
114
  } else {
77
115
  // Full update
78
- for (const storyFile of ctx.storyFiles) {
79
- await executeStoryFile(storyFile)
116
+
117
+ // Progress tracking
118
+ const fileCount = ctx.storyFiles.length
119
+ let loadedFilesCount = 0
120
+ const sendProgress = () => {
121
+ server.ws.send('histoire:stories-loading-progress', {
122
+ loadedFileCount: loadedFilesCount,
123
+ totalFileCount: fileCount,
124
+ })
80
125
  }
126
+
127
+ sendProgress()
128
+
129
+ await Promise.all(ctx.storyFiles.map(async storyFile => {
130
+ await executeStoryFile(storyFile)
131
+ loadedFilesCount++
132
+ sendProgress()
133
+ }))
134
+
135
+ didAllStoriesYet = true
136
+ server.ws.send('histoire:all-stories-loaded', {})
81
137
  }
82
- // Queued updates
83
- for (const storyFile of queuedFiles) {
84
- await executeStoryFile(storyFile)
85
- }
138
+ console.log('Collect stories end', Date.now() - time, 'ms')
86
139
 
87
140
  queuedFiles = []
141
+ queuedAll = false
88
142
  queueResolve()
89
143
 
90
- // Invalidate modules
91
- function invalidateModule (id: string) {
92
- const mod = server.moduleGraph.getModuleById(id)
93
- if (!mod) {
94
- return
95
- }
96
- server.moduleGraph.invalidateModule(mod)
97
-
98
- // Send HMR update
99
- const timestamp = Date.now()
100
- mod.lastHMRTimestamp = timestamp
101
- server.ws.send({
102
- type: 'update',
103
- updates: [
104
- {
105
- type: 'js-update',
106
- acceptedPath: mod.url,
107
- path: mod.url,
108
- timestamp: timestamp,
109
- },
110
- ],
111
- })
112
- }
113
-
114
144
  invalidateModule(RESOLVED_STORIES_ID)
115
145
  invalidateModule(RESOLVED_SEARCH_TITLE_DATA_ID)
116
146
  })
@@ -120,17 +150,10 @@ export async function createServer (ctx: Context, port: number) {
120
150
  await cb()
121
151
  }
122
152
  await server.close()
153
+ await nodeServer.close()
123
154
  await destroyCollectStories()
124
155
  }
125
156
 
126
- // On page refresh, refresh stories
127
- // Useful when vite optimizes new dependencies
128
- server.ws.on('connection', (socket) => {
129
- if (socket.protocol === 'vite-hmr') {
130
- notifyStoryChange()
131
- }
132
- })
133
-
134
157
  return {
135
158
  server,
136
159
  close,
package/src/node/vite.ts CHANGED
@@ -25,7 +25,7 @@ export const RESOLVED_SEARCH_TITLE_DATA_ID = `/${SEARCH_TITLE_DATA_ID}-resolved`
25
25
  export const SEARCH_DOCS_DATA_ID = '$histoire-search-docs-data'
26
26
  export const RESOLVED_SEARCH_DOCS_DATA_ID = `/${SEARCH_DOCS_DATA_ID}-resolved`
27
27
 
28
- export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
28
+ export async function createVitePlugins (server: boolean, ctx: Context): Promise<VitePlugin[]> {
29
29
  const viteConfig = await resolveViteConfig({}, ctx.mode === 'dev' ? 'serve' : 'build')
30
30
 
31
31
  const plugins: VitePlugin[] = []
@@ -45,7 +45,12 @@ export async function createVitePlugins (ctx: Context): Promise<VitePlugin[]> {
45
45
  config () {
46
46
  return {
47
47
  optimizeDeps: {
48
- // force include vue to avoid duplicated copies when linked + optimized
48
+ disabled: server,
49
+ entries: [
50
+ `${APP_PATH}/bundle-main.js`,
51
+ `${APP_PATH}/bundle-sandbox.js`,
52
+ `${APP_PATH}/server/index.js`,
53
+ ],
49
54
  include: [
50
55
  'vue',
51
56
  dirname(require.resolve('@vue/runtime-core/package.json')),
@@ -171,6 +176,10 @@ if (import.meta.hot) {
171
176
  },
172
177
 
173
178
  configureServer (server) {
179
+ server.ws.on('histoire:mount', () => {
180
+ notifyStoryChange()
181
+ })
182
+
174
183
  server.middlewares.use(async (req, res, next) => {
175
184
  if (req.url!.startsWith(`${server.config.base}__sandbox`)) {
176
185
  res.statusCode = 200
package/vite.config.ts CHANGED
@@ -1,9 +1,34 @@
1
1
  import { defineConfig } from 'vite'
2
2
  import vue from '@vitejs/plugin-vue'
3
+ import fs from 'fs-extra'
4
+ import path from 'pathe'
3
5
 
4
6
  export default defineConfig({
5
7
  plugins: [
6
8
  vue(),
9
+ {
10
+ name: 'histoire:preserve:import.meta',
11
+ enforce: 'pre',
12
+ transform (code) {
13
+ if (code.includes('import.meta')) {
14
+ return {
15
+ code: code.replace(/import\.meta/g, 'import__meta'),
16
+ }
17
+ }
18
+ },
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')
27
+ }
28
+ }
29
+ }
30
+ },
31
+ },
7
32
  ],
8
33
 
9
34
  build: {
@@ -1,4 +0,0 @@
1
- import { useDark, useToggle } from "@vueuse/core";
2
- const isDark = useDark({ valueDark: "htw-dark" });
3
- const toggleDark = useToggle(isDark);
4
- export { isDark as i, toggleDark as t };
@@ -1,96 +0,0 @@
1
- import { defineComponent, ref, createApp, onMounted, watch, onUnmounted, openBlock, createElementBlock, isRef, unref } from "vue";
2
- import * as setup from "$histoire-setup";
3
- const _sfc_main = /* @__PURE__ */ defineComponent({
4
- props: {
5
- variant: {
6
- type: Object,
7
- required: true
8
- },
9
- story: {
10
- type: Object,
11
- required: true
12
- },
13
- slotName: {
14
- type: String,
15
- default: "default"
16
- }
17
- },
18
- emits: {
19
- ready: () => true
20
- },
21
- setup(__props, { emit }) {
22
- const props = __props;
23
- const sandbox = ref();
24
- let app;
25
- let mounting = false;
26
- async function mountVariant() {
27
- mounting = true;
28
- await props.variant.initState();
29
- app = createApp({
30
- name: "SandboxVue3",
31
- render: () => {
32
- var _a, _b, _c, _d, _e, _f, _g;
33
- return (_g = (_c = (_a = props.variant.slots()) == null ? void 0 : _a[props.slotName]) == null ? void 0 : _c.call(_a, {
34
- state: (_b = props.variant.state) != null ? _b : {}
35
- })) != null ? _g : (_f = (_d = props.story.slots()) == null ? void 0 : _d[props.slotName]) == null ? void 0 : _f.call(_d, {
36
- state: (_e = props.variant.state) != null ? _e : {}
37
- });
38
- }
39
- });
40
- if (typeof (setup == null ? void 0 : setup.setupVue3) === "function") {
41
- await setup.setupVue3({
42
- app,
43
- story: props.story,
44
- variant: props.variant
45
- });
46
- }
47
- if (typeof props.variant.setupApp === "function") {
48
- await props.variant.setupApp({
49
- app,
50
- story: props.story,
51
- variant: props.variant
52
- });
53
- }
54
- const target = document.createElement("div");
55
- sandbox.value.appendChild(target);
56
- app.mount(target);
57
- emit("ready");
58
- }
59
- onMounted(async () => {
60
- if (props.variant.initState) {
61
- await mountVariant();
62
- }
63
- });
64
- watch(() => props.variant.initState, (value) => {
65
- if (value && !mounting) {
66
- mountVariant();
67
- }
68
- });
69
- onUnmounted(() => {
70
- app == null ? void 0 : app.unmount();
71
- });
72
- return (_ctx, _cache) => {
73
- return openBlock(), createElementBlock("div", {
74
- ref_key: "sandbox",
75
- ref: sandbox,
76
- class: "__histoire-sandbox htw-overflow-auto"
77
- }, null, 512);
78
- };
79
- }
80
- });
81
- const isObject = (val) => val !== null && typeof val === "object";
82
- function toRawDeep(val) {
83
- const unwrappedValue = isRef(val) ? unref(val) : val;
84
- if (!isObject(unwrappedValue)) {
85
- return unwrappedValue;
86
- }
87
- if (Array.isArray(unwrappedValue)) {
88
- return unwrappedValue.map(toRawDeep);
89
- }
90
- return toRawObject(unwrappedValue);
91
- }
92
- const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
93
- raw[key] = toRawDeep(obj[key]);
94
- return raw;
95
- }, {});
96
- export { _sfc_main as _, toRawDeep as t };
@@ -1 +0,0 @@
1
- export declare function toRawDeep(val: any): any;
@@ -1,16 +0,0 @@
1
- import { unref, isRef } from 'vue';
2
- const isObject = (val) => val !== null && typeof val === 'object';
3
- export function toRawDeep(val) {
4
- const unwrappedValue = isRef(val) ? unref(val) : val;
5
- if (!isObject(unwrappedValue)) {
6
- return unwrappedValue;
7
- }
8
- if (Array.isArray(unwrappedValue)) {
9
- return unwrappedValue.map(toRawDeep);
10
- }
11
- return toRawObject(unwrappedValue);
12
- }
13
- const toRawObject = (obj) => Object.keys(obj).reduce((raw, key) => {
14
- raw[key] = toRawDeep(obj[key]);
15
- return raw;
16
- }, {});
@@ -1,22 +0,0 @@
1
- import { unref, isRef } from 'vue'
2
-
3
- const isObject = (val) => val !== null && typeof val === 'object'
4
-
5
- export function toRawDeep (val) {
6
- const unwrappedValue = isRef(val) ? unref(val) : val
7
-
8
- if (!isObject(unwrappedValue)) {
9
- return unwrappedValue
10
- }
11
-
12
- if (Array.isArray(unwrappedValue)) {
13
- return unwrappedValue.map(toRawDeep)
14
- }
15
-
16
- return toRawObject(unwrappedValue)
17
- }
18
-
19
- const toRawObject = (obj: Record<any, any>) => Object.keys(obj).reduce((raw, key) => {
20
- raw[key] = toRawDeep(obj[key])
21
- return raw
22
- }, {})