@tolki/enum 0.0.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Abraham Arango
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,189 @@
1
+ # Tolki JS Enum Package
2
+
3
+ This package provides enum utility functions similar to Laravel's Enum class facade.
4
+
5
+ ## Documentation
6
+
7
+ The full documentation for the enum utilities can be found at [https://tolki.abe.dev](https://tolki.abe.dev/enums/).
8
+
9
+ <!-- AUTO-GENERATED-DOCS:START -->
10
+
11
+ # Enum Utilities Installation
12
+
13
+ The [`@tolki/enum`](https://www.npmjs.com/package/@tolki/enum) package provides a variety of enum manipulation utilities inspired by PHP's enum utilities like [from](https://www.php.net/manual/en/backedenum.from.php), [tryFrom](https://www.php.net/manual/en/backedenum.tryfrom.php), and [cases](https://www.php.net/manual/en/unitenum.cases.php).
14
+
15
+ This package is meant to be used with the Laravel enum package [Laravel TypeScript Publisher](https://github.com/abetwothree/laravel-ts-publish), which transforms PHP enums into TypeScript enums. The `@tolki/enum` package provides utilities to work with these TypeScript enums in a way that is similar to how you would work with PHP enums in Laravel.
16
+
17
+ You can install this package via npm, yarn, or pnpm:
18
+
19
+ ```bash [npm]
20
+ npm install @tolki/enum
21
+ ```
22
+
23
+ ```bash [yarn]
24
+ yarn add @tolki/enum
25
+ ```
26
+
27
+ ```bash [pnpm]
28
+ pnpm add @tolki/enum
29
+ ```
30
+
31
+ # Tolki Enum Utilities List
32
+
33
+ ## Enum Utilities List
34
+
35
+ As mentioned in the [Enum Utilities Installation](./index.md) page, the `@tolki/enum` package is not meant to be used as standalone package as it works with the [Laravel TypeScript Publisher](https://github.com/abetwothree/laravel-ts-publish) package to transform PHP enums into TypeScript enums. The functions below are being listed out for reference, not necessarily for direct use.
36
+
37
+ [cases](#cases) [defineEnum](#defineenum) [from](#from) [tryFrom](#tryfrom)
38
+
39
+ ## Enum Utilities Details
40
+
41
+ ### cases
42
+
43
+ Similar to the PHP [cases](https://www.php.net/manual/en/unitenum.cases.php) method, this function returns an array of all the cases of the given enum.
44
+
45
+ ```javascript
46
+ import { cases } from "@tolki/enum";
47
+ import { Status } from "@js/types/enums";
48
+
49
+ const result = cases(Status); // result is an array with an enum instance for each case in the Status enum
50
+ ```
51
+
52
+ ### defineEnum
53
+
54
+ This is a factory function that is automatically applied by the Laravel TypeScript Publisher package when it transforms PHP enums into TypeScript enums. It automatically adds the `cases`, `from`, and `tryFrom` methods to the transformed TypeScript enums.
55
+
56
+ ```javascript
57
+ import { defineEnum } from "@tolki/enum";
58
+
59
+ const Status = defineEnum({
60
+ ACTIVE: "active",
61
+ INACTIVE: "inactive",
62
+ PENDING: "pending",
63
+ // automatically added by the Laravel TypeScript Publisher package
64
+ _cases: ["ACTIVE", "INACTIVE", "PENDING"],
65
+ _methods: [],
66
+ _static: [],
67
+ });
68
+
69
+ Status.cases(); // result is an array with an enum instance for each case in the Status enum
70
+ Status.from("active"); // result is the enum instance for the ACTIVE case
71
+ Status.tryFrom("non-valid-key"); // result null
72
+ ```
73
+
74
+ ### from
75
+
76
+ Similar to the PHP [from](https://www.php.net/manual/en/backedenum.from.php) method, this function returns the enum instance for the given value. If the value does not exist in the enum, it throws an error.
77
+
78
+ ```javascript
79
+ import { from } from "@tolki/enum";
80
+ import { Status } from "@js/types/enums";
81
+
82
+ const result = from(Status, "active"); // result is the enum instance for the ACTIVE case
83
+ const result2 = from(Status, "non-valid-key"); // throws an error because "non-valid-key" is not a valid value
84
+ ```
85
+
86
+ ### tryFrom
87
+
88
+ Similar to the PHP [tryFrom](https://www.php.net/manual/en/backedenum.tryfrom.php) method, this function returns the enum instance for the given value. If the value does not exist in the enum, it returns null instead of throwing an error.
89
+
90
+ ```javascript
91
+ import { tryFrom } from "@tolki/enum";
92
+ import { Status } from "@js/types/enums";
93
+
94
+ const result = tryFrom(Status, "active"); // result is the enum instance for the ACTIVE case
95
+ const result2 = tryFrom(Status, "non-valid-key"); // result is null because "non-valid-key" is not a valid value
96
+ ```
97
+
98
+ # Tolki Enum Laravel TypeScript Publisher Vite Plugin
99
+
100
+ The `@tolki/enum` package provides a Vite plugin to automatically watch for changes of the transformed PHP files by the [Laravel TypeScript Publisher](https://github.com/abetwothree/laravel-ts-publish) package.
101
+
102
+ The Laravel TypeScript Publisher package can publish a JSON file list of transformed PHP files. This Vite plugin uses that JSON file list to watch for changes in those PHP files and automatically call the `php artisan ts:publish` command to transform the changed PHP files into TypeScript files.
103
+
104
+ ## Usage
105
+
106
+ To use the Vite plugin, you need to add it to your Vite configuration file. Below is an example of how to add the plugin to your Vite configuration file:
107
+
108
+ ```javascript
109
+ import { defineConfig } from "vite";
110
+ import { laravelTsPublish } from "@tolki/enum";
111
+
112
+ export default defineConfig({
113
+ plugins: [laravelTsPublish()],
114
+ });
115
+ ```
116
+
117
+ ## Default Functionality
118
+
119
+ By default, the plugin will work in the following way:
120
+
121
+ 1. It will call `php artisan ts:publish` as the republish command when a file changes.
122
+ 2. It will look for the list of transformed PHP files here: `resources/js/types/laravel-ts-collected-files.json`.
123
+ 3. It will reload the page after you make any update to any of the transformed PHP files.
124
+ 4. It will call the publish command on `vite build` before bundling.
125
+ 5. It will throw an error if the publish command fails on `vite build`.
126
+
127
+ ## Plugin Options
128
+
129
+ The plugin accepts an options object to customize its behavior. It is recommended to use `.env` config settings to sync settings between the PHP side and the Vite plugin for the `filename` and `directory` options.
130
+
131
+ Below are the available options with a description and default values:
132
+
133
+ ```javascript
134
+ import { defineConfig } from "vite";
135
+ import { laravelTsPublish } from "@tolki/enum";
136
+
137
+ export default defineConfig({
138
+ plugins: [
139
+ laravelTsPublish({
140
+ /**
141
+ * The publish command to run when a watched PHP file changes.
142
+ *
143
+ * If you use Sail and run your Vite dev server inside the Sail container,
144
+ * you may need to change this command to `sail php artisan ts:publish`
145
+ * or `./vendor/bin/sail php artisan ts:publish` depending on your setup.
146
+ */
147
+ command: "php artisan ts:publish",
148
+ /**
149
+ * The filename of the JSON manifest listing collected PHP files.
150
+ */
151
+ filename: "laravel-ts-collected-files.json",
152
+ /**
153
+ * The directory where the JSON manifest file exists, relative to the Vite root.
154
+ */
155
+ directory: "resources/js/types/",
156
+ /**
157
+ * Whether to run the publish command once when `vite dev` starts.
158
+ *
159
+ * Has no effect during `vite build`.
160
+ */
161
+ runOnDevStart: false,
162
+ /**
163
+ * Whether to run the publish command once before bundling during `vite build`.
164
+ *
165
+ * Has no effect during `vite dev`.
166
+ */
167
+ runOnBuildStart: true,
168
+ /**
169
+ * Whether to trigger a full browser reload after the
170
+ * command runs successfully during `vite dev`.
171
+ *
172
+ * Has no effect during `vite build`.
173
+ */
174
+ reload: true,
175
+ /**
176
+ * Whether to throw an error (aborting the build) when the command fails.
177
+ *
178
+ * When not specified, defaults to `true` during `vite build`
179
+ * and `false` during `vite dev`.
180
+ *
181
+ * When specified, it will apply to both `vite dev` and `vite build`.
182
+ */
183
+ failOnError: undefined,
184
+ }),
185
+ ],
186
+ });
187
+ ```
188
+
189
+ <!-- AUTO-GENERATED-DOCS:END -->
@@ -0,0 +1,51 @@
1
+ import { CaseValue, DefineEnumResult, EnumConst, ToEnumResult } from '../../types/src/index.ts';
2
+ /**
3
+ * Creates an enum instance from a case value similar to PHP's `BackedEnum::from()`
4
+ *
5
+ * It will remove all the cases and make the matching case's value available as `value`
6
+ *
7
+ * All instance methods will be flattened from an object of case keys & values to a key/value pair for the matched case.
8
+ *
9
+ * The enumObj is the published enum from the Laravel TypeScript Publish package.
10
+ *
11
+ * @see https://github.com/abetwothree/laravel-ts-publish#enum-metadata--tolki-enum-package
12
+ *
13
+ * @param enumObj - The enum const object to resolve from.
14
+ * @param value - The case value to resolve. Must be one of the values defined in the enum const's cases.
15
+ * @returns The resolved enum case with its associated methods and properties for the value provided.
16
+ * @throws If the value does not match any case in the enum, an error is thrown.
17
+ */
18
+ export declare function from<TEnum extends EnumConst, const TValue extends CaseValue<TEnum>>(enumObj: TEnum, value: TValue): ToEnumResult<TEnum, TValue>;
19
+ /**
20
+ * Similar to the {@linkcode from | from} function but returns null instead of throwing an error for invalid values.
21
+ *
22
+ * Mirrors PHP's `BackedEnum::tryFrom()`.
23
+ *
24
+ * @param enumObj - The enum const object to resolve from.
25
+ * @param value - The case value to resolve.
26
+ * @returns The resolved enum case, or null if the value does not match any case.
27
+ */
28
+ export declare function tryFrom<TEnum extends EnumConst, const TValue extends CaseValue<TEnum>>(enumObj: TEnum, value: TValue): ToEnumResult<TEnum, TValue> | null;
29
+ /**
30
+ * Returns all enum cases as resolved instances by running each case value through the {@linkcode from | from} function.
31
+ *
32
+ * Mirrors PHP's `BackedEnum::cases()`, returning one resolved instance per case defined in the enum const.
33
+ *
34
+ * @param enumObj - The enum const object to resolve all cases from.
35
+ * @returns An array of resolved enum instances, one for each case.
36
+ */
37
+ export declare function cases<TEnum extends EnumConst>(enumObj: TEnum): Array<ToEnumResult<TEnum, CaseValue<TEnum>>>;
38
+ /**
39
+ * Factory function that creates an enriched enum object
40
+ *
41
+ * It automatically binds Tolki helper methods {@linkcode from | from}, {@linkcode tryFrom | tryFrom}, and {@linkcode cases | cases}.
42
+ *
43
+ * This allows your published enum to have PHP-like enum behavior with type safety and autocompletion in TypeScript.
44
+ *
45
+ * The original enum data is preserved and the PHP like enum methods are attached directly to the returned object.
46
+ *
47
+ * @param enumObj - The raw enum const object to enrich.
48
+ * @returns The enum object with `from`, `tryFrom`, and `cases` methods bound to it.
49
+ */
50
+ export declare function defineEnum<const TEnum extends EnumConst>(enumObj: TEnum): DefineEnumResult<TEnum>;
51
+ //# sourceMappingURL=enums.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../src/enums.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,YAAY,EACf,MAAM,cAAc,CAAC;AAEtB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,IAAI,CAChB,KAAK,SAAS,SAAS,EACvB,KAAK,CAAC,MAAM,SAAS,SAAS,CAAC,KAAK,CAAC,EACvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CA2C5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACnB,KAAK,SAAS,SAAS,EACvB,KAAK,CAAC,MAAM,SAAS,SAAS,CAAC,KAAK,CAAC,EACvC,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,GAAG,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,IAAI,CAMnE;AAED;;;;;;;GAOG;AACH,wBAAgB,KAAK,CAAC,KAAK,SAAS,SAAS,EACzC,OAAO,EAAE,KAAK,GACf,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAI9C;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,CAAC,KAAK,SAAS,SAAS,EACpD,OAAO,EAAE,KAAK,GACf,gBAAgB,CAAC,KAAK,CAAC,CA2BzB"}
package/dist/enums.js ADDED
@@ -0,0 +1,57 @@
1
+ function c(e, t) {
2
+ const n = new Set(e._cases);
3
+ let r;
4
+ for (const s of n)
5
+ if (e[s] === t) {
6
+ r = s;
7
+ break;
8
+ }
9
+ if (!r)
10
+ throw new Error(
11
+ `Value "${String(t)}" does not match any case in the enum. Cases: ${[...n].join(", ")}`
12
+ );
13
+ const o = { value: t }, h = new Set(e._methods), a = e._helpers, f = new Set(
14
+ Array.isArray(a) ? a : []
15
+ ), l = /* @__PURE__ */ new Set([
16
+ "_cases",
17
+ "_methods",
18
+ "_helpers",
19
+ "_static"
20
+ ]);
21
+ for (const [s, i] of Object.entries(e))
22
+ l.has(s) || n.has(s) || f.has(s) || (h.has(s) ? o[s] = i[r] : o[s] = i);
23
+ return o;
24
+ }
25
+ function y(e, t) {
26
+ try {
27
+ return c(e, t);
28
+ } catch {
29
+ return null;
30
+ }
31
+ }
32
+ function _(e) {
33
+ return e._cases.map(
34
+ (t) => c(e, e[t])
35
+ );
36
+ }
37
+ function p(e) {
38
+ const t = {
39
+ from: (r) => c(e, r),
40
+ tryFrom: (r) => y(e, r),
41
+ cases: () => _(e)
42
+ }, n = Object.keys(t);
43
+ return Object.assign(
44
+ /* @__PURE__ */ Object.create(null),
45
+ e,
46
+ t,
47
+ {
48
+ _helpers: n
49
+ }
50
+ );
51
+ }
52
+ export {
53
+ _ as cases,
54
+ p as defineEnum,
55
+ c as from,
56
+ y as tryFrom
57
+ };
@@ -0,0 +1,3 @@
1
+ export * from './enums';
2
+ export * from './vite-plugin';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ import { cases as o, defineEnum as m, from as f, tryFrom as s } from "./enums.js";
2
+ import { laravelTsPublish as l } from "./vite-plugin.js";
3
+ export {
4
+ o as cases,
5
+ m as defineEnum,
6
+ f as from,
7
+ l as laravelTsPublish,
8
+ s as tryFrom
9
+ };
@@ -0,0 +1,101 @@
1
+ import { Plugin } from 'vite';
2
+ export interface LaravelTsPublishOptions {
3
+ /**
4
+ * The command to run when a watched PHP file changes.
5
+ *
6
+ * @default "php artisan ts:publish"
7
+ */
8
+ command?: string;
9
+ /**
10
+ * The filename of the JSON manifest listing collected PHP files.
11
+ *
12
+ * @default "laravel-ts-collected-files.json"
13
+ */
14
+ filename?: string;
15
+ /**
16
+ * The directory where the JSON manifest file exists, relative to the Vite root.
17
+ *
18
+ * @default "resources/js/types/"
19
+ */
20
+ directory?: string;
21
+ /**
22
+ * Whether to run the publish command once when `vite dev` starts.
23
+ *
24
+ * Has no effect during `vite build`.
25
+ *
26
+ * @default false
27
+ */
28
+ runOnDevStart?: boolean;
29
+ /**
30
+ * Whether to run the publish command once before bundling during
31
+ * `vite build`.
32
+ *
33
+ * Has no effect during `vite dev`.
34
+ *
35
+ * @default true
36
+ */
37
+ runOnBuildStart?: boolean;
38
+ /**
39
+ * Whether to trigger a full browser reload after the command runs
40
+ * successfully during `vite dev`.
41
+ *
42
+ * Has no effect during `vite build`.
43
+ *
44
+ * @default true
45
+ */
46
+ reload?: boolean;
47
+ /**
48
+ * Whether to throw an error (aborting the build) when the command fails.
49
+ *
50
+ * When not specified, defaults to `true` during `vite build` and `false`
51
+ * during `vite dev`.
52
+ */
53
+ failOnError?: boolean;
54
+ }
55
+ /**
56
+ * Vite plugin that watches PHP source files listed in the Laravel TypeScript
57
+ * Publisher manifest and re-runs the publish command when any of them change.
58
+ *
59
+ * - **Build mode** (`vite build`): runs the command once before bundling so
60
+ * TypeScript definitions are always up-to-date (disable with
61
+ * `runOnBuildStart: false`). Fails the build by default if the command errors.
62
+ * - **Dev mode** (`vite dev`): loads the manifest, explicitly adds the listed
63
+ * PHP files to the dev-server file watcher, and re-runs the command when any
64
+ * of them change via HMR. Optionally runs the command once at startup when
65
+ * `runOnDevStart` is `true`. Sends a full browser reload after every
66
+ * successful run (disable with `reload: false`).
67
+ *
68
+ * @param options - Configuration options for the plugin.
69
+ * @returns A Vite plugin object.
70
+ *
71
+ * @example
72
+ * ```ts
73
+ * // vite.config.ts
74
+ * import { defineConfig } from "vite";
75
+ * import { laravelTsPublish } from "@tolki/enum";
76
+ *
77
+ * export default defineConfig({
78
+ * plugins: [
79
+ * laravelTsPublish(),
80
+ * ],
81
+ * });
82
+ * ```
83
+ *
84
+ * @example
85
+ * ```ts
86
+ * // With Laravel Sail
87
+ * laravelTsPublish({
88
+ * command: "sail artisan ts:publish",
89
+ * });
90
+ * ```
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * // Also run the command when the dev server starts
95
+ * laravelTsPublish({
96
+ * runOnDevStart: true,
97
+ * });
98
+ * ```
99
+ */
100
+ export declare function laravelTsPublish(options?: LaravelTsPublishOptions): Plugin;
101
+ //# sourceMappingURL=vite-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vite-plugin.d.ts","sourceRoot":"","sources":["../src/vite-plugin.ts"],"names":[],"mappings":"AAKA,OAAO,EAEH,KAAK,MAAM,EAGd,MAAM,MAAM,CAAC;AAId,MAAM,WAAW,uBAAuB;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;;;;;;OAOG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB;;;;;OAKG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4CG;AACH,wBAAgB,gBAAgB,CAC5B,OAAO,GAAE,uBAA4B,GACtC,MAAM,CA8LR"}
@@ -0,0 +1,99 @@
1
+ import { exec as O } from "node:child_process";
2
+ import { readFile as z } from "node:fs/promises";
3
+ import p from "node:path";
4
+ import { promisify as P } from "node:util";
5
+ import { normalizePath as c } from "vite";
6
+ const T = P(O);
7
+ function C(h = {}) {
8
+ const {
9
+ command: u = "php artisan ts:publish",
10
+ filename: w = "laravel-ts-collected-files.json",
11
+ directory: y = "resources/js/types/",
12
+ runOnDevStart: v = !1,
13
+ runOnBuildStart: $ = !0,
14
+ reload: b = !0,
15
+ failOnError: d
16
+ } = h;
17
+ let r, i;
18
+ const t = /* @__PURE__ */ new Set();
19
+ let s = "", l = !1, f = !1;
20
+ const a = "[laravel-ts-publish]", m = async () => {
21
+ t.clear();
22
+ try {
23
+ const e = await z(s, "utf-8"), o = JSON.parse(e);
24
+ for (const S of o) {
25
+ const F = c(p.resolve(r.root, S));
26
+ t.add(F);
27
+ }
28
+ } catch (e) {
29
+ if (e instanceof Error && e.code === "ENOENT") {
30
+ r.logger.warn(
31
+ `${a} Manifest not found: ${s}`
32
+ );
33
+ return;
34
+ }
35
+ r.logger.error(
36
+ `${a} Failed to read manifest: ${e instanceof Error ? e.message : String(e)}`
37
+ );
38
+ }
39
+ }, g = () => {
40
+ if (i)
41
+ for (const e of t)
42
+ i.watcher.add(e);
43
+ }, E = () => d !== void 0 ? d : r.command === "build", n = async () => {
44
+ if (l) {
45
+ f = !0;
46
+ return;
47
+ }
48
+ l = !0;
49
+ try {
50
+ r.logger.info(`${a} Running: ${u}`, {
51
+ timestamp: !0
52
+ }), await T(u, { cwd: r.root }), r.logger.info(`${a} Types published successfully`, {
53
+ timestamp: !0
54
+ }), b && i && i.ws.send({ type: "full-reload" });
55
+ } catch (e) {
56
+ const o = `${a} Command failed: ${e instanceof Error ? e.message : String(e)}`;
57
+ if (E())
58
+ throw new Error(o, { cause: e });
59
+ r.logger.error(o);
60
+ } finally {
61
+ l = !1, f && (f = !1, await n());
62
+ }
63
+ };
64
+ return {
65
+ name: "@tolki/vite-plugin-laravel-ts-publish",
66
+ enforce: "pre",
67
+ configResolved(e) {
68
+ r = e, s = c(
69
+ p.resolve(r.root, y, w)
70
+ );
71
+ },
72
+ configureServer(e) {
73
+ i = e;
74
+ },
75
+ async buildStart() {
76
+ if (r.command === "build") {
77
+ $ && await n();
78
+ return;
79
+ }
80
+ await m(), g(), t.size > 0 && r.logger.info(
81
+ `${a} Watching ${t.size} PHP file${t.size === 1 ? "" : "s"} for changes`,
82
+ { timestamp: !0 }
83
+ ), v && await n();
84
+ },
85
+ async handleHotUpdate({ file: e }) {
86
+ const o = c(e);
87
+ if (o === s)
88
+ return r.logger.info(
89
+ `${a} Manifest changed, reloading watched files`,
90
+ { timestamp: !0 }
91
+ ), await m(), g(), await n(), [];
92
+ if (t.has(o))
93
+ return await n(), [];
94
+ }
95
+ };
96
+ }
97
+ export {
98
+ C as laravelTsPublish
99
+ };
package/package.json ADDED
@@ -0,0 +1,62 @@
1
+ {
2
+ "name": "@tolki/enum",
3
+ "version": "0.0.0",
4
+ "description": "A set of enum utilities for the @tolki packages.",
5
+ "author": "Abraham Arango <https://github.com/abetwothree>",
6
+ "license": "MIT",
7
+ "homepage": "https://tolki.abe.dev/enums/",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/abetwothree/tolki.git",
11
+ "directory": "packages/enum"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/abetwothree/tolki/issues"
15
+ },
16
+ "main": "dist/index.js",
17
+ "type": "module",
18
+ "keywords": [
19
+ "enum",
20
+ "enums",
21
+ "laravel",
22
+ "utils",
23
+ "utilities"
24
+ ],
25
+ "dependencies": {
26
+ "@tolki/types": "^1.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "vite": "^7.0.0"
30
+ },
31
+ "sideEffects": false,
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "tolki": {
36
+ "docs": [
37
+ "enums/index.md",
38
+ "enums/enum-utilities-list.md",
39
+ "enums/enum-vite-plugin.md"
40
+ ]
41
+ },
42
+ "scripts": {
43
+ "build": "vite build",
44
+ "readme:build": "ts-node ../../scripts/readme-build.ts --filter @tolki/enum"
45
+ },
46
+ "types": "dist/index.d.ts",
47
+ "exports": {
48
+ ".": {
49
+ "import": "./dist/index.js",
50
+ "require": "./dist/index.js",
51
+ "types": "./dist/index.d.ts"
52
+ },
53
+ "./enums": {
54
+ "import": "./dist/enums/index.js",
55
+ "types": "./dist/enums/index.d.ts"
56
+ },
57
+ "./vite": {
58
+ "import": "./dist/vite-plugin/index.js",
59
+ "types": "./dist/vite-plugin/index.d.ts"
60
+ }
61
+ }
62
+ }