@stonecrop/stonecrop 0.13.3 → 0.13.5
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/src/composables/lazy-link.d.ts.map +1 -1
- package/dist/src/composables/lazy-link.js +1 -2
- package/dist/src/composables/stonecrop.js +8 -8
- package/dist/src/doctype.d.ts.map +1 -1
- package/dist/src/doctype.js +2 -0
- package/dist/src/field-triggers.d.ts.map +1 -1
- package/dist/src/field-triggers.js +11 -9
- package/dist/src/plugins/index.d.ts.map +1 -1
- package/dist/src/plugins/index.js +0 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +7 -6
- package/dist/src/schema-validator.d.ts.map +1 -1
- package/dist/src/schema-validator.js +10 -0
- package/dist/src/stonecrop.d.ts.map +1 -1
- package/dist/src/stonecrop.js +9 -1
- package/dist/src/stores/hst.d.ts.map +1 -1
- package/dist/src/stores/hst.js +5 -14
- package/dist/src/stores/operation-log.d.ts.map +1 -1
- package/dist/src/stores/operation-log.js +21 -29
- package/dist/src/types/composable.d.ts +1 -1
- package/dist/src/types/composable.d.ts.map +1 -1
- package/dist/stonecrop.d.ts +1 -1
- package/dist/stonecrop.js +1328 -1334
- package/dist/stonecrop.js.map +1 -1
- package/package.json +12 -15
- package/src/composables/lazy-link.ts +1 -2
- package/src/composables/stonecrop.ts +10 -10
- package/src/doctype.ts +2 -0
- package/src/field-triggers.ts +11 -9
- package/src/plugins/index.ts +0 -1
- package/src/registry.ts +11 -8
- package/src/schema-validator.ts +10 -0
- package/src/stonecrop.ts +10 -3
- package/src/stores/hst.ts +13 -30
- package/src/stores/operation-log.ts +25 -31
- package/src/types/composable.ts +1 -1
|
@@ -87,6 +87,24 @@ function deserializeFromBroadcast(serialized: SerializedCrossTabMessage): CrossT
|
|
|
87
87
|
return message
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Revert an operation (apply beforeValue)
|
|
92
|
+
*/
|
|
93
|
+
function revertOperation(operation: HSTOperation, store: HSTNode) {
|
|
94
|
+
if ((operation.type === 'set' || operation.type === 'delete') && store && typeof store.set === 'function') {
|
|
95
|
+
store.set(operation.path, operation.beforeValue, 'undo')
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Apply an operation (apply afterValue)
|
|
101
|
+
*/
|
|
102
|
+
function applyOperation(operation: HSTOperation, store: HSTNode) {
|
|
103
|
+
if ((operation.type === 'set' || operation.type === 'delete') && store && typeof store.set === 'function') {
|
|
104
|
+
store.set(operation.path, operation.afterValue, 'redo')
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
90
108
|
/**
|
|
91
109
|
* Global HST Operation Log Store
|
|
92
110
|
* Tracks all mutations with full metadata for undo/redo, sync, and audit
|
|
@@ -312,7 +330,6 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
312
330
|
if (!operation.reversible) {
|
|
313
331
|
// Warn about irreversible operation
|
|
314
332
|
if (typeof console !== 'undefined' && operation.irreversibleReason) {
|
|
315
|
-
// eslint-disable-next-line no-console
|
|
316
333
|
console.warn('Cannot undo irreversible operation:', operation.irreversibleReason)
|
|
317
334
|
}
|
|
318
335
|
return false
|
|
@@ -345,7 +362,6 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
345
362
|
} catch (error) {
|
|
346
363
|
// Log error in development
|
|
347
364
|
if (typeof console !== 'undefined') {
|
|
348
|
-
// eslint-disable-next-line no-console
|
|
349
365
|
console.error('Undo failed:', error)
|
|
350
366
|
}
|
|
351
367
|
return false
|
|
@@ -386,37 +402,12 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
386
402
|
} catch (error) {
|
|
387
403
|
// Log error in development
|
|
388
404
|
if (typeof console !== 'undefined') {
|
|
389
|
-
// eslint-disable-next-line no-console
|
|
390
405
|
console.error('Redo failed:', error)
|
|
391
406
|
}
|
|
392
407
|
return false
|
|
393
408
|
}
|
|
394
409
|
}
|
|
395
410
|
|
|
396
|
-
/**
|
|
397
|
-
* Revert an operation (apply beforeValue)
|
|
398
|
-
*/
|
|
399
|
-
function revertOperation(operation: HSTOperation, store: HSTNode) {
|
|
400
|
-
// Both 'set' and 'delete' operations can be reverted by setting to beforeValue
|
|
401
|
-
if ((operation.type === 'set' || operation.type === 'delete') && store && typeof store.set === 'function') {
|
|
402
|
-
store.set(operation.path, operation.beforeValue, 'undo')
|
|
403
|
-
}
|
|
404
|
-
// Note: 'transition' operations are marked as non-reversible, so they won't reach here
|
|
405
|
-
// Note: 'batch' operations are handled separately in the undo function
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
/**
|
|
409
|
-
* Apply an operation (apply afterValue)
|
|
410
|
-
*/
|
|
411
|
-
function applyOperation(operation: HSTOperation, store: HSTNode) {
|
|
412
|
-
// Both 'set' and 'delete' operations can be applied by setting to afterValue
|
|
413
|
-
if ((operation.type === 'set' || operation.type === 'delete') && store && typeof store.set === 'function') {
|
|
414
|
-
store.set(operation.path, operation.afterValue, 'redo')
|
|
415
|
-
}
|
|
416
|
-
// Note: 'transition' operations are marked as non-reversible, so they won't reach here
|
|
417
|
-
// Note: 'batch' operations are handled separately in the redo function
|
|
418
|
-
}
|
|
419
|
-
|
|
420
411
|
/**
|
|
421
412
|
* Get operation log snapshot for debugging
|
|
422
413
|
*/
|
|
@@ -511,7 +502,6 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
511
502
|
|
|
512
503
|
if (!rawMessage || typeof rawMessage !== 'object') return
|
|
513
504
|
|
|
514
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
515
505
|
const message = deserializeFromBroadcast(rawMessage)
|
|
516
506
|
|
|
517
507
|
// Ignore messages from this tab
|
|
@@ -523,7 +513,9 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
523
513
|
currentIndex.value = operations.value.length - 1
|
|
524
514
|
} else if (message.type === 'operation' && message.operations) {
|
|
525
515
|
// Add batch operations from another tab
|
|
526
|
-
operations.value.push(
|
|
516
|
+
operations.value.push(
|
|
517
|
+
...message.operations.map((op): HSTOperation => Object.assign({}, op, { source: 'sync' as const }))
|
|
518
|
+
)
|
|
527
519
|
currentIndex.value = operations.value.length - 1
|
|
528
520
|
}
|
|
529
521
|
})
|
|
@@ -538,6 +530,7 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
538
530
|
clientId: clientId.value,
|
|
539
531
|
timestamp: new Date(),
|
|
540
532
|
}
|
|
533
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- BroadcastChannel.postMessage does not accept targetOrigin; rule only applies to window.postMessage
|
|
541
534
|
broadcastChannel.postMessage(serializeForBroadcast(message))
|
|
542
535
|
}
|
|
543
536
|
|
|
@@ -550,6 +543,7 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
550
543
|
clientId: clientId.value,
|
|
551
544
|
timestamp: new Date(),
|
|
552
545
|
}
|
|
546
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- BroadcastChannel.postMessage does not accept targetOrigin; rule only applies to window.postMessage
|
|
553
547
|
broadcastChannel.postMessage(serializeForBroadcast(message))
|
|
554
548
|
}
|
|
555
549
|
|
|
@@ -562,6 +556,7 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
562
556
|
clientId: clientId.value,
|
|
563
557
|
timestamp: new Date(),
|
|
564
558
|
}
|
|
559
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- BroadcastChannel.postMessage does not accept targetOrigin; rule only applies to window.postMessage
|
|
565
560
|
broadcastChannel.postMessage(serializeForBroadcast(message))
|
|
566
561
|
}
|
|
567
562
|
|
|
@@ -574,6 +569,7 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
574
569
|
clientId: clientId.value,
|
|
575
570
|
timestamp: new Date(),
|
|
576
571
|
}
|
|
572
|
+
// oxlint-disable-next-line unicorn/require-post-message-target-origin -- BroadcastChannel.postMessage does not accept targetOrigin; rule only applies to window.postMessage
|
|
577
573
|
broadcastChannel.postMessage(serializeForBroadcast(message))
|
|
578
574
|
}
|
|
579
575
|
|
|
@@ -615,7 +611,6 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
615
611
|
} catch (error) {
|
|
616
612
|
// Log error in development
|
|
617
613
|
if (typeof console !== 'undefined') {
|
|
618
|
-
// eslint-disable-next-line no-console
|
|
619
614
|
console.error('Failed to load operations from persistence:', error)
|
|
620
615
|
}
|
|
621
616
|
}
|
|
@@ -635,7 +630,6 @@ export const useOperationLogStore = defineStore('hst-operation-log', () => {
|
|
|
635
630
|
} catch (error) {
|
|
636
631
|
// Log error in development
|
|
637
632
|
if (typeof console !== 'undefined') {
|
|
638
|
-
// eslint-disable-next-line no-console
|
|
639
633
|
console.error('Failed to save operations to persistence:', error)
|
|
640
634
|
}
|
|
641
635
|
}
|
package/src/types/composable.ts
CHANGED