New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lwrjs/app-service

Package Overview
Dependencies
Maintainers
7
Versions
490
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lwrjs/app-service - npm Package Compare versions

Comparing version 0.0.2-alpha17 to 0.0.2-alpha18

40

cjs/moduleProvider/index.js

@@ -11,3 +11,3 @@ "use strict";

function validateSpecifier(specifier) {
return specifier.startsWith(shared_utils_1.BOOTSTRAP_NAMESPACE) || specifier.startsWith(shared_utils_1.VIEW_NAMESPACE);
return specifier.startsWith(shared_utils_1.BOOTSTRAP_NAMESPACE);
}

@@ -26,9 +26,6 @@ class AppService {

async getModuleEntry({ specifier }) {
const appName = specifier.replace(`${shared_utils_1.BOOTSTRAP_NAMESPACE}/`, '');
const { appName } = shared_utils_1.parseSyntheticSpecifier(specifier);
// Validate the root app module specifier
// expected formats:
// - @lwrjs/view/path
// - @lwrjs/bootstrap/app/name
if (specifier.startsWith(shared_utils_1.VIEW_NAMESPACE) ||
(specifier.startsWith(shared_utils_1.BOOTSTRAP_NAMESPACE) && appName === this.appContext.name)) {
// expected format: @lwrjs/bootstrap/app/name[/path/{requestPath}]
if (validateSpecifier(specifier) && appName === this.appContext.name) {
const normalizedSpecifier = specifier.endsWith('/') ? `${specifier}index` : specifier;

@@ -52,17 +49,18 @@ return {

}
// Generate the ABS module
const { root } = this.appContext;
const rootModules = [];
// Get the array of root components in the view
if (specifier.startsWith(shared_utils_1.VIEW_NAMESPACE)) {
const requestPath = specifier.replace(shared_utils_1.VIEW_NAMESPACE, '');
const { metadata } = await this.viewRegistry.getRenderedView({
path: requestPath,
requestPath,
}, runtimeContext);
rootModules.push(...metadata.customElements.map(shared_utils_1.kebabcaseToCamelcase));
// Get the array of root components in the view by request path
// The ABS specifier is in form: "@lwrjs/bootstrap/{appName}[/path/{requestPath}]"
const { requestPath = '/' } = shared_utils_1.parseSyntheticSpecifier(specifier);
// TODO240: If missing, pull the path from config (by appName)
const { metadata } = await this.viewRegistry.getRenderedView({
path: requestPath,
requestPath,
}, runtimeContext);
const rootModules = metadata.customElements.map(shared_utils_1.kebabcaseToCamelcase);
if (!rootModules.includes(this.appContext.root)) {
// If the root application module is not included in the root module array, add it
// This happens when the 'lwr-root' HTML property is used for root insertion (see init.ts)
// TODO240: Pull "root" component (if it exists) from config (by appName)
rootModules.unshift(this.appContext.root);
}
else {
rootModules.push(root);
}
// Generate ABS module
const originalSource = await utils_1.createVirtualSource(rootModules, this.appContext, runtimeContext.format, this.moduleRegistry);

@@ -69,0 +67,0 @@ return {

@@ -24,16 +24,17 @@ "use strict";

const { mode, format } = context;
const { name: appName, root: appRoot, workers, loaderServices, autoBoot = true } = this.appContext;
const { name: configuredAppName, root: appRoot, workers, loaderServices, autoBoot = true, } = this.appContext;
const { type, appName } = shared_utils_1.parseSyntheticSpecifier(specifier);
// Reject the request if the app name (from config) or version (from package.json) do not match
if (appName !== configuredAppName || version !== this.version) {
return;
}
// Check if the resource is JSON for an app
// expected format: @lwrjs/json/my/app
const jsonSpecifier = specifier.replace(`${shared_utils_1.JSON_NAMESPACE}/`, '');
if (specifier.startsWith(shared_utils_1.JSON_NAMESPACE) && jsonSpecifier === appName && version === this.version) {
return await utils_1.createJsonSource({ appName, appRoot, workers, version: this.version }, this.moduleRegistry, this.resourceRegistry, context);
// expected format: @lwrjs/json/{appName}[/path/{requestPath}]
if (type === shared_utils_1.JSON_NAMESPACE) {
return await utils_1.createJsonSource({ specifier, appRoot, workers, version: this.version }, context, this.moduleRegistry, this.resourceRegistry);
}
// Check if the resource is a Client Bootstrap Config
// expected format: @lwrjs/config/my/app
const configSpecifier = specifier.replace(`${shared_utils_1.CONFIG_NAMESPACE}/`, '');
if (specifier.startsWith(shared_utils_1.CONFIG_NAMESPACE) &&
configSpecifier === appName &&
version === this.version) {
return await utils_1.createBootstrapConfig({ appName, appRoot, mode, format, loaderServices, autoBoot, version: this.version }, context, this.moduleRegistry);
// expected format: @lwrjs/config/{appName}[/path/{requestPath}]
if (type === shared_utils_1.CONFIG_NAMESPACE) {
return await utils_1.createBootstrapConfig({ specifier, mode, format, loaderServices, autoBoot }, context, this.moduleRegistry);
}

@@ -40,0 +41,0 @@ }

import { BootstrapRuntimeContext, PublicModuleRegistry, PublicResourceRegistry, ResourceDefinition, RuntimeContext } from '@lwrjs/types';
interface ConfigContext {
appName: string;
appRoot: string;
specifier: string;
mode: string;
format: string;
version: string;
autoBoot: boolean;

@@ -19,3 +17,3 @@ loaderServices: string[];

interface JsonContext {
appName: string;
specifier: string;
appRoot: string;

@@ -35,4 +33,4 @@ workers: {

*/
export declare function createJsonSource({ appName, appRoot, workers: workerSpecifiers, version }: JsonContext, moduleRegistry: PublicModuleRegistry, resourceRegistry: PublicResourceRegistry, context: RuntimeContext): Promise<ResourceDefinition>;
export declare function createJsonSource({ specifier, appRoot, workers: workerSpecifiers, version }: JsonContext, context: RuntimeContext, moduleRegistry: PublicModuleRegistry, resourceRegistry: PublicResourceRegistry): Promise<ResourceDefinition>;
export {};
//# sourceMappingURL=utils.d.ts.map

@@ -21,7 +21,7 @@ "use strict";

async function createBootstrapConfig(context, runtimeContext, moduleRegistry) {
const { appName, mode, format, autoBoot, loaderServices } = context;
const { specifier, mode, format, autoBoot, loaderServices } = context;
let loaderConfigStr = '';
if (format === 'amd') {
// Build specifiers for the ABS module and Root App Component
const bootstrapSpecifier = await shared_utils_1.getVersionedSpecifier(`${shared_utils_1.BOOTSTRAP_NAMESPACE}/${appName}`, moduleRegistry);
const bootstrapSpecifier = await shared_utils_1.getVersionedSpecifier(specifier.replace(shared_utils_1.CONFIG_NAMESPACE, shared_utils_1.BOOTSTRAP_NAMESPACE), moduleRegistry);
// If loader services/hooks are used, add all ABS module dependencies to requiredModules[]

@@ -48,3 +48,3 @@ let requiredModules = [];

return {
specifier: `${shared_utils_1.CONFIG_NAMESPACE}/${appName}`,
specifier,
type: 'application/javascript',

@@ -91,3 +91,3 @@ defer: true,

*/
async function createJsonSource({ appName, appRoot, workers: workerSpecifiers, version }, moduleRegistry, resourceRegistry, context) {
async function createJsonSource({ specifier, appRoot, workers: workerSpecifiers, version }, context, moduleRegistry, resourceRegistry) {
// Build the workers object

@@ -100,3 +100,3 @@ const workers = {};

const [bootstrapModule, rootComponent] = await Promise.all([
createJsonModule(`${shared_utils_1.BOOTSTRAP_NAMESPACE}/${appName}`, moduleRegistry, context),
createJsonModule(specifier.replace(shared_utils_1.JSON_NAMESPACE, shared_utils_1.BOOTSTRAP_NAMESPACE), moduleRegistry, context),
createJsonModule(appRoot, moduleRegistry, context),

@@ -107,3 +107,3 @@ ]);

// Client Bootstrap Config resource
createJsonResource(`${shared_utils_1.CONFIG_NAMESPACE}/${appName}`, version, 'application/javascript', resourceRegistry, context),
createJsonResource(specifier.replace(shared_utils_1.JSON_NAMESPACE, shared_utils_1.CONFIG_NAMESPACE), version, 'application/javascript', resourceRegistry, context),
],

@@ -121,3 +121,3 @@ // Application bootstrap module and root application component

// Import Metadata resource
createJsonResource(`${shared_utils_1.MAPPING_NAMESPACE}/${appName}`, version, 'application/javascript', resourceRegistry, context));
createJsonResource(specifier.replace(shared_utils_1.JSON_NAMESPACE, shared_utils_1.MAPPING_NAMESPACE), version, 'application/javascript', resourceRegistry, context));
}

@@ -128,3 +128,3 @@ // Hash the JSON content

return {
specifier: `${shared_utils_1.JSON_NAMESPACE}/${appName}`,
specifier,
type: 'application/json',

@@ -131,0 +131,0 @@ content: JSON.stringify(json),

@@ -7,3 +7,3 @@ {

},
"version": "0.0.2-alpha17",
"version": "0.0.2-alpha18",
"homepage": "https://lwr.dev/",

@@ -27,5 +27,5 @@ "repository": {

"dependencies": {
"@lwrjs/shared-utils": "0.0.2-alpha17"
"@lwrjs/shared-utils": "0.0.2-alpha18"
},
"gitHead": "462556b16ca6b92f24becb361e510aa1a805e28b"
"gitHead": "9cf922f2e624d3255ab89d39a019be4e88793c61"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc