Sign In

@wyw-in-js/processor-utils

Package Overview
Dependencies
Maintainers
2
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wyw-in-js/processor-utils - npm Package Compare versions

Comparing version
2.4.0
to
2.4.1
+1
-1
esm/BaseProcessor.js

@@ -40,3 +40,3 @@ import { hasEvalMeta } from "@wyw-in-js/shared";

isValidValue(value) {
return typeof value === "function" || isCSSable(value) || hasEvalMeta(value);
return typeof value === "function" || hasEvalMeta(value) || isCSSable(value);
}

@@ -43,0 +43,0 @@ /* eslint-enable @typescript-eslint/member-ordering */

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

{"mappings":"AAEA,SAAS,mBAAmB;AAS5B,SAAS,wBAAwB;AACjC,SAAS,yCAAyC;AASlD,OAAO,yBAAyB;AAChC,SAAS,iBAAiB;AAE1B,SAAS,sBAAsB;AAc/B,OAAO,MAAe,cAAc;CAClC,OAAc,OAAO,OAAO,OAAO;CAEnC,AAAgB,YAAwB,EAAE;CAE1C,AAAgB;CAEhB,AAAgB,eAAkC,EAAE;CAEpD,AAAO,iBAAmC,EAAE;CAE5C,AAAgB;CAEhB,AAAU;CAEV,AAAU;CAIV,AAAO,YACL,QACA,AAAO,WACP,AAAmB,YACnB,AAAgB,UAChB,AAAmB,UAInB,AAAgB,aAChB,AAAgB,cAChB,AAAmB,KACnB,AAAmB,SACnB,AAAmB,SACnB;EAZO;EACY;EACH;EACG;EAIH;EACA;EACG;EACA;EACA;AAEnB,iBACE,QACA,CAAC,SAAS,EACV,iDACD;EAED,MAAM,EAAE,WAAW,SAAS,oBAC1B,KAAK,aACL,KAAK,KACL,KAAK,SACL,KAAK,QACN;AAED,OAAK,YAAY;AACjB,OAAK,OAAO;AAEZ,GAAC,GAAG,KAAK,WAAW;;CAetB,AAAO,cAAc,YAAuC;AAC1D,OAAK,UAAU,KACb,kCAAkC;GAChC,GAAG;GACH,KAAK,WAAW,OAAO,KAAK,UAAU,OAAO;GAC7C,OAAO,WAAW,SAAS,KAAK,UAAU,SAAS;GACpD,CAAC,CACH;;CAmBH,AAAO,aAAa,OAAgC;AAClD,SACE,OAAO,UAAU,cAAc,UAAU,MAAM,IAAI,YAAY,MAAM;;;CAKzE,AAAO,WAAmB;AACxB,SAAO,KAAK,eAAe;;CAG7B,AAAU,gBAAwB;AAChC,SAAO,iBAAiB,KAAK,OAAO","names":[],"sources":["../src/BaseProcessor.ts"],"version":3,"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport type {\n AstService,\n Expression,\n Identifier,\n MemberExpression,\n SourceLocation,\n} from './ast';\nimport { expressionToCode } from './ast';\nimport { createProcessorDiagnosticArtifact } from './diagnostics';\nimport type { ProcessorStaticContext, ProcessorStaticValue } from './static';\nimport type {\n IInterpolation,\n Params,\n ProcessorDiagnostic,\n Value,\n ValueCache,\n} from './types';\nimport getClassNameAndSlug from './utils/getClassNameAndSlug';\nimport { isCSSable } from './utils/toCSS';\nimport type { IFileContext, IOptions } from './utils/types';\nimport { validateParams } from './utils/validateParams';\n\nexport type { Expression };\n\nexport type ProcessorParams = ConstructorParameters<typeof BaseProcessor>;\nexport type TailProcessorParams = ProcessorParams extends [Params, ...infer T]\n ? T\n : never;\n\nexport type TagSource = {\n imported: string;\n source: string;\n};\n\nexport abstract class BaseProcessor {\n public static SKIP = Symbol('skip');\n\n public readonly artifacts: Artifact[] = [];\n\n public readonly className: string;\n\n public readonly dependencies: ExpressionValue[] = [];\n\n public interpolations: IInterpolation[] = [];\n\n public readonly slug: string;\n\n protected callee: Identifier | MemberExpression;\n\n protected evaluated:\n | Record<'dependencies' | 'expression', Value[]>\n | undefined;\n\n public constructor(\n params: Params,\n public tagSource: TagSource,\n protected readonly astService: AstService,\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: unknown) => Expression),\n isPure: boolean\n ) => void,\n public readonly displayName: string,\n public readonly isReferenced: boolean,\n protected readonly idx: number,\n protected readonly options: IOptions,\n protected readonly context: IFileContext\n ) {\n validateParams(\n params,\n ['callee'],\n 'Unknown error: a callee param is not specified'\n );\n\n const { className, slug } = getClassNameAndSlug(\n this.displayName,\n this.idx,\n this.options,\n this.context\n );\n\n this.className = className;\n this.slug = slug;\n\n [[, this.callee]] = params;\n }\n\n /**\n * A replacement for tag referenced in a template literal.\n */\n public abstract get asSelector(): string;\n\n /**\n * A replacement for the tag in evaluation time.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with an object with metadata.\n */\n public abstract get value(): Expression;\n\n public addDiagnostic(diagnostic: ProcessorDiagnostic): void {\n this.artifacts.push(\n createProcessorDiagnosticArtifact({\n ...diagnostic,\n end: diagnostic.end ?? this.location?.end ?? null,\n start: diagnostic.start ?? this.location?.start ?? null,\n })\n );\n }\n\n /* eslint-disable @typescript-eslint/member-ordering */\n public getStaticValue?(\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public resolveStaticInterpolation?(\n interpolation: IInterpolation,\n value: ProcessorStaticValue,\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public resolveStaticTagTarget?(\n target: ProcessorStaticValue,\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || isCSSable(value) || hasEvalMeta(value)\n );\n }\n /* eslint-enable @typescript-eslint/member-ordering */\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n return expressionToCode(this.callee);\n }\n\n public abstract build(values: ValueCache): void;\n\n /**\n * Perform a replacement for the tag in evaluation time.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with an object with metadata.\n */\n public abstract doEvaltimeReplacement(): void;\n\n /**\n * Perform a replacement for the tag with its runtime version.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with a component.\n * If some parts require evaluated data for render,\n * they will be replaced with placeholders.\n */\n public abstract doRuntimeReplacement(): void;\n}\n"],"file":"BaseProcessor.js"}
{"mappings":"AAEA,SAAS,mBAAmB;AAS5B,SAAS,wBAAwB;AACjC,SAAS,yCAAyC;AASlD,OAAO,yBAAyB;AAChC,SAAS,iBAAiB;AAE1B,SAAS,sBAAsB;AAc/B,OAAO,MAAe,cAAc;CAClC,OAAc,OAAO,OAAO,OAAO;CAEnC,AAAgB,YAAwB,EAAE;CAE1C,AAAgB;CAEhB,AAAgB,eAAkC,EAAE;CAEpD,AAAO,iBAAmC,EAAE;CAE5C,AAAgB;CAEhB,AAAU;CAEV,AAAU;CAIV,AAAO,YACL,QACA,AAAO,WACP,AAAmB,YACnB,AAAgB,UAChB,AAAmB,UAInB,AAAgB,aAChB,AAAgB,cAChB,AAAmB,KACnB,AAAmB,SACnB,AAAmB,SACnB;EAZO;EACY;EACH;EACG;EAIH;EACA;EACG;EACA;EACA;AAEnB,iBACE,QACA,CAAC,SAAS,EACV,iDACD;EAED,MAAM,EAAE,WAAW,SAAS,oBAC1B,KAAK,aACL,KAAK,KACL,KAAK,SACL,KAAK,QACN;AAED,OAAK,YAAY;AACjB,OAAK,OAAO;AAEZ,GAAC,GAAG,KAAK,WAAW;;CAetB,AAAO,cAAc,YAAuC;AAC1D,OAAK,UAAU,KACb,kCAAkC;GAChC,GAAG;GACH,KAAK,WAAW,OAAO,KAAK,UAAU,OAAO;GAC7C,OAAO,WAAW,SAAS,KAAK,UAAU,SAAS;GACpD,CAAC,CACH;;CAmBH,AAAO,aAAa,OAAgC;AAClD,SACE,OAAO,UAAU,cAAc,YAAY,MAAM,IAAI,UAAU,MAAM;;;CAKzE,AAAO,WAAmB;AACxB,SAAO,KAAK,eAAe;;CAG7B,AAAU,gBAAwB;AAChC,SAAO,iBAAiB,KAAK,OAAO","names":[],"sources":["../src/BaseProcessor.ts"],"version":3,"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport type {\n AstService,\n Expression,\n Identifier,\n MemberExpression,\n SourceLocation,\n} from './ast';\nimport { expressionToCode } from './ast';\nimport { createProcessorDiagnosticArtifact } from './diagnostics';\nimport type { ProcessorStaticContext, ProcessorStaticValue } from './static';\nimport type {\n IInterpolation,\n Params,\n ProcessorDiagnostic,\n Value,\n ValueCache,\n} from './types';\nimport getClassNameAndSlug from './utils/getClassNameAndSlug';\nimport { isCSSable } from './utils/toCSS';\nimport type { IFileContext, IOptions } from './utils/types';\nimport { validateParams } from './utils/validateParams';\n\nexport type { Expression };\n\nexport type ProcessorParams = ConstructorParameters<typeof BaseProcessor>;\nexport type TailProcessorParams = ProcessorParams extends [Params, ...infer T]\n ? T\n : never;\n\nexport type TagSource = {\n imported: string;\n source: string;\n};\n\nexport abstract class BaseProcessor {\n public static SKIP = Symbol('skip');\n\n public readonly artifacts: Artifact[] = [];\n\n public readonly className: string;\n\n public readonly dependencies: ExpressionValue[] = [];\n\n public interpolations: IInterpolation[] = [];\n\n public readonly slug: string;\n\n protected callee: Identifier | MemberExpression;\n\n protected evaluated:\n | Record<'dependencies' | 'expression', Value[]>\n | undefined;\n\n public constructor(\n params: Params,\n public tagSource: TagSource,\n protected readonly astService: AstService,\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: unknown) => Expression),\n isPure: boolean\n ) => void,\n public readonly displayName: string,\n public readonly isReferenced: boolean,\n protected readonly idx: number,\n protected readonly options: IOptions,\n protected readonly context: IFileContext\n ) {\n validateParams(\n params,\n ['callee'],\n 'Unknown error: a callee param is not specified'\n );\n\n const { className, slug } = getClassNameAndSlug(\n this.displayName,\n this.idx,\n this.options,\n this.context\n );\n\n this.className = className;\n this.slug = slug;\n\n [[, this.callee]] = params;\n }\n\n /**\n * A replacement for tag referenced in a template literal.\n */\n public abstract get asSelector(): string;\n\n /**\n * A replacement for the tag in evaluation time.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with an object with metadata.\n */\n public abstract get value(): Expression;\n\n public addDiagnostic(diagnostic: ProcessorDiagnostic): void {\n this.artifacts.push(\n createProcessorDiagnosticArtifact({\n ...diagnostic,\n end: diagnostic.end ?? this.location?.end ?? null,\n start: diagnostic.start ?? this.location?.start ?? null,\n })\n );\n }\n\n /* eslint-disable @typescript-eslint/member-ordering */\n public getStaticValue?(\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public resolveStaticInterpolation?(\n interpolation: IInterpolation,\n value: ProcessorStaticValue,\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public resolveStaticTagTarget?(\n target: ProcessorStaticValue,\n context: ProcessorStaticContext\n ): ProcessorStaticValue | null | undefined;\n\n public isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || hasEvalMeta(value) || isCSSable(value)\n );\n }\n /* eslint-enable @typescript-eslint/member-ordering */\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n return expressionToCode(this.callee);\n }\n\n public abstract build(values: ValueCache): void;\n\n /**\n * Perform a replacement for the tag in evaluation time.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with an object with metadata.\n */\n public abstract doEvaltimeReplacement(): void;\n\n /**\n * Perform a replacement for the tag with its runtime version.\n * For example, `css` tag will be replaced with its className,\n * whereas `styled` tag will be replaced with a component.\n * If some parts require evaluated data for render,\n * they will be replaced with placeholders.\n */\n public abstract doRuntimeReplacement(): void;\n}\n"],"file":"BaseProcessor.js"}
{
"name": "@wyw-in-js/processor-utils",
"version": "2.4.0",
"version": "2.4.1",
"type": "module",

@@ -5,0 +5,0 @@ "dependencies": {

@@ -49,3 +49,3 @@ import { hasEvalMeta } from '@wyw-in-js/shared';

isValidValue(value) {
return (typeof value === 'function' || isCSSable(value) || hasEvalMeta(value));
return (typeof value === 'function' || hasEvalMeta(value) || isCSSable(value));
}

@@ -52,0 +52,0 @@ /* eslint-enable @typescript-eslint/member-ordering */