@weaverse/hydrogen 1.0.43 → 1.0.45
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 +25 -5
- package/dist/index.mjs +25 -5
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -59,12 +59,13 @@ function createWeaverseHydrogenContext({ weaverseData }, components) {
|
|
|
59
59
|
pageId: page?.id,
|
|
60
60
|
platformType: "shopify-hydrogen"
|
|
61
61
|
});
|
|
62
|
+
weaverse.elementInstances.clear();
|
|
62
63
|
Object.entries(components).forEach(([key, component]) => {
|
|
63
64
|
weaverse.registerElement({
|
|
64
65
|
type: component?.schema?.type || key,
|
|
65
66
|
Component: component?.default,
|
|
67
|
+
// @ts-ignore
|
|
66
68
|
schema: component?.schema
|
|
67
|
-
// defaultCss: component?.css,
|
|
68
69
|
});
|
|
69
70
|
});
|
|
70
71
|
return weaverse;
|
|
@@ -550,8 +551,13 @@ var WeaverseItemStore = class {
|
|
|
550
551
|
};
|
|
551
552
|
this.stitchesClass = "";
|
|
552
553
|
this._data = { id: "", type: "" };
|
|
553
|
-
this.setData = (
|
|
554
|
-
|
|
554
|
+
this.setData = (update) => {
|
|
555
|
+
let platformType = this.weaverse.platformType;
|
|
556
|
+
if (platformType === "shopify-hydrogen") {
|
|
557
|
+
this.data = update;
|
|
558
|
+
} else {
|
|
559
|
+
this.data = Object.assign(this.data, update);
|
|
560
|
+
}
|
|
555
561
|
this.triggerUpdate();
|
|
556
562
|
return this.data;
|
|
557
563
|
};
|
|
@@ -585,10 +591,24 @@ var WeaverseItemStore = class {
|
|
|
585
591
|
get Element() {
|
|
586
592
|
return this.weaverse.elementInstances.get(this._data.type);
|
|
587
593
|
}
|
|
588
|
-
set data(
|
|
589
|
-
|
|
594
|
+
set data(update) {
|
|
595
|
+
let platformType = this.weaverse.platformType;
|
|
596
|
+
if (platformType === "shopify-hydrogen") {
|
|
597
|
+
this._data.data = merge(this.data, update);
|
|
598
|
+
} else {
|
|
599
|
+
this._data = { ...this.data, ...update };
|
|
600
|
+
}
|
|
590
601
|
}
|
|
591
602
|
get data() {
|
|
603
|
+
let platformType = this.weaverse.platformType;
|
|
604
|
+
if (platformType === "shopify-hydrogen") {
|
|
605
|
+
let defaultData2 = { ...this.Element?.Component?.defaultProps };
|
|
606
|
+
return {
|
|
607
|
+
...this._data,
|
|
608
|
+
...defaultData2,
|
|
609
|
+
...this._data.data
|
|
610
|
+
};
|
|
611
|
+
}
|
|
592
612
|
let defaultCss = this.Element?.defaultCss || {};
|
|
593
613
|
let currentCss = this._data.css || {};
|
|
594
614
|
let css = merge(defaultCss, currentCss);
|
package/dist/index.mjs
CHANGED
|
@@ -22,12 +22,13 @@ function createWeaverseHydrogenContext({ weaverseData }, components) {
|
|
|
22
22
|
pageId: page?.id,
|
|
23
23
|
platformType: "shopify-hydrogen"
|
|
24
24
|
});
|
|
25
|
+
weaverse.elementInstances.clear();
|
|
25
26
|
Object.entries(components).forEach(([key, component]) => {
|
|
26
27
|
weaverse.registerElement({
|
|
27
28
|
type: component?.schema?.type || key,
|
|
28
29
|
Component: component?.default,
|
|
30
|
+
// @ts-ignore
|
|
29
31
|
schema: component?.schema
|
|
30
|
-
// defaultCss: component?.css,
|
|
31
32
|
});
|
|
32
33
|
});
|
|
33
34
|
return weaverse;
|
|
@@ -513,8 +514,13 @@ var WeaverseItemStore = class {
|
|
|
513
514
|
};
|
|
514
515
|
this.stitchesClass = "";
|
|
515
516
|
this._data = { id: "", type: "" };
|
|
516
|
-
this.setData = (
|
|
517
|
-
|
|
517
|
+
this.setData = (update) => {
|
|
518
|
+
let platformType = this.weaverse.platformType;
|
|
519
|
+
if (platformType === "shopify-hydrogen") {
|
|
520
|
+
this.data = update;
|
|
521
|
+
} else {
|
|
522
|
+
this.data = Object.assign(this.data, update);
|
|
523
|
+
}
|
|
518
524
|
this.triggerUpdate();
|
|
519
525
|
return this.data;
|
|
520
526
|
};
|
|
@@ -548,10 +554,24 @@ var WeaverseItemStore = class {
|
|
|
548
554
|
get Element() {
|
|
549
555
|
return this.weaverse.elementInstances.get(this._data.type);
|
|
550
556
|
}
|
|
551
|
-
set data(
|
|
552
|
-
|
|
557
|
+
set data(update) {
|
|
558
|
+
let platformType = this.weaverse.platformType;
|
|
559
|
+
if (platformType === "shopify-hydrogen") {
|
|
560
|
+
this._data.data = merge(this.data, update);
|
|
561
|
+
} else {
|
|
562
|
+
this._data = { ...this.data, ...update };
|
|
563
|
+
}
|
|
553
564
|
}
|
|
554
565
|
get data() {
|
|
566
|
+
let platformType = this.weaverse.platformType;
|
|
567
|
+
if (platformType === "shopify-hydrogen") {
|
|
568
|
+
let defaultData2 = { ...this.Element?.Component?.defaultProps };
|
|
569
|
+
return {
|
|
570
|
+
...this._data,
|
|
571
|
+
...defaultData2,
|
|
572
|
+
...this._data.data
|
|
573
|
+
};
|
|
574
|
+
}
|
|
555
575
|
let defaultCss = this.Element?.defaultCss || {};
|
|
556
576
|
let currentCss = this._data.css || {};
|
|
557
577
|
let css = merge(defaultCss, currentCss);
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.45",
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"typings": "dist/index.d.ts",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"author": "Weaverse Team",
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@shopify/hydrogen": "2023.4.1",
|
|
36
|
-
"@weaverse/react": "1.0.
|
|
36
|
+
"@weaverse/react": "1.0.45"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@shopify/remix-oxygen": "^1.0.6"
|