@promptframe/component-kit 0.1.9 → 0.1.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 CHANGED
@@ -11,6 +11,7 @@ npm install @promptframe/component-kit
11
11
  - Standard version stamps for component metadata, sourced from `@promptframe/contracts`.
12
12
  - Preview constraints used by PromptFrame component tooling.
13
13
  - Bounded local preview case matrix helpers for aspect and default-props stress checks.
14
+ - `public/` resource lookup helper for runtime-injected component resources with local-dev fallback.
14
15
  - Timing helpers for deterministic fps-aware timing and frame-driven animations.
15
16
  - Public style helpers backed by `@promptframe/contracts`.
16
17
 
@@ -25,6 +26,19 @@ export const manifest = {
25
26
  };
26
27
  ```
27
28
 
29
+ ```ts
30
+ import { promptFramePublicResource, type PromptFrameRuntimeResourceProps } from '@promptframe/component-kit';
31
+
32
+ type Props = PromptFrameRuntimeResourceProps & {
33
+ title: string;
34
+ };
35
+
36
+ export function Component(props: Props) {
37
+ const logoSrc = promptFramePublicResource(props, '/logo.png', '/fallback-logo.png');
38
+ return logoSrc;
39
+ }
40
+ ```
41
+
28
42
  ```ts
29
43
  import { COMPONENT_PREVIEW_CONSTRAINTS, createPreviewCaseMatrix } from '@promptframe/component-kit/preview';
30
44
 
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './preview.js';
2
+ export * from './resources.js';
2
3
  export * from './standard.js';
3
4
  export * from './style.js';
4
5
  export * from './timing.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './preview.js';
2
+ export * from './resources.js';
2
3
  export * from './standard.js';
3
4
  export * from './style.js';
4
5
  export * from './timing.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { type ComponentRuntimeResourceManifest } from '@promptframe/contracts';
2
+ export type PromptFrameRuntimeResources = ComponentRuntimeResourceManifest;
3
+ export interface PromptFrameRuntimeResourceProps {
4
+ promptFrameResources?: PromptFrameRuntimeResources;
5
+ }
6
+ export declare function promptFramePublicResource(resourcesOrProps: PromptFrameRuntimeResources | PromptFrameRuntimeResourceProps | undefined, publicPath: string, fallback?: string): string;
7
+ export declare function normalizePromptFramePublicResourcePath(publicPath: string): `/${string}` | undefined;
8
+ //# sourceMappingURL=resources.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,wBAAwB,CAAC;AAEhC,MAAM,MAAM,2BAA2B,GAAG,gCAAgC,CAAC;AAE3E,MAAM,WAAW,+BAA+B;IAC9C,oBAAoB,CAAC,EAAE,2BAA2B,CAAC;CACpD;AAED,wBAAgB,yBAAyB,CACvC,gBAAgB,EAAE,2BAA2B,GAAG,+BAA+B,GAAG,SAAS,EAC3F,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,MAAM,GAChB,MAAM,CAOR;AAED,wBAAgB,sCAAsC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,MAAM,EAAE,GAAG,SAAS,CASnG"}
@@ -0,0 +1,39 @@
1
+ import { COMPONENT_PUBLIC_RESOURCES_CONTRACT_VERSION, } from '@promptframe/contracts';
2
+ export function promptFramePublicResource(resourcesOrProps, publicPath, fallback) {
3
+ const normalized = normalizePromptFramePublicResourcePath(publicPath);
4
+ if (!normalized)
5
+ return fallback ?? '';
6
+ const resources = extractPromptFrameRuntimeResources(resourcesOrProps);
7
+ const match = resources?.entries.find((entry) => entry.publicPath === normalized);
8
+ return match?.url ?? fallback ?? normalized;
9
+ }
10
+ export function normalizePromptFramePublicResourcePath(publicPath) {
11
+ const value = publicPath.trim();
12
+ if (!value || value !== publicPath)
13
+ return undefined;
14
+ if (/^[a-z][a-z0-9+.-]*:/i.test(value) || value.startsWith('//') || value.includes('\\'))
15
+ return undefined;
16
+ const withSlash = value.startsWith('/') ? value : `/${value}`;
17
+ if (withSlash.includes('//'))
18
+ return undefined;
19
+ const parts = withSlash.slice(1).split('/');
20
+ if (parts.some((part) => !part || part === '.' || part === '..'))
21
+ return undefined;
22
+ return /^[A-Za-z0-9._~!$&'()+,;=@/-]+$/.test(withSlash) ? withSlash : undefined;
23
+ }
24
+ function extractPromptFrameRuntimeResources(resourcesOrProps) {
25
+ if (!resourcesOrProps)
26
+ return undefined;
27
+ const candidate = hasRuntimeResourceEntries(resourcesOrProps)
28
+ ? resourcesOrProps
29
+ : resourcesOrProps.promptFrameResources;
30
+ if (!candidate || candidate.contractVersion !== COMPONENT_PUBLIC_RESOURCES_CONTRACT_VERSION)
31
+ return undefined;
32
+ return candidate;
33
+ }
34
+ function hasRuntimeResourceEntries(value) {
35
+ return typeof value === 'object'
36
+ && value !== null
37
+ && Array.isArray(value.entries);
38
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,CAAC,CAAC;IAC5C,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,IAAI,IAAI,KAAK,GAAG,IAAI,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,SAAS,CAAC;IACnF,OAAO,gCAAgC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAyB,CAAC,CAAC,CAAC,SAAS,CAAC;AAClG,CAAC;AAED,SAAS,kCAAkC,CACzC,gBAA2F;IAE3F,IAAI,CAAC,gBAAgB;QAAE,OAAO,SAAS,CAAC;IACxC,MAAM,SAAS,GAAG,yBAAyB,CAAC,gBAAgB,CAAC;QAC3D,CAAC,CAAC,gBAAgB;QAClB,CAAC,CAAC,gBAAgB,CAAC,oBAAoB,CAAC;IAC1C,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC,eAAe,KAAK,2CAA2C;QAAE,OAAO,SAAS,CAAC;IAC9G,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,yBAAyB,CAAC,KAAc;IAC/C,OAAO,OAAO,KAAK,KAAK,QAAQ;WAC3B,KAAK,KAAK,IAAI;WACd,KAAK,CAAC,OAAO,CAAE,KAA+B,CAAC,OAAO,CAAC,CAAC;AAC/D,CAAC"}
@@ -1,14 +1,14 @@
1
1
  export declare const COMPONENT_STANDARD_VERSION: "component-standard.v0.1.0";
2
2
  export declare const COMPONENT_STANDARD_SOURCE_HASH: "sha256:8c1e01c36155b4b646981064d24df9bd8cda501fd9cd9da93e5b62f40db22d52";
3
3
  export declare const COMPONENT_STANDARD_SOURCE_PATH: "https://github.com/ty-teams/promptframe-component-authoring#readme";
4
- export declare const COMPONENT_KIT_VERSION: "0.1.9";
4
+ export declare const COMPONENT_KIT_VERSION: "0.1.11";
5
5
  export declare const COMPONENT_MANIFEST_SCHEMA_VERSION: "component-manifest.v0.1.0";
6
6
  export declare const COMPONENT_REVIEW_CHECKLIST_VERSION: "component-review-checklist.v0.1.0";
7
7
  export declare function getComponentStandardStamp(): {
8
8
  sourceVersion: "component-standard.v0.1.0";
9
9
  sourceHash: "sha256:8c1e01c36155b4b646981064d24df9bd8cda501fd9cd9da93e5b62f40db22d52";
10
10
  sourcePath: "https://github.com/ty-teams/promptframe-component-authoring#readme";
11
- componentKitVersion: "0.1.9";
11
+ componentKitVersion: "0.1.11";
12
12
  manifestSchemaVersion: "component-manifest.v0.1.0";
13
13
  reviewChecklistVersion: "component-review-checklist.v0.1.0";
14
14
  };
@@ -1 +1 @@
1
- {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,0BAA0B,6BAAuC,CAAC;AAC/E,eAAO,MAAM,8BAA8B,2EAA2C,CAAC;AACvF,eAAO,MAAM,8BAA8B,EAAG,oEAA6E,CAAC;AAC5H,eAAO,MAAM,qBAAqB,EAAG,OAAgB,CAAC;AACtD,eAAO,MAAM,iCAAiC,6BAA8C,CAAC;AAC7F,eAAO,MAAM,kCAAkC,EAAG,mCAA4C,CAAC;AAE/F,wBAAgB,yBAAyB;;;;;;;EASxC"}
1
+ {"version":3,"file":"standard.d.ts","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,0BAA0B,6BAAuC,CAAC;AAC/E,eAAO,MAAM,8BAA8B,2EAA2C,CAAC;AACvF,eAAO,MAAM,8BAA8B,EAAG,oEAA6E,CAAC;AAC5H,eAAO,MAAM,qBAAqB,EAAG,QAAiB,CAAC;AACvD,eAAO,MAAM,iCAAiC,6BAA8C,CAAC;AAC7F,eAAO,MAAM,kCAAkC,EAAG,mCAA4C,CAAC;AAE/F,wBAAgB,yBAAyB;;;;;;;EASxC"}
package/dist/standard.js CHANGED
@@ -2,7 +2,7 @@ import { COMPONENT_MANIFEST_SCHEMA_VERSION as CONTRACTS_COMPONENT_MANIFEST_SCHEM
2
2
  export const COMPONENT_STANDARD_VERSION = CONTRACTS_COMPONENT_STANDARD_VERSION;
3
3
  export const COMPONENT_STANDARD_SOURCE_HASH = CONTRACTS_COMPONENT_STANDARD_SOURCE_HASH;
4
4
  export const COMPONENT_STANDARD_SOURCE_PATH = 'https://github.com/ty-teams/promptframe-component-authoring#readme';
5
- export const COMPONENT_KIT_VERSION = '0.1.9';
5
+ export const COMPONENT_KIT_VERSION = '0.1.11';
6
6
  export const COMPONENT_MANIFEST_SCHEMA_VERSION = CONTRACTS_COMPONENT_MANIFEST_SCHEMA_VERSION;
7
7
  export const COMPONENT_REVIEW_CHECKLIST_VERSION = 'component-review-checklist.v0.1.0';
8
8
  export function getComponentStandardStamp() {
@@ -1 +1 @@
1
- {"version":3,"file":"standard.js","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,IAAI,2CAA2C,EAChF,8BAA8B,IAAI,wCAAwC,EAC1E,0BAA0B,IAAI,oCAAoC,GACnE,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AAC/E,MAAM,CAAC,MAAM,8BAA8B,GAAG,wCAAwC,CAAC;AACvF,MAAM,CAAC,MAAM,8BAA8B,GAAG,oEAA6E,CAAC;AAC5H,MAAM,CAAC,MAAM,qBAAqB,GAAG,OAAgB,CAAC;AACtD,MAAM,CAAC,MAAM,iCAAiC,GAAG,2CAA2C,CAAC;AAC7F,MAAM,CAAC,MAAM,kCAAkC,GAAG,mCAA4C,CAAC;AAE/F,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,aAAa,EAAE,0BAA0B;QACzC,UAAU,EAAE,8BAA8B;QAC1C,UAAU,EAAE,8BAA8B;QAC1C,mBAAmB,EAAE,qBAAqB;QAC1C,qBAAqB,EAAE,iCAAiC;QACxD,sBAAsB,EAAE,kCAAkC;KAC3D,CAAC;AACJ,CAAC"}
1
+ {"version":3,"file":"standard.js","sourceRoot":"","sources":["../src/standard.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iCAAiC,IAAI,2CAA2C,EAChF,8BAA8B,IAAI,wCAAwC,EAC1E,0BAA0B,IAAI,oCAAoC,GACnE,MAAM,wBAAwB,CAAC;AAEhC,MAAM,CAAC,MAAM,0BAA0B,GAAG,oCAAoC,CAAC;AAC/E,MAAM,CAAC,MAAM,8BAA8B,GAAG,wCAAwC,CAAC;AACvF,MAAM,CAAC,MAAM,8BAA8B,GAAG,oEAA6E,CAAC;AAC5H,MAAM,CAAC,MAAM,qBAAqB,GAAG,QAAiB,CAAC;AACvD,MAAM,CAAC,MAAM,iCAAiC,GAAG,2CAA2C,CAAC;AAC7F,MAAM,CAAC,MAAM,kCAAkC,GAAG,mCAA4C,CAAC;AAE/F,MAAM,UAAU,yBAAyB;IACvC,OAAO;QACL,aAAa,EAAE,0BAA0B;QACzC,UAAU,EAAE,8BAA8B;QAC1C,UAAU,EAAE,8BAA8B;QAC1C,mBAAmB,EAAE,qBAAqB;QAC1C,qBAAqB,EAAE,iCAAiC;QACxD,sBAAsB,EAAE,kCAAkC;KAC3D,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptframe/component-kit",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -57,7 +57,7 @@
57
57
  "clean": "rm -rf dist"
58
58
  },
59
59
  "dependencies": {
60
- "@promptframe/contracts": "^0.1.11"
60
+ "@promptframe/contracts": "^0.1.13"
61
61
  },
62
62
  "peerDependencies": {
63
63
  "react": "^19.0.0",