@softarc/native-federation-orchestrator 4.0.0-RC1
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/LICENSE.md +9 -0
- package/README.md +142 -0
- package/fesm2022/@softarc/native-federation-orchestrator.mjs +2539 -0
- package/fesm2022/@softarc/native-federation-orchestrator.mjs.map +7 -0
- package/fesm2022/audit.mjs +67 -0
- package/fesm2022/audit.mjs.map +7 -0
- package/fesm2022/options.mjs +173 -0
- package/fesm2022/options.mjs.map +7 -0
- package/fesm2022/registry.mjs +110 -0
- package/fesm2022/registry.mjs.map +7 -0
- package/fesm2022/sdk.mjs +99 -0
- package/fesm2022/sdk.mjs.map +7 -0
- package/init-registry.mjs +1 -0
- package/package.json +58 -0
- package/quickstart.mjs +18 -0
- package/types/init-registry.d.ts +6 -0
- package/types/lib/1.domain/externals/external.contract.d.ts +14 -0
- package/types/lib/1.domain/externals/version.contract.d.ts +21 -0
- package/types/lib/1.domain/import-map/import-map.contract.d.ts +7 -0
- package/types/lib/1.domain/index.d.ts +7 -0
- package/types/lib/1.domain/registry/event-registry.contract.d.ts +8 -0
- package/types/lib/1.domain/registry/event.contract.d.ts +15 -0
- package/types/lib/1.domain/registry/index.d.ts +3 -0
- package/types/lib/1.domain/registry/registry-options.contract.d.ts +11 -0
- package/types/lib/1.domain/remote/remote-info.contract.d.ts +8 -0
- package/types/lib/1.domain/remote/remote-module.contract.d.ts +4 -0
- package/types/lib/1.domain/remote-entry/manifest.contract.d.ts +3 -0
- package/types/lib/1.domain/remote-entry/remote-entry.contract.d.ts +30 -0
- package/types/lib/2.app/config/config.contract.d.ts +7 -0
- package/types/lib/2.app/config/host.contract.d.ts +14 -0
- package/types/lib/2.app/config/import-map.contract.d.ts +9 -0
- package/types/lib/2.app/config/index.d.ts +6 -0
- package/types/lib/2.app/config/log.contract.d.ts +21 -0
- package/types/lib/2.app/config/mode.contract.d.ts +19 -0
- package/types/lib/2.app/config/registry.contract.d.ts +6 -0
- package/types/lib/2.app/config/storage.contract.d.ts +18 -0
- package/types/lib/2.app/driver-ports/audit/for-auditing-externals.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/audit/index.d.ts +1 -0
- package/types/lib/2.app/driver-ports/dynamic-init/drivers.contract.d.ts +13 -0
- package/types/lib/2.app/driver-ports/dynamic-init/flow.contract.d.ts +4 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-converting-to-import-map.d.ts +6 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-getting-remote-entry.port.d.ts +3 -0
- package/types/lib/2.app/driver-ports/dynamic-init/for-updating-cache.d.ts +5 -0
- package/types/lib/2.app/driver-ports/dynamic-init/index.d.ts +5 -0
- package/types/lib/2.app/driver-ports/flow-factory.contract.d.ts +7 -0
- package/types/lib/2.app/driver-ports/init/drivers.contract.d.ts +17 -0
- package/types/lib/2.app/driver-ports/init/flow.contract.d.ts +6 -0
- package/types/lib/2.app/driver-ports/init/for-committing-changes.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-determining-shared-externals.port.d.ts +1 -0
- package/types/lib/2.app/driver-ports/init/for-exposing-module-loader.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-generating-import-map.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/for-getting-remote-entries.port.d.ts +3 -0
- package/types/lib/2.app/driver-ports/init/for-processing-remote-entries.port.d.ts +2 -0
- package/types/lib/2.app/driver-ports/init/index.d.ts +8 -0
- package/types/lib/2.app/driver-ports/registry/for-managing-events.port.d.ts +2 -0
- package/types/lib/2.app/driving-ports/driving.contract.d.ts +16 -0
- package/types/lib/2.app/driving-ports/for-browser-tasks.d.ts +7 -0
- package/types/lib/2.app/driving-ports/for-providing-manifest.port.d.ts +4 -0
- package/types/lib/2.app/driving-ports/for-providing-remote-entries.port.d.ts +4 -0
- package/types/lib/2.app/driving-ports/for-remote-info-storage.port.d.ts +11 -0
- package/types/lib/2.app/driving-ports/for-scoped-externals-storage.port.d.ts +9 -0
- package/types/lib/2.app/driving-ports/for-shared-externals-storage.port.d.ts +13 -0
- package/types/lib/2.app/driving-ports/for-version-checking.port.d.ts +6 -0
- package/types/lib/2.app/driving-ports/index.d.ts +8 -0
- package/types/lib/2.app/flows/audit/externals-audit.d.ts +4 -0
- package/types/lib/2.app/flows/dynamic-init/convert-to-import-map.d.ts +3 -0
- package/types/lib/2.app/flows/dynamic-init/get-remote-entry.d.ts +5 -0
- package/types/lib/2.app/flows/dynamic-init/update-cache.d.ts +5 -0
- package/types/lib/2.app/flows/init/commit-changes.d.ts +4 -0
- package/types/lib/2.app/flows/init/determine-shared-externals.d.ts +5 -0
- package/types/lib/2.app/flows/init/expose-module-loader.d.ts +4 -0
- package/types/lib/2.app/flows/init/generate-import-map.d.ts +5 -0
- package/types/lib/2.app/flows/init/get-remote-entries.d.ts +6 -0
- package/types/lib/2.app/flows/init/process-remote-entries.d.ts +5 -0
- package/types/lib/2.app/flows/registry/setup-registry.d.ts +3 -0
- package/types/lib/3.adapters/browser/browser.d.ts +4 -0
- package/types/lib/3.adapters/checks/version.check.d.ts +3 -0
- package/types/lib/3.adapters/http/manifest-provider.d.ts +3 -0
- package/types/lib/3.adapters/http/remote-entry-provider.d.ts +3 -0
- package/types/lib/3.adapters/storage/remote-info.repository.d.ts +4 -0
- package/types/lib/3.adapters/storage/scoped-externals.repository.d.ts +4 -0
- package/types/lib/3.adapters/storage/shared-externals.repository.d.ts +4 -0
- package/types/lib/4.config/host/host.config.d.ts +2 -0
- package/types/lib/4.config/import-map/import-map.config.d.ts +2 -0
- package/types/lib/4.config/import-map/index.d.ts +3 -0
- package/types/lib/4.config/import-map/replace-in-dom.d.ts +2 -0
- package/types/lib/4.config/import-map/use-default.d.ts +3 -0
- package/types/lib/4.config/import-map/use-import-shim.d.ts +5 -0
- package/types/lib/4.config/logging/console.logger.d.ts +3 -0
- package/types/lib/4.config/logging/index.d.ts +2 -0
- package/types/lib/4.config/logging/log.config.d.ts +2 -0
- package/types/lib/4.config/logging/log.handler.d.ts +3 -0
- package/types/lib/4.config/logging/noop.logger.d.ts +3 -0
- package/types/lib/4.config/mode/caching.profile.d.ts +2 -0
- package/types/lib/4.config/mode/default.profile.d.ts +2 -0
- package/types/lib/4.config/mode/index.d.ts +2 -0
- package/types/lib/4.config/mode/mode.config.d.ts +2 -0
- package/types/lib/4.config/storage/global-this.storage.d.ts +3 -0
- package/types/lib/4.config/storage/index.d.ts +3 -0
- package/types/lib/4.config/storage/local.storage.d.ts +3 -0
- package/types/lib/4.config/storage/session.storage.d.ts +3 -0
- package/types/lib/4.config/storage/storage.config.d.ts +2 -0
- package/types/lib/5.di/config.factory.d.ts +2 -0
- package/types/lib/5.di/driving.factory.d.ts +6 -0
- package/types/lib/5.di/flows/dynamic-init.factory.d.ts +14 -0
- package/types/lib/5.di/flows/init.factory.d.ts +14 -0
- package/types/lib/6.mocks/handlers/log.handler.d.ts +2 -0
- package/types/lib/audit.index.d.ts +2 -0
- package/types/lib/index.d.ts +7 -0
- package/types/lib/init-federation.contract.d.ts +15 -0
- package/types/lib/init-federation.d.ts +4 -0
- package/types/lib/native-federation.error.d.ts +4 -0
- package/types/lib/options.index.d.ts +5 -0
- package/types/lib/registry.index.d.ts +4 -0
- package/types/lib/sdk.index.d.ts +8 -0
- package/types/lib/utils/clone-entry.d.ts +4 -0
- package/types/lib/utils/optional.d.ts +13 -0
- package/types/lib/utils/path.d.ts +3 -0
- package/types/quickstart.d.ts +1 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// src/lib/2.app/config/log.contract.ts
|
|
2
|
+
var LogLevel = {
|
|
3
|
+
debug: 0,
|
|
4
|
+
warn: 1,
|
|
5
|
+
error: 2
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
// src/lib/4.config/logging/console.logger.ts
|
|
9
|
+
var consoleLogger = {
|
|
10
|
+
/* eslint no-console: "off", curly: "error" */
|
|
11
|
+
debug: (step, msg, err) => !!err ? console.log(`[DEBUG][${step}]: ${msg}`, err) : console.log(`[DEBUG][${step}]: ${msg}`),
|
|
12
|
+
error: (step, msg, err) => !!err ? console.error(`[NF][${step}]: ${msg}`, err) : console.error(`[NF][${step}]: ${msg}`),
|
|
13
|
+
warn: (step, msg, err) => !!err ? console.warn(`[NF][${step}]: ${msg}`, err) : console.warn(`[NF][${step}]: ${msg}`)
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/lib/4.config/logging/noop.logger.ts
|
|
17
|
+
var noopLogger = {
|
|
18
|
+
debug: () => {
|
|
19
|
+
},
|
|
20
|
+
error: () => {
|
|
21
|
+
},
|
|
22
|
+
warn: () => {
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
// src/lib/native-federation.error.ts
|
|
27
|
+
var NFError = class extends Error {
|
|
28
|
+
constructor(message, cause) {
|
|
29
|
+
super(message, cause);
|
|
30
|
+
this.name = "NFError";
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
// src/lib/utils/clone-entry.ts
|
|
35
|
+
var cloneEntry = (name, raw) => {
|
|
36
|
+
try {
|
|
37
|
+
if (typeof structuredClone === "function") {
|
|
38
|
+
return structuredClone(raw);
|
|
39
|
+
}
|
|
40
|
+
} catch {
|
|
41
|
+
}
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(JSON.stringify(raw));
|
|
44
|
+
} catch {
|
|
45
|
+
}
|
|
46
|
+
throw new NFError(`Could not parse storage entry '${String(name)}'`);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/lib/4.config/storage/global-this.storage.ts
|
|
50
|
+
var globalThisStorageEntry = (namespace) => (key, initialValue) => {
|
|
51
|
+
if (!globalThis[namespace]) {
|
|
52
|
+
globalThis[namespace] = {};
|
|
53
|
+
}
|
|
54
|
+
const storage = globalThis[namespace];
|
|
55
|
+
if (!storage[key]) storage[key] = initialValue;
|
|
56
|
+
const entry = {
|
|
57
|
+
get() {
|
|
58
|
+
return cloneEntry(key, storage[key]);
|
|
59
|
+
},
|
|
60
|
+
set(value) {
|
|
61
|
+
storage[key] = cloneEntry(key, value);
|
|
62
|
+
return entry;
|
|
63
|
+
},
|
|
64
|
+
clear() {
|
|
65
|
+
storage[key] = cloneEntry(key, initialValue);
|
|
66
|
+
return this;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return entry;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
// src/lib/4.config/storage/local.storage.ts
|
|
73
|
+
var localStorageEntry = (namespace) => (key, initialValue) => {
|
|
74
|
+
if (!localStorage.getItem(`${namespace}.${String(key)}`)) {
|
|
75
|
+
localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));
|
|
76
|
+
}
|
|
77
|
+
const entry = {
|
|
78
|
+
get() {
|
|
79
|
+
const fromCache = localStorage.getItem(`${namespace}.${String(key)}`);
|
|
80
|
+
if (!fromCache) return void 0;
|
|
81
|
+
return JSON.parse(fromCache);
|
|
82
|
+
},
|
|
83
|
+
set(value) {
|
|
84
|
+
localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(value));
|
|
85
|
+
return entry;
|
|
86
|
+
},
|
|
87
|
+
clear() {
|
|
88
|
+
localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));
|
|
89
|
+
return this;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
return entry;
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
// src/lib/4.config/storage/session.storage.ts
|
|
96
|
+
var sessionStorageEntry = (namespace) => (key, initialValue) => {
|
|
97
|
+
if (!sessionStorage.getItem(`${namespace}.${String(key)}`)) {
|
|
98
|
+
sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));
|
|
99
|
+
}
|
|
100
|
+
const entry = {
|
|
101
|
+
get() {
|
|
102
|
+
const fromCache = sessionStorage.getItem(`${namespace}.${String(key)}`);
|
|
103
|
+
if (!fromCache) return void 0;
|
|
104
|
+
return JSON.parse(fromCache);
|
|
105
|
+
},
|
|
106
|
+
set(value) {
|
|
107
|
+
sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(value));
|
|
108
|
+
return entry;
|
|
109
|
+
},
|
|
110
|
+
clear() {
|
|
111
|
+
sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));
|
|
112
|
+
return this;
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
return entry;
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
// src/lib/4.config/import-map/replace-in-dom.ts
|
|
119
|
+
var replaceInDOM = (mapType) => (importMap, opts = {}) => {
|
|
120
|
+
if (opts?.override) {
|
|
121
|
+
document.head.querySelectorAll(`script[type="${mapType}"]`).forEach((importMap2) => importMap2.remove());
|
|
122
|
+
}
|
|
123
|
+
document.head.appendChild(
|
|
124
|
+
Object.assign(document.createElement("script"), {
|
|
125
|
+
type: mapType,
|
|
126
|
+
innerHTML: JSON.stringify(importMap)
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
return Promise.resolve(importMap);
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
// src/lib/4.config/import-map/use-import-shim.ts
|
|
133
|
+
var useShimImportMap = (cfg = { shimMode: false }) => ({
|
|
134
|
+
loadModuleFn: (url) => importShim(url),
|
|
135
|
+
setImportMapFn: replaceInDOM(cfg.shimMode ? "importmap-shim" : "importmap")
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// src/lib/4.config/import-map/use-default.ts
|
|
139
|
+
var useDefaultImportMap = () => ({
|
|
140
|
+
loadModuleFn: (url) => import(
|
|
141
|
+
/* @vite-ignore */
|
|
142
|
+
url
|
|
143
|
+
),
|
|
144
|
+
setImportMapFn: replaceInDOM("importmap")
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
// src/lib/4.config/mode/default.profile.ts
|
|
148
|
+
var defaultProfile = {
|
|
149
|
+
latestSharedExternal: false,
|
|
150
|
+
overrideCachedRemotes: "init-only",
|
|
151
|
+
overrideCachedRemotesIfURLMatches: false
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
// src/lib/4.config/mode/caching.profile.ts
|
|
155
|
+
var cachingProfile = {
|
|
156
|
+
latestSharedExternal: false,
|
|
157
|
+
overrideCachedRemotes: "never",
|
|
158
|
+
overrideCachedRemotesIfURLMatches: false
|
|
159
|
+
};
|
|
160
|
+
export {
|
|
161
|
+
LogLevel,
|
|
162
|
+
cachingProfile,
|
|
163
|
+
consoleLogger,
|
|
164
|
+
defaultProfile,
|
|
165
|
+
globalThisStorageEntry,
|
|
166
|
+
localStorageEntry,
|
|
167
|
+
noopLogger,
|
|
168
|
+
replaceInDOM,
|
|
169
|
+
sessionStorageEntry,
|
|
170
|
+
useDefaultImportMap,
|
|
171
|
+
useShimImportMap
|
|
172
|
+
};
|
|
173
|
+
//# sourceMappingURL=options.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/2.app/config/log.contract.ts", "../../src/lib/4.config/logging/console.logger.ts", "../../src/lib/4.config/logging/noop.logger.ts", "../../src/lib/native-federation.error.ts", "../../src/lib/utils/clone-entry.ts", "../../src/lib/4.config/storage/global-this.storage.ts", "../../src/lib/4.config/storage/local.storage.ts", "../../src/lib/4.config/storage/session.storage.ts", "../../src/lib/4.config/import-map/replace-in-dom.ts", "../../src/lib/4.config/import-map/use-import-shim.ts", "../../src/lib/4.config/import-map/use-default.ts", "../../src/lib/4.config/mode/default.profile.ts", "../../src/lib/4.config/mode/caching.profile.ts"],
|
|
4
|
+
"sourcesContent": ["export const LogLevel = {\n debug: 0,\n warn: 1,\n error: 2,\n};\n\nexport type LogType = keyof typeof LogLevel;\n\nexport type Logger = {\n error: (step: number, msg: string, details?: unknown) => void;\n warn: (step: number, msg: string, details?: unknown) => void;\n debug: (step: number, msg: string, details?: unknown) => void;\n};\n\nexport type LogHandler = Logger & {\n level: LogType;\n};\n\nexport type LoggingConfig = {\n log: LogHandler;\n};\n\nexport type LoggingOptions = {\n logger?: Logger;\n logLevel?: LogType;\n};\n", "import type { Logger } from 'lib/2.app/config/log.contract';\n\nconst consoleLogger: Logger = {\n /* eslint no-console: \"off\", curly: \"error\" */\n debug: (step: number, msg: string, err) =>\n !!err ? console.log(`[DEBUG][${step}]: ${msg}`, err) : console.log(`[DEBUG][${step}]: ${msg}`),\n error: (step: number, msg: string, err) =>\n !!err ? console.error(`[NF][${step}]: ${msg}`, err) : console.error(`[NF][${step}]: ${msg}`),\n warn: (step: number, msg: string, err) =>\n !!err ? console.warn(`[NF][${step}]: ${msg}`, err) : console.warn(`[NF][${step}]: ${msg}`),\n};\n\nexport { consoleLogger };\n", "import type { Logger } from 'lib/2.app/config/log.contract';\n\nconst noopLogger: Logger = {\n debug: () => {},\n error: () => {},\n warn: () => {},\n};\n\nexport { noopLogger };\n", "class NFError extends Error {\n constructor(message: string, cause?: Error) {\n super(message, cause);\n this.name = 'NFError';\n }\n}\n\nexport { NFError };\n", "import type { StorageEntryKey } from 'lib/2.app/config/storage.contract';\nimport { NFError } from 'lib/native-federation.error';\n\ntype CloneEntry = <T>(name: StorageEntryKey, raw: T) => T;\n\nconst cloneEntry: CloneEntry = <T>(name: StorageEntryKey, raw: T) => {\n try {\n if (typeof structuredClone === 'function') {\n return structuredClone(raw);\n }\n } catch {\n /* structured clone is unavailable */\n }\n try {\n return JSON.parse(JSON.stringify(raw));\n } catch {\n /* object is not stringifyable */\n }\n throw new NFError(`Could not parse storage entry '${String(name)}'`);\n};\n\nexport { CloneEntry, cloneEntry };\n", "import { cloneEntry } from '../../utils/clone-entry';\nimport { type StorageEntryCreator, type StorageEntry } from 'lib/2.app/config/storage.contract';\n\nconst globalThisStorageEntry: StorageEntryCreator =\n (namespace: string) =>\n <TValue>(key: string, initialValue: TValue) => {\n if (!(globalThis as unknown as { [namespace]: unknown })[namespace]) {\n (globalThis as unknown as { [namespace]: unknown })[namespace] = {};\n }\n\n const storage = (globalThis as unknown as { [namespace]: { [P in typeof key]: TValue } })[\n namespace\n ]!;\n if (!storage[key]) storage[key] = initialValue;\n\n const entry: StorageEntry<TValue> = {\n get(): TValue {\n return cloneEntry(key, storage[key])!;\n },\n set(value: TValue): StorageEntry<TValue> {\n storage[key] = cloneEntry(key, value);\n return entry;\n },\n clear(): StorageEntry<TValue> {\n storage[key] = cloneEntry(key, initialValue);\n return this;\n },\n };\n\n return entry;\n };\n\nexport { globalThisStorageEntry };\n", "import type { StorageEntryCreator, StorageEntry } from 'lib/2.app/config/storage.contract';\n\nconst localStorageEntry: StorageEntryCreator =\n (namespace: string) =>\n <TValue>(key: string, initialValue: TValue) => {\n if (!localStorage.getItem(`${namespace}.${String(key)}`)) {\n localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));\n }\n const entry: StorageEntry<TValue> = {\n get() {\n const fromCache = localStorage.getItem(`${namespace}.${String(key)}`);\n if (!fromCache) return undefined;\n return JSON.parse(fromCache);\n },\n set(value: TValue): StorageEntry<TValue> {\n localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(value));\n return entry;\n },\n clear(): StorageEntry<TValue> {\n localStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));\n return this;\n },\n };\n return entry;\n };\n\nexport { localStorageEntry };\n", "import type { StorageEntryCreator, StorageEntry } from 'lib/2.app/config/storage.contract';\n\nconst sessionStorageEntry: StorageEntryCreator =\n (namespace: string) =>\n <TValue>(key: string, initialValue: TValue) => {\n if (!sessionStorage.getItem(`${namespace}.${String(key)}`)) {\n sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));\n }\n const entry: StorageEntry<TValue> = {\n get() {\n const fromCache = sessionStorage.getItem(`${namespace}.${String(key)}`);\n if (!fromCache) return undefined;\n return JSON.parse(fromCache);\n },\n set(value: TValue): StorageEntry<TValue> {\n sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(value));\n return entry;\n },\n clear(): StorageEntry<TValue> {\n sessionStorage.setItem(`${namespace}.${String(key)}`, JSON.stringify(initialValue));\n return this;\n },\n };\n return entry;\n };\n\nexport { sessionStorageEntry };\n", "import type { ImportMap } from 'lib/1.domain';\nimport type { SetImportMap } from 'lib/2.app/config/import-map.contract';\n\nexport const replaceInDOM =\n (mapType: string): SetImportMap =>\n (importMap: ImportMap, opts = {}) => {\n if (opts?.override) {\n document.head\n .querySelectorAll(`script[type=\"${mapType}\"]`)\n .forEach(importMap => importMap.remove());\n }\n\n document.head.appendChild(\n Object.assign(document.createElement('script'), {\n type: mapType,\n innerHTML: JSON.stringify(importMap),\n })\n );\n return Promise.resolve(importMap);\n };\n", "import type { ImportMapConfig } from 'lib/2.app/config/import-map.contract';\nimport { replaceInDOM } from './replace-in-dom';\n\ndeclare function importShim<T>(url: string): T;\n\nconst useShimImportMap = (cfg: { shimMode: boolean } = { shimMode: false }): ImportMapConfig => ({\n loadModuleFn: url => importShim(url),\n setImportMapFn: replaceInDOM(cfg.shimMode ? 'importmap-shim' : 'importmap'),\n});\n\nexport { useShimImportMap };\n", "import type { ImportMapConfig } from 'lib/2.app/config/import-map.contract';\nimport { replaceInDOM } from './replace-in-dom';\n\nconst useDefaultImportMap = (): ImportMapConfig => ({\n loadModuleFn: url => import(/* @vite-ignore */ url),\n setImportMapFn: replaceInDOM('importmap'),\n});\n\nexport { useDefaultImportMap };\n", "import type { ModeProfileConfig } from 'lib/2.app/config/mode.contract';\n\nexport const defaultProfile: ModeProfileConfig = {\n latestSharedExternal: false,\n overrideCachedRemotes: 'init-only',\n overrideCachedRemotesIfURLMatches: false,\n};\n", "import type { ModeProfileConfig } from 'lib/2.app/config/mode.contract';\n\nexport const cachingProfile: ModeProfileConfig = {\n latestSharedExternal: false,\n overrideCachedRemotes: 'never',\n overrideCachedRemotesIfURLMatches: false,\n};\n"],
|
|
5
|
+
"mappings": ";AAAO,IAAM,WAAW;AAAA,EACtB,OAAO;AAAA,EACP,MAAM;AAAA,EACN,OAAO;AACT;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;AAAA,EAC/C,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mCAAmC;AACrC;;;ACJO,IAAM,iBAAoC;AAAA,EAC/C,sBAAsB;AAAA,EACtB,uBAAuB;AAAA,EACvB,mCAAmC;AACrC;",
|
|
6
|
+
"names": ["importMap"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// src/lib/2.app/flows/registry/setup-registry.ts
|
|
2
|
+
function createRegistry(opts) {
|
|
3
|
+
const resources = /* @__PURE__ */ new Map();
|
|
4
|
+
const pending = /* @__PURE__ */ new Map();
|
|
5
|
+
const events = /* @__PURE__ */ new Map();
|
|
6
|
+
const listeners = /* @__PURE__ */ new Map();
|
|
7
|
+
const recentlyUsedEvents = /* @__PURE__ */ new Set();
|
|
8
|
+
const REMOVE_EVENTS = Math.ceil(opts.maxEvents * opts.removePercentage);
|
|
9
|
+
const register = async (type, resource) => {
|
|
10
|
+
const value = typeof resource === "function" ? await resource() : resource;
|
|
11
|
+
resources.set(type, value);
|
|
12
|
+
const callbacks = pending.get(type);
|
|
13
|
+
if (callbacks) {
|
|
14
|
+
pending.delete(type);
|
|
15
|
+
callbacks.forEach((cb) => cb(value));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
const onReady = (type, callback) => {
|
|
19
|
+
const existing = resources.get(type);
|
|
20
|
+
if (existing !== void 0) {
|
|
21
|
+
callback(existing);
|
|
22
|
+
return () => {
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
let callbacks = pending.get(type);
|
|
26
|
+
if (!callbacks) {
|
|
27
|
+
callbacks = /* @__PURE__ */ new Set();
|
|
28
|
+
pending.set(type, callbacks);
|
|
29
|
+
}
|
|
30
|
+
callbacks.add(callback);
|
|
31
|
+
return () => {
|
|
32
|
+
callbacks.delete(callback);
|
|
33
|
+
if (callbacks.size === 0) {
|
|
34
|
+
pending.delete(type);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
const on = (type, callback) => {
|
|
39
|
+
const history = events.get(type);
|
|
40
|
+
const historyCopy = history ? [...history] : null;
|
|
41
|
+
let typeListeners = listeners.get(type);
|
|
42
|
+
if (!typeListeners) {
|
|
43
|
+
typeListeners = /* @__PURE__ */ new Set();
|
|
44
|
+
listeners.set(type, typeListeners);
|
|
45
|
+
}
|
|
46
|
+
typeListeners.add(callback);
|
|
47
|
+
if (historyCopy && historyCopy.length > 0) {
|
|
48
|
+
queueMicrotask(() => {
|
|
49
|
+
historyCopy.forEach((event) => callback(event));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return () => {
|
|
53
|
+
typeListeners.delete(callback);
|
|
54
|
+
if (typeListeners.size === 0) {
|
|
55
|
+
listeners.delete(type);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
const emit = (type, data) => {
|
|
60
|
+
const event = {
|
|
61
|
+
data,
|
|
62
|
+
timestamp: Date.now()
|
|
63
|
+
};
|
|
64
|
+
recentlyUsedEvents.delete(type);
|
|
65
|
+
recentlyUsedEvents.add(type);
|
|
66
|
+
if (recentlyUsedEvents.size > opts.maxStreams) {
|
|
67
|
+
const oldest = recentlyUsedEvents.values().next().value;
|
|
68
|
+
if (oldest) {
|
|
69
|
+
recentlyUsedEvents.delete(oldest);
|
|
70
|
+
events.delete(oldest);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
let history = events.get(type) || [];
|
|
74
|
+
history.push(event);
|
|
75
|
+
if (history.length > opts.maxEvents) {
|
|
76
|
+
history = history.slice(-(opts.maxEvents - REMOVE_EVENTS));
|
|
77
|
+
}
|
|
78
|
+
events.set(type, history);
|
|
79
|
+
const typeListeners = listeners.get(type);
|
|
80
|
+
if (typeListeners && typeListeners.size > 0) {
|
|
81
|
+
typeListeners.forEach((listener) => listener(event));
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
const clear = (type) => {
|
|
85
|
+
if (type) {
|
|
86
|
+
events.delete(type);
|
|
87
|
+
listeners.delete(type);
|
|
88
|
+
resources.delete(type);
|
|
89
|
+
pending.delete(type);
|
|
90
|
+
recentlyUsedEvents.delete(type);
|
|
91
|
+
} else {
|
|
92
|
+
events.clear();
|
|
93
|
+
listeners.clear();
|
|
94
|
+
pending.clear();
|
|
95
|
+
resources.clear();
|
|
96
|
+
recentlyUsedEvents.clear();
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
return () => ({
|
|
100
|
+
register,
|
|
101
|
+
onReady,
|
|
102
|
+
emit,
|
|
103
|
+
on,
|
|
104
|
+
clear
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
export {
|
|
108
|
+
createRegistry
|
|
109
|
+
};
|
|
110
|
+
//# sourceMappingURL=registry.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/2.app/flows/registry/setup-registry.ts"],
|
|
4
|
+
"sourcesContent": ["import type {\n NFEventConsumer,\n NFEventData,\n NFEventProvider,\n NFEventUnsubscribe,\n} from '../../../1.domain/registry/event.contract';\nimport type { ForManagingEvents } from 'lib/2.app/driver-ports/registry/for-managing-events.port';\nimport type { NFEventRegistryConfig } from 'lib/2.app/config/registry.contract';\n\nexport function createRegistry(opts: NFEventRegistryConfig): ForManagingEvents {\n // resources\n const resources = new Map<string, unknown>();\n const pending = new Map<string, Set<NFEventConsumer<any>>>();\n\n // events\n const events = new Map<string, NFEventData[]>();\n const listeners = new Map<string, Set<NFEventConsumer<NFEventData<any>>>>();\n const recentlyUsedEvents = new Set<string>();\n\n const REMOVE_EVENTS = Math.ceil(opts.maxEvents * opts.removePercentage);\n\n /**\n * RESOURCE: Register a resource by name. If the resource is a provider function, it is\n * invoked to obtain the actual resource. All callbacks waiting for this\n * resource via `onReady` are invoked once the resource is registered.\n */\n const register = async <T>(type: string, resource: T | NFEventProvider<T>): Promise<void> => {\n const value =\n typeof resource === 'function' ? await (resource as NFEventProvider<T>)() : resource;\n\n resources.set(type, value);\n\n const callbacks = pending.get(type);\n if (callbacks) {\n pending.delete(type);\n callbacks.forEach(cb => cb(value));\n }\n };\n\n /**\n * RESOURCE: Subscribe to the readiness of a resource. If the resource is already\n * registered, the callback is invoked immediately. Otherwise, the callback\n * is invoked once the resource is registered.\n */\n const onReady = <T>(type: string, callback: NFEventConsumer<T>): NFEventUnsubscribe => {\n const existing = resources.get(type);\n if (existing !== undefined) {\n callback(existing as T);\n return () => {};\n }\n\n let callbacks = pending.get(type);\n if (!callbacks) {\n callbacks = new Set();\n pending.set(type, callbacks);\n }\n callbacks.add(callback);\n\n return () => {\n callbacks!.delete(callback);\n if (callbacks!.size === 0) {\n pending.delete(type);\n }\n };\n };\n\n /**\n * EVENT: Subscribe to events of a specific type. The callback is invoked for all\n * past events of that type, and for all future events.\n */\n const on = <T>(type: string, callback: NFEventConsumer<NFEventData<T>>): NFEventUnsubscribe => {\n const history = events.get(type);\n const historyCopy = history ? [...history] : null;\n\n let typeListeners = listeners.get(type);\n if (!typeListeners) {\n typeListeners = new Set();\n listeners.set(type, typeListeners);\n }\n typeListeners.add(callback);\n\n if (historyCopy && historyCopy.length > 0) {\n queueMicrotask(() => {\n historyCopy.forEach(event => callback(event));\n });\n }\n\n return () => {\n typeListeners!.delete(callback);\n if (typeListeners!.size === 0) {\n listeners.delete(type);\n }\n };\n };\n\n /**\n * Emit an event of a specific type with associated data. The event is stored\n * in the history for that type, and all listeners subscribed to that type are\n * invoked with the new event. If the number of stored events exceeds\n * the maximum, the oldest events are removed based on the configured\n * removal percentage. If the number of event types exceeds the maximum,\n * the oldest event type and its history are removed.\n */\n const emit = <T>(type: string, data: T): void => {\n const event: NFEventData<T> = {\n data,\n timestamp: Date.now(),\n };\n\n recentlyUsedEvents.delete(type);\n recentlyUsedEvents.add(type);\n\n if (recentlyUsedEvents.size > opts.maxStreams) {\n const oldest = recentlyUsedEvents.values().next().value;\n if (oldest) {\n recentlyUsedEvents.delete(oldest);\n events.delete(oldest);\n }\n }\n\n let history = events.get(type) || [];\n history.push(event);\n\n if (history.length > opts.maxEvents) {\n history = history.slice(-(opts.maxEvents - REMOVE_EVENTS));\n }\n\n events.set(type, history);\n\n const typeListeners = listeners.get(type);\n if (typeListeners && typeListeners.size > 0) {\n typeListeners.forEach(listener => listener(event));\n }\n };\n\n const clear = (type?: string): void => {\n if (type) {\n // Clear event-related data\n events.delete(type);\n listeners.delete(type);\n\n // Clear resource-related data\n resources.delete(type);\n pending.delete(type);\n\n recentlyUsedEvents.delete(type);\n } else {\n // Clear all data\n events.clear();\n listeners.clear();\n pending.clear();\n resources.clear();\n recentlyUsedEvents.clear();\n }\n };\n\n return () => ({\n register,\n onReady,\n emit,\n on,\n clear,\n });\n}\n"],
|
|
5
|
+
"mappings": ";AASO,SAAS,eAAe,MAAgD;AAE7E,QAAM,YAAY,oBAAI,IAAqB;AAC3C,QAAM,UAAU,oBAAI,IAAuC;AAG3D,QAAM,SAAS,oBAAI,IAA2B;AAC9C,QAAM,YAAY,oBAAI,IAAoD;AAC1E,QAAM,qBAAqB,oBAAI,IAAY;AAE3C,QAAM,gBAAgB,KAAK,KAAK,KAAK,YAAY,KAAK,gBAAgB;AAOtE,QAAM,WAAW,OAAU,MAAc,aAAoD;AAC3F,UAAM,QACJ,OAAO,aAAa,aAAa,MAAO,SAAgC,IAAI;AAE9E,cAAU,IAAI,MAAM,KAAK;AAEzB,UAAM,YAAY,QAAQ,IAAI,IAAI;AAClC,QAAI,WAAW;AACb,cAAQ,OAAO,IAAI;AACnB,gBAAU,QAAQ,QAAM,GAAG,KAAK,CAAC;AAAA,IACnC;AAAA,EACF;AAOA,QAAM,UAAU,CAAI,MAAc,aAAqD;AACrF,UAAM,WAAW,UAAU,IAAI,IAAI;AACnC,QAAI,aAAa,QAAW;AAC1B,eAAS,QAAa;AACtB,aAAO,MAAM;AAAA,MAAC;AAAA,IAChB;AAEA,QAAI,YAAY,QAAQ,IAAI,IAAI;AAChC,QAAI,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,SAAS,KAAK,WAAW;AACnC,gBAAU,QAAQ,MAAM,EAAE,KAAK,YAAY,cAAc;AAAA,IAC3D;AAEA,WAAO,IAAI,MAAM,OAAO;AAExB,UAAM,gBAAgB,UAAU,IAAI,IAAI;AACxC,QAAI,iBAAiB,cAAc,OAAO,GAAG;AAC3C,oBAAc,QAAQ,cAAY,SAAS,KAAK,CAAC;AAAA,IACnD;AAAA,EACF;AAEA,QAAM,QAAQ,CAAC,SAAwB;AACrC,QAAI,MAAM;AAER,aAAO,OAAO,IAAI;AAClB,gBAAU,OAAO,IAAI;AAGrB,gBAAU,OAAO,IAAI;AACrB,cAAQ,OAAO,IAAI;AAEnB,yBAAmB,OAAO,IAAI;AAAA,IAChC,OAAO;AAEL,aAAO,MAAM;AACb,gBAAU,MAAM;AAChB,cAAQ,MAAM;AACd,gBAAU,MAAM;AAChB,yBAAmB,MAAM;AAAA,IAC3B;AAAA,EACF;AAEA,SAAO,OAAO;AAAA,IACZ;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/fesm2022/sdk.mjs
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/lib/1.domain/externals/external.contract.ts
|
|
8
|
+
var GLOBAL_SCOPE = "__GLOBAL__";
|
|
9
|
+
var STRICT_SCOPE = "strict";
|
|
10
|
+
|
|
11
|
+
// src/lib/utils/optional.ts
|
|
12
|
+
var Optional = class _Optional {
|
|
13
|
+
constructor(item) {
|
|
14
|
+
this.item = item;
|
|
15
|
+
}
|
|
16
|
+
static of(item) {
|
|
17
|
+
return new _Optional(item);
|
|
18
|
+
}
|
|
19
|
+
static empty() {
|
|
20
|
+
return _Optional.of(void 0);
|
|
21
|
+
}
|
|
22
|
+
isPresent() {
|
|
23
|
+
return typeof this.item !== "undefined" && this.item !== null;
|
|
24
|
+
}
|
|
25
|
+
set(other) {
|
|
26
|
+
return _Optional.of(other);
|
|
27
|
+
}
|
|
28
|
+
ifPresent(callback) {
|
|
29
|
+
if (this.isPresent()) callback(this.item);
|
|
30
|
+
}
|
|
31
|
+
map(callback) {
|
|
32
|
+
if (!this.isPresent()) return _Optional.empty();
|
|
33
|
+
const result = callback(this.item);
|
|
34
|
+
return result instanceof _Optional ? result : _Optional.of(result);
|
|
35
|
+
}
|
|
36
|
+
orElse(other) {
|
|
37
|
+
return this.isPresent() ? this.item : other;
|
|
38
|
+
}
|
|
39
|
+
orThrow(error) {
|
|
40
|
+
if (this.isPresent()) return this.item;
|
|
41
|
+
if (typeof error === "function") throw error();
|
|
42
|
+
throw typeof error === "string" ? new Error(error) : error;
|
|
43
|
+
}
|
|
44
|
+
get() {
|
|
45
|
+
return this.item;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// src/lib/utils/path.ts
|
|
50
|
+
var path_exports = {};
|
|
51
|
+
__export(path_exports, {
|
|
52
|
+
getScope: () => getScope,
|
|
53
|
+
join: () => join
|
|
54
|
+
});
|
|
55
|
+
function join(pathA, pathB) {
|
|
56
|
+
pathA = pathA.endsWith("/") ? pathA.slice(0, -1) : pathA;
|
|
57
|
+
pathB = pathB.startsWith("/") ? pathB.slice(1) : pathB;
|
|
58
|
+
return `${pathA}/${pathB}`;
|
|
59
|
+
}
|
|
60
|
+
function getScope(path) {
|
|
61
|
+
if (!path) return "";
|
|
62
|
+
const parts = path.split("/");
|
|
63
|
+
if (parts[parts.length - 1] === "" || parts[parts.length - 1].includes(".")) {
|
|
64
|
+
parts.pop();
|
|
65
|
+
}
|
|
66
|
+
if (parts.length < 1) return "";
|
|
67
|
+
return `${parts.join("/")}/`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// src/lib/native-federation.error.ts
|
|
71
|
+
var NFError = class extends Error {
|
|
72
|
+
constructor(message, cause) {
|
|
73
|
+
super(message, cause);
|
|
74
|
+
this.name = "NFError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
// src/lib/utils/clone-entry.ts
|
|
79
|
+
var cloneEntry = (name, raw) => {
|
|
80
|
+
try {
|
|
81
|
+
if (typeof structuredClone === "function") {
|
|
82
|
+
return structuredClone(raw);
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
}
|
|
86
|
+
try {
|
|
87
|
+
return JSON.parse(JSON.stringify(raw));
|
|
88
|
+
} catch {
|
|
89
|
+
}
|
|
90
|
+
throw new NFError(`Could not parse storage entry '${String(name)}'`);
|
|
91
|
+
};
|
|
92
|
+
export {
|
|
93
|
+
GLOBAL_SCOPE,
|
|
94
|
+
Optional,
|
|
95
|
+
STRICT_SCOPE,
|
|
96
|
+
path_exports as _path,
|
|
97
|
+
cloneEntry
|
|
98
|
+
};
|
|
99
|
+
//# sourceMappingURL=sdk.mjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/lib/1.domain/externals/external.contract.ts", "../../src/lib/utils/optional.ts", "../../src/lib/utils/path.ts", "../../src/lib/native-federation.error.ts", "../../src/lib/utils/clone-entry.ts"],
|
|
4
|
+
"sourcesContent": ["import type { SharedVersion, ScopedVersion } from './version.contract';\n\nexport type ExternalName = string;\n\nexport type ScopedExternals = Record<string, ScopedExternal>;\n\nexport const GLOBAL_SCOPE = '__GLOBAL__';\n\nexport const STRICT_SCOPE = 'strict';\n\nexport type SharedExternal = {\n dirty: boolean;\n versions: SharedVersion[];\n};\n\nexport type shareScope = Record<string, SharedExternal>;\n\nexport type SharedExternals = Record<string, shareScope> & { [GLOBAL_SCOPE]: shareScope };\n\nexport type ScopedExternal = Record<string, ScopedVersion>;\n", "export class Optional<T> {\n private constructor(private item?: T) {}\n\n public static of<T>(item?: T): Optional<T> {\n return new Optional(item);\n }\n public static empty<U>(): Optional<U> {\n return Optional.of<U>(undefined);\n }\n\n public isPresent() {\n return typeof this.item !== 'undefined' && this.item !== null;\n }\n public set<U>(other: U) {\n return Optional.of(other);\n }\n\n public ifPresent(callback: (_: T) => void): void {\n if (this.isPresent()) callback(this.item as T);\n }\n\n public map<U>(callback: (_: NonNullable<T>) => U | Optional<U>): Optional<U> {\n if (!this.isPresent()) return Optional.empty();\n\n const result = callback(this.item as NonNullable<T>);\n return result instanceof Optional ? result : Optional.of(result);\n }\n\n public orElse(other: Required<T>): NonNullable<T> {\n return this.isPresent() ? (this.item as NonNullable<T>) : (other as NonNullable<T>);\n }\n\n public orThrow(error: Error | string | (() => Error)): NonNullable<T> {\n if (this.isPresent()) return this.item as NonNullable<T>;\n if (typeof error === 'function') throw error();\n throw typeof error === 'string' ? new Error(error) : error;\n }\n\n public get(): T | undefined {\n return this.item;\n }\n}\n", "function join(pathA: string, pathB: string): string {\n pathA = pathA.endsWith('/') ? pathA.slice(0, -1) : pathA;\n pathB = pathB.startsWith('/') ? pathB.slice(1) : pathB;\n return `${pathA}/${pathB}`;\n}\n\nfunction getScope(path: string) {\n if (!path) return '';\n\n const parts = path.split('/');\n\n if (parts[parts.length - 1] === '' || parts[parts.length - 1]!.includes('.')) {\n parts.pop();\n }\n if (parts.length < 1) return '';\n\n return `${parts.join('/')}/`;\n}\n\nexport { join, getScope };\n", "class NFError extends Error {\n constructor(message: string, cause?: Error) {\n super(message, cause);\n this.name = 'NFError';\n }\n}\n\nexport { NFError };\n", "import type { StorageEntryKey } from 'lib/2.app/config/storage.contract';\nimport { NFError } from 'lib/native-federation.error';\n\ntype CloneEntry = <T>(name: StorageEntryKey, raw: T) => T;\n\nconst cloneEntry: CloneEntry = <T>(name: StorageEntryKey, raw: T) => {\n try {\n if (typeof structuredClone === 'function') {\n return structuredClone(raw);\n }\n } catch {\n /* structured clone is unavailable */\n }\n try {\n return JSON.parse(JSON.stringify(raw));\n } catch {\n /* object is not stringifyable */\n }\n throw new NFError(`Could not parse storage entry '${String(name)}'`);\n};\n\nexport { CloneEntry, cloneEntry };\n"],
|
|
5
|
+
"mappings": ";;;;;;;AAMO,IAAM,eAAe;AAErB,IAAM,eAAe;;;ACRrB,IAAM,WAAN,MAAM,UAAY;AAAA,EACf,YAAoB,MAAU;AAAV;AAAA,EAAW;AAAA,EAEvC,OAAc,GAAM,MAAuB;AACzC,WAAO,IAAI,UAAS,IAAI;AAAA,EAC1B;AAAA,EACA,OAAc,QAAwB;AACpC,WAAO,UAAS,GAAM,MAAS;AAAA,EACjC;AAAA,EAEO,YAAY;AACjB,WAAO,OAAO,KAAK,SAAS,eAAe,KAAK,SAAS;AAAA,EAC3D;AAAA,EACO,IAAO,OAAU;AACtB,WAAO,UAAS,GAAG,KAAK;AAAA,EAC1B;AAAA,EAEO,UAAU,UAAgC;AAC/C,QAAI,KAAK,UAAU,EAAG,UAAS,KAAK,IAAS;AAAA,EAC/C;AAAA,EAEO,IAAO,UAA+D;AAC3E,QAAI,CAAC,KAAK,UAAU,EAAG,QAAO,UAAS,MAAM;AAE7C,UAAM,SAAS,SAAS,KAAK,IAAsB;AACnD,WAAO,kBAAkB,YAAW,SAAS,UAAS,GAAG,MAAM;AAAA,EACjE;AAAA,EAEO,OAAO,OAAoC;AAChD,WAAO,KAAK,UAAU,IAAK,KAAK,OAA2B;AAAA,EAC7D;AAAA,EAEO,QAAQ,OAAuD;AACpE,QAAI,KAAK,UAAU,EAAG,QAAO,KAAK;AAClC,QAAI,OAAO,UAAU,WAAY,OAAM,MAAM;AAC7C,UAAM,OAAO,UAAU,WAAW,IAAI,MAAM,KAAK,IAAI;AAAA,EACvD;AAAA,EAEO,MAAqB;AAC1B,WAAO,KAAK;AAAA,EACd;AACF;;;ACzCA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAS,KAAK,OAAe,OAAuB;AAClD,UAAQ,MAAM,SAAS,GAAG,IAAI,MAAM,MAAM,GAAG,EAAE,IAAI;AACnD,UAAQ,MAAM,WAAW,GAAG,IAAI,MAAM,MAAM,CAAC,IAAI;AACjD,SAAO,GAAG,KAAK,IAAI,KAAK;AAC1B;AAEA,SAAS,SAAS,MAAc;AAC9B,MAAI,CAAC,KAAM,QAAO;AAElB,QAAM,QAAQ,KAAK,MAAM,GAAG;AAE5B,MAAI,MAAM,MAAM,SAAS,CAAC,MAAM,MAAM,MAAM,MAAM,SAAS,CAAC,EAAG,SAAS,GAAG,GAAG;AAC5E,UAAM,IAAI;AAAA,EACZ;AACA,MAAI,MAAM,SAAS,EAAG,QAAO;AAE7B,SAAO,GAAG,MAAM,KAAK,GAAG,CAAC;AAC3B;;;ACjBA,IAAM,UAAN,cAAsB,MAAM;AAAA,EAC1B,YAAY,SAAiB,OAAe;AAC1C,UAAM,SAAS,KAAK;AACpB,SAAK,OAAO;AAAA,EACd;AACF;;;ACAA,IAAM,aAAyB,CAAI,MAAuB,QAAW;AACnE,MAAI;AACF,QAAI,OAAO,oBAAoB,YAAY;AACzC,aAAO,gBAAgB,GAAG;AAAA,IAC5B;AAAA,EACF,QAAQ;AAAA,EAER;AACA,MAAI;AACF,WAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AAAA,EACvC,QAAQ;AAAA,EAER;AACA,QAAM,IAAI,QAAQ,kCAAkC,OAAO,IAAI,CAAC,GAAG;AACrE;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(r){let g=new Map,o=new Map,v=new Map,m=new Map,a=new Set,E=Math.ceil(r.maxEvents*r.removePercentage),f=async(e,n)=>{let i=typeof n=="function"?await n():n;g.set(e,i);let t=o.get(e);t&&(o.delete(e),t.forEach(s=>s(i)))},l=(e,n)=>{let i=g.get(e);if(i!==void 0)return n(i),()=>{};let t=o.get(e);return t||(t=new Set,o.set(e,t)),t.add(n),()=>{t.delete(n),t.size===0&&o.delete(e)}},N=(e,n)=>{let i=v.get(e),t=i?[...i]:null,s=m.get(e);return s||(s=new Set,m.set(e,s)),s.add(n),t&&t.length>0&&queueMicrotask(()=>{t.forEach(c=>n(c))}),()=>{s.delete(n),s.size===0&&m.delete(e)}},u=(e,n)=>{let i={data:n,timestamp:Date.now()};if(a.delete(e),a.add(e),a.size>r.maxStreams){let c=a.values().next().value;c&&(a.delete(c),v.delete(c))}let t=v.get(e)||[];t.push(i),t.length>r.maxEvents&&(t=t.slice(-(r.maxEvents-E))),v.set(e,t);let s=m.get(e);s&&s.size>0&&s.forEach(c=>c(i))},F=e=>{e?(v.delete(e),m.delete(e),g.delete(e),o.delete(e),a.delete(e)):(v.clear(),m.clear(),o.clear(),g.clear(),a.clear())};return()=>({register:f,onReady:l,emit:u,on:N,clear:F})}(function(){let r=document.currentScript,g={maxStreams:r?.dataset?.maxStreams?Number(r.dataset.maxStreams):50,maxEvents:r?.dataset?.maxEvents?Number(r.dataset.maxEvents):50,removePercentage:r?.dataset?.removePercentage?Number(r.dataset.removePercentage)/100:.5},o=d(g);window.__NF_REGISTRY__=Object.freeze(o())})();
|
package/package.json
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "4.0.0-RC1",
|
|
3
|
+
"name": "@softarc/native-federation-orchestrator",
|
|
4
|
+
"author": "Aukevanoost",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"native-federation",
|
|
7
|
+
"native-federation-orchestrator",
|
|
8
|
+
"micro-frontends"
|
|
9
|
+
],
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/native-federation/orchestrator.git"
|
|
13
|
+
},
|
|
14
|
+
"pnpm": {
|
|
15
|
+
"overrides": {
|
|
16
|
+
"js-yaml": ">=4.1.1"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"semver": "^7.7.1"
|
|
23
|
+
},
|
|
24
|
+
"exports": {
|
|
25
|
+
"./package.json": {
|
|
26
|
+
"default": "./package.json"
|
|
27
|
+
},
|
|
28
|
+
"./quickstart.mjs": {
|
|
29
|
+
"default": "./quickstart.mjs"
|
|
30
|
+
},
|
|
31
|
+
"./init-registry.mjs": {
|
|
32
|
+
"default": "./init-registry.mjs"
|
|
33
|
+
},
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./types/lib/index.d.ts",
|
|
36
|
+
"default": "./fesm2022/@softarc/native-federation-orchestrator.mjs"
|
|
37
|
+
},
|
|
38
|
+
"./sdk": {
|
|
39
|
+
"types": "./types/lib/sdk.index.d.ts",
|
|
40
|
+
"default": "./fesm2022/sdk.mjs"
|
|
41
|
+
},
|
|
42
|
+
"./registry": {
|
|
43
|
+
"types": "./types/lib/registry.index.d.ts",
|
|
44
|
+
"default": "./fesm2022/registry.mjs"
|
|
45
|
+
},
|
|
46
|
+
"./options": {
|
|
47
|
+
"types": "./types/lib/options.index.d.ts",
|
|
48
|
+
"default": "./fesm2022/options.mjs"
|
|
49
|
+
},
|
|
50
|
+
"./audit": {
|
|
51
|
+
"types": "./types/lib/audit.index.d.ts",
|
|
52
|
+
"default": "./fesm2022/audit.mjs"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"typings": "./types/lib/index.d.ts",
|
|
56
|
+
"module": "./fesm2022/@softarc/native-federation-orchestrator.mjs",
|
|
57
|
+
"type": "module"
|
|
58
|
+
}
|