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

vue3-sfc-loader

Package Overview
Dependencies
Maintainers
1
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue3-sfc-loader - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

56

build/evalHtmlComments.js

@@ -1,33 +0,49 @@

let content = `
const fs = require('fs');
let content = fs.readFileSync(0, 'utf-8');
https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js
const delimiters = ['<!---', '-->'];
<!---
const entries = content.split(new RegExp(delimiters[0] + '([^]*?)' + delimiters[1], 'g'));
const fctList = entries
.filter((v, i) => i % 2)
.map(code => ctx => (function() { return eval(code) }).call(ctx) );
const versionObj = require('semver').parse(require('../package.json').version);
this.replace(/(cdn\\.jsdelivr\\.net\\/npm\\/vue3-sfc-loader)(.*?)(\\/dist\\/vue3-sfc-loader\\.js)/g, '$1@^' + versionObj.major + '$3');
for ( let i = 0; i < entries.length; i += 2 )
for ( const apply of fctList )
entries[i] = apply(entries[i])
-->
const result = entries.map((e, i) => i % 2 ? delimiters[0] + e + delimiters[1] : e).join('');
fs.writeFileSync(1, result);
// abc55555def
`;
/*
const blockBegin = '<!---';
const blockEnd = '-->';
example:
-------
const entries = content.split(new RegExp(blockBegin + '([^]*?)' + blockEnd, 'g'));
file.md:
| ...
| <body>
| <div id="app"></div>
| <script src="https://unpkg.com/vue@next"></script>
| <script src="https://pugjs.org/js/pug.js"></script>
| <script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader@latest/dist/vue3-sfc-loader.js"></script>
| ...
|
| <!---
|
| const versionObj = require('semver').parse(require(process.cwd() + '/package.json').version);
| this.replace(/(\/vue3-sfc-loader@)(.*?)(\/)/g, `$1^${ versionObj.major }.${ versionObj.minor }$3`);
|
| -->
const fctList = entries
.filter((v, i) => i % 2)
.map(code => ctx => (function() { return eval(code) }).call(ctx) );
> node ./build/evalHtmlComments.js < README.md > README.md
for ( let i = 0; i < entries.length; i += 2 )
for ( const apply of fctList )
entries[i] = apply(entries[i])
result:
| ...
| <script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader@^0.2/dist/vue3-sfc-loader.js"></script>
| ...
const result = entries.map((e, i) => i % 2 ? blockBegin + e + blockEnd : e).join('');
console.log(result)
*/
### [0.2.11](https://github.com/FranckFreiburger/vue3-sfc-loader/compare/v0.2.10...v0.2.11) (2020-11-28)
### Features
* **core:** loadModule() throw when a mandatory option is not defined. ([1f62eac](https://github.com/FranckFreiburger/vue3-sfc-loader/commit/1f62eac14972e25833eacb5781b7c9ee7283254c))
* **workflow:** add evalHtmlComments.js tool ([c86208b](https://github.com/FranckFreiburger/vue3-sfc-loader/commit/c86208bb4cd84686d615c74e29977da11c15a9f4))
### [0.2.10](https://github.com/FranckFreiburger/vue3-sfc-loader/compare/v0.2.8...v0.2.10) (2020-11-28)

@@ -3,0 +11,0 @@

@@ -185,3 +185,3 @@ interface Cache {

*/
export declare function loadModule(path: string, options: Options): Promise<Module>;
export declare function loadModule(path: string, options?: Options): Promise<Module>;
export {};

@@ -24,3 +24,3 @@ **[vue3-sfc-loader](../README.md)**

*Defined in [index.ts:67](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L67)*
*Defined in [index.ts:67](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L67)*

@@ -41,3 +41,3 @@ #### Parameters:

*Defined in [index.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L68)*
*Defined in [index.ts:68](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L68)*

@@ -44,0 +44,0 @@ #### Parameters:

@@ -18,3 +18,3 @@ **[vue3-sfc-loader](../README.md)**

*Defined in [index.ts:231](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L231)*
*Defined in [index.ts:231](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L231)*

@@ -21,0 +21,0 @@ Called by the library when it does not handle a loaded file type (eg. .json files).

@@ -32,3 +32,3 @@ **[vue3-sfc-loader](../README.md)**

*Defined in [index.ts:140](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L140)*
*Defined in [index.ts:140](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L140)*

@@ -48,3 +48,3 @@ Additional babel plugins. [TBD]

*Defined in [index.ts:147](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L147)*
*Defined in [index.ts:147](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L147)*

@@ -59,3 +59,3 @@ Additional module type handlers. see [ModuleHandler](modulehandler.md)

*Defined in [index.ts:186](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L186)*
*Defined in [index.ts:186](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L186)*

@@ -103,3 +103,3 @@ [get](cache.md#get)() and [set](cache.md#set)() functions of this object are called when the lib needs to save or load already compiled code. get and set functions must return a `Promise` (or can be `async`).

*Defined in [index.ts:89](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L89)*
*Defined in [index.ts:89](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L89)*

@@ -124,3 +124,3 @@ Initial cache that will contain resolved dependencies.

*Defined in [index.ts:129](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L129)*
*Defined in [index.ts:129](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L129)*

@@ -157,3 +157,3 @@ Called by the library when CSS style must be added in the HTML document.

*Defined in [index.ts:107](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L107)*
*Defined in [index.ts:107](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L107)*

@@ -188,3 +188,3 @@ Called by the library when it needs a file.

*Defined in [index.ts:204](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L204)*
*Defined in [index.ts:204](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L204)*

@@ -191,0 +191,0 @@ Called by the library when there is somthing to log (eg. scripts compilation errors, template compilation errors, template compilation tips, style compilation errors, ...)

@@ -30,3 +30,3 @@ **[vue3-sfc-loader](README.md)**

*Defined in [index.ts:248](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L248)*
*Defined in [index.ts:248](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L248)*

@@ -39,5 +39,5 @@ the version of the library (process.env.VERSION is set by webpack, at compile-time)

▸ **loadModule**(`path`: string, `options`: [Options](interfaces/options.md)): Promise\<[Module](interfaces/module.md)>
▸ **loadModule**(`path`: string, `options?`: [Options](interfaces/options.md)): Promise\<[Module](interfaces/module.md)>
*Defined in [index.ts:700](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/e6d9175/src/index.ts#L700)*
*Defined in [index.ts:708](https://github.com/FranckFreiburger/vue3-sfc-loader/blob/af93193/src/index.ts#L708)*

@@ -48,6 +48,6 @@ This is the main function.

Name | Type | Description |
------ | ------ | ------ |
`path` | string | The path of the .vue file |
`options` | [Options](interfaces/options.md) | The options |
Name | Type | Default value | Description |
------ | ------ | ------ | ------ |
`path` | string | - | The path of the .vue file |
`options` | [Options](interfaces/options.md) | throwNotDefined('options') | The options |

@@ -54,0 +54,0 @@ **Returns:** Promise\<[Module](interfaces/module.md)>

@@ -11,3 +11,3 @@ {

"license": "MIT",
"version": "0.2.10",
"version": "0.2.11",
"main": "dist/vue3-sfc-loader.js",

@@ -14,0 +14,0 @@ "scripts": {

@@ -236,3 +236,3 @@ # vue3-sfc-loader

<script src="https://pugjs.org/js/pug.js"></script>
<script src="vue3-sfc-loader.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader@latest/dist/vue3-sfc-loader.js"></script>
<script>

@@ -264,2 +264,4 @@

},
addStyle: () => {},
}

@@ -275,1 +277,61 @@

```
### SFC style CSS variable injection (new edition)
_see at [vuejs/rfcs](https://github.com/vuejs/rfcs/pull/231)_
```html
<!DOCTYPE html>
<html>
<body>
<div id="app"></div>
<script src="https://unpkg.com/vue@next"></script>
<script src="https://cdn.jsdelivr.net/npm/vue3-sfc-loader/dist/vue3-sfc-loader.js"></script>
<script>
const sfcSontent = /* <!-- */`
<template>
Hello <span class="example">{{ msg }}</span>
</template>
<script>
export default {
data () {
return {
msg: 'world!',
color: 'blue',
}
}
}
</script>
<style scoped>
.example {
color: v-bind('color')
}
</style>
`/* --> */;
const options = {
moduleCache: {
vue: Vue,
},
getFile(url) {
if ( url === './myComponent.vue' )
return Promise.resolve(sfcSontent);
return fetch(url).then(response => response.ok ? response.text() : Promise.reject(response));
},
addStyle(styleStr) {
const style = document.createElement('style');
style.textContent = styleStr;
const ref = document.head.getElementsByTagName('style')[0] || null;
document.head.insertBefore(style, ref);
},
}
const { loadModule } = window["vue3-sfc-loader"];
Vue.createApp(Vue.defineAsyncComponent(() => loadModule('./myComponent.vue', options))).mount('#app');
</script>
</body>
</html>
```

@@ -262,2 +262,10 @@ import { posix as Path } from 'path'

*/
function throwNotDefined(details : string) : never {
throw new ReferenceError(`${ details } is not defined`);
}
/**
* @internal
*/
function hash(...valueList : any[]) : string {

@@ -701,5 +709,10 @@

*/
export async function loadModule(path : string, options : Options) {
export async function loadModule(path : string, options : Options = throwNotDefined('options')) {
const { getFile, additionalModuleHandlers = {} } = options;
const {
moduleCache = throwNotDefined('options.moduleCache'),
getFile = throwNotDefined('options.getFile()'),
addStyle = throwNotDefined('options.addStyle()'),
additionalModuleHandlers = {}
} = options;

@@ -706,0 +719,0 @@ const moduleHandlers = { ...defaultModuleHandlers, ...additionalModuleHandlers };

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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