@jinntec/fore 3.3.2 → 4.0.0

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.
Files changed (73) hide show
  1. package/README.md +98 -70
  2. package/dist/fore-dev.js +5593 -6832
  3. package/dist/fore.js +5602 -4887
  4. package/index.js +5 -10
  5. package/package.json +7 -7
  6. package/resources/fore.css +33 -0
  7. package/src/DependencyNotifyingDomFacade.js +90 -21
  8. package/src/DependentXPathQueries.js +15 -2
  9. package/src/ForeElementMixin.js +110 -16
  10. package/src/UndoManager.js +267 -0
  11. package/src/actions/abstract-action.js +71 -30
  12. package/src/actions/fx-action.js +5 -0
  13. package/src/actions/fx-append.js +3 -3
  14. package/src/actions/fx-commit-history.js +26 -0
  15. package/src/actions/fx-hide.js +1 -1
  16. package/src/actions/fx-insert.js +25 -22
  17. package/src/actions/fx-load.js +5 -5
  18. package/src/actions/fx-redo.js +58 -0
  19. package/src/actions/fx-refresh.js +2 -2
  20. package/src/actions/fx-reload.js +1 -1
  21. package/src/actions/fx-replace.js +1 -1
  22. package/src/actions/fx-send.js +27 -5
  23. package/src/actions/fx-setattribute.js +11 -7
  24. package/src/actions/fx-undo.js +58 -0
  25. package/src/createNodes.js +314 -0
  26. package/src/fore.js +53 -18
  27. package/src/functions/fx-functionlib.js +10 -10
  28. package/src/fx-bind.js +30 -18
  29. package/src/fx-fore.js +222 -200
  30. package/src/fx-instance.js +18 -1
  31. package/src/fx-model.js +236 -69
  32. package/src/fx-submission.js +37 -29
  33. package/src/fx-var.js +49 -13
  34. package/src/getInScopeContext.js +1 -1
  35. package/src/json/JSONDomFacade.js +1 -1
  36. package/src/json/JSONLens.js +2 -2
  37. package/src/ui/UIElement.js +18 -8
  38. package/src/ui/abstract-control.js +45 -3
  39. package/src/ui/fx-alert.js +4 -0
  40. package/src/ui/fx-case.js +1 -1
  41. package/src/ui/fx-container.js +3 -0
  42. package/src/ui/fx-control-menu.js +79 -11
  43. package/src/ui/fx-control.js +130 -41
  44. package/src/ui/fx-dialog.js +5 -0
  45. package/src/ui/fx-items.js +6 -6
  46. package/src/ui/fx-output.js +37 -1
  47. package/src/ui/fx-repeat.js +1065 -103
  48. package/src/ui/fx-repeatitem.js +4 -1
  49. package/src/ui/fx-switch.js +116 -3
  50. package/src/ui/fx-trigger.js +9 -4
  51. package/src/ui/fx-upload.js +10 -4
  52. package/src/ui/repeat-base.js +20 -12
  53. package/src/withDraggability.js +10 -1
  54. package/src/xpath-evaluation.js +30 -18
  55. package/src/xpath-path.js +122 -0
  56. package/src/xpath-util.js +11 -126
  57. package/src/actions/StringTpl.js +0 -17
  58. package/src/extract-predicate-deps.js +0 -57
  59. package/src/extractPredicateDependencies.js +0 -36
  60. package/src/json/lensFromNode.js +0 -5
  61. package/src/json-util.js +0 -27
  62. package/src/tools/adi.js +0 -1111
  63. package/src/tools/deprecation.md +0 -1
  64. package/src/tools/fx-action-log.js +0 -745
  65. package/src/tools/fx-devtools.js +0 -444
  66. package/src/tools/fx-dom-inspector.js +0 -610
  67. package/src/tools/fx-json-instance.js +0 -444
  68. package/src/tools/fx-log-item.js +0 -128
  69. package/src/tools/fx-log-settings.js +0 -533
  70. package/src/tools/fx-minimap.js +0 -203
  71. package/src/tools/helpers.js +0 -132
  72. package/src/ui/TemplateExpression.js +0 -12
  73. package/src/ui/fx-dom-inspector.js +0 -1255
@@ -1,444 +0,0 @@
1
- import './fx-action-log.js';
2
- import './fx-dom-inspector.js';
3
- import './fx-json-instance.js';
4
- // import './fx-minimap.js';
5
-
6
- export class FxDevtools extends HTMLElement {
7
- static get properties() {
8
- return {
9
- fore: {
10
- type: Object,
11
- description: 'The fx-fore element the devtools are attached to',
12
- },
13
- instances: {
14
- type: Array,
15
- description: 'Instances of selected Fore element',
16
- },
17
- selector: {
18
- type: String,
19
- description: 'optional selector to attach to a certain fx-fore element with given id',
20
- },
21
- };
22
- }
23
-
24
- constructor() {
25
- super();
26
- this.attachShadow({ mode: 'open' });
27
- Object.keys(this.constructor.properties).forEach(propertyName => {
28
- const property = this.constructor.properties[propertyName];
29
- const attribute = property.attribute || propertyName;
30
- const value = this.getAttribute(attribute) || property.default;
31
- const typedValue = property.type(value);
32
- this[propertyName] = typedValue;
33
- });
34
-
35
- this.isResizing = false;
36
- this.lastY = 0;
37
- this.defaultHeight = '40vh';
38
-
39
- this.buttonByInstanceId = new Map();
40
-
41
- const attachToFore = fore => {
42
- this.fore = fore;
43
- this.instances = [...this.fore.getModel().instances];
44
- // console.log('instances',this.instances);
45
- const header = this.shadowRoot.querySelector('.instances header');
46
- header.textContent = 'Data ';
47
- this.instances.forEach(instance => {
48
- const btn = document.createElement('button');
49
- btn.setAttribute('type', 'button');
50
- btn.textContent = instance.id;
51
- header.appendChild(btn);
52
- this.buttonByInstanceId.set(instance.id, btn);
53
- btn.addEventListener('click', () => this.selectInstance(instance.id));
54
- });
55
- if (!this.instances.length) {
56
- return;
57
- }
58
- this.selectInstance(this.instances[0].id);
59
- };
60
-
61
- const fore = document.querySelector('fx-fore');
62
- if (fore) {
63
- // If there's no `fore` element, there cannot be an inspector
64
- if (fore.inited) {
65
- // The fore element is already initialized. We can attach immediately.
66
- // This can happen if the fore element does not use anything asynchronous and loads right away.
67
- attachToFore(fore);
68
- } else {
69
- fore.addEventListener('model-construct-done', () => attachToFore(fore));
70
- }
71
- }
72
-
73
- window.document.addEventListener('log-active-element', e => {
74
- const target = e ? e.detail?.target || e.target : window.event.srcElement;
75
-
76
- // Note that the event target or srcElement may be the document node.
77
- const closestFore = target.nodeType === Node.DOCUMENT_NODE ? null : target.closest('fx-fore');
78
- if (closestFore) {
79
- attachToFore(closestFore);
80
- }
81
-
82
- const instance = this.instances.find(instance => {
83
- if (instance.type !== 'xml') {
84
- // TODO: handle JSON instances!
85
- return false;
86
- }
87
- return instance.instanceData.contains(target);
88
- });
89
- // const instance = this._getInstanceForTarget(target);
90
-
91
- if (instance) {
92
- this.selectInstance(instance.id);
93
- }
94
- });
95
- }
96
-
97
- _getInstanceForTarget(node) {
98
- this.instances.forEach(instance => {
99
- if (instance.type === 'xml' && instance.instanceData.contains(node)) {
100
- return instance;
101
- }
102
- if (instance.type === 'json') {
103
- return instance;
104
- }
105
- });
106
- }
107
-
108
- selectInstance(instanceId) {
109
- const button = this.buttonByInstanceId.get(instanceId);
110
- if (!button) {
111
- return;
112
- }
113
- if (button.classList.contains('selected-btn')) {
114
- return;
115
- }
116
-
117
- const selectedBtn = this.shadowRoot.querySelector('.selected-btn');
118
- if (selectedBtn) {
119
- selectedBtn.classList.remove('selected-btn');
120
- }
121
-
122
- button.classList.add('selected-btn');
123
-
124
- const instancePanel = this.shadowRoot.querySelector('.instance-panel');
125
- instancePanel.innerHTML = '';
126
-
127
- this.instances = [...this.fore.querySelectorAll('fx-instance')];
128
- const instance = Array.from(this.instances).find(inst => inst.id === instanceId);
129
- // console.log('wanted instance', instance);
130
-
131
- const panelContent = this._renderInstancePanel(instance);
132
- // console.log('panelContent', panelContent);
133
- // instancePanel.innerHTML = panelContent;
134
- instancePanel.append(panelContent);
135
- }
136
-
137
- connectedCallback() {
138
- this.render();
139
- // document.body.style.height = document.body.scrollHeight + 320 + 'px';
140
- }
141
-
142
- _startResize(event) {
143
- this.isResizing = true;
144
- this.lastY = event.clientY;
145
- }
146
-
147
- _resizePanel(event) {
148
- if (!this.isResizing) return;
149
- const delta = event.clientY - this.lastY;
150
- this.style.height = `${this.offsetHeight - delta}px`;
151
- this.lastHeight = this.style.height;
152
- this.lastY = event.clientY;
153
- }
154
-
155
- _stopResize(event) {
156
- event.preventDefault();
157
- event.stopPropagation();
158
- this.isResizing = false;
159
- document.body.style.height = 'inherit'; // reset before calculating scrollheight
160
- document.body.style.width = 'inherit'; // reset before calculating scrollheight
161
- const newHeight = document.body.scrollHeight + this.offsetHeight;
162
- document.body.style.height = `${newHeight}px`;
163
- }
164
-
165
- render() {
166
- const style = `
167
- @import '../../resources/fore.css';
168
-
169
- :host {
170
- display:block;
171
- position:fixed;
172
- bottom:0;
173
- left:0;
174
- width:100vw;
175
- height:var(--fx-devtools-height);
176
- font-style:inherit;
177
- font-family: 'Verdana' , 'Sans';
178
- font-size:1em;
179
- max-width:100vw;
180
- height:3em;
181
- }
182
- :host(.open){
183
- height:40vh;
184
- }
185
-
186
- fx-action-log{
187
- height:100%;
188
- }
189
- fx-dom-inspector{
190
- max-height:100%;
191
- height:100%;
192
- position:relative;
193
- }
194
- body {
195
- }
196
- details{
197
- height:100%;
198
- background:#ebf6ff;
199
- }
200
- .dom{
201
- width:45%;
202
- border-left:1px solid #999;
203
- position:relative
204
- }
205
- .dom fx-minimap{
206
- position:absolute;
207
- right:0;
208
- top:0;
209
- width:5rem;
210
- height:6rem;
211
- }
212
- header{
213
- padding:0.5rem;
214
- border-bottom:2px solid #ddd;
215
- font-size:1rem;
216
- }
217
- header button{
218
- margin:0 0.5em;
219
- border:thin solid #999;
220
- padding:0 0.5em;
221
- cursor:pointer;
222
- }
223
- header button:hover{
224
- background:white;
225
- }
226
-
227
- header button.selected-btn{
228
- background:steelblue;
229
- color:white;
230
- }
231
- .instances{
232
- width:35%;
233
- border-left:1px solid #999;
234
- }
235
- .instance-panel{
236
- height:100%;
237
- overflow:auto;
238
- }
239
- .panels{
240
- display:grid;
241
- grid-template-columns:20% 50% 30%;
242
- height:100%;
243
- width:100%;
244
- max-height:100%;
245
- border-top:thin solid #ddd;
246
- }
247
- .panels > section {
248
- min-height:20rem;
249
- /*
250
- background:#efefef;
251
- */
252
- position:relative;
253
- display:inline-block;
254
- height:100%;
255
- width:auto;
256
- }
257
- #options{
258
- display:none;
259
- }
260
- #options.open{
261
- position:absolute;
262
- z-index:10;
263
- left:0;
264
- top:3em;
265
- height:100%;
266
- display:block;
267
- padding:0;
268
- background:rgba(255,255,255,0.95);
269
- width:100%;
270
- }
271
- .optionsBtn{
272
- font-size:2rem;
273
- }
274
- details[open] .optionsBtn{
275
- display:inline;
276
- }
277
- .resizer{
278
- width:100vw;
279
- height:6px;
280
- background:rgba(215,220,235,0.3);
281
- cursor: ns-resize;
282
- position:absolute;
283
- top:0;
284
-
285
- }
286
- summary{
287
- height:3rem;
288
- padding:0 1em;
289
- border-bottom:2px solid #ddd;
290
- display:flex;
291
- justify-content:space-between;
292
- align-items:center;
293
- color:rgba(0,0,0,0.7);
294
- background: rgba(235, 255, 255, 0.2);
295
- box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
296
- backdrop-filter: blur(5px);
297
- -webkit-backdrop-filter: blur(5px);
298
- border: 1px solid rgba(255, 255, 255, 0.3);
299
-
300
- color:white;
301
- font-weight:300;
302
- background: rgb(119,119,119);
303
- background: linear-gradient(90deg, rgba(0,85,159,0.75) 0%, rgba(56,154,252,0.5) 50%, rgba(255,255,255,0.1) 100%);
304
-
305
- }
306
- summary button{
307
- padding:0;
308
- border:0;
309
- background:transparent;
310
- }
311
- .wrapper{
312
- height:100%;
313
- }
314
- .vertDevider{
315
- background:#ddd;
316
- width:4px;
317
- height:100%;
318
- cursor: ew-resize;
319
- }
320
- `;
321
- // console.log('render instances',this.instances);
322
-
323
- const html = `
324
- <section class="wrapper">
325
- <slot></slot>
326
- <details class="fx-devtools" open>
327
- <div class="resizer"></div>
328
- <summary>Fore Glass
329
- <div>
330
- <svg preserveAspectRatio="xMidYMid meet" focusable="true" style="width: 24px;height: 24px; margin-bottom:-1px;" width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg">
331
- <g role="button" id="find-in-page"><path d="M20 19.59V8l-6-6H6c-1.1 0-1.99.9-1.99 2L4 20c0 1.1.89 2 1.99 2H18c.45 0 .85-.15 1.19-.4l-4.43-4.43c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L20 19.59zM9 13c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3z"></path></g>
332
- </svg>
333
- <button class="optionsBtn" id="optionsTrigger">&#9881;</button>
334
- </div>
335
- </summary>
336
- <section class="panels">
337
- <section class="log">
338
- <fx-action-log selector="${this.selector}"></fx-action-log>
339
- </section>
340
- <section class="dom">
341
- <fx-dom-inspector>
342
- <header slot="header">Document</header>
343
- </fx-dom-inspector>
344
- </section>
345
- <section class="instances">
346
- <header></header>
347
- <div class="instance-panel">
348
- </div>
349
- </section>
350
- <section id="options">
351
- <fx-log-settings></fx-log-settings>
352
- </section>
353
- </section>
354
- </details>
355
- </section>
356
- `;
357
-
358
- this.shadowRoot.innerHTML = `
359
- <style>
360
- ${style}
361
- </style>
362
- ${html}
363
- `;
364
-
365
- // resizing handler
366
- this.resizer = this.shadowRoot.querySelector('.resizer');
367
- this.resizer.addEventListener('mousedown', this._startResize.bind(this));
368
- document.addEventListener('mousemove', this._resizePanel.bind(this));
369
- document.addEventListener('mouseup', this._stopResize.bind(this));
370
-
371
- // setup handler for option button on the right of the panel
372
- const optionsTrigger = this.shadowRoot.querySelector('#optionsTrigger');
373
- optionsTrigger.addEventListener('click', () => {
374
- const tr = this.shadowRoot.querySelector('#options');
375
- tr.classList.toggle('open');
376
- tr.classList.contains('open')
377
- ? (optionsTrigger.style.background = 'lightsteelblue')
378
- : (optionsTrigger.style.background = 'transparent');
379
- });
380
-
381
- // opening/closing the devtools
382
- const caption = this.shadowRoot.querySelector('.fx-devtools');
383
- caption.addEventListener('click', ev => {
384
- if (ev.target.nodeName === 'DIV' && ev.target.classList.contains('resizer')) {
385
- return;
386
- }
387
- if (ev.target.parentNode.open) {
388
- this.removeAttribute('open');
389
- this.lastHeight = this.style.height;
390
- this.style.height = '3em';
391
- } else {
392
- this.setAttribute('open', '');
393
- this.style.height = this.lastHeight ? this.lastHeight : '40vh';
394
- }
395
- });
396
-
397
- this.classList.add('open');
398
-
399
- /*
400
- document.addEventListener('value-changed', e =>{
401
- console.log('value-changed hitting glass', e.target);
402
- })
403
- */
404
- }
405
-
406
- _handleOpen(ev) {
407
- // console.log('that works')
408
-
409
- document.body.style.height = '';
410
- }
411
-
412
- _renderInstancePanel(instance) {
413
- if (instance.type === 'xml') {
414
- const domInspector = document.createElement('fx-dom-inspector');
415
- domInspector.setInstance(instance);
416
- domInspector.setAttribute('instance', instance.id);
417
- return domInspector;
418
-
419
- /*
420
- return
421
- `<fx-dom-inspector instance="${instance.id}"> </fx-dom-inspector>`
422
- */
423
- }
424
- if (instance.type === 'json') {
425
- const jsonInspector = document.createElement('fx-json-instance');
426
- jsonInspector.setAttribute('instance', instance.id);
427
- const span = document.createElement('span');
428
- span.setAttribute('slot', 'header');
429
- jsonInspector.append(span);
430
- return jsonInspector;
431
- /*
432
- return `
433
- <fx-json-instance instance="${instance.id}">
434
- <span slot="header"></span>
435
- </fx-json-instance>
436
- `
437
- */
438
- }
439
- }
440
- }
441
-
442
- if (!customElements.get('fx-devtools')) {
443
- customElements.define('fx-devtools', FxDevtools);
444
- }