@discord/intl-loader-core 0.19.1 → 0.19.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@discord/intl-loader-core",
3
- "version": "0.19.1",
3
+ "version": "0.19.2",
4
4
  "license": "MIT",
5
5
  "description": "Core utilities for writing loaders and transformers using @discord/intl",
6
6
  "author": "Jon Egeland",
@@ -28,7 +28,7 @@
28
28
  "dependencies": {
29
29
  "chokidar": "^3.6.0",
30
30
  "debug": "^4.3.6",
31
- "@discord/intl-message-database": "0.19.1"
31
+ "@discord/intl-message-database": "0.19.2"
32
32
  },
33
33
  "devDependencies": {
34
34
  "@types/debug": "^4.1.12",
@@ -124,36 +124,13 @@ class MessageDefinitionsTransformer {
124
124
  * more of a debugging utility than anything else, but can be useful for diagnosing when messages
125
125
  * are used in critical paths or otherwise.
126
126
  *
127
- * @param {string} bindFunc Code expression that creates a getter bind
128
- * @returns {string}
127
+ * @returns {string[]}
129
128
  */
130
- createBindsProxy(bindFunc) {
131
- return `new Proxy({},
132
- {
133
- ownKeys(self) {
134
- return Reflect.ownKeys(self);
135
- },
136
- getOwnPropertyDescriptor(self, prop) {
137
- return {
138
- value: self[prop] ||= ${bindFunc},
139
- configurable: true,
140
- enumerable: true,
141
- writable: false,
142
- };
143
- },
144
- get(self, prop) {
145
- if (prop === '$$typeof') {
146
- return 'object';
147
- }
148
- if (prop === Symbol.toStringTag) {
149
- return 'IntlMessagesProxy';
150
- }
151
-
152
- self[prop] ||= ${bindFunc};
153
- return self[prop];
154
- },
155
- },
156
- )`;
129
+ createBindsProxy() {
130
+ return [
131
+ `const {makeMessagesProxy} = require('@discord/intl');`,
132
+ `const binds = makeMessagesProxy(${this.loaderName});`,
133
+ ];
157
134
  }
158
135
 
159
136
  /**
@@ -168,7 +145,7 @@ class MessageDefinitionsTransformer {
168
145
  case 'proxy':
169
146
  return [
170
147
  `const ${this.loaderName} = createLoader(_localeMap, _defaultLocale);`,
171
- `const binds = ${this.createBindsProxy(`(locale) => ${this.loaderName}.get(prop, locale)`)};`,
148
+ ...this.createBindsProxy(),
172
149
  ];
173
150
  case 'literal': {
174
151
  const bindLines = Object.keys(this.options.messageKeys).map(
@@ -105,10 +105,9 @@ export class MessageDefinitionsTransformer {
105
105
  * more of a debugging utility than anything else, but can be useful for diagnosing when messages
106
106
  * are used in critical paths or otherwise.
107
107
  *
108
- * @param {string} bindFunc Code expression that creates a getter bind
109
- * @returns {string}
108
+ * @returns {string[]}
110
109
  */
111
- createBindsProxy(bindFunc: string): string;
110
+ createBindsProxy(): string[];
112
111
  /**
113
112
  * Return a map of key names to bound message getter functions. If `proxyBinds` is
114
113
  * configured to be `true`, the binds will be created as a constant object in the output.