houxit 0.1.12 → 0.1.14

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/houxit.cjs CHANGED
@@ -54,7 +54,7 @@ var isChar = (char) => isString(char) || isSymbol(char);
54
54
  var isPromise = (prom) => _toStringCall(prom) === "[object Promise]" && isFunction(prom.then) && isFunction(prom.catch);
55
55
  var isTrue = (compute) => compute === true;
56
56
  var isFalse = (compute) => compute === false;
57
- var $warner = `<<< Houxit Exception >>> ..... >>>>>>>`;
57
+ var $warner = `<<<[ Houxit Exception ]>>> ..... >>>>>>>`;
58
58
  var stringsMonitorRegex = /"(.*?)"|'(.*?)'|`+(.*?\s)`+/gm;
59
59
  function debugHandler(msg, self, dictateW = false, txt = "") {
60
60
  let DEBUG_ENV = true;
@@ -311,9 +311,6 @@ var validHouxitWidget = (w) => w && ((is_wuf_class(w) || isObject(w)) && !isProx
311
311
  function isAsyncFunction(fn) {
312
312
  return isPFunction(fn) && fn?.constructor?.name === "AsyncFunction";
313
313
  }
314
- function parseScript(script, args) {
315
- return new Function(`"use strict"; return (${script})`)(args);
316
- }
317
314
  var isInDomNode = (element) => inBrowserCompiler && element?.getRootNode() === document;
318
315
  var GLOBAL_EVENTS = "abort,animationcancel,animationend,animationiteration,animationstart,auxclick,blur,error,focus,canplay,canplaythrough,cancel,change,click,close,contextmenu,dblclick,drag,dragend,dragenter,dragleave,dragover,dragstart,drop,durationchange,emptied,ended,formdata,gotpointercapture,input,invalid,keydown,keypress,load,keyup,loadeddata,loadedmetadata,loadend,loadstart,lostpointercapture,mousedown,mouseenter,mouseleave,mousemove,mouseout,mouseover,mouseup,mousewheel,wheel,pause,play,playing,pointerdown,pointermove,pointerup,pointercancel,pointerover,pointerout,pointerleave,pointerenter,pointerlockchange,pointerlockerror,progress,ratechange,reset,resize,scroll,securitypolicyviolation,seeked,seeking,select,selectstart,selectionchange,slotchange,stalled,submit,suspend,timeupdate,touchcancel,touchend,touchstart,touchmove,transitioncancel,transitionrun,transitioned,transitionstart,waiting,volumechange,autocompleteerror,autocomplete,hover";
319
316
  var IS_VALID_EVENT_HANDLER = (eventName) => _makeMap_(GLOBAL_EVENTS, eventName);
@@ -372,7 +369,7 @@ function compileToRenderable(value, preserve = true) {
372
369
  var arrowFNRegex = /^(async[ ]+)?(\(([\w$,.\[\]\{\} ]*)\)|[\w$]+)[ ]*=>[ ]*[{]?\s*/;
373
370
  var functionFNRegex = /^(async[ ]+)?(function)?([*]?([ ]*)[\w$]*)?\(([\w$]*)?\)[ ]*\{\s*/m;
374
371
  var isArrowFunction = (fn) => isPFunction(fn) && arrowFNRegex.test(fn.toString());
375
- var isFNString = (str) => isString(str) && isTrue(arrowFNRegex.test(str) || functionFNRegex.test(str));
372
+ var isFNString = (str) => isString(str) && (arrowFNRegex.test(str) || functionFNRegex.test(str));
376
373
  var objectDestructureRegex = /^{(.*?)}$/;
377
374
  var arrayDestructureRegex = /^\[(.*?)\]$/;
378
375
  var isForLoopDestructureRegex = /^((\(|\<)(.*?)(\)|\>))$/;
@@ -944,89 +941,52 @@ var arrayMM = "push,pop,shift,unshift,splice,sort,reverse,copyWithin,fill";
944
941
  var setMM = "add,delete,clear";
945
942
  var mapMM = "set,delete,clear";
946
943
  var tupleMM = "add,delete,clear,shift,unshift,splice,pop,extend,replace,prepend,arrange,exchange";
947
- var objectMM = "define,delete";
948
- function getMutationArgs(data) {
949
- return isArray(data) ? arrayMM : isSet(data) ? setMM : isMap(data) ? mapMM : isTuple(data) ? tupleMM : isPObject(data) ? objectMM : "";
950
- }
951
- function getAgentMutators(data, prop, model) {
952
- const value = data;
953
- data = unwrap(data);
954
- let mutateArgs = getMutationArgs(data) + "write";
955
- const mutation_object = createObj("Mutatations");
956
- for (let name of mutateArgs.split(",").values()) {
957
- function mutate(arg) {
958
- let rv = void 0;
959
- if (validateType(data, [
960
- Set,
961
- Tuple,
962
- Array,
963
- Map
964
- ])) rv = data[name](arg);
965
- else if (isPObject(data)) {
966
- if ("define" === name) rv = define(data, ...arguments);
967
- else if ("delete" === name) {
968
- delete data[arg];
969
- rv = true;
970
- }
971
- }
972
- let assV = rv;
973
- if ((model || !isPrimitive(value)) && prop && name === "write") assV = set_Object_Value(isModelInstance(model) ? model : !isPrimitive(value) ? value : freeze(), prop, len(arguments) ? arg : data);
974
- return assV;
975
- }
976
- mutate = Function("fn", `
977
- return function ${name === "delete" ? "del" : name}(value){
978
- return fn(...arguments);
979
- }
980
- `)(mutate);
981
- define(mutation_object, name, {
982
- value: mutate,
983
- enumerable
984
- });
985
- }
986
- return mutation_object;
944
+ function getMutationArgs(base) {
945
+ return hasPrototype(base, Set) || hasPrototype(base, WeakSet) ? setMM : hasPrototype(base, Array) ? arrayMM : hasPrototype(base, Tuple) ? tupleMM : hasPrototype(base, Map) || hasPrototype(base, WeakMap) ? mapMM : "";
987
946
  }
988
- function _useAgent_(data, ModelInstance) {
947
+ function _useAgent_(data, config) {
989
948
  const dataRead = () => data;
990
949
  if (!validateCollectionArgs(arguments, {
991
950
  min: 1,
992
951
  max: 2,
993
- validators: [Any, [Model]],
952
+ validators: [Any, [Object]],
994
953
  name: "useAgent"
995
954
  })) return [dataRead, pass];
996
- if (isHouxitBuild(this) && !isChar(data)) {
955
+ let model = isHouxitBuild(this) ? this.__public_model__ : void 0;
956
+ if (!model && isObject(this)) model = this;
957
+ if (model && (!isChar(data) || !object_Has_Path(model, data))) {
997
958
  debugHandler(`[ ] data path at positional argument 1 expects a string/symbol value of an existing model path\n\n.>...$useAgent`);
998
959
  return [dataRead, pass];
999
- } else if (isModelInstance(ModelInstance) && !isChar(data)) {
1000
- debugHandler(`[ ] data property at positional argument 1 of "useAgent" expects a string/symbol value\n\nMust be a model valid path`);
1001
- return [dataRead, pass];
1002
- }
1003
- const self = isHouxitBuild(this) ? this : isModelInstance(ModelInstance) ? { __public_model__: ModelInstance } : null;
1004
- ModelInstance = self ? self.__public_model__ : null;
1005
- if (self && !isHouxitBuild(self)) delete self.__public_model__;
1006
- let prop = isModelInstance(ModelInstance) ? data : isToken(data) ? data[refInternalEffectKey].accessor : "";
1007
- if (isModelInstance(ModelInstance) && !object_Has_Path(ModelInstance, prop)) {
1008
- debugHandler(`[ ] "${prop}" property is not a valid model property`);
1009
- return [dataRead, pass];
1010
960
  }
1011
- data = isModelInstance(ModelInstance) && exists(prop) ? _$runModelBind(ModelInstance, prop || "") : data;
1012
- const mutateArgs = getAgentMutators(data, prop, ModelInstance);
1013
- let defineCount = 0;
961
+ let prop = model ? data : isToken(data) ? data[refInternalEffectKey].accessor : "";
962
+ data = model && exists(prop) ? () => _$runModelBind(model, prop || "") : data;
1014
963
  const unwrappedGetter = () => read(data);
1015
- function mutate(mutation) {
1016
- if (isPFunction(mutation) && defineCount < 1) {
1017
- defineCount++;
1018
- define(mutateArgs, "data", { get() {
1019
- return unwrappedGetter();
1020
- } });
1021
- }
1022
- if (isPFunction(mutation)) try {
964
+ const mutateArgs = {
965
+ get value() {
966
+ return unwrappedGetter();
967
+ },
968
+ write(...args) {
969
+ return write(...args);
970
+ }
971
+ };
972
+ function write(value) {
973
+ return mutate(value, PRIVATE_PROPERTY_KEY);
974
+ }
975
+ function mutate(mutation, p_p_k) {
976
+ if (isPFunction(mutation) && p_p_k !== PRIVATE_PROPERTY_KEY) try {
1023
977
  mutation(mutateArgs);
1024
978
  } catch (err) {
1025
- debugHandler(`[ ] Encountered an error during the call of the writer callback\n\n${err}`);
979
+ debugHandler(`[ useAgent write failure ] Encountered an error during the call of the writer callback\n\n${err}`);
980
+ debugHandler(`${err}`);
1026
981
  return false;
1027
982
  }
1028
983
  else if (!isPFunction(mutation)) {
1029
- set_Object_Value(isModelInstance(ModelInstance) ? ModelInstance : !isPrimitive(data) ? data : freeze(), prop, mutation);
984
+ try {
985
+ set_Object_Value(model ? model : !isPrimitive(data) ? data : freeze(), prop, mutation);
986
+ } catch (e) {
987
+ debugHandler(e);
988
+ return false;
989
+ }
1030
990
  return true;
1031
991
  }
1032
992
  }
@@ -1038,8 +998,8 @@ function _useAgent_(data, ModelInstance) {
1038
998
  }
1039
999
  return [reader, writer];
1040
1000
  }
1041
- function useAgent(data, ModelInstance) {
1042
- return _useAgent_(...arguments);
1001
+ function useAgent(data, value) {
1002
+ return _useAgent_.call(this, ...arguments);
1043
1003
  }
1044
1004
  function WRITE(props) {
1045
1005
  if (!validateCollectionArgs(arguments, {
@@ -2208,10 +2168,8 @@ function _createAgent(value, config) {
2208
2168
  min: 1,
2209
2169
  max: 2,
2210
2170
  validators: [Any, Object]
2211
- })) return pass;
2212
- if (!getCurrentRunningEffect({ name: "agent" })) return [pass, pass];
2213
- const parameters = [value, assign({ shallow: true }, config || {})];
2214
- return _useAgent_(!isToken(value) && !isPrimitive(value) ? stream(...parameters) : token(...parameters));
2171
+ })) return [pass, pass];
2172
+ return _useAgent_(token(...[value, assign({ shallow: true }, config || {})]));
2215
2173
  }
2216
2174
  function agent(value, config) {
2217
2175
  return _createAgent(...arguments);
@@ -2340,35 +2298,10 @@ var FrameworkCompilerOptions = class {
2340
2298
  scopedStyle = true;
2341
2299
  };
2342
2300
  var Compiler_Config_Options = new FrameworkCompilerOptions();
2343
- var HouxitCompilerSetup = class {
2344
- debug(debug) {
2345
- if (isFalse(mapSettingCheck(this, "debug", debug))) return this;
2346
- Compiler_Config_Options.debug = debug;
2347
- }
2348
- forwardAttrs(forwardAttrs) {
2349
- if (isFalse(mapSettingCheck(this, "forwardAttrs", forwardAttrs))) return this;
2350
- Compiler_Config_Options.forwardAttrs = forwardAttrs;
2351
- }
2352
- forwardEvents(forwardEvents) {
2353
- if (isFalse(mapSettingCheck(this, "forwardEvents", forwardEvents))) return this;
2354
- Compiler_Config_Options.forwardEvents = forwardEvents;
2355
- }
2356
- flushType(flushType) {
2357
- if (isFalse(mapSettingCheck(this, "flushType", flushType))) return this;
2358
- Compiler_Config_Options.flushType = flushType;
2359
- }
2360
- forwardSlot(forwardSlot) {
2361
- if (isFalse(mapSettingCheck(this, "forwardSlot", forwardSlot))) return this;
2362
- Compiler_Config_Options.forwardSlot = forwardSlot;
2363
- }
2364
- delimiters(delimiters) {
2365
- if (isFalse(mapSettingCheck(this, "delimiters", delimiters))) return this;
2366
- Compiler_Config_Options.delimiters = delimiters;
2367
- }
2368
- scopedStyle(scopedStyle) {
2369
- if (isFalse(mapSettingCheck(this, "scopedStyle", scopedStyle))) return this;
2370
- Compiler_Config_Options.scopedStyle = scopedStyle;
2371
- }
2301
+ var CompilerConfigOptions = class {};
2302
+ for (let key of keys(Compiler_Config_Options)) CompilerConfigOptions.prototype[key] = function(config) {
2303
+ if (isFalse(mapSettingCheck(this, key, config))) return this;
2304
+ Compiler_Config_Options[key] = config;
2372
2305
  };
2373
2306
  function isXtruct(func, ...arg) {
2374
2307
  try {
@@ -3887,7 +3820,7 @@ function debug_unrecognized_tagname(tagname, self) {
3887
3820
  debugHandler(`[ ] [unexpected template tagname] "${tagname}" is not a valid html element, or a registered widget instance.\n\nif this is a customElement, make sure its defined through the "customElements.define()" method `, self, true);
3888
3821
  }
3889
3822
  function isCustomElementTagname(tagname) {
3890
- return isPFunction(customElements.get(tagname));
3823
+ return isFunction(customElements.get(tagname));
3891
3824
  }
3892
3825
  function getBoundary(instance) {
3893
3826
  return isHouxitBuild(instance) ? instance[$$$core].virtualNode.filesFilter.suspense : instance?.[isVNodeClass(instance) ? "filesFilter" : "VNodeManager"]?.suspense;
@@ -4128,6 +4061,7 @@ var HouxitNativeElement = class extends HouxitElement {
4128
4061
  constructor(vnode) {
4129
4062
  super(...arguments);
4130
4063
  this.VNodeManager.SSRVnode = new vNodeClass();
4064
+ this.VNodeManager.customEvents = {};
4131
4065
  HouxitTemplateGenerators.call(this, ...arguments);
4132
4066
  this.prototype_ = vnode.type;
4133
4067
  }
@@ -4335,19 +4269,9 @@ function generateTemplateElement(vnode, self, hx_Element, siblings, IS_RENDERLES
4335
4269
  }
4336
4270
  function _generateTemplateElement(virtualNode, self, hx_Element, siblings, IS_RENDERLESS, customElementsArgs, config) {
4337
4271
  const { prototype_ } = virtualNode;
4338
- if (isString(prototype_) && IS_VALID_TAGNAME(prototype_)) return _createNativeElement(...arguments);
4339
- else if (isString(prototype_)) return generateCustomNativeElement(...arguments);
4272
+ if (isString(prototype_)) return _createNativeElement(...arguments);
4340
4273
  else return _createWidgetElement(...arguments);
4341
4274
  }
4342
- function generateCustomNativeElement(vnode, self, hx_Element, siblings, IS_RENDERLESS, customElementsArgs, config) {
4343
- let { type, props, children, key } = vnode;
4344
- len(arguments);
4345
- hx_Element?.is_hyperscript;
4346
- if (self[$$$operands]?.initializedRender) return;
4347
- const element = document.createElement(type);
4348
- element._set_compiler_options(...arguments);
4349
- return element;
4350
- }
4351
4275
  function _createNativeElement(virtualNode, self, hx_Element, siblings, IS_RENDERLESS, customElementsArgs, config, o) {
4352
4276
  config = assign({}, config);
4353
4277
  let { type, props, children, key } = virtualNode;
@@ -4415,7 +4339,10 @@ function _createNativeElement(virtualNode, self, hx_Element, siblings, IS_RENDER
4415
4339
  index++;
4416
4340
  }
4417
4341
  }
4418
- if (props) Props_dilation_compile(virtualNode, self, hx_Element, metrics, element, config);
4342
+ if (props) {
4343
+ if (!IS_VALID_TAGNAME(type)) config.isCustomElement = true;
4344
+ Props_dilation_compile(virtualNode, self, hx_Element, metrics, element, config);
4345
+ }
4419
4346
  if (!isRerender && virtualNode.prototype_ === "slot" && !(isSSR ? element?.props.name.trim() : element.name?.trim())) {
4420
4347
  slotNamingTRANSITION(self, { value: "default" }, element, hx_Element, {
4421
4348
  is_hyperscript,
@@ -4713,21 +4640,14 @@ function abstractFilterName(filter) {
4713
4640
  }
4714
4641
  var HouxitDirectives = "if,else,else-if,html,text,for,raw,slot,model,bind,on,scoped,provide,transite,animate,clone";
4715
4642
  var isHouxitDirective = (dir) => _makeMap_(HouxitDirectives, dir);
4643
+ var commentRegex = /\/\/.*$|\/\*[^]*?\*\//gm;
4644
+ var unsupportedRegex = /(?:\.\.|\bthrow\b|\bdelete\b|\bvoid\b|\bconst\b|\blet\b|\bvar\b|\bwhile\b|\bfor\b|\bof\b|\bif\b|\belse\b|\bimport\b|\bexport\b|\bswitch\b|\bcase\b|\btry\b|\bcatch\b|\bcontinue\b|\bbreak\b|\bwith\b|\bdebugger\b|\blabel\b|\bdo\b|\bfrom\b|\bas\b|\bfinally\b|\benum\b|\bimplements\b|\binterface\b|\bpackage\b|\bprotected\b|\bin\b)/gm;
4716
4645
  function _Evaluate_THIS(obj, str, self, optional) {
4717
- const commentRegex = /\/\/.*$|\/\*[^]*?\*\//g;
4718
- let expressionWithoutComments = str.replace(commentRegex, "").replace(stringsMonitorRegex, () => "");
4719
- const unsupportedRegex = /(?:\.\.|\bthrow\b|\bdelete\b|\bvoid\b|\bconst\b|\blet\b|\bvar\b|\bwhile\b|\bfor\b|\bof\b|\bif\b|\belse\b|\bimport\b|\bexport\b|\bswitch\b|\bcase\b|\btry\b|\bcatch\b|\bcontinue\b|\bbreak\b|\bwith\b|\bdebugger\b|\blabel\b|\bdo\b|\bfrom\b|\bas\b|\bfinally\b|\benum\b|\bimplements\b|\binterface\b|\bpackage\b|\bprotected\b)/;
4720
- let checkRegex = false;
4721
- try {
4722
- parseScript(expressionWithoutComments);
4723
- } catch (err) {
4724
- checkRegex = true;
4725
- }
4726
- if (checkRegex && unsupportedRegex.test(expressionWithoutComments.replace(stringsMonitorRegex, () => ""))) throw new Error(`Invalid expression: \n\nUnsupported constructs are not allowed.\n\n"${str}"`, self, true);
4727
- else if (commentRegex.test(str)) {
4728
- debugHandler(`[ ] Template SyntaxError...\n\nComments not allowed in template expression\n\n"${str}"`, self, true);
4646
+ let expressionWithoutComments = str.replace(commentRegex, "").replace(stringsMonitorRegex, "");
4647
+ if (unsupportedRegex.test(expressionWithoutComments.replace(stringsMonitorRegex, () => ""))) {
4648
+ debugHandler(`Invalid expression: \n\nUnsupported constructs are not allowed.\n\n"${str}"\n\n"${expressionWithoutComments.match(unsupportedRegex).join(", ")}" not supported in an inline bind expression`, self, true);
4729
4649
  return;
4730
- }
4650
+ } else if (commentRegex.test(str.replace(stringsMonitorRegex, () => ""))) str = expressionWithoutComments;
4731
4651
  let dexTransform;
4732
4652
  if (optional && isPObject(optional) && hasOwn(optional, $$dexTransformKey)) {
4733
4653
  dexTransform = optional[$$dexTransformKey];
@@ -4737,7 +4657,8 @@ function _Evaluate_THIS(obj, str, self, optional) {
4737
4657
  let compile_Str = `with(obj){
4738
4658
  with($$$ctx){
4739
4659
  try{
4740
- return dexTransform ? dexTransform.traverse() : ${str.trim() || "undefined"};
4660
+ if(dexTransform) return dexTransform.traverse();
4661
+ else return ${str.trim() || "undefined"};
4741
4662
  }catch(err){
4742
4663
  throw new Error(err);
4743
4664
  }
@@ -4750,7 +4671,10 @@ function _Evaluate_THIS(obj, str, self, optional) {
4750
4671
  let value;
4751
4672
  try {
4752
4673
  value = getValue.call(obj, obj, isPObject(optional) ? optional : {}, dexTransform, self[$$$core].__env__ || {});
4753
- } catch (error) {}
4674
+ } catch (error) {
4675
+ debugHandler(`${error}`, self, true);
4676
+ return;
4677
+ }
4754
4678
  return value;
4755
4679
  }
4756
4680
  function transformDestructureContext(props, sources, vv, metrics = []) {
@@ -5218,7 +5142,7 @@ function validateListenSpecialEvent(self, bindings) {
5218
5142
  bindings.modifiers = isString(modifiers) ? modifiers.split("|") : isArray(modifiers) ? modifiers : [];
5219
5143
  return true;
5220
5144
  }
5221
- function HTMLAttrsMagnifier(element, bindings, hx_Element, self, metrics) {
5145
+ function HTMLAttrsMagnifier(element, bindings, hx_Element, self, metrics, config) {
5222
5146
  let { is_hyperscript, isRerender, vNode, forwardAttrs } = metrics;
5223
5147
  const isSSR = isSSRCompiler(self);
5224
5148
  let { key, value: attr, src } = bindings;
@@ -5236,7 +5160,7 @@ function HTMLAttrsMagnifier(element, bindings, hx_Element, self, metrics) {
5236
5160
  is_hyperscript,
5237
5161
  bindings,
5238
5162
  forwardAttrs
5239
- }, hx_Element);
5163
+ }, hx_Element, config);
5240
5164
  else if (!isRerender && (isOnListener(key) || isInlineListener(key) || key === "dispatch")) {
5241
5165
  if (!click_handler_facading(self, [
5242
5166
  key,
@@ -5250,7 +5174,7 @@ function HTMLAttrsMagnifier(element, bindings, hx_Element, self, metrics) {
5250
5174
  else if (key === "motion") motionPropFacade(self, bindings, element, hx_Element, metrics);
5251
5175
  else {
5252
5176
  try {
5253
- attr = compileToRenderable(unwrap(attr));
5177
+ attr = compileToRenderable(unwrap(attr), config.isCustomElement);
5254
5178
  const sp = hx_Element?.VNodeManager?.patchFlags.shapeProps;
5255
5179
  if (isSSR || isRerender) {
5256
5180
  const props = isRerender ? sp : element.props;
@@ -5263,10 +5187,10 @@ function HTMLAttrsMagnifier(element, bindings, hx_Element, self, metrics) {
5263
5187
  }
5264
5188
  if (isRerender && !len(bindings.subscribers) || isSSR) return;
5265
5189
  const flush = createPriorityFlush(bindings.effect, function(observers) {
5266
- value = _createElementPropsEffectBlock_(self, {
5190
+ attr = _createElementPropsEffectBlock_(self, {
5267
5191
  element,
5268
5192
  key,
5269
- value: compileToRenderable(value),
5193
+ value: compileToRenderable(attr, config.isCustomElement),
5270
5194
  mode: void 0,
5271
5195
  effect: bindings.effect
5272
5196
  }, observers);
@@ -5300,6 +5224,7 @@ function isInlineListener(key) {
5300
5224
  }
5301
5225
  function click_handler_facading(self, [key, attr, src], bindings, element, hx_Element, metrics) {
5302
5226
  attr = unwrap(attr);
5227
+ const { config } = metrics;
5303
5228
  if (key === "dispatch" && !isArray(attr)) {
5304
5229
  debugHandler(`[ ] <dispatch> dispatcher expects an array value of events and method\n\nFound "${attr}" of "${getType(attr)}" type`, self, !isNull(self));
5305
5230
  return;
@@ -5312,6 +5237,10 @@ function click_handler_facading(self, [key, attr, src], bindings, element, hx_El
5312
5237
  bindings.value = attr;
5313
5238
  metrics = assign({ options }, metrics);
5314
5239
  if (!validateListenSpecialEvent(self, bindings)) return;
5240
+ if (config.isCustomElement) {
5241
+ element[key] = attr;
5242
+ return;
5243
+ }
5315
5244
  $$dir_ON(self, bindings, element, hx_Element, metrics);
5316
5245
  return true;
5317
5246
  }
@@ -5463,9 +5392,8 @@ function transformAttachProp(self, bindings, element, hx_Element, metrics) {
5463
5392
  }
5464
5393
  function __widget_props_effect(app, metrics, observers) {
5465
5394
  if (!isHouxitBuild(app)) return;
5466
- const { value, effect, key } = metrics;
5467
- const transform = effect.runEffect().value;
5468
- const newValue = unwrap(transform);
5395
+ const { value, effect, key, config } = metrics;
5396
+ const newValue = unwrap(isEffect(effect) ? effect.runEffect?.().value : effect);
5469
5397
  const params = app[$$$ownProperties].$params;
5470
5398
  const attrs = app.__public_model__.$attrs;
5471
5399
  const mode = hasOwn(params, key) ? "params" : hasOwn(attrs, key) ? "attrs" : void 0;
@@ -5534,7 +5462,7 @@ function attributes_hydration(props, self, hx_Element, metrics, element, config,
5534
5462
  else if (bindings.key === "key") {
5535
5463
  hx_Element.VNodeManager.vNodeClass.key = bindings.value;
5536
5464
  hx_Element.VNodeManager.keyIdBinding = bindings;
5537
- } else (isW ? widget_props_plugin : HTMLAttrsMagnifier)(element, bindings, hx_Element, self, metrics);
5465
+ } else (isW ? widget_props_plugin : HTMLAttrsMagnifier)(element, bindings, hx_Element, self, metrics, config);
5538
5466
  }
5539
5467
  function slotNamingTRANSITION(self, bindings, element, hx_Element, metrics) {
5540
5468
  let { value } = bindings;
@@ -5594,7 +5522,7 @@ function SlotContextBindingTRANSITON(self, bindings, element, hx_Element, metric
5594
5522
  });
5595
5523
  }
5596
5524
  }
5597
- function IDLPropsTransform(self, props, element, metrics, hx_Element) {
5525
+ function IDLPropsTransform(self, props, element, metrics, hx_Element, config) {
5598
5526
  let [key, attr] = props;
5599
5527
  const { is_hyperscript, bindings } = metrics;
5600
5528
  const isSSR = isSSRCompiler(self);
@@ -5610,8 +5538,8 @@ function IDLPropsTransform(self, props, element, metrics, hx_Element) {
5610
5538
  } else element.className = element.className + " " + transform.join(" ");
5611
5539
  } else if (isSSR || isRerender) {
5612
5540
  const props = isRerender ? sp : hx_Element.VNodeManager.SSRVnode.props;
5613
- props[_makeMap_("innerText,textContent", key) ? "innerText" : key] = escapeDecoder(compileToRenderable(attr));
5614
- } else element[key] = compileToRenderable(attr);
5541
+ props[_makeMap_("innerText,textContent", key) ? "innerText" : key] = config.isCustomElement ? attr : escapeDecoder(compileToRenderable(attr));
5542
+ } else element[key] = compileToRenderable(attr, config.isCustomElement);
5615
5543
  if (isRerender && !len(bindings.subscribers) || isSSR) return;
5616
5544
  const flush = createPriorityFlush(bindings.effect, function(observers) {
5617
5545
  _createElementPropsEffectBlock_(self, {
@@ -5813,7 +5741,7 @@ function Special_REF_Modifier(self, node, binding, hx_Element, metrics) {
5813
5741
  self[$$$core].map.is_hyperscript;
5814
5742
  let refKey = effect ? effect.value : value;
5815
5743
  const templateRefs = self[$$$operands].templateRefsInputs;
5816
- const model = self.__public_model__;
5744
+ self.__public_model__;
5817
5745
  let ref;
5818
5746
  if (isString(refKey)) {
5819
5747
  if (!hasOwn(templateRefs, refKey)) {
@@ -5826,7 +5754,7 @@ function Special_REF_Modifier(self, node, binding, hx_Element, metrics) {
5826
5754
  debugHandler(`[templateRefs reference] not a token. templateRefs expects a token() instance.\nSee [Template Refs] reference`, self, true);
5827
5755
  return;
5828
5756
  }
5829
- const [getRef, setRef] = model.$useAgent(ref);
5757
+ const [getRef, setRef] = useAgent(ref);
5830
5758
  let cb = pass;
5831
5759
  const current = getRef();
5832
5760
  if (current && !isArray(current)) setRef(shallowStream([current]));
@@ -5957,9 +5885,8 @@ function $$dir_ON(self, bindings, node, hx_Element, metrics) {
5957
5885
  }, hx_Element, metrics.is_hyperscript);
5958
5886
  const funcToken = attr;
5959
5887
  effect = _createHouxitEffectFrame(() => {
5960
- attr = _$runModelBind(self, attr, hx_Element);
5961
- attr = object_Has_Path(self.__public_model__, funcToken) && isPFunction(attr) ? attr.bind(self.__public_model__) : attr;
5962
- return attr;
5888
+ let res = _$runModelBind(self, attr, hx_Element);
5889
+ return object_Has_Path(self.__public_model__, funcToken) && isPFunction(res) ? res.bind(self.__public_model__) : res;
5963
5890
  }, self);
5964
5891
  try {
5965
5892
  attr = effectRunner(effect).value;
@@ -5979,21 +5906,19 @@ function $$dir_ON(self, bindings, node, hx_Element, metrics) {
5979
5906
  if (!isRerender && isWidget) {
5980
5907
  const board = vNode.filesFilter.$$$Events;
5981
5908
  for (let [ind, ev] of deepKeys.entries()) {
5982
- let card = {
5909
+ if (!hasOwn(board, ev)) board[ev] = {
5983
5910
  callbacks: new Tuple(),
5984
5911
  event: ev,
5985
5912
  effect
5986
5913
  };
5987
- if (hasOwn(board, ev)) card = board[ev];
5988
- else board[ev] = card;
5989
5914
  attr.options = options;
5990
- card.callbacks.add(attr);
5915
+ board[ev].callbacks.add(attr);
5991
5916
  }
5992
- } else if (!isRerender && isHydration(self) && isVNodeClass(node) || !isSSR && IS_ELEMENT_NODE(node)) for (let event of deepKeys.values()) if (!IS_VALID_EVENT_HANDLER(event)) debugHandler(`[ ] "${event}" is not a valid event name`, self, true);
5917
+ } else if (!isRerender && isHydration(self) && isVNodeClass(node) || !isSSR && IS_ELEMENT_NODE(node)) for (let event of deepKeys.values()) if (!IS_VALID_EVENT_HANDLER(event) && !metrics.config.isCustomElement) debugHandler(`[ ] "${event}" is not a valid event name`, self, true);
5993
5918
  else {
5994
5919
  const callbackListen = (element) => {
5995
5920
  element.addEventListener(event, (...args) => {
5996
- (isFunction(listenerHandle) ? listenerHandle : pass)(...args);
5921
+ safeCall(listenerHandle, ...args);
5997
5922
  }, options);
5998
5923
  };
5999
5924
  if (isHydration(self)) node.filesFilter.$ssr_kit.hydrationFlushs.add(callbackListen);
@@ -6001,7 +5926,6 @@ function $$dir_ON(self, bindings, node, hx_Element, metrics) {
6001
5926
  }
6002
5927
  createPriorityFlush(effect, () => {
6003
5928
  listenerHandle = effect.runEffect().value;
6004
- listenerHandle = !isPFunction(listenerHandle) ? pass : listenerHandle;
6005
5929
  });
6006
5930
  return node;
6007
5931
  }
@@ -6039,10 +5963,6 @@ function normalize_motion_directives(self, bindings, node, hx_Element, metrics,
6039
5963
  let { value, modifiers, key, directive, deepKeys } = bindings;
6040
5964
  modifiers = new Set(modifiers);
6041
5965
  hx_Element.is_hyperscript;
6042
- value = effectRunner(_createHouxitEffectFrame(function() {
6043
- return _$runModelBind(self, value, hx_Element, !modifiers.has("bind"));
6044
- }, self)).value;
6045
- value = unwrap(value);
6046
5966
  const obj = hx_Element.VNodeManager.motion_object;
6047
5967
  const mode = modifiers.has("in") ? "in," : modifiers.has("out") ? "out" : "both";
6048
5968
  const activateMotion = (key, directive) => {
@@ -6157,13 +6077,12 @@ function $$dir_MODEL(self, bindings, element, hx_Element, metrics) {
6157
6077
  try {
6158
6078
  initVal = updateElementModelValue(self, element, get_I_V($ev.target), item, initVal, modifiers);
6159
6079
  } catch (err) {
6160
- debugHandler(err);
6161
6080
  debugHandler(`[ ] ${err}`, self, true);
6162
6081
  }
6163
6082
  });
6164
6083
  }
6165
6084
  if (isHydration(self)) element.filesFilter.$ssr_kit.hydrationFlushs.add(flushCallback);
6166
- else if (!isSSR) whenMounted(self, element, () => flushCallback(element));
6085
+ else if (!isSSR) flushCallback(element);
6167
6086
  createPriorityFlush(effect, () => {
6168
6087
  if (localName === "form") return;
6169
6088
  applyModelInitialState(self, element, unwrap(effect.runEffect().value), localName);
@@ -6205,6 +6124,7 @@ function normalize_form_model(self, element, value, modifiers, effect) {
6205
6124
  try {
6206
6125
  initVal = updateElementModelValue(self, control, get_I_V($ev.target), name, initVal, modifiers, value);
6207
6126
  } catch (err) {
6127
+ console.error(err);
6208
6128
  debugHandler(err);
6209
6129
  debugHandler(`[ ] ${err}`, self, true);
6210
6130
  }
@@ -6244,7 +6164,7 @@ function applyModelInitialState(self, element, initVal, localName, inForm) {
6244
6164
  if (isCollection(initVal) ? genericCollection(initVal).has(value) : !element.hasAttribute("value") ? initVal : value === initVal) element.checked = true;
6245
6165
  else element.checked = false;
6246
6166
  } else if (type === "file") {
6247
- debugHandler(`[Houxit $$model Warning]:$$model is not supported on ${escapeDecoder("<input type=\"file\">")}. Use @change to access event.target.files instead.`);
6167
+ debugHandler(`[Houxit $$model Warning]:$$model is not supported on ${escapeDecoder("<input type=\"file\">")}. \nUse @change to access event.target.files instead.`);
6248
6168
  return;
6249
6169
  } else if (!isNull(initVal)) element.value = compileToRenderable(initVal);
6250
6170
  }
@@ -6258,11 +6178,15 @@ function updateElementModelValue(self, element, target_value, path, value, modif
6258
6178
  return val;
6259
6179
  };
6260
6180
  if (name === "select") {
6181
+ if (element.multiple && !isCollection(value)) {
6182
+ debugHandler(`[ invalid $$model value ] ${escapeDecoder("<select multiple>")} expects an array/collection value reference`, self, true);
6183
+ return;
6184
+ }
6261
6185
  let coll = isCollection(value) && element.multiple ? genericCollection(value) : value;
6262
6186
  for (let [index, opt] of entries(element.options)) {
6263
6187
  const v = applyModelValueModifiers(opt.value, modifiers);
6264
6188
  if (opt.selected && !(element.multiple ? coll.has(v) : v === value)) value = isCollection(value) && element.multiple ? coll.add(v) : setV(v);
6265
- else if (!opt.selected && (element.multiple ? coll.has(v) : v === value)) value = isCollection(value) && element.multiple ? coll.delete(v) : setV(null);
6189
+ else if (!opt.selected && (element.multiple ? coll.has?.(v) : v === value)) value = isCollection(value) && element.multiple ? coll.delete(v) : setV(null);
6266
6190
  }
6267
6191
  } else {
6268
6192
  if (!element.hasAttribute("value")) current = element.checked ? true : false;
@@ -6272,7 +6196,7 @@ function updateElementModelValue(self, element, target_value, path, value, modif
6272
6196
  if (element.checked && !coll.has(current)) coll.add(current);
6273
6197
  else if (!element.checked && coll.has(current)) coll.delete(current);
6274
6198
  } else if (!cs || cs && isNull(value)) value = setV(current);
6275
- } else if (!cs || cs && isNull(value)) value = setV(current);
6199
+ } else if (!cs || cs && isNull(value)) value = setV(target_value);
6276
6200
  }
6277
6201
  return value;
6278
6202
  }
@@ -7551,7 +7475,7 @@ function grabSSRVNodSlots(self, vnode, name) {
7551
7475
  if (name === value.props.name || ssrSmartDefaultToggle(value.props, name)) return value;
7552
7476
  }
7553
7477
  }
7554
- function assignSlot(self, slot, content, name, assynedSlots, renderedSlotsList, vnode) {
7478
+ function assignSlot(self, slot, content, name, assynedSlots, renderedSlotsList, vnode, isCustomElement) {
7555
7479
  if (content && isHouxitElement(content) && !hasOwn(renderedSlotsList, name)) {
7556
7480
  if (isSSRCompiler(self)) {
7557
7481
  slot = grabSSRVNodSlots(self, vnode, name);
@@ -7574,13 +7498,26 @@ var shouldForwwardSlots = (element, slots, self) => {
7574
7498
  if (isSSRCompiler(self)) return isString(element.type) && !len(element.children) && element?.type !== "slot";
7575
7499
  return IS_ELEMENT_NODE(element) && !element.innerHTML.trim() && element?.localName !== "slot";
7576
7500
  };
7501
+ function custom_elements_slotting(element, slots, self) {
7502
+ slots.default = new Tuple();
7503
+ for (let [ind, el] of entries(element.children)) {
7504
+ let name = el.slot || "default";
7505
+ if (!hasOwn(slots, name)) slots[name] = new Tuple();
7506
+ slots[name].add(el._hx_Element.hx_Element);
7507
+ if (isInDomNode(el)) el.remove();
7508
+ }
7509
+ for (let [name, content] of entries(slots)) if (len(content) > 1) slots[name] = new HouxitFragmentElement(content.list(), self);
7510
+ else if (len(content)) slots[name] = content.at(0);
7511
+ }
7577
7512
  function _$slotHydrationRenderer(self, opts, vnode_build) {
7578
7513
  const slots = self[$$$core].slots;
7579
- if (!len(slots) || !vnode_build || !isHouxitElement(vnode_build) || isHouxitTextElement(vnode_build)) return vnode_build;
7514
+ const $$config = self[$$$compiler].$$config;
7515
+ if (!len(slots) && !$$config?.isCustomElement || !vnode_build || !isHouxitElement(vnode_build) || isHouxitTextElement(vnode_build)) return vnode_build;
7580
7516
  const renderedSlotsList = {};
7581
7517
  const slot_elements = resolveSlotsFilter(self, vnode_build);
7582
7518
  const assynedSlots = new Tuple();
7583
- for (const [slotN, slot_el] of entries(slot_elements)) if (hasOwn(slots, slotN) && !assynedSlots.has(slotN)) assignSlot(self, slot_el, slots[slotN]?.(self), slotN, assynedSlots, renderedSlotsList, vnode_build);
7519
+ if ($$config?.isCustomElement) custom_elements_slotting($$config.element, slots, self);
7520
+ for (const [slotN, slot_el] of entries(slot_elements)) if (hasOwn(slots, slotN) && !assynedSlots.has(slotN)) assignSlot(self, slot_el, safeCall(slots[slotN], self), slotN, assynedSlots, renderedSlotsList, vnode_build, $$config.isCustomElement);
7584
7521
  if (shouldForwwardSlots(vnode_build?.$element, slot_elements, self) && !len(vnode_build.NodeList)) {
7585
7522
  if (self[$$$core].settings.forwardSlot) {
7586
7523
  const slotContent = hasOwn(slots, "default") ? slots.default(self) : null;
@@ -7914,12 +7851,34 @@ function createSignalFromEventObject(self, event) {
7914
7851
  return merger.call(this, ...arguments);
7915
7852
  };
7916
7853
  }
7854
+ var HouxitEvents = class extends Event {
7855
+ #properties;
7856
+ constructor(event, properties = {}) {
7857
+ super(event);
7858
+ this.#properties = properties;
7859
+ }
7860
+ get target() {
7861
+ return this.#properties.target_value;
7862
+ }
7863
+ };
7917
7864
  function $construct_With_Signals(self, options, in_build = false, vnode) {
7865
+ const $$config = self[$$$compiler].$$config;
7918
7866
  if (!self.__public_model__.$events) defineGetter(self.__public_model__, "$events", new Events());
7919
7867
  if (in_build) vnode = options;
7920
7868
  const $$events = self[$$$core].virtualNode.filesFilter.$$$Events;
7921
7869
  const signals = new Tuple(...options.signals || []);
7922
7870
  const $signals = self.__public_model__.$signals;
7871
+ const ce_hx_Element = $$config?.element?._hx_Element.hx_Element;
7872
+ if (!in_build && $$config?.isCustomElement) for (let [ev_name, my_event] of entries(ce_hx_Element.VNodeManager.customEvents)) {
7873
+ if (!hasOwn($$events, ev_name)) $$events[ev_name] = {
7874
+ callbacks: new Tuple(),
7875
+ event: ev_name,
7876
+ effect: void 0
7877
+ };
7878
+ $$events[ev_name].callbacks.add(function() {
7879
+ $$config.element.dispatchEvent(my_event);
7880
+ });
7881
+ }
7923
7882
  for (const [key, event] of entries($$events)) if (signals.has(key)) $signals[key] = createSignalFromEventObject(self, event);
7924
7883
  for (const signal of signals.values()) if (!hasOwn($signals, signal)) $signals[signal] = createSignalFromEventObject(self, { callbacks: [] });
7925
7884
  }
@@ -8148,9 +8107,9 @@ function collectionsPropAssertion(target, prop) {
8148
8107
  } else if (isMap(target) || isWeakMap(target)) {
8149
8108
  if (_makeMap_(mapMM, prop)) response = false;
8150
8109
  } else if (isTuple(target)) {
8151
- if (_makeMap_(tupleMM)) response = false;
8110
+ if (_makeMap_(tupleMM, prop)) response = false;
8152
8111
  } else if (isArray(target)) {
8153
- if (_makeMap_(arrayMM)) response = false;
8112
+ if (_makeMap_(arrayMM, prop)) response = false;
8154
8113
  } else if (prop === $$$StreamProxyKey) response = false;
8155
8114
  if (isCollection(target)) prop = target;
8156
8115
  return [response, prop];
@@ -8226,6 +8185,7 @@ function transformProxyStream(obj, ReactiveEffect, config) {
8226
8185
  return reactive;
8227
8186
  }
8228
8187
  function hasPrototype(obj, prototype) {
8188
+ if (!isClass(obj) && isPObject(obj)) obj instanceof prototype;
8229
8189
  obj = obj.prototype;
8230
8190
  prototype = prototype.prototype;
8231
8191
  while (obj) {
@@ -8241,7 +8201,7 @@ function streamReactiveHook(X, args, name, ReactiveEffect) {
8241
8201
  return res;
8242
8202
  }
8243
8203
  function CollectionsEffectMutationsTrap(BaseStream, ReactiveEffect) {
8244
- (hasPrototype(BaseStream, Set) || hasPrototype(BaseStream, WeakSet) ? setMM : hasPrototype(BaseStream, Array) ? arrayMM : hasPrototype(BaseStream, Tuple) ? tupleMM : hasPrototype(BaseStream, Map) || hasPrototype(BaseStream, WeakMap) ? mapMM : "").split(",").values().forEach((method) => {
8204
+ getMutationArgs(BaseStream).split(",").values().forEach((method) => {
8245
8205
  if (!method) return;
8246
8206
  BaseStream.prototype[method] = Function("streamReactiveHook", `
8247
8207
  return function ${method === "delete" ? "del" : method}(){
@@ -8692,7 +8652,7 @@ function mapPublicationsTraverse(self, opts, adapter) {
8692
8652
  }
8693
8653
  function receivePublicationPrefix(self, opts, in_build = false) {
8694
8654
  if (!hasOwn(opts, "receive")) return;
8695
- const globalBoard = isInitialBuild(self) ? self[$$$core]?.$globals.transmited : (self[$$$core].$root || {})[$$$core]?.$globals.transmited;
8655
+ const globalBoard = isInitialBuild(self) ? self[$$$core]?.$globals.transmited : (self[$$$core].$root || {})[$$$core]?.$globals.transmited || {};
8696
8656
  for (let [key, valueX] of getIterator(opts.receive)) {
8697
8657
  let keyName = isArray(opts.receive) ? valueX : key;
8698
8658
  if (!validateType(keyName, [String, Symbol])) {
@@ -8754,7 +8714,7 @@ function applyMixinMergeStrategy(self, options, mixins) {
8754
8714
  const store = {};
8755
8715
  for (const mx of mixins.toReversed().values()) {
8756
8716
  if (!validateType(mx, [Function, Object])) {
8757
- debugHandler(`[ ] [Houxit Mixin Merge Warn] Mixins expects a plain fuction/object instance/valid Houxit widget instance`, self, true);
8717
+ debugHandler(`[Houxit Mixin Merge Warn] Mixins expects a plain fuction/object instance/valid Houxit widget instance`, self, true);
8758
8718
  return;
8759
8719
  } else if (applied_mixins.has(mx)) continue;
8760
8720
  applied_mixins.prepend(mx);
@@ -9775,7 +9735,10 @@ function Render_Effect_Reactive_Transform(self, observer) {
9775
9735
  is_hyperscript,
9776
9736
  observer
9777
9737
  });
9778
- }).catch((e) => debugHandler(e));
9738
+ }).catch((e) => {
9739
+ console.error(e);
9740
+ debugHandler(e);
9741
+ });
9779
9742
  } catch (e) {
9780
9743
  RenderEffect_$Warn(self, e);
9781
9744
  }
@@ -10185,7 +10148,7 @@ function installTransformersArgumentations(self, child, hx_Element, vNode) {
10185
10148
  define(child[$$$core], "$root", { value: root });
10186
10149
  define(child[$$$core], "$parent", { value: hx_Element.compiler_options.parent });
10187
10150
  define(child[$$$core], "$owner", { value: self });
10188
- for (let [prop, content] of entries(root[$$$core].$globals.register)) child[$$$core].$globals.register[prop] = assign(child[$$$core].$globals.register[prop], content);
10151
+ for (let [prop, content] of entries(root?.[$$$core]?.$globals?.register || {})) child[$$$core].$globals.register[prop] = assign(child[$$$core].$globals.register[prop], content);
10189
10152
  }
10190
10153
  function resolveInstanceWidgetNormalizer(self, vNode) {
10191
10154
  const tagname = isBlockTag(vNode.type) ? getBlockTagName(vNode.type) : vNode.type;
@@ -10251,16 +10214,18 @@ function $compilerEngine(self, virtualNode, hx_Element, slotsCompilerArgs, confi
10251
10214
  virtualNode.filesFilter.useSSRCompiler = true;
10252
10215
  if (isHydration(self)) virtualNode.filesFilter.isHydration = true;
10253
10216
  }
10254
- return initializedRenderBuild(self, hx_Element, virtualNode).mount(_createFragment());
10217
+ return initializedRenderBuild(self, hx_Element, virtualNode, config).mount(_createFragment());
10255
10218
  }
10256
- function initializedRenderBuild(self, hx_Element, virtualNode) {
10219
+ function initializedRenderBuild(self, hx_Element, virtualNode, config) {
10257
10220
  const child = new HouxitBuild(virtualNode);
10221
+ child[$$$compiler].$$config = config;
10258
10222
  integrateUseInstallProto(child);
10259
10223
  if (hx_Element) hx_Element.widget_instance = child;
10260
10224
  if (self) {
10261
10225
  controllerHydration(self, child, hx_Element, virtualNode);
10262
10226
  child.install(controllerGlobalPlugin, { self });
10263
10227
  }
10228
+ if (config.isCustomElement) for (let callback of config.configureApp.values()) callback.call(config.element, child);
10264
10229
  return child;
10265
10230
  }
10266
10231
  function integrateUseInstallProto(self) {
@@ -10473,7 +10438,7 @@ function isDynamicPropTag(tag) {
10473
10438
  var isOpenEmptyTag = (tag) => /(\<[ ]*\>)/.test(tag);
10474
10439
  var isCloseEmptyTag = (tag) => /(\<\/[ ]*\>)/.test(tag);
10475
10440
  var openingTagsRegex = /(\<[ ]*\>|\<\/[ ]*\>)|(<(\/)?([\w\-\$!:\#\@.()[\]%?\/&]+)(\s+[^>]*?(?:(?:[\w]+[_!@#$'"%^&*()+\-\[\]{};:\\|,.<\/?~`]*)|(?:'[^']*'[^>\s]*)|(?:"[^"]*"[^>\s]*)))*\s*(\/)?>)|([\w \s!@#$'"%^&*()+\-\[\]{};:\\|,.>=\/?`~]+)/gm;
10476
- var openingTagRegex = /<([\w\-\$!:\#\@.()[\]%?&]+)(\s+[^>]*?(?:(?:[\w]+[_!@#$'"%^&*()+\-\[\]{};:\\|,.<\/?>=`~]*)|(?:'[^']*'[^>\s]*)|(?:"[^"]*"[^>\s]*)))*\s*(\/)?>/m;
10441
+ var openingTagRegex = /<([\w\-\$!:\#\@.()[\]%?&]+)(\s+[^>]*?(?:(?:[\w]+[_!@#$'"%^&*()+\-\[\]{};:\\|,.<\/?=`~]*)|(?:'[^']*'[^>\s]*)|(?:"[^"]*"[^>\s]*)))*\s*(\/)?>/m;
10477
10442
  var isOpeningTag = (source) => openingTagRegex.test(source);
10478
10443
  var closingTagRegex = /<[\/]([\w$.:\-\@()[\]%&?\\\/]+)[ ]*>/;
10479
10444
  var isClosingTag = (source) => closingTagRegex.test(source);
@@ -10482,7 +10447,7 @@ var openingTagAttrRegex = /^<[\w\-\$!\@:.()[\]%?&]+([\s\S]*[^\/>])?\s*(\/)?>\s*$
10482
10447
  var JSXParserRegex = /hx:\(\(__(\d)__\)\)/;
10483
10448
  var isOpeningCommentTag = (tag) => /<!-->/.test(tag);
10484
10449
  var isClosingCommentTag = (tag) => /<\/-->/.test(tag);
10485
- var commentRegex = /((<!--)|(-->))/g;
10450
+ var tempCommentRegex = /((<!--)|(-->))/g;
10486
10451
  function compelToResolveTagname(self, vNode, config = {}) {
10487
10452
  if (isHouxitBuild(self) && isString(vNode.type) && !IS_VALID_TAGNAME(vNode.type)) resolveInstanceWidgetNormalizer(self, vNode);
10488
10453
  else if (config.JSXParser && isString(vNode.type) && JSXParserRegex.test(vNode.type)) {
@@ -10535,7 +10500,7 @@ function normalize_jsx_props(vnode, config) {
10535
10500
  else if (JSXParserRegex.test(value)) {
10536
10501
  const instance = normalizeJSXPropValue(config, key);
10537
10502
  if (!isString(instance)) {
10538
- debugHandler(`[ ] property key value passed to the "html" macro is not a valid prop name\n\ntype of "${typeof instance}" found >>>> Expects a "string" value`);
10503
+ debugHandler(`[ ] property key value passed to the "htx" macro is not a valid prop name\n\ntype of "${typeof instance}" found >>>> Expects a "string" value`);
10539
10504
  return;
10540
10505
  }
10541
10506
  vnode.props[instance] = vnode.props[key];
@@ -10612,7 +10577,7 @@ function openingTagHydrate(tagMatch, NodeList, setup, metrics) {
10612
10577
  function parserSourceInitializer(source, self) {
10613
10578
  return source.replace(generateBlockTagRegex(isHouxitBuild(self) ? self[$$$core].settings.delimiters : void 0), (match, timing, ClosingTag, name, value, selfClosed) => {
10614
10579
  return `<${ClosingTag === "/" ? "/" : ""}::@_(${name})_ ${ClosingTag === "@" ? "exp=\"" + escapeDecoder(value) + "\"" : ""} ${selfClosed ? "/" : ""}>`;
10615
- }).replace(commentRegex, (match, path, r) => /<!--/.test(match) ? "<!-->" : /-->/.test(match) ? "</-->" : match);
10580
+ }).replace(tempCommentRegex, (match, path, r) => /<!--/.test(match) ? "<!-->" : /-->/.test(match) ? "</-->" : match);
10616
10581
  }
10617
10582
  function __HouxitHTMLParser__(source, NodeList = [], config = {}, self) {
10618
10583
  if (!isString(source) && !source.trim()) return !isArray(NodeList) ? [] : NodeList;
@@ -11125,7 +11090,7 @@ function blockConstPreprocessor(self, node, blockN, metrics, [children, exp], co
11125
11090
  debugHandler(`[ ] "${variable}" is an invalid identifier`, self, true);
11126
11091
  return [];
11127
11092
  }
11128
- const data = _$runModelBind(self, expression?.trim(), hx_Element || context);
11093
+ let data = _$runModelBind(self, expression?.trim(), hx_Element || context);
11129
11094
  if (isDestructureSyntax(variable)) {
11130
11095
  if (isFalse(destructWarn(variable, data, self))) return [];
11131
11096
  smartDextCtxMerging(fall, { [$$dexTransformKey]: {
@@ -11174,12 +11139,12 @@ function blockForProcessor(self, node, blockN, metrics, [children, exp], isWidge
11174
11139
  count: index
11175
11140
  }, options);
11176
11141
  else if (!is_hyperscript) {
11177
- if (isForLoopDestructureRegex.test(provide.value)) provide.value = "[" + provide.value.slice(1, -1) + "]";
11178
- options = wrapNamespaceBind(self, options, provide.value, arrayDestructureRegex.test(provide.value) ? loopState : loopState[0]);
11142
+ if (isForLoopDestructureRegex.test(provide?.value)) provide.value = "[" + provide.value.slice(1, -1) + "]";
11143
+ options = wrapNamespaceBind(self, options, provide?.value, arrayDestructureRegex.test(provide?.value) ? loopState : loopState[0]);
11179
11144
  }
11180
11145
  config.loop_context = loopState;
11181
11146
  const createElement = () => {
11182
- let src = children.map((child) => factoryRender(options, config, safeCall(child, loopState))).filter((v) => isHouxitElement(v));
11147
+ let src = children.map((child) => factoryRender(options, config, safeCall(child, ...loopState))).filter((v) => isHouxitElement(v));
11183
11148
  src = len(src) < 2 ? src[0] : new HouxitFragmentElement(src, self, hx_Element, null, value);
11184
11149
  return src;
11185
11150
  };
@@ -11466,12 +11431,12 @@ function normalizePreJSXFormat(strings, values) {
11466
11431
  }
11467
11432
  return __HouxitHTMLParser__(boundJoin.join(""), [], { JSXParser: { sources: values } });
11468
11433
  }
11469
- function html(strings, ...values) {
11434
+ function htx(strings, ...values) {
11470
11435
  return __EncodeJSXParser__(strings, values);
11471
11436
  }
11472
11437
  function __EncodeJSXParser__(strings, values) {
11473
11438
  if (!isFunction(strings.reduce)) {
11474
- debugHandler(`[ ] html macro can only be called with backticks embeded directly to method name\n\n"html\`<templates>\`" instead of "html()"\nCheck html macro call`);
11439
+ debugHandler(`[ ] htx macro can only be called with backticks embeded directly to method name\n\n"htx\`<templates>\`" instead of "htx()"\nCheck htx macro call`);
11475
11440
  return;
11476
11441
  }
11477
11442
  if (len(values)) return normalizePreJSXFormat(strings, values);
@@ -11480,13 +11445,15 @@ function __EncodeJSXParser__(strings, values) {
11480
11445
  return acc + str + value;
11481
11446
  }, "");
11482
11447
  if (!isString(html)) {
11483
- debugHandler(`[ ] html parser macro expects strings values`);
11448
+ debugHandler(`[ ] htx parser macro expects strings values`);
11484
11449
  return null;
11485
11450
  }
11486
11451
  return __HouxitHTMLParser__(html, [], { trim: true }, null);
11487
11452
  }
11488
- function MKDParser(mkd) {}
11489
- function markdown(mkd, ...values) {
11453
+ function MKDParser(mkd) {
11454
+ return MKDParser(mkd);
11455
+ }
11456
+ function mdx(mkd, ...values) {
11490
11457
  if (!isString(mkd)) {
11491
11458
  debugHandler(`[ ] markdown helper expects strings values`);
11492
11459
  return null;
@@ -11495,76 +11462,158 @@ function markdown(mkd, ...values) {
11495
11462
  function createCustomElement(options) {
11496
11463
  return _createCustomElement.call({}, ...arguments);
11497
11464
  }
11498
- function generateCustomNativeElementConstructor() {
11465
+ function __observeAttributes() {
11466
+ this.__attributeObserver = new MutationObserver((mutations) => {
11467
+ for (const mutation of mutations) {
11468
+ if (mutation.type !== "attributes") continue;
11469
+ const name = mutation.attributeName;
11470
+ const newValue = this.getAttribute(name);
11471
+ const oldValue = mutation.oldValue;
11472
+ if (oldValue === newValue) continue;
11473
+ __widget_props_effect(this.__app, {
11474
+ value: oldValue,
11475
+ effect: newValue,
11476
+ key: name
11477
+ });
11478
+ }
11479
+ });
11480
+ }
11481
+ function generateCustomNativeElementConstructor(setup, self) {
11499
11482
  if (!inBrowserCompiler) return;
11500
- return class CustomNativeElement extends HTMLElement {
11483
+ return class HouxitCustomElement extends HTMLElement {
11501
11484
  constructor() {
11502
11485
  super();
11486
+ __observeAttributes.call(this);
11487
+ }
11488
+ static get observedAttributes() {
11489
+ return [];
11490
+ }
11491
+ __app = void 0;
11492
+ get __eventsMap() {
11493
+ return new Tuple();
11494
+ }
11495
+ addEventListener(e, h, o) {
11496
+ const customEvents = this._hx_Element.hx_Element.VNodeManager.customEvents;
11497
+ if (!hasOwn(customEvents, e)) customEvents[e] = new HouxitEvents(e, { target_value: this });
11498
+ return super.addEventListener(e, h, o);
11499
+ }
11500
+ dispatchEvent(e) {
11501
+ return super.dispatchEvent(e);
11503
11502
  }
11504
- compiler_options = {};
11505
- _set_compiler_options(...compiler_options) {
11506
- this.compiler_options = compiler_options;
11503
+ connectedCallback(...args) {
11504
+ for (let hooks of setup.connected.values()) hooks.call(this, ...args);
11505
+ }
11506
+ disConnectedCallback(...args) {
11507
+ for (let hooks of setup.disconnected.values()) hooks.call(this, ...args);
11508
+ }
11509
+ adoptedCallback(...args) {
11510
+ for (let hooks of setup.adopted.values()) hooks.call(this, ...args);
11511
+ }
11512
+ attributeChangedCallback(...args) {
11513
+ for (let hooks of setup.attrChanged.values()) hooks.call(this, ...args);
11507
11514
  }
11508
11515
  };
11509
11516
  }
11510
- function generateCustomElementConstructor(name) {
11517
+ function generateCustomElementConstructor(name, HouxitCustomElement) {
11511
11518
  name = ToPascalCase(name);
11512
11519
  if (!isValidIdentifier(name)) {
11513
11520
  debugHandler(`[ ] unable to parse the customElements tag name\n\n
11514
11521
  seems to have been an invalid identifier`);
11515
11522
  return;
11516
11523
  }
11517
- return Function("CustomNativeElement", `
11518
- return class ${name} extends CustomNativeElement{
11524
+ return Function("HouxitCustomElement", `
11525
+ return class ${name} extends HouxitCustomElement{
11519
11526
  constructor(){
11520
11527
  super(...arguments);
11521
11528
  }
11522
11529
  }
11523
- `)(CustomNativeElement);
11524
- }
11525
- function _createCustomElement(opts) {
11530
+ `)(HouxitCustomElement);
11531
+ }
11532
+ var configOpts = {
11533
+ shadowMode: [String, Boolean],
11534
+ nonce: String,
11535
+ configureElement: Function,
11536
+ configureApp: Function,
11537
+ connected: Function,
11538
+ adopted: Function,
11539
+ attrChanged: Function,
11540
+ disconnected: Function
11541
+ };
11542
+ var ce_lch = "connected,disconnected,adopted,attrChanged,configureApp,configureElement";
11543
+ function _createCustomElement(opts, config) {
11526
11544
  this.is_Custom_Node = true;
11527
11545
  if (!validateCollectionArgs(arguments, {
11528
- count: 1,
11529
- validators: [[Function, Object]],
11546
+ min: 1,
11547
+ max: 2,
11548
+ validators: [[Function, Object], Object],
11530
11549
  name: "createCustomElement"
11531
11550
  })) return;
11532
- const LifeCycleHooksList = "onConnected,onDisconnected,onAdopted,onAttrChanged,plugin";
11533
- let Hooks = {};
11534
- entries(defineWidget(opts)).forEach(([ind, value]) => {
11535
- if (_makeMap_(LifeCycleHooksList, ind)) {
11536
- if (!isFunction(value)) {
11537
- debugHandler(`[ ] LifeCycle callback error\n\n"${ind}" is a callback function, received an invalid type`);
11538
- return;
11539
- }
11540
- if (ind != "plugin") Hooks[ind] = value;
11541
- delete opts[ind];
11551
+ const setup = {
11552
+ connected: [],
11553
+ disconnected: [],
11554
+ adopted: [],
11555
+ attrChanged: [],
11556
+ configureApp: [],
11557
+ configureElement: []
11558
+ };
11559
+ for (let [name, type] of entries(configOpts)) {
11560
+ if (!hasOwn(config, name)) continue;
11561
+ const value = config[name];
11562
+ if (!validateType(value, type)) {
11563
+ debugHandler(`[ createCustomElement options ] customElements config options fails to meet type validation\n"${name}" option`);
11564
+ continue;
11542
11565
  }
11543
- });
11544
- const CustomNativeElement = generateCustomNativeElementConstructor();
11545
- CustomNativeElement.prototype.disConnectedCallback = Hooks.disConnectedCallback || pass;
11546
- CustomNativeElement.prototype.adoptedCallback = Hooks.adoptedCallback || pass;
11547
- CustomNativeElement.prototype.attributeChangedCallback = Hooks.attributeChangedCallback || pass;
11548
- CustomNativeElement.prototype.connectedCallback = connectedCallback;
11566
+ if (name === "shadowMode" && isString(value) && !_makeMap_("closed,open", value)) debugHandler(`"shadowMode" config option of createCustomElement expects only valid type of 'open' | 'closed'\n\nmay output Unexpected result`);
11567
+ if (_makeMap_(ce_lch, name)) setup[name].push(value);
11568
+ }
11569
+ let { shadowMode = "open", nonce = "" } = config || {};
11570
+ const HouxitCustomElement = generateCustomNativeElementConstructor(setup);
11549
11571
  function connectedCallback() {
11550
11572
  let props = {};
11573
+ const compiler_options = {};
11551
11574
  if (len(keys(this.attributes))) for (const [key, attr] of entries(this.attributes)) {
11552
- const { name, value } = attr;
11575
+ let { name, value } = attr;
11576
+ if (isOnListener(name)) {
11577
+ const customEvents = this._hx_Element.hx_Element.VNodeManager.customEvents;
11578
+ name = name.slice(2);
11579
+ if (!hasOwn(customEvents, name)) customEvents[name] = new HouxitEvents(name, { target_value: this });
11580
+ continue;
11581
+ }
11553
11582
  props[name] = value;
11554
11583
  }
11555
- let [vnode, self, hx_Element, siblings, IS_RENDERLESS, customElementsArgs] = this.compiler_options;
11556
- const shadow = this.attachShadow({ mode: "open" });
11557
- vnode = h(opts, assign(props, vnode.props || {}), vnode.children);
11558
- customElementsArgs.unshift();
11559
- const createElement = () => $compilerEngine(null, vnode, null, {}).$build;
11584
+ let shadow;
11585
+ if (isBoolean(shadowMode)) if (!shadowMode) shadowMode = "closed";
11586
+ else shadowMode = "open";
11587
+ if (isString(shadowMode)) shadow = this.attachShadow({ mode: shadowMode });
11588
+ let vnode = h(opts, props);
11589
+ const createElement = () => {
11590
+ return $compilerEngine(null, vnode, null, {}, {
11591
+ isCustomElement: true,
11592
+ element: this,
11593
+ shadow,
11594
+ compiler_options,
11595
+ configureApp: setup.configureApp
11596
+ }).$build;
11597
+ };
11598
+ setup.configureApp.unshift(function(app) {
11599
+ defineGetter(this, "__app", app);
11600
+ });
11560
11601
  const template = createElement();
11561
11602
  shadow.appendChild(template.$element);
11562
- (Hooks.connectedCallback || pass).call(this, ...arguments);
11603
+ this.__attributeObserver.observe(this, {
11604
+ attributes: true,
11605
+ attributeOldValue: true
11606
+ });
11563
11607
  }
11564
- CustomNativeElement.define = function define(name, inherit) {
11565
- return __define.call(this, ...arguments);
11608
+ setup.connected.unshift(connectedCallback);
11609
+ setup.disconnected.unshift(function() {
11610
+ this.__attributeObserver.disconnect();
11611
+ });
11612
+ for (let hks of setup.configureElement.values()) hks.call(this);
11613
+ HouxitCustomElement.define = function define(name, inherit) {
11614
+ return __define.call(this, name, inherit, HouxitCustomElement);
11566
11615
  };
11567
- function __define(name, inherit) {
11616
+ function __define(name, inherit, HouxitCustomElement) {
11568
11617
  if (!validateCollectionArgs(arguments, {
11569
11618
  name: "customElements.define()",
11570
11619
  min: 1,
@@ -11576,15 +11625,15 @@ function _createCustomElement(opts) {
11576
11625
  return;
11577
11626
  }
11578
11627
  if (inherit && !isString(inherit) && !IS_HTML_TAG(inherit)) {
11579
- debugHandler(`[ ] problem with the inherit value, \n\n may not be a string value or a valid HTML tagName`);
11628
+ debugHandler(`[ ] problem with the inherit value, \n\n may not be a string value or a valid HTML tagName signature`);
11580
11629
  debugHandler(`[ ] CustomElement registration failed`);
11581
11630
  return;
11582
11631
  }
11583
- const CustomElementsInstance = generateCustomElementConstructor(name);
11632
+ const CustomElementsInstance = generateCustomElementConstructor(name, HouxitCustomElement);
11584
11633
  if (inBrowserCompiler) customElements.define(name, CustomElementsInstance, inherit ? { extends: inherit } : {});
11585
11634
  return CustomElementsInstance;
11586
11635
  }
11587
- return CustomNativeElement;
11636
+ return HouxitCustomElement;
11588
11637
  }
11589
11638
  function _asyncWidget(callback, config) {
11590
11639
  if (!validateCollectionArgs(arguments, {
@@ -11659,7 +11708,7 @@ function createSSRStreamHack(vnodePlate, ssrConfig) {
11659
11708
  }
11660
11709
  function _renderToStringCompiler(build, config) {
11661
11710
  if (!isSSRCompiler(build)) {
11662
- debugHandler(`[ ] "renderToString" macro was called on a non SSR renderer build...\n\nplease check, you may have used "initBuild" app initializer instead of the "initSSRBuild"`);
11711
+ debugHandler(`[ ] "renderToString" macro was called on a non SSR App build...\n\nuse "initSSRBuild" instead for an SSR App`);
11663
11712
  return;
11664
11713
  }
11665
11714
  return new Promise((resolve) => {
@@ -11702,6 +11751,11 @@ function compileSSRProps(props, ctx) {
11702
11751
  else src += " " + key + (value.trim() ? "=\"" + value + "\"" : "");
11703
11752
  return src;
11704
11753
  }
11754
+ function renderToNodeStream(app) {}
11755
+ function renderToNodeWritable(app, writable) {}
11756
+ function renderToWebWritable(app, writable) {}
11757
+ function renderToWebStream(app) {}
11758
+ function renderToSimpleStream(app, cbs) {}
11705
11759
  function _createInitSSRBuild_(options, props, children) {
11706
11760
  const vNode = createSSRStreamHack(arguments, {
11707
11761
  type: "stream",
@@ -11794,6 +11848,7 @@ exports.Any = Any;
11794
11848
  exports.Arguments = Arguments;
11795
11849
  exports.Build = Build;
11796
11850
  exports.Class = Class;
11851
+ exports.CompilerConfigOptions = CompilerConfigOptions;
11797
11852
  exports.Else = Else;
11798
11853
  exports.ElseIf = ElseIf;
11799
11854
  exports.Exception = Exception;
@@ -11801,7 +11856,6 @@ exports.For = For;
11801
11856
  exports.Fragment = Fragment;
11802
11857
  exports.HTMLParser = HTMLParser;
11803
11858
  exports.HTMLPropsParser = HTMLPropsParser;
11804
- exports.HouxitCompilerSetup = HouxitCompilerSetup;
11805
11859
  exports.If = If;
11806
11860
  exports.MKDParser = MKDParser;
11807
11861
  exports.Memo = Memo;
@@ -11856,7 +11910,7 @@ exports.generateTemplateElement = generateTemplateElement;
11856
11910
  exports.generateUUID = generateUUID;
11857
11911
  exports.get_version = get_version;
11858
11912
  exports.h = h;
11859
- exports.html = html;
11913
+ exports.htx = htx;
11860
11914
  exports.initBuild = initBuild;
11861
11915
  exports.initSSRBuild = initSSRBuild;
11862
11916
  exports.isComputed = isComputed;
@@ -11874,7 +11928,7 @@ exports.isToken = isToken;
11874
11928
  exports.len = len;
11875
11929
  exports.log = log;
11876
11930
  exports.markRaw = markRaw;
11877
- exports.markdown = markdown;
11931
+ exports.mdx = mdx;
11878
11932
  exports.memMove = memMove;
11879
11933
  exports.mergeProps = mergeProps;
11880
11934
  exports.observe = observe;
@@ -11895,7 +11949,12 @@ exports.raise = raise;
11895
11949
  exports.read = read;
11896
11950
  exports.readonly = readonly;
11897
11951
  exports.readonlyStream = readonlyStream;
11952
+ exports.renderToNodeStream = renderToNodeStream;
11953
+ exports.renderToNodeWritable = renderToNodeWritable;
11954
+ exports.renderToSimpleStream = renderToSimpleStream;
11898
11955
  exports.renderToString = renderToString;
11956
+ exports.renderToWebStream = renderToWebStream;
11957
+ exports.renderToWebWritable = renderToWebWritable;
11899
11958
  exports.resolve = resolve;
11900
11959
  exports.scaffold = scaffold;
11901
11960
  exports.scopeEffectHook = scopeEffectHook;