@asteby/metacore-runtime-react 10.0.0 → 11.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.
- package/CHANGELOG.md +23 -0
- package/dist/slot.d.ts.map +1 -1
- package/dist/slot.js +2 -0
- package/package.json +3 -3
- package/src/__tests__/slot.test.ts +70 -0
- package/src/slot.tsx +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @asteby/metacore-runtime-react
|
|
2
2
|
|
|
3
|
+
## 11.0.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3a3ea4b: fix: unify slot priority ordering across SDK and runtime-react (was
|
|
8
|
+
inconsistent — DESC is now canonical, see `docs/slot-priority.md`).
|
|
9
|
+
|
|
10
|
+
`Registry.registerSlot` in `@asteby/metacore-sdk` sorted ascending
|
|
11
|
+
("lower renders first") while `slotRegistry` in
|
|
12
|
+
`@asteby/metacore-runtime-react` sorted descending ("higher renders
|
|
13
|
+
first"). The runtime-react behaviour matches `docs/dynamic-ui.md`,
|
|
14
|
+
`mergeNavigation` and every other priority sort in the codebase, so the
|
|
15
|
+
SDK has been flipped to match. Addons that register a single
|
|
16
|
+
contribution per slot — i.e. every in-tree consumer we audited — are
|
|
17
|
+
unaffected. Addons relying on the inverted SDK order will need to swap
|
|
18
|
+
their priority values.
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [dee623a]
|
|
21
|
+
- Updated dependencies [56d2013]
|
|
22
|
+
- Updated dependencies [1c4a108]
|
|
23
|
+
- Updated dependencies [3a3ea4b]
|
|
24
|
+
- @asteby/metacore-sdk@2.6.0
|
|
25
|
+
|
|
3
26
|
## 10.0.0
|
|
4
27
|
|
|
5
28
|
### Minor Changes
|
package/dist/slot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slot.d.ts","sourceRoot":"","sources":["../src/slot.tsx"],"names":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CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,IAAI;IAoB7G,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE;IAIhC,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,IAAI;IAKzC,OAAO,CAAC,IAAI;CACf;AAED,eAAO,MAAM,YAAY,kBAAyB,CAAA;AAElD,MAAM,WAAW,SAAS;IACtB,eAAe;IACf,IAAI,EAAE,MAAM,CAAA;IACZ,sDAAsD;IACtD,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IAC3B,iEAAiE;IACjE,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAC7B;AAED,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,QAAe,EAAE,EAAE,SAAS,2CAe/D"}
|
package/dist/slot.js
CHANGED
|
@@ -10,6 +10,8 @@ class SlotRegistryImpl {
|
|
|
10
10
|
const entry = { id: slotId, component, priority: opts?.priority ?? 0, source: opts?.source };
|
|
11
11
|
const list = this.slots.get(slotId) ?? [];
|
|
12
12
|
list.push(entry);
|
|
13
|
+
// Higher priority renders first — canonical across SDK and runtime-react.
|
|
14
|
+
// See docs/slot-priority.md.
|
|
13
15
|
list.sort((a, b) => b.priority - a.priority);
|
|
14
16
|
this.slots.set(slotId, list);
|
|
15
17
|
this.emit();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@asteby/metacore-runtime-react",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "React runtime for metacore hosts — renders addon contributions dynamically",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"lucide-react": ">=0.460",
|
|
33
33
|
"date-fns": ">=3",
|
|
34
34
|
"react-day-picker": ">=8",
|
|
35
|
-
"@asteby/metacore-sdk": "^2.
|
|
35
|
+
"@asteby/metacore-sdk": "^2.6.0",
|
|
36
36
|
"@asteby/metacore-ui": "^2.0.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependenciesMeta": {
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
"typescript": "^6.0.0",
|
|
61
61
|
"vitest": "^4.0.0",
|
|
62
62
|
"zustand": "^5.0.0",
|
|
63
|
-
"@asteby/metacore-sdk": "2.
|
|
63
|
+
"@asteby/metacore-sdk": "2.6.0",
|
|
64
64
|
"@asteby/metacore-ui": "2.0.0"
|
|
65
65
|
},
|
|
66
66
|
"scripts": {
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest'
|
|
2
|
+
import type { ComponentType } from 'react'
|
|
3
|
+
import { slotRegistry } from '../slot'
|
|
4
|
+
|
|
5
|
+
// Dummy components — slot registry stores+sorts, doesn't render.
|
|
6
|
+
const A: ComponentType = () => null
|
|
7
|
+
const B: ComponentType = () => null
|
|
8
|
+
const C: ComponentType = () => null
|
|
9
|
+
const D: ComponentType = () => null
|
|
10
|
+
|
|
11
|
+
describe('slotRegistry priority ordering', () => {
|
|
12
|
+
it('renders higher priority first (DESC) — canonical contract', () => {
|
|
13
|
+
const slot = `test.desc.${Math.random()}`
|
|
14
|
+
const off1 = slotRegistry.register(slot, A, { priority: 1 })
|
|
15
|
+
const off2 = slotRegistry.register(slot, B, { priority: 5 })
|
|
16
|
+
const off3 = slotRegistry.register(slot, C, { priority: 3 })
|
|
17
|
+
|
|
18
|
+
const items = slotRegistry.get(slot)
|
|
19
|
+
expect(items.map((i) => i.priority)).toEqual([5, 3, 1])
|
|
20
|
+
expect(items.map((i) => i.component)).toEqual([B, C, A])
|
|
21
|
+
|
|
22
|
+
off1()
|
|
23
|
+
off2()
|
|
24
|
+
off3()
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
it('treats missing priority as 0', () => {
|
|
28
|
+
const slot = `test.zero.${Math.random()}`
|
|
29
|
+
const off1 = slotRegistry.register(slot, A)
|
|
30
|
+
const off2 = slotRegistry.register(slot, B, { priority: 10 })
|
|
31
|
+
const off3 = slotRegistry.register(slot, C, { priority: -5 })
|
|
32
|
+
|
|
33
|
+
const items = slotRegistry.get(slot)
|
|
34
|
+
expect(items.map((i) => i.component)).toEqual([B, A, C])
|
|
35
|
+
|
|
36
|
+
off1()
|
|
37
|
+
off2()
|
|
38
|
+
off3()
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
it('preserves insertion order on ties', () => {
|
|
42
|
+
const slot = `test.ties.${Math.random()}`
|
|
43
|
+
const off1 = slotRegistry.register(slot, A, { priority: 1 })
|
|
44
|
+
const off2 = slotRegistry.register(slot, B, { priority: 1 })
|
|
45
|
+
const off3 = slotRegistry.register(slot, C, { priority: 2 })
|
|
46
|
+
const off4 = slotRegistry.register(slot, D, { priority: 1 })
|
|
47
|
+
|
|
48
|
+
const items = slotRegistry.get(slot)
|
|
49
|
+
expect(items.map((i) => i.component)).toEqual([C, A, B, D])
|
|
50
|
+
|
|
51
|
+
off1()
|
|
52
|
+
off2()
|
|
53
|
+
off3()
|
|
54
|
+
off4()
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('unregister removes the entry and notifies subscribers', () => {
|
|
58
|
+
const slot = `test.unreg.${Math.random()}`
|
|
59
|
+
let notifications = 0
|
|
60
|
+
const unsubscribe = slotRegistry.subscribe(() => { notifications++ })
|
|
61
|
+
const off = slotRegistry.register(slot, A, { priority: 1 })
|
|
62
|
+
expect(slotRegistry.get(slot)).toHaveLength(1)
|
|
63
|
+
expect(notifications).toBeGreaterThanOrEqual(1)
|
|
64
|
+
const before = notifications
|
|
65
|
+
off()
|
|
66
|
+
expect(slotRegistry.get(slot)).toHaveLength(0)
|
|
67
|
+
expect(notifications).toBeGreaterThan(before)
|
|
68
|
+
unsubscribe()
|
|
69
|
+
})
|
|
70
|
+
})
|
package/src/slot.tsx
CHANGED
|
@@ -22,6 +22,8 @@ class SlotRegistryImpl {
|
|
|
22
22
|
const entry: SlotEntry = { id: slotId, component, priority: opts?.priority ?? 0, source: opts?.source }
|
|
23
23
|
const list = this.slots.get(slotId) ?? []
|
|
24
24
|
list.push(entry)
|
|
25
|
+
// Higher priority renders first — canonical across SDK and runtime-react.
|
|
26
|
+
// See docs/slot-priority.md.
|
|
25
27
|
list.sort((a, b) => b.priority - a.priority)
|
|
26
28
|
this.slots.set(slotId, list)
|
|
27
29
|
this.emit()
|