fuzor 0.0.1 → 0.2.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 (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +112 -0
  3. package/dist/cli.d.ts +3 -0
  4. package/dist/cli.d.ts.map +1 -0
  5. package/dist/cli.js +97 -0
  6. package/dist/cli.js.map +1 -0
  7. package/dist/compiler/index.d.ts +28 -0
  8. package/dist/compiler/index.d.ts.map +1 -0
  9. package/dist/compiler/index.js +184 -0
  10. package/dist/compiler/index.js.map +1 -0
  11. package/dist/compiler/islands.d.ts +17 -0
  12. package/dist/compiler/islands.d.ts.map +1 -0
  13. package/dist/compiler/islands.js +78 -0
  14. package/dist/compiler/islands.js.map +1 -0
  15. package/dist/create.d.ts +21 -0
  16. package/dist/create.d.ts.map +1 -0
  17. package/dist/create.js +111 -0
  18. package/dist/create.js.map +1 -0
  19. package/dist/index.d.ts +8 -8
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +6 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/islands/react.d.ts +8 -0
  24. package/dist/islands/react.d.ts.map +1 -0
  25. package/dist/islands/react.js +19 -0
  26. package/dist/islands/react.js.map +1 -0
  27. package/dist/islands/solid.d.ts +8 -0
  28. package/dist/islands/solid.d.ts.map +1 -0
  29. package/dist/islands/solid.js +15 -0
  30. package/dist/islands/solid.js.map +1 -0
  31. package/dist/islands/vue.d.ts +5 -0
  32. package/dist/islands/vue.d.ts.map +1 -0
  33. package/dist/islands/vue.js +13 -0
  34. package/dist/islands/vue.js.map +1 -0
  35. package/dist/runtime/atom.d.ts +10 -0
  36. package/dist/runtime/atom.d.ts.map +1 -0
  37. package/dist/runtime/atom.js +38 -0
  38. package/dist/runtime/atom.js.map +1 -0
  39. package/dist/runtime/index.d.ts +31 -0
  40. package/dist/runtime/index.d.ts.map +1 -0
  41. package/dist/runtime/index.js +121 -0
  42. package/dist/runtime/index.js.map +1 -0
  43. package/dist/runtime/islands.d.ts +6 -0
  44. package/dist/runtime/islands.d.ts.map +1 -0
  45. package/dist/runtime/islands.js +43 -0
  46. package/dist/runtime/islands.js.map +1 -0
  47. package/dist/ssr/node.d.ts +7 -0
  48. package/dist/ssr/node.d.ts.map +1 -0
  49. package/dist/ssr/node.js +46 -0
  50. package/dist/ssr/node.js.map +1 -0
  51. package/dist/ssr.d.ts +10 -0
  52. package/dist/ssr.d.ts.map +1 -0
  53. package/dist/ssr.js +19 -0
  54. package/dist/ssr.js.map +1 -0
  55. package/dist/vite.d.ts +8 -0
  56. package/dist/vite.d.ts.map +1 -0
  57. package/dist/vite.js +310 -0
  58. package/dist/vite.js.map +1 -0
  59. package/package.json +71 -56
  60. package/templates/basic/README.md +16 -0
  61. package/templates/basic/_gitignore +3 -0
  62. package/templates/basic/components/app-badge.html +1 -0
  63. package/templates/basic/index.html +12 -0
  64. package/templates/basic/islands/counter.ts +13 -0
  65. package/templates/basic/package.json +20 -0
  66. package/templates/basic/pages/about/index.html +5 -0
  67. package/templates/basic/pages/docs/index.md +9 -0
  68. package/templates/basic/pages/index.html +9 -0
  69. package/templates/basic/pages/layout.html +8 -0
  70. package/templates/basic/pnpm-workspace.yaml +5 -0
  71. package/templates/basic/server.mjs +10 -0
  72. package/templates/basic/style.css +1 -0
  73. package/templates/basic/tsconfig.json +13 -0
  74. package/templates/basic/vite.config.ts +4 -0
  75. package/bin/index.js +0 -13
  76. package/dist/core/init.d.ts +0 -7
  77. package/dist/core/router.d.ts +0 -4
  78. package/dist/core/vite-config.d.ts +0 -5
  79. package/dist/init.cjs +0 -237
  80. package/dist/init.js +0 -468
  81. package/dist/lib.cjs +0 -222
  82. package/dist/lib.js +0 -19247
  83. package/dist/render/lit.d.ts +0 -1
  84. package/dist/render/preact.d.ts +0 -1
  85. package/dist/render/react.d.ts +0 -7
  86. package/dist/render/solid.d.ts +0 -1
  87. package/dist/render/svelte.d.ts +0 -6
  88. package/dist/render/vue.d.ts +0 -1
  89. package/dist/utils/create-file-if-not-exists.d.ts +0 -1
  90. package/dist/utils/create-folder-if-not-exist.d.ts +0 -2
  91. package/dist/utils/default-theme-files.d.ts +0 -7
  92. package/dist/utils/file-path-helpers.d.ts +0 -3
  93. package/dist/utils/is-valid-wordpress-slug.d.ts +0 -17
  94. package/dist/utils/read-write-file.d.ts +0 -1
  95. package/dist/utils/remove-file-exists.d.ts +0 -2
  96. package/dist/utils/remove-trailing-slash-url.d.ts +0 -1
  97. package/dist/utils/router-helpers.d.ts +0 -19
  98. package/dist/utils/zip-wp-theme.d.ts +0 -2
  99. package/types/index.d.ts +0 -6
package/dist/init.js DELETED
@@ -1,468 +0,0 @@
1
- import { getWpNowConfig as j, startServer as x } from "@wp-now/wp-now";
2
- import s from "node:path";
3
- import $, { access as S, mkdir as T, readFile as E, writeFile as y, unlink as O } from "node:fs/promises";
4
- import g from "@parcel/watcher";
5
- import k from "fast-glob";
6
- async function I(t) {
7
- try {
8
- try {
9
- await S(t);
10
- } catch {
11
- await T(t, { recursive: !0 });
12
- }
13
- } catch (e) {
14
- console.error(e);
15
- }
16
- }
17
- async function P(t, e = "") {
18
- try {
19
- await $.access(t);
20
- } catch (a) {
21
- if (a instanceof Error && a.code === "ENOENT")
22
- await $.writeFile(t, e, { flag: "wx" });
23
- else
24
- throw console.error(
25
- `Error checking or creating file: ${a instanceof Error ? a.message : a}`
26
- ), a;
27
- }
28
- }
29
- async function w(t, e) {
30
- try {
31
- const a = await E(t, "utf8");
32
- await y(e, a);
33
- } catch (a) {
34
- console.error("Error:", a);
35
- }
36
- }
37
- const u = [
38
- ".html",
39
- ".jsx",
40
- ".tsx",
41
- ".svelte",
42
- ".vue",
43
- ".css"
44
- ];
45
- async function f(t, e) {
46
- try {
47
- const a = `${t}/**/*.{${u.map((i) => i.slice(1)).join(",")}}`, n = {
48
- pages: (await k(a, { dot: !0 })).map((i) => ({
49
- path: s.basename(i, s.extname(i)),
50
- type: "create"
51
- }))
52
- };
53
- await y(e, JSON.stringify(n, null, 2)), console.log(`JSON saved to ${e}`);
54
- } catch (a) {
55
- console.error("Error creating JSON:", a);
56
- }
57
- }
58
- async function R(t, e) {
59
- try {
60
- const a = await E(e, "utf-8"), r = JSON.parse(a), l = s.basename(t, s.extname(t));
61
- r.pages = r.pages.filter((n) => n.path !== l), await y(e, JSON.stringify(r, null, 2)), console.log(
62
- `Entry with path "${l}" has been removed from ${e}`
63
- );
64
- } catch (a) {
65
- console.error("Error deleting entry from JSON:", a);
66
- }
67
- }
68
- const v = (t, e) => t.includes(s.join(s.sep, e, s.sep)), b = async (t) => {
69
- const e = s.basename(t.path);
70
- v(t.path, "pages") && await w(
71
- s.resolve(t.path),
72
- s.resolve(c, "theme", "templates", e)
73
- ), v(t.path, "components") && await w(
74
- s.resolve(t.path),
75
- s.resolve(c, "theme", "parts", e)
76
- );
77
- }, N = async (t, e) => {
78
- switch (t.type) {
79
- case "create":
80
- console.log("create"), await b(t), await f(d, p);
81
- break;
82
- case "update":
83
- console.log("update"), e && (await b(t), await f(d, p));
84
- break;
85
- case "delete":
86
- console.log("delete"), await R(t.path, p);
87
- break;
88
- }
89
- };
90
- async function J() {
91
- (await g.getEventsSince(h, m)).filter(
92
- (a) => u.some((r) => a.path.endsWith(r))
93
- ).forEach((a) => {
94
- console.log("since"), N(a, !1);
95
- }), await g.subscribe(
96
- h,
97
- (a, r) => {
98
- if (a) {
99
- console.error("Error watching files:", a);
100
- return;
101
- }
102
- r.filter(
103
- (n) => u.some((i) => n.path.endsWith(i))
104
- ).forEach((n) => {
105
- N(n, !0);
106
- });
107
- },
108
- { ignore: ["node_modules"] }
109
- ), await g.writeSnapshot(h, m);
110
- }
111
- const F = () => `== theme ==
112
-
113
- Contributors: fuzia
114
- Requires at least: 6.7
115
- Tested up to: 6.7
116
- Requires PHP: 5.7
117
- License: GPLv2 or later
118
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
119
-
120
-
121
- == Description ==
122
-
123
- blank theme
124
-
125
-
126
- == Changelog ==
127
-
128
- = 1.0.0 =
129
- * Initial release
130
-
131
-
132
- == Copyright ==
133
-
134
- theme WordPress Theme, (C) 2025 fuzia
135
- theme is distributed under the terms of the GNU GPL.
136
-
137
- This program is free software: you can redistribute it and/or modify
138
- it under the terms of the GNU General Public License as published by
139
- the Free Software Foundation, either version 2 of the License, or
140
- (at your option) any later version.
141
-
142
- This program is distributed in the hope that it will be useful,
143
- but WITHOUT ANY WARRANTY; without even the implied warranty of
144
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
145
- GNU General Public License for more details.`, U = () => `/*
146
- Theme Name: theme
147
- Theme URI:
148
- Author: fuzia
149
- Author URI:
150
- Description: blank theme
151
- Requires at least: 6.7
152
- Tested up to: 6.7
153
- Requires PHP: 5.7
154
- Version:
155
- License: GNU General Public License v2 or later
156
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
157
- Text Domain: theme
158
- Tags:
159
- */`, A = `{
160
- "settings": {
161
- "appearanceTools": true,
162
- "layout": {
163
- "contentSize": "620px",
164
- "wideSize": "1000px"
165
- },
166
- "spacing": {
167
- "units": [
168
- "%",
169
- "px",
170
- "em",
171
- "rem",
172
- "vh",
173
- "vw"
174
- ]
175
- },
176
- "typography": {
177
- "fontFamilies": [
178
- {
179
- "fontFamily": "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif",
180
- "name": "System Font",
181
- "slug": "system-font"
182
- }
183
- ]
184
- },
185
- "useRootPaddingAwareAlignments": true
186
- },
187
- "templateParts": [
188
- {
189
- "area": "header",
190
- "name": "header"
191
- },
192
- {
193
- "area": "footer",
194
- "name": "footer"
195
- }
196
- ],
197
- "version": 3,
198
- "$schema": "https://schemas.wp.org/wp/6.7/theme.json"
199
- }`, C = `<?php
200
- // Flag to prevent recursive execution
201
- $prevent_recursive_execution = false;
202
-
203
- function create_or_update_or_delete_pages_from_json() {
204
- global $prevent_recursive_execution;
205
-
206
- // Prevent recursive execution
207
- if ($prevent_recursive_execution) {
208
- return;
209
- }
210
-
211
- // Path to the JSON file
212
- $json_file = get_template_directory() . '/pages.json';
213
-
214
- // Check if the file exists
215
- if (file_exists($json_file)) {
216
- // Read the JSON file
217
- $json_data = file_get_contents($json_file);
218
- $pages = json_decode($json_data, true)['pages'];
219
-
220
- // Initialize an array to store pages that are not deleted
221
- $updated_pages = [];
222
-
223
- // Get all pages from the database
224
- $all_pages = get_pages(array(
225
- 'post_status' => 'any'
226
- ));
227
-
228
- // Check if $all_pages is an array
229
- if (is_array($all_pages)) {
230
- // Create an array of slugs for all pages in the database
231
- $db_page_slugs = array_map(function($page) {
232
- return $page->post_name;
233
- }, $all_pages);
234
- } else {
235
- $db_page_slugs = [];
236
- }
237
-
238
- // Loop through the pages array
239
- foreach ($pages as $page) {
240
- $page_slug = $page['path'];
241
- $page_type = $page['type'];
242
-
243
- // Use WP_Query to find the page by slug
244
- $query = new WP_Query(array(
245
- 'post_type' => 'page',
246
- 'name' => $page_slug,
247
- 'post_status' => 'any',
248
- 'posts_per_page' => 1,
249
- 'no_found_rows' => true,
250
- 'ignore_sticky_posts' => true,
251
- 'update_post_term_cache' => false,
252
- 'update_post_meta_cache' => false,
253
- ));
254
-
255
- $page_check = !empty($query->posts) ? $query->posts[0] : null;
256
-
257
- if ($page_type === 'create') {
258
- // If the page exists, update it
259
- if ($page_check) {
260
- $page_id = $page_check->ID;
261
- $my_post = array(
262
- 'ID' => $page_id,
263
- 'post_title' => ucfirst(str_replace('-', ' ', $page_slug)),
264
- 'post_name' => $page_slug,
265
- 'post_status' => 'publish',
266
- 'post_author' => 1,
267
- 'post_type' => 'page',
268
- 'page_template' => $page_slug
269
- );
270
-
271
- // Update the post in the database
272
- wp_update_post($my_post);
273
- } else {
274
- // If the page doesn't exist, create it
275
- $my_post = array(
276
- 'post_title' => ucfirst(str_replace('-', ' ', $page_slug)),
277
- 'post_name' => $page_slug,
278
- 'post_status' => 'publish',
279
- 'post_author' => 1,
280
- 'post_type' => 'page',
281
- 'page_template' => $page_slug
282
- );
283
-
284
- // Insert the post into the database
285
- wp_insert_post($my_post);
286
- }
287
-
288
- // Add the page to the updated pages array
289
- $updated_pages[] = $page;
290
- } elseif ($page_type === 'delete' && $page_check) {
291
- // If the page exists and the type is 'delete', delete it
292
- wp_delete_post($page_check->ID, true);
293
-
294
- // Remove the "create" entry of the deleted page
295
- $updated_pages = array_filter($updated_pages, function($p) use ($page_slug) {
296
- return $p['path'] !== $page_slug;
297
- });
298
- }
299
- }
300
-
301
- // Update the JSON file with the remaining pages
302
- $new_json_data = json_encode(['pages' => $updated_pages], JSON_PRETTY_PRINT);
303
- file_put_contents($json_file, $new_json_data);
304
- }
305
- }
306
-
307
- // Hook the function to the 'init' action
308
- add_action('init', 'create_or_update_or_delete_pages_from_json');
309
-
310
- // Function to remove page from JSON before deletion
311
- function remove_page_from_json_before_delete($post_id) {
312
- global $prevent_recursive_execution;
313
-
314
- // Check if the post type is 'page'
315
- if (get_post_type($post_id) !== 'page') {
316
- return;
317
- }
318
-
319
- // Path to the JSON file
320
- $json_file = get_template_directory() . '/pages.json';
321
-
322
- // Check if the file exists
323
- if (file_exists($json_file)) {
324
- // Read the JSON file
325
- $json_data = file_get_contents($json_file);
326
- $pages = json_decode($json_data, true)['pages'];
327
-
328
- // Get the slug of the page being deleted
329
- $page_slug = get_post_field('post_name', $post_id);
330
-
331
- // Remove the page entry from the JSON data
332
- $updated_pages = array_filter($pages, function($page) use ($page_slug) {
333
- return $page['path'] !== $page_slug;
334
- });
335
-
336
- // Update the JSON file with the remaining pages
337
- $new_json_data = json_encode(['pages' => array_values($updated_pages)], JSON_PRETTY_PRINT);
338
- file_put_contents($json_file, $new_json_data);
339
-
340
- // Set the flag to prevent recursive execution
341
- $prevent_recursive_execution = true;
342
- }
343
- }
344
-
345
- // Hook the function to the 'wp_trash_post' and 'wp_delete_post' actions
346
- add_action('wp_trash_post', 'remove_page_from_json_before_delete', 10, 1);
347
- add_action('wp_delete_post', 'remove_page_from_json_before_delete', 10, 1);`;
348
- async function D(t) {
349
- try {
350
- await S(t), await O(t);
351
- } catch (e) {
352
- e instanceof Error && e.code === "ENOENT" || console.error(`Error checking or removing file "${t}":`, e);
353
- }
354
- }
355
- const _ = process.cwd(), c = s.resolve(_, "__dev"), d = s.resolve(_, "src", "pages"), h = s.resolve(_, "src"), o = s.resolve(c, "theme"), p = s.resolve(o, "pages.json"), m = s.resolve(
356
- c,
357
- "cache",
358
- "snapshot.txt"
359
- ), L = [
360
- /* {
361
- type: "del",
362
- path: snapshotTXTPath,
363
- }, */
364
- {
365
- type: "del",
366
- path: p
367
- },
368
- {
369
- type: "dir",
370
- path: c
371
- },
372
- {
373
- type: "dir",
374
- path: o
375
- },
376
- {
377
- type: "file",
378
- path: p,
379
- content: JSON.stringify({})
380
- },
381
- {
382
- type: "dir",
383
- path: s.resolve(o, "parts")
384
- },
385
- {
386
- type: "dir",
387
- path: s.resolve(o, "templates")
388
- },
389
- {
390
- type: "dir",
391
- path: s.resolve(c, "cache")
392
- },
393
- {
394
- type: "file",
395
- path: m,
396
- content: ""
397
- },
398
- {
399
- type: "file",
400
- path: s.resolve(_, "src", "theme.json"),
401
- content: A
402
- },
403
- {
404
- type: "file",
405
- path: s.resolve(o, "readme.txt"),
406
- content: F()
407
- },
408
- {
409
- type: "file",
410
- path: s.resolve(o, "style.css"),
411
- content: U()
412
- },
413
- {
414
- type: "file",
415
- path: s.resolve(o, "functions.php"),
416
- content: C
417
- }
418
- ];
419
- async function B() {
420
- for await (const e of L)
421
- switch (e.type) {
422
- case "dir":
423
- await I(e.path);
424
- break;
425
- case "file":
426
- await P(e.path, e.content);
427
- break;
428
- case "del":
429
- await D(e.path);
430
- break;
431
- }
432
- await f(d, p);
433
- const t = await j({
434
- path: o
435
- /* blueprintObject: {
436
- steps: [
437
- {
438
- step: "defineWpConfigConsts",
439
- consts: {
440
- WP_HOME: "http://localhost:8881",
441
- WP_SITEURL: "http://localhost:8881",
442
- WP_LOCAL_DEV: true,
443
- },
444
- },
445
- ],
446
- }, */
447
- });
448
- await x(t);
449
- try {
450
- await J();
451
- } catch (e) {
452
- if (e instanceof Error && e.message === "ENOENT")
453
- console.error("Error executing wp-start:", e.message);
454
- else
455
- throw console.error(
456
- `Error checking or creating file: ${e instanceof Error ? e.message : e}`
457
- ), e;
458
- }
459
- }
460
- export {
461
- c as devDirPath,
462
- B as init,
463
- d as pagesDir,
464
- p as pagesJSON,
465
- m as snapshotTXTPath,
466
- h as srcDir,
467
- o as themeDir
468
- };