kirbyup 2.0.2 → 2.1.0-beta.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/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { cac } from 'cac';
2
- import { n as name, b as build, s as serve, v as version, h as handleError } from './shared/kirbyup.93e22e45.mjs';
2
+ import { n as name, b as build, s as serve, v as version, h as handleError } from './shared/kirbyup.59842435.mjs';
3
3
  import 'node:fs';
4
4
  import 'node:fs/promises';
5
5
  import 'pathe';
@@ -9,6 +9,7 @@ import 'perfect-debounce';
9
9
  import 'vite';
10
10
  import 'vue/compiler-sfc';
11
11
  import '@vitejs/plugin-vue2';
12
+ import '@vitejs/plugin-vue2-jsx';
12
13
  import 'vite-plugin-full-reload';
13
14
  import 'postcss-load-config';
14
15
  import 'postcss-logical';
package/dist/index.mjs CHANGED
@@ -7,11 +7,12 @@ import 'perfect-debounce';
7
7
  import 'vite';
8
8
  import 'vue/compiler-sfc';
9
9
  import '@vitejs/plugin-vue2';
10
+ import '@vitejs/plugin-vue2-jsx';
10
11
  import 'vite-plugin-full-reload';
11
12
  import 'postcss-load-config';
12
13
  import 'postcss-logical';
13
14
  import 'postcss-dir-pseudo-class';
14
- export { b as build, s as serve } from './shared/kirbyup.93e22e45.mjs';
15
+ export { b as build, s as serve } from './shared/kirbyup.59842435.mjs';
15
16
  import 'zlib';
16
17
  import 'util';
17
18
  import 'fs';
@@ -6,7 +6,8 @@ import colors from 'picocolors';
6
6
  import { debounce } from 'perfect-debounce';
7
7
  import { createServer, mergeConfig, build as build$1 } from 'vite';
8
8
  import * as vueCompilerSfc from 'vue/compiler-sfc';
9
- import vuePlugin, { parseVueRequest } from '@vitejs/plugin-vue2';
9
+ import vuePlugin from '@vitejs/plugin-vue2';
10
+ import vueJsxPlugin from '@vitejs/plugin-vue2-jsx';
10
11
  import fullReloadPlugin from 'vite-plugin-full-reload';
11
12
  import postcssrc from 'postcss-load-config';
12
13
  import postcssLogical from 'postcss-logical';
@@ -19,7 +20,7 @@ import MagicString from 'magic-string';
19
20
  import { detect } from 'detect-package-manager';
20
21
 
21
22
  const name = "kirbyup";
22
- const version = "2.0.2";
23
+ const version = "2.1.0-beta.1";
23
24
 
24
25
  class PrettyError extends Error {
25
26
  constructor(message) {
@@ -98,6 +99,66 @@ async function loadConfig(cwd = process.cwd(), configOrPath = cwd, extraConfigSo
98
99
 
99
100
  const multilineCommentsRE = /\/\*(.|[\r\n])*?\*\//gm;
100
101
  const singlelineCommentsRE = /\/\/.*/g;
102
+ const HMR_RUNTIME_ID = "\0plugin-vue2:hmr-runtime";
103
+ const JSX_HMR_RUNTIME_ID = "plugin-vue2-jsx:hmr-runtime";
104
+ const isHmrRuntimeId = (id) => id === HMR_RUNTIME_ID || id === JSX_HMR_RUNTIME_ID;
105
+ const __INJECTED_HMR_CODE__ = `
106
+ /** - injected by kirbyup - */
107
+ for (const methodName of ['rerender', 'reload']) {
108
+ const original = __VUE_HMR_RUNTIME__[methodName]
109
+
110
+ __VUE_HMR_RUNTIME__[methodName] = function (id, updatedDef) {
111
+ const key = updatedDef?.__file ? '__file' : updatedDef?.__hmrId ? '__hmrId' : null
112
+
113
+ if (key) {
114
+ const pluginComponents = window.panel.plugins.components
115
+ const usedComponentDefs = window.panel.$vue.$options.components
116
+
117
+ for (const componentName in pluginComponents) {
118
+ if (updatedDef[key] === pluginComponents[componentName][key]) {
119
+ const usedDefinition = usedComponentDefs[componentName].options
120
+
121
+ if (map[id].options !== usedDefinition)
122
+ map[id].options = usedDefinition
123
+
124
+ if (typeof map[id].options.$_isSection !== 'boolean')
125
+ map[id].options.$_isSection = /^k-.*-section$/.test(componentName)
126
+
127
+ break
128
+ }
129
+ }
130
+ }
131
+
132
+ return original.apply(this, arguments)
133
+ }
134
+ }
135
+
136
+ function $_applyKirbyModifications(activeDef, newDef) {
137
+ const usedComponentDefs = window.panel.$vue.$options.components
138
+
139
+ if (newDef.template)
140
+ newDef.render = null
141
+
142
+ if (activeDef.$_isSection)
143
+ newDef.$_isSection = true
144
+ if (newDef.$_isSection && !newDef.mixins?.[0]?.methods?.load)
145
+ newDef.mixins = [activeDef.mixins[0], ...(newDef.mixins || [])]
146
+
147
+ if (typeof newDef.extends === 'string') {
148
+ if (newDef.extends === activeDef.extends?.options?.name) {
149
+ newDef.extends = activeDef.extends
150
+ }
151
+ else if (usedComponentDefs[newDef.extends]) {
152
+ newDef.extends = usedComponentDefs[newDef.extends].extend({
153
+ options: newDef,
154
+ components: { ...usedComponentDefs, ...(newDef.components || {}) },
155
+ })
156
+ }
157
+ else { newDef.extends = null }
158
+ }
159
+ }
160
+ /** -- */
161
+ `;
101
162
 
102
163
  function kirbyupAutoImportPlugin() {
103
164
  let config;
@@ -134,10 +195,6 @@ function kirbyupAutoImportPlugin() {
134
195
  };
135
196
  }
136
197
 
137
- const __HMR_CODE__ = `
138
- if (typeof __VUE_HMR_RUNTIME__ !== 'undefined' && import.meta.hot) {
139
- __VUE_HMR_RUNTIME__.reload = () => import.meta.hot.invalidate();
140
- }`.trim();
141
198
  const getViteProxyModule = (entryUrl, pm) => `
142
199
  try {
143
200
  await import("${entryUrl}");
@@ -160,13 +217,12 @@ function kirbyupHmrPlugin(options) {
160
217
  indexMjs = resolve(config.root, options.outDir || "", "index.dev.mjs");
161
218
  },
162
219
  transform(code, id) {
163
- const { query } = parseVueRequest(id);
164
- if (query.raw)
165
- return;
166
- if ((typeof id !== "string" || /\0/.test(id)) && !query.vue)
167
- return;
168
- if (/\.vue$/.test(id) && !query.vue)
169
- return `${code};${__HMR_CODE__}`;
220
+ if (isHmrRuntimeId(id)) {
221
+ return code.replace(
222
+ /^.*=\s*record\.Ctor\.super\.extend\(options\)/m,
223
+ "$_applyKirbyModifications(record.Ctor.options, options) // injected by kirbyup\n$&"
224
+ ) + __INJECTED_HMR_CODE__;
225
+ }
170
226
  },
171
227
  configureServer(server) {
172
228
  if (!server.httpServer)
@@ -215,6 +271,7 @@ function getViteConfig(command, options) {
215
271
  },
216
272
  plugins: [
217
273
  vuePlugin({ compiler: vueCompilerSfc }),
274
+ vueJsxPlugin(),
218
275
  kirbyupAutoImportPlugin()
219
276
  ],
220
277
  css: { postcss: resolvedPostCssConfig },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kirbyup",
3
- "version": "2.0.2",
3
+ "version": "2.1.0-beta.1",
4
4
  "packageManager": "pnpm@7.13.1",
5
5
  "description": "Zero-config bundler for Kirby Panel plugins",
6
6
  "author": {
@@ -14,9 +14,7 @@
14
14
  "type": "git",
15
15
  "url": "git+https://github.com/johannschopplich/kirbyup.git"
16
16
  },
17
- "bugs": {
18
- "url": "https://github.com/johannschopplich/kirbyup/issues"
19
- },
17
+ "bugs": "https://github.com/johannschopplich/kirbyup/issues",
20
18
  "keywords": [
21
19
  "kirby-cms",
22
20
  "kirby-plugin",
@@ -61,7 +59,7 @@
61
59
  },
62
60
  "scripts": {
63
61
  "build": "unbuild",
64
- "dev": "unbuild --stub",
62
+ "dev": "STUB=true unbuild",
65
63
  "lint": "eslint .",
66
64
  "lint:fix": "eslint . --fix",
67
65
  "release": "bumpp --commit --push --tag",
@@ -70,7 +68,8 @@
70
68
  "prepare": "simple-git-hooks"
71
69
  },
72
70
  "dependencies": {
73
- "@vitejs/plugin-vue2": "^2.0.0",
71
+ "@vitejs/plugin-vue2": "2.0.0",
72
+ "@vitejs/plugin-vue2-jsx": "1.0.3",
74
73
  "@vue/compiler-sfc": "^2.7.10",
75
74
  "cac": "^6.7.14",
76
75
  "chokidar": "^3.5.3",