@dinoreic/fez 0.3.0 → 0.3.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/README.md +44 -0
- package/dist/fez.js +18 -15
- package/dist/fez.js.map +4 -4
- package/package.json +1 -1
- package/src/fez/defaults.js +36 -1
- package/src/fez/instance.js +43 -13
- package/src/fez/root.js +2 -13
- package/src/fez/utility.js +13 -0
- package/src/{log.js → fez/utils/dump.js} +99 -42
- package/dist/log.js +0 -5
- package/dist/log.js.map +0 -7
package/package.json
CHANGED
package/src/fez/defaults.js
CHANGED
|
@@ -53,6 +53,41 @@ const loadDefaults = () => {
|
|
|
53
53
|
}
|
|
54
54
|
}
|
|
55
55
|
})
|
|
56
|
+
|
|
57
|
+
// Memory store for memoization
|
|
58
|
+
const memoStore = new Map()
|
|
59
|
+
|
|
60
|
+
// memoize component content by key
|
|
61
|
+
// <fez-memoize key="unique-key">content to memoize</fez-memoize>
|
|
62
|
+
Fez('fez-memoize', class {
|
|
63
|
+
init(props) {
|
|
64
|
+
if (!props.key) {
|
|
65
|
+
Fez.error('fez-memoize: key prop is required')
|
|
66
|
+
return
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (memoStore.has(props.key)) {
|
|
70
|
+
// Restore from memory in init
|
|
71
|
+
const storedNode = memoStore.get(props.key)
|
|
72
|
+
Fez.log(`Memoize - key: "${props.key}" - restore`)
|
|
73
|
+
this.root.innerHTML = ''
|
|
74
|
+
this.root.appendChild(storedNode.cloneNode(true))
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
onMount(props) {
|
|
79
|
+
// Only store if not already in memory
|
|
80
|
+
if (!memoStore.has(props.key)) {
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
// Store current DOM content
|
|
83
|
+
const contentNode = document.createElement('div')
|
|
84
|
+
contentNode.innerHTML = this.root.innerHTML
|
|
85
|
+
Fez.log(`Memoize - key: "${props.key}" - set`)
|
|
86
|
+
memoStore.set(props.key, contentNode)
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
56
91
|
}
|
|
57
92
|
|
|
58
93
|
// Only load defaults if Fez is available
|
|
@@ -61,4 +96,4 @@ if (typeof Fez !== 'undefined' && Fez) {
|
|
|
61
96
|
}
|
|
62
97
|
|
|
63
98
|
// Export for use in tests
|
|
64
|
-
export { loadDefaults }
|
|
99
|
+
export { loadDefaults }
|
package/src/fez/instance.js
CHANGED
|
@@ -359,27 +359,20 @@ export default class FezBase {
|
|
|
359
359
|
newNode.innerHTML = this.parseHtml(renderedTpl)
|
|
360
360
|
}
|
|
361
361
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
const oldEl = this.root.querySelector(`[fez-keep="${key}"]`)
|
|
362
|
+
// Handle fez-keep attributes
|
|
363
|
+
this.fezKeepNode(newNode)
|
|
365
364
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
newEl.parentNode.replaceChild(oldEl, newEl)
|
|
369
|
-
} else if (key === 'default-slot') {
|
|
370
|
-
// First render - populate the slot with current root children
|
|
371
|
-
Array.from(this.root.childNodes).forEach(child => newEl.appendChild(child))
|
|
372
|
-
}
|
|
373
|
-
})
|
|
365
|
+
// Handle fez-memoize attributes
|
|
366
|
+
this.fezMemoization(newNode)
|
|
374
367
|
|
|
375
368
|
Fez.morphdom(this.root, newNode)
|
|
376
369
|
|
|
377
|
-
this.
|
|
370
|
+
this.fezRenderPostProcess()
|
|
378
371
|
|
|
379
372
|
this.afterRender()
|
|
380
373
|
}
|
|
381
374
|
|
|
382
|
-
|
|
375
|
+
fezRenderPostProcess() {
|
|
383
376
|
const fetchAttr = (name, func) => {
|
|
384
377
|
this.root.querySelectorAll(`*[${name}]`).forEach((n)=>{
|
|
385
378
|
let value = n.getAttribute(name)
|
|
@@ -440,6 +433,43 @@ export default class FezBase {
|
|
|
440
433
|
})
|
|
441
434
|
}
|
|
442
435
|
|
|
436
|
+
fezKeepNode(newNode) {
|
|
437
|
+
newNode.querySelectorAll('[fez-keep]').forEach(newEl => {
|
|
438
|
+
const key = newEl.getAttribute('fez-keep')
|
|
439
|
+
const oldEl = this.root.querySelector(`[fez-keep="${key}"]`)
|
|
440
|
+
|
|
441
|
+
if (oldEl) {
|
|
442
|
+
// Keep the old element in place of the new one
|
|
443
|
+
newEl.parentNode.replaceChild(oldEl, newEl)
|
|
444
|
+
} else if (key === 'default-slot') {
|
|
445
|
+
// First render - populate the slot with current root children
|
|
446
|
+
Array.from(this.root.childNodes).forEach(child => newEl.appendChild(child))
|
|
447
|
+
}
|
|
448
|
+
})
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
fezMemoization(newNode) {
|
|
452
|
+
// Find the single memoize element in new DOM (excluding fez components)
|
|
453
|
+
const newMemoEl = newNode.querySelector('[fez-memoize]:not(.fez)')
|
|
454
|
+
if (!newMemoEl) return
|
|
455
|
+
|
|
456
|
+
this.fezMemoStore ||= new Map()
|
|
457
|
+
|
|
458
|
+
const newMemoElKey = newMemoEl.getAttribute('fez-memoize')
|
|
459
|
+
const storedNode = this.fezMemoStore.get(newMemoElKey)
|
|
460
|
+
|
|
461
|
+
if (storedNode) {
|
|
462
|
+
Fez.log(`Memoize restore ${this.fezName}: ${newMemoElKey}`)
|
|
463
|
+
newMemoEl.parentNode.replaceChild(storedNode.cloneNode(true), newMemoEl)
|
|
464
|
+
} else {
|
|
465
|
+
const oldMemoEl = this.root.querySelector('[fez-memoize]:not(.fez)')
|
|
466
|
+
if (oldMemoEl) {
|
|
467
|
+
const oldMemoElKey = oldMemoEl.getAttribute('fez-memoize')
|
|
468
|
+
this.fezMemoStore.set(oldMemoElKey, oldMemoEl.cloneNode(true))
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
|
|
443
473
|
// refresh single node only
|
|
444
474
|
refresh(selector) {
|
|
445
475
|
alert('NEEDS FIX and remove htmlTemplate')
|
package/src/fez/root.js
CHANGED
|
@@ -4,6 +4,7 @@ import Gobber from './vendor/gobber.js'
|
|
|
4
4
|
// morph dom from one state to another
|
|
5
5
|
import { Idiomorph } from './vendor/idiomorph.js'
|
|
6
6
|
|
|
7
|
+
import objectDump from './utils/dump.js'
|
|
7
8
|
import connect from './connect.js'
|
|
8
9
|
import compile from './compile.js'
|
|
9
10
|
import state from './lib/global-state.js'
|
|
@@ -165,19 +166,6 @@ Fez.tag = (tag, opts = {}, html = '') => {
|
|
|
165
166
|
// return data
|
|
166
167
|
};
|
|
167
168
|
|
|
168
|
-
// Resolve a function from a string or function reference
|
|
169
|
-
Fez.getFunction = (pointer) => {
|
|
170
|
-
if (!pointer) {
|
|
171
|
-
return ()=>{}
|
|
172
|
-
}
|
|
173
|
-
else if (typeof pointer === 'function') {
|
|
174
|
-
return pointer;
|
|
175
|
-
}
|
|
176
|
-
else if (typeof pointer === 'string') {
|
|
177
|
-
return new Function(pointer);
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
|
|
181
169
|
Fez.error = (text, show) => {
|
|
182
170
|
text = `Fez: ${text}`
|
|
183
171
|
console.error(text)
|
|
@@ -376,5 +364,6 @@ addUtilities(Fez)
|
|
|
376
364
|
|
|
377
365
|
Fez.compile = compile
|
|
378
366
|
Fez.state = state
|
|
367
|
+
Fez.dump = objectDump
|
|
379
368
|
|
|
380
369
|
export default Fez
|
package/src/fez/utility.js
CHANGED
|
@@ -181,4 +181,17 @@ export default (Fez) => {
|
|
|
181
181
|
Fez.isTrue = (val) => {
|
|
182
182
|
return ['1', 'true', 'on'].includes(String(val).toLowerCase())
|
|
183
183
|
}
|
|
184
|
+
|
|
185
|
+
// Resolve a function from a string or function reference
|
|
186
|
+
Fez.getFunction = (pointer) => {
|
|
187
|
+
if (!pointer) {
|
|
188
|
+
return ()=>{}
|
|
189
|
+
}
|
|
190
|
+
else if (typeof pointer === 'function') {
|
|
191
|
+
return pointer;
|
|
192
|
+
}
|
|
193
|
+
else if (typeof pointer === 'string') {
|
|
194
|
+
return new Function(pointer);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
184
197
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// pretty print HTML
|
|
2
|
-
const
|
|
2
|
+
const log_pretty_print = (html) => {
|
|
3
3
|
const parts = html
|
|
4
4
|
.split(/(<\/?[^>]+>)/g)
|
|
5
5
|
.map(p => p.trim())
|
|
@@ -55,50 +55,58 @@ const LOG = (() => {
|
|
|
55
55
|
const logTypes = []; // Track the original type of each log
|
|
56
56
|
let currentIndex = 0;
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
} else if (typeof o === 'object' && o !== null) {
|
|
77
|
-
originalType = 'object';
|
|
58
|
+
// Add ESC key handler
|
|
59
|
+
document.addEventListener('keydown', (e) => {
|
|
60
|
+
if (e.key === 'Escape') {
|
|
61
|
+
e.preventDefault();
|
|
62
|
+
const dialog = document.getElementById('dump-dialog');
|
|
63
|
+
const button = document.getElementById('log-reopen-button');
|
|
64
|
+
|
|
65
|
+
if (dialog) {
|
|
66
|
+
// Close dialog
|
|
67
|
+
dialog.remove();
|
|
68
|
+
localStorage.setItem('_LOG_CLOSED', 'true');
|
|
69
|
+
createLogButton();
|
|
70
|
+
} else if (button) {
|
|
71
|
+
// Open dialog
|
|
72
|
+
button.remove();
|
|
73
|
+
localStorage.setItem('_LOG_CLOSED', 'false');
|
|
74
|
+
showLogDialog();
|
|
75
|
+
}
|
|
78
76
|
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
const createLogButton = () => {
|
|
80
|
+
let btn = document.getElementById('log-reopen-button');
|
|
81
|
+
if (!btn) {
|
|
82
|
+
btn = document.body.appendChild(document.createElement('button'));
|
|
83
|
+
btn.id = 'log-reopen-button';
|
|
84
|
+
btn.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style="vertical-align:middle;margin-right:4px"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path><polyline points="14 2 14 8 20 8"></polyline><line x1="16" y1="13" x2="8" y2="13"></line><line x1="16" y1="17" x2="8" y2="17"></line><polyline points="10 9 9 9 8 9"></polyline></svg>LOG';
|
|
85
|
+
btn.style.cssText =
|
|
86
|
+
'position:fixed; top: 10px; right: 10px;' +
|
|
87
|
+
'padding:10px 20px;background:#ff3333;color:#fff;border:none;' +
|
|
88
|
+
'cursor:pointer;font:14px/1.4 monospace;z-index:2147483647;' +
|
|
89
|
+
'border-radius:8px;display:flex;align-items:center;' +
|
|
90
|
+
'opacity:1;visibility:visible;box-shadow:0 4px 12px rgba(255,51,51,0.3)';
|
|
91
|
+
btn.onclick = () => {
|
|
92
|
+
btn.remove();
|
|
93
|
+
localStorage.setItem('_LOG_CLOSED', 'false');
|
|
94
|
+
showLogDialog();
|
|
95
|
+
};
|
|
87
96
|
}
|
|
97
|
+
};
|
|
88
98
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
logs.push(o + `\n\ntype: ${originalType}`);
|
|
92
|
-
logTypes.push(originalType);
|
|
93
|
-
|
|
99
|
+
const showLogDialog = () => {
|
|
94
100
|
let d = document.getElementById('dump-dialog');
|
|
95
101
|
if (!d) {
|
|
96
102
|
d = document.body.appendChild(document.createElement('div'));
|
|
97
103
|
d.id = 'dump-dialog';
|
|
104
|
+
const scrollTop = window.pageYOffset || document.documentElement.scrollTop;
|
|
98
105
|
d.style.cssText =
|
|
99
|
-
'position:
|
|
100
|
-
'background:#fff;border:1px solid#333;box-shadow:0 0 10px rgba(0,0,0,0.5);' +
|
|
101
|
-
'padding:20px;overflow:auto;z-index:
|
|
106
|
+
'position:absolute; top:' + (scrollTop + 20) + 'px; left: 20px; right:20px;' +
|
|
107
|
+
'background:#fff; border:1px solid #333; box-shadow:0 0 10px rgba(0,0,0,0.5);' +
|
|
108
|
+
'padding:20px; overflow:auto; z-index:2147483646; font:13px/1.4 monospace;' +
|
|
109
|
+
'white-space:pre; display:block; opacity:1; visibility:visible';
|
|
102
110
|
}
|
|
103
111
|
|
|
104
112
|
// Check if we have a saved index and it's still valid
|
|
@@ -119,7 +127,7 @@ const LOG = (() => {
|
|
|
119
127
|
bgColor = '#d8d5ef'; // super light indigo
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
|
-
return `<button style="padding:
|
|
130
|
+
return `<button style="font-size: 14px; font-weight: 400; padding:2px 6px; margin: 0 2px 2px 0;cursor:pointer;background:${i === currentIndex ? '#333' : bgColor};color:${i === currentIndex ? '#fff' : '#000'}" data-index="${i}">${i + 1}</button>`
|
|
123
131
|
}).join('');
|
|
124
132
|
|
|
125
133
|
d.innerHTML =
|
|
@@ -128,10 +136,14 @@ const LOG = (() => {
|
|
|
128
136
|
'<div style="display:flex;flex-wrap:wrap;gap:4px;flex:1;margin-right:10px">' + buttons + '</div>' +
|
|
129
137
|
'<button style="padding:4px 8px;cursor:pointer;flex-shrink:0">×</button>' +
|
|
130
138
|
'</div>' +
|
|
131
|
-
'<xmp style="flex:1;overflow:auto;margin:0;padding:0;color:#000;background:#fff;font-size:14px;line-height:22px">' + logs[currentIndex] + '</xmp>' +
|
|
139
|
+
'<xmp style="font-family:monospace;flex:1;overflow:auto;margin:0;padding:0;color:#000;background:#fff;font-size:14px;line-height:22px">' + logs[currentIndex] + '</xmp>' +
|
|
132
140
|
'</div>';
|
|
133
141
|
|
|
134
|
-
d.querySelector('button[style*="flex-shrink:0"]').onclick = () =>
|
|
142
|
+
d.querySelector('button[style*="flex-shrink:0"]').onclick = () => {
|
|
143
|
+
d.remove();
|
|
144
|
+
localStorage.setItem('_LOG_CLOSED', 'true');
|
|
145
|
+
createLogButton();
|
|
146
|
+
};
|
|
135
147
|
|
|
136
148
|
d.querySelectorAll('button[data-index]').forEach(btn => {
|
|
137
149
|
btn.onclick = () => {
|
|
@@ -144,11 +156,56 @@ const LOG = (() => {
|
|
|
144
156
|
|
|
145
157
|
renderContent();
|
|
146
158
|
};
|
|
159
|
+
|
|
160
|
+
return o => {
|
|
161
|
+
if (!document.body) {
|
|
162
|
+
window.requestAnimationFrame( () => LOG(o) )
|
|
163
|
+
return
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (o instanceof Node) {
|
|
167
|
+
o = log_pretty_print(o.outerHTML)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
// Store the original type
|
|
171
|
+
let originalType = typeof o;
|
|
172
|
+
|
|
173
|
+
if (o === undefined) { o = 'undefined' }
|
|
174
|
+
if (o === null) { o = 'null' }
|
|
175
|
+
|
|
176
|
+
if (Array.isArray(o)) {
|
|
177
|
+
originalType = 'array';
|
|
178
|
+
} else if (typeof o === 'object' && o !== null) {
|
|
179
|
+
originalType = 'object';
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
if (typeof o != 'string') {
|
|
183
|
+
o = JSON.stringify(o, (key, value) => {
|
|
184
|
+
if (typeof value === 'function') {
|
|
185
|
+
return String(value);
|
|
186
|
+
}
|
|
187
|
+
return value;
|
|
188
|
+
}, 2).replaceAll('<', '<')
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
o = o.trim()
|
|
192
|
+
|
|
193
|
+
logs.push(o + `\n\ntype: ${originalType}`);
|
|
194
|
+
logTypes.push(originalType);
|
|
195
|
+
|
|
196
|
+
// Check if log was previously closed
|
|
197
|
+
const isClosed = localStorage.getItem('_LOG_CLOSED') === 'true';
|
|
198
|
+
|
|
199
|
+
if (isClosed) {
|
|
200
|
+
createLogButton();
|
|
201
|
+
} else {
|
|
202
|
+
showLogDialog();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
147
205
|
})();
|
|
148
206
|
|
|
149
|
-
if (typeof window !== 'undefined') {
|
|
207
|
+
if (typeof window !== 'undefined' && !window.LOG) {
|
|
150
208
|
window.LOG = LOG
|
|
151
|
-
window.LOG_PP = LOG_PP
|
|
152
209
|
}
|
|
153
210
|
|
|
154
211
|
export default LOG
|
package/dist/log.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
(()=>{var u=o=>{let a=o.split(/(<\/?[^>]+>)/g).map(i=>i.trim()).filter(i=>i),n=0,t=[];for(let i=0;i<a.length;i++){let e=a[i],s=a[i+1],p=a[i+2];if(e.startsWith("<"))if(!e.startsWith("</")&&!e.endsWith("/>")&&s&&!s.startsWith("<")&&p&&p.startsWith("</")){let r=Math.max(0,n);t.push(" ".repeat(r)+e+s+p),i+=2}else if(e.startsWith("</")){n--;let r=Math.max(0,n);t.push(" ".repeat(r)+e)}else if(e.endsWith("/>")||e.includes(" />")){let r=Math.max(0,n);t.push(" ".repeat(r)+e)}else{let r=Math.max(0,n);t.push(" ".repeat(r)+e),n++}else if(e){let r=Math.max(0,n);t.push(" ".repeat(r)+e)}}return t.join(`
|
|
2
|
-
`)},c=(()=>{let o=[],a=[],n=0;return t=>{if(!document.body){window.requestAnimationFrame(()=>c(t));return}t instanceof Node&&(t=u(t.outerHTML));let i=typeof t;t===void 0&&(t="undefined"),t===null&&(t="null"),Array.isArray(t)?i="array":typeof t=="object"&&t!==null&&(i="object"),typeof t!="string"&&(t=JSON.stringify(t,(r,l)=>typeof l=="function"?String(l):l,2).replaceAll("<","<")),t=t.trim(),o.push(t+`
|
|
3
|
-
|
|
4
|
-
type: ${i}`),a.push(i);let e=document.getElementById("dump-dialog");e||(e=document.body.appendChild(document.createElement("div")),e.id="dump-dialog",e.style.cssText="position:fixed;top:30px;left:30px;right:50px;bottom:50px;background:#fff;border:1px solid#333;box-shadow:0 0 10px rgba(0,0,0,0.5);padding:20px;overflow:auto;z-index:9999;font:13px/1.4 monospace;white-space:pre");let s=parseInt(localStorage.getItem("_LOG_INDEX"));!isNaN(s)&&s>=0&&s<o.length?n=s:n=o.length-1;let p=()=>{let r=o.map((l,d)=>{let f="#f0f0f0";return d!==n&&(a[d]==="object"?f="#d6e3ef":a[d]==="array"&&(f="#d8d5ef")),`<button style="padding:4px 8px;margin:0;cursor:pointer;background:${d===n?"#333":f};color:${d===n?"#fff":"#000"}" data-index="${d}">${d+1}</button>`}).join("");e.innerHTML='<div style="display:flex;flex-direction:column;height:100%"><div style="display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:10px"><div style="display:flex;flex-wrap:wrap;gap:4px;flex:1;margin-right:10px">'+r+'</div><button style="padding:4px 8px;cursor:pointer;flex-shrink:0">×</button></div><xmp style="flex:1;overflow:auto;margin:0;padding:0;color:#000;background:#fff;font-size:14px;line-height:22px">'+o[n]+"</xmp></div>",e.querySelector('button[style*="flex-shrink:0"]').onclick=()=>e.remove(),e.querySelectorAll("button[data-index]").forEach(l=>{l.onclick=()=>{n=parseInt(l.dataset.index),localStorage.setItem("_LOG_INDEX",n),p()}})};p()}})();typeof window<"u"&&(window.LOG=c,window.LOG_PP=u);var x=c;})();
|
|
5
|
-
//# sourceMappingURL=log.js.map
|
package/dist/log.js.map
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/log.js"],
|
|
4
|
-
"sourcesContent": ["// pretty print HTML\nconst LOG_PP = (html) => {\n const parts = html\n .split(/(<\\/?[^>]+>)/g)\n .map(p => p.trim())\n .filter(p => p);\n\n let indent = 0;\n const lines = [];\n\n for (let i = 0; i < parts.length; i++) {\n const part = parts[i];\n const nextPart = parts[i + 1];\n const nextNextPart = parts[i + 2];\n\n // Check if it's a tag\n if (part.startsWith('<')) {\n // Check if this is an opening tag followed by text and then its closing tag\n if (!part.startsWith('</') && !part.endsWith('/>') && nextPart && !nextPart.startsWith('<') && nextNextPart && nextNextPart.startsWith('</')) {\n // Combine them on one line\n const actualIndent = Math.max(0, indent);\n lines.push(' '.repeat(actualIndent) + part + nextPart + nextNextPart);\n i += 2; // Skip the next two parts\n }\n // Closing tag\n else if (part.startsWith('</')) {\n indent--;\n const actualIndent = Math.max(0, indent);\n lines.push(' '.repeat(actualIndent) + part);\n }\n // Self-closing tag\n else if (part.endsWith('/>') || part.includes(' />')) {\n const actualIndent = Math.max(0, indent);\n lines.push(' '.repeat(actualIndent) + part);\n }\n // Opening tag\n else {\n const actualIndent = Math.max(0, indent);\n lines.push(' '.repeat(actualIndent) + part);\n indent++;\n }\n }\n // Text node\n else if (part) {\n const actualIndent = Math.max(0, indent);\n lines.push(' '.repeat(actualIndent) + part);\n }\n }\n\n return lines.join('\\n');\n}\n\nconst LOG = (() => {\n const logs = [];\n const logTypes = []; // Track the original type of each log\n let currentIndex = 0;\n\n return o => {\n if (!document.body) {\n window.requestAnimationFrame( () => LOG(o) )\n return\n }\n\n if (o instanceof Node) {\n o = LOG_PP(o.outerHTML)\n }\n\n // Store the original type\n let originalType = typeof o;\n\n if (o === undefined) { o = 'undefined' }\n if (o === null) { o = 'null' }\n\n if (Array.isArray(o)) {\n originalType = 'array';\n } else if (typeof o === 'object' && o !== null) {\n originalType = 'object';\n }\n\n if (typeof o != 'string') {\n o = JSON.stringify(o, (key, value) => {\n if (typeof value === 'function') {\n return String(value);\n }\n return value;\n }, 2).replaceAll('<', '<')\n }\n\n o = o.trim()\n\n logs.push(o + `\\n\\ntype: ${originalType}`);\n logTypes.push(originalType);\n\n let d = document.getElementById('dump-dialog');\n if (!d) {\n d = document.body.appendChild(document.createElement('div'));\n d.id = 'dump-dialog';\n d.style.cssText =\n 'position:fixed;top:30px;left:30px;right:50px;bottom:50px;' +\n 'background:#fff;border:1px solid#333;box-shadow:0 0 10px rgba(0,0,0,0.5);' +\n 'padding:20px;overflow:auto;z-index:9999;font:13px/1.4 monospace;white-space:pre';\n }\n\n // Check if we have a saved index and it's still valid\n const savedIndex = parseInt(localStorage.getItem('_LOG_INDEX'));\n if (!isNaN(savedIndex) && savedIndex >= 0 && savedIndex < logs.length) {\n currentIndex = savedIndex;\n } else {\n currentIndex = logs.length - 1;\n }\n\n const renderContent = () => {\n const buttons = logs.map((_, i) => {\n let bgColor = '#f0f0f0'; // default\n if (i !== currentIndex) {\n if (logTypes[i] === 'object') {\n bgColor = '#d6e3ef'; // super light blue\n } else if (logTypes[i] === 'array') {\n bgColor = '#d8d5ef'; // super light indigo\n }\n }\n return `<button style=\"padding:4px 8px;margin:0;cursor:pointer;background:${i === currentIndex ? '#333' : bgColor};color:${i === currentIndex ? '#fff' : '#000'}\" data-index=\"${i}\">${i + 1}</button>`\n }).join('');\n\n d.innerHTML =\n '<div style=\"display:flex;flex-direction:column;height:100%\">' +\n '<div style=\"display:flex;justify-content:space-between;align-items:flex-start;margin-bottom:10px\">' +\n '<div style=\"display:flex;flex-wrap:wrap;gap:4px;flex:1;margin-right:10px\">' + buttons + '</div>' +\n '<button style=\"padding:4px 8px;cursor:pointer;flex-shrink:0\">×</button>' +\n '</div>' +\n '<xmp style=\"flex:1;overflow:auto;margin:0;padding:0;color:#000;background:#fff;font-size:14px;line-height:22px\">' + logs[currentIndex] + '</xmp>' +\n '</div>';\n\n d.querySelector('button[style*=\"flex-shrink:0\"]').onclick = () => d.remove();\n\n d.querySelectorAll('button[data-index]').forEach(btn => {\n btn.onclick = () => {\n currentIndex = parseInt(btn.dataset.index);\n localStorage.setItem('_LOG_INDEX', currentIndex);\n renderContent();\n };\n });\n };\n\n renderContent();\n };\n})();\n\nif (typeof window !== 'undefined') {\n window.LOG = LOG\n window.LOG_PP = LOG_PP\n}\n\nexport default LOG\n"],
|
|
5
|
-
"mappings": "MACA,IAAMA,EAAUC,GAAS,CACvB,IAAMC,EAAQD,EACX,MAAM,eAAe,EACrB,IAAIE,GAAKA,EAAE,KAAK,CAAC,EACjB,OAA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MA,EAAE,OAAO,EAE3EA,EAAE,iBAAiB,oBAAoB,EAAE,QAAQO,GAAO,CACtDA,EAAI,QAAU,IAAM,CAClBZ,EAAe,SAASY,EAAI,QAAQ,KAAK,EACzC,aAAa,QAAQ,aAAcZ,CAAY,EAC/CO,EAAc,CAChB,CACF,CAAC,CACH,EAEAA,EAAc,CAChB,CACF,GAAG,EAEC,OAAO,OAAW,MACpB,OAAO,IAAMV,EACb,OAAO,OAASV,GAGlB,IAAO0B,EAAQhB",
|
|
6
|
-
"names": ["LOG_PP", "html", "parts", "p", "indent", "lines", "part", "nextPart", "nextNextPart", "actualIndent", "LOG", "logs", "logTypes", "currentIndex", "o", "originalType", "key", "value", "d", "savedIndex", "renderContent", "buttons", "_", "i", "bgColor", "btn", "log_default"]
|
|
7
|
-
}
|