@hamak/ui-shell-impl 0.6.0 → 0.7.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/dist/core/DefaultShell.js +4 -4
- package/dist/core/index.d.ts +5 -5
- package/dist/core/index.js +5 -5
- package/dist/es2015/core/DefaultShell.js +4 -4
- package/dist/es2015/core/index.js +5 -5
- package/dist/es2015/index.js +7 -0
- package/dist/es2015/plugin/ShellPluginFactory.js +8 -2
- package/dist/es2015/plugin/index.js +1 -1
- package/dist/es2015/providers/index.js +5 -5
- package/dist/es2015/styles/StyleSink.js +49 -0
- package/dist/es2015/styles/index.js +5 -0
- package/dist/es2015/utils/index.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/plugin/ShellPluginFactory.d.ts +1 -1
- package/dist/plugin/ShellPluginFactory.d.ts.map +1 -1
- package/dist/plugin/ShellPluginFactory.js +8 -2
- package/dist/plugin/index.d.ts +1 -1
- package/dist/plugin/index.js +1 -1
- package/dist/providers/index.d.ts +5 -5
- package/dist/providers/index.js +5 -5
- package/dist/styles/StyleSink.d.ts +19 -0
- package/dist/styles/StyleSink.d.ts.map +1 -0
- package/dist/styles/StyleSink.js +49 -0
- package/dist/styles/index.d.ts +6 -0
- package/dist/styles/index.d.ts.map +1 -0
- package/dist/styles/index.js +5 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.js +1 -1
- package/package.json +2 -2
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Default Shell Implementation
|
|
3
3
|
*/
|
|
4
|
-
import { DefaultThemeManager } from './DefaultThemeManager';
|
|
5
|
-
import { DefaultFeatureManager } from './DefaultFeatureManager';
|
|
6
|
-
import { LocalStorageProvider } from '../providers/LocalStorageProvider';
|
|
7
|
-
import { CSSVariablesThemeProvider } from '../providers/CSSVariablesThemeProvider';
|
|
4
|
+
import { DefaultThemeManager } from './DefaultThemeManager.js';
|
|
5
|
+
import { DefaultFeatureManager } from './DefaultFeatureManager.js';
|
|
6
|
+
import { LocalStorageProvider } from '../providers/LocalStorageProvider.js';
|
|
7
|
+
import { CSSVariablesThemeProvider } from '../providers/CSSVariablesThemeProvider.js';
|
|
8
8
|
export class DefaultShell {
|
|
9
9
|
themeManager;
|
|
10
10
|
featureManager;
|
package/dist/core/index.d.ts
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Core Implementations
|
|
3
3
|
* Export all core implementation classes
|
|
4
4
|
*/
|
|
5
|
-
export * from './DefaultShell';
|
|
6
|
-
export * from './DefaultThemeManager';
|
|
7
|
-
export * from './DefaultFeatureManager';
|
|
8
|
-
export * from './DefaultLayoutManager';
|
|
9
|
-
export * from './DefaultRouter';
|
|
5
|
+
export * from './DefaultShell.js';
|
|
6
|
+
export * from './DefaultThemeManager.js';
|
|
7
|
+
export * from './DefaultFeatureManager.js';
|
|
8
|
+
export * from './DefaultLayoutManager.js';
|
|
9
|
+
export * from './DefaultRouter.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Core Implementations
|
|
3
3
|
* Export all core implementation classes
|
|
4
4
|
*/
|
|
5
|
-
export * from './DefaultShell';
|
|
6
|
-
export * from './DefaultThemeManager';
|
|
7
|
-
export * from './DefaultFeatureManager';
|
|
8
|
-
export * from './DefaultLayoutManager';
|
|
9
|
-
export * from './DefaultRouter';
|
|
5
|
+
export * from './DefaultShell.js';
|
|
6
|
+
export * from './DefaultThemeManager.js';
|
|
7
|
+
export * from './DefaultFeatureManager.js';
|
|
8
|
+
export * from './DefaultLayoutManager.js';
|
|
9
|
+
export * from './DefaultRouter.js';
|
|
@@ -10,10 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
11
|
});
|
|
12
12
|
};
|
|
13
|
-
import { DefaultThemeManager } from './DefaultThemeManager';
|
|
14
|
-
import { DefaultFeatureManager } from './DefaultFeatureManager';
|
|
15
|
-
import { LocalStorageProvider } from '../providers/LocalStorageProvider';
|
|
16
|
-
import { CSSVariablesThemeProvider } from '../providers/CSSVariablesThemeProvider';
|
|
13
|
+
import { DefaultThemeManager } from './DefaultThemeManager.js';
|
|
14
|
+
import { DefaultFeatureManager } from './DefaultFeatureManager.js';
|
|
15
|
+
import { LocalStorageProvider } from '../providers/LocalStorageProvider.js';
|
|
16
|
+
import { CSSVariablesThemeProvider } from '../providers/CSSVariablesThemeProvider.js';
|
|
17
17
|
export class DefaultShell {
|
|
18
18
|
constructor(config = {}) {
|
|
19
19
|
this.router = null;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Core Implementations
|
|
3
3
|
* Export all core implementation classes
|
|
4
4
|
*/
|
|
5
|
-
export * from './DefaultShell';
|
|
6
|
-
export * from './DefaultThemeManager';
|
|
7
|
-
export * from './DefaultFeatureManager';
|
|
8
|
-
export * from './DefaultLayoutManager';
|
|
9
|
-
export * from './DefaultRouter';
|
|
5
|
+
export * from './DefaultShell.js';
|
|
6
|
+
export * from './DefaultThemeManager.js';
|
|
7
|
+
export * from './DefaultFeatureManager.js';
|
|
8
|
+
export * from './DefaultLayoutManager.js';
|
|
9
|
+
export * from './DefaultRouter.js';
|
package/dist/es2015/index.js
CHANGED
|
@@ -4,4 +4,11 @@
|
|
|
4
4
|
* @deprecated This package is deprecated. Please migrate to @hamak/ui-shell
|
|
5
5
|
*/
|
|
6
6
|
console.warn('[@hamak/ui-shell-impl] This package is deprecated. Please migrate to @hamak/ui-shell');
|
|
7
|
+
// Re-export everything from the consolidated package for back-compat.
|
|
7
8
|
export * from '@hamak/ui-shell';
|
|
9
|
+
// Own implementations of the shell plugin factory and the plugin-style DOM sink.
|
|
10
|
+
// These explicit named re-exports take precedence over the wildcard above, so a
|
|
11
|
+
// consumer of this (deprecated) package always gets the style-mounting factory
|
|
12
|
+
// even if its installed @hamak/ui-shell predates the #15 Styles extension point.
|
|
13
|
+
export { createShellPlugin, getShellFromContext } from './plugin/index.js';
|
|
14
|
+
export { mountStyleRegistry } from './styles/index.js';
|
|
@@ -12,11 +12,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
});
|
|
13
13
|
};
|
|
14
14
|
import { SHELL_TOKEN, THEME_MANAGER_TOKEN, FEATURE_MANAGER_TOKEN, LAYOUT_MANAGER_TOKEN, ShellCommands, ShellEvents, } from '@hamak/ui-shell-api';
|
|
15
|
-
import { DefaultShell } from '../core/DefaultShell';
|
|
16
|
-
import { DefaultLayoutManager } from '../core/DefaultLayoutManager';
|
|
15
|
+
import { DefaultShell } from '../core/DefaultShell.js';
|
|
16
|
+
import { DefaultLayoutManager } from '../core/DefaultLayoutManager.js';
|
|
17
|
+
import { mountStyleRegistry } from '../styles/index.js';
|
|
17
18
|
export function createShellPlugin(config) {
|
|
18
19
|
let shell;
|
|
19
20
|
let layoutManager;
|
|
21
|
+
let unmountStyles;
|
|
20
22
|
return {
|
|
21
23
|
initialize(ctx) {
|
|
22
24
|
shell = new DefaultShell(config);
|
|
@@ -68,11 +70,15 @@ export function createShellPlugin(config) {
|
|
|
68
70
|
activate(ctx) {
|
|
69
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
70
72
|
yield shell.initialize();
|
|
73
|
+
// Mount plugin-contributed stylesheets into the document. Single well-known
|
|
74
|
+
// mount point for the whole host; SSR-safe (no-op without a document).
|
|
75
|
+
unmountStyles = mountStyleRegistry(ctx.styles);
|
|
71
76
|
const shellContext = shell.getContext();
|
|
72
77
|
ctx.hooks.emit('shell:activated', { context: shellContext });
|
|
73
78
|
});
|
|
74
79
|
},
|
|
75
80
|
deactivate() {
|
|
81
|
+
unmountStyles === null || unmountStyles === void 0 ? void 0 : unmountStyles();
|
|
76
82
|
shell.destroy();
|
|
77
83
|
layoutManager.destroy();
|
|
78
84
|
},
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Providers
|
|
3
3
|
* Export all provider implementations
|
|
4
4
|
*/
|
|
5
|
-
export * from './LocalStorageProvider';
|
|
6
|
-
export * from './MemoryStorageProvider';
|
|
7
|
-
export * from './CSSVariablesThemeProvider';
|
|
8
|
-
export * from './HistoryRouterStrategy';
|
|
9
|
-
export * from './HashRouterStrategy';
|
|
5
|
+
export * from './LocalStorageProvider.js';
|
|
6
|
+
export * from './MemoryStorageProvider.js';
|
|
7
|
+
export * from './CSSVariablesThemeProvider.js';
|
|
8
|
+
export * from './HistoryRouterStrategy.js';
|
|
9
|
+
export * from './HashRouterStrategy.js';
|
|
@@ -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
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@
|
|
|
4
4
|
* @deprecated This package is deprecated. Please migrate to @hamak/ui-shell
|
|
5
5
|
*/
|
|
6
6
|
export * from '@hamak/ui-shell';
|
|
7
|
+
export { createShellPlugin, getShellFromContext } from './plugin/index.js';
|
|
8
|
+
export { mountStyleRegistry } from './styles/index.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,cAAc,iBAAiB,CAAC;AAMhC,OAAO,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -4,4 +4,11 @@
|
|
|
4
4
|
* @deprecated This package is deprecated. Please migrate to @hamak/ui-shell
|
|
5
5
|
*/
|
|
6
6
|
console.warn('[@hamak/ui-shell-impl] This package is deprecated. Please migrate to @hamak/ui-shell');
|
|
7
|
+
// Re-export everything from the consolidated package for back-compat.
|
|
7
8
|
export * from '@hamak/ui-shell';
|
|
9
|
+
// Own implementations of the shell plugin factory and the plugin-style DOM sink.
|
|
10
|
+
// These explicit named re-exports take precedence over the wildcard above, so a
|
|
11
|
+
// consumer of this (deprecated) package always gets the style-mounting factory
|
|
12
|
+
// even if its installed @hamak/ui-shell predates the #15 Styles extension point.
|
|
13
|
+
export { createShellPlugin, getShellFromContext } from './plugin/index.js';
|
|
14
|
+
export { mountStyleRegistry } from './styles/index.js';
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import type { PluginModule } from '@hamak/microkernel-spi';
|
|
6
6
|
import type { ActivateContext } from '@hamak/microkernel-api';
|
|
7
7
|
import type { ShellConfig } from '@hamak/ui-shell-api';
|
|
8
|
-
import { DefaultShell } from '../core/DefaultShell';
|
|
8
|
+
import { DefaultShell } from '../core/DefaultShell.js';
|
|
9
9
|
export declare function createShellPlugin(config?: ShellConfig): PluginModule;
|
|
10
10
|
export declare function getShellFromContext(ctx: ActivateContext): DefaultShell;
|
|
11
11
|
//# sourceMappingURL=ShellPluginFactory.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ShellPluginFactory.d.ts","sourceRoot":"","sources":["../../src/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,qBAAqB,CAAC;AASvD,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"ShellPluginFactory.d.ts","sourceRoot":"","sources":["../../src/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,qBAAqB,CAAC;AASvD,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"}
|
|
@@ -3,11 +3,13 @@
|
|
|
3
3
|
* Creates microkernel plugin for UI Shell integration
|
|
4
4
|
*/
|
|
5
5
|
import { SHELL_TOKEN, THEME_MANAGER_TOKEN, FEATURE_MANAGER_TOKEN, LAYOUT_MANAGER_TOKEN, ShellCommands, ShellEvents, } from '@hamak/ui-shell-api';
|
|
6
|
-
import { DefaultShell } from '../core/DefaultShell';
|
|
7
|
-
import { DefaultLayoutManager } from '../core/DefaultLayoutManager';
|
|
6
|
+
import { DefaultShell } from '../core/DefaultShell.js';
|
|
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
|
},
|
package/dist/plugin/index.d.ts
CHANGED
package/dist/plugin/index.js
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* Providers
|
|
3
3
|
* Export all provider implementations
|
|
4
4
|
*/
|
|
5
|
-
export * from './LocalStorageProvider';
|
|
6
|
-
export * from './MemoryStorageProvider';
|
|
7
|
-
export * from './CSSVariablesThemeProvider';
|
|
8
|
-
export * from './HistoryRouterStrategy';
|
|
9
|
-
export * from './HashRouterStrategy';
|
|
5
|
+
export * from './LocalStorageProvider.js';
|
|
6
|
+
export * from './MemoryStorageProvider.js';
|
|
7
|
+
export * from './CSSVariablesThemeProvider.js';
|
|
8
|
+
export * from './HistoryRouterStrategy.js';
|
|
9
|
+
export * from './HashRouterStrategy.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/providers/index.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
* Providers
|
|
3
3
|
* Export all provider implementations
|
|
4
4
|
*/
|
|
5
|
-
export * from './LocalStorageProvider';
|
|
6
|
-
export * from './MemoryStorageProvider';
|
|
7
|
-
export * from './CSSVariablesThemeProvider';
|
|
8
|
-
export * from './HistoryRouterStrategy';
|
|
9
|
-
export * from './HashRouterStrategy';
|
|
5
|
+
export * from './LocalStorageProvider.js';
|
|
6
|
+
export * from './MemoryStorageProvider.js';
|
|
7
|
+
export * from './CSSVariablesThemeProvider.js';
|
|
8
|
+
export * from './HistoryRouterStrategy.js';
|
|
9
|
+
export * from './HashRouterStrategy.js';
|
|
@@ -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/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/styles/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,cAAc,aAAa,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hamak/ui-shell-impl",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.2",
|
|
4
4
|
"description": "[DEPRECATED] Use @hamak/ui-shell instead",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"access": "public"
|
|
25
25
|
},
|
|
26
26
|
"scripts": {
|
|
27
|
-
"build": "tsc -p tsconfig.lib.json",
|
|
27
|
+
"build": "tsc -p tsconfig.lib.json && node ../../../scripts/fix-esm-extensions.mjs ./dist",
|
|
28
28
|
"clean": "rm -rf dist"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|