@dynamicforms/vue-forms 2.0.2 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/plugin-uXEQYne6.js +271 -0
- package/dist/chunks/plugin-uXEQYne6.js.map +1 -0
- package/dist/chunks/registry-_vVZW3p9.js +105 -0
- package/dist/chunks/registry-_vVZW3p9.js.map +1 -0
- package/dist/dynamicforms-vue-forms.js +1320 -938
- package/dist/dynamicforms-vue-forms.js.map +1 -1
- package/dist/index.d.ts +1343 -906
- package/dist/plugins/tracking.d.ts +61 -0
- package/dist/plugins/tracking.js +279 -0
- package/dist/plugins/tracking.js.map +1 -0
- package/package.json +12 -9
- package/readme.md +139 -202
- package/dist/dynamicforms-vue-forms.css +0 -2
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
import { a as e, c as t, d as n, n as r, o as i, r as a, t as o } from "./registry-_vVZW3p9.js";
|
|
2
|
+
import { toRaw as s } from "vue";
|
|
3
|
+
//#region src/plugins/devtools/plugin.ts
|
|
4
|
+
var c = "dynamicforms-state", l = {
|
|
5
|
+
e: "editable",
|
|
6
|
+
r: "readonly",
|
|
7
|
+
d: "disabled",
|
|
8
|
+
n: "disabled-null"
|
|
9
|
+
}, u = {
|
|
10
|
+
f: "full",
|
|
11
|
+
i: "invisible",
|
|
12
|
+
h: "hidden",
|
|
13
|
+
s: "suppress"
|
|
14
|
+
};
|
|
15
|
+
function d(e) {
|
|
16
|
+
return Object.entries(e).map(([e, t]) => {
|
|
17
|
+
let n = t.indexOf(e);
|
|
18
|
+
return `${t.slice(0, n)}(${e})${t.slice(n + 1)}`;
|
|
19
|
+
}).join(" | ");
|
|
20
|
+
}
|
|
21
|
+
function f(e, t) {
|
|
22
|
+
if (typeof e != "string") return e;
|
|
23
|
+
let n = e.trim().toLowerCase();
|
|
24
|
+
return Object.values(t).includes(n) ? n : t[n] ?? e;
|
|
25
|
+
}
|
|
26
|
+
function p(e, t, n) {
|
|
27
|
+
if (t.length === 0) return n;
|
|
28
|
+
let r = Array.isArray(e) ? [...e] : { ...e };
|
|
29
|
+
return r[t[0]] = p(r[t[0]], t.slice(1), n), r;
|
|
30
|
+
}
|
|
31
|
+
function m(e, t, n, r) {
|
|
32
|
+
let i = e, [a, ...o] = n;
|
|
33
|
+
try {
|
|
34
|
+
t === "extra" ? e.setExtendedValues({ [a]: p(i.extra[a], o, r) }) : a === "value" && O(e) ? i.value = p(s(i.value), o, r) : a === "access" ? i.access = f(r, l) : a === "visibility" ? i.visibility = f(r, u) : a === "touched" && (i.touched = r);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.warn("[vue-forms devtools] the edit was refused:", e);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
function h(e, t) {
|
|
40
|
+
globalThis.__VUE_DEVTOOLS_GLOBAL_HOOK__?.emit?.("devtools-plugin:setup", e, t);
|
|
41
|
+
}
|
|
42
|
+
var g = 100, _ = Symbol.for("@dynamicforms/vue-forms.devtools"), v = /* @__PURE__ */ new Set(), y = !1;
|
|
43
|
+
function b() {
|
|
44
|
+
y || (y = !0, setTimeout(() => {
|
|
45
|
+
y = !1, v.forEach((e) => e());
|
|
46
|
+
}, 100));
|
|
47
|
+
}
|
|
48
|
+
function x(e) {
|
|
49
|
+
return e[Symbol.toStringTag] ?? "Element";
|
|
50
|
+
}
|
|
51
|
+
function S(e, t) {
|
|
52
|
+
return e.description.name ?? `${x(t)} #${e.id}`;
|
|
53
|
+
}
|
|
54
|
+
function C(e) {
|
|
55
|
+
return e.description.file ?? o(e.created?.stack);
|
|
56
|
+
}
|
|
57
|
+
function w(e) {
|
|
58
|
+
let t = e.fields;
|
|
59
|
+
if (t && x(e) !== "List") return Object.entries(t);
|
|
60
|
+
let n = e.items;
|
|
61
|
+
return n ? n.map((e, t) => [String(t), e]) : [];
|
|
62
|
+
}
|
|
63
|
+
function T(e, t, n) {
|
|
64
|
+
let r = w(n), i = x(n) === "List" ? r.slice(0, g) : r, a = i.map(([t, n]) => T(`${e}/${t}`, t, n));
|
|
65
|
+
i.length < r.length && a.push({
|
|
66
|
+
id: `${e}/…`,
|
|
67
|
+
label: `… ${r.length - i.length} more rows`
|
|
68
|
+
});
|
|
69
|
+
let o = {
|
|
70
|
+
id: e,
|
|
71
|
+
label: t,
|
|
72
|
+
tags: [{
|
|
73
|
+
label: x(n),
|
|
74
|
+
textColor: 16777215,
|
|
75
|
+
backgroundColor: n.valid ? 4372611 : 13840175
|
|
76
|
+
}]
|
|
77
|
+
};
|
|
78
|
+
return a.length && (o.children = a), o;
|
|
79
|
+
}
|
|
80
|
+
function E(t) {
|
|
81
|
+
let [n, ...r] = t.split("/"), i = e(n), a = i?.element.deref();
|
|
82
|
+
for (let e of r) {
|
|
83
|
+
if (!a) return;
|
|
84
|
+
a = w(a).find(([t]) => t === e)?.[1];
|
|
85
|
+
}
|
|
86
|
+
return i && a ? {
|
|
87
|
+
entry: i,
|
|
88
|
+
element: a
|
|
89
|
+
} : void 0;
|
|
90
|
+
}
|
|
91
|
+
function D(e) {
|
|
92
|
+
try {
|
|
93
|
+
return JSON.parse(JSON.stringify(s(e) ?? null));
|
|
94
|
+
} catch {
|
|
95
|
+
return String(e);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
function O(e) {
|
|
99
|
+
return x(e) === "Field" || x(e) === "Action";
|
|
100
|
+
}
|
|
101
|
+
function k(e) {
|
|
102
|
+
let t = e;
|
|
103
|
+
return {
|
|
104
|
+
element: [
|
|
105
|
+
{
|
|
106
|
+
key: "value",
|
|
107
|
+
value: D(t.value),
|
|
108
|
+
editable: O(e)
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
key: "originalValue",
|
|
112
|
+
value: D(t.originalValue)
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
key: "isChanged",
|
|
116
|
+
value: t.isChanged
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
key: "access",
|
|
120
|
+
value: t.access,
|
|
121
|
+
editable: !0
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
key: "access options",
|
|
125
|
+
value: d(l)
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
key: "effectiveAccess",
|
|
129
|
+
value: t.effectiveAccess
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
key: "visibility",
|
|
133
|
+
value: t.visibility,
|
|
134
|
+
editable: !0
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
key: "visibility options",
|
|
138
|
+
value: d(u)
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
key: "touched",
|
|
142
|
+
value: t.touched,
|
|
143
|
+
editable: !0
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
validity: [
|
|
147
|
+
{
|
|
148
|
+
key: "valid",
|
|
149
|
+
value: t.valid
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
key: "validating",
|
|
153
|
+
value: t.validating
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
key: "busy",
|
|
157
|
+
value: t.busy
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
key: "errors",
|
|
161
|
+
value: t.errors.map((e) => ({
|
|
162
|
+
code: e.code,
|
|
163
|
+
detail: e.detail,
|
|
164
|
+
origin: e.origin,
|
|
165
|
+
params: D(e.params)
|
|
166
|
+
}))
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
extra: Object.entries(t.extra ?? {}).map(([e, t]) => ({
|
|
170
|
+
key: e,
|
|
171
|
+
value: D(t),
|
|
172
|
+
editable: !0
|
|
173
|
+
}))
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function A(e) {
|
|
177
|
+
e[_] || (e[_] = !0, h({
|
|
178
|
+
id: "dynamicforms-vue-forms",
|
|
179
|
+
label: "vue-forms",
|
|
180
|
+
packageName: "@dynamicforms/vue-forms",
|
|
181
|
+
homepage: "https://docs.velis.si/dynamicforms/vue-forms",
|
|
182
|
+
componentStateTypes: ["vue-forms"],
|
|
183
|
+
app: e
|
|
184
|
+
}, (e) => {
|
|
185
|
+
e.addInspector({
|
|
186
|
+
id: c,
|
|
187
|
+
label: "vue-forms",
|
|
188
|
+
icon: "dynamic_form",
|
|
189
|
+
treeFilterPlaceholder: "Search state"
|
|
190
|
+
}), e.on.getInspectorTree((e) => {
|
|
191
|
+
if (e.inspectorId !== c) return;
|
|
192
|
+
let n = e.filter.toLowerCase(), r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
|
|
193
|
+
t().forEach(({ entry: e, element: t }) => {
|
|
194
|
+
let o = S(e, t), s = e.instance?.deref(), c = s ? a(s) : C(e) ?? "unknown file";
|
|
195
|
+
if (n && !`${o} ${c}`.toLowerCase().includes(n)) return;
|
|
196
|
+
let l = s ? i : r;
|
|
197
|
+
l.has(c) || l.set(c, []), l.get(c).push(T(e.id, o, t));
|
|
198
|
+
});
|
|
199
|
+
let o = (e, t, n) => {
|
|
200
|
+
let r = {
|
|
201
|
+
id: e,
|
|
202
|
+
label: t
|
|
203
|
+
};
|
|
204
|
+
return n.size && (r.children = [...n].map(([t, n]) => ({
|
|
205
|
+
id: `${e}:${t}`,
|
|
206
|
+
label: t,
|
|
207
|
+
children: n
|
|
208
|
+
}))), r;
|
|
209
|
+
};
|
|
210
|
+
e.rootNodes = [o("global", "Global state", r), o("components", "Component state", i)];
|
|
211
|
+
}), e.on.getInspectorState((e) => {
|
|
212
|
+
if (e.inspectorId !== c) return;
|
|
213
|
+
let t = E(e.nodeId);
|
|
214
|
+
if (!t) return;
|
|
215
|
+
let n = t.entry.instance?.deref(), i = r(t.entry.created?.stack).map(({ name: e, file: t, line: n, column: r }) => `${e ? `${e} ` : ""}${t}:${n}:${r}`);
|
|
216
|
+
e.state = {
|
|
217
|
+
...k(t.element),
|
|
218
|
+
location: [
|
|
219
|
+
{
|
|
220
|
+
key: "file",
|
|
221
|
+
value: C(t.entry) ?? "unknown"
|
|
222
|
+
},
|
|
223
|
+
...n ? [{
|
|
224
|
+
key: "component",
|
|
225
|
+
value: a(n)
|
|
226
|
+
}] : [],
|
|
227
|
+
...i.length ? [{
|
|
228
|
+
key: "stack",
|
|
229
|
+
value: i
|
|
230
|
+
}] : []
|
|
231
|
+
]
|
|
232
|
+
};
|
|
233
|
+
}), e.on.editInspectorState((t) => {
|
|
234
|
+
if (t.inspectorId !== c) return;
|
|
235
|
+
let n = E(t.nodeId);
|
|
236
|
+
!n || t.state?.remove || (m(n.element, t.type, t.path, t.state.value), e.sendInspectorState(c));
|
|
237
|
+
}), e.on.inspectComponent((e) => {
|
|
238
|
+
t().forEach(({ entry: t, element: n }) => {
|
|
239
|
+
if (t.instance?.deref() !== e.componentInstance) return;
|
|
240
|
+
let r = S(t, n);
|
|
241
|
+
e.instanceData.state.some((e) => e.type === "vue-forms" && e.key === r) || e.instanceData.state.push({
|
|
242
|
+
type: "vue-forms",
|
|
243
|
+
key: r,
|
|
244
|
+
value: D(n.value),
|
|
245
|
+
editable: !1
|
|
246
|
+
});
|
|
247
|
+
});
|
|
248
|
+
}), v.add(() => {
|
|
249
|
+
e.sendInspectorTree(c), e.sendInspectorState(c);
|
|
250
|
+
});
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
function j() {
|
|
254
|
+
n(b);
|
|
255
|
+
let e = globalThis.__VUE_DEVTOOLS_GLOBAL_HOOK__;
|
|
256
|
+
if (!e) return;
|
|
257
|
+
e.on?.("app:init", (e) => A(e));
|
|
258
|
+
let t = e.apps ?? e.appRecords ?? [];
|
|
259
|
+
(Array.isArray(t) ? t : [...t.values?.() ?? []]).forEach((e) => {
|
|
260
|
+
let t = e?.app ?? e;
|
|
261
|
+
t?.config && A(t);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function M(e) {
|
|
265
|
+
let t = i(e)?.instance?.deref()?.appContext.app;
|
|
266
|
+
t && A(t);
|
|
267
|
+
}
|
|
268
|
+
//#endregion
|
|
269
|
+
export { j as install, M as installFor };
|
|
270
|
+
|
|
271
|
+
//# sourceMappingURL=plugin-uXEQYne6.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-uXEQYne6.js","names":[],"sources":["../../src/plugins/devtools/plugin.ts"],"sourcesContent":["import { type App, toRaw } from 'vue';\n\nimport type { FieldBase } from '../../field-base';\n\nimport {\n callerFile,\n callerFrames,\n componentPath,\n type Entry,\n entryById,\n entryOf,\n listed,\n onRegistryChanged,\n} from './registry';\n\nconst INSPECTOR = 'dynamicforms-state';\n\n/** The part of the devtools plugin API the inspector uses. */\ninterface DevtoolsApi {\n addInspector(options: Record<string, unknown>): void;\n sendInspectorTree(inspectorId: string): void;\n sendInspectorState(inspectorId: string): void;\n on: {\n getInspectorTree(handler: (payload: any) => void): void;\n getInspectorState(handler: (payload: any) => void): void;\n inspectComponent(handler: (payload: any) => void): void;\n editInspectorState(handler: (payload: any) => void): void;\n };\n}\n\n/** The letter that stands for each access and each visibility when it is typed in the inspector. */\nconst accessShortcuts: Record<string, string> = { e: 'editable', r: 'readonly', d: 'disabled', n: 'disabled-null' };\nconst visibilityShortcuts: Record<string, string> = { f: 'full', i: 'invisible', h: 'hidden', s: 'suppress' };\n\n/** The options with their letter in parentheses: `(e)ditable | … | disabled-(n)ull`. */\nfunction hint(shortcuts: Record<string, string>): string {\n return Object.entries(shortcuts)\n .map(([letter, value]) => {\n const at = value.indexOf(letter);\n return `${value.slice(0, at)}(${letter})${value.slice(at + 1)}`;\n })\n .join(' | ');\n}\n\n/**\n * The value `input` names: the value itself or its letter, ignoring case. `input` itself where it names none, so\n * the setter refuses it.\n */\nexport function optionNamed(input: unknown, shortcuts: Record<string, string>): unknown {\n if (typeof input !== 'string') return input;\n const typed = input.trim().toLowerCase();\n if (Object.values(shortcuts).includes(typed)) return typed;\n return shortcuts[typed] ?? input;\n}\n\n/** A copy of `value` with the member at `path` replaced by `replacement`; the original is left as it is. */\nfunction replaced(value: unknown, path: string[], replacement: unknown): unknown {\n if (path.length === 0) return replacement;\n const copy: any = Array.isArray(value) ? [...value] : { ...(value as object) };\n copy[path[0]] = replaced(copy[path[0]], path.slice(1), replacement);\n return copy;\n}\n\n/**\n * Writes an edit made in the inspector: the value of a leaf (a member of an object or array it holds is written as a\n * new copy), `access`, `visibility` and `touched` of any element, and an extended property. The write goes through\n * the element's setter, so it is a transaction like a write from the application. A value the setter refuses, such\n * as an access that is none of the four, is reported in the console and changes nothing.\n */\nexport function applyEdit(element: FieldBase, section: string, path: string[], value: unknown): void {\n const e = element as any;\n const [key, ...below] = path;\n try {\n if (section === 'extra') {\n element.setExtendedValues({ [key]: replaced(e.extra[key], below, value) } as any);\n } else if (key === 'value' && isLeaf(element)) {\n e.value = replaced(toRaw(e.value), below, value);\n } else if (key === 'access') {\n e.access = optionNamed(value, accessShortcuts);\n } else if (key === 'visibility') {\n e.visibility = optionNamed(value, visibilityShortcuts);\n } else if (key === 'touched') {\n e.touched = value;\n }\n } catch (error) {\n console.warn('[vue-forms devtools] the edit was refused:', error);\n }\n}\n\n/**\n * Registers a devtools plugin through the global devtools hook, the way every version of the devtools accepts one:\n * the devtools kit that initialised the devtools listens for `devtools-plugin:setup` on the hook. A copy of the kit\n * bundled with a library (`@vue/devtools-api` 7 and 8) registers only with itself, so a plugin set up through it is\n * not seen where another copy initialised the devtools.\n */\nfunction setupDevtoolsPlugin(descriptor: Record<string, unknown>, setupFn: (api: DevtoolsApi) => void): void {\n (globalThis as any).__VUE_DEVTOOLS_GLOBAL_HOOK__?.emit?.('devtools-plugin:setup', descriptor, setupFn);\n}\n/** the rows of a list the tree shows; the rest are summed up in one node */\nconst ROWS_SHOWN = 100;\n\ntype InspectorNode = {\n id: string;\n label: string;\n children?: InspectorNode[];\n tags?: { label: string; textColor: number; backgroundColor: number }[];\n};\n\n/** set on an app once the plugin is set up on it; held on the app, so a reloaded module does not set it up twice */\nconst SetUp = Symbol.for('@dynamicforms/vue-forms.devtools');\nconst refreshers = new Set<() => void>();\nlet scheduled = false;\n\n/** Sends the inspector tree and state again, at most once per 100 ms, after a change of the listed state. */\nfunction refreshSoon(): void {\n if (scheduled) return;\n scheduled = true;\n setTimeout(() => {\n scheduled = false;\n refreshers.forEach((refresh) => refresh());\n }, 100);\n}\n\nfunction kindOf(element: FieldBase): string {\n return (element as any)[Symbol.toStringTag] ?? 'Element';\n}\n\nfunction nameOf(entry: Entry, element: FieldBase): string {\n return entry.description.name ?? `${kindOf(element)} #${entry.id}`;\n}\n\nfunction fileOf(entry: Entry): string | undefined {\n return entry.description.file ?? callerFile(entry.created?.stack);\n}\n\n/** The members of a container, by name for a group and by position for a list. */\nfunction childrenOf(element: FieldBase): [string, FieldBase][] {\n const fields = (element as any).fields;\n if (fields && kindOf(element) !== 'List') return Object.entries(fields as Record<string, FieldBase>);\n const items = (element as any).items as readonly FieldBase[] | undefined;\n return items ? items.map((row, index) => [String(index), row]) : [];\n}\n\nfunction treeOf(id: string, label: string, element: FieldBase): InspectorNode {\n const members = childrenOf(element);\n const shown = kindOf(element) === 'List' ? members.slice(0, ROWS_SHOWN) : members;\n const children = shown.map(([key, child]) => treeOf(`${id}/${key}`, key, child));\n if (shown.length < members.length) {\n children.push({ id: `${id}/…`, label: `… ${members.length - shown.length} more rows` });\n }\n const node: InspectorNode = {\n id,\n label,\n tags: [{ label: kindOf(element), textColor: 0xffffff, backgroundColor: element.valid ? 0x42b883 : 0xd32f2f }],\n };\n // the key is left out for a leaf: the devtools serialise an undefined value as a marker, and the client shows a\n // node with a `children` key as one that expands\n if (children.length) node.children = children;\n return node;\n}\n\n/** The element a node id names: a listed element, and the path of member keys below it. */\nfunction resolve(nodeId: string): { entry: Entry; element: FieldBase } | undefined {\n const [rootId, ...path] = nodeId.split('/');\n const entry = entryById(rootId);\n let element = entry?.element.deref();\n for (const key of path) {\n if (!element) return undefined;\n element = childrenOf(element).find(([name]) => name === key)?.[1];\n }\n return entry && element ? { entry, element } : undefined;\n}\n\n/** A value the devtools can display: plain data, without Vue proxies or elements. */\nfunction plain(value: unknown): unknown {\n try {\n return JSON.parse(JSON.stringify(toRaw(value) ?? null));\n } catch {\n return String(value);\n }\n}\n\n/** A `Field` or an `Action`: an element whose value is its own, not composed from members. */\nfunction isLeaf(element: FieldBase): boolean {\n return kindOf(element) === 'Field' || kindOf(element) === 'Action';\n}\n\nfunction stateOf(element: FieldBase) {\n const e = element as any;\n return {\n element: [\n { key: 'value', value: plain(e.value), editable: isLeaf(element) },\n { key: 'originalValue', value: plain(e.originalValue) },\n { key: 'isChanged', value: e.isChanged },\n { key: 'access', value: e.access, editable: true },\n { key: 'access options', value: hint(accessShortcuts) },\n { key: 'effectiveAccess', value: e.effectiveAccess },\n { key: 'visibility', value: e.visibility, editable: true },\n { key: 'visibility options', value: hint(visibilityShortcuts) },\n { key: 'touched', value: e.touched, editable: true },\n ],\n validity: [\n { key: 'valid', value: e.valid },\n { key: 'validating', value: e.validating },\n { key: 'busy', value: e.busy },\n {\n key: 'errors',\n value: (e.errors as any[]).map((error) => ({\n code: error.code,\n detail: error.detail,\n origin: error.origin,\n params: plain(error.params),\n })),\n },\n ],\n extra: Object.entries(e.extra ?? {}).map(([key, value]) => ({ key, value: plain(value), editable: true })),\n };\n}\n\nfunction setup(app: App): void {\n if ((app as any)[SetUp]) return;\n (app as any)[SetUp] = true;\n setupDevtoolsPlugin(\n {\n id: 'dynamicforms-vue-forms',\n label: 'vue-forms',\n packageName: '@dynamicforms/vue-forms',\n homepage: 'https://docs.velis.si/dynamicforms/vue-forms',\n componentStateTypes: ['vue-forms'],\n app,\n },\n (api) => {\n api.addInspector({\n id: INSPECTOR,\n label: 'vue-forms',\n icon: 'dynamic_form',\n treeFilterPlaceholder: 'Search state',\n });\n\n api.on.getInspectorTree((payload) => {\n if (payload.inspectorId !== INSPECTOR) return;\n const filter = payload.filter.toLowerCase();\n const globals = new Map<string, InspectorNode[]>();\n const components = new Map<string, InspectorNode[]>();\n listed().forEach(({ entry, element }) => {\n const name = nameOf(entry, element);\n const instance = entry.instance?.deref();\n const location = instance ? componentPath(instance) : (fileOf(entry) ?? 'unknown file');\n if (filter && !`${name} ${location}`.toLowerCase().includes(filter)) return;\n const group = instance ? components : globals;\n if (!group.has(location)) group.set(location, []);\n group.get(location)!.push(treeOf(entry.id, name, element));\n });\n const section = (id: string, label: string, groups: Map<string, InspectorNode[]>): InspectorNode => {\n const node: InspectorNode = { id, label };\n // an empty section has no children key, so the client does not show it as one that expands\n if (groups.size) {\n node.children = [...groups].map(([location, nodes]) => ({\n id: `${id}:${location}`,\n label: location,\n children: nodes,\n }));\n }\n return node;\n };\n payload.rootNodes = [\n section('global', 'Global state', globals),\n section('components', 'Component state', components),\n ];\n });\n\n api.on.getInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR) return;\n const found = resolve(payload.nodeId);\n if (!found) return;\n const instance = found.entry.instance?.deref();\n const frames = callerFrames(found.entry.created?.stack).map(\n ({ name, file, line, column }) => `${name ? `${name} ` : ''}${file}:${line}:${column}`,\n );\n payload.state = {\n ...stateOf(found.element),\n location: [\n { key: 'file', value: fileOf(found.entry) ?? 'unknown' },\n ...(instance ? [{ key: 'component', value: componentPath(instance) }] : []),\n ...(frames.length ? [{ key: 'stack', value: frames }] : []),\n ],\n };\n });\n\n api.on.editInspectorState((payload) => {\n if (payload.inspectorId !== INSPECTOR) return;\n const found = resolve(payload.nodeId);\n if (!found || payload.state?.remove) return;\n applyEdit(found.element, payload.type, payload.path, payload.state.value);\n api.sendInspectorState(INSPECTOR);\n });\n\n api.on.inspectComponent((payload) => {\n listed().forEach(({ entry, element }) => {\n if (entry.instance?.deref() !== payload.componentInstance) return;\n const key = nameOf(entry, element);\n if (payload.instanceData.state.some((item: any) => item.type === 'vue-forms' && item.key === key)) return;\n payload.instanceData.state.push({\n type: 'vue-forms',\n key,\n value: plain((element as any).value),\n editable: false,\n });\n });\n });\n\n refreshers.add(() => {\n api.sendInspectorTree(INSPECTOR);\n api.sendInspectorState(INSPECTOR);\n });\n },\n );\n}\n\n/**\n * Installs the inspector in every Vue app: the apps already known to the devtools hook, every app initialised\n * later, and the app of a component that constructs an element.\n */\nexport function install(): void {\n onRegistryChanged(refreshSoon);\n const hook = (globalThis as any).__VUE_DEVTOOLS_GLOBAL_HOOK__;\n if (!hook) return;\n hook.on?.('app:init', (app: App) => setup(app));\n const known = hook.apps ?? hook.appRecords ?? [];\n (Array.isArray(known) ? known : [...(known.values?.() ?? [])]).forEach((record: any) => {\n const app = record?.app ?? record;\n if (app?.config) setup(app);\n });\n}\n\n/** Installs the inspector in the app of the component that constructed `element`. */\nexport function installFor(element: FieldBase): void {\n const app = entryOf(element)?.instance?.deref()?.appContext.app;\n if (app) setup(app);\n}\n"],"mappings":";;;AAeA,IAAM,IAAY,sBAgBZ,IAA0C;CAAE,GAAG;CAAY,GAAG;CAAY,GAAG;CAAY,GAAG;AAAgB,GAC5G,IAA8C;CAAE,GAAG;CAAQ,GAAG;CAAa,GAAG;CAAU,GAAG;AAAW;AAG5G,SAAS,EAAK,GAA2C;CACvD,OAAO,OAAO,QAAQ,CAAS,CAAC,CAC7B,KAAK,CAAC,GAAQ,OAAW;EACxB,IAAM,IAAK,EAAM,QAAQ,CAAM;EAC/B,OAAO,GAAG,EAAM,MAAM,GAAG,CAAE,EAAE,GAAG,EAAO,GAAG,EAAM,MAAM,IAAK,CAAC;CAC9D,CAAC,CAAC,CACD,KAAK,KAAK;AACf;AAMA,SAAgB,EAAY,GAAgB,GAA4C;CACtF,IAAI,OAAO,KAAU,UAAU,OAAO;CACtC,IAAM,IAAQ,EAAM,KAAK,CAAC,CAAC,YAAY;CAEvC,OADI,OAAO,OAAO,CAAS,CAAC,CAAC,SAAS,CAAK,IAAU,IAC9C,EAAU,MAAU;AAC7B;AAGA,SAAS,EAAS,GAAgB,GAAgB,GAA+B;CAC/E,IAAI,EAAK,WAAW,GAAG,OAAO;CAC9B,IAAM,IAAY,MAAM,QAAQ,CAAK,IAAI,CAAC,GAAG,CAAK,IAAI,EAAE,GAAI,EAAiB;C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AAC,GAAM;CACX,EAAK,KAAK,aAAa,MAAa,EAAM,CAAG,CAAC;CAC9C,IAAM,IAAQ,EAAK,QAAQ,EAAK,cAAc,CAAC;CAC/C,CAAC,MAAM,QAAQ,CAAK,IAAI,IAAQ,CAAC,GAAI,EAAM,SAAS,KAAK,CAAC,CAAE,EAAA,CAAG,SAAS,MAAgB;EACtF,IAAM,IAAM,GAAQ,OAAO;EAC3B,AAAI,GAAK,UAAQ,EAAM,CAAG;CAC5B,CAAC;AACH;AAGA,SAAgB,EAAW,GAA0B;CACnD,IAAM,IAAM,EAAQ,CAAO,CAAC,EAAE,UAAU,MAAM,CAAC,EAAE,WAAW;CAC5D,AAAI,KAAK,EAAM,CAAG;AACpB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { getCurrentInstance as e, getCurrentScope as t, onScopeDispose as n } from "vue";
|
|
2
|
+
//#region src/plugins/devtools/registry.ts
|
|
3
|
+
var r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new WeakMap(), a = 1, o = "opt-out", s = !0, c, l;
|
|
4
|
+
function u(e) {
|
|
5
|
+
l = e;
|
|
6
|
+
}
|
|
7
|
+
function d(e) {
|
|
8
|
+
c = e;
|
|
9
|
+
}
|
|
10
|
+
function f(o, s) {
|
|
11
|
+
let l;
|
|
12
|
+
if (s) {
|
|
13
|
+
let e = Error.stackTraceLimit;
|
|
14
|
+
Error.stackTraceLimit = 20, l = /* @__PURE__ */ Error(), Error.stackTraceLimit = e;
|
|
15
|
+
}
|
|
16
|
+
let u = e(), d = {
|
|
17
|
+
id: String(a++),
|
|
18
|
+
element: new WeakRef(o),
|
|
19
|
+
created: l,
|
|
20
|
+
instance: u ? new WeakRef(u) : void 0,
|
|
21
|
+
description: {},
|
|
22
|
+
hidden: !1,
|
|
23
|
+
described: !1
|
|
24
|
+
};
|
|
25
|
+
r.set(d.id, d), i.set(o, d), u && t() && n(() => {
|
|
26
|
+
r.delete(d.id), c?.();
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function p(e, t) {
|
|
30
|
+
let n = i.get(e);
|
|
31
|
+
n && (n.description = {
|
|
32
|
+
...n.description,
|
|
33
|
+
...t
|
|
34
|
+
}, n.described = !0, n.hidden = !1, r.has(n.id) || (n.instance = void 0, r.set(n.id, n)), c?.());
|
|
35
|
+
}
|
|
36
|
+
function m(e) {
|
|
37
|
+
let t = i.get(e);
|
|
38
|
+
t && (t.created = void 0);
|
|
39
|
+
}
|
|
40
|
+
function h(e, t) {
|
|
41
|
+
let n = i.get(e);
|
|
42
|
+
n && (n.hidden = t, c?.());
|
|
43
|
+
}
|
|
44
|
+
function g(e) {
|
|
45
|
+
o = e, c?.();
|
|
46
|
+
}
|
|
47
|
+
function _(e) {
|
|
48
|
+
s = e, c?.();
|
|
49
|
+
}
|
|
50
|
+
function v() {
|
|
51
|
+
c?.();
|
|
52
|
+
}
|
|
53
|
+
function y(e) {
|
|
54
|
+
return i.get(e);
|
|
55
|
+
}
|
|
56
|
+
function b(e) {
|
|
57
|
+
return r.get(e);
|
|
58
|
+
}
|
|
59
|
+
function x() {
|
|
60
|
+
let e = [];
|
|
61
|
+
return s && r.forEach((t, n) => {
|
|
62
|
+
let i = t.element.deref();
|
|
63
|
+
if (!i) {
|
|
64
|
+
r.delete(n);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
t.hidden || i.parent || l?.isInternal(i) || o === "opt-in" && !t.described || e.push({
|
|
68
|
+
entry: t,
|
|
69
|
+
element: i
|
|
70
|
+
});
|
|
71
|
+
}), e;
|
|
72
|
+
}
|
|
73
|
+
function S() {
|
|
74
|
+
let e = /(?:https?:\/\/[^/\s]+|file:\/\/)?(\/[^\s?):]+\.[cm]?[jt]s)/.exec((/* @__PURE__ */ Error()).stack ?? "")?.[1] ?? "";
|
|
75
|
+
return e.includes("/src/plugins/devtools/") ? e.slice(0, e.indexOf("/src/") + 5) : e.includes("/dist/") ? e.slice(0, e.lastIndexOf("/dist/") + 6) : e;
|
|
76
|
+
}
|
|
77
|
+
var C = /^\s*at (?:(.*?) \()?(\S+?):(\d+):(\d+)\)?$/, w = /^(.*?)@(\S+?):(\d+):(\d+)$/, T = /^(?:[a-z]+:\/\/[^/\s]*)?(\/[^\s?]+\.(?:[cm]?[jt]sx?|vue))(?:\?\S*)?$/;
|
|
78
|
+
function E(e, t = S()) {
|
|
79
|
+
let n = [];
|
|
80
|
+
for (let r of e?.split("\n") ?? []) {
|
|
81
|
+
let e = C.exec(r) ?? w.exec(r), i = e && T.exec(e[2])?.[1];
|
|
82
|
+
!i || i.startsWith(t) || i.includes("/node_modules/") || n.push({
|
|
83
|
+
name: e[1] || void 0,
|
|
84
|
+
file: i.replace(/^\//, ""),
|
|
85
|
+
line: Number(e[3]),
|
|
86
|
+
column: Number(e[4])
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
return n;
|
|
90
|
+
}
|
|
91
|
+
function D(e, t = S()) {
|
|
92
|
+
return E(e, t)[0]?.file;
|
|
93
|
+
}
|
|
94
|
+
function O(e) {
|
|
95
|
+
let t = [];
|
|
96
|
+
for (let n = e; n; n = n.parent) {
|
|
97
|
+
let e = n.type;
|
|
98
|
+
t.unshift(e.name ?? e.__name ?? e.__file?.split("/").pop() ?? "Anonymous");
|
|
99
|
+
}
|
|
100
|
+
return t.join(" > ");
|
|
101
|
+
}
|
|
102
|
+
//#endregion
|
|
103
|
+
export { b as a, x as c, d, _ as f, u as h, p as i, v as l, g as m, E as n, y as o, h as p, O as r, m as s, D as t, f as u };
|
|
104
|
+
|
|
105
|
+
//# sourceMappingURL=registry-_vVZW3p9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-_vVZW3p9.js","names":[],"sources":["../../src/plugins/devtools/registry.ts"],"sourcesContent":["import { type ComponentInternalInstance, getCurrentInstance, getCurrentScope, onScopeDispose } from 'vue';\n\nimport type { FieldBase } from '../../field-base';\nimport type { PluginContext } from '../../plugins';\n\n/** Which elements the devtools list: every root element except the hidden ones, or only the described ones. */\nexport type DevtoolsRegistration = 'opt-out' | 'opt-in';\n\n/** What an application states about an element for the devtools. */\nexport interface StateDescription {\n /** The name the devtools show; defaults to the element's class and a number. */\n name?: string;\n /** The file the element is defined in; defaults to the file of the code that constructed it. */\n file?: string;\n}\n\n/** What the registry knows about one element. */\nexport interface Entry {\n id: string;\n element: WeakRef<FieldBase>;\n /** the stack at construction; its text is built on the first read, when the devtools show the entry */\n created?: Error;\n /** the component whose setup constructed the element */\n instance?: WeakRef<ComponentInternalInstance>;\n description: StateDescription;\n hidden: boolean;\n described: boolean;\n}\n\nconst entries = new Map<string, Entry>();\nconst byElement = new WeakMap<FieldBase, Entry>();\nlet nextId = 1;\nlet registration: DevtoolsRegistration = 'opt-out';\nlet enabled = true;\nlet changed: (() => void) | undefined;\nlet context: PluginContext | undefined;\n\n/** Records the context the devtools plugin received; it tells a binding or an item template from a root. */\nexport function useContext(installed: PluginContext): void {\n context = installed;\n}\n\n/** Called by the devtools plugin; runs after a change the devtools show. */\nexport function onRegistryChanged(listener: () => void): void {\n changed = listener;\n}\n\n/**\n * Records an element at construction: the component that constructs it and, where `location` is true, the stack\n * that leads to it.\n */\nexport function noteElement(element: FieldBase, location: boolean): void {\n let created: Error | undefined;\n if (location) {\n const limit = Error.stackTraceLimit;\n Error.stackTraceLimit = 20;\n created = new Error();\n Error.stackTraceLimit = limit;\n }\n const instance = getCurrentInstance();\n const entry: Entry = {\n id: String(nextId++),\n element: new WeakRef(element),\n created,\n instance: instance ? new WeakRef(instance) : undefined,\n description: {},\n hidden: false,\n described: false,\n };\n entries.set(entry.id, entry);\n byElement.set(element, entry);\n // state a component constructs is listed while the component is mounted: an element is collected only when the\n // garbage collector runs, which can be long after the component was unmounted\n if (instance && getCurrentScope()) {\n onScopeDispose(() => {\n entries.delete(entry.id);\n changed?.();\n });\n }\n}\n\nexport function describe(element: FieldBase, description: StateDescription): void {\n const entry = byElement.get(element);\n if (!entry) return;\n entry.description = { ...entry.description, ...description };\n entry.described = true;\n entry.hidden = false;\n // an element its component handed on before unmounting is listed again, as global state\n if (!entries.has(entry.id)) {\n entry.instance = undefined;\n entries.set(entry.id, entry);\n }\n changed?.();\n}\n\n/**\n * Drops the stack captured for an element a container took: a member is shown inside its container, and its own\n * file is shown again only if the container releases it.\n */\nexport function forgetLocation(element: FieldBase): void {\n const entry = byElement.get(element);\n if (entry) entry.created = undefined;\n}\n\nexport function setHidden(element: FieldBase, hidden: boolean): void {\n const entry = byElement.get(element);\n if (!entry) return;\n entry.hidden = hidden;\n changed?.();\n}\n\nexport function setRegistration(mode: DevtoolsRegistration): void {\n registration = mode;\n changed?.();\n}\n\n/** Lists nothing while `on` is false. */\nexport function setEnabled(on: boolean): void {\n enabled = on;\n changed?.();\n}\n\n/** Reports a committed change. */\nexport function noteChange(): void {\n changed?.();\n}\n\n/** The entry of an element, where it has one. */\nexport function entryOf(element: FieldBase): Entry | undefined {\n return byElement.get(element);\n}\n\nexport function entryById(id: string): Entry | undefined {\n return entries.get(id);\n}\n\n/**\n * The listed elements: alive, not held by a container, not a binding or an item template, not hidden, and in\n * opt-in mode described. Entries whose element was collected are dropped here. Nothing is listed while the devtools\n * are turned off.\n */\nexport function listed(): { entry: Entry; element: FieldBase }[] {\n const out: { entry: Entry; element: FieldBase }[] = [];\n if (!enabled) return out;\n entries.forEach((entry, id) => {\n const element = entry.element.deref();\n if (!element) {\n entries.delete(id);\n return;\n }\n if (entry.hidden || element.parent || context?.isInternal(element)) return;\n if (registration === 'opt-in' && !entry.described) return;\n out.push({ entry, element });\n });\n return out;\n}\n\n/**\n * The path prefix of the library's own files: `…/src/` where the source is served, or `…/dist/` where the build is.\n * Frames from it are skipped when the caller's file is looked up.\n */\nfunction libraryPrefix(): string {\n // the first frame of a stack taken here is this module, served from the library's source or from a chunk of its\n // build, which lives in dist/ beside the entry files\n const own = /(?:https?:\\/\\/[^/\\s]+|file:\\/\\/)?(\\/[^\\s?):]+\\.[cm]?[jt]s)/.exec(new Error().stack ?? '')?.[1] ?? '';\n if (own.includes('/src/plugins/devtools/')) return own.slice(0, own.indexOf('/src/') + 5);\n if (own.includes('/dist/')) return own.slice(0, own.lastIndexOf('/dist/') + 6);\n return own;\n}\n\n/** A frame of a stack: the function, where the stack names one, and the file, line and column. */\nexport interface StackFrame {\n name?: string;\n /** a path relative to the served root: Vite serves a project file at `/src/…` */\n file: string;\n line: number;\n column: number;\n}\n\n// a Chrome frame is ` at name (url:line:column)` or ` at url:line:column`; a Firefox and a Safari frame is\n// `name@url:line:column`\nconst chromeFrame = /^\\s*at (?:(.*?) \\()?(\\S+?):(\\d+):(\\d+)\\)?$/;\nconst firefoxFrame = /^(.*?)@(\\S+?):(\\d+):(\\d+)$/;\nconst framePath = /^(?:[a-z]+:\\/\\/[^/\\s]*)?(\\/[^\\s?]+\\.(?:[cm]?[jt]sx?|vue))(?:\\?\\S*)?$/;\n\n/**\n * The frames of `stack` outside the library and `node_modules`, outermost last. A frame without a URL of a script\n * or a `.vue` file is left out.\n */\nexport function callerFrames(stack: string | undefined, library = libraryPrefix()): StackFrame[] {\n const frames: StackFrame[] = [];\n for (const text of stack?.split('\\n') ?? []) {\n const match = chromeFrame.exec(text) ?? firefoxFrame.exec(text);\n const path = match && framePath.exec(match[2])?.[1];\n if (!path || path.startsWith(library) || path.includes('/node_modules/')) continue;\n frames.push({\n name: match[1] || undefined,\n file: path.replace(/^\\//, ''),\n line: Number(match[3]),\n column: Number(match[4]),\n });\n }\n return frames;\n}\n\n/** The file of the first frame of `stack` outside the library and `node_modules`; undefined where there is none. */\nexport function callerFile(stack: string | undefined, library = libraryPrefix()): string | undefined {\n return callerFrames(stack, library)[0]?.file;\n}\n\n/** The names of the components from the root of the app to `instance`, joined by ` > `. */\nexport function componentPath(instance: ComponentInternalInstance): string {\n const names: string[] = [];\n for (let at: ComponentInternalInstance | null = instance; at; at = at.parent) {\n const type = at.type as { name?: string; __name?: string; __file?: string };\n names.unshift(type.name ?? type.__name ?? type.__file?.split('/').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