@mintjamsinc/ichigojs 0.1.30 → 0.1.31
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/ichigo.cjs +65 -1
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +65 -1
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.min.cjs +1 -1
- package/dist/ichigo.umd.js +65 -1
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/ichigo.cjs
CHANGED
|
@@ -8182,6 +8182,59 @@
|
|
|
8182
8182
|
}
|
|
8183
8183
|
|
|
8184
8184
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
8185
|
+
/**
|
|
8186
|
+
* List of standard JavaScript global objects that should be available in expressions.
|
|
8187
|
+
* These are used as fallbacks when the identifier is not found in the bindings.
|
|
8188
|
+
*/
|
|
8189
|
+
const GLOBAL_OBJECTS = {
|
|
8190
|
+
// Math and numbers
|
|
8191
|
+
Math,
|
|
8192
|
+
Number,
|
|
8193
|
+
BigInt,
|
|
8194
|
+
Infinity,
|
|
8195
|
+
NaN,
|
|
8196
|
+
// String and text
|
|
8197
|
+
String,
|
|
8198
|
+
// Boolean
|
|
8199
|
+
Boolean,
|
|
8200
|
+
// Objects and arrays
|
|
8201
|
+
Object,
|
|
8202
|
+
Array,
|
|
8203
|
+
// Date and time
|
|
8204
|
+
Date,
|
|
8205
|
+
// JSON
|
|
8206
|
+
JSON,
|
|
8207
|
+
// Regular expressions
|
|
8208
|
+
RegExp,
|
|
8209
|
+
// Errors
|
|
8210
|
+
Error,
|
|
8211
|
+
TypeError,
|
|
8212
|
+
RangeError,
|
|
8213
|
+
SyntaxError,
|
|
8214
|
+
ReferenceError,
|
|
8215
|
+
// Other utilities
|
|
8216
|
+
parseInt,
|
|
8217
|
+
parseFloat,
|
|
8218
|
+
isNaN,
|
|
8219
|
+
isFinite,
|
|
8220
|
+
encodeURI,
|
|
8221
|
+
encodeURIComponent,
|
|
8222
|
+
decodeURI,
|
|
8223
|
+
decodeURIComponent,
|
|
8224
|
+
// Collections
|
|
8225
|
+
Map,
|
|
8226
|
+
Set,
|
|
8227
|
+
WeakMap,
|
|
8228
|
+
WeakSet,
|
|
8229
|
+
// Promises
|
|
8230
|
+
Promise,
|
|
8231
|
+
// Symbols
|
|
8232
|
+
Symbol,
|
|
8233
|
+
// Console (for debugging)
|
|
8234
|
+
console,
|
|
8235
|
+
// undefined is a special case
|
|
8236
|
+
undefined,
|
|
8237
|
+
};
|
|
8185
8238
|
/**
|
|
8186
8239
|
* A class to evaluate text with embedded expressions in the form of {{...}}.
|
|
8187
8240
|
* It extracts identifiers from the expressions and evaluates them using provided bindings.
|
|
@@ -8229,7 +8282,18 @@
|
|
|
8229
8282
|
let result = text;
|
|
8230
8283
|
evaluators.forEach((evaluator, i) => {
|
|
8231
8284
|
// Gather the current values of the identifiers from the bindings
|
|
8232
|
-
|
|
8285
|
+
// Fall back to global objects if not found in bindings
|
|
8286
|
+
const values = evaluator.ids.map(id => {
|
|
8287
|
+
const value = bindings.get(id);
|
|
8288
|
+
if (value !== undefined) {
|
|
8289
|
+
return value;
|
|
8290
|
+
}
|
|
8291
|
+
// Check if it's a global object
|
|
8292
|
+
if (id in GLOBAL_OBJECTS) {
|
|
8293
|
+
return GLOBAL_OBJECTS[id];
|
|
8294
|
+
}
|
|
8295
|
+
return undefined;
|
|
8296
|
+
});
|
|
8233
8297
|
// Evaluate the expression and replace {{...}} in the text
|
|
8234
8298
|
result = result.replace(matches[i][0], String(evaluator.func(...values)));
|
|
8235
8299
|
});
|