🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@wyw-in-js/processor-utils

Package Overview
Dependencies
Maintainers
2
Versions
30
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
1.0.5
to
1.1.0
+4
esm/diagnostics.js
export const PROCESSOR_DIAGNOSTIC_ARTIFACT = 'wyw-in-js:diagnostic';
export const createProcessorDiagnosticArtifact = diagnostic => [PROCESSOR_DIAGNOSTIC_ARTIFACT, diagnostic];
export const isProcessorDiagnosticArtifact = artifact => artifact[0] === PROCESSOR_DIAGNOSTIC_ARTIFACT;
//# sourceMappingURL=diagnostics.js.map
{"version":3,"file":"diagnostics.js","names":["PROCESSOR_DIAGNOSTIC_ARTIFACT","createProcessorDiagnosticArtifact","diagnostic","isProcessorDiagnosticArtifact","artifact"],"sources":["../src/diagnostics.ts"],"sourcesContent":["import type { Artifact } from '@wyw-in-js/shared';\n\nimport type { ProcessorDiagnostic } from './types';\n\nexport const PROCESSOR_DIAGNOSTIC_ARTIFACT = 'wyw-in-js:diagnostic' as const;\n\nexport type ProcessorDiagnosticArtifact = [\n name: typeof PROCESSOR_DIAGNOSTIC_ARTIFACT,\n data: ProcessorDiagnostic,\n];\n\nexport const createProcessorDiagnosticArtifact = (\n diagnostic: ProcessorDiagnostic\n): ProcessorDiagnosticArtifact => [PROCESSOR_DIAGNOSTIC_ARTIFACT, diagnostic];\n\nexport const isProcessorDiagnosticArtifact = (\n artifact: Artifact\n): artifact is ProcessorDiagnosticArtifact =>\n artifact[0] === PROCESSOR_DIAGNOSTIC_ARTIFACT;\n"],"mappings":"AAIA,OAAO,MAAMA,6BAA6B,GAAG,sBAA+B;AAO5E,OAAO,MAAMC,iCAAiC,GAC5CC,UAA+B,IACC,CAACF,6BAA6B,EAAEE,UAAU,CAAC;AAE7E,OAAO,MAAMC,6BAA6B,GACxCC,QAAkB,IAElBA,QAAQ,CAAC,CAAC,CAAC,KAAKJ,6BAA6B","ignoreList":[]}
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isProcessorDiagnosticArtifact = exports.createProcessorDiagnosticArtifact = exports.PROCESSOR_DIAGNOSTIC_ARTIFACT = void 0;
const PROCESSOR_DIAGNOSTIC_ARTIFACT = exports.PROCESSOR_DIAGNOSTIC_ARTIFACT = 'wyw-in-js:diagnostic';
const createProcessorDiagnosticArtifact = diagnostic => [PROCESSOR_DIAGNOSTIC_ARTIFACT, diagnostic];
exports.createProcessorDiagnosticArtifact = createProcessorDiagnosticArtifact;
const isProcessorDiagnosticArtifact = artifact => artifact[0] === PROCESSOR_DIAGNOSTIC_ARTIFACT;
exports.isProcessorDiagnosticArtifact = isProcessorDiagnosticArtifact;
//# sourceMappingURL=diagnostics.js.map
{"version":3,"file":"diagnostics.js","names":["PROCESSOR_DIAGNOSTIC_ARTIFACT","exports","createProcessorDiagnosticArtifact","diagnostic","isProcessorDiagnosticArtifact","artifact"],"sources":["../src/diagnostics.ts"],"sourcesContent":["import type { Artifact } from '@wyw-in-js/shared';\n\nimport type { ProcessorDiagnostic } from './types';\n\nexport const PROCESSOR_DIAGNOSTIC_ARTIFACT = 'wyw-in-js:diagnostic' as const;\n\nexport type ProcessorDiagnosticArtifact = [\n name: typeof PROCESSOR_DIAGNOSTIC_ARTIFACT,\n data: ProcessorDiagnostic,\n];\n\nexport const createProcessorDiagnosticArtifact = (\n diagnostic: ProcessorDiagnostic\n): ProcessorDiagnosticArtifact => [PROCESSOR_DIAGNOSTIC_ARTIFACT, diagnostic];\n\nexport const isProcessorDiagnosticArtifact = (\n artifact: Artifact\n): artifact is ProcessorDiagnosticArtifact =>\n artifact[0] === PROCESSOR_DIAGNOSTIC_ARTIFACT;\n"],"mappings":";;;;;;AAIO,MAAMA,6BAA6B,GAAAC,OAAA,CAAAD,6BAAA,GAAG,sBAA+B;AAOrE,MAAME,iCAAiC,GAC5CC,UAA+B,IACC,CAACH,6BAA6B,EAAEG,UAAU,CAAC;AAACF,OAAA,CAAAC,iCAAA,GAAAA,iCAAA;AAEvE,MAAME,6BAA6B,GACxCC,QAAkB,IAElBA,QAAQ,CAAC,CAAC,CAAC,KAAKL,6BAA6B;AAACC,OAAA,CAAAG,6BAAA,GAAAA,6BAAA","ignoreList":[]}
import type { Artifact } from '@wyw-in-js/shared';
import type { ProcessorDiagnostic } from './types';
export declare const PROCESSOR_DIAGNOSTIC_ARTIFACT: "wyw-in-js:diagnostic";
export type ProcessorDiagnosticArtifact = [
name: typeof PROCESSOR_DIAGNOSTIC_ARTIFACT,
data: ProcessorDiagnostic
];
export declare const createProcessorDiagnosticArtifact: (diagnostic: ProcessorDiagnostic) => ProcessorDiagnosticArtifact;
export declare const isProcessorDiagnosticArtifact: (artifact: Artifact) => artifact is ProcessorDiagnosticArtifact;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isProcessorDiagnosticArtifact = exports.createProcessorDiagnosticArtifact = exports.PROCESSOR_DIAGNOSTIC_ARTIFACT = void 0;
exports.PROCESSOR_DIAGNOSTIC_ARTIFACT = 'wyw-in-js:diagnostic';
const createProcessorDiagnosticArtifact = (diagnostic) => [exports.PROCESSOR_DIAGNOSTIC_ARTIFACT, diagnostic];
exports.createProcessorDiagnosticArtifact = createProcessorDiagnosticArtifact;
const isProcessorDiagnosticArtifact = (artifact) => artifact[0] === exports.PROCESSOR_DIAGNOSTIC_ARTIFACT;
exports.isProcessorDiagnosticArtifact = isProcessorDiagnosticArtifact;
+8
-0

@@ -5,2 +5,3 @@ /* eslint-disable class-methods-use-this */

import { hasEvalMeta } from '@wyw-in-js/shared';
import { createProcessorDiagnosticArtifact } from './diagnostics';
import getClassNameAndSlug from './utils/getClassNameAndSlug';

@@ -44,2 +45,9 @@ import { isCSSable } from './utils/toCSS';

addDiagnostic(diagnostic) {
this.artifacts.push(createProcessorDiagnosticArtifact({
...diagnostic,
end: diagnostic.end ?? this.location?.end ?? null,
start: diagnostic.start ?? this.location?.start ?? null
}));
}
isValidValue(value) {

@@ -46,0 +54,0 @@ return typeof value === 'function' || isCSSable(value) || hasEvalMeta(value);

+1
-1

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

{"version":3,"file":"BaseProcessor.js","names":["generator","hasEvalMeta","getClassNameAndSlug","isCSSable","validateParams","BaseProcessor","SKIP","Symbol","artifacts","dependencies","interpolations","constructor","params","tagSource","astService","location","replacer","displayName","isReferenced","idx","options","context","className","slug","callee","isValidValue","value","toString","tagSourceCode","type","name","code"],"sources":["../src/BaseProcessor.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { NodePath, types as t } from '@babel/core';\nimport generator from '@babel/generator';\nimport type {\n Expression,\n Identifier,\n SourceLocation,\n MemberExpression,\n} from '@babel/types';\n\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport type { IInterpolation, Params, Value, ValueCache } 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 { 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: typeof t & {\n addDefaultImport: (source: string, nameHint?: string) => Identifier;\n addNamedImport: (\n name: string,\n source: string,\n nameHint?: string\n ) => Identifier;\n },\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: NodePath) => 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 isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || isCSSable(value) || hasEvalMeta(value)\n );\n }\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n if (this.callee.type === 'Identifier') {\n return this.callee.name;\n }\n\n return generator(this.callee).code;\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"],"mappings":"AAAA;;AAEA,OAAOA,SAAS,MAAM,kBAAkB;AASxC,SAASC,WAAW,QAAQ,mBAAmB;AAG/C,OAAOC,mBAAmB,MAAM,6BAA6B;AAC7D,SAASC,SAAS,QAAQ,eAAe;AAEzC,SAASC,cAAc,QAAQ,wBAAwB;AAcvD,OAAO,MAAeC,aAAa,CAAC;EAClC,OAAcC,IAAI,GAAGC,MAAM,CAAC,MAAM,CAAC;EAEnBC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J,MAAM,CAACK,IAAI,KAAK,YAAY,EAAE;MACrC,OAAO,IAAI,CAACL,MAAM,CAACM,IAAI;IACzB;IAEA,OAAO9B,SAAS,CAAC,IAAI,CAACwB,MAAM,CAAC,CAACO,IAAI;EACpC;;EAIA;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AAEA","ignoreList":[]}
{"version":3,"file":"BaseProcessor.js","names":["generator","hasEvalMeta","createProcessorDiagnosticArtifact","getClassNameAndSlug","isCSSable","validateParams","BaseProcessor","SKIP","Symbol","artifacts","dependencies","interpolations","constructor","params","tagSource","astService","location","replacer","displayName","isReferenced","idx","options","context","className","slug","callee","addDiagnostic","diagnostic","push","end","start","isValidValue","value","toString","tagSourceCode","type","name","code"],"sources":["../src/BaseProcessor.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { NodePath, types as t } from '@babel/core';\nimport generator from '@babel/generator';\nimport type {\n Expression,\n Identifier,\n SourceLocation,\n MemberExpression,\n} from '@babel/types';\n\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport { createProcessorDiagnosticArtifact } from './diagnostics';\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 { 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: typeof t & {\n addDefaultImport: (source: string, nameHint?: string) => Identifier;\n addNamedImport: (\n name: string,\n source: string,\n nameHint?: string\n ) => Identifier;\n },\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: NodePath) => 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 public isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || isCSSable(value) || hasEvalMeta(value)\n );\n }\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n if (this.callee.type === 'Identifier') {\n return this.callee.name;\n }\n\n return generator(this.callee).code;\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"],"mappings":"AAAA;;AAEA,OAAOA,SAAS,MAAM,kBAAkB;AASxC,SAASC,WAAW,QAAQ,mBAAmB;AAE/C,SAASC,iCAAiC,QAAQ,eAAe;AAQjE,OAAOC,mBAAmB,MAAM,6BAA6B;AAC7D,SAASC,SAAS,QAAQ,eAAe;AAEzC,SAASC,cAAc,QAAQ,wBAAwB;AAcvD,OAAO,MAAeC,aAAa,CAAC;EAClC,OAAcC,IAAI,GAAGC,MAAM,CAAC,MAAM,CAAC;EAEnBC,SAAS,GAAe,EAAE;EAI1BC,YAAY,GAAsB,EAAE;EAE7CC,cAAc,GAAqB,EAAE;EAUrCC,WAAWA,CAChBC,MAAc,EACPC,SAAoB,EACRC,UAOlB,EACeC,QAA+B,EAC5BC,QAGV,EACOC,WAAmB,EACnBC,YAAqB,EAClBC,GAAW,EACXC,OAAiB,EACjBC,OAAqB,EACxC;IAAA,KAnBOR,SAAoB,GAApBA,SAAoB;IAAA,KACRC,UAOlB,GAPkBA,UAOlB;IAAA,KACeC,QAA+B,GAA/BA,QAA+B;IAAA,KAC5BC,QAGV,GAHUA,QAGV;IAAA,KACOC,WAAmB,GAAnBA,WAAmB;IAAA,KACnBC,YAAqB,GAArBA,YAAqB;IAAA,KAClBC,GAAW,GAAXA,GAAW;IAAA,KACXC,OAAiB,GAAjBA,OAAiB;IAAA,KACjBC,OAAqB,GAArBA,OAAqB;IAExCjB,cAAc,CACZQ,MAAM,EACN,CAAC,QAAQ,CAAC,EACV,gDACF,CAAC;IAED,MAAM;MAAEU,SAAS;MAAEC;IAAK,CAAC,GAAGrB,mBAAmB,CAC7C,IAAI,CAACe,WAAW,EAChB,IAAI,CAACE,GAAG,EACR,IAAI,CAACC,OAAO,EACZ,IAAI,CAACC,OACP,CAAC;IAED,IAAI,CAACC,SAAS,GAAGA,SAAS;IAC1B,IAAI,CAACC,IAAI,GAAGA,IAAI;IAEhB,CAAC,GAAG,IAAI,CAACC,MAAM,CAAC,CAAC,GAAGZ,MAAM;EAC5B;;EAEA;AACF;AACA;;EAGE;AACF;AACA;AACA;AACA;;EAGSa,aAAaA,CAACC,UAA+B,EAAQ;IAC1D,IAAI,CAAClB,SAAS,CAACmB,IAAI,CACjB1B,iCAAiC,CAAC;MAChC,GAAGyB,UAAU;MACbE,GAAG,EAAEF,UAAU,CAACE,GAAG,IAAI,IAAI,CAACb,QAAQ,EAAEa,GAAG,IAAI,IAAI;MACjDC,KAAK,EAAEH,UAAU,CAACG,KAAK,IAAI,IAAI,CAACd,QAAQ,EAAEc,KAAK,IAAI;IACrD,CAAC,CACH,CAAC;EACH;EAEOC,YAAYA,CAACC,KAAc,EAAkB;IAClD,OACE,OAAOA,KAAK,KAAK,UAAU,IAAI5B,SAAS,CAAC4B,KAAK,CAAC,IAAI/B,WAAW,CAAC+B,KAAK,CAAC;EAEzE;EAEOC,QAAQA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACC,aAAa,CAAC,CAAC;EAC7B;EAEUA,aAAaA,CAAA,EAAW;IAChC,IAAI,IAAI,CAACT,MAAM,CAACU,IAAI,KAAK,YAAY,EAAE;MACrC,OAAO,IAAI,CAACV,MAAM,CAACW,IAAI;IACzB;IAEA,OAAOpC,SAAS,CAAC,IAAI,CAACyB,MAAM,CAAC,CAACY,IAAI;EACpC;;EAIA;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AAEA","ignoreList":[]}
export { BaseProcessor } from './BaseProcessor';
export { createProcessorDiagnosticArtifact, isProcessorDiagnosticArtifact, PROCESSOR_DIAGNOSTIC_ARTIFACT } from './diagnostics';
export * from './types';

@@ -3,0 +4,0 @@ export { buildSlug } from './utils/buildSlug';

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

{"version":3,"file":"index.js","names":["BaseProcessor","buildSlug","isValidParams","validateParams","TaggedTemplateProcessor","toValidCSSIdentifier"],"sources":["../src/index.ts"],"sourcesContent":["export { BaseProcessor } from './BaseProcessor';\nexport type {\n Expression,\n TagSource,\n ProcessorParams,\n TailProcessorParams,\n} from './BaseProcessor';\nexport * from './types';\nexport { buildSlug } from './utils/buildSlug';\nexport type { IOptions, IFileContext } from './utils/types';\nexport { isValidParams, validateParams } from './utils/validateParams';\nexport type { MapParams, ParamConstraints } from './utils/validateParams';\nexport { TaggedTemplateProcessor } from './TaggedTemplateProcessor';\nexport { toValidCSSIdentifier } from './utils/toValidCSSIdentifier';\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAO/C,cAAc,SAAS;AACvB,SAASC,SAAS,QAAQ,mBAAmB;AAE7C,SAASC,aAAa,EAAEC,cAAc,QAAQ,wBAAwB;AAEtE,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,8BAA8B","ignoreList":[]}
{"version":3,"file":"index.js","names":["BaseProcessor","createProcessorDiagnosticArtifact","isProcessorDiagnosticArtifact","PROCESSOR_DIAGNOSTIC_ARTIFACT","buildSlug","isValidParams","validateParams","TaggedTemplateProcessor","toValidCSSIdentifier"],"sources":["../src/index.ts"],"sourcesContent":["export { BaseProcessor } from './BaseProcessor';\nexport {\n createProcessorDiagnosticArtifact,\n isProcessorDiagnosticArtifact,\n PROCESSOR_DIAGNOSTIC_ARTIFACT,\n} from './diagnostics';\nexport type { ProcessorDiagnosticArtifact } from './diagnostics';\nexport type {\n Expression,\n TagSource,\n ProcessorParams,\n TailProcessorParams,\n} from './BaseProcessor';\nexport * from './types';\nexport { buildSlug } from './utils/buildSlug';\nexport type { IOptions, IFileContext } from './utils/types';\nexport { isValidParams, validateParams } from './utils/validateParams';\nexport type { MapParams, ParamConstraints } from './utils/validateParams';\nexport { TaggedTemplateProcessor } from './TaggedTemplateProcessor';\nexport { toValidCSSIdentifier } from './utils/toValidCSSIdentifier';\n"],"mappings":"AAAA,SAASA,aAAa,QAAQ,iBAAiB;AAC/C,SACEC,iCAAiC,EACjCC,6BAA6B,EAC7BC,6BAA6B,QACxB,eAAe;AAQtB,cAAc,SAAS;AACvB,SAASC,SAAS,QAAQ,mBAAmB;AAE7C,SAASC,aAAa,EAAEC,cAAc,QAAQ,wBAAwB;AAEtE,SAASC,uBAAuB,QAAQ,2BAA2B;AACnE,SAASC,oBAAoB,QAAQ,8BAA8B","ignoreList":[]}

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

{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n Expression,\n Identifier,\n TemplateElement,\n MemberExpression,\n} from '@babel/types';\n\nimport type { ExpressionValue, Location, WYWEvalMeta } from '@wyw-in-js/shared';\n\nexport type CSSPropertyValue = string | number;\n\nexport type ObjectWithSelectors = {\n [key: string]:\n | ObjectWithSelectors\n | CSSPropertyValue\n | (ObjectWithSelectors | CSSPropertyValue)[];\n};\n\nexport type CSSable = ObjectWithSelectors[string];\n\nexport type Value = (() => void) | WYWEvalMeta | CSSable;\n\nexport type ValueCache = Map<string | number | boolean | null, unknown>;\n\nexport interface ICSSRule {\n atom?: boolean;\n className: string;\n cssText: string;\n displayName: string;\n start: Location | null | undefined;\n}\n\nexport interface IInterpolation {\n id: string;\n node: Expression;\n source: string;\n unit: string;\n}\n\nexport type Rules = Record<string, ICSSRule>;\n\nexport type CalleeParam = readonly ['callee', Identifier | MemberExpression];\nexport type CallParam = readonly ['call', ...ExpressionValue[]];\nexport type MemberParam = readonly ['member', string];\nexport type TemplateParam = readonly [\n 'template',\n (TemplateElement | ExpressionValue)[],\n];\n\nexport type Param = CalleeParam | CallParam | MemberParam | TemplateParam;\nexport type Params = readonly Param[];\n"],"mappings":"","ignoreList":[]}
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n Expression,\n Identifier,\n TemplateElement,\n MemberExpression,\n} from '@babel/types';\n\nimport type { ExpressionValue, Location, WYWEvalMeta } from '@wyw-in-js/shared';\n\nexport type CSSPropertyValue = string | number;\n\nexport type ObjectWithSelectors = {\n [key: string]:\n | ObjectWithSelectors\n | CSSPropertyValue\n | (ObjectWithSelectors | CSSPropertyValue)[];\n};\n\nexport type CSSable = ObjectWithSelectors[string];\n\nexport type Value = (() => void) | WYWEvalMeta | CSSable;\n\nexport type ValueCache = Map<string | number | boolean | null, unknown>;\n\nexport interface ICSSRule {\n atom?: boolean;\n className: string;\n cssText: string;\n displayName: string;\n start: Location | null | undefined;\n}\n\nexport interface IInterpolation {\n id: string;\n node: Expression;\n source: string;\n unit: string;\n}\n\nexport type ProcessorDiagnosticSeverity = 'error' | 'warning';\n\nexport type ProcessorDiagnostic = {\n category: string;\n end?: Location | null;\n message: string;\n severity: ProcessorDiagnosticSeverity;\n start?: Location | null;\n};\n\nexport type Rules = Record<string, ICSSRule>;\n\nexport type CalleeParam = readonly ['callee', Identifier | MemberExpression];\nexport type CallParam = readonly ['call', ...ExpressionValue[]];\nexport type MemberParam = readonly ['member', string];\nexport type TemplateParam = readonly [\n 'template',\n (TemplateElement | ExpressionValue)[],\n];\n\nexport type Param = CalleeParam | CallParam | MemberParam | TemplateParam;\nexport type Params = readonly Param[];\n"],"mappings":"","ignoreList":[]}

@@ -9,2 +9,3 @@ "use strict";

var _shared = require("@wyw-in-js/shared");
var _diagnostics = require("./diagnostics");
var _getClassNameAndSlug = _interopRequireDefault(require("./utils/getClassNameAndSlug"));

@@ -51,2 +52,10 @@ var _toCSS = require("./utils/toCSS");

addDiagnostic(diagnostic) {
var _ref, _diagnostic$end, _this$location, _ref2, _diagnostic$start, _this$location2;
this.artifacts.push((0, _diagnostics.createProcessorDiagnosticArtifact)({
...diagnostic,
end: (_ref = (_diagnostic$end = diagnostic.end) !== null && _diagnostic$end !== void 0 ? _diagnostic$end : (_this$location = this.location) === null || _this$location === void 0 ? void 0 : _this$location.end) !== null && _ref !== void 0 ? _ref : null,
start: (_ref2 = (_diagnostic$start = diagnostic.start) !== null && _diagnostic$start !== void 0 ? _diagnostic$start : (_this$location2 = this.location) === null || _this$location2 === void 0 ? void 0 : _this$location2.start) !== null && _ref2 !== void 0 ? _ref2 : null
}));
}
isValidValue(value) {

@@ -53,0 +62,0 @@ return typeof value === 'function' || (0, _toCSS.isCSSable)(value) || (0, _shared.hasEvalMeta)(value);

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

{"version":3,"file":"BaseProcessor.js","names":["_generator","_interopRequireDefault","require","_shared","_getClassNameAndSlug","_toCSS","_validateParams","e","__esModule","default","BaseProcessor","SKIP","Symbol","artifacts","dependencies","interpolations","constructor","params","tagSource","astService","location","replacer","displayName","isReferenced","idx","options","context","validateParams","className","slug","getClassNameAndSlug","callee","isValidValue","value","isCSSable","hasEvalMeta","toString","tagSourceCode","type","name","generator","code","exports"],"sources":["../src/BaseProcessor.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { NodePath, types as t } from '@babel/core';\nimport generator from '@babel/generator';\nimport type {\n Expression,\n Identifier,\n SourceLocation,\n MemberExpression,\n} from '@babel/types';\n\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport type { IInterpolation, Params, Value, ValueCache } 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 { 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: typeof t & {\n addDefaultImport: (source: string, nameHint?: string) => Identifier;\n addNamedImport: (\n name: string,\n source: string,\n nameHint?: string\n ) => Identifier;\n },\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: NodePath) => 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 isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || isCSSable(value) || hasEvalMeta(value)\n );\n }\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n if (this.callee.type === 'Identifier') {\n return this.callee.name;\n }\n\n return generator(this.callee).code;\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"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,oBAAA,GAAAH,sBAAA,CAAAC,OAAA;AACA,IAAA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GSe,YAAYA,CAACC,KAAc,EAAkB;IAClD,OACE,OAAOA,KAAK,KAAK,UAAU,IAAI,IAAAC,gBAAS,EAACD,KAAK,CAAC,IAAI,IAAAE,mBAAW,EAACF,KAAK,CAAC;EAEzE;EAEOG,QAAQA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACC,aAAa,CAAC,CAAC;EAC7B;EAEUA,aAAaA,CAAA,EAAW;IAChC,IAAI,IAAI,CAACN,MAAM,CAACO,IAAI,KAAK,YAAY,EAAE;MACrC,OAAO,IAAI,CAACP,MAAM,CAACQ,IAAI;IACzB;IAEA,OAAO,IAAAC,kBAAS,EAAC,IAAI,CAACT,MAAM,CAAC,CAACU,IAAI;EACpC;;EAIA;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AAEA;AAACC,OAAA,CAAAhC,aAAA,GAAAA,aAAA","ignoreList":[]}
{"version":3,"file":"BaseProcessor.js","names":["_generator","_interopRequireDefault","require","_shared","_diagnostics","_getClassNameAndSlug","_toCSS","_validateParams","e","__esModule","default","BaseProcessor","SKIP","Symbol","artifacts","dependencies","interpolations","constructor","params","tagSource","astService","location","replacer","displayName","isReferenced","idx","options","context","validateParams","className","slug","getClassNameAndSlug","callee","addDiagnostic","diagnostic","_ref","_diagnostic$end","_this$location","_ref2","_diagnostic$start","_this$location2","push","createProcessorDiagnosticArtifact","end","start","isValidValue","value","isCSSable","hasEvalMeta","toString","tagSourceCode","type","name","generator","code","exports"],"sources":["../src/BaseProcessor.ts"],"sourcesContent":["/* eslint-disable class-methods-use-this */\nimport type { NodePath, types as t } from '@babel/core';\nimport generator from '@babel/generator';\nimport type {\n Expression,\n Identifier,\n SourceLocation,\n MemberExpression,\n} from '@babel/types';\n\nimport type { Artifact, ExpressionValue } from '@wyw-in-js/shared';\nimport { hasEvalMeta } from '@wyw-in-js/shared';\n\nimport { createProcessorDiagnosticArtifact } from './diagnostics';\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 { 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: typeof t & {\n addDefaultImport: (source: string, nameHint?: string) => Identifier;\n addNamedImport: (\n name: string,\n source: string,\n nameHint?: string\n ) => Identifier;\n },\n public readonly location: SourceLocation | null,\n protected readonly replacer: (\n replacement: Expression | ((tagPath: NodePath) => 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 public isValidValue(value: unknown): value is Value {\n return (\n typeof value === 'function' || isCSSable(value) || hasEvalMeta(value)\n );\n }\n\n public toString(): string {\n return this.tagSourceCode();\n }\n\n protected tagSourceCode(): string {\n if (this.callee.type === 'Identifier') {\n return this.callee.name;\n }\n\n return generator(this.callee).code;\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"],"mappings":";;;;;;AAEA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AASA,IAAAC,OAAA,GAAAD,OAAA;AAEA,IAAAE,YAAA,GAAAF,OAAA;AAQA,IAAAG,oBAAA,GAAAJ,sBAAA,CAAAC,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,IAAAK,eAAA,GAAAL,OAAA;AAAwD,SAAAD,uBAAAO,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAxBxD;;AAsCO,MAAeG,aAAa,CAAC;EAClC,OAAcC,IAAI,GAAGC,MAAM,CAAC,MAAM,CAAC;EAEnBC,SAAS,GAAe,EAAE;EAI1BC,YAAY,GAAsB,EAAE;EAE7CC,cAAc,GAAqB,EAAE;EAUrCC,WAAWA,CAChBC,MAAc,EACPC,SAAoB,EACRC,UAOlB,EACeC,QAA+B,EAC5BC,QAGV,EACOC,WAAmB,EACnBC,YAAqB,EAClBC,GAAW,EACXC,OAAiB,EACjBC,OAAqB,EACxC;IAAA,KAnB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AAAA,iBAAA,IAAAC,eAAA,GAAI,IAAI,CAACnB,QAAQ,cAAAmB,eAAA,uBAAbA,eAAA,CAAeI,KAAK,cAAAN,KAAA,cAAAA,KAAA,GAAI;IACrD,CAAC,CACH,CAAC;EACH;EAEOO,YAAYA,CAACC,KAAc,EAAkB;IAClD,OACE,OAAOA,KAAK,KAAK,UAAU,IAAI,IAAAC,gBAAS,EAACD,KAAK,CAAC,IAAI,IAAAE,mBAAW,EAACF,KAAK,CAAC;EAEzE;EAEOG,QAAQA,CAAA,EAAW;IACxB,OAAO,IAAI,CAACC,aAAa,CAAC,CAAC;EAC7B;EAEUA,aAAaA,CAAA,EAAW;IAChC,IAAI,IAAI,CAAClB,MAAM,CAACmB,IAAI,KAAK,YAAY,EAAE;MACrC,OAAO,IAAI,CAACnB,MAAM,CAACoB,IAAI;IACzB;IAEA,OAAO,IAAAC,kBAAS,EAAC,IAAI,CAACrB,MAAM,CAAC,CAACsB,IAAI;EACpC;;EAIA;AACF;AACA;AACA;AACA;;EAGE;AACF;AACA;AACA;AACA;AACA;AACA;AAEA;AAACC,OAAA,CAAA5C,aAAA,GAAAA,aAAA","ignoreList":[]}

@@ -8,2 +8,5 @@ "use strict";

BaseProcessor: true,
createProcessorDiagnosticArtifact: true,
isProcessorDiagnosticArtifact: true,
PROCESSOR_DIAGNOSTIC_ARTIFACT: true,
buildSlug: true,

@@ -21,2 +24,8 @@ isValidParams: true,

});
Object.defineProperty(exports, "PROCESSOR_DIAGNOSTIC_ARTIFACT", {
enumerable: true,
get: function () {
return _diagnostics.PROCESSOR_DIAGNOSTIC_ARTIFACT;
}
});
Object.defineProperty(exports, "TaggedTemplateProcessor", {

@@ -34,2 +43,14 @@ enumerable: true,

});
Object.defineProperty(exports, "createProcessorDiagnosticArtifact", {
enumerable: true,
get: function () {
return _diagnostics.createProcessorDiagnosticArtifact;
}
});
Object.defineProperty(exports, "isProcessorDiagnosticArtifact", {
enumerable: true,
get: function () {
return _diagnostics.isProcessorDiagnosticArtifact;
}
});
Object.defineProperty(exports, "isValidParams", {

@@ -54,2 +75,3 @@ enumerable: true,

var _BaseProcessor = require("./BaseProcessor");
var _diagnostics = require("./diagnostics");
var _types = require("./types");

@@ -56,0 +78,0 @@ Object.keys(_types).forEach(function (key) {

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

{"version":3,"file":"index.js","names":["_BaseProcessor","require","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_buildSlug","_validateParams","_TaggedTemplateProcessor","_toValidCSSIdentifier"],"sources":["../src/index.ts"],"sourcesContent":["export { BaseProcessor } from './BaseProcessor';\nexport type {\n Expression,\n TagSource,\n ProcessorParams,\n TailProcessorParams,\n} from './BaseProcessor';\nexport * from './types';\nexport { buildSlug } from './utils/buildSlug';\nexport type { IOptions, IFileContext } from './utils/types';\nexport { isValidParams, validateParams } from './utils/validateParams';\nexport type { MapParams, ParamConstraints } from './utils/validateParams';\nexport { TaggedTemplateProcessor } from './TaggedTemplateProcessor';\nexport { toValidCSSIdentifier } from './utils/toValidCSSIdentifier';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AAOA,IAAAC,MAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAd,OAAA;AAEA,IAAAe,eAAA,GAAAf,OAAA;AAEA,IAAAgB,wBAAA,GAAAhB,OAAA;AACA,IAAAiB,qBAAA,GAAAjB,OAAA","ignoreList":[]}
{"version":3,"file":"index.js","names":["_BaseProcessor","require","_diagnostics","_types","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_buildSlug","_validateParams","_TaggedTemplateProcessor","_toValidCSSIdentifier"],"sources":["../src/index.ts"],"sourcesContent":["export { BaseProcessor } from './BaseProcessor';\nexport {\n createProcessorDiagnosticArtifact,\n isProcessorDiagnosticArtifact,\n PROCESSOR_DIAGNOSTIC_ARTIFACT,\n} from './diagnostics';\nexport type { ProcessorDiagnosticArtifact } from './diagnostics';\nexport type {\n Expression,\n TagSource,\n ProcessorParams,\n TailProcessorParams,\n} from './BaseProcessor';\nexport * from './types';\nexport { buildSlug } from './utils/buildSlug';\nexport type { IOptions, IFileContext } from './utils/types';\nexport { isValidParams, validateParams } from './utils/validateParams';\nexport type { MapParams, ParamConstraints } from './utils/validateParams';\nexport { TaggedTemplateProcessor } from './TaggedTemplateProcessor';\nexport { toValidCSSIdentifier } from './utils/toValidCSSIdentifier';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,cAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAYA,IAAAE,MAAA,GAAAF,OAAA;AAAAG,MAAA,CAAAC,IAAA,CAAAF,MAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,MAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,MAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,UAAA,GAAAf,OAAA;AAEA,IAAAgB,eAAA,GAAAhB,OAAA;AAEA,IAAAiB,wBAAA,GAAAjB,OAAA;AACA,IAAAkB,qBAAA,GAAAlB,OAAA","ignoreList":[]}

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

{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n Expression,\n Identifier,\n TemplateElement,\n MemberExpression,\n} from '@babel/types';\n\nimport type { ExpressionValue, Location, WYWEvalMeta } from '@wyw-in-js/shared';\n\nexport type CSSPropertyValue = string | number;\n\nexport type ObjectWithSelectors = {\n [key: string]:\n | ObjectWithSelectors\n | CSSPropertyValue\n | (ObjectWithSelectors | CSSPropertyValue)[];\n};\n\nexport type CSSable = ObjectWithSelectors[string];\n\nexport type Value = (() => void) | WYWEvalMeta | CSSable;\n\nexport type ValueCache = Map<string | number | boolean | null, unknown>;\n\nexport interface ICSSRule {\n atom?: boolean;\n className: string;\n cssText: string;\n displayName: string;\n start: Location | null | undefined;\n}\n\nexport interface IInterpolation {\n id: string;\n node: Expression;\n source: string;\n unit: string;\n}\n\nexport type Rules = Record<string, ICSSRule>;\n\nexport type CalleeParam = readonly ['callee', Identifier | MemberExpression];\nexport type CallParam = readonly ['call', ...ExpressionValue[]];\nexport type MemberParam = readonly ['member', string];\nexport type TemplateParam = readonly [\n 'template',\n (TemplateElement | ExpressionValue)[],\n];\n\nexport type Param = CalleeParam | CallParam | MemberParam | TemplateParam;\nexport type Params = readonly Param[];\n"],"mappings":"","ignoreList":[]}
{"version":3,"file":"types.js","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n Expression,\n Identifier,\n TemplateElement,\n MemberExpression,\n} from '@babel/types';\n\nimport type { ExpressionValue, Location, WYWEvalMeta } from '@wyw-in-js/shared';\n\nexport type CSSPropertyValue = string | number;\n\nexport type ObjectWithSelectors = {\n [key: string]:\n | ObjectWithSelectors\n | CSSPropertyValue\n | (ObjectWithSelectors | CSSPropertyValue)[];\n};\n\nexport type CSSable = ObjectWithSelectors[string];\n\nexport type Value = (() => void) | WYWEvalMeta | CSSable;\n\nexport type ValueCache = Map<string | number | boolean | null, unknown>;\n\nexport interface ICSSRule {\n atom?: boolean;\n className: string;\n cssText: string;\n displayName: string;\n start: Location | null | undefined;\n}\n\nexport interface IInterpolation {\n id: string;\n node: Expression;\n source: string;\n unit: string;\n}\n\nexport type ProcessorDiagnosticSeverity = 'error' | 'warning';\n\nexport type ProcessorDiagnostic = {\n category: string;\n end?: Location | null;\n message: string;\n severity: ProcessorDiagnosticSeverity;\n start?: Location | null;\n};\n\nexport type Rules = Record<string, ICSSRule>;\n\nexport type CalleeParam = readonly ['callee', Identifier | MemberExpression];\nexport type CallParam = readonly ['call', ...ExpressionValue[]];\nexport type MemberParam = readonly ['member', string];\nexport type TemplateParam = readonly [\n 'template',\n (TemplateElement | ExpressionValue)[],\n];\n\nexport type Param = CalleeParam | CallParam | MemberParam | TemplateParam;\nexport type Params = readonly Param[];\n"],"mappings":"","ignoreList":[]}
{
"name": "@wyw-in-js/processor-utils",
"version": "1.0.5",
"version": "1.1.0",
"dependencies": {
"@babel/generator": "^7.23.5",
"@wyw-in-js/shared": "1.0.5"
"@wyw-in-js/shared": "1.1.0"
},

@@ -8,0 +8,0 @@ "devDependencies": {

import type { NodePath, types as t } from '@babel/core';
import type { Expression, Identifier, SourceLocation, MemberExpression } from '@babel/types';
import type { Artifact, ExpressionValue } from '@wyw-in-js/shared';
import type { IInterpolation, Params, Value, ValueCache } from './types';
import type { IInterpolation, Params, ProcessorDiagnostic, Value, ValueCache } from './types';
import type { IFileContext, IOptions } from './utils/types';

@@ -48,2 +48,3 @@ export { Expression };

abstract get value(): Expression;
addDiagnostic(diagnostic: ProcessorDiagnostic): void;
isValidValue(value: unknown): value is Value;

@@ -50,0 +51,0 @@ toString(): string;

@@ -9,2 +9,3 @@ "use strict";

const shared_1 = require("@wyw-in-js/shared");
const diagnostics_1 = require("./diagnostics");
const getClassNameAndSlug_1 = __importDefault(require("./utils/getClassNameAndSlug"));

@@ -47,2 +48,9 @@ const toCSS_1 = require("./utils/toCSS");

}
addDiagnostic(diagnostic) {
this.artifacts.push((0, diagnostics_1.createProcessorDiagnosticArtifact)({
...diagnostic,
end: diagnostic.end ?? this.location?.end ?? null,
start: diagnostic.start ?? this.location?.start ?? null,
}));
}
isValidValue(value) {

@@ -49,0 +57,0 @@ return (typeof value === 'function' || (0, toCSS_1.isCSSable)(value) || (0, shared_1.hasEvalMeta)(value));

export { BaseProcessor } from './BaseProcessor';
export { createProcessorDiagnosticArtifact, isProcessorDiagnosticArtifact, PROCESSOR_DIAGNOSTIC_ARTIFACT, } from './diagnostics';
export type { ProcessorDiagnosticArtifact } from './diagnostics';
export type { Expression, TagSource, ProcessorParams, TailProcessorParams, } from './BaseProcessor';

@@ -3,0 +5,0 @@ export * from './types';

@@ -17,5 +17,9 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.toValidCSSIdentifier = exports.TaggedTemplateProcessor = exports.validateParams = exports.isValidParams = exports.buildSlug = exports.BaseProcessor = void 0;
exports.toValidCSSIdentifier = exports.TaggedTemplateProcessor = exports.validateParams = exports.isValidParams = exports.buildSlug = exports.PROCESSOR_DIAGNOSTIC_ARTIFACT = exports.isProcessorDiagnosticArtifact = exports.createProcessorDiagnosticArtifact = exports.BaseProcessor = void 0;
var BaseProcessor_1 = require("./BaseProcessor");
Object.defineProperty(exports, "BaseProcessor", { enumerable: true, get: function () { return BaseProcessor_1.BaseProcessor; } });
var diagnostics_1 = require("./diagnostics");
Object.defineProperty(exports, "createProcessorDiagnosticArtifact", { enumerable: true, get: function () { return diagnostics_1.createProcessorDiagnosticArtifact; } });
Object.defineProperty(exports, "isProcessorDiagnosticArtifact", { enumerable: true, get: function () { return diagnostics_1.isProcessorDiagnosticArtifact; } });
Object.defineProperty(exports, "PROCESSOR_DIAGNOSTIC_ARTIFACT", { enumerable: true, get: function () { return diagnostics_1.PROCESSOR_DIAGNOSTIC_ARTIFACT; } });
__exportStar(require("./types"), exports);

@@ -22,0 +26,0 @@ var buildSlug_1 = require("./utils/buildSlug");

@@ -23,2 +23,10 @@ import type { Expression, Identifier, TemplateElement, MemberExpression } from '@babel/types';

}
export type ProcessorDiagnosticSeverity = 'error' | 'warning';
export type ProcessorDiagnostic = {
category: string;
end?: Location | null;
message: string;
severity: ProcessorDiagnosticSeverity;
start?: Location | null;
};
export type Rules = Record<string, ICSSRule>;

@@ -25,0 +33,0 @@ export type CalleeParam = readonly ['callee', Identifier | MemberExpression];