@symbo.ls/sync 3.8.9 → 3.14.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/SyncNotifications.js +8 -6
- package/applier.js +71 -0
- package/handlers.js +83 -0
- package/index.js +187 -185
- package/package.json +15 -32
- package/Inspect.js +0 -190
- package/client.js +0 -129
- package/dist/cjs/Inspect.js +0 -191
- package/dist/cjs/SyncNotifications.js +0 -98
- package/dist/cjs/client.js +0 -129
- package/dist/cjs/index.js +0 -229
- package/dist/cjs/server.js +0 -115
- package/dist/esm/Inspect.js +0 -161
- package/dist/esm/SyncNotifications.js +0 -78
- package/dist/esm/client.js +0 -100
- package/dist/esm/index.js +0 -210
- package/dist/esm/server.js +0 -85
- package/dist/iife/index.js +0 -494
- package/dynamic.json +0 -1
- package/server.js +0 -102
package/package.json
CHANGED
|
@@ -1,38 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/sync",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.14.1",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"module": "./index.js",
|
|
6
6
|
"gitHead": "9fc1b79b41cdc725ca6b24aec64920a599634681",
|
|
7
7
|
"files": [
|
|
8
8
|
"dist",
|
|
9
|
-
"*.js"
|
|
10
|
-
"dynamic.json"
|
|
9
|
+
"*.js"
|
|
11
10
|
],
|
|
12
11
|
"repository": "https://github.com/symbo-ls/scratch",
|
|
13
12
|
"type": "module",
|
|
13
|
+
"license": "CC-BY-NC-4.0",
|
|
14
14
|
"unpkg": "./dist/iife/index.js",
|
|
15
15
|
"jsdelivr": "./dist/iife/index.js",
|
|
16
16
|
"exports": {
|
|
17
|
-
".":
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"./client": {
|
|
22
|
-
"import": "./client.js",
|
|
23
|
-
"require": "./client.js"
|
|
24
|
-
},
|
|
25
|
-
"./server": {
|
|
26
|
-
"import": "./server.js"
|
|
27
|
-
},
|
|
28
|
-
"./*.js": {
|
|
29
|
-
"import": "./dist/esm/*.js",
|
|
30
|
-
"require": "./dist/cjs/*.js"
|
|
31
|
-
},
|
|
32
|
-
"./*": {
|
|
33
|
-
"import": "./dist/esm/*.js",
|
|
34
|
-
"require": "./dist/cjs/*.js"
|
|
35
|
-
}
|
|
17
|
+
".": "./index.js",
|
|
18
|
+
"./applier": "./applier.js",
|
|
19
|
+
"./handlers": "./handlers.js",
|
|
20
|
+
"./package.json": "./package.json"
|
|
36
21
|
},
|
|
37
22
|
"source": "index.js",
|
|
38
23
|
"publishConfig": {
|
|
@@ -40,25 +25,23 @@
|
|
|
40
25
|
},
|
|
41
26
|
"scripts": {
|
|
42
27
|
"copy:package:cjs": "cp ../../build/package-cjs.json dist/cjs/package.json",
|
|
43
|
-
"build:esm": "
|
|
44
|
-
"build:cjs": "
|
|
45
|
-
"build:iife": "
|
|
28
|
+
"build:esm": "NODE_ENV=$NODE_ENV esbuild *.js --target=es2020 --format=esm --outdir=dist/esm --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
29
|
+
"build:cjs": "NODE_ENV=$NODE_ENV esbuild *.js --target=node18 --format=cjs --outdir=dist/cjs --define:process.env.NODE_ENV=process.env.NODE_ENV",
|
|
30
|
+
"build:iife": "NODE_ENV=$NODE_ENV esbuild index.js --bundle --target=es2020 --format=iife --global-name=SmblsSync --outfile=dist/iife/index.js --define:process.env.NODE_ENV=process.env.NODE_ENV --external:smbls --external:@symbo.ls/* --external:socket.io-client --external:css-in-props",
|
|
46
31
|
"build": "node ../../build/build.js",
|
|
47
32
|
"prepublish": "npm run build && npm run copy:package:cjs"
|
|
48
33
|
},
|
|
49
34
|
"dependencies": {
|
|
50
|
-
"@
|
|
51
|
-
"@
|
|
52
|
-
"@symbo.ls/scratch": "^3.
|
|
53
|
-
"@symbo.ls/
|
|
35
|
+
"@symbo.ls/router": "^3.14.1",
|
|
36
|
+
"@symbo.ls/utils": "^3.14.2",
|
|
37
|
+
"@symbo.ls/scratch": "^3.14.2",
|
|
38
|
+
"@symbo.ls/default-config": "^3.14.2",
|
|
54
39
|
"chalk": "^5.4.1",
|
|
55
|
-
"express": "^4.21.2",
|
|
56
|
-
"socket.io": "^4.8.1",
|
|
57
40
|
"socket.io-client": "^4.8.1"
|
|
58
41
|
},
|
|
59
42
|
"devDependencies": {
|
|
60
43
|
"@babel/core": "^7.26.0"
|
|
61
44
|
},
|
|
62
|
-
"browser": "./
|
|
45
|
+
"browser": "./index.js",
|
|
63
46
|
"sideEffects": false
|
|
64
47
|
}
|
package/Inspect.js
DELETED
|
@@ -1,190 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import * as smblsUI from '@symbo.ls/uikit'
|
|
4
|
-
import { isObject, isString, isArray } from '@domql/utils'
|
|
5
|
-
import { send } from './client.js'
|
|
6
|
-
|
|
7
|
-
function returnStringExtend (_extends) {
|
|
8
|
-
return isString(_extends) ? _extends : isArray(_extends) ? _extends.find(extItem => isString(extItem)) : ''
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
function getComponentKey (el) {
|
|
12
|
-
if (!el) return
|
|
13
|
-
const __componentKey = el.__ref.__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
|
-
}
|
|
18
|
-
|
|
19
|
-
function findComponent (el) {
|
|
20
|
-
if (!el || !el.__ref) return
|
|
21
|
-
const { components, pages, editor } = el.context
|
|
22
|
-
const componentKey = getComponentKey(el)
|
|
23
|
-
if (editor && editor.onInitInspect) {
|
|
24
|
-
const initInspectReturns = editor.onInitInspect(componentKey, el, el.state)
|
|
25
|
-
if (!initInspectReturns) return findComponent(el.parent)
|
|
26
|
-
}
|
|
27
|
-
if (componentKey && (components[componentKey] || pages[componentKey])) {
|
|
28
|
-
return el
|
|
29
|
-
}
|
|
30
|
-
return findComponent(el.parent)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const onInspect = (app, state, ctx) => {
|
|
34
|
-
const windowOpts = ctx.window || window
|
|
35
|
-
windowOpts.onkeydown = (ev) => {
|
|
36
|
-
if (ev.altKey && ev.shiftKey) {
|
|
37
|
-
app.state.update({ debugging: true, preventSelect: true }, {
|
|
38
|
-
preventUpdate: true,
|
|
39
|
-
preventContentUpdate: true,
|
|
40
|
-
preventRecursive: true
|
|
41
|
-
})
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
windowOpts.onkeyup = (ev) => {
|
|
45
|
-
if (app.state.preventSelect && (!ev.altKey || !ev.shiftKey)) {
|
|
46
|
-
app.state.replace({ debugging: false, preventSelect: false }, {
|
|
47
|
-
preventUpdate: true,
|
|
48
|
-
preventContentUpdate: true,
|
|
49
|
-
preventRecursive: true
|
|
50
|
-
})
|
|
51
|
-
app.Inspector.state.update({ area: false })
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export const Inspect = {
|
|
57
|
-
'.preventSelect': { userSelect: 'none' },
|
|
58
|
-
'!preventSelect': { userSelect: 'auto' },
|
|
59
|
-
|
|
60
|
-
onInspect,
|
|
61
|
-
|
|
62
|
-
onMousemove: (ev, e, state) => {
|
|
63
|
-
const el = ev.target.ref
|
|
64
|
-
const component = findComponent(el)
|
|
65
|
-
const focusState = e.Inspector.state
|
|
66
|
-
|
|
67
|
-
if (!component || !state.debugging || !component.__ref) return focusState.update({ area: false })
|
|
68
|
-
|
|
69
|
-
const componentKey = getComponentKey(component)
|
|
70
|
-
const updateValue = (area) => {
|
|
71
|
-
focusState.update({ area, focusKey: componentKey })
|
|
72
|
-
}
|
|
73
|
-
|
|
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 }
|
|
78
|
-
|
|
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 })
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
window.requestAnimationFrame(() => {
|
|
87
|
-
update()
|
|
88
|
-
window.requestAnimationFrame(update)
|
|
89
|
-
})
|
|
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
|
-
|
|
100
|
-
const editor = el.context.editor
|
|
101
|
-
if (editor && editor.onInspect) {
|
|
102
|
-
return editor.onInspect(componentKey, el, el.state, { allowRouterWhileInspect: true })
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const data = JSON.stringify({
|
|
106
|
-
componentKey: `${componentKey}`
|
|
107
|
-
})
|
|
108
|
-
send.call(el.context.socket, 'route', data)
|
|
109
|
-
|
|
110
|
-
ev.preventDefault()
|
|
111
|
-
ev.stopPropagation()
|
|
112
|
-
return false
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
Inspector: {
|
|
116
|
-
state: {},
|
|
117
|
-
|
|
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',
|
|
135
|
-
transition: 'all, defaultBezier, X',
|
|
136
|
-
textDecoration: 'underline',
|
|
137
|
-
fontWeight: '500',
|
|
138
|
-
top: '100%',
|
|
139
|
-
style: {
|
|
140
|
-
boxShadow: '0 25px 10px 35px black',
|
|
141
|
-
textShadow: '0 0 10px black'
|
|
142
|
-
},
|
|
143
|
-
text: '{{ focusKey }}'
|
|
144
|
-
},
|
|
145
|
-
|
|
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
|
|
156
|
-
}
|
|
157
|
-
}
|
|
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 = `
|
|
176
|
-
display: block !important;
|
|
177
|
-
top: ${y - 6}px;
|
|
178
|
-
left: ${x - 6}px;
|
|
179
|
-
width: ${width + 12}px;
|
|
180
|
-
height: ${height + 12}px;
|
|
181
|
-
`
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
el.node.style = style
|
|
185
|
-
el.Span.node.innerText = s.focusKey
|
|
186
|
-
|
|
187
|
-
return false
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
package/client.js
DELETED
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
import { window, isFunction, isArray } from '@domql/utils'
|
|
2
|
-
import io from 'socket.io-client'
|
|
3
|
-
|
|
4
|
-
const defautlOpts = {}
|
|
5
|
-
|
|
6
|
-
let CONNECT_ATTEPT = 0
|
|
7
|
-
const CONNECT_ATTEPT_MAX_ALLOWED = 1
|
|
8
|
-
|
|
9
|
-
const getIsDev = options => {
|
|
10
|
-
return (
|
|
11
|
-
options.development ||
|
|
12
|
-
(window && window.location && window.location.host.includes('local')) ||
|
|
13
|
-
ENV === 'testing' ||
|
|
14
|
-
ENV === 'development'
|
|
15
|
-
)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const getSocketUrl = (options, isDev) => {
|
|
19
|
-
const SOCKET_BACKEND_URL = isDev
|
|
20
|
-
? 'http://localhost:8080/'
|
|
21
|
-
: 'https://api.symbols.app/'
|
|
22
|
-
|
|
23
|
-
const socketUrls = isArray(options.socketUrl)
|
|
24
|
-
? options.socketUrl
|
|
25
|
-
: [options.socketUrl || SOCKET_BACKEND_URL]
|
|
26
|
-
|
|
27
|
-
const primaryUrl = socketUrls[0]
|
|
28
|
-
const secondaryUrl = socketUrls[1] || 'api.symbols.app'
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
primaryUrl: primaryUrl || SOCKET_BACKEND_URL,
|
|
32
|
-
secondaryUrl
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const connect = (key, options = {}) => {
|
|
37
|
-
const isDev = getIsDev(options)
|
|
38
|
-
|
|
39
|
-
const { primaryUrl, secondaryUrl } = getSocketUrl(options, isDev)
|
|
40
|
-
const socket = io(primaryUrl || secondaryUrl, {
|
|
41
|
-
// withCredentials: true
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
socket.on('connect', () => {
|
|
45
|
-
if (isDev) {
|
|
46
|
-
console.warn(
|
|
47
|
-
`Connected to %c${primaryUrl} %c${key} %c${socket.id}`,
|
|
48
|
-
'font-weight: bold; color: green;',
|
|
49
|
-
'font-weight: bold;',
|
|
50
|
-
''
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
socket.emit('initConnect', { key, ...options })
|
|
55
|
-
|
|
56
|
-
try {
|
|
57
|
-
if (isFunction(options.onConnect)) {
|
|
58
|
-
options.onConnect(socket.id, socket)
|
|
59
|
-
}
|
|
60
|
-
} catch (e) {
|
|
61
|
-
console.error(e)
|
|
62
|
-
}
|
|
63
|
-
})
|
|
64
|
-
|
|
65
|
-
socket.on('connect_error', (err) => {
|
|
66
|
-
console.log(`event: connect_error | reason: ${err.message}`)
|
|
67
|
-
try {
|
|
68
|
-
if (isFunction(options.onError)) {
|
|
69
|
-
options.onError(err, socket)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (CONNECT_ATTEPT < CONNECT_ATTEPT_MAX_ALLOWED) {
|
|
73
|
-
CONNECT_ATTEPT++
|
|
74
|
-
|
|
75
|
-
socket.disconnect()
|
|
76
|
-
|
|
77
|
-
if (utils.isNotProduction()) {
|
|
78
|
-
console.log(
|
|
79
|
-
`Could not connect to %c${primaryUrl}%c, reconnecting to %c${
|
|
80
|
-
secondaryUrl
|
|
81
|
-
}`,
|
|
82
|
-
'font-weight: bold; color: red;',
|
|
83
|
-
'',
|
|
84
|
-
'font-weight: bold; color: green;'
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
connect(key, { ...options, socketUrl: secondaryUrl })
|
|
89
|
-
}
|
|
90
|
-
} catch (e) {
|
|
91
|
-
console.error(e)
|
|
92
|
-
}
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
socket.on('disconnect', (reason) => {
|
|
96
|
-
console.log(`event: disconnect | reason: ${reason}`)
|
|
97
|
-
try {
|
|
98
|
-
if (isFunction(options.onDisconnect)) {
|
|
99
|
-
options.onDisconnect(reason, socket)
|
|
100
|
-
}
|
|
101
|
-
} catch (e) {
|
|
102
|
-
console.error(e)
|
|
103
|
-
}
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
socket.onAny((event, ...args) => {
|
|
107
|
-
if (event === 'connect') {
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
try {
|
|
112
|
-
if (isFunction(options.onChange)) {
|
|
113
|
-
options.onChange(event, args[0], socket)
|
|
114
|
-
}
|
|
115
|
-
} catch (e) {
|
|
116
|
-
console.error(e)
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
|
|
120
|
-
return socket
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
export function send(event = 'change', changes, options) {
|
|
124
|
-
this.emit(event, changes, { ...options, ...defautlOpts })
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
export function disconnect() {
|
|
128
|
-
this.disconnect()
|
|
129
|
-
}
|
package/dist/cjs/Inspect.js
DELETED
|
@@ -1,191 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var Inspect_exports = {};
|
|
30
|
-
__export(Inspect_exports, {
|
|
31
|
-
Inspect: () => Inspect
|
|
32
|
-
});
|
|
33
|
-
module.exports = __toCommonJS(Inspect_exports);
|
|
34
|
-
var smblsUI = __toESM(require("@symbo.ls/uikit"), 1);
|
|
35
|
-
var import_utils = require("@domql/utils");
|
|
36
|
-
var import_client = require("./client.js");
|
|
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
|
-
}
|
|
40
|
-
function getComponentKey(el) {
|
|
41
|
-
if (!el) return;
|
|
42
|
-
const __componentKey = el.__ref.__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];
|
|
46
|
-
}
|
|
47
|
-
function findComponent(el) {
|
|
48
|
-
if (!el || !el.__ref) return;
|
|
49
|
-
const { components, pages, editor } = el.context;
|
|
50
|
-
const componentKey = getComponentKey(el);
|
|
51
|
-
if (editor && editor.onInitInspect) {
|
|
52
|
-
const initInspectReturns = editor.onInitInspect(componentKey, el, el.state);
|
|
53
|
-
if (!initInspectReturns) return findComponent(el.parent);
|
|
54
|
-
}
|
|
55
|
-
if (componentKey && (components[componentKey] || pages[componentKey])) {
|
|
56
|
-
return el;
|
|
57
|
-
}
|
|
58
|
-
return findComponent(el.parent);
|
|
59
|
-
}
|
|
60
|
-
const onInspect = (app, state, ctx) => {
|
|
61
|
-
const windowOpts = ctx.window || window;
|
|
62
|
-
windowOpts.onkeydown = (ev) => {
|
|
63
|
-
if (ev.altKey && ev.shiftKey) {
|
|
64
|
-
app.state.update({ debugging: true, preventSelect: true }, {
|
|
65
|
-
preventUpdate: true,
|
|
66
|
-
preventContentUpdate: true,
|
|
67
|
-
preventRecursive: true
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
};
|
|
71
|
-
windowOpts.onkeyup = (ev) => {
|
|
72
|
-
if (app.state.preventSelect && (!ev.altKey || !ev.shiftKey)) {
|
|
73
|
-
app.state.replace({ debugging: false, preventSelect: false }, {
|
|
74
|
-
preventUpdate: true,
|
|
75
|
-
preventContentUpdate: true,
|
|
76
|
-
preventRecursive: true
|
|
77
|
-
});
|
|
78
|
-
app.Inspector.state.update({ area: false });
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
const Inspect = {
|
|
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 });
|
|
103
|
-
}
|
|
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 });
|
|
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;
|
|
128
|
-
},
|
|
129
|
-
Inspector: {
|
|
130
|
-
state: {},
|
|
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",
|
|
147
|
-
transition: "all, defaultBezier, X",
|
|
148
|
-
textDecoration: "underline",
|
|
149
|
-
fontWeight: "500",
|
|
150
|
-
top: "100%",
|
|
151
|
-
style: {
|
|
152
|
-
boxShadow: "0 25px 10px 35px black",
|
|
153
|
-
textShadow: "0 0 10px black"
|
|
154
|
-
},
|
|
155
|
-
text: "{{ focusKey }}"
|
|
156
|
-
},
|
|
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;
|
|
166
|
-
}
|
|
167
|
-
}
|
|
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 = `
|
|
179
|
-
display: block !important;
|
|
180
|
-
top: ${y - 6}px;
|
|
181
|
-
left: ${x - 6}px;
|
|
182
|
-
width: ${width + 12}px;
|
|
183
|
-
height: ${height + 12}px;
|
|
184
|
-
`;
|
|
185
|
-
}
|
|
186
|
-
el.node.style = style;
|
|
187
|
-
el.Span.node.innerText = s.focusKey;
|
|
188
|
-
return false;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var SyncNotifications_exports = {};
|
|
20
|
-
__export(SyncNotifications_exports, {
|
|
21
|
-
Notifications: () => Notifications,
|
|
22
|
-
connectedToSymbols: () => connectedToSymbols
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(SyncNotifications_exports);
|
|
25
|
-
const NOTIF_COLORS = {
|
|
26
|
-
success: "green",
|
|
27
|
-
error: "red",
|
|
28
|
-
warning: "yellow"
|
|
29
|
-
};
|
|
30
|
-
const connectedToSymbols = (clients, element, state) => {
|
|
31
|
-
if (clients.symbols) {
|
|
32
|
-
if (!state.connected) {
|
|
33
|
-
state.notifications.connected = {
|
|
34
|
-
title: "Connected",
|
|
35
|
-
message: "to the Symbols live server"
|
|
36
|
-
};
|
|
37
|
-
state.update({ connected: true });
|
|
38
|
-
const t = setTimeout(() => {
|
|
39
|
-
delete state.notifications.connected;
|
|
40
|
-
element.notifications.content.connected.setProps({ animation: "fadeOutDown" });
|
|
41
|
-
state.update({ connected: true });
|
|
42
|
-
clearTimeout(t);
|
|
43
|
-
}, 3e3);
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
if (state.connected) {
|
|
47
|
-
state.notifications.connected = {
|
|
48
|
-
title: "Disconnected",
|
|
49
|
-
type: "error"
|
|
50
|
-
};
|
|
51
|
-
state.update({ connected: false });
|
|
52
|
-
const t = setTimeout(() => {
|
|
53
|
-
delete state.notifications.connected;
|
|
54
|
-
if (element.notifications.content.connected) {
|
|
55
|
-
element.notifications.content.connected.setProps({ animation: "fadeOutDown" });
|
|
56
|
-
}
|
|
57
|
-
state.update({ connected: true });
|
|
58
|
-
clearTimeout(t);
|
|
59
|
-
}, 3e3);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
};
|
|
63
|
-
const Notifications = {
|
|
64
|
-
state: {
|
|
65
|
-
notifications: []
|
|
66
|
-
},
|
|
67
|
-
Notifications: {
|
|
68
|
-
position: "fixed",
|
|
69
|
-
left: "A2",
|
|
70
|
-
bottom: "Z2",
|
|
71
|
-
zIndex: "999",
|
|
72
|
-
childExtends: "Notification",
|
|
73
|
-
childProps: ({ state }) => ({
|
|
74
|
-
animationDuration: "C",
|
|
75
|
-
background: NOTIF_COLORS[state.type || "success"],
|
|
76
|
-
icon: null,
|
|
77
|
-
Flex: {
|
|
78
|
-
Title: {
|
|
79
|
-
text: "{{ title }}"
|
|
80
|
-
},
|
|
81
|
-
P: {
|
|
82
|
-
text: "{{ title }}"
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
onRender: (e, el, s) => {
|
|
86
|
-
el.setProps({ animation: "fadeInUp" });
|
|
87
|
-
},
|
|
88
|
-
onClick: (e, el, s) => {
|
|
89
|
-
delete s.notifications[el.key];
|
|
90
|
-
el.setProps({ animation: "fadeOutDown" });
|
|
91
|
-
if (s.onClose) s.onClose(e, el, s);
|
|
92
|
-
}
|
|
93
|
-
}),
|
|
94
|
-
IconText: null,
|
|
95
|
-
childrenAs: "state",
|
|
96
|
-
children: ({ state }) => state.notifications
|
|
97
|
-
}
|
|
98
|
-
};
|