@histoire/app 0.10.2 → 0.10.5

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.
@@ -22,7 +22,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
22
22
  if (iframe.value && props.variant.previewReady) {
23
23
  iframe.value.contentWindow.postMessage({
24
24
  type: STATE_SYNC,
25
- state: toRawDeep(props.variant.state)
25
+ state: toRawDeep(props.variant.state, true)
26
26
  });
27
27
  }
28
28
  }
@@ -42,7 +42,7 @@ const app = createApp({
42
42
  }
43
43
  (_a = window.parent) == null ? void 0 : _a.postMessage({
44
44
  type: STATE_SYNC,
45
- state: toRawDeep(value)
45
+ state: toRawDeep(value, true)
46
46
  });
47
47
  }, {
48
48
  deep: true
@@ -1,6 +1,6 @@
1
1
  import { isRef, unref } from "@histoire/vendors/vue";
2
2
  const isObject = (val) => val !== null && typeof val === "object";
3
- function toRawDeep(val, seen = /* @__PURE__ */ new WeakMap()) {
3
+ function toRawDeep(val, clean = false, seen = /* @__PURE__ */ new WeakMap()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
5
  if (typeof unwrappedValue === "symbol") {
6
6
  return unwrappedValue.toString();
@@ -14,18 +14,25 @@ function toRawDeep(val, seen = /* @__PURE__ */ new WeakMap()) {
14
14
  if (Array.isArray(unwrappedValue)) {
15
15
  const result = [];
16
16
  seen.set(unwrappedValue, result);
17
- result.push(...unwrappedValue.map((value) => toRawDeep(value, seen)));
17
+ let list = unwrappedValue.map((value) => toRawDeep(value, clean, seen));
18
+ if (clean) {
19
+ list = list.filter((value) => typeof value !== "function");
20
+ }
21
+ result.push(...list);
18
22
  return result;
19
23
  } else {
20
24
  const result = {};
21
25
  seen.set(unwrappedValue, result);
22
- toRawObject(unwrappedValue, result, seen);
26
+ toRawObject(unwrappedValue, result, clean, seen);
23
27
  return result;
24
28
  }
25
29
  }
26
- const toRawObject = (obj, target, seen = /* @__PURE__ */ new WeakMap()) => {
30
+ const toRawObject = (obj, target, clean = false, seen = /* @__PURE__ */ new WeakMap()) => {
27
31
  Object.keys(obj).forEach((key) => {
28
- target[key] = toRawDeep(obj[key], seen);
32
+ if (clean && typeof obj[key] === "function") {
33
+ return;
34
+ }
35
+ target[key] = toRawDeep(obj[key], clean, seen);
29
36
  });
30
37
  };
31
38
  export { toRawDeep };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@histoire/app",
3
- "version": "0.10.2",
3
+ "version": "0.10.5",
4
4
  "description": "Pre-bundled UI for Histoire",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -24,9 +24,9 @@
24
24
  },
25
25
  "types": "./src/index.ts",
26
26
  "dependencies": {
27
- "@histoire/controls": "^0.10.2",
28
- "@histoire/shared": "^0.10.2",
29
- "@histoire/vendors": "^0.10.2",
27
+ "@histoire/controls": "^0.10.5",
28
+ "@histoire/shared": "^0.10.5",
29
+ "@histoire/vendors": "^0.10.5",
30
30
  "@types/flexsearch": "^0.7.3",
31
31
  "flexsearch": "^0.7.21",
32
32
  "shiki": "0.10.1"
@@ -25,7 +25,7 @@ function syncState () {
25
25
  if (iframe.value && props.variant.previewReady) {
26
26
  iframe.value.contentWindow.postMessage({
27
27
  type: STATE_SYNC,
28
- state: toRawDeep(props.variant.state),
28
+ state: toRawDeep(props.variant.state, true),
29
29
  })
30
30
  }
31
31
  }
@@ -45,7 +45,7 @@ const app = createApp({
45
45
  }
46
46
  window.parent?.postMessage({
47
47
  type: STATE_SYNC,
48
- state: toRawDeep(value),
48
+ state: toRawDeep(value, true),
49
49
  })
50
50
  }, {
51
51
  deep: true,
@@ -1,4 +1,4 @@
1
- import type { HistoireConfig } from '../../../../histoire/src/node/config'
1
+ import type { HistoireConfig } from '@histoire/shared'
2
2
  // @ts-expect-error virtual module
3
3
  import { config as configRaw, logos as logosRaw } from '$histoire-config'
4
4
 
@@ -2,7 +2,7 @@ import { unref, isRef } from 'vue'
2
2
 
3
3
  const isObject = (val) => val !== null && typeof val === 'object'
4
4
 
5
- export function toRawDeep (val, seen = new WeakMap()) {
5
+ export function toRawDeep (val, clean = false, seen = new WeakMap()) {
6
6
  const unwrappedValue = isRef(val) ? unref(val) : val
7
7
 
8
8
  if (typeof unwrappedValue === 'symbol') {
@@ -20,18 +20,25 @@ export function toRawDeep (val, seen = new WeakMap()) {
20
20
  if (Array.isArray(unwrappedValue)) {
21
21
  const result = []
22
22
  seen.set(unwrappedValue, result)
23
- result.push(...unwrappedValue.map(value => toRawDeep(value, seen)))
23
+ let list = unwrappedValue.map(value => toRawDeep(value, clean, seen))
24
+ if (clean) {
25
+ list = list.filter(value => typeof value !== 'function')
26
+ }
27
+ result.push(...list)
24
28
  return result
25
29
  } else {
26
30
  const result = {}
27
31
  seen.set(unwrappedValue, result)
28
- toRawObject(unwrappedValue, result, seen)
32
+ toRawObject(unwrappedValue, result, clean, seen)
29
33
  return result
30
34
  }
31
35
  }
32
36
 
33
- const toRawObject = (obj: Record<any, any>, target: Record<any, any>, seen = new WeakMap()) => {
37
+ const toRawObject = (obj: Record<any, any>, target: Record<any, any>, clean = false, seen = new WeakMap()) => {
34
38
  Object.keys(obj).forEach((key) => {
35
- target[key] = toRawDeep(obj[key], seen)
39
+ if (clean && typeof obj[key] === 'function') {
40
+ return
41
+ }
42
+ target[key] = toRawDeep(obj[key], clean, seen)
36
43
  })
37
44
  }
package/tsconfig.json CHANGED
@@ -12,8 +12,7 @@
12
12
  "resolveJsonModule": true,
13
13
  "skipLibCheck": true,
14
14
  "types": [
15
- "node",
16
- "@peeky/test"
15
+ "node"
17
16
  ],
18
17
  "lib": [
19
18
  "ESNext",