Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 35 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@
"main": "./lib/diff2html.js",
"module": "./lib-esm/diff2html.js",
"types": "./lib/diff2html.d.ts",
"ts-node": {
"compilerOptions": {
"module": "commonjs",
"typeRoots": [
"./node_modules/@types",
"./typings"
]
}
},
"lint-staged": {
"**/*.+(js|jsx|ts|tsx|json)": [
"prettier --write",
Expand All @@ -82,7 +91,7 @@
},
"dependencies": {
"diff": "^7.0.0",
"hogan.js": "3.0.2"
"@profoundlogic/hogan": "^3.0.4"
},
"optionalDependencies": {
"highlight.js": "11.9.0"
Expand Down
11 changes: 7 additions & 4 deletions scripts/hulk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@
* limitations under the License.
*/

// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path="./profoundlogic__hogan.d.ts" />

import * as path from 'path';
import * as fs from 'fs';

import * as hogan from 'hogan.js';
import * as hogan from '@profoundlogic/hogan';
import nopt from 'nopt';
import * as mkderp from 'mkdirp';

Expand Down Expand Up @@ -118,7 +121,7 @@ function wrap(file: string, name: string, openedFile: string): string {
case 'amd':
return `define(${
!options.outputdir ? `"${path.join(path.dirname(file), name)}", ` : ''
}["hogan.js"], function(Hogan) { return ${hoganTemplateString}; });`;
}["@profoundlogic/hogan"], function(Hogan) { return ${hoganTemplateString}; });`;

case 'node':
// If we have a template per file the export will expose the template directly
Expand All @@ -139,12 +142,12 @@ function prepareOutput(content: string): string {
case 'node':
return `(function() {
if (!!!global.${variableName}) global.${variableName} = {};
var Hogan = require("hogan.js");
var Hogan = require("@profoundlogic/hogan);
${content}
${!options.outputdir ? `module.exports = global.${variableName};\n` : ''})();`;

case 'ts':
return `import * as Hogan from "hogan.js";
return `import * as Hogan from "@profoundlogic/hogan";
type CompiledTemplates = { [name: string]: Hogan.Template };
export const ${variableName}: CompiledTemplates = {};
${content}`;
Expand Down
52 changes: 52 additions & 0 deletions scripts/profoundlogic__hogan.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
declare module '@profoundlogic/hogan' {
export interface Context {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}

export interface SectionTags {
o: string;
c: string;
}

export interface HoganOptions {
asString?: boolean | undefined;
sectionTags?: readonly SectionTags[] | undefined;
delimiters?: string | undefined;
disableLambda?: boolean | undefined;
}

export interface Token {
tag: string;
otag?: string | undefined;
ctag?: string | undefined;
i?: number | undefined;
n?: string | undefined;
text?: string | undefined;
}

export interface Leaf extends Token {
end: number;
nodes: Token[];
}

export type Tree = Leaf[];

export interface Partials {
[symbol: string]: HoganTemplate;
}

export class HoganTemplate {
render(context: Context, partials?: Partials, indent?: string): string;
}

export { HoganTemplate as Template, HoganTemplate as template };

export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate;
export function compile(text: string, options?: HoganOptions & { asString: true }): string;
export function compile(text: string, options?: HoganOptions): HoganTemplate | string;

export function scan(text: string, delimiters?: string): Token[];

export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree;
}
2 changes: 1 addition & 1 deletion src/hoganjs-utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as Hogan from 'hogan.js';
import * as Hogan from '@profoundlogic/hogan';

import { defaultTemplates } from './diff2html-templates';

Expand Down
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"include": ["src/**/*", "typings/**/*"],
"include": ["src/**/*", "typings/**/*", "scripts/**/*"],
"exclude": ["node_modules", "src/__tests__/**"],
"compilerOptions": {
"outDir": "bundles-out",
Expand Down Expand Up @@ -32,6 +32,7 @@
"preserveConstEnums": true,
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitThis": true
"noImplicitThis": true,
"typeRoots": ["./node_modules/@types", "./typings"]
}
}
52 changes: 52 additions & 0 deletions typings/profoundlogic__hogan.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
declare module '@profoundlogic/hogan' {
export interface Context {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
[key: string]: any;
}

export interface SectionTags {
o: string;
c: string;
}

export interface HoganOptions {
asString?: boolean | undefined;
sectionTags?: readonly SectionTags[] | undefined;
delimiters?: string | undefined;
disableLambda?: boolean | undefined;
}

export interface Token {
tag: string;
otag?: string | undefined;
ctag?: string | undefined;
i?: number | undefined;
n?: string | undefined;
text?: string | undefined;
}

export interface Leaf extends Token {
end: number;
nodes: Token[];
}

export type Tree = Leaf[];

export interface Partials {
[symbol: string]: HoganTemplate;
}

export class HoganTemplate {
render(context: Context, partials?: Partials, indent?: string): string;
}

export { HoganTemplate as Template, HoganTemplate as template };

export function compile(text: string, options?: HoganOptions & { asString: false }): HoganTemplate;
export function compile(text: string, options?: HoganOptions & { asString: true }): string;
export function compile(text: string, options?: HoganOptions): HoganTemplate | string;

export function scan(text: string, delimiters?: string): Token[];

export function parse(tokens: readonly Token[], text?: undefined, options?: HoganOptions): Tree;
}