xmlui 0.12.0 → 0.12.1

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.
Files changed (30) hide show
  1. package/dist/bin/index.cjs +83 -13
  2. package/dist/bin/index.js +83 -13
  3. package/dist/for-node/server.cjs +1697 -161
  4. package/dist/for-node/server.js +1697 -161
  5. package/dist/for-node/vite-xmlui-plugin.cjs +83 -13
  6. package/dist/for-node/vite-xmlui-plugin.js +83 -13
  7. package/dist/lib/{index-Cs7rzX4T.js → index-CkXI-l7q.js} +3526 -1330
  8. package/dist/lib/index.css +1 -1
  9. package/dist/lib/{initMock-CmOpUIn_.js → initMock-eOGDnKDO.js} +1 -2
  10. package/dist/lib/{parser-DEHgOMKO.js → parser-Ck-3ozza.js} +114 -60
  11. package/dist/lib/testing.d.ts +3 -1
  12. package/dist/lib/testing.js +25 -36
  13. package/dist/lib/xmlui-parser-CZxYIZ3q.js +514 -0
  14. package/dist/lib/xmlui-parser.d.ts +6 -0
  15. package/dist/lib/xmlui-parser.js +2 -2
  16. package/dist/lib/{xmlui-serializer-hAJ-Pkue.js → xmlui-serializer-DJVLKVvd.js} +1 -1
  17. package/dist/lib/xmlui.d.ts +2 -0
  18. package/dist/lib/xmlui.js +49 -49
  19. package/dist/metadata/{collectedComponentMetadata-vOpwNII7.js → collectedComponentMetadata-CJco9icn.js} +1378 -1004
  20. package/dist/metadata/collectedComponentMetadata-DCnnMRrp.cjs +1 -0
  21. package/dist/metadata/{initMock-DJM88IlG.js → initMock-Cpy_qJ1V.js} +1 -1
  22. package/dist/metadata/{initMock-D_8ZZjLI.cjs → initMock-bKw7EX8i.cjs} +1 -1
  23. package/dist/metadata/xmlui-metadata.cjs +1 -1
  24. package/dist/metadata/xmlui-metadata.js +1 -1
  25. package/dist/metadata/xmlui.css +1 -1
  26. package/dist/standalone/xmlui-standalone.es.d.ts +2 -0
  27. package/dist/standalone/xmlui-standalone.umd.js +33 -33
  28. package/package.json +2 -2
  29. package/dist/lib/eval-tree-sync-D_BySw4Z.js +0 -2271
  30. package/dist/metadata/collectedComponentMetadata-DLqq5IL3.cjs +0 -1
@@ -5596,16 +5596,22 @@ var Parser = class {
5596
5596
  * @param stump Stump properties
5597
5597
  * @param startToken The token that starts the expression
5598
5598
  * @param endToken The token that ends the expression
5599
- * @param source Expression source code to store to the node
5600
5599
  */
5601
5600
  createExpressionNode(type, stump = {}, startToken, endToken) {
5602
5601
  if (!endToken) endToken = this._lexer.peek();
5603
5602
  if (!startToken) startToken = endToken;
5603
+ let source;
5604
+ if (startToken && endToken && this._lexer.input.source) {
5605
+ const startPos = startToken.startPosition;
5606
+ const endPos = endToken.endPosition;
5607
+ if (startPos <= endPos) source = this._lexer.input.source.substring(startPos, endPos);
5608
+ }
5604
5609
  return Object.assign({}, stump, {
5605
5610
  type,
5606
5611
  nodeId: createXmlUiTreeNodeId(),
5607
5612
  startToken,
5608
- endToken
5613
+ endToken,
5614
+ source
5609
5615
  });
5610
5616
  }
5611
5617
  /**
@@ -7103,7 +7109,8 @@ function collectStatementFromModule(stmt, result, collectedFunctions) {
7103
7109
  if (decl.id.name in result.vars) throw new Error(`Duplicated var declaration: '${decl.id.name}'`);
7104
7110
  result.vars[decl.id.name] = {
7105
7111
  [PARSED_MARK_PROP]: true,
7106
- tree: decl.expr
7112
+ tree: decl.expr,
7113
+ source: decl.expr?.source || null
7107
7114
  };
7108
7115
  });
7109
7116
  break;
@@ -7703,6 +7710,7 @@ const ErrCodesTransform = {
7703
7710
  nsValueIncorrect: "T028",
7704
7711
  nsSchemeIncorrect: "T029",
7705
7712
  scriptParse: "T030",
7713
+ globalNotAllowedInNested: "T031",
7706
7714
  ...ErrorCodes
7707
7715
  };
7708
7716
  const DIAGS_TRANSFORM = {
@@ -7788,6 +7796,10 @@ const DIAGS_TRANSFORM = {
7788
7796
  code: ErrCodesTransform.cannotMixFieldItem,
7789
7797
  message: "Cannot mix 'field' and 'item' nodes within an element."
7790
7798
  },
7799
+ globalNotAllowedInNested: {
7800
+ code: ErrCodesTransform.globalNotAllowedInNested,
7801
+ message: "Global variables can only be declared in the root element or compound component definitions, not in nested regular components."
7802
+ },
7791
7803
  cantHaveNameAttr: function(nodeName) {
7792
7804
  return {
7793
7805
  code: ErrCodesTransform.cantHaveNameAttr,
@@ -8178,6 +8190,7 @@ const HelperNode = {
8178
8190
  template: "template",
8179
8191
  event: "event",
8180
8192
  variable: "variable",
8193
+ global: "global",
8181
8194
  loaders: "loaders",
8182
8195
  uses: "uses",
8183
8196
  method: "method",
@@ -8204,11 +8217,11 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8204
8217
  fileId
8205
8218
  } }
8206
8219
  };
8207
- collectTraits(usesStack$1, component, node$1);
8220
+ collectTraits(usesStack$1, component, node$1, true);
8208
8221
  hoistScriptCollectedFromFragments(component);
8209
8222
  return component;
8210
8223
  }
8211
- function transformInnerElement(usesStack$1, node$1) {
8224
+ function transformInnerElement(usesStack$1, node$1, allowGlobalVars = false) {
8212
8225
  const name = getNamespaceResolvedComponentName(node$1, getText, namespaceStack);
8213
8226
  if (name === COMPOUND_COMP_ID) reportError(DIAGS_TRANSFORM.nestedCompDefs);
8214
8227
  let component = {
@@ -8219,7 +8232,7 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8219
8232
  fileId
8220
8233
  } }
8221
8234
  };
8222
- collectTraits(usesStack$1, component, node$1);
8235
+ collectTraits(usesStack$1, component, node$1, allowGlobalVars);
8223
8236
  hoistScriptCollectedFromFragments(component);
8224
8237
  return component;
8225
8238
  }
@@ -8245,24 +8258,38 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8245
8258
  vars[attr.name] = attr.value;
8246
8259
  });
8247
8260
  }
8261
+ let globals;
8262
+ const globalsAttrs = attrs.filter((attr) => attr.startSegment === "global");
8263
+ if (globalsAttrs.length > 0) {
8264
+ globals = {};
8265
+ globalsAttrs.forEach((attr) => {
8266
+ globals[attr.name] = attr.value;
8267
+ });
8268
+ }
8248
8269
  const children = getChildNodes(node$1);
8249
8270
  const nestedComponents = children.filter((child) => child.kind === SyntaxKind.ElementNode && !(getComponentName(child, getText) in HelperNode));
8250
8271
  if (nestedComponents.length === 0) nestedComponents.push(createTextNodeElement(""));
8251
8272
  const nonVarHelperNodes = [];
8252
8273
  const nestedVars = [];
8274
+ const nestedGlobals = [];
8253
8275
  for (let child of children) if (child.kind === SyntaxKind.ElementNode) {
8254
8276
  const childName = getComponentName(child, getText);
8255
8277
  if (childName === HelperNode.variable) nestedVars.push(child);
8278
+ else if (childName === HelperNode.global) nestedGlobals.push(child);
8256
8279
  else if (childName in HelperNode) nonVarHelperNodes.push(child);
8257
8280
  }
8258
8281
  let element;
8259
- if (nestedComponents.length > 1 || nestedVars.length > 0) element = wrapWithFragment([...nestedVars, ...nestedComponents]);
8282
+ if (nestedComponents.length > 1 || nestedVars.length > 0 || nestedGlobals.length > 0) element = wrapWithFragment([
8283
+ ...nestedVars,
8284
+ ...nestedGlobals,
8285
+ ...nestedComponents
8286
+ ]);
8260
8287
  else element = nestedComponents[0];
8261
8288
  namespaceStack.push(/* @__PURE__ */ new Map());
8262
8289
  attrs.filter((attr) => attr.namespace === "xmlns").forEach((attr) => {
8263
8290
  addToNamespaces(namespaceStack, element, attr.unsegmentedName, attr.value);
8264
8291
  });
8265
- let nestedComponent = transformInnerElement(usesStack, element);
8292
+ let nestedComponent = transformInnerElement(usesStack, element, true);
8266
8293
  namespaceStack.pop();
8267
8294
  const component = {
8268
8295
  name: compoundName.value,
@@ -8278,26 +8305,31 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8278
8305
  ...nestedComponent.vars,
8279
8306
  ...vars
8280
8307
  };
8308
+ if (globals) nestedComponent.globalVars = {
8309
+ ...nestedComponent.globalVars,
8310
+ ...globals
8311
+ };
8281
8312
  if (codeBehind) component.codeBehind = codeBehind.value;
8282
8313
  nestedComponent.debug = { source: {
8283
8314
  start: element.start,
8284
8315
  end: element.end,
8285
8316
  fileId
8286
8317
  } };
8287
- collectTraits(usesStack, component, withNewChildNodes(node$1, nonVarHelperNodes));
8318
+ collectTraits(usesStack, component, withNewChildNodes(node$1, nonVarHelperNodes), false);
8288
8319
  return component;
8289
8320
  }
8290
8321
  /**
8291
8322
  * Collects component traits from attributes and child elements
8292
8323
  * @param comp Component definition
8293
8324
  * @param element Component element
8325
+ * @param allowGlobalVars Whether global variables are allowed in this context
8294
8326
  */
8295
- function collectTraits(usesStack$1, comp, element) {
8327
+ function collectTraits(usesStack$1, comp, element, allowGlobalVars = false) {
8296
8328
  const isCompound = !isComponent(comp);
8297
8329
  const attributes = getAttributes(element);
8298
8330
  namespaceStack.push(/* @__PURE__ */ new Map());
8299
8331
  attributes.forEach((attr) => {
8300
- collectAttribute(comp, attr);
8332
+ collectAttribute(comp, attr, allowGlobalVars);
8301
8333
  });
8302
8334
  const childNodes = getChildNodes(element);
8303
8335
  let hasScriptNode = false;
@@ -8348,6 +8380,17 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8348
8380
  comp.vars[name] = value;
8349
8381
  });
8350
8382
  return;
8383
+ case HelperNode.global:
8384
+ if (!allowGlobalVars) {
8385
+ reportError(DIAGS_TRANSFORM.globalNotAllowedInNested);
8386
+ return;
8387
+ }
8388
+ collectElementHelper(usesStack$1, comp, child, (name) => isComponent(comp) ? comp.globalVars?.[name] : void 0, (name, value) => {
8389
+ if (!isComponent(comp)) return;
8390
+ comp.globalVars ??= {};
8391
+ comp.globalVars[name] = value;
8392
+ });
8393
+ return;
8351
8394
  case "loaders":
8352
8395
  collectLoadersElements(usesStack$1, comp, child);
8353
8396
  return;
@@ -8367,12 +8410,12 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8367
8410
  });
8368
8411
  namespaceStack.pop();
8369
8412
  }
8370
- function collectAttribute(comp, attr) {
8413
+ function collectAttribute(comp, attr, allowGlobalVars = false) {
8371
8414
  const { namespace, startSegment, name, value, unsegmentedName: nsKey } = segmentAttr(attr);
8372
8415
  const attrValueStringNode = attr.children[2];
8373
8416
  if (namespace === "xmlns") return addToNamespaces(namespaceStack, comp, nsKey, value);
8374
8417
  if (!isComponent(comp)) {
8375
- if (startSegment && startSegment !== "method" && startSegment !== "var") {
8418
+ if (startSegment && startSegment !== "method" && startSegment !== "var" && startSegment !== "global") {
8376
8419
  reportError(DIAGS_TRANSFORM.invalidReusableCompAttr(nsKey));
8377
8420
  return;
8378
8421
  }
@@ -8398,6 +8441,13 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8398
8441
  if (startSegment === "var") {
8399
8442
  comp.vars ??= {};
8400
8443
  comp.vars[name] = value;
8444
+ } else if (startSegment === "global") {
8445
+ if (!allowGlobalVars) {
8446
+ reportError(DIAGS_TRANSFORM.globalNotAllowedInNested);
8447
+ return;
8448
+ }
8449
+ comp.globalVars ??= {};
8450
+ comp.globalVars[name] = value;
8401
8451
  } else if (startSegment === "method") {
8402
8452
  comp.api ??= {};
8403
8453
  comp.api[name] = value;
@@ -10033,6 +10083,26 @@ function viteXmluiPlugin(pluginOptions = {}) {
10033
10083
  };
10034
10084
  }
10035
10085
  return null;
10086
+ },
10087
+ handleHotUpdate({ file, server }) {
10088
+ const normalizedFile = normalizePath(file);
10089
+ const isXmluiFile = xmluiExtension.test(normalizedFile);
10090
+ const isXsFile = xmluiScriptExtension.test(normalizedFile) || moduleScriptExtension.test(normalizedFile);
10091
+ if (isXmluiFile || isXsFile) {
10092
+ clearAllModuleCaches();
10093
+ if (isXsFile) {
10094
+ this.warn(`[vite-xmlui-plugin] Processing updated script file: ${file}`);
10095
+ const allModules = Array.from(server.moduleGraph.idToModuleMap.values());
10096
+ for (const mod of allModules) server.moduleGraph.invalidateModule(mod);
10097
+ server.ws.send({
10098
+ type: "full-reload",
10099
+ path: "*"
10100
+ });
10101
+ return [];
10102
+ }
10103
+ const module$1 = server.moduleGraph.getModuleById(normalizedFile);
10104
+ if (module$1) return [module$1];
10105
+ }
10036
10106
  }
10037
10107
  };
10038
10108
  }
package/dist/bin/index.js CHANGED
@@ -5583,16 +5583,22 @@ var Parser = class {
5583
5583
  * @param stump Stump properties
5584
5584
  * @param startToken The token that starts the expression
5585
5585
  * @param endToken The token that ends the expression
5586
- * @param source Expression source code to store to the node
5587
5586
  */
5588
5587
  createExpressionNode(type, stump = {}, startToken, endToken) {
5589
5588
  if (!endToken) endToken = this._lexer.peek();
5590
5589
  if (!startToken) startToken = endToken;
5590
+ let source;
5591
+ if (startToken && endToken && this._lexer.input.source) {
5592
+ const startPos = startToken.startPosition;
5593
+ const endPos = endToken.endPosition;
5594
+ if (startPos <= endPos) source = this._lexer.input.source.substring(startPos, endPos);
5595
+ }
5591
5596
  return Object.assign({}, stump, {
5592
5597
  type,
5593
5598
  nodeId: createXmlUiTreeNodeId(),
5594
5599
  startToken,
5595
- endToken
5600
+ endToken,
5601
+ source
5596
5602
  });
5597
5603
  }
5598
5604
  /**
@@ -7090,7 +7096,8 @@ function collectStatementFromModule(stmt, result, collectedFunctions) {
7090
7096
  if (decl.id.name in result.vars) throw new Error(`Duplicated var declaration: '${decl.id.name}'`);
7091
7097
  result.vars[decl.id.name] = {
7092
7098
  [PARSED_MARK_PROP]: true,
7093
- tree: decl.expr
7099
+ tree: decl.expr,
7100
+ source: decl.expr?.source || null
7094
7101
  };
7095
7102
  });
7096
7103
  break;
@@ -7690,6 +7697,7 @@ const ErrCodesTransform = {
7690
7697
  nsValueIncorrect: "T028",
7691
7698
  nsSchemeIncorrect: "T029",
7692
7699
  scriptParse: "T030",
7700
+ globalNotAllowedInNested: "T031",
7693
7701
  ...ErrorCodes
7694
7702
  };
7695
7703
  const DIAGS_TRANSFORM = {
@@ -7775,6 +7783,10 @@ const DIAGS_TRANSFORM = {
7775
7783
  code: ErrCodesTransform.cannotMixFieldItem,
7776
7784
  message: "Cannot mix 'field' and 'item' nodes within an element."
7777
7785
  },
7786
+ globalNotAllowedInNested: {
7787
+ code: ErrCodesTransform.globalNotAllowedInNested,
7788
+ message: "Global variables can only be declared in the root element or compound component definitions, not in nested regular components."
7789
+ },
7778
7790
  cantHaveNameAttr: function(nodeName) {
7779
7791
  return {
7780
7792
  code: ErrCodesTransform.cantHaveNameAttr,
@@ -8165,6 +8177,7 @@ const HelperNode = {
8165
8177
  template: "template",
8166
8178
  event: "event",
8167
8179
  variable: "variable",
8180
+ global: "global",
8168
8181
  loaders: "loaders",
8169
8182
  uses: "uses",
8170
8183
  method: "method",
@@ -8191,11 +8204,11 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8191
8204
  fileId
8192
8205
  } }
8193
8206
  };
8194
- collectTraits(usesStack$1, component, node$1);
8207
+ collectTraits(usesStack$1, component, node$1, true);
8195
8208
  hoistScriptCollectedFromFragments(component);
8196
8209
  return component;
8197
8210
  }
8198
- function transformInnerElement(usesStack$1, node$1) {
8211
+ function transformInnerElement(usesStack$1, node$1, allowGlobalVars = false) {
8199
8212
  const name = getNamespaceResolvedComponentName(node$1, getText, namespaceStack);
8200
8213
  if (name === COMPOUND_COMP_ID) reportError(DIAGS_TRANSFORM.nestedCompDefs);
8201
8214
  let component = {
@@ -8206,7 +8219,7 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8206
8219
  fileId
8207
8220
  } }
8208
8221
  };
8209
- collectTraits(usesStack$1, component, node$1);
8222
+ collectTraits(usesStack$1, component, node$1, allowGlobalVars);
8210
8223
  hoistScriptCollectedFromFragments(component);
8211
8224
  return component;
8212
8225
  }
@@ -8232,24 +8245,38 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8232
8245
  vars[attr.name] = attr.value;
8233
8246
  });
8234
8247
  }
8248
+ let globals;
8249
+ const globalsAttrs = attrs.filter((attr) => attr.startSegment === "global");
8250
+ if (globalsAttrs.length > 0) {
8251
+ globals = {};
8252
+ globalsAttrs.forEach((attr) => {
8253
+ globals[attr.name] = attr.value;
8254
+ });
8255
+ }
8235
8256
  const children = getChildNodes(node$1);
8236
8257
  const nestedComponents = children.filter((child) => child.kind === SyntaxKind.ElementNode && !(getComponentName(child, getText) in HelperNode));
8237
8258
  if (nestedComponents.length === 0) nestedComponents.push(createTextNodeElement(""));
8238
8259
  const nonVarHelperNodes = [];
8239
8260
  const nestedVars = [];
8261
+ const nestedGlobals = [];
8240
8262
  for (let child of children) if (child.kind === SyntaxKind.ElementNode) {
8241
8263
  const childName = getComponentName(child, getText);
8242
8264
  if (childName === HelperNode.variable) nestedVars.push(child);
8265
+ else if (childName === HelperNode.global) nestedGlobals.push(child);
8243
8266
  else if (childName in HelperNode) nonVarHelperNodes.push(child);
8244
8267
  }
8245
8268
  let element;
8246
- if (nestedComponents.length > 1 || nestedVars.length > 0) element = wrapWithFragment([...nestedVars, ...nestedComponents]);
8269
+ if (nestedComponents.length > 1 || nestedVars.length > 0 || nestedGlobals.length > 0) element = wrapWithFragment([
8270
+ ...nestedVars,
8271
+ ...nestedGlobals,
8272
+ ...nestedComponents
8273
+ ]);
8247
8274
  else element = nestedComponents[0];
8248
8275
  namespaceStack.push(/* @__PURE__ */ new Map());
8249
8276
  attrs.filter((attr) => attr.namespace === "xmlns").forEach((attr) => {
8250
8277
  addToNamespaces(namespaceStack, element, attr.unsegmentedName, attr.value);
8251
8278
  });
8252
- let nestedComponent = transformInnerElement(usesStack, element);
8279
+ let nestedComponent = transformInnerElement(usesStack, element, true);
8253
8280
  namespaceStack.pop();
8254
8281
  const component = {
8255
8282
  name: compoundName.value,
@@ -8265,26 +8292,31 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8265
8292
  ...nestedComponent.vars,
8266
8293
  ...vars
8267
8294
  };
8295
+ if (globals) nestedComponent.globalVars = {
8296
+ ...nestedComponent.globalVars,
8297
+ ...globals
8298
+ };
8268
8299
  if (codeBehind) component.codeBehind = codeBehind.value;
8269
8300
  nestedComponent.debug = { source: {
8270
8301
  start: element.start,
8271
8302
  end: element.end,
8272
8303
  fileId
8273
8304
  } };
8274
- collectTraits(usesStack, component, withNewChildNodes(node$1, nonVarHelperNodes));
8305
+ collectTraits(usesStack, component, withNewChildNodes(node$1, nonVarHelperNodes), false);
8275
8306
  return component;
8276
8307
  }
8277
8308
  /**
8278
8309
  * Collects component traits from attributes and child elements
8279
8310
  * @param comp Component definition
8280
8311
  * @param element Component element
8312
+ * @param allowGlobalVars Whether global variables are allowed in this context
8281
8313
  */
8282
- function collectTraits(usesStack$1, comp, element) {
8314
+ function collectTraits(usesStack$1, comp, element, allowGlobalVars = false) {
8283
8315
  const isCompound = !isComponent(comp);
8284
8316
  const attributes = getAttributes(element);
8285
8317
  namespaceStack.push(/* @__PURE__ */ new Map());
8286
8318
  attributes.forEach((attr) => {
8287
- collectAttribute(comp, attr);
8319
+ collectAttribute(comp, attr, allowGlobalVars);
8288
8320
  });
8289
8321
  const childNodes = getChildNodes(element);
8290
8322
  let hasScriptNode = false;
@@ -8335,6 +8367,17 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8335
8367
  comp.vars[name] = value;
8336
8368
  });
8337
8369
  return;
8370
+ case HelperNode.global:
8371
+ if (!allowGlobalVars) {
8372
+ reportError(DIAGS_TRANSFORM.globalNotAllowedInNested);
8373
+ return;
8374
+ }
8375
+ collectElementHelper(usesStack$1, comp, child, (name) => isComponent(comp) ? comp.globalVars?.[name] : void 0, (name, value) => {
8376
+ if (!isComponent(comp)) return;
8377
+ comp.globalVars ??= {};
8378
+ comp.globalVars[name] = value;
8379
+ });
8380
+ return;
8338
8381
  case "loaders":
8339
8382
  collectLoadersElements(usesStack$1, comp, child);
8340
8383
  return;
@@ -8354,12 +8397,12 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8354
8397
  });
8355
8398
  namespaceStack.pop();
8356
8399
  }
8357
- function collectAttribute(comp, attr) {
8400
+ function collectAttribute(comp, attr, allowGlobalVars = false) {
8358
8401
  const { namespace, startSegment, name, value, unsegmentedName: nsKey } = segmentAttr(attr);
8359
8402
  const attrValueStringNode = attr.children[2];
8360
8403
  if (namespace === "xmlns") return addToNamespaces(namespaceStack, comp, nsKey, value);
8361
8404
  if (!isComponent(comp)) {
8362
- if (startSegment && startSegment !== "method" && startSegment !== "var") {
8405
+ if (startSegment && startSegment !== "method" && startSegment !== "var" && startSegment !== "global") {
8363
8406
  reportError(DIAGS_TRANSFORM.invalidReusableCompAttr(nsKey));
8364
8407
  return;
8365
8408
  }
@@ -8385,6 +8428,13 @@ function nodeToComponentDef(node, originalGetText, fileId, preResolvedImports) {
8385
8428
  if (startSegment === "var") {
8386
8429
  comp.vars ??= {};
8387
8430
  comp.vars[name] = value;
8431
+ } else if (startSegment === "global") {
8432
+ if (!allowGlobalVars) {
8433
+ reportError(DIAGS_TRANSFORM.globalNotAllowedInNested);
8434
+ return;
8435
+ }
8436
+ comp.globalVars ??= {};
8437
+ comp.globalVars[name] = value;
8388
8438
  } else if (startSegment === "method") {
8389
8439
  comp.api ??= {};
8390
8440
  comp.api[name] = value;
@@ -10020,6 +10070,26 @@ function viteXmluiPlugin(pluginOptions = {}) {
10020
10070
  };
10021
10071
  }
10022
10072
  return null;
10073
+ },
10074
+ handleHotUpdate({ file, server }) {
10075
+ const normalizedFile = normalizePath(file);
10076
+ const isXmluiFile = xmluiExtension.test(normalizedFile);
10077
+ const isXsFile = xmluiScriptExtension.test(normalizedFile) || moduleScriptExtension.test(normalizedFile);
10078
+ if (isXmluiFile || isXsFile) {
10079
+ clearAllModuleCaches();
10080
+ if (isXsFile) {
10081
+ this.warn(`[vite-xmlui-plugin] Processing updated script file: ${file}`);
10082
+ const allModules = Array.from(server.moduleGraph.idToModuleMap.values());
10083
+ for (const mod of allModules) server.moduleGraph.invalidateModule(mod);
10084
+ server.ws.send({
10085
+ type: "full-reload",
10086
+ path: "*"
10087
+ });
10088
+ return [];
10089
+ }
10090
+ const module$1 = server.moduleGraph.getModuleById(normalizedFile);
10091
+ if (module$1) return [module$1];
10092
+ }
10023
10093
  }
10024
10094
  };
10025
10095
  }