prisma-php 0.0.8 → 0.0.9

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.
@@ -2,31 +2,48 @@
2
2
 
3
3
  ## Purpose
4
4
 
5
- This file describes the PulsePoint runtime that is actually implemented in the current TypeScript source of this repo. Use it as the working contract for AI-generated code.
5
+ This file describes the PulsePoint runtime that is actually implemented in the current TypeScript source of this repo. Treat it as the working contract for AI-generated code.
6
6
 
7
- If `src/` is available, read it first. If the app only exposes a plain HTML page plus a minified or bundled runtime loaded by a script tag, inspect those artifacts instead and follow the same behavior. Do not assume React, Vue, Svelte, or older PulsePoint docs.
7
+ Do not assume React, Vue, Svelte, JSX, or older PulsePoint docs.
8
8
 
9
- ## What the runtime actually does
9
+ ## Runtime shape
10
10
 
11
- PulsePoint is a browser-side component runtime. It renders HTML, binds state and events, and morphs the DOM in place.
11
+ PulsePoint is a browser-side component runtime. It executes one component script per root, renders HTML from the component scope, morphs the DOM in place, binds native event handlers, restores focus, and runs hook effects.
12
12
 
13
13
  A component root is any element with `pp-component`.
14
14
 
15
+ Important:
16
+
17
+ - In the current source, `pp-component` behaves like an instance id, not a reusable component class name.
18
+ - State, scope, template caching, parent tracking, and instance lookup are all keyed by that attribute.
19
+ - Generate unique `pp-component` values per mounted instance. Reusing the same value for multiple live roots can replace or destroy the previous instance.
20
+
15
21
  ## Component roots and scripts
16
22
 
17
23
  - Each component root may contain one inline `<script>` block for component logic.
18
- - Keep that `<script>` inside the same `pp-component` root. Do not leave it as a sibling after the root element.
24
+ - The runtime looks for that script inside the current root and ignores scripts inside nested component roots.
25
+ - Plain `<script>` is not the component-script contract in the current TypeScript source.
19
26
  - The script is plain JavaScript, not a module. Do not use `import` or `export` inside it.
20
- - Top-level bindings from the script are exported automatically to the template. Do not manually `return { ... }`.
21
- - Top-level `const`, `let`, `function`, and supported destructuring patterns become template bindings.
27
+ - Do not manually `return { ... }`. The runtime auto-exports supported top-level bindings.
22
28
  - `pp.props` contains the current prop bag for the component.
23
- - `children` contains the component's initial inner HTML.
24
- - Nested `pp-component` roots are boundaries and are not flattened by a parent component.
29
+ - `children` is injected into props and contains the root's initial inner HTML.
30
+
31
+ Bindings that are exported to the template:
32
+
33
+ - Top-level function declarations.
34
+ - Top-level identifier declarations such as `const title = ...`.
35
+ - Top-level object destructuring identifiers such as `const { title, subtitle } = pp.props`.
36
+ - Top-level array destructuring from `pp.state(...)`, such as `const [count, setCount] = pp.state(0)`.
37
+
38
+ Bindings that should not be assumed:
39
+
40
+ - Generic top-level array destructuring is not auto-exported unless it comes from `pp.state(...)`.
41
+ - Nested declarations inside functions, conditions, loops, and callbacks are not auto-exported.
25
42
 
26
43
  Example:
27
44
 
28
45
  ```html
29
- <div pp-component="counter-card">
46
+ <div pp-component="counter-card-1">
30
47
  <h2>{title}</h2>
31
48
  <p>Count: {count}</p>
32
49
  <button onclick="setCount(count + 1)">Increment</button>
@@ -34,7 +51,6 @@ Example:
34
51
  <script>
35
52
  const { title } = pp.props;
36
53
  const [count, setCount] = pp.state(0);
37
- const doubled = count * 2;
38
54
 
39
55
  function reset() {
40
56
  setCount(0);
@@ -43,32 +59,104 @@ Example:
43
59
  </div>
44
60
  ```
45
61
 
46
- ## Hooks exposed through `pp`
62
+ ## Hooks and runtime API
63
+
64
+ Hooks exposed inside component scripts through `pp`:
47
65
 
48
66
  - `pp.state(initial)` returns `[value, setValue]`.
49
- - `pp.effect(callback, deps?)` runs after render and can return cleanup.
50
- - `pp.layoutEffect(callback, deps?)` runs synchronously after DOM mutation.
67
+ - `pp.effect(callback, deps?)` runs after render and may return a cleanup function.
68
+ - `pp.layoutEffect(callback, deps?)` runs synchronously after DOM mutation and may return a cleanup function.
51
69
  - `pp.ref(initialValue?)` returns `{ current }`.
52
70
  - `pp.memo(factory, deps)` memoizes a computed value.
53
71
  - `pp.callback(callback, deps)` memoizes a function.
54
72
  - `pp.reducer(reducer, initialState)` returns `[state, dispatch]`.
73
+ - `pp.context(token)` resolves a provided context value from ancestor components.
74
+ - `pp.provideContext(token, value)` provides a context value to descendant components.
55
75
  - `pp.portal(ref, target?)` portals a ref-managed element into a target.
56
76
  - `pp.props` exposes the current props.
57
77
 
78
+ Runtime helpers exposed through the global `pp` utility object:
79
+
80
+ - `pp.createContext(defaultValue)` creates a context token.
81
+ - `pp.mount()` bootstraps the runtime.
82
+ - `pp.redirect(url)` performs SPA-aware navigation when enabled.
83
+ - `pp.fetchFunction(name, data?, optionsOrAbort?)` performs the runtime RPC/fetch bridge.
84
+ - `pp.enablePerf()` enables render timing collection.
85
+ - `pp.disablePerf()` disables render timing collection.
86
+ - `pp.getPerfStats()` returns collected render timings.
87
+ - `pp.resetPerfStats()` clears collected render timings.
88
+
58
89
  Notes:
59
90
 
60
91
  - `pp.state` setters accept either a value or an updater function.
61
- - `pp.effect` and `pp.layoutEffect` use dependency arrays like React, but only the hooks listed here exist.
92
+ - `pp.effect` and `pp.layoutEffect` behave like cleanup-style hooks. Do not rely on returned promises being awaited.
93
+ - `pp.mount()` should be called once. Do not manually instantiate `Component`.
62
94
  - Keep template-facing bindings at the top level so the AST-based exporter can see them.
63
95
 
96
+ ## Context
97
+
98
+ Context is implemented in the current source. Do not document it as unsupported.
99
+
100
+ How it works:
101
+
102
+ - Create a token with `pp.createContext(defaultValue)`.
103
+ - Provide a value from a component with `pp.provideContext(token, value)`.
104
+ - Read it in a descendant component with `pp.context(token)`.
105
+ - Resolution walks the component parent chain and falls back to `token.defaultValue` when no provider exists.
106
+ - Descendant consumers are refreshed when a provider value changes or the provider is destroyed.
107
+
108
+ Important:
109
+
110
+ - The same token object must be shared between provider and consumer.
111
+ - In this runtime, context is component-level, not directive-based. There is no `pp-context` attribute.
112
+ - If components are isolated in separate script blocks, pass the token through props or store it in a shared outer scope.
113
+
114
+ Example:
115
+
116
+ ```html
117
+ <section pp-component="theme-provider-1">
118
+ <div pp-component="theme-label-1" theme-token="{ThemeContext}">
119
+ <p>{theme}</p>
120
+
121
+ <script>
122
+ const { themeToken } = pp.props;
123
+ const theme = pp.context(themeToken);
124
+ </script>
125
+ </div>
126
+
127
+ <script>
128
+ const ThemeContext = pp.createContext("light");
129
+ const [theme] = pp.state("dark");
130
+
131
+ pp.provideContext(ThemeContext, theme);
132
+ </script>
133
+ </section>
134
+ ```
135
+
136
+ ## Props and nested components
137
+
138
+ - Child component props are derived from DOM attributes.
139
+ - Attribute names are converted from kebab-case to camelCase for the prop bag.
140
+ - Pure prop expressions such as `title="{pageTitle}"` are evaluated in the parent scope.
141
+ - Mixed strings such as `class="card {isActive ? 'active' : ''}"` are interpolated in the parent scope.
142
+ - Empty attributes become boolean `true` props.
143
+
144
+ Nested components:
145
+
146
+ - Nested `pp-component` roots are treated as component boundaries during DOM reconciliation.
147
+ - Nested roots with their own `<script>` are also masked during parent template compilation.
148
+ - Scriptless nested component roots are bootstrapped, but they are not fully masked during parent template compilation in the current source. Avoid generating child-local interpolations inside a nested root unless that child has its own `<script>`.
149
+
64
150
  ## Template expressions and attributes
65
151
 
66
152
  - Use `{expression}` in text nodes and attribute values.
67
153
  - Pure bindings like `value="{count}"` are evaluated as expressions.
68
154
  - Mixed text like `class="card {isActive ? 'active' : ''}"` is supported.
69
- - Boolean attributes are normalized for supported boolean names.
155
+ - Arrays in template expressions are joined without commas.
156
+ - `null`, `undefined`, and boolean expression results render as an empty string.
157
+ - Boolean attributes are normalized for the supported attribute names implemented by the runtime.
70
158
  - Use `pp-spread="{...attrs}"` to spread one object expression into attributes.
71
- - Use plain `key` for keyed diffing. `pp-key` is not implemented in the current source.
159
+ - Use plain `key` for keyed diffing. `pp-key` is not implemented.
72
160
 
73
161
  Example:
74
162
 
@@ -80,6 +168,7 @@ Example:
80
168
  class: "btn btn-primary",
81
169
  "aria-label": "save",
82
170
  };
171
+
83
172
  const isLoading = false;
84
173
  </script>
85
174
  ```
@@ -87,15 +176,16 @@ Example:
87
176
  ## Refs
88
177
 
89
178
  - Use `pp-ref="nameInput"` when the value is a ref object or callback already in scope.
90
- - Use `pp-ref="{registerRef(id)}"` when you need a dynamic expression.
179
+ - Use `pp-ref="{registerRef(id)}"` when you want the compiled template to capture a dynamic ref expression.
91
180
  - `pp.ref(null)` is the normal way to create a ref object.
181
+ - Callback refs and `{ current }` refs are both supported.
92
182
  - The runtime generates `data-pp-ref` internally. Do not author it.
93
183
  - Do not author `pp-event-owner`, `pp-owner`, or `pp-dynamic-*` attributes by hand.
94
184
 
95
185
  Example:
96
186
 
97
187
  ```html
98
- <div pp-component="focus-box">
188
+ <div pp-component="focus-box-1">
99
189
  <input pp-ref="nameInput" />
100
190
  <button onclick="nameInput.current?.focus()">Focus</button>
101
191
 
@@ -105,14 +195,15 @@ Example:
105
195
  </div>
106
196
  ```
107
197
 
108
- ## Lists and loops
198
+ ## Lists and keyed diffing
109
199
 
110
200
  - Use `pp-for` only on `<template>`.
111
201
  - Supported forms are `item in items` and `(item, index) in items`.
112
202
  - The collection must be an array. Non-arrays are treated as empty lists.
113
203
  - Loop content can contain interpolations, events, refs, and nested components.
204
+ - Event handlers inside loops are rewritten so loop variables still resolve after rerender.
114
205
  - Use stable unique `key` values on repeated elements.
115
- - Duplicate keys can trigger warnings, so do not use random keys.
206
+ - Duplicate keys trigger warnings and reduce diff quality.
116
207
 
117
208
  Example:
118
209
 
@@ -155,34 +246,30 @@ Example:
155
246
  - `pp-loading-transition` accepts JSON with `fadeIn` and `fadeOut` timing values.
156
247
  - `pp-reset-scroll="true"` resets scroll positions during navigation.
157
248
 
158
- The runtime also exposes navigation and bridge helpers through `pp`:
159
-
160
- - `pp.mount()`
161
- - `pp.redirect(url)`
162
- - `pp.fetchFunction(name, data?, optionsOrAbort?)`
163
- - `pp.enablePerf()`
164
- - `pp.disablePerf()`
165
- - `pp.getPerfStats()`
166
- - `pp.resetPerfStats()`
167
-
168
249
  Notes:
169
250
 
170
- - `pp.redirect()` uses SPA navigation when it is enabled and the URL is same-origin; otherwise it falls back to normal navigation.
171
- - `pp.fetchFunction()` is the runtime RPC bridge. It posts to the current route, attaches the wire headers the backend expects, and can switch to FormData for files, report upload progress, abort the previous request, or stream responses when supported.
172
- - The bundle mounts the runtime automatically once the global `pp` singleton is accessed after DOMContentLoaded, but `pp.mount()` exists if you want to trigger it explicitly.
251
+ - `pp.redirect()` uses SPA navigation when enabled and the URL is same-origin. Otherwise it falls back to normal navigation.
252
+ - `pp.fetchFunction()` posts to the current route and supports aborting previous requests, upload progress, and streamed responses when available.
253
+ - `pp.mount()` bootstraps every `[pp-component]` it finds, so AI-generated code should call it once and let the runtime manage nested components.
173
254
 
174
- ## Plain HTML bundle usage
255
+ ## AI rules
175
256
 
176
- When the app is shipped as plain HTML plus a minified bundle:
257
+ Use these rules when generating or editing PulsePoint code:
177
258
 
178
- - Keep the component markup in the HTML.
179
- - Load the bundle with a script tag after the markup or with `defer`.
180
- - Keep component logic inside `<script>` blocks in the HTML.
181
- - Do not assume access to the TypeScript source at runtime.
259
+ - Use the current TypeScript source when it is available.
260
+ - Generate unique `pp-component` values per live instance.
261
+ - Use only `<script>` for component logic.
262
+ - Keep template-facing variables at top level.
263
+ - Use `pp.createContext`, `pp.context`, and `pp.provideContext` for context. Do not invent `pp-context`.
264
+ - Keep `pp-for` on `<template>` and use plain `key`.
265
+ - Use native `on*` attributes, not framework-specific event syntax.
266
+ - Use refs and portals only through the implemented `pp` APIs.
267
+ - Avoid generating internal runtime attributes.
268
+ - Avoid scriptless nested components when the child template contains its own bindings.
182
269
 
183
270
  ## What to avoid
184
271
 
185
- Do not generate these unless the current source explicitly supports them:
272
+ Do not generate these unless the current source explicitly adds support:
186
273
 
187
274
  - `pp-context`
188
275
  - `pp-key`
@@ -192,21 +279,18 @@ Do not generate these unless the current source explicitly supports them:
192
279
  - `pp-dynamic-script`
193
280
  - `pp-dynamic-meta`
194
281
  - `pp-dynamic-link`
195
- - component logic `<script>` blocks outside a `pp-component` root
196
- - React, Vue, Svelte, or JSX-style component patterns that are not implemented here
282
+ - plain `<script>` for component logic inside a component root
283
+ - React, Vue, Svelte, or JSX-only patterns that are not implemented here
197
284
  - made-up hooks, directives, or globals not present in the current TypeScript source
198
285
 
199
- ## AI checklist
286
+ ## Review notes
200
287
 
201
- When working on PulsePoint code, follow this order:
288
+ These are current runtime caveats that matter for authors and AI tools:
202
289
 
203
- - Use the current TypeScript source when it is available.
204
- - If only HTML plus a minified bundle exists, inspect those artifacts and follow the runtime behavior implemented there.
205
- - Keep template-facing variables at the top level of the component script.
206
- - Use only the hooks, directives, and attributes listed above.
207
- - Keep `pp-for` on `<template>` and use plain `key`.
208
- - Use refs and events as implemented, not as they work in another framework.
209
- - Avoid generating internal runtime attributes.
290
+ - `pp-component` is currently used as the registry key for instances, state, parent tracking, and templates. Treat it as unique per mounted root.
291
+ - Nested roots without their own `<script>` are not fully isolated during parent template compilation.
292
+ - `pp.mount()` boots every root in the document. Call it once and avoid manual component construction.
293
+ - `pp.effect` and `pp.layoutEffect` are cleanup-style hooks. Their callbacks are not promise-aware.
210
294
 
211
295
  ## Final reminder
212
296
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prisma-php",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "description": "Prisma PHP tooling",
5
5
  "main": "index.js",
6
6
  "scripts": {