@fragmentsx/render-web 0.1.0 → 0.1.2
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.cjs.js +32 -12
- package/dist/index.es.js +32 -12
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -2083,6 +2083,8 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2083
2083
|
return {
|
|
2084
2084
|
query: `query($areaCodes: [String!]!) {
|
|
2085
2085
|
clientAreas(areaCodes: $areaCodes) {
|
|
2086
|
+
areaProperties
|
|
2087
|
+
projectProperties
|
|
2086
2088
|
variant {
|
|
2087
2089
|
fragment {
|
|
2088
2090
|
props
|
|
@@ -2104,13 +2106,18 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2104
2106
|
};
|
|
2105
2107
|
};
|
|
2106
2108
|
const fetchPlugin = (state) => {
|
|
2107
|
-
var _a, _b, _c;
|
|
2109
|
+
var _a, _b, _c, _d;
|
|
2108
2110
|
const isSelf = ((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf) ?? false;
|
|
2109
2111
|
const url = (_b = state == null ? void 0 : state.env) == null ? void 0 : _b.backendEndpoint;
|
|
2110
2112
|
const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
|
|
2111
|
-
const
|
|
2113
|
+
const referer = (_d = state == null ? void 0 : state.env) == null ? void 0 : _d.referer;
|
|
2114
|
+
let headers = {
|
|
2112
2115
|
Authorization: `Bearer ${apiToken}`
|
|
2113
|
-
}
|
|
2116
|
+
};
|
|
2117
|
+
if (referer) {
|
|
2118
|
+
headers.Referer = referer;
|
|
2119
|
+
}
|
|
2120
|
+
const fetcher = createFetcher(url, headers);
|
|
2114
2121
|
const beaconFetcher = fetchBeacon();
|
|
2115
2122
|
const queryFragment = async (fragmentId) => {
|
|
2116
2123
|
var _a2;
|
|
@@ -2184,9 +2191,16 @@ const fetchPlugin = (state) => {
|
|
|
2184
2191
|
)
|
|
2185
2192
|
);
|
|
2186
2193
|
}
|
|
2194
|
+
const resultProps = [
|
|
2195
|
+
...area.projectProperties ?? [],
|
|
2196
|
+
...area.areaProperties ?? []
|
|
2197
|
+
].reduce((acc, prop) => {
|
|
2198
|
+
acc[prop._id] = prop.defaultValue;
|
|
2199
|
+
return acc;
|
|
2200
|
+
}, area.variant.fragment.props);
|
|
2187
2201
|
const entity = {
|
|
2188
2202
|
fragmentId: area.variant.fragment.fragment.id,
|
|
2189
|
-
props:
|
|
2203
|
+
props: resultProps
|
|
2190
2204
|
};
|
|
2191
2205
|
state.$fetch.cacheAreaDocuments.set(areaCode, entity);
|
|
2192
2206
|
});
|
|
@@ -2336,7 +2350,8 @@ function generateSmallerCssBlocks(layerResolver, group, cssMaker) {
|
|
|
2336
2350
|
(smallerLayer, index2, arr) => {
|
|
2337
2351
|
const smallerChildren = getAllChildren(layerResolver, smallerLayer);
|
|
2338
2352
|
const smallerCssBlocks = smallerChildren.map(cssMaker);
|
|
2339
|
-
const
|
|
2353
|
+
const primaryLayer = layerResolver(group.primary);
|
|
2354
|
+
const max = index2 === 0 ? (primaryLayer == null ? void 0 : primaryLayer.width) - 1 : arr[index2 - 1].width;
|
|
2340
2355
|
return `@container (max-width: ${max}px) {${smallerCssBlocks.map(buildCssBlock).join("")}}`;
|
|
2341
2356
|
}
|
|
2342
2357
|
);
|
|
@@ -2419,7 +2434,7 @@ const fragmentStylesheetPlugin = (state) => {
|
|
|
2419
2434
|
};
|
|
2420
2435
|
return state;
|
|
2421
2436
|
};
|
|
2422
|
-
const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
|
|
2437
|
+
const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
|
|
2423
2438
|
const globalStylesheetPlugin = (state) => {
|
|
2424
2439
|
if (!("$fragments" in state)) {
|
|
2425
2440
|
throw new Error("GlobalStylesheetPlugin need $fragments plugin");
|
|
@@ -2695,7 +2710,6 @@ const loadPlugin = (state) => {
|
|
|
2695
2710
|
const loader = async () => {
|
|
2696
2711
|
var _a2;
|
|
2697
2712
|
const areaEntity = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryArea(areaCode));
|
|
2698
|
-
console.log(areaEntity);
|
|
2699
2713
|
await loadFragment(areaEntity == null ? void 0 : areaEntity.fragmentId, {
|
|
2700
2714
|
suspense: false
|
|
2701
2715
|
});
|
|
@@ -2736,8 +2750,9 @@ const createFragmentsClient = (options) => {
|
|
|
2736
2750
|
(state) => {
|
|
2737
2751
|
state.env = {
|
|
2738
2752
|
isSelf: (options == null ? void 0 : options.isSelf) ?? false,
|
|
2739
|
-
backendEndpoint: BACKEND_TARGET,
|
|
2740
|
-
apiToken: options == null ? void 0 : options.apiToken
|
|
2753
|
+
backendEndpoint: (options == null ? void 0 : options.backendEndpoint) ?? BACKEND_TARGET,
|
|
2754
|
+
apiToken: options == null ? void 0 : options.apiToken,
|
|
2755
|
+
referer: options == null ? void 0 : options.referer
|
|
2741
2756
|
};
|
|
2742
2757
|
},
|
|
2743
2758
|
fetchPlugin,
|
|
@@ -5403,12 +5418,17 @@ const useReadVariable = (variableKey) => {
|
|
|
5403
5418
|
layer: null
|
|
5404
5419
|
};
|
|
5405
5420
|
}
|
|
5406
|
-
|
|
5421
|
+
let instanceScope = scopes.findLast(
|
|
5407
5422
|
(scope) => {
|
|
5408
5423
|
var _a2;
|
|
5409
5424
|
return (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
5410
5425
|
}
|
|
5411
5426
|
);
|
|
5427
|
+
if (!instanceScope) {
|
|
5428
|
+
instanceScope = scopes.find(
|
|
5429
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope
|
|
5430
|
+
);
|
|
5431
|
+
}
|
|
5412
5432
|
const variableLayer = resolveVariableLayer(
|
|
5413
5433
|
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
5414
5434
|
variableKey2
|
|
@@ -5832,8 +5852,8 @@ const useLayerStyles = (layerKey) => {
|
|
|
5832
5852
|
...layout,
|
|
5833
5853
|
...layerSize,
|
|
5834
5854
|
...textStyles,
|
|
5835
|
-
display
|
|
5836
|
-
"user-select": "none"
|
|
5855
|
+
display
|
|
5856
|
+
// "user-select": "none",
|
|
5837
5857
|
// ...cssOverride,
|
|
5838
5858
|
};
|
|
5839
5859
|
} catch (e2) {
|
package/dist/index.es.js
CHANGED
|
@@ -2082,6 +2082,8 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2082
2082
|
return {
|
|
2083
2083
|
query: `query($areaCodes: [String!]!) {
|
|
2084
2084
|
clientAreas(areaCodes: $areaCodes) {
|
|
2085
|
+
areaProperties
|
|
2086
|
+
projectProperties
|
|
2085
2087
|
variant {
|
|
2086
2088
|
fragment {
|
|
2087
2089
|
props
|
|
@@ -2103,13 +2105,18 @@ const getAreaListQuery = (areaCodes) => {
|
|
|
2103
2105
|
};
|
|
2104
2106
|
};
|
|
2105
2107
|
const fetchPlugin = (state) => {
|
|
2106
|
-
var _a, _b, _c;
|
|
2108
|
+
var _a, _b, _c, _d;
|
|
2107
2109
|
const isSelf = ((_a = state == null ? void 0 : state.env) == null ? void 0 : _a.isSelf) ?? false;
|
|
2108
2110
|
const url = (_b = state == null ? void 0 : state.env) == null ? void 0 : _b.backendEndpoint;
|
|
2109
2111
|
const apiToken = (_c = state == null ? void 0 : state.env) == null ? void 0 : _c.apiToken;
|
|
2110
|
-
const
|
|
2112
|
+
const referer = (_d = state == null ? void 0 : state.env) == null ? void 0 : _d.referer;
|
|
2113
|
+
let headers = {
|
|
2111
2114
|
Authorization: `Bearer ${apiToken}`
|
|
2112
|
-
}
|
|
2115
|
+
};
|
|
2116
|
+
if (referer) {
|
|
2117
|
+
headers.Referer = referer;
|
|
2118
|
+
}
|
|
2119
|
+
const fetcher = createFetcher(url, headers);
|
|
2113
2120
|
const beaconFetcher = fetchBeacon();
|
|
2114
2121
|
const queryFragment = async (fragmentId) => {
|
|
2115
2122
|
var _a2;
|
|
@@ -2183,9 +2190,16 @@ const fetchPlugin = (state) => {
|
|
|
2183
2190
|
)
|
|
2184
2191
|
);
|
|
2185
2192
|
}
|
|
2193
|
+
const resultProps = [
|
|
2194
|
+
...area.projectProperties ?? [],
|
|
2195
|
+
...area.areaProperties ?? []
|
|
2196
|
+
].reduce((acc, prop) => {
|
|
2197
|
+
acc[prop._id] = prop.defaultValue;
|
|
2198
|
+
return acc;
|
|
2199
|
+
}, area.variant.fragment.props);
|
|
2186
2200
|
const entity = {
|
|
2187
2201
|
fragmentId: area.variant.fragment.fragment.id,
|
|
2188
|
-
props:
|
|
2202
|
+
props: resultProps
|
|
2189
2203
|
};
|
|
2190
2204
|
state.$fetch.cacheAreaDocuments.set(areaCode, entity);
|
|
2191
2205
|
});
|
|
@@ -2335,7 +2349,8 @@ function generateSmallerCssBlocks(layerResolver, group, cssMaker) {
|
|
|
2335
2349
|
(smallerLayer, index2, arr) => {
|
|
2336
2350
|
const smallerChildren = getAllChildren(layerResolver, smallerLayer);
|
|
2337
2351
|
const smallerCssBlocks = smallerChildren.map(cssMaker);
|
|
2338
|
-
const
|
|
2352
|
+
const primaryLayer = layerResolver(group.primary);
|
|
2353
|
+
const max = index2 === 0 ? (primaryLayer == null ? void 0 : primaryLayer.width) - 1 : arr[index2 - 1].width;
|
|
2339
2354
|
return `@container (max-width: ${max}px) {${smallerCssBlocks.map(buildCssBlock).join("")}}`;
|
|
2340
2355
|
}
|
|
2341
2356
|
);
|
|
@@ -2418,7 +2433,7 @@ const fragmentStylesheetPlugin = (state) => {
|
|
|
2418
2433
|
};
|
|
2419
2434
|
return state;
|
|
2420
2435
|
};
|
|
2421
|
-
const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
|
|
2436
|
+
const globalCss = '[data-key^="Fragment"] {\n [data-key^="Text"] {\n p {\n margin: 0;\n font-size: 14px;\n color: #000;\n font-weight: 400;\n }\n }\n\n ul, ol {\n padding: 0;\n }\n\n /* 1. Use a more-intuitive box-sizing model */\n\n *, *::before, *::after {\n box-sizing: border-box;\n }\n\n /* 2. Remove default margin */\n\n * {\n margin: 0;\n }\n\n /* 3. Enable keyword animations */\n @media (prefers-reduced-motion: no-preference) {\n html {\n interpolate-size: allow-keywords;\n }\n }\n\n body {\n /* 4. Add accessible line-height */\n line-height: 1.5;\n /* 5. Improve text rendering */\n -webkit-font-smoothing: antialiased;\n }\n\n /* 6. Improve media defaults */\n\n img, picture, video, canvas, svg {\n display: block;\n max-width: 100%;\n }\n\n /* 7. Inherit fonts for form controls */\n\n input, button, textarea, select {\n font: inherit;\n }\n\n /* 8. Avoid text overflows */\n\n p, h1, h2, h3, h4, h5, h6 {\n overflow-wrap: break-word;\n }\n\n /*\n 10. Create a root stacking context\n */\n\n #root, #__next {\n isolation: isolate;\n }\n\n a {\n text-decoration: none;\n }\n}\n';
|
|
2422
2437
|
const globalStylesheetPlugin = (state) => {
|
|
2423
2438
|
if (!("$fragments" in state)) {
|
|
2424
2439
|
throw new Error("GlobalStylesheetPlugin need $fragments plugin");
|
|
@@ -2694,7 +2709,6 @@ const loadPlugin = (state) => {
|
|
|
2694
2709
|
const loader = async () => {
|
|
2695
2710
|
var _a2;
|
|
2696
2711
|
const areaEntity = await ((_a2 = state == null ? void 0 : state.$fetch) == null ? void 0 : _a2.queryArea(areaCode));
|
|
2697
|
-
console.log(areaEntity);
|
|
2698
2712
|
await loadFragment(areaEntity == null ? void 0 : areaEntity.fragmentId, {
|
|
2699
2713
|
suspense: false
|
|
2700
2714
|
});
|
|
@@ -2735,8 +2749,9 @@ const createFragmentsClient = (options) => {
|
|
|
2735
2749
|
(state) => {
|
|
2736
2750
|
state.env = {
|
|
2737
2751
|
isSelf: (options == null ? void 0 : options.isSelf) ?? false,
|
|
2738
|
-
backendEndpoint: BACKEND_TARGET,
|
|
2739
|
-
apiToken: options == null ? void 0 : options.apiToken
|
|
2752
|
+
backendEndpoint: (options == null ? void 0 : options.backendEndpoint) ?? BACKEND_TARGET,
|
|
2753
|
+
apiToken: options == null ? void 0 : options.apiToken,
|
|
2754
|
+
referer: options == null ? void 0 : options.referer
|
|
2740
2755
|
};
|
|
2741
2756
|
},
|
|
2742
2757
|
fetchPlugin,
|
|
@@ -5402,12 +5417,17 @@ const useReadVariable = (variableKey) => {
|
|
|
5402
5417
|
layer: null
|
|
5403
5418
|
};
|
|
5404
5419
|
}
|
|
5405
|
-
|
|
5420
|
+
let instanceScope = scopes.findLast(
|
|
5406
5421
|
(scope) => {
|
|
5407
5422
|
var _a2;
|
|
5408
5423
|
return (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope && !!((_a2 = scope.documentManager) == null ? void 0 : _a2.resolve(variableKey2));
|
|
5409
5424
|
}
|
|
5410
5425
|
);
|
|
5426
|
+
if (!instanceScope) {
|
|
5427
|
+
instanceScope = scopes.find(
|
|
5428
|
+
(scope) => (scope == null ? void 0 : scope.type) === index.scopeTypes.InstanceScope
|
|
5429
|
+
);
|
|
5430
|
+
}
|
|
5411
5431
|
const variableLayer = resolveVariableLayer(
|
|
5412
5432
|
instanceScope == null ? void 0 : instanceScope.documentManager,
|
|
5413
5433
|
variableKey2
|
|
@@ -5831,8 +5851,8 @@ const useLayerStyles = (layerKey) => {
|
|
|
5831
5851
|
...layout,
|
|
5832
5852
|
...layerSize,
|
|
5833
5853
|
...textStyles,
|
|
5834
|
-
display
|
|
5835
|
-
"user-select": "none"
|
|
5854
|
+
display
|
|
5855
|
+
// "user-select": "none",
|
|
5836
5856
|
// ...cssOverride,
|
|
5837
5857
|
};
|
|
5838
5858
|
} catch (e2) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fragmentsx/render-web",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist"
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@graph-state/checkers": "^0.1.2",
|
|
26
26
|
"@graph-state/core": "^0.13.0",
|
|
27
|
+
"@fragmentsx/client-core": "0.1.2",
|
|
27
28
|
"@fragmentsx/definition": "0.1.0",
|
|
28
29
|
"@fragmentsx/render-core": "0.1.0",
|
|
29
|
-
"@fragmentsx/utils": "0.1.0"
|
|
30
|
-
"@fragmentsx/client-core": "0.1.0"
|
|
30
|
+
"@fragmentsx/utils": "0.1.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@graph-state/plugin-logger": "^0.3.0",
|