@vcmap/ui 5.0.0-rc.24 → 5.0.0-rc.25
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/build/build.js +132 -14
- package/build/buildHelpers.js +196 -92
- package/build/bundle.js +56 -0
- package/build/commonViteConfig.js +2 -2
- package/config/base.config.json +29 -2
- package/config/dev.config.json +29 -1
- package/config/www.config.json +81 -39
- package/dist/assets/@mdi/font/LICENSE +20 -0
- package/dist/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
- package/dist/assets/@mdi/font/css/materialdesignicons.min.e3f476.css +3 -0
- package/dist/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/dist/assets/cesium/Workers/{AxisAlignedBoundingBox-85d9e53a.js → AxisAlignedBoundingBox-4140c51f.js} +1 -1
- package/dist/assets/cesium/Workers/{BoundingRectangle-1ee7eb47.js → BoundingRectangle-c714b156.js} +1 -1
- package/dist/assets/cesium/Workers/{BoxGeometry-3b2be784.js → BoxGeometry-6f3da43d.js} +1 -1
- package/dist/assets/cesium/Workers/{Color-f107c84d.js → Color-8a565ff2.js} +5 -5
- package/dist/assets/cesium/Workers/{CoplanarPolygonGeometryLibrary-78d71993.js → CoplanarPolygonGeometryLibrary-4b4d4096.js} +1 -1
- package/dist/assets/cesium/Workers/{CorridorGeometryLibrary-50d99b33.js → CorridorGeometryLibrary-7b94502b.js} +1 -1
- package/dist/assets/cesium/Workers/{CylinderGeometry-51b0d9bf.js → CylinderGeometry-ca070b87.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseGeometry-bcfb5d87.js → EllipseGeometry-122e51fa.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseGeometryLibrary-e94f8472.js → EllipseGeometryLibrary-4d326efc.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipseOutlineGeometry-28e3a1bb.js → EllipseOutlineGeometry-16cc2bd7.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidGeometry-b222fa63.js → EllipsoidGeometry-cb148ca2.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidOutlineGeometry-38a3fb5b.js → EllipsoidOutlineGeometry-0fa10c79.js} +1 -1
- package/dist/assets/cesium/Workers/{EllipsoidTangentPlane-8c89f28c.js → EllipsoidTangentPlane-6dd1b7af.js} +1 -1
- package/dist/assets/cesium/Workers/{FrustumGeometry-bdd3a04d.js → FrustumGeometry-ee73037c.js} +1 -1
- package/dist/assets/cesium/Workers/{GeometryAttribute-153115c5.js → GeometryAttribute-ff5b4fb1.js} +1 -1
- package/dist/assets/cesium/Workers/{GeometryPipeline-acb2399c.js → GeometryPipeline-1f8fbf05.js} +1 -1
- package/dist/assets/cesium/Workers/{IntersectionTests-271e513e.js → IntersectionTests-70d39ba9.js} +1 -1
- package/dist/assets/cesium/Workers/{OrientedBoundingBox-5e04e31f.js → OrientedBoundingBox-159cf1d6.js} +1 -1
- package/dist/assets/cesium/Workers/{PolygonGeometryLibrary-6762b65b.js → PolygonGeometryLibrary-076a5d25.js} +1 -1
- package/dist/assets/cesium/Workers/{PolygonPipeline-7dc7a431.js → PolygonPipeline-b9f2810a.js} +1 -1
- package/dist/assets/cesium/Workers/{PolylinePipeline-15fde655.js → PolylinePipeline-639192e0.js} +1 -1
- package/dist/assets/cesium/Workers/{PolylineVolumeGeometryLibrary-ba7dfed5.js → PolylineVolumeGeometryLibrary-b73549fb.js} +1 -1
- package/dist/assets/cesium/Workers/{PrimitivePipeline-68f0b9a2.js → PrimitivePipeline-10ede1b6.js} +1 -1
- package/dist/assets/cesium/Workers/{RectangleGeometryLibrary-8eaf23da.js → RectangleGeometryLibrary-c35a7356.js} +1 -1
- package/dist/assets/cesium/Workers/{TerrainEncoding-eb8a645a.js → TerrainEncoding-668d242f.js} +1 -1
- package/dist/assets/cesium/Workers/{Transforms-f6451f99.js → Transforms-a2a85221.js} +14 -0
- package/dist/assets/cesium/Workers/{WallGeometryLibrary-feef3109.js → WallGeometryLibrary-1938bf0d.js} +1 -1
- package/dist/assets/cesium/Workers/cesiumWorkerBootstrapper.js +1 -1
- package/dist/assets/cesium/Workers/combineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createBoxGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createBoxOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCircleGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCircleOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCoplanarPolygonGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCoplanarPolygonOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCorridorGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCorridorOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCylinderGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createCylinderOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipseGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipseOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipsoidGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createEllipsoidOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createFrustumGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createFrustumOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createGroundPolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPlaneGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPlaneOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolygonGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolygonOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineVolumeGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createPolylineVolumeOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createRectangleGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createRectangleOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSimplePolylineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSphereGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createSphereOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createVectorTileGeometries.js +1 -1
- package/dist/assets/cesium/Workers/createVectorTilePolygons.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromGoogleEarthEnterpriseBuffer.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromHeightmap.js +1 -1
- package/dist/assets/cesium/Workers/createVerticesFromQuantizedTerrainMesh.js +1 -1
- package/dist/assets/cesium/Workers/createWallGeometry.js +1 -1
- package/dist/assets/cesium/Workers/createWallOutlineGeometry.js +1 -1
- package/dist/assets/cesium/Workers/package.js +1 -1
- package/dist/assets/cesium/Workers/transferTypedArrayTest.js +1 -1
- package/dist/assets/cesium/Workers/upsampleQuantizedTerrainMesh.js +1 -1
- package/dist/assets/{cesium.253914.js → cesium.1457fa.js} +58656 -33170
- package/dist/assets/cesium.js +1 -1
- package/dist/assets/core.47836f.js +19060 -0
- package/dist/assets/core.js +1 -1
- package/dist/assets/index-bb372634.js +1 -0
- package/dist/assets/{ol.1c946a.js → ol.9e4d23.js} +27344 -12118
- package/dist/assets/ol.js +1 -1
- package/dist/assets/ui.6ed89d.css +5 -0
- package/dist/assets/ui.6ed89d.js +13461 -0
- package/dist/assets/ui.js +1 -1
- package/dist/assets/{vue.c1ece7.js → vue.7327e4.js} +834 -598
- package/dist/assets/vue.js +2 -2
- package/dist/assets/{vuetify.6efa21.css → vuetify.d2131d.css} +1 -1
- package/dist/assets/{vuetify.6efa21.js → vuetify.d2131d.js} +343 -103
- package/dist/assets/vuetify.js +2 -2
- package/dist/index.html +7 -6
- package/index.html +14 -6
- package/index.js +17 -2
- package/lib/olLib.js +19 -16
- package/package.json +15 -14
- package/plugins/@vcmap/create-link/fallbackCreateLink.vue +0 -2
- package/plugins/@vcmap/simple-graph/index.js +1 -1
- package/plugins/@vcmap-show-case/README.md +2 -1
- package/plugins/@vcmap-show-case/buttons-example/ButtonsExample.vue +55 -79
- package/plugins/@vcmap-show-case/category-tester/CategoriesExample.vue +135 -0
- package/plugins/@vcmap-show-case/category-tester/CollectionComponentOptions.vue +209 -0
- package/plugins/@vcmap-show-case/category-tester/index.js +19 -1
- package/plugins/@vcmap-show-case/collection-manager-example/CollectionManagerExample.vue +182 -0
- package/plugins/@vcmap-show-case/collection-manager-example/README.md +3 -0
- package/plugins/@vcmap-show-case/collection-manager-example/index.js +74 -0
- package/plugins/@vcmap-show-case/collection-manager-example/package.json +5 -0
- package/plugins/@vcmap-show-case/form-inputs-example/FormInputsExample.vue +20 -3
- package/plugins/@vcmap-show-case/switch-map-callback-example/README.md +21 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/SwitchMapCallback.js +47 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/config.json +3 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/index.js +34 -0
- package/plugins/@vcmap-show-case/switch-map-callback-example/package.json +5 -0
- package/plugins/@vcmap-show-case/table-example/DataTableExample.vue +0 -1
- package/plugins/package.json +3 -1
- package/public/assets/@mdi/font/LICENSE +20 -0
- package/public/assets/@mdi/font/css/materialdesignicons.css.map +16 -0
- package/public/assets/@mdi/font/css/materialdesignicons.min.css +3 -0
- package/public/assets/@mdi/font/fonts/materialdesignicons-webfont.woff2 +0 -0
- package/public/assets/favicon-128.png +0 -0
- package/public/assets/favicon-180.png +0 -0
- package/public/assets/favicon-192.png +0 -0
- package/public/assets/favicon-32.png +0 -0
- package/public/assets/logo-mobile.svg +9 -0
- package/public/assets/logo.svg +26 -0
- package/src/application/VcsApp.vue +34 -5
- package/src/application/VcsAttributions.vue +20 -5
- package/src/application/VcsAttributionsFooter.vue +0 -1
- package/src/application/VcsNavbar.vue +18 -13
- package/src/callback/activateLayersCallback.js +54 -0
- package/src/callback/applyLayerStyleCallback.js +63 -0
- package/src/callback/deactivateLayersCallback.js +54 -0
- package/src/callback/goToViewpointCallback.js +54 -0
- package/src/callback/vcsCallback.js +66 -0
- package/src/components/buttons/VcsActionButtonList.vue +28 -10
- package/src/components/buttons/VcsButton.vue +38 -100
- package/src/components/buttons/VcsFormButton.vue +6 -4
- package/src/components/buttons/VcsToolButton.vue +161 -0
- package/src/components/form-inputs-controls/VcsDatePicker.vue +19 -5
- package/src/components/form-inputs-controls/VcsFormSection.vue +0 -1
- package/src/components/form-inputs-controls/VcsSelect.vue +16 -2
- package/src/components/form-inputs-controls/VcsSlider.vue +72 -0
- package/src/components/form-inputs-controls/VcsTextField.vue +24 -13
- package/src/components/form-inputs-controls/VcsWizard.vue +13 -14
- package/src/components/form-inputs-controls/VcsWizardStep.vue +0 -1
- package/src/components/lists/VcsList.vue +3 -2
- package/src/components/lists/VcsTreeviewLeaf.vue +0 -1
- package/src/components/tables/VcsDataTable.vue +2 -4
- package/src/contentTree/LayerTree.vue +15 -9
- package/src/contentTree/contentTreeCollection.js +1 -1
- package/src/contentTree/contentTreeItem.js +22 -3
- package/src/contentTree/groupContentTreeItem.js +1 -0
- package/src/contentTree/layerContentTreeItem.js +4 -14
- package/src/contentTree/layerGroupContentTreeItem.js +4 -14
- package/src/contentTree/obliqueCollectionContentTreeItem.js +4 -0
- package/src/contentTree/viewpointContentTreeItem.js +1 -0
- package/src/featureInfo/BalloonComponent.vue +0 -1
- package/src/featureInfo/abstractFeatureInfoView.js +16 -1
- package/src/featureInfo/featureInfo.js +45 -56
- package/src/i18n/de.js +5 -2
- package/src/i18n/en.js +5 -2
- package/src/i18n/i18nCollection.js +1 -2
- package/src/init.js +1 -4
- package/src/legend/vcsLegend.vue +1 -1
- package/src/manager/buttonManager.js +15 -0
- package/src/manager/{categoryManager/CategoryComponent.vue → collectionManager/CollectionComponent.vue} +57 -66
- package/src/manager/collectionManager/CollectionComponentList.vue +62 -0
- package/src/manager/collectionManager/CollectionComponentProvider.vue +38 -0
- package/src/manager/collectionManager/CollectionManager.vue +43 -0
- package/src/manager/collectionManager/categoryManager.js +83 -0
- package/src/manager/collectionManager/collectionComponent.js +453 -0
- package/src/manager/collectionManager/collectionManager.js +432 -0
- package/src/manager/navbarManager.js +5 -4
- package/src/manager/toolbox/GroupToolboxComponent.vue +5 -7
- package/src/manager/toolbox/SelectToolboxComponent.vue +6 -9
- package/src/manager/toolbox/ToolboxManager.vue +4 -5
- package/src/manager/window/WindowComponentHeader.vue +0 -4
- package/src/navigation/mapNavigation.vue +34 -8
- package/src/navigation/overviewMap.js +7 -1
- package/src/notifier/notifierComponent.vue +0 -1
- package/src/pluginHelper.js +5 -0
- package/src/search/resultItem.vue +0 -1
- package/src/search/searchComponent.vue +7 -9
- package/src/styles/_theming.scss +2 -2
- package/src/styles/_typography.scss +2 -2
- package/src/styles/main.scss +8 -0
- package/src/styles/vcsFont.scss +1 -22
- package/src/vcsUiApp.js +76 -12
- package/src/vuePlugins/i18n.js +18 -19
- package/src/vuePlugins/vuetify.js +0 -1
- package/dist/assets/core.3a8205.js +0 -18426
- package/dist/assets/index.91ae2d55.js +0 -1
- package/dist/assets/ui.0025be.css +0 -5
- package/dist/assets/ui.0025be.js +0 -18534
- package/plugins/@vcmap-show-case/category-tester/Categories.vue +0 -291
- package/plugins/@vcmap-show-case/category-tester/Category.vue +0 -164
- package/src/manager/categoryManager/CategoryComponentList.vue +0 -82
- package/src/manager/categoryManager/CategoryManager.vue +0 -47
- package/src/manager/categoryManager/categoryManager.js +0 -633
- package/start.js +0 -9
- /package/{src/assets/favicon-128.png → dist/assets/favicon-128.4c4ce5.png} +0 -0
- /package/{src/assets/favicon-180.png → dist/assets/favicon-180.5b99c0.png} +0 -0
- /package/{src/assets/favicon-192.png → dist/assets/favicon-192.0e205e.png} +0 -0
- /package/{src/assets/favicon-32.png → dist/assets/favicon-32.6b9add.png} +0 -0
- /package/dist/assets/{favicon.decf54cc.svg → favicon.d5ec97.svg} +0 -0
- /package/dist/assets/font/{TitilliumWeb-Regular.woff2 → TitilliumWeb-Regular.9ca076.woff2} +0 -0
- /package/{src/assets/logo-mobile.svg → dist/assets/logo-mobile.2d10a6.svg} +0 -0
- /package/{src/assets/logo.svg → dist/assets/logo.27089a.svg} +0 -0
- /package/{src → public}/assets/favicon.svg +0 -0
- /package/{src → public}/assets/font/OFL.txt +0 -0
- /package/{src → public}/assets/font/TitilliumWeb-Regular.woff2 +0 -0
package/build/build.js
CHANGED
@@ -2,11 +2,19 @@ import path from 'path';
|
|
2
2
|
import fs from 'fs';
|
3
3
|
import { build } from 'vite';
|
4
4
|
import { v4 as uuid } from 'uuid';
|
5
|
+
|
5
6
|
import rollupPluginStripPragma from 'rollup-plugin-strip-pragma';
|
6
7
|
import vcsOl from '@vcmap/rollup-plugin-vcs-ol';
|
8
|
+
|
7
9
|
import generateOLLib from './generateOLLib.js';
|
8
10
|
import buildCesium from './buildCesium.js';
|
9
|
-
import {
|
11
|
+
import {
|
12
|
+
buildLibrary,
|
13
|
+
getFileMd5,
|
14
|
+
getFilesInDirectory,
|
15
|
+
libraries,
|
16
|
+
writeRewrittenFile,
|
17
|
+
} from './buildHelpers.js';
|
10
18
|
|
11
19
|
/**
|
12
20
|
* @typedef {Object} LibraryBuildOption
|
@@ -92,15 +100,85 @@ const { libraryBuildOptions, libraryPaths } = hashLibraries();
|
|
92
100
|
console.log('Building ol dump file');
|
93
101
|
await generateOLLib();
|
94
102
|
|
103
|
+
/** Cleaning/recreating Dist Folder */
|
104
|
+
if (await fs.existsSync(path.join(process.cwd(), 'dist'))) {
|
105
|
+
await fs.promises.rm(path.join(process.cwd(), 'dist'), { recursive: true });
|
106
|
+
}
|
107
|
+
const assetsFolder = path.join(process.cwd(), 'dist', 'assets');
|
108
|
+
await fs.promises.mkdir(assetsFolder, { recursive: true });
|
109
|
+
|
110
|
+
/**
|
111
|
+
* Prepare and Copy Public folder to dist Folder. This Process will also hash the static files using a MD5 File hash.
|
112
|
+
* The renamed fileNames will be saved in the hashedPublicFiles Map. This can be used later to rewrite references
|
113
|
+
* to the public assets to the correct new fileName.
|
114
|
+
*/
|
115
|
+
|
116
|
+
const publicFolder = path.join(process.cwd(), 'public');
|
117
|
+
const publicAssetsFolder = path.join(process.cwd(), 'public', 'assets');
|
118
|
+
const fileTypesToHash = ['.png', '.css', '.svg', '.woff2'];
|
119
|
+
/**
|
120
|
+
* we exclude the materialDesignIcons font because we do not want to also rewrite the materialDesignIcons.css file.
|
121
|
+
* The .woff2 is loaded with the materialDesignIcons Version number as a query parameter. So this also makes sure,
|
122
|
+
* that the browser can cache the file.
|
123
|
+
*/
|
124
|
+
const filesToExclude = [
|
125
|
+
path.join(
|
126
|
+
'assets',
|
127
|
+
'@mdi',
|
128
|
+
'font',
|
129
|
+
'fonts',
|
130
|
+
'materialdesignicons-webfont.woff2',
|
131
|
+
),
|
132
|
+
];
|
133
|
+
const hashedPublicFiles = new Map();
|
134
|
+
const filesToCopy = new Map();
|
135
|
+
// eslint-disable-next-line no-restricted-syntax
|
136
|
+
for await (const filePath of getFilesInDirectory(publicAssetsFolder)) {
|
137
|
+
const fileType = path.extname(filePath);
|
138
|
+
const relativePath = path.relative(publicFolder, filePath);
|
139
|
+
const relativePathInDist = path.relative(publicAssetsFolder, filePath);
|
140
|
+
if (
|
141
|
+
fileTypesToHash.includes(fileType) &&
|
142
|
+
!filesToExclude.includes(relativePath)
|
143
|
+
) {
|
144
|
+
const fileHash = await getFileMd5(filePath);
|
145
|
+
const hashedFileUrl = path.posix.join(
|
146
|
+
...path.dirname(relativePathInDist).split(path.sep),
|
147
|
+
`${path.basename(filePath, fileType)}.${fileHash.slice(0, 6)}${fileType}`,
|
148
|
+
);
|
149
|
+
hashedPublicFiles.set(
|
150
|
+
path.posix.join(...relativePath.split(path.sep)),
|
151
|
+
hashedFileUrl,
|
152
|
+
);
|
153
|
+
const newFilePath = path.join(
|
154
|
+
assetsFolder,
|
155
|
+
path.dirname(relativePathInDist),
|
156
|
+
`${path.basename(relativePath, fileType)}.${fileHash.slice(
|
157
|
+
0,
|
158
|
+
6,
|
159
|
+
)}${fileType}`,
|
160
|
+
);
|
161
|
+
filesToCopy.set(filePath, newFilePath);
|
162
|
+
} else {
|
163
|
+
const newFilePath = path.join(assetsFolder, relativePathInDist);
|
164
|
+
filesToCopy.set(filePath, newFilePath);
|
165
|
+
}
|
166
|
+
}
|
167
|
+
// eslint-disable-next-line no-restricted-syntax
|
168
|
+
for await (const [originalFilePath, newFilePath] of filesToCopy) {
|
169
|
+
await fs.promises.cp(originalFilePath, newFilePath);
|
170
|
+
}
|
171
|
+
|
95
172
|
console.log('Building app');
|
96
|
-
await build({
|
173
|
+
const buildoutput = await build({
|
97
174
|
configFile: './build/commonViteConfig.js',
|
98
175
|
base: './',
|
99
176
|
define: {
|
100
177
|
'process.env.NODE_ENV': '"production"',
|
101
178
|
},
|
102
179
|
build: {
|
103
|
-
|
180
|
+
write: false,
|
181
|
+
modulePreload: false,
|
104
182
|
emptyOutDir: true,
|
105
183
|
rollupOptions: {
|
106
184
|
external: Object.keys(libraries),
|
@@ -111,6 +189,44 @@ await build({
|
|
111
189
|
},
|
112
190
|
});
|
113
191
|
|
192
|
+
/**
|
193
|
+
* Building the Main entrypoint (index.html + index.js)
|
194
|
+
* This will ensure that all references to public assets will be rewritten to the hashed filename
|
195
|
+
*/
|
196
|
+
await Promise.all(
|
197
|
+
buildoutput.output?.map((output) => {
|
198
|
+
if (output.type === 'asset') {
|
199
|
+
const { source, fileName } = output;
|
200
|
+
// remove loading of materialdesignicons from index.html, we will later inject this in the ui.js
|
201
|
+
const fileContent = source.replace(
|
202
|
+
/<link[^>]*href=".*materialdesignicons\.min\.css"[^>]*(>[^<]*<\/link>|\/>)/,
|
203
|
+
'',
|
204
|
+
);
|
205
|
+
return writeRewrittenFile(
|
206
|
+
path.join(process.cwd(), 'dist', fileName),
|
207
|
+
fileContent,
|
208
|
+
hashedPublicFiles,
|
209
|
+
'assets',
|
210
|
+
);
|
211
|
+
}
|
212
|
+
if (output.type === 'chunk') {
|
213
|
+
const { code, fileName } = output;
|
214
|
+
return writeRewrittenFile(
|
215
|
+
path.join(process.cwd(), 'dist', fileName),
|
216
|
+
code,
|
217
|
+
hashedPublicFiles,
|
218
|
+
'assets',
|
219
|
+
);
|
220
|
+
}
|
221
|
+
return undefined;
|
222
|
+
}),
|
223
|
+
);
|
224
|
+
|
225
|
+
/**
|
226
|
+
* Building the Libraries, (vue, vuetify, openlayers, cesium, core, and ui). This will build one hashed library.hash.js
|
227
|
+
* file and a second one library.js which will reexport all ES6 Modules. All references to these librarys will be
|
228
|
+
* set as externals while building these libraries or later the plugins.
|
229
|
+
*/
|
114
230
|
console.log('Building Libraries');
|
115
231
|
await Promise.all(
|
116
232
|
Object.entries(libraryBuildOptions).map(async ([key, value]) => {
|
@@ -124,9 +240,6 @@ await Promise.all(
|
|
124
240
|
};
|
125
241
|
const libraryConfig = {
|
126
242
|
configFile: './build/commonViteConfig.js',
|
127
|
-
esbuild: {
|
128
|
-
minify: true,
|
129
|
-
},
|
130
243
|
define: {
|
131
244
|
'process.env.NODE_ENV': '"production"',
|
132
245
|
},
|
@@ -136,7 +249,7 @@ await Promise.all(
|
|
136
249
|
lib: {
|
137
250
|
entry: path.resolve(process.cwd(), value.entry),
|
138
251
|
formats: ['es'],
|
139
|
-
fileName:
|
252
|
+
fileName: `${value.lib}.${value.hash}`,
|
140
253
|
},
|
141
254
|
rollupOptions: {
|
142
255
|
...value.rollupOptions,
|
@@ -145,7 +258,14 @@ await Promise.all(
|
|
145
258
|
},
|
146
259
|
},
|
147
260
|
};
|
148
|
-
await buildLibrary(
|
261
|
+
await buildLibrary(
|
262
|
+
libraryConfig,
|
263
|
+
'assets',
|
264
|
+
value.lib,
|
265
|
+
value.hash,
|
266
|
+
false,
|
267
|
+
hashedPublicFiles,
|
268
|
+
);
|
149
269
|
console.log('Building Library Entry: ', key);
|
150
270
|
|
151
271
|
const libraryEntryConfig = {
|
@@ -155,6 +275,7 @@ await Promise.all(
|
|
155
275
|
},
|
156
276
|
build: {
|
157
277
|
emptyOutDir: false,
|
278
|
+
copyPublicDir: false,
|
158
279
|
lib: {
|
159
280
|
entry: path.resolve(process.cwd(), value.libraryEntry || value.entry),
|
160
281
|
formats: ['es'],
|
@@ -172,13 +293,10 @@ await Promise.all(
|
|
172
293
|
},
|
173
294
|
};
|
174
295
|
await build(libraryEntryConfig);
|
175
|
-
await fs.promises.cp(
|
176
|
-
path.join('src', 'assets', 'font'),
|
177
|
-
path.join('dist', 'assets', 'font'),
|
178
|
-
{ recursive: true },
|
179
|
-
);
|
180
296
|
}),
|
181
297
|
);
|
182
|
-
|
298
|
+
/**
|
299
|
+
* Copy Cesium Static Assets to the dist/assets folder
|
300
|
+
*/
|
183
301
|
await buildCesium();
|
184
302
|
console.log('Finished Building vcMap');
|
package/build/buildHelpers.js
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
import { build } from 'vite'; // vite is also a plugin-cli dep
|
4
4
|
import fs from 'fs';
|
5
5
|
import path from 'path';
|
6
|
+
import { createHash } from 'crypto';
|
6
7
|
import { fileURLToPath } from 'url';
|
7
8
|
|
8
9
|
/**
|
@@ -17,6 +18,28 @@ export function getProjectPath(...pathSegments) {
|
|
17
18
|
);
|
18
19
|
}
|
19
20
|
|
21
|
+
export async function getFileMd5(filePath) {
|
22
|
+
const hash = createHash('md5');
|
23
|
+
const stream = fs.createReadStream(filePath);
|
24
|
+
// eslint-disable-next-line no-restricted-syntax
|
25
|
+
for await (const chunk of stream) {
|
26
|
+
hash.update(chunk);
|
27
|
+
}
|
28
|
+
return hash.digest('hex');
|
29
|
+
}
|
30
|
+
|
31
|
+
export async function* getFilesInDirectory(filePath) {
|
32
|
+
const entries = await fs.promises.readdir(filePath, { withFileTypes: true });
|
33
|
+
// eslint-disable-next-line no-restricted-syntax
|
34
|
+
for (const file of entries) {
|
35
|
+
if (file.isDirectory()) {
|
36
|
+
yield* getFilesInDirectory(path.join(filePath, file.name));
|
37
|
+
} else if (file.isFile()) {
|
38
|
+
yield path.join(filePath, file.name);
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
20
43
|
/**
|
21
44
|
* returns the absolute path to the plugin directory
|
22
45
|
* @returns {string}
|
@@ -90,6 +113,32 @@ export async function getInlinePlugins() {
|
|
90
113
|
return plugins;
|
91
114
|
}
|
92
115
|
|
116
|
+
/**
|
117
|
+
* Writes content in the file and replaces references to public assets with the hashed url.
|
118
|
+
* @param {string} filePath
|
119
|
+
* @param {string} content
|
120
|
+
* @param {Map<string, string>?} rewrittenPublicAssets
|
121
|
+
* @param {string?} assetsPrefix prefixes the hashed asset url with this string
|
122
|
+
* @returns {Promise<void>}
|
123
|
+
*/
|
124
|
+
export async function writeRewrittenFile(
|
125
|
+
filePath,
|
126
|
+
content,
|
127
|
+
rewrittenPublicAssets,
|
128
|
+
assetsPrefix,
|
129
|
+
) {
|
130
|
+
let fileContent = content;
|
131
|
+
if (rewrittenPublicAssets) {
|
132
|
+
rewrittenPublicAssets.forEach((hashed, ori) => {
|
133
|
+
const rewrittenUrl = assetsPrefix
|
134
|
+
? path.posix.join(assetsPrefix, hashed)
|
135
|
+
: hashed;
|
136
|
+
fileContent = fileContent.replaceAll(ori, rewrittenUrl);
|
137
|
+
});
|
138
|
+
}
|
139
|
+
return fs.promises.writeFile(filePath, fileContent);
|
140
|
+
}
|
141
|
+
|
93
142
|
/**
|
94
143
|
* builds the given configuration and writes the library to the provided outputFolder. If the build contains css a .css
|
95
144
|
* file will also be written and injected into the .js file.
|
@@ -98,6 +147,7 @@ export async function getInlinePlugins() {
|
|
98
147
|
* @param {string} library
|
99
148
|
* @param {string} [hash]
|
100
149
|
* @param {boolean} [base64Css = false] inline css. must be true for plugins
|
150
|
+
* @param {undefined|Map} [rewrittenPublicAssets=undefined] rewrittenPublicAssets Map of original filename to Hashed Filename in public folder
|
101
151
|
* @returns {Promise<void>}
|
102
152
|
*/
|
103
153
|
export async function buildLibrary(
|
@@ -106,6 +156,7 @@ export async function buildLibrary(
|
|
106
156
|
library,
|
107
157
|
hash = '',
|
108
158
|
base64Css = false,
|
159
|
+
rewrittenPublicAssets = undefined,
|
109
160
|
) {
|
110
161
|
// Base64 contains the characters '+', '/', and '=', which have a reserved meaning in URLs.
|
111
162
|
// Base64url solves this by replacing '+' with '-' and '/' with '_'.
|
@@ -136,7 +187,7 @@ function loadCss(href) {
|
|
136
187
|
'base64url',
|
137
188
|
)}`;
|
138
189
|
} else {
|
139
|
-
await
|
190
|
+
await writeRewrittenFile(
|
140
191
|
path.join(
|
141
192
|
process.cwd(),
|
142
193
|
'dist',
|
@@ -144,14 +195,27 @@ function loadCss(href) {
|
|
144
195
|
`${library}${addedHash}.css`,
|
145
196
|
),
|
146
197
|
output[1].source,
|
198
|
+
rewrittenPublicAssets,
|
147
199
|
);
|
148
|
-
|
200
|
+
if (outputFolder) {
|
201
|
+
css = `./${outputFolder}/${library}${addedHash}.css`;
|
202
|
+
} else {
|
203
|
+
css = `./${library}${addedHash}.css`;
|
204
|
+
}
|
149
205
|
}
|
150
206
|
}
|
151
207
|
if (output[0] && output[0].type === 'chunk') {
|
152
208
|
let code = css ? `${cssInjectorCode} await loadCss('${css}');` : '';
|
209
|
+
// inject materialDesignIcons here. We removed it earlier from the index.html
|
210
|
+
if (library === 'ui') {
|
211
|
+
const hashedPath = rewrittenPublicAssets.get(
|
212
|
+
'assets/@mdi/font/css/materialdesignicons.min.css',
|
213
|
+
);
|
214
|
+
code += `await loadCss('./${path.posix.join('assets', hashedPath)}');`;
|
215
|
+
}
|
216
|
+
|
153
217
|
code += output[0].code;
|
154
|
-
await
|
218
|
+
await writeRewrittenFile(
|
155
219
|
path.join(
|
156
220
|
process.cwd(),
|
157
221
|
'dist',
|
@@ -159,6 +223,7 @@ function loadCss(href) {
|
|
159
223
|
`${library}${addedHash}.js`,
|
160
224
|
),
|
161
225
|
code,
|
226
|
+
rewrittenPublicAssets,
|
162
227
|
);
|
163
228
|
}
|
164
229
|
};
|
@@ -169,13 +234,23 @@ function loadCss(href) {
|
|
169
234
|
} else if (libraryBuilds.output) {
|
170
235
|
await write(libraryBuilds.output);
|
171
236
|
} else {
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
237
|
+
/**
|
238
|
+
* This is used by the plugin-cli. If the libraryConfic includes watch: { }
|
239
|
+
* Rollup will start in Watch Mode. So we restart the browser on filechanges in the plugin-cli preview mode.
|
240
|
+
* See: https://rollupjs.org/javascript-api/#rollup-watch
|
241
|
+
* Also we need to add our BUNDLE_END event onCurrentRun, otherwise the bundle is already closed by vitejs.
|
242
|
+
* See: https://github.com/vitejs/vite/blob/main/packages/vite/src/node/build.ts#L674
|
243
|
+
*/
|
244
|
+
libraryBuilds.on('event', (event) => {
|
245
|
+
if (event.code === 'START') {
|
246
|
+
libraryBuilds.onCurrentRun('event', async (innerEvent) => {
|
247
|
+
if (innerEvent.code === 'BUNDLE_END') {
|
248
|
+
const res = await innerEvent.result.generate(
|
249
|
+
libraryConfig?.build?.rollupOptions?.output ?? {},
|
250
|
+
);
|
251
|
+
await write(res.output);
|
252
|
+
}
|
253
|
+
});
|
179
254
|
}
|
180
255
|
});
|
181
256
|
}
|
@@ -195,105 +270,134 @@ export const libraries = {
|
|
195
270
|
'vuetify/lib': 'vuetify',
|
196
271
|
};
|
197
272
|
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
const inlinePlugins = await getInlinePlugins();
|
207
|
-
const dependentPlugins = await getPluginNames();
|
273
|
+
const toCopy = [
|
274
|
+
'plugin-assets',
|
275
|
+
'package.json',
|
276
|
+
'config.json',
|
277
|
+
'LICENSE.md',
|
278
|
+
'CHANGELOG.md',
|
279
|
+
'README.md',
|
280
|
+
];
|
208
281
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
282
|
+
async function buildInlinePlugin(plugin, baseConfig, minify) {
|
283
|
+
// the relative path between plugins and libraries, is not known beforehand, so we calculate the distance.
|
284
|
+
// posixRelativePath is the relative path between the index.js of the plugin and the specific library.
|
285
|
+
const relativePluginPaths = {};
|
286
|
+
Object.entries(libraries).forEach(([key, value]) => {
|
287
|
+
const libraryPath = path.join('dist', 'assets', `${value}.js`);
|
288
|
+
const pluginPath = path.join(process.cwd(), `dist/plugins/${plugin}/`);
|
289
|
+
const relativePath = path.relative(pluginPath, libraryPath);
|
290
|
+
relativePluginPaths[key] = relativePath
|
291
|
+
.split(path.sep)
|
292
|
+
.join(path.posix.sep);
|
293
|
+
});
|
221
294
|
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
295
|
+
const pluginDir = getProjectPath('plugins', plugin);
|
296
|
+
const pluginConfig = {
|
297
|
+
...baseConfig,
|
298
|
+
esbuild: {
|
299
|
+
minify,
|
300
|
+
},
|
301
|
+
build: {
|
302
|
+
write: false,
|
303
|
+
emptyOutDir: false,
|
304
|
+
outDir: `dist/plugins/${plugin}/`,
|
305
|
+
lib: {
|
306
|
+
entry: path.join(pluginDir, 'index.js'),
|
307
|
+
formats: ['es'],
|
308
|
+
fileName: 'index',
|
226
309
|
},
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
lib: {
|
232
|
-
entry: getProjectPath('plugins', plugin, 'index.js'),
|
233
|
-
formats: ['es'],
|
234
|
-
fileName: 'index',
|
235
|
-
},
|
236
|
-
rollupOptions: {
|
237
|
-
external: Object.keys(libraries),
|
238
|
-
output: {
|
239
|
-
paths: relativePluginPaths,
|
240
|
-
},
|
310
|
+
rollupOptions: {
|
311
|
+
external: Object.keys(libraries),
|
312
|
+
output: {
|
313
|
+
paths: relativePluginPaths,
|
241
314
|
},
|
242
315
|
},
|
243
|
-
}
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
}
|
248
|
-
|
249
|
-
});
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
316
|
+
},
|
317
|
+
};
|
318
|
+
const distPath = path.join(process.cwd(), 'dist', 'plugins', plugin);
|
319
|
+
if (!fs.existsSync(distPath)) {
|
320
|
+
await fs.promises.mkdir(distPath, { recursive: true });
|
321
|
+
}
|
322
|
+
await buildLibrary(pluginConfig, `plugins/${plugin}`, 'index', '', true);
|
323
|
+
await Promise.all(
|
324
|
+
toCopy.map(async (entry) => {
|
325
|
+
if (fs.existsSync(path.join(pluginDir, entry))) {
|
326
|
+
await fs.promises.cp(
|
327
|
+
path.join(pluginDir, entry),
|
328
|
+
path.join(distPath, entry),
|
329
|
+
{ recursive: true, force: true },
|
330
|
+
);
|
257
331
|
}
|
332
|
+
}),
|
333
|
+
);
|
334
|
+
}
|
258
335
|
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
336
|
+
async function buildDependentPlugin(pluginName) {
|
337
|
+
const pluginsDirectory = getPluginDirectory();
|
338
|
+
let scope = '';
|
339
|
+
let name = pluginName;
|
340
|
+
if (pluginName.startsWith('@')) {
|
341
|
+
[scope, name] = pluginName.split('/');
|
342
|
+
}
|
343
|
+
|
344
|
+
await fs.promises.cp(
|
345
|
+
path.join(pluginsDirectory, 'node_modules', scope, name, 'dist'),
|
346
|
+
path.join(process.cwd(), 'dist', 'plugins', scope, name),
|
347
|
+
{ recursive: true, force: true },
|
348
|
+
);
|
264
349
|
|
265
|
-
|
350
|
+
// must be copied one after the other to avoid race conditions
|
351
|
+
await Promise.all(
|
352
|
+
toCopy.map(async (entry) => {
|
266
353
|
if (
|
267
354
|
fs.existsSync(
|
268
|
-
path.join(
|
269
|
-
pluginsDirectory,
|
270
|
-
'node_modules',
|
271
|
-
scope,
|
272
|
-
name,
|
273
|
-
'plugin-assets',
|
274
|
-
),
|
355
|
+
path.join(pluginsDirectory, 'node_modules', scope, name, entry),
|
275
356
|
)
|
276
357
|
) {
|
277
358
|
await fs.promises.cp(
|
278
|
-
path.join(
|
279
|
-
|
280
|
-
'node_modules',
|
281
|
-
scope,
|
282
|
-
name,
|
283
|
-
'plugin-assets',
|
284
|
-
),
|
285
|
-
path.join(
|
286
|
-
process.cwd(),
|
287
|
-
'dist',
|
288
|
-
'plugins',
|
289
|
-
scope,
|
290
|
-
name,
|
291
|
-
'plugin-assets',
|
292
|
-
),
|
359
|
+
path.join(pluginsDirectory, 'node_modules', scope, name, entry),
|
360
|
+
path.join(process.cwd(), 'dist', 'plugins', scope, name, entry),
|
293
361
|
{ recursive: true, force: true },
|
294
362
|
);
|
295
363
|
}
|
296
364
|
}),
|
297
365
|
);
|
366
|
+
}
|
367
|
+
|
368
|
+
/**
|
369
|
+
* Will build a preview of all the current plugins & inline plugins
|
370
|
+
* @param {import("vite").InlineConfig} [baseConfig={}] - the base config to use. build & esbuild will be completely overwritten
|
371
|
+
* @param {boolean} [minify=true]
|
372
|
+
* @returns {Promise<void>}
|
373
|
+
*/
|
374
|
+
export async function buildPluginsForPreview(baseConfig = {}, minify = true) {
|
375
|
+
const inlinePlugins = await getInlinePlugins();
|
376
|
+
const dependentPlugins = await getPluginNames();
|
377
|
+
|
378
|
+
const promises = inlinePlugins.map((plugin) =>
|
379
|
+
buildInlinePlugin(plugin, baseConfig, minify),
|
380
|
+
);
|
381
|
+
|
382
|
+
promises.push(
|
383
|
+
...dependentPlugins.map(async (pluginName) =>
|
384
|
+
buildDependentPlugin(pluginName, baseConfig, minify),
|
385
|
+
),
|
386
|
+
);
|
387
|
+
await Promise.all(promises);
|
388
|
+
}
|
389
|
+
|
390
|
+
export async function buildPluginsForBundle(baseConfig = {}) {
|
391
|
+
const inlinePlugins = await getInlinePlugins();
|
392
|
+
const dependentPlugins = await getPluginNames();
|
393
|
+
const promises = inlinePlugins
|
394
|
+
.filter((plugin) => plugin.startsWith('@vcmap/'))
|
395
|
+
.map((plugin) => buildInlinePlugin(plugin, baseConfig, true));
|
396
|
+
|
397
|
+
promises.push(
|
398
|
+
...dependentPlugins.map(async (pluginName) =>
|
399
|
+
buildDependentPlugin(pluginName),
|
400
|
+
),
|
401
|
+
);
|
298
402
|
await Promise.all(promises);
|
299
403
|
}
|
package/build/bundle.js
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
import vcsOl from '@vcmap/rollup-plugin-vcs-ol';
|
2
|
+
import { join as joinPath } from 'path';
|
3
|
+
import tar from 'tar';
|
4
|
+
import { cp, rm } from 'fs/promises';
|
5
|
+
import { createGzip } from 'zlib';
|
6
|
+
import { pipeline } from 'stream';
|
7
|
+
import { createReadStream, createWriteStream } from 'fs';
|
8
|
+
import { buildPluginsForBundle, getProjectPath } from './buildHelpers.js';
|
9
|
+
|
10
|
+
await import('./build.js');
|
11
|
+
console.log('ui built');
|
12
|
+
|
13
|
+
await buildPluginsForBundle({
|
14
|
+
configFile: './build/commonViteConfig.js',
|
15
|
+
plugins: [vcsOl()],
|
16
|
+
});
|
17
|
+
|
18
|
+
const distDir = getProjectPath('dist');
|
19
|
+
|
20
|
+
const rootFiles = ['package.json', 'README.md', 'CHANGELOG.md'];
|
21
|
+
await Promise.all(
|
22
|
+
rootFiles.map((entry) => cp(getProjectPath(entry), joinPath(distDir, entry))),
|
23
|
+
);
|
24
|
+
|
25
|
+
const file = joinPath(distDir, 'vcmap-bundle.tar');
|
26
|
+
|
27
|
+
await tar.c(
|
28
|
+
{
|
29
|
+
file,
|
30
|
+
cwd: distDir,
|
31
|
+
prefix: '@vcmap/ui',
|
32
|
+
},
|
33
|
+
['index.html', 'assets', ...rootFiles],
|
34
|
+
);
|
35
|
+
|
36
|
+
await tar.u(
|
37
|
+
{
|
38
|
+
file,
|
39
|
+
cwd: joinPath(distDir, 'plugins'),
|
40
|
+
},
|
41
|
+
['.'],
|
42
|
+
);
|
43
|
+
|
44
|
+
await new Promise((res, rej) => {
|
45
|
+
pipeline(
|
46
|
+
[createReadStream(file), createGzip(), createWriteStream(`${file}.gz`)],
|
47
|
+
(err) => {
|
48
|
+
if (err) {
|
49
|
+
rej(err);
|
50
|
+
} else {
|
51
|
+
res();
|
52
|
+
}
|
53
|
+
},
|
54
|
+
);
|
55
|
+
});
|
56
|
+
await rm(file);
|
@@ -1,7 +1,7 @@
|
|
1
1
|
/* eslint-disable import/extensions */
|
2
2
|
import path from 'path';
|
3
3
|
import { defineConfig } from 'vite';
|
4
|
-
import
|
4
|
+
import vue2 from '@vitejs/plugin-vue2';
|
5
5
|
import { libraries } from './buildHelpers.js';
|
6
6
|
|
7
7
|
const configMain = defineConfig({
|
@@ -17,7 +17,7 @@ const configMain = defineConfig({
|
|
17
17
|
define: {
|
18
18
|
'process.env.NODE_ENV': '"development"',
|
19
19
|
},
|
20
|
-
plugins: [
|
20
|
+
plugins: [vue2()],
|
21
21
|
css: {
|
22
22
|
preprocessorOptions: {
|
23
23
|
sass: {
|