@symbo.ls/sync 2.11.523 → 3.0.2
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/Inspect.js +106 -114
- package/dist/cjs/Inspect.js +97 -116
- package/dist/cjs/SyncNotifications.js +1 -2
- package/dist/cjs/index.js +8 -12
- package/dist/esm/Inspect.js +97 -116
- package/dist/esm/SyncNotifications.js +1 -2
- package/dist/esm/index.js +5 -9
- package/index.js +1 -1
- package/package.json +8 -8
package/Inspect.js
CHANGED
|
@@ -4,16 +4,16 @@ import * as smblsUI from '@symbo.ls/uikit'
|
|
|
4
4
|
import { isObject, isString, isArray } from '@domql/utils'
|
|
5
5
|
import { send } from '@symbo.ls/socket/client'
|
|
6
6
|
|
|
7
|
-
function returnStringExtend (
|
|
8
|
-
return isString(
|
|
7
|
+
function returnStringExtend (_extends) {
|
|
8
|
+
return isString(_extends) ? _extends : isArray(_extends) ? _extends.find(extItem => isString(extItem)) : ''
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
function getComponentKey (el) {
|
|
12
12
|
if (!el) return
|
|
13
13
|
const __componentKey = el.__ref.__componentKey
|
|
14
|
-
const
|
|
15
|
-
const parentChildExtendStr = el.parent && el.parent.
|
|
16
|
-
return (__componentKey ||
|
|
14
|
+
const extendsStr = el.extends && returnStringExtend(el.extends)
|
|
15
|
+
const parentChildExtendStr = el.parent && el.parent.childExtends && returnStringExtend(el.parent.childExtends)
|
|
16
|
+
return (__componentKey || extendsStr || parentChildExtendStr || '').split('_')[0].split('.')[0].split('+')[0]
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
function findComponent (el) {
|
|
@@ -54,145 +54,137 @@ const onInspect = (app, state, ctx) => {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export const Inspect = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
'!preventSelect': { userSelect: 'auto' },
|
|
57
|
+
'.preventSelect': { userSelect: 'none' },
|
|
58
|
+
'!preventSelect': { userSelect: 'auto' },
|
|
60
59
|
|
|
61
|
-
|
|
60
|
+
onInspect,
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
onMousemove: (ev, e, state) => {
|
|
63
|
+
const el = ev.target.ref
|
|
64
|
+
const component = findComponent(el)
|
|
65
|
+
const focusState = e.Inspector.state
|
|
67
66
|
|
|
68
|
-
|
|
67
|
+
if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false })
|
|
69
68
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
69
|
+
const componentKey = getComponentKey(component)
|
|
70
|
+
const updateValue = (area) => {
|
|
71
|
+
focusState.update({ area, focusKey: componentKey })
|
|
72
|
+
}
|
|
74
73
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
const update = () => {
|
|
75
|
+
if (ev.altKey && ev.shiftKey) {
|
|
76
|
+
const { x, y, width, height } = component.node.getBoundingClientRect()
|
|
77
|
+
const area = { x, y, width, height }
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
79
|
+
if (!focusState.area) return updateValue(area)
|
|
80
|
+
if (focusState.area.x !== area.x) updateValue(area)
|
|
81
|
+
} else if (focusState.area) {
|
|
82
|
+
focusState.update({ area: false })
|
|
85
83
|
}
|
|
84
|
+
}
|
|
86
85
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
window.requestAnimationFrame(() => {
|
|
87
|
+
update()
|
|
88
|
+
window.requestAnimationFrame(update)
|
|
89
|
+
})
|
|
90
|
+
},
|
|
92
91
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
92
|
+
onMousedown: (ev, elem, state) => {
|
|
93
|
+
if (!state.debugging) return
|
|
94
|
+
const el = ev.target.ref
|
|
95
|
+
const component = findComponent(el)
|
|
96
|
+
if (!component) return
|
|
97
|
+
const componentKey = getComponentKey(component)
|
|
98
|
+
if (!componentKey) return
|
|
99
|
+
|
|
100
|
+
const editor = el.context.editor
|
|
101
|
+
if (editor && editor.onInspect) {
|
|
102
|
+
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true })
|
|
103
|
+
}
|
|
105
104
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
const data = JSON.stringify({
|
|
106
|
+
componentKey: `${componentKey}`
|
|
107
|
+
})
|
|
108
|
+
send.call(el.context.socket, 'route', data)
|
|
110
109
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
}
|
|
110
|
+
ev.preventDefault()
|
|
111
|
+
ev.stopPropagation()
|
|
112
|
+
return false
|
|
115
113
|
},
|
|
116
114
|
|
|
117
115
|
Inspector: {
|
|
118
116
|
state: {},
|
|
119
117
|
|
|
120
|
-
|
|
118
|
+
transition: 'all, defaultBezier, X',
|
|
119
|
+
position: 'fixed',
|
|
120
|
+
hide: (el, s) => !(s.area && s.parent.debugging),
|
|
121
|
+
style: {
|
|
122
|
+
boxShadow: '0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A',
|
|
123
|
+
zIndex: '9999999',
|
|
124
|
+
borderRadius: '10px',
|
|
125
|
+
pointerEvents: 'none'
|
|
126
|
+
},
|
|
127
|
+
|
|
128
|
+
Span: {
|
|
129
|
+
position: 'absolute',
|
|
130
|
+
margin: 'A2 0',
|
|
131
|
+
fontSize: 'Z',
|
|
132
|
+
color: 'text',
|
|
133
|
+
// color: 'blue',
|
|
134
|
+
zIndex: '99999999',
|
|
121
135
|
transition: 'all, defaultBezier, X',
|
|
122
|
-
|
|
123
|
-
|
|
136
|
+
textDecoration: 'underline',
|
|
137
|
+
fontWeight: '500',
|
|
138
|
+
top: '100%',
|
|
124
139
|
style: {
|
|
125
|
-
boxShadow: '0
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
130
|
-
}),
|
|
131
|
-
|
|
132
|
-
span: {
|
|
133
|
-
props: {
|
|
134
|
-
position: 'absolute',
|
|
135
|
-
margin: 'A2 0',
|
|
136
|
-
fontSize: 'Z',
|
|
137
|
-
color: 'text',
|
|
138
|
-
// color: 'blue',
|
|
139
|
-
zIndex: '99999999',
|
|
140
|
-
transition: 'all, defaultBezier, X',
|
|
141
|
-
textDecoration: 'underline',
|
|
142
|
-
fontWeight: '500',
|
|
143
|
-
top: '100%',
|
|
144
|
-
style: {
|
|
145
|
-
boxShadow: '0 25px 10px 35px black',
|
|
146
|
-
textShadow: '0 0 10px black'
|
|
147
|
-
},
|
|
148
|
-
text: '{{ focusKey }}'
|
|
149
|
-
}
|
|
140
|
+
boxShadow: '0 25px 10px 35px black',
|
|
141
|
+
textShadow: '0 0 10px black'
|
|
142
|
+
},
|
|
143
|
+
text: '{{ focusKey }}'
|
|
150
144
|
},
|
|
151
145
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
rest[key].__ref.__componentKey = key
|
|
163
|
-
}
|
|
146
|
+
onInit: ({ context }) => {
|
|
147
|
+
const { components } = context
|
|
148
|
+
|
|
149
|
+
if (isObject(components)) {
|
|
150
|
+
const { Content, ...rest } = components
|
|
151
|
+
for (const key in rest) {
|
|
152
|
+
if (smblsUI[key]) continue
|
|
153
|
+
if (!rest[key].__ref) rest[key].__ref = {}
|
|
154
|
+
if (!rest[key].__ref.__componentKey) {
|
|
155
|
+
rest[key].__ref.__componentKey = key
|
|
164
156
|
}
|
|
165
157
|
}
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
onBeforeUpdate: (ch, el, s) => {
|
|
161
|
+
const { area } = s
|
|
162
|
+
const isDebugging = s.area && s.parent.debugging
|
|
163
|
+
|
|
164
|
+
let style
|
|
165
|
+
if (!isDebugging) {
|
|
166
|
+
style = 'display: none !important'
|
|
167
|
+
} else if (area) {
|
|
168
|
+
const { x, y, width, height } = area
|
|
169
|
+
// el.node.style = Object.stringify({
|
|
170
|
+
// top: y - 6 + 'px',
|
|
171
|
+
// left: x - 6 + 'px',
|
|
172
|
+
// width: width + 12 + 'px',
|
|
173
|
+
// height: height + 12 + 'px'
|
|
174
|
+
// })
|
|
175
|
+
style = `
|
|
183
176
|
display: block !important;
|
|
184
177
|
top: ${y - 6}px;
|
|
185
178
|
left: ${x - 6}px;
|
|
186
179
|
width: ${width + 12}px;
|
|
187
180
|
height: ${height + 12}px;
|
|
188
181
|
`
|
|
189
|
-
|
|
182
|
+
}
|
|
190
183
|
|
|
191
|
-
|
|
192
|
-
|
|
184
|
+
el.node.style = style
|
|
185
|
+
el.Span.node.innerText = s.focusKey
|
|
193
186
|
|
|
194
|
-
|
|
195
|
-
}
|
|
187
|
+
return false
|
|
196
188
|
}
|
|
197
189
|
}
|
|
198
190
|
}
|
package/dist/cjs/Inspect.js
CHANGED
|
@@ -34,26 +34,23 @@ module.exports = __toCommonJS(Inspect_exports);
|
|
|
34
34
|
var smblsUI = __toESM(require("@symbo.ls/uikit"), 1);
|
|
35
35
|
var import_utils = require("@domql/utils");
|
|
36
36
|
var import_client = require("@symbo.ls/socket/client");
|
|
37
|
-
function returnStringExtend(
|
|
38
|
-
return (0, import_utils.isString)(
|
|
37
|
+
function returnStringExtend(_extends) {
|
|
38
|
+
return (0, import_utils.isString)(_extends) ? _extends : (0, import_utils.isArray)(_extends) ? _extends.find((extItem) => (0, import_utils.isString)(extItem)) : "";
|
|
39
39
|
}
|
|
40
40
|
function getComponentKey(el) {
|
|
41
|
-
if (!el)
|
|
42
|
-
return;
|
|
41
|
+
if (!el) return;
|
|
43
42
|
const __componentKey = el.__ref.__componentKey;
|
|
44
|
-
const
|
|
45
|
-
const parentChildExtendStr = el.parent && el.parent.
|
|
46
|
-
return (__componentKey ||
|
|
43
|
+
const extendsStr = el.extends && returnStringExtend(el.extends);
|
|
44
|
+
const parentChildExtendStr = el.parent && el.parent.childExtends && returnStringExtend(el.parent.childExtends);
|
|
45
|
+
return (__componentKey || extendsStr || parentChildExtendStr || "").split("_")[0].split(".")[0].split("+")[0];
|
|
47
46
|
}
|
|
48
47
|
function findComponent(el) {
|
|
49
|
-
if (!el || !el.__ref)
|
|
50
|
-
return;
|
|
48
|
+
if (!el || !el.__ref) return;
|
|
51
49
|
const { components, pages, editor } = el.context;
|
|
52
50
|
const componentKey = getComponentKey(el);
|
|
53
51
|
if (editor && editor.onInitInspect) {
|
|
54
52
|
const initInspectReturns = editor.onInitInspect(componentKey, el, el.state);
|
|
55
|
-
if (!initInspectReturns)
|
|
56
|
-
return findComponent(el.parent);
|
|
53
|
+
if (!initInspectReturns) return findComponent(el.parent);
|
|
57
54
|
}
|
|
58
55
|
if (componentKey && (components[componentKey] || pages[componentKey])) {
|
|
59
56
|
return el;
|
|
@@ -83,128 +80,112 @@ const onInspect = (app, state, ctx) => {
|
|
|
83
80
|
};
|
|
84
81
|
};
|
|
85
82
|
const Inspect = {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
if (focusState.area.x !== area.x)
|
|
107
|
-
updateValue(area);
|
|
108
|
-
} else if (focusState.area) {
|
|
109
|
-
focusState.update({ area: false });
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
window.requestAnimationFrame(() => {
|
|
113
|
-
update();
|
|
114
|
-
window.requestAnimationFrame(update);
|
|
115
|
-
});
|
|
116
|
-
},
|
|
117
|
-
onMousedown: (ev, elem, state) => {
|
|
118
|
-
if (!state.debugging)
|
|
119
|
-
return;
|
|
120
|
-
const el = ev.target.ref;
|
|
121
|
-
const component = findComponent(el);
|
|
122
|
-
if (!component)
|
|
123
|
-
return;
|
|
124
|
-
const componentKey = getComponentKey(component);
|
|
125
|
-
if (!componentKey)
|
|
126
|
-
return;
|
|
127
|
-
const editor = el.context.editor;
|
|
128
|
-
if (editor && editor.onInspect) {
|
|
129
|
-
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true });
|
|
83
|
+
".preventSelect": { userSelect: "none" },
|
|
84
|
+
"!preventSelect": { userSelect: "auto" },
|
|
85
|
+
onInspect,
|
|
86
|
+
onMousemove: (ev, e, state) => {
|
|
87
|
+
const el = ev.target.ref;
|
|
88
|
+
const component = findComponent(el);
|
|
89
|
+
const focusState = e.Inspector.state;
|
|
90
|
+
if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false });
|
|
91
|
+
const componentKey = getComponentKey(component);
|
|
92
|
+
const updateValue = (area) => {
|
|
93
|
+
focusState.update({ area, focusKey: componentKey });
|
|
94
|
+
};
|
|
95
|
+
const update = () => {
|
|
96
|
+
if (ev.altKey && ev.shiftKey) {
|
|
97
|
+
const { x, y, width, height } = component.node.getBoundingClientRect();
|
|
98
|
+
const area = { x, y, width, height };
|
|
99
|
+
if (!focusState.area) return updateValue(area);
|
|
100
|
+
if (focusState.area.x !== area.x) updateValue(area);
|
|
101
|
+
} else if (focusState.area) {
|
|
102
|
+
focusState.update({ area: false });
|
|
130
103
|
}
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
104
|
+
};
|
|
105
|
+
window.requestAnimationFrame(() => {
|
|
106
|
+
update();
|
|
107
|
+
window.requestAnimationFrame(update);
|
|
108
|
+
});
|
|
109
|
+
},
|
|
110
|
+
onMousedown: (ev, elem, state) => {
|
|
111
|
+
if (!state.debugging) return;
|
|
112
|
+
const el = ev.target.ref;
|
|
113
|
+
const component = findComponent(el);
|
|
114
|
+
if (!component) return;
|
|
115
|
+
const componentKey = getComponentKey(component);
|
|
116
|
+
if (!componentKey) return;
|
|
117
|
+
const editor = el.context.editor;
|
|
118
|
+
if (editor && editor.onInspect) {
|
|
119
|
+
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true });
|
|
138
120
|
}
|
|
121
|
+
const data = JSON.stringify({
|
|
122
|
+
componentKey: `${componentKey}`
|
|
123
|
+
});
|
|
124
|
+
import_client.send.call(el.context.socket, "route", data);
|
|
125
|
+
ev.preventDefault();
|
|
126
|
+
ev.stopPropagation();
|
|
127
|
+
return false;
|
|
139
128
|
},
|
|
140
129
|
Inspector: {
|
|
141
130
|
state: {},
|
|
142
|
-
|
|
131
|
+
transition: "all, defaultBezier, X",
|
|
132
|
+
position: "fixed",
|
|
133
|
+
hide: (el, s) => !(s.area && s.parent.debugging),
|
|
134
|
+
style: {
|
|
135
|
+
boxShadow: "0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A",
|
|
136
|
+
zIndex: "9999999",
|
|
137
|
+
borderRadius: "10px",
|
|
138
|
+
pointerEvents: "none"
|
|
139
|
+
},
|
|
140
|
+
Span: {
|
|
141
|
+
position: "absolute",
|
|
142
|
+
margin: "A2 0",
|
|
143
|
+
fontSize: "Z",
|
|
144
|
+
color: "text",
|
|
145
|
+
// color: 'blue',
|
|
146
|
+
zIndex: "99999999",
|
|
143
147
|
transition: "all, defaultBezier, X",
|
|
144
|
-
|
|
145
|
-
|
|
148
|
+
textDecoration: "underline",
|
|
149
|
+
fontWeight: "500",
|
|
150
|
+
top: "100%",
|
|
146
151
|
style: {
|
|
147
|
-
boxShadow: "0
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
}),
|
|
153
|
-
span: {
|
|
154
|
-
props: {
|
|
155
|
-
position: "absolute",
|
|
156
|
-
margin: "A2 0",
|
|
157
|
-
fontSize: "Z",
|
|
158
|
-
color: "text",
|
|
159
|
-
// color: 'blue',
|
|
160
|
-
zIndex: "99999999",
|
|
161
|
-
transition: "all, defaultBezier, X",
|
|
162
|
-
textDecoration: "underline",
|
|
163
|
-
fontWeight: "500",
|
|
164
|
-
top: "100%",
|
|
165
|
-
style: {
|
|
166
|
-
boxShadow: "0 25px 10px 35px black",
|
|
167
|
-
textShadow: "0 0 10px black"
|
|
168
|
-
},
|
|
169
|
-
text: "{{ focusKey }}"
|
|
170
|
-
}
|
|
152
|
+
boxShadow: "0 25px 10px 35px black",
|
|
153
|
+
textShadow: "0 0 10px black"
|
|
154
|
+
},
|
|
155
|
+
text: "{{ focusKey }}"
|
|
171
156
|
},
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
rest[key].__ref = {};
|
|
182
|
-
if (!rest[key].__ref.__componentKey) {
|
|
183
|
-
rest[key].__ref.__componentKey = key;
|
|
184
|
-
}
|
|
157
|
+
onInit: ({ context }) => {
|
|
158
|
+
const { components } = context;
|
|
159
|
+
if ((0, import_utils.isObject)(components)) {
|
|
160
|
+
const { Content, ...rest } = components;
|
|
161
|
+
for (const key in rest) {
|
|
162
|
+
if (smblsUI[key]) continue;
|
|
163
|
+
if (!rest[key].__ref) rest[key].__ref = {};
|
|
164
|
+
if (!rest[key].__ref.__componentKey) {
|
|
165
|
+
rest[key].__ref.__componentKey = key;
|
|
185
166
|
}
|
|
186
167
|
}
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
onBeforeUpdate: (ch, el, s) => {
|
|
171
|
+
const { area } = s;
|
|
172
|
+
const isDebugging = s.area && s.parent.debugging;
|
|
173
|
+
let style;
|
|
174
|
+
if (!isDebugging) {
|
|
175
|
+
style = "display: none !important";
|
|
176
|
+
} else if (area) {
|
|
177
|
+
const { x, y, width, height } = area;
|
|
178
|
+
style = `
|
|
197
179
|
display: block !important;
|
|
198
180
|
top: ${y - 6}px;
|
|
199
181
|
left: ${x - 6}px;
|
|
200
182
|
width: ${width + 12}px;
|
|
201
183
|
height: ${height + 12}px;
|
|
202
184
|
`;
|
|
203
|
-
}
|
|
204
|
-
el.node.style = style;
|
|
205
|
-
el.span.node.innerText = s.focusKey;
|
|
206
|
-
return false;
|
|
207
185
|
}
|
|
186
|
+
el.node.style = style;
|
|
187
|
+
el.Span.node.innerText = s.focusKey;
|
|
188
|
+
return false;
|
|
208
189
|
}
|
|
209
190
|
}
|
|
210
191
|
};
|
package/dist/cjs/index.js
CHANGED
|
@@ -16,15 +16,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var index_exports = {};
|
|
20
|
+
__export(index_exports, {
|
|
21
21
|
DefaultSyncApp: () => DefaultSyncApp,
|
|
22
22
|
Inspect: () => import_Inspect.Inspect,
|
|
23
23
|
Notifications: () => import_SyncNotifications.Notifications,
|
|
24
24
|
SyncComponent: () => SyncComponent,
|
|
25
25
|
connectToSocket: () => connectToSocket
|
|
26
26
|
});
|
|
27
|
-
module.exports = __toCommonJS(
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
28
|
var import_router = require("@domql/router");
|
|
29
29
|
var import_init = require("@symbo.ls/init");
|
|
30
30
|
var import_client = require("@symbo.ls/socket/client");
|
|
@@ -45,8 +45,7 @@ const onChange = (el, s, ctx) => {
|
|
|
45
45
|
return (event, data) => {
|
|
46
46
|
if (event === "change") {
|
|
47
47
|
const obj = JSON.parse(data);
|
|
48
|
-
if (!(obj == null ? void 0 : obj.DATA))
|
|
49
|
-
return;
|
|
48
|
+
if (!(obj == null ? void 0 : obj.DATA)) return;
|
|
50
49
|
const { state, designSystem, pages, components, snippets, functions } = obj.DATA;
|
|
51
50
|
const { utils } = ctx;
|
|
52
51
|
if (pages) {
|
|
@@ -63,17 +62,14 @@ const onChange = (el, s, ctx) => {
|
|
|
63
62
|
}
|
|
64
63
|
if (state) {
|
|
65
64
|
const route = state.route;
|
|
66
|
-
if (route)
|
|
67
|
-
|
|
68
|
-
else if (!(snippets && functions && components && pages))
|
|
69
|
-
s.update(state);
|
|
65
|
+
if (route) (utils.router || import_router.router)(route.replace("/state", "") || "/", el, {});
|
|
66
|
+
else if (!(snippets && functions && components && pages)) s.update(state);
|
|
70
67
|
}
|
|
71
68
|
if (snippets || functions || components || pages) {
|
|
72
69
|
const { pathname, search, hash } = ctx.window.location;
|
|
73
70
|
(utils.router || import_router.router)(pathname + search + hash, el, {});
|
|
74
71
|
}
|
|
75
|
-
if (designSystem)
|
|
76
|
-
(0, import_init.init)(designSystem);
|
|
72
|
+
if (designSystem) (0, import_init.init)(designSystem);
|
|
77
73
|
}
|
|
78
74
|
if (ctx.editor.verbose && event === "clients") {
|
|
79
75
|
(0, import_SyncNotifications.connectedToSymbols)(data, el, s);
|
|
@@ -96,5 +92,5 @@ const SyncComponent = {
|
|
|
96
92
|
}
|
|
97
93
|
};
|
|
98
94
|
const DefaultSyncApp = {
|
|
99
|
-
|
|
95
|
+
extends: [SyncComponent, import_Inspect.Inspect, import_SyncNotifications.Notifications]
|
|
100
96
|
};
|
package/dist/esm/Inspect.js
CHANGED
|
@@ -16,26 +16,23 @@ var __objRest = (source, exclude) => {
|
|
|
16
16
|
import * as smblsUI from "@symbo.ls/uikit";
|
|
17
17
|
import { isObject, isString, isArray } from "@domql/utils";
|
|
18
18
|
import { send } from "@symbo.ls/socket/client";
|
|
19
|
-
function returnStringExtend(
|
|
20
|
-
return isString(
|
|
19
|
+
function returnStringExtend(_extends) {
|
|
20
|
+
return isString(_extends) ? _extends : isArray(_extends) ? _extends.find((extItem) => isString(extItem)) : "";
|
|
21
21
|
}
|
|
22
22
|
function getComponentKey(el) {
|
|
23
|
-
if (!el)
|
|
24
|
-
return;
|
|
23
|
+
if (!el) return;
|
|
25
24
|
const __componentKey = el.__ref.__componentKey;
|
|
26
|
-
const
|
|
27
|
-
const parentChildExtendStr = el.parent && el.parent.
|
|
28
|
-
return (__componentKey ||
|
|
25
|
+
const extendsStr = el.extends && returnStringExtend(el.extends);
|
|
26
|
+
const parentChildExtendStr = el.parent && el.parent.childExtends && returnStringExtend(el.parent.childExtends);
|
|
27
|
+
return (__componentKey || extendsStr || parentChildExtendStr || "").split("_")[0].split(".")[0].split("+")[0];
|
|
29
28
|
}
|
|
30
29
|
function findComponent(el) {
|
|
31
|
-
if (!el || !el.__ref)
|
|
32
|
-
return;
|
|
30
|
+
if (!el || !el.__ref) return;
|
|
33
31
|
const { components, pages, editor } = el.context;
|
|
34
32
|
const componentKey = getComponentKey(el);
|
|
35
33
|
if (editor && editor.onInitInspect) {
|
|
36
34
|
const initInspectReturns = editor.onInitInspect(componentKey, el, el.state);
|
|
37
|
-
if (!initInspectReturns)
|
|
38
|
-
return findComponent(el.parent);
|
|
35
|
+
if (!initInspectReturns) return findComponent(el.parent);
|
|
39
36
|
}
|
|
40
37
|
if (componentKey && (components[componentKey] || pages[componentKey])) {
|
|
41
38
|
return el;
|
|
@@ -65,128 +62,112 @@ const onInspect = (app, state, ctx) => {
|
|
|
65
62
|
};
|
|
66
63
|
};
|
|
67
64
|
const Inspect = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (focusState.area.x !== area.x)
|
|
89
|
-
updateValue(area);
|
|
90
|
-
} else if (focusState.area) {
|
|
91
|
-
focusState.update({ area: false });
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
window.requestAnimationFrame(() => {
|
|
95
|
-
update();
|
|
96
|
-
window.requestAnimationFrame(update);
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
onMousedown: (ev, elem, state) => {
|
|
100
|
-
if (!state.debugging)
|
|
101
|
-
return;
|
|
102
|
-
const el = ev.target.ref;
|
|
103
|
-
const component = findComponent(el);
|
|
104
|
-
if (!component)
|
|
105
|
-
return;
|
|
106
|
-
const componentKey = getComponentKey(component);
|
|
107
|
-
if (!componentKey)
|
|
108
|
-
return;
|
|
109
|
-
const editor = el.context.editor;
|
|
110
|
-
if (editor && editor.onInspect) {
|
|
111
|
-
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true });
|
|
65
|
+
".preventSelect": { userSelect: "none" },
|
|
66
|
+
"!preventSelect": { userSelect: "auto" },
|
|
67
|
+
onInspect,
|
|
68
|
+
onMousemove: (ev, e, state) => {
|
|
69
|
+
const el = ev.target.ref;
|
|
70
|
+
const component = findComponent(el);
|
|
71
|
+
const focusState = e.Inspector.state;
|
|
72
|
+
if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false });
|
|
73
|
+
const componentKey = getComponentKey(component);
|
|
74
|
+
const updateValue = (area) => {
|
|
75
|
+
focusState.update({ area, focusKey: componentKey });
|
|
76
|
+
};
|
|
77
|
+
const update = () => {
|
|
78
|
+
if (ev.altKey && ev.shiftKey) {
|
|
79
|
+
const { x, y, width, height } = component.node.getBoundingClientRect();
|
|
80
|
+
const area = { x, y, width, height };
|
|
81
|
+
if (!focusState.area) return updateValue(area);
|
|
82
|
+
if (focusState.area.x !== area.x) updateValue(area);
|
|
83
|
+
} else if (focusState.area) {
|
|
84
|
+
focusState.update({ area: false });
|
|
112
85
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
86
|
+
};
|
|
87
|
+
window.requestAnimationFrame(() => {
|
|
88
|
+
update();
|
|
89
|
+
window.requestAnimationFrame(update);
|
|
90
|
+
});
|
|
91
|
+
},
|
|
92
|
+
onMousedown: (ev, elem, state) => {
|
|
93
|
+
if (!state.debugging) return;
|
|
94
|
+
const el = ev.target.ref;
|
|
95
|
+
const component = findComponent(el);
|
|
96
|
+
if (!component) return;
|
|
97
|
+
const componentKey = getComponentKey(component);
|
|
98
|
+
if (!componentKey) return;
|
|
99
|
+
const editor = el.context.editor;
|
|
100
|
+
if (editor && editor.onInspect) {
|
|
101
|
+
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true });
|
|
120
102
|
}
|
|
103
|
+
const data = JSON.stringify({
|
|
104
|
+
componentKey: `${componentKey}`
|
|
105
|
+
});
|
|
106
|
+
send.call(el.context.socket, "route", data);
|
|
107
|
+
ev.preventDefault();
|
|
108
|
+
ev.stopPropagation();
|
|
109
|
+
return false;
|
|
121
110
|
},
|
|
122
111
|
Inspector: {
|
|
123
112
|
state: {},
|
|
124
|
-
|
|
113
|
+
transition: "all, defaultBezier, X",
|
|
114
|
+
position: "fixed",
|
|
115
|
+
hide: (el, s) => !(s.area && s.parent.debugging),
|
|
116
|
+
style: {
|
|
117
|
+
boxShadow: "0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A",
|
|
118
|
+
zIndex: "9999999",
|
|
119
|
+
borderRadius: "10px",
|
|
120
|
+
pointerEvents: "none"
|
|
121
|
+
},
|
|
122
|
+
Span: {
|
|
123
|
+
position: "absolute",
|
|
124
|
+
margin: "A2 0",
|
|
125
|
+
fontSize: "Z",
|
|
126
|
+
color: "text",
|
|
127
|
+
// color: 'blue',
|
|
128
|
+
zIndex: "99999999",
|
|
125
129
|
transition: "all, defaultBezier, X",
|
|
126
|
-
|
|
127
|
-
|
|
130
|
+
textDecoration: "underline",
|
|
131
|
+
fontWeight: "500",
|
|
132
|
+
top: "100%",
|
|
128
133
|
style: {
|
|
129
|
-
boxShadow: "0
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
134
|
-
}),
|
|
135
|
-
span: {
|
|
136
|
-
props: {
|
|
137
|
-
position: "absolute",
|
|
138
|
-
margin: "A2 0",
|
|
139
|
-
fontSize: "Z",
|
|
140
|
-
color: "text",
|
|
141
|
-
// color: 'blue',
|
|
142
|
-
zIndex: "99999999",
|
|
143
|
-
transition: "all, defaultBezier, X",
|
|
144
|
-
textDecoration: "underline",
|
|
145
|
-
fontWeight: "500",
|
|
146
|
-
top: "100%",
|
|
147
|
-
style: {
|
|
148
|
-
boxShadow: "0 25px 10px 35px black",
|
|
149
|
-
textShadow: "0 0 10px black"
|
|
150
|
-
},
|
|
151
|
-
text: "{{ focusKey }}"
|
|
152
|
-
}
|
|
134
|
+
boxShadow: "0 25px 10px 35px black",
|
|
135
|
+
textShadow: "0 0 10px black"
|
|
136
|
+
},
|
|
137
|
+
text: "{{ focusKey }}"
|
|
153
138
|
},
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
rest[key].__ref = {};
|
|
164
|
-
if (!rest[key].__ref.__componentKey) {
|
|
165
|
-
rest[key].__ref.__componentKey = key;
|
|
166
|
-
}
|
|
139
|
+
onInit: ({ context }) => {
|
|
140
|
+
const { components } = context;
|
|
141
|
+
if (isObject(components)) {
|
|
142
|
+
const _a = components, { Content } = _a, rest = __objRest(_a, ["Content"]);
|
|
143
|
+
for (const key in rest) {
|
|
144
|
+
if (smblsUI[key]) continue;
|
|
145
|
+
if (!rest[key].__ref) rest[key].__ref = {};
|
|
146
|
+
if (!rest[key].__ref.__componentKey) {
|
|
147
|
+
rest[key].__ref.__componentKey = key;
|
|
167
148
|
}
|
|
168
149
|
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
150
|
+
}
|
|
151
|
+
},
|
|
152
|
+
onBeforeUpdate: (ch, el, s) => {
|
|
153
|
+
const { area } = s;
|
|
154
|
+
const isDebugging = s.area && s.parent.debugging;
|
|
155
|
+
let style;
|
|
156
|
+
if (!isDebugging) {
|
|
157
|
+
style = "display: none !important";
|
|
158
|
+
} else if (area) {
|
|
159
|
+
const { x, y, width, height } = area;
|
|
160
|
+
style = `
|
|
179
161
|
display: block !important;
|
|
180
162
|
top: ${y - 6}px;
|
|
181
163
|
left: ${x - 6}px;
|
|
182
164
|
width: ${width + 12}px;
|
|
183
165
|
height: ${height + 12}px;
|
|
184
166
|
`;
|
|
185
|
-
}
|
|
186
|
-
el.node.style = style;
|
|
187
|
-
el.span.node.innerText = s.focusKey;
|
|
188
|
-
return false;
|
|
189
167
|
}
|
|
168
|
+
el.node.style = style;
|
|
169
|
+
el.Span.node.innerText = s.focusKey;
|
|
170
|
+
return false;
|
|
190
171
|
}
|
|
191
172
|
}
|
|
192
173
|
};
|
package/dist/esm/index.js
CHANGED
|
@@ -18,8 +18,7 @@ const onChange = (el, s, ctx) => {
|
|
|
18
18
|
return (event, data) => {
|
|
19
19
|
if (event === "change") {
|
|
20
20
|
const obj = JSON.parse(data);
|
|
21
|
-
if (!(obj == null ? void 0 : obj.DATA))
|
|
22
|
-
return;
|
|
21
|
+
if (!(obj == null ? void 0 : obj.DATA)) return;
|
|
23
22
|
const { state, designSystem, pages, components, snippets, functions } = obj.DATA;
|
|
24
23
|
const { utils } = ctx;
|
|
25
24
|
if (pages) {
|
|
@@ -36,17 +35,14 @@ const onChange = (el, s, ctx) => {
|
|
|
36
35
|
}
|
|
37
36
|
if (state) {
|
|
38
37
|
const route = state.route;
|
|
39
|
-
if (route)
|
|
40
|
-
|
|
41
|
-
else if (!(snippets && functions && components && pages))
|
|
42
|
-
s.update(state);
|
|
38
|
+
if (route) (utils.router || router)(route.replace("/state", "") || "/", el, {});
|
|
39
|
+
else if (!(snippets && functions && components && pages)) s.update(state);
|
|
43
40
|
}
|
|
44
41
|
if (snippets || functions || components || pages) {
|
|
45
42
|
const { pathname, search, hash } = ctx.window.location;
|
|
46
43
|
(utils.router || router)(pathname + search + hash, el, {});
|
|
47
44
|
}
|
|
48
|
-
if (designSystem)
|
|
49
|
-
init(designSystem);
|
|
45
|
+
if (designSystem) init(designSystem);
|
|
50
46
|
}
|
|
51
47
|
if (ctx.editor.verbose && event === "clients") {
|
|
52
48
|
connectedToSymbols(data, el, s);
|
|
@@ -69,7 +65,7 @@ const SyncComponent = {
|
|
|
69
65
|
}
|
|
70
66
|
};
|
|
71
67
|
const DefaultSyncApp = {
|
|
72
|
-
|
|
68
|
+
extends: [SyncComponent, Inspect, Notifications]
|
|
73
69
|
};
|
|
74
70
|
export {
|
|
75
71
|
DefaultSyncApp,
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/sync",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.2",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "c4dacc88fa3a65574680d11e320307dd2a22e6e9",
|
|
7
7
|
"files": [
|
|
8
8
|
"*.js",
|
|
9
9
|
"dist"
|
|
@@ -30,12 +30,12 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@domql/globals": "latest",
|
|
33
|
-
"@domql/router": "^
|
|
34
|
-
"@domql/utils": "^
|
|
35
|
-
"@symbo.ls/init": "^
|
|
36
|
-
"@symbo.ls/scratch": "^
|
|
37
|
-
"@symbo.ls/socket": "^
|
|
38
|
-
"@symbo.ls/uikit": "^
|
|
33
|
+
"@domql/router": "^3.0.0",
|
|
34
|
+
"@domql/utils": "^3.0.0",
|
|
35
|
+
"@symbo.ls/init": "^3.0.2",
|
|
36
|
+
"@symbo.ls/scratch": "^3.0.2",
|
|
37
|
+
"@symbo.ls/socket": "^3.0.2",
|
|
38
|
+
"@symbo.ls/uikit": "^3.0.2"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@babel/core": "^7.12.0"
|