@vixt/core 0.6.5 → 0.6.7

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.
@@ -24,8 +24,10 @@ interface PluginDefinition {
24
24
  }
25
25
  interface VixtPlugin {
26
26
  (this: void, vixt: VixtApp): any;
27
+ /** @internal */
28
+ _name?: string;
27
29
  }
28
30
  declare function defineVixtPlugin(definition: PluginDefinition | VixtPlugin): VixtPlugin;
29
- declare function applyPlugins(vixt: VixtApp, plugins: VixtPlugin[]): Promise<void>;
31
+ declare function applyPlugins(vixt: VixtApp, plugins: VixtPlugin[]): void;
30
32
  //#endregion
31
33
  export { CreateOptions, PluginDefinition, VixtApp, VixtAppConfig, VixtPlugin, applyPlugins, createVixtApp, defineAppConfig, defineVixtPlugin, useAppConfig, useVixtApp };
@@ -17,11 +17,13 @@ function createVixtApp(options) {
17
17
  //#endregion
18
18
  //#region src/client/plugin.ts
19
19
  function defineVixtPlugin(definition) {
20
- if (typeof definition == "function") return defineVixtPlugin({ setup: definition });
21
- return (vixt) => definition.setup?.(vixt);
20
+ if (typeof definition == "function") return definition;
21
+ const pluginName = definition.name;
22
+ const pluginSetup = definition.setup || (() => {});
23
+ return Object.assign(pluginSetup, { _name: pluginName });
22
24
  }
23
- async function applyPlugins(vixt, plugins) {
24
- for (const plugin of plugins) typeof plugin === "function" && await plugin(vixt);
25
+ function applyPlugins(vixt, plugins) {
26
+ for (const plugin of plugins) typeof plugin === "function" && plugin(vixt);
25
27
  }
26
28
 
27
29
  //#endregion
@@ -260,28 +260,31 @@ var app_default = defineVixtModule({
260
260
  },
261
261
  transformIndexHtml: {
262
262
  order,
263
- handler() {
263
+ handler(html = "") {
264
264
  if (!transformIndexHtml) return;
265
265
  const { rootTag, rootId, head } = options;
266
266
  const tags = Object.entries(head ?? {}).map(([tag, attrs]) => attrs.map((attr) => resolveHead(tag, attr))).flat();
267
267
  const loadingTemplate = resolveLoadingTemplate(options, vixt);
268
- return [
269
- {
270
- tag: rootTag,
271
- attrs: { id: rootId },
272
- children: loadingTemplate,
273
- injectTo: "body"
274
- },
275
- {
276
- tag: "script",
277
- attrs: {
278
- type: "module",
279
- src: relativeEntryPath
268
+ return {
269
+ html: `<!DOCTYPE html>\n${html}`,
270
+ tags: [
271
+ {
272
+ tag: rootTag,
273
+ attrs: { id: rootId },
274
+ children: loadingTemplate,
275
+ injectTo: "body"
280
276
  },
281
- injectTo: "body"
282
- },
283
- ...tags
284
- ];
277
+ {
278
+ tag: "script",
279
+ attrs: {
280
+ type: "module",
281
+ src: relativeEntryPath
282
+ },
283
+ injectTo: "body"
284
+ },
285
+ ...tags
286
+ ]
287
+ };
285
288
  }
286
289
  }
287
290
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vixt/core",
3
3
  "type": "module",
4
- "version": "0.6.5",
4
+ "version": "0.6.7",
5
5
  "author": "SoulLyoko<https://github.com/SoulLyoko>",
6
6
  "license": "MIT",
7
7
  "homepage": "https://soullyoko.github.io/vixt/",