PluginProbe ʕ •ᴥ•ʔ
Kubio AI Page Builder / 2.8.3
Kubio AI Page Builder v2.8.3
2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.7.0 1.7.1 1.7.2 1.7.3 1.8.0 1.8.1 1.8.2 1.9.0 2.0.0 2.1.1 2.1.2 2.1.3 2.2.0 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.3 2.3.4 2.4.0 2.4.1 2.4.2 2.4.3 2.4.5 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.6.1 2.6.2 2.6.3 2.6.5 2.6.6 2.6.7 2.7.0 2.7.1 2.7.2 2.7.3 2.8.0
kubio / defaults / style-manager-web-worker-template.js
kubio / defaults Last commit date
recommendations-pages 1 year ago recommendations-templates 1 year ago supported-themes-templates 4 years ago default-image.png 4 years ago default-site.dat 1 year ago global-data.json 2 years ago settings.php 4 years ago style-manager-web-worker-template.js 1 month ago
style-manager-web-worker-template.js
115 lines
1 // defaults and polyfills
2 // eslint-disable-next-line no-undef
3 window = self;
4 // eslint-disable-next-line no-undef
5 top = self;
6 const kubioNoop = function () {};
7
8 document = {
9 createElement() {
10 return {
11 style: [],
12 setAttribute: kubioNoop,
13 attachEvent: kubioNoop,
14 appendChild: kubioNoop,
15 };
16 },
17 createTextNode: kubioNoop,
18 attachEvent: kubioNoop,
19 addEventListener: kubioNoop,
20 querySelectorAll() {
21 return [];
22 },
23 };
24 const emptyNodeStructure = {
25 addEventListener: kubioNoop,
26 appendChild: kubioNoop,
27 querySelectorAll() {
28 return [];
29 },
30 querySelector() {
31 return null;
32 },
33 };
34 document.head = emptyNodeStructure;
35 document.body = emptyNodeStructure;
36
37 // wp imported scripts need to load kubio-style-manager
38 // {{{importScriptsPlaceholder}}}
39
40 const fonts = {};
41
42 // eslint-disable-next-line no-undef
43 wp.hooks.addAction(
44 'kubio.google-fonts.load',
45 'kubio.google-fonts.load',
46 function ( nextFonts ) {
47 nextFonts.forEach( function ( font ) {
48 fonts[ font.family ] = fonts[ font.family ] || [];
49 // eslint-disable-next-line no-undef
50 fonts[ font.family ] = lodash.uniq(
51 fonts[ font.family ].concat( font.variants )
52 );
53 } );
54 }
55 );
56
57 const renderStyle = function ( payload ) {
58 // eslint-disable-next-line no-undef
59 const dynamicStyle = lodash.get( payload.data, 'dynamicStyle', {} );
60
61 // eslint-disable-next-line no-undef
62 const renderer = new kubio.styleManager.BlockStyleRender(
63 // eslint-disable-next-line no-undef
64 lodash.omit( payload.data, 'dynamicStyle' ),
65 payload.parentDetails,
66 payload.canUseHtml,
67 payload.document || null
68 );
69
70 const styleRef = renderer.model ? renderer.model.styleRef : null;
71 const localId = renderer.model ? renderer.model.id : null;
72
73 return {
74 css: renderer.export(),
75 dynamicRules: renderer.exportDynamicStyle( dynamicStyle ),
76 styleRef,
77 localId,
78 responseHash: payload.hash,
79 fonts: Object.keys( fonts ).map( ( family ) => ( {
80 family,
81 variants: fonts[ family ],
82 } ) ),
83 };
84 };
85
86 // actual web worker runner
87 // eslint-disable-next-line no-undef
88 self.addEventListener( 'message', ( event ) => {
89 const action = event.data.action;
90 const hash = event.data.hash;
91 const payload = lodash.isObject( event.data.payload )
92 ? event.data.payload
93 : JSON.parse( event.data.payload );
94
95 let response = null;
96
97 switch ( action ) {
98 case 'EXPORT_CSS':
99 response = renderStyle( payload );
100 break;
101 case 'TEST':
102 response = 'test';
103 break;
104 }
105
106 // eslint-disable-next-line no-undef
107 self.postMessage( {
108 hash,
109 payload: response,
110 } );
111 } );
112
113 // eslint-disable-next-line no-undef
114 self.postMessage( 'WORKER_LOADED' );
115