@wyw-in-js/shared 1.1.0 → 2.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/esm/IVariableContext.js +1 -1
  2. package/esm/IVariableContext.js.map +1 -1
  3. package/esm/asyncResolveFallback.js +35 -31
  4. package/esm/asyncResolveFallback.js.map +1 -1
  5. package/esm/asyncResolverFactory.js +9 -9
  6. package/esm/asyncResolverFactory.js.map +1 -1
  7. package/esm/debugger.js +1 -1
  8. package/esm/debugger.js.map +1 -1
  9. package/esm/findPackageJSON.js +60 -68
  10. package/esm/findPackageJSON.js.map +1 -1
  11. package/esm/hasEvalMeta.js +2 -2
  12. package/esm/hasEvalMeta.js.map +1 -1
  13. package/esm/index.js +11 -10
  14. package/esm/index.js.map +1 -1
  15. package/esm/isBoxedPrimitive.js +4 -5
  16. package/esm/isBoxedPrimitive.js.map +1 -1
  17. package/esm/logger.js +17 -17
  18. package/esm/logger.js.map +1 -1
  19. package/esm/options/isFeatureEnabled.js +22 -27
  20. package/esm/options/isFeatureEnabled.js.map +1 -1
  21. package/esm/options/nativeResolverOptions.js +49 -0
  22. package/esm/options/nativeResolverOptions.js.map +1 -0
  23. package/esm/options/types.js +1 -1
  24. package/esm/options/types.js.map +1 -1
  25. package/esm/slugify.js +47 -49
  26. package/esm/slugify.js.map +1 -1
  27. package/esm/types.js +6 -10
  28. package/esm/types.js.map +1 -1
  29. package/package.json +12 -10
  30. package/types/IVariableContext.js +1 -2
  31. package/types/asyncResolveFallback.js +8 -14
  32. package/types/asyncResolverFactory.js +1 -5
  33. package/types/debugger.js +1 -2
  34. package/types/findPackageJSON.js +13 -17
  35. package/types/hasEvalMeta.js +1 -4
  36. package/types/index.d.ts +4 -2
  37. package/types/index.js +10 -23
  38. package/types/isBoxedPrimitive.js +1 -4
  39. package/types/logger.js +7 -14
  40. package/types/options/isFeatureEnabled.js +3 -7
  41. package/types/options/nativeResolverOptions.d.ts +4 -0
  42. package/types/options/nativeResolverOptions.js +55 -0
  43. package/types/options/types.d.ts +120 -10
  44. package/types/options/types.js +1 -2
  45. package/types/slugify.js +1 -4
  46. package/types/types.d.ts +40 -1
  47. package/types/types.js +2 -5
  48. package/esm/babel.js +0 -2
  49. package/esm/babel.js.map +0 -1
  50. package/lib/IVariableContext.js +0 -2
  51. package/lib/IVariableContext.js.map +0 -1
  52. package/lib/asyncResolveFallback.js +0 -47
  53. package/lib/asyncResolveFallback.js.map +0 -1
  54. package/lib/asyncResolverFactory.js +0 -18
  55. package/lib/asyncResolverFactory.js.map +0 -1
  56. package/lib/babel.js +0 -2
  57. package/lib/babel.js.map +0 -1
  58. package/lib/debugger.js +0 -2
  59. package/lib/debugger.js.map +0 -1
  60. package/lib/findPackageJSON.js +0 -81
  61. package/lib/findPackageJSON.js.map +0 -1
  62. package/lib/hasEvalMeta.js +0 -10
  63. package/lib/hasEvalMeta.js.map +0 -1
  64. package/lib/index.js +0 -81
  65. package/lib/index.js.map +0 -1
  66. package/lib/isBoxedPrimitive.js +0 -15
  67. package/lib/isBoxedPrimitive.js.map +0 -1
  68. package/lib/logger.js +0 -35
  69. package/lib/logger.js.map +0 -1
  70. package/lib/options/isFeatureEnabled.js +0 -37
  71. package/lib/options/isFeatureEnabled.js.map +0 -1
  72. package/lib/options/types.js +0 -2
  73. package/lib/options/types.js.map +0 -1
  74. package/lib/slugify.js +0 -68
  75. package/lib/slugify.js.map +0 -1
  76. package/lib/types.js +0 -16
  77. package/lib/types.js.map +0 -1
  78. package/types/babel.d.ts +0 -2
  79. package/types/babel.js +0 -2
@@ -1,7 +1,4 @@
1
- import type { TransformOptions } from '@babel/core';
2
- import type { File } from '@babel/types';
3
1
  import type { IVariableContext } from '../IVariableContext';
4
- import type { Core } from '../babel';
5
2
  type VmContext = Record<string, any>;
6
3
  export type ClassNameSlugVars = {
7
4
  dir: string;
@@ -21,15 +18,35 @@ export type EvaluatorConfig = {
21
18
  onlyExports: string[];
22
19
  root?: string;
23
20
  };
24
- export type Evaluator = (evalConfig: TransformOptions, ast: File, code: string, config: EvaluatorConfig, babel: Core) => [
25
- ast: File,
21
+ export type EvaluatorOptions = {
22
+ ast?: boolean | null;
23
+ configFile?: boolean | null | string;
24
+ env?: Record<string, EvaluatorOptions | null | undefined> | null;
25
+ filename?: string | null;
26
+ inputSourceMap?: object | null;
27
+ overrides?: EvaluatorOptions[] | null;
28
+ plugins?: unknown[] | null;
29
+ presets?: unknown[] | null;
30
+ root?: string | null;
31
+ sourceFileName?: string | null;
32
+ sourceMaps?: boolean | 'both' | 'inline' | null;
33
+ [key: string]: unknown;
34
+ };
35
+ export type TransformEngineOptions = EvaluatorOptions;
36
+ export type EvaluatorAst = unknown;
37
+ export type EvaluatorRuntime = unknown;
38
+ export type Evaluator = (evalConfig: EvaluatorOptions, ast: EvaluatorAst, code: string, config: EvaluatorConfig, runtime: EvaluatorRuntime) => [
39
+ ast: EvaluatorAst,
26
40
  code: string,
27
41
  imports: Map<string, string[]> | null,
28
42
  exports?: string[] | null
29
43
  ];
30
44
  export type EvalRule = {
31
45
  action: Evaluator | 'ignore' | string;
32
- babelOptions?: TransformOptions;
46
+ /**
47
+ * Per-rule Oxc options for the Oxc-first transform path.
48
+ */
49
+ oxcOptions?: OxcOptions;
33
50
  test?: RegExp | ((path: string, code: string) => boolean);
34
51
  };
35
52
  export type FeatureFlag = boolean | string | string[];
@@ -54,7 +71,7 @@ type ImportOverrideUnknown = {
54
71
  mock?: never;
55
72
  noShake?: never;
56
73
  /**
57
- * Controls behavior when an import reaches eval-time Node resolver fallback.
74
+ * Controls behavior when an import reaches eval-time native resolver fallback.
58
75
  * - 'warn' (default): warn once per canonical import key.
59
76
  * - 'error': throw.
60
77
  * - 'allow': no warning, keep load-as-is.
@@ -76,6 +93,53 @@ export type ImportLoaderContext = {
76
93
  };
77
94
  export type ImportLoader = 'raw' | 'url' | ((context: ImportLoaderContext) => unknown);
78
95
  export type ImportLoaders = Record<string, ImportLoader | false>;
96
+ export type EvalResolverMode = 'bundler' | 'hybrid' | 'native' | 'custom';
97
+ export type EvalRequireMode = 'warn-and-run' | 'error' | 'off';
98
+ export type EvalStrategy = 'execute' | 'hybrid' | 'static';
99
+ export type EvalRuntime = 'nodejs';
100
+ export type EvalErrorMode = 'strict' | 'loose';
101
+ export type EvalResolverKind = 'import' | 'dynamic-import' | 'require';
102
+ export type EvalWarningCode = 'resolve-fallback' | 'resolve-error' | 'require-fallback' | 'require-error' | 'dynamic-import' | 'eval-error';
103
+ export type EvalWarning = {
104
+ code: EvalWarningCode;
105
+ message: string;
106
+ importer?: string;
107
+ specifier?: string;
108
+ resolved?: string | null;
109
+ callstack?: string[];
110
+ hint?: string;
111
+ };
112
+ export type EvalOptionsV2 = {
113
+ /**
114
+ * Controls how interpolation values are computed.
115
+ * - `execute`: use the build-time evaluator.
116
+ * - `hybrid`: resolve provably static values first, then fall back to the evaluator.
117
+ * - `static`: resolve only provably static values and fail on evaluator fallback.
118
+ */
119
+ strategy?: EvalStrategy;
120
+ /**
121
+ * Runtime used by the build-time evaluator.
122
+ */
123
+ runtime?: EvalRuntime;
124
+ /**
125
+ * Default is `bundler`. `hybrid` is an opt-in mode whose intended
126
+ * precedence is customResolver -> native Oxc resolver -> bundler.
127
+ */
128
+ resolver?: EvalResolverMode;
129
+ customResolver?: (specifier: string, importer: string, kind: EvalResolverKind) => Promise<{
130
+ id: string;
131
+ external?: boolean;
132
+ } | null>;
133
+ customLoader?: (id: string) => Promise<{
134
+ code: string;
135
+ map?: unknown;
136
+ loader?: string;
137
+ } | null>;
138
+ require?: EvalRequireMode;
139
+ errors?: EvalErrorMode;
140
+ globals?: Record<string, unknown>;
141
+ onWarn?: (warning: EvalWarning) => void;
142
+ };
79
143
  export type TagResolverMeta = {
80
144
  resolvedSource?: string;
81
145
  sourceFile: string | null | undefined;
@@ -85,7 +149,6 @@ type AllFeatureFlags = {
85
149
  globalCache: FeatureFlag;
86
150
  happyDOM: FeatureFlag;
87
151
  softErrors: FeatureFlag;
88
- useBabelConfigs: FeatureFlag;
89
152
  useWeakRefInEval: FeatureFlag;
90
153
  };
91
154
  export type FeatureFlags<TOnly extends keyof AllFeatureFlags = keyof AllFeatureFlags> = Pick<AllFeatureFlags, TOnly>;
@@ -93,23 +156,70 @@ export type CodeRemoverOptions = {
93
156
  componentTypes?: Record<string, string[]>;
94
157
  hocs?: Record<string, string[]>;
95
158
  };
159
+ export type OxcOptions = {
160
+ /**
161
+ * Parser-level Oxc options. The first slice only preserves this contract.
162
+ */
163
+ parser?: Record<string, unknown>;
164
+ /**
165
+ * Resolver-level Oxc options. Bundler-aware resolution remains authoritative
166
+ * unless `eval.resolver` explicitly opts into `hybrid`.
167
+ */
168
+ resolver?: Record<string, unknown>;
169
+ /**
170
+ * Transform-level Oxc options.
171
+ */
172
+ transform?: Record<string, unknown>;
173
+ };
96
174
  export type StrictOptions = {
97
- babelOptions: TransformOptions;
98
175
  classNameSlug?: string | ClassNameFn;
99
176
  codeRemover?: CodeRemoverOptions;
100
177
  conditionNames?: string[];
101
178
  displayName: boolean;
102
- evaluate: boolean;
179
+ eval?: EvalOptionsV2;
103
180
  extensions: string[];
104
181
  features: FeatureFlags;
105
182
  highPriorityPlugins: string[];
106
183
  ignore?: RegExp;
107
184
  importLoaders?: ImportLoaders;
108
185
  importOverrides?: ImportOverrides;
186
+ /**
187
+ * Per-source map of imported names to statically-known values. Used by
188
+ * the static evaluator when resolving imports from the listed sources.
189
+ *
190
+ * Each entry maps an import source (a package name or absolute file
191
+ * path) to a record of imported names. Each name's value is either:
192
+ * - a function: treated as a pure helper. Called at every CallExpression
193
+ * site whose callee resolves to this binding, with evaluator-resolved
194
+ * args. Result is treated as a static value.
195
+ * - any other value: treated as a literal binding override. Returned
196
+ * wherever the binding is referenced.
197
+ *
198
+ * Trust model is the same as importOverrides / tagResolver: the user
199
+ * vouches that pure helpers are deterministic and that literal
200
+ * overrides reflect the runtime value (or knowingly diverge for
201
+ * prototyping / SSR theming).
202
+ *
203
+ * Example:
204
+ * staticBindings: {
205
+ * '@linaria/core': {
206
+ * cx: (...args) => args.filter(Boolean).join(' '),
207
+ * },
208
+ * '/abs/path/to/theme.ts': {
209
+ * themeVars: { panelBg: '#f00' },
210
+ * },
211
+ * }
212
+ */
213
+ staticBindings?: Record<string, Record<string, unknown>>;
109
214
  outputMetadata: boolean;
110
215
  overrideContext?: (context: Partial<VmContext>, filename: string) => Partial<VmContext>;
216
+ /**
217
+ * Oxc-first transform options.
218
+ */
219
+ oxcOptions: OxcOptions;
111
220
  rules: EvalRule[];
112
221
  tagResolver?: (source: string, tag: string, meta: TagResolverMeta) => string | null;
222
+ evalConsole?: 'warning' | 'pipe';
113
223
  variableNameConfig?: 'var' | 'dashes' | 'raw';
114
224
  variableNameSlug?: string | VariableNameFn;
115
225
  };
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/types/slugify.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
1
  /* eslint-disable no-plusplus, no-bitwise, default-case, no-param-reassign, prefer-destructuring */
3
2
  /**
4
3
  * This file contains a utility to generate hashes to be used as generated class names
5
4
  */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.slugify = slugify;
8
5
  /**
9
6
  * murmurhash2 via https://gist.github.com/raycmorgan/588423
10
7
  */
@@ -60,6 +57,6 @@ function doHash(str, seed = 0) {
60
57
  h ^= h >>> 15;
61
58
  return h >>> 0;
62
59
  }
63
- function slugify(code) {
60
+ export function slugify(code) {
64
61
  return doHash(code).toString(36);
65
62
  }
package/types/types.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { BigIntLiteral, BooleanLiteral, DecimalLiteral, Identifier, NullLiteral, NumericLiteral, StringLiteral } from '@babel/types';
2
1
  export type Artifact = [name: string, data: unknown];
3
2
  export type BuildCodeFrameErrorFn = <TError extends Error>(msg: string, Error?: new (innerMsg: string) => TError) => TError;
4
3
  export declare enum ValueType {
@@ -6,6 +5,46 @@ export declare enum ValueType {
6
5
  FUNCTION = 1,
7
6
  CONST = 2
8
7
  }
8
+ export type SourceLocation = {
9
+ end: Location;
10
+ filename?: string;
11
+ identifierName?: string | null;
12
+ start: Location;
13
+ };
14
+ export type AstNode = {
15
+ end?: number | null;
16
+ loc?: SourceLocation | null;
17
+ start?: number | null;
18
+ type: string;
19
+ };
20
+ export type AstExpression = AstNode;
21
+ export type Identifier = AstExpression & {
22
+ name: string;
23
+ type: 'Identifier';
24
+ };
25
+ export type StringLiteral = AstExpression & {
26
+ type: 'StringLiteral';
27
+ value: string;
28
+ };
29
+ export type NumericLiteral = AstExpression & {
30
+ type: 'NumericLiteral';
31
+ value: number;
32
+ };
33
+ export type NullLiteral = AstExpression & {
34
+ type: 'NullLiteral';
35
+ };
36
+ export type BooleanLiteral = AstExpression & {
37
+ type: 'BooleanLiteral';
38
+ value: boolean;
39
+ };
40
+ export type BigIntLiteral = AstExpression & {
41
+ type: 'BigIntLiteral';
42
+ value: bigint | string;
43
+ };
44
+ export type DecimalLiteral = AstExpression & {
45
+ type: 'DecimalLiteral';
46
+ value: string;
47
+ };
9
48
  export type LazyValue = {
10
49
  buildCodeFrameError: BuildCodeFrameErrorFn;
11
50
  ex: Identifier;
package/types/types.js CHANGED
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ValueType = void 0;
4
- var ValueType;
1
+ export var ValueType;
5
2
  (function (ValueType) {
6
3
  ValueType[ValueType["LAZY"] = 0] = "LAZY";
7
4
  ValueType[ValueType["FUNCTION"] = 1] = "FUNCTION";
8
5
  ValueType[ValueType["CONST"] = 2] = "CONST";
9
- })(ValueType || (exports.ValueType = ValueType = {}));
6
+ })(ValueType || (ValueType = {}));
package/esm/babel.js DELETED
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=babel.js.map
package/esm/babel.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"babel.js","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import type core from '@babel/core';\n\nexport type Core = typeof core;\n"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=IVariableContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IVariableContext.js","names":[],"sources":["../src/IVariableContext.ts"],"sourcesContent":["export interface IVariableContext {\n componentName: string;\n componentSlug: string;\n index: number;\n precedingCss: string;\n processor: string;\n source: string;\n unit: string;\n valueSlug: string;\n}\n"],"mappings":"","ignoreList":[]}
@@ -1,47 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.syncResolve = exports.asyncResolveFallback = void 0;
7
- var _path = _interopRequireDefault(require("path"));
8
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
- const safeResolve = (name, where) => {
10
- try {
11
- return require.resolve(name, {
12
- paths: where
13
- });
14
- } catch (e) {
15
- return e;
16
- }
17
- };
18
- const suffixes = ['.js', '.ts', '.jsx', '.tsx'].reduce((acc, ext) => {
19
- acc.push(`/index${ext}`);
20
- acc.push(ext);
21
- return acc;
22
- }, []);
23
- const syncResolve = (what, importer, stack) => {
24
- const where = [importer, ...stack].map(p => _path.default.dirname(p));
25
- const resolved = safeResolve(what, where);
26
- if (!(resolved instanceof Error)) {
27
- return resolved;
28
- }
29
-
30
- // eslint-disable-next-line no-restricted-syntax
31
- for (const suffix of suffixes) {
32
- const resolvedWithSuffix = safeResolve(what + suffix, where);
33
- if (resolvedWithSuffix instanceof Error) {
34
- // eslint-disable-next-line no-continue
35
- continue;
36
- }
37
- return resolvedWithSuffix;
38
- }
39
- throw resolved;
40
- };
41
- exports.syncResolve = syncResolve;
42
- const asyncResolveFallback = (what, importer, stack) => {
43
- const resolved = syncResolve(what, importer, stack);
44
- return Promise.resolve(resolved);
45
- };
46
- exports.asyncResolveFallback = asyncResolveFallback;
47
- //# sourceMappingURL=asyncResolveFallback.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asyncResolveFallback.js","names":["_path","_interopRequireDefault","require","e","__esModule","default","safeResolve","name","where","resolve","paths","suffixes","reduce","acc","ext","push","syncResolve","what","importer","stack","map","p","path","dirname","resolved","Error","suffix","resolvedWithSuffix","exports","asyncResolveFallback","Promise"],"sources":["../src/asyncResolveFallback.ts"],"sourcesContent":["import path from 'path';\n\nconst safeResolve = (name: string, where: string[]): string | Error => {\n try {\n return require.resolve(name, {\n paths: where,\n });\n } catch (e: unknown) {\n return e as Error;\n }\n};\n\nconst suffixes = ['.js', '.ts', '.jsx', '.tsx'].reduce((acc: string[], ext) => {\n acc.push(`/index${ext}`);\n acc.push(ext);\n return acc;\n}, []);\n\nexport const syncResolve = (\n what: string,\n importer: string,\n stack: string[]\n): string => {\n const where = [importer, ...stack].map((p) => path.dirname(p));\n const resolved = safeResolve(what, where);\n if (!(resolved instanceof Error)) {\n return resolved;\n }\n\n // eslint-disable-next-line no-restricted-syntax\n for (const suffix of suffixes) {\n const resolvedWithSuffix = safeResolve(what + suffix, where);\n if (resolvedWithSuffix instanceof Error) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n return resolvedWithSuffix;\n }\n\n throw resolved;\n};\n\nexport const asyncResolveFallback = (\n what: string,\n importer: string,\n stack: string[]\n): Promise<string> => {\n const resolved = syncResolve(what, importer, stack);\n return Promise.resolve(resolved);\n};\n"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAwB,SAAAD,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAExB,MAAMG,WAAW,GAAGA,CAACC,IAAY,EAAEC,KAAe,KAAqB;EACrE,IAAI;IACF,OAAON,OAAO,CAACO,OAAO,CAACF,IAAI,EAAE;MAC3BG,KAAK,EAAEF;IACT,CAAC,CAAC;EACJ,CAAC,CAAC,OAAOL,CAAU,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[]}
@@ -1,18 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.asyncResolverFactory = void 0;
7
- const asyncResolverFactory = (onResolve, mapper) => {
8
- const memoizedSyncResolve = new WeakMap();
9
- return resolveFn => {
10
- if (!memoizedSyncResolve.has(resolveFn)) {
11
- const fn = (what, importer, stack) => resolveFn(...mapper(what, importer, stack)).then(resolved => onResolve(resolved, what, importer, stack));
12
- memoizedSyncResolve.set(resolveFn, fn);
13
- }
14
- return memoizedSyncResolve.get(resolveFn);
15
- };
16
- };
17
- exports.asyncResolverFactory = asyncResolverFactory;
18
- //# sourceMappingURL=asyncResolverFactory.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"asyncResolverFactory.js","names":["asyncResolverFactory","onResolve","mapper","memoizedSyncResolve","WeakMap","resolveFn","has","fn","what","importer","stack","then","resolved","set","get","exports"],"sources":["../src/asyncResolverFactory.ts"],"sourcesContent":["export const asyncResolverFactory = <\n TResolved,\n const TResolverArgs extends readonly unknown[],\n TResolve extends (...args: TResolverArgs) => Promise<TResolved>,\n>(\n onResolve: (\n resolved: TResolved,\n what: string,\n importer: string,\n stack: string[]\n ) => Promise<string | null>,\n mapper: (what: string, importer: string, stack: string[]) => TResolverArgs\n) => {\n const memoizedSyncResolve = new WeakMap<\n TResolve,\n (what: string, importer: string, stack: string[]) => Promise<string | null>\n >();\n\n return (resolveFn: TResolve) => {\n if (!memoizedSyncResolve.has(resolveFn)) {\n const fn = (\n what: string,\n importer: string,\n stack: string[]\n ): Promise<string | null> =>\n resolveFn(...mapper(what, importer, stack)).then((resolved) =>\n onResolve(resolved, what, importer, stack)\n );\n\n memoizedSyncResolve.set(resolveFn, fn);\n }\n\n return memoizedSyncResolve.get(resolveFn)!;\n };\n};\n"],"mappings":";;;;;;AAAO,MAAMA,oBAAoB,GAAGA,CAKlCC,SAK2B,EAC3BC,MAA0E,KACvE;EACH,MAAMC,mBAAmB,GAAG,IAAIC,OAAO,CAGrC,CAAC;EAEH,OAAQC,SAAmB,IAAK;IAC9B,IAAI,CAACF,mBAAmB,CAACG,GAAG,CAACD,SAAS,CAAC,EAAE;MACvC,MAAME,EAAE,GAAGA,CACTC,IAAY,EACZC,QAAgB,EAChBC,KAAe,KAEfL,SAAS,CAAC,GAAGH,MAAM,CAACM,IAAI,EAAEC,QAAQ,EAAEC,KAAK,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IACxDX,SAAS,CAACW,QAAQ,EAAEJ,IAAI,EAAEC,QAAQ,EAAEC,KAAK,CAC3C,CAAC;MAEHP,mBAAmB,CAACU,GAAG,CAACR,SAAS,EAAEE,EAAE,CAAC;IACxC;IAEA,OAAOJ,mBAAmB,CAACW,GAAG,CAACT,SAAS,CAAC;EAC3C,CAAC;AACH,CAAC;AAACU,OAAA,CAAAf,oBAAA,GAAAA,oBAAA","ignoreList":[]}
package/lib/babel.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=babel.js.map
package/lib/babel.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"babel.js","names":[],"sources":["../src/babel.ts"],"sourcesContent":["import type core from '@babel/core';\n\nexport type Core = typeof core;\n"],"mappings":"","ignoreList":[]}
package/lib/debugger.js DELETED
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=debugger.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"debugger.js","names":[],"sources":["../src/debugger.ts"],"sourcesContent":["export type Debugger = {\n (formatter: unknown, ...args: unknown[]): void;\n color: string;\n destroy: () => boolean;\n diff: number;\n enabled: boolean;\n extend: (namespace: string, delimiter?: string) => Debugger;\n log: (...args: unknown[]) => unknown;\n namespace: string;\n};\n"],"mappings":"","ignoreList":[]}
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.findPackageJSON = findPackageJSON;
7
- var _fs = require("fs");
8
- var _path = require("path");
9
- var _findUp = _interopRequireDefault(require("find-up"));
10
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- const cache = new Map();
12
- function findSelfPackageJSON(pkgName, filename) {
13
- const packageJSONPath = _findUp.default.sync('package.json', {
14
- cwd: (0, _path.dirname)(filename)
15
- });
16
- if (!packageJSONPath) return undefined;
17
- try {
18
- const packageJSON = JSON.parse((0, _fs.readFileSync)(packageJSONPath, 'utf8'));
19
- return (packageJSON === null || packageJSON === void 0 ? void 0 : packageJSON.name) === pkgName ? packageJSONPath : undefined;
20
- } catch {
21
- return undefined;
22
- }
23
- }
24
- function findPackageJSON(pkgName, filename) {
25
- var _globalThis$process;
26
- // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined
27
- const isJest = Boolean((_globalThis$process = globalThis.process) === null || _globalThis$process === void 0 || (_globalThis$process = _globalThis$process.env) === null || _globalThis$process === void 0 ? void 0 : _globalThis$process.JEST_WORKER_ID);
28
- const skipPathsOptions = isJest && !pkgName.startsWith('.');
29
- try {
30
- const pkgPath = pkgName === '.' && filename && (0, _path.isAbsolute)(filename) ? filename : require.resolve(pkgName, filename ? {
31
- paths: [(0, _path.dirname)(filename)]
32
- } : {});
33
- if (!cache.has(pkgPath)) {
34
- cache.set(pkgPath, _findUp.default.sync('package.json', {
35
- cwd: pkgPath
36
- }));
37
- }
38
- return cache.get(pkgPath);
39
- } catch (er) {
40
- const code = typeof er === 'object' && er !== null && 'code' in er ? er.code : undefined;
41
- if (code === 'MODULE_NOT_FOUND') {
42
- if (filename) {
43
- // Bun doesn't expose workspace packages via `require.resolve`, but tests
44
- // and tooling can still reference the current package by name.
45
- const selfPackageJSON = findSelfPackageJSON(pkgName, filename);
46
- if (selfPackageJSON) {
47
- return selfPackageJSON;
48
- }
49
- const bun = globalThis.Bun;
50
- if (bun && typeof bun.resolveSync === 'function') {
51
- try {
52
- const resolved = bun.resolveSync(pkgName, filename);
53
- if (!cache.has(resolved)) {
54
- cache.set(resolved, _findUp.default.sync('package.json', {
55
- cwd: resolved
56
- }));
57
- }
58
- return cache.get(resolved);
59
- } catch {
60
- // fall through to the existing resolution heuristics
61
- }
62
- }
63
- }
64
- if (skipPathsOptions && filename) {
65
- return findPackageJSON(pkgName, null);
66
- }
67
- return undefined;
68
- }
69
- if (code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {
70
- // See https://github.com/Anber/wyw-in-js/issues/43
71
- // `require` can't resolve ESM-only packages. We can use the `resolve`
72
- // package here, but it does not solve all cases because `pkgName`
73
- // can be an alias and should be resolved by a bundler. However, we can't use
74
- // `resolve` from a bundler because it is async. The good news is that in that
75
- // specific case, we can just ignore those packages. For now.
76
- return undefined;
77
- }
78
- throw er;
79
- }
80
- }
81
- //# sourceMappingURL=findPackageJSON.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"findPackageJSON.js","names":["_fs","require","_path","_findUp","_interopRequireDefault","e","__esModule","default","cache","Map","findSelfPackageJSON","pkgName","filename","packageJSONPath","findUp","sync","cwd","dirname","undefined","packageJSON","JSON","parse","readFileSync","name","findPackageJSON","_globalThis$process","isJest","Boolean","globalThis","process","env","JEST_WORKER_ID","skipPathsOptions","startsWith","pkgPath","isAbsolute","resolve","paths","has","set","get","er","code","selfPackageJSON","bun","Bun","resolveSync","resolved"],"sources":["../src/findPackageJSON.ts"],"sourcesContent":["import { readFileSync } from 'fs';\nimport { dirname, isAbsolute } from 'path';\nimport findUp from 'find-up';\n\nconst cache = new Map<string, string | undefined>();\n\nfunction findSelfPackageJSON(pkgName: string, filename: string) {\n const packageJSONPath = findUp.sync('package.json', {\n cwd: dirname(filename),\n });\n if (!packageJSONPath) return undefined;\n\n try {\n const packageJSON = JSON.parse(readFileSync(packageJSONPath, 'utf8'));\n return packageJSON?.name === pkgName ? packageJSONPath : undefined;\n } catch {\n return undefined;\n }\n}\n\nexport function findPackageJSON(\n pkgName: string,\n filename: string | null | undefined\n) {\n // Jest's resolver does not work properly with `moduleNameMapper` when `paths` are defined\n const isJest = Boolean(globalThis.process?.env?.JEST_WORKER_ID);\n const skipPathsOptions = isJest && !pkgName.startsWith('.');\n\n try {\n const pkgPath =\n pkgName === '.' && filename && isAbsolute(filename)\n ? filename\n : require.resolve(\n pkgName,\n filename ? { paths: [dirname(filename)] } : {}\n );\n if (!cache.has(pkgPath)) {\n cache.set(pkgPath, findUp.sync('package.json', { cwd: pkgPath }));\n }\n\n return cache.get(pkgPath);\n } catch (er: unknown) {\n const code =\n typeof er === 'object' && er !== null && 'code' in er\n ? er.code\n : undefined;\n\n if (code === 'MODULE_NOT_FOUND') {\n if (filename) {\n // Bun doesn't expose workspace packages via `require.resolve`, but tests\n // and tooling can still reference the current package by name.\n const selfPackageJSON = findSelfPackageJSON(pkgName, filename);\n if (selfPackageJSON) {\n return selfPackageJSON;\n }\n\n const bun = (\n globalThis as typeof globalThis & {\n Bun?: {\n resolveSync?: (specifier: string, from: string) => string;\n };\n }\n ).Bun;\n if (bun && typeof bun.resolveSync === 'function') {\n try {\n const resolved = bun.resolveSync(pkgName, filename);\n if (!cache.has(resolved)) {\n cache.set(\n resolved,\n findUp.sync('package.json', {\n cwd: resolved,\n })\n );\n }\n\n return cache.get(resolved);\n } catch {\n // fall through to the existing resolution heuristics\n }\n }\n }\n\n if (skipPathsOptions && filename) {\n return findPackageJSON(pkgName, null);\n }\n\n return undefined;\n }\n\n if (code === 'ERR_PACKAGE_PATH_NOT_EXPORTED') {\n // See https://github.com/Anber/wyw-in-js/issues/43\n // `require` can't resolve ESM-only packages. We can use the `resolve`\n // package here, but it does not solve all cases because `pkgName`\n // can be an alias and should be resolved by a bundler. However, we can't use\n // `resolve` from a bundler because it is async. The good news is that in that\n // specific case, we can just ignore those packages. For now.\n return undefined;\n }\n\n throw er;\n }\n}\n"],"mappings":";;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAC,sBAAA,CAAAH,OAAA;AAA6B,SAAAG,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OAAOY,eAAe,CAACb,OAAO,EAAE,IAAI,CAAC;MACvC;MAEA,OAAOO,SAAS;IAClB;IAEA,IAAIwB,IAAI,KAAK,+BAA+B,EAAE;MAC5C;MACA;MACA;MACA;MACA;MACA;MACA,OAAOxB,SAAS;IAClB;IAEA,MAAMuB,EAAE;EACV;AACF","ignoreList":[]}
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.hasEvalMeta = hasEvalMeta;
7
- function hasEvalMeta(value) {
8
- return typeof value === 'object' && value !== null && '__wyw_meta' in value;
9
- }
10
- //# sourceMappingURL=hasEvalMeta.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hasEvalMeta.js","names":["hasEvalMeta","value"],"sources":["../src/hasEvalMeta.ts"],"sourcesContent":["import type { WYWEvalMeta } from './types';\n\nexport function hasEvalMeta(value: unknown): value is WYWEvalMeta {\n return typeof value === 'object' && value !== null && '__wyw_meta' in value;\n}\n"],"mappings":";;;;;;AAEO,SAASA,WAAWA,CAACC,KAAc,EAAwB;EAChE,OAAO,OAAOA,KAAK,KAAK,QAAQ,IAAIA,KAAK,KAAK,IAAI,IAAI,YAAY,IAAIA,KAAK;AAC7E","ignoreList":[]}
package/lib/index.js DELETED
@@ -1,81 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "ValueType", {
7
- enumerable: true,
8
- get: function () {
9
- return _types.ValueType;
10
- }
11
- });
12
- Object.defineProperty(exports, "asyncResolveFallback", {
13
- enumerable: true,
14
- get: function () {
15
- return _asyncResolveFallback.asyncResolveFallback;
16
- }
17
- });
18
- Object.defineProperty(exports, "asyncResolverFactory", {
19
- enumerable: true,
20
- get: function () {
21
- return _asyncResolverFactory.asyncResolverFactory;
22
- }
23
- });
24
- Object.defineProperty(exports, "enableDebug", {
25
- enumerable: true,
26
- get: function () {
27
- return _logger.enableDebug;
28
- }
29
- });
30
- Object.defineProperty(exports, "findPackageJSON", {
31
- enumerable: true,
32
- get: function () {
33
- return _findPackageJSON.findPackageJSON;
34
- }
35
- });
36
- Object.defineProperty(exports, "hasEvalMeta", {
37
- enumerable: true,
38
- get: function () {
39
- return _hasEvalMeta.hasEvalMeta;
40
- }
41
- });
42
- Object.defineProperty(exports, "isBoxedPrimitive", {
43
- enumerable: true,
44
- get: function () {
45
- return _isBoxedPrimitive.isBoxedPrimitive;
46
- }
47
- });
48
- Object.defineProperty(exports, "isFeatureEnabled", {
49
- enumerable: true,
50
- get: function () {
51
- return _isFeatureEnabled.isFeatureEnabled;
52
- }
53
- });
54
- Object.defineProperty(exports, "logger", {
55
- enumerable: true,
56
- get: function () {
57
- return _logger.logger;
58
- }
59
- });
60
- Object.defineProperty(exports, "slugify", {
61
- enumerable: true,
62
- get: function () {
63
- return _slugify.slugify;
64
- }
65
- });
66
- Object.defineProperty(exports, "syncResolve", {
67
- enumerable: true,
68
- get: function () {
69
- return _asyncResolveFallback.syncResolve;
70
- }
71
- });
72
- var _asyncResolveFallback = require("./asyncResolveFallback");
73
- var _asyncResolverFactory = require("./asyncResolverFactory");
74
- var _hasEvalMeta = require("./hasEvalMeta");
75
- var _findPackageJSON = require("./findPackageJSON");
76
- var _isBoxedPrimitive = require("./isBoxedPrimitive");
77
- var _logger = require("./logger");
78
- var _isFeatureEnabled = require("./options/isFeatureEnabled");
79
- var _slugify = require("./slugify");
80
- var _types = require("./types");
81
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","names":["_asyncResolveFallback","require","_asyncResolverFactory","_hasEvalMeta","_findPackageJSON","_isBoxedPrimitive","_logger","_isFeatureEnabled","_slugify","_types"],"sources":["../src/index.ts"],"sourcesContent":["export type { Debugger } from './debugger';\n\nexport { asyncResolveFallback, syncResolve } from './asyncResolveFallback';\nexport { asyncResolverFactory } from './asyncResolverFactory';\nexport { hasEvalMeta } from './hasEvalMeta';\nexport { findPackageJSON } from './findPackageJSON';\nexport { isBoxedPrimitive } from './isBoxedPrimitive';\nexport { enableDebug, logger } from './logger';\nexport { isFeatureEnabled } from './options/isFeatureEnabled';\nexport { slugify } from './slugify';\nexport { ValueType } from './types';\n\nexport type { IVariableContext } from './IVariableContext';\nexport type {\n ClassNameSlugVars,\n ClassNameFn,\n CodeRemoverOptions,\n ImportLoader,\n ImportLoaderContext,\n ImportLoaders,\n ImportOverride,\n ImportOverrides,\n TagResolverMeta,\n StrictOptions,\n EvalRule,\n Evaluator,\n FeatureFlag,\n EvaluatorConfig,\n FeatureFlags,\n VariableNameFn,\n} from './options/types';\nexport type {\n Artifact,\n BuildCodeFrameErrorFn,\n ConstValue,\n ExpressionValue,\n FunctionValue,\n ICSSRule,\n LazyValue,\n Location,\n Replacement,\n Replacements,\n Rules,\n WYWEvalMeta,\n} from './types';\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,IAAAA,qBAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,gBAAA,GAAAH,OAAA;AACA,IAAAI,iBAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,iBAAA,GAAAN,OAAA;AACA,IAAAO,QAAA,GAAAP,OAAA;AACA,IAAAQ,MAAA,GAAAR,OAAA","ignoreList":[]}
@@ -1,15 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isBoxedPrimitive = isBoxedPrimitive;
7
- // There is a problem with using boxed numbers and strings in TS,
8
- // so we cannot just use `instanceof` here
9
-
10
- const constructors = ['Number', 'String'];
11
- function isBoxedPrimitive(o) {
12
- if (typeof o !== 'object' || o === null) return false;
13
- return constructors.includes(o.constructor.name) && typeof (o === null || o === void 0 ? void 0 : o.valueOf()) !== 'object';
14
- }
15
- //# sourceMappingURL=isBoxedPrimitive.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"isBoxedPrimitive.js","names":["constructors","isBoxedPrimitive","o","includes","constructor","name","valueOf"],"sources":["../src/isBoxedPrimitive.ts"],"sourcesContent":["// There is a problem with using boxed numbers and strings in TS,\n// so we cannot just use `instanceof` here\n\nconst constructors = ['Number', 'String'];\nexport function isBoxedPrimitive(o: unknown): o is number | string {\n if (typeof o !== 'object' || o === null) return false;\n return (\n constructors.includes(o.constructor.name) &&\n typeof o?.valueOf() !== 'object'\n );\n}\n"],"mappings":";;;;;;AAAA;AACA;;AAEA,MAAMA,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAClC,SAASC,gBAAgBA,CAACC,CAAU,EAAwB;EACjE,IAAI,OAAOA,CAAC,KAAK,QAAQ,IAAIA,CAAC,KAAK,IAAI,EAAE,OAAO,KAAK;EACrD,OACEF,YAAY,CAACG,QAAQ,CAACD,CAAC,CAACE,WAAW,CAACC,IAAI,CAAC,IACzC,QAAOH,CAAC,aAADA,CAAC,uBAADA,CAAC,CAAEI,OAAO,CAAC,CAAC,MAAK,QAAQ;AAEpC","ignoreList":[]}
package/lib/logger.js DELETED
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.enableDebug = enableDebug;
7
- exports.logger = void 0;
8
- var _debug = _interopRequireDefault(require("debug"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- const BASE_NAMESPACE = 'wyw-in-js';
11
- const logger = exports.logger = (0, _debug.default)(BASE_NAMESPACE);
12
- const loggers = new Map();
13
- function gerOrCreate(namespace) {
14
- if (!namespace) return logger;
15
- const lastIndexOf = namespace.lastIndexOf(':');
16
- if (!loggers.has(namespace)) {
17
- loggers.set(namespace, gerOrCreate(namespace.substring(0, lastIndexOf)).extend(namespace.substring(lastIndexOf + 1)));
18
- }
19
- return loggers.get(namespace);
20
- }
21
- _debug.default.formatters.r = ref => {
22
- var _ref$text;
23
- const namespace = typeof ref === 'string' ? ref : ref.namespace;
24
- const text = typeof ref === 'string' ? namespace : (_ref$text = ref.text) !== null && _ref$text !== void 0 ? _ref$text : namespace;
25
- const color = parseInt(gerOrCreate(namespace).color, 10);
26
- const colorCode = `\u001B[3${color < 8 ? color : `8;5;${color}`}`;
27
- return `${colorCode};1m${text}\u001B[0m`;
28
- };
29
- _debug.default.formatters.f = function f(fn) {
30
- return JSON.stringify(fn());
31
- };
32
- function enableDebug(namespace = `${BASE_NAMESPACE}:*`) {
33
- _debug.default.enable(namespace);
34
- }
35
- //# sourceMappingURL=logger.js.map