prisma-php 0.0.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.
@@ -0,0 +1,434 @@
1
+ # PulsePoint: always read the official docs before generating code
2
+
3
+ > Purpose: eliminate guessing and make AI-generated PulsePoint code accurate, copy-pasteable, and aligned with the real runtime.
4
+ >
5
+ > Scope: this document covers the **core PulsePoint runtime** only — browser-side state, effects, refs, and markup directives. It does **not** assume any specific backend or server framework.
6
+ >
7
+ > Official docs: [https://pulsepoint.tsnc.tech/llms](https://pulsepoint.tsnc.tech/llms)
8
+ >
9
+ > Version: 3.0.0
10
+
11
+ ---
12
+
13
+ ## Read the PulsePoint docs first
14
+
15
+ Before generating, editing, or reviewing any PulsePoint code, read the official PulsePoint docs:
16
+
17
+ ```txt
18
+ https://pulsepoint.tsnc.tech/llms
19
+ ```
20
+
21
+ Treat the PulsePoint docs as the source of truth for:
22
+
23
+ - supported runtime APIs
24
+ - supported directives and markup behavior
25
+ - syntax rules
26
+ - state and effect patterns
27
+ - ref usage
28
+ - limitations and forbidden patterns
29
+
30
+ Do not rely on assumptions from React, Vue, Alpine, Svelte, Livewire, jQuery, or any other framework.
31
+
32
+ If the docs do not show a feature or API, do **not** invent it.
33
+
34
+ ---
35
+
36
+ ## Prisma PHP integration rule
37
+
38
+ When PulsePoint is used inside a Prisma PHP application, the default full-stack pattern is:
39
+
40
+ - PulsePoint for reactive browser state and UI updates
41
+ - `pp.fetchFunction(...)` for frontend-to-PHP server calls
42
+ - `#[Exposed]` on PHP functions or methods that the frontend should be allowed to call
43
+ - `PP\Validator` on the PHP side for authoritative input validation and normalization
44
+
45
+ Do not invent parallel client/server patterns when the built-in Prisma PHP RPC flow already fits the task. In typical Prisma PHP page work, prefer PulsePoint plus `pp.fetchFunction(...)` over ad hoc API wiring.
46
+
47
+ Use `route.php` only when you explicitly need a standalone endpoint such as a webhook, public JSON route, external integration endpoint, or other no-view handler.
48
+
49
+ ## Validation boundary
50
+
51
+ PulsePoint can help with local UX such as:
52
+
53
+ - showing inline hints
54
+ - disabling submit buttons
55
+ - rendering field-level error messages
56
+ - debouncing live validation requests
57
+
58
+ But the final validation still belongs on the PHP side.
59
+
60
+ In Prisma PHP, the default boundary is:
61
+
62
+ - **PulsePoint** for local UI state and feedback
63
+ - **`pp.fetchFunction(...)`** for sending data to PHP
64
+ - **`PP\Validator`** for authoritative backend validation
65
+
66
+ Do not present browser-only checks as the final source of truth.
67
+
68
+ ---
69
+
70
+ ## What PulsePoint is responsible for
71
+
72
+ PulsePoint is the **browser-side reactive runtime**.
73
+
74
+ It is responsible for UI interactivity such as:
75
+
76
+ - local reactive state
77
+ - reactive effects
78
+ - DOM refs
79
+ - list rendering
80
+ - attribute spreading
81
+ - simple interactive bindings
82
+
83
+ PulsePoint is **not** the backend.
84
+
85
+ That means an AI agent must keep these concerns separate:
86
+
87
+ - **PulsePoint docs** decide how frontend runtime code should be written.
88
+ - **Project/backend docs** decide how data is loaded, validated, saved, authenticated, or routed on the server.
89
+
90
+ ---
91
+
92
+ ## Allowed runtime surface
93
+
94
+ Only use the runtime surface explicitly allowed here unless the official docs say otherwise.
95
+
96
+ ### Core JavaScript API
97
+
98
+ 1. `pp.state<T>(initial)` → `[state, setState]`
99
+ 2. `pp.ref<T>(initial: T | null)`
100
+ 3. `pp.effect(fn: () => void | (() => void), deps?: Dependency[])`
101
+
102
+ ### Markup directives
103
+
104
+ 1. `pp-for` _(only on `<template>`)_
105
+ 2. `pp-spread`
106
+ 3. `pp-ref`
107
+
108
+ If a symbol is not listed above and is not documented in the official PulsePoint docs, treat it as unsupported.
109
+
110
+ ---
111
+
112
+ ## Decision rules for AI agents
113
+
114
+ When working with PulsePoint, follow these rules:
115
+
116
+ 1. Read the official PulsePoint docs before making runtime decisions.
117
+ 2. Do not invent undocumented helpers, directives, lifecycle APIs, or magic globals.
118
+ 3. Keep backend assumptions out of PulsePoint-only examples.
119
+ 4. Prefer simple, explicit patterns over framework-inspired abstractions.
120
+ 5. Generate code that is valid immediately, not pseudo-code.
121
+ 6. When uncertain, reduce scope to documented PulsePoint primitives.
122
+ 7. If a project also includes framework-specific rules, apply them **after** the PulsePoint docs for backend concerns, but keep PulsePoint runtime syntax aligned with the official PulsePoint docs.
123
+
124
+ ---
125
+
126
+ ## Priority order
127
+
128
+ When generating code that uses PulsePoint, use this order of truth:
129
+
130
+ 1. The user’s explicit request
131
+ 2. The official PulsePoint docs: `https://pulsepoint.tsnc.tech/llms`
132
+ 3. Project-specific agent rules or local project docs
133
+ 4. Existing project code and structure
134
+ 5. General framework knowledge
135
+
136
+ If any assumption conflicts with the official PulsePoint docs, follow the PulsePoint docs.
137
+
138
+ ---
139
+
140
+ ## File layout rules
141
+
142
+ For PulsePoint runtime code, keep a predictable layout:
143
+
144
+ 1. HTML markup first
145
+ 2. One `<script>` block at the bottom
146
+
147
+ Example:
148
+
149
+ ```html
150
+ <ul>
151
+ <template pp-for="user in users">
152
+ <li key="{user.id}">{user.name}</li>
153
+ </template>
154
+ </ul>
155
+
156
+ <script>
157
+ const [users, setUsers] = pp.state([
158
+ { id: 1, name: "Alice" },
159
+ { id: 2, name: "Bob" },
160
+ ]);
161
+ </script>
162
+ ```
163
+
164
+ Rules:
165
+
166
+ - Use **exactly one** `<script>` block per page or component unless the project explicitly requires something else.
167
+ - Place the script block **after** the markup.
168
+ - JavaScript should only reference data that already exists when the script runs.
169
+ - Do not scatter PulsePoint runtime logic across multiple disconnected script blocks unless the docs or project structure explicitly requires it.
170
+
171
+ ---
172
+
173
+ ## Conditionals and booleans
174
+
175
+ Prefer visibility toggles instead of complex conditional markup.
176
+
177
+ ### Preferred
178
+
179
+ ```html
180
+ <div hidden="{!isOpen}">Shown when open</div>
181
+ <div hidden="{isOpen}">Shown when closed</div>
182
+ ```
183
+
184
+ ### Text or attribute ternaries
185
+
186
+ ```html
187
+ <span class="{isActive ? 'text-green-600' : 'text-red-600'}">
188
+ {isActive ? 'Active' : 'Inactive'}
189
+ </span>
190
+ ```
191
+
192
+ ### Boolean attributes
193
+
194
+ ```html
195
+ <input type="checkbox" checked="{isActive}" />
196
+ ```
197
+
198
+ String branches in ternaries must be quoted correctly.
199
+
200
+ - Correct: `{isActive ? 'text-blue-500' : 'text-gray-500'}`
201
+ - Invalid: `{isActive ? text-blue-500' : 'text-gray-500'}`
202
+
203
+ ---
204
+
205
+ ## Refs with `pp-ref`
206
+
207
+ ### Single element ref
208
+
209
+ ```html
210
+ <input type="text" pp-ref="{nameInput}" />
211
+ <button onclick="nameInput.current?.focus()">Focus</button>
212
+
213
+ <script>
214
+ const nameInput = pp.ref(null);
215
+ </script>
216
+ ```
217
+
218
+ ### Dynamic ref registration
219
+
220
+ ```html
221
+ <ul>
222
+ <template pp-for="item in items">
223
+ <li key="{item.id}">
224
+ <input pp-ref="{registerRef(item.id)}" hidden="{editingId !== item.id}" />
225
+ <button onclick="setEditingId(item.id)">Edit</button>
226
+ </li>
227
+ </template>
228
+ </ul>
229
+
230
+ <script>
231
+ const [items, setItems] = pp.state([
232
+ { id: 1, name: "Task A" },
233
+ { id: 2, name: "Task B" },
234
+ ]);
235
+ const [editingId, setEditingId] = pp.state(null);
236
+
237
+ const itemRefs = new Map();
238
+
239
+ const registerRef = (id) => (el) => {
240
+ if (el) itemRefs.set(id, el);
241
+ else itemRefs.delete(id);
242
+ };
243
+
244
+ pp.effect(() => {
245
+ if (editingId && itemRefs.has(editingId)) {
246
+ itemRefs.get(editingId).focus();
247
+ }
248
+ }, [editingId]);
249
+ </script>
250
+ ```
251
+
252
+ Rules:
253
+
254
+ - Initialize refs with `pp.ref(null)`.
255
+ - Null-check ref access where appropriate.
256
+ - Use refs for DOM access and imperative behavior, not as general reactive state storage.
257
+
258
+ ---
259
+
260
+ ## Spread with `pp-spread`
261
+
262
+ ### Basic usage
263
+
264
+ ```html
265
+ <button pp-spread="{...btn}">Submit</button>
266
+
267
+ <script>
268
+ const [btn] = pp.state({
269
+ class: "px-3 py-2 rounded-md",
270
+ "aria-label": "submit",
271
+ });
272
+ </script>
273
+ ```
274
+
275
+ ### Multiple spreads
276
+
277
+ ```html
278
+ <input pp-spread="{...base, ...validation}" placeholder="Name" />
279
+
280
+ <script>
281
+ const [base] = pp.state({ class: "input-base", required: true });
282
+ const [validation] = pp.state({ pattern: "[A-Za-z]+" });
283
+ </script>
284
+ ```
285
+
286
+ Rules:
287
+
288
+ - Later spreads override earlier spreads.
289
+ - Explicit attributes on the element override spread values.
290
+
291
+ ---
292
+
293
+ ## Lists with `pp-for`
294
+
295
+ ```html
296
+ <ul>
297
+ <template pp-for="todo in todos">
298
+ <li key="{todo.id}">
299
+ {todo.title}
300
+ <button onclick="removeTodo(todo.id)">Remove</button>
301
+ </li>
302
+ </template>
303
+ </ul>
304
+
305
+ <script>
306
+ const [todos, setTodos] = pp.state([
307
+ { id: 1, title: "First task" },
308
+ { id: 2, title: "Second task" },
309
+ ]);
310
+
311
+ function removeTodo(id) {
312
+ setTodos(todos.filter((item) => item.id !== id));
313
+ }
314
+ </script>
315
+ ```
316
+
317
+ Rules:
318
+
319
+ - Use `pp-for` only on `<template>`.
320
+ - Always use stable keys such as IDs or stable indices.
321
+ - Never use random keys.
322
+ - Prefer immutable updates through setters.
323
+
324
+ ---
325
+
326
+ ## Effects with `pp.effect`
327
+
328
+ ```html
329
+ <script>
330
+ pp.effect(() => console.log("Any change"));
331
+
332
+ pp.effect(() => {
333
+ return () => {
334
+ // cleanup
335
+ };
336
+ }, []);
337
+
338
+ const [count, setCount] = pp.state(0);
339
+
340
+ pp.effect(() => {
341
+ console.log("count", count);
342
+ }, [count]);
343
+ </script>
344
+ ```
345
+
346
+ Rules:
347
+
348
+ - Use `[]` for one-time setup and cleanup.
349
+ - Use dependency arrays to react to specific state changes.
350
+ - Avoid unconditional setter calls inside effects.
351
+ - Guard effect-driven updates to prevent loops.
352
+
353
+ ---
354
+
355
+ ## Input binding patterns
356
+
357
+ ### Checkbox
358
+
359
+ ```html
360
+ <input
361
+ type="checkbox"
362
+ checked="{isActive}"
363
+ onchange="setIsActive(event.target.checked)"
364
+ />
365
+
366
+ <script>
367
+ const [isActive, setIsActive] = pp.state(false);
368
+ </script>
369
+ ```
370
+
371
+ ### Text input
372
+
373
+ ```html
374
+ <input type="text" value="{name}" oninput="setName(event.target.value)" />
375
+
376
+ <script>
377
+ const [name, setName] = pp.state("");
378
+ </script>
379
+ ```
380
+
381
+ Rules:
382
+
383
+ - Inputs should read from state.
384
+ - Inputs should write back through explicit setters.
385
+ - Avoid mixing manual DOM querying with reactive state for the same value.
386
+
387
+ ---
388
+
389
+ ## Forbidden patterns
390
+
391
+ Do not generate these unless the official PulsePoint docs explicitly document them:
392
+
393
+ 1. Undocumented runtime APIs
394
+ 2. Undocumented directives
395
+ 3. `pp-for` on non-`<template>` elements
396
+ 4. Random keys in rendered lists
397
+ 5. Multiple scattered script blocks for normal PulsePoint pages
398
+ 6. Direct DOM mutation for stateful UI that should be reactive
399
+ 7. Backend-specific assumptions in PulsePoint-only snippets
400
+ 8. Syntax copied from another framework without PulsePoint documentation support
401
+
402
+ ---
403
+
404
+ ## How AI should respond when PulsePoint is involved
405
+
406
+ When a user asks for PulsePoint code, the AI should:
407
+
408
+ 1. Check the official PulsePoint docs first.
409
+ 2. Keep the solution inside documented PulsePoint primitives.
410
+ 3. Separate frontend PulsePoint behavior from backend implementation details.
411
+ 4. Avoid claiming a PulsePoint feature exists unless the docs support it.
412
+ 5. Prefer working examples that are ready to paste into a project.
413
+
414
+ A good PulsePoint answer should feel:
415
+
416
+ - minimal
417
+ - explicit
418
+ - backend-agnostic when appropriate
419
+ - syntactically valid
420
+ - faithful to the documented runtime
421
+
422
+ ---
423
+
424
+ ## Final reminder
425
+
426
+ If you are generating, reviewing, or refactoring PulsePoint code, do **not** guess.
427
+
428
+ Read the official docs first:
429
+
430
+ ```txt
431
+ https://pulsepoint.tsnc.tech/llms
432
+ ```
433
+
434
+ Then generate code using documented PulsePoint behavior only.