Giter Site home page Giter Site logo

ripe-tech / ripe-sdk Goto Github PK

View Code? Open in Web Editor NEW
8.0 9.0 4.0 4.35 MB

The public Javascript SDK for RIPE Core

Home Page: https://www.platforme.com

License: Apache License 2.0

JavaScript 98.94% Python 0.17% CSS 0.30% Smarty 0.54% Dockerfile 0.05%
ripe sdk library vanilla-javascript

ripe-sdk's Introduction

RIPE SDK

The public SDK for RIPE Core written in vanilla ECMAScript v6.

Installation

When using RIPE SDK in a web context, include it via a <script> tag, such as:

<script type="text/javascript" src="https://sdk.platforme.com/js/ripe.min.js"></script>

When using RIPE SDK in a NPM compatible context, use as such:

npm install --save ripe-sdk

If using the configurator include the needed CSS tag, such as:

<link rel="stylesheet" type="text/css" href="https://sdk.platforme.com/css/ripe.css">

1. Initialization

As a starting point, you need to provide the brand and model of your customizable product. You may also pass an options map to override parameters like the base url of the server where the product is configured, as well as currency and country, which are 'EUR' and 'US' respectively by default.

var ripe = new Ripe({
    brand: brand,
    model: model,
    variant: variant,
    url: url,
    currency: currency,
    country: country,
    dku: dku
});

2. Events

After initializing the Ripe object you should subscribe to the available events so you can easily respond and update your UI.

Ready

Triggered when all of the async operations related with the instance setup are complete.

ripe.bind("ready", function() {
    doSomeStuff();
});

Update

Triggered whenever there is a customization change (eg: the color of a part is changed).

ripe.bind("update", function() {
    updateUI();
});

Price

Notifies you when the price of the customization changes.

ripe.bind("price", function(value) {
    var price = document.getElementById("price");
    price.innerHTML = value.total.price_final + " " + value.total.currency;
});

Config

Called when a new model configuration has been loaded. You should use this to explore the model's configuration data, ie: when populating the customization options on your UI.

ripe.bind("config", function(config) {
    var parts = config.parts;
});

Combinations

Called when the possible customization combinations of the product are loaded. Each combination is a triplet formed by part, material and color.

ripe.bind("combinations", function(value) {
    for (var index = 0; index < value.length; index++) {
        var triplet = value[index];
        var part = triplet[0];
        var material = triplet[1];
        var color = triplet[2];
        // (...)
    }
});

Parts

Notifies you when all the product's parts have changed.

ripe.bind("parts", function(parts) {
    parts && showPartsPicker(parts);
});

You can also be notified when a part is selected.

ripe.bind("selected_part", function(part) {
    console.log("Part selected: ", part);
});

Frames

Triggered whenever there is a frame change.

configurator.bind("changed_frame", function(frame) {
    frame === "top" && disableButton("top-view-button");
});

3. Product visualization

Usually the product has 24 lateral frames, plus a top and bottom view. To display any frame of the product you can use the bindImage function to automatically update an <img> element. This method also contains an options parameter. Subscribe to the event loaded and you will know when your image is loaded. Finally, after the initial binding of the frames you should call the load function for the initial update.

var element = document.getElementById("frame-0")
var image = ripe.bindImage(element, {
    frame: "side-0"
});

image.bind("loaded", function(frame) {
    console.log("frame " + frame + " loaded")
});

ripe.load();

Whenever you want to set a new image frame, you only have to call setFrame function.

image.setFrame("side-3");

4. Product customization

You can change a part of your product by using the setPart function. Alternatively, multiple parts can be changed at once with setParts.

ripe.setPart(part, material, color);
ripe.setParts([
    [part, material, color],
    [part, material, color]
]);

To undo part changes in the product you can call the undo function. The method canUndo is also available so you can allow the undo operation based on the current changes. To reverse an undo operation you can use the redo function.

if (ripe.canUndo()) {
    ripe.undo();
}

if (ripe.canRedo()) {
    ripe.redo();
}

Getters

If you need to explicitly retrieve the product's customization information you can use the following methods:

  • getConfig: to get information about the product's model.
  • getCombinations: to get all the customization options for products without any restrictions applied.
  • getDefaults: to get the product's default customization.
  • getFrames: to get all the product's frames.
  • getPrice: to get the product's pricing information.
  • getFactory: to get the factory information where the model is made, specifically its name and the estimated production time in days.

These functions receive a callback function as a parameter as shown below:

ripe.getPrice(function(value) {
    var price = document.getElementById("price");
    price.innerHTML = value.total.price_final + " " + value.total.currency;
});

5. Product personalization

To display a frame with initials you can use the bindImage function by setting the parameter showInitials as true on the options map. The initials are set on the Ripe object with the setInitials function which accepts initials and engraving as parameters. If your initials require a transformation to different profiles you can set a function that receives the initials and engraving parameters and transforms it into a map with initials and an array of profiles using the setInitialsBuilder function.

ripe.setInitials("SW", "metal_gold");

ripe.bindImage(document.getElementById("frame-initials"), {
    showInitials: true
});

6. Product interaction

To provide an interactive product visualization you simply need to pass a <div> element to the method bindConfigurator. Subscribe to the event loaded and you will know when your configurator is loaded.

This element supports the following methods:

Method Params Description
changeFrame
  • frame (string), named frame defined in the "view-position" format. Eg.: "side-0"
  • options (JSON object with optional fields): duration: (number) total duration, in milliseconds, of the animation; type: (string) the animation style you want, which can be "simple" (fade in), "cross" (crossfade) or null (without any style)*; preventDrag: (boolean) to choose if drag actions during an animated change of frames should be ignored. "True" by default
Displays a new frame, with an animation from the starting frame.
highlight
  • part (string), named part
  • options (JSON object with optional fields)
Highlights a product's part.
lowlight
  • options (JSON object with optional fields)
Removes any highlight from the product.
selectPart
  • part (string), named part
  • options (JSON object with optional fields)
Selects a given product's part.
deselectPart
  • part (string), named part
  • options (JSON object with optional fields)
Removes selection from a given product's part.

This element supports the following events:

Event Description
ready Triggered upon first loading of the model's internal frame structure (once per model load).
loaded Triggered when the configurator finishes loading all of the internal frames, and is ready for interaction (once per part setting).
changed_frame Raises whenever there's a rotation in the configurator viewport (viewable frame has changed).
var element = document.getElementById("config");
var configurator = ripe.bindConfigurator(element, {});

configurator.bind("loaded", function() {
    this.changeFrame("side-11", {
        duration: 500
    });
});

7. Plugins

Part synchronization

If your product has synchronization rules, where a set of parts must always have the same material and color, you can use the sync plugin to have this behavior automatically. To do this you need to initialize the SyncPlugin which receives the synchronization rules and add it to the ripe object using the addPlugin function. When a new part is set, the plugin checks the synchronization rules and automatically makes the necessary changes to the related parts.

ripe.getConfig(function(config) {
    var syncRules = config.sync;
    var syncPlugin = new Ripe.plugins.SyncPlugin(syncRules);
    ripe.addPlugin(syncPlugin);
});

Part restrictions

To include restrictions to the customization experience the Restrictions plugin is available. This allow setting rules that declare that certain combinations between different parts, materials or colors are not possible. When a new option is selected, the plugin will check if any of the other parts has become restricted by the new part and change them to a valid option automatically. The usage of this plugin is similar to the sync plugin. To be notified when a restriction causes parts to be changed, bind to the restrictions event on the plugin object. Whenever the restrictions are applied, this event will be triggered with the changes that ocurred and the part that caused them.

ripe.getConfig(function(config) {
    var restrictionRules = config.restrictions;
    var restrictionsPlugin = new Ripe.plugins.RestrictionsPlugin(restrictionRules);
    ripe.addPlugin(restrictionsPlugin);
    restrictionsPlugin.bind("restrictions", function(changes, part) {});
});

8. Sizes

If you need to create an order using the ripe-core API then you have to set the size of the product according to the ripe-core native scale. The following methods allow you to convert from and to that scale. scale is a string that represents the size scale, value is the numeric value in that scale and gender is a string that can be set to female, male or kids. To reduce the number of requests when you need to convert several size options you can use the bulk methods that accept an array of values and return an array with all the results.

  • sizeToNative(scale, value, gender)
  • nativeToSize(scale, value, gender)
  • sizeToNativeB(scales, values, genders)
  • nativeToSizeB(scales, values, genders)

9. Authentication

When using API methods that require special permissions you can use the following methods to authenticate your application: auth(username, password, callback), for login with username and password, or OAuth authentication with oauth:

if (ripe.isOAuthPending()) {
    ripe.oauth({
        clientId: clientId,
        clientSecret: clientSecret,
        scope: ["admin"]
    });
}

Appendix

Options

Name Type Description
backgroundColor string RGB format color value of the background ( no need to pass the "#" signal ). No background by default. Example: "cccccc".
country string Two letters standard country codes defined in ISO 3166-1 alpha-2 codes. "US" by default. Example: "PT".
currency string Standard currency codes defined in ISO 4217 codes. "USD" by default. Example: "EUR".
frames array of strings All the frames to be used in the customization. Example: ["top", "bottom", "1", "2"].
format string One of the valid image formats: 'lossless', 'lossful', 'jpeg', 'webp', 'sgi' or 'png'. "null" by default.
maskDuration number Specifies how many milliseconds the mask animation takes to complete. 150 by default.
maskOpacity number Specifies the opacity value of the the masks used to highlight/select parts. 0.4 by default.
maxSize number Maximum value for frame image size. 1000px by default.
noCombinations boolean Defines if the combinations are loaded or not. False (loading) by default.
noDefaults boolean Defines if the defaults are loaded or not. False (loading) by default.
noMasks boolean Used to negate the useMasks option.
noPrice boolean Used to negate the usePrice option.
parts JSON Object Defines the product initial parts. Each key is a part's name built with color and material information. Example: var parts = { "sole": { "material": "nappa", "color": "white" }, ... }.
remoteCalls boolean Activates the remote calls functionality executed by several workflows. True by default.
remoteOnConfig boolean Activates the remote execution of the model's logic on config updates. True by default.
remoteOnPart boolean Activates the remote execution of the model's logic on parts updates. True by default.
remoteOnInitials boolean Activates the remote execution of the model's logic on initials updates. True by default.
sensitivity string Defines the degree of sensitivity of the dragging interaction. 40 by default.
size number Initial size value of a frame image that is going to be composed. By default it's 1000px.
url string The base url of the server where the product is configured.
variant string Variant of the customizable product.
version string The version of the build of the customizable product.
useChain boolean Determines if a chain based loading should be used for the pre-loading process of the various image resources to be loaded. False by default.
useMasks boolean Enables masks on selection/highlight. True by default.
usePrice boolean Enables the fetch price feature every time a new part is set. True by default.
useSync boolean Enables the part synchronization feature. False by default.
useInitialsBuilderLogic boolean Enables the usage of the client-side initials builder logic defined in the 3DB, instead of the default one. True by default.

Browser Support

Desktop:

  • ≥ Chrome v23 (V8)
  • ≥ Firefox v21 (SpiderMonkey)
  • ≥ Safari v6 (Nitro)
  • ≥ Opera v12 (V8)
  • ≥ IE v11 (Chakra)

Mobile:

  • ≥ Android 4.4
  • ≥ iOS's WebKit 9

Documentation

For API reference documentation follow ripe-sdk-docs.platforme.com.

License

RIPE SDK is currently licensed under the Apache License, Version 2.0.

Build Automation

Build Status Build Status GitHub npm Status License

ripe-sdk's People

Contributors

3rdvision avatar beemargarida avatar beneditomauro avatar flavioolima avatar gcandal avatar hugo-gomes avatar joamag avatar joao-conde avatar joaofsl avatar marcosoliveira91 avatar nfss10 avatar rafaelramalho19 avatar simaob avatar veryprofessionaldodo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ripe-sdk's Issues

Tests are consistently failing and deployment is failing

Description

The npm run test step of the deployment is consistently failing in the same step and is not related to the deployment.

The error log is the following:

  1) ConfigAPI
       #configResolveSku()
         should resolve SKU:
     Uncaught TypeError: Cannot read property 'body' of null
      at /__w/ripe-sdk/ripe-sdk/node_modules/node-fetch/lib/index.js:1519:27
      at IncomingMessage.<anonymous> (node_modules/node-fetch/lib/index.js:1749:6)
      at IncomingMessage.<anonymous> (_http_client.js:389:14)
      at endReadableNT (_stream_readable.js:1241:12)
      at processTicksAndRejections (internal/process/task_queues.js:84:21)

  2) ConfigAPI
       #configResolveSku()
         should resolve SKU:
     Error: done() called multiple times in test <ConfigAPI #configResolveSku() should resolve SKU> of file /__w/ripe-sdk/ripe-sdk/test/js/api/config.js
      at runMicrotasks (<anonymous>)
      at processTicksAndRejections (internal/process/task_queues.js:97:5)



[12:00:20] 'test' errored after 2.78 min
[12:00:20] Error in plugin "gulp-mocha"

After an in-depth inspection the error is caused because of the race condition to delete the SKU at https://github.com/ripe-tech/ripe-sdk/blob/master/test/js/api/config.js#L199

This implementation of Promise will run after the test block is complete and call done a little bit after the previous requests are also complete which means done() will be called 2 times and thus the error "done() called multiple times".

This is not reproducible locally which means that is impacted by the network and processing speed - because the workflows are run on a low tier container it always reproduces.

Expected vs. Observed

- -
Expected The tests pass.
Observed The tests fail.

Repro Steps

  1. Run yarn && yarn build && yarn test
  2. See tests failing

getLogoUrl

Description

Create getLogo, getLogoP and getLogoUrl functions (similarly to getMeshX) that will rely on RIPE Core's /api/brands/<str:brand>/logo.<str:format>.

RIPE SDK not compatible with Nuxt.js under Vercel

Description

It's not possible to use the RIPE SDK with Nuxt.js when building the application with --standalone, which is done by Vercel. Accessing the page where RIPE SDK is imported results in:

 ERROR  window is not defined                                                                                                                                                                                                                                                            09:18:03

  at Object.<anonymous> (node_modules/ripe-sdk/src/js/base/compat.js:83:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Object.<anonymous> (node_modules/ripe-sdk/src/js/base/api.js:11:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Object.<anonymous> (node_modules/ripe-sdk/src/js/base/index.js:1:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Object.<anonymous> (node_modules/ripe-sdk/src/js/api/account.js:9:0)
  at __webpack_require__ (webpack/bootstrap:25:0)
  at Object.<anonymous> (node_modules/ripe-sdk/src/js/api/index.js:1:0)
  at __webpack_require__ (webpack/bootstrap:25:0)


 ERROR  Cannot read property 'a' of undefined                                                                                                                                                                                                                                            09:18:03

  at Module.ReportHermesLeatherGoods (pages/hermes_leather.js:11360:145)
  at c (node_modules/vue/dist/vue.runtime.common.prod.js:6:0)
  at Tt (node_modules/vue/dist/vue.runtime.common.prod.js:6:0)
  at Function.Cn.t.extend (node_modules/vue/dist/vue.runtime.common.prod.js:6:0)
  at sanitizeComponent (.nuxt/utils.js:74:0)
  at server.js:14522:41
  at async Promise.all (index 0)
  at async getRouteData (.nuxt/utils.js:131:0)
  at async Promise.all (index 0)
  at async setContext (.nuxt/utils.js:214:0)

This is caused by the "environment" detection part not being ready to this use case:

if (
    typeof require !== "undefined" &&
    (typeof window === "undefined" || typeof __webpack_require__ !== "undefined") && // eslint-disable-line camelcase
    typeof XMLHttpRequest === "undefined" // eslint-disable-line no-use-before-define
) {
    var XMLHttpRequest = null;
    if (
        // eslint-disable-next-line camelcase
        typeof __webpack_require__ === "undefined" &&
        (typeof navigator === "undefined" || navigator.product !== "ReactNative")
    ) {
        // this is an hack to work around metro's (react-native bundler)
        // static analysis, needed until it supports optional imports
        // (https://github.com/react-native-community/discussions-and-proposals/issues/120)
        const mixedModuleName = "Xmlhttprequest";
        const correctModuleName = mixedModuleName.toLowerCase();
        XMLHttpRequest = require(correctModuleName).XMLHttpRequest;
    } else {
        XMLHttpRequest = window.XMLHttpRequest;
    }
}

The values at play here are:

  • require is defined
  • __webpack_require__ is defined
  • window is NOT defined
  • XMLHttpRequest is NOT defined

Even though require is available and would be able to import XMLHttpRequest, the code is ending up in XMLHttpRequest = window.XMLHttpRequest; which throws an error.

Expected vs. Observed

- -
Expected Be able to import RIPE SDK.
Observed Importing RIPE SDK throws an error.

Repro Steps

  1. Using Nuxt.js, import RIPE SDK in one of the components
  2. Build the application with nuxt build --standalone
  3. Serve the generated files with nuxt start
  4. Make a request to the page where RIPE SDK is being imported

Review and improve documentation

Rationale

The RIPE-SDK documentation is lacking in some aspects such as examples and demos that could help an external person to easily dive in and start using it.

Description

Analyze and check what can be improved with the documentation and maybe create some demos and improve the examples on how to use the SDK, namely the configurator and each of the strategies (PRC and CSR)

Report URLs methods not accepting params

Description

The methods _getOrderReportURL, _getOrderReportPDFURL and _getOrderReportPNGURL aren't correctly handling params as they are being ignored and not properly added to the URL.
The methods sould be fixed and the tests updated to catch those cases.

Expected vs. Observed

- -
Expected Calling _getOrderReportPNGURL(1234, "secret-key", { params: { size: 100 } }); should return orders/1234/report.png?key=secret-key&size=100
Observed Calling _getOrderReportPNGURL(1234, "secret-key", { params: { size: 100 } }); returns orders/1234/report.png?key=secret-key

Repro Steps

  1. Use one of those methods with params passed to options
  2. Check that the params are ignored

Environment

Key Value
Device Any
Operating System Any
Browser Any

Improve textures parameterization

Rationale

Applying textures to the CSR initials is a painful and long process as in some instances there can be up to 5 different texture types just to have the visual result expected. This means that when a user wants to tweak the textures, they need to make the change in all 5 textures, upload them, make a build, deploy it and just then it's possible to visualize the result.This makes things like fine tuning extremely hard and requires the user to know how to use image editing tools when there is no need to.

There are ways to greatly improve this, one of which is supporting the parameterization of the textutes. Doing this allows the user to just specify the texture properties and the rendering will be done respecting those rules. There are no cons and the benefits would be for faster iteration on the creation of builds and allowing the fine tunning of the CSR initials via the spec.

Description

Support texture parametrization. This should be a feature that can be optionally used and the user should be able to set those properties via the config.

Implementation

Add support in CSR initials logic to load and apply textures properties and ripe-docs with documentation about the new properties supported in the config.

References

https://threejs.org/docs/#api/en/textures/Texture

SDK slow response when doing setInitialsExtra

Description

SDK takes too long to update images when calling for several setInitialsExtra.

In practice ripe-white takes much longer - more than 2x the amount of time - than RIPE API to render an image after user initials requests.

I believe this has to do with SDK's implementation to cancel old requests - it's not working as expected.

Please watch the videos below.

Expected vs. Observed

- -
Expected The image should render what it's typed on white right away, not the first character and then the whole word.
Observed The observed state at the end of the repro steps.

Repro Steps

  1. Open ripe-white https://ripe-white-now.platforme.com/?context=saint_laurent_hoodie
  2. Write something in initials input with more than 1 character like "1234"
  3. Watch the image first render an image with the first character "1" and only then "1234" no matter how fast it's typed

Videos

From RIPE White

Peek.2022-02-18.11-27.mp4

From YSL's Website

2022-02-14_15h20_05.mp4

Improve CSR deinitialization process

Test and improve RIPE SDK's CSR Configurator deinitialization logic as might not be completelly freeing all resources and handlers after a few integration tests with RIPE White

Static analysis of XMLHttpRequest package import causes problems on `watch`

Description

The conditional import of the xmlhttprequest package in SDK causes an error:

ERROR in ../ripe-commons-pluginus/node_modules/xmlhttprequest/lib/XMLHttpRequest.js Module not found: Error: Can't resolve 'child_process' in '/Users/margarida/Documents/ripe-commons-pluginus/node_modules/xmlhttprequest/lib'.

By bug was introduced in the commit ebc58a3, where the import of the xmlhttprequest package was directly imported instead of using a variable. With the use of a variable, the problem does not occur, however a warning appears Critical dependency: the request of a dependency is an expression.

Due to this, webpack static analysis may be the cause of the problem.

Similar problems found in the wild:
asvd/jailed#22
cytoscape/cytoscape.js#998

Expected vs. Observed

- -
Expected No errors launched when linking to ripe-sdk.
Observed Errors linking to more recent versions of ripe-sdk.

Repro Steps

  1. Run npm link and npm run watch in ripe-sdk
  2. Link ripe-sdk in ripe-commons-pluginus or ripe-sdk-components-vue with the command npm link ripe-sdk
  3. Link ripe-commons-pluginus to ripe-white or just run ripe-sdk-components-vue.

Environment

Key Value
Device iMac
Operating System MacOS Catalina
Browser Firefox
Instance (URL) https://localhost:3000

Screens

Screenshot 2020-10-14 at 08 40 21

CSR performance optimizations

Rationale

There are some performance gains to be made in the CSR strategy, some of which quick wins others that can come from the addition of new features/settings or from a more calmly review of the code.

Description

Review and improve the CSR performance. This may be by, when possible and if applicable, using parallelization, reusing resources, avoiding unnecessary remote calls, avoiding unnecessary usage/loading of resources, etc.

  • Use compressed textures
  • Run initials renderer in parallel if possible
  • Check the possibility of using workers
    ... maybe more???

CSR in mobile devices

Rationale

The CSR strategy should work in mobile devices without any issues. There may be oportunity for improvements and/or compatibility issues and problems that aren't still detected. Some investigation should be done to check what's the state of the CSR solution in mobile devices.

Description

Test and investigate the mobile experience of the CSR strategy. The idea is to have a robust mobile experience that works as well as the desktop experience.

Client-Side Rendering (CSR)

Sponsors

Rationale

Pre-Render & Compose (PRC) offers maximum quality but low interactivity for customers. Client-Side Rendering allows for maximum interactivity at the cost of some quality. Additionally, CSR is critical in order to provide state-of-the-art rendering strategies.

We're aiming at using this new CSR approach as a tool to strengthen our relationship with our biggest client (Dior).

Description

Extend RIPE SDK to provide a real 3D configurator making use of WebGL technology and using our 3DBs as data source.

Implementation

Software development

  • Define a spec for the 3D information to be stored in the 3DB
  • Extend RIPE SDK with a new configurator
  • Implement the current SDK API, and extend if need be

Estimation

Discipline Estimation
Software Development 60 days

Method for order image URL

Rationale

As there isn't a method in ripe-sdk to get the order image URL so currenlty we manually build the order image URL. Examples: ripe-pulse, ripe-robin-revamp, ripe-util-vue, ripe-copper, etc

Having a method to handle this will make the situation less error prone and ensure that compatiblity is maintained everywhere.

Description

Add a method in ripe-sdk to build and return an order image URL.

Implementation

Add a method called _getOrderImageURL here. The approach would be similar to, for example, _getOrderReportPNGURL

Reference

https://github.com/ripe-tech/products/issues/38 was created because inconsistencies were found between order image URL for build and buildless types.

Estimation

Discipline Estimation
Software Development 0.5 days

"lossless" image format is not lossless

Description

When using lossless as an image format, it's expected to be served images which are lossless, but that's not the case for webp with the default options.

Example:

Failling to load meshes that use Draco

Description

An error is being thrown when trying to load meshes that were compressed using Draco.

Expected vs. Observed

- -
Expected Mesh being loaded without error
Observed Errors are thrown and the mesh isn't loaded

Repro Steps

  1. Add a Draco compressed mesh to the build
  2. Open the CSR configurator
  3. Check that the configurator isn't loading and errors where thrown

Screens

imagem

Configurator ignoring size

Describe the bug
The configurator ignores the width and height passed onto it.

Impact
This prevents the user from changing the default size of the images being rendered.

IE11 issue with ES6 option

Hi,
we have an issue on IE11.

Steps to reproduce

  • Install the SDK using npm install ripe-sdk (latest version 1.2.3).
  • Import ./node_modules/ripe-sdk/dist/ripe-min.js.
  • The page breaks on IE11.

ripe-sdk - error

ripe-sdk - es6 syntax

Analysing the project seems that gulp build task copy the ripe-min from src to dist using uglifyjs with an option for ES6.

ripe-sdk/gulpfile.js

Lines 19 to 32 in 444cafd

gulp.task("build-js", () => {
return gulp.src(paths.scripts)
.pipe(uglifyes({
mangle: false,
ecma: 6
}))
.pipe(replace("__VERSION__", _package.version))
.pipe(size())
.pipe(size({
gzip: true
}))
.pipe(gulp.dest("dist"))
.pipe(count("## js files copied"));
});

API masks with the total image size

Description

When the get the compose on white we receive always the image with 1000x1000, but the masks we receive always with the size we on the build.
Example: brand=dior_tmp & model=book_tote the images are 2000x2000 and we get the mask with this size and the compose with 1000x1000

Expected vs. Observed

- -
Expected Receive the mask 1000x1000.
Observed Receive the mask 2000x2000.

Repro Steps

  1. Open, ripe-white-sbx https://ripe-white-sbx.platforme.com/?brand=dior_tmp&model=book_tote
  2. Open the inspect/ Network and choose images
  3. Refresh the page and see the requests mask and compose
  4. if you compare the masks images with the compose images you will see that have different sizes

Environment

Key Value
Device Desktop
Operating System Ubuntu 21.04
Browser Chrome
Instance (URL) https://ripe-core-sbx.platforme.com/api/mask?brand=dior_tmp&frame=side-0&model=book_tote

Screens

API Mask request:
https://ripe-core-sbx.platforme.com/api/mask?brand=dior_tmp&frame=side-0&model=book_tote
API Compose request:
https://ripe-core-sbx.platforme.com/api/compose?brand=dior_tmp&debug=1&format=webp&frame=side-0&height=1000&model=book_tote&p=body%3Amesh_logo_mizza_dr%3Amizza&p=handle%3Amesh_logo_handle_mizza_dr%3Amizza&p=ribbon%3Across_stich_mizza_dr%3Amizza&p=shadow%3Adefault%3Adefault&width=1000

image

No masks options disable highlighting but masks are still loaded

Description

Through the use of noMasks or useMasks one can control whether the masks are used. However, even when not using them, the SDK still loads them and these represent a significant amount of network requests. We should not load masks if they are not going to be used.

Expected vs. Observed

- -
Expected The masks are show and not loaded i.e. no network requests for masks are made.
Observed The masks are not shown but are loaded and you can see it in the network requests.

Repro Steps

  1. Initialize our RIPE in this repo
  2. Set useMasks: false or noMasks: true in the bindConfigurator method
  3. Build the SDK, launch the demo, go to localhost:8080/simple network tab

Screens

image

Spec.json Tag to deactivate mask

Rationale

Now we have an option on SDK to deactivate the masks and should be nice have a tag to be add in the model spec to deactivate it.

Description

Should be possible add a tag example "no_mask" and when this model is on white the masks are deactivated by default.
example:
image
image

Update Three.js version

Rationale

The Three.js version ripe-sdk is using is not the most recent one thus it's missing some fixes and performance improvements as well as some new features. This exercise should also be done from time to time to gain the beneficts of an update and ensure compatibility with it's evolution.

Description

Update Three.js version to the latest version and migrate what needs to be migrated in order for everything to work properly. The latest version uses ES Modules thus RIPE-SDK needs to be updated to support that.

References

https://threejs.org/docs/index.html#manual/en/introduction/Installation
https://github.com/mrdoob/three.js/wiki/Migration-Guide
https://github.com/mrdoob/three.js/milestones

Environment files

Rationale

Environment mapping is a solution to provide greater realism to the scene illumination. For that it uses a image that will have it's pixels detail lighting information from a certain direction. Being that they are not specific to scenes and are just generic files that can be imported to improve a scene, they can be shared and reused by other scenes thus, not bounded to any context.

Description

Find a way to store an retrieve environment files. They should be able to be accessed by any context as there is no need to have file redundancy.

  • Support HDRI
  • Support other formats
    ... maybe support upload of own environment file???

ripe-sdk doesn't work with RequireJS

ripe-sdk seems doesn't work on projects that use RequireJS.
We are upgrading ripe-sdk from 1.2.4 to latest version (1.6.25), but we encounter this issue:

ripe-sdk requirejs

I notice that between 1.2.4 and latest version the if statement has been changed.
I tried putting back the old one

if (typeof window === "undefined" && typeof require !== "undefined") {
  ...

and it works.

Could you check this?
Thanks

createAttachmentOrder with meta

Rationale

The creation of order attachments expects a file and a meta dictionary (see https://github.com/ripe-tech/ripe-core/blob/ba23882efa65acb165e924c6f836c6933646604f/src/ripe_core/controllers/api/order.py#L97).

However, the current SDK implementation of the endpoint doesn't support meta (see

dataM: {
).

Description

The implementation of the rationale above could probably be similar to:

    options = Object.assign(options, {
        url: url,
        method: "POST",
        dataM: {
            file: file,
            meta: JSON.stringify(meta)
        },
        auth: true
    });

But unless I'm missing something obvious, ripe-sdk doesn't support strings as values when using a multipart payload dataM (see

ripe.Ripe.prototype._encodeMultipart = function(fields, mime = null, doseq = false) {
).

Trying to use them results in RangeError: offset is out of bounds because the string is not being encoded, resulting in this:

image

Related: https://github.com/ripe-tech/ripe-core/pull/4564

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.