@povio/ui 5.0.0-rc.7 → 5.0.0-rc.8
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/Button-BPTvffuk.js +86 -0
- package/dist/{Calendar-BTjajO6i.js → Calendar-BxtOuqIM.js} +3 -3
- package/dist/{Checkbox-CV1ILXXO.js → Checkbox-DYxXYfKL.js} +3 -2
- package/dist/CheckboxCheckmark-D_uc9pon.js +44 -0
- package/dist/{ComponentGallery-Dp0kZVZM.js → ComponentGallery-Da70Y4_Q.js} +17 -17
- package/dist/{DatePicker-DOLL7mkc.js → DatePicker-wulRNGyL.js} +6 -6
- package/dist/{DatePickerInput-BLBcySA2.js → DatePickerInput-BB_vPlKu.js} +3 -3
- package/dist/{DateRangePicker-BF-1CztH.js → DateRangePicker-B0tMVREG.js} +6 -6
- package/dist/{DateTimePicker-Cj0qvJUz.js → DateTimePicker-WGMr0bEH.js} +6 -6
- package/dist/{FileInput-Br5DQaGQ.js → FileInput-DP105Iy9.js} +2 -2
- package/dist/{FileUpload--7ub3EZO.js → FileUpload-CgNDIvzg.js} +3 -3
- package/dist/{Form-BJ12MjE-.d.ts → Form-DbEWnCKc.d.ts} +1 -1
- package/dist/{FormField-B99dLt8o.js → FormField-AY25LzbW.js} +3 -96
- package/dist/{FormFieldError-DeOHHLo2.js → FormFieldError-BVAO5p7H.js} +2 -13
- package/dist/{InputItem-CIxbTxZu.js → InputItem-ZeN-aIz8.js} +11 -11
- package/dist/{Inputs-DJSKiaWY.js → Inputs-BC5q5Cvj.js} +1 -1
- package/dist/{Inputs-DA73LmLc.d.ts → Inputs-O84btFJL.d.ts} +1 -1
- package/dist/{NumberRangeInput-B8-LHfg3.js → NumberRangeInput-B_sMIpP1.js} +2 -2
- package/dist/{PaginationList-DtvuP63b.js → PaginationList-DptMNpNs.js} +1 -1
- package/dist/{Progress-B3mY9rIP.js → Progress-Du30L4_s.js} +2 -27
- package/dist/{RadioGroup-DOw3PRoX.js → RadioGroup-CUGNSJql.js} +3 -82
- package/dist/{RichTextEditor-D4yN7Wj7.js → RichTextEditor-VDOpj7sk.js} +3 -3
- package/dist/{Select-UR0ec2Ux.js → Select-B2pAfwRk.js} +2 -2
- package/dist/{Slider-CzEmKYBF.js → Slider-Clc1szFY.js} +1 -1
- package/dist/{Switch-CqnGEdeD.js → Switch-CimmMqEk.js} +3 -27
- package/dist/{Table-BN2_J_Ne.js → Table-CqepqSfe.js} +2 -1
- package/dist/{TextArea-D8WkKsGn.js → TextArea-B3teIhsJ.js} +3 -5
- package/dist/TextArea.cva-Bb73hriz.js +5 -0
- package/dist/{TimePicker-C4taAOFQ.js → TimePicker-CU_yL2sY.js} +4 -4
- package/dist/{Toast-DtG3pA61.js → Toast-DPbnLlBi.js} +1 -1
- package/dist/{ToggleGroup-DOk27fgI.js → ToggleGroup-BULVwErp.js} +1 -1
- package/dist/{Button-C5rv4Cr2.js → button.cva-rv5Uq4aW.js} +1 -84
- package/dist/{CheckboxCheckmark-CpC3wlMs.js → checkbox.cva-IfOByVLA.js} +1 -42
- package/dist/components/alert-dialog.js +1 -1
- package/dist/components/alert.js +116 -1
- package/dist/components/autocomplete.js +2 -2
- package/dist/components/button.js +1 -1
- package/dist/components/checkbox-group.js +3 -3
- package/dist/components/checkbox.js +1 -1
- package/dist/components/date-picker.js +1 -1
- package/dist/components/date-range-picker.js +1 -1
- package/dist/components/date-time-picker.js +1 -1
- package/dist/components/file-input.js +1 -1
- package/dist/components/file-upload-container.js +1 -1
- package/dist/components/file-upload.js +1 -1
- package/dist/components/form-field.js +1 -1
- package/dist/components/icon-button.js +1 -1
- package/dist/components/inline-icon-button.js +1 -1
- package/dist/components/input.js +3 -3
- package/dist/components/number-field.js +3 -3
- package/dist/components/number-range-input.js +1 -1
- package/dist/components/pagination-list.js +1 -1
- package/dist/components/pagination.js +1 -1
- package/dist/components/progress.js +1 -1
- package/dist/components/query-autocomplete.js +1 -1
- package/dist/components/query-select.js +2 -2
- package/dist/components/radio-group.js +1 -1
- package/dist/components/select.js +1 -1
- package/dist/components/slider.js +1 -1
- package/dist/components/split-button.js +1 -1
- package/dist/components/switch.js +1 -1
- package/dist/components/tag.js +93 -1
- package/dist/components/text-area.js +1 -1
- package/dist/components/text-button.js +1 -1
- package/dist/components/time-picker.js +1 -1
- package/dist/components/toast.js +1 -1
- package/dist/components/toggle-button.js +1 -1
- package/dist/components/toggle-group.js +1 -1
- package/dist/components/use-toast.js +2 -2
- package/dist/config/app-canvas.d.ts +79 -0
- package/dist/config/app-canvas.js +2253 -0
- package/dist/config/ui-config.d.ts +1 -1
- package/dist/config/ui-configurator.d.ts +1 -920
- package/dist/config/ui-configurator.js +127 -1174
- package/dist/configuration.context-f_FSPWhQ.d.ts +926 -0
- package/dist/{datePickerValue.utils-DCgoSrP3.js → datePickerValue.utils-CIFHjKwv.js} +1 -1
- package/dist/{dynamicInputs-iP39lVKf.d.ts → dynamicInputs-ByVMnx4Z.d.ts} +1 -1
- package/dist/formFieldError.cva-CsXaQRHX.js +14 -0
- package/dist/formFieldHelper.cva-B8F9LmsE.js +96 -0
- package/dist/grip-vertical-BVxcjdfr.js +54 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +24 -19
- package/dist/inspection-model-LuI36xTg.js +1339 -0
- package/dist/progress.cva-WQB8BGbk.js +28 -0
- package/dist/radio.cva-DGbvTymp.js +82 -0
- package/dist/rhf/checkbox.js +1 -1
- package/dist/rhf/date-picker.js +1 -1
- package/dist/rhf/date-range-picker.js +1 -1
- package/dist/rhf/date-time-picker.js +1 -1
- package/dist/rhf/file-input.js +1 -1
- package/dist/rhf/file-upload.js +1 -1
- package/dist/rhf/inputs.d.ts +1 -1
- package/dist/rhf/number-range-input.js +1 -1
- package/dist/rhf/radio-group.js +1 -1
- package/dist/rhf/rich-text-editor.js +1 -1
- package/dist/rhf/select.js +1 -1
- package/dist/rhf/slider.js +1 -1
- package/dist/rhf/switch.js +1 -1
- package/dist/rhf/text-area.js +1 -1
- package/dist/rhf/time-picker.js +1 -1
- package/dist/rhf/toggle-group.js +1 -1
- package/dist/rhf.d.ts +2 -2
- package/dist/rhf.js +24 -19
- package/dist/rich-text-editor.js +1 -1
- package/dist/{staticDateTimeSegments-DtU63_dw.js → staticDateTimeSegments-sf_ND7zL.js} +1 -1
- package/dist/{staticSelect.utils-uHa8f_c6.js → staticSelect.utils-CzlnLPPd.js} +3 -3
- package/dist/status.cva-6HxNR4EP.js +130 -0
- package/dist/styles/app-canvas.css +733 -0
- package/dist/styles/configurator.css +19 -5
- package/dist/switch.cva-BX3HOxbL.js +27 -0
- package/dist/{table.cva-D5oQ-QvA.js → table.cva-DlMT-zLD.js} +1 -54
- package/dist/{Tag-DPg5sL1Z.js → tag.cva-B3MudLeC.js} +1 -92
- package/dist/tanstack/checkbox.js +1 -1
- package/dist/tanstack/date-picker.js +1 -1
- package/dist/tanstack/date-range-picker.js +1 -1
- package/dist/tanstack/date-time-picker.js +1 -1
- package/dist/tanstack/file-input.js +1 -1
- package/dist/tanstack/file-upload.js +1 -1
- package/dist/tanstack/form.d.ts +1 -1
- package/dist/tanstack/form.js +1 -1
- package/dist/tanstack/inputs.d.ts +2 -2
- package/dist/tanstack/inputs.js +1 -1
- package/dist/tanstack/number-range-input.js +1 -1
- package/dist/tanstack/radio-group.js +1 -1
- package/dist/tanstack/rich-text-editor.js +1 -1
- package/dist/tanstack/select.js +1 -1
- package/dist/tanstack/slider.js +1 -1
- package/dist/tanstack/switch.js +1 -1
- package/dist/tanstack/table.js +2 -2
- package/dist/tanstack/text-area.js +1 -1
- package/dist/tanstack/time-picker.js +1 -1
- package/dist/tanstack/toggle-group.js +1 -1
- package/dist/tanstack.d.ts +4 -4
- package/dist/tanstack.js +39 -31
- package/dist/{toast.runtime-cxex9e4E.js → toast.runtime-Zf-XyAC3.js} +1 -1
- package/dist/{useFieldAccessibility-ScC6Mtd5.js → useFieldAccessibility-CcBTgGfm.js} +1 -1
- package/dist/{useFormAutosave-DfuP7drj.js → useFormAutosave-BD_TFqDF.js} +1 -1
- package/dist/{useStaticInputHandoff-NeZVnci-.js → useStaticInputHandoff-kkQrc6DA.js} +1 -1
- package/dist/{useTableColumnConfig-Di0_w80v.js → useTableColumnConfig-aVUWC2Mp.js} +2 -2
- package/package.json +7 -1
- package/dist/Alert-CnvEb1D_.js +0 -244
- package/dist/token-classes-Bfcx0get.js +0 -163
|
@@ -0,0 +1,2253 @@
|
|
|
1
|
+
import { t as createLucideIcon } from "../createLucideIcon-LcezOE4z.js";
|
|
2
|
+
import { t as ChevronDown } from "../chevron-down-B4Pr8bD3.js";
|
|
3
|
+
import { t as ChevronRight } from "../chevron-right-3nKJR5Bb.js";
|
|
4
|
+
import { a as InspectorDetails, c as useUIConfiguration, f as Sun, i as HighlightOverlay, m as Moon, p as Pin, r as getBoxHighlights, t as inspectElement } from "../inspection-model-LuI36xTg.js";
|
|
5
|
+
import { i as Search } from "../selectDesktop.cva-CHAMxhfO.js";
|
|
6
|
+
import { t as Upload } from "../upload-CXU83BJ4.js";
|
|
7
|
+
import { t as X } from "../x-B6vfz8Ps.js";
|
|
8
|
+
import { memo, useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
|
|
9
|
+
import { c } from "react/compiler-runtime";
|
|
10
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
11
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/code-xml.mjs
|
|
12
|
+
/**
|
|
13
|
+
* @license lucide-react v1.43.0 - ISC
|
|
14
|
+
*
|
|
15
|
+
* This source code is licensed under the ISC license.
|
|
16
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
17
|
+
*/
|
|
18
|
+
const __iconData$9 = {
|
|
19
|
+
name: "code-xml",
|
|
20
|
+
size: 24,
|
|
21
|
+
node: [
|
|
22
|
+
["path", {
|
|
23
|
+
d: "m18 16 4-4-4-4",
|
|
24
|
+
key: "1inbqp"
|
|
25
|
+
}],
|
|
26
|
+
["path", {
|
|
27
|
+
d: "m6 8-4 4 4 4",
|
|
28
|
+
key: "15zrgr"
|
|
29
|
+
}],
|
|
30
|
+
["path", {
|
|
31
|
+
d: "m14.5 4-5 16",
|
|
32
|
+
key: "e7oirm"
|
|
33
|
+
}]
|
|
34
|
+
],
|
|
35
|
+
aliases: ["code-2"]
|
|
36
|
+
};
|
|
37
|
+
__iconData$9.node;
|
|
38
|
+
const CodeXml = createLucideIcon(__iconData$9);
|
|
39
|
+
//#endregion
|
|
40
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/download.mjs
|
|
41
|
+
/**
|
|
42
|
+
* @license lucide-react v1.43.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/
|
|
47
|
+
const __iconData$8 = {
|
|
48
|
+
name: "download",
|
|
49
|
+
size: 24,
|
|
50
|
+
node: [
|
|
51
|
+
["path", {
|
|
52
|
+
d: "M12 15V3",
|
|
53
|
+
key: "m9g1x1"
|
|
54
|
+
}],
|
|
55
|
+
["path", {
|
|
56
|
+
d: "M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",
|
|
57
|
+
key: "ih7n3h"
|
|
58
|
+
}],
|
|
59
|
+
["path", {
|
|
60
|
+
d: "m7 10 5 5 5-5",
|
|
61
|
+
key: "brsn70"
|
|
62
|
+
}]
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
__iconData$8.node;
|
|
66
|
+
const Download = createLucideIcon(__iconData$8);
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/frame.mjs
|
|
69
|
+
/**
|
|
70
|
+
* @license lucide-react v1.43.0 - ISC
|
|
71
|
+
*
|
|
72
|
+
* This source code is licensed under the ISC license.
|
|
73
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
74
|
+
*/
|
|
75
|
+
const __iconData$7 = {
|
|
76
|
+
name: "frame",
|
|
77
|
+
size: 24,
|
|
78
|
+
node: [
|
|
79
|
+
["line", {
|
|
80
|
+
x1: "22",
|
|
81
|
+
x2: "2",
|
|
82
|
+
y1: "6",
|
|
83
|
+
y2: "6",
|
|
84
|
+
key: "15w7dq"
|
|
85
|
+
}],
|
|
86
|
+
["line", {
|
|
87
|
+
x1: "22",
|
|
88
|
+
x2: "2",
|
|
89
|
+
y1: "18",
|
|
90
|
+
y2: "18",
|
|
91
|
+
key: "1ip48p"
|
|
92
|
+
}],
|
|
93
|
+
["line", {
|
|
94
|
+
x1: "6",
|
|
95
|
+
x2: "6",
|
|
96
|
+
y1: "2",
|
|
97
|
+
y2: "22",
|
|
98
|
+
key: "a2lnyx"
|
|
99
|
+
}],
|
|
100
|
+
["line", {
|
|
101
|
+
x1: "18",
|
|
102
|
+
x2: "18",
|
|
103
|
+
y1: "2",
|
|
104
|
+
y2: "22",
|
|
105
|
+
key: "8vb6jd"
|
|
106
|
+
}]
|
|
107
|
+
]
|
|
108
|
+
};
|
|
109
|
+
__iconData$7.node;
|
|
110
|
+
const Frame = createLucideIcon(__iconData$7);
|
|
111
|
+
//#endregion
|
|
112
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/hand.mjs
|
|
113
|
+
/**
|
|
114
|
+
* @license lucide-react v1.43.0 - ISC
|
|
115
|
+
*
|
|
116
|
+
* This source code is licensed under the ISC license.
|
|
117
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
118
|
+
*/
|
|
119
|
+
const __iconData$6 = {
|
|
120
|
+
name: "hand",
|
|
121
|
+
size: 24,
|
|
122
|
+
node: [
|
|
123
|
+
["path", {
|
|
124
|
+
d: "M18 11V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2",
|
|
125
|
+
key: "1fvzgz"
|
|
126
|
+
}],
|
|
127
|
+
["path", {
|
|
128
|
+
d: "M14 10V4a2 2 0 0 0-2-2a2 2 0 0 0-2 2v2",
|
|
129
|
+
key: "1kc0my"
|
|
130
|
+
}],
|
|
131
|
+
["path", {
|
|
132
|
+
d: "M10 10.5V6a2 2 0 0 0-2-2a2 2 0 0 0-2 2v8",
|
|
133
|
+
key: "10h0bg"
|
|
134
|
+
}],
|
|
135
|
+
["path", {
|
|
136
|
+
d: "M18 8a2 2 0 1 1 4 0v6a8 8 0 0 1-8 8h-2c-2.8 0-4.5-.86-5.99-2.34l-3.6-3.6a2 2 0 0 1 2.83-2.82L7 15",
|
|
137
|
+
key: "1s1gnw"
|
|
138
|
+
}]
|
|
139
|
+
]
|
|
140
|
+
};
|
|
141
|
+
__iconData$6.node;
|
|
142
|
+
const Hand = createLucideIcon(__iconData$6);
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/monitor.mjs
|
|
145
|
+
/**
|
|
146
|
+
* @license lucide-react v1.43.0 - ISC
|
|
147
|
+
*
|
|
148
|
+
* This source code is licensed under the ISC license.
|
|
149
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
150
|
+
*/
|
|
151
|
+
const __iconData$5 = {
|
|
152
|
+
name: "monitor",
|
|
153
|
+
size: 24,
|
|
154
|
+
node: [
|
|
155
|
+
["rect", {
|
|
156
|
+
width: "20",
|
|
157
|
+
height: "14",
|
|
158
|
+
x: "2",
|
|
159
|
+
y: "3",
|
|
160
|
+
rx: "2",
|
|
161
|
+
key: "48i651"
|
|
162
|
+
}],
|
|
163
|
+
["line", {
|
|
164
|
+
x1: "8",
|
|
165
|
+
x2: "16",
|
|
166
|
+
y1: "21",
|
|
167
|
+
y2: "21",
|
|
168
|
+
key: "1svkeh"
|
|
169
|
+
}],
|
|
170
|
+
["line", {
|
|
171
|
+
x1: "12",
|
|
172
|
+
x2: "12",
|
|
173
|
+
y1: "17",
|
|
174
|
+
y2: "21",
|
|
175
|
+
key: "vw1qmm"
|
|
176
|
+
}]
|
|
177
|
+
]
|
|
178
|
+
};
|
|
179
|
+
__iconData$5.node;
|
|
180
|
+
const Monitor = createLucideIcon(__iconData$5);
|
|
181
|
+
//#endregion
|
|
182
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/mouse-pointer-2.mjs
|
|
183
|
+
/**
|
|
184
|
+
* @license lucide-react v1.43.0 - ISC
|
|
185
|
+
*
|
|
186
|
+
* This source code is licensed under the ISC license.
|
|
187
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
188
|
+
*/
|
|
189
|
+
const __iconData$4 = {
|
|
190
|
+
name: "mouse-pointer-2",
|
|
191
|
+
size: 24,
|
|
192
|
+
node: [["path", {
|
|
193
|
+
d: "M4.037 4.688a.495.495 0 0 1 .651-.651l16 6.5a.5.5 0 0 1-.063.947l-6.124 1.58a2 2 0 0 0-1.438 1.435l-1.579 6.126a.5.5 0 0 1-.947.063z",
|
|
194
|
+
key: "edeuup"
|
|
195
|
+
}]]
|
|
196
|
+
};
|
|
197
|
+
__iconData$4.node;
|
|
198
|
+
const MousePointer2 = createLucideIcon(__iconData$4);
|
|
199
|
+
//#endregion
|
|
200
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/panel-left.mjs
|
|
201
|
+
/**
|
|
202
|
+
* @license lucide-react v1.43.0 - ISC
|
|
203
|
+
*
|
|
204
|
+
* This source code is licensed under the ISC license.
|
|
205
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
206
|
+
*/
|
|
207
|
+
const __iconData$3 = {
|
|
208
|
+
name: "panel-left",
|
|
209
|
+
size: 24,
|
|
210
|
+
node: [["rect", {
|
|
211
|
+
width: "18",
|
|
212
|
+
height: "18",
|
|
213
|
+
x: "3",
|
|
214
|
+
y: "3",
|
|
215
|
+
rx: "2",
|
|
216
|
+
key: "afitv7"
|
|
217
|
+
}], ["path", {
|
|
218
|
+
d: "M9 3v18",
|
|
219
|
+
key: "fh3hqa"
|
|
220
|
+
}]],
|
|
221
|
+
aliases: ["sidebar"]
|
|
222
|
+
};
|
|
223
|
+
__iconData$3.node;
|
|
224
|
+
const PanelLeft = createLucideIcon(__iconData$3);
|
|
225
|
+
//#endregion
|
|
226
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/panels-top-left.mjs
|
|
227
|
+
/**
|
|
228
|
+
* @license lucide-react v1.43.0 - ISC
|
|
229
|
+
*
|
|
230
|
+
* This source code is licensed under the ISC license.
|
|
231
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
232
|
+
*/
|
|
233
|
+
const __iconData$2 = {
|
|
234
|
+
name: "panels-top-left",
|
|
235
|
+
size: 24,
|
|
236
|
+
node: [
|
|
237
|
+
["rect", {
|
|
238
|
+
width: "18",
|
|
239
|
+
height: "18",
|
|
240
|
+
x: "3",
|
|
241
|
+
y: "3",
|
|
242
|
+
rx: "2",
|
|
243
|
+
key: "afitv7"
|
|
244
|
+
}],
|
|
245
|
+
["path", {
|
|
246
|
+
d: "M3 9h18",
|
|
247
|
+
key: "1pudct"
|
|
248
|
+
}],
|
|
249
|
+
["path", {
|
|
250
|
+
d: "M9 21V9",
|
|
251
|
+
key: "1oto5p"
|
|
252
|
+
}]
|
|
253
|
+
],
|
|
254
|
+
aliases: ["layout"]
|
|
255
|
+
};
|
|
256
|
+
__iconData$2.node;
|
|
257
|
+
const PanelsTopLeft = createLucideIcon(__iconData$2);
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/scan-line.mjs
|
|
260
|
+
/**
|
|
261
|
+
* @license lucide-react v1.43.0 - ISC
|
|
262
|
+
*
|
|
263
|
+
* This source code is licensed under the ISC license.
|
|
264
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
265
|
+
*/
|
|
266
|
+
const __iconData$1 = {
|
|
267
|
+
name: "scan-line",
|
|
268
|
+
size: 24,
|
|
269
|
+
node: [
|
|
270
|
+
["path", {
|
|
271
|
+
d: "M3 7V5a2 2 0 0 1 2-2h2",
|
|
272
|
+
key: "aa7l1z"
|
|
273
|
+
}],
|
|
274
|
+
["path", {
|
|
275
|
+
d: "M17 3h2a2 2 0 0 1 2 2v2",
|
|
276
|
+
key: "4qcy5o"
|
|
277
|
+
}],
|
|
278
|
+
["path", {
|
|
279
|
+
d: "M21 17v2a2 2 0 0 1-2 2h-2",
|
|
280
|
+
key: "6vwrx8"
|
|
281
|
+
}],
|
|
282
|
+
["path", {
|
|
283
|
+
d: "M7 21H5a2 2 0 0 1-2-2v-2",
|
|
284
|
+
key: "ioqczr"
|
|
285
|
+
}],
|
|
286
|
+
["path", {
|
|
287
|
+
d: "M7 12h10",
|
|
288
|
+
key: "b7w52i"
|
|
289
|
+
}]
|
|
290
|
+
]
|
|
291
|
+
};
|
|
292
|
+
__iconData$1.node;
|
|
293
|
+
const ScanLine = createLucideIcon(__iconData$1);
|
|
294
|
+
//#endregion
|
|
295
|
+
//#region ../../node_modules/.bun/lucide-react@1.43.0+83d5fd7b249dbeef/node_modules/lucide-react/dist/esm/icons/settings-2.mjs
|
|
296
|
+
/**
|
|
297
|
+
* @license lucide-react v1.43.0 - ISC
|
|
298
|
+
*
|
|
299
|
+
* This source code is licensed under the ISC license.
|
|
300
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
301
|
+
*/
|
|
302
|
+
const __iconData = {
|
|
303
|
+
name: "settings-2",
|
|
304
|
+
size: 24,
|
|
305
|
+
node: [
|
|
306
|
+
["path", {
|
|
307
|
+
d: "M14 17H5",
|
|
308
|
+
key: "gfn3mx"
|
|
309
|
+
}],
|
|
310
|
+
["path", {
|
|
311
|
+
d: "M19 7h-9",
|
|
312
|
+
key: "6i9tg"
|
|
313
|
+
}],
|
|
314
|
+
["circle", {
|
|
315
|
+
cx: "17",
|
|
316
|
+
cy: "17",
|
|
317
|
+
r: "3",
|
|
318
|
+
key: "18b49y"
|
|
319
|
+
}],
|
|
320
|
+
["circle", {
|
|
321
|
+
cx: "7",
|
|
322
|
+
cy: "7",
|
|
323
|
+
r: "3",
|
|
324
|
+
key: "dfmy0x"
|
|
325
|
+
}]
|
|
326
|
+
]
|
|
327
|
+
};
|
|
328
|
+
__iconData.node;
|
|
329
|
+
const Settings2 = createLucideIcon(__iconData);
|
|
330
|
+
//#endregion
|
|
331
|
+
//#region src/app-canvas/PageLayers.tsx
|
|
332
|
+
const excluded = /* @__PURE__ */ new Set([
|
|
333
|
+
"SCRIPT",
|
|
334
|
+
"STYLE",
|
|
335
|
+
"LINK",
|
|
336
|
+
"META",
|
|
337
|
+
"NOSCRIPT",
|
|
338
|
+
"TEMPLATE"
|
|
339
|
+
]);
|
|
340
|
+
function childrenOf(element) {
|
|
341
|
+
return Array.from(element.children).filter((child) => child.namespaceURI === "http://www.w3.org/1999/xhtml" && !excluded.has(child.tagName) && !child.hidden && child.getClientRects().length > 0);
|
|
342
|
+
}
|
|
343
|
+
function labelOf(element) {
|
|
344
|
+
return (element.getAttribute("aria-label") || element.getAttribute("alt") || (!element.children.length ? element.textContent?.trim().replace(/\s+/g, " ") : ""))?.slice(0, 48) || (element.id ? `#${element.id}` : "");
|
|
345
|
+
}
|
|
346
|
+
/** Only expanded branches are read and rendered; large pages do not create a second full DOM tree. */
|
|
347
|
+
function PageLayers({ frame, title, selected, onSelect }) {
|
|
348
|
+
const [root, setRoot] = useState(null);
|
|
349
|
+
const [, refresh] = useReducer((value) => value + 1, 0);
|
|
350
|
+
const expanded = useRef(/* @__PURE__ */ new WeakSet());
|
|
351
|
+
const collapsed = useRef(/* @__PURE__ */ new WeakSet());
|
|
352
|
+
const ids = useRef(/* @__PURE__ */ new WeakMap());
|
|
353
|
+
const nextId = useRef(0);
|
|
354
|
+
const [limit, setLimit] = useState(300);
|
|
355
|
+
useEffect(() => {
|
|
356
|
+
if (!frame) return;
|
|
357
|
+
let observer;
|
|
358
|
+
let scheduled = null;
|
|
359
|
+
const update = () => {
|
|
360
|
+
scheduled = null;
|
|
361
|
+
refresh();
|
|
362
|
+
};
|
|
363
|
+
const attach = () => {
|
|
364
|
+
observer?.disconnect();
|
|
365
|
+
try {
|
|
366
|
+
const doc = frame.contentDocument;
|
|
367
|
+
const element = doc?.querySelector("#storybook-root, #app, #root") ?? doc?.body ?? null;
|
|
368
|
+
setRoot(element);
|
|
369
|
+
if (element) {
|
|
370
|
+
observer = new MutationObserver(() => {
|
|
371
|
+
if (scheduled === null) scheduled = requestAnimationFrame(update);
|
|
372
|
+
});
|
|
373
|
+
observer.observe(element, {
|
|
374
|
+
childList: true,
|
|
375
|
+
subtree: true,
|
|
376
|
+
attributes: true,
|
|
377
|
+
characterData: true
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
} catch {
|
|
381
|
+
setRoot(null);
|
|
382
|
+
}
|
|
383
|
+
};
|
|
384
|
+
attach();
|
|
385
|
+
frame.addEventListener("load", attach);
|
|
386
|
+
return () => {
|
|
387
|
+
observer?.disconnect();
|
|
388
|
+
frame.removeEventListener("load", attach);
|
|
389
|
+
if (scheduled !== null) cancelAnimationFrame(scheduled);
|
|
390
|
+
};
|
|
391
|
+
}, [frame]);
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
if (!root || !selected || !root.contains(selected)) return;
|
|
394
|
+
for (let parent = selected.parentElement; parent && parent !== root; parent = parent.parentElement) {
|
|
395
|
+
expanded.current.add(parent);
|
|
396
|
+
collapsed.current.delete(parent);
|
|
397
|
+
}
|
|
398
|
+
refresh();
|
|
399
|
+
}, [root, selected]);
|
|
400
|
+
const toggle = (element_0, open) => {
|
|
401
|
+
if (open) {
|
|
402
|
+
expanded.current.delete(element_0);
|
|
403
|
+
collapsed.current.add(element_0);
|
|
404
|
+
} else {
|
|
405
|
+
expanded.current.add(element_0);
|
|
406
|
+
collapsed.current.delete(element_0);
|
|
407
|
+
}
|
|
408
|
+
refresh();
|
|
409
|
+
};
|
|
410
|
+
let count = 0;
|
|
411
|
+
let truncated = false;
|
|
412
|
+
const render = (element_1, depth) => {
|
|
413
|
+
if (++count > limit || depth > 60) {
|
|
414
|
+
truncated = true;
|
|
415
|
+
return null;
|
|
416
|
+
}
|
|
417
|
+
if (!ids.current.has(element_1)) ids.current.set(element_1, ++nextId.current);
|
|
418
|
+
const children = childrenOf(element_1);
|
|
419
|
+
const open_0 = !collapsed.current.has(element_1) && (depth < 2 || expanded.current.has(element_1));
|
|
420
|
+
const label = labelOf(element_1);
|
|
421
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
422
|
+
role: "treeitem",
|
|
423
|
+
"aria-label": `${element_1.localName}${label ? ` ${label}` : ""}`,
|
|
424
|
+
"aria-level": depth + 1,
|
|
425
|
+
"aria-selected": element_1 === selected,
|
|
426
|
+
"aria-expanded": children.length ? open_0 : void 0,
|
|
427
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
428
|
+
className: "povio-canvas-layer-row",
|
|
429
|
+
style: { paddingLeft: 8 + depth * 12 },
|
|
430
|
+
children: [children.length ? /* @__PURE__ */ jsx("button", {
|
|
431
|
+
className: "povio-canvas-layer-toggle",
|
|
432
|
+
"aria-label": `${open_0 ? "Collapse" : "Expand"} ${element_1.localName}${label ? ` ${label}` : ""}`,
|
|
433
|
+
onClick: () => toggle(element_1, open_0),
|
|
434
|
+
children: open_0 ? /* @__PURE__ */ jsx(ChevronDown, { size: 12 }) : /* @__PURE__ */ jsx(ChevronRight, { size: 12 })
|
|
435
|
+
}) : /* @__PURE__ */ jsx("span", { className: "povio-canvas-layer-spacer" }), /* @__PURE__ */ jsxs("button", {
|
|
436
|
+
className: "povio-canvas-layer-select",
|
|
437
|
+
title: `${element_1.localName}${label ? ` · ${label}` : ""}`,
|
|
438
|
+
onClick: () => onSelect(element_1),
|
|
439
|
+
onKeyDown: (event) => {
|
|
440
|
+
if (event.key === "ArrowRight" && children.length && !open_0) {
|
|
441
|
+
event.preventDefault();
|
|
442
|
+
toggle(element_1, false);
|
|
443
|
+
}
|
|
444
|
+
if (event.key === "ArrowLeft" && open_0) {
|
|
445
|
+
event.preventDefault();
|
|
446
|
+
toggle(element_1, true);
|
|
447
|
+
}
|
|
448
|
+
},
|
|
449
|
+
children: [/* @__PURE__ */ jsx("code", { children: element_1.localName }), label && /* @__PURE__ */ jsx("span", { children: label })]
|
|
450
|
+
})]
|
|
451
|
+
}), open_0 && !!children.length && /* @__PURE__ */ jsx("div", {
|
|
452
|
+
role: "group",
|
|
453
|
+
children: children.map((child) => render(child, depth + 1))
|
|
454
|
+
})]
|
|
455
|
+
}, ids.current.get(element_1));
|
|
456
|
+
};
|
|
457
|
+
const content = root ? childrenOf(root).map((element_2) => render(element_2, 0)) : null;
|
|
458
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
459
|
+
className: "povio-canvas-layers",
|
|
460
|
+
"aria-label": `Layers for ${title}`,
|
|
461
|
+
children: [
|
|
462
|
+
/* @__PURE__ */ jsxs("header", { children: [
|
|
463
|
+
/* @__PURE__ */ jsx(CodeXml, { size: 14 }),
|
|
464
|
+
/* @__PURE__ */ jsx("strong", { children: "Layers" }),
|
|
465
|
+
/* @__PURE__ */ jsx("span", { children: title })
|
|
466
|
+
] }),
|
|
467
|
+
/* @__PURE__ */ jsx("div", {
|
|
468
|
+
role: "tree",
|
|
469
|
+
"aria-label": "HTML layers",
|
|
470
|
+
children: content
|
|
471
|
+
}),
|
|
472
|
+
!root && /* @__PURE__ */ jsx("p", { children: "Waiting for the page…" }),
|
|
473
|
+
truncated && /* @__PURE__ */ jsx("button", {
|
|
474
|
+
className: "povio-canvas-more-layers",
|
|
475
|
+
onClick: () => setLimit((value_0) => value_0 + 300),
|
|
476
|
+
children: "Show more layers"
|
|
477
|
+
})
|
|
478
|
+
]
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
//#endregion
|
|
482
|
+
//#region src/app-canvas/CanvasInspector.tsx
|
|
483
|
+
const unknownToken = () => false;
|
|
484
|
+
const readOnly = () => {};
|
|
485
|
+
/** Inspect the live iframe DOM using its own, unscaled viewport coordinates. */
|
|
486
|
+
function useCanvasInspector(enabled, generation) {
|
|
487
|
+
const [selection, setSelection] = useState(null);
|
|
488
|
+
const [measurement, setMeasurement] = useState(null);
|
|
489
|
+
const [pinned, setPinned] = useState(false);
|
|
490
|
+
const [highlightKey, setHighlightKey] = useState(null);
|
|
491
|
+
const hoverFrame = useRef(null);
|
|
492
|
+
const pending = useRef(null);
|
|
493
|
+
const clear = useCallback(() => {
|
|
494
|
+
if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
|
|
495
|
+
hoverFrame.current = null;
|
|
496
|
+
pending.current = null;
|
|
497
|
+
setSelection(null);
|
|
498
|
+
setMeasurement(null);
|
|
499
|
+
setPinned(false);
|
|
500
|
+
setHighlightKey(null);
|
|
501
|
+
}, []);
|
|
502
|
+
useEffect(() => {
|
|
503
|
+
if (!enabled) clear();
|
|
504
|
+
}, [enabled, clear]);
|
|
505
|
+
useEffect(() => {
|
|
506
|
+
clear();
|
|
507
|
+
}, [generation, clear]);
|
|
508
|
+
useEffect(() => () => {
|
|
509
|
+
if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
|
|
510
|
+
}, []);
|
|
511
|
+
const pick = useCallback((pageId, frame, clientX, clientY, pin) => {
|
|
512
|
+
if (!enabled || pinned && !pin) return;
|
|
513
|
+
const bounds = frame.getBoundingClientRect();
|
|
514
|
+
if (!bounds.width || !bounds.height) return;
|
|
515
|
+
try {
|
|
516
|
+
const doc = frame.contentDocument;
|
|
517
|
+
if (!doc) return;
|
|
518
|
+
const x = (clientX - bounds.left) * frame.clientWidth / bounds.width;
|
|
519
|
+
const y = (clientY - bounds.top) * frame.clientHeight / bounds.height;
|
|
520
|
+
const hit = doc.elementFromPoint(x, y);
|
|
521
|
+
const element = hit?.closest("button,input,textarea,select,a,label,[role],h1,h2,h3,h4,h5,h6,p") ?? hit;
|
|
522
|
+
if (!element || element === doc.documentElement || element === doc.body || element.namespaceURI !== "http://www.w3.org/1999/xhtml") return;
|
|
523
|
+
const target = element;
|
|
524
|
+
setSelection((current) => current?.element === target ? current : {
|
|
525
|
+
pageId,
|
|
526
|
+
element: target
|
|
527
|
+
});
|
|
528
|
+
setHighlightKey(null);
|
|
529
|
+
if (pin) setPinned((current_0) => !(current_0 && selection?.element === target));
|
|
530
|
+
} catch {
|
|
531
|
+
clear();
|
|
532
|
+
}
|
|
533
|
+
}, [
|
|
534
|
+
enabled,
|
|
535
|
+
pinned,
|
|
536
|
+
selection,
|
|
537
|
+
clear
|
|
538
|
+
]);
|
|
539
|
+
const hover = useCallback((pageId_0, frame_0, x_0, y_0) => {
|
|
540
|
+
if (!enabled || pinned) return;
|
|
541
|
+
pending.current = () => pick(pageId_0, frame_0, x_0, y_0, false);
|
|
542
|
+
if (hoverFrame.current !== null) return;
|
|
543
|
+
hoverFrame.current = requestAnimationFrame(() => {
|
|
544
|
+
hoverFrame.current = null;
|
|
545
|
+
pending.current?.();
|
|
546
|
+
pending.current = null;
|
|
547
|
+
});
|
|
548
|
+
}, [
|
|
549
|
+
enabled,
|
|
550
|
+
pinned,
|
|
551
|
+
pick
|
|
552
|
+
]);
|
|
553
|
+
const select = useCallback((pageId_1, frame_1, x_1, y_1) => {
|
|
554
|
+
if (hoverFrame.current !== null) cancelAnimationFrame(hoverFrame.current);
|
|
555
|
+
hoverFrame.current = null;
|
|
556
|
+
pending.current = null;
|
|
557
|
+
pick(pageId_1, frame_1, x_1, y_1, true);
|
|
558
|
+
}, [pick]);
|
|
559
|
+
useEffect(() => {
|
|
560
|
+
if (!enabled || !selection) return;
|
|
561
|
+
const { element: element_0 } = selection;
|
|
562
|
+
const doc_0 = element_0.ownerDocument;
|
|
563
|
+
const owner = doc_0.defaultView;
|
|
564
|
+
if (!owner) return;
|
|
565
|
+
let scheduled = null;
|
|
566
|
+
const measure = () => {
|
|
567
|
+
scheduled = null;
|
|
568
|
+
if (!element_0.isConnected) {
|
|
569
|
+
clear();
|
|
570
|
+
return;
|
|
571
|
+
}
|
|
572
|
+
const rect = element_0.getBoundingClientRect();
|
|
573
|
+
const snapshot = inspectElement(element_0, unknownToken);
|
|
574
|
+
const details = highlightKey ? getBoxHighlights(element_0, highlightKey) : null;
|
|
575
|
+
const spacing = highlightKey ? [] : [
|
|
576
|
+
"padding.top",
|
|
577
|
+
"padding.right",
|
|
578
|
+
"padding.bottom",
|
|
579
|
+
"padding.left",
|
|
580
|
+
"margin.top",
|
|
581
|
+
"margin.right",
|
|
582
|
+
"margin.bottom",
|
|
583
|
+
"margin.left",
|
|
584
|
+
"gap.row",
|
|
585
|
+
"gap.column"
|
|
586
|
+
].flatMap((key) => {
|
|
587
|
+
const [kind, side] = key.split(".");
|
|
588
|
+
const raw = kind === "padding" ? snapshot.box.padding[side] : kind === "margin" ? snapshot.box.margin[side] : snapshot.box.gap[side];
|
|
589
|
+
if (!(Math.abs(Number.parseFloat(raw)) > 0)) return [];
|
|
590
|
+
const details_0 = getBoxHighlights(element_0, key);
|
|
591
|
+
const regions = details_0.regions.filter((region) => region.width > 0 && region.height > 0);
|
|
592
|
+
return regions.length ? [{
|
|
593
|
+
key,
|
|
594
|
+
label: details_0.label,
|
|
595
|
+
regions
|
|
596
|
+
}] : [];
|
|
597
|
+
});
|
|
598
|
+
if (!highlightKey) {
|
|
599
|
+
const seen = new Set(spacing.flatMap((item) => item.regions.map((region_0) => `${item.key}:${region_0.left}:${region_0.top}:${region_0.width}:${region_0.height}`)));
|
|
600
|
+
for (const child of Array.from(element_0.children).slice(0, 80)) {
|
|
601
|
+
if (child.namespaceURI !== "http://www.w3.org/1999/xhtml" || !child.getClientRects().length) continue;
|
|
602
|
+
const style = owner.getComputedStyle(child);
|
|
603
|
+
if (style.display === "none" || style.visibility === "hidden" || /^(absolute|fixed)$/.test(style.position)) continue;
|
|
604
|
+
for (const side_0 of [
|
|
605
|
+
"top",
|
|
606
|
+
"right",
|
|
607
|
+
"bottom",
|
|
608
|
+
"left"
|
|
609
|
+
]) {
|
|
610
|
+
if (!(Math.abs(Number.parseFloat(style.getPropertyValue(`margin-${side_0}`))) > 0)) continue;
|
|
611
|
+
const key_0 = `margin.${side_0}`;
|
|
612
|
+
const details_1 = getBoxHighlights(child, key_0);
|
|
613
|
+
const regions_0 = details_1.regions.filter((region_1) => {
|
|
614
|
+
const id = `${key_0}:${region_1.left}:${region_1.top}:${region_1.width}:${region_1.height}`;
|
|
615
|
+
if (seen.has(id)) return false;
|
|
616
|
+
seen.add(id);
|
|
617
|
+
return region_1.width > 0 && region_1.height > 0;
|
|
618
|
+
});
|
|
619
|
+
if (regions_0.length) spacing.push({
|
|
620
|
+
key: key_0,
|
|
621
|
+
label: details_1.label,
|
|
622
|
+
regions: regions_0
|
|
623
|
+
});
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
const next = {
|
|
628
|
+
snapshot,
|
|
629
|
+
spacing,
|
|
630
|
+
outline: {
|
|
631
|
+
left: rect.left,
|
|
632
|
+
top: rect.top,
|
|
633
|
+
width: rect.width,
|
|
634
|
+
height: rect.height
|
|
635
|
+
},
|
|
636
|
+
highlight: details && highlightKey ? {
|
|
637
|
+
key: highlightKey,
|
|
638
|
+
...details
|
|
639
|
+
} : null
|
|
640
|
+
};
|
|
641
|
+
setMeasurement((current_1) => JSON.stringify(current_1) === JSON.stringify(next) ? current_1 : next);
|
|
642
|
+
};
|
|
643
|
+
const schedule = () => {
|
|
644
|
+
if (scheduled === null) scheduled = requestAnimationFrame(measure);
|
|
645
|
+
};
|
|
646
|
+
const mutations = new MutationObserver(schedule);
|
|
647
|
+
mutations.observe(doc_0.documentElement, {
|
|
648
|
+
subtree: true,
|
|
649
|
+
childList: true,
|
|
650
|
+
attributes: true,
|
|
651
|
+
characterData: true
|
|
652
|
+
});
|
|
653
|
+
const resize = new ResizeObserver(schedule);
|
|
654
|
+
resize.observe(element_0);
|
|
655
|
+
owner.addEventListener("scroll", schedule, true);
|
|
656
|
+
measure();
|
|
657
|
+
return () => {
|
|
658
|
+
mutations.disconnect();
|
|
659
|
+
resize.disconnect();
|
|
660
|
+
owner.removeEventListener("scroll", schedule, true);
|
|
661
|
+
if (scheduled !== null) cancelAnimationFrame(scheduled);
|
|
662
|
+
};
|
|
663
|
+
}, [
|
|
664
|
+
enabled,
|
|
665
|
+
selection,
|
|
666
|
+
highlightKey,
|
|
667
|
+
clear
|
|
668
|
+
]);
|
|
669
|
+
return {
|
|
670
|
+
selection,
|
|
671
|
+
selectElement: (pageId_2, element_1) => {
|
|
672
|
+
setSelection({
|
|
673
|
+
pageId: pageId_2,
|
|
674
|
+
element: element_1
|
|
675
|
+
});
|
|
676
|
+
setPinned(true);
|
|
677
|
+
setHighlightKey(null);
|
|
678
|
+
},
|
|
679
|
+
measurement,
|
|
680
|
+
pinned,
|
|
681
|
+
hover,
|
|
682
|
+
select,
|
|
683
|
+
clear,
|
|
684
|
+
highlight: setHighlightKey,
|
|
685
|
+
togglePin: () => setPinned((value) => !value)
|
|
686
|
+
};
|
|
687
|
+
}
|
|
688
|
+
function CanvasInspectorPanel(t0) {
|
|
689
|
+
const $ = c(21);
|
|
690
|
+
const { inspector, onClose } = t0;
|
|
691
|
+
let t1;
|
|
692
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
693
|
+
t1 = /* @__PURE__ */ jsx("strong", { children: "Inspector view" });
|
|
694
|
+
$[0] = t1;
|
|
695
|
+
} else t1 = $[0];
|
|
696
|
+
const t2 = !inspector.selection;
|
|
697
|
+
let t3;
|
|
698
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
699
|
+
t3 = /* @__PURE__ */ jsx(Pin, { size: 14 });
|
|
700
|
+
$[1] = t3;
|
|
701
|
+
} else t3 = $[1];
|
|
702
|
+
let t4;
|
|
703
|
+
if ($[2] !== inspector.pinned || $[3] !== inspector.togglePin || $[4] !== t2) {
|
|
704
|
+
t4 = /* @__PURE__ */ jsx("button", {
|
|
705
|
+
"aria-label": "Pin inspected element",
|
|
706
|
+
"aria-pressed": inspector.pinned,
|
|
707
|
+
disabled: t2,
|
|
708
|
+
onClick: inspector.togglePin,
|
|
709
|
+
children: t3
|
|
710
|
+
});
|
|
711
|
+
$[2] = inspector.pinned;
|
|
712
|
+
$[3] = inspector.togglePin;
|
|
713
|
+
$[4] = t2;
|
|
714
|
+
$[5] = t4;
|
|
715
|
+
} else t4 = $[5];
|
|
716
|
+
let t5;
|
|
717
|
+
if ($[6] === Symbol.for("react.memo_cache_sentinel")) {
|
|
718
|
+
t5 = /* @__PURE__ */ jsx(X, { size: 15 });
|
|
719
|
+
$[6] = t5;
|
|
720
|
+
} else t5 = $[6];
|
|
721
|
+
let t6;
|
|
722
|
+
if ($[7] !== onClose) {
|
|
723
|
+
t6 = /* @__PURE__ */ jsx("button", {
|
|
724
|
+
"aria-label": "Close inspector view",
|
|
725
|
+
onClick: onClose,
|
|
726
|
+
children: t5
|
|
727
|
+
});
|
|
728
|
+
$[7] = onClose;
|
|
729
|
+
$[8] = t6;
|
|
730
|
+
} else t6 = $[8];
|
|
731
|
+
let t7;
|
|
732
|
+
if ($[9] !== t4 || $[10] !== t6) {
|
|
733
|
+
t7 = /* @__PURE__ */ jsxs("header", { children: [
|
|
734
|
+
t1,
|
|
735
|
+
t4,
|
|
736
|
+
t6
|
|
737
|
+
] });
|
|
738
|
+
$[9] = t4;
|
|
739
|
+
$[10] = t6;
|
|
740
|
+
$[11] = t7;
|
|
741
|
+
} else t7 = $[11];
|
|
742
|
+
const t8 = inspector.pinned ? "Selection pinned · click it again to unpin" : "Hover a component · click to pin";
|
|
743
|
+
let t9;
|
|
744
|
+
if ($[12] !== t8) {
|
|
745
|
+
t9 = /* @__PURE__ */ jsx("p", {
|
|
746
|
+
className: "povio-canvas-inspect-hint",
|
|
747
|
+
children: t8
|
|
748
|
+
});
|
|
749
|
+
$[12] = t8;
|
|
750
|
+
$[13] = t9;
|
|
751
|
+
} else t9 = $[13];
|
|
752
|
+
let t10;
|
|
753
|
+
if ($[14] !== inspector.highlight || $[15] !== inspector.measurement) {
|
|
754
|
+
t10 = inspector.measurement ? /* @__PURE__ */ jsx(InspectorDetails, {
|
|
755
|
+
snapshot: inspector.measurement.snapshot,
|
|
756
|
+
onSelect: readOnly,
|
|
757
|
+
onHighlight: inspector.highlight
|
|
758
|
+
}) : /* @__PURE__ */ jsx("p", {
|
|
759
|
+
className: "povio-canvas-inspect-hint",
|
|
760
|
+
children: "Inspect a live page to see its padding, margins, borders, radii and gaps."
|
|
761
|
+
});
|
|
762
|
+
$[14] = inspector.highlight;
|
|
763
|
+
$[15] = inspector.measurement;
|
|
764
|
+
$[16] = t10;
|
|
765
|
+
} else t10 = $[16];
|
|
766
|
+
let t11;
|
|
767
|
+
if ($[17] !== t10 || $[18] !== t7 || $[19] !== t9) {
|
|
768
|
+
t11 = /* @__PURE__ */ jsxs("aside", {
|
|
769
|
+
className: "studio-inspector-panel povio-canvas-inspector",
|
|
770
|
+
"aria-label": "Inspector view",
|
|
771
|
+
children: [
|
|
772
|
+
t7,
|
|
773
|
+
t9,
|
|
774
|
+
t10
|
|
775
|
+
]
|
|
776
|
+
});
|
|
777
|
+
$[17] = t10;
|
|
778
|
+
$[18] = t7;
|
|
779
|
+
$[19] = t9;
|
|
780
|
+
$[20] = t11;
|
|
781
|
+
} else t11 = $[20];
|
|
782
|
+
return t11;
|
|
783
|
+
}
|
|
784
|
+
function CanvasInspectionOverlay(t0) {
|
|
785
|
+
const $ = c(9);
|
|
786
|
+
const { measurement, width } = t0;
|
|
787
|
+
let t1;
|
|
788
|
+
if ($[0] !== measurement.outline) {
|
|
789
|
+
t1 = /* @__PURE__ */ jsx("div", {
|
|
790
|
+
className: "studio-hover-outline",
|
|
791
|
+
style: measurement.outline
|
|
792
|
+
});
|
|
793
|
+
$[0] = measurement.outline;
|
|
794
|
+
$[1] = t1;
|
|
795
|
+
} else t1 = $[1];
|
|
796
|
+
let t2;
|
|
797
|
+
if ($[2] !== measurement.highlight || $[3] !== measurement.spacing || $[4] !== width) {
|
|
798
|
+
t2 = measurement.highlight ? /* @__PURE__ */ jsx(HighlightOverlay, {
|
|
799
|
+
highlight: measurement.highlight,
|
|
800
|
+
width
|
|
801
|
+
}) : measurement.spacing.map((highlight) => /* @__PURE__ */ jsxs("div", {
|
|
802
|
+
className: "povio-canvas-auto-spacing",
|
|
803
|
+
children: [/* @__PURE__ */ jsx(HighlightOverlay, {
|
|
804
|
+
highlight,
|
|
805
|
+
width
|
|
806
|
+
}), highlight.regions.map((region) => /* @__PURE__ */ jsx("span", {
|
|
807
|
+
className: "povio-canvas-spacing-value",
|
|
808
|
+
style: {
|
|
809
|
+
left: region.left + region.width / 2,
|
|
810
|
+
top: region.top + region.height / 2
|
|
811
|
+
},
|
|
812
|
+
children: highlight.label.split(": ")[1]
|
|
813
|
+
}, `${region.left}:${region.top}:${region.width}:${region.height}`))]
|
|
814
|
+
}, `${highlight.key}:${highlight.label}:${highlight.regions[0]?.left}:${highlight.regions[0]?.top}`));
|
|
815
|
+
$[2] = measurement.highlight;
|
|
816
|
+
$[3] = measurement.spacing;
|
|
817
|
+
$[4] = width;
|
|
818
|
+
$[5] = t2;
|
|
819
|
+
} else t2 = $[5];
|
|
820
|
+
let t3;
|
|
821
|
+
if ($[6] !== t1 || $[7] !== t2) {
|
|
822
|
+
t3 = /* @__PURE__ */ jsxs("div", {
|
|
823
|
+
className: "povio-canvas-inspection-overlay",
|
|
824
|
+
"aria-hidden": "true",
|
|
825
|
+
children: [t1, t2]
|
|
826
|
+
});
|
|
827
|
+
$[6] = t1;
|
|
828
|
+
$[7] = t2;
|
|
829
|
+
$[8] = t3;
|
|
830
|
+
} else t3 = $[8];
|
|
831
|
+
return t3;
|
|
832
|
+
}
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region src/app-canvas/route-model.ts
|
|
835
|
+
function joinPath(parent, path) {
|
|
836
|
+
return `${parent.replace(/\/$/, "")}/${path.replace(/^\//, "")}`.replace(/\/{2,}/g, "/") || "/";
|
|
837
|
+
}
|
|
838
|
+
function resolvePath(path, params) {
|
|
839
|
+
const missingParams = /* @__PURE__ */ new Set();
|
|
840
|
+
const value = (key, optional = false) => {
|
|
841
|
+
const actualKey = key || "_splat";
|
|
842
|
+
const raw = params[actualKey];
|
|
843
|
+
if (raw === void 0 || !optional && raw === "") {
|
|
844
|
+
if (!optional) missingParams.add(actualKey);
|
|
845
|
+
return "";
|
|
846
|
+
}
|
|
847
|
+
return actualKey === "_splat" ? raw.split("/").map(encodeURIComponent).join("/") : encodeURIComponent(raw);
|
|
848
|
+
};
|
|
849
|
+
return {
|
|
850
|
+
href: `/${path.split("/").map((segment) => {
|
|
851
|
+
if (segment.includes("{")) return segment.replace(/\{(-?)\$([^}]*)\}/g, (_, optional, key) => value(key, optional === "-"));
|
|
852
|
+
return segment.startsWith("$") ? value(segment.slice(1)) : segment;
|
|
853
|
+
}).filter(Boolean).join("/")}`,
|
|
854
|
+
missingParams: [...missingParams]
|
|
855
|
+
};
|
|
856
|
+
}
|
|
857
|
+
/** Catalog route destinations without executing loaders or needing every dynamic parameter. */
|
|
858
|
+
function discoverCanvasPages(router, options = {}) {
|
|
859
|
+
const records = [];
|
|
860
|
+
const visited = /* @__PURE__ */ new Set();
|
|
861
|
+
function visit(route, parentPath, ancestors, root = false) {
|
|
862
|
+
if (visited.has(route)) return;
|
|
863
|
+
visited.add(route);
|
|
864
|
+
const localPath = route.path ?? route.options?.path;
|
|
865
|
+
const path = route.fullPath ?? (localPath ? joinPath(parentPath, localPath) : parentPath);
|
|
866
|
+
const id = route.id ?? route.options?.id ?? path;
|
|
867
|
+
const children = Object.values(route.children ?? {});
|
|
868
|
+
if (!root && localPath !== void 0 && !options.exclude?.includes(id)) records.push({
|
|
869
|
+
route,
|
|
870
|
+
id,
|
|
871
|
+
path,
|
|
872
|
+
ancestors,
|
|
873
|
+
index: localPath === "/"
|
|
874
|
+
});
|
|
875
|
+
for (const child of children) visit(child, path, [...ancestors, id]);
|
|
876
|
+
}
|
|
877
|
+
visit(router.routeTree, "/", [], true);
|
|
878
|
+
for (const route of Object.values(router.routesById ?? {})) if (!visited.has(route)) visit(route, "/", []);
|
|
879
|
+
const byPath = /* @__PURE__ */ new Map();
|
|
880
|
+
for (const record of records) {
|
|
881
|
+
const key = record.path.replace(/\/$/, "") || "/";
|
|
882
|
+
const existing = byPath.get(key);
|
|
883
|
+
if (!existing || record.index || record.ancestors.length > existing.ancestors.length) byPath.set(key, record);
|
|
884
|
+
}
|
|
885
|
+
const selectedIds = new Set([...byPath.values()].map(({ id }) => id));
|
|
886
|
+
const destinationIds = new Map(records.map((record) => [record.id, byPath.get(record.path.replace(/\/$/, "") || "/")?.id]));
|
|
887
|
+
return [...byPath.values()].map(({ id, path, ancestors }) => {
|
|
888
|
+
const example = options.examples?.[id];
|
|
889
|
+
const resolved = resolvePath(path, example?.params ?? {});
|
|
890
|
+
const query = new URLSearchParams();
|
|
891
|
+
for (const [key, value] of Object.entries(example?.search ?? {})) if (value !== void 0) query.set(key, typeof value === "string" ? value : JSON.stringify(value));
|
|
892
|
+
const queryString = query.toString();
|
|
893
|
+
return {
|
|
894
|
+
id,
|
|
895
|
+
path,
|
|
896
|
+
title: example?.title ?? (path === "/" ? "Home" : path),
|
|
897
|
+
href: resolved.missingParams.length ? void 0 : `${resolved.href}${queryString ? `?${queryString}` : ""}`,
|
|
898
|
+
parentId: [...ancestors].reverse().map((ancestor) => destinationIds.get(ancestor) ?? ancestor).find((ancestor) => ancestor !== id && selectedIds.has(ancestor)),
|
|
899
|
+
missingParams: resolved.missingParams,
|
|
900
|
+
kind: resolved.missingParams.length ? "unresolved" : "page"
|
|
901
|
+
};
|
|
902
|
+
});
|
|
903
|
+
}
|
|
904
|
+
/** Deterministic masonry placement. Full measured heights (including 20,000px pages) are never capped. */
|
|
905
|
+
function layoutCanvasPages(pages, width, heights, positions = {}) {
|
|
906
|
+
const pageWidth = Number.isFinite(width) && width > 0 ? width : 1440;
|
|
907
|
+
const columns = Math.min(3, Math.max(1, pages.length));
|
|
908
|
+
const bottoms = Array.from({ length: columns }, () => 0);
|
|
909
|
+
for (const page of pages) {
|
|
910
|
+
const saved = positions[page.id];
|
|
911
|
+
if (!saved || !Number.isFinite(saved.x) || !Number.isFinite(saved.y)) continue;
|
|
912
|
+
const measured = heights[page.id];
|
|
913
|
+
const height = Number.isFinite(measured) && measured > 0 ? measured : 900;
|
|
914
|
+
for (let i = 0; i < columns; i++) {
|
|
915
|
+
const x = i * (pageWidth + 80);
|
|
916
|
+
if (saved.x < x + pageWidth && saved.x + pageWidth > x) bottoms[i] = Math.max(bottoms[i], saved.y + height + 128);
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
const result = [];
|
|
920
|
+
for (const page of pages) {
|
|
921
|
+
const measured = heights[page.id];
|
|
922
|
+
const height = Number.isFinite(measured) && measured > 0 ? measured : 900;
|
|
923
|
+
const column = bottoms.indexOf(Math.min(...bottoms));
|
|
924
|
+
const saved = positions[page.id];
|
|
925
|
+
const position = saved && Number.isFinite(saved.x) && Number.isFinite(saved.y) ? saved : {
|
|
926
|
+
x: column * (pageWidth + 80),
|
|
927
|
+
y: bottoms[column]
|
|
928
|
+
};
|
|
929
|
+
result.push({
|
|
930
|
+
...page,
|
|
931
|
+
...position,
|
|
932
|
+
width: pageWidth,
|
|
933
|
+
height
|
|
934
|
+
});
|
|
935
|
+
for (let i = 0; i < columns; i++) {
|
|
936
|
+
const x = i * (pageWidth + 80);
|
|
937
|
+
if (position.x < x + pageWidth && position.x + pageWidth > x) bottoms[i] = Math.max(bottoms[i], position.y + height + 128);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
return result;
|
|
941
|
+
}
|
|
942
|
+
/** Match observed navigation back to a catalog destination, including optional and splat routes. */
|
|
943
|
+
function matchCanvasPageHref(pages, href, base = "http://canvas.local/") {
|
|
944
|
+
let pathname;
|
|
945
|
+
try {
|
|
946
|
+
pathname = new URL(href, base).pathname.replace(/\/$/, "") || "/";
|
|
947
|
+
} catch {
|
|
948
|
+
return;
|
|
949
|
+
}
|
|
950
|
+
const exact = pages.find((page) => {
|
|
951
|
+
if (!page.href) return false;
|
|
952
|
+
try {
|
|
953
|
+
return (new URL(page.href, base).pathname.replace(/\/$/, "") || "/") === pathname;
|
|
954
|
+
} catch {
|
|
955
|
+
return false;
|
|
956
|
+
}
|
|
957
|
+
});
|
|
958
|
+
if (exact) return exact;
|
|
959
|
+
const escape = (part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
960
|
+
for (const page of pages) {
|
|
961
|
+
const pattern = page.path.split("/").filter(Boolean).map((part) => {
|
|
962
|
+
if (part === "$") return "/.+";
|
|
963
|
+
if (part.startsWith("$")) return "/[^/]+";
|
|
964
|
+
let text = "", cursor = 0;
|
|
965
|
+
let optional = false;
|
|
966
|
+
for (const match of part.matchAll(/\{(-?)\$([^}]*)\}/g)) {
|
|
967
|
+
text += escape(part.slice(cursor, match.index)) + (match[2] ? "[^/]+" : ".+");
|
|
968
|
+
cursor = match.index + match[0].length;
|
|
969
|
+
optional ||= match[1] === "-";
|
|
970
|
+
}
|
|
971
|
+
text += escape(part.slice(cursor));
|
|
972
|
+
return optional ? `(?:/${text})?` : `/${text}`;
|
|
973
|
+
}).join("");
|
|
974
|
+
if (new RegExp(`^${pattern || "/"}$`).test(pathname)) return page;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
//#endregion
|
|
978
|
+
//#region src/app-canvas/protocol.ts
|
|
979
|
+
const canvasProtocol = "povio-app-canvas-v1";
|
|
980
|
+
function canvasFrameIdentity() {
|
|
981
|
+
if (typeof window === "undefined" || window.parent === window) return null;
|
|
982
|
+
try {
|
|
983
|
+
const query = new URLSearchParams(window.location.search);
|
|
984
|
+
const name = window.name.startsWith(`povio-app-canvas-v1:`) ? JSON.parse(window.name.slice(20)) : null;
|
|
985
|
+
const id = query.get("__povio_canvas_frame") ?? name?.id;
|
|
986
|
+
const token = query.get("__povio_canvas_token") ?? name?.token;
|
|
987
|
+
const height = Number(query.get("__povio_canvas_height") ?? name?.viewportHeight ?? 900);
|
|
988
|
+
return typeof id === "string" && typeof token === "string" && token.length > 10 ? {
|
|
989
|
+
id,
|
|
990
|
+
token,
|
|
991
|
+
viewportHeight: Math.max(240, Math.min(4e3, height || 900))
|
|
992
|
+
} : null;
|
|
993
|
+
} catch {
|
|
994
|
+
return null;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
const isAppCanvasFrame = () => !!canvasFrameIdentity();
|
|
998
|
+
function validConfiguration(value) {
|
|
999
|
+
if (!value || typeof value !== "object") return false;
|
|
1000
|
+
const config = value;
|
|
1001
|
+
return !!config.theme && [
|
|
1002
|
+
"light",
|
|
1003
|
+
"dark",
|
|
1004
|
+
"theme"
|
|
1005
|
+
].every((key) => {
|
|
1006
|
+
const tokens = config.theme[key];
|
|
1007
|
+
return tokens && typeof tokens === "object" && Object.values(tokens).every((v) => typeof v === "string");
|
|
1008
|
+
}) && !!config.config && typeof config.config === "object";
|
|
1009
|
+
}
|
|
1010
|
+
//#endregion
|
|
1011
|
+
//#region src/app-canvas/manifest.ts
|
|
1012
|
+
function createCanvasManifest() {
|
|
1013
|
+
return {
|
|
1014
|
+
version: 1,
|
|
1015
|
+
positions: {},
|
|
1016
|
+
examples: {},
|
|
1017
|
+
manualEdges: [],
|
|
1018
|
+
hiddenEdges: [],
|
|
1019
|
+
breakpoint: "desktop"
|
|
1020
|
+
};
|
|
1021
|
+
}
|
|
1022
|
+
function isRecord(value) {
|
|
1023
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1024
|
+
}
|
|
1025
|
+
function isJSON(value, ancestors = /* @__PURE__ */ new Set(), depth = 0) {
|
|
1026
|
+
if (value === null || typeof value === "string" || typeof value === "boolean") return true;
|
|
1027
|
+
if (typeof value === "number") return Number.isFinite(value);
|
|
1028
|
+
if (typeof value !== "object" || depth > 30 || ancestors.has(value)) return false;
|
|
1029
|
+
ancestors.add(value);
|
|
1030
|
+
const valid = Object.values(value).every((child) => isJSON(child, ancestors, depth + 1));
|
|
1031
|
+
ancestors.delete(value);
|
|
1032
|
+
return valid;
|
|
1033
|
+
}
|
|
1034
|
+
/** Sanitize either stored JSON text or an imported value, retaining valid v1 entries. */
|
|
1035
|
+
function parseCanvasManifest(input) {
|
|
1036
|
+
const fallback = createCanvasManifest();
|
|
1037
|
+
let value = input;
|
|
1038
|
+
if (typeof value === "string") try {
|
|
1039
|
+
value = JSON.parse(value);
|
|
1040
|
+
} catch {
|
|
1041
|
+
return fallback;
|
|
1042
|
+
}
|
|
1043
|
+
if (!isRecord(value) || value.version !== 1) return fallback;
|
|
1044
|
+
const positions = Object.fromEntries(Object.entries(isRecord(value.positions) ? value.positions : {}).flatMap(([breakpoint, entries]) => {
|
|
1045
|
+
if (!isRecord(entries)) return [];
|
|
1046
|
+
return [[breakpoint, Object.fromEntries(Object.entries(entries).flatMap(([id, point]) => isRecord(point) && typeof point.x === "number" && Number.isFinite(point.x) && typeof point.y === "number" && Number.isFinite(point.y) ? [[id, {
|
|
1047
|
+
x: point.x,
|
|
1048
|
+
y: point.y
|
|
1049
|
+
}]] : []))]];
|
|
1050
|
+
}));
|
|
1051
|
+
const examples = Object.fromEntries(Object.entries(isRecord(value.examples) ? value.examples : {}).flatMap(([id, example]) => {
|
|
1052
|
+
if (!isRecord(example)) return [];
|
|
1053
|
+
const clean = {};
|
|
1054
|
+
if (typeof example.title === "string") clean.title = example.title;
|
|
1055
|
+
if (isRecord(example.params)) clean.params = Object.fromEntries(Object.entries(example.params).filter((entry) => typeof entry[1] === "string"));
|
|
1056
|
+
if (isRecord(example.search)) clean.search = Object.fromEntries(Object.entries(example.search).filter(([, item]) => isJSON(item)));
|
|
1057
|
+
return [[id, clean]];
|
|
1058
|
+
}));
|
|
1059
|
+
const manualEdges = (Array.isArray(value.manualEdges) ? value.manualEdges : []).flatMap((edge) => isRecord(edge) && typeof edge.from === "string" && edge.from.length > 0 && typeof edge.to === "string" && edge.to.length > 0 ? [{
|
|
1060
|
+
from: edge.from,
|
|
1061
|
+
to: edge.to
|
|
1062
|
+
}] : []);
|
|
1063
|
+
return {
|
|
1064
|
+
version: 1,
|
|
1065
|
+
positions,
|
|
1066
|
+
examples,
|
|
1067
|
+
manualEdges: [...new Map(manualEdges.map((edge) => [JSON.stringify(edge), edge])).values()],
|
|
1068
|
+
hiddenEdges: [...new Set((Array.isArray(value.hiddenEdges) ? value.hiddenEdges : []).filter((edge) => typeof edge === "string"))],
|
|
1069
|
+
breakpoint: typeof value.breakpoint === "string" && value.breakpoint.length > 0 ? value.breakpoint : fallback.breakpoint
|
|
1070
|
+
};
|
|
1071
|
+
}
|
|
1072
|
+
//#endregion
|
|
1073
|
+
//#region src/app-canvas/AppCanvas.tsx
|
|
1074
|
+
const defaultCanvasBreakpoints = [
|
|
1075
|
+
{
|
|
1076
|
+
id: "mobile",
|
|
1077
|
+
label: "Mobile",
|
|
1078
|
+
width: 390,
|
|
1079
|
+
height: 844
|
|
1080
|
+
},
|
|
1081
|
+
{
|
|
1082
|
+
id: "tablet",
|
|
1083
|
+
label: "Tablet",
|
|
1084
|
+
width: 768,
|
|
1085
|
+
height: 1024
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
id: "desktop",
|
|
1089
|
+
label: "Desktop",
|
|
1090
|
+
width: 1440,
|
|
1091
|
+
height: 900
|
|
1092
|
+
}
|
|
1093
|
+
];
|
|
1094
|
+
const emptyExamples = {};
|
|
1095
|
+
const emptyExclude = [];
|
|
1096
|
+
function readManifest(key) {
|
|
1097
|
+
if (typeof window === "undefined") return createCanvasManifest();
|
|
1098
|
+
try {
|
|
1099
|
+
return parseCanvasManifest(localStorage.getItem(key));
|
|
1100
|
+
} catch {
|
|
1101
|
+
return createCanvasManifest();
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
const PageFrame = memo(function PageFrame(t0) {
|
|
1105
|
+
const $ = c(16);
|
|
1106
|
+
const { id, src, width, height, name, interact, inspect, onLoad, register } = t0;
|
|
1107
|
+
let t1;
|
|
1108
|
+
if ($[0] !== id || $[1] !== register) {
|
|
1109
|
+
t1 = (element) => register(id, element);
|
|
1110
|
+
$[0] = id;
|
|
1111
|
+
$[1] = register;
|
|
1112
|
+
$[2] = t1;
|
|
1113
|
+
} else t1 = $[2];
|
|
1114
|
+
const t2 = !interact && !inspect;
|
|
1115
|
+
const t3 = interact ? 0 : -1;
|
|
1116
|
+
const t4 = `Page ${id}`;
|
|
1117
|
+
let t5;
|
|
1118
|
+
if ($[3] !== id || $[4] !== onLoad) {
|
|
1119
|
+
t5 = () => onLoad(id);
|
|
1120
|
+
$[3] = id;
|
|
1121
|
+
$[4] = onLoad;
|
|
1122
|
+
$[5] = t5;
|
|
1123
|
+
} else t5 = $[5];
|
|
1124
|
+
let t6;
|
|
1125
|
+
if ($[6] !== height || $[7] !== name || $[8] !== src || $[9] !== t1 || $[10] !== t2 || $[11] !== t3 || $[12] !== t4 || $[13] !== t5 || $[14] !== width) {
|
|
1126
|
+
t6 = /* @__PURE__ */ jsx("iframe", {
|
|
1127
|
+
ref: t1,
|
|
1128
|
+
inert: t2,
|
|
1129
|
+
tabIndex: t3,
|
|
1130
|
+
title: t4,
|
|
1131
|
+
name,
|
|
1132
|
+
src,
|
|
1133
|
+
width,
|
|
1134
|
+
height,
|
|
1135
|
+
className: "povio-canvas-frame",
|
|
1136
|
+
onLoad: t5
|
|
1137
|
+
});
|
|
1138
|
+
$[6] = height;
|
|
1139
|
+
$[7] = name;
|
|
1140
|
+
$[8] = src;
|
|
1141
|
+
$[9] = t1;
|
|
1142
|
+
$[10] = t2;
|
|
1143
|
+
$[11] = t3;
|
|
1144
|
+
$[12] = t4;
|
|
1145
|
+
$[13] = t5;
|
|
1146
|
+
$[14] = width;
|
|
1147
|
+
$[15] = t6;
|
|
1148
|
+
} else t6 = $[15];
|
|
1149
|
+
return t6;
|
|
1150
|
+
});
|
|
1151
|
+
/** Live route artboards. The camera transforms only the canvas, never the iframe viewport width. */
|
|
1152
|
+
function AppCanvas({ router, examples = emptyExamples, exclude = emptyExclude, breakpoints = defaultCanvasBreakpoints, storageKey = "povio-app-canvas", frameUrl }) {
|
|
1153
|
+
const configuration = useUIConfiguration();
|
|
1154
|
+
const [manifest, setManifest] = useState(() => readManifest(storageKey));
|
|
1155
|
+
const [runtime, setRuntime] = useState({});
|
|
1156
|
+
const [selected, setSelected] = useState(null);
|
|
1157
|
+
const [interact, setInteract] = useState(false);
|
|
1158
|
+
const [inspectMode, setInspectMode] = useState(false);
|
|
1159
|
+
const [dark, setDark] = useState(false);
|
|
1160
|
+
const [mobilePanel, setMobilePanel] = useState(null);
|
|
1161
|
+
const [query, setQuery] = useState("");
|
|
1162
|
+
const [notice, setNotice] = useState("");
|
|
1163
|
+
const [documentGeneration, setDocumentGeneration] = useState(0);
|
|
1164
|
+
const [reload, setReload] = useState({});
|
|
1165
|
+
const zoomOutput = useRef(null);
|
|
1166
|
+
const importInput = useRef(null);
|
|
1167
|
+
const viewport = useRef(null), world = useRef(null);
|
|
1168
|
+
const frames = useRef(/* @__PURE__ */ new Map());
|
|
1169
|
+
const [token] = useState(() => crypto.randomUUID());
|
|
1170
|
+
const revision = useRef(0), camera = useRef({
|
|
1171
|
+
x: 40,
|
|
1172
|
+
y: 40,
|
|
1173
|
+
zoom: .25
|
|
1174
|
+
}), pendingCamera = useRef(null);
|
|
1175
|
+
const pointer = useRef(null);
|
|
1176
|
+
const cameraRevision = useRef(0);
|
|
1177
|
+
const bp = breakpoints.find((item) => item.id === manifest.breakpoint) ?? breakpoints[breakpoints.length - 1] ?? defaultCanvasBreakpoints[2];
|
|
1178
|
+
const inspector = useCanvasInspector(inspectMode, `${bp.id}:${documentGeneration}:${JSON.stringify(reload)}`);
|
|
1179
|
+
const catalog = useMemo(() => discoverCanvasPages(router, {
|
|
1180
|
+
examples: {
|
|
1181
|
+
...examples,
|
|
1182
|
+
...manifest.examples
|
|
1183
|
+
},
|
|
1184
|
+
exclude
|
|
1185
|
+
}), [
|
|
1186
|
+
router,
|
|
1187
|
+
examples,
|
|
1188
|
+
manifest.examples,
|
|
1189
|
+
exclude
|
|
1190
|
+
]);
|
|
1191
|
+
const heights = useMemo(() => Object.fromEntries(catalog.map((page) => [page.id, runtime[`${bp.id}:${page.id}:${page.href ?? ""}`]?.height ?? bp.height])), [
|
|
1192
|
+
catalog,
|
|
1193
|
+
runtime,
|
|
1194
|
+
bp
|
|
1195
|
+
]);
|
|
1196
|
+
const nodes = useMemo(() => layoutCanvasPages(catalog, bp.width, heights, manifest.positions[bp.id] ?? {}), [
|
|
1197
|
+
catalog,
|
|
1198
|
+
bp,
|
|
1199
|
+
heights,
|
|
1200
|
+
manifest.positions
|
|
1201
|
+
]);
|
|
1202
|
+
const nodeMap = useMemo(() => new Map(nodes.map((node) => [node.id, node])), [nodes]);
|
|
1203
|
+
const latest = useRef({
|
|
1204
|
+
configuration: configuration.active,
|
|
1205
|
+
dark,
|
|
1206
|
+
interact,
|
|
1207
|
+
bp,
|
|
1208
|
+
catalog,
|
|
1209
|
+
frameUrl
|
|
1210
|
+
});
|
|
1211
|
+
latest.current = {
|
|
1212
|
+
configuration: configuration.active,
|
|
1213
|
+
dark,
|
|
1214
|
+
interact,
|
|
1215
|
+
bp,
|
|
1216
|
+
catalog,
|
|
1217
|
+
frameUrl
|
|
1218
|
+
};
|
|
1219
|
+
const register = useCallback((id, frame) => {
|
|
1220
|
+
if (frame) frames.current.set(id, frame);
|
|
1221
|
+
else frames.current.delete(id);
|
|
1222
|
+
}, []);
|
|
1223
|
+
const paint = useCallback(() => {
|
|
1224
|
+
if (world.current) world.current.style.transform = `translate3d(${camera.current.x}px,${camera.current.y}px,0) scale(${camera.current.zoom})`;
|
|
1225
|
+
if (zoomOutput.current) zoomOutput.current.textContent = `${Math.round(camera.current.zoom * 1e3) / 10}%`;
|
|
1226
|
+
const canvas = viewport.current?.closest(".povio-app-canvas");
|
|
1227
|
+
if (canvas) canvas.setAttribute("data-camera-revision", String(++cameraRevision.current));
|
|
1228
|
+
}, []);
|
|
1229
|
+
const schedulePaint = useCallback(() => {
|
|
1230
|
+
if (pendingCamera.current !== null) return;
|
|
1231
|
+
pendingCamera.current = requestAnimationFrame(() => {
|
|
1232
|
+
pendingCamera.current = null;
|
|
1233
|
+
paint();
|
|
1234
|
+
});
|
|
1235
|
+
}, [paint]);
|
|
1236
|
+
const send = useCallback((id_0, type = "configuration") => {
|
|
1237
|
+
const frame_0 = frames.current.get(id_0);
|
|
1238
|
+
if (!frame_0?.contentWindow) return;
|
|
1239
|
+
const current = latest.current;
|
|
1240
|
+
try {
|
|
1241
|
+
frame_0.contentWindow.postMessage({
|
|
1242
|
+
protocol: canvasProtocol,
|
|
1243
|
+
id: id_0,
|
|
1244
|
+
token,
|
|
1245
|
+
viewportHeight: current.bp.height,
|
|
1246
|
+
type,
|
|
1247
|
+
configuration: current.configuration,
|
|
1248
|
+
revision: revision.current,
|
|
1249
|
+
dark: current.dark,
|
|
1250
|
+
interact: current.interact
|
|
1251
|
+
}, new URL(frame_0.src).origin);
|
|
1252
|
+
} catch {
|
|
1253
|
+
setNotice("This configuration could not be sent to the page. Check for non-serializable values.");
|
|
1254
|
+
}
|
|
1255
|
+
}, [token]);
|
|
1256
|
+
const focusPage = useCallback((id_1) => {
|
|
1257
|
+
const node_0 = nodeMap.get(id_1), view = viewport.current;
|
|
1258
|
+
if (!node_0 || !view) return;
|
|
1259
|
+
setSelected(id_1);
|
|
1260
|
+
camera.current.zoom = Math.min(1, Math.max(.08, (view.clientWidth - 100) / node_0.width));
|
|
1261
|
+
camera.current.x = 40 - node_0.x * camera.current.zoom;
|
|
1262
|
+
camera.current.y = 40 - node_0.y * camera.current.zoom;
|
|
1263
|
+
paint();
|
|
1264
|
+
}, [nodeMap, paint]);
|
|
1265
|
+
const focusRef = useRef(focusPage);
|
|
1266
|
+
focusRef.current = focusPage;
|
|
1267
|
+
const matchHref = useCallback((href) => matchCanvasPageHref(latest.current.catalog, href, window.location.href), []);
|
|
1268
|
+
useEffect(() => {
|
|
1269
|
+
const queue = /* @__PURE__ */ new Map();
|
|
1270
|
+
let batch = 0;
|
|
1271
|
+
const flush = () => {
|
|
1272
|
+
batch = 0;
|
|
1273
|
+
const changes = Array.from(queue);
|
|
1274
|
+
queue.clear();
|
|
1275
|
+
setRuntime((current_0) => {
|
|
1276
|
+
const next = { ...current_0 };
|
|
1277
|
+
for (const [key, change] of changes) next[key] = {
|
|
1278
|
+
...next[key],
|
|
1279
|
+
...change
|
|
1280
|
+
};
|
|
1281
|
+
return next;
|
|
1282
|
+
});
|
|
1283
|
+
};
|
|
1284
|
+
const receive = (event) => {
|
|
1285
|
+
const packet = event.data;
|
|
1286
|
+
if (packet?.protocol !== "povio-app-canvas-v1" || packet.token !== token || typeof packet.id !== "string") return;
|
|
1287
|
+
const frame_1 = frames.current.get(packet.id);
|
|
1288
|
+
if (!frame_1 || event.source !== frame_1.contentWindow || event.origin !== new URL(frame_1.src).origin) return;
|
|
1289
|
+
const key_0 = `${latest.current.bp.id}:${packet.id}:${latest.current.catalog.find((page_0) => page_0.id === packet.id)?.href ?? ""}`;
|
|
1290
|
+
let change_0 = {};
|
|
1291
|
+
if (packet.type === "ready") {
|
|
1292
|
+
change_0 = {
|
|
1293
|
+
ready: true,
|
|
1294
|
+
href: packet.href,
|
|
1295
|
+
timedOut: false
|
|
1296
|
+
};
|
|
1297
|
+
send(packet.id);
|
|
1298
|
+
send(packet.id, "mode");
|
|
1299
|
+
}
|
|
1300
|
+
if (packet.type === "height" && typeof packet.height === "number" && Number.isFinite(packet.height) && packet.height > 0) change_0.height = packet.height;
|
|
1301
|
+
if (packet.type === "warning" && typeof packet.warning === "string") change_0.warning = packet.warning;
|
|
1302
|
+
if (packet.type === "ack" && typeof packet.revision === "number") change_0.revision = packet.revision;
|
|
1303
|
+
if (packet.type === "navigate" && typeof packet.href === "string") {
|
|
1304
|
+
const target = matchHref(packet.href);
|
|
1305
|
+
if (target) focusRef.current(target.id);
|
|
1306
|
+
else setNotice(`Navigation target is not in this canvas: ${packet.href}`);
|
|
1307
|
+
return;
|
|
1308
|
+
}
|
|
1309
|
+
if (!Object.keys(change_0).length) return;
|
|
1310
|
+
queue.set(key_0, {
|
|
1311
|
+
...queue.get(key_0),
|
|
1312
|
+
...change_0
|
|
1313
|
+
});
|
|
1314
|
+
if (!batch) batch = requestAnimationFrame(flush);
|
|
1315
|
+
};
|
|
1316
|
+
window.addEventListener("message", receive);
|
|
1317
|
+
return () => {
|
|
1318
|
+
window.removeEventListener("message", receive);
|
|
1319
|
+
cancelAnimationFrame(batch);
|
|
1320
|
+
};
|
|
1321
|
+
}, [
|
|
1322
|
+
token,
|
|
1323
|
+
send,
|
|
1324
|
+
matchHref
|
|
1325
|
+
]);
|
|
1326
|
+
useEffect(() => {
|
|
1327
|
+
const frame_2 = requestAnimationFrame(() => {
|
|
1328
|
+
revision.current++;
|
|
1329
|
+
for (const id_2 of frames.current.keys()) send(id_2);
|
|
1330
|
+
});
|
|
1331
|
+
return () => cancelAnimationFrame(frame_2);
|
|
1332
|
+
}, [
|
|
1333
|
+
configuration.active,
|
|
1334
|
+
dark,
|
|
1335
|
+
send
|
|
1336
|
+
]);
|
|
1337
|
+
useEffect(() => {
|
|
1338
|
+
for (const id_3 of frames.current.keys()) send(id_3, "mode");
|
|
1339
|
+
}, [interact, send]);
|
|
1340
|
+
useEffect(() => {
|
|
1341
|
+
try {
|
|
1342
|
+
localStorage.setItem(storageKey, JSON.stringify(manifest));
|
|
1343
|
+
} catch {
|
|
1344
|
+
setNotice("Browser storage is unavailable; use Export layout to save this canvas.");
|
|
1345
|
+
}
|
|
1346
|
+
}, [manifest, storageKey]);
|
|
1347
|
+
useEffect(() => {
|
|
1348
|
+
paint();
|
|
1349
|
+
const element = viewport.current;
|
|
1350
|
+
if (!element) return;
|
|
1351
|
+
const wheel = (event_0) => {
|
|
1352
|
+
event_0.preventDefault();
|
|
1353
|
+
if (event_0.ctrlKey || event_0.metaKey) {
|
|
1354
|
+
const box = element.getBoundingClientRect();
|
|
1355
|
+
const x = event_0.clientX - box.left, y = event_0.clientY - box.top;
|
|
1356
|
+
const previous = camera.current.zoom;
|
|
1357
|
+
const unit = event_0.deltaMode === 1 ? 16 : event_0.deltaMode === 2 ? element.clientHeight : 1;
|
|
1358
|
+
const next_0 = Math.max(.005, Math.min(2, previous * Math.exp(-event_0.deltaY * unit * .01)));
|
|
1359
|
+
camera.current.x = x - (x - camera.current.x) * next_0 / previous;
|
|
1360
|
+
camera.current.y = y - (y - camera.current.y) * next_0 / previous;
|
|
1361
|
+
camera.current.zoom = next_0;
|
|
1362
|
+
} else {
|
|
1363
|
+
camera.current.x -= event_0.deltaX;
|
|
1364
|
+
camera.current.y -= event_0.deltaY;
|
|
1365
|
+
}
|
|
1366
|
+
schedulePaint();
|
|
1367
|
+
};
|
|
1368
|
+
element.addEventListener("wheel", wheel, { passive: false });
|
|
1369
|
+
return () => {
|
|
1370
|
+
element.removeEventListener("wheel", wheel);
|
|
1371
|
+
if (pendingCamera.current !== null) cancelAnimationFrame(pendingCamera.current);
|
|
1372
|
+
pendingCamera.current = null;
|
|
1373
|
+
};
|
|
1374
|
+
}, [paint, schedulePaint]);
|
|
1375
|
+
const fit = () => {
|
|
1376
|
+
if (!nodes.length || !viewport.current) return;
|
|
1377
|
+
const left = Math.min(...nodes.map((n) => n.x)), top = Math.min(...nodes.map((n_0) => n_0.y));
|
|
1378
|
+
const width = Math.max(...nodes.map((n_1) => n_1.x + n_1.width)) - left, height = Math.max(...nodes.map((n_2) => n_2.y + n_2.height + 48)) - top;
|
|
1379
|
+
camera.current.zoom = Math.max(.005, Math.min(1, (viewport.current.clientWidth - 80) / width, (viewport.current.clientHeight - 80) / height));
|
|
1380
|
+
camera.current.x = 40 - left * camera.current.zoom;
|
|
1381
|
+
camera.current.y = 40 - top * camera.current.zoom;
|
|
1382
|
+
paint();
|
|
1383
|
+
};
|
|
1384
|
+
const zoomTo = (value) => {
|
|
1385
|
+
const view_0 = viewport.current;
|
|
1386
|
+
if (!view_0) return;
|
|
1387
|
+
const previous_0 = camera.current.zoom, next_1 = Math.max(.005, Math.min(2, value));
|
|
1388
|
+
camera.current.x = view_0.clientWidth / 2 - (view_0.clientWidth / 2 - camera.current.x) * next_1 / previous_0;
|
|
1389
|
+
camera.current.y = view_0.clientHeight / 2 - (view_0.clientHeight / 2 - camera.current.y) * next_1 / previous_0;
|
|
1390
|
+
camera.current.zoom = next_1;
|
|
1391
|
+
paint();
|
|
1392
|
+
};
|
|
1393
|
+
const stepZoom = (direction) => {
|
|
1394
|
+
const stops = [
|
|
1395
|
+
.005,
|
|
1396
|
+
.01,
|
|
1397
|
+
.02,
|
|
1398
|
+
.05,
|
|
1399
|
+
.1,
|
|
1400
|
+
.25,
|
|
1401
|
+
.5,
|
|
1402
|
+
.75,
|
|
1403
|
+
1,
|
|
1404
|
+
1.5,
|
|
1405
|
+
2
|
|
1406
|
+
];
|
|
1407
|
+
const current_1 = camera.current.zoom;
|
|
1408
|
+
const next_2 = direction === 1 ? stops.find((value_0) => value_0 > current_1 + 1e-4) : [...stops].reverse().find((value_1) => value_1 < current_1 - 1e-4);
|
|
1409
|
+
if (next_2 !== void 0) zoomTo(next_2);
|
|
1410
|
+
};
|
|
1411
|
+
const startPan = (event_1) => {
|
|
1412
|
+
if (inspectMode && event_1.target.closest(".povio-canvas-frame-cover")) return;
|
|
1413
|
+
if (event_1.button !== 0 || event_1.target.closest("button:not(.povio-canvas-frame-cover),input,select,.povio-canvas-node-header")) return;
|
|
1414
|
+
event_1.currentTarget.setPointerCapture(event_1.pointerId);
|
|
1415
|
+
pointer.current = {
|
|
1416
|
+
id: event_1.pointerId,
|
|
1417
|
+
x: event_1.clientX,
|
|
1418
|
+
y: event_1.clientY,
|
|
1419
|
+
startX: camera.current.x,
|
|
1420
|
+
startY: camera.current.y
|
|
1421
|
+
};
|
|
1422
|
+
};
|
|
1423
|
+
const move = (event_2) => {
|
|
1424
|
+
const current_2 = pointer.current;
|
|
1425
|
+
if (!current_2 || current_2.id !== event_2.pointerId) return;
|
|
1426
|
+
const dx = event_2.clientX - current_2.x, dy = event_2.clientY - current_2.y;
|
|
1427
|
+
if (current_2.node) {
|
|
1428
|
+
const element_0 = world.current?.querySelector(`[data-node-index="${nodes.findIndex((n_3) => n_3.id === current_2.node)}"]`);
|
|
1429
|
+
if (element_0) {
|
|
1430
|
+
element_0.style.left = `${current_2.nodeX + dx / camera.current.zoom}px`;
|
|
1431
|
+
element_0.style.top = `${current_2.nodeY + dy / camera.current.zoom}px`;
|
|
1432
|
+
}
|
|
1433
|
+
} else {
|
|
1434
|
+
camera.current.x = current_2.startX + dx;
|
|
1435
|
+
camera.current.y = current_2.startY + dy;
|
|
1436
|
+
schedulePaint();
|
|
1437
|
+
}
|
|
1438
|
+
};
|
|
1439
|
+
const end = (event_3) => {
|
|
1440
|
+
const current_3 = pointer.current;
|
|
1441
|
+
if (!current_3 || current_3.id !== event_3.pointerId) return;
|
|
1442
|
+
if (current_3.node) {
|
|
1443
|
+
const position = {
|
|
1444
|
+
x: current_3.nodeX + (event_3.clientX - current_3.x) / camera.current.zoom,
|
|
1445
|
+
y: current_3.nodeY + (event_3.clientY - current_3.y) / camera.current.zoom
|
|
1446
|
+
};
|
|
1447
|
+
setManifest((m) => ({
|
|
1448
|
+
...m,
|
|
1449
|
+
positions: {
|
|
1450
|
+
...m.positions,
|
|
1451
|
+
[bp.id]: {
|
|
1452
|
+
...m.positions[bp.id],
|
|
1453
|
+
[current_3.node]: position
|
|
1454
|
+
}
|
|
1455
|
+
}
|
|
1456
|
+
}));
|
|
1457
|
+
}
|
|
1458
|
+
pointer.current = null;
|
|
1459
|
+
if (event_3.currentTarget.hasPointerCapture(event_3.pointerId)) event_3.currentTarget.releasePointerCapture(event_3.pointerId);
|
|
1460
|
+
};
|
|
1461
|
+
const onLoad = useCallback((id_4) => {
|
|
1462
|
+
send(id_4);
|
|
1463
|
+
send(id_4, "mode");
|
|
1464
|
+
}, [send]);
|
|
1465
|
+
useEffect(() => {
|
|
1466
|
+
const timer = setTimeout(() => setRuntime((current_4) => {
|
|
1467
|
+
const next_3 = { ...current_4 };
|
|
1468
|
+
for (const page_1 of latest.current.catalog) {
|
|
1469
|
+
const key_1 = `${latest.current.bp.id}:${page_1.id}:${page_1.href ?? ""}`;
|
|
1470
|
+
if (page_1.href && !next_3[key_1]?.ready) next_3[key_1] = {
|
|
1471
|
+
...next_3[key_1],
|
|
1472
|
+
timedOut: true
|
|
1473
|
+
};
|
|
1474
|
+
}
|
|
1475
|
+
return next_3;
|
|
1476
|
+
}), 15e3);
|
|
1477
|
+
return () => clearTimeout(timer);
|
|
1478
|
+
}, [
|
|
1479
|
+
bp.id,
|
|
1480
|
+
catalog,
|
|
1481
|
+
reload
|
|
1482
|
+
]);
|
|
1483
|
+
const exportLayout = () => {
|
|
1484
|
+
const url = URL.createObjectURL(new Blob([JSON.stringify(manifest, null, 2)], { type: "application/json" }));
|
|
1485
|
+
const a = document.createElement("a");
|
|
1486
|
+
a.href = url;
|
|
1487
|
+
a.download = "povio-app-canvas.json";
|
|
1488
|
+
a.click();
|
|
1489
|
+
setTimeout(() => URL.revokeObjectURL(url), 1e3);
|
|
1490
|
+
};
|
|
1491
|
+
const width_0 = Math.max(1, ...nodes.map((n_4) => n_4.x + n_4.width + 80)), height_0 = Math.max(1, ...nodes.map((n_5) => n_5.y + n_5.height + 128));
|
|
1492
|
+
const ready = nodes.filter((n_6) => runtime[`${bp.id}:${n_6.id}:${n_6.href ?? ""}`]?.ready).length;
|
|
1493
|
+
return /* @__PURE__ */ jsxs("section", {
|
|
1494
|
+
className: "povio-app-canvas",
|
|
1495
|
+
"data-mobile-panel": mobilePanel ?? "none",
|
|
1496
|
+
"data-inspecting": inspectMode,
|
|
1497
|
+
"aria-label": "App canvas",
|
|
1498
|
+
"data-ready-count": ready,
|
|
1499
|
+
"data-page-count": nodes.length,
|
|
1500
|
+
"data-camera-revision": "0",
|
|
1501
|
+
children: [
|
|
1502
|
+
/* @__PURE__ */ jsx("input", {
|
|
1503
|
+
ref: importInput,
|
|
1504
|
+
type: "file",
|
|
1505
|
+
accept: "application/json,.json",
|
|
1506
|
+
hidden: true,
|
|
1507
|
+
"aria-label": "Import canvas layout",
|
|
1508
|
+
onChange: async (event_4) => {
|
|
1509
|
+
const file = event_4.currentTarget.files?.[0];
|
|
1510
|
+
event_4.currentTarget.value = "";
|
|
1511
|
+
if (!file) return;
|
|
1512
|
+
try {
|
|
1513
|
+
const raw = JSON.parse(await file.text());
|
|
1514
|
+
if (raw?.version !== 1) throw new Error("version");
|
|
1515
|
+
setManifest(parseCanvasManifest(raw));
|
|
1516
|
+
setRuntime({});
|
|
1517
|
+
setDocumentGeneration((value_2) => value_2 + 1);
|
|
1518
|
+
setNotice("Layout imported.");
|
|
1519
|
+
} catch {
|
|
1520
|
+
setNotice("Choose a valid version 1 canvas layout JSON file.");
|
|
1521
|
+
}
|
|
1522
|
+
}
|
|
1523
|
+
}),
|
|
1524
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1525
|
+
className: "povio-canvas-body",
|
|
1526
|
+
children: [
|
|
1527
|
+
/* @__PURE__ */ jsxs("aside", {
|
|
1528
|
+
className: "povio-canvas-catalog",
|
|
1529
|
+
"aria-label": "Page catalog",
|
|
1530
|
+
children: [
|
|
1531
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1532
|
+
className: "povio-canvas-brand",
|
|
1533
|
+
children: [/* @__PURE__ */ jsx("strong", { children: "Pages" }), /* @__PURE__ */ jsx("span", {
|
|
1534
|
+
className: "povio-canvas-page-count",
|
|
1535
|
+
children: nodes.length
|
|
1536
|
+
})]
|
|
1537
|
+
}),
|
|
1538
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1539
|
+
className: "povio-canvas-search",
|
|
1540
|
+
children: [
|
|
1541
|
+
/* @__PURE__ */ jsx(Search, { size: 14 }),
|
|
1542
|
+
/* @__PURE__ */ jsx("input", {
|
|
1543
|
+
"aria-label": "Find page",
|
|
1544
|
+
placeholder: "Find page…",
|
|
1545
|
+
value: query,
|
|
1546
|
+
onChange: (event_5) => setQuery(event_5.target.value)
|
|
1547
|
+
}),
|
|
1548
|
+
/* @__PURE__ */ jsx("button", {
|
|
1549
|
+
className: "povio-canvas-panel-close",
|
|
1550
|
+
"aria-label": "Close pages panel",
|
|
1551
|
+
onClick: () => setMobilePanel(null),
|
|
1552
|
+
children: /* @__PURE__ */ jsx(X, { size: 16 })
|
|
1553
|
+
})
|
|
1554
|
+
]
|
|
1555
|
+
}),
|
|
1556
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1557
|
+
className: "povio-canvas-page-list",
|
|
1558
|
+
children: [nodes.filter((node_1) => `${node_1.title} ${node_1.path}`.toLowerCase().includes(query.toLowerCase())).map((node_2) => /* @__PURE__ */ jsxs("button", {
|
|
1559
|
+
"aria-pressed": selected === node_2.id,
|
|
1560
|
+
onClick: () => {
|
|
1561
|
+
focusPage(node_2.id);
|
|
1562
|
+
setMobilePanel(null);
|
|
1563
|
+
},
|
|
1564
|
+
children: [/* @__PURE__ */ jsx(Frame, { size: 15 }), /* @__PURE__ */ jsxs("span", {
|
|
1565
|
+
className: "povio-canvas-page-label",
|
|
1566
|
+
children: [/* @__PURE__ */ jsx("strong", { children: node_2.title }), node_2.kind === "unresolved" && /* @__PURE__ */ jsx("small", { children: "Needs parameters" })]
|
|
1567
|
+
})]
|
|
1568
|
+
}, node_2.id)), selected && nodeMap.get(selected)?.href && /* @__PURE__ */ jsx(PageLayers, {
|
|
1569
|
+
frame: frames.current.get(selected) ?? null,
|
|
1570
|
+
title: nodeMap.get(selected).title,
|
|
1571
|
+
selected: inspector.selection?.pageId === selected ? inspector.selection.element : void 0,
|
|
1572
|
+
onSelect: (element_1) => {
|
|
1573
|
+
setInteract(false);
|
|
1574
|
+
setInspectMode(true);
|
|
1575
|
+
inspector.selectElement(selected, element_1);
|
|
1576
|
+
setMobilePanel(null);
|
|
1577
|
+
requestAnimationFrame(() => {
|
|
1578
|
+
const node_3 = nodeMap.get(selected), view_1 = viewport.current;
|
|
1579
|
+
if (!node_3 || !view_1 || !element_1.isConnected) return;
|
|
1580
|
+
const rect = element_1.getBoundingClientRect();
|
|
1581
|
+
camera.current.x = view_1.clientWidth / 2 - (node_3.x + rect.left + rect.width / 2) * camera.current.zoom;
|
|
1582
|
+
camera.current.y = view_1.clientHeight / 2 - (node_3.y + 48 + rect.top + rect.height / 2) * camera.current.zoom;
|
|
1583
|
+
paint();
|
|
1584
|
+
});
|
|
1585
|
+
}
|
|
1586
|
+
}, `${bp.id}:${documentGeneration}:${reload[selected] ?? 0}:${selected}:${nodeMap.get(selected)?.href}`)]
|
|
1587
|
+
}),
|
|
1588
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1589
|
+
className: "povio-canvas-sidebar-actions",
|
|
1590
|
+
children: [
|
|
1591
|
+
/* @__PURE__ */ jsx("button", {
|
|
1592
|
+
className: "povio-canvas-file-action",
|
|
1593
|
+
onClick: exportLayout,
|
|
1594
|
+
"aria-label": "Export layout",
|
|
1595
|
+
title: "Export layout",
|
|
1596
|
+
children: /* @__PURE__ */ jsx(Download, { size: 16 })
|
|
1597
|
+
}),
|
|
1598
|
+
/* @__PURE__ */ jsx("button", {
|
|
1599
|
+
className: "povio-canvas-file-action",
|
|
1600
|
+
onClick: () => importInput.current?.click(),
|
|
1601
|
+
"aria-label": "Import layout",
|
|
1602
|
+
title: "Import layout",
|
|
1603
|
+
children: /* @__PURE__ */ jsx(Upload, { size: 16 })
|
|
1604
|
+
}),
|
|
1605
|
+
/* @__PURE__ */ jsxs("span", {
|
|
1606
|
+
className: "povio-canvas-ready",
|
|
1607
|
+
role: "status",
|
|
1608
|
+
children: [
|
|
1609
|
+
/* @__PURE__ */ jsx("i", {}),
|
|
1610
|
+
ready,
|
|
1611
|
+
"/",
|
|
1612
|
+
nodes.length,
|
|
1613
|
+
" pages ready"
|
|
1614
|
+
]
|
|
1615
|
+
})
|
|
1616
|
+
]
|
|
1617
|
+
})
|
|
1618
|
+
]
|
|
1619
|
+
}),
|
|
1620
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1621
|
+
ref: viewport,
|
|
1622
|
+
className: "povio-canvas-viewport",
|
|
1623
|
+
onKeyDownCapture: (event_6) => {
|
|
1624
|
+
if (inspectMode && event_6.key === "Escape") {
|
|
1625
|
+
event_6.preventDefault();
|
|
1626
|
+
inspector.clear();
|
|
1627
|
+
}
|
|
1628
|
+
},
|
|
1629
|
+
onPointerDown: startPan,
|
|
1630
|
+
onPointerMove: move,
|
|
1631
|
+
onPointerUp: end,
|
|
1632
|
+
onPointerCancel: (event_7) => {
|
|
1633
|
+
const current_5 = pointer.current;
|
|
1634
|
+
if (current_5?.node) {
|
|
1635
|
+
const element_2 = world.current?.querySelector(`[data-node-index="${nodes.findIndex((node_4) => node_4.id === current_5.node)}"]`);
|
|
1636
|
+
if (element_2) {
|
|
1637
|
+
element_2.style.left = `${current_5.nodeX}px`;
|
|
1638
|
+
element_2.style.top = `${current_5.nodeY}px`;
|
|
1639
|
+
}
|
|
1640
|
+
}
|
|
1641
|
+
pointer.current = null;
|
|
1642
|
+
if (event_7.currentTarget.hasPointerCapture(event_7.pointerId)) event_7.currentTarget.releasePointerCapture(event_7.pointerId);
|
|
1643
|
+
},
|
|
1644
|
+
children: [
|
|
1645
|
+
/* @__PURE__ */ jsx("div", {
|
|
1646
|
+
className: "povio-canvas-mobile-tools",
|
|
1647
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
1648
|
+
"aria-label": "Toggle pages panel",
|
|
1649
|
+
"aria-pressed": mobilePanel === "pages",
|
|
1650
|
+
onClick: () => setMobilePanel(mobilePanel === "pages" ? null : "pages"),
|
|
1651
|
+
children: /* @__PURE__ */ jsx(PanelLeft, { size: 18 })
|
|
1652
|
+
})
|
|
1653
|
+
}),
|
|
1654
|
+
/* @__PURE__ */ jsx("div", {
|
|
1655
|
+
ref: world,
|
|
1656
|
+
className: "povio-canvas-world",
|
|
1657
|
+
style: {
|
|
1658
|
+
width: width_0,
|
|
1659
|
+
height: height_0
|
|
1660
|
+
},
|
|
1661
|
+
children: nodes.map((node_5, index) => {
|
|
1662
|
+
const state = runtime[`${bp.id}:${node_5.id}:${node_5.href ?? ""}`] ?? {};
|
|
1663
|
+
let source = "";
|
|
1664
|
+
let originError = false;
|
|
1665
|
+
if (node_5.href) try {
|
|
1666
|
+
const url_0 = new URL(frameUrl?.(node_5) ?? node_5.href, window.location.href);
|
|
1667
|
+
if (url_0.origin !== window.location.origin) throw new Error("same origin required");
|
|
1668
|
+
url_0.searchParams.delete("povioCanvas");
|
|
1669
|
+
url_0.searchParams.set("__povio_canvas_frame", node_5.id);
|
|
1670
|
+
url_0.searchParams.set("__povio_canvas_token", token);
|
|
1671
|
+
url_0.searchParams.set("__povio_canvas_height", String(bp.height));
|
|
1672
|
+
source = url_0.href;
|
|
1673
|
+
} catch {
|
|
1674
|
+
originError = true;
|
|
1675
|
+
}
|
|
1676
|
+
const redirected = state.href && node_5.href && new URL(state.href, window.location.href).pathname !== new URL(node_5.href, window.location.href).pathname;
|
|
1677
|
+
return /* @__PURE__ */ jsxs("article", {
|
|
1678
|
+
"data-node-index": index,
|
|
1679
|
+
"data-page-id": node_5.id,
|
|
1680
|
+
className: `povio-canvas-node${selected === node_5.id ? " is-selected" : ""}`,
|
|
1681
|
+
style: {
|
|
1682
|
+
left: node_5.x,
|
|
1683
|
+
top: node_5.y,
|
|
1684
|
+
width: node_5.width
|
|
1685
|
+
},
|
|
1686
|
+
children: [
|
|
1687
|
+
/* @__PURE__ */ jsxs("header", {
|
|
1688
|
+
className: "povio-canvas-node-header",
|
|
1689
|
+
onPointerDown: (event_8) => {
|
|
1690
|
+
if (event_8.button !== 0 || event_8.target.closest("button")) return;
|
|
1691
|
+
event_8.stopPropagation();
|
|
1692
|
+
viewport.current?.setPointerCapture(event_8.pointerId);
|
|
1693
|
+
pointer.current = {
|
|
1694
|
+
id: event_8.pointerId,
|
|
1695
|
+
x: event_8.clientX,
|
|
1696
|
+
y: event_8.clientY,
|
|
1697
|
+
startX: 0,
|
|
1698
|
+
startY: 0,
|
|
1699
|
+
node: node_5.id,
|
|
1700
|
+
nodeX: node_5.x,
|
|
1701
|
+
nodeY: node_5.y
|
|
1702
|
+
};
|
|
1703
|
+
setSelected(node_5.id);
|
|
1704
|
+
},
|
|
1705
|
+
children: [
|
|
1706
|
+
/* @__PURE__ */ jsx("strong", { children: node_5.title }),
|
|
1707
|
+
/* @__PURE__ */ jsxs("span", { children: [
|
|
1708
|
+
bp.width,
|
|
1709
|
+
" × ",
|
|
1710
|
+
Math.round(node_5.height).toLocaleString()
|
|
1711
|
+
] }),
|
|
1712
|
+
/* @__PURE__ */ jsx("button", {
|
|
1713
|
+
"aria-label": `Focus ${node_5.title}`,
|
|
1714
|
+
onClick: () => focusPage(node_5.id),
|
|
1715
|
+
children: "↗"
|
|
1716
|
+
}),
|
|
1717
|
+
/* @__PURE__ */ jsx("button", {
|
|
1718
|
+
"aria-label": `Reload ${node_5.title}`,
|
|
1719
|
+
onClick: () => {
|
|
1720
|
+
setRuntime((r) => ({
|
|
1721
|
+
...r,
|
|
1722
|
+
[`${bp.id}:${node_5.id}:${node_5.href ?? ""}`]: {}
|
|
1723
|
+
}));
|
|
1724
|
+
setReload((r_0) => ({
|
|
1725
|
+
...r_0,
|
|
1726
|
+
[node_5.id]: (r_0[node_5.id] ?? 0) + 1
|
|
1727
|
+
}));
|
|
1728
|
+
},
|
|
1729
|
+
children: "↻"
|
|
1730
|
+
})
|
|
1731
|
+
]
|
|
1732
|
+
}),
|
|
1733
|
+
!node_5.href ? /* @__PURE__ */ jsxs("form", {
|
|
1734
|
+
className: "povio-canvas-unresolved",
|
|
1735
|
+
onSubmit: (event_9) => {
|
|
1736
|
+
event_9.preventDefault();
|
|
1737
|
+
const form = new FormData(event_9.currentTarget);
|
|
1738
|
+
const enteredParams = Object.fromEntries(node_5.missingParams.map((key_2) => {
|
|
1739
|
+
const value_3 = form.get(key_2);
|
|
1740
|
+
return [key_2, typeof value_3 === "string" ? value_3 : ""];
|
|
1741
|
+
}));
|
|
1742
|
+
setManifest((m_0) => ({
|
|
1743
|
+
...m_0,
|
|
1744
|
+
examples: {
|
|
1745
|
+
...m_0.examples,
|
|
1746
|
+
[node_5.id]: {
|
|
1747
|
+
...examples[node_5.id],
|
|
1748
|
+
...m_0.examples[node_5.id],
|
|
1749
|
+
params: {
|
|
1750
|
+
...examples[node_5.id]?.params,
|
|
1751
|
+
...m_0.examples[node_5.id]?.params,
|
|
1752
|
+
...enteredParams
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
}
|
|
1756
|
+
}));
|
|
1757
|
+
},
|
|
1758
|
+
children: [
|
|
1759
|
+
/* @__PURE__ */ jsx("strong", { children: "Route needs parameters" }),
|
|
1760
|
+
/* @__PURE__ */ jsx("code", { children: node_5.path }),
|
|
1761
|
+
node_5.missingParams.map((key_3) => /* @__PURE__ */ jsxs("label", { children: [key_3, /* @__PURE__ */ jsx("input", {
|
|
1762
|
+
name: key_3,
|
|
1763
|
+
required: true
|
|
1764
|
+
})] }, key_3)),
|
|
1765
|
+
/* @__PURE__ */ jsx("button", { children: "Render page" })
|
|
1766
|
+
]
|
|
1767
|
+
}) : originError ? /* @__PURE__ */ jsx("p", {
|
|
1768
|
+
className: "povio-canvas-unresolved",
|
|
1769
|
+
children: "Canvas pages must use the same origin."
|
|
1770
|
+
}) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
1771
|
+
/* @__PURE__ */ jsx(PageFrame, {
|
|
1772
|
+
id: node_5.id,
|
|
1773
|
+
interact,
|
|
1774
|
+
inspect: inspectMode,
|
|
1775
|
+
src: source,
|
|
1776
|
+
width: bp.width,
|
|
1777
|
+
height: node_5.height,
|
|
1778
|
+
name: `${canvasProtocol}:${JSON.stringify({
|
|
1779
|
+
id: node_5.id,
|
|
1780
|
+
token,
|
|
1781
|
+
viewportHeight: bp.height
|
|
1782
|
+
})}`,
|
|
1783
|
+
onLoad,
|
|
1784
|
+
register
|
|
1785
|
+
}, `${documentGeneration}:${bp.id}:${source}:${reload[node_5.id] ?? 0}`),
|
|
1786
|
+
!interact && /* @__PURE__ */ jsx("button", {
|
|
1787
|
+
type: "button",
|
|
1788
|
+
className: "povio-canvas-frame-cover",
|
|
1789
|
+
tabIndex: 0,
|
|
1790
|
+
"aria-label": `Select ${node_5.title}`,
|
|
1791
|
+
onKeyDown: (event_10) => {
|
|
1792
|
+
if (event_10.key === "Enter" || event_10.key === " ") {
|
|
1793
|
+
event_10.preventDefault();
|
|
1794
|
+
setSelected(node_5.id);
|
|
1795
|
+
}
|
|
1796
|
+
},
|
|
1797
|
+
onPointerMove: (event_11) => {
|
|
1798
|
+
const frame_3 = frames.current.get(node_5.id);
|
|
1799
|
+
if (frame_3) inspector.hover(node_5.id, frame_3, event_11.clientX, event_11.clientY);
|
|
1800
|
+
},
|
|
1801
|
+
onPointerDown: (event_12) => {
|
|
1802
|
+
setSelected(node_5.id);
|
|
1803
|
+
if (inspectMode) {
|
|
1804
|
+
const frame_4 = frames.current.get(node_5.id);
|
|
1805
|
+
if (frame_4) inspector.select(node_5.id, frame_4, event_12.clientX, event_12.clientY);
|
|
1806
|
+
}
|
|
1807
|
+
},
|
|
1808
|
+
onClick: () => setSelected(node_5.id)
|
|
1809
|
+
}),
|
|
1810
|
+
inspectMode && inspector.selection?.pageId === node_5.id && inspector.measurement && /* @__PURE__ */ jsx(CanvasInspectionOverlay, {
|
|
1811
|
+
measurement: inspector.measurement,
|
|
1812
|
+
width: node_5.width
|
|
1813
|
+
})
|
|
1814
|
+
] }),
|
|
1815
|
+
(redirected || state.warning || state.timedOut) && /* @__PURE__ */ jsxs("div", {
|
|
1816
|
+
className: "povio-canvas-page-note",
|
|
1817
|
+
children: [
|
|
1818
|
+
redirected ? `Rendered ${state.href} (route redirected). ` : "",
|
|
1819
|
+
state.warning,
|
|
1820
|
+
state.timedOut && !state.ready ? " Frame bridge has not connected. Check access or page errors." : ""
|
|
1821
|
+
]
|
|
1822
|
+
})
|
|
1823
|
+
]
|
|
1824
|
+
}, node_5.id);
|
|
1825
|
+
})
|
|
1826
|
+
}),
|
|
1827
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1828
|
+
className: "povio-canvas-tool-dock",
|
|
1829
|
+
children: [
|
|
1830
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1831
|
+
className: "povio-canvas-mode-switch",
|
|
1832
|
+
role: "group",
|
|
1833
|
+
"aria-label": "Canvas mode",
|
|
1834
|
+
children: [
|
|
1835
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1836
|
+
"aria-label": "Inspect layouts",
|
|
1837
|
+
title: "Inspect layouts",
|
|
1838
|
+
"aria-pressed": inspectMode,
|
|
1839
|
+
onClick: () => {
|
|
1840
|
+
setInteract(false);
|
|
1841
|
+
setInspectMode(true);
|
|
1842
|
+
},
|
|
1843
|
+
children: [/* @__PURE__ */ jsx(ScanLine, { size: 18 }), /* @__PURE__ */ jsx("span", { children: "Inspect" })]
|
|
1844
|
+
}),
|
|
1845
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1846
|
+
"aria-label": "Pan",
|
|
1847
|
+
title: "Pan",
|
|
1848
|
+
"aria-pressed": !inspectMode && !interact,
|
|
1849
|
+
onClick: () => {
|
|
1850
|
+
setInspectMode(false);
|
|
1851
|
+
setInteract(false);
|
|
1852
|
+
},
|
|
1853
|
+
children: [/* @__PURE__ */ jsx(Hand, { size: 18 }), /* @__PURE__ */ jsx("span", { children: "Pan" })]
|
|
1854
|
+
}),
|
|
1855
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1856
|
+
"aria-label": "Interact",
|
|
1857
|
+
title: "Interact with pages",
|
|
1858
|
+
"aria-pressed": interact,
|
|
1859
|
+
onClick: () => {
|
|
1860
|
+
setInspectMode(false);
|
|
1861
|
+
setInteract(true);
|
|
1862
|
+
},
|
|
1863
|
+
children: [/* @__PURE__ */ jsx(MousePointer2, { size: 18 }), /* @__PURE__ */ jsx("span", { children: "Interact" })]
|
|
1864
|
+
})
|
|
1865
|
+
]
|
|
1866
|
+
}),
|
|
1867
|
+
/* @__PURE__ */ jsx("span", { className: "povio-canvas-dock-divider" }),
|
|
1868
|
+
/* @__PURE__ */ jsxs("button", {
|
|
1869
|
+
"aria-label": "Auto layout",
|
|
1870
|
+
onClick: () => setManifest((m_1) => ({
|
|
1871
|
+
...m_1,
|
|
1872
|
+
positions: {
|
|
1873
|
+
...m_1.positions,
|
|
1874
|
+
[bp.id]: {}
|
|
1875
|
+
}
|
|
1876
|
+
})),
|
|
1877
|
+
children: [/* @__PURE__ */ jsx(PanelsTopLeft, { size: 17 }), /* @__PURE__ */ jsx("span", { children: "Auto layout" })]
|
|
1878
|
+
})
|
|
1879
|
+
]
|
|
1880
|
+
}),
|
|
1881
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1882
|
+
className: "povio-canvas-camera",
|
|
1883
|
+
children: [
|
|
1884
|
+
/* @__PURE__ */ jsx("button", {
|
|
1885
|
+
className: "povio-canvas-configure",
|
|
1886
|
+
"aria-label": "Configure UI",
|
|
1887
|
+
title: "Configure UI",
|
|
1888
|
+
onClick: configuration.openFloating,
|
|
1889
|
+
children: /* @__PURE__ */ jsx(Settings2, { size: 16 })
|
|
1890
|
+
}),
|
|
1891
|
+
/* @__PURE__ */ jsx("button", {
|
|
1892
|
+
className: "povio-canvas-theme-toggle",
|
|
1893
|
+
onClick: () => setDark(!dark),
|
|
1894
|
+
"aria-pressed": dark,
|
|
1895
|
+
"aria-label": dark ? "Dark" : "Light",
|
|
1896
|
+
title: "Toggle page theme",
|
|
1897
|
+
children: dark ? /* @__PURE__ */ jsx(Moon, { size: 16 }) : /* @__PURE__ */ jsx(Sun, { size: 16 })
|
|
1898
|
+
}),
|
|
1899
|
+
/* @__PURE__ */ jsxs("div", {
|
|
1900
|
+
className: "povio-canvas-breakpoint",
|
|
1901
|
+
children: [/* @__PURE__ */ jsx(Monitor, { size: 15 }), /* @__PURE__ */ jsx("select", {
|
|
1902
|
+
"aria-label": "Canvas breakpoint",
|
|
1903
|
+
value: bp.id,
|
|
1904
|
+
onChange: (e) => {
|
|
1905
|
+
if (e.target.value === bp.id) return;
|
|
1906
|
+
setRuntime({});
|
|
1907
|
+
setManifest((m_2) => ({
|
|
1908
|
+
...m_2,
|
|
1909
|
+
breakpoint: e.target.value
|
|
1910
|
+
}));
|
|
1911
|
+
},
|
|
1912
|
+
children: breakpoints.map((item_0) => /* @__PURE__ */ jsxs("option", {
|
|
1913
|
+
value: item_0.id,
|
|
1914
|
+
children: [
|
|
1915
|
+
item_0.label,
|
|
1916
|
+
" · ",
|
|
1917
|
+
item_0.width,
|
|
1918
|
+
"px"
|
|
1919
|
+
]
|
|
1920
|
+
}, item_0.id))
|
|
1921
|
+
})]
|
|
1922
|
+
}),
|
|
1923
|
+
/* @__PURE__ */ jsx("span", { className: "povio-canvas-dock-divider" }),
|
|
1924
|
+
/* @__PURE__ */ jsx("button", {
|
|
1925
|
+
onClick: () => stepZoom(-1),
|
|
1926
|
+
"aria-label": "Zoom out",
|
|
1927
|
+
children: "−"
|
|
1928
|
+
}),
|
|
1929
|
+
/* @__PURE__ */ jsx("button", {
|
|
1930
|
+
className: "povio-canvas-zoom-reset",
|
|
1931
|
+
"aria-label": "Zoom to 100%",
|
|
1932
|
+
title: "Zoom to 100%",
|
|
1933
|
+
onClick: () => zoomTo(1),
|
|
1934
|
+
children: /* @__PURE__ */ jsx("output", {
|
|
1935
|
+
ref: zoomOutput,
|
|
1936
|
+
children: "25%"
|
|
1937
|
+
})
|
|
1938
|
+
}),
|
|
1939
|
+
/* @__PURE__ */ jsx("button", {
|
|
1940
|
+
onClick: () => stepZoom(1),
|
|
1941
|
+
"aria-label": "Zoom in",
|
|
1942
|
+
children: "+"
|
|
1943
|
+
}),
|
|
1944
|
+
/* @__PURE__ */ jsx("button", {
|
|
1945
|
+
onClick: fit,
|
|
1946
|
+
children: "Fit all"
|
|
1947
|
+
})
|
|
1948
|
+
]
|
|
1949
|
+
})
|
|
1950
|
+
]
|
|
1951
|
+
}),
|
|
1952
|
+
inspectMode && /* @__PURE__ */ jsx(CanvasInspectorPanel, {
|
|
1953
|
+
inspector,
|
|
1954
|
+
onClose: () => setInspectMode(false)
|
|
1955
|
+
})
|
|
1956
|
+
]
|
|
1957
|
+
}),
|
|
1958
|
+
notice && /* @__PURE__ */ jsxs("div", {
|
|
1959
|
+
className: "povio-canvas-notice",
|
|
1960
|
+
role: "status",
|
|
1961
|
+
children: [notice, /* @__PURE__ */ jsx("button", {
|
|
1962
|
+
onClick: () => setNotice(""),
|
|
1963
|
+
children: "Dismiss"
|
|
1964
|
+
})]
|
|
1965
|
+
})
|
|
1966
|
+
]
|
|
1967
|
+
});
|
|
1968
|
+
}
|
|
1969
|
+
//#endregion
|
|
1970
|
+
//#region src/app-canvas/document-frame.ts
|
|
1971
|
+
/** Adapt a same-origin document to an uncropped, full-page canvas artboard. */
|
|
1972
|
+
function startCanvasDocument(doc, options) {
|
|
1973
|
+
const win = doc.defaultView;
|
|
1974
|
+
if (!win) throw new Error("Canvas document must belong to a window.");
|
|
1975
|
+
const viewportHeight = Math.max(1, options.viewportHeight);
|
|
1976
|
+
let interact = options.interact ?? false;
|
|
1977
|
+
let destroyed = false;
|
|
1978
|
+
let frame = 0;
|
|
1979
|
+
let lastHeight = 0;
|
|
1980
|
+
let lastLinks = "";
|
|
1981
|
+
const originals = /* @__PURE__ */ new Map();
|
|
1982
|
+
const mediaOriginals = /* @__PURE__ */ new Map();
|
|
1983
|
+
const liveStyles = /* @__PURE__ */ new Set();
|
|
1984
|
+
const liveMedia = /* @__PURE__ */ new Set();
|
|
1985
|
+
const warnedSheets = /* @__PURE__ */ new WeakSet();
|
|
1986
|
+
const positioned = /* @__PURE__ */ new WeakSet();
|
|
1987
|
+
const set = (style, property, value, priority = "important") => {
|
|
1988
|
+
liveStyles.add(style);
|
|
1989
|
+
if (style.getPropertyValue(property) === value && style.getPropertyPriority(property) === priority) return;
|
|
1990
|
+
let saved = originals.get(style);
|
|
1991
|
+
if (!saved) {
|
|
1992
|
+
saved = /* @__PURE__ */ new Map();
|
|
1993
|
+
originals.set(style, saved);
|
|
1994
|
+
}
|
|
1995
|
+
if (!saved.has(property)) saved.set(property, [style.getPropertyValue(property), style.getPropertyPriority(property)]);
|
|
1996
|
+
style.setProperty(property, value, priority);
|
|
1997
|
+
};
|
|
1998
|
+
const freezeUnits = (style) => {
|
|
1999
|
+
liveStyles.add(style);
|
|
2000
|
+
for (const property of Array.from(style)) {
|
|
2001
|
+
const value = style.getPropertyValue(property);
|
|
2002
|
+
const frozen = value.replace(/(-?(?:\d*\.)?\d+)(?:dvh|svh|lvh|vh)\b/gi, (_, amount) => `${Number(amount) * viewportHeight / 100}px`);
|
|
2003
|
+
if (value !== frozen) set(style, property, frozen, style.getPropertyPriority(property));
|
|
2004
|
+
}
|
|
2005
|
+
};
|
|
2006
|
+
const freezeMedia = (media) => {
|
|
2007
|
+
liveMedia.add(media);
|
|
2008
|
+
if (mediaOriginals.has(media)) return;
|
|
2009
|
+
const original = media.mediaText;
|
|
2010
|
+
const frozen = original.replace(/\([^()]*\b(?:height|orientation|aspect-ratio)\b[^()]*\)/gi, (predicate) => win.matchMedia(predicate).matches ? "(min-width: 0px)" : "(max-width: -1px)");
|
|
2011
|
+
if (frozen !== original) {
|
|
2012
|
+
mediaOriginals.set(media, original);
|
|
2013
|
+
media.mediaText = frozen;
|
|
2014
|
+
}
|
|
2015
|
+
};
|
|
2016
|
+
const visitRules = (rules) => {
|
|
2017
|
+
for (const rule of Array.from(rules)) {
|
|
2018
|
+
if ("style" in rule) freezeUnits(rule.style);
|
|
2019
|
+
if ("media" in rule) freezeMedia(rule.media);
|
|
2020
|
+
if ("cssRules" in rule) visitRules(rule.cssRules);
|
|
2021
|
+
if ("styleSheet" in rule && rule.styleSheet) visitSheet(rule.styleSheet);
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
const visitSheet = (sheet) => {
|
|
2025
|
+
try {
|
|
2026
|
+
freezeMedia(sheet.media);
|
|
2027
|
+
visitRules(sheet.cssRules);
|
|
2028
|
+
} catch {
|
|
2029
|
+
if (!warnedSheets.has(sheet)) {
|
|
2030
|
+
warnedSheets.add(sheet);
|
|
2031
|
+
const message = `App canvas cannot normalize inaccessible stylesheet ${sheet.href ?? "(inline)"}. Serve its CSS from the app origin for accurate full-page dimensions.`;
|
|
2032
|
+
if (options.onWarning) options.onWarning(message);
|
|
2033
|
+
else win.console.warn(message);
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
};
|
|
2037
|
+
const anchorURL = (anchor) => {
|
|
2038
|
+
try {
|
|
2039
|
+
const url = new URL(anchor.getAttribute("href") ?? "", doc.baseURI);
|
|
2040
|
+
return /^https?:$/.test(url.protocol) && url.origin === new URL(doc.baseURI).origin ? url.href : null;
|
|
2041
|
+
} catch {
|
|
2042
|
+
return null;
|
|
2043
|
+
}
|
|
2044
|
+
};
|
|
2045
|
+
const refresh = () => {
|
|
2046
|
+
if (destroyed) return;
|
|
2047
|
+
if (frame) {
|
|
2048
|
+
win.cancelAnimationFrame(frame);
|
|
2049
|
+
frame = 0;
|
|
2050
|
+
}
|
|
2051
|
+
observer.disconnect();
|
|
2052
|
+
liveStyles.clear();
|
|
2053
|
+
liveMedia.clear();
|
|
2054
|
+
for (const sheet of [...Array.from(doc.styleSheets), ...Array.from(doc.adoptedStyleSheets ?? [])]) visitSheet(sheet);
|
|
2055
|
+
const elements = Array.from(doc.querySelectorAll("*")).filter((el) => "style" in el);
|
|
2056
|
+
for (const el of elements) freezeUnits(el.style);
|
|
2057
|
+
const snapshots = elements.map((el) => ({
|
|
2058
|
+
el,
|
|
2059
|
+
css: win.getComputedStyle(el),
|
|
2060
|
+
rect: el.getBoundingClientRect()
|
|
2061
|
+
}));
|
|
2062
|
+
for (const { el, css, rect } of snapshots) {
|
|
2063
|
+
if (!positioned.has(el) && (css.position === "fixed" || css.position === "sticky")) {
|
|
2064
|
+
positioned.add(el);
|
|
2065
|
+
if (css.position === "sticky") set(el.style, "position", "static");
|
|
2066
|
+
else {
|
|
2067
|
+
set(el.style, "position", "absolute");
|
|
2068
|
+
const containingBlock = el.offsetParent;
|
|
2069
|
+
const parentRect = containingBlock?.getBoundingClientRect();
|
|
2070
|
+
const parentTop = containingBlock && containingBlock !== doc.body && containingBlock !== doc.documentElement ? (parentRect?.top ?? 0) + containingBlock.clientTop - containingBlock.scrollTop : -win.scrollY;
|
|
2071
|
+
const parentLeft = containingBlock && containingBlock !== doc.body && containingBlock !== doc.documentElement ? (parentRect?.left ?? 0) + containingBlock.clientLeft - containingBlock.scrollLeft : -win.scrollX;
|
|
2072
|
+
set(el.style, "top", `${rect.top - parentTop}px`);
|
|
2073
|
+
set(el.style, "left", `${rect.left - parentLeft}px`);
|
|
2074
|
+
set(el.style, "right", "auto");
|
|
2075
|
+
set(el.style, "bottom", "auto");
|
|
2076
|
+
set(el.style, "width", `${rect.width}px`);
|
|
2077
|
+
set(el.style, "height", `${rect.height}px`);
|
|
2078
|
+
}
|
|
2079
|
+
}
|
|
2080
|
+
if (/^(auto|scroll)$/.test(css.overflowY) && el.scrollHeight > el.clientHeight) {
|
|
2081
|
+
let ancestor = el;
|
|
2082
|
+
while (ancestor && ancestor !== doc.documentElement) {
|
|
2083
|
+
set(ancestor.style, "height", "auto");
|
|
2084
|
+
set(ancestor.style, "max-height", "none");
|
|
2085
|
+
set(ancestor.style, "overflow-y", "visible");
|
|
2086
|
+
set(ancestor.style, "flex-shrink", "0");
|
|
2087
|
+
ancestor = ancestor.parentElement;
|
|
2088
|
+
}
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
set(doc.documentElement.style, "height", "auto");
|
|
2092
|
+
set(doc.documentElement.style, "min-height", "0px");
|
|
2093
|
+
set(doc.documentElement.style, "overflow-y", "hidden");
|
|
2094
|
+
if (doc.body) {
|
|
2095
|
+
set(doc.body.style, "height", "auto");
|
|
2096
|
+
set(doc.body.style, "min-height", "0px");
|
|
2097
|
+
}
|
|
2098
|
+
let bottom = 0;
|
|
2099
|
+
for (const el of elements) {
|
|
2100
|
+
if (el === doc.documentElement || el === doc.body || !el.getClientRects().length) continue;
|
|
2101
|
+
bottom = Math.max(bottom, el.getBoundingClientRect().bottom + win.scrollY);
|
|
2102
|
+
}
|
|
2103
|
+
if (doc.body) bottom = Math.max(bottom, doc.body.getBoundingClientRect().bottom + win.scrollY);
|
|
2104
|
+
const height = Math.max(viewportHeight, Math.ceil(bottom));
|
|
2105
|
+
if (height !== lastHeight) {
|
|
2106
|
+
lastHeight = height;
|
|
2107
|
+
options.onHeight(height);
|
|
2108
|
+
}
|
|
2109
|
+
if (options.onLinks) {
|
|
2110
|
+
const links = Array.from(doc.querySelectorAll("a[href]")).flatMap((anchor) => {
|
|
2111
|
+
const href = anchorURL(anchor);
|
|
2112
|
+
return href ? [{
|
|
2113
|
+
href,
|
|
2114
|
+
label: anchor.textContent?.trim() || anchor.getAttribute("aria-label") || href
|
|
2115
|
+
}] : [];
|
|
2116
|
+
});
|
|
2117
|
+
const signature = JSON.stringify(links);
|
|
2118
|
+
if (signature !== lastLinks) {
|
|
2119
|
+
lastLinks = signature;
|
|
2120
|
+
options.onLinks(links);
|
|
2121
|
+
}
|
|
2122
|
+
}
|
|
2123
|
+
for (const style of originals.keys()) if (!liveStyles.has(style)) originals.delete(style);
|
|
2124
|
+
for (const media of mediaOriginals.keys()) if (!liveMedia.has(media)) mediaOriginals.delete(media);
|
|
2125
|
+
liveStyles.clear();
|
|
2126
|
+
liveMedia.clear();
|
|
2127
|
+
observer.observe(doc.documentElement, {
|
|
2128
|
+
subtree: true,
|
|
2129
|
+
childList: true,
|
|
2130
|
+
attributes: true,
|
|
2131
|
+
characterData: true
|
|
2132
|
+
});
|
|
2133
|
+
};
|
|
2134
|
+
const schedule = () => {
|
|
2135
|
+
if (!destroyed && !frame) frame = win.requestAnimationFrame(refresh);
|
|
2136
|
+
};
|
|
2137
|
+
const observer = new win.MutationObserver(schedule);
|
|
2138
|
+
const resize = new win.ResizeObserver(schedule);
|
|
2139
|
+
resize.observe(doc.documentElement);
|
|
2140
|
+
if (doc.body) resize.observe(doc.body);
|
|
2141
|
+
const click = (event) => {
|
|
2142
|
+
const anchor = event.target?.closest?.("a[href]");
|
|
2143
|
+
if (interact && !anchor) return;
|
|
2144
|
+
event.preventDefault();
|
|
2145
|
+
event.stopImmediatePropagation();
|
|
2146
|
+
if (anchor) {
|
|
2147
|
+
const href = anchorURL(anchor);
|
|
2148
|
+
if (href) options.onNavigate(href);
|
|
2149
|
+
}
|
|
2150
|
+
};
|
|
2151
|
+
const submit = (event) => {
|
|
2152
|
+
if (!interact) {
|
|
2153
|
+
event.preventDefault();
|
|
2154
|
+
event.stopImmediatePropagation();
|
|
2155
|
+
}
|
|
2156
|
+
};
|
|
2157
|
+
win.addEventListener("click", click, true);
|
|
2158
|
+
win.addEventListener("submit", submit, true);
|
|
2159
|
+
win.addEventListener("resize", schedule);
|
|
2160
|
+
doc.addEventListener("load", schedule, true);
|
|
2161
|
+
doc.fonts?.ready.then(schedule);
|
|
2162
|
+
refresh();
|
|
2163
|
+
return {
|
|
2164
|
+
refresh,
|
|
2165
|
+
setInteract(value) {
|
|
2166
|
+
interact = value;
|
|
2167
|
+
},
|
|
2168
|
+
destroy() {
|
|
2169
|
+
destroyed = true;
|
|
2170
|
+
if (frame) win.cancelAnimationFrame(frame);
|
|
2171
|
+
observer.disconnect();
|
|
2172
|
+
resize.disconnect();
|
|
2173
|
+
win.removeEventListener("click", click, true);
|
|
2174
|
+
win.removeEventListener("submit", submit, true);
|
|
2175
|
+
win.removeEventListener("resize", schedule);
|
|
2176
|
+
doc.removeEventListener("load", schedule, true);
|
|
2177
|
+
for (const [media, value] of mediaOriginals) media.mediaText = value;
|
|
2178
|
+
for (const [style, values] of originals) for (const [property, [value, priority]] of values) if (value) style.setProperty(property, value, priority);
|
|
2179
|
+
else style.removeProperty(property);
|
|
2180
|
+
}
|
|
2181
|
+
};
|
|
2182
|
+
}
|
|
2183
|
+
//#endregion
|
|
2184
|
+
//#region src/app-canvas/AppCanvasFrameBridge.tsx
|
|
2185
|
+
/** Mount once inside the application's existing UIConfigurationProvider. No separate app copy or theme fork. */
|
|
2186
|
+
function AppCanvasFrameBridge({ href }) {
|
|
2187
|
+
const { setPreviewConfiguration } = useUIConfiguration();
|
|
2188
|
+
const [identity] = useState(canvasFrameIdentity);
|
|
2189
|
+
const currentHref = useRef(href);
|
|
2190
|
+
currentHref.current = href;
|
|
2191
|
+
useEffect(() => {
|
|
2192
|
+
if (!identity) return;
|
|
2193
|
+
const send = (data) => window.parent.postMessage({
|
|
2194
|
+
protocol: canvasProtocol,
|
|
2195
|
+
...identity,
|
|
2196
|
+
...data
|
|
2197
|
+
}, window.location.origin);
|
|
2198
|
+
const renderer = startCanvasDocument(document, {
|
|
2199
|
+
viewportHeight: identity.viewportHeight,
|
|
2200
|
+
onHeight: (height) => send({
|
|
2201
|
+
type: "height",
|
|
2202
|
+
height
|
|
2203
|
+
}),
|
|
2204
|
+
onNavigate: (url) => send({
|
|
2205
|
+
type: "navigate",
|
|
2206
|
+
href: url
|
|
2207
|
+
}),
|
|
2208
|
+
onWarning: (warning) => send({
|
|
2209
|
+
type: "warning",
|
|
2210
|
+
warning
|
|
2211
|
+
})
|
|
2212
|
+
});
|
|
2213
|
+
let ackFrame = 0;
|
|
2214
|
+
const receive = (event) => {
|
|
2215
|
+
const packet = event.data;
|
|
2216
|
+
if (event.source !== window.parent || event.origin !== window.location.origin || packet?.protocol !== "povio-app-canvas-v1" || packet.token !== identity.token || packet.id !== identity.id) return;
|
|
2217
|
+
if (packet.type === "mode") renderer.setInteract(!!packet.interact);
|
|
2218
|
+
if (packet.type === "configuration" && validConfiguration(packet.configuration)) {
|
|
2219
|
+
setPreviewConfiguration(packet.configuration);
|
|
2220
|
+
document.documentElement.classList.toggle("dark", !!packet.dark);
|
|
2221
|
+
cancelAnimationFrame(ackFrame);
|
|
2222
|
+
ackFrame = requestAnimationFrame(() => {
|
|
2223
|
+
send({
|
|
2224
|
+
type: "ack",
|
|
2225
|
+
revision: packet.revision
|
|
2226
|
+
});
|
|
2227
|
+
});
|
|
2228
|
+
}
|
|
2229
|
+
};
|
|
2230
|
+
window.addEventListener("message", receive);
|
|
2231
|
+
send({
|
|
2232
|
+
type: "ready",
|
|
2233
|
+
href: currentHref.current ?? window.location.href
|
|
2234
|
+
});
|
|
2235
|
+
return () => {
|
|
2236
|
+
cancelAnimationFrame(ackFrame);
|
|
2237
|
+
window.removeEventListener("message", receive);
|
|
2238
|
+
renderer.destroy();
|
|
2239
|
+
setPreviewConfiguration(null);
|
|
2240
|
+
};
|
|
2241
|
+
}, [identity, setPreviewConfiguration]);
|
|
2242
|
+
useEffect(() => {
|
|
2243
|
+
if (identity && href) window.parent.postMessage({
|
|
2244
|
+
protocol: canvasProtocol,
|
|
2245
|
+
...identity,
|
|
2246
|
+
type: "ready",
|
|
2247
|
+
href
|
|
2248
|
+
}, window.location.origin);
|
|
2249
|
+
}, [href, identity]);
|
|
2250
|
+
return null;
|
|
2251
|
+
}
|
|
2252
|
+
//#endregion
|
|
2253
|
+
export { AppCanvas, AppCanvasFrameBridge, defaultCanvasBreakpoints, discoverCanvasPages, isAppCanvasFrame, layoutCanvasPages };
|