@hamak/ui-shell 0.5.8 → 0.5.9
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/impl/index.d.ts +1 -0
- package/dist/impl/index.d.ts.map +1 -1
- package/dist/impl/index.js +2 -0
- package/dist/impl/plugin/ShellPluginFactory.d.ts.map +1 -1
- package/dist/impl/plugin/ShellPluginFactory.js +6 -0
- package/dist/impl/styles/StyleSink.d.ts +19 -0
- package/dist/impl/styles/StyleSink.d.ts.map +1 -0
- package/dist/impl/styles/StyleSink.js +49 -0
- package/dist/impl/styles/index.d.ts +6 -0
- package/dist/impl/styles/index.d.ts.map +1 -0
- package/dist/impl/styles/index.js +5 -0
- package/package.json +1 -1
package/dist/impl/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from '../spi/index.js';
|
|
|
10
10
|
export * from './core/index.js';
|
|
11
11
|
export * from './providers/index.js';
|
|
12
12
|
export * from './utils/index.js';
|
|
13
|
+
export * from './styles/index.js';
|
|
13
14
|
export * from './plugin/index.js';
|
|
14
15
|
import { DefaultShell } from './core/DefaultShell.js';
|
|
15
16
|
import { DefaultLayoutManager } from './core/DefaultLayoutManager.js';
|
package/dist/impl/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/impl/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAE9D;AAED,wBAAgB,mBAAmB,IAAI,oBAAoB,CAE1D;AAKD,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAK3D;AAED,wBAAgB,UAAU,IAAI,IAAI,CAKjC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/impl/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,QAAQ,CAAC;AACvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,QAAQ,CAAC;AAGvB,cAAc,aAAa,CAAC;AAG5B,cAAc,SAAS,CAAC;AAGxB,cAAc,UAAU,CAAC;AAGzB,cAAc,UAAU,CAAC;AAGzB,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAE1C,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAE9D;AAED,wBAAgB,mBAAmB,IAAI,oBAAoB,CAE1D;AAKD,wBAAgB,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CAK3D;AAED,wBAAgB,UAAU,IAAI,IAAI,CAKjC"}
|
package/dist/impl/index.js
CHANGED
|
@@ -14,6 +14,8 @@ export * from './core/index.js';
|
|
|
14
14
|
export * from './providers/index.js';
|
|
15
15
|
// Export utilities
|
|
16
16
|
export * from './utils/index.js';
|
|
17
|
+
// Export plugin-contributed stylesheet mounting
|
|
18
|
+
export * from './styles/index.js';
|
|
17
19
|
// Export plugin integration
|
|
18
20
|
export * from './plugin/index.js';
|
|
19
21
|
// Factory functions
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShellPluginFactory.d.ts","sourceRoot":"","sources":["../../../src/impl/plugin/ShellPluginFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ShellPluginFactory.d.ts","sourceRoot":"","sources":["../../../src/impl/plugin/ShellPluginFactory.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAS7C,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAIpD,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,CA8EpE;AAGD,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,YAAY,CAEtE"}
|
|
@@ -5,9 +5,11 @@
|
|
|
5
5
|
import { SHELL_TOKEN, THEME_MANAGER_TOKEN, FEATURE_MANAGER_TOKEN, LAYOUT_MANAGER_TOKEN, ShellCommands, ShellEvents, } from '../../api/index.js';
|
|
6
6
|
import { DefaultShell } from '../core/DefaultShell.js';
|
|
7
7
|
import { DefaultLayoutManager } from '../core/DefaultLayoutManager.js';
|
|
8
|
+
import { mountStyleRegistry } from '../styles/index.js';
|
|
8
9
|
export function createShellPlugin(config) {
|
|
9
10
|
let shell;
|
|
10
11
|
let layoutManager;
|
|
12
|
+
let unmountStyles;
|
|
11
13
|
return {
|
|
12
14
|
initialize(ctx) {
|
|
13
15
|
shell = new DefaultShell(config);
|
|
@@ -58,10 +60,14 @@ export function createShellPlugin(config) {
|
|
|
58
60
|
},
|
|
59
61
|
async activate(ctx) {
|
|
60
62
|
await shell.initialize();
|
|
63
|
+
// Mount plugin-contributed stylesheets into the document. Single well-known
|
|
64
|
+
// mount point for the whole host; SSR-safe (no-op without a document).
|
|
65
|
+
unmountStyles = mountStyleRegistry(ctx.styles);
|
|
61
66
|
const shellContext = shell.getContext();
|
|
62
67
|
ctx.hooks.emit('shell:activated', { context: shellContext });
|
|
63
68
|
},
|
|
64
69
|
deactivate() {
|
|
70
|
+
unmountStyles?.();
|
|
65
71
|
shell.destroy();
|
|
66
72
|
layoutManager.destroy();
|
|
67
73
|
},
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Sink
|
|
3
|
+
*
|
|
4
|
+
* Mounts plugin-contributed stylesheets (from the microkernel StyleRegistry)
|
|
5
|
+
* into the document as keyed <style> elements. The registry is pure data; this
|
|
6
|
+
* is the DOM side, kept here so microkernel-impl stays DOM-free and node-safe.
|
|
7
|
+
*/
|
|
8
|
+
import type { StyleRegistry } from '@hamak/microkernel-api';
|
|
9
|
+
/**
|
|
10
|
+
* Subscribe a StyleRegistry to a document, keeping a `<style data-plugin-style="<id>">`
|
|
11
|
+
* element in `<head>` in sync with every contribution. Updates mutate the element in
|
|
12
|
+
* place; removed contributions unmount their element.
|
|
13
|
+
*
|
|
14
|
+
* SSR / node-safe: a no-op (returns an empty disposer) when there is no document.
|
|
15
|
+
*
|
|
16
|
+
* @returns an unmount function that removes all mounted styles and stops reacting.
|
|
17
|
+
*/
|
|
18
|
+
export declare function mountStyleRegistry(registry: StyleRegistry, doc?: Document): () => void;
|
|
19
|
+
//# sourceMappingURL=StyleSink.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StyleSink.d.ts","sourceRoot":"","sources":["../../../src/impl/styles/StyleSink.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,aAAa,EACvB,GAAG,GAAE,QAA+E,GACnF,MAAM,IAAI,CAgCZ"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style Sink
|
|
3
|
+
*
|
|
4
|
+
* Mounts plugin-contributed stylesheets (from the microkernel StyleRegistry)
|
|
5
|
+
* into the document as keyed <style> elements. The registry is pure data; this
|
|
6
|
+
* is the DOM side, kept here so microkernel-impl stays DOM-free and node-safe.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Subscribe a StyleRegistry to a document, keeping a `<style data-plugin-style="<id>">`
|
|
10
|
+
* element in `<head>` in sync with every contribution. Updates mutate the element in
|
|
11
|
+
* place; removed contributions unmount their element.
|
|
12
|
+
*
|
|
13
|
+
* SSR / node-safe: a no-op (returns an empty disposer) when there is no document.
|
|
14
|
+
*
|
|
15
|
+
* @returns an unmount function that removes all mounted styles and stops reacting.
|
|
16
|
+
*/
|
|
17
|
+
export function mountStyleRegistry(registry, doc = (typeof document === 'undefined' ? undefined : document)) {
|
|
18
|
+
if (!doc || !doc.head)
|
|
19
|
+
return () => { };
|
|
20
|
+
const els = new Map();
|
|
21
|
+
const unsubscribe = registry.subscribe((styles) => {
|
|
22
|
+
const seen = new Set();
|
|
23
|
+
for (const { id, css } of styles) {
|
|
24
|
+
seen.add(id);
|
|
25
|
+
let el = els.get(id);
|
|
26
|
+
if (!el) {
|
|
27
|
+
el = doc.createElement('style');
|
|
28
|
+
el.setAttribute('data-plugin-style', id);
|
|
29
|
+
doc.head.appendChild(el);
|
|
30
|
+
els.set(id, el);
|
|
31
|
+
}
|
|
32
|
+
if (el.textContent !== css)
|
|
33
|
+
el.textContent = css;
|
|
34
|
+
}
|
|
35
|
+
// Remove styles whose contribution disappeared (dispose/unregister).
|
|
36
|
+
for (const [id, el] of els) {
|
|
37
|
+
if (!seen.has(id)) {
|
|
38
|
+
el.remove();
|
|
39
|
+
els.delete(id);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
return () => {
|
|
44
|
+
unsubscribe();
|
|
45
|
+
for (const el of els.values())
|
|
46
|
+
el.remove();
|
|
47
|
+
els.clear();
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/impl/styles/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC"}
|