@mintjamsinc/ichigojs 0.1.9 → 0.1.11
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 +52 -1
- package/dist/ichigo.esm.js +578 -13
- 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 +579 -12
- 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/VApplication.d.ts +8 -2
- package/dist/types/ichigo/components/VComponent.d.ts +23 -0
- package/dist/types/ichigo/components/VComponentRegistry.d.ts +35 -0
- package/dist/types/ichigo/directives/StandardDirectiveName.d.ts +6 -2
- package/dist/types/ichigo/directives/VComponentDirective.d.ts +81 -0
- package/dist/types/ichigo/directives/VPerformanceDirective.d.ts +18 -28
- package/dist/types/index.d.ts +2 -0
- package/package.json +1 -1
package/dist/ichigo.umd.js
CHANGED
@@ -5,7 +5,96 @@
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
6
6
|
|
7
7
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
8
|
+
/**
|
9
|
+
* Represents a reusable component definition.
|
10
|
+
*/
|
11
|
+
class VComponent {
|
12
|
+
/**
|
13
|
+
* The unique identifier for the component.
|
14
|
+
*/
|
15
|
+
id;
|
16
|
+
/**
|
17
|
+
* The function that creates a new instance of the component.
|
18
|
+
*/
|
19
|
+
createInstance;
|
20
|
+
/**
|
21
|
+
* The optional template ID for the component.
|
22
|
+
* If not specified, defaults to the component ID.
|
23
|
+
*/
|
24
|
+
templateID;
|
25
|
+
/**
|
26
|
+
* Creates a new component definition.
|
27
|
+
* @param id The unique identifier for the component.
|
28
|
+
* @param createInstance The function that creates a new instance of the component.
|
29
|
+
* @param templateID The optional template ID for the component.
|
30
|
+
*/
|
31
|
+
constructor(id, createInstance, templateID) {
|
32
|
+
if (!id || typeof id !== 'string') {
|
33
|
+
throw new Error('Component ID must be a non-empty string.');
|
34
|
+
}
|
35
|
+
if (typeof createInstance !== 'function') {
|
36
|
+
throw new Error('createInstance must be a function.');
|
37
|
+
}
|
38
|
+
this.id = id.trim();
|
39
|
+
this.createInstance = createInstance;
|
40
|
+
this.templateID = templateID?.trim() || this.id;
|
41
|
+
}
|
42
|
+
}
|
43
|
+
|
44
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
45
|
+
/**
|
46
|
+
* A registry for managing component definitions.
|
47
|
+
*/
|
8
48
|
class VComponentRegistry {
|
49
|
+
/**
|
50
|
+
* Map of component ID to component definition.
|
51
|
+
*/
|
52
|
+
#components = new Map();
|
53
|
+
/**
|
54
|
+
* Registers a new component.
|
55
|
+
* @param id The unique identifier for the component.
|
56
|
+
* @param createInstance The function that creates a new instance of the component.
|
57
|
+
* @param templateID The optional template ID for the component.
|
58
|
+
* @returns True if the component was registered, false if a component with the same ID already exists.
|
59
|
+
*/
|
60
|
+
register(id, createInstance, templateID) {
|
61
|
+
if (this.has(id)) {
|
62
|
+
return false;
|
63
|
+
}
|
64
|
+
const component = new VComponent(id, createInstance, templateID);
|
65
|
+
this.#components.set(id, component);
|
66
|
+
return true;
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Checks if a component with the given ID exists.
|
70
|
+
* @param id The component ID to check.
|
71
|
+
* @returns True if the component exists, false otherwise.
|
72
|
+
*/
|
73
|
+
has(id) {
|
74
|
+
return this.#components.has(id);
|
75
|
+
}
|
76
|
+
/**
|
77
|
+
* Gets a component by its ID.
|
78
|
+
* @param id The component ID to retrieve.
|
79
|
+
* @returns The component definition, or undefined if not found.
|
80
|
+
*/
|
81
|
+
get(id) {
|
82
|
+
return this.#components.get(id);
|
83
|
+
}
|
84
|
+
/**
|
85
|
+
* Removes a component from the registry.
|
86
|
+
* @param id The component ID to remove.
|
87
|
+
* @returns True if the component was removed, false if it didn't exist.
|
88
|
+
*/
|
89
|
+
unregister(id) {
|
90
|
+
return this.#components.delete(id);
|
91
|
+
}
|
92
|
+
/**
|
93
|
+
* Clears all registered components.
|
94
|
+
*/
|
95
|
+
clear() {
|
96
|
+
this.#components.clear();
|
97
|
+
}
|
9
98
|
}
|
10
99
|
|
11
100
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
@@ -74,10 +163,14 @@
|
|
74
163
|
StandardDirectiveName["V_BIND"] = "v-bind";
|
75
164
|
/** Two-way data binding directives. */
|
76
165
|
StandardDirectiveName["V_MODEL"] = "v-model";
|
77
|
-
/**
|
166
|
+
/** Resize observer directives. */
|
78
167
|
StandardDirectiveName["V_RESIZE"] = "v-resize";
|
79
168
|
/** Intersection observer directives. */
|
80
169
|
StandardDirectiveName["V_INTERSECTION"] = "v-intersection";
|
170
|
+
/** Performance observer directives. */
|
171
|
+
StandardDirectiveName["V_PERFORMANCE"] = "v-performance";
|
172
|
+
/** Component directive. */
|
173
|
+
StandardDirectiveName["V_COMPONENT"] = "v-component";
|
81
174
|
})(StandardDirectiveName || (StandardDirectiveName = {}));
|
82
175
|
|
83
176
|
// This file was generated. Do not modify manually!
|
@@ -6644,10 +6737,16 @@
|
|
6644
6737
|
const isArrowFunction = /^\s*(\([^)]*\)|[a-zA-Z_$][a-zA-Z0-9_$]*)\s*=>/.test(source);
|
6645
6738
|
const isFunctionExpression = source.startsWith('function');
|
6646
6739
|
const isAsyncFunction = source.startsWith('async');
|
6647
|
-
// If it's a method shorthand (e.g., "methodName() { ... }"), convert to function expression
|
6648
|
-
if (!isFunctionExpression && !isArrowFunction
|
6740
|
+
// If it's a method shorthand (e.g., "methodName() { ... }" or "async methodName() { ... }"), convert to function expression
|
6741
|
+
if (!isFunctionExpression && !isArrowFunction) {
|
6649
6742
|
// It's likely a method shorthand, convert to function expression
|
6650
|
-
|
6743
|
+
if (isAsyncFunction) {
|
6744
|
+
// Remove 'async' prefix and add 'async function' prefix
|
6745
|
+
source = `async function ${source.substring(5).trim()}`;
|
6746
|
+
}
|
6747
|
+
else {
|
6748
|
+
source = `function ${source}`;
|
6749
|
+
}
|
6651
6750
|
}
|
6652
6751
|
// Wrap in parentheses for parsing
|
6653
6752
|
source = `(${source})`;
|
@@ -7115,6 +7214,226 @@
|
|
7115
7214
|
}
|
7116
7215
|
}
|
7117
7216
|
|
7217
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
7218
|
+
/**
|
7219
|
+
* Directive for rendering components.
|
7220
|
+
* Usage: <div v-component="componentId" :options="props"></div>
|
7221
|
+
*
|
7222
|
+
* The :options binding is used to pass properties to the component.
|
7223
|
+
* Example:
|
7224
|
+
* <div v-component="my-component" :options="{message: 'Hello'}"></div>
|
7225
|
+
*/
|
7226
|
+
class VComponentDirective {
|
7227
|
+
/**
|
7228
|
+
* The virtual node to which this directive is applied.
|
7229
|
+
*/
|
7230
|
+
#vNode;
|
7231
|
+
/**
|
7232
|
+
* The component ID expression.
|
7233
|
+
*/
|
7234
|
+
#expression;
|
7235
|
+
/**
|
7236
|
+
* Whether the component ID is static (not reactive).
|
7237
|
+
*/
|
7238
|
+
#isStatic = false;
|
7239
|
+
/**
|
7240
|
+
* The component ID to render.
|
7241
|
+
*/
|
7242
|
+
#componentId;
|
7243
|
+
/**
|
7244
|
+
* The child application instance for the component.
|
7245
|
+
*/
|
7246
|
+
#childApp;
|
7247
|
+
/**
|
7248
|
+
* Whether the component has been activated.
|
7249
|
+
*/
|
7250
|
+
#isActivated = false;
|
7251
|
+
constructor(context) {
|
7252
|
+
this.#vNode = context.vNode;
|
7253
|
+
this.#expression = context.attribute.value;
|
7254
|
+
// Check for .static modifier
|
7255
|
+
const attrName = context.attribute.name;
|
7256
|
+
this.#isStatic = attrName.includes('.static');
|
7257
|
+
// Remove the directive attribute from the element
|
7258
|
+
this.#vNode.node.removeAttribute(context.attribute.name);
|
7259
|
+
}
|
7260
|
+
/**
|
7261
|
+
* @inheritdoc
|
7262
|
+
*/
|
7263
|
+
get name() {
|
7264
|
+
return StandardDirectiveName.V_COMPONENT;
|
7265
|
+
}
|
7266
|
+
/**
|
7267
|
+
* @inheritdoc
|
7268
|
+
*/
|
7269
|
+
get vNode() {
|
7270
|
+
return this.#vNode;
|
7271
|
+
}
|
7272
|
+
/**
|
7273
|
+
* @inheritdoc
|
7274
|
+
*/
|
7275
|
+
get needsAnchor() {
|
7276
|
+
return false;
|
7277
|
+
}
|
7278
|
+
/**
|
7279
|
+
* @inheritdoc
|
7280
|
+
*/
|
7281
|
+
get bindingsPreparer() {
|
7282
|
+
return undefined;
|
7283
|
+
}
|
7284
|
+
/**
|
7285
|
+
* @inheritdoc
|
7286
|
+
*/
|
7287
|
+
get domUpdater() {
|
7288
|
+
// Component rendering is handled through onMounted lifecycle hook
|
7289
|
+
return undefined;
|
7290
|
+
}
|
7291
|
+
/**
|
7292
|
+
* @inheritdoc
|
7293
|
+
*/
|
7294
|
+
get templatize() {
|
7295
|
+
return false;
|
7296
|
+
}
|
7297
|
+
/**
|
7298
|
+
* @inheritdoc
|
7299
|
+
*/
|
7300
|
+
get dependentIdentifiers() {
|
7301
|
+
return [];
|
7302
|
+
}
|
7303
|
+
/**
|
7304
|
+
* @inheritdoc
|
7305
|
+
*/
|
7306
|
+
get onMount() {
|
7307
|
+
return () => {
|
7308
|
+
this.renderComponent();
|
7309
|
+
};
|
7310
|
+
}
|
7311
|
+
/**
|
7312
|
+
* @inheritdoc
|
7313
|
+
*/
|
7314
|
+
get onMounted() {
|
7315
|
+
return undefined;
|
7316
|
+
}
|
7317
|
+
/**
|
7318
|
+
* @inheritdoc
|
7319
|
+
*/
|
7320
|
+
get onUpdate() {
|
7321
|
+
return undefined;
|
7322
|
+
}
|
7323
|
+
/**
|
7324
|
+
* @inheritdoc
|
7325
|
+
*/
|
7326
|
+
get onUpdated() {
|
7327
|
+
return undefined;
|
7328
|
+
}
|
7329
|
+
/**
|
7330
|
+
* @inheritdoc
|
7331
|
+
*/
|
7332
|
+
get onUnmount() {
|
7333
|
+
return () => this.cleanupComponent();
|
7334
|
+
}
|
7335
|
+
/**
|
7336
|
+
* @inheritdoc
|
7337
|
+
*/
|
7338
|
+
get onUnmounted() {
|
7339
|
+
return undefined;
|
7340
|
+
}
|
7341
|
+
/**
|
7342
|
+
* @inheritdoc
|
7343
|
+
*/
|
7344
|
+
destroy() {
|
7345
|
+
this.cleanupComponent();
|
7346
|
+
}
|
7347
|
+
/**
|
7348
|
+
* Renders the component.
|
7349
|
+
*/
|
7350
|
+
renderComponent() {
|
7351
|
+
const element = this.#vNode.node;
|
7352
|
+
if (!element) {
|
7353
|
+
return;
|
7354
|
+
}
|
7355
|
+
// For now, only support static component IDs
|
7356
|
+
const componentId = this.#expression.trim();
|
7357
|
+
if (!componentId) {
|
7358
|
+
console.warn(`Component ID is empty for v-component directive`);
|
7359
|
+
return;
|
7360
|
+
}
|
7361
|
+
// Get properties from :options or :options.component directive
|
7362
|
+
let properties = {};
|
7363
|
+
const optionsDirective = this.#vNode.directiveManager?.optionsDirective('component');
|
7364
|
+
if (optionsDirective && optionsDirective.expression) {
|
7365
|
+
// Evaluate the options expression
|
7366
|
+
const identifiers = optionsDirective.dependentIdentifiers;
|
7367
|
+
const values = identifiers.map(id => this.#vNode.bindings?.get(id));
|
7368
|
+
const args = identifiers.join(", ");
|
7369
|
+
const funcBody = `return (${optionsDirective.expression});`;
|
7370
|
+
const func = new Function(args, funcBody);
|
7371
|
+
const result = func(...values);
|
7372
|
+
if (typeof result === 'object' && result !== null) {
|
7373
|
+
properties = result;
|
7374
|
+
}
|
7375
|
+
}
|
7376
|
+
// Store component ID
|
7377
|
+
this.#componentId = componentId;
|
7378
|
+
// Get component definition from the application's component registry
|
7379
|
+
const vApplication = this.#vNode.vApplication;
|
7380
|
+
if (!vApplication) {
|
7381
|
+
console.error('VApplication not found on VNode');
|
7382
|
+
return;
|
7383
|
+
}
|
7384
|
+
const component = vApplication.componentRegistry.get(componentId);
|
7385
|
+
if (!component) {
|
7386
|
+
console.error(`Component '${componentId}' not found in registry`);
|
7387
|
+
return;
|
7388
|
+
}
|
7389
|
+
// Get template element
|
7390
|
+
const finalTemplateID = component.templateID;
|
7391
|
+
const templateElement = document.querySelector(`#${finalTemplateID}`);
|
7392
|
+
if (!templateElement || !(templateElement instanceof HTMLTemplateElement)) {
|
7393
|
+
console.error(`Template element '#${finalTemplateID}' not found`);
|
7394
|
+
return;
|
7395
|
+
}
|
7396
|
+
// Clone template content
|
7397
|
+
const fragment = templateElement.content.cloneNode(true);
|
7398
|
+
const childNodes = Array.from(fragment.childNodes);
|
7399
|
+
// Find the first element node
|
7400
|
+
let componentElement;
|
7401
|
+
for (const node of childNodes) {
|
7402
|
+
if (node.nodeType === Node.ELEMENT_NODE) {
|
7403
|
+
componentElement = node;
|
7404
|
+
break;
|
7405
|
+
}
|
7406
|
+
}
|
7407
|
+
if (!componentElement) {
|
7408
|
+
console.error(`No element found in template '#${finalTemplateID}'`);
|
7409
|
+
return;
|
7410
|
+
}
|
7411
|
+
// Replace element with component element
|
7412
|
+
const parent = element.parentNode;
|
7413
|
+
if (parent) {
|
7414
|
+
parent.insertBefore(componentElement, element);
|
7415
|
+
parent.removeChild(element);
|
7416
|
+
}
|
7417
|
+
// Create component instance
|
7418
|
+
const instance = component.createInstance(properties);
|
7419
|
+
// Create and mount child application using the parent application's registries
|
7420
|
+
this.#childApp = vApplication.createChildApp(instance);
|
7421
|
+
this.#childApp.mount(componentElement);
|
7422
|
+
this.#isActivated = true;
|
7423
|
+
}
|
7424
|
+
/**
|
7425
|
+
* Cleans up the component.
|
7426
|
+
*/
|
7427
|
+
cleanupComponent() {
|
7428
|
+
if (this.#childApp) {
|
7429
|
+
// TODO: Implement unmount when available in VApplication
|
7430
|
+
// this.#childApp.unmount();
|
7431
|
+
this.#childApp = undefined;
|
7432
|
+
}
|
7433
|
+
this.#isActivated = false;
|
7434
|
+
}
|
7435
|
+
}
|
7436
|
+
|
7118
7437
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
7119
7438
|
/**
|
7120
7439
|
* Utility class for creating reactive proxies that automatically track changes.
|
@@ -7593,7 +7912,11 @@
|
|
7593
7912
|
}
|
7594
7913
|
// If this is an options binding directive, cache it
|
7595
7914
|
if (directive.name === StandardDirectiveName.V_BIND && directive.isOptions) {
|
7596
|
-
|
7915
|
+
const bindDirective = directive;
|
7916
|
+
const attrName = bindDirective.attributeName;
|
7917
|
+
if (attrName) {
|
7918
|
+
this.#optionsDirectives[attrName] = bindDirective;
|
7919
|
+
}
|
7597
7920
|
}
|
7598
7921
|
}
|
7599
7922
|
}
|
@@ -9927,6 +10250,220 @@
|
|
9927
10250
|
}
|
9928
10251
|
}
|
9929
10252
|
|
10253
|
+
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
10254
|
+
/**
|
10255
|
+
* Directive for observing performance metrics using PerformanceObserver.
|
10256
|
+
* The `v-performance` directive allows you to monitor various performance entries.
|
10257
|
+
*
|
10258
|
+
* Example usage:
|
10259
|
+
* <div v-performance="handlePerformance">Performance monitoring</div>
|
10260
|
+
* <div v-performance="handlePerformance" :options.performance="{entryTypes: ['measure']}">Performance monitoring</div>
|
10261
|
+
*
|
10262
|
+
* By default (without options), it observes 'mark' and 'measure' entry types.
|
10263
|
+
*
|
10264
|
+
* The handler receives PerformanceObserverEntryList, PerformanceObserver, options (with droppedEntriesCount), and $ctx as arguments:
|
10265
|
+
* handlePerformance(entries, observer, options, $ctx) {
|
10266
|
+
* entries.getEntries().forEach(entry => {
|
10267
|
+
* console.log(`${entry.name}: ${entry.duration}ms`);
|
10268
|
+
* });
|
10269
|
+
* if (options?.droppedEntriesCount) {
|
10270
|
+
* console.log(`Dropped entries: ${options.droppedEntriesCount}`);
|
10271
|
+
* }
|
10272
|
+
* }
|
10273
|
+
*
|
10274
|
+
* Options can be provided via :options or :options.performance attribute:
|
10275
|
+
* :options="{entryTypes: ['measure', 'mark']}"
|
10276
|
+
* :options.performance="{type: 'navigation', buffered: true}"
|
10277
|
+
*
|
10278
|
+
* This directive is useful for performance monitoring, profiling, and identifying
|
10279
|
+
* performance bottlenecks in your application.
|
10280
|
+
*/
|
10281
|
+
class VPerformanceDirective {
|
10282
|
+
/**
|
10283
|
+
* The virtual node to which this directive is applied.
|
10284
|
+
*/
|
10285
|
+
#vNode;
|
10286
|
+
/**
|
10287
|
+
* A list of variable and function names used in the directive's expression.
|
10288
|
+
*/
|
10289
|
+
#dependentIdentifiers;
|
10290
|
+
/**
|
10291
|
+
* The performance handler wrapper function.
|
10292
|
+
*/
|
10293
|
+
#handlerWrapper;
|
10294
|
+
/**
|
10295
|
+
* The PerformanceObserver instance.
|
10296
|
+
*/
|
10297
|
+
#performanceObserver;
|
10298
|
+
/**
|
10299
|
+
* @param context The context for parsing the directive.
|
10300
|
+
*/
|
10301
|
+
constructor(context) {
|
10302
|
+
this.#vNode = context.vNode;
|
10303
|
+
// Parse the expression to extract identifiers and create the handler wrapper
|
10304
|
+
const expression = context.attribute.value;
|
10305
|
+
if (expression) {
|
10306
|
+
this.#dependentIdentifiers = ExpressionUtils.extractIdentifiers(expression, context.vNode.vApplication.functionDependencies);
|
10307
|
+
this.#handlerWrapper = this.#createPerformanceHandlerWrapper(expression);
|
10308
|
+
}
|
10309
|
+
// Remove the directive attribute from the element
|
10310
|
+
this.#vNode.node.removeAttribute(context.attribute.name);
|
10311
|
+
}
|
10312
|
+
/**
|
10313
|
+
* @inheritdoc
|
10314
|
+
*/
|
10315
|
+
get name() {
|
10316
|
+
return StandardDirectiveName.V_PERFORMANCE;
|
10317
|
+
}
|
10318
|
+
/**
|
10319
|
+
* @inheritdoc
|
10320
|
+
*/
|
10321
|
+
get vNode() {
|
10322
|
+
return this.#vNode;
|
10323
|
+
}
|
10324
|
+
/**
|
10325
|
+
* @inheritdoc
|
10326
|
+
*/
|
10327
|
+
get needsAnchor() {
|
10328
|
+
return false;
|
10329
|
+
}
|
10330
|
+
/**
|
10331
|
+
* @inheritdoc
|
10332
|
+
*/
|
10333
|
+
get bindingsPreparer() {
|
10334
|
+
return undefined;
|
10335
|
+
}
|
10336
|
+
/**
|
10337
|
+
* @inheritdoc
|
10338
|
+
*/
|
10339
|
+
get domUpdater() {
|
10340
|
+
return undefined;
|
10341
|
+
}
|
10342
|
+
/**
|
10343
|
+
* @inheritdoc
|
10344
|
+
*/
|
10345
|
+
get templatize() {
|
10346
|
+
return false;
|
10347
|
+
}
|
10348
|
+
/**
|
10349
|
+
* @inheritdoc
|
10350
|
+
*/
|
10351
|
+
get dependentIdentifiers() {
|
10352
|
+
return this.#dependentIdentifiers ?? [];
|
10353
|
+
}
|
10354
|
+
/**
|
10355
|
+
* @inheritdoc
|
10356
|
+
*/
|
10357
|
+
get onMount() {
|
10358
|
+
return undefined;
|
10359
|
+
}
|
10360
|
+
/**
|
10361
|
+
* @inheritdoc
|
10362
|
+
*/
|
10363
|
+
get onMounted() {
|
10364
|
+
if (!this.#handlerWrapper) {
|
10365
|
+
return undefined;
|
10366
|
+
}
|
10367
|
+
const handler = this.#handlerWrapper;
|
10368
|
+
return () => {
|
10369
|
+
// Get options from :options.performance or :options directive
|
10370
|
+
let optionsDirective = this.#vNode.directiveManager?.optionsDirective('performance');
|
10371
|
+
// Evaluate the options expression
|
10372
|
+
let options;
|
10373
|
+
if (optionsDirective && optionsDirective.expression) {
|
10374
|
+
// Evaluate the options expression
|
10375
|
+
const identifiers = optionsDirective.dependentIdentifiers;
|
10376
|
+
const values = identifiers.map(id => this.#vNode.bindings?.get(id));
|
10377
|
+
const args = identifiers.join(", ");
|
10378
|
+
const funcBody = `return (${optionsDirective.expression});`;
|
10379
|
+
const func = new Function(args, funcBody);
|
10380
|
+
options = func(...values);
|
10381
|
+
}
|
10382
|
+
// Create PerformanceObserver and start observing
|
10383
|
+
// Note: The callback receives a third argument 'options' with droppedEntriesCount in modern browsers
|
10384
|
+
// TypeScript's type definition only includes 2 arguments, so we use type assertion
|
10385
|
+
this.#performanceObserver = new PerformanceObserver(((...args) => {
|
10386
|
+
const [entries, observer, callbackOptions] = args;
|
10387
|
+
handler(entries, observer, callbackOptions);
|
10388
|
+
}));
|
10389
|
+
// If no options provided, use default: observe marks and measures
|
10390
|
+
if (!options) {
|
10391
|
+
options = { entryTypes: ['mark', 'measure'] };
|
10392
|
+
}
|
10393
|
+
// Start observing with options
|
10394
|
+
this.#performanceObserver.observe(options);
|
10395
|
+
};
|
10396
|
+
}
|
10397
|
+
/**
|
10398
|
+
* @inheritdoc
|
10399
|
+
*/
|
10400
|
+
get onUpdate() {
|
10401
|
+
return undefined;
|
10402
|
+
}
|
10403
|
+
/**
|
10404
|
+
* @inheritdoc
|
10405
|
+
*/
|
10406
|
+
get onUpdated() {
|
10407
|
+
return undefined;
|
10408
|
+
}
|
10409
|
+
/**
|
10410
|
+
* @inheritdoc
|
10411
|
+
*/
|
10412
|
+
get onUnmount() {
|
10413
|
+
return undefined;
|
10414
|
+
}
|
10415
|
+
/**
|
10416
|
+
* @inheritdoc
|
10417
|
+
*/
|
10418
|
+
get onUnmounted() {
|
10419
|
+
return undefined;
|
10420
|
+
}
|
10421
|
+
/**
|
10422
|
+
* @inheritdoc
|
10423
|
+
*/
|
10424
|
+
destroy() {
|
10425
|
+
// Disconnect the PerformanceObserver when the directive is destroyed
|
10426
|
+
if (this.#performanceObserver) {
|
10427
|
+
this.#performanceObserver.disconnect();
|
10428
|
+
this.#performanceObserver = undefined;
|
10429
|
+
}
|
10430
|
+
}
|
10431
|
+
/**
|
10432
|
+
* Creates a wrapper function for performance handlers.
|
10433
|
+
* @param expression The expression string to evaluate.
|
10434
|
+
* @returns A function that handles the performance event.
|
10435
|
+
*/
|
10436
|
+
#createPerformanceHandlerWrapper(expression) {
|
10437
|
+
const identifiers = this.#dependentIdentifiers ?? [];
|
10438
|
+
const vNode = this.#vNode;
|
10439
|
+
// Return a function that handles the performance event with proper scope
|
10440
|
+
return (entries, observer, options) => {
|
10441
|
+
const bindings = vNode.bindings;
|
10442
|
+
const $ctx = {
|
10443
|
+
element: vNode.node,
|
10444
|
+
vnode: vNode,
|
10445
|
+
userData: vNode.userData
|
10446
|
+
};
|
10447
|
+
// If the expression is just a method name, call it with bindings as 'this'
|
10448
|
+
const trimmedExpr = expression.trim();
|
10449
|
+
if (identifiers.includes(trimmedExpr) && typeof bindings?.get(trimmedExpr) === 'function') {
|
10450
|
+
const methodName = trimmedExpr;
|
10451
|
+
const originalMethod = bindings?.get(methodName);
|
10452
|
+
// Call the method with bindings as 'this' context
|
10453
|
+
// Pass entries, observer, options, and $ctx as arguments
|
10454
|
+
return originalMethod(entries, observer, options, $ctx);
|
10455
|
+
}
|
10456
|
+
// For inline expressions, evaluate normally
|
10457
|
+
// Note: inline expressions receive entries, observer, options, and $ctx as parameters
|
10458
|
+
const values = identifiers.map(id => vNode.bindings?.get(id));
|
10459
|
+
const args = [...identifiers, 'entries', 'observer', 'options', '$ctx'].join(", ");
|
10460
|
+
const funcBody = `return (${expression});`;
|
10461
|
+
const func = new Function(args, funcBody);
|
10462
|
+
return func.call(bindings?.raw, ...values, entries, observer, options, $ctx);
|
10463
|
+
};
|
10464
|
+
}
|
10465
|
+
}
|
10466
|
+
|
9930
10467
|
// Copyright (c) 2025 MintJams Inc. Licensed under MIT License.
|
9931
10468
|
/**
|
9932
10469
|
* Directive for observing element resize events using ResizeObserver.
|
@@ -10357,7 +10894,12 @@
|
|
10357
10894
|
// v-resize
|
10358
10895
|
context.attribute.name === StandardDirectiveName.V_RESIZE ||
|
10359
10896
|
// v-intersection
|
10360
|
-
context.attribute.name === StandardDirectiveName.V_INTERSECTION
|
10897
|
+
context.attribute.name === StandardDirectiveName.V_INTERSECTION ||
|
10898
|
+
// v-performance
|
10899
|
+
context.attribute.name === StandardDirectiveName.V_PERFORMANCE ||
|
10900
|
+
// v-component, v-component.<modifier>
|
10901
|
+
context.attribute.name === StandardDirectiveName.V_COMPONENT ||
|
10902
|
+
context.attribute.name.startsWith(StandardDirectiveName.V_COMPONENT + ".")) {
|
10361
10903
|
return true;
|
10362
10904
|
}
|
10363
10905
|
return false;
|
@@ -10404,6 +10946,15 @@
|
|
10404
10946
|
if (context.attribute.name === StandardDirectiveName.V_INTERSECTION) {
|
10405
10947
|
return new VIntersectionDirective(context);
|
10406
10948
|
}
|
10949
|
+
// v-performance
|
10950
|
+
if (context.attribute.name === StandardDirectiveName.V_PERFORMANCE) {
|
10951
|
+
return new VPerformanceDirective(context);
|
10952
|
+
}
|
10953
|
+
// v-component, v-component.<modifier>
|
10954
|
+
if (context.attribute.name === StandardDirectiveName.V_COMPONENT ||
|
10955
|
+
context.attribute.name.startsWith(StandardDirectiveName.V_COMPONENT + ".")) {
|
10956
|
+
return new VComponentDirective(context);
|
10957
|
+
}
|
10407
10958
|
throw new Error(`The attribute "${context.attribute.name}" cannot be parsed by ${this.name}.`);
|
10408
10959
|
}
|
10409
10960
|
}
|
@@ -10637,12 +11188,18 @@
|
|
10637
11188
|
}
|
10638
11189
|
/**
|
10639
11190
|
* Mounts the application.
|
10640
|
-
* @param
|
10641
|
-
*/
|
10642
|
-
mount(
|
10643
|
-
|
10644
|
-
if (
|
10645
|
-
|
11191
|
+
* @param target The CSS selector string or HTMLElement to mount the application to.
|
11192
|
+
*/
|
11193
|
+
mount(target) {
|
11194
|
+
let element;
|
11195
|
+
if (typeof target === 'string') {
|
11196
|
+
element = document.querySelector(target);
|
11197
|
+
if (!element) {
|
11198
|
+
throw new Error(`Element not found for selector: ${target}`);
|
11199
|
+
}
|
11200
|
+
}
|
11201
|
+
else {
|
11202
|
+
element = target;
|
10646
11203
|
}
|
10647
11204
|
// Clean the element by removing unnecessary whitespace text nodes
|
10648
11205
|
this.#cleanElement(element);
|
@@ -10656,6 +11213,14 @@
|
|
10656
11213
|
this.#vNode.update();
|
10657
11214
|
this.#logger.info('Application mounted.');
|
10658
11215
|
}
|
11216
|
+
/**
|
11217
|
+
* Creates a child application instance with the same registries.
|
11218
|
+
* @param options The application options for the child.
|
11219
|
+
* @returns The created child application instance.
|
11220
|
+
*/
|
11221
|
+
createChildApp(options) {
|
11222
|
+
return new VApplication(options, this.#directiveParserRegistry, this.#componentRegistry);
|
11223
|
+
}
|
10659
11224
|
/**
|
10660
11225
|
* Cleans the element by removing unnecessary whitespace text nodes.
|
10661
11226
|
* @param element The element to clean.
|
@@ -10892,6 +11457,8 @@
|
|
10892
11457
|
}
|
10893
11458
|
}
|
10894
11459
|
|
11460
|
+
exports.VComponent = VComponent;
|
11461
|
+
exports.VComponentRegistry = VComponentRegistry;
|
10895
11462
|
exports.VDOM = VDOM;
|
10896
11463
|
|
10897
11464
|
}));
|