@mbler/mcx-core 0.1.1-beta.r3 → 0.1.1-beta.r4

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/index.js CHANGED
@@ -10,7 +10,6 @@ var Module = require('node:module');
10
10
  var vm = require('node:vm');
11
11
  var node_buffer = require('node:buffer');
12
12
  var node_fs = require('node:fs');
13
- var node_crypto = require('node:crypto');
14
13
  var MagicString = require('magic-string');
15
14
 
16
15
  function _interopNamespaceDefault(e) {
@@ -7863,7 +7862,7 @@ class ItemComponent {
7863
7862
  format_version: '',
7864
7863
  _meta: {
7865
7864
  type: 'item',
7866
- file_edit: [],
7865
+ file_edit: this.#edit || [],
7867
7866
  },
7868
7867
  'minecraft:item': {
7869
7868
  components: {},
@@ -9830,10 +9829,10 @@ class ItemComponent {
9830
9829
  const textureKey = this.#opt.id.includes(':')
9831
9830
  ? this.#opt.id.split(':')[1]
9832
9831
  : this.#opt.id;
9833
- const idKey = '__icon_id_point';
9834
9832
  if (!this.#edit)
9835
9833
  this.#edit = [];
9836
9834
  let idx = -1;
9835
+ const idKey = '__icon_key__';
9837
9836
  const found = this.#edit.find((v, i) => {
9838
9837
  if (v.type == 'batch' &&
9839
9838
  v.options[0] &&
@@ -9849,10 +9848,8 @@ class ItemComponent {
9849
9848
  if (found && idx !== -1) {
9850
9849
  this.#edit.splice(idx, 1);
9851
9850
  }
9852
- const execId = node_crypto.randomUUID();
9853
9851
  this.#edit.push({
9854
9852
  type: 'batch',
9855
- id: execId,
9856
9853
  options: [
9857
9854
  {
9858
9855
  type: 'copy_assets',
@@ -9863,7 +9860,7 @@ class ItemComponent {
9863
9860
  },
9864
9861
  output: {
9865
9862
  base: 'resources',
9866
- file: `items/${execId}.png`,
9863
+ file: `textures/items/${textureKey}.png`,
9867
9864
  },
9868
9865
  },
9869
9866
  {
@@ -9881,7 +9878,7 @@ class ItemComponent {
9881
9878
  },
9882
9879
  texture: {
9883
9880
  from: 'var',
9884
- data: `items/${execId}.png`,
9881
+ data: `items/${textureKey}.png`,
9885
9882
  },
9886
9883
  },
9887
9884
  run: async (define) => {
@@ -11803,6 +11800,8 @@ async function execEdit(option, ctx) {
11803
11800
  if ('bind' in editOption.source) {
11804
11801
  if (editOption.source.bind == 'item_texture' &&
11805
11802
  editOption.source.type == 'append') {
11803
+ if (!Array.isArray(execResult))
11804
+ throw new Error('[mcx component]: json._meta.file_edit: error exec result');
11806
11805
  if (!cachedOption['item_texture'])
11807
11806
  cachedOption['item_texture'] = [];
11808
11807
  if (Array.isArray(execResult)) {
@@ -11813,6 +11812,9 @@ async function execEdit(option, ctx) {
11813
11812
  }
11814
11813
  }
11815
11814
  }
11815
+ else {
11816
+ throw new Error('[mcx component]: json._meta.file_edit: unkown output place.');
11817
+ }
11816
11818
  }
11817
11819
  }
11818
11820
  }