histoire 0.8.2 → 0.8.3

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.
@@ -53,6 +53,10 @@
53
53
  bottom: -.625rem;
54
54
  }
55
55
 
56
+ .bind-icon-color[data-v-2cdc2ac0] {
57
+ color: var(--3c4190ff);
58
+ }
59
+
56
60
  .bind-tree-margin[data-v-1b0b957a] {
57
61
  margin-left: var(--2101d9b6);
58
62
  }
@@ -60,31 +64,27 @@
60
64
  color: var(--0fbedaf2);
61
65
  }
62
66
 
63
- .__histoire-code-placeholder[data-v-19579c98] {
64
- color: inherit;
65
- font-size: inherit;
66
- }
67
-
68
67
  .bind-tree-padding[data-v-1a78012e] {
69
68
  padding-left: var(--27f98670);
70
69
  }
71
70
 
72
- .bind-icon-color[data-v-2cdc2ac0] {
73
- color: var(--3c4190ff);
71
+ .__histoire-code-placeholder[data-v-19579c98] {
72
+ color: inherit;
73
+ font-size: inherit;
74
74
  }
75
75
 
76
76
  .bind-icon-color[data-v-30bcb922] {
77
77
  color: var(--33d9fc01);
78
78
  }
79
79
 
80
- .bind-icon-color[data-v-307653da] {
81
- color: var(--5f94a358);
82
- }
83
-
84
80
  .bind-icon-color[data-v-7856c5b0] {
85
81
  color: var(--0e1c785e);
86
82
  }
87
83
 
84
+ .bind-icon-color[data-v-307653da] {
85
+ color: var(--5f94a358);
86
+ }
87
+
88
88
  .bind-preview-bg[data-v-bde73868] {
89
89
  background-color: var(--b797c7ca);
90
90
  }
@@ -67,7 +67,7 @@ function mapVariant(variant, existingVariant) {
67
67
  }
68
68
  } else {
69
69
  result = __spreadProps(__spreadValues({}, variant), {
70
- state: reactive({}),
70
+ state: reactive(createVariantState()),
71
71
  setupApp: null,
72
72
  slots: () => ({}),
73
73
  previewReady: false
@@ -75,4 +75,20 @@ function mapVariant(variant, existingVariant) {
75
75
  }
76
76
  return result;
77
77
  }
78
+ function createVariantState() {
79
+ const obj = {};
80
+ Object.defineProperty(obj, "_hPropState", {
81
+ value: null,
82
+ writable: true,
83
+ configurable: true,
84
+ enumerable: false
85
+ });
86
+ Object.defineProperty(obj, "_hPropDefs", {
87
+ value: null,
88
+ writable: true,
89
+ configurable: true,
90
+ enumerable: false
91
+ });
92
+ return obj;
93
+ }
78
94
  export { mapFile, mapVariant };
@@ -1,6 +1,6 @@
1
1
  import { isRef, unref } from "@histoire/vendors/dist/client/vue.js";
2
2
  const isObject = (val) => val !== null && typeof val === "object";
3
- function toRawDeep(val, seen = /* @__PURE__ */ new Map()) {
3
+ function toRawDeep(val, seen = /* @__PURE__ */ new WeakMap()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
5
  if (typeof unwrappedValue === "symbol") {
6
6
  return unwrappedValue.toString();
@@ -11,17 +11,21 @@ function toRawDeep(val, seen = /* @__PURE__ */ new Map()) {
11
11
  if (seen.has(unwrappedValue)) {
12
12
  return seen.get(unwrappedValue);
13
13
  }
14
- let result;
15
14
  if (Array.isArray(unwrappedValue)) {
16
- result = unwrappedValue.map((value) => toRawDeep(value, seen));
15
+ const result = [];
16
+ seen.set(unwrappedValue, result);
17
+ result.push(...unwrappedValue.map((value) => toRawDeep(value, seen)));
18
+ return result;
17
19
  } else {
18
- result = toRawObject(unwrappedValue, seen);
20
+ const result = {};
21
+ seen.set(unwrappedValue, result);
22
+ toRawObject(unwrappedValue, result, seen);
23
+ return result;
19
24
  }
20
- seen.set(unwrappedValue, result);
21
- return result;
22
25
  }
23
- const toRawObject = (obj, seen = /* @__PURE__ */ new Map()) => Object.keys(obj).reduce((raw, key) => {
24
- raw[key] = toRawDeep(obj[key], seen);
25
- return raw;
26
- }, {});
26
+ const toRawObject = (obj, target, seen = /* @__PURE__ */ new WeakMap()) => {
27
+ Object.keys(obj).forEach((key) => {
28
+ target[key] = toRawDeep(obj[key], seen);
29
+ });
30
+ };
27
31
  export { toRawDeep };
@@ -59,7 +59,7 @@ export function mapVariant(variant, existingVariant) {
59
59
  // Create
60
60
  result = {
61
61
  ...variant,
62
- state: _reactive({}),
62
+ state: _reactive(createVariantState()),
63
63
  setupApp: null,
64
64
  slots: () => ({}),
65
65
  previewReady: false,
@@ -67,3 +67,19 @@ export function mapVariant(variant, existingVariant) {
67
67
  }
68
68
  return result;
69
69
  }
70
+ function createVariantState() {
71
+ const obj = {};
72
+ Object.defineProperty(obj, '_hPropState', {
73
+ value: null,
74
+ writable: true,
75
+ configurable: true,
76
+ enumerable: false,
77
+ });
78
+ Object.defineProperty(obj, '_hPropDefs', {
79
+ value: null,
80
+ writable: true,
81
+ configurable: true,
82
+ enumerable: false,
83
+ });
84
+ return obj;
85
+ }
@@ -1 +1 @@
1
- export declare function toRawDeep(val: any, seen?: Map<any, any>): any;
1
+ export declare function toRawDeep(val: any, seen?: WeakMap<object, any>): any;
@@ -1,6 +1,6 @@
1
1
  import { unref, isRef } from 'vue';
2
2
  const isObject = (val) => val !== null && typeof val === 'object';
3
- export function toRawDeep(val, seen = new Map()) {
3
+ export function toRawDeep(val, seen = new WeakMap()) {
4
4
  const unwrappedValue = isRef(val) ? unref(val) : val;
5
5
  if (typeof unwrappedValue === 'symbol') {
6
6
  return unwrappedValue.toString();
@@ -11,17 +11,21 @@ export function toRawDeep(val, seen = new Map()) {
11
11
  if (seen.has(unwrappedValue)) {
12
12
  return seen.get(unwrappedValue);
13
13
  }
14
- let result;
15
14
  if (Array.isArray(unwrappedValue)) {
16
- result = unwrappedValue.map(value => toRawDeep(value, seen));
15
+ const result = [];
16
+ seen.set(unwrappedValue, result);
17
+ result.push(...unwrappedValue.map(value => toRawDeep(value, seen)));
18
+ return result;
17
19
  }
18
20
  else {
19
- result = toRawObject(unwrappedValue, seen);
21
+ const result = {};
22
+ seen.set(unwrappedValue, result);
23
+ toRawObject(unwrappedValue, result, seen);
24
+ return result;
20
25
  }
21
- seen.set(unwrappedValue, result);
22
- return result;
23
26
  }
24
- const toRawObject = (obj, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
25
- raw[key] = toRawDeep(obj[key], seen);
26
- return raw;
27
- }, {});
27
+ const toRawObject = (obj, target, seen = new WeakMap()) => {
28
+ Object.keys(obj).forEach((key) => {
29
+ target[key] = toRawDeep(obj[key], seen);
30
+ });
31
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "histoire",
3
- "version": "0.8.2",
3
+ "version": "0.8.3",
4
4
  "description": "A fast story book powered by Vite",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -33,10 +33,10 @@
33
33
  "histoire": "./bin.mjs"
34
34
  },
35
35
  "dependencies": {
36
- "@histoire/controls": "^0.8.2",
37
- "@histoire/plugin-vue": "^0.8.2",
38
- "@histoire/shared": "^0.8.2",
39
- "@histoire/vendors": "^0.8.2",
36
+ "@histoire/controls": "^0.8.3",
37
+ "@histoire/plugin-vue": "^0.8.3",
38
+ "@histoire/shared": "^0.8.3",
39
+ "@histoire/vendors": "^0.8.3",
40
40
  "@types/flexsearch": "^0.7.3",
41
41
  "@types/markdown-it": "^12.2.3",
42
42
  "birpc": "^0.1.1",
@@ -63,7 +63,7 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
63
63
  // Create
64
64
  result = {
65
65
  ...variant,
66
- state: _reactive({}),
66
+ state: _reactive(createVariantState()),
67
67
  setupApp: null,
68
68
  slots: () => ({}),
69
69
  previewReady: false,
@@ -72,3 +72,20 @@ export function mapVariant (variant: Variant, existingVariant?: Variant): Varian
72
72
 
73
73
  return result
74
74
  }
75
+
76
+ function createVariantState () {
77
+ const obj = {}
78
+ Object.defineProperty(obj, '_hPropState', {
79
+ value: null,
80
+ writable: true,
81
+ configurable: true,
82
+ enumerable: false,
83
+ })
84
+ Object.defineProperty(obj, '_hPropDefs', {
85
+ value: null,
86
+ writable: true,
87
+ configurable: true,
88
+ enumerable: false,
89
+ })
90
+ return obj
91
+ }
@@ -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 Map()) {
5
+ export function toRawDeep (val, seen = new WeakMap()) {
6
6
  const unwrappedValue = isRef(val) ? unref(val) : val
7
7
 
8
8
  if (typeof unwrappedValue === 'symbol') {
@@ -17,20 +17,21 @@ export function toRawDeep (val, seen = new Map()) {
17
17
  return seen.get(unwrappedValue)
18
18
  }
19
19
 
20
- let result
21
-
22
20
  if (Array.isArray(unwrappedValue)) {
23
- result = unwrappedValue.map(value => toRawDeep(value, seen))
21
+ const result = []
22
+ seen.set(unwrappedValue, result)
23
+ result.push(...unwrappedValue.map(value => toRawDeep(value, seen)))
24
+ return result
24
25
  } else {
25
- result = toRawObject(unwrappedValue, seen)
26
+ const result = {}
27
+ seen.set(unwrappedValue, result)
28
+ toRawObject(unwrappedValue, result, seen)
29
+ return result
26
30
  }
27
-
28
- seen.set(unwrappedValue, result)
29
-
30
- return result
31
31
  }
32
32
 
33
- const toRawObject = (obj: Record<any, any>, seen = new Map()) => Object.keys(obj).reduce((raw, key) => {
34
- raw[key] = toRawDeep(obj[key], seen)
35
- return raw
36
- }, {})
33
+ const toRawObject = (obj: Record<any, any>, target: Record<any, any>, seen = new WeakMap()) => {
34
+ Object.keys(obj).forEach((key) => {
35
+ target[key] = toRawDeep(obj[key], seen)
36
+ })
37
+ }