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

@microsoft/mgt-element

Package Overview
Dependencies
Maintainers
2
Versions
835
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/mgt-element - npm Package Compare versions

Comparing version 2.2.0 to 2.2.1-preview.10e98e4

5

dist/es6/components/templatedComponent.js

@@ -89,6 +89,7 @@ /**

div.dataset.generated = 'template';
TemplateHelper.renderTemplate(div, this.templates[templateType], context, Object.assign({}, this.templateContext));
const dataContext = Object.assign(Object.assign({}, context), this.templateContext);
TemplateHelper.renderTemplate(div, this.templates[templateType], dataContext);
this.appendChild(div);
this._renderedTemplates[slotName] = { context, slot: div };
this.fireCustomEvent('templateRendered', { templateType, context, element: div });
this.fireCustomEvent('templateRendered', { templateType, context: dataContext, element: div });
return template;

@@ -95,0 +96,0 @@ }

@@ -20,10 +20,2 @@ /**

/**
* The base URL for the mock endpoint
*/
const BASE_URL = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
/**
* The base URL for the graph
*/
const ROOT_GRAPH_URL = 'https://graph.microsoft.com/';
/**
* MockGraph Instance

@@ -46,3 +38,2 @@ *

super(Client.initWithMiddleware({
baseUrl: BASE_URL + ROOT_GRAPH_URL,
middleware: chainMiddleware(...middleware)

@@ -77,5 +68,4 @@ }));

try {
const url = context.request;
const baseLength = BASE_URL.length;
context.request = url.substring(0, baseLength) + escape(url.substring(baseLength));
const baseUrl = yield MockMiddleware.getBaseUrl();
context.request = baseUrl + escape(context.request);
}

@@ -97,3 +87,19 @@ catch (error) {

}
static getBaseUrl() {
return __awaiter(this, void 0, void 0, function* () {
if (!this._baseUrl) {
try {
// get the url we should be using from the endpoint service
let response = yield fetch('https://cdn.graph.office.net/en-us/graph/api/proxy/endpoint');
this._baseUrl = (yield response.json()) + '?url=';
}
catch (_a) {
// fallback to hardcoded value
this._baseUrl = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
}
}
return this._baseUrl;
});
}
}
//# sourceMappingURL=MockGraph.js.map

3

dist/es6/utils/TemplateHelper.d.ts

@@ -30,5 +30,4 @@ /**

* @param context the data context to be applied
* @param additionalContext additional context that could contain functions to transform the data
*/
static renderTemplate(root: HTMLElement, template: HTMLTemplateElement, context: object, additionalContext?: object): void;
static renderTemplate(root: HTMLElement, template: HTMLTemplateElement, context: object): void;
/**

@@ -35,0 +34,0 @@ * Set an alternative binding syntax. Default is {{ <value> }}

@@ -30,5 +30,4 @@ /**

* @param context the data context to be applied
* @param additionalContext additional context that could contain functions to transform the data
*/
static renderTemplate(root, template, context, additionalContext) {
static renderTemplate(root, template, context) {
// inherit context from parent template

@@ -41,3 +40,3 @@ if (template.$parentTemplateContext) {

const templateContent = template.content.cloneNode(true);
rendered = this.renderNode(templateContent, root, context, additionalContext);
rendered = this.renderNode(templateContent, root, context);
}

@@ -50,3 +49,3 @@ else if (template.childNodes.length) {

}
rendered = this.renderNode(div, root, context, additionalContext);
rendered = this.renderNode(div, root, context);
}

@@ -70,3 +69,3 @@ if (rendered) {

const end = this.escapeRegex(this._endExpression);
this._expression = new RegExp(`${start}\\s*\([$\\w\\.()\\[\\]]+\)\\s*${end}`, 'g');
this._expression = new RegExp(`${start}\\s*([$\\w\\.,'"\\s()\\[\\]]+)\\s*${end}`, 'g');
}

@@ -109,5 +108,5 @@ /**

}
static expandExpressionsAsString(str, context, additionalContext) {
static expandExpressionsAsString(str, context) {
return str.replace(this.expression, (match, p1) => {
const value = this.evalInContext(p1 || this.trimExpression(match), Object.assign(Object.assign({}, context), additionalContext));
const value = this.evalInContext(p1 || this.trimExpression(match), context);
if (value) {

@@ -124,5 +123,5 @@ if (typeof value === 'object') {

}
static renderNode(node, root, context, additionalContext) {
static renderNode(node, root, context) {
if (node.nodeName === '#text') {
node.textContent = this.expandExpressionsAsString(node.textContent, context, additionalContext);
node.textContent = this.expandExpressionsAsString(node.textContent, context);
return node;

@@ -147,3 +146,3 @@ }

const key = keyValue[0].trim();
const value = this.evalInContext(keyValue[1].trim(), Object.assign(Object.assign({}, context), additionalContext));
const value = this.evalInContext(keyValue[1].trim(), context);
if (key.startsWith('@')) {

@@ -162,3 +161,3 @@ // event

else {
nodeElement.setAttribute(attribute.name, this.expandExpressionsAsString(attribute.value, context, additionalContext));
nodeElement.setAttribute(attribute.name, this.expandExpressionsAsString(attribute.value, context));
}

@@ -182,3 +181,3 @@ }

const expression = childElement.dataset.if;
if (!this.evalBoolInContext(this.trimExpression(expression), Object.assign(Object.assign({}, context), additionalContext))) {
if (!this.evalBoolInContext(this.trimExpression(expression), context)) {
removeChildren.push(childElement);

@@ -206,7 +205,7 @@ childWillBeRemoved = true;

else if (!childWillBeRemoved) {
this.renderNode(childNode, root, context, additionalContext);
this.renderNode(childNode, root, context);
}
}
else {
this.renderNode(childNode, root, context, additionalContext);
this.renderNode(childNode, root, context);
}

@@ -233,3 +232,3 @@ // clear the flag if the current node wasn't data-if

const listKey = loopTokens[2];
const list = this.evalInContext(listKey, Object.assign(Object.assign({}, context), additionalContext));
const list = this.evalInContext(listKey, context);
if (Array.isArray(list)) {

@@ -244,3 +243,3 @@ // first remove the child

const clone = childElement.cloneNode(true);
this.renderNode(clone, root, newContext, additionalContext);
this.renderNode(clone, root, newContext);
nodeElement.insertBefore(clone, childElement);

@@ -247,0 +246,0 @@ }

@@ -7,3 +7,3 @@ /**

*/
export declare const PACKAGE_VERSION = "2.2.0";
export declare const PACKAGE_VERSION = "2.2.1";
//# sourceMappingURL=version.d.ts.map

@@ -9,3 +9,3 @@ /**

// ANY CHANGES WILL BE LOST DURING BUILD
export const PACKAGE_VERSION = '2.2.0';
export const PACKAGE_VERSION = '2.2.1';
//# sourceMappingURL=version.js.map
{
"name": "@microsoft/mgt-element",
"version": "2.2.0",
"version": "2.2.1-preview.10e98e4",
"description": "Microsoft Graph Toolkit base classes",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/microsoftgraph/microsoft-graph-toolkit",

@@ -129,6 +129,6 @@ /**

TemplateHelper.renderTemplate(div, this.templates[templateType], context, {
...this.templateContext
});
const dataContext = { ...context, ...this.templateContext };
TemplateHelper.renderTemplate(div, this.templates[templateType], dataContext);
this.appendChild(div);

@@ -138,3 +138,3 @@

this.fireCustomEvent('templateRendered', { templateType, context, element: div });
this.fireCustomEvent('templateRendered', { templateType, context: dataContext, element: div });

@@ -141,0 +141,0 @@ return template;

@@ -24,12 +24,2 @@ /**

/**
* The base URL for the mock endpoint
*/
const BASE_URL = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
/**
* The base URL for the graph
*/
const ROOT_GRAPH_URL = 'https://graph.microsoft.com/';
/**
* MockGraph Instance

@@ -54,3 +44,2 @@ *

Client.initWithMiddleware({
baseUrl: BASE_URL + ROOT_GRAPH_URL,
middleware: chainMiddleware(...middleware)

@@ -90,8 +79,9 @@ })

private static _baseUrl;
// tslint:disable-next-line: completed-docs
public async execute(context: Context): Promise<void> {
try {
const url = context.request as string;
const baseLength = BASE_URL.length;
context.request = url.substring(0, baseLength) + escape(url.substring(baseLength));
const baseUrl = await MockMiddleware.getBaseUrl();
context.request = baseUrl + escape(context.request as string);
} catch (error) {

@@ -111,2 +101,17 @@ // ignore error

}
private static async getBaseUrl() {
if (!this._baseUrl) {
try {
// get the url we should be using from the endpoint service
let response = await fetch('https://cdn.graph.office.net/en-us/graph/api/proxy/endpoint');
this._baseUrl = (await response.json()) + '?url=';
} catch {
// fallback to hardcoded value
this._baseUrl = 'https://proxy.apisandbox.msdn.microsoft.com/svc?url=';
}
}
return this._baseUrl;
}
}

@@ -31,10 +31,4 @@ /**

* @param context the data context to be applied
* @param additionalContext additional context that could contain functions to transform the data
*/
public static renderTemplate(
root: HTMLElement,
template: HTMLTemplateElement,
context: object,
additionalContext?: object
) {
public static renderTemplate(root: HTMLElement, template: HTMLTemplateElement, context: object) {
// inherit context from parent template

@@ -49,3 +43,3 @@ if ((template as any).$parentTemplateContext) {

const templateContent = template.content.cloneNode(true);
rendered = this.renderNode(templateContent, root, context, additionalContext);
rendered = this.renderNode(templateContent, root, context);
} else if (template.childNodes.length) {

@@ -57,3 +51,3 @@ const div = document.createElement('div');

}
rendered = this.renderNode(div, root, context, additionalContext);
rendered = this.renderNode(div, root, context);
}

@@ -81,3 +75,3 @@

this._expression = new RegExp(`${start}\\s*\([$\\w\\.()\\[\\]]+\)\\s*${end}`, 'g');
this._expression = new RegExp(`${start}\\s*([$\\w\\.,'"\\s()\\[\\]]+)\\s*${end}`, 'g');
}

@@ -135,5 +129,5 @@

private static expandExpressionsAsString(str: string, context: object, additionalContext: object) {
private static expandExpressionsAsString(str: string, context: object) {
return str.replace(this.expression, (match, p1) => {
const value = this.evalInContext(p1 || this.trimExpression(match), { ...context, ...additionalContext });
const value = this.evalInContext(p1 || this.trimExpression(match), context);
if (value) {

@@ -150,5 +144,5 @@ if (typeof value === 'object') {

private static renderNode(node: Node, root: HTMLElement, context: object, additionalContext: object) {
private static renderNode(node: Node, root: HTMLElement, context: object) {
if (node.nodeName === '#text') {
node.textContent = this.expandExpressionsAsString(node.textContent, context, additionalContext);
node.textContent = this.expandExpressionsAsString(node.textContent, context);
return node;

@@ -175,3 +169,3 @@ } else if (node.nodeName === 'TEMPLATE') {

const key = keyValue[0].trim();
const value = this.evalInContext(keyValue[1].trim(), { ...context, ...additionalContext });
const value = this.evalInContext(keyValue[1].trim(), context);

@@ -189,6 +183,3 @@ if (key.startsWith('@')) {

} else {
nodeElement.setAttribute(
attribute.name,
this.expandExpressionsAsString(attribute.value, context, additionalContext)
);
nodeElement.setAttribute(attribute.name, this.expandExpressionsAsString(attribute.value, context));
}

@@ -217,3 +208,3 @@ }

const expression = childElement.dataset.if;
if (!this.evalBoolInContext(this.trimExpression(expression), { ...context, ...additionalContext })) {
if (!this.evalBoolInContext(this.trimExpression(expression), context)) {
removeChildren.push(childElement);

@@ -238,6 +229,6 @@ childWillBeRemoved = true;

} else if (!childWillBeRemoved) {
this.renderNode(childNode, root, context, additionalContext);
this.renderNode(childNode, root, context);
}
} else {
this.renderNode(childNode, root, context, additionalContext);
this.renderNode(childNode, root, context);
}

@@ -270,3 +261,3 @@

const list = this.evalInContext(listKey, { ...context, ...additionalContext });
const list = this.evalInContext(listKey, context);
if (Array.isArray(list)) {

@@ -286,3 +277,3 @@ // first remove the child

const clone = childElement.cloneNode(true);
this.renderNode(clone, root, newContext, additionalContext);
this.renderNode(clone, root, newContext);
nodeElement.insertBefore(clone, childElement);

@@ -289,0 +280,0 @@ }

@@ -11,2 +11,2 @@ /**

export const PACKAGE_VERSION = '2.2.0';
export const PACKAGE_VERSION = '2.2.1';

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

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