@teambit/ui-foundation.ui.rendering.html 0.0.84 → 0.0.89
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/dev-tools.d.ts +2 -2
- package/dist/full-height-style.d.ts +2 -2
- package/dist/html.d.ts +4 -2
- package/dist/html.js +15 -3
- package/dist/html.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mount-point.d.ts +2 -2
- package/dist/ssr-styles.d.ts +2 -2
- package/dist/stored-assets.d.ts +2 -2
- package/dist/tsconfig.json +5 -1
- package/html.tsx +20 -2
- package/index.ts +1 -1
- package/package.json +5 -3
- package/tsconfig.json +5 -1
- /package/dist/{preview-1695234806813.js → preview-1713191433000.js} +0 -0
package/dist/dev-tools.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function CrossIframeDevTools(): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function CrossIframeDevTools(): React.JSX.Element;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function FullHeightStyle(): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function FullHeightStyle(): React.JSX.Element;
|
package/dist/html.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { fillMountPoint } from './mount-point';
|
|
3
|
-
export declare
|
|
3
|
+
export declare const LOAD_EVENT = "_DOM_LOADED_";
|
|
4
|
+
export type Assets = Partial<{
|
|
4
5
|
/** page title */
|
|
5
6
|
title: string;
|
|
6
7
|
/** js files to load */
|
|
@@ -17,9 +18,10 @@ export interface HtmlProps extends React.HtmlHTMLAttributes<HTMLHtmlElement> {
|
|
|
17
18
|
fullHeight?: boolean;
|
|
18
19
|
assets?: Assets;
|
|
19
20
|
ssr?: boolean;
|
|
21
|
+
notifyParentOnLoad?: boolean;
|
|
20
22
|
}
|
|
21
23
|
/** html template for the main UI, when ssr is active */
|
|
22
|
-
export declare function Html({ assets, withDevTools, fullHeight, ssr, children, ...rest }: HtmlProps): JSX.Element;
|
|
24
|
+
export declare function Html({ assets, withDevTools, fullHeight, ssr, children, notifyParentOnLoad, ...rest }: HtmlProps): React.JSX.Element;
|
|
23
25
|
export declare namespace Html {
|
|
24
26
|
var fillContent: typeof fillMountPoint;
|
|
25
27
|
var popAssets: typeof import("./stored-assets").popAssets;
|
package/dist/html.js
CHANGED
|
@@ -14,17 +14,28 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ssrCleanup = exports.Html = void 0;
|
|
17
|
+
exports.ssrCleanup = exports.Html = exports.LOAD_EVENT = void 0;
|
|
18
18
|
const react_1 = __importDefault(require("react"));
|
|
19
19
|
const dev_tools_1 = require("./dev-tools");
|
|
20
20
|
const mount_point_1 = require("./mount-point");
|
|
21
21
|
const stored_assets_1 = require("./stored-assets");
|
|
22
22
|
const ssr_styles_1 = require("./ssr-styles");
|
|
23
23
|
const full_height_style_1 = require("./full-height-style");
|
|
24
|
+
exports.LOAD_EVENT = '_DOM_LOADED_';
|
|
25
|
+
const NotifyParentScript = () => (react_1.default.createElement("script", { dangerouslySetInnerHTML: {
|
|
26
|
+
__html: `
|
|
27
|
+
// only send loaded event when mounted in an iframe
|
|
28
|
+
if (window.parent && window !== window.parent) {
|
|
29
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
30
|
+
window.parent.postMessage({ event: '${exports.LOAD_EVENT}' }, '*');
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
`,
|
|
34
|
+
} }));
|
|
24
35
|
/** html template for the main UI, when ssr is active */
|
|
25
36
|
function Html(_a) {
|
|
26
37
|
var _b, _c, _d;
|
|
27
|
-
var { assets = {}, withDevTools = false, fullHeight, ssr, children = react_1.default.createElement(mount_point_1.MountPoint, null) } = _a, rest = __rest(_a, ["assets", "withDevTools", "fullHeight", "ssr", "children"]);
|
|
38
|
+
var { assets = {}, withDevTools = false, fullHeight, ssr, children = react_1.default.createElement(mount_point_1.MountPoint, null), notifyParentOnLoad = true } = _a, rest = __rest(_a, ["assets", "withDevTools", "fullHeight", "ssr", "children", "notifyParentOnLoad"]);
|
|
28
39
|
return (react_1.default.createElement("html", Object.assign({ lang: "en" }, rest),
|
|
29
40
|
react_1.default.createElement("head", null,
|
|
30
41
|
react_1.default.createElement("title", null, assets.title || 'bit scope'),
|
|
@@ -34,7 +45,8 @@ function Html(_a) {
|
|
|
34
45
|
fullHeight && react_1.default.createElement(full_height_style_1.FullHeightStyle, null),
|
|
35
46
|
withDevTools && react_1.default.createElement(dev_tools_1.CrossIframeDevTools, null), (_b = assets.style) === null || _b === void 0 ? void 0 :
|
|
36
47
|
_b.map((x, idx) => (react_1.default.createElement("style", { key: idx }, x))), (_c = assets.css) === null || _c === void 0 ? void 0 :
|
|
37
|
-
_c.map((x, idx) => (react_1.default.createElement("link", { key: idx, href: x, rel: "stylesheet", type: "text/css" })))
|
|
48
|
+
_c.map((x, idx) => (react_1.default.createElement("link", { key: idx, href: x, rel: "stylesheet", type: "text/css" }))),
|
|
49
|
+
notifyParentOnLoad && react_1.default.createElement(NotifyParentScript, null)),
|
|
38
50
|
react_1.default.createElement("body", null,
|
|
39
51
|
children,
|
|
40
52
|
assets.json && react_1.default.createElement(stored_assets_1.StoredAssets, { data: assets.json }), (_d = assets.js) === null || _d === void 0 ? void 0 :
|
package/dist/html.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.js","sourceRoot":"","sources":["../html.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,2CAAkD;AAClD,+CAA2D;AAC3D,mDAA0D;AAC1D,6CAA0D;AA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GAAG,EAAC,YAAY,EAAC,IAAI,EAAC,UAAU,GAAG,CAC7D,CAAC;YACD,kBAAkB,IAAI,8BAAC,kBAAkB,OAAG,CACxC;QACP;YACG,QAAQ;YACR,MAAM,CAAC,IAAI,IAAI,8BAAC,4BAAY,IAAC,IAAI,EAAE,MAAM,CAAC,IAAI,GAAI,EAElD,MAAA,MAAM,CAAC,EAAE;eAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAC1B,0CAAQ,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,GAAI,CAC7B,CAAC,CACG,CACF,CACR,CAAC;AACJ,CAAC;AAtCD,oBAsCC;AAED,IAAI,CAAC,WAAW,GAAG,4BAAc,CAAC;AAClC,IAAI,CAAC,SAAS,GAAG,yBAAS,CAAC;AAE3B,SAAgB,UAAU;IACxB,IAAA,4BAAe,GAAE,CAAC;AACpB,CAAC;AAFD,gCAEC"}
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.popAssets = exports.mountPointId = exports.MountPoint = exports.ssrCleanup = exports.Html = void 0;
|
|
3
|
+
exports.popAssets = exports.mountPointId = exports.MountPoint = exports.LOAD_EVENT = exports.ssrCleanup = exports.Html = void 0;
|
|
4
4
|
var html_1 = require("./html");
|
|
5
5
|
Object.defineProperty(exports, "Html", { enumerable: true, get: function () { return html_1.Html; } });
|
|
6
6
|
Object.defineProperty(exports, "ssrCleanup", { enumerable: true, get: function () { return html_1.ssrCleanup; } });
|
|
7
|
+
Object.defineProperty(exports, "LOAD_EVENT", { enumerable: true, get: function () { return html_1.LOAD_EVENT; } });
|
|
7
8
|
var mount_point_1 = require("./mount-point");
|
|
8
9
|
Object.defineProperty(exports, "MountPoint", { enumerable: true, get: function () { return mount_point_1.MountPoint; } });
|
|
9
10
|
Object.defineProperty(exports, "mountPointId", { enumerable: true, get: function () { return mount_point_1.mountPointId; } });
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,+
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;AAAA,+BAAsD;AAA7C,4FAAA,IAAI,OAAA;AAAE,kGAAA,UAAU,OAAA;AAAE,kGAAA,UAAU,OAAA;AACrC,6CAAyD;AAAhD,yGAAA,UAAU,OAAA;AAAE,2GAAA,YAAY,OAAA;AACjC,iDAA4C;AAAnC,0GAAA,SAAS,OAAA"}
|
package/dist/mount-point.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
1
|
+
import React, { ReactNode } from 'react';
|
|
2
2
|
export declare const mountPointId = "root";
|
|
3
3
|
export declare function MountPoint({ children }: {
|
|
4
4
|
children?: ReactNode;
|
|
5
|
-
}): JSX.Element;
|
|
5
|
+
}): React.JSX.Element;
|
|
6
6
|
export declare function fillMountPoint(htmlTemplate: string, content: string): string;
|
package/dist/ssr-styles.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
export declare function SsrStyles(): JSX.Element;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare function SsrStyles(): React.JSX.Element;
|
|
3
3
|
export declare function removeSsrStyles(): void;
|
package/dist/stored-assets.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
export declare function StoredAssets({ data }: {
|
|
3
3
|
data: Record<string, string>;
|
|
4
|
-
}): JSX.Element;
|
|
4
|
+
}): React.JSX.Element;
|
|
5
5
|
/** read and remove stored data from the dom */
|
|
6
6
|
export declare function popAssets(): Map<string, string>;
|
package/dist/tsconfig.json
CHANGED
package/html.tsx
CHANGED
|
@@ -5,6 +5,8 @@ import { popAssets, StoredAssets } from './stored-assets';
|
|
|
5
5
|
import { SsrStyles, removeSsrStyles } from './ssr-styles';
|
|
6
6
|
import { FullHeightStyle } from './full-height-style';
|
|
7
7
|
|
|
8
|
+
export const LOAD_EVENT = '_DOM_LOADED_';
|
|
9
|
+
|
|
8
10
|
export type Assets = Partial<{
|
|
9
11
|
/** page title */
|
|
10
12
|
title: string;
|
|
@@ -23,8 +25,24 @@ export interface HtmlProps extends React.HtmlHTMLAttributes<HTMLHtmlElement> {
|
|
|
23
25
|
fullHeight?: boolean;
|
|
24
26
|
assets?: Assets;
|
|
25
27
|
ssr?: boolean;
|
|
28
|
+
notifyParentOnLoad?: boolean;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
const NotifyParentScript = () => (
|
|
32
|
+
<script
|
|
33
|
+
dangerouslySetInnerHTML={{
|
|
34
|
+
__html: `
|
|
35
|
+
// only send loaded event when mounted in an iframe
|
|
36
|
+
if (window.parent && window !== window.parent) {
|
|
37
|
+
document.addEventListener('DOMContentLoaded', function() {
|
|
38
|
+
window.parent.postMessage({ event: '${LOAD_EVENT}' }, '*');
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
`,
|
|
42
|
+
}}
|
|
43
|
+
></script>
|
|
44
|
+
);
|
|
45
|
+
|
|
28
46
|
/** html template for the main UI, when ssr is active */
|
|
29
47
|
export function Html({
|
|
30
48
|
assets = {},
|
|
@@ -32,6 +50,7 @@ export function Html({
|
|
|
32
50
|
fullHeight,
|
|
33
51
|
ssr,
|
|
34
52
|
children = <MountPoint />,
|
|
53
|
+
notifyParentOnLoad = true,
|
|
35
54
|
...rest
|
|
36
55
|
}: HtmlProps) {
|
|
37
56
|
return (
|
|
@@ -51,12 +70,11 @@ export function Html({
|
|
|
51
70
|
{assets.css?.map((x, idx) => (
|
|
52
71
|
<link key={idx} href={x} rel="stylesheet" type="text/css" />
|
|
53
72
|
))}
|
|
73
|
+
{notifyParentOnLoad && <NotifyParentScript />}
|
|
54
74
|
</head>
|
|
55
75
|
<body>
|
|
56
76
|
{children}
|
|
57
|
-
|
|
58
77
|
{assets.json && <StoredAssets data={assets.json} />}
|
|
59
|
-
|
|
60
78
|
{/* load scripts after showing the the whole html */}
|
|
61
79
|
{assets.js?.map((x, idx) => (
|
|
62
80
|
<script key={idx} src={x} />
|
package/index.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teambit/ui-foundation.ui.rendering.html",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.89",
|
|
4
4
|
"homepage": "https://bit.cloud/teambit/ui-foundation/ui/rendering/html",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"componentId": {
|
|
7
7
|
"scope": "teambit.ui-foundation",
|
|
8
8
|
"name": "ui/rendering/html",
|
|
9
|
-
"version": "0.0.
|
|
9
|
+
"version": "0.0.89"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"core-js": "^3.0.0"
|
|
@@ -25,6 +25,8 @@
|
|
|
25
25
|
"react-dom": "^16.8.0 || ^17.0.0"
|
|
26
26
|
},
|
|
27
27
|
"license": "Apache-2.0",
|
|
28
|
+
"optionalDependencies": {},
|
|
29
|
+
"peerDependenciesMeta": {},
|
|
28
30
|
"private": false,
|
|
29
31
|
"engines": {
|
|
30
32
|
"node": ">=12.22.0"
|
|
@@ -43,4 +45,4 @@
|
|
|
43
45
|
"angular",
|
|
44
46
|
"angular-components"
|
|
45
47
|
]
|
|
46
|
-
}
|
|
48
|
+
}
|
package/tsconfig.json
CHANGED
|
File without changes
|