@mintjamsinc/ichigojs 0.1.8 → 0.1.10
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/README.md +71 -1
- package/dist/ichigo.esm.js +271 -6
- package/dist/ichigo.esm.js.map +1 -1
- package/dist/ichigo.esm.min.js +1 -1
- package/dist/ichigo.esm.min.js.map +1 -1
- package/dist/ichigo.umd.js +271 -6
- package/dist/ichigo.umd.js.map +1 -1
- package/dist/ichigo.umd.min.js +1 -1
- package/dist/ichigo.umd.min.js.map +1 -1
- package/dist/types/ichigo/directives/StandardDirectiveName.d.ts +16 -1
- package/dist/types/ichigo/directives/VConditionalDirective.d.ts +5 -0
- package/dist/types/ichigo/directives/VDirectiveParserRegistry.d.ts +4 -0
- package/dist/types/ichigo/directives/VPerformanceDirective.d.ts +95 -0
- package/dist/types/ichigo/directives/VResizeDirective.d.ts +5 -0
- package/dist/types/ichigo/util/ExpressionUtils.d.ts +3 -0
- package/dist/types/ichigo/util/LogLevel.d.ts +4 -0
- package/package.json +1 -1
package/dist/ichigo.umd.js
CHANGED
@@ -9,6 +9,10 @@
|
|
9
9
|
}
|
10
10
|
|
11
11
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
12
|
+
/**
|
13
|
+
* Registry for managing directive parsers.
|
14
|
+
* This class allows registering, unregistering, and finding directive parsers.
|
15
|
+
*/
|
12
16
|
class VDirectiveParserRegistry {
|
13
17
|
/**
|
14
18
|
* The list of registered directive parsers.
|
@@ -49,18 +53,33 @@
|
|
49
53
|
}
|
50
54
|
|
51
55
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
56
|
+
/**
|
57
|
+
* Standard directive names used in the framework.
|
58
|
+
*/
|
52
59
|
var StandardDirectiveName;
|
53
60
|
(function (StandardDirectiveName) {
|
61
|
+
/** Conditional rendering directives (if). */
|
54
62
|
StandardDirectiveName["V_IF"] = "v-if";
|
63
|
+
/** Conditional rendering directives (else if). */
|
55
64
|
StandardDirectiveName["V_ELSE_IF"] = "v-else-if";
|
65
|
+
/** Conditional rendering directives (else). */
|
56
66
|
StandardDirectiveName["V_ELSE"] = "v-else";
|
67
|
+
/** Conditional rendering directives (show). */
|
57
68
|
StandardDirectiveName["V_SHOW"] = "v-show";
|
69
|
+
/** List rendering directives. */
|
58
70
|
StandardDirectiveName["V_FOR"] = "v-for";
|
71
|
+
/** Event handling directives. */
|
59
72
|
StandardDirectiveName["V_ON"] = "v-on";
|
73
|
+
/** Attribute binding directives. */
|
60
74
|
StandardDirectiveName["V_BIND"] = "v-bind";
|
75
|
+
/** Two-way data binding directives. */
|
61
76
|
StandardDirectiveName["V_MODEL"] = "v-model";
|
77
|
+
/** Resize observer directives. */
|
62
78
|
StandardDirectiveName["V_RESIZE"] = "v-resize";
|
79
|
+
/** Intersection observer directives. */
|
63
80
|
StandardDirectiveName["V_INTERSECTION"] = "v-intersection";
|
81
|
+
/** Performance observer directives. */
|
82
|
+
StandardDirectiveName["V_PERFORMANCE"] = "v-performance";
|
64
83
|
})(StandardDirectiveName || (StandardDirectiveName = {}));
|
65
84
|
|
66
85
|
// This file was generated. Do not modify manually!
|
@@ -6581,6 +6600,9 @@
|
|
6581
6600
|
};
|
6582
6601
|
|
6583
6602
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
6603
|
+
/**
|
6604
|
+
* Utility class for analyzing JavaScript expressions to extract variable and function dependencies.
|
6605
|
+
*/
|
6584
6606
|
class ExpressionUtils {
|
6585
6607
|
/**
|
6586
6608
|
* Extracts variable and function names used in the expression.
|
@@ -8317,6 +8339,11 @@
|
|
8317
8339
|
}
|
8318
8340
|
|
8319
8341
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
8342
|
+
/**
|
8343
|
+
* Base class for conditional directives such as v-if, v-else-if, and v-else.
|
8344
|
+
* This class manages the rendering of the associated virtual node based on the evaluation of the directive's condition.
|
8345
|
+
* It also coordinates with other related conditional directives to ensure only one block is rendered at a time.
|
8346
|
+
*/
|
8320
8347
|
class VConditionalDirective {
|
8321
8348
|
/**
|
8322
8349
|
* The virtual node to which this directive is applied.
|
@@ -9902,6 +9929,220 @@
|
|
9902
9929
|
}
|
9903
9930
|
}
|
9904
9931
|
|
9932
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
9933
|
+
/**
|
9934
|
+
* Directive for observing performance metrics using PerformanceObserver.
|
9935
|
+
* The `v-performance` directive allows you to monitor various performance entries.
|
9936
|
+
*
|
9937
|
+
* Example usage:
|
9938
|
+
* <div v-performance="handlePerformance">Performance monitoring</div>
|
9939
|
+
* <div v-performance="handlePerformance" :options.performance="{entryTypes: ['measure']}">Performance monitoring</div>
|
9940
|
+
*
|
9941
|
+
* By default (without options), it observes 'mark' and 'measure' entry types.
|
9942
|
+
*
|
9943
|
+
* The handler receives PerformanceObserverEntryList, PerformanceObserver, options (with droppedEntriesCount), and $ctx as arguments:
|
9944
|
+
* handlePerformance(entries, observer, options, $ctx) {
|
9945
|
+
* entries.getEntries().forEach(entry => {
|
9946
|
+
* console.log(`${entry.name}: ${entry.duration}ms`);
|
9947
|
+
* });
|
9948
|
+
* if (options?.droppedEntriesCount) {
|
9949
|
+
* console.log(`Dropped entries: ${options.droppedEntriesCount}`);
|
9950
|
+
* }
|
9951
|
+
* }
|
9952
|
+
*
|
9953
|
+
* Options can be provided via :options or :options.performance attribute:
|
9954
|
+
* :options="{entryTypes: ['measure', 'mark']}"
|
9955
|
+
* :options.performance="{type: 'navigation', buffered: true}"
|
9956
|
+
*
|
9957
|
+
* This directive is useful for performance monitoring, profiling, and identifying
|
9958
|
+
* performance bottlenecks in your application.
|
9959
|
+
*/
|
9960
|
+
class VPerformanceDirective {
|
9961
|
+
/**
|
9962
|
+
* The virtual node to which this directive is applied.
|
9963
|
+
*/
|
9964
|
+
#vNode;
|
9965
|
+
/**
|
9966
|
+
* A list of variable and function names used in the directive's expression.
|
9967
|
+
*/
|
9968
|
+
#dependentIdentifiers;
|
9969
|
+
/**
|
9970
|
+
* The performance handler wrapper function.
|
9971
|
+
*/
|
9972
|
+
#handlerWrapper;
|
9973
|
+
/**
|
9974
|
+
* The PerformanceObserver instance.
|
9975
|
+
*/
|
9976
|
+
#performanceObserver;
|
9977
|
+
/**
|
9978
|
+
* @param context The context for parsing the directive.
|
9979
|
+
*/
|
9980
|
+
constructor(context) {
|
9981
|
+
this.#vNode = context.vNode;
|
9982
|
+
// Parse the expression to extract identifiers and create the handler wrapper
|
9983
|
+
const expression = context.attribute.value;
|
9984
|
+
if (expression) {
|
9985
|
+
this.#dependentIdentifiers = ExpressionUtils.extractIdentifiers(expression, context.vNode.vApplication.functionDependencies);
|
9986
|
+
this.#handlerWrapper = this.#createPerformanceHandlerWrapper(expression);
|
9987
|
+
}
|
9988
|
+
// Remove the directive attribute from the element
|
9989
|
+
this.#vNode.node.removeAttribute(context.attribute.name);
|
9990
|
+
}
|
9991
|
+
/**
|
9992
|
+
* @inheritdoc
|
9993
|
+
*/
|
9994
|
+
get name() {
|
9995
|
+
return StandardDirectiveName.V_PERFORMANCE;
|
9996
|
+
}
|
9997
|
+
/**
|
9998
|
+
* @inheritdoc
|
9999
|
+
*/
|
10000
|
+
get vNode() {
|
10001
|
+
return this.#vNode;
|
10002
|
+
}
|
10003
|
+
/**
|
10004
|
+
* @inheritdoc
|
10005
|
+
*/
|
10006
|
+
get needsAnchor() {
|
10007
|
+
return false;
|
10008
|
+
}
|
10009
|
+
/**
|
10010
|
+
* @inheritdoc
|
10011
|
+
*/
|
10012
|
+
get bindingsPreparer() {
|
10013
|
+
return undefined;
|
10014
|
+
}
|
10015
|
+
/**
|
10016
|
+
* @inheritdoc
|
10017
|
+
*/
|
10018
|
+
get domUpdater() {
|
10019
|
+
return undefined;
|
10020
|
+
}
|
10021
|
+
/**
|
10022
|
+
* @inheritdoc
|
10023
|
+
*/
|
10024
|
+
get templatize() {
|
10025
|
+
return false;
|
10026
|
+
}
|
10027
|
+
/**
|
10028
|
+
* @inheritdoc
|
10029
|
+
*/
|
10030
|
+
get dependentIdentifiers() {
|
10031
|
+
return this.#dependentIdentifiers ?? [];
|
10032
|
+
}
|
10033
|
+
/**
|
10034
|
+
* @inheritdoc
|
10035
|
+
*/
|
10036
|
+
get onMount() {
|
10037
|
+
return undefined;
|
10038
|
+
}
|
10039
|
+
/**
|
10040
|
+
* @inheritdoc
|
10041
|
+
*/
|
10042
|
+
get onMounted() {
|
10043
|
+
if (!this.#handlerWrapper) {
|
10044
|
+
return undefined;
|
10045
|
+
}
|
10046
|
+
const handler = this.#handlerWrapper;
|
10047
|
+
return () => {
|
10048
|
+
// Get options from :options.performance or :options directive
|
10049
|
+
let optionsDirective = this.#vNode.directiveManager?.optionsDirective('performance');
|
10050
|
+
// Evaluate the options expression
|
10051
|
+
let options;
|
10052
|
+
if (optionsDirective && optionsDirective.expression) {
|
10053
|
+
// Evaluate the options expression
|
10054
|
+
const identifiers = optionsDirective.dependentIdentifiers;
|
10055
|
+
const values = identifiers.map(id => this.#vNode.bindings?.get(id));
|
10056
|
+
const args = identifiers.join(", ");
|
10057
|
+
const funcBody = `return (${optionsDirective.expression});`;
|
10058
|
+
const func = new Function(args, funcBody);
|
10059
|
+
options = func(...values);
|
10060
|
+
}
|
10061
|
+
// Create PerformanceObserver and start observing
|
10062
|
+
// Note: The callback receives a third argument 'options' with droppedEntriesCount in modern browsers
|
10063
|
+
// TypeScript's type definition only includes 2 arguments, so we use type assertion
|
10064
|
+
this.#performanceObserver = new PerformanceObserver(((...args) => {
|
10065
|
+
const [entries, observer, callbackOptions] = args;
|
10066
|
+
handler(entries, observer, callbackOptions);
|
10067
|
+
}));
|
10068
|
+
// If no options provided, use default: observe marks and measures
|
10069
|
+
if (!options) {
|
10070
|
+
options = { entryTypes: ['mark', 'measure'] };
|
10071
|
+
}
|
10072
|
+
// Start observing with options
|
10073
|
+
this.#performanceObserver.observe(options);
|
10074
|
+
};
|
10075
|
+
}
|
10076
|
+
/**
|
10077
|
+
* @inheritdoc
|
10078
|
+
*/
|
10079
|
+
get onUpdate() {
|
10080
|
+
return undefined;
|
10081
|
+
}
|
10082
|
+
/**
|
10083
|
+
* @inheritdoc
|
10084
|
+
*/
|
10085
|
+
get onUpdated() {
|
10086
|
+
return undefined;
|
10087
|
+
}
|
10088
|
+
/**
|
10089
|
+
* @inheritdoc
|
10090
|
+
*/
|
10091
|
+
get onUnmount() {
|
10092
|
+
return undefined;
|
10093
|
+
}
|
10094
|
+
/**
|
10095
|
+
* @inheritdoc
|
10096
|
+
*/
|
10097
|
+
get onUnmounted() {
|
10098
|
+
return undefined;
|
10099
|
+
}
|
10100
|
+
/**
|
10101
|
+
* @inheritdoc
|
10102
|
+
*/
|
10103
|
+
destroy() {
|
10104
|
+
// Disconnect the PerformanceObserver when the directive is destroyed
|
10105
|
+
if (this.#performanceObserver) {
|
10106
|
+
this.#performanceObserver.disconnect();
|
10107
|
+
this.#performanceObserver = undefined;
|
10108
|
+
}
|
10109
|
+
}
|
10110
|
+
/**
|
10111
|
+
* Creates a wrapper function for performance handlers.
|
10112
|
+
* @param expression The expression string to evaluate.
|
10113
|
+
* @returns A function that handles the performance event.
|
10114
|
+
*/
|
10115
|
+
#createPerformanceHandlerWrapper(expression) {
|
10116
|
+
const identifiers = this.#dependentIdentifiers ?? [];
|
10117
|
+
const vNode = this.#vNode;
|
10118
|
+
// Return a function that handles the performance event with proper scope
|
10119
|
+
return (entries, observer, options) => {
|
10120
|
+
const bindings = vNode.bindings;
|
10121
|
+
const $ctx = {
|
10122
|
+
element: vNode.node,
|
10123
|
+
vnode: vNode,
|
10124
|
+
userData: vNode.userData
|
10125
|
+
};
|
10126
|
+
// If the expression is just a method name, call it with bindings as 'this'
|
10127
|
+
const trimmedExpr = expression.trim();
|
10128
|
+
if (identifiers.includes(trimmedExpr) && typeof bindings?.get(trimmedExpr) === 'function') {
|
10129
|
+
const methodName = trimmedExpr;
|
10130
|
+
const originalMethod = bindings?.get(methodName);
|
10131
|
+
// Call the method with bindings as 'this' context
|
10132
|
+
// Pass entries, observer, options, and $ctx as arguments
|
10133
|
+
return originalMethod(entries, observer, options, $ctx);
|
10134
|
+
}
|
10135
|
+
// For inline expressions, evaluate normally
|
10136
|
+
// Note: inline expressions receive entries, observer, options, and $ctx as parameters
|
10137
|
+
const values = identifiers.map(id => vNode.bindings?.get(id));
|
10138
|
+
const args = [...identifiers, 'entries', 'observer', 'options', '$ctx'].join(", ");
|
10139
|
+
const funcBody = `return (${expression});`;
|
10140
|
+
const func = new Function(args, funcBody);
|
10141
|
+
return func.call(bindings?.raw, ...values, entries, observer, options, $ctx);
|
10142
|
+
};
|
10143
|
+
}
|
10144
|
+
}
|
10145
|
+
|
9905
10146
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
9906
10147
|
/**
|
9907
10148
|
* Directive for observing element resize events using ResizeObserver.
|
@@ -9909,6 +10150,7 @@
|
|
9909
10150
|
*
|
9910
10151
|
* Example usage:
|
9911
10152
|
* <div v-resize="handleResize">Resizable content</div>
|
10153
|
+
* <div v-resize="handleResize" :options.resize="{box: 'border-box'}">Resizable content</div>
|
9912
10154
|
*
|
9913
10155
|
* The handler receives ResizeObserverEntry array as the first argument and $ctx as the second:
|
9914
10156
|
* handleResize(entries, $ctx) {
|
@@ -9916,6 +10158,10 @@
|
|
9916
10158
|
* console.log(`Size: ${width}x${height}`);
|
9917
10159
|
* }
|
9918
10160
|
*
|
10161
|
+
* Options can be provided via :options or :options.resize attribute:
|
10162
|
+
* :options="{box: 'border-box'}"
|
10163
|
+
* :options.resize="{box: 'content-box'}"
|
10164
|
+
*
|
9919
10165
|
* This directive is useful for responsive layouts, charts, and other components
|
9920
10166
|
* that need to adapt to size changes.
|
9921
10167
|
*/
|
@@ -10008,11 +10254,24 @@
|
|
10008
10254
|
const element = this.#vNode.node;
|
10009
10255
|
const handler = this.#handlerWrapper;
|
10010
10256
|
return () => {
|
10257
|
+
// Get options from :options.resize or :options directive
|
10258
|
+
let optionsDirective = this.#vNode.directiveManager?.optionsDirective('resize');
|
10259
|
+
// Evaluate the options expression
|
10260
|
+
let options;
|
10261
|
+
if (optionsDirective && optionsDirective.expression) {
|
10262
|
+
// Evaluate the options expression
|
10263
|
+
const identifiers = optionsDirective.dependentIdentifiers;
|
10264
|
+
const values = identifiers.map(id => this.#vNode.bindings?.get(id));
|
10265
|
+
const args = identifiers.join(", ");
|
10266
|
+
const funcBody = `return (${optionsDirective.expression});`;
|
10267
|
+
const func = new Function(args, funcBody);
|
10268
|
+
options = func(...values);
|
10269
|
+
}
|
10011
10270
|
// Create ResizeObserver and start observing
|
10012
10271
|
this.#resizeObserver = new ResizeObserver((entries) => {
|
10013
10272
|
handler(entries);
|
10014
10273
|
});
|
10015
|
-
this.#resizeObserver.observe(element);
|
10274
|
+
this.#resizeObserver.observe(element, options);
|
10016
10275
|
};
|
10017
10276
|
}
|
10018
10277
|
/**
|
@@ -10314,7 +10573,9 @@
|
|
10314
10573
|
// v-resize
|
10315
10574
|
context.attribute.name === StandardDirectiveName.V_RESIZE ||
|
10316
10575
|
// v-intersection
|
10317
|
-
context.attribute.name === StandardDirectiveName.V_INTERSECTION
|
10576
|
+
context.attribute.name === StandardDirectiveName.V_INTERSECTION ||
|
10577
|
+
// v-performance
|
10578
|
+
context.attribute.name === StandardDirectiveName.V_PERFORMANCE) {
|
10318
10579
|
return true;
|
10319
10580
|
}
|
10320
10581
|
return false;
|
@@ -10361,6 +10622,10 @@
|
|
10361
10622
|
if (context.attribute.name === StandardDirectiveName.V_INTERSECTION) {
|
10362
10623
|
return new VIntersectionDirective(context);
|
10363
10624
|
}
|
10625
|
+
// v-performance
|
10626
|
+
if (context.attribute.name === StandardDirectiveName.V_PERFORMANCE) {
|
10627
|
+
return new VPerformanceDirective(context);
|
10628
|
+
}
|
10364
10629
|
throw new Error(`The attribute "${context.attribute.name}" cannot be parsed by ${this.name}.`);
|
10365
10630
|
}
|
10366
10631
|
}
|
@@ -10371,13 +10636,13 @@
|
|
10371
10636
|
*/
|
10372
10637
|
var LogLevel;
|
10373
10638
|
(function (LogLevel) {
|
10374
|
-
|
10639
|
+
/** Debug level */
|
10375
10640
|
LogLevel["DEBUG"] = "debug";
|
10376
|
-
|
10641
|
+
/** Info level */
|
10377
10642
|
LogLevel["INFO"] = "info";
|
10378
|
-
|
10643
|
+
/** Warning level */
|
10379
10644
|
LogLevel["WARN"] = "warn";
|
10380
|
-
|
10645
|
+
/** Error level */
|
10381
10646
|
LogLevel["ERROR"] = "error";
|
10382
10647
|
})(LogLevel || (LogLevel = {}));
|
10383
10648
|
|