@mintjamsinc/ichigojs 0.1.75 → 0.1.76
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 +82 -4
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +82 -5
- 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 +82 -4
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/util/DisplayString.d.ts +12 -0
- package/dist/types/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/ichigo.esm.js
CHANGED
|
@@ -9170,6 +9170,83 @@ class VDirectiveManager {
|
|
|
9170
9170
|
}
|
|
9171
9171
|
}
|
|
9172
9172
|
|
|
9173
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
9174
|
+
/**
|
|
9175
|
+
* The default Object.prototype.toString, used to detect plain objects that
|
|
9176
|
+
* have not overridden their string representation.
|
|
9177
|
+
*/
|
|
9178
|
+
const objectToString = Object.prototype.toString;
|
|
9179
|
+
/**
|
|
9180
|
+
* Checks if the value is a non-null object.
|
|
9181
|
+
*/
|
|
9182
|
+
function isObject(value) {
|
|
9183
|
+
return value !== null && typeof value === 'object';
|
|
9184
|
+
}
|
|
9185
|
+
/**
|
|
9186
|
+
* Checks if the value is a plain object (i.e. `[object Object]`).
|
|
9187
|
+
*/
|
|
9188
|
+
function isPlainObject(value) {
|
|
9189
|
+
return objectToString.call(value) === '[object Object]';
|
|
9190
|
+
}
|
|
9191
|
+
/**
|
|
9192
|
+
* Converts a symbol to a readable string, leaving other values untouched.
|
|
9193
|
+
* Used when rendering Map keys and Set entries.
|
|
9194
|
+
*/
|
|
9195
|
+
function stringifySymbol(value, index = '') {
|
|
9196
|
+
return typeof value === 'symbol' ? `Symbol(${value.description ?? index})` : value;
|
|
9197
|
+
}
|
|
9198
|
+
/**
|
|
9199
|
+
* JSON.stringify replacer that renders values JSON cannot represent natively
|
|
9200
|
+
* (Map, Set, Symbol, and non-plain objects) in a readable form.
|
|
9201
|
+
*/
|
|
9202
|
+
function replacer(_key, value) {
|
|
9203
|
+
if (value instanceof Map) {
|
|
9204
|
+
return {
|
|
9205
|
+
[`Map(${value.size})`]: [...value.entries()].reduce((entries, [key, val], i) => {
|
|
9206
|
+
entries[`${stringifySymbol(key, i)} =>`] = val;
|
|
9207
|
+
return entries;
|
|
9208
|
+
}, {}),
|
|
9209
|
+
};
|
|
9210
|
+
}
|
|
9211
|
+
if (value instanceof Set) {
|
|
9212
|
+
return {
|
|
9213
|
+
[`Set(${value.size})`]: [...value.values()].map(v => stringifySymbol(v)),
|
|
9214
|
+
};
|
|
9215
|
+
}
|
|
9216
|
+
if (typeof value === 'symbol') {
|
|
9217
|
+
return stringifySymbol(value);
|
|
9218
|
+
}
|
|
9219
|
+
if (isObject(value) && !Array.isArray(value) && !isPlainObject(value)) {
|
|
9220
|
+
// Non-plain objects (Date, RegExp, DOM nodes, ...) render via their own toString
|
|
9221
|
+
return String(value);
|
|
9222
|
+
}
|
|
9223
|
+
return value;
|
|
9224
|
+
}
|
|
9225
|
+
/**
|
|
9226
|
+
* Converts a value to a string suitable for display in rendered output,
|
|
9227
|
+
* following Vue's `toDisplayString` semantics:
|
|
9228
|
+
* - strings are returned as-is
|
|
9229
|
+
* - null and undefined become an empty string
|
|
9230
|
+
* - arrays and plain objects (without a custom toString) are rendered as
|
|
9231
|
+
* pretty-printed JSON, with Map/Set/Symbol entries made readable
|
|
9232
|
+
* - everything else is converted with String()
|
|
9233
|
+
* @param value The value to convert.
|
|
9234
|
+
* @returns The display string for the value.
|
|
9235
|
+
*/
|
|
9236
|
+
function toDisplayString(value) {
|
|
9237
|
+
if (typeof value === 'string') {
|
|
9238
|
+
return value;
|
|
9239
|
+
}
|
|
9240
|
+
if (value === null || value === undefined) {
|
|
9241
|
+
return '';
|
|
9242
|
+
}
|
|
9243
|
+
if (Array.isArray(value) ||
|
|
9244
|
+
(isObject(value) && (value.toString === objectToString || typeof value.toString !== 'function'))) {
|
|
9245
|
+
return JSON.stringify(value, replacer, 2);
|
|
9246
|
+
}
|
|
9247
|
+
return String(value);
|
|
9248
|
+
}
|
|
9249
|
+
|
|
9173
9250
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
9174
9251
|
/**
|
|
9175
9252
|
* List of standard JavaScript global objects that should be available in expressions.
|
|
@@ -9290,8 +9367,9 @@ class VTextEvaluator {
|
|
|
9290
9367
|
return GLOBAL_OBJECTS[name];
|
|
9291
9368
|
return undefined;
|
|
9292
9369
|
});
|
|
9293
|
-
// Evaluate the expression and replace {{...}} in the text
|
|
9294
|
-
|
|
9370
|
+
// Evaluate the expression and replace {{...}} in the text.
|
|
9371
|
+
// A function replacement keeps `$`-patterns in the value literal.
|
|
9372
|
+
result = result.replace(matches[i][0], () => toDisplayString(evaluator.func(...values)));
|
|
9295
9373
|
});
|
|
9296
9374
|
return result;
|
|
9297
9375
|
};
|
|
@@ -13052,8 +13130,7 @@ class VTextDirective {
|
|
|
13052
13130
|
},
|
|
13053
13131
|
applyToDOM() {
|
|
13054
13132
|
const element = vNode.node;
|
|
13055
|
-
|
|
13056
|
-
element.textContent = textContent ?? '';
|
|
13133
|
+
element.textContent = toDisplayString(evaluator.evaluate());
|
|
13057
13134
|
}
|
|
13058
13135
|
};
|
|
13059
13136
|
return updater;
|
|
@@ -15033,5 +15110,5 @@ function defineComponent(tagName, options) {
|
|
|
15033
15110
|
customElements.define(tagName, ComponentElement);
|
|
15034
15111
|
}
|
|
15035
15112
|
|
|
15036
|
-
export { ExpressionUtils, IchigoElement, ReactiveProxy, VComponent, VComponentRegistry, VDOM, defineComponent };
|
|
15113
|
+
export { ExpressionUtils, IchigoElement, ReactiveProxy, VComponent, VComponentRegistry, VDOM, defineComponent, toDisplayString };
|
|
15037
15114
|
//# sourceMappingURL=ichigo.esm.js.map
|