tinymce-solid 0.0.7 → 0.0.9

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.
@@ -1,391 +0,0 @@
1
- import { createEffect, createSignal, on, onCleanup, onMount } from "solid-js";
2
- import { Dynamic } from "solid-js/web";
3
- import { type ScriptItem, ScriptLoader } from "../ScriptLoader2";
4
- import { getTinymce } from "../TinyMCE";
5
- import {
6
- isFunction,
7
- isTextareaOrInput,
8
- mergePlugins,
9
- uuid,
10
- configHandlers,
11
- isBeforeInputEventAvailable,
12
- isInDoc,
13
- setMode,
14
- } from "../Utils";
15
- import {
16
- IAllProps,
17
- Version,
18
- EditorOptions,
19
- InitOptions,
20
- OmittedInitProps,
21
- // IProps,
22
- } from "./EditorPropTypes";
23
- import { Bookmark, Editor as TinyMCEEditor, EditorEvent } from "tinymce";
24
-
25
- export const Editor = (props: Partial<IAllProps>) => {
26
- const [id] = createSignal(props.id || uuid("solid-tinymce-editor"));
27
- const initialValue = () => props.initialValue;
28
- const value = () => props.value || "";
29
- const skin = () => props.skin || "oxide";
30
- const tagName = () => props.tagName || "div";
31
- const contentCss = () => props.contentCss || "default";
32
- const disabled = () => props.disabled || false;
33
- const [editor, setEditor] = createSignal<TinyMCEEditor>();
34
- const [currentContent, setCurrentContent] = createSignal<string>(value());
35
- const [rollbackTimer, setRollbackTimer] = createSignal<number>();
36
- const [valueCursor, setValueCursor] = createSignal<Bookmark>();
37
- const [boundHandlers, setBoundHandlers] = createSignal<
38
- Record<string, (event: EditorEvent<unknown>) => unknown>
39
- >({});
40
- const view = () => props?.elementRef?.ownerDocument.defaultView ?? window;
41
-
42
- const getInitialValue = () => {
43
- if (typeof initialValue() === "string") {
44
- return initialValue() as string;
45
- } else if (typeof value() === "string") {
46
- return value();
47
- } else {
48
- return "";
49
- }
50
- };
51
- const getScriptSources = (): ScriptItem[] => {
52
- const async = props.scriptLoading?.async;
53
- const defer = props.scriptLoading?.defer;
54
- if (props.tinymceScriptSrc !== undefined) {
55
- if (typeof props.tinymceScriptSrc === "string") {
56
- return [{ src: props.tinymceScriptSrc, async, defer }];
57
- }
58
- // multiple scripts can be specified which allows for hybrid mode
59
- return (props.tinymceScriptSrc as string[] | ScriptItem[]).map((item) => {
60
- if (typeof item === "string") {
61
- // async does not make sense for multiple items unless
62
- // they are not dependent (which will be unlikely)
63
- return { src: item, async, defer };
64
- } else {
65
- return item;
66
- }
67
- });
68
- }
69
-
70
- // fallback to the cloud when the tinymceScriptSrc is not specified
71
- const channel = (props.cloudChannel || "7") as Version; // `cloudChannel` is in `defaultProps`, so it's always defined.
72
- const apiKey = props.apiKey ? props.apiKey : "no-api-key";
73
- const cloudTinyJs = `https://cdn.tiny.cloud/1/${apiKey}/tinymce/${channel}/tinymce.min.js`;
74
- return [{ src: cloudTinyJs, async, defer }];
75
- };
76
-
77
- const bindHandlers = (prevProps: Partial<IAllProps>) => {
78
- if (editor() !== undefined) {
79
- const tinyEditor = editor()!;
80
-
81
- // typescript chokes trying to understand the type of the lookup function
82
- configHandlers(
83
- tinyEditor,
84
- prevProps,
85
- props,
86
- boundHandlers(),
87
- (key) => props[key],
88
- );
89
- // check if we should monitor editor changes
90
- const isValueControlled = (p: Partial<IAllProps>) =>
91
- p.onEditorChange !== undefined || p.value !== undefined;
92
- const wasControlled = isValueControlled(prevProps);
93
- const nowControlled = isValueControlled(props);
94
- if (!wasControlled && nowControlled) {
95
- tinyEditor.on(changeEvents(), handleEditorChange);
96
- tinyEditor.on(beforeInputEvent(), handleBeforeInput);
97
- tinyEditor.on("keydown", handleBeforeInputSpecial);
98
- tinyEditor.on("keyup", handleEditorChangeSpecial);
99
- tinyEditor.on("NewBlock", handleEditorChange);
100
- } else if (wasControlled && !nowControlled) {
101
- tinyEditor.off(changeEvents(), handleEditorChange);
102
- tinyEditor.off(beforeInputEvent(), handleBeforeInput);
103
- tinyEditor.off("keydown", handleBeforeInputSpecial);
104
- tinyEditor.off("keyup", handleEditorChangeSpecial);
105
- tinyEditor.off("NewBlock", handleEditorChange);
106
- }
107
- }
108
- };
109
- const successHandler = () => {
110
- props.onScriptsLoad?.();
111
- initialise();
112
- };
113
- const errorHandler = (err: unknown) => {
114
- // console.warn(err);
115
- props.onScriptsLoadError?.(err);
116
- };
117
-
118
- const initialise = (attempts = 0) => {
119
- const target = props.elementRef;
120
- if (!target) {
121
- return; // Editor has been unmounted
122
- }
123
- if (!isInDoc(target)) {
124
- // this is probably someone trying to help by rendering us offscreen
125
- // but we can't do that because the editor iframe must be in the document
126
- // in order to have state
127
- if (attempts === 0) {
128
- // we probably just need to wait for the current events to be processed
129
- setTimeout(() => initialise(1), 1);
130
- } else if (attempts < 100) {
131
- // wait for ten seconds, polling every tenth of a second
132
- setTimeout(() => initialise(attempts + 1), 100);
133
- } else {
134
- // give up, at this point it seems that more polling is unlikely to help
135
- throw new Error("tinymce can only be initialised when in a document");
136
- }
137
- return;
138
- }
139
-
140
- const tinymce = getTinymce(view());
141
- if (!tinymce) {
142
- throw new Error("tinymce should have been loaded into global scope");
143
- }
144
-
145
- const finalInit: EditorOptions = {
146
- ...(props.init as Omit<InitOptions, OmittedInitProps>),
147
- selector: undefined,
148
- target,
149
- skin: skin(),
150
- content_css: contentCss(),
151
- readonly: props.disabled,
152
- inline: props.inline,
153
- plugins: mergePlugins(props.init?.plugins, props.plugins),
154
- toolbar: props.toolbar ?? props.init?.toolbar,
155
- ...(props.licenseKey ? { license_key: props.licenseKey } : {}),
156
- setup: (editor) => {
157
- setEditor(editor);
158
- bindHandlers({});
159
-
160
- // When running in inline mode the editor gets the initial value
161
- // from the innerHTML of the element it is initialized on.
162
- // However we don't want to take on the responsibility of sanitizing
163
- // to remove XSS in the react integration so we have a chicken and egg
164
- // problem... We avoid it by sneaking in a set content before the first
165
- // "official" setContent and using TinyMCE to do the sanitization.
166
- if (props.inline && !isTextareaOrInput(target)) {
167
- editor.once("PostRender", (_evt) => {
168
- editor.setContent(getInitialValue(), {
169
- no_events: true,
170
- event_name: _evt.type,
171
- });
172
- });
173
- }
174
-
175
- if (props.init && isFunction(props.init.setup)) {
176
- props.init.setup(editor);
177
- }
178
- },
179
- init_instance_callback: (editor) => {
180
- // check for changes that happened since tinymce.init() was called
181
- const initialValue = getInitialValue();
182
- let newCurrentValue = currentContent() ?? editor.getContent();
183
- if (newCurrentValue !== initialValue) {
184
- newCurrentValue = initialValue;
185
- // same as resetContent in TinyMCE 5
186
- editor.setContent(initialValue);
187
- editor.undoManager.clear();
188
- editor.undoManager.add();
189
- editor.setDirty(false);
190
- }
191
- setCurrentContent(newCurrentValue);
192
- const isDisabled = disabled() ?? false;
193
- setMode(editor, isDisabled ? "readonly" : "design");
194
- // ensure existing init_instance_callback is called
195
- if (props.init && isFunction(props.init.init_instance_callback)) {
196
- props.init.init_instance_callback(editor);
197
- }
198
- },
199
- };
200
- if (!props.inline) {
201
- target.style.visibility = "";
202
- }
203
- if (isTextareaOrInput(target)) {
204
- target.value = getInitialValue();
205
- }
206
-
207
- tinymce.init(finalInit);
208
- };
209
- const mountCallback = () => {
210
- if (getTinymce(view()) !== null) {
211
- initialise();
212
- } else if (
213
- Array.isArray(props.tinymceScriptSrc) &&
214
- props.tinymceScriptSrc.length === 0
215
- ) {
216
- props.onScriptsLoadError?.(
217
- new Error(
218
- "No `tinymce` global is present but the `tinymceScriptSrc` prop was an empty array.",
219
- ),
220
- );
221
- } else if (props?.elementRef?.ownerDocument) {
222
- ScriptLoader.loadList(
223
- props.elementRef.ownerDocument,
224
- getScriptSources(),
225
- props.scriptLoading?.delay ?? 0,
226
- successHandler,
227
- errorHandler,
228
- );
229
- }
230
- };
231
- const cleanUpCallback = () => {
232
- const tinyEditor = editor()!;
233
- if (typeof tinyEditor !== "undefined") {
234
- tinyEditor.off(changeEvents(), handleEditorChange);
235
- tinyEditor.off(beforeInputEvent(), handleBeforeInput);
236
- tinyEditor.off("keypress", handleEditorChangeSpecial);
237
- tinyEditor.off("keydown", handleBeforeInputSpecial);
238
- tinyEditor.off("NewBlock", handleEditorChange);
239
- Object.keys(boundHandlers()).forEach((eventName) => {
240
- tinyEditor.off(eventName, boundHandlers()[eventName]);
241
- });
242
- setBoundHandlers({});
243
- tinyEditor.destroy();
244
- tinyEditor.remove();
245
- setEditor();
246
- }
247
- };
248
-
249
- createEffect(
250
- on(value, () => {
251
- if (value() !== currentContent()) {
252
- setCurrentContent(value());
253
- editor()?.setContent(value(), { no_events: true, event_name: "input" });
254
- }
255
- }),
256
- );
257
-
258
- createEffect(
259
- on(skin, () => {
260
- cleanUpCallback();
261
- setTimeout(mountCallback, 1);
262
- }),
263
- );
264
-
265
- createEffect(
266
- on(disabled, () => {
267
- const tinyEditor = editor();
268
- if (tinyEditor?.initialized) {
269
- const isDisabled = disabled() ?? false;
270
- setMode(tinyEditor, isDisabled ? "readonly" : "design");
271
- }
272
- }),
273
- );
274
-
275
- onMount(mountCallback);
276
- onCleanup(cleanUpCallback);
277
-
278
- const changeEvents = () => {
279
- const isIE = getTinymce(view())?.Env?.browser?.isIE();
280
- return isIE
281
- ? "change keyup compositionend setcontent CommentChange"
282
- : "change input compositionend setcontent CommentChange";
283
- };
284
-
285
- const beforeInputEvent = () => {
286
- return isBeforeInputEventAvailable()
287
- ? "beforeinput SelectionChange"
288
- : "SelectionChange";
289
- };
290
-
291
- const handleEditorChange = (event: EditorEvent<unknown>) => {
292
- const tinyEditor = editor();
293
- if (tinyEditor && tinyEditor.initialized && !event.isDefaultPrevented()) {
294
- const newContent = tinyEditor.getContent();
295
- if (
296
- props.value !== undefined &&
297
- props.value !== newContent &&
298
- props.rollback !== false
299
- ) {
300
- // start a timer and revert to the value if not applied in time
301
- if (!rollbackTimer()) {
302
- setRollbackTimer(
303
- window.setTimeout(
304
- rollbackChange,
305
- typeof props.rollback === "number" ? props.rollback : 200,
306
- ),
307
- );
308
- }
309
- }
310
-
311
- if (newContent !== currentContent()) {
312
- setCurrentContent(newContent);
313
- if (isFunction(props.onEditorChange)) {
314
- props.onEditorChange(newContent, tinyEditor);
315
- }
316
- }
317
- }
318
- };
319
-
320
- const rollbackChange = () => {
321
- const tinyEditor = editor();
322
- const value = props.value;
323
- if (tinyEditor && value && value !== currentContent()) {
324
- tinyEditor.undoManager.ignore(() => {
325
- tinyEditor.setContent(value);
326
- // only restore cursor on inline editors when they are focused
327
- // as otherwise it will cause a focus grab
328
- if (valueCursor() && (!props.inline || tinyEditor.hasFocus())) {
329
- try {
330
- tinyEditor.selection.moveToBookmark(valueCursor()!);
331
- } catch (e) {
332
- /* ignore */
333
- }
334
- }
335
- });
336
- }
337
- setRollbackTimer(undefined);
338
- };
339
-
340
- const handleBeforeInput = (event: EditorEvent<unknown>) => {
341
- const tinyEditor = editor()!;
342
- if (
343
- props.value !== undefined &&
344
- props.value === currentContent() &&
345
- tinyEditor &&
346
- !event.isDefaultPrevented()
347
- ) {
348
- if (!props.inline || tinyEditor.hasFocus()) {
349
- try {
350
- // getBookmark throws exceptions when the editor has not been focused
351
- // possibly only in inline mode but I'm not taking chances
352
- // this.valueCursor = tinyEditor.selection.getBookmark(3);
353
- setValueCursor(tinyEditor.selection.getBookmark(3));
354
- } catch (e) {
355
- /* ignore */
356
- }
357
- }
358
- }
359
- };
360
-
361
- const handleEditorChangeSpecial = (evt: EditorEvent<KeyboardEvent>) => {
362
- if (
363
- evt.key === "Enter" ||
364
- evt.key === "Backspace" ||
365
- evt.key === "Delete"
366
- ) {
367
- handleBeforeInput(evt);
368
- }
369
- };
370
-
371
- const handleBeforeInputSpecial = (evt: EditorEvent<KeyboardEvent>) => {
372
- if (
373
- evt.key === "Enter" ||
374
- evt.key === "Backspace" ||
375
- evt.key === "Delete"
376
- ) {
377
- handleBeforeInput(evt);
378
- }
379
- };
380
-
381
- return (
382
- <Dynamic
383
- component={props.inline ? tagName() : "textarea"}
384
- id={id()}
385
- data-testid={props.testid}
386
- tabIndex={props.tabIndex}
387
- ref={props.elementRef}
388
- {...props}
389
- />
390
- );
391
- };
@@ -1,191 +0,0 @@
1
- import * as PropTypes from "prop-types";
2
- import { IEvents } from "../Events";
3
- import { Editor as TinyMCEEditor, TinyMCE } from "tinymce";
4
- import { ScriptItem } from "../ScriptLoader2";
5
-
6
- export type OmitStringIndexSignature<T> = {
7
- [K in keyof T as string extends K ? never : K]: T[K];
8
- };
9
-
10
- interface DoNotUse<T extends string> {
11
- __brand: T;
12
- }
13
-
14
- export type OmittedInitProps =
15
- | "selector"
16
- | "target"
17
- | "readonly"
18
- | "license_key";
19
-
20
- export type EditorOptions = Parameters<TinyMCE["init"]>[0];
21
-
22
- export type InitOptions = Omit<
23
- OmitStringIndexSignature<EditorOptions>,
24
- OmittedInitProps
25
- > & {
26
- selector?: DoNotUse<"selector prop is handled internally by the component">;
27
- target?: DoNotUse<"target prop is handled internally by the component">;
28
- readonly?: DoNotUse<"readonly prop is overridden by the component, use the `disabled` prop instead">;
29
- license_key?: DoNotUse<"license_key prop is overridden by the integration, use the `licenseKey` prop instead">;
30
- } & { [key: string]: unknown };
31
-
32
- export type Version =
33
- `${"4" | "5" | "6" | "7"}${"" | "-dev" | "-testing" | `.${number}` | `.${number}.${number}`}`;
34
-
35
- export interface IProps {
36
- propTypes: IEditorPropTypes;
37
- elementRef: HTMLDivElement | HTMLTextAreaElement;
38
- apiKey: string;
39
- id: string;
40
- testid: string; // testing-library attribute
41
- inline: boolean;
42
- initialValue: string;
43
- onEditorChange: (content: string, editor: TinyMCEEditor) => void;
44
- value: string;
45
- init: InitOptions;
46
- tagName: string;
47
- tabIndex: number;
48
- cloudChannel: Version;
49
- plugins: NonNullable<EditorOptions["plugins"]>;
50
- toolbar: NonNullable<EditorOptions["toolbar"]>;
51
- disabled: boolean;
52
- textareaName: string;
53
- tinymceScriptSrc: string | string[] | ScriptItem[];
54
- rollback: number | false;
55
- skin: "oxide" | "oxide-dark" | "tinymce-5" | "tinymce-5-dark";
56
- contentCss:
57
- | "default"
58
- | "dark"
59
- | "document"
60
- | "tinymce-5"
61
- | "tinymce-5-dark"
62
- | "writer";
63
- scriptLoading: {
64
- async?: boolean;
65
- defer?: boolean;
66
- delay?: number;
67
- };
68
- licenseKey: string;
69
- }
70
-
71
- export interface IAllProps extends Partial<IProps>, Partial<IEvents> {}
72
-
73
- export type CopyProps<T> = { [P in keyof T]: PropTypes.Requireable<unknown> };
74
-
75
- export type IEventPropTypes = CopyProps<IEvents>;
76
-
77
- export interface IEditorPropTypes extends IEventPropTypes, CopyProps<IProps> {}
78
-
79
- export const eventPropTypes: IEventPropTypes = {
80
- onActivate: PropTypes.func,
81
- onAddUndo: PropTypes.func,
82
- onBeforeAddUndo: PropTypes.func,
83
- onBeforeExecCommand: PropTypes.func,
84
- onBeforeGetContent: PropTypes.func,
85
- onBeforeRenderUI: PropTypes.func,
86
- onBeforeSetContent: PropTypes.func,
87
- onBeforePaste: PropTypes.func,
88
- onBlur: PropTypes.func,
89
- onChange: PropTypes.func,
90
- onClearUndos: PropTypes.func,
91
- onClick: PropTypes.func,
92
- onContextMenu: PropTypes.func,
93
- onCommentChange: PropTypes.func,
94
- onCompositionEnd: PropTypes.func,
95
- onCompositionStart: PropTypes.func,
96
- onCompositionUpdate: PropTypes.func,
97
- onCopy: PropTypes.func,
98
- onCut: PropTypes.func,
99
- onDblclick: PropTypes.func,
100
- onDeactivate: PropTypes.func,
101
- onDirty: PropTypes.func,
102
- onDrag: PropTypes.func,
103
- onDragDrop: PropTypes.func,
104
- onDragEnd: PropTypes.func,
105
- onDragGesture: PropTypes.func,
106
- onDragOver: PropTypes.func,
107
- onDrop: PropTypes.func,
108
- onExecCommand: PropTypes.func,
109
- onFocus: PropTypes.func,
110
- onFocusIn: PropTypes.func,
111
- onFocusOut: PropTypes.func,
112
- onGetContent: PropTypes.func,
113
- onHide: PropTypes.func,
114
- onInit: PropTypes.func,
115
- onInput: PropTypes.func,
116
- onKeyDown: PropTypes.func,
117
- onKeyPress: PropTypes.func,
118
- onKeyUp: PropTypes.func,
119
- onLoadContent: PropTypes.func,
120
- onMouseDown: PropTypes.func,
121
- onMouseEnter: PropTypes.func,
122
- onMouseLeave: PropTypes.func,
123
- onMouseMove: PropTypes.func,
124
- onMouseOut: PropTypes.func,
125
- onMouseOver: PropTypes.func,
126
- onMouseUp: PropTypes.func,
127
- onNodeChange: PropTypes.func,
128
- onObjectResizeStart: PropTypes.func,
129
- onObjectResized: PropTypes.func,
130
- onObjectSelected: PropTypes.func,
131
- onPaste: PropTypes.func,
132
- onPostProcess: PropTypes.func,
133
- onPostRender: PropTypes.func,
134
- onPreProcess: PropTypes.func,
135
- onProgressState: PropTypes.func,
136
- onRedo: PropTypes.func,
137
- onRemove: PropTypes.func,
138
- onReset: PropTypes.func,
139
- onSaveContent: PropTypes.func,
140
- onSelectionChange: PropTypes.func,
141
- onSetAttrib: PropTypes.func,
142
- onSetContent: PropTypes.func,
143
- onShow: PropTypes.func,
144
- onSubmit: PropTypes.func,
145
- onUndo: PropTypes.func,
146
- onVisualAid: PropTypes.func,
147
- onSkinLoadError: PropTypes.func,
148
- onThemeLoadError: PropTypes.func,
149
- onModelLoadError: PropTypes.func,
150
- onPluginLoadError: PropTypes.func,
151
- onIconsLoadError: PropTypes.func,
152
- onLanguageLoadError: PropTypes.func,
153
- onScriptsLoad: PropTypes.func,
154
- onScriptsLoadError: PropTypes.func,
155
- };
156
-
157
- export const EditorPropTypes = {
158
- apiKey: PropTypes.string,
159
- licenseKey: PropTypes.string,
160
- id: PropTypes.string,
161
- inline: PropTypes.bool,
162
- init: PropTypes.object,
163
- initialValue: PropTypes.string,
164
- onEditorChange: PropTypes.func,
165
- value: PropTypes.string,
166
- tagName: PropTypes.string,
167
- tabIndex: PropTypes.number,
168
- cloudChannel: PropTypes.string,
169
- plugins: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
170
- toolbar: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
171
- disabled: PropTypes.bool,
172
- textareaName: PropTypes.string,
173
- tinymceScriptSrc: PropTypes.oneOfType([
174
- PropTypes.string,
175
- PropTypes.arrayOf(PropTypes.string),
176
- PropTypes.arrayOf(
177
- PropTypes.shape({
178
- src: PropTypes.string,
179
- async: PropTypes.bool,
180
- defer: PropTypes.bool,
181
- }),
182
- ),
183
- ]),
184
- rollback: PropTypes.oneOfType([PropTypes.number, PropTypes.oneOf([false])]),
185
- scriptLoading: PropTypes.shape({
186
- async: PropTypes.bool,
187
- defer: PropTypes.bool,
188
- delay: PropTypes.number,
189
- }),
190
- ...eventPropTypes,
191
- };
package/src/index.tsx DELETED
@@ -1,6 +0,0 @@
1
- import { Editor } from "./components/Editor";
2
- import { type IAllProps, EditorPropTypes } from "./components/EditorPropTypes";
3
-
4
- export default Editor;
5
- export { type IAllProps };
6
- export { EditorPropTypes };
package/tsconfig.json DELETED
@@ -1,25 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ESNext",
4
- "module": "ESNext",
5
- "lib": ["DOM", "DOM.Iterable", "ESNext"],
6
- "moduleResolution": "bundler",
7
- "allowSyntheticDefaultImports": true,
8
- "allowImportingTsExtensions": true,
9
- "esModuleInterop": true,
10
- "jsx": "preserve",
11
- "jsxImportSource": "solid-js",
12
- "allowJs": true,
13
- "strict": true,
14
- "noEmit": true,
15
- "types": ["vite/client", "node"],
16
- "isolatedModules": true,
17
- "baseUrl": ".",
18
- "paths": {
19
- "~/*": ["./src/*"],
20
- "@/*": ["./demo/*"],
21
- }
22
- },
23
- "include": ["src"],
24
- "exclude": ["node_modules", "dist", "demo", "experiments"]
25
- }
package/tsup.config.ts DELETED
@@ -1,40 +0,0 @@
1
- import { defineConfig } from "tsup";
2
- import * as preset from "tsup-preset-solid";
3
-
4
- const preset_options: preset.PresetOptions = {
5
- // array or single object
6
- entries: [
7
- // default entry (index)
8
- {
9
- // entries with '.tsx' extension will have `solid` export condition generated
10
- entry: "./src/index.tsx",
11
- // will generate a separate development entry
12
- dev_entry: true,
13
- },
14
- ],
15
- // Set to `true` to remove all `console.*` calls and `debugger` statements in prod builds
16
- drop_console: true,
17
- // Set to `true` to generate a CommonJS build alongside ESM
18
- // cjs: true,
19
- };
20
-
21
- const CI =
22
- process.env['CI'] === 'true' ||
23
- process.env['GITHUB_ACTIONS'] === 'true' ||
24
- process.env['CI'] === '"1"' ||
25
- process.env['GITHUB_ACTIONS'] === '"1"'
26
-
27
- export default defineConfig(config => {
28
- const watching = !!config.watch;
29
-
30
- const parsed_options = preset.parsePresetOptions(preset_options, watching);
31
-
32
- if (!watching && !CI) {
33
- const package_fields = preset.generatePackageExports(parsed_options)
34
-
35
- // will update ./package.json with the correct export fields
36
- preset.writePackageJson(package_fields)
37
- }
38
-
39
- return preset.generateTsupOptions(parsed_options);
40
- });