vanilla-native-federation
Advanced tools
Comparing version 0.7.0 to 0.8.0
@@ -1,6 +0,5 @@ | ||
import type { ExposedModuleHandler } from "./exposed-module"; | ||
import type { ExternalsHandler } from "./externals"; | ||
import type { ImportMapHandler } from "./import-map"; | ||
import type { LogHandler } from "./logging"; | ||
import type { RemoteInfoHandler } from "./remote-info"; | ||
import type { SharedInfoHandler } from "./shared-info/shared-info.contract"; | ||
import type { NfCache, StorageHandler } from "./storage/storage.contract"; | ||
@@ -10,7 +9,6 @@ type Handlers = { | ||
remoteInfoHandler: RemoteInfoHandler; | ||
sharedInfoHandler: SharedInfoHandler; | ||
externalsHandler: ExternalsHandler; | ||
logHandler: LogHandler; | ||
storageHandler: StorageHandler<NfCache>; | ||
exposedModuleHandler: ExposedModuleHandler; | ||
}; | ||
export { Handlers }; |
import type { Config } from "../utils"; | ||
import type { Handlers } from "./handlers.contract"; | ||
import type { NfCache } from "./storage/storage.contract"; | ||
declare const resolveHandlers: <TCache extends NfCache>({ storageType, cache, logger, logLevel }: Config<TCache>) => Handlers; | ||
declare const resolveHandlers: <TCache extends NfCache>(config: Config<TCache>) => Handlers; | ||
export { resolveHandlers }; |
import type { ImportMap } from '@softarc/native-federation-runtime'; | ||
import type { Remote } from '../remote-info/remote-info.contract'; | ||
import type { RemoteName } from '../remote-info'; | ||
type ImportMapHandler = { | ||
toImportMap: (remoteInfo: Remote, remoteName?: string) => ImportMap; | ||
createEmpty: () => ImportMap; | ||
merge: (maps: ImportMap[]) => ImportMap; | ||
create: (from?: ImportMap) => ImportMap; | ||
fromStorage: (manifest: RemoteName[]) => ImportMap; | ||
addToDOM: (map: ImportMap) => ImportMap; | ||
}; | ||
export { Imports } from '@softarc/native-federation-runtime'; | ||
export { Imports, Scopes } from '@softarc/native-federation-runtime'; | ||
export { ImportMapHandler, ImportMap }; |
import type { ImportMapHandler } from "./import-map.contract"; | ||
import type { SharedInfoHandler } from "../shared-info/shared-info.contract"; | ||
declare const importMapHandlerFactory: (sharedInfoHandler: SharedInfoHandler) => ImportMapHandler; | ||
import type { ExternalsHandler } from "../externals/externals.contract"; | ||
import type { RemoteInfoHandler } from "../remote-info"; | ||
declare const importMapHandlerFactory: (externalsHandler: ExternalsHandler, remoteInfoHandler: RemoteInfoHandler) => ImportMapHandler; | ||
export { importMapHandlerFactory }; |
export * from './logging'; | ||
export * from './storage'; | ||
export * from './import-map'; | ||
export * from './shared-info'; | ||
export * from './exposed-module'; | ||
export * from './externals'; | ||
export * from './remote-info'; |
export * from './noop.logger'; | ||
export * from './console.logger'; | ||
export * from './log.contract'; |
@@ -1,3 +0,4 @@ | ||
import { type LogHandler, type LogType } from "./log.contract"; | ||
declare const logHandlerFactory: (minLevel: LogType, logger: LogHandler) => LogHandler; | ||
import { type LogHandler } from "./log.contract"; | ||
import type { LoggingConfig } from "../../utils/config/config.contract"; | ||
declare const logHandlerFactory: ({ logger, logLevel }: LoggingConfig) => LogHandler; | ||
export { logHandlerFactory }; |
@@ -1,11 +0,23 @@ | ||
import type { FederationInfo } from '@softarc/native-federation-runtime'; | ||
import type { ExposesInfo, FederationInfo } from '@softarc/native-federation-runtime'; | ||
type RemoteName = string; | ||
type RemoteEntry = string; | ||
type RemoteModule = { | ||
moduleName: string; | ||
url: string; | ||
}; | ||
type RemoteInfo = { | ||
remoteName: string; | ||
scopeUrl: string; | ||
exposes: RemoteModule[]; | ||
}; | ||
type RemoteInfoHandler = { | ||
addToCache: (remote: Remote, remoteName?: string) => Remote; | ||
getFromCache: (remoteEntryUrl?: string, remoteName?: string) => Promise<Remote>; | ||
getFromEntry: (remoteEntryUrl: string) => Promise<Remote>; | ||
toStorage: (remote: { | ||
name: string; | ||
exposes: ExposesInfo[]; | ||
}, baseUrl: string) => RemoteInfo; | ||
fromStorage: ((remoteName: string) => RemoteInfo) & ((remoteName: string, exposedModule: string) => RemoteModule); | ||
getFromEntry: (remoteEntryUrl: string) => Promise<FederationInfo>; | ||
toScope: (remoteEntry: RemoteEntry) => string; | ||
}; | ||
type Remote = FederationInfo & { | ||
baseUrl: string; | ||
}; | ||
export { Remote, RemoteInfoHandler }; | ||
export { RemoteInfo, RemoteModule, RemoteName, RemoteEntry, RemoteInfoHandler }; | ||
export type { ExposesInfo, FederationInfo } from '@softarc/native-federation-runtime'; |
import type { RemoteInfoHandler } from "./remote-info.contract"; | ||
import type { SharedInfoHandler } from "../shared-info"; | ||
import type { NfCache, StorageHandler } from "../storage/storage.contract"; | ||
declare const remoteInfoHandlerFactory: <TCache extends NfCache>(storage: StorageHandler<TCache>, sharedInfoHandler: SharedInfoHandler) => RemoteInfoHandler; | ||
declare const remoteInfoHandlerFactory: <TCache extends NfCache>(storageHandler: StorageHandler<TCache>) => RemoteInfoHandler; | ||
export { remoteInfoHandlerFactory, RemoteInfoHandler }; |
@@ -1,2 +0,3 @@ | ||
import type { Remote } from '../remote-info/remote-info.contract'; | ||
import type { RemoteInfo } from '../remote-info'; | ||
import type { Version } from '../version/version.contract'; | ||
declare const nfNamespace = "__NATIVE_FEDERATION__"; | ||
@@ -7,5 +8,6 @@ /** | ||
type NfCache = { | ||
externals: Record<string, string>; | ||
remoteNamesToRemote: Record<string, Remote>; | ||
baseUrlToRemoteNames: Record<string, string>; | ||
externals: { | ||
global: Record<string, Version>; | ||
} & Record<string, Record<string, Version>>; | ||
remotes: Record<string, RemoteInfo>; | ||
}; | ||
@@ -12,0 +14,0 @@ type StorageEntry<TValue> = { |
@@ -1,3 +0,4 @@ | ||
import type { StorageHandler, NfCache, StorageEntryCreator } from "./storage.contract"; | ||
declare function storageHandlerFactory<TCache extends NfCache>(cache: TCache, cacheEntryCreator: StorageEntryCreator): StorageHandler<TCache>; | ||
import type { StorageHandler, NfCache } from "./storage.contract"; | ||
import type { StorageConfig } from "../../utils/config/config.contract"; | ||
declare const storageHandlerFactory: <TCache extends NfCache>({ cache, toStorageEntry }: StorageConfig<TCache>) => StorageHandler<TCache>; | ||
export { storageHandlerFactory }; |
@@ -6,5 +6,5 @@ import type { StepFactories } from "./steps/steps.contract"; | ||
}) => Promise<{ | ||
load: (optionsOrRemoteName: import("./handlers").ExposedModule | string, exposedModule?: string) => Promise<any>; | ||
importMap: import("@softarc/native-federation-runtime").ImportMap; | ||
load: (remoteName: string, exposedModule: string) => Promise<any>; | ||
manifest: Record<import("./handlers").RemoteName, import("./handlers").RemoteEntry>; | ||
}>; | ||
export { initFederation }; |
@@ -1,9 +0,8 @@ | ||
import type { ExposedModule } from "../handlers/exposed-module/exposed-module.contract"; | ||
import type { Handlers } from "../handlers/handlers.contract"; | ||
import type { ImportMap } from "../handlers/import-map/import-map.contract"; | ||
type ExposeModuleLoader = (importMap: ImportMap) => Promise<{ | ||
load: (optionsOrRemoteName: ExposedModule | string, exposedModule?: string) => Promise<any>; | ||
importMap: ImportMap; | ||
import type { RemoteEntry, RemoteName } from "../handlers/remote-info/remote-info.contract"; | ||
type ExposeModuleLoader = (manifest: Record<RemoteName, RemoteEntry>) => Promise<{ | ||
load: (remoteName: string, exposedModule: string) => Promise<any>; | ||
manifest: Record<RemoteName, RemoteEntry>; | ||
}>; | ||
declare const exposeModuleLoader: ({ remoteInfoHandler, logHandler, exposedModuleHandler }: Handlers) => ExposeModuleLoader; | ||
declare const exposeModuleLoader: ({ logHandler, remoteInfoHandler }: Handlers) => ExposeModuleLoader; | ||
export { ExposeModuleLoader, exposeModuleLoader }; |
@@ -1,5 +0,2 @@ | ||
export { FetchImportMaps } from "./1-fetch-import-maps"; | ||
export { MergeImportMaps } from "./2-merge-import-maps"; | ||
export { UpdateDOM } from "./3-update-dom"; | ||
export { ExposeModuleLoader } from "./4-expose-module-loader"; | ||
export * from './steps.contract'; | ||
export { StepFactory } from './steps.contract'; |
@@ -1,4 +0,4 @@ | ||
import type { FetchImportMaps } from "./1-fetch-import-maps"; | ||
import type { MergeImportMaps } from "./2-merge-import-maps"; | ||
import type { UpdateDOM } from "./3-update-dom"; | ||
import type { FetchManifest } from "./1-fetch-manifest"; | ||
import type { FetchRemoteEntries } from "./2-fetch-remote-entries"; | ||
import type { CreateImportMap } from "./3-create-import-map"; | ||
import type { ExposeModuleLoader } from "./4-expose-module-loader"; | ||
@@ -8,7 +8,7 @@ import type { Handlers } from "../handlers/handlers.contract"; | ||
type StepFactories = { | ||
fetchImportMaps: StepFactory<FetchImportMaps>; | ||
mergeImportMaps: StepFactory<MergeImportMaps>; | ||
updateDOM: StepFactory<UpdateDOM>; | ||
fetchManifest: StepFactory<FetchManifest>; | ||
fetchRemoteEntries: StepFactory<FetchRemoteEntries>; | ||
createImportMap: StepFactory<CreateImportMap>; | ||
exposeModuleLoader: StepFactory<ExposeModuleLoader>; | ||
}; | ||
export { StepFactories, StepFactory }; |
@@ -5,7 +5,7 @@ import type { StepFactories } from "./steps.contract"; | ||
declare const resolver: <TCache extends NfCache>(config: Config<TCache>, stepsOverride?: Partial<StepFactories>) => { | ||
fetchImportMaps: import("./1-fetch-import-maps").FetchImportMaps; | ||
mergeImportMaps: import("./2-merge-import-maps").MergeImportMaps; | ||
updateDOM: import("./3-update-dom").UpdateDOM; | ||
fetchManifest: import("./1-fetch-manifest").FetchManifest; | ||
fetchRemoteEntries: import("./2-fetch-remote-entries").FetchRemoteEntries; | ||
createImportMap: import("./3-create-import-map").CreateImportMap; | ||
exposeModuleLoader: import("./4-expose-module-loader").ExposeModuleLoader; | ||
}; | ||
export { resolver }; |
import type { LogHandler, LogType } from "../../handlers/logging/log.contract"; | ||
import type { NfCache, StorageEntryCreator } from "../../handlers/storage/storage.contract"; | ||
type Config<TCache extends NfCache = NfCache> = { | ||
type BuilderType = 'vite' | 'default'; | ||
type StorageConfig<TCache extends NfCache = NfCache> = { | ||
cache: TCache; | ||
storageType: StorageEntryCreator; | ||
toStorageEntry: StorageEntryCreator; | ||
}; | ||
type LoggingConfig = { | ||
logger: LogHandler; | ||
logLevel: LogType; | ||
}; | ||
export { Config }; | ||
type BuilderConfig = { | ||
builderType: BuilderType; | ||
}; | ||
type Config<TCache extends NfCache = NfCache> = StorageConfig<TCache> & LoggingConfig & BuilderConfig; | ||
export { Config, StorageConfig, LoggingConfig, BuilderConfig }; |
{ | ||
"version": "0.7.0", | ||
"version": "0.8.0", | ||
"name": "vanilla-native-federation", | ||
@@ -21,9 +21,12 @@ "author": "aukevanoost", | ||
"types": "./index.d.ts", | ||
"esm2022": "./esm2022/vanilla-native-federation.mjs", | ||
"esm": "./esm2022/vanilla-native-federation.mjs", | ||
"default": "./fesm2022/vanilla-native-federation.mjs" | ||
}, | ||
"./plugins/logging": { | ||
"types": "./plugins/logging/index.d.ts", | ||
"esm": "./esm2022/vanilla-native-federation-logging.mjs", | ||
"default": "./fesm2022/vanilla-native-federation-logging.mjs" | ||
}, | ||
"./plugins/storage": { | ||
"types": "./plugins/storage/index.d.ts", | ||
"esm2022": "./esm2022/vanilla-native-federation-storage.mjs", | ||
"esm": "./esm2022/vanilla-native-federation-storage.mjs", | ||
@@ -30,0 +33,0 @@ "default": "./fesm2022/vanilla-native-federation-storage.mjs" |
@@ -58,3 +58,3 @@ # vanilla-native-federation | ||
The `initFederation` will return the importMap object that was appended to the HTML page together with a `load()` callback, this function can load remote modules using the imported dependencies from the importMap. The `load()` callback returns a `Promise<any>` that represents the remote module that was retrieved. | ||
The `initFederation` will return the importMap object that was appended to the HTML page together with a `load()` callback, this function can load remote modules using the imported dependencies from the importMap. The `load()` callback returns a `Promise<unknown>` that represents the remote module that was retrieved. | ||
@@ -188,3 +188,4 @@ Below are the types of the exposed functions: | ||
``` | ||
import { initFederation, consoleLogger, noopLogger } from 'vanilla-native-federation'; | ||
import { initFederation, noopLogger } from 'vanilla-native-federation'; | ||
import { consoleLogger } from 'vanilla-native-federation/plugins/logging'; | ||
@@ -191,0 +192,0 @@ (() => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
101592
1259
269
94