@symbo.ls/sync 2.11.522 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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 (extend) {
8
- return isString(extend) ? extend : isArray(extend) ? extend.find(extItem => isString(extItem)) : ''
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 extendStr = el.extend && returnStringExtend(el.extend)
15
- const parentChildExtendStr = el.parent && el.parent.childExtend && returnStringExtend(el.parent.childExtend)
16
- return (__componentKey || extendStr || parentChildExtendStr || '').split('_')[0].split('.')[0].split('+')[0]
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
- props: {
58
- '.preventSelect': { userSelect: 'none' },
59
- '!preventSelect': { userSelect: 'auto' },
57
+ '.preventSelect': { userSelect: 'none' },
58
+ '!preventSelect': { userSelect: 'auto' },
60
59
 
61
- onInspect,
60
+ onInspect,
62
61
 
63
- onMousemove: (ev, e, state) => {
64
- const el = ev.target.ref
65
- const component = findComponent(el)
66
- const focusState = e.Inspector.state
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
- if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false })
67
+ if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false })
69
68
 
70
- const componentKey = getComponentKey(component)
71
- const updateValue = (area) => {
72
- focusState.update({ area, focusKey: componentKey })
73
- }
69
+ const componentKey = getComponentKey(component)
70
+ const updateValue = (area) => {
71
+ focusState.update({ area, focusKey: componentKey })
72
+ }
74
73
 
75
- const update = () => {
76
- if (ev.altKey && ev.shiftKey) {
77
- const { x, y, width, height } = component.node.getBoundingClientRect()
78
- const area = { x, y, width, height }
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
- if (!focusState.area) return updateValue(area)
81
- if (focusState.area.x !== area.x) updateValue(area)
82
- } else if (focusState.area) {
83
- focusState.update({ area: false })
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
- window.requestAnimationFrame(() => {
88
- update()
89
- window.requestAnimationFrame(update)
90
- })
91
- },
86
+ window.requestAnimationFrame(() => {
87
+ update()
88
+ window.requestAnimationFrame(update)
89
+ })
90
+ },
92
91
 
93
- onMousedown: (ev, elem, state) => {
94
- if (!state.debugging) return
95
- const el = ev.target.ref
96
- const component = findComponent(el)
97
- if (!component) return
98
- const componentKey = getComponentKey(component)
99
- if (!componentKey) return
100
-
101
- const editor = el.context.editor
102
- if (editor && editor.onInspect) {
103
- return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true })
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
- const data = JSON.stringify({
107
- componentKey: `${componentKey}`
108
- })
109
- send.call(el.context.socket, 'route', data)
105
+ const data = JSON.stringify({
106
+ componentKey: `${componentKey}`
107
+ })
108
+ send.call(el.context.socket, 'route', data)
110
109
 
111
- ev.preventDefault()
112
- ev.stopPropagation()
113
- return false
114
- }
110
+ ev.preventDefault()
111
+ ev.stopPropagation()
112
+ return false
115
113
  },
116
114
 
117
115
  Inspector: {
118
116
  state: {},
119
117
 
120
- props: (el, s) => ({
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
- position: 'fixed',
123
- hide: !(s.area && s.parent.debugging),
136
+ textDecoration: 'underline',
137
+ fontWeight: '500',
138
+ top: '100%',
124
139
  style: {
125
- boxShadow: '0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A',
126
- zIndex: '9999999',
127
- borderRadius: '10px',
128
- pointerEvents: 'none'
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
- on: {
153
- init: ({ context }) => {
154
- const { components } = context
155
-
156
- if (isObject(components)) {
157
- const { Content, ...rest } = components
158
- for (const key in rest) {
159
- if (smblsUI[key]) continue
160
- if (!rest[key].__ref) rest[key].__ref = {}
161
- if (!rest[key].__ref.__componentKey) {
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
- beforeUpdate: (ch, el, s) => {
168
- const { area } = s
169
- const isDebugging = s.area && s.parent.debugging
170
-
171
- let style
172
- if (!isDebugging) {
173
- style = 'display: none !important'
174
- } else if (area) {
175
- const { x, y, width, height } = area
176
- // el.node.style = Object.stringify({
177
- // top: y - 6 + 'px',
178
- // left: x - 6 + 'px',
179
- // width: width + 12 + 'px',
180
- // height: height + 12 + 'px'
181
- // })
182
- style = `
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
- el.node.style = style
192
- el.span.node.innerText = s.focusKey
184
+ el.node.style = style
185
+ el.Span.node.innerText = s.focusKey
193
186
 
194
- return false
195
- }
187
+ return false
196
188
  }
197
189
  }
198
190
  }
@@ -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(extend) {
38
- return (0, import_utils.isString)(extend) ? extend : (0, import_utils.isArray)(extend) ? extend.find((extItem) => (0, import_utils.isString)(extItem)) : "";
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 extendStr = el.extend && returnStringExtend(el.extend);
45
- const parentChildExtendStr = el.parent && el.parent.childExtend && returnStringExtend(el.parent.childExtend);
46
- return (__componentKey || extendStr || parentChildExtendStr || "").split("_")[0].split(".")[0].split("+")[0];
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
- props: {
87
- ".preventSelect": { userSelect: "none" },
88
- "!preventSelect": { userSelect: "auto" },
89
- onInspect,
90
- onMousemove: (ev, e, state) => {
91
- const el = ev.target.ref;
92
- const component = findComponent(el);
93
- const focusState = e.Inspector.state;
94
- if (!component || !state.debugging || !component.__ref)
95
- return focusState.update({ area: false });
96
- const componentKey = getComponentKey(component);
97
- const updateValue = (area) => {
98
- focusState.update({ area, focusKey: componentKey });
99
- };
100
- const update = () => {
101
- if (ev.altKey && ev.shiftKey) {
102
- const { x, y, width, height } = component.node.getBoundingClientRect();
103
- const area = { x, y, width, height };
104
- if (!focusState.area)
105
- return updateValue(area);
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
- const data = JSON.stringify({
132
- componentKey: `${componentKey}`
133
- });
134
- import_client.send.call(el.context.socket, "route", data);
135
- ev.preventDefault();
136
- ev.stopPropagation();
137
- return false;
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
- props: (el, s) => ({
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
- position: "fixed",
145
- hide: !(s.area && s.parent.debugging),
148
+ textDecoration: "underline",
149
+ fontWeight: "500",
150
+ top: "100%",
146
151
  style: {
147
- boxShadow: "0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A",
148
- zIndex: "9999999",
149
- borderRadius: "10px",
150
- pointerEvents: "none"
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
- on: {
173
- init: ({ context }) => {
174
- const { components } = context;
175
- if ((0, import_utils.isObject)(components)) {
176
- const { Content, ...rest } = components;
177
- for (const key in rest) {
178
- if (smblsUI[key])
179
- continue;
180
- if (!rest[key].__ref)
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
- beforeUpdate: (ch, el, s) => {
189
- const { area } = s;
190
- const isDebugging = s.area && s.parent.debugging;
191
- let style;
192
- if (!isDebugging) {
193
- style = "display: none !important";
194
- } else if (area) {
195
- const { x, y, width, height } = area;
196
- style = `
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
  };
@@ -88,8 +88,7 @@ const Notifications = {
88
88
  onClick: (e, el, s) => {
89
89
  delete s.notifications[el.key];
90
90
  el.setProps({ animation: "fadeOutDown" });
91
- if (s.onClose)
92
- s.onClose(e, el, s);
91
+ if (s.onClose) s.onClose(e, el, s);
93
92
  }
94
93
  }),
95
94
  IconText: null,
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 sync_exports = {};
20
- __export(sync_exports, {
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(sync_exports);
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
- (utils.router || import_router.router)(route.replace("/state", "") || "/", el, {});
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
- extend: [SyncComponent, import_Inspect.Inspect, import_SyncNotifications.Notifications]
95
+ extends: [SyncComponent, import_Inspect.Inspect, import_SyncNotifications.Notifications]
100
96
  };
@@ -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(extend) {
20
- return isString(extend) ? extend : isArray(extend) ? extend.find((extItem) => isString(extItem)) : "";
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 extendStr = el.extend && returnStringExtend(el.extend);
27
- const parentChildExtendStr = el.parent && el.parent.childExtend && returnStringExtend(el.parent.childExtend);
28
- return (__componentKey || extendStr || parentChildExtendStr || "").split("_")[0].split(".")[0].split("+")[0];
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
- props: {
69
- ".preventSelect": { userSelect: "none" },
70
- "!preventSelect": { userSelect: "auto" },
71
- onInspect,
72
- onMousemove: (ev, e, state) => {
73
- const el = ev.target.ref;
74
- const component = findComponent(el);
75
- const focusState = e.Inspector.state;
76
- if (!component || !state.debugging || !component.__ref)
77
- return focusState.update({ area: false });
78
- const componentKey = getComponentKey(component);
79
- const updateValue = (area) => {
80
- focusState.update({ area, focusKey: componentKey });
81
- };
82
- const update = () => {
83
- if (ev.altKey && ev.shiftKey) {
84
- const { x, y, width, height } = component.node.getBoundingClientRect();
85
- const area = { x, y, width, height };
86
- if (!focusState.area)
87
- return updateValue(area);
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
- const data = JSON.stringify({
114
- componentKey: `${componentKey}`
115
- });
116
- send.call(el.context.socket, "route", data);
117
- ev.preventDefault();
118
- ev.stopPropagation();
119
- return false;
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
- props: (el, s) => ({
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
- position: "fixed",
127
- hide: !(s.area && s.parent.debugging),
130
+ textDecoration: "underline",
131
+ fontWeight: "500",
132
+ top: "100%",
128
133
  style: {
129
- boxShadow: "0 0 10px #3686F733, 0 0 0 3px #3686F766, 0 0 100vmax 100vmax #000A",
130
- zIndex: "9999999",
131
- borderRadius: "10px",
132
- pointerEvents: "none"
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
- on: {
155
- init: ({ context }) => {
156
- const { components } = context;
157
- if (isObject(components)) {
158
- const _a = components, { Content } = _a, rest = __objRest(_a, ["Content"]);
159
- for (const key in rest) {
160
- if (smblsUI[key])
161
- continue;
162
- if (!rest[key].__ref)
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
- beforeUpdate: (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 = `
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
  };
@@ -64,8 +64,7 @@ const Notifications = {
64
64
  onClick: (e, el, s) => {
65
65
  delete s.notifications[el.key];
66
66
  el.setProps({ animation: "fadeOutDown" });
67
- if (s.onClose)
68
- s.onClose(e, el, s);
67
+ if (s.onClose) s.onClose(e, el, s);
69
68
  }
70
69
  }),
71
70
  IconText: null,
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
- (utils.router || router)(route.replace("/state", "") || "/", el, {});
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
- extend: [SyncComponent, Inspect, Notifications]
68
+ extends: [SyncComponent, Inspect, Notifications]
73
69
  };
74
70
  export {
75
71
  DefaultSyncApp,
package/index.js CHANGED
@@ -84,5 +84,5 @@ export const SyncComponent = {
84
84
  }
85
85
 
86
86
  export const DefaultSyncApp = {
87
- extend: [SyncComponent, Inspect, Notifications]
87
+ extends: [SyncComponent, Inspect, Notifications]
88
88
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/sync",
3
- "version": "2.11.522",
3
+ "version": "3.0.1",
4
4
  "main": "index.js",
5
5
  "module": "index.js",
6
- "gitHead": "f0cf0f8e16c7cac278886a322e85cb8d8188ca24",
6
+ "gitHead": "a4e7f586f7e4f60bd7b6a8388bdacc3ae1879433",
7
7
  "files": [
8
8
  "*.js",
9
9
  "dist"
@@ -32,10 +32,10 @@
32
32
  "@domql/globals": "latest",
33
33
  "@domql/router": "^2.5.0",
34
34
  "@domql/utils": "^2.5.0",
35
- "@symbo.ls/init": "^2.11.522",
36
- "@symbo.ls/scratch": "^2.11.522",
37
- "@symbo.ls/socket": "^2.11.522",
38
- "@symbo.ls/uikit": "^2.11.522"
35
+ "@symbo.ls/init": "^3.0.1",
36
+ "@symbo.ls/scratch": "^3.0.1",
37
+ "@symbo.ls/socket": "^3.0.1",
38
+ "@symbo.ls/uikit": "^3.0.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@babel/core": "^7.12.0"