@narrat/plugin-counter 2.12.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.
Files changed (43) hide show
  1. package/.vscode/extensions.json +3 -0
  2. package/README.md +3 -0
  3. package/_gitignore +24 -0
  4. package/dist/components/counter-ui.vue.d.ts +4 -0
  5. package/dist/custom-stores/counter-store.d.ts +9 -0
  6. package/dist/data/audio.yaml +7 -0
  7. package/dist/data/buttons.yaml +1 -0
  8. package/dist/data/characters.yaml +11 -0
  9. package/dist/data/config.yaml +41 -0
  10. package/dist/data/game.nar +2 -0
  11. package/dist/data/items.yaml +1 -0
  12. package/dist/data/quests.yaml +4 -0
  13. package/dist/data/screens.yaml +3 -0
  14. package/dist/data/scripts.yaml +2 -0
  15. package/dist/data/skills.yaml +20 -0
  16. package/dist/demo.d.ts +1 -0
  17. package/dist/img/backgrounds/curtain.webp +0 -0
  18. package/dist/narrat-plugin-counter.es.js +76 -0
  19. package/dist/narrat-plugin-counter.umd.js +1 -0
  20. package/dist/plugin.d.ts +14 -0
  21. package/dist/style.css +0 -0
  22. package/index.html +21 -0
  23. package/package.json +41 -0
  24. package/public/data/audio.yaml +7 -0
  25. package/public/data/buttons.yaml +1 -0
  26. package/public/data/characters.yaml +11 -0
  27. package/public/data/config.yaml +41 -0
  28. package/public/data/game.nar +2 -0
  29. package/public/data/items.yaml +1 -0
  30. package/public/data/quests.yaml +4 -0
  31. package/public/data/screens.yaml +3 -0
  32. package/public/data/scripts.yaml +2 -0
  33. package/public/data/skills.yaml +20 -0
  34. package/public/img/backgrounds/curtain.webp +0 -0
  35. package/src/components/counter-ui.vue +22 -0
  36. package/src/custom-stores/counter-store.ts +20 -0
  37. package/src/demo.ts +12 -0
  38. package/src/plugin.ts +57 -0
  39. package/src/style.css +0 -0
  40. package/src/vite-env.d.ts +21 -0
  41. package/tsconfig.json +26 -0
  42. package/tsconfig.node.json +9 -0
  43. package/vite.config.ts +37 -0
@@ -0,0 +1,3 @@
1
+ {
2
+ "recommendations": ["Vue.volar"]
3
+ }
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Narrat plugin template
2
+
3
+ TODO: Docs
package/_gitignore ADDED
@@ -0,0 +1,24 @@
1
+ # Logs
2
+ logs
3
+ *.log
4
+ npm-debug.log*
5
+ yarn-debug.log*
6
+ yarn-error.log*
7
+ pnpm-debug.log*
8
+ lerna-debug.log*
9
+
10
+ node_modules
11
+ dist
12
+ dist-ssr
13
+ *.local
14
+
15
+ # Editor directories and files
16
+ .vscode/*
17
+ !.vscode/extensions.json
18
+ .idea
19
+ .DS_Store
20
+ *.suo
21
+ *.ntvs*
22
+ *.njsproj
23
+ *.sln
24
+ *.sw?
@@ -0,0 +1,4 @@
1
+ declare const _default: import("vue").DefineComponent<{}, {
2
+ counter: import("vue").ComputedRef<number>;
3
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>;
4
+ export default _default;
@@ -0,0 +1,9 @@
1
+ export declare const useCounter: import("pinia").StoreDefinition<"counter", {
2
+ count: number;
3
+ }, {}, {
4
+ save(): {
5
+ count: number;
6
+ };
7
+ load(data: any): void;
8
+ reset(): void;
9
+ }>;
@@ -0,0 +1,7 @@
1
+ files: {}
2
+ options:
3
+ volume: 0.5
4
+ musicFadeInTime: 0.5
5
+ musicFadeInDelay: 0.5
6
+ musicFadeOutTime: 0.5
7
+ audioTriggers: {}
@@ -0,0 +1 @@
1
+ buttons: {}
@@ -0,0 +1,11 @@
1
+ ---
2
+ config:
3
+ imagesPath: img/characters/
4
+ characters:
5
+ game:
6
+ name: ''
7
+ color: white
8
+ player:
9
+ style:
10
+ color: orange
11
+ name: You
@@ -0,0 +1,41 @@
1
+ ---
2
+ gameTitle: Narrat Game Example
3
+ images: {}
4
+ dialogPanel:
5
+ textSpeed: 30
6
+ animateText: true
7
+ timeBetweenLines: 100
8
+ overlayMode: true
9
+ rightOffset: 100
10
+ bottomOffset: 50
11
+ width: 475
12
+ height: 680
13
+ layout:
14
+ backgrounds:
15
+ width: 1280
16
+ height: 720
17
+ dialogBottomPadding: 70
18
+ mobileDialogHeightPercentage: 60
19
+ verticalLayoutThreshold: 600
20
+ portraits:
21
+ width: 100
22
+ height: 100
23
+ screens: data/screens.yaml
24
+ buttons: data/buttons.yaml
25
+ skills: data/skills.yaml
26
+ scripts: data/scripts.yaml
27
+ characters: data/characters.yaml
28
+ audio: data/audio.yaml
29
+ notifications:
30
+ timeOnScreen: 2.5
31
+ alsoPrintInDialogue: true
32
+ hudStats: {}
33
+ items: data/items.yaml
34
+ interactionTags:
35
+ default:
36
+ onlyInteractOutsideOfScripts: true
37
+ quests: data/quests.yaml
38
+ menuButtons: {}
39
+ saves:
40
+ mode: manual
41
+ slots: 10
@@ -0,0 +1,2 @@
1
+ main:
2
+ "Hello world"
@@ -0,0 +1 @@
1
+ items: {}
@@ -0,0 +1,4 @@
1
+ categories:
2
+ - id: default
3
+ title: Default quest category
4
+ quests: {}
@@ -0,0 +1,3 @@
1
+ screens:
2
+ default:
3
+ background: img/backgrounds/curtain.webp
@@ -0,0 +1,2 @@
1
+ ---
2
+ - data/game.nar
@@ -0,0 +1,20 @@
1
+ skills: {}
2
+ skillChecks:
3
+ rollRange: 100
4
+ skillMultiplier: 10
5
+ failureChance: 1
6
+ difficultyText:
7
+ - - 0
8
+ - Very Easy
9
+ - - 10
10
+ - Easy
11
+ - - 30
12
+ - Medium
13
+ - - 50
14
+ - Hard
15
+ - - 70
16
+ - Very Hard
17
+ - - 80
18
+ - Extremely Hard
19
+ - - 90
20
+ - Near Impossible
package/dist/demo.d.ts ADDED
@@ -0,0 +1 @@
1
+ import 'narrat/dist/style.css';
@@ -0,0 +1,76 @@
1
+ var i = Object.defineProperty;
2
+ var m = (t, n, o) => n in t ? i(t, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[n] = o;
3
+ var c = (t, n, o) => (m(t, typeof n != "symbol" ? n + "" : n, o), o);
4
+ import { defineComponent as l, computed as p, openBlock as _, createElementBlock as d, toDisplayString as g } from "vue";
5
+ import { defineStore as f } from "pinia";
6
+ import { NarratPlugin as C, CommandPlugin as a } from "narrat";
7
+ const r = f("counter", {
8
+ state: () => ({
9
+ count: 0
10
+ }),
11
+ actions: {
12
+ save() {
13
+ return {
14
+ count: this.count
15
+ };
16
+ },
17
+ load(t) {
18
+ this.count = t.count;
19
+ },
20
+ reset() {
21
+ this.count = 0;
22
+ }
23
+ }
24
+ }), h = l({
25
+ setup() {
26
+ console.log("counter ui");
27
+ const t = r();
28
+ return { counter: p(() => t.count) };
29
+ }
30
+ });
31
+ const v = (t, n) => {
32
+ const o = t.__vccOpts || t;
33
+ for (const [e, u] of n)
34
+ o[e] = u;
35
+ return o;
36
+ };
37
+ function x(t, n, o, e, u, s) {
38
+ return _(), d("h1", null, "Counter value: " + g(t.counter), 1);
39
+ }
40
+ const $ = /* @__PURE__ */ v(h, [["render", x]]);
41
+ class w extends C {
42
+ constructor() {
43
+ super();
44
+ c(this, "customStores");
45
+ c(this, "customCommands");
46
+ c(this, "customMenuTabs");
47
+ const o = "2.12.1", e = new Date("2023-04-12T18:44:03.331Z").toLocaleString();
48
+ console.log(
49
+ `%c [Narrat plugin] [@narrat/plugin-counter] v${o} - Built at ${e}`,
50
+ "background: #222; color: #bada55"
51
+ ), this.customStores = {
52
+ counter: r
53
+ }, this.customCommands = [
54
+ new a(
55
+ "increase_counter",
56
+ [],
57
+ async (s) => r().count++
58
+ ),
59
+ new a("get_counter", [], async (s) => r().count)
60
+ ], this.customMenuTabs = [
61
+ {
62
+ menuId: "menu",
63
+ config: {
64
+ id: "counter",
65
+ text: "Counter",
66
+ cssClass: "counter-menu-button",
67
+ component: "CounterUi"
68
+ },
69
+ component: $
70
+ }
71
+ ];
72
+ }
73
+ }
74
+ export {
75
+ w as CounterPlugin
76
+ };
@@ -0,0 +1 @@
1
+ (function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("pinia"),require("narrat")):typeof define=="function"&&define.amd?define(["exports","vue","pinia","narrat"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n["narrat-plugin-counter"]={},n.Vue,n.pinia,n.narrat))})(this,function(n,e,o,a){"use strict";var C=Object.defineProperty;var h=(n,e,o)=>e in n?C(n,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):n[e]=o;var i=(n,e,o)=>(h(n,typeof e!="symbol"?e+"":e,o),o);const c=o.defineStore("counter",{state:()=>({count:0}),actions:{save(){return{count:this.count}},load(t){this.count=t.count},reset(){this.count=0}}}),m=e.defineComponent({setup(){console.log("counter ui");const t=c();return{counter:e.computed(()=>t.count)}}}),y="",p=(t,r)=>{const u=t.__vccOpts||t;for(const[s,d]of r)u[s]=d;return u};function f(t,r,u,s,d,l){return e.openBlock(),e.createElementBlock("h1",null,"Counter value: "+e.toDisplayString(t.counter),1)}const _=p(m,[["render",f]]);class g extends a.NarratPlugin{constructor(){super();i(this,"customStores");i(this,"customCommands");i(this,"customMenuTabs");const u="2.12.1",s=new Date("2023-04-12T18:44:03.331Z").toLocaleString();console.log(`%c [Narrat plugin] [@narrat/plugin-counter] v${u} - Built at ${s}`,"background: #222; color: #bada55"),this.customStores={counter:c},this.customCommands=[new a.CommandPlugin("increase_counter",[],async l=>c().count++),new a.CommandPlugin("get_counter",[],async l=>c().count)],this.customMenuTabs=[{menuId:"menu",config:{id:"counter",text:"Counter",cssClass:"counter-menu-button",component:"CounterUi"},component:_}]}}n.CounterPlugin=g,Object.defineProperties(n,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
@@ -0,0 +1,14 @@
1
+ import { CommandPlugin, CustomMenuTab, CustomStores, NarratPlugin } from 'narrat';
2
+ /**
3
+ * The CounterPlugin is a simple example plugin to showcase the various features plugins can use.
4
+ * This plugin will use the `counter-store` custom store to store custom data (which gets saved and loaded)
5
+ * It uses the `counter-ui.vue` component to display the counter
6
+ * It uses some `CommandPlugin` to add new commands to modify or get the counter's value
7
+ * It uses the `CustomMenuButton` to add a new menu button to the menu bar
8
+ */
9
+ export declare class CounterPlugin extends NarratPlugin {
10
+ customStores: CustomStores;
11
+ customCommands: CommandPlugin<any>[];
12
+ customMenuTabs: CustomMenuTab[];
13
+ constructor();
14
+ }
package/dist/style.css ADDED
File without changes
package/index.html ADDED
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <title>Narrat plugin counter test page</title>
6
+ <link rel="icon" href="/favicon.svg" />
7
+ <meta name="apple-mobile-web-app-capable" content="yes" />
8
+ <meta
9
+ name="apple-mobile-web-app-status-bar-style"
10
+ content="black-translucent"
11
+ />
12
+ <meta
13
+ name="viewport"
14
+ content="viewport-fit=cover, user-scalable=no, width=device-width, initial-scale=1, maximum-scale=1"
15
+ />
16
+ </head>
17
+ <body>
18
+ <script type="module" src="src/demo.ts"></script>
19
+ <div id="game-holder"></div>
20
+ </body>
21
+ </html>
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "@narrat/plugin-counter",
3
+ "description": "A counter plugin to narrat, used as a demo of the plugin system",
4
+ "main": "dist/narrat-plugin-counter.es.js",
5
+ "module": "dist/narrat-plugin-counter.es.js",
6
+ "types": "dist/plugin.d.ts",
7
+ "version": "2.12.1",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git@github.com:liana-p/narrat-engine.git",
11
+ "directory": "packages/narrat-plugin-counter"
12
+ },
13
+ "engines": {
14
+ "node": ">=16"
15
+ },
16
+ "type": "module",
17
+ "homepage": "https://get-narrat.com",
18
+ "scripts": {
19
+ "dev": "vite",
20
+ "generate-types": "vue-tsc --emitDeclarationOnly --outDir dist && pnpm run fix-type-aliases",
21
+ "fix-type-aliases": "tsc-alias -p tsconfig.json",
22
+ "build": "vue-tsc --noEmit && vite build && pnpm run generate-types",
23
+ "preview": "vite preview"
24
+ },
25
+ "dependencies": {},
26
+ "peerDependencies": {
27
+ "narrat": "workspace:*",
28
+ "pinia": "^2.0.14",
29
+ "vue": "^3.2.37"
30
+ },
31
+ "devDependencies": {
32
+ "@vitejs/plugin-vue": "^3.0.0",
33
+ "tsc-alias": "^1.6.11",
34
+ "typescript": "^4.6.4",
35
+ "vite": "^3.0.0",
36
+ "vue-tsc": "^0.38.4",
37
+ "narrat": "workspace:*",
38
+ "pinia": "^2.0.14",
39
+ "vue": "^3.2.37"
40
+ }
41
+ }
@@ -0,0 +1,7 @@
1
+ files: {}
2
+ options:
3
+ volume: 0.5
4
+ musicFadeInTime: 0.5
5
+ musicFadeInDelay: 0.5
6
+ musicFadeOutTime: 0.5
7
+ audioTriggers: {}
@@ -0,0 +1 @@
1
+ buttons: {}
@@ -0,0 +1,11 @@
1
+ ---
2
+ config:
3
+ imagesPath: img/characters/
4
+ characters:
5
+ game:
6
+ name: ''
7
+ color: white
8
+ player:
9
+ style:
10
+ color: orange
11
+ name: You
@@ -0,0 +1,41 @@
1
+ ---
2
+ gameTitle: Narrat Game Example
3
+ images: {}
4
+ dialogPanel:
5
+ textSpeed: 30
6
+ animateText: true
7
+ timeBetweenLines: 100
8
+ overlayMode: true
9
+ rightOffset: 100
10
+ bottomOffset: 50
11
+ width: 475
12
+ height: 680
13
+ layout:
14
+ backgrounds:
15
+ width: 1280
16
+ height: 720
17
+ dialogBottomPadding: 70
18
+ mobileDialogHeightPercentage: 60
19
+ verticalLayoutThreshold: 600
20
+ portraits:
21
+ width: 100
22
+ height: 100
23
+ screens: data/screens.yaml
24
+ buttons: data/buttons.yaml
25
+ skills: data/skills.yaml
26
+ scripts: data/scripts.yaml
27
+ characters: data/characters.yaml
28
+ audio: data/audio.yaml
29
+ notifications:
30
+ timeOnScreen: 2.5
31
+ alsoPrintInDialogue: true
32
+ hudStats: {}
33
+ items: data/items.yaml
34
+ interactionTags:
35
+ default:
36
+ onlyInteractOutsideOfScripts: true
37
+ quests: data/quests.yaml
38
+ menuButtons: {}
39
+ saves:
40
+ mode: manual
41
+ slots: 10
@@ -0,0 +1,2 @@
1
+ main:
2
+ "Hello world"
@@ -0,0 +1 @@
1
+ items: {}
@@ -0,0 +1,4 @@
1
+ categories:
2
+ - id: default
3
+ title: Default quest category
4
+ quests: {}
@@ -0,0 +1,3 @@
1
+ screens:
2
+ default:
3
+ background: img/backgrounds/curtain.webp
@@ -0,0 +1,2 @@
1
+ ---
2
+ - data/game.nar
@@ -0,0 +1,20 @@
1
+ skills: {}
2
+ skillChecks:
3
+ rollRange: 100
4
+ skillMultiplier: 10
5
+ failureChance: 1
6
+ difficultyText:
7
+ - - 0
8
+ - Very Easy
9
+ - - 10
10
+ - Easy
11
+ - - 30
12
+ - Medium
13
+ - - 50
14
+ - Hard
15
+ - - 70
16
+ - Very Hard
17
+ - - 80
18
+ - Extremely Hard
19
+ - - 90
20
+ - Near Impossible
@@ -0,0 +1,22 @@
1
+ <template>
2
+ <h1>Counter value: {{ counter }}</h1>
3
+ </template>
4
+ <script lang="ts">
5
+ import { computed, defineComponent } from 'vue';
6
+ import { useCounter } from '../custom-stores/counter-store';
7
+
8
+ export default defineComponent({
9
+ setup() {
10
+ console.log('counter ui');
11
+ const counterStore = useCounter();
12
+ const counter = computed(() => {
13
+ return counterStore.count;
14
+ });
15
+ return { counter };
16
+ },
17
+ });
18
+ </script>
19
+
20
+ <style>
21
+ /* Write CSS for this vue component */
22
+ </style>
@@ -0,0 +1,20 @@
1
+ import { defineStore } from 'pinia';
2
+
3
+ export const useCounter = defineStore('counter', {
4
+ state: () => ({
5
+ count: 0,
6
+ }),
7
+ actions: {
8
+ save() {
9
+ return {
10
+ count: this.count,
11
+ };
12
+ },
13
+ load(data: any) {
14
+ this.count = data.count;
15
+ },
16
+ reset() {
17
+ this.count = 0;
18
+ },
19
+ },
20
+ });
package/src/demo.ts ADDED
@@ -0,0 +1,12 @@
1
+ import 'narrat/dist/style.css';
2
+ import { registerPlugin, startApp } from 'narrat';
3
+ import { CounterPlugin } from './plugin';
4
+
5
+ window.addEventListener('load', () => {
6
+ registerPlugin(new CounterPlugin());
7
+ startApp({
8
+ configPath: 'data/config.yaml',
9
+ logging: false,
10
+ debug: true,
11
+ });
12
+ });
package/src/plugin.ts ADDED
@@ -0,0 +1,57 @@
1
+ import CounterUi from './components/counter-ui.vue';
2
+ import { useCounter } from './custom-stores/counter-store';
3
+ import {
4
+ CommandPlugin,
5
+ CustomMenuTab,
6
+ CustomStores,
7
+ NarratPlugin,
8
+ } from 'narrat';
9
+
10
+ /**
11
+ * The CounterPlugin is a simple example plugin to showcase the various features plugins can use.
12
+ * This plugin will use the `counter-store` custom store to store custom data (which gets saved and loaded)
13
+ * It uses the `counter-ui.vue` component to display the counter
14
+ * It uses some `CommandPlugin` to add new commands to modify or get the counter's value
15
+ * It uses the `CustomMenuButton` to add a new menu button to the menu bar
16
+ */
17
+ export class CounterPlugin extends NarratPlugin {
18
+ customStores: CustomStores;
19
+ customCommands: CommandPlugin<any>[];
20
+ customMenuTabs: CustomMenuTab[];
21
+
22
+ constructor() {
23
+ super();
24
+ const version = import.meta.env.VITE_BUILD_VERSION;
25
+ const date = new Date(import.meta.env.VITE_BUILD_DATE).toLocaleString();
26
+ const name = import.meta.env.VITE_PLUGIN_NAME;
27
+ console.log(
28
+ `%c [Narrat plugin] [${name}] v${version} - Built at ${date}`,
29
+ 'background: #222; color: #bada55',
30
+ );
31
+ this.customStores = {
32
+ counter: useCounter,
33
+ };
34
+
35
+ this.customCommands = [
36
+ new CommandPlugin(
37
+ 'increase_counter',
38
+ [],
39
+ async (ctx) => useCounter().count++,
40
+ ),
41
+ new CommandPlugin('get_counter', [], async (ctx) => useCounter().count),
42
+ ];
43
+
44
+ this.customMenuTabs = [
45
+ {
46
+ menuId: 'menu',
47
+ config: {
48
+ id: 'counter',
49
+ text: 'Counter',
50
+ cssClass: 'counter-menu-button',
51
+ component: 'CounterUi',
52
+ },
53
+ component: CounterUi,
54
+ },
55
+ ];
56
+ }
57
+ }
package/src/style.css ADDED
File without changes
@@ -0,0 +1,21 @@
1
+ /// <reference types="vite/client" />
2
+
3
+ declare module '*.vue' {
4
+ import type { DefineComponent } from 'vue';
5
+ const component: DefineComponent<{}, {}, any>;
6
+ export default component;
7
+ }
8
+
9
+ /// <reference types="vite/client" />
10
+
11
+ interface ImportMetaEnv {
12
+ readonly VITE_BUILD_DATE: string;
13
+ readonly VITE_BUILD_VERSION: string;
14
+ readonly VITE_PLUGIN_NAME: string;
15
+ // more env variables...
16
+ }
17
+
18
+ // eslint-disable-next-line no-unused-vars
19
+ interface ImportMeta {
20
+ readonly env: ImportMetaEnv;
21
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "esnext",
4
+ "baseUrl": "./",
5
+ "useDefineForClassFields": true,
6
+ "module": "esnext",
7
+ "moduleResolution": "node",
8
+ "strict": true,
9
+ "jsx": "preserve",
10
+ "outDir": "dist",
11
+ "sourceMap": true,
12
+ "isolatedModules": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "esModuleInterop": true,
16
+ "allowJs": true,
17
+ "lib": ["esnext", "dom"],
18
+ "skipLibCheck": true,
19
+ "paths": {
20
+ "@/*": ["src/*"]
21
+ },
22
+ "typeRoots": ["types/", "node_modules/@types/"]
23
+ },
24
+ "include": ["src/**/*.ts", "src/**/*.d.ts", "src/**/*.tsx", "src/**/*.vue"],
25
+ "references": [{ "path": "./tsconfig.node.json" }]
26
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true
7
+ },
8
+ "include": ["vite.config.ts"]
9
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,37 @@
1
+ import { defineConfig } from 'vite';
2
+ import vue from '@vitejs/plugin-vue';
3
+ import { resolve } from 'path';
4
+ import { fileURLToPath, URL } from 'url';
5
+ import packageJson from './package.json';
6
+
7
+ // https://vitejs.dev/config/
8
+ process.env.VITE_BUILD_DATE = new Date().toISOString();
9
+ process.env.VITE_BUILD_VERSION = packageJson?.version ?? 'Unknown';
10
+ process.env.VITE_PLUGIN_NAME = packageJson?.name ?? 'Unknown plugin';
11
+
12
+ export default defineConfig({
13
+ plugins: [vue()],
14
+ base: '',
15
+ build: {
16
+ lib: {
17
+ entry: resolve(__dirname, 'src/plugin.ts'),
18
+ name: 'narrat-plugin-counter',
19
+ fileName: (format) => `narrat-plugin-counter.${format}.js`,
20
+ },
21
+ rollupOptions: {
22
+ external: ['vue', 'narrat', 'pinia'],
23
+ output: {
24
+ globals: {
25
+ vue: 'Vue',
26
+ narrat: 'narrat',
27
+ pinia: 'pinia',
28
+ },
29
+ },
30
+ },
31
+ },
32
+ resolve: {
33
+ alias: {
34
+ '@': fileURLToPath(new URL('./src', import.meta.url)),
35
+ },
36
+ },
37
+ });