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

components-helper

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

components-helper - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

11

CHANGELOG.md
# Changelog
### 2.1.0
feat
- update web-types to 2.0
- add attribute enum autosuggestion for web-types
### 2.0.0

@@ -28,4 +35,4 @@

- titleRegExp: '#+\\s+(.*)\\n+>\\s\*([^(#|\\n)]*)',
+ titleRegExp: /#+\s+(.*)\n+>\s\*([^(#|\n)]*)/g,
- titleRegExp: '#+\\s+(.*)\\n+>\\s*([^(#|\\n)]*)',
+ titleRegExp: /#+\s+(.*)\n+>\s*([^(#|\n)]*)/g,

@@ -32,0 +39,0 @@ - tableRegExp: '#+\\s+(.*)\\n+(\\|?.+\\|.+)\\n\\|?\\s*:?-+:?\\s*\\|.+((\\n\\|?.+\\|.+)+)',

47

lib/index.es.js

@@ -32,3 +32,3 @@ import fg from'fast-glob';import {readFileSync,mkdir,writeFileSync}from'fs';import {resolve}from'path';var config = {

function checkArray(item) {
return item && item.length ? item : undefined;
return (item === null || item === void 0 ? void 0 : item.length) ? item : undefined;
}

@@ -45,2 +45,8 @@ function isString(val) {

}
function splitString(options, str) {
if (!str)
return undefined;
var separator = options.separator;
return str.split(separator).map(function (item) { return item.trim(); });
}
function getComponentsName(options, title, fileName, path) {

@@ -274,6 +280,6 @@ if (title === void 0) { title = ''; }

var _name = name + '/' + _item;
var _type = item[propsType] || '';
var _type = (item[propsType] || '').replace(separator, '|');
var _options = item[propsOptions];
var _optionsList = /string/i.test(_type) && _options
? _options.split(separator).map(function (item) { return item.trim(); })
? splitString(options, _options)
: undefined;

@@ -283,3 +289,3 @@ var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1);

propsList[_name] = {
type: item[propsType],
type: _type || undefined,
options: _optionsList,

@@ -305,5 +311,3 @@ description: _description_1,

var _subtags = item[slotsSubtags];
var _subtagsList = _subtags
? _subtags.split(separator).map(function (item) { return item.trim(); })
: undefined;
var _subtagsList = _subtags ? splitString(options, _subtags) : undefined;
if (_subtagsList) {

@@ -329,11 +333,11 @@ subtags = subtags.concat(_subtagsList);

return {
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
$schema: 'http://json.schemastore.org/web-types',
framework: 'vue',
name: name,
version: version,
'js-types-syntax': 'typescript',
'description-markup': 'markdown',
contributions: {
html: {
'types-syntax': 'typescript',
'description-markup': 'markdown',
tags: tags,
'vue-components': tags,
attributes: attributes,

@@ -345,3 +349,3 @@ },

function getWebTypes(options, list) {
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsDefault = options.propsDefault, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsName = options.slotsName, slotsDescription = options.slotsDescription, directivesName = options.directivesName, directivesType = options.directivesType, directivesDescription = options.directivesDescription;
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsName = options.slotsName, slotsDescription = options.slotsDescription, directivesName = options.directivesName, directivesType = options.directivesType, directivesDescription = options.directivesDescription;
var tagsList = [];

@@ -367,8 +371,3 @@ var directivesList = [];

'doc-url': getDocUrl(options, fileName, directives === null || directives === void 0 ? void 0 : directives.title, path),
value: item[directivesType]
? {
type: item[directivesType],
kind: 'expression',
}
: undefined,
type: checkArray(splitString(options, item[directivesType])),
});

@@ -392,2 +391,3 @@ }

if (_item) {
var _optionsList = splitString(options, item[propsOptions]);
propsList.push({

@@ -397,9 +397,8 @@ name: _item,

'doc-url': getDocUrl(options, fileName, props === null || props === void 0 ? void 0 : props.title, path),
type: checkArray(splitString(options, item[propsType])),
default: item[propsDefault],
value: item[propsType]
? {
type: item[propsType],
kind: 'expression',
}
'attribute-value': checkArray(_optionsList)
? { type: 'enum' }
: undefined,
values: checkArray(_optionsList === null || _optionsList === void 0 ? void 0 : _optionsList.map(function (name) { return ({ name: name }); })),
});

@@ -433,3 +432,3 @@ }

'doc-url': getDocUrl(options, fileName, title, path),
attributes: checkArray(propsList),
props: checkArray(propsList),
events: checkArray(eventsList),

@@ -436,0 +435,0 @@ slots: checkArray(slotsList),

@@ -32,3 +32,3 @@ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var fg=require('fast-glob'),fs=require('fs'),path=require('path');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var fg__default=/*#__PURE__*/_interopDefaultLegacy(fg);var config = {

function checkArray(item) {
return item && item.length ? item : undefined;
return (item === null || item === void 0 ? void 0 : item.length) ? item : undefined;
}

@@ -45,2 +45,8 @@ function isString(val) {

}
function splitString(options, str) {
if (!str)
return undefined;
var separator = options.separator;
return str.split(separator).map(function (item) { return item.trim(); });
}
function getComponentsName(options, title, fileName, path) {

@@ -274,6 +280,6 @@ if (title === void 0) { title = ''; }

var _name = name + '/' + _item;
var _type = item[propsType] || '';
var _type = (item[propsType] || '').replace(separator, '|');
var _options = item[propsOptions];
var _optionsList = /string/i.test(_type) && _options
? _options.split(separator).map(function (item) { return item.trim(); })
? splitString(options, _options)
: undefined;

@@ -283,3 +289,3 @@ var _description_1 = getVeturDescription(options, item[propsDescription], item[propsDefault], docUrl_1);

propsList[_name] = {
type: item[propsType],
type: _type || undefined,
options: _optionsList,

@@ -305,5 +311,3 @@ description: _description_1,

var _subtags = item[slotsSubtags];
var _subtagsList = _subtags
? _subtags.split(separator).map(function (item) { return item.trim(); })
: undefined;
var _subtagsList = _subtags ? splitString(options, _subtags) : undefined;
if (_subtagsList) {

@@ -329,11 +333,11 @@ subtags = subtags.concat(_subtagsList);

return {
$schema: 'https://raw.githubusercontent.com/JetBrains/web-types/master/schema/web-types.json',
$schema: 'http://json.schemastore.org/web-types',
framework: 'vue',
name: name,
version: version,
'js-types-syntax': 'typescript',
'description-markup': 'markdown',
contributions: {
html: {
'types-syntax': 'typescript',
'description-markup': 'markdown',
tags: tags,
'vue-components': tags,
attributes: attributes,

@@ -345,3 +349,3 @@ },

function getWebTypes(options, list) {
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsDefault = options.propsDefault, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsName = options.slotsName, slotsDescription = options.slotsDescription, directivesName = options.directivesName, directivesType = options.directivesType, directivesDescription = options.directivesDescription;
var propsName = options.propsName, propsType = options.propsType, propsDescription = options.propsDescription, propsOptions = options.propsOptions, propsDefault = options.propsDefault, eventsName = options.eventsName, eventsDescription = options.eventsDescription, slotsName = options.slotsName, slotsDescription = options.slotsDescription, directivesName = options.directivesName, directivesType = options.directivesType, directivesDescription = options.directivesDescription;
var tagsList = [];

@@ -367,8 +371,3 @@ var directivesList = [];

'doc-url': getDocUrl(options, fileName, directives === null || directives === void 0 ? void 0 : directives.title, path),
value: item[directivesType]
? {
type: item[directivesType],
kind: 'expression',
}
: undefined,
type: checkArray(splitString(options, item[directivesType])),
});

@@ -392,2 +391,3 @@ }

if (_item) {
var _optionsList = splitString(options, item[propsOptions]);
propsList.push({

@@ -397,9 +397,8 @@ name: _item,

'doc-url': getDocUrl(options, fileName, props === null || props === void 0 ? void 0 : props.title, path),
type: checkArray(splitString(options, item[propsType])),
default: item[propsDefault],
value: item[propsType]
? {
type: item[propsType],
kind: 'expression',
}
'attribute-value': checkArray(_optionsList)
? { type: 'enum' }
: undefined,
values: checkArray(_optionsList === null || _optionsList === void 0 ? void 0 : _optionsList.map(function (name) { return ({ name: name }); })),
});

@@ -433,3 +432,3 @@ }

'doc-url': getDocUrl(options, fileName, title, path),
attributes: checkArray(propsList),
props: checkArray(propsList),
events: checkArray(eventsList),

@@ -436,0 +435,0 @@ slots: checkArray(slotsList),

@@ -84,61 +84,323 @@ export declare type ReComponentName = (title: string, fileName: string, path: string) => string;

}
export interface WebEvent {
name: string;
description?: string;
'doc-url'?: string;
}
export interface WebSlot {
name: string;
description?: string;
'doc-url'?: string;
}
export interface WebAttribute {
name: string;
description?: string;
'doc-url'?: string;
default?: string;
value?: {
type: string;
kind: string;
};
}
/**
* Language in which JavaScript objects types are specified.
*/
export declare type JsTypesSyntax = 'typescript';
/**
* Markup language in which descriptions are formatted.
*/
export declare type DescriptionMarkup = 'html' | 'markdown' | 'none';
/**
* A RegEx pattern to match whole content. Syntax should work with at least ECMA, Java and Python implementations.
*/
export declare type Pattern = string | {
regex?: string;
'case-sensitive'?: boolean;
[k: string]: unknown;
};
/**
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^/(html|css|js)/[^/\n\r]+$".
*/
export declare type NameConverter = 'as-is' | 'PascalCase' | 'camelCase' | 'lowercase' | 'UPPERCASE' | 'kebab-case' | 'snake_case';
/**
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^/(html|css|js)/[^/\n\r]+$".
*
* This interface was referenced by `undefined`'s JSON-Schema definition
* via the `patternProperty` "^/(html|css|js)/[^/\n\r]+$".
*/
export declare type NameConverters = NameConverter[];
/**
* Relative path to the icon representing the symbol.
*/
export declare type Icon = string;
/**
* Contains contributions to HTML namespace. It's property names represent symbol kinds, its property values contain list of contributions of particular kind. There are 2 predefined kinds, which integrate directly with IDE - HTML elements and HTML attributes. There are also 2 deprecated kinds: tags (which is equivalent to 'elements') and 'events' (which was moved to JS namespace)
*/
export declare type Html = HtmlContributionsHost;
export declare type WebElement = BaseContribution & HtmlContributionsHost;
export declare type Name = string;
/**
* Short description to be rendered in documentation popup. It will be rendered according to description-markup setting.
*/
export declare type Description = string;
/**
* Link to online documentation.
*/
export declare type DocUrl = string;
/**
* Allows to specify the source of the entity. For Vue.js component this may be for instance a class.
*/
export declare type Source = {
/**
* Path to the file, relative to the web-types JSON.
*/
file: string;
/**
* Offset in the file under which the source symbol, like class name, is located.
*/
offset: number;
} | {
/**
* Name of module, which exports the symbol. May be omitted, in which case it's assumed to be the name of the library.
*/
module?: string;
/**
* Name of the exported symbol.
*/
symbol: string;
};
export declare type Deprecated = boolean;
export declare type Experimental = boolean;
export declare type Priority = 'lowest' | 'low' | 'normal' | 'high' | 'highest';
export declare type Proximity = number;
/**
* Mark contribution as virtual. Virtual contributions can be filtered out if needed in references. A virtual contribution meaning may differ by framework or kind contexts, but usually means something synthetic or something, which gets erased in the runtime by the framework. E.g. Vue or Angular attribute bindings are virtual.
*/
export declare type Virtual = boolean;
/**
* Mark contribution as abstract. Such contributions serve only as super contributions for other contributions.
*/
export declare type Abstract = boolean;
/**
* Mark contribution as an extension. Such contributions do not define a new contribution on their own, but can provide additional properties or contributions to existing contributions.
*/
export declare type Extension = boolean;
/**
* A reference to an element in Web-Types model.
*/
export declare type Reference = ReferenceWithProps | string;
export declare type NamePatternRoot = NamePattern | string;
export declare type NamePattern = {
required?: Required;
unique?: boolean;
repeat?: boolean;
template?: NamePatternTemplate;
or?: NamePatternTemplate;
delegate?: Reference;
deprecated?: Deprecated;
priority?: Priority;
proximity?: Proximity;
items?: ListReference;
} | {
file: string;
offset: number;
regex: string;
'case-sensitive'?: boolean;
};
export interface WebTag {
name: string;
source: Source;
description?: string;
'doc-url'?: string;
attributes?: WebAttribute[];
events?: WebEvent[];
slots?: WebSlot[];
}
export interface WebDirective {
name: string;
source: Source;
description?: string;
'doc-url'?: string;
value?: {
type: string;
kind: string;
};
}
export declare type Required = boolean;
export declare type NamePatternTemplate = [
string | NamePatternTemplate | NamePattern,
...(string | NamePatternTemplate | NamePattern)[]
];
/**
* A reference to an element in Web-Types model.
*/
export declare type ListReference = Reference | Reference[];
/**
* Contains contributions to CSS namespace. It's property names represent symbol kinds, its property values contain list of contributions of particular kind. There are 5 predefined kinds, which integrate directly with IDE - properties, classes, functions, pseudo-elements and pseudo-classes.
*/
export declare type Css = CssContributionsHost;
export declare type CssProperty = BaseContribution & CssContributionsHost;
export declare type CssPseudoElement = BaseContribution & CssContributionsHost;
export declare type CssPseudoClass = BaseContribution & CssContributionsHost;
export declare type CssGenericItem = BaseContribution & CssContributionsHost;
export declare type GenericCssContribution = GenericContribution & CssContributionsHost;
/**
* A generic contribution. All contributions are of this type, except for HTML attributes and elements, as well as predefined CSS contribution kinds.
*/
export declare type GenericContribution = TypedContribution;
/**
* The base for any contribution, which can possibly have a JS type.
*/
export declare type TypedContribution = BaseContribution;
/**
* Contains contributions to JS namespace. It's property names represent symbol kinds, its property values contain list of contributions of particular kind. There are 2 predefined kinds, which integrate directly with IDE - properties and events.
*/
export declare type Js = JsContributionsHost;
export declare type WebEvent = GenericContribution & JsContributionsHost;
/**
* Specify list of contribution kinds qualified with a namespace, for which during reference resolution this will be the final contribution host. E.g. if a special HTML element does not accept standard attributes, add:
* "exclusive-contributions": ["/html/attributes"].
*/
export declare type ExclusiveContributions = string[];
export declare type WebAttribute = BaseContribution & HtmlContributionsHost;
/**
* This interface was referenced by `HtmlContributionsHost`'s JSON-Schema definition
* via the `patternProperty` "^(?!pattern$).*$".
*/
export declare type GenericHtmlContributions = GenericHtmlContributionOrProperty | GenericHtmlContributionOrProperty[];
export declare type GenericHtmlContributionOrProperty = string | number | boolean;
export interface WebTypes {
$schema: string;
framework: string;
$schema?: string;
/**
* Framework, for which the components are provided by the library. If the library is not enabled in a particular context, all symbols from this file will not be available as well. If you want symbols to be always available do not specify framework.
*/
framework?: string;
/**
* Name of the library.
*/
name: string;
/**
* Version of the library, for which Web-Types are provided.
*/
version: string;
contributions: {
html: {
'types-syntax': string;
'description-markup': string;
tags?: WebTag[];
attributes?: WebDirective[];
};
'js-types-syntax'?: JsTypesSyntax;
'description-markup'?: DescriptionMarkup;
'framework-config'?: FrameworkConfig;
'default-icon'?: Icon;
/**
* Symbol can be contributed to one of the 3 namespaces - HTML, CSS and JS. Within a particular namespace there can be different kinds of symbols. In each of the namespaces, there are several predefined kinds, which integrate directly with IDE, but providers are free to define their own.
*/
contributions?: {
html?: Html;
css?: Css;
js?: Js;
};
}
/**
* Provide configuration for the specified web framework. This is an advanced feature, which is used to provide support for templating frameworks like Angular, Vue, Svelte, etc.
*/
export interface FrameworkConfig {
'enable-when'?: EnablementRules;
'disable-when'?: DisablementRules;
/**
* In many frameworks symbols can have multiple versions of a name. Specify canonical name conversion rule for names of particular symbol kinds against which comparisons will be made. Format of the 'canonical-names' property names is '{namespace}/{symbol kind}'. By default symbol names in HTML namespace are converted to lower-case, and in CSS and JS namespaces are left as-is. In case of name patterns, rules are applied to each part of the pattern separately, so even if the symbol with pattern is in HTML namespace, references to JS events will be case-sensitive.
*/
'canonical-names'?: {
[k: string]: NameConverter;
};
/**
* Provide an array of name conversions, in which particular symbol kinds should be matched against canonical names of symbols. By default symbol names are converted using canonical-names rule.
*/
'match-names'?: {
[k: string]: NameConverters;
};
/**
* Provide an array of name conversions, in which particular symbol kinds should be proposed in auto completion. Format of the 'name-variants' property names is '{namespace}/{symbol kind}'. All symbol kinds are by default provided as-is.
*/
'name-variants'?: {
[k: string]: NameConverters;
};
}
/**
* Specify rules for enabling web framework support. Only one framework can be enabled in a particular file. If you need your contributions to be enabled in all files, regardless of the context, do not specify the framework.
*/
export interface EnablementRules {
/**
* Node.js package names, which enable framework support within the folder containing the package.json.
*/
'node-packages'?: string[];
/**
* RegExps to match script URLs, which enable framework support within a particular HTML.
*/
'script-url-patterns'?: Pattern[];
/**
* Extensions of files, which should have the framework support enabled. Use this to support custom file extensions like '.vue' or '.svelte'. Never specify generic extensions like '.html', '.js' or '.ts'. If you need your contributions to be present in every file don't specify the framework at all
*/
'file-extensions'?: string[];
/**
* RegExp patterns to match file names, which should have the framework support enabled. Use carefully as broken pattern may even freeze IDE.
*/
'file-name-patterns'?: Pattern[];
/**
* Global JavaScript libraries names enabled within the IDE, which enable framework support in the whole project
*/
'ide-libraries'?: string[];
}
/**
* Specify rules for disabling web framework support. These rules take precedence over enable-when rules. They allow to turn off framework support in case of some conflicts between frameworks priority.
*/
export interface DisablementRules {
/**
* Extensions of files, which should have the framework support disabled
*/
'file-extensions'?: string[];
/**
* RegExp patterns to match file names, which should have the framework support disabled
*/
'file-name-patterns'?: Pattern[];
}
export interface HtmlContributionsHost {
/**
* HTML elements.
*/
elements?: WebElement[];
/**
* HTML attributes.
*/
attributes?: WebAttribute[];
/**
* for Vue
*/
'vue-components'?: WebElement[];
}
/**
* The base for any contributions.
*/
export interface BaseContribution {
name?: Name;
description?: Description;
'description-sections'?: DescriptionSections;
'doc-url'?: DocUrl;
icon?: Icon;
source?: Source;
deprecated?: Deprecated;
experimental?: Experimental;
priority?: Priority;
proximity?: Proximity;
virtual?: Virtual;
abstract?: Abstract;
extension?: Extension;
extends?: Reference;
pattern?: NamePatternRoot;
html?: Html;
css?: Css;
js?: Js;
'exclusive-contributions'?: ExclusiveContributions;
[k: string]: unknown;
}
/**
* Custom sections to be shown below description in the documentation popup.
*/
export interface DescriptionSections {
[k: string]: string;
}
export interface ReferenceWithProps {
path: string;
includeVirtual?: boolean;
includeAbstract?: boolean;
filter?: string;
[k: string]: unknown;
}
export interface CssContributionsHost {
/**
* CSS properties
*/
properties?: CssProperty[];
/**
* CSS pseudo-elements
*/
'pseudo-elements'?: CssPseudoElement[];
/**
* CSS pseudo-classes
*/
'pseudo-classes'?: CssPseudoClass[];
/**
* CSS functions
*/
functions?: CssGenericItem[];
/**
* CSS classes
*/
classes?: CssGenericItem[];
}
export interface JsContributionsHost {
/**
* DOM events
*/
events?: WebEvent[];
/**
* JavaScript properties of an object, HTML tag, framework component, etc.
*/
properties?: WebEvent[];
}
import type { Options, Source } from './type';
export declare function hyphenate(str: string): string;
export declare function checkArray<T extends Array<unknown>>(item: T): T | undefined;
export declare function checkArray<T extends Array<unknown>>(item?: T): T | undefined;
export declare function isString(val: unknown): val is string;
export declare function isFunction(val: unknown): val is Function;
export declare function normalizeFile(file: string): string;
export declare function splitString(options: Options, str?: string): string[] | undefined;
export declare function getComponentsName(options: Options, title: string | undefined, fileName: string, path: string): string;

@@ -8,0 +9,0 @@ export declare function getDocUrl(options: Options, fileName: string, header?: string, path?: string): string | undefined;

@@ -1,6 +0,6 @@

import type { Options, NormalizeData, WebTypes, WebTag, WebDirective } from './type';
import type { Options, NormalizeData, WebTypes, WebElement, WebAttribute } from './type';
export declare function webTypes(options: Options, list: NormalizeData[]): WebTypes;
export declare function getWebTypes(options: Options, list: NormalizeData[]): {
tags: WebTag[] | undefined;
attributes: WebDirective[] | undefined;
tags: WebElement[] | undefined;
attributes: WebAttribute[] | undefined;
};
{
"name": "components-helper",
"version": "2.0.0",
"version": "2.1.0",
"description": "Based on the docs to provide code prompt files for vue component library",

@@ -53,3 +53,3 @@ "main": "lib/index.js",

"devDependencies": {
"@types/node": "^16.11.21",
"@types/node": "^18.0.6",
"@typescript-eslint/eslint-plugin": "^5.10.0",

@@ -59,7 +59,8 @@ "@typescript-eslint/parser": "^5.10.0",

"eslint-plugin-prettier": "^4.0.0",
"husky": "^7.0.4",
"lint-staged": "^12.2.2",
"husky": "^8.0.1",
"lint-staged": "^13.0.3",
"prettier": "^2.5.1",
"rollup": "^2.66.0",
"rollup-plugin-typescript2": "^0.31.1",
"rollup-plugin-typescript2": "^0.32.1",
"tslib": "^2.4.0",
"typescript": "^4.5.5"

@@ -66,0 +67,0 @@ },

@@ -358,3 +358,3 @@ # components-helper

/#+\s+(`.*`)\n+>\s\*(`[^(#|\n)]*`)/g
/#+\s+(`.*`)\n+>\s*(`[^(#|\n)]*`)/g

@@ -361,0 +361,0 @@ <div>

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