@mintjamsinc/ichigojs 0.1.29 → 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 +350 -2
- package/dist/ichigo.cjs.map +1 -1
- package/dist/ichigo.esm.js +350 -2
- 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 +350 -2
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/types/ichigo/directives/StandardDirectiveName.d.ts +5 -1
- package/dist/types/ichigo/directives/VHtmlDirective.d.ts +78 -0
- package/dist/types/ichigo/directives/VTextDirective.d.ts +78 -0
- package/package.json +1 -1
package/dist/ichigo.cjs
CHANGED
|
@@ -171,6 +171,10 @@
|
|
|
171
171
|
StandardDirectiveName["V_PERFORMANCE"] = "v-performance";
|
|
172
172
|
/** Component directive. */
|
|
173
173
|
StandardDirectiveName["V_COMPONENT"] = "v-component";
|
|
174
|
+
/** Raw HTML content directive. */
|
|
175
|
+
StandardDirectiveName["V_HTML"] = "v-html";
|
|
176
|
+
/** Text content directive. */
|
|
177
|
+
StandardDirectiveName["V_TEXT"] = "v-text";
|
|
174
178
|
})(StandardDirectiveName || (StandardDirectiveName = {}));
|
|
175
179
|
|
|
176
180
|
// This file was generated. Do not modify manually!
|
|
@@ -8178,6 +8182,59 @@
|
|
|
8178
8182
|
}
|
|
8179
8183
|
|
|
8180
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
|
+
};
|
|
8181
8238
|
/**
|
|
8182
8239
|
* A class to evaluate text with embedded expressions in the form of {{...}}.
|
|
8183
8240
|
* It extracts identifiers from the expressions and evaluates them using provided bindings.
|
|
@@ -8225,7 +8282,18 @@
|
|
|
8225
8282
|
let result = text;
|
|
8226
8283
|
evaluators.forEach((evaluator, i) => {
|
|
8227
8284
|
// Gather the current values of the identifiers from the bindings
|
|
8228
|
-
|
|
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
|
+
});
|
|
8229
8297
|
// Evaluate the expression and replace {{...}} in the text
|
|
8230
8298
|
result = result.replace(matches[i][0], String(evaluator.func(...values)));
|
|
8231
8299
|
});
|
|
@@ -9751,6 +9819,140 @@
|
|
|
9751
9819
|
}
|
|
9752
9820
|
}
|
|
9753
9821
|
|
|
9822
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
9823
|
+
/**
|
|
9824
|
+
* Directive for setting raw HTML content of an element.
|
|
9825
|
+
* This directive evaluates an expression and sets the result as the innerHTML of the element.
|
|
9826
|
+
* For example:
|
|
9827
|
+
* <div v-html="htmlContent"></div>
|
|
9828
|
+
* The element's innerHTML will be replaced with the value of htmlContent.
|
|
9829
|
+
*
|
|
9830
|
+
* WARNING: Dynamically rendering arbitrary HTML can be very dangerous because it can easily lead to XSS attacks.
|
|
9831
|
+
* Only use v-html on trusted content and never on user-provided content.
|
|
9832
|
+
*/
|
|
9833
|
+
class VHtmlDirective {
|
|
9834
|
+
/**
|
|
9835
|
+
* The virtual node to which this directive is applied.
|
|
9836
|
+
*/
|
|
9837
|
+
#vNode;
|
|
9838
|
+
/**
|
|
9839
|
+
* The expression evaluator for this directive.
|
|
9840
|
+
*/
|
|
9841
|
+
#evaluator;
|
|
9842
|
+
/**
|
|
9843
|
+
* @param context The context for parsing the directive.
|
|
9844
|
+
*/
|
|
9845
|
+
constructor(context) {
|
|
9846
|
+
this.#vNode = context.vNode;
|
|
9847
|
+
// Parse the expression and create the evaluator
|
|
9848
|
+
const expression = context.attribute.value;
|
|
9849
|
+
if (!context.vNode.bindings) {
|
|
9850
|
+
throw new Error('VHtmlDirective requires bindings');
|
|
9851
|
+
}
|
|
9852
|
+
this.#evaluator = ExpressionEvaluator.create(expression, context.vNode.bindings, context.vNode.vApplication.functionDependencies);
|
|
9853
|
+
// Remove the directive attribute from the element
|
|
9854
|
+
this.#vNode.node.removeAttribute(context.attribute.name);
|
|
9855
|
+
}
|
|
9856
|
+
/**
|
|
9857
|
+
* @inheritdoc
|
|
9858
|
+
*/
|
|
9859
|
+
get name() {
|
|
9860
|
+
return StandardDirectiveName.V_HTML;
|
|
9861
|
+
}
|
|
9862
|
+
/**
|
|
9863
|
+
* @inheritdoc
|
|
9864
|
+
*/
|
|
9865
|
+
get vNode() {
|
|
9866
|
+
return this.#vNode;
|
|
9867
|
+
}
|
|
9868
|
+
/**
|
|
9869
|
+
* @inheritdoc
|
|
9870
|
+
*/
|
|
9871
|
+
get needsAnchor() {
|
|
9872
|
+
return false;
|
|
9873
|
+
}
|
|
9874
|
+
/**
|
|
9875
|
+
* @inheritdoc
|
|
9876
|
+
*/
|
|
9877
|
+
get bindingsPreparer() {
|
|
9878
|
+
return undefined;
|
|
9879
|
+
}
|
|
9880
|
+
/**
|
|
9881
|
+
* @inheritdoc
|
|
9882
|
+
*/
|
|
9883
|
+
get domUpdater() {
|
|
9884
|
+
const identifiers = this.#evaluator.dependentIdentifiers;
|
|
9885
|
+
const evaluator = this.#evaluator;
|
|
9886
|
+
const vNode = this.#vNode;
|
|
9887
|
+
// Create an updater that sets the innerHTML
|
|
9888
|
+
const updater = {
|
|
9889
|
+
get dependentIdentifiers() {
|
|
9890
|
+
return identifiers;
|
|
9891
|
+
},
|
|
9892
|
+
applyToDOM() {
|
|
9893
|
+
const element = vNode.node;
|
|
9894
|
+
const htmlContent = evaluator.evaluate();
|
|
9895
|
+
element.innerHTML = htmlContent ?? '';
|
|
9896
|
+
}
|
|
9897
|
+
};
|
|
9898
|
+
return updater;
|
|
9899
|
+
}
|
|
9900
|
+
/**
|
|
9901
|
+
* @inheritdoc
|
|
9902
|
+
*/
|
|
9903
|
+
get templatize() {
|
|
9904
|
+
return false;
|
|
9905
|
+
}
|
|
9906
|
+
/**
|
|
9907
|
+
* @inheritdoc
|
|
9908
|
+
*/
|
|
9909
|
+
get dependentIdentifiers() {
|
|
9910
|
+
return this.#evaluator.dependentIdentifiers;
|
|
9911
|
+
}
|
|
9912
|
+
/**
|
|
9913
|
+
* @inheritdoc
|
|
9914
|
+
*/
|
|
9915
|
+
get onMount() {
|
|
9916
|
+
return undefined;
|
|
9917
|
+
}
|
|
9918
|
+
/**
|
|
9919
|
+
* @inheritdoc
|
|
9920
|
+
*/
|
|
9921
|
+
get onMounted() {
|
|
9922
|
+
return undefined;
|
|
9923
|
+
}
|
|
9924
|
+
/**
|
|
9925
|
+
* @inheritdoc
|
|
9926
|
+
*/
|
|
9927
|
+
get onUpdate() {
|
|
9928
|
+
return undefined;
|
|
9929
|
+
}
|
|
9930
|
+
/**
|
|
9931
|
+
* @inheritdoc
|
|
9932
|
+
*/
|
|
9933
|
+
get onUpdated() {
|
|
9934
|
+
return undefined;
|
|
9935
|
+
}
|
|
9936
|
+
/**
|
|
9937
|
+
* @inheritdoc
|
|
9938
|
+
*/
|
|
9939
|
+
get onUnmount() {
|
|
9940
|
+
return undefined;
|
|
9941
|
+
}
|
|
9942
|
+
/**
|
|
9943
|
+
* @inheritdoc
|
|
9944
|
+
*/
|
|
9945
|
+
get onUnmounted() {
|
|
9946
|
+
return undefined;
|
|
9947
|
+
}
|
|
9948
|
+
/**
|
|
9949
|
+
* @inheritdoc
|
|
9950
|
+
*/
|
|
9951
|
+
destroy() {
|
|
9952
|
+
// No specific cleanup needed for this directive
|
|
9953
|
+
}
|
|
9954
|
+
}
|
|
9955
|
+
|
|
9754
9956
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
9755
9957
|
/**
|
|
9756
9958
|
* Directive for conditional rendering in the virtual DOM.
|
|
@@ -11262,6 +11464,140 @@
|
|
|
11262
11464
|
}
|
|
11263
11465
|
}
|
|
11264
11466
|
|
|
11467
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
11468
|
+
/**
|
|
11469
|
+
* Directive for setting text content of an element.
|
|
11470
|
+
* This directive evaluates an expression and sets the result as the textContent of the element.
|
|
11471
|
+
* For example:
|
|
11472
|
+
* <div v-text="message"></div>
|
|
11473
|
+
* The element's textContent will be replaced with the value of message.
|
|
11474
|
+
*
|
|
11475
|
+
* Unlike v-html, this directive safely escapes HTML content, preventing XSS attacks.
|
|
11476
|
+
* Use this directive when you want to display plain text.
|
|
11477
|
+
*/
|
|
11478
|
+
class VTextDirective {
|
|
11479
|
+
/**
|
|
11480
|
+
* The virtual node to which this directive is applied.
|
|
11481
|
+
*/
|
|
11482
|
+
#vNode;
|
|
11483
|
+
/**
|
|
11484
|
+
* The expression evaluator for this directive.
|
|
11485
|
+
*/
|
|
11486
|
+
#evaluator;
|
|
11487
|
+
/**
|
|
11488
|
+
* @param context The context for parsing the directive.
|
|
11489
|
+
*/
|
|
11490
|
+
constructor(context) {
|
|
11491
|
+
this.#vNode = context.vNode;
|
|
11492
|
+
// Parse the expression and create the evaluator
|
|
11493
|
+
const expression = context.attribute.value;
|
|
11494
|
+
if (!context.vNode.bindings) {
|
|
11495
|
+
throw new Error('VTextDirective requires bindings');
|
|
11496
|
+
}
|
|
11497
|
+
this.#evaluator = ExpressionEvaluator.create(expression, context.vNode.bindings, context.vNode.vApplication.functionDependencies);
|
|
11498
|
+
// Remove the directive attribute from the element
|
|
11499
|
+
this.#vNode.node.removeAttribute(context.attribute.name);
|
|
11500
|
+
}
|
|
11501
|
+
/**
|
|
11502
|
+
* @inheritdoc
|
|
11503
|
+
*/
|
|
11504
|
+
get name() {
|
|
11505
|
+
return StandardDirectiveName.V_TEXT;
|
|
11506
|
+
}
|
|
11507
|
+
/**
|
|
11508
|
+
* @inheritdoc
|
|
11509
|
+
*/
|
|
11510
|
+
get vNode() {
|
|
11511
|
+
return this.#vNode;
|
|
11512
|
+
}
|
|
11513
|
+
/**
|
|
11514
|
+
* @inheritdoc
|
|
11515
|
+
*/
|
|
11516
|
+
get needsAnchor() {
|
|
11517
|
+
return false;
|
|
11518
|
+
}
|
|
11519
|
+
/**
|
|
11520
|
+
* @inheritdoc
|
|
11521
|
+
*/
|
|
11522
|
+
get bindingsPreparer() {
|
|
11523
|
+
return undefined;
|
|
11524
|
+
}
|
|
11525
|
+
/**
|
|
11526
|
+
* @inheritdoc
|
|
11527
|
+
*/
|
|
11528
|
+
get domUpdater() {
|
|
11529
|
+
const identifiers = this.#evaluator.dependentIdentifiers;
|
|
11530
|
+
const evaluator = this.#evaluator;
|
|
11531
|
+
const vNode = this.#vNode;
|
|
11532
|
+
// Create an updater that sets the textContent
|
|
11533
|
+
const updater = {
|
|
11534
|
+
get dependentIdentifiers() {
|
|
11535
|
+
return identifiers;
|
|
11536
|
+
},
|
|
11537
|
+
applyToDOM() {
|
|
11538
|
+
const element = vNode.node;
|
|
11539
|
+
const textContent = evaluator.evaluate();
|
|
11540
|
+
element.textContent = textContent ?? '';
|
|
11541
|
+
}
|
|
11542
|
+
};
|
|
11543
|
+
return updater;
|
|
11544
|
+
}
|
|
11545
|
+
/**
|
|
11546
|
+
* @inheritdoc
|
|
11547
|
+
*/
|
|
11548
|
+
get templatize() {
|
|
11549
|
+
return false;
|
|
11550
|
+
}
|
|
11551
|
+
/**
|
|
11552
|
+
* @inheritdoc
|
|
11553
|
+
*/
|
|
11554
|
+
get dependentIdentifiers() {
|
|
11555
|
+
return this.#evaluator.dependentIdentifiers;
|
|
11556
|
+
}
|
|
11557
|
+
/**
|
|
11558
|
+
* @inheritdoc
|
|
11559
|
+
*/
|
|
11560
|
+
get onMount() {
|
|
11561
|
+
return undefined;
|
|
11562
|
+
}
|
|
11563
|
+
/**
|
|
11564
|
+
* @inheritdoc
|
|
11565
|
+
*/
|
|
11566
|
+
get onMounted() {
|
|
11567
|
+
return undefined;
|
|
11568
|
+
}
|
|
11569
|
+
/**
|
|
11570
|
+
* @inheritdoc
|
|
11571
|
+
*/
|
|
11572
|
+
get onUpdate() {
|
|
11573
|
+
return undefined;
|
|
11574
|
+
}
|
|
11575
|
+
/**
|
|
11576
|
+
* @inheritdoc
|
|
11577
|
+
*/
|
|
11578
|
+
get onUpdated() {
|
|
11579
|
+
return undefined;
|
|
11580
|
+
}
|
|
11581
|
+
/**
|
|
11582
|
+
* @inheritdoc
|
|
11583
|
+
*/
|
|
11584
|
+
get onUnmount() {
|
|
11585
|
+
return undefined;
|
|
11586
|
+
}
|
|
11587
|
+
/**
|
|
11588
|
+
* @inheritdoc
|
|
11589
|
+
*/
|
|
11590
|
+
get onUnmounted() {
|
|
11591
|
+
return undefined;
|
|
11592
|
+
}
|
|
11593
|
+
/**
|
|
11594
|
+
* @inheritdoc
|
|
11595
|
+
*/
|
|
11596
|
+
destroy() {
|
|
11597
|
+
// No specific cleanup needed for this directive
|
|
11598
|
+
}
|
|
11599
|
+
}
|
|
11600
|
+
|
|
11265
11601
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
|
11266
11602
|
/**
|
|
11267
11603
|
* The directive parser for standard directives.
|
|
@@ -11299,7 +11635,11 @@
|
|
|
11299
11635
|
context.attribute.name === StandardDirectiveName.V_PERFORMANCE ||
|
|
11300
11636
|
// v-component, v-component.<modifier>
|
|
11301
11637
|
context.attribute.name === StandardDirectiveName.V_COMPONENT ||
|
|
11302
|
-
context.attribute.name.startsWith(StandardDirectiveName.V_COMPONENT + ".")
|
|
11638
|
+
context.attribute.name.startsWith(StandardDirectiveName.V_COMPONENT + ".") ||
|
|
11639
|
+
// v-html
|
|
11640
|
+
context.attribute.name === StandardDirectiveName.V_HTML ||
|
|
11641
|
+
// v-text
|
|
11642
|
+
context.attribute.name === StandardDirectiveName.V_TEXT) {
|
|
11303
11643
|
return true;
|
|
11304
11644
|
}
|
|
11305
11645
|
return false;
|
|
@@ -11355,6 +11695,14 @@
|
|
|
11355
11695
|
context.attribute.name.startsWith(StandardDirectiveName.V_COMPONENT + ".")) {
|
|
11356
11696
|
return new VComponentDirective(context);
|
|
11357
11697
|
}
|
|
11698
|
+
// v-html
|
|
11699
|
+
if (context.attribute.name === StandardDirectiveName.V_HTML) {
|
|
11700
|
+
return new VHtmlDirective(context);
|
|
11701
|
+
}
|
|
11702
|
+
// v-text
|
|
11703
|
+
if (context.attribute.name === StandardDirectiveName.V_TEXT) {
|
|
11704
|
+
return new VTextDirective(context);
|
|
11705
|
+
}
|
|
11358
11706
|
throw new Error(`The attribute "${context.attribute.name}" cannot be parsed by ${this.name}.`);
|
|
11359
11707
|
}
|
|
11360
11708
|
}
|