sveltekit-temporal 0.3.0 → 0.5.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/README.md CHANGED
@@ -1,21 +1,19 @@
1
1
  # sveltekit-temporal
2
2
 
3
- Think about it, temporal may be supported in big 3 wrosers soon, but your users may bit update for some time.
3
+ Think about it, temporal may be supported in big 3 browsers soon, but your users may not update for some time.
4
4
 
5
- One-shot CLI that wires the Temporal API polyfill into a SvelteKit project, with conditional loading so browsers that ship Temporal natively (Chrome 144+, Firefox 139+) and server runtimes that do too (Node.js 26+) pay zero bytes.
5
+ This One-shot CLI that wires the Temporal API polyfill into a SvelteKit project, with conditional loading so browsers that ship Temporal natively (Chrome 144+, Firefox 139+) and server runtimes that do too (Node.js 26+) pay zero bytes.
6
6
 
7
7
 
8
8
  ## Usage
9
9
 
10
10
  ## Using with the Svelte CLI (`sv add`)
11
11
 
12
- If you prefer the official Svelte CLI, this package also works as an `sv` add-on:
12
+ This package also works as an `sv` add-on:
13
13
 
14
14
  ```bash
15
- # Or when creating a new project
16
- npx sv create my-app
17
- cd my-app
18
- npx sv add sveltekit-temporal
15
+ # When creating a new project
16
+ npx sv create my-app --add sveltekit-temporal
19
17
 
20
18
  # Into an existing project
21
19
  npx sv add sveltekit-temporal
@@ -28,15 +26,14 @@ Run it inside a SvelteKit project. It will:
28
26
 
29
27
  1. Verify you're in a SvelteKit project (checks `svelte` + `@sveltejs/kit` in `package.json`).
30
28
  2. Detect TypeScript (presence of `tsconfig.json` or `src/app.d.ts`).
31
- 3. Detect your package manager from lockfiles (`bun.lock`, `pnpm-lock.yaml`, `yarn.lock`, else npm).
32
- 4. Prompt you to choose a polyfill:
29
+ 3. Prompt you to choose a polyfill:
33
30
  - **`@js-temporal/polyfill`** — official, ~100 KB gzipped, spec-conservative.
34
31
  - **`temporal-polyfill`** — smaller (~40 KB gzipped), same API.
35
- 5. Install the chosen package.
36
- 6. Create / update the following files:
32
+ 4. Install the chosen package.
33
+ 5. Create / update the following files:
37
34
  - `src/lib/temporal.{ts,js}` — the conditional bootstrap module.
38
35
  - `src/routes/+layout.{ts,js}` — prepends `import '$lib/temporal'` (preserves existing content).
39
- - `src/hooks.server.{ts,js}` — same import for server-side.
36
+ - `src/hooks.server.{ts,js}` — add commented out example import for server-side.
40
37
  - `src/app.d.ts` — adds global `Temporal` type and `Date.toTemporalInstant()` augmentation (TypeScript only).
41
38
 
42
39
  ## Idempotency
@@ -49,9 +46,9 @@ Re-running is safe. Files written by the script are tagged with a `// sveltekit-
49
46
 
50
47
  ## Usage in your app
51
48
 
52
- After running, reference `Temporal` directly anywhere — no imports needed:
49
+ After running, reference `Temporal` directly anywhere — no imports needed and guaranteed to work.
53
50
 
54
- ```svelte
51
+ ```js
55
52
  <script lang="ts">
56
53
  const today = Temporal.Now.plainDateISO();
57
54
  const inAWeek = today.add({ days: 7 });
@@ -62,11 +59,11 @@ After running, reference `Temporal` directly anywhere — no imports needed:
62
59
 
63
60
  ## Server hooks (only if needed)
64
61
 
65
- If you use Temporal inside `hooks.server.ts` or `+server.ts` endpoints that might run before any layout, add the import there as well:
62
+ If you use Temporal inside `hooks.server.ts` or `+server.ts` endpoints that might run before any layout, uncomment the import there as well:
66
63
 
67
64
  `src/hooks.server.ts`:
68
65
  ```ts
69
- import '$lib/temporal';
66
+ // import '$lib/temporal';
70
67
 
71
68
  export async function handle({ event, resolve }) {
72
69
  return resolve(event);
package/dist/addon.js CHANGED
@@ -86,7 +86,10 @@ function escapeRegex(s) {
86
86
  var options = defineAddonOptions().add("polyfill", {
87
87
  question: "Which Temporal polyfill would you like to use?",
88
88
  type: "select",
89
- options: ["@js-temporal/polyfill", "temporal-polyfill"],
89
+ options: [
90
+ { value: "@js-temporal/polyfill", label: "@js-temporal/polyfill", hint: "Official TC39 polyfill, ~100KB gzipped, spec-conservative" },
91
+ { value: "temporal-polyfill", label: "temporal-polyfill", hint: "Smaller (~40KB gzipped) by Adam Shaw, same API surface" }
92
+ ],
90
93
  default: "@js-temporal/polyfill"
91
94
  }).build();
92
95
  var addon_default = defineAddon({
@@ -112,7 +115,7 @@ ${content}`
112
115
  );
113
116
  sv.file(
114
117
  `${directory.src}/hooks.server.${ext}`,
115
- (content) => content.includes("import '$lib/temporal'") ? false : `import '$lib/temporal';
118
+ (content) => content.includes("import '$lib/temporal'") ? false : `// import '$lib/temporal';
116
119
  ${content}`
117
120
  );
118
121
  if (isTs) {
package/dist/index.js CHANGED
@@ -806,7 +806,7 @@ async function run() {
806
806
  const layoutPath = join(cwd, "src", "routes", `+layout.${ext}`);
807
807
  ensureImportInFile(layoutPath, "import '$lib/temporal';", { created, updated, skipped });
808
808
  const hooksPath = join(cwd, "src", `hooks.server.${ext}`);
809
- ensureImportInFile(hooksPath, "import '$lib/temporal';", { created, updated, skipped });
809
+ ensureImportInFile(hooksPath, "// import '$lib/temporal';", { created, updated, skipped });
810
810
  if (isTypeScript) {
811
811
  const dtsPath = join(cwd, "src", "app.d.ts");
812
812
  updateAppDts(dtsPath, polyfill.pkg, { created, updated, skipped });
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "sveltekit-temporal",
3
3
  "author": "Scott Rhamy",
4
- "version": "0.3.0",
4
+ "version": "0.5.0",
5
5
  "description": "Set up the Temporal API polyfill in a SvelteKit project with conditional loading on client and server.",
6
6
  "type": "module",
7
7
  "exports": {