@excom/quark-sheet 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.
Files changed (37) hide show
  1. package/.rush/temp/chunked-rush-logs/quark-sheet.apply-exports.chunks.jsonl +1 -0
  2. package/.rush/temp/chunked-rush-logs/quark-sheet.build_docs.chunks.jsonl +1 -0
  3. package/.rush/temp/chunked-rush-logs/quark-sheet.build_package-metas.chunks.jsonl +1 -0
  4. package/.rush/temp/operation/apply-exports/all.log +1 -0
  5. package/.rush/temp/operation/apply-exports/log-chunks.jsonl +1 -0
  6. package/.rush/temp/operation/apply-exports/state.json +3 -0
  7. package/.rush/temp/operation/build_docs/all.log +1 -0
  8. package/.rush/temp/operation/build_docs/log-chunks.jsonl +1 -0
  9. package/.rush/temp/operation/build_docs/state.json +3 -0
  10. package/.rush/temp/operation/build_package-metas/all.log +1 -0
  11. package/.rush/temp/operation/build_package-metas/log-chunks.jsonl +1 -0
  12. package/.rush/temp/operation/build_package-metas/state.json +3 -0
  13. package/.rush/temp/shrinkwrap-deps.json +3 -0
  14. package/config/rig.json +5 -0
  15. package/index.css +5 -0
  16. package/index.ts +17 -0
  17. package/package.json +46 -0
  18. package/quark-sheet.ts +182 -0
  19. package/rush-logs/quark-sheet.apply-exports.cache.log +1 -0
  20. package/rush-logs/quark-sheet.apply-exports.log +1 -0
  21. package/rush-logs/quark-sheet.build_docs.cache.log +1 -0
  22. package/rush-logs/quark-sheet.build_docs.log +1 -0
  23. package/rush-logs/quark-sheet.build_package-metas.cache.log +1 -0
  24. package/rush-logs/quark-sheet.build_package-metas.log +1 -0
  25. package/src/quark-sheet.css +8 -0
  26. package/support/custom-elements.json +220 -0
  27. package/support/demos/provider.html +13 -0
  28. package/support/demos/simple.html +14 -0
  29. package/support/dist-docs/quark-sheet.md +147 -0
  30. package/support/docs/README.md +53 -0
  31. package/support/package-meta.json +185 -0
  32. package/support/tests/__snapshots__/provider.view.test.ts.snap +23 -0
  33. package/support/tests/__snapshots__/simple.view.test.ts.snap +23 -0
  34. package/support/tests/provider.view.test.ts +42 -0
  35. package/support/tests/quark-sheet.test.ts +377 -0
  36. package/support/tests/simple.view.test.ts +33 -0
  37. package/tsconfig.json +5 -0
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: cd \"$RUSH_PROJECT_FOLDER\" && node ../heft-rig/scripts/apply-exports.mjs \n"}
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs \n"}
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs \n"}
@@ -0,0 +1 @@
1
+ Invoking: cd "$RUSH_PROJECT_FOLDER" && node ../heft-rig/scripts/apply-exports.mjs
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: cd \"$RUSH_PROJECT_FOLDER\" && node ../heft-rig/scripts/apply-exports.mjs \n"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "nonCachedDurationMs": 38.93855100000019
3
+ }
@@ -0,0 +1 @@
1
+ Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs \n"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "nonCachedDurationMs": 51.72877900000003
3
+ }
@@ -0,0 +1 @@
1
+ Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs
@@ -0,0 +1 @@
1
+ {"kind":"O","text":"Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs \n"}
@@ -0,0 +1,3 @@
1
+ {
2
+ "nonCachedDurationMs": 107.8026809999999
3
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "../../packages/quark-sheet": "../../packages/quark-sheet:i+nbLCbAzl73Wvd7BEwK65xRFYNcSWL1m9qbAQlsxIc=:"
3
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
3
+ "rigPackageName": "@excom/heft-rig",
4
+ "rigProfile": "default"
5
+ }
package/index.css ADDED
@@ -0,0 +1,5 @@
1
+ @import "./src/quark-sheet.css";
2
+
3
+ @layer {
4
+ @mixin module-quark-sheet;
5
+ }
package/index.ts ADDED
@@ -0,0 +1,17 @@
1
+ import { QuarkSheet } from "./quark-sheet";
2
+
3
+ QuarkSheet.define();
4
+
5
+ export { QuarkSheet };
6
+
7
+ type T_HTMLQuarkSheetElement = typeof QuarkSheet.CustomElement;
8
+ declare global {
9
+ interface HTMLQuarkSheetElement extends T_HTMLQuarkSheetElement {}
10
+ interface Window {
11
+ HTMLQuarkSheetElement: HTMLQuarkSheetElement;
12
+ }
13
+ interface HTMLElementTagNameMap {
14
+ "quark-sheet": HTMLQuarkSheetElement;
15
+ }
16
+ }
17
+ export type { HTMLQuarkSheetElement };
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@excom/quark-sheet",
3
+ "version": "0.1.0",
4
+ "description": "<quark-sheet> — host a Quark orchestration sheet for sibling markup",
5
+ "license": "MIT",
6
+ "engines": {
7
+ "node": ">=24.13.0"
8
+ },
9
+ "type": "module",
10
+ "dependencies": {
11
+ "@excom/loadable-element": "^0.1.0",
12
+ "@excom/neutron": "^0.1.0",
13
+ "@excom/quark": "^0.1.0",
14
+ "@excom/kit-utils": "^0.1.0",
15
+ "@excom/kit-logger": "^0.1.0"
16
+ },
17
+ "peerDependencies": {},
18
+ "devDependencies": {
19
+ "@excom/heft-rig": "^0.1.0"
20
+ },
21
+ "repository": {
22
+ "url": "excom-dev/nucleus",
23
+ "directory": "packages/quark-sheet"
24
+ },
25
+ "homepage": "https://github.com/excom-dev/nucleus/tree/main/packages/quark-sheet/support/docs/README.md",
26
+ "bugs": "https://github.com/excom-dev/nucleus/issues",
27
+ "keywords": [
28
+ "quark-sheet",
29
+ "neutron",
30
+ "custom-elements"
31
+ ],
32
+ "excom": {
33
+ "packageType": "kit-element"
34
+ },
35
+ "scripts": {
36
+ "build": "node node_modules/@excom/heft-rig/scripts/vite-build.mjs",
37
+ "build:watch": "node node_modules/@excom/heft-rig/scripts/vite-build-watch.mjs",
38
+ "format": "node node_modules/@excom/heft-rig/scripts/format.mjs",
39
+ "test": "node node_modules/@excom/heft-rig/scripts/vitest.mjs",
40
+ "coverage": "node node_modules/@excom/heft-rig/scripts/coverage.mjs",
41
+ "dev": "node node_modules/@excom/heft-rig/scripts/vite-dev.mjs",
42
+ "preview": "node node_modules/@excom/heft-rig/scripts/vite-preview.mjs",
43
+ "build:package-metas": "node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs",
44
+ "build:docs": "node node_modules/@excom/heft-rig/scripts/build-docs.mjs"
45
+ }
46
+ }
package/quark-sheet.ts ADDED
@@ -0,0 +1,182 @@
1
+ import { KitLogger } from "@excom/kit-logger";
2
+ import { clearFetchCaches, fetchPlainText } from "@excom/kit-utils";
3
+ import { LoadableElement } from "@excom/loadable-element";
4
+ import { ConstructorType, Neutron, TEvent } from "@excom/neutron";
5
+ import { Quark } from "@excom/quark";
6
+
7
+ export type QuarkSheetLoadingEvent = TEvent & {
8
+ type: "quark-sheet-loading";
9
+ detail: void;
10
+ };
11
+
12
+ export type QuarkSheetSuccessEvent = TEvent & {
13
+ type: "quark-sheet-success";
14
+ detail: void;
15
+ };
16
+
17
+ export type QuarkSheetErrorEvent = TEvent & {
18
+ type: "quark-sheet-error";
19
+ detail: unknown;
20
+ };
21
+
22
+ /**
23
+ * Hosts a Quark orchestration sheet for its parent. Put markup and
24
+ * `<quark-sheet>` as siblings under the same parent — Quark scopes to that
25
+ * host. Inline sheet text, or load remote Quark via `src-url`.
26
+ *
27
+ * @summary Load / own a Quark sheet for sibling markup.
28
+ *
29
+ * @example
30
+ * <section>
31
+ * <quark-sheet>
32
+ * details[open] [bind-status] { content: "Open"; }
33
+ * details:not([open]) [bind-status] { content: "Closed"; }
34
+ * </quark-sheet>
35
+ * <details>
36
+ * <summary>Panel</summary>
37
+ * <span bind-status></span>
38
+ * </details>
39
+ * </section>
40
+ *
41
+ * @command --reload - Drops the shared text cache entry for `src-url` and
42
+ * fetches the sheet again (the cache is page-wide: every element loading
43
+ * the same URL shares it). No-op without `src-url`.
44
+ *
45
+ * @fires quark-sheet-loading - After `is-loading` becomes true (fetch in
46
+ * flight).
47
+ * @type QuarkSheetLoadingEvent
48
+ * @fires quark-sheet-success - After the sheet parses and registers
49
+ * successfully (`is-success`).
50
+ * @type QuarkSheetSuccessEvent
51
+ * @fires quark-sheet-error - After parse / fetch failure (`is-error`).
52
+ * `event.detail` is the error.
53
+ * @type QuarkSheetErrorEvent
54
+ */
55
+ export const QuarkSheet = Neutron.compose([
56
+ LoadableElement,
57
+ Neutron({
58
+ tag: "quark-sheet",
59
+ props: {
60
+ /**
61
+ * @option
62
+ * URL of a remote `.quark` / text sheet. When set, contents are
63
+ * fetched into the live sheet (replacing inline text).
64
+ * @values <URL>
65
+ */
66
+ srcUrl: String,
67
+ /**
68
+ * @option
69
+ * Run top-level rules in the root context (the whole document)
70
+ * instead of implicitly wrapping the sheet in `@scope { }`. Rules
71
+ * nested inside an explicit `@scope { }` block remain scoped to the
72
+ * host either way.
73
+ */
74
+ isGlobal: Boolean,
75
+ // from LoadableElement; repeated so the docs here are local
76
+ /**
77
+ * @state
78
+ * Fetch in progress.
79
+ */
80
+ isLoading: Boolean,
81
+ /**
82
+ * @state
83
+ * Sheet parsed and registered on the host.
84
+ */
85
+ isSuccess: Boolean,
86
+ /**
87
+ * @state
88
+ * Fetch or Quark parse/register failed.
89
+ */
90
+ isError: Boolean,
91
+ // private
92
+ srcPromise: Promise as ConstructorType<Promise<string>>,
93
+ /**
94
+ * @state
95
+ * Resolved sheet source text (from fetch or inline). Not reflected —
96
+ * sheets can be large.
97
+ */
98
+ srcText: {
99
+ type: String,
100
+ // sheets can be large: never reflect
101
+ attr: false,
102
+ },
103
+ /**
104
+ * @state
105
+ * Live `Quark` instance while registered.
106
+ */
107
+ quarkInstance: Quark,
108
+ },
109
+ }),
110
+ ])
111
+ /* No `src-url`: take the inline sheet text. */
112
+ .onConnected(
113
+ ({ srcUrl, textContent }) =>
114
+ !srcUrl && textContent?.trim() && { srcText: textContent }
115
+ )
116
+ .onConnected((element) => {
117
+ /* Reconnect: re-register the live instance on the (maybe new) parent. */
118
+ if (element.quarkInstance) {
119
+ element.quarkInstance.register({
120
+ sheetElement: element,
121
+ });
122
+ }
123
+ })
124
+ /* `src-url` set: fetch the remote sheet. */
125
+ .onPropSet("srcUrl", ({ srcUrl }) => ({
126
+ srcPromise: fetchPlainText(srcUrl),
127
+ }))
128
+ /* Reload: drop the shared cache entry and fetch again. */
129
+ .onCommand("--reload", ({ srcUrl }) => {
130
+ if (!srcUrl) return;
131
+ clearFetchCaches(srcUrl);
132
+ // clear `srcText` too: identical remote text must still re-register
133
+ return { srcText: null, srcPromise: fetchPlainText(srcUrl) };
134
+ })
135
+ /* Fetch settled: drop `srcPromise`, write `srcText`. */
136
+ .onPromiseResolved("srcPromise", (_, result) => ({
137
+ srcPromise: null,
138
+ srcText: result.srcPromise as any,
139
+ }))
140
+ /* In-flight `srcPromise` → loading. */
141
+ .onPropChanged(
142
+ "srcPromise",
143
+ ({ srcPromise }) => !!srcPromise && { _setLoading: [] }
144
+ )
145
+ /* Fetch failed → error. */
146
+ .onPromiseRejected("srcPromise", (_, result) => {
147
+ KitLogger.error(`quark-sheet error:`, result.srcPromise);
148
+ return { srcPromise: null, _setError: [result.srcPromise] };
149
+ })
150
+ /* `srcText` / `isGlobal` changed: parse and register again. */
151
+ .onPropChanged(["srcText", "isGlobal"], (element) => {
152
+ const { srcText, srcPromise, quarkInstance, isGlobal } = element;
153
+ // wait out an in-flight fetch before (re)registering
154
+ if (srcText && !srcPromise) {
155
+ try {
156
+ quarkInstance?.unregister();
157
+ return [
158
+ {
159
+ quarkInstance: new Quark({
160
+ src: srcText,
161
+ // host-scoped unless `is-global` (the historical default)
162
+ options: { isScoped: !isGlobal },
163
+ }),
164
+ },
165
+ { _setSuccess: [null] },
166
+ ];
167
+ } catch (e: any) {
168
+ KitLogger.error(`quark-sheet error:`, e);
169
+ return { _setError: [e] };
170
+ }
171
+ }
172
+ })
173
+ .onPropSet("quarkInstance", (element) => {
174
+ element.quarkInstance?.register({
175
+ sheetElement: element,
176
+ });
177
+ })
178
+ /* When element is disconnected, clean up quark. A move re-registers on
179
+ reconnect (the host may have changed), so `isMoving` cannot skip it. */
180
+ .onDisconnected(({ quarkInstance }) => {
181
+ quarkInstance?.unregister();
182
+ });
@@ -0,0 +1 @@
1
+ Caching has been disabled for this project's "apply-exports" command.
@@ -0,0 +1 @@
1
+ Invoking: cd "$RUSH_PROJECT_FOLDER" && node ../heft-rig/scripts/apply-exports.mjs
@@ -0,0 +1 @@
1
+ This project does not define the caching behavior of the "build:docs" command, so caching has been disabled.
@@ -0,0 +1 @@
1
+ Invoking: node node_modules/@excom/heft-rig/scripts/build-docs.mjs
@@ -0,0 +1 @@
1
+ This project does not define the caching behavior of the "build:package-metas" command, so caching has been disabled.
@@ -0,0 +1 @@
1
+ Invoking: node node_modules/@excom/heft-rig/scripts/build-package-metas.mjs
@@ -0,0 +1,8 @@
1
+ /* Selector aliases. */
2
+ @custom-selector :--quark-sheet quark-sheet, .tag-quark-sheet;
3
+
4
+ @define-mixin module-quark-sheet {
5
+ :--quark-sheet {
6
+ display: none;
7
+ }
8
+ }
@@ -0,0 +1,220 @@
1
+ {
2
+ "schemaVersion": "1.0.0",
3
+ "modules": [
4
+ {
5
+ "kind": "javascript-module",
6
+ "path": "quark-sheet.ts",
7
+ "declarations": [
8
+ {
9
+ "kind": "class",
10
+ "name": "QuarkSheet",
11
+ "customElement": true,
12
+ "tagName": "quark-sheet",
13
+ "mixins": [
14
+ {
15
+ "name": "LoadableElement",
16
+ "package": "@excom/loadable-element"
17
+ }
18
+ ],
19
+ "summary": "Load / own a Quark sheet for sibling markup.",
20
+ "description": "Hosts a Quark orchestration sheet for its parent. Put markup and `<quark-sheet>` as siblings under the same parent — Quark scopes to that host. Inline sheet text, or load remote Quark via `src-url`.",
21
+ "attributes": [
22
+ {
23
+ "name": "src-url",
24
+ "type": {
25
+ "text": "string"
26
+ },
27
+ "description": "URL of a remote `.quark` / text sheet. When set, contents are fetched into the live sheet (replacing inline text).",
28
+ "fieldName": "srcUrl",
29
+ "values": [
30
+ "<URL>"
31
+ ]
32
+ },
33
+ {
34
+ "name": "is-global",
35
+ "type": {
36
+ "text": "boolean"
37
+ },
38
+ "description": "Run top-level rules in the root context (the whole document) instead of implicitly wrapping the sheet in `@scope { }`. Rules nested inside an explicit `@scope { }` block remain scoped to the host either way.",
39
+ "fieldName": "isGlobal"
40
+ },
41
+ {
42
+ "name": "is-loading",
43
+ "type": {
44
+ "text": "boolean"
45
+ },
46
+ "description": "Fetch in progress.",
47
+ "fieldName": "isLoading"
48
+ },
49
+ {
50
+ "name": "is-success",
51
+ "type": {
52
+ "text": "boolean"
53
+ },
54
+ "description": "Sheet parsed and registered on the host.",
55
+ "fieldName": "isSuccess"
56
+ },
57
+ {
58
+ "name": "is-error",
59
+ "type": {
60
+ "text": "boolean"
61
+ },
62
+ "description": "Fetch or Quark parse/register failed.",
63
+ "fieldName": "isError"
64
+ },
65
+ {
66
+ "name": "quark-instance",
67
+ "type": {
68
+ "text": "Quark"
69
+ },
70
+ "description": "Live `Quark` instance while registered.",
71
+ "fieldName": "quarkInstance"
72
+ }
73
+ ],
74
+ "members": [
75
+ {
76
+ "kind": "field",
77
+ "name": "srcUrl",
78
+ "type": {
79
+ "text": "string"
80
+ },
81
+ "privacy": "public",
82
+ "readonly": false,
83
+ "description": "URL of a remote `.quark` / text sheet. When set, contents are fetched into the live sheet (replacing inline text).",
84
+ "_neutron": {
85
+ "surface": "option"
86
+ }
87
+ },
88
+ {
89
+ "kind": "field",
90
+ "name": "isGlobal",
91
+ "type": {
92
+ "text": "boolean"
93
+ },
94
+ "privacy": "public",
95
+ "readonly": false,
96
+ "description": "Run top-level rules in the root context (the whole document) instead of implicitly wrapping the sheet in `@scope { }`. Rules nested inside an explicit `@scope { }` block remain scoped to the host either way.",
97
+ "_neutron": {
98
+ "surface": "option"
99
+ }
100
+ },
101
+ {
102
+ "kind": "field",
103
+ "name": "isLoading",
104
+ "type": {
105
+ "text": "boolean"
106
+ },
107
+ "privacy": "public",
108
+ "readonly": true,
109
+ "description": "Fetch in progress.",
110
+ "_neutron": {
111
+ "surface": "state"
112
+ }
113
+ },
114
+ {
115
+ "kind": "field",
116
+ "name": "isSuccess",
117
+ "type": {
118
+ "text": "boolean"
119
+ },
120
+ "privacy": "public",
121
+ "readonly": true,
122
+ "description": "Sheet parsed and registered on the host.",
123
+ "_neutron": {
124
+ "surface": "state"
125
+ }
126
+ },
127
+ {
128
+ "kind": "field",
129
+ "name": "isError",
130
+ "type": {
131
+ "text": "boolean"
132
+ },
133
+ "privacy": "public",
134
+ "readonly": true,
135
+ "description": "Fetch or Quark parse/register failed.",
136
+ "_neutron": {
137
+ "surface": "state"
138
+ }
139
+ },
140
+ {
141
+ "kind": "field",
142
+ "name": "quarkInstance",
143
+ "type": {
144
+ "text": "Quark"
145
+ },
146
+ "privacy": "public",
147
+ "readonly": true,
148
+ "description": "Live `Quark` instance while registered.",
149
+ "_neutron": {
150
+ "surface": "state"
151
+ }
152
+ }
153
+ ],
154
+ "events": [
155
+ {
156
+ "name": "quark-sheet-loading",
157
+ "description": "After `is-loading` becomes true (fetch in flight).",
158
+ "type": {
159
+ "text": "QuarkSheetLoadingEvent",
160
+ "expanded": "CustomEvent & { type: \"quark-sheet-loading\"; detail: void; bubbles: true; cancelable: true; composed: true }"
161
+ }
162
+ },
163
+ {
164
+ "name": "quark-sheet-success",
165
+ "description": "After the sheet parses and registers successfully (`is-success`).",
166
+ "type": {
167
+ "text": "QuarkSheetSuccessEvent",
168
+ "expanded": "CustomEvent & { type: \"quark-sheet-success\"; detail: void; bubbles: true; cancelable: true; composed: true }"
169
+ }
170
+ },
171
+ {
172
+ "name": "quark-sheet-error",
173
+ "description": "After parse / fetch failure (`is-error`). `event.detail` is the error.",
174
+ "type": {
175
+ "text": "QuarkSheetErrorEvent",
176
+ "expanded": "CustomEvent & { type: \"quark-sheet-error\"; detail: unknown; bubbles: true; cancelable: true; composed: true }"
177
+ }
178
+ }
179
+ ],
180
+ "_neutron": {
181
+ "commands": [
182
+ {
183
+ "name": "--reload",
184
+ "description": "Drops the shared text cache entry for `src-url` and fetches the sheet again (the cache is page-wide: every element loading the same URL shares it). No-op without `src-url`."
185
+ }
186
+ ],
187
+ "cssAliases": [
188
+ {
189
+ "name": ":--quark-sheet",
190
+ "selectors": [
191
+ "quark-sheet",
192
+ ".tag-quark-sheet"
193
+ ],
194
+ "kind": "element"
195
+ }
196
+ ]
197
+ }
198
+ }
199
+ ],
200
+ "exports": [
201
+ {
202
+ "kind": "js",
203
+ "name": "QuarkSheet",
204
+ "declaration": {
205
+ "name": "QuarkSheet",
206
+ "module": "quark-sheet.ts"
207
+ }
208
+ },
209
+ {
210
+ "kind": "custom-element-definition",
211
+ "name": "quark-sheet",
212
+ "declaration": {
213
+ "name": "QuarkSheet",
214
+ "module": "quark-sheet.ts"
215
+ }
216
+ }
217
+ ]
218
+ }
219
+ ]
220
+ }
@@ -0,0 +1,13 @@
1
+ <section>
2
+ <provider-fetch api-url="/api/todos/1">
3
+ <p>Title: <span bind-title></span></p>
4
+ </provider-fetch>
5
+ <quark-sheet>
6
+ provider-fetch[is-success] {
7
+ $todo: prop("provision").body;
8
+ [bind-title] {
9
+ content: $todo.title;
10
+ }
11
+ }
12
+ </quark-sheet>
13
+ </section>
@@ -0,0 +1,14 @@
1
+ <section>
2
+ <quark-sheet>
3
+ details[open] summary {
4
+ content: "Panel Open";
5
+ }
6
+ details:not([open]) summary {
7
+ content: "Panel Closed";
8
+ }
9
+ </quark-sheet>
10
+ <details>
11
+ <summary></summary>
12
+ <p>This is the panel content.</p>
13
+ </details>
14
+ </section>