@fluxdown/solid 0.0.0-stage → 0.2.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/CHANGELOG.md +17 -0
- package/LICENSE +21 -0
- package/README.md +2 -2
- package/dist/cjs/assets/raw-Dob3BCyv.css +56 -0
- package/dist/cjs/chunks/raw-DlzW8_Im.cjs +609 -0
- package/dist/cjs/components/block-reconciler/index.d.cts +2 -0
- package/dist/cjs/components/block-reconciler/type.d.cts +22 -0
- package/dist/cjs/components/block-reconciler/utils.d.cts +2 -0
- package/dist/cjs/components/index.d.cts +2 -0
- package/dist/cjs/components/root-reconciler/index.d.cts +6 -0
- package/dist/cjs/consts/config.d.cts +2 -0
- package/dist/cjs/consts/defaults.d.cts +2 -0
- package/dist/cjs/consts/index.d.cts +4 -0
- package/dist/cjs/consts/smooth.d.cts +3 -0
- package/dist/cjs/consts/styles.d.cts +1 -0
- package/dist/cjs/context/index.d.cts +1 -0
- package/dist/cjs/context/render/index.d.cts +6 -0
- package/dist/cjs/env.d.cts +1 -0
- package/dist/cjs/full.browser.cjs +2 -0
- package/dist/cjs/full.cjs +13 -0
- package/dist/cjs/hooks/index.d.cts +1 -0
- package/dist/cjs/hooks/plugins.d.cts +6 -0
- package/dist/cjs/lite.browser.cjs +2 -0
- package/dist/cjs/lite.cjs +13 -0
- package/dist/cjs/modules/index.d.cts +1 -0
- package/dist/cjs/modules/solid-renderer/index.d.cts +9 -0
- package/dist/cjs/modules/solid-renderer/type.d.cts +4 -0
- package/dist/cjs/packs/full/index.d.cts +5 -0
- package/dist/cjs/packs/full/type.d.cts +3 -0
- package/dist/cjs/packs/lite/index.d.cts +5 -0
- package/dist/cjs/packs/lite/type.d.cts +3 -0
- package/dist/cjs/packs/raw/index.d.cts +5 -0
- package/dist/cjs/packs/raw/type.d.cts +77 -0
- package/dist/cjs/packs/raw/utils.d.cts +2 -0
- package/dist/cjs/packs/utils/config.d.cts +13 -0
- package/dist/cjs/packs/utils/effect.d.cts +4 -0
- package/dist/cjs/packs/utils/index.d.cts +3 -0
- package/dist/cjs/packs/utils/patches.d.cts +2 -0
- package/dist/cjs/raw.browser.cjs +2 -0
- package/dist/cjs/raw.cjs +3 -0
- package/dist/cjs/server/full.cjs +13 -0
- package/dist/cjs/server/lite.cjs +13 -0
- package/dist/cjs/server/raw.cjs +593 -0
- package/dist/cjs/styles.css +2 -0
- package/dist/cjs/theme/consts.d.cts +4 -0
- package/dist/cjs/theme/hooks.d.cts +2 -0
- package/dist/cjs/theme/index.d.cts +1 -0
- package/dist/cjs/theme/presets/base.d.cts +2 -0
- package/dist/cjs/theme/presets/dark.d.cts +2 -0
- package/dist/cjs/theme/presets/index.d.cts +4 -0
- package/dist/cjs/theme/presets/light.d.cts +2 -0
- package/dist/cjs/theme/utils.d.cts +4 -0
- package/dist/cjs/types/index.d.cts +2 -0
- package/dist/cjs/types/theme.d.cts +138 -0
- package/dist/esm/assets/raw-Dob3BCyv.css +56 -0
- package/dist/esm/chunks/raw-ULd4Y10B.js +598 -0
- package/dist/esm/components/block-reconciler/index.d.ts +2 -0
- package/dist/esm/components/block-reconciler/type.d.ts +22 -0
- package/dist/esm/components/block-reconciler/utils.d.ts +2 -0
- package/dist/esm/components/index.d.ts +2 -0
- package/dist/esm/components/root-reconciler/index.d.ts +6 -0
- package/dist/esm/consts/config.d.ts +2 -0
- package/dist/esm/consts/defaults.d.ts +2 -0
- package/dist/esm/consts/index.d.ts +4 -0
- package/dist/esm/consts/smooth.d.ts +3 -0
- package/dist/esm/consts/styles.d.ts +1 -0
- package/dist/esm/context/index.d.ts +1 -0
- package/dist/esm/context/render/index.d.ts +6 -0
- package/dist/esm/env.d.ts +1 -0
- package/dist/esm/full.browser.js +2 -0
- package/dist/esm/full.js +12 -0
- package/dist/esm/hooks/index.d.ts +1 -0
- package/dist/esm/hooks/plugins.d.ts +6 -0
- package/dist/esm/lite.browser.js +2 -0
- package/dist/esm/lite.js +12 -0
- package/dist/esm/modules/index.d.ts +1 -0
- package/dist/esm/modules/solid-renderer/index.d.ts +9 -0
- package/dist/esm/modules/solid-renderer/type.d.ts +4 -0
- package/dist/esm/packs/full/index.d.ts +5 -0
- package/dist/esm/packs/full/type.d.ts +3 -0
- package/dist/esm/packs/lite/index.d.ts +5 -0
- package/dist/esm/packs/lite/type.d.ts +3 -0
- package/dist/esm/packs/raw/index.d.ts +5 -0
- package/dist/esm/packs/raw/type.d.ts +77 -0
- package/dist/esm/packs/raw/utils.d.ts +2 -0
- package/dist/esm/packs/utils/config.d.ts +13 -0
- package/dist/esm/packs/utils/effect.d.ts +4 -0
- package/dist/esm/packs/utils/index.d.ts +3 -0
- package/dist/esm/packs/utils/patches.d.ts +2 -0
- package/dist/esm/raw.browser.js +2 -0
- package/dist/esm/raw.js +2 -0
- package/dist/esm/server/full.js +12 -0
- package/dist/esm/server/lite.js +12 -0
- package/dist/esm/server/raw.js +591 -0
- package/dist/esm/styles.css +2 -0
- package/dist/esm/theme/consts.d.ts +4 -0
- package/dist/esm/theme/hooks.d.ts +2 -0
- package/dist/esm/theme/index.d.ts +1 -0
- package/dist/esm/theme/presets/base.d.ts +2 -0
- package/dist/esm/theme/presets/dark.d.ts +2 -0
- package/dist/esm/theme/presets/index.d.ts +4 -0
- package/dist/esm/theme/presets/light.d.ts +2 -0
- package/dist/esm/theme/utils.d.ts +4 -0
- package/dist/esm/types/index.d.ts +2 -0
- package/dist/esm/types/theme.d.ts +138 -0
- package/package.json +121 -3
|
@@ -0,0 +1,593 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
let solid_js_web = require("solid-js/web");
|
|
3
|
+
let _fluxdown_core = require("@fluxdown/core");
|
|
4
|
+
let _fluxdown_core_plugins_presets_mapper = require("@fluxdown/core-plugins/presets/mapper");
|
|
5
|
+
let _fluxdown_solid_plugins_base = require("@fluxdown/solid-plugins/base");
|
|
6
|
+
let lodash_es = require("lodash-es");
|
|
7
|
+
let shallow_equal = require("shallow-equal");
|
|
8
|
+
let solid_js = require("solid-js");
|
|
9
|
+
let stative = require("stative");
|
|
10
|
+
let _fluxdown_types = require("@fluxdown/types");
|
|
11
|
+
let _fluxdown_core_plugins_plugins_mapper_smooth = require("@fluxdown/core-plugins/plugins/mapper/smooth");
|
|
12
|
+
let _fluxdown_utils = require("@fluxdown/utils");
|
|
13
|
+
//#region src/context/render/index.ts
|
|
14
|
+
var RenderContext = /*#__PURE__*/ (0, solid_js.createContext)(null);
|
|
15
|
+
var RenderProvider = RenderContext.Provider;
|
|
16
|
+
var useRender = () => {
|
|
17
|
+
const config = (0, solid_js.useContext)(RenderContext);
|
|
18
|
+
if (config === null) throw new Error("[Fluxdown] A render context is required.");
|
|
19
|
+
return config;
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
//#region src/components/block-reconciler/utils.tsx
|
|
23
|
+
var isElementContent = (node) => {
|
|
24
|
+
return node.type === "comment" || node.type === "element" || node.type === "text";
|
|
25
|
+
};
|
|
26
|
+
var getChildKey = (node, fallbackIndex) => {
|
|
27
|
+
if (node.type === "element" && node.properties?.dataParserPatch === "1" && (0, lodash_es.isString)(node.properties.dataPatchKey)) return `patch:${node.properties.dataPatchKey}`;
|
|
28
|
+
if ((0, lodash_es.isString)(node.data?.renderKey)) return `render:${node.data.renderKey}`;
|
|
29
|
+
const tagName = node.type === "element" ? `:${node.tagName}` : "";
|
|
30
|
+
if (node.position?.start.offset !== void 0) return `source:${node.position.start.offset}:${node.type}${tagName}`;
|
|
31
|
+
return `${fallbackIndex}:${node.type}${tagName}`;
|
|
32
|
+
};
|
|
33
|
+
var ChildrenReconciler = (props) => {
|
|
34
|
+
const nodes = (0, solid_js.createMemo)(() => {
|
|
35
|
+
const children = props.node?.children ?? [];
|
|
36
|
+
const result = /* @__PURE__ */ new Map();
|
|
37
|
+
children.forEach((child, index) => {
|
|
38
|
+
if (!isElementContent(child)) return;
|
|
39
|
+
const previous = children[index - 1];
|
|
40
|
+
const key = child.type === "text" ? `text:${previous ? getChildKey(previous, index - 1) : "start"}` : getChildKey(child, index);
|
|
41
|
+
result.set(result.has(key) ? `fallback:${index}` : key, child);
|
|
42
|
+
});
|
|
43
|
+
return result;
|
|
44
|
+
});
|
|
45
|
+
const keys = (0, solid_js.createMemo)(() => [...nodes().keys()]);
|
|
46
|
+
return (0, solid_js_web.createComponent)(solid_js.For, {
|
|
47
|
+
get each() {
|
|
48
|
+
return keys();
|
|
49
|
+
},
|
|
50
|
+
children: (key) => {
|
|
51
|
+
return (0, solid_js_web.createComponent)(NodeReconciler, (0, solid_js_web.mergeProps)(props, { get node() {
|
|
52
|
+
return nodes().get(key);
|
|
53
|
+
} }));
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
var NodeReconciler = (props) => {
|
|
58
|
+
const childParents = (0, solid_js.createMemo)(() => {
|
|
59
|
+
const node = props.node;
|
|
60
|
+
return node && (0, _fluxdown_solid_plugins_base.isHastParent)(node) ? [...props.parents, node] : props.parents;
|
|
61
|
+
});
|
|
62
|
+
const render = (node) => {
|
|
63
|
+
return (0, solid_js_web.createComponent)(NodeReconciler, (0, solid_js_web.mergeProps)(props, {
|
|
64
|
+
get node() {
|
|
65
|
+
return typeof node === "function" ? node() : node;
|
|
66
|
+
},
|
|
67
|
+
get parents() {
|
|
68
|
+
return childParents();
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
};
|
|
72
|
+
const renderChildren = (target) => {
|
|
73
|
+
const current = target === void 0 || target === props.node;
|
|
74
|
+
const node = () => {
|
|
75
|
+
const value = current ? props.node : typeof target === "function" ? target() : target;
|
|
76
|
+
return value && (0, _fluxdown_solid_plugins_base.isHastParent)(value) ? value : void 0;
|
|
77
|
+
};
|
|
78
|
+
const parents = () => {
|
|
79
|
+
const value = node();
|
|
80
|
+
return current || !value ? childParents() : [...childParents(), value];
|
|
81
|
+
};
|
|
82
|
+
return (0, solid_js_web.createComponent)(ChildrenReconciler, (0, solid_js_web.mergeProps)(props, {
|
|
83
|
+
get node() {
|
|
84
|
+
return node();
|
|
85
|
+
},
|
|
86
|
+
get parents() {
|
|
87
|
+
return parents();
|
|
88
|
+
}
|
|
89
|
+
}));
|
|
90
|
+
};
|
|
91
|
+
const getProps = (target) => {
|
|
92
|
+
if (props.getProps === null) return {};
|
|
93
|
+
const node = props.node;
|
|
94
|
+
const current = target ?? (node && (0, _fluxdown_solid_plugins_base.isHastElement)(node) ? node : void 0);
|
|
95
|
+
return props.getProps ? props.getProps(current) : { ...current?.properties };
|
|
96
|
+
};
|
|
97
|
+
const matched = (0, solid_js.createMemo)(() => {
|
|
98
|
+
const node = props.node;
|
|
99
|
+
if (!node) return;
|
|
100
|
+
let result;
|
|
101
|
+
let priority = Infinity;
|
|
102
|
+
for (const plugin of props.plugins) {
|
|
103
|
+
const nextPriority = plugin.config.priority ?? _fluxdown_types.PluginPriority.Default;
|
|
104
|
+
if (nextPriority > priority || !plugin.match({
|
|
105
|
+
node,
|
|
106
|
+
parents: props.parents
|
|
107
|
+
})) continue;
|
|
108
|
+
result = plugin;
|
|
109
|
+
priority = nextPriority;
|
|
110
|
+
}
|
|
111
|
+
return result;
|
|
112
|
+
});
|
|
113
|
+
const Renderer = (0, solid_js.createMemo)(() => {
|
|
114
|
+
const plugin = matched();
|
|
115
|
+
return plugin?.render.bind(plugin);
|
|
116
|
+
});
|
|
117
|
+
return (0, solid_js_web.createComponent)(solid_js_web.Dynamic, (0, solid_js_web.mergeProps)({ get component() {
|
|
118
|
+
return Renderer();
|
|
119
|
+
} }, (0, solid_js.mergeProps)(props, {
|
|
120
|
+
getProps,
|
|
121
|
+
render,
|
|
122
|
+
renderChildren
|
|
123
|
+
}), { get node() {
|
|
124
|
+
return props.node;
|
|
125
|
+
} }));
|
|
126
|
+
};
|
|
127
|
+
//#endregion
|
|
128
|
+
//#region src/components/block-reconciler/index.tsx
|
|
129
|
+
var BlockReconciler = (props) => {
|
|
130
|
+
const config = useRender();
|
|
131
|
+
const root = (0, _fluxdown_solid_plugins_base.createStateValue)(() => props.block.value);
|
|
132
|
+
const patches = (0, solid_js.createMemo)(() => (0, stative.toState)(props.patches));
|
|
133
|
+
const plugins = (0, _fluxdown_solid_plugins_base.createStateValue)(() => (0, stative.toState)(props.plugins));
|
|
134
|
+
return (0, solid_js_web.createComponent)(ChildrenReconciler, {
|
|
135
|
+
get node() {
|
|
136
|
+
return root();
|
|
137
|
+
},
|
|
138
|
+
get parents() {
|
|
139
|
+
return [root()];
|
|
140
|
+
},
|
|
141
|
+
get patches() {
|
|
142
|
+
return patches();
|
|
143
|
+
},
|
|
144
|
+
get plugins() {
|
|
145
|
+
return plugins();
|
|
146
|
+
},
|
|
147
|
+
get getProps() {
|
|
148
|
+
return config.getProps;
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
};
|
|
152
|
+
//#endregion
|
|
153
|
+
//#region src/components/root-reconciler/index.tsx
|
|
154
|
+
var RootReconciler = (props) => {
|
|
155
|
+
const value = (0, _fluxdown_solid_plugins_base.createStateValue)(() => props.value);
|
|
156
|
+
const blocks = (0, solid_js.createMemo)(() => {
|
|
157
|
+
const entries = value();
|
|
158
|
+
return new Map(entries.map((block) => [block.key, block]));
|
|
159
|
+
});
|
|
160
|
+
const keys = (0, solid_js.createMemo)(() => [...blocks().keys()]);
|
|
161
|
+
return (0, solid_js_web.createComponent)(solid_js.For, {
|
|
162
|
+
get each() {
|
|
163
|
+
return keys();
|
|
164
|
+
},
|
|
165
|
+
children: (key) => {
|
|
166
|
+
return (0, solid_js_web.createComponent)(BlockReconciler, (0, solid_js_web.mergeProps)(() => blocks().get(key)));
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
//#endregion
|
|
171
|
+
//#region src/consts/config.ts
|
|
172
|
+
var DEFAULT_CONFIG = {
|
|
173
|
+
footnote: false,
|
|
174
|
+
repair: true,
|
|
175
|
+
repairEnding: false,
|
|
176
|
+
tex: false,
|
|
177
|
+
indentedCode: false,
|
|
178
|
+
setextHeading: false
|
|
179
|
+
};
|
|
180
|
+
//#endregion
|
|
181
|
+
//#region src/consts/defaults.ts
|
|
182
|
+
var EL = [];
|
|
183
|
+
var EO = {};
|
|
184
|
+
//#endregion
|
|
185
|
+
//#region src/consts/smooth.ts
|
|
186
|
+
var ALL_TICKERS = [_fluxdown_core_plugins_plugins_mapper_smooth.RafSmoothTicker, _fluxdown_core_plugins_plugins_mapper_smooth.IntervalSmoothTicker];
|
|
187
|
+
var ALL_SCHEDULERS = [_fluxdown_core_plugins_plugins_mapper_smooth.SpringSmoothScheduler];
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region src/consts/styles.ts
|
|
190
|
+
var ROOT_CLASS_NAME = `${_fluxdown_solid_plugins_base.PREFIX}-root`;
|
|
191
|
+
//#endregion
|
|
192
|
+
//#region src/hooks/plugins.ts
|
|
193
|
+
var createPlugins = (items, type) => {
|
|
194
|
+
return (0, solid_js.createMemo)(() => (0, _fluxdown_solid_plugins_base.toPluginList)(items(), type));
|
|
195
|
+
};
|
|
196
|
+
var createMergedPlugins = (presets, plugins) => {
|
|
197
|
+
return (0, solid_js.createMemo)(() => {
|
|
198
|
+
const items = (0, lodash_es.castArray)(plugins() ?? EL);
|
|
199
|
+
const merge = (type) => {
|
|
200
|
+
const overrides = (0, _fluxdown_solid_plugins_base.toPluginList)(items, type);
|
|
201
|
+
return [...(0, _fluxdown_solid_plugins_base.filterDisabledBy)((0, _fluxdown_solid_plugins_base.toPluginList)(presets, type), overrides), ...overrides];
|
|
202
|
+
};
|
|
203
|
+
return {
|
|
204
|
+
remarks: merge("remarks"),
|
|
205
|
+
rehypes: merge("rehypes"),
|
|
206
|
+
repairs: merge("repairs"),
|
|
207
|
+
mappers: merge("mappers"),
|
|
208
|
+
renders: merge("renders"),
|
|
209
|
+
slots: merge("slots")
|
|
210
|
+
};
|
|
211
|
+
});
|
|
212
|
+
};
|
|
213
|
+
//#endregion
|
|
214
|
+
//#region src/modules/solid-renderer/index.tsx
|
|
215
|
+
var SolidRenderer = class extends _fluxdown_core.BaseRenderer {
|
|
216
|
+
renderItem(item) {
|
|
217
|
+
const { patches, plugins } = this.inputs;
|
|
218
|
+
return {
|
|
219
|
+
key: item.meta.value.key,
|
|
220
|
+
block: item,
|
|
221
|
+
patches,
|
|
222
|
+
plugins
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
};
|
|
226
|
+
var index_module_default = { root: "_root_f61oc_1" };
|
|
227
|
+
//#endregion
|
|
228
|
+
//#region src/theme/presets/base.ts
|
|
229
|
+
var BASE_TOKENS = {
|
|
230
|
+
typography: {
|
|
231
|
+
fontSans: "Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif",
|
|
232
|
+
fontMono: "'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace",
|
|
233
|
+
fontSmoothing: "antialiased",
|
|
234
|
+
fontSize: {
|
|
235
|
+
xs: "0.75rem",
|
|
236
|
+
sm: "0.875rem",
|
|
237
|
+
md: "1rem"
|
|
238
|
+
},
|
|
239
|
+
lineHeight: {
|
|
240
|
+
sm: 1.4,
|
|
241
|
+
md: 1.65,
|
|
242
|
+
lg: 1.8
|
|
243
|
+
},
|
|
244
|
+
fontWeight: {
|
|
245
|
+
normal: 400,
|
|
246
|
+
medium: 600,
|
|
247
|
+
bold: 650
|
|
248
|
+
}
|
|
249
|
+
},
|
|
250
|
+
heading: {
|
|
251
|
+
h1: {
|
|
252
|
+
fontSize: "2rem",
|
|
253
|
+
fontWeight: 650,
|
|
254
|
+
lineHeight: 1.25,
|
|
255
|
+
marginTop: "2rem",
|
|
256
|
+
marginBottom: "1rem"
|
|
257
|
+
},
|
|
258
|
+
h2: {
|
|
259
|
+
fontSize: "1.5rem",
|
|
260
|
+
fontWeight: 650,
|
|
261
|
+
lineHeight: 1.3,
|
|
262
|
+
marginTop: "1.75rem",
|
|
263
|
+
marginBottom: "0.875rem"
|
|
264
|
+
},
|
|
265
|
+
h3: {
|
|
266
|
+
fontSize: "1.25rem",
|
|
267
|
+
fontWeight: 600,
|
|
268
|
+
lineHeight: 1.4,
|
|
269
|
+
marginTop: "1.5rem",
|
|
270
|
+
marginBottom: "0.75rem"
|
|
271
|
+
},
|
|
272
|
+
h4: {
|
|
273
|
+
fontSize: "1.125rem",
|
|
274
|
+
fontWeight: 600,
|
|
275
|
+
lineHeight: 1.4,
|
|
276
|
+
marginTop: "1.25rem",
|
|
277
|
+
marginBottom: "0.625rem"
|
|
278
|
+
},
|
|
279
|
+
h5: {
|
|
280
|
+
fontSize: "1rem",
|
|
281
|
+
fontWeight: 600,
|
|
282
|
+
lineHeight: 1.5,
|
|
283
|
+
marginTop: "1rem",
|
|
284
|
+
marginBottom: "0.5rem"
|
|
285
|
+
},
|
|
286
|
+
h6: {
|
|
287
|
+
fontSize: "0.875rem",
|
|
288
|
+
fontWeight: 600,
|
|
289
|
+
lineHeight: 1.5,
|
|
290
|
+
marginTop: "1rem",
|
|
291
|
+
marginBottom: "0.5rem"
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
paragraph: {
|
|
295
|
+
marginTop: "0",
|
|
296
|
+
marginBottom: "1rem"
|
|
297
|
+
},
|
|
298
|
+
code: {
|
|
299
|
+
fontSize: "0.875rem",
|
|
300
|
+
lineHeight: 1.65
|
|
301
|
+
},
|
|
302
|
+
inlineCode: {
|
|
303
|
+
paddingBlock: "0.15em",
|
|
304
|
+
paddingInline: "0.35em",
|
|
305
|
+
border: `1px solid var(--${_fluxdown_solid_plugins_base.PREFIX}-colors-border)`,
|
|
306
|
+
borderRadius: `var(--${_fluxdown_solid_plugins_base.PREFIX}-radius-sm)`,
|
|
307
|
+
background: `var(--${_fluxdown_solid_plugins_base.PREFIX}-colors-surface-muted)`,
|
|
308
|
+
fontFamily: `var(--${_fluxdown_solid_plugins_base.PREFIX}-typography-font-mono)`,
|
|
309
|
+
fontSize: "0.875em",
|
|
310
|
+
whiteSpace: "break-spaces"
|
|
311
|
+
},
|
|
312
|
+
divider: {
|
|
313
|
+
height: "1px",
|
|
314
|
+
marginBlock: `var(--${_fluxdown_solid_plugins_base.PREFIX}-spacing-xl)`,
|
|
315
|
+
marginInline: "0",
|
|
316
|
+
border: "0",
|
|
317
|
+
borderBlockEnd: `var(--${_fluxdown_solid_plugins_base.PREFIX}-divider-border)`,
|
|
318
|
+
background: `var(--${_fluxdown_solid_plugins_base.PREFIX}-colors-border)`
|
|
319
|
+
},
|
|
320
|
+
footnotes: {
|
|
321
|
+
marginTop: `var(--${_fluxdown_solid_plugins_base.PREFIX}-spacing-xl)`,
|
|
322
|
+
paddingTop: `var(--${_fluxdown_solid_plugins_base.PREFIX}-spacing-lg)`,
|
|
323
|
+
borderTop: `1px solid var(--${_fluxdown_solid_plugins_base.PREFIX}-colors-border)`,
|
|
324
|
+
color: `var(--${_fluxdown_solid_plugins_base.PREFIX}-colors-fg-muted)`,
|
|
325
|
+
fontSize: `var(--${_fluxdown_solid_plugins_base.PREFIX}-typography-font-size-sm)`
|
|
326
|
+
},
|
|
327
|
+
radius: {
|
|
328
|
+
sm: "0.25rem",
|
|
329
|
+
md: "0.5rem",
|
|
330
|
+
lg: "0.875rem"
|
|
331
|
+
},
|
|
332
|
+
spacing: {
|
|
333
|
+
xs: "0.25rem",
|
|
334
|
+
sm: "0.5rem",
|
|
335
|
+
md: "0.75rem",
|
|
336
|
+
lg: "1rem",
|
|
337
|
+
xl: "1.5rem"
|
|
338
|
+
}
|
|
339
|
+
};
|
|
340
|
+
//#endregion
|
|
341
|
+
//#region src/theme/presets/dark.ts
|
|
342
|
+
var DARK_THEME = { tokens: {
|
|
343
|
+
...BASE_TOKENS,
|
|
344
|
+
colors: {
|
|
345
|
+
fg: "#ececf1",
|
|
346
|
+
fgMuted: "#a6a8b0",
|
|
347
|
+
bg: "#212121",
|
|
348
|
+
border: "#3c3e42",
|
|
349
|
+
accent: "#82b7ff",
|
|
350
|
+
accentHover: "#b1d2ff",
|
|
351
|
+
surfaceMuted: "#353639",
|
|
352
|
+
surfaceSubtle: "#292a2d",
|
|
353
|
+
borderEmphasis: "#666970"
|
|
354
|
+
},
|
|
355
|
+
syntax: {
|
|
356
|
+
comment: "#9da7b3",
|
|
357
|
+
keyword: "#ff7b72",
|
|
358
|
+
string: "#a5d6ff",
|
|
359
|
+
number: "#79c0ff",
|
|
360
|
+
function: "#d2a8ff",
|
|
361
|
+
variable: "#ffa657",
|
|
362
|
+
punctuation: "#c9d1d9",
|
|
363
|
+
inserted: "#7ee787",
|
|
364
|
+
deleted: "#ffa198"
|
|
365
|
+
}
|
|
366
|
+
} };
|
|
367
|
+
//#endregion
|
|
368
|
+
//#region src/theme/presets/index.ts
|
|
369
|
+
var PRESET_THEME_MAP = {
|
|
370
|
+
light: { tokens: {
|
|
371
|
+
...BASE_TOKENS,
|
|
372
|
+
colors: {
|
|
373
|
+
fg: "#202123",
|
|
374
|
+
fgMuted: "#64676b",
|
|
375
|
+
bg: "#ffffff",
|
|
376
|
+
border: "#e5e7eb",
|
|
377
|
+
accent: "#0969da",
|
|
378
|
+
accentHover: "#0550ae",
|
|
379
|
+
surfaceMuted: "#f1f2f4",
|
|
380
|
+
surfaceSubtle: "#f7f8fa",
|
|
381
|
+
borderEmphasis: "#b5bac1"
|
|
382
|
+
},
|
|
383
|
+
syntax: {
|
|
384
|
+
comment: "#6e7781",
|
|
385
|
+
keyword: "#cf222e",
|
|
386
|
+
string: "#0a3069",
|
|
387
|
+
number: "#0550ae",
|
|
388
|
+
function: "#8250df",
|
|
389
|
+
variable: "#953800",
|
|
390
|
+
punctuation: "#57606a",
|
|
391
|
+
inserted: "#116329",
|
|
392
|
+
deleted: "#a40e26"
|
|
393
|
+
}
|
|
394
|
+
} },
|
|
395
|
+
dark: DARK_THEME
|
|
396
|
+
};
|
|
397
|
+
//#endregion
|
|
398
|
+
//#region src/theme/utils.ts
|
|
399
|
+
var isThemeTuple = (theme) => (0, lodash_es.isArray)(theme);
|
|
400
|
+
var resolveTheme = (theme = "light") => {
|
|
401
|
+
if ((0, lodash_es.isString)(theme)) return PRESET_THEME_MAP[theme];
|
|
402
|
+
const [preset, overrides] = isThemeTuple(theme) ? theme : ["light", theme];
|
|
403
|
+
return (0, lodash_es.merge)({}, PRESET_THEME_MAP[preset], overrides);
|
|
404
|
+
};
|
|
405
|
+
var mapTokensToStyles = (tokens) => {
|
|
406
|
+
const styles = {};
|
|
407
|
+
const visit = (value, path) => {
|
|
408
|
+
(0, lodash_es.forOwn)(value, (token, key) => {
|
|
409
|
+
const name = `${path}-${(0, lodash_es.replace)(key, /[A-Z]/g, (letter) => `-${(0, lodash_es.toLower)(letter)}`)}`;
|
|
410
|
+
if ((0, lodash_es.isObject)(token)) visit(token, name);
|
|
411
|
+
else styles[name] = (0, lodash_es.toString)(token);
|
|
412
|
+
});
|
|
413
|
+
};
|
|
414
|
+
visit(tokens, `--${_fluxdown_solid_plugins_base.PREFIX}`);
|
|
415
|
+
return styles;
|
|
416
|
+
};
|
|
417
|
+
//#endregion
|
|
418
|
+
//#region src/theme/consts.ts
|
|
419
|
+
var PRESET_STYLES = /*#__PURE__*/ (0, lodash_es.mapValues)(PRESET_THEME_MAP, ({ tokens }) => mapTokensToStyles(tokens));
|
|
420
|
+
//#endregion
|
|
421
|
+
//#region src/theme/hooks.ts
|
|
422
|
+
var createThemeStyles = (theme = () => "light") => {
|
|
423
|
+
return (0, solid_js.createMemo)(() => {
|
|
424
|
+
const value = theme();
|
|
425
|
+
return (0, lodash_es.isString)(value) ? PRESET_STYLES[value] : mapTokensToStyles(resolveTheme(value).tokens);
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/packs/utils/config.ts
|
|
430
|
+
var getTickerByType = (type) => {
|
|
431
|
+
if (!(0, lodash_es.isString)(type)) return type;
|
|
432
|
+
const ticker = ALL_TICKERS.find((item) => item.name === type);
|
|
433
|
+
(0, _fluxdown_utils.assert)(ticker, `Unknown ticker type: ${type}`);
|
|
434
|
+
return ticker;
|
|
435
|
+
};
|
|
436
|
+
var getSchedulerByType = (type) => {
|
|
437
|
+
if (!(0, lodash_es.isString)(type)) return type;
|
|
438
|
+
const scheduler = ALL_SCHEDULERS.find((item) => item.name === type);
|
|
439
|
+
(0, _fluxdown_utils.assert)(scheduler, `Unknown scheduler type: ${type}`);
|
|
440
|
+
return scheduler;
|
|
441
|
+
};
|
|
442
|
+
var toSmoothConfig = (config) => {
|
|
443
|
+
const { enabled = false, ticker, scheduler } = (0, lodash_es.isBoolean)(config) ? {
|
|
444
|
+
enabled: config,
|
|
445
|
+
ticker: (0, _fluxdown_utils.isEnableRAF)() ? "raf" : "interval",
|
|
446
|
+
scheduler: "spring"
|
|
447
|
+
} : config;
|
|
448
|
+
return {
|
|
449
|
+
enabled,
|
|
450
|
+
ticker: getTickerByType(ticker),
|
|
451
|
+
scheduler: getSchedulerByType(scheduler)
|
|
452
|
+
};
|
|
453
|
+
};
|
|
454
|
+
var toStreamingConfig = (config = false) => {
|
|
455
|
+
if ((0, lodash_es.isBoolean)(config)) return {
|
|
456
|
+
repairEnding: config,
|
|
457
|
+
smooth: config,
|
|
458
|
+
effect: config ? "scale" : false
|
|
459
|
+
};
|
|
460
|
+
const { repairEnding = true, smooth = true, effect = "scale" } = config;
|
|
461
|
+
return {
|
|
462
|
+
repairEnding,
|
|
463
|
+
smooth,
|
|
464
|
+
effect
|
|
465
|
+
};
|
|
466
|
+
};
|
|
467
|
+
var toBuildConfig = ({ base, repairEnding, idPrefix }) => {
|
|
468
|
+
return {
|
|
469
|
+
...(0, _fluxdown_utils.defaultsBy)(base, {
|
|
470
|
+
...DEFAULT_CONFIG,
|
|
471
|
+
idPrefix
|
|
472
|
+
}),
|
|
473
|
+
repairEnding
|
|
474
|
+
};
|
|
475
|
+
};
|
|
476
|
+
//#endregion
|
|
477
|
+
//#region src/packs/utils/effect.ts
|
|
478
|
+
var toEffects = (effect = false) => {
|
|
479
|
+
if (effect === false) return [];
|
|
480
|
+
if (effect === true) return ["scale"];
|
|
481
|
+
if (!(0, lodash_es.isArray)(effect)) return [effect];
|
|
482
|
+
if (effect.length === 2 && !(0, lodash_es.isArray)(effect[1]) && (0, lodash_es.isObjectLike)(effect[1])) return [effect];
|
|
483
|
+
return effect;
|
|
484
|
+
};
|
|
485
|
+
var toEffectMappers = (effects, presets) => {
|
|
486
|
+
return effects.map((effect) => {
|
|
487
|
+
const [key, config] = (0, lodash_es.isArray)(effect) ? effect : [effect, EO];
|
|
488
|
+
if (!(0, lodash_es.isString)(key)) return effect;
|
|
489
|
+
const Mapper = presets.find((item) => item.key === key);
|
|
490
|
+
(0, _fluxdown_utils.assert)(Mapper, `Unknown effect: ${key}`);
|
|
491
|
+
return [Mapper, (0, lodash_es.defaults)({ ...config }, { enabled: true })];
|
|
492
|
+
});
|
|
493
|
+
};
|
|
494
|
+
//#endregion
|
|
495
|
+
//#region src/packs/utils/patches.ts
|
|
496
|
+
var isPatchRangeEqual = (left, right) => {
|
|
497
|
+
return left === right || ((0, lodash_es.isNumber)(left) ? left : left[0]) === ((0, lodash_es.isNumber)(right) ? right : right[0]) && ((0, lodash_es.isNumber)(left) ? left : left[1]) === ((0, lodash_es.isNumber)(right) ? right : right[1]);
|
|
498
|
+
};
|
|
499
|
+
var isPatchesEqual = (left, right) => {
|
|
500
|
+
return left === right || left.length === right.length && left.every((patch, index) => {
|
|
501
|
+
const other = right[index];
|
|
502
|
+
return other !== void 0 && patch.key === other.key && isPatchRangeEqual(patch.range, other.range) && patch.render === other.render;
|
|
503
|
+
});
|
|
504
|
+
};
|
|
505
|
+
//#endregion
|
|
506
|
+
//#region src/packs/raw/utils.ts
|
|
507
|
+
var mergeStyles = (theme, style) => {
|
|
508
|
+
if (!(0, lodash_es.isString)(style)) return {
|
|
509
|
+
...theme,
|
|
510
|
+
...style
|
|
511
|
+
};
|
|
512
|
+
return `${Object.entries(theme).map(([name, value]) => `${name}:${value}`).join(";")};${style}`;
|
|
513
|
+
};
|
|
514
|
+
//#endregion
|
|
515
|
+
//#region src/packs/raw/index.tsx
|
|
516
|
+
var FluxdownRaw = (props) => {
|
|
517
|
+
const [options, attributes] = (0, solid_js.splitProps)(props, [
|
|
518
|
+
"text",
|
|
519
|
+
"build",
|
|
520
|
+
"streaming",
|
|
521
|
+
"patches",
|
|
522
|
+
"plugins",
|
|
523
|
+
"theme",
|
|
524
|
+
"class",
|
|
525
|
+
"style",
|
|
526
|
+
"ref"
|
|
527
|
+
]);
|
|
528
|
+
const streaming = (0, solid_js.createMemo)(() => toStreamingConfig(options.streaming));
|
|
529
|
+
const effects = (0, solid_js.createMemo)(() => toEffectMappers(toEffects(streaming().effect), _fluxdown_core_plugins_presets_mapper.PRESET_MAPPER_PLUGINS));
|
|
530
|
+
const idPrefix = (0, solid_js.createUniqueId)();
|
|
531
|
+
const build = (0, _fluxdown_solid_plugins_base.createStateOf)(() => toBuildConfig({
|
|
532
|
+
base: options.build ?? EO,
|
|
533
|
+
repairEnding: streaming().repairEnding,
|
|
534
|
+
idPrefix
|
|
535
|
+
}), shallow_equal.shallowEqual);
|
|
536
|
+
const patches = (0, _fluxdown_solid_plugins_base.createStateOf)(() => options.patches ?? EL, isPatchesEqual);
|
|
537
|
+
const text = (0, _fluxdown_solid_plugins_base.createStateOf)(() => options.text);
|
|
538
|
+
const plugins = (0, solid_js.createMemo)(() => (0, lodash_es.castArray)(options.plugins));
|
|
539
|
+
const _remarks = createPlugins(plugins, "remarks");
|
|
540
|
+
const _rehypes = createPlugins(plugins, "rehypes");
|
|
541
|
+
const _repairs = createPlugins(plugins, "repairs");
|
|
542
|
+
const _mappers = createPlugins(plugins, "mappers");
|
|
543
|
+
const _renders = createPlugins(plugins, "renders");
|
|
544
|
+
const slots = createPlugins(plugins, "slots");
|
|
545
|
+
const remarks = (0, _fluxdown_solid_plugins_base.createStateOf)(_remarks, _fluxdown_core.isPluggablesEqual);
|
|
546
|
+
const rehypes = (0, _fluxdown_solid_plugins_base.createStateOf)(_rehypes, _fluxdown_core.isPluggablesEqual);
|
|
547
|
+
const repairs = (0, _fluxdown_solid_plugins_base.createStateOf)(_repairs, _fluxdown_core.isPluggablesEqual);
|
|
548
|
+
const mappers = (0, _fluxdown_solid_plugins_base.createStateOf)(() => [[..._mappers(), ...effects()], { smooth: toSmoothConfig(streaming().smooth) }], _fluxdown_core.isPluginSetEqual);
|
|
549
|
+
const renders = (0, _fluxdown_solid_plugins_base.createStateOf)(_renders, _fluxdown_core.isPluggablesEqual);
|
|
550
|
+
const core = (0, stative.render)((0, stative.S)([_fluxdown_core.Core, {
|
|
551
|
+
Renderer: (0, stative.D)(SolidRenderer),
|
|
552
|
+
build,
|
|
553
|
+
patches,
|
|
554
|
+
rehypes,
|
|
555
|
+
remarks,
|
|
556
|
+
renders,
|
|
557
|
+
repairs,
|
|
558
|
+
mappers,
|
|
559
|
+
text
|
|
560
|
+
}]));
|
|
561
|
+
const theme = createThemeStyles(() => options.theme ?? "light");
|
|
562
|
+
options.ref?.(core);
|
|
563
|
+
(0, solid_js.onCleanup)(() => core.destroy());
|
|
564
|
+
return (0, solid_js_web.ssrElement)("div", (0, solid_js_web.mergeProps)(attributes, {
|
|
565
|
+
get ["class"]() {
|
|
566
|
+
return [
|
|
567
|
+
index_module_default.root,
|
|
568
|
+
ROOT_CLASS_NAME,
|
|
569
|
+
options.class
|
|
570
|
+
].filter(Boolean).join(" ");
|
|
571
|
+
},
|
|
572
|
+
get style() {
|
|
573
|
+
return mergeStyles(theme(), options.style);
|
|
574
|
+
}
|
|
575
|
+
}), () => (0, solid_js_web.escape)((0, solid_js_web.createComponent)(RenderProvider, {
|
|
576
|
+
value: { getProps: _fluxdown_solid_plugins_base.getSolidProps },
|
|
577
|
+
get children() {
|
|
578
|
+
return (0, solid_js_web.createComponent)(_fluxdown_solid_plugins_base.SlotProvider, {
|
|
579
|
+
get plugins() {
|
|
580
|
+
return slots();
|
|
581
|
+
},
|
|
582
|
+
get children() {
|
|
583
|
+
return (0, solid_js_web.createComponent)(RootReconciler, { get value() {
|
|
584
|
+
return core.value;
|
|
585
|
+
} });
|
|
586
|
+
}
|
|
587
|
+
});
|
|
588
|
+
}
|
|
589
|
+
})), true);
|
|
590
|
+
};
|
|
591
|
+
//#endregion
|
|
592
|
+
exports.FluxdownRaw = FluxdownRaw;
|
|
593
|
+
exports.createMergedPlugins = createMergedPlugins;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './hooks.cjs';
|