Vite Vue 3 library build doesn’t implicitly include dist/style.css

I built a library project (Vue 3, Vite) and I want to include it in a host project via package.json.

But I faced a problem where I can import the components and run a simple programme with those imported components but their styles are gone.

Please let me know what is wrong with my config. It doesn’t make sense when I have to manually import css into my host project.

Just to clarify, I don’t have any .css source files in my project. style.css was compiled from my *.vue components


This is the vite.config.ts for my library project. Everything that I need exported is in src/.

// Library project
import { defineConfig } from "vite"

import vue from "@vitejs/plugin-vue"

import typescript from '@rollup/plugin-typescript';

const path = require("path")
// https://vitejs.dev/config/
export default defineConfig( {
  plugins: [{
    ...typescript( { tsconfig: "./tsconfig.json" } ),
    apply: "build",
    declaration: true,
    declarationDir: "types/",
    rootDir: "/",
  }, vue()],
  resolve: { alias: { "@": path.resolve(__dirname, "./src") } },
  build: {
    lib: {
      entry: path.resolve(__dirname, "src/index.ts"),
      name: "gsd-vue-egui",
      // fileName: (format) => `gsd-vue-egui.${format}.js`,
    },
    rollupOptions: {
      external: ["vue"],
      output: {
        // Provide global variables to use in the UMD build
        // Add external deps here
        globals: { vue: "Vue" },
      },
    },
  },
  server: {
    port: 30001,
  }
} )

And this is the relevant part of my package.json

{
  "name": "gsd-vue-egui",
  "private": true,
  "version": "0.0.0",

  "scripts": {
    "preinstall": "npx npm-force-resolutions",
    "dev": "vite",
    "build": "vue-tsc --noEmit && vite build",
    "preview": "vite preview",
    "storybook": "start-storybook -p 6006",
    "build-storybook": "build-storybook",
    "test": "npm run test:unit",
    "test:unit": "jest --config=jest.config.js test",
    "lint:css": "stylelint --formatter verbose --config .stylelintrc "." --fix",
    "lint:eslint": "eslint --ext js,vue,ts "." --fix",
    "lint": "npm run lint:css && npm run lint:eslint"
  },
  ...
}

The structure of my dist/ folder after running npm run build is as follows:

dist/
|-components/
|  |-Button.vue.d.ts
|-App.vue.d.ts
|-MyLibraryName.es.js
|-MyLibraryName.umd.js
|-index.d.ts
|-main.d.ts
|-style.css

How to save an image from an HTML5 canvas and upload it to image storage?

I have an HTML5 canvas image that I want to save from one page and use it on another page (by uploading the image into storage, AWS S3). I don’t want to upload it to S3 on the first page.

What is the best strategy for this?

Possible solution

  1. save the canvas as a dataURL / buffer ?
  2. save that file to the user’s device (local storage)?
  3. on the new page retrieve the file
  4. post image / file to S3

Prevent overlapping of vis-timeline items

vis-timeline items gets overlapped not sure exactly why this overlapping occurs, but this overlapping occur in the following cases and is there any other way to remove this overlapping issue ?

Here is a JSFiddle: https://jsfiddle.net/Kumaran_Kanagaraj/cmgyxf31/7/

    var itemDataWithSubGroup = [
{
    "id": "NULL/Epic:2659",
    "group": "NULL",
    "subgroup": "NULL/Epic:2659",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "17. Bent both rule develop thou practical sentence sell different bread.",
    "order": 17,
    "type": "range"
},
{
    "id": "NULL/Epic:2658",
    "group": "NULL",
    "subgroup": "NULL/Epic:2658",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "18. Slept tank they tank screen simple center visit plain lead.",
    "order": 18,
    "type": "range"
},
{
    "id": "NULL/Epic:2657",
    "group": "NULL",
    "subgroup": "NULL/Epic:2657",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "19. Left hollow plates water bill crack motion blew fuel now.",
    "order": 19,
    "type": "range"
},
{
    "id": "NULL/Epic:2656",
    "group": "NULL",
    "subgroup": "NULL/Epic:2656",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-17T18:30:00.000Z",
    "content": "20. Please getting since fireplace location object receive pot oldest right.",
    "order": 20,
    "type": "range"
},
{
    "id": "NULL/Epic:2655",
    "group": "NULL",
    "subgroup": "NULL/Epic:2655",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "21. Nose small window social happily youth month realize those goes.",
    "order": 21,
    "type": "range"
},
{
    "id": "NULL/Epic:2654",
    "group": "NULL",
    "subgroup": "NULL/Epic:2654",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "22. Acres wrapped fruit possible happened common lovely southern riding feature.",
    "order": 22,
    "type": "range"
},
{
    "id": "NULL/Epic:2653",
    "group": "NULL",
    "subgroup": "NULL/Epic:2653",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "23. Inch similar establish captured control native chapter combination plural voyage.",
    "order": 23,
    "type": "range"
},
{
    "id": "NULL/Epic:2652",
    "group": "NULL",
    "subgroup": "NULL/Epic:2652",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "24. Weigh child belt how pattern fully country deeply harder trap.",
    "order": 24,
    "type": "range"
},
{
    "id": "NULL/Epic:2651",
    "group": "NULL",
    "subgroup": "NULL/Epic:2651",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "25. Carbon building make experiment class indeed wait brass cotton your.",
    "order": 25,
    "type": "range"
},
{
    "id": "NULL/Epic:2650",
    "group": "NULL",
    "subgroup": "NULL/Epic:2650",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "26. Liquid everyone bit fairly hundred into point bone bush lamp.",
    "order": 26,
    "type": "range"
},
{
    "id": "NULL/Epic:2649",
    "group": "NULL",
    "subgroup": "NULL/Epic:2649",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "27. Feature same element cast wherever onto shoe soldier man cap.",
    "order": 27,
    "type": "range"
},
{
    "id": "NULL/Epic:2648",
    "group": "NULL",
    "subgroup": "NULL/Epic:2648",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "28. Fort stream slow sugar bend brief table railroad brush describe.",
    "order": 28,
    "type": "range"
},
{
    "id": "NULL/Epic:2647",
    "group": "NULL",
    "subgroup": "NULL/Epic:2647",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-03-29T18:30:00.000Z",
    "content": "29. Corn upper rear rocket strength trick knowledge should courage setting.",
    "order": 29,
    "type": "range"
},
{
    "id": "NULL/Epic:2646",
    "group": "NULL",
    "subgroup": "NULL/Epic:2646",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-10T18:30:00.000Z",
    "content": "30. Strip sang eight bell express start large thought cold sat.",
    "order": 30,
    "type": "range"
},
{
    "id": "NULL/Epic:2645",
    "group": "NULL",
    "subgroup": "NULL/Epic:2645",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-10T18:30:00.000Z",
    "content": "31. Standard up largest market carefully dull task former space post.",
    "order": 31,
    "type": "range"
},
{
    "id": "NULL/Epic:2644",
    "group": "NULL",
    "subgroup": "NULL/Epic:2644",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "32. Conversation nervous want excitement one contain pressure tie tongue development.",
    "order": 32,
    "type": "range"
},
{
    "id": "NULL/Epic:2643",
    "group": "NULL",
    "subgroup": "NULL/Epic:2643",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-10T18:30:00.000Z",
    "content": "33. Kept church fell completely ran doctor man straw usual recent.",
    "order": 33,
    "type": "range"
},
{
    "id": "NULL/Epic:2640",
    "group": "NULL",
    "subgroup": "NULL/Epic:2640",
    "start": "2021-10-26T18:30:00.000Z",
    "end": "2022-12-31T18:30:00.000Z",
    "content": "34. Cry occasionally bent composed unhappy fun floating situation office throat.",
    "order": 34,
    "type": "range"
},
{
    "id": "NULL/Epic:2639",
    "group": "NULL",
    "subgroup": "NULL/Epic:2639",
    "start": "2021-08-16T18:30:00.000Z",
    "end": "2022-03-31T18:30:00.000Z",
    "content": "35. Mine about frog valley captured property size origin cent most.",
    "order": 35,
    "type": "range"
},
{
    "id": "NULL/Epic:2633",
    "group": "NULL",
    "subgroup": "NULL/Epic:2633",
    "start": "2021-01-05T18:30:00.000Z",
    "end": "2021-03-30T18:30:00.000Z",
    "content": "36. Division powerful ring separate lonely purple nation cold stick cup.",
    "order": 36,
    "type": "range"
},
{
    "id": "NULL/Epic:2632",
    "group": "NULL",
    "subgroup": "NULL/Epic:2632",
    "start": "2021-02-23T18:30:00.000Z",
    "end": "2021-04-02T18:30:00.000Z",
    "content": "37. Comfortable giving carefully aid look late pretty origin pocket zero.",
    "order": 37,
    "type": "range"
},
{
    "id": "NULL/Epic:2631",
    "group": "NULL",
    "subgroup": "NULL/Epic:2631",
    "start": "2021-01-28T18:30:00.000Z",
    "end": "2021-11-02T18:30:00.000Z",
    "content": "38. Diagram lost safety desert purpose damage zipper whistle bell voice.",
    "order": 38,
    "type": "range"
},
{
    "id": "NULL/Epic:2628",
    "group": "NULL",
    "subgroup": "NULL/Epic:2628",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-06-01T18:30:00.000Z",
    "content": "39. Mass also deal farm arrow fairly prepare steady farmer plural.",
    "order": 39,
    "type": "range"
},
{
    "id": "NULL/Epic:2620",
    "group": "NULL",
    "subgroup": "NULL/Epic:2620",
    "start": "2021-10-26T18:30:00.000Z",
    "end": "2022-01-04T18:30:00.000Z",
    "content": "40. Suddenly property fly job interest evening greatly birthday depend brought.",
    "order": 40,
    "type": "range"
},
{
    "id": "NULL/Epic:2618",
    "group": "NULL",
    "subgroup": "NULL/Epic:2618",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "41. Tired throw sent car brief against muscle captain people needs.",
    "order": 41,
    "type": "range"
},
{
    "id": "NULL/Epic:2617",
    "group": "NULL",
    "subgroup": "NULL/Epic:2617",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "42. Market last tip planned loose solid characteristic told palace missing.",
    "order": 42,
    "type": "range"
},
{
    "id": "NULL/Epic:2616",
    "group": "NULL",
    "subgroup": "NULL/Epic:2616",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "43. Cause bring knife because stove law pet shake seen name.",
    "order": 43,
    "type": "range"
},
{
    "id": "NULL/Epic:2615",
    "group": "NULL",
    "subgroup": "NULL/Epic:2615",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "44. Where wagon young minute needed glass foot running instant trick.",
    "order": 44,
    "type": "range"
},
{
    "id": "NULL/Epic:2614",
    "group": "NULL",
    "subgroup": "NULL/Epic:2614",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "45. Molecular huge meal friend call good thing stairs as slip.",
    "order": 45,
    "type": "range"
},
{
    "id": "NULL/Epic:2610",
    "group": "NULL",
    "subgroup": "NULL/Epic:2610",
    "start": "2022-05-10T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "46. Snake dark yourself spoken between grass people inch hour frog.",
    "order": 46,
    "type": "range"
},
{
    "id": "NULL/Epic:2609",
    "group": "NULL",
    "subgroup": "NULL/Epic:2609",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "47. Income offer function lot service describe constantly am tune related.",
    "order": 47,
    "type": "range"
},
{
    "id": "NULL/Epic:2608",
    "group": "NULL",
    "subgroup": "NULL/Epic:2608",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "48. Cold threw knife package pan chamber hole clock parent difficulty.",
    "order": 48,
    "type": "range"
},
{
    "id": "NULL/Epic:2607",
    "group": "NULL",
    "subgroup": "NULL/Epic:2607",
    "start": "2022-04-12T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "49. Fight pile adventure several earn mirror topic lonely built window.",
    "order": 49,
    "type": "range"
},
{
    "id": "NULL/Epic:2606",
    "group": "NULL",
    "subgroup": "NULL/Epic:2606",
    "start": "2022-04-12T18:30:00.000Z",
    "end": "2022-05-07T18:30:00.000Z",
    "content": "50. Jar add door victory shine compass number course dull older.",
    "order": 50,
    "type": "range"
},
{
    "id": "NULL/Epic:2605",
    "group": "NULL",
    "subgroup": "NULL/Epic:2605",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-07T18:30:00.000Z",
    "content": "51. Copper star space slide strength verb few division avoidhttps://jsfiddle.net/Kumaran_Kanagaraj/cmgyxf31/1/# passage.",
    "order": 51,
    "type": "range"
},
{
    "id": "NULL/Epic:2604",
    "group": "NULL",
    "subgroup": "NULL/Epic:2604",
    "start": "2022-02-15T18:30:00.000Z",
    "end": "2022-04-09T18:30:00.000Z",
    "content": "52. Future horse given shoulder notice distance scene degree beneath pony.",
    "order": 52,
    "type": "range"
},
{
    "id": "NULL/Epic:2603",
    "group": "NULL",
    "subgroup": "NULL/Epic:2603",
    "start": "2022-02-15T18:30:00.000Z",
    "end": "2022-04-21T18:30:00.000Z",
    "content": "53. Leather highest mad fly strange separate greater bark giant till.",
    "order": 53,
    "type": "range"
},
{
    "id": "NULL/Epic:2602",
    "group": "NULL",
    "subgroup": "NULL/Epic:2602",
    "start": "2022-03-14T18:30:00.000Z",
    "end": "2022-05-11T18:30:00.000Z",
    "content": "54. Grabbed recall area carried shake count relationship experience peace slowly.",
    "order": 54,
    "type": "range"
},
{
    "id": "NULL/Epic:2601",
    "group": "NULL",
    "subgroup": "NULL/Epic:2601",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-10T18:30:00.000Z",
    "content": "55. Composed trick figure visitor gain per where journey card meet.",
    "order": 55,
    "type": "range"
},
{
    "id": "NULL/Epic:2600",
    "group": "NULL",
    "subgroup": "NULL/Epic:2600",
    "start": "2022-02-07T18:30:00.000Z",
    "end": "2022-04-26T18:30:00.000Z",
    "content": "56. Verb someone poet room pair glass stomach soon ever seen.",
    "order": 56,
    "type": "range"
},
{
    "id": "NULL/Epic:2599",
    "group": "NULL",
    "subgroup": "NULL/Epic:2599",
    "start": "2022-01-24T18:30:00.000Z",
    "end": "2022-04-26T18:30:00.000Z",
    "content": "57. Audience gun bent hurried wealth distance silent your seldom said.",
    "order": 57,
    "type": "range"
},
{
    "id": "NULL/Epic:2598",
    "group": "NULL",
    "subgroup": "NULL/Epic:2598",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-04-26T18:30:00.000Z",
    "content": "58. Tip who held stuck visitor earth also term route importance.",
    "order": 58,
    "type": "range"
},
{
    "id": "NULL/Epic:2597",
    "group": "NULL",
    "subgroup": "NULL/Epic:2597",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "59. Shake in parent border real grade poem upward bigger muscle.",
    "order": 59,
    "type": "range"
},
{
    "id": "NULL/Epic:2596",
    "group": "NULL",
    "subgroup": "NULL/Epic:2596",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "60. Variety exercise fought wise shinning shown medicine thought party why.",
    "order": 60,
    "type": "range"
},
{
    "id": "NULL/Epic:2595",
    "group": "NULL",
    "subgroup": "NULL/Epic:2595",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "61. Flight amount atomic sink century made people whenever average again.",
    "order": 61,
    "type": "range"
},
{
    "id": "NULL/Epic:2594",
    "group": "NULL",
    "subgroup": "NULL/Epic:2594",
    "start": "2022-01-05T18:30:00.000Z",
    "end": "2022-03-16T18:30:00.000Z",
    "content": "62. Carried trouble die warn after silk bank shade note visitor.",
    "order": 62,
    "type": "range"
},
{
    "id": "NULL/Epic:2593",
    "group": "NULL",
    "subgroup": "NULL/Epic:2593",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "63. Beginning remarkable clothes value outside tool telephone nose bank necessary.",
    "order": 63,
    "type": "range"
},
{
    "id": "NULL/Epic:2592",
    "group": "NULL",
    "subgroup": "NULL/Epic:2592",
    "start": "2021-10-26T18:30:00.000Z",
    "end": "2022-01-04T18:30:00.000Z",
    "content": "64. Dance connected piano daily real indicate exercise mine feature eager.",
    "order": 64,
    "type": "range"
},
{
    "id": "NULL/Epic:2591",
    "group": "NULL",
    "subgroup": "NULL/Epic:2591",
    "start": "2021-10-26T18:30:00.000Z",
    "end": "2021-12-21T18:30:00.000Z",
    "content": "65. Part above planned fox adjective establish nobody told uncle knife.",
    "order": 65,
    "type": "range"
},
{
    "id": "NULL/Epic:2590",
    "group": "NULL",
    "subgroup": "NULL/Epic:2590",
    "start": "2020-09-15T18:30:00.000Z",
    "end": "2020-12-15T18:30:00.000Z",
    "content": "66. Fifty run sky special eventually progress country remove chance dark.",
    "order": 66,
    "type": "range"
},
{
    "id": "NULL/Epic:2589",
    "group": "NULL",
    "subgroup": "NULL/Epic:2589",
    "start": "2020-12-31T18:30:00.000Z",
    "end": "2022-12-31T18:30:00.000Z",
    "content": "67. Short easier southern cannot every offer use read dance even.",
    "order": 67,
    "type": "range"
},
{
    "id": "NULL/Epic:2588",
    "group": "NULL",
    "subgroup": "NULL/Epic:2588",
    "start": "2020-09-29T18:30:00.000Z",
    "end": "2020-12-15T18:30:00.000Z",
    "content": "68. Became carried carefully saddle badly product instance progress speak trip.",
    "order": 68,
    "type": "range"
},
{
    "id": "NULL/Epic:2587",
    "group": "NULL",
    "subgroup": "NULL/Epic:2587",
    "start": "2022-03-15T18:30:00.000Z",
    "end": "2022-05-24T18:30:00.000Z",
    "content": "69. Ordinary verb instant film drive leaving appearance cool vapor joy.",
    "order": 69,
    "type": "range"
},
{
    "id": "NULL/Epic:2584",
    "group": "NULL",
    "subgroup": "NULL/Epic:2584",
    "start": "2022-01-04T18:30:00.000Z",
    "end": "2022-03-15T18:30:00.000Z",
    "content": "70. Yet news doubt poet inch age toward dollar hurt additional.",
    "order": 70,
    "type": "range"
},
{
    "id": "NULL/Epic:1194",
    "group": "NULL",
    "subgroup": "NULL/Epic:1194",
    "start": "2020-05-06T18:30:00.000Z",
    "end": "2020-07-06T18:30:00.000Z",
    "content": "71. Quietly ranch crack are grandfather foreign affect claws behind however.",
    "order": 71,
    "type": "range"
},
{
    "id": "NULL/Epic:1193",
    "group": "NULL",
    "subgroup": "NULL/Epic:1193",
    "start": "2020-05-03T18:30:00.000Z",
    "end": "2020-08-01T18:30:00.000Z",
    "content": "72. But slabs planning railroad watch speed car making spin sold.",
    "order": 72,
    "type": "range"
},
{
    "id": "NULL/Epic:1192",
    "group": "NULL",
    "subgroup": "NULL/Epic:1192",
    "start": "2020-05-03T18:30:00.000Z",
    "end": "2020-08-01T18:30:00.000Z",
    "content": "73. Town store hide met later real probably sleep zebra been.",
    "order": 73,
    "type": "range"
},
{
    "id": "NULL/Epic:1191",
    "group": "NULL",
    "subgroup": "NULL/Epic:1191",
    "start": "2020-05-03T18:30:00.000Z",
    "end": "2020-08-01T18:30:00.000Z",
    "content": "74. Store car successful draw strange radio prize selection club key.",
    "order": 74,
    "type": "range"
},
{
    "id": "NULL/Epic:1190",
    "group": "NULL",
    "subgroup": "NULL/Epic:1190",
    "start": "2020-01-05T18:30:00.000Z",
    "end": "2020-05-02T18:30:00.000Z",
    "content": "75. Idea molecular indeed coat spent toward wish shown finally loss.",
    "order": 75,
    "type": "range"
},
{
    "id": "NULL/Epic:1184",
    "group": "NULL",
    "subgroup": "NULL/Epic:1184",
    "start": "2020-01-05T18:30:00.000Z",
    "end": "2020-03-09T18:30:00.000Z",
    "content": "76. Rather kitchen citizen sides good potatoes breathe sport structure share.",
    "order": 76,
    "type": "range"
},
{
    "id": "NULL/Epic:1183",
    "group": "NULL",
    "subgroup": "NULL/Epic:1183",
    "start": "2020-01-05T18:30:00.000Z",
    "end": "2020-03-09T18:30:00.000Z",
    "content": "77. Stretch show dead look rhyme diagram loud village birth system.",
    "order": 77,
    "type": "range"
},
{
    "className": "first-background",
    "group": "NULL",
    "start": "2021-01-28T18:30:00.000Z",
    "end": "2021-11-02T18:30:00.000Z",
    "subgroup": "NULL/Epic:2631",
    "type": "background",
    "id": "eb227dfa-425d-47e7-a668-d4a355feea40"
},
{
    "className": "last-background",
    "group": "NULL",
    "start": "2021-01-28T18:30:00.000Z",
    "end": "2021-11-02T18:30:00.000Z",
    "subgroup": "NULL/Epic:2632",
    "type": "background",
    "id": "ad6399cb-39b0-465c-82a6-33e0c4ad0f58"
}]

var groupData = [
    {
        "id": "NULL",
        "oidToken": "NULL",
        "stack": false,
        "subgroupStack": true,
        "content": "NULL",
        "subgroupOrder": "order",
        subgroupOrder: function (a, b) {
            return a.order - b.order;
        }
    }
]

var options =
{
    "stack": true,
    "autoResize": true,
    "orientation": {
        "item": "both",
        "axis": "both"
    },
    "width": '100%',
    "margin": {
        "item": {
            "vertical": 16,
        },
    },
    "start": "2021-12-01T18:30:00.000Z",
    "end": "2022-12-01T18:30:00.000Z",
    "dataAttributes": [
        "name",
        "oidToken",
        "group",
        "assetType",
        "isExpanded"
    ],
    "locale": "en",
    "locales": {
        "en": {
            "current": "current",
            "time": "time"
        }
    }
};

var container = document.getElementById("visualization");
var groups = new vis.DataSet(groupData);
var items = new vis.DataSet(itemDataWithSubGroup);

var timeline = new vis.Timeline(container, items, groups, options);
window.ctimeline = timeline;
timeline.setGroups(groups);
timeline.setItems(items);
  1. Given I have both the box items and background items. Provided that the both the background item and the box item need to be in the same subgroup. When the background item time range is large when comparing that to the box item which is beneath that background. Then the overlapping occur.

    Here in the provided example item “37. Comfortable giving carefully aid look late pretty origin pocket zero.” time range is between 2021-02-23 to 2021-04-02 and its corresponding background item time range is 2021-01-28 to 2021-11-02 which having the id ‘ad6399cb-39b0-465c-82a6-33e0c4ad0f58’ and className as ‘last-background’. If we remove that background or adjust their time range such that both their time range are more or less equal then this overlapping will not occur.

  2. Given if I set stack:true in vis-timeline configure options. Provided that the both the background item and the box item need to be in the same subgroup. Then the overlapping occur. This is in contradiction with the document.

    Here in the provided example if I set stack:false in vis-timeline options then this overlapping will not occur.

Have posted this issue in vis-timeline repo but no solution yet so asking here in stackoverflow.

How to determine if user input is in a rich text editor (on all sites)

I’m working on a Chrome translation extension that allows users to select a text and press a key (T) to display the translation directly behind the text.
 

But if the user selects text and presses (T) in the input box, the extension will also show the translation result, which is not what I want.  Fortunately, the input field is usually wrapped around the <input></input> tag, so I can tell that the user does not trigger the translation function when the <input> tag is used.

if (keyCode == "T") {
    let userSelection = window.getSelection();
    let userSelectionNode = window.getSelection().anchorNode.parentElement;
    if ($(userSelectionNode).find("input").length == 0) {
        let userSelection_string = userSelection.toString();
        if (userSelection_string.length > 0) {
            getTranslate(userSelection_string);
        }
    }
}

But if the user is in a rich text editor, my method doesn’t work, and I can’t tell if the user is in a rich text editor.  So do I have a way to tell if the user is in a rich text editor?
 It is important to note that the extension runs on all web pages, so the method should be generic and not targeted at a particular rich text editor

Why is there an extra iteration here?

This is one of the easy problems in LeeteCode. solution
But my question isn’t really about the problem, the code bellow iterate through a 2d Array
like this

[
    [1, 1, 0, 0, 0],
    [1, 1, 1, 1, 0],
    [1, 0, 0, 0, 0],
    [1, 1, 0, 0, 0],
    [1, 1, 1, 1, 1],
  ]

The problem, I don’t understand is why j <= x while i < y isn’t j going an extra iteration? I would have thought j < would be the correct way but it is not

var kWeakestRows = function(M, K) {
    let y = M.length, x = M[0].length,
        vis = new Uint8Array(y), ans = []
    for (let j = 0; j <= x; j++)
        for (let i = 0; i < y; i++) {
            if (!vis[i] && !M[i][j]) ans.push(i), vis[i]++
            if (ans.length === K) return ans
        }
};

Trying to parse a PDF from an Electron app

I am trying to parse data from a PDF using the pdf-parse package. I am doing this through a vanilla electron app on MacOS. Here is app.js, which is used to parse the PDF that is in the same directory as app.js.

const fs = require('fs');
const pdf = require('pdf-parse');
 
let dataBuffer = fs.readFileSync('/Users/username/Documents/pdf-data-tool/src/PDF_DATA.pdf');

pdf(dataBuffer).then(function(data) {

    // number of pages
    console.log(data.numpages);
    // number of rendered pages
    console.log(data.numrender);
    // PDF info
    console.log(data.info);
    // PDF metadata
    console.log(data.metadata); 
    // PDF.js version
    // check https://mozilla.github.io/pdf.js/getting_started/
    console.log(data.version);
    // PDF text
    console.log(data.text); 

});

I am getting this error in the electron console:

enter image description here

  • I’ve tried specifying the relative path to the PDF
  • I’ve tried “./PDF_DATA.pdf”

I’ve hit a dead end and I’ve exhausted my Googling skills, any help is much appreciated~

Event listeners get removed after moving some elements

I have a <ul> list with some <li> elements inside, and I’ve added a click event listener for each of these elements to move the clicked item to the top of the list.

function add_event_listeners() {
    let elements = my_list.getElementsByTagName('li');
    for (let item of elements) {
        item.addEventListener("click", send_to_top);
    }
}

function send_to_top() {
    this.parentElement.children[0].insertAdjacentElement('beforebegin', this);
}

This code works fine only with the first click, but after that, all the event listeners get removed, and the clicks after that don’t work.

I tried to call the add_event_listeners() function inside the send_to_top() function like below, but it didn’t work:

function send_to_top() {
    this.parentElement.children[0].insertAdjacentElement('beforebegin', this);
    add_event_listeners();
}

But when I run the send_to_top() function in the browser console, the event listeners get added to the elements, but again, it works for one time then all get removed.

Why calling the add_event_listeners() function inside the send_to_top() function is not working as expected?

And how to find a way to resolve this issue? By avoiding the removal of the event listeners, or by adding them again after removal?

How to pass form-data in Loopback code in Mocha Unit Testing NodeJs

I am trying Unit Testing Using Loopback Mocha. I have a POST API /admin/url/createShortUrl which requires actualUrl as a formdata. Also some headers. But headers seems working fine.
I tried multiple answers from stackoverflow but none worked. I am trying to set Content-type as application/json as well as multipart/form-data. But none of it is working.

require('dotenv').config();
import {Client, expect} from '@loopback/testlab';
import {BrickAdminPanelApplication} from '../../application';
import upload from 'multer';

import {setupApplication} from './test-helper';

admin-panel.datasource’;
const token =
‘eyJ0eXAiOiJKV1QiLCJhbGci’;

describe('ShortenedUrlController', () => {
    let app: BrickAdminPanelApplication;
    let client: Client;

    before('setupApplication', async () => {
        ({app, client} = await setupApplication());
    });

    after(async () => {
        await app.stop();
    });

    it('invokes POST /admin/url/createShortUrl', async () => {
        await client
        .post('/admin/url/createShortUrl')
        .set({Authorization: `Bearer ${token}`})
        .set('emailId', '[email protected]')

        .set('Content-Type', 'multipart/form-data') //Not working
        .set('Content-Type', 'application/json') //Not working
        .field('Content-Type', 'multipart/form-data') //Not working
        .field(
            'actualUrl',
            'https%3A%2F%2Fadminss.papers.com%2Fddqwderss1ssdadsdassatsddqposissdcsuy',
        )
        .expect(400);
    });
});

ERROR

 1) ShortenedUrlController
   invokes POST /admin/url/createShortUrl:
 Error: expected 400 "Bad Request", got 415 "Unsupported Media Type"
  at Context.<anonymous> (src__tests__acceptanceurl-shortener.acceptance.ts:92:8)
  at processImmediate (node:internal/timers:466:21)
  at process.callbackTrampoline (node:internal/async_hooks:130:17)
  at Test._assertStatus (node_modulessupertestlibtest.js:304:12)
  at C:project testMT-PampersBrick-Admin-APInode_modulessupertestlibtest.js:80:15
  at Test._assertFunction (node_modulessupertestlibtest.js:338:11)
  at Test.assert (node_modulessupertestlibtest.js:209:21)
  at localAssert (node_modulessupertestlibtest.js:167:12)
  at fn (node_modulessupertestlibtest.js:164:5)
  at Test.callback (node_modulessuperagentsrcnodeindex.js:902:3)
  at fn (node_modulessuperagentsrcnodeindex.js:1130:18)
  at IncomingMessage.<anonymous> (node_modulessuperagentsrcnodeparsersjson.js:19:7)
  at IncomingMessage.emit (node:events:539:35)
  at endReadableNT (node:internal/streams/readable:1345:12)
  at processTicksAndRejections (node:internal/process/task_queues:83:21)

how to enable top level await in reactjs

I have installed craco
using yarn add @craco/craco
I have also replaced the scritps
and have created a craco.config.js

module.exports = {
    webpack: {
        experiments: {
            topLevelAwait: true
        }
    }
}

but when I’m trying to use await at top level
I’m still getting this error in my react app

ERROR in ./src/Enforcer.js

Module parse failed: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
File was processed with these loaders:
 * ./node_modules/@pmmmwh/react-refresh-webpack-plugin/loader/index.js
 * ./node_modules/babel-loader/lib/index.js
 * ./node_modules/source-map-loader/dist/cjs.js
You may need an additional loader to handle the result of these loaders.
Error: The top-level-await experiment is not enabled (set experiments.topLevelAwait: true to enabled it)
    at /home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/dependencies/HarmonyDetectionParserPlugin.js:54:11
    at Hook.eval [as call] (eval at create (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:16)
    at Hook.CALL_DELEGATE [as _call] (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/tapable/lib/Hook.js:14:14)
    at JavascriptParser.walkAwaitExpression (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:2337:29)
    at JavascriptParser.walkExpression (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:2267:10)
    at JavascriptParser.walkVariableDeclaration (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:2121:33)
    at JavascriptParser.walkStatement (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:1615:10)
    at JavascriptParser.walkStatements (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:1476:9)
    at JavascriptParser.parse (/home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/javascript/JavascriptParser.js:3370:9)
    at /home/shivansh/Desktop/dev/os-2/casbin-core/test/reactjs/node_modules/webpack/lib/NormalModule.js:1087:26

Why my JS code isnt enabling the Nav list toggle

https://codepen.io/brunhild_912/pen/MWQPErp

Here is my code. I am trying to enable the nav list toggle, but its not happening. Why? Any guidance or tips over this issue ae welcomed. I have tried many options but its being stubborn unfortunately.

HTML

<button type="button" class="nav-toggler">
                        <span></span>
                    </button>

                    <!--Navbar-->
                    <nav class="nav">
                        <ul>
                            <li class="nav=item"><a href="#home">Home</a></li>
                            <li class="nav=item"><a href="#about">About</a></li>
                            <li class="nav=item"><a href="#our-menu">Menu</a></li>
                            <li class="nav=item"><a href="#testimonials">Testimonials</a></li>
                            <li class="nav=item"><a href="#team">Team</a></li>
                            <li class="nav=item"><a href="#contact">Contact</a></li>
                        </ul>
                    </nav>

CSS

.header .nav-toggler{
    height: 40px;
    width: 44px;
    margin-right: 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header .nav-toggler.active{
    position: absolute;
    right: 0;
    z-index: 1;
}

.header .nav{
    position: fixed;
    right: 0;
    top: 0;
    height: 100%;
    width: 280px;
    background-color: var(--main-color);
    box-shadow: var(--shadow);
    overflow-y: auto;
    padding: 80px 0 40px;
    transform: transform 0.5s ease;
    transform: translateX(100%);
}

.header .nav .open{
    transform: translateX(0%);
}

JavaScript

const navToggler = document.querySelector(".nav-toggler");
navToggler.addEventListener("click", toggleNav);

function toggleNav(){
    navToggler.classList.toggle(".active");
    document.querySelector(".nav").classList.toggle(".open");
}