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

@helios-lang/compiler-utils

Package Overview
Dependencies
Maintainers
0
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@helios-lang/compiler-utils - npm Package Compare versions

Comparing version

to
0.5.0

2

package.json
{
"name": "@helios-lang/compiler-utils",
"version": "0.4.2",
"version": "0.5.0",
"description": "Helios language compiler library",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -122,11 +122,11 @@ export {

/**
* length is a separate field because of performance
* Source is used by textual-Uplc, IR and Helios
* @typedef {object} Source
* @prop {string} content
* @prop {string} name - provided filename (or script name parsed from script header)
* @prop {string} moduleName - script/module name, parsed from the script header
* @prop {string} purpose - script purpose, parsed from the script header
* @prop {string} [project] - optional project name in which the module is defined
* @prop {string} [moreInfo] - optional additional info about the source
* @prop {number} length
* @prop {string} name provided filename (or script name parsed from script header)
* @prop {string} [moduleName] optional helios-specific script/module name, parsed from the script header
* @prop {string} [purpose] optional helios-specific script purpose, parsed from the script header
* @prop {string} [project] optional project name in which the module is defined
* @prop {string} [moreInfo] optional additional info about the source
* @prop {number} length length is a separate field because of performance
* @prop {number[]} lineEndLocations

@@ -133,0 +133,0 @@ * @prop {(i: number) => string} getChar

@@ -12,2 +12,4 @@ import { segmentArray } from "@helios-lang/codec-utils"

* @property {string} [project] - optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases
* @property {string} [purpose] - helios-specific sources have a purpose
* @property {string} [moduleName] - can differ from file name
* @property {string} [moreInfo] - additional textual info about the source, useful in advanced code-generation cases

@@ -24,3 +26,5 @@ */

* @param {object} options
* @param {string} [options.name] optional file name; defaults to the module name parsed from the source's `<purpose> <name>` header
* @param {string} [options.name] optional file name; defaults to the empty string
* @param {string} [options.purpose] helios-specific sources have a purpose
* @param {string} [options.moduleName] can differ from file name
* @param {string} [options.project] optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases

@@ -35,2 +39,23 @@ * @param {string} [options.moreInfo] additional textual info about the source, useful in advanced code-generation cases

/**
* Parses purpose and moduleName from source
* @param {string} content
* @param {object} options
* @param {string} [options.name] optional file name; defaults to the module name parsed from the source's `<purpose> <name>` header
* @param {string} [options.project] optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases
* @param {string} [options.moreInfo] additional textual info about the source, useful in advanced code-generation cases
* @returns {Source}
*/
export function makeHeliosSource(content, options = {}) {
const { moduleName, purpose } = minimalScriptInfo(content)
const name = options.name ?? moduleName
return makeSource(content, {
...options,
name,
moduleName,
purpose
})
}
/**
* A Source instance wraps a string so we can use it cheaply as a reference inside a Site.

@@ -63,3 +88,3 @@ * Also used by VSCode plugin

* @readonly
* @type {string}
* @type {string | undefined}
*/

@@ -71,3 +96,3 @@ moduleName

* @readonly
* @type {string}
* @type {string | undefined}
*/

@@ -119,4 +144,6 @@ purpose

this.content = content
// one-step split to utf-8 runes in the content
const asCodePoints = [...content]
// heuristic for chunk size

@@ -127,8 +154,10 @@ this._chunkSize = Math.max(

)
this._contentChunks = segmentArray(asCodePoints, this._chunkSize)
this.length = asCodePoints.length
const parsedInfo = minimalScriptInfo(content)
this.name = options.name ?? parsedInfo.moduleName
this.moduleName = parsedInfo.moduleName
this.purpose = parsedInfo.purpose
this.name = options.name ?? options.moduleName ?? ""
this.moduleName = options.moduleName
this.purpose = options.purpose
this.project = options.project

@@ -135,0 +164,0 @@ this.moreInfo = options.moreInfo

@@ -84,3 +84,3 @@ export { translateImportPaths } from "./formatters/index.js";

/**
* length is a separate field because of performance
* Source is used by textual-Uplc, IR and Helios
*/

@@ -90,21 +90,24 @@ export type Source = {

/**
* - provided filename (or script name parsed from script header)
* provided filename (or script name parsed from script header)
*/
name: string;
/**
* - script/module name, parsed from the script header
* optional helios-specific script/module name, parsed from the script header
*/
moduleName: string;
moduleName?: string | undefined;
/**
* - script purpose, parsed from the script header
* optional helios-specific script purpose, parsed from the script header
*/
purpose: string;
purpose?: string | undefined;
/**
* - optional project name in which the module is defined
* optional project name in which the module is defined
*/
project?: string | undefined;
/**
* - optional additional info about the source
* optional additional info about the source
*/
moreInfo?: string | undefined;
/**
* length is a separate field because of performance
*/
length: number;

@@ -111,0 +114,0 @@ lineEndLocations: number[];

@@ -9,2 +9,4 @@ /**

* @property {string} [project] - optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases
* @property {string} [purpose] - helios-specific sources have a purpose
* @property {string} [moduleName] - can differ from file name
* @property {string} [moreInfo] - additional textual info about the source, useful in advanced code-generation cases

@@ -19,3 +21,5 @@ */

* @param {object} options
* @param {string} [options.name] optional file name; defaults to the module name parsed from the source's `<purpose> <name>` header
* @param {string} [options.name] optional file name; defaults to the empty string
* @param {string} [options.purpose] helios-specific sources have a purpose
* @param {string} [options.moduleName] can differ from file name
* @param {string} [options.project] optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases

@@ -27,5 +31,21 @@ * @param {string} [options.moreInfo] additional textual info about the source, useful in advanced code-generation cases

name?: string | undefined;
purpose?: string | undefined;
moduleName?: string | undefined;
project?: string | undefined;
moreInfo?: string | undefined;
}): Source;
/**
* Parses purpose and moduleName from source
* @param {string} content
* @param {object} options
* @param {string} [options.name] optional file name; defaults to the module name parsed from the source's `<purpose> <name>` header
* @param {string} [options.project] optional project name; can be used to add transpancy for advanced cross-project source-file reference use-cases
* @param {string} [options.moreInfo] additional textual info about the source, useful in advanced code-generation cases
* @returns {Source}
*/
export function makeHeliosSource(content: string, options?: {
name?: string | undefined;
project?: string | undefined;
moreInfo?: string | undefined;
}): Source;
export type SourceOptions = {

@@ -41,2 +61,10 @@ /**

/**
* - helios-specific sources have a purpose
*/
purpose?: string | undefined;
/**
* - can differ from file name
*/
moduleName?: string | undefined;
/**
* - additional textual info about the source, useful in advanced code-generation cases

@@ -43,0 +71,0 @@ */

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet