@potch/html-bin 1.0.0 → 1.1.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/index.html +1 -2
- package/package.json +6 -3
- package/rollup.config.js +16 -2
- package/src/index.js +9 -0
- package/src/style.css +0 -33
package/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Document</title>
|
|
7
7
|
<script defer type="module">
|
|
8
|
-
import { createBin } from "/build/index.js";
|
|
8
|
+
import { createBin } from "/build/index.min.js";
|
|
9
9
|
window.bin = createBin({
|
|
10
10
|
container: document.body,
|
|
11
11
|
sources: {
|
|
@@ -29,7 +29,6 @@ setInterval(() => {
|
|
|
29
29
|
height: "512px",
|
|
30
30
|
});
|
|
31
31
|
</script>
|
|
32
|
-
<link rel="stylesheet" href="src/style.css" />
|
|
33
32
|
</head>
|
|
34
33
|
<body></body>
|
|
35
34
|
</html>
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@potch/html-bin",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "",
|
|
5
|
-
"main": "index.js",
|
|
5
|
+
"main": "src/index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
@@ -23,11 +23,14 @@
|
|
|
23
23
|
"@codemirror/view": "^6.36.8",
|
|
24
24
|
"@potch/minifw": "^3.1.1",
|
|
25
25
|
"@rollup/plugin-terser": "^0.4.4",
|
|
26
|
-
"@uiw/codemirror-theme-dracula": "^4.23.12"
|
|
26
|
+
"@uiw/codemirror-theme-dracula": "^4.23.12",
|
|
27
|
+
"rollup-plugin-import-css": "^4.0.1"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
29
30
|
"@potch/tinyserve": "^1.5.1",
|
|
30
31
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
32
|
+
"cssnano": "^7.0.7",
|
|
33
|
+
"postcss": "^8.5.4",
|
|
31
34
|
"rollup": "^4.40.2"
|
|
32
35
|
}
|
|
33
36
|
}
|
package/rollup.config.js
CHANGED
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
import { nodeResolve } from "@rollup/plugin-node-resolve";
|
|
2
|
+
import postcss from "postcss";
|
|
3
|
+
import cssnano from "cssnano";
|
|
4
|
+
import css from "rollup-plugin-import-css";
|
|
2
5
|
import terser from "@rollup/plugin-terser";
|
|
3
6
|
|
|
4
7
|
export default {
|
|
5
8
|
input: "src/index.js",
|
|
6
9
|
output: {
|
|
7
10
|
sourcemap: true,
|
|
8
|
-
|
|
11
|
+
file: "build/index.min.js",
|
|
9
12
|
format: "es",
|
|
10
13
|
},
|
|
11
|
-
plugins: [
|
|
14
|
+
plugins: [
|
|
15
|
+
nodeResolve(),
|
|
16
|
+
css({
|
|
17
|
+
transform: async (source) => {
|
|
18
|
+
const result = await postcss([cssnano()]).process(source, {
|
|
19
|
+
from: undefined,
|
|
20
|
+
});
|
|
21
|
+
return result.css;
|
|
22
|
+
},
|
|
23
|
+
}),
|
|
24
|
+
terser(),
|
|
25
|
+
],
|
|
12
26
|
};
|
package/src/index.js
CHANGED
|
@@ -55,6 +55,10 @@ import {
|
|
|
55
55
|
on as _on,
|
|
56
56
|
} from "@potch/minifw";
|
|
57
57
|
|
|
58
|
+
import styles from "./style.css";
|
|
59
|
+
|
|
60
|
+
let injectedStyles = null;
|
|
61
|
+
|
|
58
62
|
const getLeft = (el) => (el ? el.offsetLeft + getLeft(el.offsetParent) : 0);
|
|
59
63
|
const getTop = (el) => (el ? el.offsetTop + getTop(el.offsetParent) : 0);
|
|
60
64
|
|
|
@@ -82,6 +86,11 @@ export const createBin = ({
|
|
|
82
86
|
width,
|
|
83
87
|
height,
|
|
84
88
|
}) => {
|
|
89
|
+
if (!injectedStyles) {
|
|
90
|
+
injectedStyles = _("style", {}, styles);
|
|
91
|
+
document.head.append(injectedStyles);
|
|
92
|
+
}
|
|
93
|
+
|
|
85
94
|
const editorSplit = signal(parseFloat(split) || 0.5);
|
|
86
95
|
|
|
87
96
|
const teardownFns = [];
|
package/src/style.css
CHANGED
|
@@ -325,36 +325,3 @@
|
|
|
325
325
|
.tok-important {
|
|
326
326
|
color: #ffb86c;
|
|
327
327
|
}
|
|
328
|
-
|
|
329
|
-
/*
|
|
330
|
-
.tok-link
|
|
331
|
-
.tok-heading
|
|
332
|
-
.tok-emphasis
|
|
333
|
-
.tok-strong
|
|
334
|
-
.tok-keyword
|
|
335
|
-
.tok-atom
|
|
336
|
-
.tok-bool
|
|
337
|
-
.tok-url
|
|
338
|
-
.tok-labelName
|
|
339
|
-
.tok-inserted
|
|
340
|
-
.tok-deleted
|
|
341
|
-
.tok-literal
|
|
342
|
-
.tok-string
|
|
343
|
-
.tok-number
|
|
344
|
-
.tok-string2
|
|
345
|
-
.tok-variableName
|
|
346
|
-
.tok-variableName.tok-local
|
|
347
|
-
.tok-variableName.tok-definition
|
|
348
|
-
.tok-variableName2
|
|
349
|
-
.tok-propertyName.tok-definition
|
|
350
|
-
.tok-typeName
|
|
351
|
-
.tok-namespace
|
|
352
|
-
.tok-className
|
|
353
|
-
.tok-macroName
|
|
354
|
-
.tok-propertyName
|
|
355
|
-
.tok-operator
|
|
356
|
-
.tok-comment
|
|
357
|
-
.tok-meta
|
|
358
|
-
.tok-invalid
|
|
359
|
-
.tok-punctuation
|
|
360
|
-
*/
|