mechanica 1.0.23 → 1.0.25

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/bin/bin.js CHANGED
File without changes
package/bin/compile.js CHANGED
@@ -53,10 +53,7 @@ const walkTree = (blocks, callback) => {
53
53
  }
54
54
  };
55
55
  const walkSchema = (obj, schema, callback) => {
56
- if (schema.type === "object" && schema.properties) {
57
- if (!obj) {
58
- return;
59
- }
56
+ if (schema.type === "object" && schema.properties && obj) {
60
57
  for (let [key, childSchema] of Object.entries(schema.properties)) {
61
58
  const isRequired = schema.required.includes(key);
62
59
  callback(obj[key], childSchema, key, obj, isRequired);
@@ -65,7 +62,7 @@ const walkSchema = (obj, schema, callback) => {
65
62
  }
66
63
  }
67
64
  }
68
- if (schema.type === "array" && schema.items) {
65
+ if (schema.type === "array" && schema.items && obj) {
69
66
  for (let value of obj) {
70
67
  callback(value, schema.items);
71
68
  if (schema.items.type === "array" || schema.items.type === "object") {
@@ -150,7 +147,7 @@ async function* generateProject(options) {
150
147
  const schema = options.blocksMap.get(block.blockId);
151
148
  walkSchema(block.data, schema.props, (val, schema2, key, parent) => {
152
149
  if (!val) return;
153
- if (schema2.format === "image") {
150
+ if (schema2.format === "image" || schema2.format === "file") {
154
151
  if (val.src) {
155
152
  val.src = options.onFile(val.src);
156
153
  }
package/dist/editor.js CHANGED
@@ -1446,10 +1446,7 @@ const walkTree = (blocks, callback) => {
1446
1446
  }
1447
1447
  };
1448
1448
  const walkSchema = (obj, schema, callback) => {
1449
- if (schema.type === "object" && schema.properties) {
1450
- if (!obj) {
1451
- return;
1452
- }
1449
+ if (schema.type === "object" && schema.properties && obj) {
1453
1450
  for (let [key, childSchema] of Object.entries(schema.properties)) {
1454
1451
  const isRequired = schema.required.includes(key);
1455
1452
  callback(obj[key], childSchema, key, obj, isRequired);
@@ -1458,7 +1455,7 @@ const walkSchema = (obj, schema, callback) => {
1458
1455
  }
1459
1456
  }
1460
1457
  }
1461
- if (schema.type === "array" && schema.items) {
1458
+ if (schema.type === "array" && schema.items && obj) {
1462
1459
  for (let value of obj) {
1463
1460
  callback(value, schema.items);
1464
1461
  if (schema.items.type === "array" || schema.items.type === "object") {