Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-inbrowser-compiler-utils

Package Overview
Dependencies
Maintainers
3
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-inbrowser-compiler-utils - npm Package Compare versions

Comparing version 4.33.0 to 4.33.2

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

## [4.33.2](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.33.1...v4.33.2) (2020-10-19)
### Bug Fixes
* when there is a template in the script ([35ac16d](https://github.com/vue-styleguidist/vue-styleguidist/commit/35ac16d9f3be4c172df556fe6655cc7c640cf8ae)), closes [#1000](https://github.com/vue-styleguidist/vue-styleguidist/issues/1000)
# [4.33.0](https://github.com/vue-styleguidist/vue-styleguidist/compare/v4.32.4...v4.33.0) (2020-10-12)

@@ -8,0 +19,0 @@

31

lib/vue-inbrowser-compiler-utils.cjs.js

@@ -215,3 +215,4 @@ (function (global, factory) {

var PARTS = ['template', 'script'];
// highest priority first
var PARTS = ['script', 'template'];
function parseComponent(code) {

@@ -224,20 +225,14 @@ // reinintialize regexp after each tour

var descriptor = {};
var partsWithWrapper = {};
var codeCleaned = code;
// extract all parts
PARTS.forEach(function (part) {
var res = partsRE[part].exec(code);
var res = partsRE[part].exec(codeCleaned);
if (res) {
partsWithWrapper[part] = res[0];
var partFound = res[0];
descriptor[part] = res[1];
// once we have extracted one part,
// remove it from the analyzed blob
codeCleaned = codeCleaned.replace(partFound, '');
}
});
// make sure they are the only components of the code
var check = code;
var i = PARTS.length;
while (i-- && check.length) {
var withWrapper = partsWithWrapper[PARTS[i]];
if (withWrapper) {
check = check.replace(withWrapper, '').trim();
}
}
// we assume that

@@ -248,3 +243,3 @@ var styleRE = /(<style[^>]*>)([^<]+)(<.......)/g;

var stylesWithWrapper = [];
var stylePart = styleRE.exec(check);
var stylePart = styleRE.exec(codeCleaned);
var styleHeader = stylePart ? stylePart[1] : '';

@@ -263,3 +258,3 @@ var styles;

// if we just started to analyze a new style tag
stylePart = styleRE.exec(check);
stylePart = styleRE.exec(codeCleaned);
styleHeader = stylePart ? stylePart[1] : '';

@@ -270,3 +265,3 @@ }

styleFollowUpRE.lastIndex = styleRE.lastIndex;
stylePart = styleFollowUpRE.exec(check);
stylePart = styleFollowUpRE.exec(codeCleaned);
}

@@ -278,6 +273,6 @@ }

while (j--) {
check = check.replace(stylesWithWrapper[j], '').trim();
codeCleaned = codeCleaned.replace(stylesWithWrapper[j], '').trim();
}
}
return check.length ? {} : descriptor;
return codeCleaned.trim().length ? {} : descriptor;
}

@@ -284,0 +279,0 @@

@@ -209,3 +209,4 @@ /* eslint-disable no-control-regex */

var PARTS = ['template', 'script'];
// highest priority first
var PARTS = ['script', 'template'];
function parseComponent(code) {

@@ -218,20 +219,14 @@ // reinintialize regexp after each tour

var descriptor = {};
var partsWithWrapper = {};
var codeCleaned = code;
// extract all parts
PARTS.forEach(function (part) {
var res = partsRE[part].exec(code);
var res = partsRE[part].exec(codeCleaned);
if (res) {
partsWithWrapper[part] = res[0];
var partFound = res[0];
descriptor[part] = res[1];
// once we have extracted one part,
// remove it from the analyzed blob
codeCleaned = codeCleaned.replace(partFound, '');
}
});
// make sure they are the only components of the code
var check = code;
var i = PARTS.length;
while (i-- && check.length) {
var withWrapper = partsWithWrapper[PARTS[i]];
if (withWrapper) {
check = check.replace(withWrapper, '').trim();
}
}
// we assume that

@@ -242,3 +237,3 @@ var styleRE = /(<style[^>]*>)([^<]+)(<.......)/g;

var stylesWithWrapper = [];
var stylePart = styleRE.exec(check);
var stylePart = styleRE.exec(codeCleaned);
var styleHeader = stylePart ? stylePart[1] : '';

@@ -257,3 +252,3 @@ var styles;

// if we just started to analyze a new style tag
stylePart = styleRE.exec(check);
stylePart = styleRE.exec(codeCleaned);
styleHeader = stylePart ? stylePart[1] : '';

@@ -264,3 +259,3 @@ }

styleFollowUpRE.lastIndex = styleRE.lastIndex;
stylePart = styleFollowUpRE.exec(check);
stylePart = styleFollowUpRE.exec(codeCleaned);
}

@@ -272,6 +267,6 @@ }

while (j--) {
check = check.replace(stylesWithWrapper[j], '').trim();
codeCleaned = codeCleaned.replace(stylesWithWrapper[j], '').trim();
}
}
return check.length ? {} : descriptor;
return codeCleaned.trim().length ? {} : descriptor;
}

@@ -278,0 +273,0 @@

{
"name": "vue-inbrowser-compiler-utils",
"version": "4.33.0",
"version": "4.33.2",
"description": "use this with vue-inbrowser-compiler to allow jsx compilation",

@@ -33,3 +33,3 @@ "module": "lib/vue-inbrowser-compiler-utils.esm.js",

"license": "MIT",
"gitHead": "8769bab0a35f8bbaadec6cc6218ca9beba3e409a"
"gitHead": "59aecb7613bc6ab9cfb82645515db9d32b6b5e13"
}

@@ -28,6 +28,6 @@ import parseComponent from '../parseComponent'

expect(comp.script).toMatchInlineSnapshot(`
"
export default {}
"
`)
"
export default {}
"
`)
})

@@ -105,2 +105,35 @@

})
it('should allow for templates inside of script strings', () => {
const comp = parseComponent(`
<template>
<MyComponent/>
</template>
<script>
const MyComponent = \`
<div>
<template v-if="true">
FOO
</template>
</div>
\`
export default {};
</script>`)
expect(comp.template).toMatch(/<MyComponent/)
expect(comp.script).toMatchInlineSnapshot(`
"
const MyComponent = \`
<div>
<template v-if=\\"true\\">
FOO
</template>
</div>
\`
export default {};
"
`)
})
})

@@ -10,3 +10,4 @@ interface VsgSFCDescriptorSimple {

const PARTS: (keyof VsgSFCDescriptorSimple)[] = ['template', 'script']
// highest priority first
const PARTS: (keyof VsgSFCDescriptorSimple)[] = ['script', 'template']

@@ -26,21 +27,18 @@ export default function parseComponent(code: string): VsgSFCDescriptor {

let codeCleaned = code
// extract all parts
PARTS.forEach(part => {
const res = partsRE[part].exec(code)
const res = partsRE[part].exec(codeCleaned)
if (res) {
partsWithWrapper[part] = res[0]
const partFound = res[0] as string
partsWithWrapper[part] = partFound
descriptor[part] = res[1]
// once we have extracted one part,
// remove it from the analyzed blob
codeCleaned = codeCleaned.replace(partFound, '')
}
})
// make sure they are the only components of the code
let check = code
let i = PARTS.length
while (i-- && check.length) {
const withWrapper = partsWithWrapper[PARTS[i]]
if (withWrapper) {
check = check.replace(withWrapper, '').trim()
}
}
// we assume that

@@ -51,3 +49,3 @@ const styleRE = /(<style[^>]*>)([^<]+)(<.......)/g

const stylesWithWrapper: string[] = []
let stylePart: RegExpExecArray | undefined | null = styleRE.exec(check)
let stylePart: RegExpExecArray | undefined | null = styleRE.exec(codeCleaned)
let styleHeader: string = stylePart ? stylePart[1] : ''

@@ -68,3 +66,3 @@ let styles: string[] | undefined

// if we just started to analyze a new style tag
stylePart = styleRE.exec(check)
stylePart = styleRE.exec(codeCleaned)
styleHeader = stylePart ? stylePart[1] : ''

@@ -74,3 +72,3 @@ } else {

styleFollowUpRE.lastIndex = styleRE.lastIndex
stylePart = styleFollowUpRE.exec(check)
stylePart = styleFollowUpRE.exec(codeCleaned)
}

@@ -82,6 +80,6 @@ }

while (j--) {
check = check.replace(stylesWithWrapper[j], '').trim()
codeCleaned = codeCleaned.replace(stylesWithWrapper[j], '').trim()
}
}
return check.length ? {} : descriptor
return codeCleaned.trim().length ? {} : descriptor
}
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