@nowline/preview-shell 0.4.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/LICENSE +190 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/markup.d.ts +28 -0
- package/dist/markup.d.ts.map +1 -0
- package/dist/markup.js +99 -0
- package/dist/markup.js.map +1 -0
- package/dist/mount.d.ts +95 -0
- package/dist/mount.d.ts.map +1 -0
- package/dist/mount.js +695 -0
- package/dist/mount.js.map +1 -0
- package/dist/styles.d.ts +16 -0
- package/dist/styles.d.ts.map +1 -0
- package/dist/styles.js +292 -0
- package/dist/styles.js.map +1 -0
- package/package.json +58 -0
- package/src/index.ts +23 -0
- package/src/markup.ts +129 -0
- package/src/mount.ts +814 -0
- package/src/styles.ts +293 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding any notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
Copyright 2026 Lolay, Inc.
|
|
179
|
+
|
|
180
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
181
|
+
you may not use this file except in compliance with the License.
|
|
182
|
+
You may obtain a copy of the License at
|
|
183
|
+
|
|
184
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
185
|
+
|
|
186
|
+
Unless required by applicable law or agreed to in writing, software
|
|
187
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
188
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
189
|
+
See the License for the specific language governing permissions and
|
|
190
|
+
limitations under the License.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { DiagnosticRow } from '@nowline/browser';
|
|
2
|
+
export { __resetPreviewShellStylesheetForTests, type DiagnosticGoto, type ExportRequest, type InitialFit, type MountPreviewOptions, mountPreview, type NowOverride, type PreviewHandle, type ThemeOverride, type ViewBaseline, type ViewOptionsOverrides, } from './mount.js';
|
|
3
|
+
export { PREVIEW_SHELL_CSS, VSCODE_THEME_BRIDGE_CSS } from './styles.js';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,YAAY,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EACH,qCAAqC,EACrC,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,YAAY,EACZ,KAAK,WAAW,EAChB,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,YAAY,EACjB,KAAK,oBAAoB,GAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Public API for `@nowline/preview-shell`.
|
|
2
|
+
//
|
|
3
|
+
// Mounts a self-contained preview viewport (zoom, pan, fit, minimap,
|
|
4
|
+
// diagnostic table) into a host-supplied element and returns an
|
|
5
|
+
// imperative handle. Consumers feed in SVG + diagnostics; user
|
|
6
|
+
// interactions surface via callback options. No assumed text editor,
|
|
7
|
+
// no assumed message bus, no VS Code coupling.
|
|
8
|
+
export { __resetPreviewShellStylesheetForTests, mountPreview, } from './mount.js';
|
|
9
|
+
export { PREVIEW_SHELL_CSS, VSCODE_THEME_BRIDGE_CSS } from './styles.js';
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,2CAA2C;AAC3C,EAAE;AACF,qEAAqE;AACrE,gEAAgE;AAChE,+DAA+D;AAC/D,qEAAqE;AACrE,+CAA+C;AAG/C,OAAO,EACH,qCAAqC,EAKrC,YAAY,GAMf,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,iBAAiB,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/markup.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export interface ViewportElements {
|
|
2
|
+
root: HTMLElement;
|
|
3
|
+
viewport: HTMLElement;
|
|
4
|
+
canvas: HTMLElement;
|
|
5
|
+
empty: HTMLElement;
|
|
6
|
+
chrome: HTMLElement;
|
|
7
|
+
zoomReset: HTMLButtonElement;
|
|
8
|
+
zoomIn: HTMLButtonElement;
|
|
9
|
+
zoomOut: HTMLButtonElement;
|
|
10
|
+
fitWidth: HTMLButtonElement;
|
|
11
|
+
fitPage: HTMLButtonElement;
|
|
12
|
+
viewToggle: HTMLButtonElement;
|
|
13
|
+
viewMenu: HTMLUListElement;
|
|
14
|
+
saveToggle: HTMLButtonElement;
|
|
15
|
+
saveMenu: HTMLUListElement;
|
|
16
|
+
copyToggle: HTMLButtonElement;
|
|
17
|
+
copyMenu: HTMLUListElement;
|
|
18
|
+
minimap: HTMLElement;
|
|
19
|
+
minimapCanvas: HTMLElement;
|
|
20
|
+
minimapRect: HTMLElement;
|
|
21
|
+
minimapClose: HTMLButtonElement;
|
|
22
|
+
diagnostics: HTMLElement;
|
|
23
|
+
diagSummary: HTMLElement;
|
|
24
|
+
diagTbody: HTMLElement;
|
|
25
|
+
openProblems: HTMLAnchorElement;
|
|
26
|
+
}
|
|
27
|
+
export declare function buildViewport(rootEl: HTMLElement): ViewportElements;
|
|
28
|
+
//# sourceMappingURL=markup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.d.ts","sourceRoot":"","sources":["../src/markup.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC7B,IAAI,EAAE,WAAW,CAAC;IAClB,QAAQ,EAAE,WAAW,CAAC;IACtB,MAAM,EAAE,WAAW,CAAC;IACpB,KAAK,EAAE,WAAW,CAAC;IACnB,MAAM,EAAE,WAAW,CAAC;IACpB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,QAAQ,EAAE,iBAAiB,CAAC;IAC5B,OAAO,EAAE,iBAAiB,CAAC;IAC3B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,UAAU,EAAE,iBAAiB,CAAC;IAC9B,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,WAAW,CAAC;IAC3B,WAAW,EAAE,WAAW,CAAC;IACzB,YAAY,EAAE,iBAAiB,CAAC;IAChC,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,WAAW,CAAC;IACvB,YAAY,EAAE,iBAAiB,CAAC;CACnC;AAoED,wBAAgB,aAAa,CAAC,MAAM,EAAE,WAAW,GAAG,gBAAgB,CA8BnE"}
|
package/dist/markup.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Markup helpers for `mountPreview()`. Builds the viewport DOM tree
|
|
2
|
+
// inside the supplied root element. All element refs are namespaced by
|
|
3
|
+
// CSS class (rather than `id="..."`) so two preview shells can mount in
|
|
4
|
+
// the same document without clashing.
|
|
5
|
+
const TEMPLATE = `
|
|
6
|
+
<div class="viewport"><div class="canvas"></div></div>
|
|
7
|
+
<div class="empty">Rendering preview…</div>
|
|
8
|
+
<div class="chrome">
|
|
9
|
+
<div class="toolbar zoom-toolbar">
|
|
10
|
+
<button class="btn zoom-out" title="Zoom out">−</button>
|
|
11
|
+
<button class="btn zoom-label zoom-reset" title="Reset to 100%">100%</button>
|
|
12
|
+
<button class="btn zoom-in" title="Zoom in">+</button>
|
|
13
|
+
<span class="sep"></span>
|
|
14
|
+
<button class="btn glyph fit-width" title="Fit width (3)" aria-label="Fit width">↔</button>
|
|
15
|
+
<button class="btn glyph fit-page" title="Fit page (1)" aria-label="Fit page">⛶</button>
|
|
16
|
+
<span class="sep"></span>
|
|
17
|
+
<div class="dropdown">
|
|
18
|
+
<button class="btn view-toggle" title="View options for this preview (theme, now-line, links)">View ▾</button>
|
|
19
|
+
<ul class="menu view-menu" hidden>
|
|
20
|
+
<li class="menu-section">Theme</li>
|
|
21
|
+
<li><button class="btn view-opt" data-opt="theme" data-value="auto">Auto</button></li>
|
|
22
|
+
<li><button class="btn view-opt" data-opt="theme" data-value="light">Light</button></li>
|
|
23
|
+
<li><button class="btn view-opt" data-opt="theme" data-value="dark">Dark</button></li>
|
|
24
|
+
<li class="menu-divider"></li>
|
|
25
|
+
<li class="menu-section">Now-line</li>
|
|
26
|
+
<li><button class="btn view-opt" data-opt="now" data-value="today">Today</button></li>
|
|
27
|
+
<li><button class="btn view-opt" data-opt="now" data-value="hide">Hide</button></li>
|
|
28
|
+
<li class="menu-divider"></li>
|
|
29
|
+
<li><button class="btn view-opt" data-opt="showLinks" data-value="toggle">Show links</button></li>
|
|
30
|
+
</ul>
|
|
31
|
+
</div>
|
|
32
|
+
<span class="sep"></span>
|
|
33
|
+
<div class="dropdown">
|
|
34
|
+
<button class="btn save-toggle" title="Save the rendered diagram">Save ▾</button>
|
|
35
|
+
<ul class="menu save-menu" hidden>
|
|
36
|
+
<li><button class="btn" data-action="save-svg">Save SVG…</button></li>
|
|
37
|
+
<li><button class="btn" data-action="save-png">Save PNG…</button></li>
|
|
38
|
+
</ul>
|
|
39
|
+
</div>
|
|
40
|
+
<div class="dropdown">
|
|
41
|
+
<button class="btn copy-toggle" title="Copy the rendered diagram to the clipboard">Copy ▾</button>
|
|
42
|
+
<ul class="menu copy-menu" hidden>
|
|
43
|
+
<li><button class="btn" data-action="copy-svg">Copy SVG</button></li>
|
|
44
|
+
<li><button class="btn" data-action="copy-png">Copy PNG</button></li>
|
|
45
|
+
</ul>
|
|
46
|
+
</div>
|
|
47
|
+
</div>
|
|
48
|
+
</div>
|
|
49
|
+
<div class="minimap hidden">
|
|
50
|
+
<button class="btn minimap-close" title="Hide minimap">×</button>
|
|
51
|
+
<div class="minimap-canvas"></div>
|
|
52
|
+
<div class="minimap-rect"></div>
|
|
53
|
+
</div>
|
|
54
|
+
<div class="diagnostics">
|
|
55
|
+
<div class="diag-header">
|
|
56
|
+
<span class="diag-summary"></span>
|
|
57
|
+
<a class="open-problems" href="#">Open Problems panel</a>
|
|
58
|
+
</div>
|
|
59
|
+
<table class="diag-table"><tbody></tbody></table>
|
|
60
|
+
</div>
|
|
61
|
+
`;
|
|
62
|
+
function q(root, selector) {
|
|
63
|
+
const el = root.querySelector(selector);
|
|
64
|
+
if (!el) {
|
|
65
|
+
throw new Error(`preview-shell: required element "${selector}" missing from template`);
|
|
66
|
+
}
|
|
67
|
+
return el;
|
|
68
|
+
}
|
|
69
|
+
export function buildViewport(rootEl) {
|
|
70
|
+
rootEl.classList.add('nl-preview-root');
|
|
71
|
+
rootEl.innerHTML = TEMPLATE;
|
|
72
|
+
return {
|
|
73
|
+
root: rootEl,
|
|
74
|
+
viewport: q(rootEl, '.viewport'),
|
|
75
|
+
canvas: q(rootEl, '.canvas'),
|
|
76
|
+
empty: q(rootEl, '.empty'),
|
|
77
|
+
chrome: q(rootEl, '.chrome'),
|
|
78
|
+
zoomReset: q(rootEl, '.zoom-reset'),
|
|
79
|
+
zoomIn: q(rootEl, '.zoom-in'),
|
|
80
|
+
zoomOut: q(rootEl, '.zoom-out'),
|
|
81
|
+
fitWidth: q(rootEl, '.fit-width'),
|
|
82
|
+
fitPage: q(rootEl, '.fit-page'),
|
|
83
|
+
viewToggle: q(rootEl, '.view-toggle'),
|
|
84
|
+
viewMenu: q(rootEl, '.view-menu'),
|
|
85
|
+
saveToggle: q(rootEl, '.save-toggle'),
|
|
86
|
+
saveMenu: q(rootEl, '.save-menu'),
|
|
87
|
+
copyToggle: q(rootEl, '.copy-toggle'),
|
|
88
|
+
copyMenu: q(rootEl, '.copy-menu'),
|
|
89
|
+
minimap: q(rootEl, '.minimap'),
|
|
90
|
+
minimapCanvas: q(rootEl, '.minimap-canvas'),
|
|
91
|
+
minimapRect: q(rootEl, '.minimap-rect'),
|
|
92
|
+
minimapClose: q(rootEl, '.minimap-close'),
|
|
93
|
+
diagnostics: q(rootEl, '.diagnostics'),
|
|
94
|
+
diagSummary: q(rootEl, '.diag-summary'),
|
|
95
|
+
diagTbody: q(rootEl, '.diag-table tbody'),
|
|
96
|
+
openProblems: q(rootEl, '.open-problems'),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingUR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AAC,CAAoB,MAAM,EAAE,cAAc,CAAC;QACxD,QAAQ,EAAE,CAAC,CAAmB,MAAM,EAAE,YAAY,CAAC;QACnD,UAAU,EAAE,CAAC,CAAoB,MAAM,EAAE,cAAc,CAAC;QACxD,QAAQ,EAAE,CAAC,CAAmB,MAAM,EAAE,YAAY,CAAC;QACnD,UAAU,EAAE,CAAC,CAAoB,MAAM,EAAE,cAAc,CAAC;QACxD,QAAQ,EAAE,CAAC,CAAmB,MAAM,EAAE,YAAY,CAAC;QACnD,OAAO,EAAE,CAAC,CAAc,MAAM,EAAE,UAAU,CAAC;QAC3C,aAAa,EAAE,CAAC,CAAc,MAAM,EAAE,iBAAiB,CAAC;QACxD,WAAW,EAAE,CAAC,CAAc,MAAM,EAAE,eAAe,CAAC;QACpD,YAAY,EAAE,CAAC,CAAoB,MAAM,EAAE,gBAAgB,CAAC;QAC5D,WAAW,EAAE,CAAC,CAAc,MAAM,EAAE,cAAc,CAAC;QACnD,WAAW,EAAE,CAAC,CAAc,MAAM,EAAE,eAAe,CAAC;QACpD,SAAS,EAAE,CAAC,CAAc,MAAM,EAAE,mBAAmB,CAAC;QACtD,YAAY,EAAE,CAAC,CAAoB,MAAM,EAAE,gBAAgB,CAAC;KAC/D,CAAC;AACN,CAAC"}
|
package/dist/mount.d.ts
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { DiagnosticRow } from '@nowline/browser';
|
|
2
|
+
export type ThemeOverride = 'auto' | 'light' | 'dark';
|
|
3
|
+
export type NowOverride = 'today' | 'hide';
|
|
4
|
+
export type InitialFit = 'fitPage' | 'fitWidth' | 'actual';
|
|
5
|
+
/**
|
|
6
|
+
* Locator info posted when the user clicks a diagnostic row. `file`
|
|
7
|
+
* carries the absolute fs path from the originating DiagnosticRow;
|
|
8
|
+
* `line` and `column` are 1-based to match VS Code's Problems panel.
|
|
9
|
+
*/
|
|
10
|
+
export interface DiagnosticGoto {
|
|
11
|
+
file: string;
|
|
12
|
+
line: number;
|
|
13
|
+
column: number;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Save / copy request payload. The shell rasterizes PNG via
|
|
17
|
+
* `<canvas>`; consumers receive the bytes and decide where they go.
|
|
18
|
+
*/
|
|
19
|
+
export interface ExportRequest {
|
|
20
|
+
format: 'svg' | 'png';
|
|
21
|
+
body: string | Uint8Array;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* View-options overrides emitted when the user clicks the View ▾ menu.
|
|
25
|
+
* Only fields the user explicitly chose are present; consumers merge
|
|
26
|
+
* with their own option-resolution chain (settings, .nowlinerc, etc.).
|
|
27
|
+
*/
|
|
28
|
+
export interface ViewOptionsOverrides {
|
|
29
|
+
theme?: ThemeOverride;
|
|
30
|
+
now?: NowOverride;
|
|
31
|
+
showLinks?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Baseline view state pushed by the consumer (e.g. when settings
|
|
35
|
+
* change). The shell uses these to pre-fill the View menu's
|
|
36
|
+
* checkmarks without claiming the option as user-overridden.
|
|
37
|
+
*/
|
|
38
|
+
export interface ViewBaseline {
|
|
39
|
+
theme?: ThemeOverride;
|
|
40
|
+
/** Maps to one of `today` | `hide` for the checkmark — host values like 'auto' / 'YYYY-MM-DD' collapse to 'today'. */
|
|
41
|
+
now?: NowOverride | 'auto' | 'none' | string;
|
|
42
|
+
showLinks?: boolean;
|
|
43
|
+
}
|
|
44
|
+
export interface MountPreviewOptions {
|
|
45
|
+
initialFit?: InitialFit;
|
|
46
|
+
showMinimap?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Initial view-menu baseline. Consumers can omit and push later
|
|
49
|
+
* with `handle.setViewBaseline(...)`.
|
|
50
|
+
*/
|
|
51
|
+
viewBaseline?: ViewBaseline;
|
|
52
|
+
onGoto?: (loc: DiagnosticGoto) => void;
|
|
53
|
+
onOpenProblems?: () => void;
|
|
54
|
+
onSave?: (req: ExportRequest) => void;
|
|
55
|
+
onCopy?: (req: ExportRequest) => void;
|
|
56
|
+
/**
|
|
57
|
+
* Fired when the user toggles save-png / copy-png and the browser's
|
|
58
|
+
* `navigator.clipboard.write` is unavailable. Consumers usually
|
|
59
|
+
* pass the bytes off to a host-side fallback (write to a temp file
|
|
60
|
+
* + notify) and pop a message describing what happened.
|
|
61
|
+
*/
|
|
62
|
+
onCopyPngFallback?: (body: Uint8Array) => void;
|
|
63
|
+
onViewOptions?: (overrides: ViewOptionsOverrides) => void;
|
|
64
|
+
onFatal?: (message: string) => void;
|
|
65
|
+
}
|
|
66
|
+
export interface PreviewHandle {
|
|
67
|
+
/** Replace the diagram with new SVG markup. */
|
|
68
|
+
setSvg(svg: string): void;
|
|
69
|
+
/** Switch to the diagnostics overlay; dims any prior SVG. */
|
|
70
|
+
setDiagnostics(rows: DiagnosticRow[]): void;
|
|
71
|
+
/** Show a one-row diagnostics overlay with the supplied message. */
|
|
72
|
+
setFatal(message: string): void;
|
|
73
|
+
/** Re-skin the view-menu baselines without claiming user overrides. */
|
|
74
|
+
setViewBaseline(baseline: ViewBaseline, resetOverrides?: boolean): void;
|
|
75
|
+
/** Update the "default fit" used by the next first-render. */
|
|
76
|
+
setDefaultFit(fit: InitialFit): void;
|
|
77
|
+
/** Toggle the minimap behaviour from the host. */
|
|
78
|
+
setShowMinimap(show: boolean): void;
|
|
79
|
+
fitPage(): void;
|
|
80
|
+
fitWidth(): void;
|
|
81
|
+
actualSize(): void;
|
|
82
|
+
getZoom(): number;
|
|
83
|
+
setZoom(scale: number): void;
|
|
84
|
+
/** Remove all listeners + DOM and detach the shell from the root element. */
|
|
85
|
+
dispose(): void;
|
|
86
|
+
}
|
|
87
|
+
export declare function mountPreview(rootEl: HTMLElement, options?: MountPreviewOptions): PreviewHandle;
|
|
88
|
+
/**
|
|
89
|
+
* Test-only helper. Clears the module-level latch that prevents the
|
|
90
|
+
* stylesheet from being mounted twice. Vitest reuses module instances
|
|
91
|
+
* across tests, so without this every test after the first one would
|
|
92
|
+
* skip writing the stylesheet into the test document.
|
|
93
|
+
*/
|
|
94
|
+
export declare function __resetPreviewShellStylesheetForTests(): void;
|
|
95
|
+
//# sourceMappingURL=mount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mount.d.ts","sourceRoot":"","sources":["../src/mount.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAItD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,CAAC;AAC3C,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,CAAC;AAE3D;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAClB;AAED;;;GAGG;AACH,MAAM,WAAW,aAAa;IAC1B,MAAM,EAAE,KAAK,GAAG,KAAK,CAAC;IACtB,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACjC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,GAAG,CAAC,EAAE,WAAW,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,MAAM,WAAW,YAAY;IACzB,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,sHAAsH;IACtH,GAAG,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IAC7C,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,mBAAmB;IAChC,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB;;;OAGG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,MAAM,CA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