@abraca/nuxt 2.16.0 → 2.17.1

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/dist/module.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "compatibility": {
5
5
  "nuxt": ">=4.0.0"
6
6
  },
7
- "version": "2.16.0",
7
+ "version": "2.17.1",
8
8
  "builder": {
9
9
  "@nuxt/module-builder": "1.0.2",
10
10
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -196,7 +196,13 @@ const module$1 = defineNuxtModule({
196
196
  "@codemirror/state",
197
197
  "@codemirror/view",
198
198
  "@codemirror/language",
199
- "y-codemirror.next"
199
+ "y-codemirror.next",
200
+ // Code-block highlighting. pnpm can nest a second copy of highlight.js
201
+ // (a transitive of lowlight) under this module; dedupe collapses both
202
+ // lowlight + highlight.js to one root copy so the runtime dynamic
203
+ // `import("lowlight")` and the optimizer agree on a single instance.
204
+ "lowlight",
205
+ "highlight.js"
200
206
  ];
201
207
  nuxt.options.vite = defu(nuxt.options.vite, { resolve: { dedupe: [] } });
202
208
  const existing = nuxt.options.vite.resolve?.dedupe ?? [];
@@ -269,6 +275,13 @@ const module$1 = defineNuxtModule({
269
275
  "@tiptap/extension-subscript",
270
276
  "@tiptap/extension-code-block-lowlight",
271
277
  "lowlight",
278
+ // `lowlight` does a `default` import from the CommonJS `highlight.js/lib/core`.
279
+ // It MUST be pre-bundled (CJS→ESM) or the browser can't read its default
280
+ // export and the whole editor-extension load wave rejects. (Belt-and-
281
+ // suspenders: the editor-prebundle client plugin force-feeds these to the
282
+ // dev scanner too, since `optimizeDeps.include` is not always honoured.)
283
+ "highlight.js",
284
+ "highlight.js/lib/core",
272
285
  // Yjs + provider deps (shared globals + client plugin)
273
286
  "yjs",
274
287
  // NOTE: `@abraca/dabra` deliberately NOT pre-bundled. esbuild treeshakes
@@ -386,6 +399,12 @@ const module$1 = defineNuxtModule({
386
399
  src: resolver.resolve("./runtime/plugin-shared-globals.client"),
387
400
  mode: "client"
388
401
  });
402
+ if (options.features?.editor !== false) {
403
+ addPlugin({
404
+ src: resolver.resolve("./runtime/plugin-editor-prebundle.client"),
405
+ mode: "client"
406
+ });
407
+ }
389
408
  addPlugin({
390
409
  src: resolver.resolve("./runtime/plugin-abracadabra.client"),
391
410
  mode: "client"
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Force Vite's dev dependency SCANNER to pre-bundle the editor's CJS / singleton
3
+ * dependencies — the ones it otherwise never sees.
4
+ *
5
+ * Why this exists
6
+ * ---------------
7
+ * The core plugin loads the TipTap/ProseMirror extension graph via *dynamic*
8
+ * `import()` (see `plugins/core.plugin.ts`, kept lazy on purpose). Vite's dep
9
+ * scanner does NOT follow dynamic imports that live inside `@abraca/nuxt`
10
+ * (the module is in `optimizeDeps.exclude`, so its internals aren't crawled —
11
+ * only its *static* imports are picked up). And in some Nuxt 4 + Vite 7 setups
12
+ * `optimizeDeps.include` is silently ignored by the dev optimizer, so listing
13
+ * the deps there is not enough.
14
+ *
15
+ * The result, when these deps slip through un-optimized:
16
+ * - `lowlight` does a `default` import from the CommonJS `highlight.js/lib/core`.
17
+ * Served raw, the browser can't read its `default` export → the whole
18
+ * extension-load wave rejects → TipTap builds an empty schema →
19
+ * "Schema is missing its top node type ('doc')".
20
+ * - duplicate `prosemirror-state` copies (pnpm nests one under the module when
21
+ * `@tiptap/pm` versions skew) → "Adding different instances of a keyed
22
+ * plugin (plugin$)" from `EditorState.reconfigure`.
23
+ *
24
+ * A *static* side-effect import from this registered plugin puts each dep in the
25
+ * app's import graph, so the scanner pre-bundles it (CJS→ESM) as a single shared
26
+ * instance. Nothing is used at runtime — these are pre-bundle hints only.
27
+ *
28
+ * Only registered when `features.editor !== false` (see `module.ts`), so apps
29
+ * with the editor disabled never pull these in. The deps are guaranteed present
30
+ * whenever the editor is enabled (`lowlight` + the `@tiptap`/ProseMirror stack
31
+ * are peer deps; `highlight.js` ships transitively with `lowlight` and is also a
32
+ * declared peer).
33
+ */
34
+ import 'highlight.js/lib/core';
35
+ import 'lowlight';
36
+ import 'prosemirror-state';
37
+ import 'prosemirror-view';
38
+ import 'prosemirror-model';
39
+ import 'prosemirror-transform';
40
+ import 'prosemirror-keymap';
41
+ declare const _default: import("#app").Plugin<Record<string, unknown>> & import("#app").ObjectPlugin<Record<string, unknown>>;
42
+ export default _default;
@@ -0,0 +1,14 @@
1
+ import "highlight.js/lib/core";
2
+ import "lowlight";
3
+ import "prosemirror-state";
4
+ import "prosemirror-view";
5
+ import "prosemirror-model";
6
+ import "prosemirror-transform";
7
+ import "prosemirror-keymap";
8
+ import { defineNuxtPlugin } from "#imports";
9
+ export default defineNuxtPlugin({
10
+ name: "abracadabra:editor-prebundle",
11
+ enforce: "pre",
12
+ setup() {
13
+ }
14
+ });
@@ -257,11 +257,19 @@ async function loadServerExtensions() {
257
257
  let _cachedClient = null;
258
258
  let _cachedServer = null;
259
259
  let _clientReady = null;
260
+ let _clientLoadError = null;
261
+ let _warnedEmptySchema = false;
260
262
  function ensureClientReady() {
261
263
  if (_clientReady) return _clientReady;
262
264
  _clientReady = loadClientExtensions().then((exts) => {
263
265
  _cachedClient = exts;
264
- }).catch((e) => console.warn("[abracadabra:core] Failed to preload client extensions:", e));
266
+ }).catch((e) => {
267
+ _clientLoadError = e;
268
+ console.error(
269
+ `[abracadabra:core] Failed to load editor extensions \u2014 the editor will fail to mount with "Schema is missing its top node type ('doc')". This is almost always a CJS/duplicate editor dep that Vite did not pre-bundle (highlight.js/lowlight, prosemirror-*). Underlying error:`,
270
+ e
271
+ );
272
+ });
265
273
  return _clientReady;
266
274
  }
267
275
  export const corePlugin = {
@@ -288,7 +296,15 @@ export const corePlugin = {
288
296
  ])
289
297
  ),
290
298
  extensions() {
291
- if (!_cachedClient) return [];
299
+ if (!_cachedClient) {
300
+ if (!_warnedEmptySchema) {
301
+ _warnedEmptySchema = true;
302
+ console.error(
303
+ _clientLoadError ? "[abracadabra:core] Editor extensions failed to load (see error above) \u2014 building the editor with an EMPTY extension set." : "[abracadabra:core] Editor extensions are not ready yet \u2014 building with an EMPTY extension set. Ensure waitForExtensions() resolves before constructing the Editor."
304
+ );
305
+ }
306
+ return [];
307
+ }
292
308
  let disabled = [];
293
309
  try {
294
310
  disabled = useRuntimeConfig().public?.abracadabra?.disabledBuiltins ?? [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abraca/nuxt",
3
- "version": "2.16.0",
3
+ "version": "2.17.1",
4
4
  "description": "First-class Nuxt module for the Abracadabra CRDT collaboration platform",
5
5
  "repository": "abracadabra/abracadabra-nuxt",
6
6
  "license": "MIT",
@@ -68,16 +68,23 @@
68
68
  "@tiptap/extension-task-list": "^3.0.0",
69
69
  "@tiptap/extension-text-align": "^3.0.0",
70
70
  "@tiptap/extension-text-style": "^3.0.0",
71
+ "@tiptap/pm": "^3.0.0",
71
72
  "@tiptap/starter-kit": "^3.0.0",
72
73
  "@tiptap/suggestion": "^3.0.0",
73
74
  "@tiptap/vue-3": "^3.0.0",
74
75
  "@unovis/ts": "^1.6.5",
75
76
  "@unovis/vue": "^1.6.5",
76
77
  "d3-force": "^3.0.0",
78
+ "highlight.js": "^11.0.0",
77
79
  "jszip": "^3.0.0",
78
80
  "lowlight": "^3.0.0",
79
81
  "mapbox-gl": "^3.0.0",
80
82
  "nuxt": "^4.0.0",
83
+ "prosemirror-keymap": "^1.0.0",
84
+ "prosemirror-model": "^1.0.0",
85
+ "prosemirror-state": "^1.0.0",
86
+ "prosemirror-transform": "^1.0.0",
87
+ "prosemirror-view": "^1.0.0",
81
88
  "three": "^0.184.0",
82
89
  "vue": "^3.4.0",
83
90
  "y-codemirror.next": "^0.3.5",
@@ -140,6 +147,27 @@
140
147
  },
141
148
  "@unovis/ts": {
142
149
  "optional": true
150
+ },
151
+ "@tiptap/pm": {
152
+ "optional": true
153
+ },
154
+ "highlight.js": {
155
+ "optional": true
156
+ },
157
+ "prosemirror-keymap": {
158
+ "optional": true
159
+ },
160
+ "prosemirror-model": {
161
+ "optional": true
162
+ },
163
+ "prosemirror-state": {
164
+ "optional": true
165
+ },
166
+ "prosemirror-transform": {
167
+ "optional": true
168
+ },
169
+ "prosemirror-view": {
170
+ "optional": true
143
171
  }
144
172
  },
145
173
  "devDependencies": {