Skip to content

Commit

Permalink
Fixes for highlighting
Browse files Browse the repository at this point in the history
  • Loading branch information
yashovardhan committed Nov 29, 2023
1 parent cab7cb3 commit dadebf3
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
8 changes: 3 additions & 5 deletions plugins/docusaurus-plugin-virtual-files/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ module.exports = (context, options) => ({
const dir = path.resolve(context.siteDir, options.rootDir);
const filenames = Object.values(hostedFileLinks);
const fileContents = {};
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir, { recursive: true });
}

if (environment === "development") {
var data = "";
for (const filename of filenames) {
const filePath = path.join(dir, filename.replaceAll("/", "-"));
const directoryPath = path.dirname(filePath);

try {
data = await readFileAsync(filePath, "utf8");
} catch (e) {
Expand All @@ -44,9 +45,6 @@ module.exports = (context, options) => ({
data = await fetchHostedFile(filename);

try {
if (!fs.existsSync(directoryPath)) {
fs.mkdirSync(directoryPath, { recursive: true });
}
await writeFileAsync(filePath, data);
console.log(`Saved ${filename} to cache`);
} catch (error) {
Expand Down
7 changes: 3 additions & 4 deletions src/pages/integration-builder/builder/choices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const MPC_CORE_KIT = "MPC_CORE_KIT";

// Platform choices
export const REACT = "REACT";
export const NEXT = "NEXT";
export const NEXTJS = "NEXTJS";
export const VUE = "VUE";
export const ANGULAR = "ANGULAR";
export const HTML = "HTML";
Expand All @@ -39,7 +39,7 @@ export const UNREAL = "UNREAL";
export const NODE = "NODE";

export const WEB_SDKS = [PNP_MODAL, PNP_NO_MODAL, SFA_WEB, MPC_CORE_KIT];
export const WEB_FRAMEWORKS = [REACT, NEXT, VUE, ANGULAR, HTML];
export const WEB_FRAMEWORKS = [REACT, NEXTJS, VUE, ANGULAR];

export const SDKS_PNP: DisplayChoice[] = [
{ key: PNP_MODAL, displayName: "Web - Modal SDK" },
Expand All @@ -62,10 +62,9 @@ export const SDKS_CORE_KIT: DisplayChoice[] = [

export const LANGS_WEB: DisplayChoice[] = [
{ key: REACT, displayName: "React" },
{ key: NEXT, displayName: "Next JS" },
{ key: NEXTJS, displayName: "Next JS" },
{ key: VUE, displayName: "Vue" },
{ key: ANGULAR, displayName: "Angular" },
{ key: HTML, displayName: "HTML/JS" },
];

export const LANGS_WEB_PNP_MODAL: DisplayChoice[] = [...LANGS_WEB, { key: HTML, displayName: "HTML/JS" }];
Expand Down
6 changes: 3 additions & 3 deletions src/pages/integration-builder/builder/highlight.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
function highlightStart(fileContent: string, variableName: string): string {
const contentByLine = fileContent.split(`\n`);
for (let i = 0; i < contentByLine.length; i += 1) {
if (contentByLine[i].includes(`HIGHLIGHTSTART-${variableName}`)) {
if (contentByLine[i].includes(`IMP START - ${variableName}`)) {
contentByLine[i] = "// highlight-start";
}
}
Expand All @@ -11,7 +11,7 @@ function highlightStart(fileContent: string, variableName: string): string {
function highlightEnd(fileContent: string, variableName: string): string {
const contentByLine = fileContent.split(`\n`);
for (let i = 0; i < contentByLine.length; i += 1) {
if (contentByLine[i].includes(`HIGHLIGHTEND-${variableName}`)) {
if (contentByLine[i].includes(`IMP END - ${variableName}`)) {
contentByLine[i] = "// highlight-end";
}
}
Expand All @@ -22,7 +22,7 @@ function removeHighlightCode(fileContent: string): string {
// 2. line that this occurs on
const contentByLine = fileContent.split(`\n`);
for (let i = 0; i < contentByLine.length; i += 1) {
if (contentByLine[i].includes("HIGHLIGHT")) {
if (contentByLine[i].includes("IMP")) {
contentByLine.splice(i, 1);
}
}
Expand Down
6 changes: 4 additions & 2 deletions src/pages/integration-builder/builder/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* eslint-disable camelcase */
import { IntegrationBuilder, IntegrationStep } from "../interfaces";
import {
CORE_KIT,
HTML,
LANGS_ANDROID,
LANGS_FLUTTER,
LANGS_IOS,
Expand Down Expand Up @@ -205,7 +205,9 @@ const builder: IntegrationBuilder = {

if (WEB_SDKS.includes(finalValues.sdk)) {
if (!WEB_FRAMEWORKS.includes(finalValues.framework)) {
finalValues.framework = WEB_FRAMEWORKS[0];
if (!(finalValues.sdk === PNP_MODAL && finalValues.framework === HTML)) {
finalValues.framework = WEB_FRAMEWORKS[0];
}
}
selectedSDK = `${finalValues.sdk}_${finalValues.framework}`;
} else {
Expand Down
26 changes: 15 additions & 11 deletions src/pages/integration-builder/builder/pnp/web_modal/html/steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,51 @@ export default function getSteps(steps, files, replacementAggregator) {
steps.push(
{
...STEPS.htmlQuickStart,
pointer: replacementAggregator.highlightRange(hostedFileLinks.MODAL_HTML_STYLE_CSS, files[hostedFileLinks.MODAL_HTML_STYLE_CSS], "Quick Start"),
pointer: replacementAggregator.highlightRange(
hostedFileLinks.MODAL_HTML_INDEX_HTML,
files[hostedFileLinks.MODAL_HTML_INDEX_HTML],
"Quick Start"
),
},
{
...STEPS.registerApp,
pointer: replacementAggregator.highlightRange(
hostedFileLinks.MODAL_HTML_STYLE_CSS,
files[hostedFileLinks.MODAL_HTML_STYLE_CSS],
hostedFileLinks.MODAL_HTML_INDEX_HTML,
files[hostedFileLinks.MODAL_HTML_INDEX_HTML],
"Dashboard Registration"
),
},
{
...STEPS.initialization,
pointer: replacementAggregator.highlightRange(
hostedFileLinks.MODAL_HTML_STYLE_CSS,
files[hostedFileLinks.MODAL_HTML_STYLE_CSS],
hostedFileLinks.MODAL_HTML_INDEX_HTML,
files[hostedFileLinks.MODAL_HTML_INDEX_HTML],
"SDK Initialization"
),
},
{
...STEPS.login,
pointer: replacementAggregator.highlightRange(hostedFileLinks.MODAL_HTML_STYLE_CSS, files[hostedFileLinks.MODAL_HTML_STYLE_CSS], "Login"),
pointer: replacementAggregator.highlightRange(hostedFileLinks.MODAL_HTML_INDEX_HTML, files[hostedFileLinks.MODAL_HTML_INDEX_HTML], "Login"),
},
{
...STEPS.getUserInfo,
pointer: replacementAggregator.highlightRange(
hostedFileLinks.MODAL_HTML_STYLE_CSS,
files[hostedFileLinks.MODAL_HTML_STYLE_CSS],
hostedFileLinks.MODAL_HTML_INDEX_HTML,
files[hostedFileLinks.MODAL_HTML_INDEX_HTML],
"Get User Information"
),
},
{
...STEPS.blockchainCalls,
pointer: replacementAggregator.highlightRange(
hostedFileLinks.MODAL_HTML_STYLE_CSS,
files[hostedFileLinks.MODAL_HTML_STYLE_CSS],
hostedFileLinks.MODAL_HTML_INDEX_HTML,
files[hostedFileLinks.MODAL_HTML_INDEX_HTML],
"Blockchain Calls"
),
},
{
...STEPS.logout,
pointer: replacementAggregator.highlightRange(hostedFileLinks.MODAL_HTML_STYLE_CSS, files[hostedFileLinks.MODAL_HTML_STYLE_CSS], "Logout"),
pointer: replacementAggregator.highlightRange(hostedFileLinks.MODAL_HTML_INDEX_HTML, files[hostedFileLinks.MODAL_HTML_INDEX_HTML], "Logout"),
}
);
}
4 changes: 2 additions & 2 deletions src/pages/integration-builder/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ export class ReplaceFileAggregator {
const startLine = [];
const endLine = [];
for (let i = 0; i < contentByLine.length; i += 1) {
if (contentByLine[i].includes(`HIGHLIGHTSTART-${variableName}`)) {
if (contentByLine[i].includes(`IMP START - ${variableName}`)) {
startLine.push(i);
}
if (contentByLine[i].includes(`HIGHLIGHTEND-${variableName}`)) {
if (contentByLine[i].includes(`IMP END - ${variableName}`)) {
endLine.push(i);
}
}
Expand Down

0 comments on commit dadebf3

Please sign in to comment.