Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

François GrandSchtroumpf

🏠
Working from home
View GitHub Profile
@GrandSchtroumpf
GrandSchtroumpf / fireauth.service.preview.ts
Created Sep 9, 2019
Preview of Firebase Auth Service
View fireauth.service.preview.ts
import { inject } from '@angular/core';
import { AngularFireAuth } from '@angular/fire/auth';
import { AngularFirestore, AngularFirestoreCollection } from '@angular/fire/firestore';
import { auth, User } from 'firebase';
import { switchMap, tap } from 'rxjs/operators';
import { Observable, of, combineLatest } from 'rxjs';
import { Store } from '@datorama/akita';
export const fireAuthProviders = ['github', 'google', 'microsoft', 'facebook', 'twitter' , 'email'] as const;
@GrandSchtroumpf
GrandSchtroumpf / external-script.js
Created May 11, 2020
External Script to test vscode extension webview
View external-script.js
console.log('Hello World From External source');
@GrandSchtroumpf
GrandSchtroumpf / Markdium-typescript.ts
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-typescript.ts
RouterModule.forRoot([], { useHash: true })
@GrandSchtroumpf
GrandSchtroumpf / Markdium-JSON.json
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-JSON.json
"assets": [
"apps/vs-code/src/assets",
"apps/vs-code/src/package.json"
]
@GrandSchtroumpf
GrandSchtroumpf / Markdium-typescript.ts
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-typescript.ts
const html = await fs.readFile(join(context.extensionPath, 'studio/index.html'), 'utf-8');
// 1. Get all link prefixed by href or src
const matchLinks = /(href|src)="([^"]*)"/g;
// 2. Transform the result of the regex into a vscode's URI format
const toUri = (_, prefix: 'href' | 'src', link: string) => {
// For
if (link === '#') {
return `${prefix}="${link}"`;
}
@GrandSchtroumpf
GrandSchtroumpf / Markdium-JSON.json
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-JSON.json
{
"version": "0.2.0",
"configurations": [{
"name": "Run Extension In Dev Mode",
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceFolder}/dist/apps/vs-code"
],
@GrandSchtroumpf
GrandSchtroumpf / Markdium-typescript.ts
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-typescript.ts
import { promises as fs } from 'fs'; // Require @types/node@latest
import { join } from 'path';
// On activation
export function activate(context: ExtensionContext) {
// Register command "start"
commands.registerCommand('start', async () => {
...
const indexPath = join(context.extensionPath, 'studio/index.html');
const html = await fs.readFile(indexPath, 'utf-8');
@GrandSchtroumpf
GrandSchtroumpf / Markdium-typescript.ts
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-typescript.ts
import { commands, ExtensionContext, window } from 'vscode';
// On activation
export function activate(context: ExtensionContext) {
// Register command "start"
commands.registerCommand('start', () => {
window.showInformationMessage('Hello World');
})
}
@GrandSchtroumpf
GrandSchtroumpf / Markdium-typescript.ts
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-typescript.ts
const index = join(context.extensionPath, 'studio/index.html');
// Refresh the webview on update from the code
const updateWebview = async () => {
const html = await fs.readFile(index, 'utf-8');
panel.webview.html = html.replace(matchLinks, toUri);
}
// In dev mode listen on changes from index.html & update the view
if (!environment.production) {
@GrandSchtroumpf
GrandSchtroumpf / Markdium-JSON.json
Created May 7, 2020
Markdium-VSCode extension inside a nx workspace
View Markdium-JSON.json
{
"name": "studio",
"version": "0.0.0",
"main": "main.js",
"engines": {
"vscode": "^1.44.0"
},
"contributes": {
"commands": [{
"command": "start",
You can’t perform that action at this time.