@pithyjs/core 0.1.0-beta.1 → 0.1.0-beta.11
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 +12 -6
- package/dist/a11y/focus-trap.d.ts.map +1 -1
- package/dist/a11y/focus-trap.js +2 -0
- package/dist/a11y/focus-trap.js.map +1 -1
- package/dist/a11y/index.d.ts +4 -4
- package/dist/a11y/index.js +4 -4
- package/dist/a11y/index.js.map +1 -1
- package/dist/a11y/keyboard-utils.js.map +1 -1
- package/dist/a11y/roving-tabindex.js.map +1 -1
- package/dist/a11y/skip-link.js.map +1 -1
- package/dist/compile/bindSwitchCases.d.ts +8 -3
- package/dist/compile/bindSwitchCases.d.ts.map +1 -1
- package/dist/compile/bindSwitchCases.js +114 -181
- package/dist/compile/bindSwitchCases.js.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.d.ts +1 -0
- package/dist/compile/binds/bindBoundAttributes.d.ts.map +1 -1
- package/dist/compile/binds/bindBoundAttributes.js +47 -2
- package/dist/compile/binds/bindBoundAttributes.js.map +1 -1
- package/dist/compile/binds/bindClassDirectives.d.ts +3 -2
- package/dist/compile/binds/bindClassDirectives.d.ts.map +1 -1
- package/dist/compile/binds/bindClassDirectives.js +53 -18
- package/dist/compile/binds/bindClassDirectives.js.map +1 -1
- package/dist/compile/binds/bindComponentsTags.d.ts +2 -0
- package/dist/compile/binds/bindComponentsTags.d.ts.map +1 -1
- package/dist/compile/binds/bindComponentsTags.js +86 -46
- package/dist/compile/binds/bindComponentsTags.js.map +1 -1
- package/dist/compile/binds/bindConditionals.d.ts +2 -2
- package/dist/compile/binds/bindConditionals.d.ts.map +1 -1
- package/dist/compile/binds/bindConditionals.js +22 -5
- package/dist/compile/binds/bindConditionals.js.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.d.ts.map +1 -1
- package/dist/compile/binds/bindDefaultTwoWay.js +2 -1
- package/dist/compile/binds/bindDefaultTwoWay.js.map +1 -1
- package/dist/compile/binds/bindDeferDirectives.js +4 -4
- package/dist/compile/binds/bindDeferDirectives.js.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.d.ts.map +1 -1
- package/dist/compile/binds/bindErrorBoundary.js +8 -3
- package/dist/compile/binds/bindErrorBoundary.js.map +1 -1
- package/dist/compile/binds/bindEventHandlers.js +2 -2
- package/dist/compile/binds/bindEventHandlers.js.map +1 -1
- package/dist/compile/binds/bindRefDirectives.js.map +1 -1
- package/dist/compile/binds/bindStyleDirectives.d.ts +17 -0
- package/dist/compile/binds/bindStyleDirectives.d.ts.map +1 -0
- package/dist/compile/binds/bindStyleDirectives.js +47 -0
- package/dist/compile/binds/bindStyleDirectives.js.map +1 -0
- package/dist/compile/binds/bindTextInterpolations.d.ts +2 -1
- package/dist/compile/binds/bindTextInterpolations.d.ts.map +1 -1
- package/dist/compile/binds/bindTextInterpolations.js +55 -17
- package/dist/compile/binds/bindTextInterpolations.js.map +1 -1
- package/dist/compile/binds/directiveRegistry.js.map +1 -1
- package/dist/compile/binds/forwardedAttrs.js.map +1 -1
- package/dist/compile/binds/propNames.d.ts +14 -0
- package/dist/compile/binds/propNames.d.ts.map +1 -0
- package/dist/compile/binds/propNames.js +116 -0
- package/dist/compile/binds/propNames.js.map +1 -0
- package/dist/compile/compileExpression.js.map +1 -1
- package/dist/compile/compileNodes.d.ts.map +1 -1
- package/dist/compile/compileNodes.js +6 -3
- package/dist/compile/compileNodes.js.map +1 -1
- package/dist/compile/compileTemplate.d.ts +3 -4
- package/dist/compile/compileTemplate.d.ts.map +1 -1
- package/dist/compile/compileTemplate.js +28 -31
- package/dist/compile/compileTemplate.js.map +1 -1
- package/dist/compile/componentResult.js.map +1 -1
- package/dist/compile/contentProjection.d.ts +1 -1
- package/dist/compile/contentProjection.d.ts.map +1 -1
- package/dist/compile/contentProjection.js +32 -15
- package/dist/compile/contentProjection.js.map +1 -1
- package/dist/compile/forLoops/bindForLoops.d.ts +2 -2
- package/dist/compile/forLoops/bindForLoops.d.ts.map +1 -1
- package/dist/compile/forLoops/bindForLoops.js +9 -22
- package/dist/compile/forLoops/bindForLoops.js.map +1 -1
- package/dist/compile/forLoops/createLoopManager.d.ts +3 -3
- package/dist/compile/forLoops/createLoopManager.d.ts.map +1 -1
- package/dist/compile/forLoops/createLoopManager.js +40 -38
- package/dist/compile/forLoops/createLoopManager.js.map +1 -1
- package/dist/compile/forLoops/index.d.ts +5 -5
- package/dist/compile/forLoops/index.js +5 -5
- package/dist/compile/forLoops/index.js.map +1 -1
- package/dist/compile/forLoops/loopHelpers.d.ts +6 -0
- package/dist/compile/forLoops/loopHelpers.d.ts.map +1 -1
- package/dist/compile/forLoops/loopHelpers.js +17 -0
- package/dist/compile/forLoops/loopHelpers.js.map +1 -1
- package/dist/compile/forLoops/loopSignals.js +2 -2
- package/dist/compile/forLoops/loopSignals.js.map +1 -1
- package/dist/compile/forLoops/loopTraversal.js +2 -2
- package/dist/compile/forLoops/loopTraversal.js.map +1 -1
- package/dist/compile/handleConditionalChain.d.ts +2 -2
- package/dist/compile/handleConditionalChain.d.ts.map +1 -1
- package/dist/compile/handleConditionalChain.js +22 -87
- package/dist/compile/handleConditionalChain.js.map +1 -1
- package/dist/compile/index.d.ts +17 -17
- package/dist/compile/index.js +14 -14
- package/dist/compile/index.js.map +1 -1
- package/dist/compile/injectScopedStyle.js.map +1 -1
- package/dist/compile/nodeExpando.d.ts +6 -0
- package/dist/compile/nodeExpando.d.ts.map +1 -1
- package/dist/compile/nodeExpando.js.map +1 -1
- package/dist/compile/parseHtml.d.ts.map +1 -1
- package/dist/compile/parseHtml.js +2 -2
- package/dist/compile/parseHtml.js.map +1 -1
- package/dist/compile/pithyTreeToDom.js +1 -1
- package/dist/compile/pithyTreeToDom.js.map +1 -1
- package/dist/compile/renderBranch.d.ts +13 -0
- package/dist/compile/renderBranch.d.ts.map +1 -0
- package/dist/compile/renderBranch.js +65 -0
- package/dist/compile/renderBranch.js.map +1 -0
- package/dist/compile/renderChildren.d.ts +2 -2
- package/dist/compile/renderChildren.js +2 -2
- package/dist/compile/renderChildren.js.map +1 -1
- package/dist/compile/ssrCrashes.d.ts +1 -1
- package/dist/compile/ssrCrashes.js +3 -3
- package/dist/compile/ssrCrashes.js.map +1 -1
- package/dist/compile/ssrMode.js +1 -1
- package/dist/compile/ssrMode.js.map +1 -1
- package/dist/compile/textValue.js.map +1 -1
- package/dist/compile/trimBlankEdges.d.ts +2 -0
- package/dist/compile/trimBlankEdges.d.ts.map +1 -0
- package/dist/compile/trimBlankEdges.js +15 -0
- package/dist/compile/trimBlankEdges.js.map +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +6 -6
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/interfaces/index.js +2 -2
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/ref-signal.interface.js.map +1 -1
- package/dist/interfaces/ref.interface.js.map +1 -1
- package/dist/runtime/applyBindings.d.ts +3 -3
- package/dist/runtime/applyBindings.d.ts.map +1 -1
- package/dist/runtime/applyBindings.js +74 -22
- package/dist/runtime/applyBindings.js.map +1 -1
- package/dist/runtime/bindings/applyComponent.d.ts +2 -2
- package/dist/runtime/bindings/applyComponent.d.ts.map +1 -1
- package/dist/runtime/bindings/applyComponent.js +41 -32
- package/dist/runtime/bindings/applyComponent.js.map +1 -1
- package/dist/runtime/bindings/applyDefer.d.ts +1 -1
- package/dist/runtime/bindings/applyDefer.js +6 -6
- package/dist/runtime/bindings/applyDefer.js.map +1 -1
- package/dist/runtime/bindings/applySimple.d.ts +1 -1
- package/dist/runtime/bindings/applySimple.d.ts.map +1 -1
- package/dist/runtime/bindings/applySimple.js +45 -13
- package/dist/runtime/bindings/applySimple.js.map +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts +1 -1
- package/dist/runtime/bindings/applyStructural.d.ts.map +1 -1
- package/dist/runtime/bindings/applyStructural.js +58 -68
- package/dist/runtime/bindings/applyStructural.js.map +1 -1
- package/dist/runtime/bindings/helpers.d.ts +1 -1
- package/dist/runtime/bindings/helpers.js +1 -1
- package/dist/runtime/bindings/helpers.js.map +1 -1
- package/dist/runtime/bindings/index.d.ts +6 -6
- package/dist/runtime/bindings/index.d.ts.map +1 -1
- package/dist/runtime/bindings/index.js +5 -5
- package/dist/runtime/bindings/index.js.map +1 -1
- package/dist/runtime/bindings/types.js.map +1 -1
- package/dist/runtime/bootstrap.d.ts +1 -1
- package/dist/runtime/bootstrap.js +1 -1
- package/dist/runtime/bootstrap.js.map +1 -1
- package/dist/runtime/createContextProxy.js.map +1 -1
- package/dist/runtime/deferHelpers.d.ts +1 -1
- package/dist/runtime/deferHelpers.js.map +1 -1
- package/dist/runtime/html.d.ts.map +1 -1
- package/dist/runtime/html.js +6 -5
- package/dist/runtime/html.js.map +1 -1
- package/dist/runtime/index.d.ts +6 -6
- package/dist/runtime/index.js +6 -6
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/lazy.js +1 -1
- package/dist/runtime/lazy.js.map +1 -1
- package/dist/runtime/module-cache.js.map +1 -1
- package/dist/runtime/onDestroy.d.ts +7 -0
- package/dist/runtime/onDestroy.d.ts.map +1 -1
- package/dist/runtime/onDestroy.js +16 -1
- package/dist/runtime/onDestroy.js.map +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js +1 -1
- package/dist/runtime/parseIdentifiersFromTemplate.js.map +1 -1
- package/dist/runtime/resource/createAction.d.ts +1 -1
- package/dist/runtime/resource/createAction.js +1 -1
- package/dist/runtime/resource/createAction.js.map +1 -1
- package/dist/runtime/resource/createResource.d.ts +1 -1
- package/dist/runtime/resource/createResource.d.ts.map +1 -1
- package/dist/runtime/resource/createResource.js +3 -4
- package/dist/runtime/resource/createResource.js.map +1 -1
- package/dist/runtime/resource/engine.d.ts +1 -1
- package/dist/runtime/resource/engine.js.map +1 -1
- package/dist/runtime/resource/index.d.ts +3 -3
- package/dist/runtime/resource/index.js +2 -2
- package/dist/runtime/resource/index.js.map +1 -1
- package/dist/runtime/resource/types.js.map +1 -1
- package/dist/types/globals.d.ts +2 -2
- package/dist/types/globals.js.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.d.ts +2 -2
- package/dist/utilities/index.js +2 -2
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/ref-signal.utility.d.ts +1 -1
- package/dist/utilities/ref-signal.utility.js.map +1 -1
- package/dist/utilities/ref.untility.d.ts +1 -1
- package/dist/utilities/ref.untility.js.map +1 -1
- package/package.json +11 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../../src/runtime/resource/engine.ts"],"names":[],"mappings":"AAAA;;;;;;;EAOE;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAe,MAAM,kBAAkB,CAAC;AAG9D;;;;;GAKG;AACH,gLAAgL;AAChL,8EAA8E;AAC9E,6EAA6E;AAC7E,4CAA4C;AAC5C,MAAM,CAAC,MAAM,OAAO,GAClB,MAAM,CAAC,MAAM,CAAC;IACZ,EAAE,EAAE,KAAK;IACT,OAAO,EAAE,IAAI;CACd,CAAmD,CAAC;AA6CvD;;;;;;;GAOG;AACH,+LAA+L;AAC/L,MAAM,UAAU,iBAAiB,CAC/B,OAA2B;IAE3B,MAAM,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC;IAErC,MAAM,IAAI,GAAG,MAAM,CAAgB,SAAS,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,MAAM,CAAgB,SAAS,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,MAAM,CAAiB,MAAM,CAAC,CAAC;IAE9C;;;;OAIG;IACH,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,IAAI,UAAU,GAA2B,IAAI,CAA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ACd,IAAI,SAAS;YAAE,OAAO;QACtB,SAAS,GAAG,IAAI,CAAC;QACjB,uEAAuE;QACvE,4DAA4D;QAC5D,mEAAmE;QACnE,kEAAkE;QAClE,mEAAmE;QACnE,uEAAuE;QACvE,mEAAmE;QACnE,gDAAgD;QAChD,MAAM,WAAW,GAAG,QAAQ,CAAC;QAC7B,kBAAkB,EAAE,CAAC;QACrB,mEAAmE;QACnE,uEAAuE;QACvE,oEAAoE;QACpE,kEAAkE;QAClE,sEAAsE;QACtE,0DAA0D;QAC1D,IAAI,WAAW;YAAE,MAAM,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,CAAC;IACnE,CAAC;IAED,OAAO;QACL,IAAI;QACJ,KAAK;QACL,MAAM;QACN,UAAU,EAAE,GAAG,EAAE,CAAC,QAAQ;QAC1B,cAAc,EAAE,GAAG,EAAE,CAAC,WAAW,GAAG,CAAC;QACrC,OAAO;QACP,KAAK;QACL,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.resource.engine\",\n \"title\": \"Async State Engine\",\n \"category\": \"runtime\",\n \"risk\": \"high\"\n}\n*/\n\n/**\n * Shared async-state engine behind `createResource` and `createAction`.\n *\n * The two public primitives are thin policy layers over this engine: they\n * differ only in defaults (auto-run, overlap policy, previous-data retention)\n * and in the shape of their call signature. All state transitions, cancellation\n * and teardown live here so both primitives cannot drift apart.\n *\n * ## Why not reuse the router's loader system?\n *\n * `packages/router/src/router/features/loaders/` solves a superficially similar\n * problem, but it is not reusable here:\n *\n * - It contains ZERO signals — `executeLoader()` returns a bare promise, so\n * there is no observable `status`/`data`/`error` for a template to bind to.\n * - It is route-keyed (`executeLoader(routeId, ...)`). A form submit has no\n * `routeId` and is not a navigation.\n * - Its `ResourceCache` is `get`/`set`/`clear` only — there is no per-key\n * invalidation, which is a supporting reason this primitive ships without a\n * cache in v1 (there would be no correct way to invalidate one entry).\n * - Importing it would add a `core -> router` dependency and recreate a known\n * build cycle. The prior art is referenced here in comments only.\n *\n * ## Why a generation counter and not an in-flight AbortController registry?\n *\n * `LoaderManager` keeps `private activeLoaders = new Map<string, AbortController>()`\n * and relies on `abort()` to make a superseded request lose. That is not\n * sufficient on its own: aborting cannot stop a fetcher that ignores its signal\n * (a `setTimeout`-based mock, a third-party SDK, `indexedDB`, or any promise not\n * wired to `AbortSignal`). Such a fetcher still settles and would happily write\n * stale data into the signals.\n *\n * So correctness comes from the monotonic `generation` counter — a settled\n * result may only write state if its generation is still the current one — and\n * the `AbortController` is kept purely as a courtesy so well-behaved fetchers\n * can stop early. (If a caller-supplied signal is ever needed, the router's\n * `combineAbortSignals()` in `router/core/utils.ts` shows the shape. Not in v1.)\n *\n * ## Why the explicit `destroyed` flag?\n *\n * Disposing an effect does NOT stop an already in-flight promise from writing\n * signals afterwards — the disposer only runs cleanups. And `onCleanup()`\n * outside every effect is a silent no-op, so a primitive constructed in a plain\n * component body with no owner gets no automatic teardown at all. `destroy()`\n * is therefore load-bearing, not a nicety.\n *\n * Async continuations are automatically untracked (the signals runtime clears\n * `currentEffect` synchronously in `runEffect`'s `finally`), so writing signals\n * from a `.then`/`await` continuation can never subscribe the caller's effect to\n * them. That is what makes this engine safe to use inside a component body.\n *\n * CAVEAT this does NOT cover: `execute()`'s synchronous prologue (everything\n * up to the first `await task(...)`) runs inside whatever tracking context the\n * *caller* was in — `currentEffect` is only cleared once execution actually\n * suspends. So a fetcher's signal READS (e.g. `id()` referenced in its body\n * before the first `await`) are tracked by an enclosing effect if one is\n * running. Concretely: `effect(() => createResource(() => fetch(`/api/u/${id()}`)))`\n * re-runs on every `id` change, constructing a brand-new resource and firing a\n * brand-new fetch each time. The prior resource is now destroyed on that re-run\n * rather than leaked, but the re-fetching itself remains a caller footgun, not\n * an engine bug; it is documented for callers in the README's Async State\n * section.\n *\n * @module runtime/resource/engine\n */\n\nimport { batch, signal, type Signal } from '@pithyjs/signals';\nimport type { ActionResult, ResourceStatus } from './types';\n\n/**\n * The single \"nothing happened\" result value.\n *\n * Structurally assignable to `ActionResult<T, E>` for any `T`/`E`, so it can be\n * returned from every generic entry point without an allocation per call.\n */\n/** @codexApi {\"parent\":\"pithy.core.resource.engine\",\"name\":\"DROPPED\",\"stability\":\"experimental\",\"signature\":\"const DROPPED: { readonly ok: false; readonly dropped: true }\"} */\n// `readonly` is compile-time only — freeze it too, so a consumer mutating the\n// object (accidentally or otherwise) cannot corrupt this shared sentinel for\n// every resource and action in the process.\nexport const DROPPED: { readonly ok: false; readonly dropped: true } =\n Object.freeze({\n ok: false,\n dropped: true,\n }) as { readonly ok: false; readonly dropped: true };\n\n/** Construction options for {@link createAsyncEngine}. */\n/** @codexApi {\"parent\":\"pithy.core.resource.engine\",\"name\":\"AsyncEngineOptions\",\"stability\":\"experimental\",\"signature\":\"interface AsyncEngineOptions\"} */\nexport interface AsyncEngineOptions {\n /** Keep the last successful `data` readable while the next task is in flight. */\n keepPreviousData: boolean;\n}\n\n/** Internal engine surface consumed by `createResource` / `createAction`. */\n/** @codexApi {\"parent\":\"pithy.core.resource.engine\",\"name\":\"AsyncEngine\",\"stability\":\"experimental\",\"signature\":\"interface AsyncEngine<T, E>\"} */\nexport interface AsyncEngine<T, E> {\n /** Latest successful value. */\n readonly data: Signal<T | undefined>;\n /** Latest error, carried by reference. */\n readonly error: Signal<E | undefined>;\n /** Current lifecycle status. */\n readonly status: Signal<ResourceStatus>;\n /**\n * Non-reactive flag: is there a run whose result we still want?\n *\n * Cleared by `reset()` and `destroy()`. NOT the overlap guard — see\n * {@link AsyncEngine.hasRunningTask}.\n */\n isInFlight: () => boolean;\n /**\n * Non-reactive flag: is user code (a fetcher or performer) still executing?\n *\n * This is what the `'drop'` overlap policy guards on. It deliberately\n * survives `reset()`, which abandons the result but cannot recall a request\n * already sent — an action's performer never receives the `AbortSignal`, so\n * nothing stops it. Guarding on `isInFlight()` instead let\n * Save -> dismiss -> Save issue two concurrent POSTs.\n */\n hasRunningTask: () => boolean;\n /** Run `task`, transitioning state and resolving (never rejecting) a result. */\n execute: (\n task: (signal: AbortSignal) => T | Promise<T>\n ) => Promise<ActionResult<T, E>>;\n /** Return to `'idle'` and abandon anything in flight. */\n reset: () => void;\n /** Permanently stop the engine. No signal is written after this returns. */\n destroy: () => void;\n}\n\n/**\n * Create the shared async-state engine.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam E - Type of the carried error.\n * @param options - Engine behaviour flags.\n * @returns An {@link AsyncEngine} owning three signals and the run lifecycle.\n */\n/** @codexApi {\"parent\":\"pithy.core.resource.engine\",\"name\":\"createAsyncEngine\",\"stability\":\"experimental\",\"signature\":\"<T, E = unknown>(options: AsyncEngineOptions) => AsyncEngine<T, E>\"} */\nexport function createAsyncEngine<T, E = unknown>(\n options: AsyncEngineOptions\n): AsyncEngine<T, E> {\n const { keepPreviousData } = options;\n\n const data = signal<T | undefined>(undefined);\n const error = signal<E | undefined>(undefined);\n const status = signal<ResourceStatus>('idle');\n\n /**\n * Monotonic run id. Only a task whose id still equals `generation` may write\n * state — this is what makes a stale response lose even when its fetcher\n * ignored the abort signal entirely.\n */\n let generation = 0;\n let inFlight = false;\n let controller: AbortController | null = null;\n let destroyed = false;\n\n /**\n * How many attempts are still executing USER CODE — deliberately distinct\n * from `inFlight`, which tracks whether we still WANT the result.\n *\n * `reset()` clears `inFlight` because it abandons the result, but it cannot\n * recall a performer that is already running. An action drops its\n * `AbortSignal` by design, so abort is inert there and nothing stops the\n * request. The double-submit guard therefore has to consult this counter:\n * otherwise Save -> dismiss (reset) -> Save fires two concurrent POSTs, the\n * exact case `overlap: 'drop'` exists to prevent.\n */\n let outstanding = 0;\n\n /**\n * Release callbacks for attempts parked on `await`.\n *\n * The generation gate sits after the await, so without these a superseded\n * attempt cannot report `DROPPED` until its own task settles — and a task\n * that ignores its abort signal (or an action, which never receives one) may\n * never settle at all, leaving a promise documented to resolve pending\n * forever. Invalidation releases them so they resolve on their own.\n */\n const parked = new Set<() => void>();\n\n /**\n * Invalidate anything currently running: bump the generation (so a late\n * settle can never win), abort the controller as a courtesy, and release\n * every parked attempt so it stops waiting on a task it no longer needs.\n */\n function invalidateInFlight(): void {\n generation++;\n inFlight = false;\n controller?.abort();\n controller = null;\n const releasing = [...parked];\n parked.clear();\n for (const release of releasing) release();\n }\n\n /**\n * Perform a signal write with consumer re-entry isolated.\n *\n * Every write below re-enters application code: `set()` invokes `.subscribe()`\n * listeners synchronously — even inside `batch()`, which only defers effects —\n * and the outermost `batch()` flushes those effects on its way out. That pass\n * runs every subscriber before rethrowing the first failure, so a throw\n * propagates back into the engine — unless the caller wrapped the call in its\n * own `batch()`. Then the effects run at the caller's flush, and a failure\n * there is thrown by the caller's `batch()`, outside anything the engine can\n * contain.\n *\n * Unisolated that was live in two ways: a throwing subscriber on the success\n * write landed in the `catch` below, turning a SUCCESSFUL fetch into a\n * failure carrying the consumer's own error; and the failure write then\n * re-entered the same subscriber, whose second throw escaped `execute()`\n * entirely — rejecting a promise the contract says never rejects.\n *\n * The throw is REPORTED rather than re-raised. Re-raising from a microtask\n * would reach `window.onerror`, but it also becomes an uncaught exception —\n * which crashes a Node process and fails a test run over a fault in consumer\n * code that the engine has already contained. Reporting keeps it visible\n * without letting one bad subscriber take down the host. The tradeoff is\n * that error-reporting tools hooked only to `window.onerror` will not see\n * it; those that capture `console.error` (most do) still will.\n */\n function report(err: unknown): void {\n console.error(\n '[PithyJS] A subscriber threw while a resource/action was writing its ' +\n 'state. The transition completed and the engine is unaffected — fix ' +\n 'the subscriber.',\n err\n );\n }\n\n /**\n * Apply a state transition one setter at a time.\n *\n * Wrapping the three setters in a single `batch()` is NOT enough to make the\n * transition atomic, because `set()` invokes `.subscribe()` listeners\n * synchronously — batching defers effects, not listeners. Two consequences,\n * both of which this guards:\n *\n * - **A throw must not truncate the transition.** With one `try` around the\n * whole batch, a listener throwing on the first setter skipped the rest —\n * leaving `data` written while `status` stayed `'loading'` even though\n * `execute()` went on to resolve success. Each setter is isolated instead,\n * so one bad listener costs its own write and nothing else.\n *\n * - **A re-entrant supersede must win.** A listener can synchronously call\n * `reset()` or start a newer run between two setters. That newer state is\n * already committed by the time this loop resumes, so continuing would\n * overwrite it with the remainder of a transition that is now stale.\n * `superseded()` is therefore re-checked before every setter, not once up\n * front.\n *\n * Setter order matters and is deliberate: `status` is written LAST, so a\n * consumer keyed on `status` never observes the new status beside the old\n * data.\n */\n function commit(\n writes: readonly (() => void)[],\n superseded: () => boolean\n ): void {\n try {\n batch(() => {\n for (const write of writes) {\n if (superseded()) return;\n try {\n write();\n } catch (err) {\n report(err);\n }\n }\n });\n } catch (err) {\n // The outermost `batch()` flushes queued effects on its way out and rethrows\n // the first failure; that flush happens after the loop above, so it needs its\n // own guard. Nested in a caller's `batch()`, nothing flushes or throws here.\n report(err);\n }\n }\n\n /**\n * `.set(() => value)` rather than `.set(value)`: the signals `set()` treats a\n * function argument as an updater, so the updater form is the only spelling\n * that stays correct when `T` is itself a function type.\n */\n function writeSuccess(value: T, superseded: () => boolean): void {\n commit(\n [\n () => data.set(() => value),\n () => error.set(() => undefined),\n () => status.set('success'),\n ],\n superseded\n );\n }\n\n function writeFailure(carried: E, superseded: () => boolean): void {\n commit(\n [() => error.set(() => carried), () => status.set('error')],\n superseded\n );\n }\n\n async function execute(\n task: (signal: AbortSignal) => T | Promise<T>\n ): Promise<ActionResult<T, E>> {\n if (destroyed) return DROPPED;\n\n // Supersede everything prior: bumps the generation so a late settle can\n // never win, aborts the old controller, and releases any parked attempt so\n // it reports DROPPED without waiting on a task that may never settle.\n invalidateInFlight();\n\n const runGeneration = generation;\n const runController = new AbortController();\n controller = runController;\n inFlight = true;\n\n /** Superseded by a newer run, or torn down. Either way: write nothing. */\n const stale = (): boolean => destroyed || runGeneration !== generation;\n\n let release!: () => void;\n const parkedUntilInvalidated = new Promise<void>(resolve => {\n release = resolve;\n });\n parked.add(release);\n\n try {\n commit(\n [\n () => status.set('loading'),\n () => error.set(() => undefined),\n ...(keepPreviousData ? [] : [() => data.set(() => undefined)]),\n ],\n stale\n );\n\n // The prologue above re-enters consumer code, which can synchronously\n // `destroy()` or `reset()` this handle before any await. Invoking `task`\n // afterwards would fire a side effect — for an action, a POST — on\n // behalf of a handle that no longer exists.\n if (stale()) return DROPPED;\n\n outstanding++;\n // Wrapped in an async IIFE so a SYNCHRONOUS throw from `task` becomes a\n // rejection of `running` rather than escaping before the race is armed.\n const running = (async () => task(runController.signal))();\n // Settles `outstanding` against the task itself, not against our\n // interest in it — see the counter's declaration. Doubles as the\n // consumer of a rejection we may stop awaiting, so abandoning a\n // superseded task never surfaces as an unhandled rejection.\n running.then(\n () => {\n outstanding--;\n },\n () => {\n outstanding--;\n }\n );\n\n const outcome = await Promise.race([\n running.then(value => ({ settled: true as const, value })),\n parkedUntilInvalidated.then(() => ({ settled: false as const })),\n ]);\n\n // `!outcome.settled` means invalidation released us first; `stale()`\n // covers a supersession that raced the task's own settle.\n if (!outcome.settled || stale()) return DROPPED;\n\n inFlight = false;\n controller = null;\n writeSuccess(outcome.value, stale);\n return { ok: true, data: outcome.value };\n } catch (thrown) {\n if (stale()) return DROPPED;\n\n inFlight = false;\n controller = null;\n // Errors are carried by reference with `E = unknown` — never wrapped in\n // an `Error`, so a thrown string, a `Response`, or a typed API failure\n // envelope survives intact.\n const carried = thrown as E;\n writeFailure(carried, stale);\n return { ok: false, dropped: false, error: carried };\n } finally {\n parked.delete(release);\n }\n }\n\n function reset(): void {\n if (destroyed) return;\n invalidateInFlight();\n // Note this abandons the RESULT but cannot recall a running performer —\n // `outstanding` deliberately survives, so the drop guard still holds.\n // A listener could start a newer run mid-transition; that run's state must\n // stand rather than be clobbered by the rest of this reset.\n const at = generation;\n commit(\n [\n () => data.set(() => undefined),\n () => error.set(() => undefined),\n () => status.set('idle'),\n ],\n () => generation !== at\n );\n }\n\n function destroy(): void {\n if (destroyed) return;\n destroyed = true;\n // Captured BEFORE invalidateInFlight() clears it, and used in place of\n // reading status(). The two are equivalent — `inFlight` and\n // `status === 'loading'` are set together in execute() and cleared\n // together on settle — but `inFlight` is a plain boolean, whereas\n // status() is a signal read. destroy() runs outside any effect, so\n // reading a signal here trips the dev-mode \"read outside of a reactive\n // context\" warning on every teardown. The test env suppresses that\n // warning, which is why the suite never saw it.\n const wasInFlight = inFlight;\n invalidateInFlight();\n // `data`/`error` freeze exactly as they were, so a subscriber that\n // outlives the primitive sees no phantom value change. `status` is the\n // one exception: a destroy mid-flight must not leave it permanently\n // stuck at 'loading' (a surviving subscriber would show a spinner\n // forever, and reset() can no longer clear it — reset() early-returns\n // once `destroyed` is true). Settle it to 'idle' instead.\n if (wasInFlight) commit([() => status.set('idle')], () => false);\n }\n\n return {\n data,\n error,\n status,\n isInFlight: () => inFlight,\n hasRunningTask: () => outstanding > 0,\n execute,\n reset,\n destroy,\n };\n}\n"]}
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module runtime/resource
|
|
15
15
|
*/
|
|
16
|
-
export { createResource } from './createResource';
|
|
17
|
-
export { createAction } from './createAction';
|
|
18
|
-
export type { ResourceStatus, ResourceFetcher, ResourceOptions, ResourceHandle, ActionPerformer, ActionOverlap, ActionOptions, ActionHandle, ActionResult, } from './types';
|
|
16
|
+
export { createResource } from './createResource.js';
|
|
17
|
+
export { createAction } from './createAction.js';
|
|
18
|
+
export type { ResourceStatus, ResourceFetcher, ResourceOptions, ResourceHandle, ActionPerformer, ActionOverlap, ActionOptions, ActionHandle, ActionResult, } from './types.js';
|
|
19
19
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
*
|
|
14
14
|
* @module runtime/resource
|
|
15
15
|
*/
|
|
16
|
-
export { createResource } from './createResource';
|
|
17
|
-
export { createAction } from './createAction';
|
|
16
|
+
export { createResource } from './createResource.js';
|
|
17
|
+
export { createAction } from './createAction.js';
|
|
18
18
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/resource/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/runtime/resource/index.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAEF;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.resource.barrel\",\n \"title\": \"Async State Primitive Barrel\",\n \"category\": \"runtime\"\n}\n*/\n\n/**\n * Public surface of the async-state primitives.\n *\n * `engine.ts` is intentionally NOT re-exported — it is an internal seam shared\n * by the two primitives, not API.\n *\n * @module runtime/resource\n */\n\nexport { createResource } from './createResource';\nexport { createAction } from './createAction';\nexport type {\n ResourceStatus,\n ResourceFetcher,\n ResourceOptions,\n ResourceHandle,\n ActionPerformer,\n ActionOverlap,\n ActionOptions,\n ActionHandle,\n ActionResult,\n} from './types';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/resource/types.ts"],"names":[],"mappings":"AAAA;;;;;;EAME"}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/runtime/resource/types.ts"],"names":[],"mappings":"AAAA;;;;;;EAME","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.core.resource.types\",\n \"title\": \"Async State Primitive Types\",\n \"category\": \"types\"\n}\n*/\n\n/**\n * Public types for the async-state primitives (`createResource`, `createAction`).\n *\n * @module runtime/resource/types\n */\n\n/**\n * Read access to a signal: call it to read (tracked normally inside an\n * effect), `subscribe` to observe. Deliberately omits `.set()`.\n *\n * `@pithyjs/signals` exports `ReadonlySignal<T> = () => T`, which drops\n * `.subscribe` as well. Observing without an effect is legitimate read access,\n * so the handles use this instead — the write path is what has to be closed\n * off, not the read path. If this proves generally useful it belongs in\n * `@pithyjs/signals` beside `Signal` and `ReadonlySignal`.\n */\nexport type ReadableSignal<T> = (() => T) & {\n subscribe: (fn: (value: T) => void) => () => void;\n};\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ResourceStatus\",\"stability\":\"stable\",\"signature\":\"type ResourceStatus = 'idle' | 'loading' | 'success' | 'error'\"} */\n/**\n * Lifecycle status of a resource or action.\n *\n * NAMING NOTE: this is deliberately NOT called `ResourceState`. `@pithyjs/router`\n * already exports an interface named `ResourceState` (route loader state), and\n * `@pithyjs/core` re-exports its whole runtime barrel — an app importing both\n * packages would otherwise face an ambiguous name.\n */\nexport type ResourceStatus = 'idle' | 'loading' | 'success' | 'error';\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ResourceFetcher\",\"stability\":\"stable\",\"signature\":\"type ResourceFetcher<T> = (signal: AbortSignal) => T | Promise<T>\"} */\n/**\n * The function a resource calls to produce its data.\n *\n * Receives an `AbortSignal` that is aborted when the resource is refetched,\n * reset or destroyed. Forwarding it to `fetch()` is a courtesy optimisation\n * only — correctness never depends on the fetcher honouring it (see\n * `engine.ts` for the generation counter that guarantees it).\n *\n * @typeParam T - Type of the resolved data.\n */\nexport type ResourceFetcher<T> = (signal: AbortSignal) => T | Promise<T>;\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ActionPerformer\",\"stability\":\"stable\",\"signature\":\"type ActionPerformer<T, A extends unknown[]> = (...args: A) => T | Promise<T>\"} */\n/**\n * The function an action calls to perform its side effect.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam A - Tuple of arguments forwarded from `run()`.\n */\nexport type ActionPerformer<T, A extends unknown[]> = (\n ...args: A\n) => T | Promise<T>;\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ActionResult\",\"stability\":\"stable\",\"signature\":\"type ActionResult<T, E = unknown> = { ok: true; data: T } | { ok: false; dropped: false; error: E } | { ok: false; dropped: true }\"} */\n/**\n * Discriminated union resolved by `run()` and `refetch()`.\n *\n * These methods RESOLVE this union — they never reject. This deliberately\n * diverges from the router's `executeLoader`, which rejects on failure; see the\n * comment above `run()` in `createAction.ts` for the rationale.\n *\n * Narrowing:\n * ```ts\n * if (result.ok) result.data; // success\n * else if (result.dropped) { } // superseded / destroyed / SSR — no run happened\n * else result.error; // failure, error carried by reference\n * ```\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam E - Type of the carried error (defaults to `unknown` — thrown values\n * are carried by reference and never wrapped in an `Error`).\n */\nexport type ActionResult<T, E = unknown> =\n | { readonly ok: true; readonly data: T }\n | { readonly ok: false; readonly dropped: false; readonly error: E }\n | { readonly ok: false; readonly dropped: true };\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ResourceOptions\",\"stability\":\"stable\",\"signature\":\"interface ResourceOptions\"} */\n/** Options for {@link createResource}. */\nexport interface ResourceOptions {\n /**\n * Fetch as soon as the resource is created.\n *\n * Ignored under server rendering (SSG *and* dynamic SSR), where the\n * resource always stays `'idle'`.\n *\n * @default true\n */\n immediate?: boolean;\n\n /**\n * Keep the last successful `data` readable while a refetch is in flight,\n * **and after that refetch fails**. When `false`, `data` is cleared the\n * moment a refetch starts.\n *\n * The post-failure half matters: on failure `status` becomes `'error'` and\n * `error` is populated, but `data` still holds the last success. A view that\n * renders `data` whenever it is defined will therefore show stale content\n * beside a fresh error unless it checks `status` too. That is the intended\n * behaviour — it is what makes a transient refetch failure non-destructive —\n * but it has to be handled deliberately.\n *\n * @default false\n */\n keepPreviousData?: boolean;\n}\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ActionOverlap\",\"stability\":\"stable\",\"signature\":\"type ActionOverlap = 'drop' | 'restart'\"} */\n/**\n * What happens when `run()` is called while a previous run is still in flight.\n *\n * - `'drop'` — the new call is ignored and resolves `{ ok: false, dropped: true }`.\n * The default for actions: double-submitting a form should not fire twice.\n * - `'restart'` — the new call supersedes the old one, which resolves\n * `{ ok: false, dropped: true }` and can never write state again.\n */\nexport type ActionOverlap = 'drop' | 'restart';\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ActionOptions\",\"stability\":\"stable\",\"signature\":\"interface ActionOptions\"} */\n/** Options for {@link createAction}. */\nexport interface ActionOptions {\n /**\n * Overlap policy for concurrent `run()` calls.\n *\n * @default 'drop'\n */\n overlap?: ActionOverlap;\n\n /**\n * Keep the last successful `data` readable while the next run is in flight\n * — AND after that run fails. `writeFailure()` never clears `data`, so with\n * this on (the default), a failed run leaves the previous success value\n * readable in `data()` alongside the new `error()`/`status() === 'error'`.\n * Only a subsequent success or an explicit `reset()` clears it.\n *\n * Defaults to `true` — the inverse of {@link ResourceOptions.keepPreviousData} —\n * because an action's result is usually a receipt the UI keeps showing.\n *\n * @default true\n */\n keepPreviousData?: boolean;\n}\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ResourceHandle\",\"stability\":\"stable\",\"signature\":\"interface ResourceHandle<T, E = unknown>\"} */\n/**\n * Handle returned by {@link createResource}.\n *\n * `data`, `error` and `status` are exposed as {@link ReadableSignal} — read and\n * subscribe, but no `.set()` — rather than `Signal`. `readonly` on the property alone\n * would only stop the field being reassigned; the `Signal` behind it still\n * carries `.set()`, so `resource.status.set('success')` would type-check and\n * desync `status` from the engine's untracked bookkeeping, after which\n * `destroy()` cannot clear a stuck spinner and `loading()` reports a state the\n * engine never produced. The accessor type makes the intent enforceable\n * instead of conventional.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam E - Type of the carried error.\n */\nexport interface ResourceHandle<T, E = unknown> {\n /** Latest successful value, or `undefined` before the first success. */\n readonly data: ReadableSignal<T | undefined>;\n\n /**\n * Latest error, carried by reference and never wrapped.\n *\n * `status() === 'error'` is the authoritative failure check, NOT\n * `error() !== undefined`. A rejection can legitimately carry `undefined`\n * (e.g. `Promise.reject()` / `throw undefined`), in which case `status()`\n * is `'error'` while `error()` reads `undefined` — a consumer checking only\n * `error()` would silently miss that failure.\n */\n readonly error: ReadableSignal<E | undefined>;\n\n /** Current lifecycle status. */\n readonly status: ReadableSignal<ResourceStatus>;\n\n /**\n * `true` while a fetch is in flight.\n *\n * A plain accessor rather than `computed()` — it still tracks reactively\n * because it reads `status()` inside the caller's effect, and it avoids\n * `computed()`'s leaked internal subscription.\n */\n readonly loading: () => boolean;\n\n /**\n * Re-run the fetcher. The newest call always wins; superseded calls resolve\n * `{ ok: false, dropped: true }`. Inert under any server render.\n */\n refetch: () => Promise<ActionResult<T, E>>;\n\n /** Return to `'idle'`, clearing data and error, and abandon any in-flight fetch. */\n reset: () => void;\n\n /**\n * Permanently stop the resource: aborts the in-flight request and guarantees\n * no signal is ever written again.\n *\n * MUST be called from the owning component's cleanup. `onCleanup()` is a\n * silent no-op outside an effect, so this is not optional.\n */\n destroy: () => void;\n}\n\n/** @codexApi {\"parent\":\"pithy.core.resource.types\",\"name\":\"ActionHandle\",\"stability\":\"stable\",\"signature\":\"interface ActionHandle<T, A extends unknown[], E = unknown>\"} */\n/**\n * Handle returned by {@link createAction}.\n *\n * @typeParam T - Type of the resolved data.\n * @typeParam A - Tuple of arguments accepted by `run()`.\n * @typeParam E - Type of the carried error.\n */\nexport interface ActionHandle<T, A extends unknown[], E = unknown> {\n /** Result of the latest successful run. */\n readonly data: ReadableSignal<T | undefined>;\n\n /**\n * Error of the latest failed run, carried by reference and never wrapped.\n *\n * `status() === 'error'` is the authoritative failure check, NOT\n * `error() !== undefined`. A rejection can legitimately carry `undefined`\n * (e.g. `Promise.reject()` / `throw undefined`), in which case `status()`\n * is `'error'` while `error()` reads `undefined` — a consumer checking only\n * `error()` would silently miss that failure.\n */\n readonly error: ReadableSignal<E | undefined>;\n\n /** Current lifecycle status. */\n readonly status: ReadableSignal<ResourceStatus>;\n\n /** `true` while a run is in flight (plain accessor, see `ResourceHandle.loading`). */\n readonly pending: () => boolean;\n\n /**\n * Perform the action. Always resolves — never rejects — with an\n * {@link ActionResult}.\n */\n run: (...args: A) => Promise<ActionResult<T, E>>;\n\n /** Return to `'idle'`, clearing data and error, and abandon any in-flight run. */\n reset: () => void;\n\n /**\n * Permanently stop the action: aborts the in-flight run and guarantees no\n * signal is ever written again. See {@link ResourceHandle.destroy}.\n */\n destroy: () => void;\n}\n"]}
|
package/dist/types/globals.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { SlotMap } from '../compile/contentProjection';
|
|
1
|
+
import type { SlotMap } from '../compile/contentProjection.js';
|
|
2
2
|
import type { PithyNode } from '@pithyjs/compiler';
|
|
3
|
-
import type { ChildFactory } from '../runtime/bindings/types';
|
|
3
|
+
import type { ChildFactory } from '../runtime/bindings/types.js';
|
|
4
4
|
export interface PithyComponentContext extends Record<string, unknown> {
|
|
5
5
|
__parentComponentContext?: PithyComponentContext;
|
|
6
6
|
__slotMap?: SlotMap;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,YAAY;IAC1B,OAAO,UAA8C,CAAC;AACxD,CAAC"}
|
|
1
|
+
{"version":3,"file":"globals.js","sourceRoot":"","sources":["../../src/types/globals.ts"],"names":[],"mappings":"AA4BA,MAAM,UAAU,YAAY;IAC1B,OAAO,UAA8C,CAAC;AACxD,CAAC","sourcesContent":["import type { SlotMap } from '../compile/contentProjection';\nimport type { PithyNode } from '@pithyjs/compiler';\nimport type { ChildFactory } from '../runtime/bindings/types';\n\nexport interface PithyComponentContext extends Record<string, unknown> {\n __parentComponentContext?: PithyComponentContext;\n __slotMap?: SlotMap;\n __childAstNodes?: PithyNode[];\n __childFactory?: ChildFactory;\n}\n\nexport interface PithyGlobals {\n /**\n * SSR component-crash registry. Lives on `globalThis` rather than in a module\n * so that an app and `@pithyjs/ssr` resolving two physical copies of\n * `@pithyjs/core` still share one — see `compile/ssrCrashes.ts`.\n */\n __pithySSRCrashes?: Map<Element, unknown>;\n PITHY_DEBUG_PROJECTION?: boolean;\n __PITHY_SSR__?: boolean;\n __getComponentContext?: () => Record<string, unknown> | undefined;\n __pithyComponentContext?: PithyComponentContext;\n __pithyProjectedChildren?: DocumentFragment;\n __pithyRenderingComponent?: boolean;\n __pithyGetDestroyCallbacks?: () => (() => void)[] | undefined;\n __pithySetDestroyCallbacks?: (cbs: (() => void)[]) => void;\n}\n\nexport function pithyGlobals(): typeof globalThis & PithyGlobals {\n return globalThis as typeof globalThis & PithyGlobals;\n}\n"]}
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * What a component returns.\n *\n * `el` is any DOM `Node`, not only an element or fragment. It was declared as\n * `HTMLElement | DocumentFragment` while the runtime happily inserted anything\n * `replaceWith` accepts — a component returning `document.createTextNode('hi')`\n * rendered correctly and always had. Narrowing the runtime to match the old\n * declaration would have silently dropped those subtrees, so the declaration is\n * widened to match the behaviour instead.\n *\n * Anything that is a real node but cannot be inserted at a given position — a\n * `Document`, say — still fails at insertion and is reported, rather than being\n * excluded by type.\n */\nexport type Component = () => {\n el: Node;\n destroy?: () => void;\n};\n\ndeclare global {\n interface Window {\n __pithyCapture?: Record<string, unknown>;\n }\n}\n\nexport {};\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ref.untility';
|
|
2
|
-
export * from './ref-signal.utility';
|
|
1
|
+
export * from './ref.untility.js';
|
|
2
|
+
export * from './ref-signal.utility.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/utilities/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './ref.untility';
|
|
2
|
-
export * from './ref-signal.utility';
|
|
1
|
+
export * from './ref.untility.js';
|
|
2
|
+
export * from './ref-signal.utility.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utilities/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,sBAAsB,CAAC","sourcesContent":["export * from './ref.untility';\nexport * from './ref-signal.utility';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref-signal.utility.js","sourceRoot":"","sources":["../../src/utilities/ref-signal.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8JAA8J;AAC9J,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,GAAqB,MAAM,CAAW,IAAI,CAAC,CAAC;IAEnD,MAAM,GAAG,GAAG;QACV,OAAO,CAAC,EAAE,CAAC;IACb,CAAiB,CAAC;IAElB,GAAG,CAAC,GAAG,GAAG,CAAC,EAAY,EAAQ,EAAE;QAC/B,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE;QACpC,GAAG;YACD,OAAO,CAAC,EAAE,CAAC;QACb,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
1
|
+
{"version":3,"file":"ref-signal.utility.js","sourceRoot":"","sources":["../../src/utilities/ref-signal.utility.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAU,MAAM,kBAAkB,CAAC;AAGlD;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,8JAA8J;AAC9J,MAAM,UAAU,SAAS;IACvB,MAAM,CAAC,GAAqB,MAAM,CAAW,IAAI,CAAC,CAAC;IAEnD,MAAM,GAAG,GAAG;QACV,OAAO,CAAC,EAAE,CAAC;IACb,CAAiB,CAAC;IAElB,GAAG,CAAC,GAAG,GAAG,CAAC,EAAY,EAAQ,EAAE;QAC/B,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACZ,CAAC,CAAC;IAEF,MAAM,CAAC,cAAc,CAAC,GAAG,EAAE,SAAS,EAAE;QACpC,GAAG;YACD,OAAO,CAAC,EAAE,CAAC;QACb,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC","sourcesContent":["import { signal, Signal } from '@pithyjs/signals';\nimport type { RefSignal } from '../interfaces/ref-signal.interface';\n\n/**\n * Creates a reactive reference signal for HTML elements.\n *\n * This function returns a RefSignal object that can be used to hold and manage\n * references to DOM elements. It provides both function-style and object-style\n * access to the referenced element.\n *\n * @template T - The type of HTML element being referenced, defaults to HTMLElement\n *\n * @returns {RefSignal<T>} A RefSignal object with the following capabilities:\n * - Can be called as a function to get the current element\n * - Has a `set` method to update the referenced element\n * - Has a `current` property to access the referenced element (React-style)\n *\n * @example\n * ```typescript\n * const divRef = refSignal<HTMLDivElement>();\n *\n * // Function-style usage\n * const element = divRef();\n *\n * // Setter usage\n * divRef.set(someElement);\n *\n * // Property-style usage (React-like)\n * const currentElement = divRef.current;\n * ```\n */\n/** @codexApi {\"parent\":\"pithy.feature.refs\",\"name\":\"refSignal\",\"stability\":\"stable\",\"signature\":\"<T extends HTMLElement = HTMLElement>() => RefSignal<T>\"} */\nexport function refSignal<T extends HTMLElement = HTMLElement>(): RefSignal<T> {\n const r: Signal<T | null> = signal<T | null>(null);\n\n const ref = function (): T | null {\n return r();\n } as RefSignal<T>;\n\n ref.set = (el: T | null): void => {\n r.set(el);\n };\n\n Object.defineProperty(ref, 'current', {\n get(): T | null {\n return r();\n },\n });\n\n return ref;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ref.untility.js","sourceRoot":"","sources":["../../src/utilities/ref.untility.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,kJAAkJ;AAClJ,MAAM,UAAU,GAAG;IACjB,IAAI,KAAK,GAAa,IAAI,CAAC;IAC3B,MAAM,GAAG,GAAG,CAAC,EAAY,EAAE,EAAE;QAC3B,KAAK,GAAG,EAAE,CAAC;IACb,CAAC,CAAC;IACF,OAAO;QACL,IAAI,OAAO;YACT,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG;KACa,CAAC;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"ref.untility.js","sourceRoot":"","sources":["../../src/utilities/ref.untility.ts"],"names":[],"mappings":"AAAA;;;;;;EAME;AAIF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,kJAAkJ;AAClJ,MAAM,UAAU,GAAG;IACjB,IAAI,KAAK,GAAa,IAAI,CAAC;IAC3B,MAAM,GAAG,GAAG,CAAC,EAAY,EAAE,EAAE;QAC3B,KAAK,GAAG,EAAE,CAAC;IACb,CAAC,CAAC;IACF,OAAO;QACL,IAAI,OAAO;YACT,OAAO,KAAK,CAAC;QACf,CAAC;QACD,GAAG;KACa,CAAC;AACrB,CAAC","sourcesContent":["/** @codex\n{\n \"id\": \"pithy.feature.refs\",\n \"title\": \"Element Reference System\",\n \"category\": \"feature\"\n}\n*/\n\nimport type { Ref } from '../interfaces/ref.interface';\n\n/**\n * Creates a non-reactive reference object for HTML elements.\n *\n * This function returns a Ref object that can be used to hold and manage\n * references to DOM elements. It provides a React-like interface with\n * a `current` property and a `set` method.\n *\n * @template T - The type of HTML element being referenced, defaults to HTMLElement\n *\n * @returns {Ref<T>} A Ref object with the following:\n * - `current` - A getter property that returns the current element reference\n * - `set` - A method to update the referenced element\n *\n * @example\n * ```typescript\n * const divRef = ref<HTMLDivElement>();\n *\n * // Update the reference\n * divRef.set(someElement);\n *\n * // Access the current element\n * const element = divRef.current;\n * ```\n *\n * @see {@link RefSignal} for a reactive version of this reference\n */\n/** @codexApi {\"parent\":\"pithy.feature.refs\",\"name\":\"ref\",\"stability\":\"stable\",\"signature\":\"<T extends HTMLElement = HTMLElement>() => Ref<T>\"} */\nexport function ref<T extends HTMLElement = HTMLElement>(): Ref<T> {\n let value: T | null = null;\n const set = (el: T | null) => {\n value = el;\n };\n return {\n get current() {\n return value;\n },\n set,\n } satisfies Ref<T>;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pithyjs/core",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.11",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/PithyJS/pithyjs.git",
|
|
7
|
+
"directory": "packages/core"
|
|
8
|
+
},
|
|
4
9
|
"main": "dist/index.js",
|
|
5
10
|
"types": "dist/index.d.ts",
|
|
6
11
|
"type": "module",
|
|
@@ -19,10 +24,10 @@
|
|
|
19
24
|
}
|
|
20
25
|
},
|
|
21
26
|
"dependencies": {
|
|
22
|
-
"@pithyjs/shared": "0.1.0-beta.
|
|
23
|
-
"@pithyjs/signals": "0.1.0-beta.
|
|
24
|
-
"@pithyjs/compiler": "0.1.0-beta.
|
|
25
|
-
"@pithyjs/design-system": "0.1.0-beta.
|
|
27
|
+
"@pithyjs/shared": "0.1.0-beta.3",
|
|
28
|
+
"@pithyjs/signals": "0.1.0-beta.2",
|
|
29
|
+
"@pithyjs/compiler": "0.1.0-beta.4",
|
|
30
|
+
"@pithyjs/design-system": "0.1.0-beta.6"
|
|
26
31
|
},
|
|
27
32
|
"peerDependencies": {
|
|
28
33
|
"parse5": ">=7.0.0"
|
|
@@ -49,7 +54,7 @@
|
|
|
49
54
|
"dist"
|
|
50
55
|
],
|
|
51
56
|
"scripts": {
|
|
52
|
-
"build": "tsc -p tsconfig.json",
|
|
57
|
+
"build": "tsc -p tsconfig.json && node ../../scripts/add-js-extensions.mjs dist",
|
|
53
58
|
"test": "vitest"
|
|
54
59
|
}
|
|
55
60
|
}
|