@mono-lit/helper 0.0.10 → 0.1.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/dist/nuxt.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as monoSsr } from "./vite-CivRCJaf.js";
1
+ import { t as monoSsr } from "./vite-CfW7z2wn.js";
2
2
  import { join } from "node:path";
3
3
  import { pathToFileURL } from "node:url";
4
4
  import { addComponent, addPlugin, addPluginTemplate, addVitePlugin, createResolver, defineNuxtModule, extendViteConfig, hasNuxtModule, tryResolveModule, useLogger } from "@nuxt/kit";
@@ -1,5 +1,4 @@
1
- import { NodeTypes, parse } from "@vue/compiler-dom";
2
- import { parse as parse$1 } from "@vue/compiler-sfc";
1
+ import { parse } from "vue/compiler-sfc";
3
2
  import MagicString from "magic-string";
4
3
 
5
4
  //#region src/vite/shadow-manifest.ts
@@ -74,6 +73,13 @@ function shadowTagsFromScript(script) {
74
73
 
75
74
  //#endregion
76
75
  //#region src/vite/mono-client-only.ts
76
+ const NodeTypes = {
77
+ ELEMENT: 1,
78
+ TEXT: 2,
79
+ COMMENT: 3,
80
+ ATTRIBUTE: 6,
81
+ DIRECTIVE: 7
82
+ };
77
83
  const LIT_DIRECTIVES_TO_MOVE = [
78
84
  "v-for",
79
85
  ":key",
@@ -121,18 +127,19 @@ function monoClientOnlyPlugin(options = {}) {
121
127
  if (!filename.endsWith(".vue")) return null;
122
128
  if (filename.includes("/node_modules/") || filename.includes("\\node_modules\\")) return null;
123
129
  if (!source.toLowerCase().includes(`<${normalizedPrefix}`)) return null;
124
- const { descriptor, errors } = parse$1(source, { filename });
125
- if (errors.length > 0 || !descriptor.template) return null;
130
+ const { descriptor, errors } = parse(source, {
131
+ filename,
132
+ templateParseOptions: { comments: true }
133
+ });
134
+ if (errors.length > 0 || !descriptor.template?.ast) return null;
126
135
  const fileShadowTags = /* @__PURE__ */ new Set();
127
136
  if (litWrapper) {
128
137
  for (const tag of shadowOverride) fileShadowTags.add(tag);
129
138
  const script = `${descriptor.scriptSetup?.content ?? ""}\n${descriptor.script?.content ?? ""}`;
130
139
  for (const tag of shadowTagsFromScript(script)) fileShadowTags.add(tag);
131
140
  }
132
- const template = descriptor.template;
133
- const ast = parse(template.content, { comments: true });
141
+ const ast = descriptor.template.ast;
134
142
  const magicString = new MagicString(source);
135
- const templateOffset = template.loc.start.offset;
136
143
  let changed = false;
137
144
  /** A `mono-*` element whose shadow build this file imports → SSR-wrapped. */
138
145
  function isShadowElement(node) {
@@ -154,8 +161,8 @@ function monoClientOnlyPlugin(options = {}) {
154
161
  * No skeleton fallback — the element is server-rendered to DSD.
155
162
  */
156
163
  function wrapLit(node) {
157
- const start = templateOffset + node.loc.start.offset;
158
- const end = templateOffset + node.loc.end.offset;
164
+ const start = node.loc.start.offset;
165
+ const end = node.loc.end.offset;
159
166
  const moved = node.props.filter((prop) => prop.type === NodeTypes.DIRECTIVE && !!prop.rawName && LIT_DIRECTIVES_TO_MOVE.includes(prop.rawName));
160
167
  const directivesToAdd = moved.length ? ` ${moved.map((prop) => prop.loc.source).join(" ")}` : "";
161
168
  const startTag = `<${litWrapperComponent}${directivesToAdd}>`;
@@ -165,7 +172,7 @@ function monoClientOnlyPlugin(options = {}) {
165
172
  magicString.overwrite(start, end, `${startTag}${stripped}${endTag}`);
166
173
  } else {
167
174
  const lastProp = node.props.length ? node.props[node.props.length - 1] : void 0;
168
- const contentStart = lastProp ? templateOffset + lastProp.loc.end.offset : start + node.tag.length + 2;
175
+ const contentStart = lastProp ? lastProp.loc.end.offset : start + node.tag.length + 2;
169
176
  const stripped = source.slice(start, contentStart).replace(litDirectivesRegex, "").trim();
170
177
  magicString.overwrite(start, contentStart, stripped);
171
178
  magicString.prependLeft(start, startTag);
@@ -174,13 +181,13 @@ function monoClientOnlyPlugin(options = {}) {
174
181
  changed = true;
175
182
  }
176
183
  function wrapRange(firstNode, lastNode) {
177
- const start = templateOffset + firstNode.loc.start.offset;
178
- const end = templateOffset + lastNode.loc.end.offset;
184
+ const start = firstNode.loc.start.offset;
185
+ const end = lastNode.loc.end.offset;
179
186
  function extractAndRemoveStaticAttr(name) {
180
187
  const attribute = getStaticAttribute(firstNode, name);
181
188
  if (!attribute) return "";
182
- const attributeStart = templateOffset + attribute.loc.start.offset;
183
- const attributeEnd = templateOffset + attribute.loc.end.offset;
189
+ const attributeStart = attribute.loc.start.offset;
190
+ const attributeEnd = attribute.loc.end.offset;
184
191
  let removalStart = attributeStart;
185
192
  while (removalStart > start && /\s/.test(source[removalStart - 1] ?? "")) removalStart--;
186
193
  magicString.remove(removalStart, attributeEnd);
package/dist/vite.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as monoSsrStubPlugin, r as monoClientOnlyPlugin, t as monoSsr } from "./vite-CivRCJaf.js";
1
+ import { n as monoSsrStubPlugin, r as monoClientOnlyPlugin, t as monoSsr } from "./vite-CfW7z2wn.js";
2
2
 
3
3
  export { monoClientOnlyPlugin, monoSsr, monoSsrStubPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mono-lit/helper",
3
- "version": "0.0.10",
3
+ "version": "0.1.0",
4
4
  "description": "Lit web components (tables, forms, inputs, dialogs, charts) for Vue and Nuxt, with light-DOM and shadow-DOM builds.",
5
5
  "keywords": [
6
6
  "lit",
@@ -328,15 +328,17 @@
328
328
  "@floating-ui/core": "1.8.0",
329
329
  "@floating-ui/dom": "1.8.0",
330
330
  "@iconify/json": "2.2.505",
331
+ "@nuxt/schema": "^4.6.2",
331
332
  "@tsdown/css": "0.23.1",
332
333
  "@unocss/preset-web-fonts": "66.11.0",
334
+ "@vue/compiler-dom": "3.5.44",
333
335
  "basecoat-css": "1.0.2",
334
336
  "chart.js": "4.5.1",
335
337
  "cross-env": "10.1.0",
336
338
  "dotenv": "^17.4.2",
337
339
  "dotenv-cli": "^11.0.0",
338
340
  "exceljs": "4.4.0",
339
- "handlebars": "4.7.9",
341
+ "handlebars": "4.7.10",
340
342
  "postcss": "^8.5.6",
341
343
  "postcss-import": "17.0.1",
342
344
  "suneditor": "3.3.3",
@@ -349,21 +351,18 @@
349
351
  "vite-plugin-html-inject": "1.1.2",
350
352
  "vue": "3.5.44",
351
353
  "yup": "1.7.1",
352
- "@mono-lit/utility": "0.0.6",
353
- "@mono-lit/devextreme": "0.0.2"
354
+ "@mono-lit/devextreme": "0.0.2",
355
+ "@mono-lit/utility": "0.1.0"
354
356
  },
355
357
  "dependencies": {
356
358
  "@lit-labs/ssr": "3.2.2",
357
359
  "@lit-labs/ssr-client": "^1.1.7",
358
360
  "@nuxt/kit": "^4.6.2",
359
- "@nuxt/schema": "^4.6.2",
360
361
  "@types/mdast": "^4.0.4",
361
- "@vue/compiler-dom": "3.5.44",
362
- "@vue/compiler-sfc": "3.5.44",
363
362
  "@webcomponents/template-shadowroot": "^0.2.1",
364
363
  "flatpickr": "4.6.13",
365
364
  "jexl": "^2.3.0",
366
- "lit": "3.3.3",
365
+ "lit": "^3.3.3",
367
366
  "magic-string": "^0.30.21",
368
367
  "p-debounce": "^5.1.0",
369
368
  "p-throttle": "^8.1.0",
@@ -377,11 +376,11 @@
377
376
  "@floating-ui/dom": "^1.7.0",
378
377
  "@mono-lit/utility": "*",
379
378
  "chart.js": "4.5.1",
380
- "exceljs": ">=4",
381
- "handlebars": ">=4",
379
+ "exceljs": "4.4.0",
380
+ "handlebars": "4.7.10",
382
381
  "suneditor": "^3.3.3",
383
- "vite": ">=5",
384
- "vue": ">=3.3"
382
+ "vite": "^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0",
383
+ "vue": "^3.4.0"
385
384
  },
386
385
  "peerDependenciesMeta": {
387
386
  "vue": {