@nookuio/iframe 0.6.0 → 0.7.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.
- package/dist/editor.js +30 -1
- package/dist/editor.mjs +28 -1
- package/dist/types.d.ts +24 -0
- package/package.json +1 -1
package/dist/editor.js
CHANGED
|
@@ -7,6 +7,35 @@ exports.createEditorClient = createEditorClient;
|
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
var _createClient = require("./createClient");
|
|
9
9
|
var _telejson = require("telejson");
|
|
10
|
+
function deserialize(data) {
|
|
11
|
+
const parsed = (0, _telejson.parse)(data, {
|
|
12
|
+
maxDepth: Infinity
|
|
13
|
+
});
|
|
14
|
+
const senitizeRefs = obj => {
|
|
15
|
+
if (Array.isArray(obj)) {
|
|
16
|
+
obj.forEach((item, index) => {
|
|
17
|
+
obj[index] = senitizeRefs(item);
|
|
18
|
+
});
|
|
19
|
+
} else if (obj && typeof obj === "object") {
|
|
20
|
+
if (obj.hasOwnProperty("__v_isRef")) {
|
|
21
|
+
const newObj = {
|
|
22
|
+
...obj,
|
|
23
|
+
__v_isRef: "true",
|
|
24
|
+
// converted to string
|
|
25
|
+
value: obj.hasOwnProperty("value") && obj.value !== void 0 ? obj.value : obj._value ?? obj._rawValue
|
|
26
|
+
};
|
|
27
|
+
return newObj;
|
|
28
|
+
} else {
|
|
29
|
+
Object.keys(obj).forEach(key => {
|
|
30
|
+
obj[key] = senitizeRefs(obj[key]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return obj;
|
|
35
|
+
};
|
|
36
|
+
const d = senitizeRefs(parsed);
|
|
37
|
+
return d;
|
|
38
|
+
}
|
|
10
39
|
function createEditorClient(iframe) {
|
|
11
40
|
let iframeElement;
|
|
12
41
|
function getIframe() {
|
|
@@ -72,7 +101,7 @@ function createEditorClient(iframe) {
|
|
|
72
101
|
handleRequest(event.data.request);
|
|
73
102
|
});
|
|
74
103
|
},
|
|
75
|
-
deserialize
|
|
104
|
+
deserialize,
|
|
76
105
|
serialize: v => (0, _telejson.stringify)(v, {
|
|
77
106
|
maxDepth: Infinity
|
|
78
107
|
})
|
package/dist/editor.mjs
CHANGED
|
@@ -1,6 +1,33 @@
|
|
|
1
1
|
import { EDITOR_SOURCE_NAME, IFRAME_SOURCE_NAME } from "./constants.mjs";
|
|
2
2
|
import { createClient } from "./createClient.mjs";
|
|
3
3
|
import { stringify, parse } from "telejson";
|
|
4
|
+
function deserialize(data) {
|
|
5
|
+
const parsed = parse(data, { maxDepth: Infinity });
|
|
6
|
+
const senitizeRefs = (obj) => {
|
|
7
|
+
if (Array.isArray(obj)) {
|
|
8
|
+
obj.forEach((item, index) => {
|
|
9
|
+
obj[index] = senitizeRefs(item);
|
|
10
|
+
});
|
|
11
|
+
} else if (obj && typeof obj === "object") {
|
|
12
|
+
if (obj.hasOwnProperty("__v_isRef")) {
|
|
13
|
+
const newObj = {
|
|
14
|
+
...obj,
|
|
15
|
+
__v_isRef: "true",
|
|
16
|
+
// converted to string
|
|
17
|
+
value: obj.hasOwnProperty("value") && obj.value !== void 0 ? obj.value : obj._value ?? obj._rawValue
|
|
18
|
+
};
|
|
19
|
+
return newObj;
|
|
20
|
+
} else {
|
|
21
|
+
Object.keys(obj).forEach((key) => {
|
|
22
|
+
obj[key] = senitizeRefs(obj[key]);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return obj;
|
|
27
|
+
};
|
|
28
|
+
const d = senitizeRefs(parsed);
|
|
29
|
+
return d;
|
|
30
|
+
}
|
|
4
31
|
export function createEditorClient(iframe) {
|
|
5
32
|
let iframeElement;
|
|
6
33
|
function getIframe() {
|
|
@@ -60,7 +87,7 @@ export function createEditorClient(iframe) {
|
|
|
60
87
|
handleRequest(event.data.request);
|
|
61
88
|
});
|
|
62
89
|
},
|
|
63
|
-
deserialize
|
|
90
|
+
deserialize,
|
|
64
91
|
serialize: (v) => stringify(v, { maxDepth: Infinity })
|
|
65
92
|
}
|
|
66
93
|
);
|
package/dist/types.d.ts
CHANGED
|
@@ -96,3 +96,27 @@ export interface ElementStyles extends ElementPosition {
|
|
|
96
96
|
left: string;
|
|
97
97
|
};
|
|
98
98
|
}
|
|
99
|
+
export interface PageOptions {
|
|
100
|
+
path: string;
|
|
101
|
+
layout?: string | false;
|
|
102
|
+
injectTailwind?: boolean;
|
|
103
|
+
tailwindVersion?: 3 | 4;
|
|
104
|
+
/**
|
|
105
|
+
* Specifically for pages
|
|
106
|
+
*
|
|
107
|
+
* If true, the page will be rendered as a component
|
|
108
|
+
*/
|
|
109
|
+
renderAsComponent?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Page params
|
|
112
|
+
*/
|
|
113
|
+
params?: Record<string, string>;
|
|
114
|
+
/**
|
|
115
|
+
* Component props
|
|
116
|
+
*/
|
|
117
|
+
props?: Record<string, any>;
|
|
118
|
+
/**
|
|
119
|
+
* Specifically for virtual SFC renderer page
|
|
120
|
+
*/
|
|
121
|
+
code?: string;
|
|
122
|
+
}
|