@gem-sdk/core 1.45.0-dev.113 → 1.45.0-dev.118
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/cjs/helpers/loop-component.js +16 -0
- package/dist/cjs/helpers/pascal-to-kebab-case.js +7 -0
- package/dist/cjs/helpers/remove-matching-key.js +12 -0
- package/dist/cjs/helpers/third-party/addAppBlockId.js +20 -0
- package/dist/cjs/helpers/third-party/appConfig.js +38 -0
- package/dist/cjs/helpers/third-party/appSetting.js +71 -0
- package/dist/cjs/helpers/third-party/composeAppBlockId.js +11 -0
- package/dist/cjs/helpers/third-party/constant.js +15 -0
- package/dist/cjs/helpers/third-party/generateAppBlockConfigs.js +21 -0
- package/dist/cjs/helpers/third-party/getAppBlockConfig.js +23 -0
- package/dist/cjs/helpers/third-party/getAppBlockType.js +12 -0
- package/dist/cjs/helpers/third-party/getAppBlocks.js +41 -0
- package/dist/cjs/index.js +4 -0
- package/dist/esm/helpers/loop-component.js +14 -0
- package/dist/esm/helpers/pascal-to-kebab-case.js +5 -0
- package/dist/esm/helpers/remove-matching-key.js +10 -0
- package/dist/esm/helpers/third-party/addAppBlockId.js +18 -0
- package/dist/esm/helpers/third-party/appConfig.js +32 -0
- package/dist/esm/helpers/third-party/appSetting.js +69 -0
- package/dist/esm/helpers/third-party/composeAppBlockId.js +9 -0
- package/dist/esm/helpers/third-party/constant.js +12 -0
- package/dist/esm/helpers/third-party/generateAppBlockConfigs.js +19 -0
- package/dist/esm/helpers/third-party/getAppBlockConfig.js +21 -0
- package/dist/esm/helpers/third-party/getAppBlockType.js +10 -0
- package/dist/esm/helpers/third-party/getAppBlocks.js +39 -0
- package/dist/esm/index.js +2 -0
- package/dist/types/index.d.ts +10 -1
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function loopComponent(component, callback) {
|
|
4
|
+
if (component) {
|
|
5
|
+
callback(component);
|
|
6
|
+
}
|
|
7
|
+
if (component?.childrens?.length) {
|
|
8
|
+
// eslint-disable-next-line
|
|
9
|
+
for(let i = 0; i < component.childrens.length; i++){
|
|
10
|
+
const children = component.childrens[i];
|
|
11
|
+
loopComponent(children, callback);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
exports.loopComponent = loopComponent;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var loopComponent = require('../loop-component.js');
|
|
4
|
+
var composeAppBlockId = require('./composeAppBlockId.js');
|
|
5
|
+
|
|
6
|
+
const addAppBlockId = (component)=>{
|
|
7
|
+
const strComponent = JSON.stringify(component) || '';
|
|
8
|
+
if (!strComponent.includes('appBlockId')) {
|
|
9
|
+
return component;
|
|
10
|
+
}
|
|
11
|
+
loopComponent.loopComponent(component, (component)=>handleSetBlockId(component));
|
|
12
|
+
return component;
|
|
13
|
+
};
|
|
14
|
+
const handleSetBlockId = (component)=>{
|
|
15
|
+
const { tag, uid } = component;
|
|
16
|
+
if (component.settings.appBlockId === undefined) return component;
|
|
17
|
+
component.settings.appBlockId = composeAppBlockId.composeAppBlockId(tag, uid);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
exports.addAppBlockId = addAppBlockId;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const RechargeSubscriptionsConfig = {
|
|
4
|
+
RechargeSubscriptions: {
|
|
5
|
+
appName: 'recharge-subscriptions',
|
|
6
|
+
appId: '371eed76-0b44-4869-9813-730372ea378e'
|
|
7
|
+
}
|
|
8
|
+
};
|
|
9
|
+
const BonLoyaltyRewardsReferralsConfig = {
|
|
10
|
+
BonLoyaltyRewardsReferrals: {
|
|
11
|
+
appName: 'bon-loyalty',
|
|
12
|
+
appId: '63496a04-c097-48d1-8c11-475aec24b12e'
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const SubifySubscriptionsConfig = {
|
|
16
|
+
SubifySubscriptionsApp: {
|
|
17
|
+
appName: 'subify-subscriptions-app',
|
|
18
|
+
appId: 'bc0dba25-cd46-4841-bea4-6bdfe9ac815f'
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
const SelleasyConfig = {
|
|
22
|
+
SelleasyApp: {
|
|
23
|
+
appName: 'selleasy',
|
|
24
|
+
appId: '790c1a03-a71f-4bc1-9869-00dad526d3c2'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const LoopSubscriptionsConfig = {
|
|
28
|
+
LoopSubscriptions: {
|
|
29
|
+
appName: 'Loop Subscriptions',
|
|
30
|
+
appId: '267a7c64-5cb3-4552-b817-5485165f0a0b'
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.BonLoyaltyRewardsReferralsConfig = BonLoyaltyRewardsReferralsConfig;
|
|
35
|
+
exports.LoopSubscriptionsConfig = LoopSubscriptionsConfig;
|
|
36
|
+
exports.RechargeSubscriptionsConfig = RechargeSubscriptionsConfig;
|
|
37
|
+
exports.SelleasyConfig = SelleasyConfig;
|
|
38
|
+
exports.SubifySubscriptionsConfig = SubifySubscriptionsConfig;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const RechargeSubscriptions = {
|
|
4
|
+
RechargeSubscriptions: {
|
|
5
|
+
'subscription-widget': {
|
|
6
|
+
product: '{{ product }}'
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
const LoyaltyRewardsReferrals = {
|
|
11
|
+
BonLoyaltyRewardsReferrals: {
|
|
12
|
+
'loyalty-page-block': null,
|
|
13
|
+
'loyalty-page-earning-block': null,
|
|
14
|
+
'loyalty-page-header-block': null,
|
|
15
|
+
'loyalty-page-profile-block': null,
|
|
16
|
+
'loyalty-page-redeem-block': null,
|
|
17
|
+
'loyalty-page-referral-block': null,
|
|
18
|
+
'loyalty-page-tier-block': null,
|
|
19
|
+
'product-point-preview': null
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const SubifySubscriptions = {
|
|
23
|
+
SubifySubscriptionsApp: {
|
|
24
|
+
'app-block': {
|
|
25
|
+
product: '{{product}}',
|
|
26
|
+
use_app_block_wording: false,
|
|
27
|
+
widget_label: 'Purchase options',
|
|
28
|
+
one_time_purchase_text: 'One-Time Purchase',
|
|
29
|
+
subscription_text: 'Subscribe and save',
|
|
30
|
+
delivery_frequency_text: 'Delivery frequency',
|
|
31
|
+
prepaid_subscription_text: 'Subscription with prepaid',
|
|
32
|
+
skin1_priceSuffix: 'each',
|
|
33
|
+
skin1_save: 'Save(skin1)',
|
|
34
|
+
skin1_prepaid_payment_title: 'prepaid',
|
|
35
|
+
skin1_normal_payment_title: 'pay as you go',
|
|
36
|
+
skin2_discountSuffix: 'Save',
|
|
37
|
+
skin3_fullPrice: 'Full price',
|
|
38
|
+
skin3_priceSuffix: 'each',
|
|
39
|
+
skin3_discountSuffix: 'Off',
|
|
40
|
+
skin4_justOnce: 'Just once',
|
|
41
|
+
skin4_discountSuffix: 'Off',
|
|
42
|
+
skin4_priceSuffix: 'each',
|
|
43
|
+
skin4_fullPrice: '(Full price)',
|
|
44
|
+
skin4_sellingPlansTitle: 'Renews every:',
|
|
45
|
+
from: 'from',
|
|
46
|
+
max_discount_badge_title: 'UP To',
|
|
47
|
+
pay: 'Pay',
|
|
48
|
+
price_save_up_to: 'save up to'
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const SelleasyWidget = {
|
|
53
|
+
Selleasy: {
|
|
54
|
+
'lb-upsell-fbt-block': null,
|
|
55
|
+
'lb-upsell-addon-block': null
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
const LoopSubscriptions = {
|
|
59
|
+
LoopSubscriptions: {
|
|
60
|
+
'star_rating': null
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const composeSettingsByWidgetType = {
|
|
64
|
+
...LoopSubscriptions,
|
|
65
|
+
...RechargeSubscriptions,
|
|
66
|
+
...LoyaltyRewardsReferrals,
|
|
67
|
+
...SubifySubscriptions,
|
|
68
|
+
...SelleasyWidget
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
exports.composeSettingsByWidgetType = composeSettingsByWidgetType;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var pascalToKebabCase = require('../pascal-to-kebab-case.js');
|
|
4
|
+
var constant = require('./constant.js');
|
|
5
|
+
|
|
6
|
+
const composeAppBlockId = (tag, uid)=>{
|
|
7
|
+
const key = pascalToKebabCase.pascalToKebab(tag);
|
|
8
|
+
return `${constant.THIRD_PARTY_APP_BLOCK_ID_PREFIX}_${key}_${uid}`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.composeAppBlockId = composeAppBlockId;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var appConfig = require('./appConfig.js');
|
|
4
|
+
|
|
5
|
+
const mapShopifyAppMeta = {
|
|
6
|
+
...appConfig.RechargeSubscriptionsConfig,
|
|
7
|
+
...appConfig.BonLoyaltyRewardsReferralsConfig,
|
|
8
|
+
...appConfig.SubifySubscriptionsConfig,
|
|
9
|
+
...appConfig.SelleasyConfig,
|
|
10
|
+
...appConfig.LoopSubscriptionsConfig
|
|
11
|
+
};
|
|
12
|
+
const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
|
|
13
|
+
|
|
14
|
+
exports.THIRD_PARTY_APP_BLOCK_ID_PREFIX = THIRD_PARTY_APP_BLOCK_ID_PREFIX;
|
|
15
|
+
exports.mapShopifyAppMeta = mapShopifyAppMeta;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var loopComponent = require('../loop-component.js');
|
|
4
|
+
var getAppBlockConfig = require('./getAppBlockConfig.js');
|
|
5
|
+
|
|
6
|
+
const generateAppBlockConfigs = (component)=>{
|
|
7
|
+
const strComponent = JSON.stringify(component) || '';
|
|
8
|
+
if (!strComponent.includes('appBlockId')) return null;
|
|
9
|
+
const configs = [];
|
|
10
|
+
loopComponent.loopComponent(component, (component)=>{
|
|
11
|
+
const settings = component.settings || {};
|
|
12
|
+
const appBlockId = settings?.appBlockId || '';
|
|
13
|
+
if (!appBlockId) return;
|
|
14
|
+
const config = getAppBlockConfig.getAppBlockConfig(component.tag, appBlockId, settings);
|
|
15
|
+
if (!config) return;
|
|
16
|
+
configs.push(config);
|
|
17
|
+
});
|
|
18
|
+
return configs;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.generateAppBlockConfigs = generateAppBlockConfigs;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var appSetting = require('./appSetting.js');
|
|
4
|
+
var getAppBlockType = require('./getAppBlockType.js');
|
|
5
|
+
|
|
6
|
+
const getAppBlockConfig = (tag, appBlockId, settings)=>{
|
|
7
|
+
const appBlockType = getAppBlockType.getAppBlockType({
|
|
8
|
+
tag,
|
|
9
|
+
widgetType: settings?.widgetType
|
|
10
|
+
});
|
|
11
|
+
const settingByWidget = appSetting.composeSettingsByWidgetType[tag][settings?.widgetType];
|
|
12
|
+
return {
|
|
13
|
+
key: appBlockId,
|
|
14
|
+
value: {
|
|
15
|
+
type: appBlockType,
|
|
16
|
+
...settingByWidget && {
|
|
17
|
+
settings: settingByWidget
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
exports.getAppBlockConfig = getAppBlockConfig;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constant = require('./constant.js');
|
|
4
|
+
|
|
5
|
+
const getAppBlockType = ({ tag, widgetType })=>{
|
|
6
|
+
const shopifyAppMeta = constant.mapShopifyAppMeta[tag];
|
|
7
|
+
if (!shopifyAppMeta) return '';
|
|
8
|
+
const { appName, appId } = shopifyAppMeta;
|
|
9
|
+
return `shopify://apps/${appName}/blocks/${widgetType}/${appId}`;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
exports.getAppBlockType = getAppBlockType;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var removeMatchingKey = require('../remove-matching-key.js');
|
|
4
|
+
var addAppBlockId = require('./addAppBlockId.js');
|
|
5
|
+
var generateAppBlockConfigs = require('./generateAppBlockConfigs.js');
|
|
6
|
+
|
|
7
|
+
const getAppBlocks = (section, currentBlock, currentBlockOrder)=>{
|
|
8
|
+
const component = JSON.parse(section?.component || '');
|
|
9
|
+
const componentWithAppBlockId = addAppBlockId.addAppBlockId(component);
|
|
10
|
+
const appBlockConfigs = generateAppBlockConfigs.generateAppBlockConfigs(componentWithAppBlockId);
|
|
11
|
+
if (!appBlockConfigs?.length) {
|
|
12
|
+
return {
|
|
13
|
+
blocks: currentBlock,
|
|
14
|
+
block_order: currentBlockOrder
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
let newBlocks = currentBlock;
|
|
18
|
+
let newBlockOrder = currentBlockOrder;
|
|
19
|
+
appBlockConfigs.forEach(({ key, value })=>{
|
|
20
|
+
const newBlock = {
|
|
21
|
+
[key]: value
|
|
22
|
+
};
|
|
23
|
+
const oldKeyRemovedBlock = removeMatchingKey.removeMatchingKey(newBlocks, key);
|
|
24
|
+
newBlocks = {
|
|
25
|
+
...oldKeyRemovedBlock,
|
|
26
|
+
...newBlock
|
|
27
|
+
};
|
|
28
|
+
newBlockOrder = newBlockOrder ? [
|
|
29
|
+
...newBlockOrder,
|
|
30
|
+
key
|
|
31
|
+
] : [
|
|
32
|
+
key
|
|
33
|
+
];
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
blocks: newBlocks,
|
|
37
|
+
block_order: newBlockOrder
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
exports.getAppBlocks = getAppBlocks;
|
package/dist/cjs/index.js
CHANGED
|
@@ -106,6 +106,8 @@ var animations$1 = require('./types/animations.js');
|
|
|
106
106
|
var getCollection = require('./helpers/queries/get-collection.js');
|
|
107
107
|
var getProduct = require('./helpers/queries/get-product.js');
|
|
108
108
|
var getProductBySlug = require('./helpers/queries/get-product-by-slug.js');
|
|
109
|
+
var getAppBlocks = require('./helpers/third-party/getAppBlocks.js');
|
|
110
|
+
var addAppBlockId = require('./helpers/third-party/addAppBlockId.js');
|
|
109
111
|
|
|
110
112
|
|
|
111
113
|
|
|
@@ -399,3 +401,5 @@ exports.fetchMedias = getProduct.fetchMedias;
|
|
|
399
401
|
exports.fetchVariants = getProduct.fetchVariants;
|
|
400
402
|
exports.getProduct = getProduct.getProduct;
|
|
401
403
|
exports.getProductBySlug = getProductBySlug.getProductBySlug;
|
|
404
|
+
exports.getAppBlocks = getAppBlocks.getAppBlocks;
|
|
405
|
+
exports.addAppBlockId = addAppBlockId.addAppBlockId;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function loopComponent(component, callback) {
|
|
2
|
+
if (component) {
|
|
3
|
+
callback(component);
|
|
4
|
+
}
|
|
5
|
+
if (component?.childrens?.length) {
|
|
6
|
+
// eslint-disable-next-line
|
|
7
|
+
for(let i = 0; i < component.childrens.length; i++){
|
|
8
|
+
const children = component.childrens[i];
|
|
9
|
+
loopComponent(children, callback);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { loopComponent };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { loopComponent } from '../loop-component.js';
|
|
2
|
+
import { composeAppBlockId } from './composeAppBlockId.js';
|
|
3
|
+
|
|
4
|
+
const addAppBlockId = (component)=>{
|
|
5
|
+
const strComponent = JSON.stringify(component) || '';
|
|
6
|
+
if (!strComponent.includes('appBlockId')) {
|
|
7
|
+
return component;
|
|
8
|
+
}
|
|
9
|
+
loopComponent(component, (component)=>handleSetBlockId(component));
|
|
10
|
+
return component;
|
|
11
|
+
};
|
|
12
|
+
const handleSetBlockId = (component)=>{
|
|
13
|
+
const { tag, uid } = component;
|
|
14
|
+
if (component.settings.appBlockId === undefined) return component;
|
|
15
|
+
component.settings.appBlockId = composeAppBlockId(tag, uid);
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { addAppBlockId };
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
const RechargeSubscriptionsConfig = {
|
|
2
|
+
RechargeSubscriptions: {
|
|
3
|
+
appName: 'recharge-subscriptions',
|
|
4
|
+
appId: '371eed76-0b44-4869-9813-730372ea378e'
|
|
5
|
+
}
|
|
6
|
+
};
|
|
7
|
+
const BonLoyaltyRewardsReferralsConfig = {
|
|
8
|
+
BonLoyaltyRewardsReferrals: {
|
|
9
|
+
appName: 'bon-loyalty',
|
|
10
|
+
appId: '63496a04-c097-48d1-8c11-475aec24b12e'
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const SubifySubscriptionsConfig = {
|
|
14
|
+
SubifySubscriptionsApp: {
|
|
15
|
+
appName: 'subify-subscriptions-app',
|
|
16
|
+
appId: 'bc0dba25-cd46-4841-bea4-6bdfe9ac815f'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const SelleasyConfig = {
|
|
20
|
+
SelleasyApp: {
|
|
21
|
+
appName: 'selleasy',
|
|
22
|
+
appId: '790c1a03-a71f-4bc1-9869-00dad526d3c2'
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
const LoopSubscriptionsConfig = {
|
|
26
|
+
LoopSubscriptions: {
|
|
27
|
+
appName: 'Loop Subscriptions',
|
|
28
|
+
appId: '267a7c64-5cb3-4552-b817-5485165f0a0b'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export { BonLoyaltyRewardsReferralsConfig, LoopSubscriptionsConfig, RechargeSubscriptionsConfig, SelleasyConfig, SubifySubscriptionsConfig };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
const RechargeSubscriptions = {
|
|
2
|
+
RechargeSubscriptions: {
|
|
3
|
+
'subscription-widget': {
|
|
4
|
+
product: '{{ product }}'
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
const LoyaltyRewardsReferrals = {
|
|
9
|
+
BonLoyaltyRewardsReferrals: {
|
|
10
|
+
'loyalty-page-block': null,
|
|
11
|
+
'loyalty-page-earning-block': null,
|
|
12
|
+
'loyalty-page-header-block': null,
|
|
13
|
+
'loyalty-page-profile-block': null,
|
|
14
|
+
'loyalty-page-redeem-block': null,
|
|
15
|
+
'loyalty-page-referral-block': null,
|
|
16
|
+
'loyalty-page-tier-block': null,
|
|
17
|
+
'product-point-preview': null
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
const SubifySubscriptions = {
|
|
21
|
+
SubifySubscriptionsApp: {
|
|
22
|
+
'app-block': {
|
|
23
|
+
product: '{{product}}',
|
|
24
|
+
use_app_block_wording: false,
|
|
25
|
+
widget_label: 'Purchase options',
|
|
26
|
+
one_time_purchase_text: 'One-Time Purchase',
|
|
27
|
+
subscription_text: 'Subscribe and save',
|
|
28
|
+
delivery_frequency_text: 'Delivery frequency',
|
|
29
|
+
prepaid_subscription_text: 'Subscription with prepaid',
|
|
30
|
+
skin1_priceSuffix: 'each',
|
|
31
|
+
skin1_save: 'Save(skin1)',
|
|
32
|
+
skin1_prepaid_payment_title: 'prepaid',
|
|
33
|
+
skin1_normal_payment_title: 'pay as you go',
|
|
34
|
+
skin2_discountSuffix: 'Save',
|
|
35
|
+
skin3_fullPrice: 'Full price',
|
|
36
|
+
skin3_priceSuffix: 'each',
|
|
37
|
+
skin3_discountSuffix: 'Off',
|
|
38
|
+
skin4_justOnce: 'Just once',
|
|
39
|
+
skin4_discountSuffix: 'Off',
|
|
40
|
+
skin4_priceSuffix: 'each',
|
|
41
|
+
skin4_fullPrice: '(Full price)',
|
|
42
|
+
skin4_sellingPlansTitle: 'Renews every:',
|
|
43
|
+
from: 'from',
|
|
44
|
+
max_discount_badge_title: 'UP To',
|
|
45
|
+
pay: 'Pay',
|
|
46
|
+
price_save_up_to: 'save up to'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const SelleasyWidget = {
|
|
51
|
+
Selleasy: {
|
|
52
|
+
'lb-upsell-fbt-block': null,
|
|
53
|
+
'lb-upsell-addon-block': null
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const LoopSubscriptions = {
|
|
57
|
+
LoopSubscriptions: {
|
|
58
|
+
'star_rating': null
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
const composeSettingsByWidgetType = {
|
|
62
|
+
...LoopSubscriptions,
|
|
63
|
+
...RechargeSubscriptions,
|
|
64
|
+
...LoyaltyRewardsReferrals,
|
|
65
|
+
...SubifySubscriptions,
|
|
66
|
+
...SelleasyWidget
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export { composeSettingsByWidgetType };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { pascalToKebab } from '../pascal-to-kebab-case.js';
|
|
2
|
+
import { THIRD_PARTY_APP_BLOCK_ID_PREFIX } from './constant.js';
|
|
3
|
+
|
|
4
|
+
const composeAppBlockId = (tag, uid)=>{
|
|
5
|
+
const key = pascalToKebab(tag);
|
|
6
|
+
return `${THIRD_PARTY_APP_BLOCK_ID_PREFIX}_${key}_${uid}`;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { composeAppBlockId };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RechargeSubscriptionsConfig, BonLoyaltyRewardsReferralsConfig, SubifySubscriptionsConfig, SelleasyConfig, LoopSubscriptionsConfig } from './appConfig.js';
|
|
2
|
+
|
|
3
|
+
const mapShopifyAppMeta = {
|
|
4
|
+
...RechargeSubscriptionsConfig,
|
|
5
|
+
...BonLoyaltyRewardsReferralsConfig,
|
|
6
|
+
...SubifySubscriptionsConfig,
|
|
7
|
+
...SelleasyConfig,
|
|
8
|
+
...LoopSubscriptionsConfig
|
|
9
|
+
};
|
|
10
|
+
const THIRD_PARTY_APP_BLOCK_ID_PREFIX = 'gp_app';
|
|
11
|
+
|
|
12
|
+
export { THIRD_PARTY_APP_BLOCK_ID_PREFIX, mapShopifyAppMeta };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { loopComponent } from '../loop-component.js';
|
|
2
|
+
import { getAppBlockConfig } from './getAppBlockConfig.js';
|
|
3
|
+
|
|
4
|
+
const generateAppBlockConfigs = (component)=>{
|
|
5
|
+
const strComponent = JSON.stringify(component) || '';
|
|
6
|
+
if (!strComponent.includes('appBlockId')) return null;
|
|
7
|
+
const configs = [];
|
|
8
|
+
loopComponent(component, (component)=>{
|
|
9
|
+
const settings = component.settings || {};
|
|
10
|
+
const appBlockId = settings?.appBlockId || '';
|
|
11
|
+
if (!appBlockId) return;
|
|
12
|
+
const config = getAppBlockConfig(component.tag, appBlockId, settings);
|
|
13
|
+
if (!config) return;
|
|
14
|
+
configs.push(config);
|
|
15
|
+
});
|
|
16
|
+
return configs;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { generateAppBlockConfigs };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { composeSettingsByWidgetType } from './appSetting.js';
|
|
2
|
+
import { getAppBlockType } from './getAppBlockType.js';
|
|
3
|
+
|
|
4
|
+
const getAppBlockConfig = (tag, appBlockId, settings)=>{
|
|
5
|
+
const appBlockType = getAppBlockType({
|
|
6
|
+
tag,
|
|
7
|
+
widgetType: settings?.widgetType
|
|
8
|
+
});
|
|
9
|
+
const settingByWidget = composeSettingsByWidgetType[tag][settings?.widgetType];
|
|
10
|
+
return {
|
|
11
|
+
key: appBlockId,
|
|
12
|
+
value: {
|
|
13
|
+
type: appBlockType,
|
|
14
|
+
...settingByWidget && {
|
|
15
|
+
settings: settingByWidget
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { getAppBlockConfig };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { mapShopifyAppMeta } from './constant.js';
|
|
2
|
+
|
|
3
|
+
const getAppBlockType = ({ tag, widgetType })=>{
|
|
4
|
+
const shopifyAppMeta = mapShopifyAppMeta[tag];
|
|
5
|
+
if (!shopifyAppMeta) return '';
|
|
6
|
+
const { appName, appId } = shopifyAppMeta;
|
|
7
|
+
return `shopify://apps/${appName}/blocks/${widgetType}/${appId}`;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { getAppBlockType };
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { removeMatchingKey } from '../remove-matching-key.js';
|
|
2
|
+
import { addAppBlockId } from './addAppBlockId.js';
|
|
3
|
+
import { generateAppBlockConfigs } from './generateAppBlockConfigs.js';
|
|
4
|
+
|
|
5
|
+
const getAppBlocks = (section, currentBlock, currentBlockOrder)=>{
|
|
6
|
+
const component = JSON.parse(section?.component || '');
|
|
7
|
+
const componentWithAppBlockId = addAppBlockId(component);
|
|
8
|
+
const appBlockConfigs = generateAppBlockConfigs(componentWithAppBlockId);
|
|
9
|
+
if (!appBlockConfigs?.length) {
|
|
10
|
+
return {
|
|
11
|
+
blocks: currentBlock,
|
|
12
|
+
block_order: currentBlockOrder
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
let newBlocks = currentBlock;
|
|
16
|
+
let newBlockOrder = currentBlockOrder;
|
|
17
|
+
appBlockConfigs.forEach(({ key, value })=>{
|
|
18
|
+
const newBlock = {
|
|
19
|
+
[key]: value
|
|
20
|
+
};
|
|
21
|
+
const oldKeyRemovedBlock = removeMatchingKey(newBlocks, key);
|
|
22
|
+
newBlocks = {
|
|
23
|
+
...oldKeyRemovedBlock,
|
|
24
|
+
...newBlock
|
|
25
|
+
};
|
|
26
|
+
newBlockOrder = newBlockOrder ? [
|
|
27
|
+
...newBlockOrder,
|
|
28
|
+
key
|
|
29
|
+
] : [
|
|
30
|
+
key
|
|
31
|
+
];
|
|
32
|
+
});
|
|
33
|
+
return {
|
|
34
|
+
blocks: newBlocks,
|
|
35
|
+
block_order: newBlockOrder
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { getAppBlocks };
|
package/dist/esm/index.js
CHANGED
|
@@ -109,3 +109,5 @@ export { AnimationDirectionType, AnimationEasingType, AnimationSetting, Animatio
|
|
|
109
109
|
export { calculateFirstProduct, getCollection } from './helpers/queries/get-collection.js';
|
|
110
110
|
export { fetchMedias, fetchVariants, getProduct } from './helpers/queries/get-product.js';
|
|
111
111
|
export { getProductBySlug } from './helpers/queries/get-product-by-slug.js';
|
|
112
|
+
export { getAppBlocks } from './helpers/third-party/getAppBlocks.js';
|
|
113
|
+
export { addAppBlockId } from './helpers/third-party/addAppBlockId.js';
|
package/dist/types/index.d.ts
CHANGED
|
@@ -37537,4 +37537,13 @@ type PublishedThemePageSelectFragment = Pick<PublishedThemePage$1, 'id' | 'name'
|
|
|
37537
37537
|
|
|
37538
37538
|
declare const getProductBySlug: (fetcher: FetchFunc, slug?: string) => Promise<ProductSelectFragment>;
|
|
37539
37539
|
|
|
37540
|
-
|
|
37540
|
+
declare const getAppBlocks: (section: PublishedPageSection$1 & {
|
|
37541
|
+
appBlocks: string;
|
|
37542
|
+
}, currentBlock: {}, currentBlockOrder: string[]) => {
|
|
37543
|
+
blocks: {};
|
|
37544
|
+
block_order: string[];
|
|
37545
|
+
};
|
|
37546
|
+
|
|
37547
|
+
declare const addAppBlockId: (component: Component) => Component;
|
|
37548
|
+
|
|
37549
|
+
export { AddOn, AddonProvider, AddonProviderProps, AdvancedType, AliReviewsWidgetType, AlignItemProp, AlignProp, AnimationBaseSetting, AnimationConfig, AnimationDirectionType, AnimationEasingType, AnimationFadeSettingType, AnimationSetting, AnimationSettingType, AnimationShakeSettingType, AnimationSlideSettingType, AnimationTrigger, AnimationTriggerType, AnimationType, AnimationZoomDirectionType, AnimationZoomSettingType, appAPI as AppAPIType, ArticleListProvider, ArticleListProviderProps, ArticleProvider, ArticleProviderProps, Background, BaseProps, BasePropsWrap, BlockEntity, BogosWidgetType, BoldSubscriptionsWidgetType, Border, BorderStyle, BuilderComponentProvider, BuilderComponentProviderProps, BuilderEntity, BuilderEntityNested, BuilderPreviewProvider, BuilderPreviewProviderProps, BuilderProvider, BuilderProviderProps, BuilderState, Builtin, CartLineProvider, CartLineProviderProps, CollectionDetailFilterDocument, CollectionDetailFilterQueryResponse, CollectionDetailFilterQueryVariables, CollectionDocument, CollectionProvider, CollectionProviderProps, CollectionQueryResponse, CollectionQueryVariables, CollectionSelectFragment, CollectionsDocument, CollectionsQueryResponse, CollectionsQueryVariables, ColorKey, ColorType$1 as ColorType, ColorValueType, Component, ComponentPreset, ComponentSetting, ContainerProp, ControlProp, ControlTriggerAction, ControlUI, CornerRadius, CornerRadiusType, CustomComponentConfig, DeepPartial, DynamicCollection, DynamicProduct, ExtractState, FeraReviewsV3WidgetType, FeraReviewsWidgetType, FetchCollectionArgs, FetchFunc, FetchProductParams, FlexDirectionProp, FontName, GRADIENT_BGR_KEY, GlobalStyleConfig, GlobalStyleResponsiveConfig, GlobalSwatchesData, GraphQLConnection, GroupPropType, GrowaveWidgetType, HSLAColorType, HSLColorType, HexColorType, ImageShape$1 as ImageShape, InitComponentType, InstantJudgeMeReviewsWidgetType, InstantKlaviyoWidgetType, InstantLooxReviewsWidgetType, Interaction, InteractionCondition, InteractionElement, InteractionTarget, InteractionTargetEvent, InteractionTargetEventObject, InteractionTriggerEvent, JudgeMeReviewsWidgetType, KlaviyoWidgetType, LaiProductReviewsAdvancedWidgetType, LaiProductReviewsWidgetType, LibrarySaleFunnelDocument, LibrarySaleFunnelQueryResponse, LibrarySaleFunnelQueryVariables, LibraryTemplateDocument, LibraryTemplateQueryResponse, LibraryTemplateQueryVariables, LooxReviewsWidgetType, ModalProvider, ModalProviderProps, NameDevices$1 as NameDevices, NestedKeys, ObjectDeviceGlobalType, ObjectDevices, ObjectLayoutValue, OmnisendWidgetType, OnlyOne, OpinewDesignWidgetType, OpinewWidgetType, OptionNormalStyle, OptionSpecialStyle, Options, PageContext, PageProvider, PageProviderProps, PageType, PageViewUpDocument, PageViewUpMutationResponse, PageViewUpMutationVariables, PickyStoryWidgetType, PostPurchaseTypo, PreviewPageDocument, PreviewPageQueryResponse, PreviewPageQueryVariables, Primitive, ProductInputAnalytic, ProductListProvider, ProductListProviderProps, ProductOffer, ProductProvider, ProductProviderProps, ProductReviewsWidgetType, ProductSelectFragment, ProductsDocument, ProductsQueryResponse, ProductsQueryVariables, PublicStoreFrontData, PublishedThemePageSelectFragment, PublishedThemePagesDocument, PublishedThemePagesQueryResponse, PublishedThemePagesQueryVariables, RGBAColorType, RGBColorType, Ratio$1 as Ratio, RawChild, RenderMemo as Render, RenderChildren, RenderIf, Render as RenderLiquid, RenderMode, RenderPreviewMemo as RenderPreview, RequiredCursorEdge, ResponsiveKey, ResponsiveStateProp, RivyoWidgetType, RoundedSize, RyviuWidgetType, SaleFunnelDiscount$1 as SaleFunnelDiscount, SaleFunnelDiscountEdge$1 as SaleFunnelDiscountEdge, SaleFunnelDiscountObjectType$1 as SaleFunnelDiscountObjectType, SaleFunnelDiscountType$1 as SaleFunnelDiscountType, SaleFunnelDiscountValueType$1 as SaleFunnelDiscountValueType, SaleFunnelDiscountsDocument, SaleFunnelDiscountsQueryResponse, SaleFunnelDiscountsQueryVariables, Scalars$1 as Scalars, ScaleByDirection, SectionData, SectionEntity, SectionProvider, SectionProviderProps, SettingByAnimationType, SettingByAnimationValues, ShadowProps, ShadowStyle, ShadowStyleApplied, ShadowType, ShopProvider, ShopProviderProps, shop as ShopType, SizeProps, SizeSetting, SizeSettingGlobal, SizeType, SpacingType, StampedWidgetType, StateProp, StateSelector, StateType, StoreConfig, StorePropertyDocument, StorePropertyQueryResponse, StorePropertyQueryVariables, SwatchesOptionType, SwatchesOptionValue, ThemePageDocument, ThemePageQueryResponse, ThemePageQueryVariables, ThemeSectionStatus$1 as ThemeSectionStatus, TransformProp, TriggerConfig, TrustooWidgetType, TypographyProps, TypographySetting, TypographySettingV2, TypographyType, TypographyV2Attrs, TypographyV2Props, UltimateSalesBoostWidgetType, VariantSelectFragment, VitalsWidgetType, WiserV2WidgetType, WiserWidgetType, WrapRenderChildren, YotpoReviewsWidgetType, addAppBlockId, animations, baseAssetURL, calculateFirstProduct, checkAvailableVariantInStock, cls, composeAdvanceStyle, composeAdvanceStyleForPostPurchase, composeBackgroundCss, composeBorderCss, composeCornerCss, composeFallbackTypographyStyle, composeFontFamilyTypographyV2, composeGridLayout, composeMemo, composePositionLineHeight, composePostionIconList, composeRadius, composeRadiusResponsive, composeShadowCss, composeSize, composeSizeCss, composeSpacing, composeTextColorCss, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, convertHTML, convertOldLayout, convertTextAlignToJustify, dataStringify, fetchMedias, fetchVariants, filterAttrInStyle, filterCornerInStyle, filterToolbarPreview, flattenConnection, formatMoney, fpixel, genSizeClass, genTypoClass, genVariable, generateCollectionQueryKey, generateProductQueryKey, generateProductsQueryKey, getAppBlocks, getAspectRatioGlobalSize, getBgImageByDevice, getBorderRadiusStyle, getBorderStyle, getCarouselContainerHeight, getCollection, getCornerCSSFromGlobal, getCustomRadius, getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateClassDynamicBtn, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveClassDynamicBtn, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getGlobalSizeGap, getGradientBgrStyleByDevice, getGradientBgrStyleForButton, getHeightByShapeGlobalSize, getPaddingGlobalSize, getProduct, getProductBySlug, getRadiusCSSFromGlobal, getRadiusStyleActiveState, getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen, getSelectedVariant, getShortName, getSingleColorVariable, getSpacingVariable, getStyleBackgroundByDevice, getStyleBgColor, getStyleShadow, getStyleShadowState, getValueByDevice, getWidthByShapeGlobalSize, getWidthHeightGlobalSize, globalEvent, gridToArrayRegex, gtag, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn, isBrowser, isColor, isColumnDirectionExist, isDefined, isEmptyChildren, isLocalEnv, isSafari, loadScript, makeAspectRatio, makeContainerWidthOrHeight, makeDotGapToCarouselStyle, makeFixedBgAttachment, makeGlobalSize, makeGlobalSizeHeightResponsive, makeGlobalSizeIcon, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveByScreen, makeStyleResponsiveState, makeStyleState, makeStyleWithDefault, makeWidth, normalizeBuilderData, optionLayoutStyle, parseSelectedOption, parseValueWithUnit, prefetchQueries, props, removeAttrInStyle, removeNullUndefined, removePaddingYInStyle, removeUndefinedValuesFromObject, shopifyPriceRounding, splitStyle, styles, template, tiktokpixel, useAddToCart, useAddon, useAddons, useArticleListStore, useArticleStore, useArticlesQuery, useBlogsQuery, useBuilderComponent, useBuilderPreviewStore, useBuilderStore, useCartData, useCartDiscountCodesUpdate, useCartId, useCartLine, useCartLineStore, useCartNoteUpdate, useCartUI, useCheckAvailableVariantInStock, useCheckoutUrl, useCollection, useCollectionQuery, useCollectionStore, useCollectionsQuery, useConnectedShopify, useCreateCart, useCurrency, useCurrentDevice, useCurrentVariant, useCurrentVariantInStock, useEditorMode, useFeaturedImageGlobal, useFormatMoney, useInitialSwatchesOptions, useIsSampleProduct, useIsStorefrontProduct, useIsSyncProduct, useIsomorphicLayoutEffect, useLazyVideo, useLoadScript, useLocale, useMatchMutate, useMobileOnly, useModalStore, useMoney, useMoneyFormat, usePageStore, usePageType, usePluginEnable, usePrevious, useProduct, useProductList, useProductListProducts, useProductListSettings, useProductListStore, useProductListStyles, useProductOfferDiscount, useProductProperties, useProductQuery, useProductStore, useProductsQuery, useProductsQueryAll, useQuantity, useRemoveCartItem, useSection, useSectionStore, useSelectedOption, useShopStore, useStoreFront, useSuspenseFetch, useSwatches, useSwatchesOptions, useUniqProductID, useUpdateCartItem, useVariant, useVariantOutStock, useVariants, validateEmail };
|