lundi 29 mai 2023

single-spa consume shared utility module in ember

I want to use single-spa with react and ember apps that will need to share data between them, I would like to use https://single-spa.js.org/docs/module-types/#utilities utility module for exposing observable data.

In react project utility module is consumed via webpacks externals option

reacts webpack:

module.exports = (webpackConfigEnv, argv) => {
  const defaultConfig = singleSpaDefaults({
    orgName: "company",
    projectName: "react-app",
    webpackConfigEnv,
    argv,
  });

  return merge(defaultConfig, {
      externals: {
        "react": "react",
        "react-dom": "react-dom",
        // utility module 
        "@company/utility": "@company/utility"
      }
  });
};

And it works just fine in react, but ember uses ember-cli/broccoli for building an app and I don't know how to consume utility package, is it even possible? Or the only way to use package is to publish it via npm or expose functionality via props when registering ember mf in root-config for example:

registerApplication(
  "ember",
  () => {
    const appName = "ember";
    const appUrl = `${domain}/ember/assets/ember.js`;
    const vendorUrl = `${domain}/ember/assets/vendor.js`;
    console.log({ appName, appUrl, vendorUrl });
    return loadEmberApp(appName, appUrl, vendorUrl);
  },
  (location) => {
    console.log(location.pathname.startsWith("/ember"))
    return location.pathname.startsWith("/ember");
  },
  { // all data from utility module should be exposed here }
);



vendredi 26 mai 2023

How can I troubleshoot a router.js:958 error while processing route: item in Ember.js?

Any thoughts as to how this can be fixed -- I have not a clue! It works fine until an upgrade is done. I have tried multiple times with various versions but no go.

post-upgrade: router.js:958 Error while processing route: item You must provide a param idPath. and
jquery.min.js:2 Uncaught Error: You must provide a param idPath.

bower.json original { "name": "shepherd", "private": true, "dependencies": { "bootstrap": "~3.3.2", "ember": "~1.10.0", "handlebars": "~3.0.0", "jquery": "~1.11.3" } } # updated(attempt) { "name": "shepherd", "private": true, "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "jquery": "^3.7.0", "bootstrap": "^5.2.3", "handlebars": "^4.7.7", "ember": "^2.0" } }

# tab config  index.html: <script src="config.js"></script>
# consumed by app.js
<script src="app.js"></script>
var config = {}
config.title = 'TABS Title'
config.items = [
  {name: 'T1', items: [
    {name: "NDC-A", items: [
      {name: "T1-NDCA:Z1 Stats", url: "<LINK>"},
      {name: "T1-NDCA:Z1 Graphs", url: "<LINK>"},
      {name: "T1-NDCA:Z2 Stats", url: "<LINK>"},
      {name: "T1-NDCA:Z2 Graphs", url: "<LINK>"},
    ]},
    {name: "NDC-B", items: [
      {name: "T1-NDCB:Z1 Stats", url: "<LINK>"},
      {name: "T1-NDCB:Z1 Graphs", url: "<LINK>"},
      {name: "T1-NDCB:Z2 Stats", url: "<LINK>"},
      {name: "T1-NDCB:Z2 Graphs", url: "<LINK>"},
    ]},
   ]},
]

FYI: tabs sample as generated via above config # app.js index.html:

    var App = Ember.Application.create({
    })
    
    App.initializer({
        name: 'config',
        initialize: function(container, app) {
            app.config = Ember.copy(config)
        },
    })
    
    App.Router.map(function() {
        this.resource('item', {path: '/*idPath'})
    })
    
   // fails here
    
    App.ItemRoute = Ember.Route.extend(App.TitleHandler, App.ItemFactory, {
        model: function(params) {
            var items = this.getItems(App.config.items)
            var item = this.getItem(items, params.idPath)
            **// 'item' and 'items' are both populated as expected**
            if (!item) {
                return this.transitionTo('item', '')
            }
            this.setTitle(item.title)
            return item
            **// FAILS HERE 'port return'**
        },
    })
    
    



jeudi 25 mai 2023

How to install ember-cli 4.12.1

When I use npm to install ember-cli 4.12.1 by below command

#npm install -g ember-cli@4.12.1

The install is successful, but I see ember-cli version is 3.27.0

#ember --version
Browserslist: caniuse-lite is outdated. Please run:
  npx update-browserslist-db@latest
  Why you should do it regularly: https://github.com/browserslist/update-db#readme
WARNING: Node v18.16.0 is not tested against Ember CLI on your platform. We recommend that you use the most-recent "Active LTS" version of Node.js. See https://git.io/v7S5n for details.
ember-cli: 3.27.0
node: 18.16.0
os: linux x64

The version is available from npm, so how can I install ember-cli 4.12.1?

#npm view ember-cli
ember-cli@4.12.1 | MIT | deps: 93 | versions: 315Command line tool for developing ambitious ember.js appshttps://cli.emberjs.com/release/
......

I also manually download tarball from https://registry.npmjs.org/ember-cli/-/ember-cli-4.12.1.tgz and installed the tarball, but the version still is 3.27.0




mercredi 24 mai 2023

Why am I losing JSDoc type definitions when importing a React library into an Ember app in a monorepo?

I have two packages in a single repo, charts is for all of the charts and is built in React, while ui is for the rest of the UI and built in Ember.

Because the charts library is quite complicated, I decided to add JSDoc to each chart to expose the expected parameters to the UI library. To make this simpler, each chart is exported, then imported into a index.js file in the React app, which is then imported into the Ember app and consumed there.

The issue I'm facing is that I can see the type definition everywhere in the React app, but as soon as I import it into the Ember app, I lose all of the type definition on hover

I tried following the steps here to no avail




lundi 22 mai 2023

Adding custom text below categories image in discourse

In discourse categories page have one class i can target to add custom text using content on class::after but this function create text on all the images because all have same class .category-logo.aspect-image img , i want to add unique text below all categories , i have written this code but it only works after reloading the page. please support

    <script>
  document.addEventListener("DOMContentLoaded", function() {
    $(function() {
      var categories = [
        {
          logoUrl: "/uploads/",
          line1: "ATALANTA, USA",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
        {
          logoUrl: "/uploads", // Replace with actual image URL for Category 2
          line1: "Denver, United States",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
        // Add more objects for other categories
        {
          logoUrl: "/uploads", // Replace with actual image URL for Category 2
          line1: "Dowman Drive, Atalanta",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
        {
          logoUrl: "/uploads", // Replace with actual image URL for Category 2
          line1: "ATALANTA, USA",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
        {
          logoUrl: "/uploads", // Replace with actual image URL for Category 2
          line1: "ATALANTA, USA",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
        {
          logoUrl: "/uploads", // Replace with actual image URL for Category 2
          line1: "ATALANTA, USA",
          line2: "<a href='https://example.com' style='color: #646464;'>WWW.ATALANTA.COM</a>"
        },
      ];

      $(".category-heading").each(function(index) {
        var category = categories[index];
        var $logoElement = $(this).find(".category-logo img");
        var $descriptionElement = $("<p>")
          .html(category.line1 + "<br>" + category.line2)
          .addClass("custom99"); // Add your custom class name here

        $logoElement.after($descriptionElement);
      });
    });
  });
</script>



vendredi 12 mai 2023

Having trouble with QUnit test in ember because of Toast-ui-Editor, cannot find the solution

I'm currently working on an emberJS project, and I have a random global failure whenever I'm running tests (QUnit). We've been working on it since few days with a colleague, and we found out that it's coming from the Toast UI editor made for ember (https://github.com/evocount/ember-tui-editor) It hasn't been updated since 7 months, but we have no idea what to do to solve the problem :/

we tried to add a later() method to wait (like a set Timeout) and it's not working when we comment the willDestroy ember hook inside the TUI component, tests are running completely. There is no coherent pattern to find out what the problem exactly is! ^^'




lundi 8 mai 2023

Parent route's model gets fired when transition to child route in ember

Having parent route with dynamic segment and queryparam and child route with dynamic segment. From parent route tried to transition to child route, but parents model hook is also getting triggered again.

Example:

From Route: parent/:parent_id? Qp=sample To Route: Parent/:parent_id/child/:child_id? Qp=sample

Currently in "From Route" And trying to transition to "To Route". But parent's model hook getting called again.

I don't want the parent route to triggered again. Please help me how to solve this issue.




npm - same dependency version getting different dependencies tree

In my two projects, I have defined devDependencies for optional-features as

"@ember/optional-features": "^1.3.0",

But when I do npm ls after npm install in both projects, I get different dependency tree.

One has

├─┬ @ember/optional-features@1.3.0
│ └─┬ inquirer@7.1.0
│   └── lodash@4.17.15  deduped

Second one has :

├─┬ @ember/optional-features@1.3.0
│ └─┬ inquirer@7.3.3
│   └── lodash@4.17.21  deduped

In ember/option-features, inquirer is defined as "inquirer": "^7.0.1",

I have verified that I am using same nvm version for both the projects.

Why npm is not getting same inquirer@7.3.3 for both projects? Is there something I am missing?