create-prisma-php-app 4.0.0-alpha.95 → 4.1.0-alpha.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/app-gitignore +0 -3
- package/dist/index.js +1 -1
- package/dist/prisma-php.js +1 -1
- package/dist/public/js/reactive-v1.js +3 -2
- package/dist/ts/global-functions.ts +35 -0
- package/dist/ts/main.ts +2 -0
- package/dist/vite.config.ts +33 -0
- package/package.json +1 -1
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export function createGlobalSingleton<T>(
|
|
2
|
+
name: string,
|
|
3
|
+
SingletonClass: { getInstance(): T } | T,
|
|
4
|
+
target: any = window,
|
|
5
|
+
immediateInit: boolean = true
|
|
6
|
+
) {
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
get() {
|
|
9
|
+
if (
|
|
10
|
+
SingletonClass &&
|
|
11
|
+
(typeof SingletonClass === "function" ||
|
|
12
|
+
typeof SingletonClass === "object") &&
|
|
13
|
+
"getInstance" in SingletonClass &&
|
|
14
|
+
typeof SingletonClass.getInstance === "function"
|
|
15
|
+
) {
|
|
16
|
+
return (SingletonClass as { getInstance(): T }).getInstance();
|
|
17
|
+
} else {
|
|
18
|
+
return SingletonClass as T;
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
set(next) {
|
|
22
|
+
console.warn(`[${name}] Cannot override global ${name}; ignoring.`, next);
|
|
23
|
+
},
|
|
24
|
+
configurable: false,
|
|
25
|
+
enumerable: true,
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
if (immediateInit) {
|
|
29
|
+
try {
|
|
30
|
+
target[name];
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(`Failed to initialize ${name}:`, error);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
package/dist/ts/main.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { defineConfig } from "vite";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import fg from "fast-glob";
|
|
4
|
+
|
|
5
|
+
const entries = Object.fromEntries(
|
|
6
|
+
fg.sync("ts/**/*.ts", { ignore: ["**/*.test.ts"] }).map((f) => {
|
|
7
|
+
const rel = f.replace(/^ts\//, "").replace(/\.ts$/, "");
|
|
8
|
+
return [rel, path.resolve(__dirname, f)];
|
|
9
|
+
})
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export default defineConfig({
|
|
13
|
+
publicDir: false,
|
|
14
|
+
build: {
|
|
15
|
+
outDir: "public/js",
|
|
16
|
+
emptyOutDir: false,
|
|
17
|
+
minify: "esbuild",
|
|
18
|
+
sourcemap: false,
|
|
19
|
+
watch: {
|
|
20
|
+
exclude: ["public/**", "node_modules/**"],
|
|
21
|
+
},
|
|
22
|
+
rollupOptions: {
|
|
23
|
+
input: entries,
|
|
24
|
+
output: {
|
|
25
|
+
entryFileNames: "[name].js",
|
|
26
|
+
chunkFileNames: "chunks/[name]-[hash].js",
|
|
27
|
+
assetFileNames: "assets/[name]-[hash][extname]",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
esbuild: { legalComments: "none" },
|
|
32
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
33
|
+
});
|