@viewstem/core 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.ko.md +120 -0
- package/README.md +120 -2
- package/dist/THIRD-PARTY-NOTICES.txt +23 -0
- package/dist/cel-support.json +108 -0
- package/dist/cel.d.ts +10 -0
- package/dist/cel.js +12 -0
- package/dist/cel.js.map +7 -0
- package/dist/chunks/chunk-7UF7IFQE.js +4866 -0
- package/dist/chunks/chunk-7UF7IFQE.js.map +7 -0
- package/dist/chunks/chunk-ABYD66VN.js +4624 -0
- package/dist/chunks/chunk-ABYD66VN.js.map +7 -0
- package/dist/chunks/chunk-HIWAPDU3.js +481 -0
- package/dist/chunks/chunk-HIWAPDU3.js.map +7 -0
- package/dist/chunks/chunk-HT34IHOC.js +692 -0
- package/dist/chunks/chunk-HT34IHOC.js.map +7 -0
- package/dist/http.d.ts +12 -0
- package/dist/http.js +8 -0
- package/dist/http.js.map +7 -0
- package/dist/index.d.ts +335 -0
- package/dist/index.js +95 -0
- package/dist/index.js.map +7 -0
- package/dist/renderer.d.ts +104 -0
- package/dist/renderer.js +378 -0
- package/dist/renderer.js.map +7 -0
- package/package.json +53 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 miinhlym
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.ko.md
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
# @viewstem/core
|
|
2
|
+
|
|
3
|
+
[English](README.md) | 한국어
|
|
4
|
+
|
|
5
|
+
Viewstem은 [MIT 라이선스](LICENSE)로 배포합니다. 함께 배포하는 CEL 코드의 저작자 표시와 라이선스는 [THIRD-PARTY-NOTICES.txt](dist/THIRD-PARTY-NOTICES.txt)에 포함합니다.
|
|
6
|
+
|
|
7
|
+
선언형 UI의 검증·값·상태·Query·Action·화면 수명을 실행하는 ESM 라이브러리입니다. DOM, Svelte, 회사 도메인에 의존하지 않습니다.
|
|
8
|
+
|
|
9
|
+
```ts
|
|
10
|
+
import { createRegistry, createRuntime, defineResourceSet } from '@viewstem/core';
|
|
11
|
+
|
|
12
|
+
const registry = createRegistry();
|
|
13
|
+
registry.registerResourceSet(defineResourceSet({
|
|
14
|
+
id: 'projection-example', version: '1',
|
|
15
|
+
components: [{
|
|
16
|
+
contract: {
|
|
17
|
+
kind: 'Component', id: 'Label',
|
|
18
|
+
spec: { ports: { text: { kind: 'Value', schema: { type: 'string' }, required: true } } },
|
|
19
|
+
},
|
|
20
|
+
connectorId: 'projection-example', implementation: {},
|
|
21
|
+
}],
|
|
22
|
+
}));
|
|
23
|
+
const runtime = createRuntime({ registry });
|
|
24
|
+
const view = await runtime.createView({
|
|
25
|
+
states: { title: { kind: 'State', schema: { type: 'string' }, initial: 'Hello' } },
|
|
26
|
+
render: { id: 'label', componentRef: 'Label', inputs: { text: { '@path': '/states/title' } } },
|
|
27
|
+
});
|
|
28
|
+
await view.whenSettled(view.initial);
|
|
29
|
+
const stop = view.subscribe(snapshot => {
|
|
30
|
+
console.log(snapshot.roots[0]?.inputs.text);
|
|
31
|
+
});
|
|
32
|
+
view.getState('title').write('Updated');
|
|
33
|
+
stop();
|
|
34
|
+
await runtime.dispose();
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`view.whenSettled(application)`은 이번 적용에서 실행 가능한 첫 Query들의 성공/오류가 확정된 완료 신호입니다. UI는 준비된 부분부터 관찰할 수 있습니다. 입력 미준비·gate 차단은 완료를 막지 않으며 Query 오류는 `(await view.whenSettled(view.initial)).queryErrors`에 포함됩니다. DOM paint 완료 신호는 아닙니다.
|
|
38
|
+
|
|
39
|
+
## API 경계
|
|
40
|
+
|
|
41
|
+
- `createRegistry`: `(kind, id)` 등록·검증, 코드형 Component/Action 등록, 목록·설명·정의 추출·명시적 정의 교체.
|
|
42
|
+
- `createStateStore`: scope, State, `writeBatch`/동기 `transaction`, 안정적인 읽기 snapshot, `registerReaction`, Clock·URL 연결. Derived는 View/Component의 `states`에 선언합니다. 외부에서 주입한 Store는 runtime 폐기로 제거하지 않습니다.
|
|
43
|
+
- `createRuntime()`은 기본 Registry를 생성합니다. Runtime은 `createView(source, options?)`, `invokeAction(request)`, `registry`, `stateStore`, `dispose`를 제공합니다. View는 `setInputs`, `updateDefinition`, `applyResourceSets`, `replace`, `invokeAction`, `whenSettled`, `emit`, `getSnapshot`, `subscribe`, `getState`, `getQuery`, `exportDefinition`을 제공합니다.
|
|
44
|
+
- `mergeOwnedUrl`: 호스트 URL adapter에서 소유 키만 병합합니다.
|
|
45
|
+
- `computeGridLayout`: 12열 배치 계산만 제공하며 Grid UI를 자동 등록하지 않습니다.
|
|
46
|
+
|
|
47
|
+
루트 진입점은 `defineCodeAction`과 `defineResourceSet`도 내보냅니다. 선택 실행기는 별도 진입점에서 가져옵니다.
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
import { createHttpExecutor } from '@viewstem/core/http';
|
|
51
|
+
import { compileCel, evaluateCel, defaultCelLimits } from '@viewstem/core/cel';
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`Registry`, `StateStore`, `Runtime`, `View`는 생성자가 아닌 타입입니다. 팩토리가 반환하는 객체에는 공개 메서드만 있으며 내부 엔진·검증기·초기화 메서드를 노출하지 않습니다. `@path`/`@call`, Query, Variable은 리소스 선언을 통해 실행합니다. 기존 생성자·엔진 export를 사용했다면 같은 revision의 [API 변경 안내](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-refactor-2026-11-02.md)를 따릅니다.
|
|
55
|
+
|
|
56
|
+
정확한 타입·필드는 패키지의 `dist/index.d.ts`, `dist/http.d.ts`, `dist/cel.d.ts`를 따릅니다. Registry/Store/View 및 State/Query 핸들은 라이브러리가 발급한 객체입니다. JSON 값으로 직렬화하거나 일반 객체로 모사하지 않습니다. Value는 원본을 격리하고 읽기 전용으로 전달합니다. Set/Map은 native 정체성·동등성 계약을 유지하며 HTTP 계획 입력에서만 배열/엔트리 쌍으로 변환합니다.
|
|
57
|
+
|
|
58
|
+
## 호스트 연결
|
|
59
|
+
|
|
60
|
+
렌더러는 `view.getSnapshot()` 또는 `subscribe()`의 `roots`를 그립니다. 각 노드는 `instanceId`, `generation`, `status`, `inputs`, `children`, 이름별 `slots`를 포함합니다. 이벤트는 선언된 payload만 `view.emit(node, event, payload)`로 전달합니다. DOM 이벤트 객체를 전달하지 않습니다. `when:false`/실제 제거는 수명을 끝내지만 일시적인 입력 대기는 기존 상태·실행 연결을 유지합니다.
|
|
61
|
+
|
|
62
|
+
기존 화면은 주입 시점의 리소스 정의를 유지합니다. `registry.updateResource`는 공용 정의를 변경하고 `view.replace`나 새 createView에서 이를 주입합니다. `view.updateDefinition`는 현재 화면 구성만 바꿉니다. 유지하는 셀의 State↔Derived 변경은 쓰기 계약 불일치로 거절합니다. State·현재 화면·공용 정의의 변경/추출은 DB 저장과 별개입니다.
|
|
63
|
+
|
|
64
|
+
코드 Action의 필수 입력은 포트에 `required: true`로 선언합니다. 기본값이 있는 Value 포트도 연결된 값이 없을 수 있으므로 핸들러에서는 선택 입력입니다. `updateResource`는 참조 Type을 포함한 코드 Action의 입출력 계약을 보존합니다. 계약을 바꿀 때는 새 Action ID로 핸들러를 함께 등록하고 호출 위치의 참조를 옮깁니다.
|
|
65
|
+
|
|
66
|
+
View가 투영을 계산하거나 발행하는 중 구독자가 State를 쓰면, runtime은 후속 투영을 예약합니다. 현재의 불변 snapshot 통지를 마친 뒤 새 투영을 발행하며, 그동안 발생한 여러 쓰기는 한 번의 후속 투영으로 합칩니다. 같은 값을 다시 쓰면 새 State 변경을 만들지 않습니다. 변경된 노드 입력은 다음 snapshot에서 확인하고 DOM 반영은 렌더러의 완료 수단으로 확인합니다.
|
|
67
|
+
|
|
68
|
+
`authorize`는 Action 실행과 기존 View의 변경 권한을 검사합니다. 반환값이 `true`일 때만 허용합니다. Action 호출의 읽기 전용 `resource`는 실행에 사용한 Registry 스냅샷의 `{ kind: 'Action', id }`입니다. 인라인 Action은 `null`이며 하위 호출은 자기 대상을 식별합니다. 목록 노출 필터, 사용자 신원, 저장 권한은 호스트가 구성합니다.
|
|
69
|
+
|
|
70
|
+
`update`의 owner는 createView가 반환한 공개 View와 같은 객체입니다. `invoke`의 owner는 수명별 비교에만 쓰는 불투명 식별 객체이며 실행 메서드가 없습니다. 권한 콜백에는 등록된 코드 Action의 구현 함수를 전달하지 않습니다.
|
|
71
|
+
|
|
72
|
+
`defineCodeAction({ definition, requires? })`으로 계약을 선언하고 `.implement(handler)`로 타입이 있는 엔트리를 만듭니다. 이 엔트리를 `defineResourceSet({ actions: [entry], ... })`에 전달합니다. 같은 계약에 새 함수를 연결한 엔트리는 `registry.replaceResource({ action: entry })`에 전달합니다. 참조 스키마의 타입은 `defineCodeAction<Inputs, Output>()`으로 명시합니다.
|
|
73
|
+
|
|
74
|
+
`runtime.invokeAction(request)`와 `view.invokeAction(request)`는 독립 호출을 시작합니다. 요청에 `signal: AbortSignal`을 전달하면 해당 호출과 하위 호출을 취소할 수 있습니다. `context.invokeAction`은 부모의 취소와 재귀 스택을 상속합니다. 취소된 호출은 `CANCELLED`로 거절되며 이미 성공한 효과는 보존됩니다.
|
|
75
|
+
|
|
76
|
+
## HTTP와 URL
|
|
77
|
+
|
|
78
|
+
`requestExecutor(plan, {signal})`을 주입하지 않으면 native fetch 기반 공개 HTTP를 사용합니다. secret이나 Login이 필요한 계획은 신뢰하는 서버에서 `createHttpExecutor({authorize,resolveSecret,caller})`로 실행합니다. 브라우저에 secret resolver를 넣지 않습니다. 주소 권한·헤더·파라미터·응답 파싱·timeout은 매 요청에 적용합니다. 서비스의 실제 권한·저장소 구현은 패키지에 포함하지 않습니다.
|
|
79
|
+
|
|
80
|
+
URL adapter는 `read`, `subscribe`, `writeOwned(patch,{mode,isCurrent})`를 구현합니다. 비동기 준비 이후 **실제 URL 반영 직전**에 `isCurrent()`를 확인해야 합니다. `mergeOwnedUrl`은 정확히 소유한 키만 변경하고 다른 query 문자열의 원래 인코딩을 보존합니다. View 편의 연결은 `createView/replace`의 `url:{adapter,bindings:[{state,key?,history?}],limits?}`로 사용하며 Store의 직접 `connectUrl`과 동시에 연결할 수 없습니다. cleanup 실패는 새 화면 적용을 완료하고 오류를 기록합니다. 새 초기값이 늦게 준비돼도 남은 옛 URL로 덮지 않으며, 초기값 준비 중 명시한 State 쓰기는 준비 완료 후 URL에 반영합니다.
|
|
81
|
+
|
|
82
|
+
## CEL 지원 및 제한
|
|
83
|
+
|
|
84
|
+
`dist/cel-support.json`에 공개 지원 목록이 포함됩니다. upstream cel-js 8.0.0, 검증된 기존 패치와 production 수정 패치의 SHA-256을 확인해 빌드합니다. 정확한 시그니처는 배포물의 지원 목록을 따릅니다. 전체 CEL 적합성을 주장하지 않습니다. bytes, uint, type, optional, cel.bind 등은 미지원입니다. 날짜는 선언된 문자열/명시적 시간대 계약을 사용합니다. 일반 `number`는 CEL double, `integer`는 안전 정수입니다.
|
|
85
|
+
|
|
86
|
+
CEL AST·비용·결과 크기 제한은 `defaultCelLimits`로 확인할 수 있습니다. 등록 함수는 신뢰하는 호스트의 동기·순수 콜백이며 스키마 검증과 읽기 전용 입력을 적용합니다. 실행 시간 격리나 악성 호스트 콜백 sandbox는 제공하지 않습니다.
|
|
87
|
+
|
|
88
|
+
## 상세 계약과 문서 버전
|
|
89
|
+
|
|
90
|
+
패키지 안에서 확인할 정확한 API는 [기본 타입](dist/index.d.ts), [HTTP 타입](dist/http.d.ts), [CEL 타입](dist/cel.d.ts), 지원 함수 목록은 [CEL 지원 JSON](dist/cel-support.json)이다. 이 파일들은 빌드·tarball에 포함된다. 위 사용 예제는 이 공개 API를 설명한다.
|
|
91
|
+
|
|
92
|
+
다음 링크는 **같은 revision의 소스 저장소에서 읽는 문서**다. 상세 `docs/`는 tarball에 포함되지 않으며 설치 디렉터리를 기준으로 이 상대 링크를 해석하지 않는다.
|
|
93
|
+
|
|
94
|
+
- [전체 계약과 문서 지도](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/README.ko.md): 리소스별 기준 명세와 검증 경로.
|
|
95
|
+
- [스키마 프로필](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/03-variable-type.md), [값·날짜·snapshot](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/10-value-contracts.md).
|
|
96
|
+
- [호스트·권한·초기 완료](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/07-host-integration.md), [Store·reaction·URL](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/09-preserved-contracts.md).
|
|
97
|
+
- [CEL 지원 의미·제한](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/core-cel-support.md), [패치와 재현 빌드](vendor/README.md).
|
|
98
|
+
- [API 정리 이후 검증 결과](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-verification-results.json), [초기 제품 검증 결과](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/core-verification-results.json), [후속 범위](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/open-contracts.md#실제-남은-작업).
|
|
99
|
+
|
|
100
|
+
발행된 tarball에는 해당 소스 커밋의 공개 문서 링크가 포함됩니다.
|
|
101
|
+
|
|
102
|
+
## 재현
|
|
103
|
+
|
|
104
|
+
저장소 루트에서:
|
|
105
|
+
|
|
106
|
+
```sh
|
|
107
|
+
npm ci --ignore-scripts
|
|
108
|
+
npm run check
|
|
109
|
+
npx playwright install chromium
|
|
110
|
+
npm run test:browser
|
|
111
|
+
npm run test:package
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Node 22.21.1·24.1.0 및 Playwright 1.62.1 Chromium으로 검증합니다. Svelte 앱 연결은 별도 [@viewstem/svelte](../svelte/README.ko.md)를 사용합니다. Dart/Flutter와 선택 차트는 후속 패키지 범위입니다. HTTP 실서비스 정책, 다른 브라우저 및 운영 성능은 이 검사로 보장하지 않습니다.
|
|
115
|
+
|
|
116
|
+
빌드는 세 진입점·필수 타입 선언·공통 모듈 chunk를 모두 준비한 뒤 `dist`를 교체하며 이전 빌드의 불필요한 파일을 남기지 않습니다. `npm run check`는 `skip`·`todo`를 통과로 집계하지 않고 실패 처리하며, 인수 대조에는 실제 실행 보고서가 필요합니다.
|
|
117
|
+
|
|
118
|
+
공개 이름 변경은 [U42 이행표](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-naming-2026-11-02.md)를 따릅니다. `registerComponentContract`, `exportResource`, `writeBatch`, `registerReaction`, `getSnapshot`, `getDiagnostics`를 사용하며 이전 이름의 별칭은 제공하지 않습니다. JSON State 선언의 `initial`은 그대로입니다.
|
|
119
|
+
|
|
120
|
+
[이 버전의 소스와 문서](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/README.ko.md)
|
package/README.md
CHANGED
|
@@ -1,3 +1,121 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @viewstem/core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
English | [한국어](README.ko.md)
|
|
4
|
+
|
|
5
|
+
Viewstem is [MIT licensed](LICENSE). Vendored CEL attribution and license text
|
|
6
|
+
are shipped in [THIRD-PARTY-NOTICES.txt](dist/THIRD-PARTY-NOTICES.txt).
|
|
7
|
+
|
|
8
|
+
This ESM library validates declarative UI definitions and runs their values, state, queries, actions, and view lifecycles. It is independent of the DOM, Svelte, and any business domain.
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { createRegistry, createRuntime, defineResourceSet } from '@viewstem/core';
|
|
12
|
+
|
|
13
|
+
const registry = createRegistry();
|
|
14
|
+
registry.registerResourceSet(defineResourceSet({
|
|
15
|
+
id: 'projection-example', version: '1',
|
|
16
|
+
components: [{
|
|
17
|
+
contract: {
|
|
18
|
+
kind: 'Component', id: 'Label',
|
|
19
|
+
spec: { ports: { text: { kind: 'Value', schema: { type: 'string' }, required: true } } },
|
|
20
|
+
},
|
|
21
|
+
connectorId: 'projection-example', implementation: {},
|
|
22
|
+
}],
|
|
23
|
+
}));
|
|
24
|
+
const runtime = createRuntime({ registry });
|
|
25
|
+
const view = await runtime.createView({
|
|
26
|
+
states: { title: { kind: 'State', schema: { type: 'string' }, initial: 'Hello' } },
|
|
27
|
+
render: { id: 'label', componentRef: 'Label', inputs: { text: { '@path': '/states/title' } } },
|
|
28
|
+
});
|
|
29
|
+
await view.whenSettled(view.initial);
|
|
30
|
+
const stop = view.subscribe(snapshot => {
|
|
31
|
+
console.log(snapshot.roots[0]?.inputs.text);
|
|
32
|
+
});
|
|
33
|
+
view.getState('title').write('Updated');
|
|
34
|
+
stop();
|
|
35
|
+
await runtime.dispose();
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
`view.whenSettled(application)` settles once the initial queries eligible to run for this application of the view have succeeded or failed. The UI can observe parts of the view as they become ready. Unready inputs and closed gates do not delay completion, and query errors appear in `(await view.whenSettled(view.initial)).queryErrors`. DOM paint is outside the scope of this signal.
|
|
39
|
+
|
|
40
|
+
## Public API
|
|
41
|
+
|
|
42
|
+
- `createRegistry` registers and validates resources by `(kind, id)`, registers code-backed Components and Actions, lists and describes resources, and exports and explicitly replaces definitions.
|
|
43
|
+
- `createStateStore` manages scopes and State, provides `writeBatch` and synchronous `transaction`, exposes stable read snapshots, and supports `registerReaction` and clock and URL integration. Declare Derived values in the `states` of a View or Component. Disposing the runtime preserves an injected store.
|
|
44
|
+
- `createRuntime()` creates a Registry by default. The Runtime exposes `createView(source, options?)`, `invokeAction(request)`, `registry`, `stateStore`, and `dispose`. A View exposes `setInputs`, `updateDefinition`, `applyResourceSets`, `replace`, `invokeAction`, `whenSettled`, `emit`, `getSnapshot`, `subscribe`, `getState`, `getQuery`, and `exportDefinition`.
|
|
45
|
+
- `mergeOwnedUrl` lets a host URL adapter merge only the keys it owns.
|
|
46
|
+
- `computeGridLayout` calculates a 12-column layout. Grid UI requires separate registration.
|
|
47
|
+
|
|
48
|
+
The root entry point also exports `defineCodeAction` and `defineResourceSet`. Import optional executors from their own entry points.
|
|
49
|
+
|
|
50
|
+
```ts
|
|
51
|
+
import { createHttpExecutor } from '@viewstem/core/http';
|
|
52
|
+
import { compileCel, evaluateCel, defaultCelLimits } from '@viewstem/core/cel';
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
`Registry`, `StateStore`, `Runtime`, and `View` are type-only exports. The factories return objects containing public methods only. Use resource declarations to execute `@path`, `@call`, Query, and Variable. If you used the former constructors or engine exports, follow the [public API migration guide (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-refactor-2026-11-02.md) for the same revision.
|
|
56
|
+
|
|
57
|
+
For exact types and fields, see `dist/index.d.ts`, `dist/http.d.ts`, and `dist/cel.d.ts` in the package. Use the Registry, Store, View, State, and Query handles issued by the library directly. Serializing them as JSON or recreating them as plain objects is unsupported. The runtime isolates Value inputs from their originals and delivers them as read-only values. Sets and maps retain native identity and equality semantics. Conversion to arrays or entry pairs happens only in HTTP plan inputs.
|
|
58
|
+
|
|
59
|
+
## Host integration
|
|
60
|
+
|
|
61
|
+
Render the `roots` from `view.getSnapshot()` or `subscribe()`. Each node includes `instanceId`, `generation`, `status`, `inputs`, `children`, and named `slots`. Pass only the declared payload to `view.emit(node, event, payload)`. Keep DOM event objects in the host. Setting `when:false` or removing a node ends its lifetime. A temporary wait for inputs preserves existing state and execution connections.
|
|
62
|
+
|
|
63
|
+
An existing view keeps the resource definitions it received when it was applied. `registry.updateResource` changes the shared definition, which `view.replace` or a new `createView` call can then apply. `view.updateDefinition` changes only the current view configuration. An update that changes a retained cell between State and Derived fails because the write contracts differ. Changing or exporting State, the current view, and shared definitions is separate from database persistence.
|
|
64
|
+
|
|
65
|
+
For code Actions, declare every required input with `required: true`. A Value port with a default is optional in the handler because the caller may bind a missing value. `updateResource` preserves the code Action's input and output contracts, including referenced Types. Register changes under a new Action ID with its handler and update the callers.
|
|
66
|
+
|
|
67
|
+
If a subscriber writes State while the View is computing or publishing a projection, the runtime queues a follow-up projection. Listeners finish receiving the current immutable snapshot before the new projection is published. Several writes in that interval are combined into one follow-up; writing the same value does not create another State change. Inspect a subsequent snapshot for the resulting node inputs and use the renderer's completion mechanism for DOM updates.
|
|
68
|
+
|
|
69
|
+
`authorize` checks permission to execute Actions or modify an existing View. It grants permission only when it returns `true`. For Action calls, use the readonly `resource` value from the invocation's Registry snapshot to identify a registered Action by `{ kind: 'Action', id }`. An inline Action passes `null`. Each child call identifies its own target. The host configures resource-list visibility, user identity, and persistence permissions.
|
|
70
|
+
|
|
71
|
+
For `update`, the owner is the same public View object returned by `createView`. For `invoke`, the owner is an opaque identity object used only for comparisons within a lifetime. It exposes no execution methods. Authorization callbacks receive definitions without the implementation functions of registered code-backed Actions.
|
|
72
|
+
|
|
73
|
+
Use `defineCodeAction({ definition, requires? })` to capture a contract and `.implement(handler)` to create a typed entry. Pass that entry to `defineResourceSet({ actions: [entry], ... })`, or bind a new handler to the same contract and pass the entry to `registry.replaceResource({ action: entry })`. Use `defineCodeAction<Inputs, Output>()` to type referenced schemas.
|
|
74
|
+
|
|
75
|
+
`runtime.invokeAction(request)` and `view.invokeAction(request)` start independent invocations. Pass `signal: AbortSignal` to cancel that invocation and its descendants. `context.invokeAction` inherits the parent's cancellation and recursion stack. A cancelled invocation rejects with `CANCELLED`, and effects that already succeeded persist.
|
|
76
|
+
|
|
77
|
+
## HTTP and URLs
|
|
78
|
+
|
|
79
|
+
The runtime uses native fetch for public HTTP unless you inject `requestExecutor(plan, {signal})`. Execute plans that require a secret or Login on a trusted server with `createHttpExecutor({authorize,resolveSecret,caller})`. Keep the secret resolver on the server. Destination authorization, headers, parameters, response parsing, and timeouts apply to each request. The package leaves service-specific authorization and storage to the host.
|
|
80
|
+
|
|
81
|
+
A URL adapter implements `read`, `subscribe`, and `writeOwned(patch,{mode,isCurrent})`. After asynchronous preparation, check `isCurrent()` **immediately before writing the URL**. `mergeOwnedUrl` changes only the keys it owns and preserves the original encoding of other query parameters. For view-level integration, pass `url:{adapter,bindings:[{state,key?,history?}],limits?}` to `createView` or `replace`. This integration and the store's direct `connectUrl` are mutually exclusive. If cleanup fails, the runtime finishes applying the new view and records the error. Late-arriving initial values take precedence over leftover URL values. An explicit State write while initial values are pending is reflected in the URL after initialization.
|
|
82
|
+
|
|
83
|
+
## CEL support and limits
|
|
84
|
+
|
|
85
|
+
`dist/cel-support.json` lists the supported public CEL surface. The build verifies SHA-256 hashes for upstream cel-js 8.0.0, the previously verified patches, and the production fixes. Use the support list shipped in the package for exact signatures. Support is limited to that profile, which excludes features such as bytes, uint, type, optional, and cel.bind. Dates follow the declared string format and explicit time zone contract. A general `number` is a CEL double, and an `integer` is a safe integer.
|
|
86
|
+
|
|
87
|
+
See `defaultCelLimits` for CEL AST, cost, and result size limits. Registered functions are synchronous, pure callbacks from a trusted host. They receive schema-validated, read-only inputs. The runtime provides no execution-time isolation or sandbox for malicious host callbacks.
|
|
88
|
+
|
|
89
|
+
## Detailed contracts and documentation versions
|
|
90
|
+
|
|
91
|
+
The package's [core types](dist/index.d.ts), [HTTP types](dist/http.d.ts), and [CEL types](dist/cel.d.ts) define the exact API. [CEL support JSON](dist/cel-support.json) lists the supported functions. The build and tarball include these files, and the examples above illustrate this public API.
|
|
92
|
+
|
|
93
|
+
Read the following links in the **source repository at the same revision**. The tarball omits detailed `docs/` files, so resolve these relative links from the source checkout.
|
|
94
|
+
|
|
95
|
+
- The [specification and documentation map](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/README.md) points to resource contracts and verification procedures.
|
|
96
|
+
- [Schema profile (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/03-variable-type.md) and [values, dates, and snapshots (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/10-value-contracts.md).
|
|
97
|
+
- [Host integration, permissions, and initial completion (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/07-host-integration.md) and [store, reactions, and URLs (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/spec/09-preserved-contracts.md).
|
|
98
|
+
- [CEL semantics and limits (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/core-cel-support.md) and [patches and reproducible builds](vendor/README.md).
|
|
99
|
+
- [Verification after the public API refactor](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-verification-results.json), [initial product verification](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/core-verification-results.json), and [remaining work (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/open-contracts.md#실제-남은-작업).
|
|
100
|
+
|
|
101
|
+
Published tarballs link to the documentation at their source commit.
|
|
102
|
+
|
|
103
|
+
## Reproduce verification
|
|
104
|
+
|
|
105
|
+
Run these commands from the repository root.
|
|
106
|
+
|
|
107
|
+
```sh
|
|
108
|
+
npm ci --ignore-scripts
|
|
109
|
+
npm run check
|
|
110
|
+
npx playwright install chromium
|
|
111
|
+
npm run test:browser
|
|
112
|
+
npm run test:package
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Verification uses Node 22.21.1 and 24.1.0 and Chromium from Playwright 1.62.1. Use [@viewstem/svelte](../svelte/README.md) to integrate with a Svelte app. Dart/Flutter and optional charts are follow-up packages. These checks cover the tested environment. Production HTTP policies, other browsers, and production performance are outside their scope.
|
|
116
|
+
|
|
117
|
+
The build prepares all three entry points, the required type declarations, and the shared module chunks before replacing `dist`. Replacing the directory clears obsolete build artifacts. `npm run check` treats `skip` and `todo` as failures. Acceptance comparisons require a report from an actual run.
|
|
118
|
+
|
|
119
|
+
See the [U42 migration table (Korean)](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/handoff/public-api-naming-2026-11-02.md) for public naming changes. Use `registerComponentContract`, `exportResource`, `writeBatch`, `registerReaction`, `getSnapshot`, and `getDiagnostics`. Previous names have no aliases. JSON State declarations still use `initial`.
|
|
120
|
+
|
|
121
|
+
[Source and documentation for this version](https://github.com/miinhlym/viewstem/blob/da46e078af0c11f28f4102bb132ec7e2445c464f/docs/README.md)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
cel-js 8.0.0 with Viewstem patches
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2025 Marc Bachmann
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"upstream": [
|
|
3
|
+
"dyn(dyn): dyn",
|
|
4
|
+
"bool(bool): bool",
|
|
5
|
+
"bool(string): bool",
|
|
6
|
+
"size(string): int",
|
|
7
|
+
"size(list<dyn>): int",
|
|
8
|
+
"size(map<dyn, dyn>): int",
|
|
9
|
+
"string.size(): int",
|
|
10
|
+
"list<dyn>.size(): int",
|
|
11
|
+
"map<dyn, dyn>.size(): int",
|
|
12
|
+
"double(double): double",
|
|
13
|
+
"double(int): double",
|
|
14
|
+
"double(string): double",
|
|
15
|
+
"int(int): int",
|
|
16
|
+
"int(double): int",
|
|
17
|
+
"int(string): int",
|
|
18
|
+
"string(string): string",
|
|
19
|
+
"string(bool): string",
|
|
20
|
+
"string(int): string",
|
|
21
|
+
"string(double): string",
|
|
22
|
+
"string.startsWith(string): bool",
|
|
23
|
+
"string.endsWith(string): bool",
|
|
24
|
+
"string.contains(string): bool",
|
|
25
|
+
"string.lowerAscii(): string",
|
|
26
|
+
"string.upperAscii(): string",
|
|
27
|
+
"string.trim(): string",
|
|
28
|
+
"string.indexOf(string): int",
|
|
29
|
+
"string.indexOf(string, int): int",
|
|
30
|
+
"string.lastIndexOf(string): int",
|
|
31
|
+
"string.lastIndexOf(string, int): int",
|
|
32
|
+
"string.substring(int): string",
|
|
33
|
+
"string.substring(int, int): string",
|
|
34
|
+
"string.matches(string): bool",
|
|
35
|
+
"matches(string, string): bool",
|
|
36
|
+
"string.split(string): list<string>",
|
|
37
|
+
"string.split(string, int): list<string>",
|
|
38
|
+
"list<string>.join(): string",
|
|
39
|
+
"list<string>.join(string): string",
|
|
40
|
+
"timestamp(string): google.protobuf.Timestamp",
|
|
41
|
+
"timestamp(int): google.protobuf.Timestamp",
|
|
42
|
+
"google.protobuf.Timestamp.getDate(): int",
|
|
43
|
+
"google.protobuf.Timestamp.getDate(string): int",
|
|
44
|
+
"google.protobuf.Timestamp.getDayOfMonth(): int",
|
|
45
|
+
"google.protobuf.Timestamp.getDayOfMonth(string): int",
|
|
46
|
+
"google.protobuf.Timestamp.getDayOfWeek(): int",
|
|
47
|
+
"google.protobuf.Timestamp.getDayOfWeek(string): int",
|
|
48
|
+
"google.protobuf.Timestamp.getDayOfYear(): int",
|
|
49
|
+
"google.protobuf.Timestamp.getDayOfYear(string): int",
|
|
50
|
+
"google.protobuf.Timestamp.getFullYear(): int",
|
|
51
|
+
"google.protobuf.Timestamp.getFullYear(string): int",
|
|
52
|
+
"google.protobuf.Timestamp.getHours(): int",
|
|
53
|
+
"google.protobuf.Timestamp.getHours(string): int",
|
|
54
|
+
"google.protobuf.Timestamp.getMilliseconds(): int",
|
|
55
|
+
"google.protobuf.Timestamp.getMilliseconds(string): int",
|
|
56
|
+
"google.protobuf.Timestamp.getMinutes(): int",
|
|
57
|
+
"google.protobuf.Timestamp.getMinutes(string): int",
|
|
58
|
+
"google.protobuf.Timestamp.getMonth(): int",
|
|
59
|
+
"google.protobuf.Timestamp.getMonth(string): int",
|
|
60
|
+
"google.protobuf.Timestamp.getSeconds(): int",
|
|
61
|
+
"google.protobuf.Timestamp.getSeconds(string): int",
|
|
62
|
+
"duration(string): google.protobuf.Duration",
|
|
63
|
+
"google.protobuf.Duration.getHours(): int",
|
|
64
|
+
"google.protobuf.Duration.getMinutes(): int",
|
|
65
|
+
"google.protobuf.Duration.getSeconds(): int",
|
|
66
|
+
"google.protobuf.Duration.getMilliseconds(): int",
|
|
67
|
+
"has(ast): bool",
|
|
68
|
+
"list<dyn>.all(ast, ast): bool",
|
|
69
|
+
"list<dyn>.exists(ast, ast): bool",
|
|
70
|
+
"list<dyn>.exists_one(ast, ast): bool",
|
|
71
|
+
"list<dyn>.map(ast, ast): list<dyn>",
|
|
72
|
+
"list<dyn>.map(ast, ast, ast): list<dyn>",
|
|
73
|
+
"list<dyn>.filter(ast, ast): list<dyn>"
|
|
74
|
+
],
|
|
75
|
+
"native": [
|
|
76
|
+
"setSize(NativeSet): int",
|
|
77
|
+
"setHas(NativeSet, dyn): bool",
|
|
78
|
+
"setSame(NativeSet, NativeSet): bool",
|
|
79
|
+
"mapSize(NativeMap): int",
|
|
80
|
+
"mapSame(NativeMap, NativeMap): bool",
|
|
81
|
+
"mapHas(NativeMap, int): bool",
|
|
82
|
+
"mapGet(NativeMap, int): dyn",
|
|
83
|
+
"mapHas(NativeMap, double): bool",
|
|
84
|
+
"mapGet(NativeMap, double): dyn",
|
|
85
|
+
"mapHas(NativeMap, string): bool",
|
|
86
|
+
"mapGet(NativeMap, string): dyn",
|
|
87
|
+
"dateText(DateValue): string",
|
|
88
|
+
"dateKind(DateValue): string",
|
|
89
|
+
"localDate(int, string): string",
|
|
90
|
+
"addDate(string, int): string",
|
|
91
|
+
"atLocal(string, string, string): string",
|
|
92
|
+
"startOfDay(string, string): string",
|
|
93
|
+
"nextDayStart(string, string): string",
|
|
94
|
+
"parseYY(string): int"
|
|
95
|
+
],
|
|
96
|
+
"excluded": [
|
|
97
|
+
"bytes and byte literals",
|
|
98
|
+
"uint and uint literals",
|
|
99
|
+
"type reflection",
|
|
100
|
+
"optional namespace/types/syntax",
|
|
101
|
+
"cel.bind namespace extension"
|
|
102
|
+
],
|
|
103
|
+
"notes": [
|
|
104
|
+
"Syntax signatures containing ast are macros.",
|
|
105
|
+
"Timestamp/duration are internal intermediates only; no implicit conversion to public date/time/datetime.",
|
|
106
|
+
"All signatures are a supported surface inventory, not full CEL conformance evidence."
|
|
107
|
+
]
|
|
108
|
+
}
|
package/dist/cel.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CelFunction, Schema } from './index.js';
|
|
2
|
+
export type { CelFunction, CelValue } from './index.js';
|
|
3
|
+
|
|
4
|
+
export interface CelLimits { readonly expressionChars: number; readonly inputNodes: number; readonly outputNodes: number; readonly valueBytes: number; readonly depth: number }
|
|
5
|
+
export const defaultCelLimits: CelLimits;
|
|
6
|
+
export interface CelOptions { readonly inputs?: Readonly<Record<string, Schema>>; readonly output?: Schema; readonly functions?: readonly CelFunction[]; readonly limits?: Partial<CelLimits>; readonly cost?: number }
|
|
7
|
+
export function compileCel(expression: string, options?: CelOptions): (bindings?: Readonly<Record<string, unknown>>) => unknown;
|
|
8
|
+
export function evaluateCel(expression: string, bindings: Readonly<Record<string, unknown>>, options?: CelOptions): unknown;
|
|
9
|
+
|
|
10
|
+
export {};
|
package/dist/cel.js
ADDED