timvir 0.2.32 → 0.2.34
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/blocks/Font/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useMDXComponents } from '@mdx-js/react';
|
|
2
|
+
import * as builtins from 'timvir/builtins';
|
|
2
3
|
import * as React from 'react';
|
|
3
4
|
import * as Icons from 'react-feather';
|
|
4
5
|
|
|
@@ -40,7 +41,7 @@ const classes = {
|
|
|
40
41
|
};
|
|
41
42
|
function Font(props, ref) {
|
|
42
43
|
const components = {
|
|
43
|
-
|
|
44
|
+
...builtins,
|
|
44
45
|
...useMDXComponents()
|
|
45
46
|
};
|
|
46
47
|
const {
|
package/blocks/Viewport/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { useResizeObserverEntry, useResizeObserver } from 'timvir/hooks';
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useImmer } from 'use-immer';
|
|
6
6
|
import { useMDXComponents } from '@mdx-js/react';
|
|
7
|
+
import * as builtins from 'timvir/builtins';
|
|
7
8
|
import { Code } from 'timvir/blocks';
|
|
8
9
|
import * as Icons from 'react-feather';
|
|
9
10
|
|
|
@@ -38,7 +39,7 @@ var cx_default = cx;
|
|
|
38
39
|
|
|
39
40
|
function Caption(props) {
|
|
40
41
|
const components = {
|
|
41
|
-
|
|
42
|
+
...builtins,
|
|
42
43
|
...useMDXComponents()
|
|
43
44
|
};
|
|
44
45
|
const {
|
|
@@ -119,25 +120,25 @@ function Ruler(props) {
|
|
|
119
120
|
viewportWidth = 0
|
|
120
121
|
} = props;
|
|
121
122
|
return /*#__PURE__*/React.createElement("svg", {
|
|
122
|
-
viewBox: `-${containerWidth / 2} ${-
|
|
123
|
+
viewBox: `-${containerWidth / 2} ${ -16 / 2} ${containerWidth} ${height}`,
|
|
123
124
|
className: "ssl4j8q"
|
|
124
125
|
}, /*#__PURE__*/React.createElement("rect", {
|
|
125
126
|
x: -containerWidth / 2,
|
|
126
|
-
y: -
|
|
127
|
+
y: -16 / 2,
|
|
127
128
|
width: containerWidth,
|
|
128
129
|
height: height,
|
|
129
130
|
fill: "var(--timvir-secondary-background-color)"
|
|
130
131
|
}), /*#__PURE__*/React.createElement("line", {
|
|
131
132
|
x1: -viewportWidth / 2,
|
|
132
133
|
x2: -viewportWidth / 2,
|
|
133
|
-
y1: -
|
|
134
|
+
y1: -16 / 2,
|
|
134
135
|
y2: height / 2,
|
|
135
136
|
strokeWidth: 2,
|
|
136
137
|
stroke: "var(--timvir-text-color)"
|
|
137
138
|
}), /*#__PURE__*/React.createElement("line", {
|
|
138
139
|
x1: viewportWidth / 2,
|
|
139
140
|
x2: viewportWidth / 2,
|
|
140
|
-
y1: -
|
|
141
|
+
y1: -16 / 2,
|
|
141
142
|
y2: height / 2,
|
|
142
143
|
strokeWidth: 2,
|
|
143
144
|
stroke: "var(--timvir-text-color)"
|
|
@@ -217,22 +218,6 @@ function Viewport(props, ref) {
|
|
|
217
218
|
setHeight(height);
|
|
218
219
|
setMaxHeight(Math.max(height, maxHeight ?? 0));
|
|
219
220
|
});
|
|
220
|
-
|
|
221
|
-
/*
|
|
222
|
-
* 20ms after the height has been set, we consider this block settled. This
|
|
223
|
-
* time includes the 16ms CSS transition time, and a tiny bit more to allow
|
|
224
|
-
* for the content in the iframe itself to finish rendering.
|
|
225
|
-
*/
|
|
226
|
-
React.useEffect(() => {
|
|
227
|
-
const timeoutId = setTimeout(() => {
|
|
228
|
-
mutate(draft => {
|
|
229
|
-
draft.settled = true;
|
|
230
|
-
});
|
|
231
|
-
}, 20);
|
|
232
|
-
return () => {
|
|
233
|
-
clearTimeout(timeoutId);
|
|
234
|
-
};
|
|
235
|
-
}, [mutate, height]);
|
|
236
221
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
237
222
|
ref: containerRef
|
|
238
223
|
}), /*#__PURE__*/React.createElement(Root, {
|
|
@@ -279,7 +264,7 @@ function Viewport(props, ref) {
|
|
|
279
264
|
*/
|
|
280
265
|
|
|
281
266
|
const initializeDocument = () => {
|
|
282
|
-
if (document.readyState === "
|
|
267
|
+
if (document.readyState === "complete") {
|
|
283
268
|
/*
|
|
284
269
|
* Inject a simple style reset into the document.
|
|
285
270
|
*/
|
|
@@ -303,6 +288,21 @@ function Viewport(props, ref) {
|
|
|
303
288
|
* style reset into the iframe document).
|
|
304
289
|
*/
|
|
305
290
|
iframeRO.observe(document.body);
|
|
291
|
+
|
|
292
|
+
/*
|
|
293
|
+
* 50ms after the iframe document is complete, we consider the Viewport block
|
|
294
|
+
* settled. This time includes the 16ms CSS transition time, and a tiny bit more
|
|
295
|
+
* to allow for the content in the iframe itself to finish rendering.
|
|
296
|
+
*
|
|
297
|
+
* This time is not quite enough if the iframe loads additional code or needs to
|
|
298
|
+
* load data from a remote source. But should be enough for statically rendered
|
|
299
|
+
* content.
|
|
300
|
+
*/
|
|
301
|
+
setTimeout(() => {
|
|
302
|
+
mutate(draft => {
|
|
303
|
+
draft.settled = true;
|
|
304
|
+
});
|
|
305
|
+
}, 50);
|
|
306
306
|
} else {
|
|
307
307
|
document?.addEventListener("readystatechange", initializeDocument, {
|
|
308
308
|
once: true
|
|
@@ -3,7 +3,7 @@ interface Props {
|
|
|
3
3
|
gridColumn: string;
|
|
4
4
|
lock: React.MutableRefObject<string>;
|
|
5
5
|
edge: "left" | "right";
|
|
6
|
-
iframeRef: React.RefObject<HTMLIFrameElement>;
|
|
6
|
+
iframeRef: React.RefObject<null | HTMLIFrameElement>;
|
|
7
7
|
}
|
|
8
8
|
declare function Handle(props: Props): React.JSX.Element;
|
|
9
9
|
declare const _default: React.MemoExoticComponent<typeof Handle>;
|
package/builtins/components.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
export declare const h1:
|
|
2
|
+
export declare const h1: any;
|
|
3
3
|
export declare const h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
|
|
4
4
|
export declare const h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
|
|
5
5
|
export declare const h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => React.JSX.Element;
|
|
6
|
-
export declare const blockquote:
|
|
7
|
-
export declare const hr:
|
|
8
|
-
export declare const table:
|
|
9
|
-
export declare const thead:
|
|
10
|
-
export declare const tbody:
|
|
11
|
-
export declare const tr:
|
|
12
|
-
export declare const th:
|
|
13
|
-
export declare const td:
|
|
14
|
-
export declare const code:
|
|
15
|
-
export declare const a:
|
|
16
|
-
export declare const p:
|
|
17
|
-
export declare const ul:
|
|
18
|
-
export declare const ol:
|
|
6
|
+
export declare const blockquote: any;
|
|
7
|
+
export declare const hr: any;
|
|
8
|
+
export declare const table: any;
|
|
9
|
+
export declare const thead: any;
|
|
10
|
+
export declare const tbody: any;
|
|
11
|
+
export declare const tr: any;
|
|
12
|
+
export declare const th: any;
|
|
13
|
+
export declare const td: any;
|
|
14
|
+
export declare const code: any;
|
|
15
|
+
export declare const a: any;
|
|
16
|
+
export declare const p: any;
|
|
17
|
+
export declare const ul: any;
|
|
18
|
+
export declare const ol: any;
|
package/builtins/index.js
CHANGED
|
@@ -101,7 +101,7 @@ function styled(tag) {
|
|
|
101
101
|
}
|
|
102
102
|
const render = (props, ref) => {
|
|
103
103
|
const { as: component = tag, class: className = mockedClass } = props;
|
|
104
|
-
const shouldKeepProps = options.propsAsIs ===
|
|
104
|
+
const shouldKeepProps = options.propsAsIs === undefined ? !(typeof component === "string" && component.indexOf("-") === -1 && !isCapital(component[0])) : options.propsAsIs;
|
|
105
105
|
const filteredProps = filterProps(shouldKeepProps, props, [
|
|
106
106
|
"as",
|
|
107
107
|
"class"
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "timvir",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.34",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"exports": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"downshift": "^7 || ^8 || ^9",
|
|
21
21
|
"fuzzaldrin-plus": "^0.6.0",
|
|
22
22
|
"immer": "^9 || ^10",
|
|
23
|
-
"shiki": "^1",
|
|
23
|
+
"shiki": "^1 || ^2",
|
|
24
24
|
"react-feather": "^2",
|
|
25
25
|
"use-immer": "^0.8.0 || ^0.8.1 || ^0.9.0 || ^0.10.0 || ^0.11.0",
|
|
26
26
|
"wonka": "^6"
|