@plumeria/utils 19.2.15 → 19.2.16

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.
package/dist/parser.js CHANGED
@@ -102,6 +102,35 @@ const getRootIdentifier = (node) => {
102
102
  return null;
103
103
  };
104
104
  exports.getRootIdentifier = getRootIdentifier;
105
+ const EXPRESSION_KINDS = {
106
+ NullLiteral: 'null',
107
+ ObjectExpression: 'an object literal',
108
+ ArrayExpression: 'an array literal',
109
+ CallExpression: 'a function call',
110
+ NewExpression: 'a new expression',
111
+ ConditionalExpression: 'a conditional expression',
112
+ ArrowFunctionExpression: 'a function',
113
+ FunctionExpression: 'a function',
114
+ TaggedTemplateExpression: 'a tagged template',
115
+ AwaitExpression: 'an await expression',
116
+ };
117
+ const expressionLabel = (node) => {
118
+ node = unwrapExpression(node);
119
+ if (exports.t.isIdentifier(node))
120
+ return node.value;
121
+ if (exports.t.isStringLiteral(node))
122
+ return `'${node.value}'`;
123
+ if (exports.t.isNumericLiteral(node))
124
+ return String(node.value);
125
+ if (exports.t.isMemberExpression(node)) {
126
+ const property = node.property;
127
+ if (property.type === 'Identifier')
128
+ return `${expressionLabel(node.object)}.${property.value}`;
129
+ if (property.type === 'Computed')
130
+ return `${expressionLabel(node.object)}[${expressionLabel(property.expression)}]`;
131
+ }
132
+ return EXPRESSION_KINDS[node.type] ?? 'an expression';
133
+ };
105
134
  const getNamespaceMember = (node, rootName) => {
106
135
  node = unwrapExpression(node);
107
136
  if (exports.t.isCallExpression(node)) {
@@ -278,7 +307,7 @@ function objectExpressionToObject(node, staticTable, keyframesHashTable, viewTra
278
307
  [root]: resolved,
279
308
  }));
280
309
  if (member === undefined)
281
- throw new Error(`[plumeria] Unknown style member on ${root}.`);
310
+ throw new Error(`[plumeria] Unknown style member: ${expressionLabel(val)} does not exist.`);
282
311
  obj[key] = member;
283
312
  return;
284
313
  }
@@ -684,7 +713,7 @@ function evaluateTemplateLiteral(node, staticTable, keyframesHashTable, viewTran
684
713
  const expr = node.expressions[i];
685
714
  const evaluatedExpr = evaluateExpression(expr, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
686
715
  if (evaluatedExpr === null || typeof evaluatedExpr === 'object')
687
- throw new Error('[plumeria] Template value cannot be resolved to a primitive.');
716
+ throw new Error(`[plumeria] Template value cannot be resolved to a primitive: ${expressionLabel(expr)} inside \${} must resolve to a string or number at build time.`);
688
717
  result += String(evaluatedExpr);
689
718
  }
690
719
  }
@@ -752,7 +781,7 @@ function evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTra
752
781
  const rightType = right === null ? 'null' : typeof right;
753
782
  throw new Error(`[plumeria] Binary operator ${node.operator} requires ${expected} operands; received ${leftType} and ${rightType}.`);
754
783
  }
755
- throw new Error(`[plumeria] Unsupported binary operator: ${node.operator}`);
784
+ throw new Error(`[plumeria] Unsupported binary operator: ${node.operator}. Use arithmetic, bitwise, &&, ||, or ?? operators, which can be resolved at build time.`);
756
785
  }
757
786
  function evaluateCallExpression(node, staticTable) {
758
787
  const callee = node.callee;
@@ -826,7 +855,7 @@ function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitio
826
855
  return createStaticObjectTable[hash];
827
856
  }
828
857
  }
829
- throw new Error(`[plumeria] Cannot resolve static value: ${node.value}`);
858
+ throw new Error(`[plumeria] Cannot resolve static value: ${node.value}. It must be a const holding a string or number, declared in this file or imported from a module plumeria can read.`);
830
859
  }
831
860
  if (exports.t.isMemberExpression(node)) {
832
861
  const resolved = resolveStaticTableMemberExpression(node, staticTable);
@@ -841,7 +870,7 @@ function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitio
841
870
  if (resolvedStatic !== undefined) {
842
871
  return resolvedStatic;
843
872
  }
844
- throw new Error('[plumeria] Cannot resolve static member expression.');
873
+ throw new Error(`[plumeria] Cannot resolve static member expression: ${expressionLabel(node)}. Its object must be a const or a value created by css.createStatic or css.createTheme.`);
845
874
  }
846
875
  if (exports.t.isBinaryExpression(node)) {
847
876
  return evaluateBinaryExpression(node, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
@@ -861,12 +890,12 @@ function evaluateExpression(node, staticTable, keyframesHashTable, viewTransitio
861
890
  if (node.operator === '~')
862
891
  return ~value;
863
892
  }
864
- throw new Error(`[plumeria] Unsupported unary operand for ${node.operator}`);
893
+ throw new Error(`[plumeria] Unsupported unary operand for ${node.operator}: ${expressionLabel(node.argument)} must resolve to a number at build time.`);
865
894
  }
866
895
  if (exports.t.isParenthesisExpression(node)) {
867
896
  return evaluateExpression(node.expression, staticTable, keyframesHashTable, viewTransitionHashTable, createThemeHashTable, createThemeObjectTable, createStaticHashTable, createStaticObjectTable);
868
897
  }
869
- throw new Error(`[plumeria] Unsupported expression type: ${node.type}`);
898
+ throw new Error(`[plumeria] Unsupported expression type: ${expressionLabel(node)}. Style values must be literals, consts, or arithmetic and template expressions of them.`);
870
899
  }
871
900
  function resolveKeyframesTableMemberExpression(node, keyframesHashTable) {
872
901
  if (exports.t.isIdentifier(node)) {
@@ -1686,7 +1715,7 @@ function runScan(scanCwd = process.cwd()) {
1686
1715
  else if (method === 'createTheme') {
1687
1716
  const selector = resolveThemeSelector(init.arguments[0].expression, scopedStaticTable, localCreateStaticHashTable, localCreateStaticObjectTable);
1688
1717
  if (!selector)
1689
- throw new Error('[plumeria] createTheme requires a statically resolvable non-empty selector.');
1718
+ throw new Error('[plumeria] createTheme needs a non-empty selector it can read at build time. Pass a string literal such as ".dark", or a name this file declares as one.');
1690
1719
  const hash = (0, createTheme_1.themeHashOf)(selector, obj);
1691
1720
  localTables.createThemeObjectTable[hash] = obj;
1692
1721
  localCreateThemeObjectTable[hash] = obj;
package/dist/transform.js CHANGED
@@ -39,7 +39,7 @@ const path = __importStar(require("path"));
39
39
  const zss_engine_1 = require("zss-engine");
40
40
  const parser_1 = require("./parser");
41
41
  const unresolvableValue_1 = require("./unresolvableValue");
42
- const spreadValues = (tables, constNodes) => {
42
+ const spreadValues = (tables, constNodes, sourceOf) => {
43
43
  const spread = (prop) => {
44
44
  let values;
45
45
  try {
@@ -72,7 +72,7 @@ const spreadValues = (tables, constNodes) => {
72
72
  return false;
73
73
  }
74
74
  };
75
- return { spread, resolvesValue };
75
+ return { spread, resolvesValue, sourceOf };
76
76
  };
77
77
  const create_1 = require("./create");
78
78
  const dynamicKey_1 = require("./dynamicKey");
@@ -128,9 +128,9 @@ const destructuredPropAliases = (fn) => {
128
128
  }
129
129
  return aliases;
130
130
  };
131
- const propDefaultMessage = (source) => `Plumeria: A style prop default must be a defined style: "${source}". ` +
131
+ const propDefaultMessage = (source) => `[plumeria] A style prop default must be a defined style: "${source}". ` +
132
132
  `Apply a conditional or dynamic style where the element is styled.`;
133
- const spreadStyleMessage = (source) => `Plumeria: Spread elements in a style array are not supported: "...${source}". ` +
133
+ const spreadStyleMessage = (source) => `[plumeria] Spread elements in a style array are not supported: "...${source}". ` +
134
134
  `List each style explicitly.`;
135
135
  const resolveLocalStyleAlias = (aliases, expression) => {
136
136
  let current = expression;
@@ -196,6 +196,11 @@ const transformSource = async (env) => {
196
196
  const sourceBuffer = Buffer.from(source, 'utf-8');
197
197
  const leadingBytes = Buffer.byteLength(source.slice(0, leadingLen), 'utf-8');
198
198
  const baseByteOffset = ast.span.start - leadingBytes;
199
+ const getSource = (node) => {
200
+ const start = node.span.start - baseByteOffset;
201
+ const end = node.span.end - baseByteOffset;
202
+ return sourceBuffer.subarray(start, end).toString('utf-8');
203
+ };
199
204
  const throwCompilationError = (message, node) => {
200
205
  let suffix = '';
201
206
  if (node) {
@@ -232,16 +237,16 @@ const transformSource = async (env) => {
232
237
  if (!isPlumeriaStyle) {
233
238
  const failure = (0, parser_1.resolveOriginError)(node, rootId, localImports);
234
239
  if (failure) {
235
- throwCompilationError(`Plumeria: ${failure.message} (${path.basename(failure.filePath)})`);
240
+ throwCompilationError(`[plumeria] ${failure.message} (${path.basename(failure.filePath)})`);
236
241
  }
237
- throwCompilationError(`Plumeria: Dynamic or unresolvable style object "${getSource(node)}" is not supported.`, node);
242
+ throwCompilationError(`[plumeria] Dynamic or unresolvable style object "${getSource(node)}" is not supported.`, node);
238
243
  }
239
244
  }
240
245
  };
241
246
  const scannedTables = (0, parser_1.scanOverlay)();
242
247
  const ownFailure = (0, parser_1.resolveFileError)(baseId, '');
243
248
  if (ownFailure)
244
- throwCompilationError(`Plumeria: ${ownFailure.message}`);
249
+ throwCompilationError(`[plumeria] ${ownFailure.message}`);
245
250
  for (const node of ast.body) {
246
251
  if (node.type === 'ImportDeclaration') {
247
252
  const sourcePath = node.source.value;
@@ -605,14 +610,14 @@ const transformSource = async (env) => {
605
610
  if (propName && init && parser_1.t.isCallExpression(init)) {
606
611
  if (['create', 'createTheme', 'createStatic'].includes(propName) &&
607
612
  !topLevelDeclarators.has(node)) {
608
- throwCompilationError(`Plumeria: css.${propName} must be assigned to a top-level variable so its styles can be resolved across files. Move this declaration outside the function or block.`, node);
613
+ throwCompilationError(`[plumeria] css.${propName} must be assigned to a top-level variable so its styles can be resolved across files. Move this declaration outside the function or block.`, node);
609
614
  }
610
615
  if (['create', 'createTheme', 'createStatic'].includes(propName)) {
611
616
  const argumentIndex = propName === 'createTheme' ? 1 : 0;
612
617
  const argument = init.arguments[argumentIndex];
613
618
  const object = argument && literalObjectArgument(argument.expression);
614
619
  if (!object)
615
- throwCompilationError(`Plumeria: css.${propName} needs a style object it can read at build time. Pass an object literal or a top-level constant containing one.`, init);
620
+ throwCompilationError(`[plumeria] css.${propName} needs a style object it can read at build time. Pass an object literal or a top-level constant containing one.`, init);
616
621
  argument.expression = object;
617
622
  registeredStyleCalls.add(init.span.start);
618
623
  }
@@ -628,7 +633,7 @@ const transformSource = async (env) => {
628
633
  mergedCreateTable,
629
634
  mergedCreateStaticHashTable,
630
635
  scannedTables.createStaticObjectTable,
631
- ], localConstNodes));
636
+ ], localConstNodes, getSource));
632
637
  if (obj) {
633
638
  const hashMap = {};
634
639
  Object.entries(obj).forEach(([key, style]) => {
@@ -672,11 +677,11 @@ const transformSource = async (env) => {
672
677
  const selectorExpr = init.arguments[0].expression;
673
678
  const selector = (0, parser_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
674
679
  if (!selector) {
675
- throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
680
+ throwCompilationError(`[plumeria] createTheme needs a selector it can read at build time. ` +
676
681
  `Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
677
682
  }
678
683
  if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
679
- throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
684
+ throwCompilationError(`[plumeria] Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
680
685
  }
681
686
  const obj = (0, parser_1.objectExpressionToObject)(init.arguments[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
682
687
  (0, unresolvableValue_1.assertNoDroppedValues)(init.arguments[1].expression, obj, spreadValues([
@@ -688,7 +693,7 @@ const transformSource = async (env) => {
688
693
  mergedCreateTable,
689
694
  mergedCreateStaticHashTable,
690
695
  scannedTables.createStaticObjectTable,
691
- ], localConstNodes));
696
+ ], localConstNodes, getSource));
692
697
  const hash = (0, createTheme_1.themeHashOf)(selector, obj);
693
698
  if (parser_1.t.isIdentifier(node.id)) {
694
699
  const uniqueKey = `${resourcePath}-${node.id.value}`;
@@ -736,7 +741,7 @@ const transformSource = async (env) => {
736
741
  mergedCreateTable,
737
742
  mergedCreateStaticHashTable,
738
743
  scannedTables.createStaticObjectTable,
739
- ], localConstNodes));
744
+ ], localConstNodes, getSource));
740
745
  const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
741
746
  if (parser_1.t.isIdentifier(node.id)) {
742
747
  const uniqueKey = `${resourcePath}-${node.id.value}`;
@@ -842,7 +847,7 @@ const transformSource = async (env) => {
842
847
  if (propName) {
843
848
  if (['create', 'createTheme', 'createStatic'].includes(propName) &&
844
849
  !registeredStyleCalls.has(node.span.start)) {
845
- throwCompilationError(`Plumeria: css.${propName} must be assigned to a named top-level variable. Destructuring, assignment statements, and default-exported calls cannot be compiled.`, node);
850
+ throwCompilationError(`[plumeria] css.${propName} must be assigned to a named top-level variable. Destructuring, assignment statements, and default-exported calls cannot be compiled.`, node);
846
851
  }
847
852
  const args = node.arguments;
848
853
  if (propName === 'keyframes' && args.length > 0) {
@@ -858,7 +863,7 @@ const transformSource = async (env) => {
858
863
  mergedCreateTable,
859
864
  mergedCreateStaticHashTable,
860
865
  scannedTables.createStaticObjectTable,
861
- ], localConstNodes));
866
+ ], localConstNodes, getSource));
862
867
  const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
863
868
  scannedTables.keyframesObjectTable[hash] = obj;
864
869
  replacements.push({
@@ -881,7 +886,7 @@ const transformSource = async (env) => {
881
886
  mergedCreateTable,
882
887
  mergedCreateStaticHashTable,
883
888
  scannedTables.createStaticObjectTable,
884
- ], localConstNodes));
889
+ ], localConstNodes, getSource));
885
890
  const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
886
891
  scannedTables.viewTransitionObjectTable[hash] = obj;
887
892
  replacements.push({
@@ -896,11 +901,11 @@ const transformSource = async (env) => {
896
901
  const selectorExpr = args[0].expression;
897
902
  const selector = (0, parser_1.resolveThemeSelector)(selectorExpr, mergedStaticTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
898
903
  if (!selector) {
899
- throwCompilationError(`Plumeria: createTheme needs a selector it can read at build time. ` +
904
+ throwCompilationError(`[plumeria] createTheme needs a selector it can read at build time. ` +
900
905
  `Pass a string literal such as ".dark", or a name this file declares as one.`, selectorExpr);
901
906
  }
902
907
  if (selector.startsWith('@') && !(0, zss_engine_1.isAtRule)(selector)) {
903
- throwCompilationError(`Plumeria: Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
908
+ throwCompilationError(`[plumeria] Unsupported at-rule: "${selector}". createTheme only supports nesting at-rules such as @media, @container, @supports, @layer, and @scope.`, selectorExpr);
904
909
  }
905
910
  const obj = (0, parser_1.objectExpressionToObject)(args[1].expression, mergedStaticTable, mergedKeyframesTable, mergedViewTransitionTable, mergedCreateThemeHashTable, scannedTables.createThemeObjectTable, mergedCreateTable, mergedCreateStaticHashTable, scannedTables.createStaticObjectTable);
906
911
  (0, unresolvableValue_1.assertNoDroppedValues)(args[1].expression, obj, spreadValues([
@@ -912,7 +917,7 @@ const transformSource = async (env) => {
912
917
  mergedCreateTable,
913
918
  mergedCreateStaticHashTable,
914
919
  scannedTables.createStaticObjectTable,
915
- ], localConstNodes));
920
+ ], localConstNodes, getSource));
916
921
  const hash = (0, createTheme_1.themeHashOf)(selector, obj);
917
922
  scannedTables.createThemeObjectTable[hash] = obj;
918
923
  if (scannedTables.createThemeSelectorTable) {
@@ -932,7 +937,7 @@ const transformSource = async (env) => {
932
937
  mergedCreateTable,
933
938
  mergedCreateStaticHashTable,
934
939
  scannedTables.createStaticObjectTable,
935
- ], localConstNodes));
940
+ ], localConstNodes, getSource));
936
941
  const hash = (0, zss_engine_1.genBase36Hash)(obj, 1, 8);
937
942
  scannedTables.createStaticObjectTable[hash] = obj;
938
943
  }
@@ -1008,11 +1013,6 @@ const transformSource = async (env) => {
1008
1013
  }
1009
1014
  Object.values(n).forEach((val) => excludeSubtreeSpans(val));
1010
1015
  };
1011
- const getSource = (node) => {
1012
- const start = node.span.start - baseByteOffset;
1013
- const end = node.span.end - baseByteOffset;
1014
- return sourceBuffer.subarray(start, end).toString('utf-8');
1015
- };
1016
1016
  const isVisibleReference = (expr) => {
1017
1017
  if (parser_1.t.isIdentifier(expr))
1018
1018
  return referenceIdents.references.has(expr.span.start);
@@ -1148,7 +1148,7 @@ const transformSource = async (env) => {
1148
1148
  const argExpr = callArgs[0]?.expression;
1149
1149
  if (callArgs.length > 1 ||
1150
1150
  (argExpr && argExpr.type !== 'ObjectExpression')) {
1151
- throwCompilationError(`Plumeria: ${getSource(expr)} takes one object argument, because ${callee.property.value} destructures its parameter.`, expr);
1151
+ throwCompilationError(`[plumeria] ${getSource(expr)} takes one object argument, because ${callee.property.value} destructures its parameter.`, expr);
1152
1152
  }
1153
1153
  const given = new Map();
1154
1154
  (argExpr?.properties ?? []).forEach((prop) => {
@@ -1168,7 +1168,7 @@ const transformSource = async (env) => {
1168
1168
  if (!source) {
1169
1169
  if (func.defaults?.[local])
1170
1170
  return;
1171
- return throwCompilationError(`Plumeria: ${getSource(expr)} leaves "${key}" unset, and a dynamic style function has no value to fall back on.`, expr);
1171
+ return throwCompilationError(`[plumeria] ${getSource(expr)} leaves "${key}" unset, and a dynamic style function has no value to fall back on.`, expr);
1172
1172
  }
1173
1173
  if (!forceRuntime &&
1174
1174
  isStaticArgValue(source) &&
@@ -1387,7 +1387,7 @@ const transformSource = async (env) => {
1387
1387
  const dynamic = resolveDynamicCall(node);
1388
1388
  if (dynamic) {
1389
1389
  if (!isStyleProp) {
1390
- throwCompilationError(`Plumeria: css.use(${getSource(node)}) does not support dynamic function keys.`, node);
1390
+ throwCompilationError(`[plumeria] css.use(${getSource(node)}) does not support dynamic function keys.`, node);
1391
1391
  }
1392
1392
  branchStyle = dynamic.style;
1393
1393
  dynamic.vars.forEach((v) => dynamicVars.push({
@@ -1516,7 +1516,7 @@ const transformSource = async (env) => {
1516
1516
  }
1517
1517
  const carriesVars = possibilities.some((entry) => entry.hasVars);
1518
1518
  if (carriesVars && !isStyleProp) {
1519
- throwCompilationError(`Plumeria: "${varName}" carries a dynamic function key, and css.use() returns only a class name. ` +
1519
+ throwCompilationError(`[plumeria] "${varName}" carries a dynamic function key, and css.use() returns only a class name. ` +
1520
1520
  `Apply it to ${styleProp} on the element instead.`, expr);
1521
1521
  }
1522
1522
  const gate = gates.length ? `(${gates.join(' && ')}) && ` : '';
@@ -2276,7 +2276,7 @@ const transformSource = async (env) => {
2276
2276
  }
2277
2277
  const { classParts, isOptimizable, baseStyle, dynamicVars, propVarSpreads, } = buildClassParts(args, dynamicClassParts, existingClassExpr, true);
2278
2278
  if (!isOptimizable) {
2279
- throwCompilationError(`Plumeria: Dynamic or unresolvable style object "${getSource(expr)}" is not supported.`, expr);
2279
+ throwCompilationError(`[plumeria] Dynamic or unresolvable style object "${getSource(expr)}" is not supported.`, expr);
2280
2280
  }
2281
2281
  const styleParts = [
2282
2282
  ...existingStyleParts,
@@ -2346,7 +2346,7 @@ const transformSource = async (env) => {
2346
2346
  const propKey = callee.property.value;
2347
2347
  const styleInfo = localCreateStyles[varName];
2348
2348
  if (styleInfo?.functions?.[propKey]) {
2349
- throwCompilationError(`Plumeria: css.use(${getSource(expr)}) does not support dynamic function keys.`, expr);
2349
+ throwCompilationError(`[plumeria] css.use(${getSource(expr)}) does not support dynamic function keys.`, expr);
2350
2350
  }
2351
2351
  }
2352
2352
  const { classParts, isOptimizable } = buildClassParts(args);
@@ -2359,7 +2359,7 @@ const transformSource = async (env) => {
2359
2359
  });
2360
2360
  }
2361
2361
  else {
2362
- throwCompilationError(`Plumeria: Dynamic or unresolvable style object "${getSource(node)}" is not supported.`, node);
2362
+ throwCompilationError(`[plumeria] Dynamic or unresolvable style object "${getSource(node)}" is not supported.`, node);
2363
2363
  }
2364
2364
  },
2365
2365
  });
@@ -2369,7 +2369,7 @@ const transformSource = async (env) => {
2369
2369
  if (appliedStyleProps.has(`${name}:${propName}`)) {
2370
2370
  continue;
2371
2371
  }
2372
- throwCompilationError(`Plumeria: "${propName}" is a style received through a prop but is never applied ` +
2372
+ throwCompilationError(`[plumeria] "${propName}" is a style received through a prop but is never applied ` +
2373
2373
  `to ${styleProp} or css.use() here. Apply it on an element this component renders; ` +
2374
2374
  `a style prop cannot be passed on to another component.`, node);
2375
2375
  }
@@ -2379,7 +2379,7 @@ const transformSource = async (env) => {
2379
2379
  if (!isDev || keys.length === 0) {
2380
2380
  return JSON.stringify('');
2381
2381
  }
2382
- const head = JSON.stringify(`Plumeria: "${info.name}.`);
2382
+ const head = JSON.stringify(`[plumeria] "${info.name}.`);
2383
2383
  const tail = JSON.stringify(`" was read at runtime. The file that read it was not compiled ` +
2384
2384
  `because it does not reference "@plumeria/core" — add ` +
2385
2385
  `import '@plumeria/core'; to it (see the stack below). Defined in ` +
@@ -2410,7 +2410,7 @@ const transformSource = async (env) => {
2410
2410
  const end = call.span.end - baseByteOffset;
2411
2411
  const isResolved = replacements.some((r) => r.start <= start && r.end >= end);
2412
2412
  if (!isResolved) {
2413
- throwCompilationError(`Plumeria: ${getSource(call)} is only supported in the ${styleProp} prop. ` +
2413
+ throwCompilationError(`[plumeria] ${getSource(call)} is only supported in the ${styleProp} prop. ` +
2414
2414
  `A dynamic style function resolves to a class name and a CSS variable on the element itself, ` +
2415
2415
  `so it cannot be passed through another prop or read as a value.`, call);
2416
2416
  }
@@ -9,6 +9,7 @@ type ResolveSpread = (prop: SpreadElement) => SpreadInfo | null;
9
9
  export type StyleContext = {
10
10
  spread: ResolveSpread;
11
11
  resolvesValue: (value: unknown) => boolean;
12
+ sourceOf?: (node: unknown) => string;
12
13
  };
13
14
  export declare const assertNoDroppedValues: (node: SourceObject, resolved: StaticValues | null | undefined, context?: StyleContext, ignore?: Set<string>) => void;
14
15
  export {};
@@ -9,7 +9,7 @@ const keyValue = (key) => {
9
9
  ? value
10
10
  : undefined;
11
11
  };
12
- const unresolvableValue = (key, node) => new Error(`[plumeria] Cannot resolve the value of "${key}" at build time (${node.type}). ` +
12
+ const unresolvableValue = (key, node, context) => new Error(`[plumeria] Cannot resolve the value of "${key}" at build time (${context?.sourceOf?.(node) ?? node.type}). ` +
13
13
  `Values in css.create must be statically known; pass a runtime value through the ` +
14
14
  `function form, css.create({ name: (value) => ({ ... }) }).`);
15
15
  const overwrittenLater = (properties, index, key, context) => {
@@ -101,12 +101,12 @@ const assertStyleFunction = (func, context) => {
101
101
  continue;
102
102
  }
103
103
  if (RUNTIME_ONLY.has(value.type) && !readsAnyOf(value, params))
104
- throw unresolvableValue(key ?? '', value);
104
+ throw unresolvableValue(key ?? '', value, context);
105
105
  if ((value.type === 'Identifier' || value.type === 'MemberExpression') &&
106
106
  context &&
107
107
  !readsAnyOf(value, params) &&
108
108
  !context.resolvesValue(value))
109
- throw unresolvableValue(key ?? '', value);
109
+ throw unresolvableValue(key ?? '', value, context);
110
110
  }
111
111
  };
112
112
  walk(returned);
@@ -166,7 +166,7 @@ const assertNoDroppedValues = (node, resolved, context, ignore) => {
166
166
  if (value.type === 'NullLiteral')
167
167
  continue;
168
168
  if (!(key in resolved))
169
- throw unresolvableValue(key, value);
169
+ throw unresolvableValue(key, value, context);
170
170
  if (value.type === 'ObjectExpression') {
171
171
  const nested = resolved[key];
172
172
  if (nested && typeof nested === 'object')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plumeria/utils",
3
- "version": "19.2.15",
3
+ "version": "19.2.16",
4
4
  "description": "Plumeria Utils",
5
5
  "author": "Refirst 11",
6
6
  "license": "MIT",