@coldsmirk/inkstone-core 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -12
- package/dist/index.cjs +0 -80
- package/dist/index.d.cts +0 -55
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coldsmirk/inkstone-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "Shared Shiki highlighter service for the inkstone editor toolkit: one fine-grained singleton (catppuccin themes, JS regex engine) reused by Monaco, static rendering, and markdown surfaces.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"shiki",
|
|
@@ -24,19 +24,11 @@
|
|
|
24
24
|
"type": "module",
|
|
25
25
|
"exports": {
|
|
26
26
|
".": {
|
|
27
|
-
"
|
|
28
|
-
|
|
29
|
-
"default": "./dist/index.js"
|
|
30
|
-
},
|
|
31
|
-
"require": {
|
|
32
|
-
"types": "./dist/index.d.cts",
|
|
33
|
-
"default": "./dist/index.cjs"
|
|
34
|
-
}
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"default": "./dist/index.js"
|
|
35
29
|
},
|
|
36
30
|
"./package.json": "./package.json"
|
|
37
31
|
},
|
|
38
|
-
"main": "./dist/index.cjs",
|
|
39
|
-
"module": "./dist/index.js",
|
|
40
32
|
"types": "./dist/index.d.ts",
|
|
41
33
|
"files": [
|
|
42
34
|
"dist"
|
|
@@ -47,7 +39,7 @@
|
|
|
47
39
|
"shiki": "^4.3.1"
|
|
48
40
|
},
|
|
49
41
|
"engines": {
|
|
50
|
-
"node": ">=
|
|
42
|
+
"node": ">=24"
|
|
51
43
|
},
|
|
52
44
|
"publishConfig": {
|
|
53
45
|
"access": "public"
|
package/dist/index.cjs
DELETED
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
//#region \0rolldown/runtime.js
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
11
|
-
key = keys[i];
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
13
|
-
get: ((k) => from[k]).bind(null, key),
|
|
14
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
20
|
-
value: mod,
|
|
21
|
-
enumerable: true
|
|
22
|
-
}) : target, mod));
|
|
23
|
-
//#endregion
|
|
24
|
-
let _shikijs_langs_javascript = require("@shikijs/langs/javascript");
|
|
25
|
-
_shikijs_langs_javascript = __toESM(_shikijs_langs_javascript, 1);
|
|
26
|
-
let _shikijs_langs_json = require("@shikijs/langs/json");
|
|
27
|
-
_shikijs_langs_json = __toESM(_shikijs_langs_json, 1);
|
|
28
|
-
let _shikijs_langs_sql = require("@shikijs/langs/sql");
|
|
29
|
-
_shikijs_langs_sql = __toESM(_shikijs_langs_sql, 1);
|
|
30
|
-
let _shikijs_langs_typescript = require("@shikijs/langs/typescript");
|
|
31
|
-
_shikijs_langs_typescript = __toESM(_shikijs_langs_typescript, 1);
|
|
32
|
-
let _shikijs_themes_catppuccin_latte = require("@shikijs/themes/catppuccin-latte");
|
|
33
|
-
_shikijs_themes_catppuccin_latte = __toESM(_shikijs_themes_catppuccin_latte, 1);
|
|
34
|
-
let _shikijs_themes_catppuccin_macchiato = require("@shikijs/themes/catppuccin-macchiato");
|
|
35
|
-
_shikijs_themes_catppuccin_macchiato = __toESM(_shikijs_themes_catppuccin_macchiato, 1);
|
|
36
|
-
let shiki_core = require("shiki/core");
|
|
37
|
-
let shiki_engine_javascript = require("shiki/engine/javascript");
|
|
38
|
-
//#region src/shiki.ts
|
|
39
|
-
const INKSTONE_LIGHT_THEME = "catppuccin-latte";
|
|
40
|
-
const INKSTONE_DARK_THEME = "catppuccin-macchiato";
|
|
41
|
-
const DEFAULT_HIGHLIGHTER_LANGS = [
|
|
42
|
-
_shikijs_langs_javascript.default,
|
|
43
|
-
_shikijs_langs_typescript.default,
|
|
44
|
-
_shikijs_langs_json.default,
|
|
45
|
-
_shikijs_langs_sql.default
|
|
46
|
-
];
|
|
47
|
-
let config = {};
|
|
48
|
-
let promise = null;
|
|
49
|
-
function configureHighlighter(options) {
|
|
50
|
-
if (promise) throw new Error("configureHighlighter must be called before the first getHighlighter()");
|
|
51
|
-
config = {
|
|
52
|
-
...config,
|
|
53
|
-
...options
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
function getHighlighter() {
|
|
57
|
-
promise ??= (0, shiki_core.createHighlighterCore)({
|
|
58
|
-
themes: [
|
|
59
|
-
_shikijs_themes_catppuccin_latte.default,
|
|
60
|
-
_shikijs_themes_catppuccin_macchiato.default,
|
|
61
|
-
...config.themes ?? []
|
|
62
|
-
],
|
|
63
|
-
langs: config.langs ?? [...DEFAULT_HIGHLIGHTER_LANGS],
|
|
64
|
-
engine: (0, shiki_engine_javascript.createJavaScriptRegexEngine)()
|
|
65
|
-
}).catch((error) => {
|
|
66
|
-
promise = null;
|
|
67
|
-
throw error;
|
|
68
|
-
});
|
|
69
|
-
return promise;
|
|
70
|
-
}
|
|
71
|
-
function shikiThemeId(dark) {
|
|
72
|
-
return dark ? INKSTONE_DARK_THEME : INKSTONE_LIGHT_THEME;
|
|
73
|
-
}
|
|
74
|
-
//#endregion
|
|
75
|
-
exports.DEFAULT_HIGHLIGHTER_LANGS = DEFAULT_HIGHLIGHTER_LANGS;
|
|
76
|
-
exports.INKSTONE_DARK_THEME = INKSTONE_DARK_THEME;
|
|
77
|
-
exports.INKSTONE_LIGHT_THEME = INKSTONE_LIGHT_THEME;
|
|
78
|
-
exports.configureHighlighter = configureHighlighter;
|
|
79
|
-
exports.getHighlighter = getHighlighter;
|
|
80
|
-
exports.shikiThemeId = shikiThemeId;
|
package/dist/index.d.cts
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { HighlighterCore, HighlighterCore as HighlighterCore$1, LanguageInput, ThemeInput } from "shiki/core";
|
|
2
|
-
|
|
3
|
-
//#region src/shiki.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Shiki theme id inkstone editors use in light mode.
|
|
6
|
-
*/
|
|
7
|
-
declare const INKSTONE_LIGHT_THEME = "catppuccin-latte";
|
|
8
|
-
/**
|
|
9
|
-
* Shiki theme id inkstone editors use in dark mode.
|
|
10
|
-
*/
|
|
11
|
-
declare const INKSTONE_DARK_THEME = "catppuccin-macchiato";
|
|
12
|
-
/**
|
|
13
|
-
* The grammars the shared highlighter loads when {@link configureHighlighter} is not called:
|
|
14
|
-
* JavaScript / TypeScript / JSON / SQL — the set the coldsmirk apps actually edit and render.
|
|
15
|
-
* Spread these when adding a grammar: `configureHighlighter({ langs: [...DEFAULT_HIGHLIGHTER_LANGS, yaml] })`.
|
|
16
|
-
*/
|
|
17
|
-
declare const DEFAULT_HIGHLIGHTER_LANGS: readonly LanguageInput[];
|
|
18
|
-
interface HighlighterConfig {
|
|
19
|
-
/**
|
|
20
|
-
* Grammars to load, replacing {@link DEFAULT_HIGHLIGHTER_LANGS}.
|
|
21
|
-
*/
|
|
22
|
-
langs?: LanguageInput[];
|
|
23
|
-
/**
|
|
24
|
-
* Extra themes loaded alongside the built-in catppuccin pair (which is always loaded —
|
|
25
|
-
* the editor components select it by id).
|
|
26
|
-
*/
|
|
27
|
-
themes?: ThemeInput[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Configure the shared highlighter before its first use. The highlighter is a process-wide
|
|
31
|
-
* singleton (editors, static rendering, and markdown surfaces all share it for consistent
|
|
32
|
-
* colors), so configuration is process-global too and must happen before the first
|
|
33
|
-
* {@link getHighlighter} call — afterwards the instance is already built and this throws.
|
|
34
|
-
*/
|
|
35
|
-
declare function configureHighlighter(options: HighlighterConfig): void;
|
|
36
|
-
/**
|
|
37
|
-
* The shared Shiki highlighter, built lazily on first call.
|
|
38
|
-
*
|
|
39
|
-
* Fine-grained build: only the configured grammars and the two catppuccin themes are bundled,
|
|
40
|
-
* whereas the convenient `createHighlighter` generates a lazy chunk for *every* Shiki theme and
|
|
41
|
-
* language. The JS regex engine avoids the Oniguruma WASM — smaller, no extra network request,
|
|
42
|
-
* ideal for offline deployments (Tauri webviews, rust-embed consoles).
|
|
43
|
-
*
|
|
44
|
-
* A failed build is not cached: the slot resets so a later call retries (and
|
|
45
|
-
* {@link configureHighlighter} becomes callable again), instead of replaying one transient
|
|
46
|
-
* failure — a chunk 404 after a redeploy, a flaky network — for the rest of the session.
|
|
47
|
-
*/
|
|
48
|
-
declare function getHighlighter(): Promise<HighlighterCore$1>;
|
|
49
|
-
/**
|
|
50
|
-
* The Shiki theme id for a color scheme — {@link INKSTONE_DARK_THEME} when `dark`, else
|
|
51
|
-
* {@link INKSTONE_LIGHT_THEME}.
|
|
52
|
-
*/
|
|
53
|
-
declare function shikiThemeId(dark: boolean): string;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { DEFAULT_HIGHLIGHTER_LANGS, type HighlighterConfig, type HighlighterCore, INKSTONE_DARK_THEME, INKSTONE_LIGHT_THEME, configureHighlighter, getHighlighter, shikiThemeId };
|