@lwrjs/app-service
Advanced tools
Comparing version 0.0.2-alpha32 to 0.0.2-alpha33
@@ -7,5 +7,5 @@ import { BootstrapRuntimeEnvironment, NormalizedLwrRoute, ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider } from '@lwrjs/types'; | ||
private moduleRegistry; | ||
constructor({ moduleRegistry, config: { routes } }: ProviderContext); | ||
constructor({ moduleRegistry, config: { routes }, runtimeEnvironment: { lwrVersion } }: ProviderContext); | ||
getResource<T extends ResourceIdentifier>(resource: T, environment: BootstrapRuntimeEnvironment): Promise<ResourceDefinition | undefined>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const path_1 = __importDefault(require("path")); | ||
const shared_utils_1 = require("@lwrjs/shared-utils"); | ||
const utils_1 = require("./utils"); | ||
const identity_1 = require("../identity"); | ||
const utils_js_1 = require("./utils.js"); | ||
const identity_js_1 = require("../identity.js"); | ||
class ClientBootstrapConfigProvider { | ||
constructor({ moduleRegistry, config: { routes } }) { | ||
constructor({ moduleRegistry, config: { routes }, runtimeEnvironment: { lwrVersion } }) { | ||
this.name = 'config-provider'; | ||
this.routesConfig = routes; | ||
this.moduleRegistry = moduleRegistry; | ||
// Get version of this Provider from package.json | ||
const json = shared_utils_1.readFile(path_1.default.join(__dirname, '../../package.json')); | ||
this.version = JSON.parse(json).version; | ||
this.version = lwrVersion; | ||
} | ||
@@ -23,3 +16,3 @@ // Generate the Client Bootstrap Config (globalThis.LWR) script code | ||
const { specifier, version = this.version } = resource; | ||
const appIdentity = identity_1.parseAppIdentity(specifier); | ||
const appIdentity = identity_js_1.parseAppIdentity(specifier); | ||
const route = this.routesConfig.find((r) => r.id === appIdentity?.appName); | ||
@@ -29,3 +22,3 @@ // Reject the request if a route (from config) or version (from package.json) do not match | ||
!route || | ||
!identity_1.isValidResourceIdentity(appIdentity, identity_1.AppResourceEnum.CONFIG) || | ||
!identity_js_1.isValidResourceIdentity(appIdentity, identity_js_1.AppResourceEnum.CONFIG) || | ||
version !== this.version) { | ||
@@ -36,6 +29,6 @@ return; | ||
// expected format: @lwrjs/app-service/{appName}/config/{format}[/path/{requestPath}] | ||
const bootstrapSpecifier = identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.MODULE }); | ||
const { autoBoot, services } = route.bootstrap; | ||
const bootstrapSpecifier = identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.MODULE }); | ||
const { autoBoot, services } = route.bootstrap || shared_utils_1.DEFAULT_LWR_BOOTSTRAP_CONFIG; | ||
const { format, bootstrapImports, bootstrapDynamicImports } = environment; | ||
return await utils_1.createBootstrapConfig({ | ||
return await utils_js_1.createBootstrapConfig({ | ||
specifier: bootstrapSpecifier, | ||
@@ -42,0 +35,0 @@ format, |
@@ -43,2 +43,3 @@ "use strict"; | ||
} | ||
const versionedRequiredmodules = await Promise.all(requiredModules.map((specifier) => shared_utils_1.getVersionedSpecifier(specifier, moduleRegistry))); | ||
// Add AMD Loader Shim properties | ||
@@ -52,3 +53,3 @@ const config = { | ||
// because order is not guaranteed with async | ||
requiredModules: [bootstrapSpecifier, ...requiredModules], | ||
requiredModules: [bootstrapSpecifier, ...versionedRequiredmodules], | ||
}; | ||
@@ -55,0 +56,0 @@ // include any preloadModules |
@@ -1,2 +0,2 @@ | ||
import { BootstrapRuntimeEnvironment, NormalizedLwrRoute, ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider } from '@lwrjs/types'; | ||
import { BootstrapRuntimeEnvironment, NormalizedLwrRoute, ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider, RuntimeParams } from '@lwrjs/types'; | ||
export default class BootstrapJsonProvider implements ResourceProvider { | ||
@@ -9,5 +9,5 @@ name: string; | ||
private viewRegistry; | ||
constructor({ moduleRegistry, resourceRegistry, viewRegistry, config: { routes } }: ProviderContext); | ||
getResource<T extends ResourceIdentifier>(resource: T, environment: BootstrapRuntimeEnvironment): Promise<ResourceDefinition | undefined>; | ||
constructor({ moduleRegistry, resourceRegistry, viewRegistry, config: { routes }, runtimeEnvironment: { lwrVersion }, }: ProviderContext); | ||
getResource<T extends ResourceIdentifier>(resource: T, environment: BootstrapRuntimeEnvironment, params?: RuntimeParams): Promise<ResourceDefinition | undefined>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const path_1 = __importDefault(require("path")); | ||
const shared_utils_1 = require("@lwrjs/shared-utils"); | ||
const utils_1 = require("./utils"); | ||
const identity_1 = require("../identity"); | ||
const utils_js_1 = require("./utils.js"); | ||
const identity_js_1 = require("../identity.js"); | ||
class BootstrapJsonProvider { | ||
constructor({ moduleRegistry, resourceRegistry, viewRegistry, config: { routes } }) { | ||
constructor({ moduleRegistry, resourceRegistry, viewRegistry, config: { routes }, runtimeEnvironment: { lwrVersion }, }) { | ||
this.name = 'json-provider'; | ||
@@ -18,10 +12,8 @@ this.routesConfig = routes; | ||
this.viewRegistry = viewRegistry; | ||
// Get version of this Provider from package.json | ||
const json = shared_utils_1.readFile(path_1.default.join(__dirname, '../../package.json')); | ||
this.version = JSON.parse(json).version; | ||
this.version = lwrVersion; | ||
} | ||
// Generate the Client Bootstrap Config (globalThis.LWR) script code | ||
async getResource(resource, environment) { | ||
async getResource(resource, environment, params) { | ||
const { specifier, version = this.version } = resource; | ||
const appIdentity = identity_1.parseAppIdentity(specifier); | ||
const appIdentity = identity_js_1.parseAppIdentity(specifier); | ||
const route = this.routesConfig.find((r) => r.id === appIdentity?.appName); | ||
@@ -31,3 +23,3 @@ // Reject the request if a route (from config) or version (from package.json) do not match | ||
!route || | ||
!identity_1.isValidResourceIdentity(appIdentity, identity_1.AppResourceEnum.JSON) || | ||
!identity_js_1.isValidResourceIdentity(appIdentity, identity_js_1.AppResourceEnum.JSON) || | ||
version !== this.version) { | ||
@@ -38,6 +30,6 @@ return; | ||
const { workers } = route.bootstrap; | ||
const rootComponents = await identity_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
const rootComponents = await identity_js_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
// Check if the resource is JSON for an app | ||
// expected format: @lwrjs/app-service/{appName}/json/{format}[/path/{requestPath}] | ||
return await utils_1.createJsonSource({ appIdentity, rootComponents, workers, version: this.version }, environment, this.moduleRegistry, this.resourceRegistry); | ||
return await utils_js_1.createJsonSource({ appIdentity, rootComponents, workers, version: this.version }, this.moduleRegistry, this.resourceRegistry, environment, params); | ||
} | ||
@@ -44,0 +36,0 @@ } |
@@ -1,3 +0,3 @@ | ||
import { PublicModuleRegistry, PublicResourceRegistry, ResourceDefinition, RuntimeEnvironment } from '@lwrjs/types'; | ||
import { AppResourceIdentity } from '../identity'; | ||
import { PublicModuleRegistry, PublicResourceRegistry, ResourceDefinition, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types'; | ||
import { AppResourceIdentity } from '../identity.js'; | ||
interface JsonContext { | ||
@@ -19,4 +19,4 @@ appIdentity: AppResourceIdentity; | ||
*/ | ||
export declare function createJsonSource({ appIdentity, rootComponents, workers: workerSpecifiers, version }: JsonContext, environment: RuntimeEnvironment, moduleRegistry: PublicModuleRegistry, resourceRegistry: PublicResourceRegistry): Promise<ResourceDefinition>; | ||
export declare function createJsonSource({ appIdentity, rootComponents, workers: workerSpecifiers, version }: JsonContext, moduleRegistry: PublicModuleRegistry, resourceRegistry: PublicResourceRegistry, environment: RuntimeEnvironment, params?: RuntimeParams): Promise<ResourceDefinition>; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -5,3 +5,3 @@ "use strict"; | ||
const shared_utils_1 = require("@lwrjs/shared-utils"); | ||
const identity_1 = require("../identity"); | ||
const identity_js_1 = require("../identity.js"); | ||
// Given a specifier and version, return the JSON serialized Resource data | ||
@@ -13,3 +13,3 @@ function createJsonResource(specifier, version, type, resourceRegistry, runtimeEnvironment) { | ||
// Given a specifier and resource type, return the JSON serialized Module data | ||
async function createJsonModule(specifier, moduleRegistry, environment) { | ||
async function createJsonModule(specifier, moduleRegistry, environment, params) { | ||
const { version } = await moduleRegistry.getModuleEntry({ specifier }); | ||
@@ -30,3 +30,3 @@ const { namespace, name } = shared_utils_1.explodeSpecifier(specifier); | ||
links: { | ||
self: moduleRegistry.resolveModuleUri(moduleIdentifier, environment, ownHash), | ||
self: moduleRegistry.resolveModuleUri(moduleIdentifier, environment, params, ownHash), | ||
}, | ||
@@ -43,16 +43,16 @@ }; | ||
*/ | ||
async function createJsonSource({ appIdentity, rootComponents, workers: workerSpecifiers, version }, environment, moduleRegistry, resourceRegistry) { | ||
async function createJsonSource({ appIdentity, rootComponents, workers: workerSpecifiers, version }, moduleRegistry, resourceRegistry, environment, params) { | ||
// Build the workers object | ||
const workers = {}; | ||
Object.entries(workerSpecifiers).forEach(async ([id, s]) => { | ||
workers[id] = await createJsonModule(s, moduleRegistry, environment); | ||
workers[id] = await createJsonModule(s, moduleRegistry, environment, params); | ||
}); | ||
// Application bootstrap module and root application component(s) | ||
const bootstrapSpecifier = identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.MODULE }); | ||
const bootstrapSpecifier = identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.MODULE }); | ||
const modules = await Promise.all([ | ||
createJsonModule(bootstrapSpecifier, moduleRegistry, environment), | ||
...rootComponents.map((c) => createJsonModule(c, moduleRegistry, environment)), | ||
createJsonModule(bootstrapSpecifier, moduleRegistry, environment, params), | ||
...rootComponents.map((c) => createJsonModule(c, moduleRegistry, environment, params)), | ||
]); | ||
// All formats | ||
const configSpecifier = identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.CONFIG }); | ||
const configSpecifier = identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.CONFIG }); | ||
const json = { | ||
@@ -69,3 +69,3 @@ resources: [ | ||
if (environment.format === 'amd') { | ||
const mappingSpecifier = identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.MAPPING }); | ||
const mappingSpecifier = identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.MAPPING }); | ||
json.resources.push( | ||
@@ -80,3 +80,3 @@ // Loader shim resource | ||
// Return a resource | ||
const jsonSpecifier = identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.JSON }); | ||
const jsonSpecifier = identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.JSON }); | ||
return { | ||
@@ -83,0 +83,0 @@ specifier: jsonSpecifier, |
@@ -1,2 +0,2 @@ | ||
import { BootstrapRuntimeEnvironment, ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider } from '@lwrjs/types'; | ||
import { BootstrapRuntimeEnvironment, ProviderContext, ResourceDefinition, ResourceIdentifier, ResourceProvider, RuntimeParams } from '@lwrjs/types'; | ||
/** | ||
@@ -13,4 +13,4 @@ * The Mapping Resource Provider | ||
constructor(providerContext: ProviderContext); | ||
getResource<T extends ResourceIdentifier>({ specifier }: T, environment: BootstrapRuntimeEnvironment): Promise<ResourceDefinition | undefined>; | ||
getResource<T extends ResourceIdentifier>({ specifier }: T, environment: BootstrapRuntimeEnvironment, params?: RuntimeParams): Promise<ResourceDefinition | undefined>; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const utils_1 = require("./utils"); | ||
const identity_1 = require("../identity"); | ||
const utils_js_1 = require("./utils.js"); | ||
const identity_js_1 = require("../identity.js"); | ||
/** | ||
@@ -19,8 +19,8 @@ * The Mapping Resource Provider | ||
// Get a JSON mapping resource | ||
async getResource({ specifier }, environment) { | ||
async getResource({ specifier }, environment, params) { | ||
// Check for a valid App ID and corresponding route config object | ||
const appIdentity = identity_1.parseAppIdentity(specifier); | ||
const appIdentity = identity_js_1.parseAppIdentity(specifier); | ||
const route = this.routesConfig.find((r) => r.id === appIdentity?.appName); | ||
// Reject the request if there is no matching route (from config) | ||
if (!appIdentity || !route || !identity_1.isValidResourceIdentity(appIdentity, identity_1.AppResourceEnum.MAPPING)) { | ||
if (!appIdentity || !route || !identity_js_1.isValidResourceIdentity(appIdentity, identity_js_1.AppResourceEnum.MAPPING)) { | ||
return; | ||
@@ -30,9 +30,9 @@ } | ||
const bootstrapImports = environment.bootstrapImports || [ | ||
identity_1.getAppSpecifer({ ...appIdentity, resourceType: identity_1.AppResourceEnum.MODULE }), | ||
identity_js_1.getAppSpecifer({ ...appIdentity, resourceType: identity_js_1.AppResourceEnum.MODULE }), | ||
]; | ||
const rootComponents = await identity_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
const content = await utils_1.createJsonSource( | ||
const rootComponents = await identity_js_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
const content = await utils_js_1.createJsonSource( | ||
// The import metadata crawls the dependencies of | ||
// the root app component(s) and the app bootstrap module | ||
[...rootComponents, ...bootstrapImports], environment, this.moduleRegistry); | ||
[...rootComponents, ...bootstrapImports], this.moduleRegistry, environment, params); | ||
return { | ||
@@ -39,0 +39,0 @@ specifier, |
@@ -1,2 +0,2 @@ | ||
import { PublicModuleRegistry, RuntimeEnvironment } from '@lwrjs/types'; | ||
import { PublicModuleRegistry, RuntimeEnvironment, RuntimeParams } from '@lwrjs/types'; | ||
declare type ImportMetadata = { | ||
@@ -18,4 +18,4 @@ [specifier: string]: string; | ||
*/ | ||
export declare function createJsonSource<R extends RuntimeEnvironment>(specifiers: string[], environment: R, registry: PublicModuleRegistry): Promise<string>; | ||
export declare function createJsonSource<R extends RuntimeEnvironment>(specifiers: string[], registry: PublicModuleRegistry, environment: R, params?: RuntimeParams): Promise<string>; | ||
export {}; | ||
//# sourceMappingURL=utils.d.ts.map |
@@ -24,3 +24,3 @@ "use strict"; | ||
// This does an in place transformation of the allData object | ||
async function buildImportMetadata(allData, moduleRef, runtimeEnvironment, registry) { | ||
async function buildImportMetadata(allData, moduleRef, registry, runtimeEnvironment, runtimeParams) { | ||
// Ensure the module has NOT already been processed (i.e. exists in allData) | ||
@@ -36,7 +36,7 @@ if (allData[moduleRef.specifier]) { | ||
// Create a URL mapping for this specifier | ||
const uri = registry.resolveModuleUri(moduleRef, runtimeEnvironment, moduleDef.ownHash); | ||
const uri = registry.resolveModuleUri(moduleRef, runtimeEnvironment, runtimeParams, moduleDef.ownHash); | ||
allData[moduleRef.specifier] = uri; | ||
// Recursively calculate the import metadata for all child dependencies | ||
const dependencies = moduleDef.moduleRecord.imports || []; | ||
await Promise.all(dependencies.map((d) => buildImportMetadata(allData, d, runtimeEnvironment, registry))); | ||
await Promise.all(dependencies.map((d) => buildImportMetadata(allData, d, registry, runtimeEnvironment, runtimeParams))); | ||
} | ||
@@ -85,7 +85,7 @@ /** | ||
// Build import metadata for the given specifiers | ||
async function getImportMetadata(specifiers, runtimeEnvironment, registry) { | ||
async function getImportMetadata(specifiers, registry, runtimeEnvironment, runtimeParams) { | ||
const allData = {}; | ||
// Get the metadata for the specifiers | ||
const moduleRefs = await Promise.all(specifiers.map((s) => getModuleIdFromSpecifier(s, registry))); | ||
await Promise.all(moduleRefs.map((r) => buildImportMetadata(allData, r, runtimeEnvironment, registry))); | ||
await Promise.all(moduleRefs.map((r) => buildImportMetadata(allData, r, registry, runtimeEnvironment, runtimeParams))); | ||
// Process and return the metadata | ||
@@ -101,4 +101,4 @@ return processImportMetadata(allData); | ||
*/ | ||
async function createJsonSource(specifiers, environment, registry) { | ||
const imports = await getImportMetadata(specifiers, environment, registry); | ||
async function createJsonSource(specifiers, registry, environment, params) { | ||
const imports = await getImportMetadata(specifiers, registry, environment, params); | ||
return JSON.stringify({ | ||
@@ -105,0 +105,0 @@ imports, |
@@ -9,3 +9,3 @@ import { ModuleCompiled, ModuleEntry, ModuleProvider, ModuleSource, NormalizedLwrRoute, ProviderContext, AbstractModuleId } from '@lwrjs/types'; | ||
private hmrEnabled; | ||
constructor({ compiler, viewRegistry, config: { routes }, runtimeEnvironment: { hmrEnabled }, }: ProviderContext); | ||
constructor({ compiler, viewRegistry, config: { routes }, runtimeEnvironment: { hmrEnabled, lwrVersion }, }: ProviderContext); | ||
getModuleEntry({ specifier }: AbstractModuleId): Promise<ModuleEntry | undefined>; | ||
@@ -12,0 +12,0 @@ getModuleSource<R extends AbstractModuleId>({ specifier, namespace, name, }: R): Promise<ModuleSource | undefined>; |
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/* eslint-disable @typescript-eslint/no-unused-vars */ | ||
const path_1 = __importDefault(require("path")); | ||
const shared_utils_1 = require("@lwrjs/shared-utils"); | ||
const utils_1 = require("./utils"); | ||
const identity_1 = require("../identity"); | ||
const utils_js_1 = require("./utils.js"); | ||
const identity_js_1 = require("../identity.js"); | ||
// Validation gating methods | ||
function validateSpecifier(specifier) { | ||
const appIdentity = identity_1.parseAppIdentity(specifier); | ||
return !!appIdentity && identity_1.isValidResourceIdentity(appIdentity, identity_1.AppResourceEnum.MODULE); | ||
const appIdentity = identity_js_1.parseAppIdentity(specifier); | ||
return !!appIdentity && identity_js_1.isValidResourceIdentity(appIdentity, identity_js_1.AppResourceEnum.MODULE); | ||
} | ||
class AppModuleProvider { | ||
constructor({ compiler, viewRegistry, config: { routes }, runtimeEnvironment: { hmrEnabled }, }) { | ||
constructor({ compiler, viewRegistry, config: { routes }, runtimeEnvironment: { hmrEnabled, lwrVersion }, }) { | ||
this.name = 'app-provider'; | ||
@@ -24,5 +19,3 @@ this.hmrEnabled = false; | ||
this.hmrEnabled = hmrEnabled; | ||
// Get version of this Provider from package.json | ||
const json = shared_utils_1.readFile(path_1.default.join(__dirname, '../../package.json')); | ||
this.version = JSON.parse(json).version; | ||
this.version = lwrVersion; | ||
} | ||
@@ -45,4 +38,4 @@ async getModuleEntry({ specifier }) { | ||
async getModuleSource({ specifier, namespace, name, }) { | ||
const appIdentity = identity_1.parseAppIdentity(specifier); | ||
if (!appIdentity || !identity_1.isValidResourceIdentity(appIdentity, identity_1.AppResourceEnum.MODULE)) { | ||
const appIdentity = identity_js_1.parseAppIdentity(specifier); | ||
if (!appIdentity || !identity_js_1.isValidResourceIdentity(appIdentity, identity_js_1.AppResourceEnum.MODULE)) { | ||
return; | ||
@@ -57,5 +50,5 @@ } | ||
// Get the array of root components for this route | ||
const rootComponents = await identity_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
const rootComponents = await identity_js_1.getRootComponents(appIdentity, route, this.viewRegistry); | ||
// Generate ABS module | ||
const originalSource = await utils_1.createVirtualSource(appIdentity.format, this.hmrEnabled, rootComponents, route.bootstrap); | ||
const originalSource = await utils_js_1.createVirtualSource(appIdentity.format, this.hmrEnabled, rootComponents, route.bootstrap); | ||
return { | ||
@@ -62,0 +55,0 @@ id: moduleEntry.id, |
@@ -1,2 +0,2 @@ | ||
import { NormalizedLwrAppBootstrapConfig, ModuleFormat } from '@lwrjs/types'; | ||
import { LwrAppBootstrapConfig, ModuleFormat } from '@lwrjs/types'; | ||
/** | ||
@@ -12,3 +12,3 @@ * Create the virtual source for the application module | ||
*/ | ||
export declare function createVirtualSource(format: ModuleFormat, hmrEnabled: boolean, rootComponents: string[], { init: initModule, locker, services, syntheticShadow, workers }: NormalizedLwrAppBootstrapConfig): Promise<string>; | ||
export declare function createVirtualSource(format: ModuleFormat, hmrEnabled: boolean, rootComponents: string[], { init: initModule, locker, services, syntheticShadow, workers, }?: Required<LwrAppBootstrapConfig>): Promise<string>; | ||
//# sourceMappingURL=utils.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.createVirtualSource = void 0; | ||
const shared_utils_1 = require("@lwrjs/shared-utils"); | ||
function getDefaultImportName(service) { | ||
@@ -28,3 +29,3 @@ return `loaderService_${service.replace(/\//gi, '_').replace(/@/gi, '')}`; | ||
*/ | ||
async function createVirtualSource(format, hmrEnabled, rootComponents, { init: initModule, locker, services, syntheticShadow, workers }) { | ||
async function createVirtualSource(format, hmrEnabled, rootComponents, { init: initModule, locker, services, syntheticShadow, workers, } = shared_utils_1.DEFAULT_LWR_BOOTSTRAP_CONFIG) { | ||
const isAMD = format === 'amd'; | ||
@@ -34,3 +35,3 @@ const isESM = format === 'esm'; | ||
const importRootModules = rootComponents.map((wc, index) => `import Ctor${index} from '${wc}'`); | ||
const workerCmps = Object.values(workers); | ||
const workerCmps = workers ? Object.values(workers) : []; | ||
return [ | ||
@@ -62,3 +63,3 @@ '/* This module is generated */', | ||
`const rootCmps = ${JSON.stringify(rootComponents)}; | ||
const appRoot = globalThis.LWR.rootComponent; | ||
const appRoot = globalThis.LWR.rootComponent; | ||
if (!appRoot || rootCmps.includes(appRoot)) { | ||
@@ -65,0 +66,0 @@ ${rootComponents |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "0.0.2-alpha32", | ||
"version": "0.0.2-alpha33", | ||
"homepage": "https://lwr.dev/", | ||
@@ -19,6 +19,49 @@ "repository": { | ||
"scripts": { | ||
"clean": "rimraf cjs/" | ||
"clean": "rimraf cjs/ es/ *.tsbuildinfo", | ||
"build": "tsc -p tsconfig.cjs.json" | ||
}, | ||
"types": "build/es/index.d.ts", | ||
"type": "module", | ||
"main": "index.js", | ||
"exports": { | ||
"./configProvider": { | ||
"import": "./build/es/configProvider/index.js", | ||
"require": "./cjs/configProvider/index.js" | ||
}, | ||
"./cjs/configProvider": { | ||
"import": "./build/es/configProvider/index.js", | ||
"require": "./cjs/configProvider/index.js" | ||
}, | ||
"./jsonProvider": { | ||
"import": "./build/es/jsonProvider/index.js", | ||
"require": "./cjs/jsonProvider/index.js" | ||
}, | ||
"./cjs/jsonProvider": { | ||
"import": "./build/es/jsonProvider/index.js", | ||
"require": "./cjs/jsonProvider/index.js" | ||
}, | ||
"./mappingProvider": { | ||
"import": "./build/es/mappingProvider/index.js", | ||
"require": "./cjs/mappingProvider/index.js" | ||
}, | ||
"./cjs/mappingProvider": { | ||
"import": "./build/es/mappingProvider/index.js", | ||
"require": "./cjs/mappingProvider/index.js" | ||
}, | ||
"./moduleProvider": { | ||
"import": "./build/es/moduleProvider/index.js", | ||
"require": "./cjs/moduleProvider/index.js" | ||
}, | ||
"./cjs/moduleProvider": { | ||
"import": "./build/es/moduleProvider/index.js", | ||
"require": "./cjs/moduleProvider/index.js" | ||
}, | ||
"./cjs/identity": { | ||
"import": "./build/es/identity.js", | ||
"require": "./cjs/identity/index.js" | ||
} | ||
}, | ||
"files": [ | ||
"build/**/*.js", | ||
"build/**/*.d.ts", | ||
"cjs/**/*.js", | ||
@@ -28,5 +71,11 @@ "cjs/**/*.d.ts" | ||
"dependencies": { | ||
"@lwrjs/shared-utils": "0.0.2-alpha32" | ||
"@lwrjs/shared-utils": "0.0.2-alpha33" | ||
}, | ||
"gitHead": "2d07a298719f056b7ce9c16788f6e57ab64723dd" | ||
"devDependencies": { | ||
"@lwrjs/types": "0.0.2-alpha33" | ||
}, | ||
"engines": { | ||
"node": ">=14.15.1 <15" | ||
}, | ||
"gitHead": "092bdb8a5e7d34f0afb4737c8f71bf345d6f10d4" | ||
} |
82675
39
1695
Yes
1
+ Added@lwrjs/shared-utils@0.0.2-alpha33(transitive)
+ Addedtypescript@4.9.5(transitive)
- Removed@lwrjs/shared-utils@0.0.2-alpha32(transitive)