@nookuio/iframe 0.4.0 → 0.6.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/constants.d.ts +3 -2
- package/dist/constants.js +4 -3
- package/dist/constants.mjs +3 -2
- package/dist/createClient.d.ts +2 -1
- package/dist/editor.js +0 -1
- package/dist/editor.mjs +0 -1
- package/dist/iframe.d.ts +4 -4
- package/dist/iframe.js +3 -2
- package/dist/iframe.mjs +2 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +22 -0
- package/dist/index.mjs +2 -0
- package/dist/types.d.ts +12 -9
- package/package.json +1 -1
package/dist/constants.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The path of the editor page which will be rendered in canvas
|
|
3
3
|
*/
|
|
4
|
-
export declare const EDITOR_PAGE_PATH = "/
|
|
5
|
-
export declare const COMPONENT_PREVIEW_PAGE_PATH = "/
|
|
4
|
+
export declare const EDITOR_PAGE_PATH = "/__nooku__/editor";
|
|
5
|
+
export declare const COMPONENT_PREVIEW_PAGE_PATH = "/__nooku__/component-preview";
|
|
6
|
+
export declare const VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = "/__nooku__/virtual-sfc-preview";
|
|
6
7
|
export declare const IFRAME_SOURCE_NAME = "nooku-frame";
|
|
7
8
|
export declare const EDITOR_SOURCE_NAME = "nooku-editor";
|
package/dist/constants.js
CHANGED
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.IFRAME_SOURCE_NAME = exports.EDITOR_SOURCE_NAME = exports.EDITOR_PAGE_PATH = exports.COMPONENT_PREVIEW_PAGE_PATH = void 0;
|
|
7
|
-
const EDITOR_PAGE_PATH = exports.EDITOR_PAGE_PATH = `/
|
|
8
|
-
const COMPONENT_PREVIEW_PAGE_PATH = exports.COMPONENT_PREVIEW_PAGE_PATH = `/
|
|
6
|
+
exports.VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = exports.IFRAME_SOURCE_NAME = exports.EDITOR_SOURCE_NAME = exports.EDITOR_PAGE_PATH = exports.COMPONENT_PREVIEW_PAGE_PATH = void 0;
|
|
7
|
+
const EDITOR_PAGE_PATH = exports.EDITOR_PAGE_PATH = `/__nooku__/editor`;
|
|
8
|
+
const COMPONENT_PREVIEW_PAGE_PATH = exports.COMPONENT_PREVIEW_PAGE_PATH = `/__nooku__/component-preview`;
|
|
9
|
+
const VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = exports.VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = `/__nooku__/virtual-sfc-preview`;
|
|
9
10
|
const IFRAME_SOURCE_NAME = exports.IFRAME_SOURCE_NAME = "nooku-frame";
|
|
10
11
|
const EDITOR_SOURCE_NAME = exports.EDITOR_SOURCE_NAME = "nooku-editor";
|
package/dist/constants.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export const EDITOR_PAGE_PATH = `/
|
|
2
|
-
export const COMPONENT_PREVIEW_PAGE_PATH = `/
|
|
1
|
+
export const EDITOR_PAGE_PATH = `/__nooku__/editor`;
|
|
2
|
+
export const COMPONENT_PREVIEW_PAGE_PATH = `/__nooku__/component-preview`;
|
|
3
|
+
export const VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH = `/__nooku__/virtual-sfc-preview`;
|
|
3
4
|
export const IFRAME_SOURCE_NAME = "nooku-frame";
|
|
4
5
|
export const EDITOR_SOURCE_NAME = "nooku-editor";
|
package/dist/createClient.d.ts
CHANGED
|
@@ -46,5 +46,6 @@ interface ClientOptions {
|
|
|
46
46
|
*/
|
|
47
47
|
deserialize?: (data: any) => any;
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
type Context = Record<string, any>;
|
|
50
|
+
export declare function createClient<R extends Context, L extends Context, RE, LE>(localCtx: L, options: ClientOptions): ClientReturn<R, L, RE, LE>;
|
|
50
51
|
export {};
|
package/dist/editor.js
CHANGED
|
@@ -7,7 +7,6 @@ exports.createEditorClient = createEditorClient;
|
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
var _createClient = require("./createClient");
|
|
9
9
|
var _telejson = require("telejson");
|
|
10
|
-
const listenersCollection = /* @__PURE__ */new Map();
|
|
11
10
|
function createEditorClient(iframe) {
|
|
12
11
|
let iframeElement;
|
|
13
12
|
function getIframe() {
|
package/dist/editor.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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
|
-
const listenersCollection = /* @__PURE__ */ new Map();
|
|
5
4
|
export function createEditorClient(iframe) {
|
|
6
5
|
let iframeElement;
|
|
7
6
|
function getIframe() {
|
package/dist/iframe.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { CoreIframeContext,
|
|
1
|
+
import type { CoreIframeContext, EditorEvents, VueIframeContext, VueIframeEvents } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* This function should be called inside the iframe
|
|
4
4
|
*/
|
|
5
|
-
export declare function
|
|
5
|
+
export declare function createVueIframeClient(vueCtx: Omit<VueIframeContext, keyof CoreIframeContext>, options?: {
|
|
6
6
|
/**
|
|
7
7
|
* If true, the default console methods will be disabled
|
|
8
8
|
*
|
|
@@ -10,9 +10,9 @@ export declare function createIframeClient<IframeContext extends CoreIframeConte
|
|
|
10
10
|
*/
|
|
11
11
|
disableDefaultConsole?: boolean;
|
|
12
12
|
}): {} & {
|
|
13
|
-
$context:
|
|
13
|
+
$context: VueIframeContext;
|
|
14
14
|
on: <E extends never>(eventName: E, listener: (...args: EditorEvents[E] extends infer T ? T extends EditorEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
15
15
|
off: <E extends never>(eventName: E, listener: (...args: EditorEvents[E] extends infer T ? T extends EditorEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void) => void;
|
|
16
|
-
emit: <E extends keyof
|
|
16
|
+
emit: <E extends keyof VueIframeEvents>(eventName: E, ...args: VueIframeEvents[E] extends infer T ? T extends VueIframeEvents[E] ? T extends (...args: infer A) => any ? A : never : never : never) => void;
|
|
17
17
|
removeAllListeners: () => void;
|
|
18
18
|
};
|
package/dist/iframe.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.createVueIframeClient = createVueIframeClient;
|
|
7
7
|
var _constants = require("./constants");
|
|
8
8
|
var _createClient = require("./createClient");
|
|
9
9
|
var _telejson = require("telejson");
|
|
@@ -36,8 +36,9 @@ function getElementStyles(selector, withPadding) {
|
|
|
36
36
|
if (!styles?.length) return;
|
|
37
37
|
return styles.length === 1 ? styles[0] : styles;
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function createVueIframeClient(vueCtx, options) {
|
|
40
40
|
const client = (0, _createClient.createClient)({
|
|
41
|
+
...vueCtx,
|
|
41
42
|
document: window.document,
|
|
42
43
|
async editText({
|
|
43
44
|
path,
|
package/dist/iframe.mjs
CHANGED
|
@@ -30,9 +30,10 @@ function getElementStyles(selector, withPadding) {
|
|
|
30
30
|
if (!styles?.length) return;
|
|
31
31
|
return styles.length === 1 ? styles[0] : styles;
|
|
32
32
|
}
|
|
33
|
-
export function
|
|
33
|
+
export function createVueIframeClient(vueCtx, options) {
|
|
34
34
|
const client = createClient(
|
|
35
35
|
{
|
|
36
|
+
...vueCtx,
|
|
36
37
|
document: window.document,
|
|
37
38
|
async editText({ path, id }) {
|
|
38
39
|
if (!path || id === void 0) return;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -24,4 +24,26 @@ Object.keys(_types).forEach(function (key) {
|
|
|
24
24
|
return _types[key];
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
+
});
|
|
28
|
+
var _iframe = require("./iframe");
|
|
29
|
+
Object.keys(_iframe).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _iframe[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _iframe[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
var _editor = require("./editor");
|
|
40
|
+
Object.keys(_editor).forEach(function (key) {
|
|
41
|
+
if (key === "default" || key === "__esModule") return;
|
|
42
|
+
if (key in exports && exports[key] === _editor[key]) return;
|
|
43
|
+
Object.defineProperty(exports, key, {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function () {
|
|
46
|
+
return _editor[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
27
49
|
});
|
package/dist/index.mjs
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -46,34 +46,37 @@ export interface CoreIframeEvents {
|
|
|
46
46
|
ready: () => void;
|
|
47
47
|
resize: (height: number) => void;
|
|
48
48
|
console: (type: 'log' | 'error' | 'info' | 'warn', message: any[]) => void;
|
|
49
|
-
'route-change': (to: string) => void;
|
|
50
49
|
'text-update': (options: {
|
|
51
50
|
path: string;
|
|
52
51
|
id: string;
|
|
53
52
|
content: string;
|
|
54
53
|
}) => void;
|
|
55
54
|
}
|
|
56
|
-
export interface
|
|
55
|
+
export interface VueIframeContext extends CoreIframeContext {
|
|
57
56
|
navigateTo: (to: string) => void;
|
|
58
|
-
getValue: (
|
|
57
|
+
getValue: (options: {
|
|
59
58
|
code: string;
|
|
60
59
|
path?: string;
|
|
61
60
|
onTemplateContext?: boolean;
|
|
62
61
|
context?: Record<string, any>;
|
|
63
62
|
}) => any;
|
|
64
63
|
getInstanceData: (path: string /** filepath path of the component */) => Record<string, any>;
|
|
65
|
-
runCode: (
|
|
64
|
+
runCode: (options: {
|
|
66
65
|
path?: string;
|
|
67
66
|
code: string;
|
|
68
67
|
onTemplateContext?: boolean;
|
|
69
68
|
context?: Record<string, any>;
|
|
70
69
|
}) => any;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
/**
|
|
71
|
+
* For virtual SFC preview
|
|
72
|
+
*
|
|
73
|
+
* Works only on VIRTUAL_VUE_SFC_RENDERER_PAGE_PATH
|
|
74
|
+
*/
|
|
75
|
+
updateVirtualSfcCode?: (path: string, code: string) => void;
|
|
75
76
|
}
|
|
76
|
-
export interface
|
|
77
|
+
export interface VueIframeEvents extends CoreIframeEvents {
|
|
78
|
+
'route-change': (to: string) => void;
|
|
79
|
+
'instance-data-update': (data: Record<string, any>) => void;
|
|
77
80
|
}
|
|
78
81
|
export interface EditorContext {
|
|
79
82
|
}
|