@widgetic/editor 4.0.2 → 4.0.3
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/dist/components/MockWidget.svelte +1 -1
- package/dist/components/WidgetPreview.svelte +34 -50
- package/dist/components/editors/EmbedEditor.svelte +1 -1
- package/dist/components/editors/PropsEditor.svelte +173 -148
- package/dist/components/ic/BrowserInputController.svelte +14 -14
- package/dist/components/ic/CheckboxInputController.svelte +1 -1
- package/dist/components/ic/ColorPickerInputController.svelte +37 -37
- package/dist/components/ic/DatePickerInputController.svelte +6 -6
- package/dist/components/ic/DropdownInputController.svelte +1 -1
- package/dist/components/ic/FontInputController.svelte +136 -63
- package/dist/components/ic/FontInputController.svelte.d.ts +3 -1
- package/dist/components/ic/NumberInputController.svelte +37 -37
- package/dist/components/ic/RadioGroupInputController.svelte +1 -1
- package/dist/components/ic/SliderRangeInputController.svelte +1 -1
- package/dist/components/ic/SwitchInputController.svelte +1 -1
- package/dist/components/ic/TextAreaInputController.svelte +23 -23
- package/dist/components/ic/TextAreaPreviewInputController.svelte +2 -2
- package/dist/components/ic/VectorInputController.svelte +34 -34
- package/dist/components/ic/shared/CategoryTabs.svelte +1 -0
- package/dist/components/ic/shared/RecentItemsSection.svelte +21 -6
- package/dist/components/ic/shared/RecentItemsSection.svelte.d.ts +1 -0
- package/dist/stores/userSession.d.ts +1 -1
- package/dist/stores/userSession.js +17 -2
- package/dist/utils/FontManager.d.ts +1 -1
- package/dist/utils/FontManager.js +75 -102
- package/dist/utils/VectorManager.d.ts +3 -1
- package/dist/utils/VectorManager.js +30 -70
- package/dist/utils/colorTransparency.js +3 -3
- package/dist/utils/fontUtils.js +1 -1
- package/dist/utils/passiveEvents.d.ts +5 -0
- package/dist/utils/passiveEvents.js +9 -18
- package/dist/utils/recentColors.js +15 -15
- package/dist/utils/vectorUtils.js +1 -1
- package/package.json +1 -1
|
@@ -285,12 +285,12 @@
|
|
|
285
285
|
const containerHeight = contentArea.clientHeight;
|
|
286
286
|
const isOverflowing = contentHeight > containerHeight;
|
|
287
287
|
|
|
288
|
-
console.log('Initial overflow check:', {
|
|
289
|
-
contentHeight,
|
|
290
|
-
containerHeight,
|
|
291
|
-
difference: contentHeight - containerHeight,
|
|
292
|
-
isOverflowing
|
|
293
|
-
});
|
|
288
|
+
// console.log('Initial overflow check:', {
|
|
289
|
+
// contentHeight,
|
|
290
|
+
// containerHeight,
|
|
291
|
+
// difference: contentHeight - containerHeight,
|
|
292
|
+
// isOverflowing
|
|
293
|
+
// });
|
|
294
294
|
|
|
295
295
|
if (isOverflowing) {
|
|
296
296
|
proseMirror.style.backgroundColor = 'rgba(255, 0, 0, 0.1)';
|
|
@@ -361,7 +361,7 @@
|
|
|
361
361
|
// Only update if there's a change to prevent unnecessary rerenders
|
|
362
362
|
if (JSON.stringify(newFormats) !== JSON.stringify($state.snapshot(activeFormats))) {
|
|
363
363
|
activeFormats = newFormats;
|
|
364
|
-
console.log('Active formats updated:', $state.snapshot(activeFormats));
|
|
364
|
+
// console.log('Active formats updated:', $state.snapshot(activeFormats));
|
|
365
365
|
}
|
|
366
366
|
}
|
|
367
367
|
|
|
@@ -416,7 +416,7 @@
|
|
|
416
416
|
|
|
417
417
|
// Use $state.snapshot() for logging
|
|
418
418
|
const currentValues = $state.snapshot(toggleValues);
|
|
419
|
-
console.log('Toggle change:', { newValues, currentValues });
|
|
419
|
+
// console.log('Toggle change:', { newValues, currentValues });
|
|
420
420
|
|
|
421
421
|
// Find which format was toggled by comparing the arrays
|
|
422
422
|
const added = newValues.filter(v => !currentValues.includes(v));
|
|
@@ -427,14 +427,14 @@
|
|
|
427
427
|
// Find the format type for the added value
|
|
428
428
|
const format = Object.entries(formatMapping).find(([_, m]) => m.value === added[0])?.[0] as FormatType;
|
|
429
429
|
if (format) {
|
|
430
|
-
console.log('Applying format:', format);
|
|
430
|
+
// console.log('Applying format:', format);
|
|
431
431
|
applyFormat(format, true);
|
|
432
432
|
}
|
|
433
433
|
} else if (removed.length > 0) {
|
|
434
434
|
// Find the format type for the removed value
|
|
435
435
|
const format = Object.entries(formatMapping).find(([_, m]) => m.value === removed[0])?.[0] as FormatType;
|
|
436
436
|
if (format) {
|
|
437
|
-
console.log('Removing format:', format);
|
|
437
|
+
// console.log('Removing format:', format);
|
|
438
438
|
applyFormat(format, false);
|
|
439
439
|
}
|
|
440
440
|
}
|
|
@@ -454,7 +454,7 @@
|
|
|
454
454
|
const { from, to } = editorInstance.state.selection;
|
|
455
455
|
const selectedText = editorInstance.state.doc.textBetween(from, to);
|
|
456
456
|
|
|
457
|
-
console.log('Changing style for text "%s" to:', (selectedText || 'No text selected'), value);
|
|
457
|
+
// console.log('Changing style for text "%s" to:', (selectedText || 'No text selected'), value);
|
|
458
458
|
|
|
459
459
|
// Store the current scroll position and selection
|
|
460
460
|
const editorDom = editorInstance.view.dom;
|
|
@@ -696,18 +696,18 @@
|
|
|
696
696
|
currentColor = color;
|
|
697
697
|
}
|
|
698
698
|
|
|
699
|
-
console.log('Selection updated:', {
|
|
700
|
-
text: editorInstance.state.doc.textBetween(from, to),
|
|
701
|
-
range: { from, to },
|
|
702
|
-
style: currentTextStyle,
|
|
703
|
-
format: [
|
|
704
|
-
...(editorInstance.isActive('bold') ? ['b'] : []),
|
|
705
|
-
...(editorInstance.isActive('italic') ? ['i'] : []),
|
|
706
|
-
...(editorInstance.isActive('underline') ? ['u'] : []),
|
|
707
|
-
...(editorInstance.isActive('link') ? ['link'] : [])
|
|
708
|
-
],
|
|
709
|
-
color: currentColor
|
|
710
|
-
});
|
|
699
|
+
// console.log('Selection updated:', {
|
|
700
|
+
// text: editorInstance.state.doc.textBetween(from, to),
|
|
701
|
+
// range: { from, to },
|
|
702
|
+
// style: currentTextStyle,
|
|
703
|
+
// format: [
|
|
704
|
+
// ...(editorInstance.isActive('bold') ? ['b'] : []),
|
|
705
|
+
// ...(editorInstance.isActive('italic') ? ['i'] : []),
|
|
706
|
+
// ...(editorInstance.isActive('underline') ? ['u'] : []),
|
|
707
|
+
// ...(editorInstance.isActive('link') ? ['link'] : [])
|
|
708
|
+
// ],
|
|
709
|
+
// color: currentColor
|
|
710
|
+
// });
|
|
711
711
|
} else {
|
|
712
712
|
selectedRange = null;
|
|
713
713
|
currentColor = textColor; // Reset to default color when deselecting
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
|
|
123
123
|
function handleClick() {
|
|
124
|
-
console.log('Opening text area in portal');
|
|
124
|
+
// console.log('Opening text area in portal');
|
|
125
125
|
isShowingTextArea = !isShowingTextArea;
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
}
|
|
146
146
|
|
|
147
147
|
$: if (value) {
|
|
148
|
-
console.log('[TextAreaPreview] compact preview html', value.slice(0, 180));
|
|
148
|
+
// console.log('[TextAreaPreview] compact preview html', value.slice(0, 180));
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
function handlePortalMouseEnter() {
|
|
@@ -329,7 +329,7 @@
|
|
|
329
329
|
const testImg = new Image();
|
|
330
330
|
testImg.onload = () => {
|
|
331
331
|
// Vector loads successfully
|
|
332
|
-
console.log(`✅ [VectorInput] Current vector loads successfully: ${value.name}`);
|
|
332
|
+
// console.log(`✅ [VectorInput] Current vector loads successfully: ${value.name}`);
|
|
333
333
|
};
|
|
334
334
|
testImg.onerror = () => {
|
|
335
335
|
// Mark as error if it fails to load
|
|
@@ -420,13 +420,13 @@
|
|
|
420
420
|
|
|
421
421
|
// Preload the vectors to detect missing files early
|
|
422
422
|
if (filteredVectors.length > 0) {
|
|
423
|
-
console.log(`🔍 [VectorInput] Preloading ${filteredVectors.length} vectors to detect missing files...`);
|
|
423
|
+
// console.log(`🔍 [VectorInput] Preloading ${filteredVectors.length} vectors to detect missing files...`);
|
|
424
424
|
preloadVectors(filteredVectors);
|
|
425
425
|
}
|
|
426
426
|
|
|
427
427
|
// Also preload recent vectors
|
|
428
428
|
if (recentVectors.length > 0) {
|
|
429
|
-
console.log(`🔍 [VectorInput] Preloading ${recentVectors.length} recent vectors...`);
|
|
429
|
+
// console.log(`🔍 [VectorInput] Preloading ${recentVectors.length} recent vectors...`);
|
|
430
430
|
preloadVectors(recentVectors);
|
|
431
431
|
}
|
|
432
432
|
|
|
@@ -897,12 +897,12 @@
|
|
|
897
897
|
}
|
|
898
898
|
}, 0);
|
|
899
899
|
|
|
900
|
-
console.log('📝 [VectorSearch] Loaded next batch:', {
|
|
901
|
-
batchSize: nextBatch.length,
|
|
902
|
-
totalDisplayed: filteredVectors.length,
|
|
903
|
-
remainingVectors: currentSearchResults.length - filteredVectors.length,
|
|
904
|
-
nextBatchSize: SEARCH_BATCH_SIZE
|
|
905
|
-
});
|
|
900
|
+
// console.log('📝 [VectorSearch] Loaded next batch:', {
|
|
901
|
+
// batchSize: nextBatch.length,
|
|
902
|
+
// totalDisplayed: filteredVectors.length,
|
|
903
|
+
// remainingVectors: currentSearchResults.length - filteredVectors.length,
|
|
904
|
+
// nextBatchSize: SEARCH_BATCH_SIZE
|
|
905
|
+
// });
|
|
906
906
|
}
|
|
907
907
|
} else {
|
|
908
908
|
// Normal vector list scrolling
|
|
@@ -971,17 +971,17 @@
|
|
|
971
971
|
}
|
|
972
972
|
showVectorModal = false;
|
|
973
973
|
|
|
974
|
-
console.log('🧹 [VectorInput] Cleanup complete:', {
|
|
975
|
-
controllerId,
|
|
976
|
-
lastFilter: currentFilter
|
|
977
|
-
});
|
|
974
|
+
// console.log('🧹 [VectorInput] Cleanup complete:', {
|
|
975
|
+
// controllerId,
|
|
976
|
+
// lastFilter: currentFilter
|
|
977
|
+
// });
|
|
978
978
|
});
|
|
979
979
|
|
|
980
980
|
/**
|
|
981
981
|
* Opens the file browser for vector selection
|
|
982
982
|
*/
|
|
983
983
|
async function openFileBrowser() {
|
|
984
|
-
console.log('🔍 [VectorInput] Opening file browser for vectors');
|
|
984
|
+
// console.log('🔍 [VectorInput] Opening file browser for vectors');
|
|
985
985
|
|
|
986
986
|
try {
|
|
987
987
|
// Get the current vector's ID if it exists in our custom vectors
|
|
@@ -990,10 +990,10 @@
|
|
|
990
990
|
.find(v => v.name === value.name && v.category === 'Mine')?.name
|
|
991
991
|
: undefined;
|
|
992
992
|
|
|
993
|
-
console.log('🔍 [VectorInput] Opening file browser:', {
|
|
994
|
-
fileTypes: ['svg'],
|
|
995
|
-
selectedId
|
|
996
|
-
});
|
|
993
|
+
// console.log('🔍 [VectorInput] Opening file browser:', {
|
|
994
|
+
// fileTypes: ['svg'],
|
|
995
|
+
// selectedId
|
|
996
|
+
// });
|
|
997
997
|
|
|
998
998
|
// TODO: Implement file browser functionality
|
|
999
999
|
// This will be similar to FontInputController but for SVG files
|
|
@@ -1167,21 +1167,21 @@
|
|
|
1167
1167
|
// Add to VectorInputController.svelte
|
|
1168
1168
|
function handleToggle() {
|
|
1169
1169
|
const beforeState = $openDropdowns?.has(controllerId);
|
|
1170
|
-
console.log('🟡 [VectorInput] Toggle start:', {
|
|
1171
|
-
controllerId,
|
|
1172
|
-
beforeState,
|
|
1173
|
-
openDropdowns: Array.from($openDropdowns || new Set())
|
|
1174
|
-
});
|
|
1170
|
+
// console.log('🟡 [VectorInput] Toggle start:', {
|
|
1171
|
+
// controllerId,
|
|
1172
|
+
// beforeState,
|
|
1173
|
+
// openDropdowns: Array.from($openDropdowns || new Set())
|
|
1174
|
+
// });
|
|
1175
1175
|
|
|
1176
1176
|
toggleDropdown(controllerId);
|
|
1177
1177
|
|
|
1178
1178
|
const afterState = $openDropdowns?.has(controllerId);
|
|
1179
|
-
console.log('🟢 [VectorInput] Toggle complete:', {
|
|
1180
|
-
controllerId,
|
|
1181
|
-
beforeState,
|
|
1182
|
-
afterState,
|
|
1183
|
-
openDropdowns: Array.from($openDropdowns || new Set())
|
|
1184
|
-
});
|
|
1179
|
+
// console.log('🟢 [VectorInput] Toggle complete:', {
|
|
1180
|
+
// controllerId,
|
|
1181
|
+
// beforeState,
|
|
1182
|
+
// afterState,
|
|
1183
|
+
// openDropdowns: Array.from($openDropdowns || new Set())
|
|
1184
|
+
// });
|
|
1185
1185
|
}
|
|
1186
1186
|
|
|
1187
1187
|
function closeDropdown() {
|
|
@@ -1216,7 +1216,7 @@
|
|
|
1216
1216
|
|
|
1217
1217
|
// If scrolling outside our containers, close dropdowns
|
|
1218
1218
|
if ($openDropdowns?.has(controllerId)) {
|
|
1219
|
-
console.log('🔴 [VectorInput] Closing dropdown due to external scroll');
|
|
1219
|
+
// console.log('🔴 [VectorInput] Closing dropdown due to external scroll');
|
|
1220
1220
|
toggleDropdown(controllerId);
|
|
1221
1221
|
}
|
|
1222
1222
|
}
|
|
@@ -1283,7 +1283,7 @@
|
|
|
1283
1283
|
// Create a Svelte action to handle image error events
|
|
1284
1284
|
function handleImageError(node: HTMLElement, vectorName: string) {
|
|
1285
1285
|
const errorHandler = (event: Event) => {
|
|
1286
|
-
console.log(`❌ [VectorInput] Image failed to load: ${vectorName}`);
|
|
1286
|
+
// console.log(`❌ [VectorInput] Image failed to load: ${vectorName}`);
|
|
1287
1287
|
svgLoadErrors.set(vectorName, true);
|
|
1288
1288
|
svgLoadErrors = new Map(svgLoadErrors);
|
|
1289
1289
|
|
|
@@ -1481,7 +1481,7 @@
|
|
|
1481
1481
|
if (hasSvgLoadError(value.name)) {
|
|
1482
1482
|
svgLoadErrors.delete(value.name);
|
|
1483
1483
|
svgLoadErrors = new Map(svgLoadErrors);
|
|
1484
|
-
console.log(`✅ [VectorInput] Vector now loads successfully: ${value.name}`);
|
|
1484
|
+
// console.log(`✅ [VectorInput] Vector now loads successfully: ${value.name}`);
|
|
1485
1485
|
}
|
|
1486
1486
|
};
|
|
1487
1487
|
testImg.onerror = () => {
|
|
@@ -1648,10 +1648,10 @@
|
|
|
1648
1648
|
// Ensure the observer is set up after the DOM updates
|
|
1649
1649
|
setTimeout(() => {
|
|
1650
1650
|
setupVectorObserver();
|
|
1651
|
-
console.log('🔄 [VectorSearch] Observer setup after search clear');
|
|
1651
|
+
// console.log('🔄 [VectorSearch] Observer setup after search clear');
|
|
1652
1652
|
}, 50);
|
|
1653
1653
|
|
|
1654
|
-
console.log('🔄 [VectorSearch] Search cleared');
|
|
1654
|
+
// console.log('🔄 [VectorSearch] Search cleared');
|
|
1655
1655
|
}}
|
|
1656
1656
|
/>
|
|
1657
1657
|
</div>
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
export let displayMode: 'list' | 'grid' = 'list';
|
|
27
27
|
export let hideTrashIcon: boolean = false;
|
|
28
28
|
export let itemType: 'font' | 'vector' = 'font';
|
|
29
|
+
export let selectionToken = '';
|
|
29
30
|
|
|
30
31
|
// Helper function to determine if the result has HTML content
|
|
31
32
|
function hasHtml(result: { html: string } | string): result is { html: string } {
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
|
|
40
41
|
{#if displayMode === 'list'}
|
|
41
42
|
<div class="grid grid-cols-1">
|
|
42
|
-
{#each recentItems as item (getItemKey(item))}
|
|
43
|
+
{#each recentItems as item (getItemKey(item) + '-' + selectionToken)}
|
|
43
44
|
{@const renderedItem = renderItem(item)}
|
|
44
45
|
{@const selected = isItemSelected(item)}
|
|
45
46
|
|
|
@@ -47,9 +48,10 @@
|
|
|
47
48
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
48
49
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
49
50
|
<div
|
|
50
|
-
class="w-full px-4 cursor-pointer overflow-hidden relative rounded-small"
|
|
51
|
+
class="font-list-row w-full px-4 cursor-pointer overflow-hidden relative rounded-small"
|
|
51
52
|
class:bg-sage-green={selected}
|
|
52
53
|
class:text-white={selected}
|
|
54
|
+
class:text-grey7={!selected}
|
|
53
55
|
class:hover:bg-light-green={!selected}
|
|
54
56
|
class:selected-item={selected}
|
|
55
57
|
onclick={() => onItemSelect(item)}
|
|
@@ -69,6 +71,7 @@
|
|
|
69
71
|
{#if isCustomItem(item) && !hideTrashIcon}
|
|
70
72
|
<button
|
|
71
73
|
type="button"
|
|
74
|
+
tabindex="-1"
|
|
72
75
|
class="p-1 rounded-full hover:bg-red-100 hover:text-red-500 transition-colors"
|
|
73
76
|
onclick={(e) => {
|
|
74
77
|
e.stopPropagation();
|
|
@@ -84,9 +87,10 @@
|
|
|
84
87
|
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
|
85
88
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
|
86
89
|
<div
|
|
87
|
-
class="w-full px-4 cursor-pointer overflow-hidden relative rounded-small"
|
|
90
|
+
class="font-list-row w-full px-4 cursor-pointer overflow-hidden relative rounded-small"
|
|
88
91
|
class:bg-sage-green={selected}
|
|
89
92
|
class:text-white={selected}
|
|
93
|
+
class:text-grey7={!selected}
|
|
90
94
|
class:hover:bg-light-green={!selected}
|
|
91
95
|
class:selected-item={selected}
|
|
92
96
|
onclick={() => onItemSelect(item)}
|
|
@@ -105,6 +109,7 @@
|
|
|
105
109
|
{#if isCustomItem(item) && !hideTrashIcon}
|
|
106
110
|
<button
|
|
107
111
|
type="button"
|
|
112
|
+
tabindex="-1"
|
|
108
113
|
class="p-1 rounded-full hover:bg-red-100 hover:text-red-500 transition-colors"
|
|
109
114
|
onclick={(e) => {
|
|
110
115
|
e.stopPropagation();
|
|
@@ -121,7 +126,7 @@
|
|
|
121
126
|
</div>
|
|
122
127
|
{:else}
|
|
123
128
|
<div class="grid grid-cols-3 gap-x-6 gap-y-4 pt-2 pb-0">
|
|
124
|
-
{#each recentItems as item (getItemKey(item))}
|
|
129
|
+
{#each recentItems as item (getItemKey(item) + '-' + selectionToken)}
|
|
125
130
|
{@const renderedItem = renderItem(item)}
|
|
126
131
|
{@const selected = isItemSelected(item)}
|
|
127
132
|
|
|
@@ -132,6 +137,7 @@
|
|
|
132
137
|
class="flex-shrink-0 flex items-center justify-center widgetic-radius rounded transition-colors cursor-pointer border-2 border-grey2"
|
|
133
138
|
class:bg-sage-green={selected}
|
|
134
139
|
class:text-white={selected}
|
|
140
|
+
class:text-grey7={!selected}
|
|
135
141
|
class:border-sage-green={selected}
|
|
136
142
|
class:hover:bg-light-green={!selected}
|
|
137
143
|
class:selected-item={selected}
|
|
@@ -152,6 +158,7 @@
|
|
|
152
158
|
<button
|
|
153
159
|
type="button"
|
|
154
160
|
class="absolute top-1 right-1 p-1 rounded-full hover:bg-red-100 hover:text-red-500 transition-colors bg-white"
|
|
161
|
+
tabindex="-1"
|
|
155
162
|
onclick={(e) => {
|
|
156
163
|
e.stopPropagation();
|
|
157
164
|
onItemDelete(item, e);
|
|
@@ -169,6 +176,7 @@
|
|
|
169
176
|
class="flex-shrink-0 flex items-center justify-center widgetic-radius rounded transition-colors cursor-pointer border-2 border-grey2"
|
|
170
177
|
class:bg-sage-green={selected}
|
|
171
178
|
class:text-white={selected}
|
|
179
|
+
class:text-grey7={!selected}
|
|
172
180
|
class:border-sage-green={selected}
|
|
173
181
|
class:hover:bg-light-green={!selected}
|
|
174
182
|
class:selected-item={selected}
|
|
@@ -188,6 +196,7 @@
|
|
|
188
196
|
<button
|
|
189
197
|
type="button"
|
|
190
198
|
class="absolute top-1 right-1 p-1 rounded-full hover:bg-red-100 hover:text-red-500 transition-colors bg-white"
|
|
199
|
+
tabindex="-1"
|
|
191
200
|
onclick={(e) => {
|
|
192
201
|
e.stopPropagation();
|
|
193
202
|
onItemDelete(item, e);
|
|
@@ -252,9 +261,15 @@
|
|
|
252
261
|
background-color: hsl(var(--light-green)) !important;
|
|
253
262
|
}
|
|
254
263
|
|
|
255
|
-
|
|
256
|
-
:global(.selected-item:hover) {
|
|
264
|
+
:global(.font-list-row.selected-item:hover),
|
|
265
|
+
:global([data-item].selected-item:hover) {
|
|
257
266
|
background-color: hsl(var(--sage-green)) !important;
|
|
267
|
+
color: white !important;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
:global(.font-list-row:not(.selected-item)),
|
|
271
|
+
:global([data-item]:not(.selected-item)) {
|
|
272
|
+
color: hsl(var(--grey7)) !important;
|
|
258
273
|
}
|
|
259
274
|
|
|
260
275
|
</style>
|
|
@@ -1,7 +1,22 @@
|
|
|
1
1
|
import { writable } from 'svelte/store';
|
|
2
|
+
const isBrowser = typeof window !== 'undefined';
|
|
3
|
+
let initialJwt = null;
|
|
4
|
+
let initialUser = null;
|
|
5
|
+
if (isBrowser) {
|
|
6
|
+
try {
|
|
7
|
+
initialJwt = localStorage.getItem('jwt');
|
|
8
|
+
const userStr = localStorage.getItem('user');
|
|
9
|
+
if (userStr) {
|
|
10
|
+
initialUser = JSON.parse(userStr);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
console.error('Failed to read initial session from localStorage:', error);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
2
17
|
export const userSession = writable({
|
|
3
|
-
user:
|
|
4
|
-
jwt:
|
|
18
|
+
user: initialUser,
|
|
19
|
+
jwt: initialJwt
|
|
5
20
|
});
|
|
6
21
|
export function setSession(user, jwt) {
|
|
7
22
|
userSession.set({ user, jwt });
|
|
@@ -25,7 +25,7 @@ export interface FontData {
|
|
|
25
25
|
/** Google Web Fonts API variant ids (e.g. "400", "700", "regular") */
|
|
26
26
|
variants?: string[];
|
|
27
27
|
}
|
|
28
|
-
/** Maps Google Fonts API variant ids to display weight labels. */
|
|
28
|
+
/** Maps Google Fonts API variant ids to display weight labels (includes italic faces). */
|
|
29
29
|
export declare function mapGoogleVariantIdsToWeightNames(variants: string[]): string[];
|
|
30
30
|
declare class FontManager {
|
|
31
31
|
private static readonly DEBUG_MODE;
|