@nookuio/iframe 0.9.1 → 0.9.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.
- package/dist/createClient.js +7 -4
- package/dist/createClient.mjs +7 -4
- package/dist/editor.js +1 -1
- package/dist/editor.mjs +1 -1
- package/dist/iframe.js +21 -1
- package/dist/iframe.mjs +12 -1
- package/dist/types.d.ts +13 -3
- package/package.json +1 -1
package/dist/createClient.js
CHANGED
|
@@ -36,7 +36,9 @@ function createClient(localCtx, options) {
|
|
|
36
36
|
key: request.key,
|
|
37
37
|
result: void 0
|
|
38
38
|
};
|
|
39
|
-
|
|
39
|
+
let args = request.args ? deserialize(request.args) : [];
|
|
40
|
+
if (!Array.isArray(args)) args = [args];
|
|
41
|
+
const result = typeof value === "function" ? await value(...args) : value;
|
|
40
42
|
return {
|
|
41
43
|
type: "response",
|
|
42
44
|
id: request.id,
|
|
@@ -47,7 +49,9 @@ function createClient(localCtx, options) {
|
|
|
47
49
|
handleEvent(request => {
|
|
48
50
|
const currentEventListeners = listenersCollection.get(request.eventName);
|
|
49
51
|
if (!currentEventListeners?.length) return;
|
|
50
|
-
|
|
52
|
+
let args = request.args ? deserialize(request.args) : [];
|
|
53
|
+
if (!Array.isArray(args)) args = [args];
|
|
54
|
+
currentEventListeners.forEach(listener => listener(...args));
|
|
51
55
|
});
|
|
52
56
|
const proxyCache = /* @__PURE__ */new Map();
|
|
53
57
|
function createProxyForPath(path) {
|
|
@@ -109,10 +113,9 @@ function createClient(localCtx, options) {
|
|
|
109
113
|
}
|
|
110
114
|
if (prop === "emit") {
|
|
111
115
|
const emitHandler = (eventName, ...args) => {
|
|
112
|
-
args = args.map(arg => serialize(arg));
|
|
113
116
|
emit({
|
|
114
117
|
eventName,
|
|
115
|
-
args
|
|
118
|
+
args: serialize(args)
|
|
116
119
|
});
|
|
117
120
|
};
|
|
118
121
|
return emitHandler;
|
package/dist/createClient.mjs
CHANGED
|
@@ -24,7 +24,9 @@ export function createClient(localCtx, options) {
|
|
|
24
24
|
key: request.key,
|
|
25
25
|
result: void 0
|
|
26
26
|
};
|
|
27
|
-
|
|
27
|
+
let args = request.args ? deserialize(request.args) : [];
|
|
28
|
+
if (!Array.isArray(args)) args = [args];
|
|
29
|
+
const result = typeof value === "function" ? await value(...args) : value;
|
|
28
30
|
return {
|
|
29
31
|
type: "response",
|
|
30
32
|
id: request.id,
|
|
@@ -35,7 +37,9 @@ export function createClient(localCtx, options) {
|
|
|
35
37
|
handleEvent((request) => {
|
|
36
38
|
const currentEventListeners = listenersCollection.get(request.eventName);
|
|
37
39
|
if (!currentEventListeners?.length) return;
|
|
38
|
-
|
|
40
|
+
let args = request.args ? deserialize(request.args) : [];
|
|
41
|
+
if (!Array.isArray(args)) args = [args];
|
|
42
|
+
currentEventListeners.forEach((listener) => listener(...args));
|
|
39
43
|
});
|
|
40
44
|
const proxyCache = /* @__PURE__ */ new Map();
|
|
41
45
|
function createProxyForPath(path) {
|
|
@@ -99,8 +103,7 @@ export function createClient(localCtx, options) {
|
|
|
99
103
|
}
|
|
100
104
|
if (prop === "emit") {
|
|
101
105
|
const emitHandler = (eventName, ...args) => {
|
|
102
|
-
|
|
103
|
-
emit({ eventName, args });
|
|
106
|
+
emit({ eventName, args: serialize(args) });
|
|
104
107
|
};
|
|
105
108
|
return emitHandler;
|
|
106
109
|
}
|
package/dist/editor.js
CHANGED
|
@@ -39,7 +39,7 @@ function deserialize(data) {
|
|
|
39
39
|
function createEditorClient(iframe) {
|
|
40
40
|
let iframeElement;
|
|
41
41
|
function getIframe() {
|
|
42
|
-
if (!iframeElement) {
|
|
42
|
+
if (!iframeElement || !iframeElement.isConnected) {
|
|
43
43
|
iframeElement = typeof iframe === "string" ? document.querySelector(`#${iframe}`) : iframe;
|
|
44
44
|
}
|
|
45
45
|
return iframeElement;
|
package/dist/editor.mjs
CHANGED
|
@@ -31,7 +31,7 @@ function deserialize(data) {
|
|
|
31
31
|
export function createEditorClient(iframe) {
|
|
32
32
|
let iframeElement;
|
|
33
33
|
function getIframe() {
|
|
34
|
-
if (!iframeElement) {
|
|
34
|
+
if (!iframeElement || !iframeElement.isConnected) {
|
|
35
35
|
iframeElement = typeof iframe === "string" ? document.querySelector(`#${iframe}`) : iframe;
|
|
36
36
|
}
|
|
37
37
|
return iframeElement;
|
package/dist/iframe.js
CHANGED
|
@@ -39,7 +39,6 @@ function getElementStyles(selector, withPadding) {
|
|
|
39
39
|
function createVueIframeClient(vueCtx, options) {
|
|
40
40
|
const client = (0, _createClient.createClient)({
|
|
41
41
|
...vueCtx,
|
|
42
|
-
document: window.document,
|
|
43
42
|
async editText({
|
|
44
43
|
path,
|
|
45
44
|
id
|
|
@@ -140,6 +139,27 @@ function createVueIframeClient(vueCtx, options) {
|
|
|
140
139
|
document.documentElement.classList.remove("dark");
|
|
141
140
|
document.documentElement.classList.add("light");
|
|
142
141
|
}
|
|
142
|
+
},
|
|
143
|
+
updateElementClass({
|
|
144
|
+
className,
|
|
145
|
+
id,
|
|
146
|
+
path
|
|
147
|
+
}) {
|
|
148
|
+
const selector = getSelector(path, id);
|
|
149
|
+
const elements = document.querySelectorAll(selector);
|
|
150
|
+
if (!elements?.length) return;
|
|
151
|
+
elements.forEach(elm => elm.className = className);
|
|
152
|
+
},
|
|
153
|
+
updateElementAttribute({
|
|
154
|
+
attribute,
|
|
155
|
+
value,
|
|
156
|
+
id,
|
|
157
|
+
path
|
|
158
|
+
}) {
|
|
159
|
+
const selector = getSelector(path, id);
|
|
160
|
+
const elements = document.querySelectorAll(selector);
|
|
161
|
+
if (!elements?.length) return;
|
|
162
|
+
elements.forEach(elm => elm.setAttribute(attribute, value));
|
|
143
163
|
}
|
|
144
164
|
}, {
|
|
145
165
|
handle(handler) {
|
package/dist/iframe.mjs
CHANGED
|
@@ -34,7 +34,6 @@ export function createVueIframeClient(vueCtx, options) {
|
|
|
34
34
|
const client = createClient(
|
|
35
35
|
{
|
|
36
36
|
...vueCtx,
|
|
37
|
-
document: window.document,
|
|
38
37
|
async editText({ path, id }) {
|
|
39
38
|
if (!path || id === void 0) return;
|
|
40
39
|
const selector = getSelector(path, id);
|
|
@@ -120,6 +119,18 @@ export function createVueIframeClient(vueCtx, options) {
|
|
|
120
119
|
document.documentElement.classList.remove("dark");
|
|
121
120
|
document.documentElement.classList.add("light");
|
|
122
121
|
}
|
|
122
|
+
},
|
|
123
|
+
updateElementClass({ className, id, path }) {
|
|
124
|
+
const selector = getSelector(path, id);
|
|
125
|
+
const elements = document.querySelectorAll(selector);
|
|
126
|
+
if (!elements?.length) return;
|
|
127
|
+
elements.forEach((elm) => elm.className = className);
|
|
128
|
+
},
|
|
129
|
+
updateElementAttribute({ attribute, value, id, path }) {
|
|
130
|
+
const selector = getSelector(path, id);
|
|
131
|
+
const elements = document.querySelectorAll(selector);
|
|
132
|
+
if (!elements?.length) return;
|
|
133
|
+
elements.forEach((elm) => elm.setAttribute(attribute, value));
|
|
123
134
|
}
|
|
124
135
|
},
|
|
125
136
|
{
|
package/dist/types.d.ts
CHANGED
|
@@ -40,7 +40,17 @@ export interface CoreIframeContext {
|
|
|
40
40
|
path: string;
|
|
41
41
|
id: string;
|
|
42
42
|
}) => void;
|
|
43
|
-
|
|
43
|
+
updateElementClass(options: {
|
|
44
|
+
id: string;
|
|
45
|
+
path: string;
|
|
46
|
+
className: string;
|
|
47
|
+
}): void;
|
|
48
|
+
updateElementAttribute(options: {
|
|
49
|
+
id: string;
|
|
50
|
+
path: string;
|
|
51
|
+
attribute: string;
|
|
52
|
+
value: string;
|
|
53
|
+
}): void;
|
|
44
54
|
}
|
|
45
55
|
export interface CoreIframeEvents {
|
|
46
56
|
ready: () => void;
|
|
@@ -72,7 +82,7 @@ export interface VueIframeContext extends CoreIframeContext {
|
|
|
72
82
|
*
|
|
73
83
|
* Works only on VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH
|
|
74
84
|
*/
|
|
75
|
-
updateVirtualSfcCode
|
|
85
|
+
updateVirtualSfcCode: (path: string, code: string) => void;
|
|
76
86
|
}
|
|
77
87
|
export interface VueIframeEvents extends CoreIframeEvents {
|
|
78
88
|
'route-change': (to: string) => void;
|
|
@@ -96,7 +106,7 @@ export interface ElementStyles extends ElementPosition {
|
|
|
96
106
|
left: string;
|
|
97
107
|
};
|
|
98
108
|
}
|
|
99
|
-
export interface
|
|
109
|
+
export interface IframePageOptions {
|
|
100
110
|
path: string;
|
|
101
111
|
layout?: string | false;
|
|
102
112
|
injectTailwind?: boolean;
|