@teleporthq/teleport-shared 0.43.57 → 0.43.60
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/__tests__/utils/ast-effect-cleanup.ts +312 -0
- package/__tests__/utils/string-utils.ts +16 -0
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +5 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/utils/ast-effect-cleanup.d.ts +54 -0
- package/dist/cjs/utils/ast-effect-cleanup.d.ts.map +1 -0
- package/dist/cjs/utils/ast-effect-cleanup.js +358 -0
- package/dist/cjs/utils/ast-effect-cleanup.js.map +1 -0
- package/dist/cjs/utils/product-discounts.d.ts +27 -0
- package/dist/cjs/utils/product-discounts.d.ts.map +1 -0
- package/dist/cjs/utils/product-discounts.js +31 -0
- package/dist/cjs/utils/product-discounts.js.map +1 -0
- package/dist/cjs/utils/string-utils.d.ts +1 -0
- package/dist/cjs/utils/string-utils.d.ts.map +1 -1
- package/dist/cjs/utils/string-utils.js +9 -1
- package/dist/cjs/utils/string-utils.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/utils/ast-effect-cleanup.d.ts +54 -0
- package/dist/esm/utils/ast-effect-cleanup.d.ts.map +1 -0
- package/dist/esm/utils/ast-effect-cleanup.js +330 -0
- package/dist/esm/utils/ast-effect-cleanup.js.map +1 -0
- package/dist/esm/utils/product-discounts.d.ts +27 -0
- package/dist/esm/utils/product-discounts.d.ts.map +1 -0
- package/dist/esm/utils/product-discounts.js +27 -0
- package/dist/esm/utils/product-discounts.js.map +1 -0
- package/dist/esm/utils/string-utils.d.ts +1 -0
- package/dist/esm/utils/string-utils.d.ts.map +1 -1
- package/dist/esm/utils/string-utils.js +7 -0
- package/dist/esm/utils/string-utils.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +4 -0
- package/src/utils/ast-effect-cleanup.ts +370 -0
- package/src/utils/product-discounts.ts +122 -0
- package/src/utils/string-utils.ts +8 -0
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
26
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
27
|
+
if (ar || !(i in from)) {
|
|
28
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
29
|
+
ar[i] = from[i];
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.normalizeEffectCleanups = exports.isProvablyNotAFunction = exports.EFFECT_HOOK_NAMES = void 0;
|
|
36
|
+
var types = __importStar(require("@babel/types"));
|
|
37
|
+
var ast_scope_1 = require("./ast-scope");
|
|
38
|
+
/**
|
|
39
|
+
* ------------------------------------------------------------------
|
|
40
|
+
* Effect-cleanup contract for generated React components
|
|
41
|
+
* ------------------------------------------------------------------
|
|
42
|
+
*
|
|
43
|
+
* React reads the RETURN VALUE of an effect callback as that effect's cleanup
|
|
44
|
+
* function and calls it on unmount (and before every re-run). Anything else
|
|
45
|
+
* coming back is stored anyway and invoked blindly, so a callback that returns
|
|
46
|
+
* a value which is not callable does not fail where it was written — it fails
|
|
47
|
+
* later, in React's own commit phase, as
|
|
48
|
+
*
|
|
49
|
+
* TypeError: destroy is not a function
|
|
50
|
+
* at safelyCallDestroy (react-dom.development.js)
|
|
51
|
+
*
|
|
52
|
+
* with a stack made entirely of React frames and no hint of the component that
|
|
53
|
+
* caused it. The page renders fine; it dies the moment the user navigates away.
|
|
54
|
+
*
|
|
55
|
+
* The shape that produced it here was a concise arrow body:
|
|
56
|
+
*
|
|
57
|
+
* useEffect(() => import('@google/model-viewer'), [])
|
|
58
|
+
*
|
|
59
|
+
* The arrow was only meant to RUN the dynamic import, but a concise body also
|
|
60
|
+
* RETURNS it, so every product card handed React a Promise as its cleanup and
|
|
61
|
+
* paginating the product list crashed the app.
|
|
62
|
+
*
|
|
63
|
+
* Emitters are expected to build effects whose callback returns a function or
|
|
64
|
+
* nothing at all. This module is the end-of-pipeline NET that repairs the
|
|
65
|
+
* shapes which are provably in breach, no matter which plugin produced them,
|
|
66
|
+
* so the same mistake can never reach a browser again.
|
|
67
|
+
*
|
|
68
|
+
* Like `ast-statement-order`, every repair here is a no-op on healthy code: a
|
|
69
|
+
* callback that already honours the contract prints byte-identical.
|
|
70
|
+
*/
|
|
71
|
+
/** The hooks whose first argument React treats as an effect with a cleanup. */
|
|
72
|
+
exports.EFFECT_HOOK_NAMES = new Set([
|
|
73
|
+
'useEffect',
|
|
74
|
+
'useLayoutEffect',
|
|
75
|
+
'useInsertionEffect',
|
|
76
|
+
]);
|
|
77
|
+
/**
|
|
78
|
+
* Identifier used for the temporary holding an effect callback's repaired
|
|
79
|
+
* return value. Prefixed and namespaced so it cannot collide with anything the
|
|
80
|
+
* UIDL can name; {@link pickCleanupBindingName} still proves it free.
|
|
81
|
+
*/
|
|
82
|
+
var CLEANUP_BINDING_NAME = '__tqEffectCleanup';
|
|
83
|
+
/**
|
|
84
|
+
* Statement-valued node keys — the positions where a single statement can sit
|
|
85
|
+
* without an enclosing block, e.g. the `return` of `if (done) return {}`.
|
|
86
|
+
* Repairing one means replacing it with a block, which these keys allow.
|
|
87
|
+
*/
|
|
88
|
+
var SINGLE_STATEMENT_KEYS = ['consequent', 'alternate', 'body'];
|
|
89
|
+
/**
|
|
90
|
+
* The hook a call expression invokes — a bare `useEffect(…)` or the
|
|
91
|
+
* `React.useEffect(…)` spelling some plugins emit — or `null` for anything
|
|
92
|
+
* else.
|
|
93
|
+
*
|
|
94
|
+
* Only the `React` namespace is accepted on purpose: `anything.useEffect(…)`
|
|
95
|
+
* would let an unrelated API that happens to share the name inherit React's
|
|
96
|
+
* cleanup contract, and rewriting ITS return value would be a real change in
|
|
97
|
+
* behaviour rather than a repair.
|
|
98
|
+
*/
|
|
99
|
+
var getCalledHookName = function (callee) {
|
|
100
|
+
if (!callee) {
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
if (callee.type === 'Identifier') {
|
|
104
|
+
return callee.name;
|
|
105
|
+
}
|
|
106
|
+
if ((callee.type === 'MemberExpression' || callee.type === 'OptionalMemberExpression') &&
|
|
107
|
+
!callee.computed &&
|
|
108
|
+
callee.object.type === 'Identifier' &&
|
|
109
|
+
callee.object.name === 'React' &&
|
|
110
|
+
callee.property.type === 'Identifier') {
|
|
111
|
+
return callee.property.name;
|
|
112
|
+
}
|
|
113
|
+
return null;
|
|
114
|
+
};
|
|
115
|
+
/** True for the two node types React can actually call as a cleanup. */
|
|
116
|
+
var isFunctionExpression = function (node) {
|
|
117
|
+
return !!node && (node.type === 'ArrowFunctionExpression' || node.type === 'FunctionExpression');
|
|
118
|
+
};
|
|
119
|
+
/** True for `import('…')`, whose value is always a Promise. */
|
|
120
|
+
var isDynamicImportCall = function (node) {
|
|
121
|
+
if (node.type !== 'CallExpression' && node.type !== 'OptionalCallExpression') {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
var callee = node.callee;
|
|
125
|
+
// Babel models the dynamic import callee as its own `Import` node, but a
|
|
126
|
+
// hand-built AST may spell it as an identifier that happens to print the
|
|
127
|
+
// same. Both are the same expression once generated.
|
|
128
|
+
return callee.type === 'Import' || (callee.type === 'Identifier' && callee.name === 'import');
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* True when an expression can NEVER evaluate to something callable, so React
|
|
132
|
+
* would certainly reject it as a cleanup.
|
|
133
|
+
*
|
|
134
|
+
* Deliberately conservative — every entry is a shape whose result type is
|
|
135
|
+
* fixed by the language. `a || b`, `cond ? a : b`, `new X()` and any ordinary
|
|
136
|
+
* call are all absent because each of them CAN yield a function, and a net
|
|
137
|
+
* that rewrites code it has not proven broken is worse than the bug it hunts.
|
|
138
|
+
*/
|
|
139
|
+
var isProvablyNotAFunction = function (node) {
|
|
140
|
+
if (!node) {
|
|
141
|
+
return false;
|
|
142
|
+
}
|
|
143
|
+
switch (node.type) {
|
|
144
|
+
case 'StringLiteral':
|
|
145
|
+
case 'NumericLiteral':
|
|
146
|
+
case 'BooleanLiteral':
|
|
147
|
+
case 'NullLiteral':
|
|
148
|
+
case 'BigIntLiteral':
|
|
149
|
+
case 'DecimalLiteral':
|
|
150
|
+
case 'RegExpLiteral':
|
|
151
|
+
case 'TemplateLiteral':
|
|
152
|
+
case 'ObjectExpression':
|
|
153
|
+
case 'ArrayExpression':
|
|
154
|
+
case 'JSXElement':
|
|
155
|
+
case 'JSXFragment':
|
|
156
|
+
// `void x`, `typeof x`, `!x`, `-x`, `delete x` — each has a primitive result.
|
|
157
|
+
case 'UnaryExpression':
|
|
158
|
+
// `a + b`, `a instanceof B`, `a in b` — a number, string or boolean.
|
|
159
|
+
case 'BinaryExpression':
|
|
160
|
+
case 'UpdateExpression':
|
|
161
|
+
return true;
|
|
162
|
+
// A sequence evaluates to its last operand.
|
|
163
|
+
case 'SequenceExpression':
|
|
164
|
+
return (0, exports.isProvablyNotAFunction)(node.expressions[node.expressions.length - 1]);
|
|
165
|
+
default:
|
|
166
|
+
return isDynamicImportCall(node);
|
|
167
|
+
}
|
|
168
|
+
};
|
|
169
|
+
exports.isProvablyNotAFunction = isProvablyNotAFunction;
|
|
170
|
+
/**
|
|
171
|
+
* A binding name for the repaired return value that `expression` does not
|
|
172
|
+
* already read. Without this check the `const` introduced by the repair could
|
|
173
|
+
* shadow an outer binding the expression itself depends on, turning a cleanup
|
|
174
|
+
* bug into a ReferenceError.
|
|
175
|
+
*/
|
|
176
|
+
var pickCleanupBindingName = function (expression) {
|
|
177
|
+
var referenced = (0, ast_scope_1.collectReferencedIdentifiers)(expression, { includeDeferred: true });
|
|
178
|
+
if (!referenced.has(CLEANUP_BINDING_NAME)) {
|
|
179
|
+
return CLEANUP_BINDING_NAME;
|
|
180
|
+
}
|
|
181
|
+
var suffix = 2;
|
|
182
|
+
while (referenced.has("".concat(CLEANUP_BINDING_NAME).concat(suffix))) {
|
|
183
|
+
suffix++;
|
|
184
|
+
}
|
|
185
|
+
return "".concat(CLEANUP_BINDING_NAME).concat(suffix);
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* `<expression>; return;` — keeps the side effect and the early exit the
|
|
189
|
+
* original `return <expression>` had, and hands React nothing.
|
|
190
|
+
*/
|
|
191
|
+
var dropReturnedValue = function (statement) { return [
|
|
192
|
+
types.expressionStatement(statement.argument),
|
|
193
|
+
types.returnStatement(),
|
|
194
|
+
]; };
|
|
195
|
+
/**
|
|
196
|
+
* Turns a concise arrow body into a block that cannot leak a bad cleanup.
|
|
197
|
+
*
|
|
198
|
+
* The two branches match the two things a concise body can mean. An arrow
|
|
199
|
+
* returning an arrow (`() => () => stop()`) is a cleanup written on purpose
|
|
200
|
+
* and is left alone. Everything else returned a value only because concise
|
|
201
|
+
* arrow syntax returns whatever it evaluates — the author wrote an expression
|
|
202
|
+
* to RUN, not to hand back — so the value is either dropped (when it is
|
|
203
|
+
* provably not callable) or passed through a `typeof` gate that keeps a real
|
|
204
|
+
* cleanup and swallows anything else.
|
|
205
|
+
*/
|
|
206
|
+
var repairConciseArrowBody = function (callback) {
|
|
207
|
+
var expression = callback.body;
|
|
208
|
+
if (isFunctionExpression(expression)) {
|
|
209
|
+
return 0;
|
|
210
|
+
}
|
|
211
|
+
if ((0, exports.isProvablyNotAFunction)(expression)) {
|
|
212
|
+
callback.body = types.blockStatement([types.expressionStatement(expression)]);
|
|
213
|
+
return 1;
|
|
214
|
+
}
|
|
215
|
+
var name = pickCleanupBindingName(expression);
|
|
216
|
+
callback.body = types.blockStatement([
|
|
217
|
+
types.variableDeclaration('const', [
|
|
218
|
+
types.variableDeclarator(types.identifier(name), expression),
|
|
219
|
+
]),
|
|
220
|
+
types.ifStatement(types.binaryExpression('===', types.unaryExpression('typeof', types.identifier(name)), types.stringLiteral('function')), types.returnStatement(types.identifier(name))),
|
|
221
|
+
]);
|
|
222
|
+
return 1;
|
|
223
|
+
};
|
|
224
|
+
/**
|
|
225
|
+
* Strips values from the `return`s that belong to an effect callback's own
|
|
226
|
+
* body. Nested functions are skipped: their `return`s are answers to whoever
|
|
227
|
+
* calls them, not cleanups handed to React.
|
|
228
|
+
*/
|
|
229
|
+
var repairEffectReturns = function (body) {
|
|
230
|
+
var repaired = 0;
|
|
231
|
+
var needsRepair = function (statement) {
|
|
232
|
+
return statement.type === 'ReturnStatement' && (0, exports.isProvablyNotAFunction)(statement.argument);
|
|
233
|
+
};
|
|
234
|
+
// tslint:disable-next-line:no-any
|
|
235
|
+
var visit = function (node) {
|
|
236
|
+
if (!node || typeof node !== 'object') {
|
|
237
|
+
return;
|
|
238
|
+
}
|
|
239
|
+
if (Array.isArray(node)) {
|
|
240
|
+
for (var index = 0; index < node.length; index++) {
|
|
241
|
+
var entry = node[index];
|
|
242
|
+
if (entry && needsRepair(entry)) {
|
|
243
|
+
var replacement = dropReturnedValue(entry);
|
|
244
|
+
node.splice.apply(node, __spreadArray([index, 1], replacement, false));
|
|
245
|
+
// Step past the inserted `return;` — it is already compliant.
|
|
246
|
+
index += replacement.length - 1;
|
|
247
|
+
repaired++;
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
visit(entry);
|
|
251
|
+
}
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (typeof node.type !== 'string') {
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
// A nested function owns its own returns.
|
|
258
|
+
if (ast_scope_1.FUNCTION_NODE_TYPES.has(node.type)) {
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
// `if (done) return {}` has no statement list to splice into, so the bare
|
|
262
|
+
// statement is promoted to a block holding the repaired pair.
|
|
263
|
+
SINGLE_STATEMENT_KEYS.forEach(function (key) {
|
|
264
|
+
var child = node[key];
|
|
265
|
+
if (child && child.type === 'ReturnStatement' && needsRepair(child)) {
|
|
266
|
+
node[key] = types.blockStatement(dropReturnedValue(child));
|
|
267
|
+
repaired++;
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
Object.keys(node).forEach(function (key) {
|
|
271
|
+
if (ast_scope_1.AST_METADATA_KEYS.has(key) || key.charAt(0) === '_') {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
visit(node[key]);
|
|
275
|
+
});
|
|
276
|
+
};
|
|
277
|
+
visit(body);
|
|
278
|
+
return repaired;
|
|
279
|
+
};
|
|
280
|
+
/**
|
|
281
|
+
* Rebuilds an `async` effect callback as a synchronous one that starts the
|
|
282
|
+
* async work and returns nothing.
|
|
283
|
+
*
|
|
284
|
+
* An async function ALWAYS returns a Promise, so `useEffect(async () => …)` is
|
|
285
|
+
* broken by construction however careful its body is. Running the original
|
|
286
|
+
* function as an IIFE keeps its behaviour exactly (React passes an effect
|
|
287
|
+
* callback no arguments, so no parameter is lost) while the effect itself now
|
|
288
|
+
* hands React nothing.
|
|
289
|
+
*/
|
|
290
|
+
var wrapAsyncCallback = function (callback) {
|
|
291
|
+
return types.arrowFunctionExpression([], types.blockStatement([types.expressionStatement(types.callExpression(callback, []))]));
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* Brings one effect call in line with the cleanup contract. Returns how many
|
|
295
|
+
* repairs it took, so `0` means the call was already correct.
|
|
296
|
+
*/
|
|
297
|
+
var repairEffectCall = function (call) {
|
|
298
|
+
var callback = call.arguments[0];
|
|
299
|
+
if (!isFunctionExpression(callback)) {
|
|
300
|
+
// `useEffect(handler, [])` — the callback is defined elsewhere and nothing
|
|
301
|
+
// here can prove what it returns.
|
|
302
|
+
return 0;
|
|
303
|
+
}
|
|
304
|
+
// A generator called as an effect callback returns an iterator, but calling
|
|
305
|
+
// one runs NONE of its body, so there is no repair that preserves what the
|
|
306
|
+
// author wrote. Left untouched on purpose.
|
|
307
|
+
if (callback.generator) {
|
|
308
|
+
return 0;
|
|
309
|
+
}
|
|
310
|
+
if (callback.async) {
|
|
311
|
+
call.arguments[0] = wrapAsyncCallback(callback);
|
|
312
|
+
return 1;
|
|
313
|
+
}
|
|
314
|
+
if (callback.type === 'ArrowFunctionExpression' && callback.body.type !== 'BlockStatement') {
|
|
315
|
+
return repairConciseArrowBody(callback);
|
|
316
|
+
}
|
|
317
|
+
return repairEffectReturns(callback.body);
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Applies the cleanup contract to every effect hook call in an AST.
|
|
321
|
+
*
|
|
322
|
+
* Returns how many callbacks were repaired, which is what a caller wanting to
|
|
323
|
+
* assert "the pipeline emitted nothing broken" checks.
|
|
324
|
+
*/
|
|
325
|
+
var normalizeEffectCleanups = function (ast) {
|
|
326
|
+
var repaired = 0;
|
|
327
|
+
// tslint:disable-next-line:no-any
|
|
328
|
+
var walk = function (node) {
|
|
329
|
+
if (!node || typeof node !== 'object') {
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
if (Array.isArray(node)) {
|
|
333
|
+
node.forEach(function (entry) { return walk(entry); });
|
|
334
|
+
return;
|
|
335
|
+
}
|
|
336
|
+
if (typeof node.type !== 'string') {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (node.type === 'CallExpression' || node.type === 'OptionalCallExpression') {
|
|
340
|
+
var hookName = getCalledHookName(node.callee);
|
|
341
|
+
if (hookName && exports.EFFECT_HOOK_NAMES.has(hookName)) {
|
|
342
|
+
// Repaired before descending, so the walk goes on to visit whatever
|
|
343
|
+
// replaced the callback and finds any effect nested inside it.
|
|
344
|
+
repaired += repairEffectCall(node);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
Object.keys(node).forEach(function (key) {
|
|
348
|
+
if (ast_scope_1.AST_METADATA_KEYS.has(key) || key.charAt(0) === '_') {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
walk(node[key]);
|
|
352
|
+
});
|
|
353
|
+
};
|
|
354
|
+
walk(ast);
|
|
355
|
+
return repaired;
|
|
356
|
+
};
|
|
357
|
+
exports.normalizeEffectCleanups = normalizeEffectCleanups;
|
|
358
|
+
//# sourceMappingURL=ast-effect-cleanup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast-effect-cleanup.js","sourceRoot":"","sources":["../../../src/utils/ast-effect-cleanup.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,kD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AAQ,GAAG,iBAAiB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC/C,IAAI,QAAQ,IAAI,yBAAiB,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBAC/C,oEAAoE;gBACpE,+DAA+D;gBAC/D,QAAQ,IAAI,gBAAgB,CAAC,IAAI,CAAC,CAAA;aACnC;SACF;QAED,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,UAAC,GAAG;YAC5B,IAAI,6BAAiB,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,GAAG,EAAE;gBACvD,OAAM;aACP;YACD,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAA;QACjB,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,IAAI,CAAC,GAAG,CAAC,CAAA;IACT,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA;AArCY,QAAA,uBAAuB,2BAqCnC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The per-product discount rule, as ES5 source for embedding into generated
|
|
3
|
+
* runtime code (the data-source product transform, the storefront cart
|
|
4
|
+
* provider) that cannot import from this package.
|
|
5
|
+
*
|
|
6
|
+
* ⚠️ THIRD MIRROR. The same arithmetic exists in teleport-gui as
|
|
7
|
+
* `features/e-commerce/utils/product-discounts.ts` (the editor/canvas copy) and
|
|
8
|
+
* `features/workflows/templates/builders/ecommerce/product-discount-script.ts`
|
|
9
|
+
* (the copy baked into the add-to-cart workflow). All three must agree to the
|
|
10
|
+
* cent, or the price on the card, the price added to the cart and the price
|
|
11
|
+
* stored on the order will differ. The GUI's
|
|
12
|
+
* `utils/__tests__/product-discount-parity.spec.ts` pins the first two together;
|
|
13
|
+
* this one is covered by `__tests__/product-discounts.test.ts` here.
|
|
14
|
+
*
|
|
15
|
+
* Two rules the whole feature rests on:
|
|
16
|
+
*
|
|
17
|
+
* - Discounts come off the NET price, BEFORE storefront tax. Tax is a
|
|
18
|
+
* percentage of what is actually charged.
|
|
19
|
+
* - The stored `price` column never changes. A discount is a scheduled VIEW of
|
|
20
|
+
* the price, resolved on every read, so it starts and expires on its own.
|
|
21
|
+
*
|
|
22
|
+
* Everything is prefixed `__pd` so the block can be concatenated into any
|
|
23
|
+
* generated module without colliding with its locals — including alongside the
|
|
24
|
+
* `applyStorefrontTax` helpers, which it is always emitted with.
|
|
25
|
+
*/
|
|
26
|
+
export declare const generateProductDiscountHelperCode: () => string;
|
|
27
|
+
//# sourceMappingURL=product-discounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-discounts.d.ts","sourceRoot":"","sources":["../../../src/utils/product-discounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,iCAAiC,QAAO,MAgGpD,CAAA"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateProductDiscountHelperCode = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The per-product discount rule, as ES5 source for embedding into generated
|
|
6
|
+
* runtime code (the data-source product transform, the storefront cart
|
|
7
|
+
* provider) that cannot import from this package.
|
|
8
|
+
*
|
|
9
|
+
* ⚠️ THIRD MIRROR. The same arithmetic exists in teleport-gui as
|
|
10
|
+
* `features/e-commerce/utils/product-discounts.ts` (the editor/canvas copy) and
|
|
11
|
+
* `features/workflows/templates/builders/ecommerce/product-discount-script.ts`
|
|
12
|
+
* (the copy baked into the add-to-cart workflow). All three must agree to the
|
|
13
|
+
* cent, or the price on the card, the price added to the cart and the price
|
|
14
|
+
* stored on the order will differ. The GUI's
|
|
15
|
+
* `utils/__tests__/product-discount-parity.spec.ts` pins the first two together;
|
|
16
|
+
* this one is covered by `__tests__/product-discounts.test.ts` here.
|
|
17
|
+
*
|
|
18
|
+
* Two rules the whole feature rests on:
|
|
19
|
+
*
|
|
20
|
+
* - Discounts come off the NET price, BEFORE storefront tax. Tax is a
|
|
21
|
+
* percentage of what is actually charged.
|
|
22
|
+
* - The stored `price` column never changes. A discount is a scheduled VIEW of
|
|
23
|
+
* the price, resolved on every read, so it starts and expires on its own.
|
|
24
|
+
*
|
|
25
|
+
* Everything is prefixed `__pd` so the block can be concatenated into any
|
|
26
|
+
* generated module without colliding with its locals — including alongside the
|
|
27
|
+
* `applyStorefrontTax` helpers, which it is always emitted with.
|
|
28
|
+
*/
|
|
29
|
+
var generateProductDiscountHelperCode = function () { return "\n// \u2500\u2500 Per-product discounts \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n// Rides the product row as a JSON `discounts` column: an array of\n// { id, type: 'percentage'|'fixed', value, startsAt, endsAt } with ISO UTC\n// bounds and a HALF-OPEN [startsAt, endsAt) window, so back-to-back discounts\n// hand over with no overlap and no gap.\nfunction __pdRound2(n) { return Math.round(n * 100) / 100; }\n\nfunction __pdSafe(n) {\n var x = typeof n === 'number' ? n : parseFloat(n);\n return isFinite(x) ? x : 0;\n}\n\n// A bound that was written but cannot be read makes the window meaningless, so\n// the entry is dropped rather than silently becoming unbounded.\nfunction __pdBound(value) {\n if (value === null || value === undefined || value === '') { return { ok: true, time: null }; }\n var parsed = Date.parse(String(value));\n if (!isFinite(parsed)) { return { ok: false, time: null }; }\n return { ok: true, time: parsed };\n}\n\n// The column arrives as JSON text on SQL backends and as a real array on the\n// document stores, and it is hand-editable through the admin panel. Anything\n// unparseable means \"no discounts\" rather than an exception inside a render.\nfunction __pdParseDiscounts(raw) {\n var source = raw;\n if (typeof source === 'string') {\n if (source === '') { return []; }\n try { source = JSON.parse(source); } catch (e) { return []; }\n }\n if (Object.prototype.toString.call(source) !== '[object Array]') { return []; }\n var out = [];\n for (var i = 0; i < source.length; i++) {\n var entry = source[i];\n if (!entry || typeof entry !== 'object') { continue; }\n if (entry.type !== 'percentage' && entry.type !== 'fixed') { continue; }\n var value = __pdSafe(entry.value);\n if (value <= 0) { continue; }\n if (entry.type === 'percentage' && value > 100) { continue; }\n var start = __pdBound(entry.startsAt);\n var end = __pdBound(entry.endsAt);\n if (!start.ok || !end.ok) { continue; }\n out.push({\n type: entry.type,\n value: value,\n startTime: start.time === null ? -Infinity : start.time,\n endTime: end.time === null ? Infinity : end.time\n });\n }\n return out;\n}\n\n// Valid data has at most one live entry \u2014 the merchant panel refuses\n// overlapping windows \u2014 but the column is hand-editable, so first-live-wins\n// keeps the runtime deterministic instead of trusting.\nfunction __pdResolveActive(raw, nowMs) {\n var list = __pdParseDiscounts(raw);\n var now = isFinite(nowMs) ? Number(nowMs) : Date.now();\n for (var i = 0; i < list.length; i++) {\n if (list[i].startTime <= now && now < list[i].endTime) {\n return { type: list[i].type, value: list[i].value };\n }\n }\n return null;\n}\n\n// NET in, NET out \u2014 tax is added on top of the result. Clamped at both ends: a\n// fixed amount larger than the price makes the product free, never negative.\nfunction __pdDiscountedPrice(netPrice, discount) {\n var base = __pdRound2(__pdSafe(netPrice));\n if (base <= 0) { return Math.max(0, base); }\n if (!discount) { return base; }\n var value = Math.max(0, __pdSafe(discount.value));\n var discounted = discount.type === 'percentage'\n ? base * (1 - Math.min(value, 100) / 100)\n : base - value;\n return Math.max(0, __pdRound2(discounted));\n}\n\nfunction __pdDiscountAmount(netPrice, discount) {\n var base = Math.max(0, __pdRound2(__pdSafe(netPrice)));\n return __pdRound2(base - __pdDiscountedPrice(base, discount));\n}\n\n// \"10% off\" / \"$10 off\" / \"10 kr off\" \u2014 the badge copy. Symbol-based rather\n// than Intl-based, because it sits beside prices the storefront renders as a\n// symbol glued to two decimals.\nfunction __pdDiscountLabel(discount, currencySymbol, symbolPosition) {\n if (!discount) { return ''; }\n var value = __pdSafe(discount.value);\n var text = (Math.round(value * 100) / 100).toString();\n if (discount.type === 'percentage') { return text + '% off'; }\n var symbol = currencySymbol || '$';\n return (symbolPosition === 'after' ? text + ' ' + symbol : symbol + text) + ' off';\n}\n"; };
|
|
30
|
+
exports.generateProductDiscountHelperCode = generateProductDiscountHelperCode;
|
|
31
|
+
//# sourceMappingURL=product-discounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"product-discounts.js","sourceRoot":"","sources":["../../../src/utils/product-discounts.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,IAAM,iCAAiC,GAAG,cAAc,OAAA,uxIAgG9D,EAhG8D,CAgG9D,CAAA;AAhGY,QAAA,iCAAiC,qCAgG7C"}
|
|
@@ -29,5 +29,6 @@ export declare const addSpacesToEachLine: (spaces: string, str: string) => strin
|
|
|
29
29
|
export declare const removeLastEmptyLine: (str: string) => string;
|
|
30
30
|
export declare const encode: (str: string) => string;
|
|
31
31
|
export declare const generateRandomString: () => string;
|
|
32
|
+
export declare const sanitizeTranslationKey: (key: string) => string;
|
|
32
33
|
export declare const generateCSSVariableName: (name: string) => string;
|
|
33
34
|
//# sourceMappingURL=string-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.d.ts","sourceRoot":"","sources":["../../../src/utils/string-utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,MACgC,CAAA;AAClF,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,MACqB,CAAA;AAEvE,eAAO,MAAM,UAAU,QAAS,MAAM,KAAG,MAA6C,CAAA;AACtF,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAA6C,CAAA;AAEpF,eAAO,MAAM,wBAAwB,QAA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OAAO,MAAM,WAK9D,CAAA;AAED,eAAO,MAAM,mBAAmB,QAAS,MAAM,WAE9C,CAAA;AAYD,eAAO,MAAM,MAAM,QAAS,MAAM,WAQjC,CAAA;AAED,eAAO,MAAM,oBAAoB,cAAmD,CAAA;AAQpF,eAAO,MAAM,sBAAsB,QAAS,MAAM,KAAG,MAAiC,CAAA;AAEtF,eAAO,MAAM,uBAAuB,SAAU,MAAM,KAAG,MAEtD,CAAA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateCSSVariableName = exports.generateRandomString = exports.encode = exports.removeLastEmptyLine = exports.addSpacesToEachLine = exports.createGlobalStateSetterName = exports.createStateStoringFunction = exports.createStateOrPropStoringValue = exports.slugify = exports.removeIllegalCharacters = exports.dashCaseToUpperCamelCase = exports.camelize = exports.capitalize = exports.dashCaseToCamelCase = exports.camelCaseToDashCase = void 0;
|
|
3
|
+
exports.generateCSSVariableName = exports.sanitizeTranslationKey = exports.generateRandomString = exports.encode = exports.removeLastEmptyLine = exports.addSpacesToEachLine = exports.createGlobalStateSetterName = exports.createStateStoringFunction = exports.createStateOrPropStoringValue = exports.slugify = exports.removeIllegalCharacters = exports.dashCaseToUpperCamelCase = exports.camelize = exports.capitalize = exports.dashCaseToCamelCase = exports.camelCaseToDashCase = void 0;
|
|
4
4
|
var js_identifiers_1 = require("./js-identifiers");
|
|
5
5
|
var camelCaseToDashCase = function (str) {
|
|
6
6
|
return str.replace(/([a-z])(?=[A-Z])|([A-Z0-9])(?=[A-Z][a-z])/g, '$1$2-').toLowerCase();
|
|
@@ -101,6 +101,14 @@ var encode = function (str) {
|
|
|
101
101
|
exports.encode = encode;
|
|
102
102
|
var generateRandomString = function () { return Math.random().toString(36).substring(2, 6); };
|
|
103
103
|
exports.generateRandomString = generateRandomString;
|
|
104
|
+
// next-intl refuses to initialise when a messages-file key contains a `.` (its
|
|
105
|
+
// namespace separator), and translation keys minted from user text can contain
|
|
106
|
+
// anything. Every emitter of a translation key — the locale messages files AND
|
|
107
|
+
// each `translate.raw('<key>')` lookup — must funnel the key through this so
|
|
108
|
+
// both sides stay consistent for projects whose stored UIDL already carries
|
|
109
|
+
// dotted keys.
|
|
110
|
+
var sanitizeTranslationKey = function (key) { return key.replace(/\./g, '_'); };
|
|
111
|
+
exports.sanitizeTranslationKey = sanitizeTranslationKey;
|
|
104
112
|
var generateCSSVariableName = function (name) {
|
|
105
113
|
return name.startsWith('--') ? (0, exports.camelCaseToDashCase)(name) : (0, exports.camelCaseToDashCase)("--".concat(name));
|
|
106
114
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../../src/utils/string-utils.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAElD,IAAM,mBAAmB,GAAG,UAAC,GAAW;IAC7C,OAAA,GAAG,CAAC,OAAO,CAAC,4CAA4C,EAAE,OAAO,CAAC,CAAC,WAAW,EAAE;AAAhF,CAAgF,CAAA;AADrE,QAAA,mBAAmB,uBACkD;AAC3E,IAAM,mBAAmB,GAAG,UAAC,GAAW;IAC7C,OAAA,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,UAAC,CAAC,EAAE,GAAG,IAAK,OAAA,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAA9B,CAA8B,CAAC;AAArE,CAAqE,CAAA;AAD1D,QAAA,mBAAmB,uBACuC;AAEhE,IAAM,UAAU,GAAG,UAAC,GAAW,IAAa,OAAA,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAnC,CAAmC,CAAA;AAAzE,QAAA,UAAU,cAA+D;AAC/E,IAAM,QAAQ,GAAG,UAAC,GAAW,IAAa,OAAA,GAAG,CAAC,CAAC,CAAC,CAAC,W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,uBAAuB,2BAEnC"}
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,12 +5,14 @@ import * as GenericUtils from './utils/generic';
|
|
|
5
5
|
import * as JSIdentifiers from './utils/js-identifiers';
|
|
6
6
|
import * as ASTScope from './utils/ast-scope';
|
|
7
7
|
import * as ASTStatementOrder from './utils/ast-statement-order';
|
|
8
|
+
import * as ASTEffectCleanup from './utils/ast-effect-cleanup';
|
|
8
9
|
import * as RoutePaths from './utils/route-paths';
|
|
9
10
|
import * as LayoutTopology from './utils/layout-topology';
|
|
10
11
|
import * as HtmlContentModel from './utils/html-content-model';
|
|
11
12
|
import * as StyleDeclarations from './utils/style-declarations';
|
|
12
13
|
import * as StorefrontTax from './utils/storefront-tax';
|
|
14
|
+
import * as ProductDiscounts from './utils/product-discounts';
|
|
13
15
|
import * as EmailDate from './utils/email-date';
|
|
14
16
|
import * as DataCache from './cache';
|
|
15
|
-
export { Constants, StringUtils, UIDLUtils, GenericUtils, JSIdentifiers, ASTScope, ASTStatementOrder, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, EmailDate, DataCache, };
|
|
17
|
+
export { Constants, StringUtils, UIDLUtils, GenericUtils, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, EmailDate, DataCache, };
|
|
16
18
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,aAAa,MAAM,wBAA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A;AAC/D,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,gBAAgB,MAAM,2BAA2B,CAAA;AAC7D,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,SAAS,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,gBAAgB,EAChB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,SAAS,EACT,SAAS,GACV,CAAA"}
|
package/dist/esm/index.js
CHANGED
|
@@ -5,12 +5,14 @@ import * as GenericUtils from './utils/generic';
|
|
|
5
5
|
import * as JSIdentifiers from './utils/js-identifiers';
|
|
6
6
|
import * as ASTScope from './utils/ast-scope';
|
|
7
7
|
import * as ASTStatementOrder from './utils/ast-statement-order';
|
|
8
|
+
import * as ASTEffectCleanup from './utils/ast-effect-cleanup';
|
|
8
9
|
import * as RoutePaths from './utils/route-paths';
|
|
9
10
|
import * as LayoutTopology from './utils/layout-topology';
|
|
10
11
|
import * as HtmlContentModel from './utils/html-content-model';
|
|
11
12
|
import * as StyleDeclarations from './utils/style-declarations';
|
|
12
13
|
import * as StorefrontTax from './utils/storefront-tax';
|
|
14
|
+
import * as ProductDiscounts from './utils/product-discounts';
|
|
13
15
|
import * as EmailDate from './utils/email-date';
|
|
14
16
|
import * as DataCache from './cache';
|
|
15
|
-
export { Constants, StringUtils, UIDLUtils, GenericUtils, JSIdentifiers, ASTScope, ASTStatementOrder, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, EmailDate, DataCache, };
|
|
17
|
+
export { Constants, StringUtils, UIDLUtils, GenericUtils, JSIdentifiers, ASTScope, ASTStatementOrder, ASTEffectCleanup, RoutePaths, LayoutTopology, HtmlContentModel, StyleDeclarations, StorefrontTax, ProductDiscounts, EmailDate, DataCache, };
|
|
16
18
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC/C,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAA;AAC7C,OAAO,KAAK,iBAAiB,MAAM,6BAA6B,CAAA;AAChE,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,gBAAgB,MAAM,4BAA4B,CAAA;AAC9D,OAAO,KAAK,iBAAiB,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,aAAa,MAAM,wBAAwB,CAAA;AACvD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,SAAS,MAAM,SAAS,CAAA;AAEpC,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,YAAY,EACZ,aAAa,EACb,QAAQ,EACR,iBAAiB,EACjB,UAAU,EACV,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,SAAS,EACT,SAAS,GACV,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,WAAW,MAAM,sBAAsB,CAAA;AACnD,OAAO,KAAK,SAAS,MAAM,oBAAoB,CAAA;AAC/C,OAAO,KAAK,YAAY,MAAM,iBAAiB,CAAA;AAC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