@windycom/plugin-devtools 1.0.1
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/README.md +3 -0
- package/index.mjs +298 -0
- package/package.json +9 -0
- package/publishExamples.sh +19 -0
- package/types/AromeProduct.d.ts +5 -0
- package/types/Bar.d.ts +114 -0
- package/types/BindedBar.d.ts +51 -0
- package/types/BindedCheckbox.d.ts +30 -0
- package/types/BindedSwitch.d.ts +35 -0
- package/types/BottomSlide.d.ts +53 -0
- package/types/BottomTagPlugin.d.ts +8 -0
- package/types/Calendar.d.ts +149 -0
- package/types/ClickHandler.d.ts +19 -0
- package/types/Color.d.ts +175 -0
- package/types/DataTiler.d.ts +41 -0
- package/types/Drag.d.ts +43 -0
- package/types/DraggableDiv.d.ts +21 -0
- package/types/DropDown.d.ts +37 -0
- package/types/EcmwfAnalysisProduct.d.ts +5 -0
- package/types/EcmwfProduct.d.ts +29 -0
- package/types/Evented.d.ts +78 -0
- package/types/ExternalSveltePlugin.d.ts +29 -0
- package/types/Favs.d.ts +83 -0
- package/types/GhostBox.d.ts +17 -0
- package/types/GlObj.d.ts +252 -0
- package/types/HrrrProducts.d.ts +5 -0
- package/types/IconProducts.d.ts +5 -0
- package/types/LabelsLayer.d.ts +2 -0
- package/types/LandMask.d.ts +2 -0
- package/types/Layer.d.ts +137 -0
- package/types/Legend.d.ts +6 -0
- package/types/LongTap.d.ts +21 -0
- package/types/Metric.d.ts +132 -0
- package/types/MetricClasses.d.ts +37 -0
- package/types/MobileCalendar.d.ts +47 -0
- package/types/NamProducts.d.ts +5 -0
- package/types/OfflineMessagesClasses.d.ts +30 -0
- package/types/Overlay.d.ts +150 -0
- package/types/OverlayClasses.d.ts +29 -0
- package/types/Particles.d.ts +111 -0
- package/types/Plugin.d.ts +112 -0
- package/types/Product.d.ts +211 -0
- package/types/ProductSwitch.d.ts +14 -0
- package/types/Renderer.d.ts +69 -0
- package/types/SatelliteProduct.d.ts +19 -0
- package/types/Scrollable.d.ts +14 -0
- package/types/StaticProduct.d.ts +7 -0
- package/types/SveltePanePlugin.d.ts +18 -0
- package/types/SveltePlugin.d.ts +40 -0
- package/types/Swipe.d.ts +34 -0
- package/types/Switch.d.ts +24 -0
- package/types/TagPlugin.d.ts +6 -0
- package/types/TileLayer.d.ts +9 -0
- package/types/TileLayerCanvas.d.ts +2 -0
- package/types/TileLayerMultiPatch.d.ts +2 -0
- package/types/TimestampBar.d.ts +8 -0
- package/types/Webcams.d.ts +66 -0
- package/types/Window.d.ts +107 -0
- package/types/WindowPlugin.d.ts +171 -0
- package/types/baseMap.d.ts +10 -0
- package/types/broadcast.d.ts +14 -0
- package/types/cityLabels.d.ts +2 -0
- package/types/cloudSync.d.ts +12 -0
- package/types/colors.d.ts +4 -0
- package/types/connection.d.ts +4 -0
- package/types/css.d.ts +25 -0
- package/types/dataLoader.d.ts +26 -0
- package/types/dataSpecifications.d.ts +12 -0
- package/types/detectDevice.d.ts +6 -0
- package/types/device.d.ts +19 -0
- package/types/deviceLogging.d.ts +13 -0
- package/types/fetch.d.ts +88 -0
- package/types/format.d.ts +102 -0
- package/types/ga.d.ts +1 -0
- package/types/geolocation.d.ts +30 -0
- package/types/glTileRender.d.ts +178 -0
- package/types/glsl-modules.d.ts +26 -0
- package/types/hp.d.ts +15 -0
- package/types/http.d.ts +62 -0
- package/types/iconfont.d.ts +196 -0
- package/types/index.d.ts +1 -0
- package/types/interfaces.d.ts +1727 -0
- package/types/interpolator.d.ts +19 -0
- package/types/lang-files.d.ts +5116 -0
- package/types/latestBroadcasts.d.ts +14 -0
- package/types/layers.d.ts +78 -0
- package/types/leaflet.d.ts +1919 -0
- package/types/legends.d.ts +6 -0
- package/types/levelUtils.d.ts +2 -0
- package/types/libGuard.d.ts +1 -0
- package/types/location.d.ts +72 -0
- package/types/log.d.ts +2 -0
- package/types/lruCache.d.ts +69 -0
- package/types/map.d.ts +80 -0
- package/types/metrics.d.ts +3 -0
- package/types/mobileUtils.d.ts +7 -0
- package/types/models.d.ts +42 -0
- package/types/node-modules.d.ts +16 -0
- package/types/notifications.d.ts +66 -0
- package/types/offlineController.d.ts +20 -0
- package/types/overlays.d.ts +67 -0
- package/types/particleRenderers.d.ts +4 -0
- package/types/permanentPromos.d.ts +2 -0
- package/types/picker.d.ts +66 -0
- package/types/plugins.d.ts +3 -0
- package/types/pois.d.ts +16 -0
- package/types/products.d.ts +3 -0
- package/types/promo.d.ts +37 -0
- package/types/query.d.ts +19 -0
- package/types/queryString.d.ts +2 -0
- package/types/renderCtrl.d.ts +8 -0
- package/types/renderTile.d.ts +6 -0
- package/types/renderUtils.d.ts +107 -0
- package/types/renderers.d.ts +20 -0
- package/types/reverseName.d.ts +10 -0
- package/types/rhMessage.d.ts +3 -0
- package/types/rootScope.d.ts +152 -0
- package/types/router.d.ts +30 -0
- package/types/seoParser.d.ts +19 -0
- package/types/share.d.ts +1 -0
- package/types/showableErrorsService.d.ts +31 -0
- package/types/singleclick.d.ts +52 -0
- package/types/storage.d.ts +3 -0
- package/types/store.d.ts +148 -0
- package/types/subscription.d.ts +65 -0
- package/types/tileInterpolator.d.ts +27 -0
- package/types/tileLayerInstance.d.ts +2 -0
- package/types/timestampUtils.d.ts +5 -0
- package/types/trans.d.ts +68 -0
- package/types/ts-interfaces.d.ts +66 -0
- package/types/ts-types.d.ts +43 -0
- package/types/types.d.ts +308 -0
- package/types/user.d.ts +54 -0
- package/types/userFavs.d.ts +129 -0
- package/types/utils.d.ts +424 -0
- package/types/variables.d.ts +238 -0
- package/types/windy-modules.d.ts +7 -0
package/README.md
ADDED
package/index.mjs
ADDED
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// Transferred via https://transform.tools/typescript-to-javascript
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import assert from 'assert';
|
|
4
|
+
import MagicString from 'magic-string';
|
|
5
|
+
import { walk } from 'estree-walker';
|
|
6
|
+
|
|
7
|
+
const testLoadedPlugin = config => {
|
|
8
|
+
const { name, version, title, desktopUI, mobileUI, routerPath, icon } = config;
|
|
9
|
+
|
|
10
|
+
assert(
|
|
11
|
+
typeof name === 'string' && /^windy-plugin-([a-z0-9-]+)$/.test(name),
|
|
12
|
+
'Plugin name MUST be prefixed with windy-plugin- string and can contain only lowercase letters, numbers and dashes',
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
assert(
|
|
16
|
+
typeof version === 'string' && version.match(/^\d+\.\d+\.\d+$/),
|
|
17
|
+
'Plugin version is not defined or is not in semversion format (example: 1.3.7)',
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
assert(
|
|
21
|
+
typeof icon === 'string' && /^.$/u.test(icon),
|
|
22
|
+
'Plugin icon MUSt be just single emoji character',
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
assert(
|
|
26
|
+
!routerPath ||
|
|
27
|
+
(typeof routerPath === 'string' &&
|
|
28
|
+
routerPath.length > 4 &&
|
|
29
|
+
/^\/[a-z0-9-/:?]+$/.test(routerPath)),
|
|
30
|
+
'Router path MUST be longer than 4 characters and can contain only lowercase letters, numbers and dashes (example hello-world). It must have leading slash "/".',
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
assert(
|
|
34
|
+
typeof title === 'string' && title.length > 7 && title.length < 50,
|
|
35
|
+
'Plugin title is not defined or is too short or too long',
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
assert(
|
|
39
|
+
typeof desktopUI === 'string' && desktopUI.match(/^(rhpane|embedded)$/),
|
|
40
|
+
'Plugin desktopUI is not defined or is not one of allowed values',
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
assert(
|
|
44
|
+
typeof mobileUI === 'string' && mobileUI.match(/^(fullscreen|small|embedded)$/),
|
|
45
|
+
'Plugin mobileUI is not defined or is not one of allowed values',
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Replaces @windy/, @plugins/ virtual imports in the given AST with the appropriate code modifications.
|
|
51
|
+
*
|
|
52
|
+
* @param ast - The Abstract Syntax Tree (AST) representing the code.
|
|
53
|
+
* @param msCode - The MagicString object representing the code with source maps.
|
|
54
|
+
*/
|
|
55
|
+
const replaceVirualImports = (ast, msCode) => {
|
|
56
|
+
walk(ast, {
|
|
57
|
+
enter(node) {
|
|
58
|
+
if (node.type === 'ImportDeclaration') {
|
|
59
|
+
const source = node.source.value?.toString() || '';
|
|
60
|
+
const { start, end, specifiers } = node;
|
|
61
|
+
|
|
62
|
+
const removeEmptyImpoert = () => {
|
|
63
|
+
const originalString = msCode.slice(start, end);
|
|
64
|
+
msCode.overwrite(
|
|
65
|
+
start,
|
|
66
|
+
end,
|
|
67
|
+
`// transformCode (empty import): ${originalString}`,
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (source.startsWith('@windy/')) {
|
|
72
|
+
if (!specifiers || !specifiers.length) {
|
|
73
|
+
// Empty useless import line like: import '@windy/whatever';
|
|
74
|
+
removeEmptyImpoert();
|
|
75
|
+
} else {
|
|
76
|
+
const originalString = msCode.slice(start, end);
|
|
77
|
+
const windyModuleId = source.replace('@windy/', '');
|
|
78
|
+
let newCode = `// transformCode: ${originalString}\n`;
|
|
79
|
+
|
|
80
|
+
const multipleSpecifiers = [];
|
|
81
|
+
for (const specifier of specifiers) {
|
|
82
|
+
if (specifier.type === 'ImportSpecifier') {
|
|
83
|
+
// named imports
|
|
84
|
+
if (specifier.imported.name === specifier.local.name) {
|
|
85
|
+
multipleSpecifiers.push(specifier.local.name);
|
|
86
|
+
} else {
|
|
87
|
+
multipleSpecifiers.push(
|
|
88
|
+
`${specifier.imported.name}: ${specifier.local.name}`,
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
} else {
|
|
92
|
+
// default import, or import to one variable
|
|
93
|
+
newCode += `const ${specifier.local.name} = W.${windyModuleId};\n`;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (multipleSpecifiers.length) {
|
|
97
|
+
newCode += `const { ${multipleSpecifiers.join(
|
|
98
|
+
', ',
|
|
99
|
+
)} } = W.${windyModuleId};\n`;
|
|
100
|
+
}
|
|
101
|
+
msCode.overwrite(start, end, newCode);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Replaces the export statements in the given AST with a modified export statement.
|
|
111
|
+
* If no export statements are found, a new export statement is added.
|
|
112
|
+
*
|
|
113
|
+
* @param ast - The Abstract Syntax Tree (AST) of the code.
|
|
114
|
+
* @param msCode - The MagicString instance representing the code.
|
|
115
|
+
* @param addedLiterars - An array of additional literals to be exported.
|
|
116
|
+
*/
|
|
117
|
+
const replaceExports = (ast, msCode, addedLiterars) => {
|
|
118
|
+
let exportWasReplaced = false;
|
|
119
|
+
walk(ast, {
|
|
120
|
+
enter(node) {
|
|
121
|
+
if (node.type === 'ExportNamedDeclaration') {
|
|
122
|
+
const { start, end, specifiers } = node;
|
|
123
|
+
const specifierLiterals = specifiers?.map(s => {
|
|
124
|
+
if (s.local.name === s.exported.name) {
|
|
125
|
+
return s.local.name;
|
|
126
|
+
} else {
|
|
127
|
+
return `${s.local.name} as ${s.exported.name}`;
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const newExports = [...addedLiterars, ...specifierLiterals];
|
|
131
|
+
const newCode = `\n// transformCode: Export statement was modified\nexport { ${newExports.join(
|
|
132
|
+
', ',
|
|
133
|
+
)} };\n`;
|
|
134
|
+
msCode.append(newCode);
|
|
135
|
+
msCode.remove(start, end);
|
|
136
|
+
exportWasReplaced = true;
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
|
|
141
|
+
if (!exportWasReplaced) {
|
|
142
|
+
const newCode = `\n// transformCode: Export statement was added\nexport { ${addedLiterars.join(
|
|
143
|
+
', ',
|
|
144
|
+
)} };\n`;
|
|
145
|
+
msCode.append(newCode);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Transforms the code based on the provided parameters.
|
|
151
|
+
*/
|
|
152
|
+
const transformCode = async (code, sourcemaps, pluginContext, path, output) => {
|
|
153
|
+
const ast = pluginContext.parse(code);
|
|
154
|
+
const msCode = new MagicString(code);
|
|
155
|
+
|
|
156
|
+
replaceVirualImports(ast, msCode);
|
|
157
|
+
|
|
158
|
+
const configPath = `${path}/pluginConfig.ts`;
|
|
159
|
+
let screenshot;
|
|
160
|
+
|
|
161
|
+
// Copy screenshot.jpg/png/webp/jpeg to the output directory
|
|
162
|
+
try {
|
|
163
|
+
for (const type of ['jpg', 'png', 'webp', 'jpeg']) {
|
|
164
|
+
const screenshotPath = `${path}/screenshot.${type}`;
|
|
165
|
+
if (fs.existsSync(screenshotPath)) {
|
|
166
|
+
fs.copyFileSync(screenshotPath, `${output}/screenshot.${type}`);
|
|
167
|
+
screenshot = `screenshot.${type}`;
|
|
168
|
+
break;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} catch (e) {
|
|
172
|
+
console.error(`Error while copying screenshot`, e);
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
try {
|
|
176
|
+
// This part of code reads the pluginConfig.ts file and
|
|
177
|
+
// make the most stupid regex/eval extracting of the object
|
|
178
|
+
// properties. It is not perfect, but it works.
|
|
179
|
+
const configFile = fs.readFileSync(configPath, 'utf8');
|
|
180
|
+
const getObjectParser = /^[^{]+(?<body>{(?:[^}]*name:[^}]+)+})[^}]+$/gm; // https://regex101.com/r/0VX3vT/2
|
|
181
|
+
const dirtyBody = getObjectParser.exec(configFile)?.groups?.body;
|
|
182
|
+
const pluginConfig = eval(`(${dirtyBody})`);
|
|
183
|
+
|
|
184
|
+
testLoadedPlugin(pluginConfig);
|
|
185
|
+
|
|
186
|
+
pluginConfig.built = Date.now();
|
|
187
|
+
pluginConfig.builtReadable = new Date().toISOString();
|
|
188
|
+
pluginConfig.screenshot = screenshot;
|
|
189
|
+
|
|
190
|
+
const formattedConfig = JSON.stringify(pluginConfig, undefined, 2);
|
|
191
|
+
|
|
192
|
+
fs.writeFileSync(`${output}/plugin.json`, formattedConfig);
|
|
193
|
+
|
|
194
|
+
msCode.prepend(`const __pluginConfig = ${formattedConfig};\n\n`);
|
|
195
|
+
} catch (e) {
|
|
196
|
+
console.error(`Error while opening and parsing ${configPath}`, e);
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
replaceExports(ast, msCode, ['__pluginConfig']);
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
code: msCode.toString(),
|
|
204
|
+
map: sourcemaps ? msCode.generateMap({ hires: true }) : undefined,
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Creates a Rollup plugin that transforms code to ESM format with our enhancements
|
|
210
|
+
* @returns The Rollup plugin.
|
|
211
|
+
*/
|
|
212
|
+
export function transformCodeToESMPlugin() {
|
|
213
|
+
let shouldGenerateSourcemaps = false;
|
|
214
|
+
let outputDirectory = null;
|
|
215
|
+
return {
|
|
216
|
+
name: 'transform-to-esm-plugin',
|
|
217
|
+
options(options) {
|
|
218
|
+
const outputOptions = Array.isArray(options.output)
|
|
219
|
+
? options.output[0]
|
|
220
|
+
: options.output ?? {};
|
|
221
|
+
|
|
222
|
+
shouldGenerateSourcemaps = Boolean(outputOptions.sourcemap);
|
|
223
|
+
outputDirectory = outputOptions.file.replace(/\/[^/]+$/, '');
|
|
224
|
+
|
|
225
|
+
return undefined;
|
|
226
|
+
},
|
|
227
|
+
renderChunk(code, chunk) {
|
|
228
|
+
const { facadeModuleId } = chunk;
|
|
229
|
+
const pathOfTheFile = facadeModuleId.replace(/\/[^/]*$/, '');
|
|
230
|
+
|
|
231
|
+
if (!fs.existsSync(outputDirectory)) {
|
|
232
|
+
fs.mkdirSync(outputDirectory, { recursive: true });
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return transformCode(
|
|
236
|
+
code,
|
|
237
|
+
shouldGenerateSourcemaps,
|
|
238
|
+
this,
|
|
239
|
+
pathOfTheFile,
|
|
240
|
+
outputDirectory,
|
|
241
|
+
);
|
|
242
|
+
},
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export const certificatePEM = `
|
|
247
|
+
-----BEGIN CERTIFICATE-----
|
|
248
|
+
MIIDWTCCAkGgAwIBAgIJAJsJO7x13pwAMA0GCSqGSIb3DQEBCwUAMEMxCzAJBgNV
|
|
249
|
+
BAYTAkNaMRAwDgYDVQQIDAdDemVjaGlhMQ4wDAYDVQQKDAVXaW5keTESMBAGA1UE
|
|
250
|
+
AwwJbG9jYWxob3N0MB4XDTE4MTAyNTEyMzc1NloXDTI4MTAyMjEyMzc1NlowQzEL
|
|
251
|
+
MAkGA1UEBhMCQ1oxEDAOBgNVBAgMB0N6ZWNoaWExDjAMBgNVBAoMBVdpbmR5MRIw
|
|
252
|
+
EAYDVQQDDAlsb2NhbGhvc3QwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIB
|
|
253
|
+
AQDKLfu9uX9A97rUE0kTGa7COeShMz4SJVQI+2Z7dV+6MC42rNpvbPjyWMKMjMTi
|
|
254
|
+
p6ARYrDtG6ARNETV+RIYBOIAEU5InKGJNdpOSlTxFq87XDTwdYtG9XLYhQZTOFSk
|
|
255
|
+
DjgwZkFfcXDbnhwzyu2tF+nPP1kt7k0qt0AwNn/QI3RvRlWC9gpX644xHyJPp6H7
|
|
256
|
+
6M4gxYvNw9Eh+UrbAbp27+tnQEd+qQi9adK3qi2C0GL787HEhIA18A4EJY7PIrIN
|
|
257
|
+
NjD4r9IiFF78pZFXEUszE2aE4GVe8v12VmhRPntPUgKLskFZAuAnKOxan8zar7b5
|
|
258
|
+
bIDq9M0l/+JqN7x+nB9Cx9kLAgMBAAGjUDBOMB0GA1UdDgQWBBSCb0qLtMQ8cub9
|
|
259
|
+
Go4xvwJfsWh0azAfBgNVHSMEGDAWgBSCb0qLtMQ8cub9Go4xvwJfsWh0azAMBgNV
|
|
260
|
+
HRMEBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQAJTqnecj58DrQXvWFwyewbWH2Q
|
|
261
|
+
hkv6vggR6+yM3J63bm4MBYjHs2Ut21TFlcN6ItwzIPP0prVgGrbrx7L6vJNDaDVO
|
|
262
|
+
ycaSicw++fuIIFZzmvn7ALQbRz4KtmmUqT/m6WoGyhWolDjweaPZDcmbErw8XZrk
|
|
263
|
+
rNWi3It/WA5COBxVdPzgv6vyB6FmZKNgqgaRO1NUXcNenGGR+V3CFwhmCsXsiM0G
|
|
264
|
+
L2eqlverl/YyiFUECWXsUmjpVnt86px7NXMsdBOLHJyJMAB2iLgR7gy/StV1zxSX
|
|
265
|
+
l48WMLKAXRnbcrsrAUXgfkJbaviTyvCgwFmx99yc4oP9onbEbNQJdp4gTrat
|
|
266
|
+
-----END CERTIFICATE-----
|
|
267
|
+
`;
|
|
268
|
+
|
|
269
|
+
export const keyPEM = `
|
|
270
|
+
-----BEGIN PRIVATE KEY-----
|
|
271
|
+
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDKLfu9uX9A97rU
|
|
272
|
+
E0kTGa7COeShMz4SJVQI+2Z7dV+6MC42rNpvbPjyWMKMjMTip6ARYrDtG6ARNETV
|
|
273
|
+
+RIYBOIAEU5InKGJNdpOSlTxFq87XDTwdYtG9XLYhQZTOFSkDjgwZkFfcXDbnhwz
|
|
274
|
+
yu2tF+nPP1kt7k0qt0AwNn/QI3RvRlWC9gpX644xHyJPp6H76M4gxYvNw9Eh+Urb
|
|
275
|
+
Abp27+tnQEd+qQi9adK3qi2C0GL787HEhIA18A4EJY7PIrINNjD4r9IiFF78pZFX
|
|
276
|
+
EUszE2aE4GVe8v12VmhRPntPUgKLskFZAuAnKOxan8zar7b5bIDq9M0l/+JqN7x+
|
|
277
|
+
nB9Cx9kLAgMBAAECggEBAKIE/ZNJ3t+KZs7i8ZF76F8/k6dW8CwMe+6CwNq48dC8
|
|
278
|
+
IZyxIo9erZVQaf/GI1VbbVvhUdWBaOHAmFU8tzJGX3IcbDamRpE1dc99o9pcCmsw
|
|
279
|
+
dkAogkeIFNPMrofsQXAC8SZgG41H1GA6sXET8yneWwE5S9cR/Ab6OVcppX1/nCQ6
|
|
280
|
+
tSLCTi5Uxqq1T2qdVPwGsm0GtE3XvLkfhoQBjt46T+pOVECshkFIIcpRdLaK/Q7+
|
|
281
|
+
PUfQDEgmsqV1qViLMm01nFJTHlZvL3rVS64HojPXXB6gtuCAN7K9RKWUlwhlklPb
|
|
282
|
+
M+ydISklWwbvLbIqALKsGqeLk7tf9FHd7WFJHUnTkkkCgYEA6wnYfTAGuAoAHMoa
|
|
283
|
+
7mVrSqxytlKcudnkr0LaTvBQ0o0IRLPi21kZIZzjT6jt5SSZmwZzvwr0TFCCuvHW
|
|
284
|
+
wfJnSdYCy/oB/g4D2oViGKus4sbzlS1MOvPNzlUzyp1h2ugdgBlyCzopn9MgZQVg
|
|
285
|
+
uOyzY34ChIdhyDE8yWmOI9cQSqUCgYEA3DXwViUToYuvgjq3+UfZDFMjSYJd3LOO
|
|
286
|
+
NjzhRxNxWZJxEXbO799m/zDSmWUJU/wPTJcIyM9eYcRxCoj2JyyLy0dGmq/2n8Nv
|
|
287
|
+
hQj0NpeEdpm6dn0kJMnNgSeqrjbMIlkgYkafp+24lbUnyiJV8akV/twYylBOfCuQ
|
|
288
|
+
jKKov0pGNe8CgYEA47RSLFZO7BWkLkAO/076NwoCyGgYtmVGjBT0cu2XH6TKkeTE
|
|
289
|
+
r0UOd+YKwq4ia5Cdz/bcRAVU0GpffMW3DYbOUlYnt32qWHszeI0okEYh5EJi0e9k
|
|
290
|
+
nuh8Rp1845q9ptqhWe1M81uR3+kmxTgEkKOg147I2aRfMxegkHDW6Bn/CpECgYB2
|
|
291
|
+
3C5jcRPNiIYtNuCCjwNaoa1USie7rrc+E1JNePMfs+mP0Z8U3nLLn2CtJ1oHmO/x
|
|
292
|
+
GTzGlxeMkemqFA85SdQS3t//MqddyLFzD0gyB0qacZOxzQ4rRTnFUtHPwwggKhdO
|
|
293
|
+
tGwMykVtmSBm/G2DSQ70R3yiBwK2BxW4szt+NOr8xQKBgFZKzJJJCI7tIx4Q4W6u
|
|
294
|
+
eXBYiWI6UlNpl7NRaaomk1rfIF6mZwN4jdNMSCaYxMRS6AeMBLF7a3t1SaZ+rOAM
|
|
295
|
+
h3aspktieVxk6EW6XE5niS8FphEdWc2ttqPYTEH/xlnyk5huBtgUbIWfjdK2sPcy
|
|
296
|
+
5MnCHcPPkW3bLxyZSC9y84aP
|
|
297
|
+
-----END PRIVATE KEY-----
|
|
298
|
+
`;
|
package/package.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
source .secret-api-key.sh
|
|
4
|
+
|
|
5
|
+
NAME=example
|
|
6
|
+
SHA=$(git rev-parse --short HEAD)
|
|
7
|
+
OWNER=windycom
|
|
8
|
+
|
|
9
|
+
DIR=dist/example05
|
|
10
|
+
|
|
11
|
+
cd ./$DIR
|
|
12
|
+
echo "Creating plugin archive..."
|
|
13
|
+
echo "{\"repositoryName\": \"https://github.com/windycom/windy-plugin-template\", \"commitSha\": \"${SHA}\", \"repositoryOwner\": \"${OWNER}\"}" > ./plugin-info.json
|
|
14
|
+
jq -s '.[0] * .[1]' ./plugin.json ./plugin-info.json > ./plugin2.json
|
|
15
|
+
rm ./plugin.json && mv ./plugin2.json ./plugin.json
|
|
16
|
+
tar cf ./plugin.tar --exclude='./plugin.tar' .
|
|
17
|
+
echo "Publishing plugin..."
|
|
18
|
+
curl -s --fail-with-body -XPOST 'https://api.windy.com/api/windy-plugins/v1.0/upload' -H "x-windy-api-key: ${WINDY_API_KEY}" -F "plugin_archive=@./plugin.tar"
|
|
19
|
+
rm ./plugin.tar
|
package/types/Bar.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @class Bar
|
|
3
|
+
* Horizontal ProgressBar Class binded to stores's `timestamp`
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* new Bar({
|
|
7
|
+
* progressLine: _.$(...) // el to catch mouseevents
|
|
8
|
+
* })
|
|
9
|
+
*/
|
|
10
|
+
import { Drag } from '@windy/Drag';
|
|
11
|
+
import { GhostBox } from '@windy/GhostBox';
|
|
12
|
+
import type { Calendar } from '@windy/Calendar';
|
|
13
|
+
import type { Timestamp } from '@windy/types';
|
|
14
|
+
export type BarInitParams = {
|
|
15
|
+
progressBar: HTMLDivElement;
|
|
16
|
+
offset?: number;
|
|
17
|
+
borderOffset?: number;
|
|
18
|
+
jumpingGhost?: boolean;
|
|
19
|
+
bcastLimit?: number;
|
|
20
|
+
jumpingWidth?: number;
|
|
21
|
+
resizableEl?: HTMLElement;
|
|
22
|
+
};
|
|
23
|
+
export declare class Bar {
|
|
24
|
+
protected drag: Drag;
|
|
25
|
+
protected ghostBox?: GhostBox;
|
|
26
|
+
/**
|
|
27
|
+
* EL of wrapping element,
|
|
28
|
+
*/
|
|
29
|
+
private progressBar;
|
|
30
|
+
/**
|
|
31
|
+
* A progress line to be used in GhostBox. We need to make a copy here for mobile where
|
|
32
|
+
* the GhostBox is not present.
|
|
33
|
+
*/
|
|
34
|
+
private progressLine;
|
|
35
|
+
/**
|
|
36
|
+
* Offset from left side of begginging of pb
|
|
37
|
+
*/
|
|
38
|
+
private offset;
|
|
39
|
+
/**
|
|
40
|
+
* offset of pb from border of a screen
|
|
41
|
+
*/
|
|
42
|
+
private borderOffset;
|
|
43
|
+
/**
|
|
44
|
+
* How often bcast dragging
|
|
45
|
+
*/
|
|
46
|
+
private bcastLimit;
|
|
47
|
+
/**
|
|
48
|
+
* Width of main box fo ghost jumping
|
|
49
|
+
*/
|
|
50
|
+
protected jumpingWidth: number;
|
|
51
|
+
private maxWidth;
|
|
52
|
+
private pxRatio;
|
|
53
|
+
private timecode;
|
|
54
|
+
private nowMark?;
|
|
55
|
+
private played?;
|
|
56
|
+
private ghostTxt?;
|
|
57
|
+
private throttledBcast;
|
|
58
|
+
protected progressWidth: number;
|
|
59
|
+
protected calendar: Calendar | null;
|
|
60
|
+
protected left: number;
|
|
61
|
+
protected calendarHours: number;
|
|
62
|
+
protected timestamp: Timestamp;
|
|
63
|
+
protected text: HTMLDivElement;
|
|
64
|
+
protected resizableEl: HTMLElement;
|
|
65
|
+
/**
|
|
66
|
+
* Should ghost box jump over timebox?
|
|
67
|
+
*/
|
|
68
|
+
jumpingGhost: boolean;
|
|
69
|
+
constructor(params: BarInitParams);
|
|
70
|
+
/**
|
|
71
|
+
* creates text in the timeBox on a basis of
|
|
72
|
+
* relative position on a progressBar
|
|
73
|
+
*/
|
|
74
|
+
protected createText(_el: HTMLDivElement): string;
|
|
75
|
+
protected pos2ts(pos: number): number;
|
|
76
|
+
protected createGhostText(_left: number): string;
|
|
77
|
+
protected setTimestamp(ts: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Time box change its position
|
|
80
|
+
*/
|
|
81
|
+
protected update(newPos: number): number;
|
|
82
|
+
/**
|
|
83
|
+
* Call recalculate && setIndex
|
|
84
|
+
*/
|
|
85
|
+
protected onresize(): void;
|
|
86
|
+
/**
|
|
87
|
+
* Click on progress bar
|
|
88
|
+
*/
|
|
89
|
+
protected click(event: MouseEvent): void;
|
|
90
|
+
/**
|
|
91
|
+
* Sets timestamp
|
|
92
|
+
* noAnimation ... do not do CSS animation
|
|
93
|
+
*/
|
|
94
|
+
protected set(timestamp: Timestamp): void;
|
|
95
|
+
protected onbcast(): void;
|
|
96
|
+
protected ondragstart(_startXY: [number, number]): void;
|
|
97
|
+
protected ondragend(_e: MouseEvent | TouchEvent): void;
|
|
98
|
+
/**
|
|
99
|
+
* Main timebox
|
|
100
|
+
*/
|
|
101
|
+
private ondrag;
|
|
102
|
+
/**
|
|
103
|
+
* Updates timestamp and broadcasts it out
|
|
104
|
+
*/
|
|
105
|
+
private bcast;
|
|
106
|
+
private addAnimation;
|
|
107
|
+
private removeAnimation;
|
|
108
|
+
/**
|
|
109
|
+
* Position based on ts
|
|
110
|
+
*/
|
|
111
|
+
private ts2pos;
|
|
112
|
+
private updateBarFreeRange;
|
|
113
|
+
private updateGhost;
|
|
114
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Bar } from '@windy/Bar';
|
|
2
|
+
import type { BarInitParams } from '@windy/Bar';
|
|
3
|
+
import type { Calendar } from '@windy/Calendar';
|
|
4
|
+
import type { PickDataSpecificationPropsByType } from '@windy/dataSpecifications.d';
|
|
5
|
+
import type { TimeFormatFunction } from '@windy/format.d';
|
|
6
|
+
import type { Timestamp } from '@windy/types.d';
|
|
7
|
+
export type BindedBarInitParams = {
|
|
8
|
+
UIident: string;
|
|
9
|
+
bindTimestamp: keyof PickDataSpecificationPropsByType<Timestamp>;
|
|
10
|
+
bindCalendar: keyof PickDataSpecificationPropsByType<Calendar, false>;
|
|
11
|
+
bindAnimation: keyof PickDataSpecificationPropsByType<boolean>;
|
|
12
|
+
} & BarInitParams;
|
|
13
|
+
export declare class BindedBar extends Bar {
|
|
14
|
+
/**
|
|
15
|
+
* To prevent cycling
|
|
16
|
+
*/
|
|
17
|
+
protected UIident: string;
|
|
18
|
+
/**
|
|
19
|
+
* Value to be binded as timetamp
|
|
20
|
+
*/
|
|
21
|
+
protected bindTimestamp: keyof PickDataSpecificationPropsByType<Timestamp>;
|
|
22
|
+
/**
|
|
23
|
+
* Value to be binded as calendar
|
|
24
|
+
*/
|
|
25
|
+
private bindCalendar;
|
|
26
|
+
/**
|
|
27
|
+
* Value binded with animation true/false
|
|
28
|
+
*/
|
|
29
|
+
private bindAnimation;
|
|
30
|
+
protected displayHour: TimeFormatFunction;
|
|
31
|
+
protected zuluMode: boolean;
|
|
32
|
+
protected numberOfHours: number;
|
|
33
|
+
constructor(params: BindedBarInitParams);
|
|
34
|
+
unmount(): void;
|
|
35
|
+
protected onbcast(): void;
|
|
36
|
+
protected stopAnim(): void;
|
|
37
|
+
protected ondragstart(_startXY: [number, number]): void;
|
|
38
|
+
/**
|
|
39
|
+
* Click on progress bar -> stop animation
|
|
40
|
+
* @param event
|
|
41
|
+
*/
|
|
42
|
+
protected click(event: MouseEvent): void;
|
|
43
|
+
/**
|
|
44
|
+
* Initialization of progressBar after changing of product etc.
|
|
45
|
+
* @param calendar
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
protected setCal(calendar: Calendar | null): void;
|
|
49
|
+
private render;
|
|
50
|
+
private ontstamp;
|
|
51
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { DataSpecifications } from '@windy/dataSpecifications.d';
|
|
2
|
+
type BindedCheckboxInitParams<T extends keyof DataSpecifications> = {
|
|
3
|
+
el: HTMLElement;
|
|
4
|
+
bindStore: T;
|
|
5
|
+
onValue?: DataSpecifications[T]['def'];
|
|
6
|
+
offValue?: DataSpecifications[T]['def'];
|
|
7
|
+
};
|
|
8
|
+
export declare class BindedCheckbox<T extends keyof DataSpecifications> {
|
|
9
|
+
/**
|
|
10
|
+
* Element in DOM
|
|
11
|
+
*/
|
|
12
|
+
private el;
|
|
13
|
+
/**
|
|
14
|
+
* Store item binded to this DOM el
|
|
15
|
+
*/
|
|
16
|
+
private bindStore;
|
|
17
|
+
/**
|
|
18
|
+
* What kind of value is considered ON in the store
|
|
19
|
+
*/
|
|
20
|
+
private onValue;
|
|
21
|
+
/**
|
|
22
|
+
* What kind of value is considered OFF in the store
|
|
23
|
+
*/
|
|
24
|
+
private offValue;
|
|
25
|
+
constructor(params: BindedCheckboxInitParams<T>);
|
|
26
|
+
unmount(): void;
|
|
27
|
+
toggle(): void;
|
|
28
|
+
private set;
|
|
29
|
+
}
|
|
30
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Switch } from '@windy/Switch';
|
|
2
|
+
import type { DataSpecifications } from '@windy/dataSpecifications.d';
|
|
3
|
+
import type { SwitchInitParams } from '@windy/Switch';
|
|
4
|
+
export type BindedSwitchInitParams<T extends keyof DataSpecifications> = {
|
|
5
|
+
bindStore: T;
|
|
6
|
+
} & SwitchInitParams<DataSpecifications[T]['def']>;
|
|
7
|
+
/**
|
|
8
|
+
* BindedSwitch is a switch that is bound to a store item.
|
|
9
|
+
* When the store item changes, the switch is updated.
|
|
10
|
+
* When the switch is clicked, the store item is updated.
|
|
11
|
+
*/
|
|
12
|
+
export declare class BindedSwitch<T extends keyof DataSpecifications> extends Switch<DataSpecifications[T]['def']> {
|
|
13
|
+
/**
|
|
14
|
+
* Ident of store item to bind switch with
|
|
15
|
+
*/
|
|
16
|
+
bindStore: T;
|
|
17
|
+
constructor(params: BindedSwitchInitParams<T>);
|
|
18
|
+
unmount(): void;
|
|
19
|
+
set(value: DataSpecifications[T]['def'], _uiIdent?: string | void): void;
|
|
20
|
+
/**
|
|
21
|
+
* Handles the click event for the BindedSwitch component.
|
|
22
|
+
* @param command - The command to execute.
|
|
23
|
+
* @param value - The value to pass to the command.
|
|
24
|
+
*/
|
|
25
|
+
click(command: string, value: string | DataSpecifications[T]['def']): void;
|
|
26
|
+
/**
|
|
27
|
+
* Optional method to re-render itself
|
|
28
|
+
*/
|
|
29
|
+
render?(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Optional redraw used in some instances
|
|
32
|
+
*/
|
|
33
|
+
protected redraw?(): void;
|
|
34
|
+
protected getEl(value: DataSpecifications[T]['def']): HTMLElement | null;
|
|
35
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slides plugin from bootm on mobile
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* if( rs.isMobile ) {
|
|
6
|
+
*
|
|
7
|
+
* new BottomSlide({
|
|
8
|
+
* el: this.refs.handler, // Sensitive handler
|
|
9
|
+
* pluginEl: this.node, // El of plugin
|
|
10
|
+
* pluginName: 'articles',
|
|
11
|
+
* })
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
import { Drag } from '@windy/Drag';
|
|
15
|
+
import { Swipe } from '@windy/Swipe';
|
|
16
|
+
import type { DragInitParams } from '@windy/Drag';
|
|
17
|
+
import type { Plugins } from '@windy/plugins.d';
|
|
18
|
+
export type BottomSlideInitParams = {
|
|
19
|
+
pluginEl: HTMLElement;
|
|
20
|
+
pluginName: keyof Plugins;
|
|
21
|
+
scrollEl?: HTMLElement;
|
|
22
|
+
closeOnSwipeDown?: boolean;
|
|
23
|
+
} & DragInitParams;
|
|
24
|
+
export declare class BottomSlide extends Drag {
|
|
25
|
+
/**
|
|
26
|
+
* DOM element with plugin itself
|
|
27
|
+
*/
|
|
28
|
+
private pluginEl;
|
|
29
|
+
/**
|
|
30
|
+
* Ident of plugin
|
|
31
|
+
*/
|
|
32
|
+
private pluginName;
|
|
33
|
+
/**
|
|
34
|
+
* Which elemnt should handle the scroll
|
|
35
|
+
*/
|
|
36
|
+
private scrollEl?;
|
|
37
|
+
/**
|
|
38
|
+
* Swiping on whole element down cause closing el
|
|
39
|
+
*/
|
|
40
|
+
private closeOnSwipeDown?;
|
|
41
|
+
private threshold;
|
|
42
|
+
protected swipeHandler: Swipe;
|
|
43
|
+
private startY;
|
|
44
|
+
private transformedY;
|
|
45
|
+
private throttledY;
|
|
46
|
+
private difference;
|
|
47
|
+
constructor(params: BottomSlideInitParams);
|
|
48
|
+
ondrag(_x: number, y: number, e: Event): void;
|
|
49
|
+
ondragend(): void;
|
|
50
|
+
startDrag(e: TouchEvent): void;
|
|
51
|
+
private initCloseOnSwipeDown;
|
|
52
|
+
private updatePosition;
|
|
53
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { WindowPlugin } from '@windy/WindowPlugin';
|
|
2
|
+
import type { WindowPluginInitParams } from '@windy/WindowPlugin';
|
|
3
|
+
import type { BottomTagPlugins } from '@windy/plugins.d';
|
|
4
|
+
export type BottomTagPluginInitParams<P extends keyof BottomTagPlugins> = Omit<WindowPluginInitParams<P>, 'ident'> & Pick<BottomTagPlugin<P>, 'ident'>;
|
|
5
|
+
export declare class BottomTagPlugin<P extends keyof BottomTagPlugins> extends WindowPlugin<P> {
|
|
6
|
+
ident: P;
|
|
7
|
+
constructor(params: BottomTagPluginInitParams<P>);
|
|
8
|
+
}
|