@saykit/transform-js 0.8.0 → 0.9.0

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 (2) hide show
  1. package/dist/parser.mjs +0 -33
  2. package/package.json +2 -2
package/dist/parser.mjs CHANGED
@@ -12,10 +12,6 @@ function parseTaggedTemplateExpression(tagged) {
12
12
  context: descriptor ? findPropertyValueIfStringLiteralAsString(descriptor, "context") : void 0
13
13
  }, getTranslatorComments(tagged.leadingComments ?? []), tagged.loc ? [`${tagged.loc.filename}:${tagged.loc.start.line}`] : [], children, accessor);
14
14
  }
15
- /**
16
- * The text and the values of a template literal, in the order they were
17
- * written — the message the template spells out.
18
- */
19
15
  function buildTemplateChildren(template) {
20
16
  return template.quasis.reduce((c, q, i) => {
21
17
  c.push(new LiteralMessage(q.value.cooked ?? q.value.raw));
@@ -77,15 +73,6 @@ function parseCallExpression(call) {
77
73
  }
78
74
  return null;
79
75
  }
80
- /**
81
- * The `offset` a plural subtracts from its selector before `#` is formatted, so
82
- * "You and 2 others" can select on a total of three.
83
- *
84
- * Read only from an integer literal: the offset is baked into the extracted
85
- * message, so it has to be known at build time, and a fractional or negative
86
- * one is not something ICU accepts. Anything else stays an ordinary branch and
87
- * is validated as the key it looks like.
88
- */
89
76
  function findPluralOffset(object) {
90
77
  for (const property of object.properties) {
91
78
  if (!t.isObjectProperty(property) || property.computed) continue;
@@ -136,16 +123,6 @@ function getExpressionAsKey(node) {
136
123
  if (t.isJSXIdentifier(node)) return node.name;
137
124
  return AUTO_INCREMENT_IDENTIFIER;
138
125
  }
139
- /**
140
- * Read the name off a value written as a single-key object and hand back the
141
- * value alone, so the wrapper never reaches the output: `${{ total: sum() }}`
142
- * is `{total}` rather than `{0}`.
143
- *
144
- * An inline one-key object is the only shape this claims, and it is a shape
145
- * that could not mean anything else — interpolating an object stringifies it
146
- * to `[object Object]`, and rendering one in JSX throws. Anything else is
147
- * returned untouched and named the way it always was.
148
- */
149
126
  function unwrapPlaceholder(expression) {
150
127
  if (!t.isObjectExpression(expression) || expression.properties.length !== 1) return [getExpressionAsKey(expression), expression];
151
128
  const [property] = expression.properties;
@@ -156,16 +133,6 @@ function unwrapPlaceholder(expression) {
156
133
  if (!PLACEHOLDER_PATTERN.test(name)) throw new Error(`Invalid placeholder name '${name}', expected a letter or underscore followed by letters, digits, or underscores`);
157
134
  return [name, property.value];
158
135
  }
159
- /**
160
- * Whether two placeholders sharing a name are the same placeholder, and so
161
- * compile to one prop a translator can move around the sentence freely.
162
- *
163
- * A value is compared whole: the same variable interpolated twice is one value,
164
- * while `${name}` beside `${{ name: author.name }}` is two things claiming one
165
- * name. An element is compared on its opening element alone — `say-tag` has
166
- * been stripped by the time this runs, and its children come from the
167
- * translation rather than the source.
168
- */
169
136
  function isEquivalentPlaceholder(a, b) {
170
137
  if (t.isJSXElement(a) || t.isJSXElement(b)) {
171
138
  if (!t.isJSXElement(a) || !t.isJSXElement(b)) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@saykit/transform-js",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "JavaScript and TypeScript transformer for SayKit",
5
5
  "keywords": [
6
6
  "i18n",
@@ -47,7 +47,7 @@
47
47
  "@babel/parser": "^7.29.7",
48
48
  "@babel/traverse": "^7.29.7",
49
49
  "@babel/types": "^7.29.7",
50
- "@saykit/config": "^0.8.0"
50
+ "@saykit/config": "^0.9.0"
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/core": "^7.29.7",