@pactor-app/runtime 1.56.0 → 1.58.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/dist/index.cjs CHANGED
@@ -28,7 +28,9 @@ __export(index_exports, {
28
28
  I18nContextProvider: () => I18nContextProvider,
29
29
  LocalizationProtocolError: () => LocalizationProtocolError,
30
30
  PageRuntimeError: () => PageRuntimeError,
31
+ PageRuntimeVersionError: () => PageRuntimeVersionError,
31
32
  PageRuntimeView: () => PageRuntimeView,
33
+ RUNTIME_VERSION: () => RUNTIME_VERSION,
32
34
  StateStore: () => StateStore,
33
35
  UnsupportedComponent: () => UnsupportedComponent,
34
36
  buildScope: () => buildScope,
@@ -1898,6 +1900,15 @@ function isEmbeddedDslNode(value) {
1898
1900
  // src/page/page-runtime.tsx
1899
1901
  var import_core6 = require("@pactor-app/core");
1900
1902
  var import_schema2 = require("@pactor-app/schema");
1903
+ var import_semver = require("semver");
1904
+
1905
+ // package.json
1906
+ var version = "1.58.0";
1907
+
1908
+ // src/version.ts
1909
+ var RUNTIME_VERSION = version;
1910
+
1911
+ // src/page/page-runtime.tsx
1901
1912
  var import_jsx_runtime4 = require("react/jsx-runtime");
1902
1913
  var PageRuntimeError = class extends Error {
1903
1914
  constructor(errors) {
@@ -1908,7 +1919,38 @@ var PageRuntimeError = class extends Error {
1908
1919
  this.errors = errors;
1909
1920
  }
1910
1921
  };
1922
+ var PageRuntimeVersionError = class extends PageRuntimeError {
1923
+ constructor(requirement, runtimeVersion, message) {
1924
+ super([{ path: "/requires/runtime", keyword: "version", message }]);
1925
+ this.name = "PageRuntimeVersionError";
1926
+ this.requirement = requirement;
1927
+ this.runtimeVersion = runtimeVersion;
1928
+ }
1929
+ };
1930
+ function assertRuntimeVersion(pageDsl) {
1931
+ const requirement = pageDsl?.requires?.runtime;
1932
+ if (typeof requirement !== "string") {
1933
+ return;
1934
+ }
1935
+ const pageId = pageDsl?.page?.id;
1936
+ const label = pageId === void 0 ? "\u9875\u9762" : `\u9875\u9762\uFF08${pageId}\uFF09`;
1937
+ if ((0, import_semver.validRange)(requirement) === null) {
1938
+ throw new PageRuntimeVersionError(
1939
+ requirement,
1940
+ RUNTIME_VERSION,
1941
+ `${label}\u7684 requires.runtime \u4E0D\u662F\u5408\u6CD5\u7684\u7248\u672C\u8303\u56F4\uFF1A"${requirement}"`
1942
+ );
1943
+ }
1944
+ if (!(0, import_semver.satisfies)(RUNTIME_VERSION, requirement)) {
1945
+ throw new PageRuntimeVersionError(
1946
+ requirement,
1947
+ RUNTIME_VERSION,
1948
+ `${label}\u8981\u6C42 Runtime ${requirement}\uFF0C\u5F53\u524D Runtime \u7248\u672C\u4E3A ${RUNTIME_VERSION}`
1949
+ );
1950
+ }
1951
+ }
1911
1952
  function createPageRuntime(pageDsl, options = {}) {
1953
+ assertRuntimeVersion(pageDsl);
1912
1954
  const validation = (0, import_schema2.validatePageDsl)(pageDsl);
1913
1955
  if (!validation.valid) {
1914
1956
  throw new PageRuntimeError(validation.errors);
@@ -2064,7 +2106,9 @@ function renderRootItems(items, context, engine, children) {
2064
2106
  I18nContextProvider,
2065
2107
  LocalizationProtocolError,
2066
2108
  PageRuntimeError,
2109
+ PageRuntimeVersionError,
2067
2110
  PageRuntimeView,
2111
+ RUNTIME_VERSION,
2068
2112
  StateStore,
2069
2113
  UnsupportedComponent,
2070
2114
  buildScope,
package/dist/index.d.cts CHANGED
@@ -522,6 +522,17 @@ declare class PageRuntimeError extends Error {
522
522
  readonly errors: DslValidationError[];
523
523
  constructor(errors: DslValidationError[]);
524
524
  }
525
+ /**
526
+ * Runtime 版本不满足 Page DSL `requires.runtime` 声明的错误。
527
+ * 继承 `PageRuntimeError`,宿主现有的「DSL 校验失败」处理可直接复用。
528
+ */
529
+ declare class PageRuntimeVersionError extends PageRuntimeError {
530
+ /** 页面声明的版本范围(requires.runtime) */
531
+ readonly requirement: string;
532
+ /** 当前 Runtime 版本 */
533
+ readonly runtimeVersion: string;
534
+ constructor(requirement: string, runtimeVersion: string, message: string);
535
+ }
525
536
  /**
526
537
  * PageRuntime(设计文档第 20、89 节,决策 D6):
527
538
  * PageDsl → 校验 → RuntimeContext → 初始化 state / dataSources(autoLoad)
@@ -571,4 +582,10 @@ declare function PageRuntimeView({ runtime, children, }: {
571
582
  children?: ReactNode;
572
583
  }): ReactNode;
573
584
 
574
- export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type LocalizationMode, LocalizationProtocolError, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type ResolveDeepOptions, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
585
+ /**
586
+ * 当前 Runtime 版本(构建时从 package.json 注入)。
587
+ * 用于 Page DSL `requires.runtime` 的版本兼容性校验。
588
+ */
589
+ declare const RUNTIME_VERSION: string;
590
+
591
+ export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type LocalizationMode, LocalizationProtocolError, type PageRuntime, PageRuntimeError, PageRuntimeVersionError, PageRuntimeView, type PermissionAdapter, RUNTIME_VERSION, type RendererContextValue, type ResolveDeepOptions, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
package/dist/index.d.ts CHANGED
@@ -522,6 +522,17 @@ declare class PageRuntimeError extends Error {
522
522
  readonly errors: DslValidationError[];
523
523
  constructor(errors: DslValidationError[]);
524
524
  }
525
+ /**
526
+ * Runtime 版本不满足 Page DSL `requires.runtime` 声明的错误。
527
+ * 继承 `PageRuntimeError`,宿主现有的「DSL 校验失败」处理可直接复用。
528
+ */
529
+ declare class PageRuntimeVersionError extends PageRuntimeError {
530
+ /** 页面声明的版本范围(requires.runtime) */
531
+ readonly requirement: string;
532
+ /** 当前 Runtime 版本 */
533
+ readonly runtimeVersion: string;
534
+ constructor(requirement: string, runtimeVersion: string, message: string);
535
+ }
525
536
  /**
526
537
  * PageRuntime(设计文档第 20、89 节,决策 D6):
527
538
  * PageDsl → 校验 → RuntimeContext → 初始化 state / dataSources(autoLoad)
@@ -571,4 +582,10 @@ declare function PageRuntimeView({ runtime, children, }: {
571
582
  children?: ReactNode;
572
583
  }): ReactNode;
573
584
 
574
- export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type LocalizationMode, LocalizationProtocolError, type PageRuntime, PageRuntimeError, PageRuntimeView, type PermissionAdapter, type RendererContextValue, type ResolveDeepOptions, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
585
+ /**
586
+ * 当前 Runtime 版本(构建时从 package.json 注入)。
587
+ * 用于 Page DSL `requires.runtime` 的版本兼容性校验。
588
+ */
589
+ declare const RUNTIME_VERSION: string;
590
+
591
+ export { type ActionContext, ActionEngine, type ActionHandler, type ActionRegistry, type ActionResult, type CapabilityRegistry, type ComponentEntry, type ComponentRegistry, type CreateRuntimeContextOptions, type DataSourceStatus, DataStore, type DataStoreDeps, DslRenderer, type DslRendererProps, DslSourceBoundary, type DslSourceBoundaryProps, DslSourceResolver, type DslSourceResolverDeps, type FormHandle, type FormRegistry, type HttpAdapter, type HttpRequestConfig, I18nContextProvider, type LocalScope, type LocalizationMode, LocalizationProtocolError, type PageRuntime, PageRuntimeError, PageRuntimeVersionError, PageRuntimeView, type PermissionAdapter, RUNTIME_VERSION, type RendererContextValue, type ResolveDeepOptions, type RouteContext, type RouterAdapter, type RuntimeContext, type ScopedComponentEntry, type ServiceHandler, type ServiceRegistry, StateStore, UnsupportedComponent, buildScope, createDefaultPermissionAdapter, createDefaultRouterAdapter, createFetchHttpAdapter, createPageRuntime, createRuntimeContext, dslSourceKey, registerBuiltinActions, resolveDeep, useDataSource, useI18n, useRenderer, useRuntimeState };
package/dist/index.js CHANGED
@@ -1871,6 +1871,15 @@ import {
1871
1871
  validateDslNodes as validateDslNodes2,
1872
1872
  validatePageDsl
1873
1873
  } from "@pactor-app/schema";
1874
+ import { satisfies, validRange } from "semver";
1875
+
1876
+ // package.json
1877
+ var version = "1.58.0";
1878
+
1879
+ // src/version.ts
1880
+ var RUNTIME_VERSION = version;
1881
+
1882
+ // src/page/page-runtime.tsx
1874
1883
  import { Fragment as Fragment2, jsx as jsx3 } from "react/jsx-runtime";
1875
1884
  var PageRuntimeError = class extends Error {
1876
1885
  constructor(errors) {
@@ -1881,7 +1890,38 @@ var PageRuntimeError = class extends Error {
1881
1890
  this.errors = errors;
1882
1891
  }
1883
1892
  };
1893
+ var PageRuntimeVersionError = class extends PageRuntimeError {
1894
+ constructor(requirement, runtimeVersion, message) {
1895
+ super([{ path: "/requires/runtime", keyword: "version", message }]);
1896
+ this.name = "PageRuntimeVersionError";
1897
+ this.requirement = requirement;
1898
+ this.runtimeVersion = runtimeVersion;
1899
+ }
1900
+ };
1901
+ function assertRuntimeVersion(pageDsl) {
1902
+ const requirement = pageDsl?.requires?.runtime;
1903
+ if (typeof requirement !== "string") {
1904
+ return;
1905
+ }
1906
+ const pageId = pageDsl?.page?.id;
1907
+ const label = pageId === void 0 ? "\u9875\u9762" : `\u9875\u9762\uFF08${pageId}\uFF09`;
1908
+ if (validRange(requirement) === null) {
1909
+ throw new PageRuntimeVersionError(
1910
+ requirement,
1911
+ RUNTIME_VERSION,
1912
+ `${label}\u7684 requires.runtime \u4E0D\u662F\u5408\u6CD5\u7684\u7248\u672C\u8303\u56F4\uFF1A"${requirement}"`
1913
+ );
1914
+ }
1915
+ if (!satisfies(RUNTIME_VERSION, requirement)) {
1916
+ throw new PageRuntimeVersionError(
1917
+ requirement,
1918
+ RUNTIME_VERSION,
1919
+ `${label}\u8981\u6C42 Runtime ${requirement}\uFF0C\u5F53\u524D Runtime \u7248\u672C\u4E3A ${RUNTIME_VERSION}`
1920
+ );
1921
+ }
1922
+ }
1884
1923
  function createPageRuntime(pageDsl, options = {}) {
1924
+ assertRuntimeVersion(pageDsl);
1885
1925
  const validation = validatePageDsl(pageDsl);
1886
1926
  if (!validation.valid) {
1887
1927
  throw new PageRuntimeError(validation.errors);
@@ -2036,7 +2076,9 @@ export {
2036
2076
  I18nContextProvider,
2037
2077
  LocalizationProtocolError,
2038
2078
  PageRuntimeError,
2079
+ PageRuntimeVersionError,
2039
2080
  PageRuntimeView,
2081
+ RUNTIME_VERSION,
2040
2082
  StateStore,
2041
2083
  UnsupportedComponent,
2042
2084
  buildScope,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pactor-app/runtime",
3
- "version": "1.56.0",
3
+ "version": "1.58.0",
4
4
  "description": "Pactor runtime: RuntimeContext, StateStore, DataSource runtime, action engine, React renderer and page runtime",
5
5
  "keywords": [
6
6
  "pactor",
@@ -45,9 +45,10 @@
45
45
  "access": "public"
46
46
  },
47
47
  "dependencies": {
48
- "@pactor-app/expression": "1.56.0",
49
- "@pactor-app/core": "1.56.0",
50
- "@pactor-app/schema": "1.56.0"
48
+ "semver": "^7.8.5",
49
+ "@pactor-app/core": "1.58.0",
50
+ "@pactor-app/expression": "1.58.0",
51
+ "@pactor-app/schema": "1.58.0"
51
52
  },
52
53
  "peerDependencies": {
53
54
  "react": ">=18"
@@ -57,6 +58,7 @@
57
58
  "@testing-library/react": "^16.3.2",
58
59
  "@types/react": "^19.2.18",
59
60
  "@types/react-dom": "^19.2.4",
61
+ "@types/semver": "^7.8.0",
60
62
  "jsdom": "^30.0.1",
61
63
  "react": "^19.2.8",
62
64
  "react-dom": "^19.2.8"