Skip to content

Commit

Permalink
ci(publish): try to fix publish actions, attempt 4
Browse files Browse the repository at this point in the history
  • Loading branch information
nvlang committed Jun 30, 2024
1 parent c2ef823 commit ef5a76c
Show file tree
Hide file tree
Showing 40 changed files with 138 additions and 106 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ jobs:
run:
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_ENV

- run: pnpm publish --provenance
- run: pnpm publish --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
14 changes: 13 additions & 1 deletion deno.jsonc
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
{
"$schema": "https://raw.githubusercontent.com/denoland/deno/main/cli/schemas/config-file.v1.json",
"name": "@nvl/sveltex",
"version": "0.1.0-beta.4",
"version": "0.1.0-beta.5",
"exports": {
// Default entry point, which can be imported as `@nvl/sveltex`
".": "./src/mod.ts"
},
"lint": {
"include": ["src/**"],
"exclude": [
"**/node_modules/**",
"**/dist/**",
"**/docs/**",
"**/.github/**",
"**/.vscode/**",
"**/.svelte-kit/**"
]
},
"publish": {
"include": [
// Source files
Expand All @@ -19,6 +30,7 @@
"tsconfig.json",
"jsr.jsonc"
],

"exclude": [
// Unit and E2E tests
"**/tests/**",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nvl/sveltex",
"version": "0.1.0-beta.4",
"version": "0.1.0-beta.5",
"description": "Svelte + Markdown + LaTeX",
"type": "module",
"author": {
Expand Down
2 changes: 1 addition & 1 deletion src/base/Sveltex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ export class Sveltex<
* ⚠ **Warning**: Mutating this object will have no effect on the Sveltex
* instance.
*/
get configuration() {
get configuration(): FullSveltexConfiguration<M, C, T> {
const clone = deepClone(this._configuration);
const { markdown, code, math, verbatim } = this._configuration;

Expand Down
10 changes: 6 additions & 4 deletions src/base/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import {
isPresentAndDefined,
isString,
} from '$typeGuards/utils.js';
import {
import type {
CleanPopplerSvgOptions,
PopplerSvgOptions,
} from '$types/utils/PopplerOptions.js';
import { PropertiesDefined } from '$types/utils/utility-types.js';
import type { PropertiesDefined } from '$types/utils/utility-types.js';
import { interpretAttributes } from '$utils/parseComponent.js';

// External dependencies
Expand Down Expand Up @@ -159,7 +159,9 @@ export function getDefaultMathConfiguration<
}
}

const cacheDir = findCacheDirectory({ name: '@nvl/sveltex' });
const cacheDir: string | undefined = findCacheDirectory({
name: '@nvl/sveltex',
});

/**
* The default cache directory for SvelTeX.
Expand All @@ -169,7 +171,7 @@ const cacheDir = findCacheDirectory({ name: '@nvl/sveltex' });
* 'node_modules/.cache/@nvl/sveltex'
* ```
*/
export const defaultCacheDirectory = cacheDir
export const defaultCacheDirectory: string = cacheDir
? relative(process.cwd(), cacheDir)
: resolve(
process.env['XDG_CACHE_HOME'] ?? join(homedir(), '.cache'),
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/CodeHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { applyTransformations } from '$utils/transformers.js';
import {
type StarryNightLanguage,
starryNightLanguages,
StarryNightScope,
type StarryNightScope,
} from '$data/code.js';

// External dependencies
Expand Down
9 changes: 8 additions & 1 deletion src/handlers/MarkdownHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type {
MarkdownProcessOptions,
MarkdownProcessor,
} from '$types/handlers/Markdown.js';
import type { UnescapeOptions } from '$types/utils/Escape.js';

// Internal dependencies
import { missingDeps } from '$utils/env.js';
Expand Down Expand Up @@ -53,7 +54,13 @@ export class MarkdownHandler<B extends MarkdownBackend> extends Handler<
};
}

override get process() {
override get process(): (
content: string,
options: MarkdownProcessOptions,
) => Promise<{
processed: string;
unescapeOptions: UnescapeOptions;
}> {
return async (content: string, options: MarkdownProcessOptions) => {
let unescapeTags: (str: string) => string = (str) => str;
if (!this._configuration.strict) {
Expand Down
14 changes: 9 additions & 5 deletions src/handlers/MathHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type {
MathProcessFn,
MathProcessOptions,
} from '$types/handlers/Math.js';
import type { ProcessedSnippet } from '$types/utils/Escape.js';

// Internal dependencies
import { getDefaultMathConfiguration } from '$base/defaults.js';
Expand All @@ -33,7 +34,10 @@ export class MathHandler<B extends MathBackend> extends Handler<
FullMathConfiguration<B>,
MathHandler<B>
> {
override get process() {
override get process(): (
tex: string,
options?: MathProcessOptions<B>,
) => Promise<ProcessedSnippet> {
return async (tex: string, options?: MathProcessOptions<B>) => {
await this.handleCss();

Expand Down Expand Up @@ -65,7 +69,7 @@ export class MathHandler<B extends MathBackend> extends Handler<

private _handleCss: (mathHandler: this) => Promise<void> = () =>
Promise.resolve();
get handleCss() {
get handleCss(): () => Promise<void> {
return async () => {
if (this._handledCss) {
return;
Expand Down Expand Up @@ -98,7 +102,7 @@ export class MathHandler<B extends MathBackend> extends Handler<
/* v8 ignore next 2 (unreachable code) */
private _updateCss: (mathHandler: this) => void = () => undefined;

get updateCss() {
get updateCss(): () => void {
return () => {
if (
this.backend === 'mathjax' &&
Expand All @@ -119,7 +123,7 @@ export class MathHandler<B extends MathBackend> extends Handler<
* handler is being used on.
*/
private _headLines: string[] = [];
get headLines() {
get headLines(): string[] {
return this._headLines;
}

Expand All @@ -133,7 +137,7 @@ export class MathHandler<B extends MathBackend> extends Handler<
* of the page.
*/
private _scriptLines: string[] = [];
get scriptLines() {
get scriptLines(): string[] {
return this._scriptLines;
}

Expand Down
6 changes: 5 additions & 1 deletion src/handlers/TexHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { SveltexCache } from '$utils/cache.js';
import { Handler } from '$handlers/Handler.js';
import { pathExists } from '$utils/fs.js';
import { mergeConfigs } from '$utils/merge.js';
import type { ProcessedSnippet } from '$types/utils/Escape.js';

export class TexHandler extends Handler<
TexBackend,
Expand Down Expand Up @@ -45,7 +46,10 @@ export class TexHandler extends Handler<
* @param options - Options to pass to the processor.
* @returns The processed content, or promise resolving to it.
*/
override get process() {
override get process(): (
content: string,
options: TexProcessOptions,
) => ProcessedSnippet | Promise<ProcessedSnippet> {
return (content: string, options: TexProcessOptions) => {
return super.process(content, options);
};
Expand Down
4 changes: 2 additions & 2 deletions src/handlers/VerbatimHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import type { ProcessedSnippet, UnescapeOptions } from '$types/utils/Escape.js';

// Internal dependencies
import { getDefaultVerbEnvConfig } from '$base/defaults.js';
import { TexHandler } from '$handlers/TexHandler.js';
import { CodeHandler } from '$handlers/CodeHandler.js';
import type { TexHandler } from '$handlers/TexHandler.js';
import type { CodeHandler } from '$handlers/CodeHandler.js';
import { Handler } from '$handlers/Handler.js';
import { log } from '$utils/debug.js';
import { diagnoseVerbEnvConfig } from '$utils/diagnosers/verbatimEnvironmentConfiguration.js';
Expand Down
8 changes: 4 additions & 4 deletions src/typeGuards/code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import type { Equals, Extends } from '$deps.js';

// Internal dependencies
import { isOneOf, isString } from '$typeGuards/utils.js';
import { CodeBackend, CodeBackendWithCss } from '$types/handlers/Code.js';
import { SupportedCdn } from '$types/handlers/Css.js';
import type { CodeBackend, CodeBackendWithCss } from '$types/handlers/Code.js';
import type { SupportedCdn } from '$types/handlers/Css.js';
import {
HighlightJsThemeName,
StarryNightThemeName,
type HighlightJsThemeName,
type StarryNightThemeName,
highlightJsThemeNames,
starryNightThemeNames,
} from '$data/code.js';
Expand Down
2 changes: 1 addition & 1 deletion src/typeGuards/frontmatter.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// File description:

// Types
import { Equals, typeAssert } from '$deps.js';
import { type Equals, typeAssert } from '$deps.js';
import type { MetaHttpEquiv, MetaName } from '$types/utils/Frontmatter.js';

export function isMetaName(name: string): name is MetaName {
Expand Down
2 changes: 1 addition & 1 deletion src/typeGuards/verbatim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
} from '$typeGuards/utils.js';

// External dependencies
import { Equals, typeAssert } from '$deps.js';
import { type Equals, typeAssert } from '$deps.js';

export const supportedTexEngines = [
'lualatex',
Expand Down
11 changes: 3 additions & 8 deletions src/types/handlers/Handler.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
// File description: Types related to the `Handler` class.

/* eslint-disable tsdoc/syntax */
import { ProcessedSnippet } from '$types/utils/Escape.js';

// For TSDoc comments
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { Handler } from '$handlers/Handler.js';
/* eslint-enable @typescript-eslint/no-unused-vars */
import type { ProcessedSnippet } from '$types/utils/Escape.js';

/**
* A transformer. Two types of transformers are supported:
Expand All @@ -26,8 +21,8 @@ import type { Handler } from '$handlers/Handler.js';
*
* @typeParam Options - The type of the options object that may be passed to the
* transformation functions. Generally speaking, this should be or extend the
* `ProcessOptions` type parameter of the {@link Handler | `Handler`} class in
* which the transformer is being called.
* `ProcessOptions` type parameter of the `Handler` class in which the
* transformer is being called.
*/
export type Transformer<Options extends object = object> =
| [RegExp | string, string]
Expand Down
14 changes: 7 additions & 7 deletions src/types/handlers/Tex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import type { TexComponent } from '$utils/TexComponent.js';

// For IntelliSense
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { DvisvgmSvgOutputOptions } from '$types/utils/DvisvgmOptions.js';
import type { TexLogSeverity } from '$data/tex.js';
import type { DvisvgmSvgOutputOptions as _DvisvgmSvgOutputOptions } from '$types/utils/DvisvgmOptions.js';
import type { TexLogSeverity as _TexLogSeverity } from '$data/tex.js';
/* eslint-enable @typescript-eslint/no-unused-vars */

/**
Expand Down Expand Up @@ -433,7 +433,7 @@ interface OptimizationOptions {
* @remarks
* `dvisvgm` already includes options to achieve the behavior that this
* property aims to achieve (namely, the
* {@link DvisvgmSvgOutputOptions.currentColor | `DvisvgmOptions.svg.currentColor`}).
* {@link _DvisvgmSvgOutputOptions.currentColor | `DvisvgmOptions.svg.currentColor`}).
* However, this present option can still be useful to take care of any
* potential edge cases that `dvisvgm`'s `currentColor` option might not
* cover.
Expand Down Expand Up @@ -522,7 +522,7 @@ interface DebugOptions {
* ```
*/
verbosity?:
| ('all' | TexLogSeverity | 'none' | undefined)
| ('all' | _TexLogSeverity | 'none' | undefined)
| {
/**
* Lowest severity level of messages from LaTeX log to print upon
Expand All @@ -546,7 +546,7 @@ interface DebugOptions {
* 'box'
* ```
*/
onFailure?: 'all' | TexLogSeverity | 'none' | undefined;
onFailure?: 'all' | _TexLogSeverity | 'none' | undefined;

/**
* Lowest severity level of messages from LaTeX log to print upon
Expand All @@ -570,7 +570,7 @@ interface DebugOptions {
* 'box'
* ```
*/
onSuccess?: 'all' | TexLogSeverity | 'none' | undefined;
onSuccess?: 'all' | _TexLogSeverity | 'none' | undefined;
}
| undefined;
}
Expand Down Expand Up @@ -668,5 +668,5 @@ export interface Problem {
message: string;
line: number;
col?: number | undefined;
severity: TexLogSeverity;
severity: _TexLogSeverity;
}
12 changes: 6 additions & 6 deletions src/types/handlers/Verbatim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import type { TexComponent } from '$utils/TexComponent.js';

// For TSDoc comments
/* eslint-disable @typescript-eslint/no-unused-vars */
import type { CompilationOptions } from '$types/handlers/Tex.js';
import type { SveltexConfiguration } from '$types/SveltexConfiguration.js';
import type { CompilationOptions as _CompilationOptions } from '$types/handlers/Tex.js';
import type { SveltexConfiguration as _SveltexConfiguration } from '$types/SveltexConfiguration.js';
/* eslint-enable @typescript-eslint/no-unused-vars */

export interface VerbatimProcessOptions {
Expand Down Expand Up @@ -607,7 +607,7 @@ interface TikzPreset {
/**
* This library provides capabilities for automatic graph drawing. It
* requires that the document is typeset using LuaTeX (i.e.,
* {@link CompilationOptions.engine | `engine`} set to `lualatex` or
* {@link _CompilationOptions.engine | `engine`} set to `lualatex` or
* `lualatexmk`). This package should work with LuaTeX 0.54 or higher.
*
* @see https://tikz.dev/gd-usage-tikz#pgf.graphdrawing
Expand Down Expand Up @@ -869,7 +869,7 @@ interface TikzPreset {
* such annotations with this library.
*
* @remarks
* {@link CompilationOptions.intermediateFiletype | `intermediateFiletype`}
* {@link _CompilationOptions.intermediateFiletype | `intermediateFiletype`}
* must be set to `'dvi'` for this library to work.
*
* @see https://tikz.dev/library-rdf
Expand Down Expand Up @@ -1114,7 +1114,7 @@ export interface VerbEnvConfigTex extends VerbEnvConfigBase {
*
* @remarks
* Sveltex will automatically add the class option `dvisvgm` if
* {@link CompilationOptions.intermediateFiletype | `intermediateFiletype`}
* {@link _CompilationOptions.intermediateFiletype | `intermediateFiletype`}
* is set to `'dvi'`. See https://tikz.dev/drivers.
*/
options?: string[] | undefined;
Expand All @@ -1123,7 +1123,7 @@ export interface VerbEnvConfigTex extends VerbEnvConfigBase {

/**
* Override any part of the default TeX configuration inherited
* from the {@link SveltexConfiguration.tex | `tex`}
* from the {@link _SveltexConfiguration.tex | `tex`}
* property of the Sveltex configuration.
*/
overrides?: TexConfiguration | undefined;
Expand Down
17 changes: 10 additions & 7 deletions src/types/utils/Frontmatter.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// File description: Types related to SvelTeX's handling of frontmatter.

import { MdastLiteral } from '$deps.js';
import type { MdastLiteral } from '$deps.js';

export type MetaName =
| 'charset'
Expand Down Expand Up @@ -133,9 +133,12 @@ export interface MdastJson extends MdastLiteral {
type: 'json';
}

declare module 'mdast' {
interface FrontmatterContentMap {
toml: MdastToml;
json: MdastJson;
}
}
// JSR doesn't like this
// (see https://jsr.io/docs/about-slow-types#global-augmentation)

// declare module 'mdast' {
// interface FrontmatterContentMap {
// toml: MdastToml;
// json: MdastJson;
// }
// }
Loading

0 comments on commit ef5a76c

Please sign in to comment.