image-to-pixel 3.0.0 → 3.0.1
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/LICENSE +21 -21
- package/README.md +69 -69
- package/dist/editor.css.map +1 -1
- package/dist/editor.esm.js +1 -1
- package/dist/editor.esm.js.map +1 -1
- package/dist/fonts/README.md +6 -6
- package/dist/fonts/geist-LICENSE.txt +93 -93
- package/dist/image-to-pixel.bundle.esm.js +13 -13
- package/dist/image-to-pixel.bundle.esm.js.map +2 -2
- package/dist/image-to-pixel.cjs +2 -2
- package/dist/image-to-pixel.cjs.map +2 -2
- package/dist/image-to-pixel.esm.js +2 -2
- package/dist/image-to-pixel.esm.js.map +2 -2
- package/dist/image-to-pixel.js +2 -2
- package/dist/image-to-pixel.js.map +2 -2
- package/dist/image-to-pixel.min.js +11 -11
- package/dist/image-to-pixel.min.js.map +2 -2
- package/dist/video.esm.js +1 -1
- package/dist/video.esm.js.map +1 -1
- package/lib/core/color.js +69 -69
- package/lib/core/cpu/pipeline.js +21 -21
- package/lib/core/cpu/stages.js +227 -227
- package/lib/core/dither/bluenoise-data.js +3 -3
- package/lib/core/dither/kernels.js +27 -27
- package/lib/core/dither/matrices.js +95 -95
- package/lib/core/engine.js +158 -158
- package/lib/core/export/canvas.js +22 -22
- package/lib/core/export/crc32.js +15 -15
- package/lib/core/export/gif.js +153 -153
- package/lib/core/export/png.js +94 -94
- package/lib/core/export/scale.js +103 -103
- package/lib/core/export/sheet.js +95 -95
- package/lib/core/export/zip.js +55 -55
- package/lib/core/gpu/backend.js +159 -159
- package/lib/core/gpu/shaders.js +258 -258
- package/lib/core/palette/builtin.js +36 -36
- package/lib/core/palette/extract.js +69 -69
- package/lib/core/palette/lospec.js +24 -24
- package/lib/core/palette/parse.js +112 -112
- package/lib/core/plan.js +58 -58
- package/lib/core/presets.js +42 -42
- package/lib/core/settings.js +274 -274
- package/lib/core/source.js +89 -89
- package/lib/core/video/frames.js +144 -144
- package/lib/core/video/mux-mp4.js +131 -131
- package/lib/core/video/mux-webm.js +127 -127
- package/lib/editor/controls.js +139 -139
- package/lib/editor/dom.js +65 -65
- package/lib/editor/exporter.js +185 -185
- package/lib/editor/icons.js +61 -61
- package/lib/editor/index.js +793 -793
- package/lib/editor/inspector.js +328 -328
- package/lib/editor/library.js +182 -182
- package/lib/editor/persist.js +18 -18
- package/lib/editor/samples.js +90 -90
- package/lib/editor/stage.js +239 -239
- package/lib/editor/store.js +80 -80
- package/lib/editor/styles/editor.css +385 -385
- package/lib/editor/styles/fonts/README.md +6 -6
- package/lib/editor/styles/fonts/geist-LICENSE.txt +93 -93
- package/lib/editor/styles/tokens.css +89 -89
- package/lib/editor/ui.js +97 -97
- package/lib/index.js +3 -1
- package/lib/video.js +92 -92
- package/package.json +92 -92
- package/types/editor.d.ts +34 -34
- package/types/index.d.ts +196 -196
- package/types/video.d.ts +43 -43
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Fonts are self-hosted (no third-party requests). All of these are licensed under the SIL Open Font License 1.1.
|
|
2
|
-
|
|
3
|
-
- Geist, by Vercel. https://github.com/vercel/geist-font
|
|
4
|
-
- JetBrains Mono, by JetBrains. https://github.com/JetBrains/JetBrainsMono
|
|
5
|
-
|
|
6
|
-
Latin subsets of the variable builds, via Fontsource (https://fontsource.org).
|
|
1
|
+
Fonts are self-hosted (no third-party requests). All of these are licensed under the SIL Open Font License 1.1.
|
|
2
|
+
|
|
3
|
+
- Geist, by Vercel. https://github.com/vercel/geist-font
|
|
4
|
+
- JetBrains Mono, by JetBrains. https://github.com/JetBrains/JetBrainsMono
|
|
5
|
+
|
|
6
|
+
Latin subsets of the variable builds, via Fontsource (https://fontsource.org).
|
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) Geist-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
|
|
2
|
-
|
|
3
|
-
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
-
This license is copied below, and is also available with a FAQ at:
|
|
5
|
-
http://scripts.sil.org/OFL
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
-----------------------------------------------------------
|
|
9
|
-
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
-
-----------------------------------------------------------
|
|
11
|
-
|
|
12
|
-
PREAMBLE
|
|
13
|
-
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
-
development of collaborative font projects, to support the font creation
|
|
15
|
-
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
-
open framework in which fonts may be shared and improved in partnership
|
|
17
|
-
with others.
|
|
18
|
-
|
|
19
|
-
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
-
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
-
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
-
redistributed and/or sold with any software provided that any reserved
|
|
23
|
-
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
-
however, cannot be released under any other type of license. The
|
|
25
|
-
requirement for fonts to remain under this license does not apply
|
|
26
|
-
to any document created using the fonts or their derivatives.
|
|
27
|
-
|
|
28
|
-
DEFINITIONS
|
|
29
|
-
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
-
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
-
include source files, build scripts and documentation.
|
|
32
|
-
|
|
33
|
-
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
-
copyright statement(s).
|
|
35
|
-
|
|
36
|
-
"Original Version" refers to the collection of Font Software components as
|
|
37
|
-
distributed by the Copyright Holder(s).
|
|
38
|
-
|
|
39
|
-
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
-
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
-
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
-
new environment.
|
|
43
|
-
|
|
44
|
-
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
-
writer or other person who contributed to the Font Software.
|
|
46
|
-
|
|
47
|
-
PERMISSION & CONDITIONS
|
|
48
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
-
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
-
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
-
Software, subject to the following conditions:
|
|
52
|
-
|
|
53
|
-
1) Neither the Font Software nor any of its individual components,
|
|
54
|
-
in Original or Modified Versions, may be sold by itself.
|
|
55
|
-
|
|
56
|
-
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
-
redistributed and/or sold with any software, provided that each copy
|
|
58
|
-
contains the above copyright notice and this license. These can be
|
|
59
|
-
included either as stand-alone text files, human-readable headers or
|
|
60
|
-
in the appropriate machine-readable metadata fields within text or
|
|
61
|
-
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
-
|
|
63
|
-
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
-
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
-
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
-
presented to the users.
|
|
67
|
-
|
|
68
|
-
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
-
Software shall not be used to promote, endorse or advertise any
|
|
70
|
-
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
-
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
-
permission.
|
|
73
|
-
|
|
74
|
-
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
-
must be distributed entirely under this license, and must not be
|
|
76
|
-
distributed under any other license. The requirement for fonts to
|
|
77
|
-
remain under this license does not apply to any document created
|
|
78
|
-
using the Font Software.
|
|
79
|
-
|
|
80
|
-
TERMINATION
|
|
81
|
-
This license becomes null and void if any of the above conditions are
|
|
82
|
-
not met.
|
|
83
|
-
|
|
84
|
-
DISCLAIMER
|
|
85
|
-
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
-
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
-
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
-
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
-
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
-
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
-
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
1
|
+
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font) Geist-Italic[wght].ttf: Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)
|
|
2
|
+
|
|
3
|
+
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
|
4
|
+
This license is copied below, and is also available with a FAQ at:
|
|
5
|
+
http://scripts.sil.org/OFL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
-----------------------------------------------------------
|
|
9
|
+
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
|
10
|
+
-----------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
PREAMBLE
|
|
13
|
+
The goals of the Open Font License (OFL) are to stimulate worldwide
|
|
14
|
+
development of collaborative font projects, to support the font creation
|
|
15
|
+
efforts of academic and linguistic communities, and to provide a free and
|
|
16
|
+
open framework in which fonts may be shared and improved in partnership
|
|
17
|
+
with others.
|
|
18
|
+
|
|
19
|
+
The OFL allows the licensed fonts to be used, studied, modified and
|
|
20
|
+
redistributed freely as long as they are not sold by themselves. The
|
|
21
|
+
fonts, including any derivative works, can be bundled, embedded,
|
|
22
|
+
redistributed and/or sold with any software provided that any reserved
|
|
23
|
+
names are not used by derivative works. The fonts and derivatives,
|
|
24
|
+
however, cannot be released under any other type of license. The
|
|
25
|
+
requirement for fonts to remain under this license does not apply
|
|
26
|
+
to any document created using the fonts or their derivatives.
|
|
27
|
+
|
|
28
|
+
DEFINITIONS
|
|
29
|
+
"Font Software" refers to the set of files released by the Copyright
|
|
30
|
+
Holder(s) under this license and clearly marked as such. This may
|
|
31
|
+
include source files, build scripts and documentation.
|
|
32
|
+
|
|
33
|
+
"Reserved Font Name" refers to any names specified as such after the
|
|
34
|
+
copyright statement(s).
|
|
35
|
+
|
|
36
|
+
"Original Version" refers to the collection of Font Software components as
|
|
37
|
+
distributed by the Copyright Holder(s).
|
|
38
|
+
|
|
39
|
+
"Modified Version" refers to any derivative made by adding to, deleting,
|
|
40
|
+
or substituting -- in part or in whole -- any of the components of the
|
|
41
|
+
Original Version, by changing formats or by porting the Font Software to a
|
|
42
|
+
new environment.
|
|
43
|
+
|
|
44
|
+
"Author" refers to any designer, engineer, programmer, technical
|
|
45
|
+
writer or other person who contributed to the Font Software.
|
|
46
|
+
|
|
47
|
+
PERMISSION & CONDITIONS
|
|
48
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
49
|
+
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
|
50
|
+
redistribute, and sell modified and unmodified copies of the Font
|
|
51
|
+
Software, subject to the following conditions:
|
|
52
|
+
|
|
53
|
+
1) Neither the Font Software nor any of its individual components,
|
|
54
|
+
in Original or Modified Versions, may be sold by itself.
|
|
55
|
+
|
|
56
|
+
2) Original or Modified Versions of the Font Software may be bundled,
|
|
57
|
+
redistributed and/or sold with any software, provided that each copy
|
|
58
|
+
contains the above copyright notice and this license. These can be
|
|
59
|
+
included either as stand-alone text files, human-readable headers or
|
|
60
|
+
in the appropriate machine-readable metadata fields within text or
|
|
61
|
+
binary files as long as those fields can be easily viewed by the user.
|
|
62
|
+
|
|
63
|
+
3) No Modified Version of the Font Software may use the Reserved Font
|
|
64
|
+
Name(s) unless explicit written permission is granted by the corresponding
|
|
65
|
+
Copyright Holder. This restriction only applies to the primary font name as
|
|
66
|
+
presented to the users.
|
|
67
|
+
|
|
68
|
+
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
|
69
|
+
Software shall not be used to promote, endorse or advertise any
|
|
70
|
+
Modified Version, except to acknowledge the contribution(s) of the
|
|
71
|
+
Copyright Holder(s) and the Author(s) or with their explicit written
|
|
72
|
+
permission.
|
|
73
|
+
|
|
74
|
+
5) The Font Software, modified or unmodified, in part or in whole,
|
|
75
|
+
must be distributed entirely under this license, and must not be
|
|
76
|
+
distributed under any other license. The requirement for fonts to
|
|
77
|
+
remain under this license does not apply to any document created
|
|
78
|
+
using the Font Software.
|
|
79
|
+
|
|
80
|
+
TERMINATION
|
|
81
|
+
This license becomes null and void if any of the above conditions are
|
|
82
|
+
not met.
|
|
83
|
+
|
|
84
|
+
DISCLAIMER
|
|
85
|
+
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
86
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
|
87
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
|
88
|
+
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
|
89
|
+
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
|
90
|
+
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
|
91
|
+
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
92
|
+
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
|
93
|
+
OTHER DEALINGS IN THE FONT SOFTWARE.
|
|
@@ -1,89 +1,89 @@
|
|
|
1
|
-
/* Design tokens shared by the editor and the site. Dark is the default; light via
|
|
2
|
-
[data-theme="light"] or the OS preference when no explicit theme is set. */
|
|
3
|
-
|
|
4
|
-
@font-face { font-family: "Geist"; src: url("fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
5
|
-
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; }
|
|
6
|
-
|
|
7
|
-
:root {
|
|
8
|
-
--font-ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
9
|
-
--font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
10
|
-
|
|
11
|
-
--r-sm: 6px;
|
|
12
|
-
--r-md: 8px;
|
|
13
|
-
--r-lg: 10px;
|
|
14
|
-
|
|
15
|
-
--fs-xs: 11px;
|
|
16
|
-
--fs-sm: 12px;
|
|
17
|
-
--fs-md: 13px;
|
|
18
|
-
--fs-lg: 15px;
|
|
19
|
-
--fs-xl: 20px;
|
|
20
|
-
|
|
21
|
-
--ease: cubic-bezier(.2, .7, .2, 1);
|
|
22
|
-
--dur: 140ms;
|
|
23
|
-
|
|
24
|
-
/* dark */
|
|
25
|
-
color-scheme: dark;
|
|
26
|
-
--bg: #111214;
|
|
27
|
-
--stage: #0d0e10;
|
|
28
|
-
--panel: #16171a;
|
|
29
|
-
--raised: #1d1e22;
|
|
30
|
-
--raised-2: #24252a;
|
|
31
|
-
--line: #26272c;
|
|
32
|
-
--line-strong: #33343a;
|
|
33
|
-
--text: #e6e6e9;
|
|
34
|
-
--text-2: #b4b5bc;
|
|
35
|
-
--muted: #84868f;
|
|
36
|
-
--faint: #5d5f68;
|
|
37
|
-
--accent: #8f80f5;
|
|
38
|
-
--accent-strong: #a395ff;
|
|
39
|
-
--accent-ink: #0f0d1f;
|
|
40
|
-
--accent-soft: rgba(143, 128, 245, 0.16);
|
|
41
|
-
--ok: #5fc48a;
|
|
42
|
-
--warn: #e3b55b;
|
|
43
|
-
--danger: #ec6a6a;
|
|
44
|
-
--checker-a: #1a1b1f;
|
|
45
|
-
--checker-b: #222328;
|
|
46
|
-
--shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line-strong);
|
|
47
|
-
--focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
:root[data-theme="light"] {
|
|
51
|
-
color-scheme: light;
|
|
52
|
-
--bg: #f5f5f6;
|
|
53
|
-
--stage: #ececee;
|
|
54
|
-
--panel: #ffffff;
|
|
55
|
-
--raised: #f2f2f4;
|
|
56
|
-
--raised-2: #e9e9ec;
|
|
57
|
-
--line: #e4e4e8;
|
|
58
|
-
--line-strong: #d4d4da;
|
|
59
|
-
--text: #18181b;
|
|
60
|
-
--text-2: #3f4047;
|
|
61
|
-
--muted: #6b6d76;
|
|
62
|
-
--faint: #9a9ca4;
|
|
63
|
-
--accent: #6553d6;
|
|
64
|
-
--accent-strong: #5442c4;
|
|
65
|
-
--accent-ink: #ffffff;
|
|
66
|
-
--accent-soft: rgba(101, 83, 214, 0.11);
|
|
67
|
-
--ok: #2f9a5e;
|
|
68
|
-
--warn: #b7841f;
|
|
69
|
-
--danger: #cf4040;
|
|
70
|
-
--checker-a: #e4e4e8;
|
|
71
|
-
--checker-b: #f4f4f6;
|
|
72
|
-
--shadow-pop: 0 12px 32px rgba(20, 20, 40, 0.14), 0 0 0 1px var(--line-strong);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
@media (prefers-color-scheme: light) {
|
|
76
|
-
:root:not([data-theme="dark"]):not([data-theme="light"]) {
|
|
77
|
-
color-scheme: light;
|
|
78
|
-
--bg: #f5f5f6; --stage: #ececee; --panel: #ffffff; --raised: #f2f2f4; --raised-2: #e9e9ec;
|
|
79
|
-
--line: #e4e4e8; --line-strong: #d4d4da; --text: #18181b; --text-2: #3f4047; --muted: #6b6d76; --faint: #9a9ca4;
|
|
80
|
-
--accent: #6553d6; --accent-strong: #5442c4; --accent-ink: #ffffff; --accent-soft: rgba(101, 83, 214, 0.11);
|
|
81
|
-
--ok: #2f9a5e; --warn: #b7841f; --danger: #cf4040; --checker-a: #e4e4e8; --checker-b: #f4f4f6;
|
|
82
|
-
--shadow-pop: 0 12px 32px rgba(20, 20, 40, 0.14), 0 0 0 1px var(--line-strong);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@media (prefers-reduced-motion: reduce) {
|
|
87
|
-
:root { --dur: 0ms; }
|
|
88
|
-
*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
|
|
89
|
-
}
|
|
1
|
+
/* Design tokens shared by the editor and the site. Dark is the default; light via
|
|
2
|
+
[data-theme="light"] or the OS preference when no explicit theme is set. */
|
|
3
|
+
|
|
4
|
+
@font-face { font-family: "Geist"; src: url("fonts/geist.woff2") format("woff2"); font-weight: 100 900; font-style: normal; font-display: swap; }
|
|
5
|
+
@font-face { font-family: "JetBrains Mono"; src: url("fonts/jetbrains-mono.woff2") format("woff2"); font-weight: 100 800; font-style: normal; font-display: swap; }
|
|
6
|
+
|
|
7
|
+
:root {
|
|
8
|
+
--font-ui: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
|
|
9
|
+
--font-mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
|
|
10
|
+
|
|
11
|
+
--r-sm: 6px;
|
|
12
|
+
--r-md: 8px;
|
|
13
|
+
--r-lg: 10px;
|
|
14
|
+
|
|
15
|
+
--fs-xs: 11px;
|
|
16
|
+
--fs-sm: 12px;
|
|
17
|
+
--fs-md: 13px;
|
|
18
|
+
--fs-lg: 15px;
|
|
19
|
+
--fs-xl: 20px;
|
|
20
|
+
|
|
21
|
+
--ease: cubic-bezier(.2, .7, .2, 1);
|
|
22
|
+
--dur: 140ms;
|
|
23
|
+
|
|
24
|
+
/* dark */
|
|
25
|
+
color-scheme: dark;
|
|
26
|
+
--bg: #111214;
|
|
27
|
+
--stage: #0d0e10;
|
|
28
|
+
--panel: #16171a;
|
|
29
|
+
--raised: #1d1e22;
|
|
30
|
+
--raised-2: #24252a;
|
|
31
|
+
--line: #26272c;
|
|
32
|
+
--line-strong: #33343a;
|
|
33
|
+
--text: #e6e6e9;
|
|
34
|
+
--text-2: #b4b5bc;
|
|
35
|
+
--muted: #84868f;
|
|
36
|
+
--faint: #5d5f68;
|
|
37
|
+
--accent: #8f80f5;
|
|
38
|
+
--accent-strong: #a395ff;
|
|
39
|
+
--accent-ink: #0f0d1f;
|
|
40
|
+
--accent-soft: rgba(143, 128, 245, 0.16);
|
|
41
|
+
--ok: #5fc48a;
|
|
42
|
+
--warn: #e3b55b;
|
|
43
|
+
--danger: #ec6a6a;
|
|
44
|
+
--checker-a: #1a1b1f;
|
|
45
|
+
--checker-b: #222328;
|
|
46
|
+
--shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 1px var(--line-strong);
|
|
47
|
+
--focus: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
:root[data-theme="light"] {
|
|
51
|
+
color-scheme: light;
|
|
52
|
+
--bg: #f5f5f6;
|
|
53
|
+
--stage: #ececee;
|
|
54
|
+
--panel: #ffffff;
|
|
55
|
+
--raised: #f2f2f4;
|
|
56
|
+
--raised-2: #e9e9ec;
|
|
57
|
+
--line: #e4e4e8;
|
|
58
|
+
--line-strong: #d4d4da;
|
|
59
|
+
--text: #18181b;
|
|
60
|
+
--text-2: #3f4047;
|
|
61
|
+
--muted: #6b6d76;
|
|
62
|
+
--faint: #9a9ca4;
|
|
63
|
+
--accent: #6553d6;
|
|
64
|
+
--accent-strong: #5442c4;
|
|
65
|
+
--accent-ink: #ffffff;
|
|
66
|
+
--accent-soft: rgba(101, 83, 214, 0.11);
|
|
67
|
+
--ok: #2f9a5e;
|
|
68
|
+
--warn: #b7841f;
|
|
69
|
+
--danger: #cf4040;
|
|
70
|
+
--checker-a: #e4e4e8;
|
|
71
|
+
--checker-b: #f4f4f6;
|
|
72
|
+
--shadow-pop: 0 12px 32px rgba(20, 20, 40, 0.14), 0 0 0 1px var(--line-strong);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
@media (prefers-color-scheme: light) {
|
|
76
|
+
:root:not([data-theme="dark"]):not([data-theme="light"]) {
|
|
77
|
+
color-scheme: light;
|
|
78
|
+
--bg: #f5f5f6; --stage: #ececee; --panel: #ffffff; --raised: #f2f2f4; --raised-2: #e9e9ec;
|
|
79
|
+
--line: #e4e4e8; --line-strong: #d4d4da; --text: #18181b; --text-2: #3f4047; --muted: #6b6d76; --faint: #9a9ca4;
|
|
80
|
+
--accent: #6553d6; --accent-strong: #5442c4; --accent-ink: #ffffff; --accent-soft: rgba(101, 83, 214, 0.11);
|
|
81
|
+
--ok: #2f9a5e; --warn: #b7841f; --danger: #cf4040; --checker-a: #e4e4e8; --checker-b: #f4f4f6;
|
|
82
|
+
--shadow-pop: 0 12px 32px rgba(20, 20, 40, 0.14), 0 0 0 1px var(--line-strong);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@media (prefers-reduced-motion: reduce) {
|
|
87
|
+
:root { --dur: 0ms; }
|
|
88
|
+
*, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
|
|
89
|
+
}
|
package/lib/editor/ui.js
CHANGED
|
@@ -1,97 +1,97 @@
|
|
|
1
|
-
// Menus, dialogs and toasts.
|
|
2
|
-
|
|
3
|
-
import { h, render } from './dom.js';
|
|
4
|
-
import { icon } from './icons.js';
|
|
5
|
-
|
|
6
|
-
let toastHost = null;
|
|
7
|
-
const host = () => (toastHost ||= document.body.appendChild(h('div.itp-toasts.itp', { role: 'status', 'aria-live': 'polite' })));
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Show a toast. Returns { update(msg), progress(0..1), close() }.
|
|
11
|
-
* @param {string} msg
|
|
12
|
-
* @param {{ kind?: 'info'|'ok'|'error', timeout?: number, action?: { label, onClick }, progress?: boolean, onCancel?: () => void }} [o]
|
|
13
|
-
*/
|
|
14
|
-
export function toast(msg, o = {}) {
|
|
15
|
-
const kind = o.kind || 'info';
|
|
16
|
-
const text = h('div.msg', {}, h('div', { text: msg }));
|
|
17
|
-
const bar = o.progress ? h('div.itp-progress', {}, h('i')) : null;
|
|
18
|
-
if (bar) text.append(bar);
|
|
19
|
-
const el = h(`div.itp-toast.${kind}`, {}, o.progress ? h('div.itp-spinner') : h('span.itp-dot'), text);
|
|
20
|
-
if (o.action) el.append(h('button.itp-btn.small.outline', { type: 'button', text: o.action.label, onclick: () => { o.action.onClick(); close(); } }));
|
|
21
|
-
if (o.onCancel) el.append(h('button.itp-btn.small', { type: 'button', text: 'Cancel', onclick: () => { o.onCancel(); close(); } }));
|
|
22
|
-
else el.append(h('button.itp-btn.small.icon', { type: 'button', 'aria-label': 'Dismiss', html: icon('x'), onclick: () => close() }));
|
|
23
|
-
host().append(el);
|
|
24
|
-
let timer = null;
|
|
25
|
-
const close = () => { clearTimeout(timer); el.remove(); };
|
|
26
|
-
const arm = ms => { clearTimeout(timer); if (ms) timer = setTimeout(close, ms); };
|
|
27
|
-
arm(o.timeout ?? (o.progress ? 0 : kind === 'error' ? 7000 : 3200));
|
|
28
|
-
return {
|
|
29
|
-
update(m) { text.firstChild.textContent = m; },
|
|
30
|
-
progress(p) { if (bar) bar.firstChild.style.width = `${Math.round(p * 100)}%`; },
|
|
31
|
-
close,
|
|
32
|
-
done(m, k = 'ok') { close(); toast(m, { kind: k }); },
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let openMenu = null;
|
|
37
|
-
/**
|
|
38
|
-
* Popover menu anchored to a button.
|
|
39
|
-
* items: [{ label, sub?, icon?, kbd?, onClick, disabled? } | 'sep' | { group: 'Label' }]
|
|
40
|
-
*/
|
|
41
|
-
export function menu(anchor, items, { align = 'end' } = {}) {
|
|
42
|
-
closeMenu();
|
|
43
|
-
const el = h('div.itp-menu.itp', { role: 'menu' });
|
|
44
|
-
for (const it of items) {
|
|
45
|
-
if (it === 'sep') { el.append(h('hr')); continue; }
|
|
46
|
-
if (it.group) { el.append(h('div.mlabel', { text: it.group })); continue; }
|
|
47
|
-
const b = h('button.mi', { type: 'button', role: 'menuitem', disabled: !!it.disabled },
|
|
48
|
-
h('span', { html: it.icon ? icon(it.icon) : '' }),
|
|
49
|
-
h('span', {}, it.label, it.sub ? h('small', { text: it.sub }) : null),
|
|
50
|
-
it.kbd ? h('kbd', { text: it.kbd }) : h('span'));
|
|
51
|
-
b.addEventListener('click', () => { closeMenu(); it.onClick(); });
|
|
52
|
-
el.append(b);
|
|
53
|
-
}
|
|
54
|
-
document.body.append(el);
|
|
55
|
-
const r = anchor.getBoundingClientRect();
|
|
56
|
-
const mw = el.offsetWidth, mh = el.offsetHeight;
|
|
57
|
-
let left = align === 'end' ? r.right - mw : r.left;
|
|
58
|
-
left = Math.max(8, Math.min(left, innerWidth - mw - 8));
|
|
59
|
-
let top = r.bottom + 6;
|
|
60
|
-
if (top + mh > innerHeight - 8) top = Math.max(8, r.top - mh - 6);
|
|
61
|
-
Object.assign(el.style, { left: `${left}px`, top: `${top}px` });
|
|
62
|
-
anchor.setAttribute('aria-expanded', 'true');
|
|
63
|
-
const buttons = [...el.querySelectorAll('button.mi:not(:disabled)')];
|
|
64
|
-
buttons[0]?.focus();
|
|
65
|
-
const onKey = e => {
|
|
66
|
-
const i = buttons.indexOf(document.activeElement);
|
|
67
|
-
if (e.key === 'Escape') { e.preventDefault(); closeMenu(); anchor.focus(); }
|
|
68
|
-
else if (e.key === 'ArrowDown') { e.preventDefault(); buttons[(i + 1) % buttons.length]?.focus(); }
|
|
69
|
-
else if (e.key === 'ArrowUp') { e.preventDefault(); buttons[(i - 1 + buttons.length) % buttons.length]?.focus(); }
|
|
70
|
-
else if (e.key === 'Tab') closeMenu();
|
|
71
|
-
};
|
|
72
|
-
const onDown = e => { if (!el.contains(e.target) && e.target !== anchor && !anchor.contains(e.target)) closeMenu(); };
|
|
73
|
-
el.addEventListener('keydown', onKey);
|
|
74
|
-
setTimeout(() => document.addEventListener('pointerdown', onDown, true));
|
|
75
|
-
openMenu = { el, anchor, cleanup: () => document.removeEventListener('pointerdown', onDown, true) };
|
|
76
|
-
}
|
|
77
|
-
export function closeMenu() {
|
|
78
|
-
if (!openMenu) return;
|
|
79
|
-
openMenu.cleanup(); openMenu.el.remove(); openMenu.anchor.setAttribute('aria-expanded', 'false');
|
|
80
|
-
openMenu = null;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/** Modal dialog. Returns the <dialog>; content can be updated with render(). */
|
|
84
|
-
export function dialog(title, content, { actions = [], onClose } = {}) {
|
|
85
|
-
const body = h('div.content', {}, content);
|
|
86
|
-
const d = h('dialog.itp-dialog.itp', { 'aria-label': title },
|
|
87
|
-
h('header', {}, h('h2', { text: title }), h('button.itp-btn.icon', { type: 'button', 'aria-label': 'Close', html: icon('x'), onclick: () => d.close() })),
|
|
88
|
-
body,
|
|
89
|
-
actions.length ? h('footer', {}, ...actions.map(a => h(`button.itp-btn${a.primary ? '.primary' : '.outline'}`, { type: 'button', text: a.label, onclick: async () => { if ((await a.onClick?.()) !== false) d.close(); } }))) : null,
|
|
90
|
-
);
|
|
91
|
-
d.addEventListener('close', () => { d.remove(); onClose?.(); });
|
|
92
|
-
document.body.append(d);
|
|
93
|
-
d.showModal();
|
|
94
|
-
d.body = body;
|
|
95
|
-
d.setContent = (...c) => render(body, ...c);
|
|
96
|
-
return d;
|
|
97
|
-
}
|
|
1
|
+
// Menus, dialogs and toasts.
|
|
2
|
+
|
|
3
|
+
import { h, render } from './dom.js';
|
|
4
|
+
import { icon } from './icons.js';
|
|
5
|
+
|
|
6
|
+
let toastHost = null;
|
|
7
|
+
const host = () => (toastHost ||= document.body.appendChild(h('div.itp-toasts.itp', { role: 'status', 'aria-live': 'polite' })));
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Show a toast. Returns { update(msg), progress(0..1), close() }.
|
|
11
|
+
* @param {string} msg
|
|
12
|
+
* @param {{ kind?: 'info'|'ok'|'error', timeout?: number, action?: { label, onClick }, progress?: boolean, onCancel?: () => void }} [o]
|
|
13
|
+
*/
|
|
14
|
+
export function toast(msg, o = {}) {
|
|
15
|
+
const kind = o.kind || 'info';
|
|
16
|
+
const text = h('div.msg', {}, h('div', { text: msg }));
|
|
17
|
+
const bar = o.progress ? h('div.itp-progress', {}, h('i')) : null;
|
|
18
|
+
if (bar) text.append(bar);
|
|
19
|
+
const el = h(`div.itp-toast.${kind}`, {}, o.progress ? h('div.itp-spinner') : h('span.itp-dot'), text);
|
|
20
|
+
if (o.action) el.append(h('button.itp-btn.small.outline', { type: 'button', text: o.action.label, onclick: () => { o.action.onClick(); close(); } }));
|
|
21
|
+
if (o.onCancel) el.append(h('button.itp-btn.small', { type: 'button', text: 'Cancel', onclick: () => { o.onCancel(); close(); } }));
|
|
22
|
+
else el.append(h('button.itp-btn.small.icon', { type: 'button', 'aria-label': 'Dismiss', html: icon('x'), onclick: () => close() }));
|
|
23
|
+
host().append(el);
|
|
24
|
+
let timer = null;
|
|
25
|
+
const close = () => { clearTimeout(timer); el.remove(); };
|
|
26
|
+
const arm = ms => { clearTimeout(timer); if (ms) timer = setTimeout(close, ms); };
|
|
27
|
+
arm(o.timeout ?? (o.progress ? 0 : kind === 'error' ? 7000 : 3200));
|
|
28
|
+
return {
|
|
29
|
+
update(m) { text.firstChild.textContent = m; },
|
|
30
|
+
progress(p) { if (bar) bar.firstChild.style.width = `${Math.round(p * 100)}%`; },
|
|
31
|
+
close,
|
|
32
|
+
done(m, k = 'ok') { close(); toast(m, { kind: k }); },
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let openMenu = null;
|
|
37
|
+
/**
|
|
38
|
+
* Popover menu anchored to a button.
|
|
39
|
+
* items: [{ label, sub?, icon?, kbd?, onClick, disabled? } | 'sep' | { group: 'Label' }]
|
|
40
|
+
*/
|
|
41
|
+
export function menu(anchor, items, { align = 'end' } = {}) {
|
|
42
|
+
closeMenu();
|
|
43
|
+
const el = h('div.itp-menu.itp', { role: 'menu' });
|
|
44
|
+
for (const it of items) {
|
|
45
|
+
if (it === 'sep') { el.append(h('hr')); continue; }
|
|
46
|
+
if (it.group) { el.append(h('div.mlabel', { text: it.group })); continue; }
|
|
47
|
+
const b = h('button.mi', { type: 'button', role: 'menuitem', disabled: !!it.disabled },
|
|
48
|
+
h('span', { html: it.icon ? icon(it.icon) : '' }),
|
|
49
|
+
h('span', {}, it.label, it.sub ? h('small', { text: it.sub }) : null),
|
|
50
|
+
it.kbd ? h('kbd', { text: it.kbd }) : h('span'));
|
|
51
|
+
b.addEventListener('click', () => { closeMenu(); it.onClick(); });
|
|
52
|
+
el.append(b);
|
|
53
|
+
}
|
|
54
|
+
document.body.append(el);
|
|
55
|
+
const r = anchor.getBoundingClientRect();
|
|
56
|
+
const mw = el.offsetWidth, mh = el.offsetHeight;
|
|
57
|
+
let left = align === 'end' ? r.right - mw : r.left;
|
|
58
|
+
left = Math.max(8, Math.min(left, innerWidth - mw - 8));
|
|
59
|
+
let top = r.bottom + 6;
|
|
60
|
+
if (top + mh > innerHeight - 8) top = Math.max(8, r.top - mh - 6);
|
|
61
|
+
Object.assign(el.style, { left: `${left}px`, top: `${top}px` });
|
|
62
|
+
anchor.setAttribute('aria-expanded', 'true');
|
|
63
|
+
const buttons = [...el.querySelectorAll('button.mi:not(:disabled)')];
|
|
64
|
+
buttons[0]?.focus();
|
|
65
|
+
const onKey = e => {
|
|
66
|
+
const i = buttons.indexOf(document.activeElement);
|
|
67
|
+
if (e.key === 'Escape') { e.preventDefault(); closeMenu(); anchor.focus(); }
|
|
68
|
+
else if (e.key === 'ArrowDown') { e.preventDefault(); buttons[(i + 1) % buttons.length]?.focus(); }
|
|
69
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); buttons[(i - 1 + buttons.length) % buttons.length]?.focus(); }
|
|
70
|
+
else if (e.key === 'Tab') closeMenu();
|
|
71
|
+
};
|
|
72
|
+
const onDown = e => { if (!el.contains(e.target) && e.target !== anchor && !anchor.contains(e.target)) closeMenu(); };
|
|
73
|
+
el.addEventListener('keydown', onKey);
|
|
74
|
+
setTimeout(() => document.addEventListener('pointerdown', onDown, true));
|
|
75
|
+
openMenu = { el, anchor, cleanup: () => document.removeEventListener('pointerdown', onDown, true) };
|
|
76
|
+
}
|
|
77
|
+
export function closeMenu() {
|
|
78
|
+
if (!openMenu) return;
|
|
79
|
+
openMenu.cleanup(); openMenu.el.remove(); openMenu.anchor.setAttribute('aria-expanded', 'false');
|
|
80
|
+
openMenu = null;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Modal dialog. Returns the <dialog>; content can be updated with render(). */
|
|
84
|
+
export function dialog(title, content, { actions = [], onClose } = {}) {
|
|
85
|
+
const body = h('div.content', {}, content);
|
|
86
|
+
const d = h('dialog.itp-dialog.itp', { 'aria-label': title },
|
|
87
|
+
h('header', {}, h('h2', { text: title }), h('button.itp-btn.icon', { type: 'button', 'aria-label': 'Close', html: icon('x'), onclick: () => d.close() })),
|
|
88
|
+
body,
|
|
89
|
+
actions.length ? h('footer', {}, ...actions.map(a => h(`button.itp-btn${a.primary ? '.primary' : '.outline'}`, { type: 'button', text: a.label, onclick: async () => { if ((await a.onClick?.()) !== false) d.close(); } }))) : null,
|
|
90
|
+
);
|
|
91
|
+
d.addEventListener('close', () => { d.remove(); onClose?.(); });
|
|
92
|
+
document.body.append(d);
|
|
93
|
+
d.showModal();
|
|
94
|
+
d.body = body;
|
|
95
|
+
d.setContent = (...c) => render(body, ...c);
|
|
96
|
+
return d;
|
|
97
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -26,4 +26,6 @@ export { createZip } from './core/export/zip.js';
|
|
|
26
26
|
export { packSpriteSheet, buildTileset } from './core/export/sheet.js';
|
|
27
27
|
export { forEachFrame, estimateFps, seekTo, frameTimes, videoReady, mediaError, sniffVideoCodec } from './core/video/frames.js';
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/* global __ITP_VERSION__ */
|
|
30
|
+
// The build replaces __ITP_VERSION__ with package.json's version; unbundled source reports 'dev'.
|
|
31
|
+
export const VERSION = typeof __ITP_VERSION__ === 'string' ? __ITP_VERSION__ : 'dev';
|