@cchistory/lite 0.4.4 → 0.5.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/INSTALL.md +1 -1
- package/apps/lite-cli/dist/agent-contract.d.ts +4 -5
- package/apps/lite-cli/dist/agent-contract.d.ts.map +1 -1
- package/apps/lite-cli/dist/agent-contract.js +35 -28
- package/apps/lite-cli/dist/agent-contract.js.map +1 -1
- package/apps/lite-cli/dist/bin.js +3 -3
- package/apps/lite-cli/dist/bin.js.map +1 -1
- package/apps/lite-cli/dist/index.d.ts.map +1 -1
- package/apps/lite-cli/dist/index.js +155 -81
- package/apps/lite-cli/dist/index.js.map +1 -1
- package/apps/lite-cli/dist/index.test.js +87 -63
- package/apps/lite-cli/dist/index.test.js.map +1 -1
- package/apps/lite-cli/dist/query.d.ts +4 -1
- package/apps/lite-cli/dist/query.d.ts.map +1 -1
- package/apps/lite-cli/dist/query.js +45 -29
- package/apps/lite-cli/dist/query.js.map +1 -1
- package/apps/lite-cli/dist/resource-errors.d.ts +3 -0
- package/apps/lite-cli/dist/resource-errors.d.ts.map +1 -0
- package/apps/lite-cli/dist/resource-errors.js +17 -0
- package/apps/lite-cli/dist/resource-errors.js.map +1 -0
- package/apps/lite-cli/dist/shell.d.ts +12 -2
- package/apps/lite-cli/dist/shell.d.ts.map +1 -1
- package/apps/lite-cli/dist/shell.js +129 -57
- package/apps/lite-cli/dist/shell.js.map +1 -1
- package/apps/lite-cli/dist/sql-query.test.d.ts +2 -0
- package/apps/lite-cli/dist/sql-query.test.d.ts.map +1 -0
- package/apps/lite-cli/dist/sql-query.test.js +290 -0
- package/apps/lite-cli/dist/sql-query.test.js.map +1 -0
- package/apps/lite-cli/dist/version.d.ts +1 -1
- package/apps/lite-cli/dist/version.js +1 -1
- package/apps/lite-tui/dist/bin.js +3 -3
- package/apps/lite-tui/dist/bin.js.map +1 -1
- package/apps/lite-tui/dist/index.d.ts.map +1 -1
- package/apps/lite-tui/dist/index.js +2 -2
- package/apps/lite-tui/dist/index.js.map +1 -1
- package/apps/lite-tui/dist/index.test.js +5 -3
- package/apps/lite-tui/dist/index.test.js.map +1 -1
- package/apps/lite-tui/dist/render.d.ts +1 -1
- package/apps/lite-tui/dist/version.d.ts +1 -1
- package/apps/lite-tui/dist/version.js +1 -1
- package/bin/cchistory-lite-tui.mjs +3 -3
- package/bin/cchistory-lite.mjs +3 -3
- package/docs/guide/for-agents.md +65 -42
- package/docs/guide/lite.md +64 -24
- package/docs/guide/queries/latest-sessions.sql +4 -0
- package/docs/guide/queries/latest-turns.sql +1 -0
- package/docs/guide/queries/list-sessions.sql +2 -0
- package/docs/guide/query.md +153 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts +7 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/directory-scope.js +11 -0
- package/node_modules/@cchistory/canonical/dist/directory-scope.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts +5 -1
- package/node_modules/@cchistory/canonical/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/index.js +5 -1
- package/node_modules/@cchistory/canonical/dist/index.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/query.d.ts +15 -0
- package/node_modules/@cchistory/canonical/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/query.js +208 -0
- package/node_modules/@cchistory/canonical/dist/query.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts +1 -0
- package/node_modules/@cchistory/canonical/dist/session-family.d.ts.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.js +3 -0
- package/node_modules/@cchistory/canonical/dist/session-family.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-family.test.js +61 -0
- package/node_modules/@cchistory/canonical/dist/session-family.test.js.map +1 -1
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts +30 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js +713 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.js.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts +2 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.d.ts.map +1 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js +56 -0
- package/node_modules/@cchistory/canonical/dist/session-interpreter.test.js.map +1 -0
- package/node_modules/@cchistory/canonical/package.json +1 -1
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts +7 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js +36 -0
- package/node_modules/@cchistory/domain/dist/evidence-atoms.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts +26 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js +80 -0
- package/node_modules/@cchistory/domain/dist/evidence-values.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/domain/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/domain/dist/index.js +5 -0
- package/node_modules/@cchistory/domain/dist/index.js.map +1 -1
- package/node_modules/@cchistory/domain/dist/masks.d.ts +31 -0
- package/node_modules/@cchistory/domain/dist/masks.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/masks.js +342 -0
- package/node_modules/@cchistory/domain/dist/masks.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts +58 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js +2 -0
- package/node_modules/@cchistory/domain/dist/parsed-session.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts +67 -0
- package/node_modules/@cchistory/domain/dist/query.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/query.js +2 -0
- package/node_modules/@cchistory/domain/dist/query.js.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts +14 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js +247 -0
- package/node_modules/@cchistory/domain/dist/token-evidence.js.map +1 -0
- package/node_modules/@cchistory/domain/package.json +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js +0 -1
- package/node_modules/@cchistory/live-runtime/dist/bootstrap.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts +30 -9
- package/node_modules/@cchistory/live-runtime/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.js +263 -58
- package/node_modules/@cchistory/live-runtime/dist/index.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/index.test.js +177 -20
- package/node_modules/@cchistory/live-runtime/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts +16 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js +55 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js +192 -0
- package/node_modules/@cchistory/live-runtime/dist/preparation-metadata.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts +32 -23
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js +65 -45
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js +363 -59
- package/node_modules/@cchistory/live-runtime/dist/scan-guard.test.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts +47 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js +15 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js +166 -0
- package/node_modules/@cchistory/live-runtime/dist/selective-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts +37 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js +301 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js +67 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-query.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js +14 -0
- package/node_modules/@cchistory/live-runtime/dist/sql-worker.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts +13 -10
- package/node_modules/@cchistory/live-runtime/dist/system-memory.d.ts.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js +61 -34
- package/node_modules/@cchistory/live-runtime/dist/system-memory.js.map +1 -1
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts +2 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.d.ts.map +1 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js +76 -0
- package/node_modules/@cchistory/live-runtime/dist/system-memory.test.js.map +1 -0
- package/node_modules/@cchistory/live-runtime/package.json +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/discovery.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts +2 -4
- package/node_modules/@cchistory/source-adapters/dist/core/factories.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js +1 -23
- package/node_modules/@cchistory/source-adapters/dist/core/factories.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts +25 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js +80 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js +122 -0
- package/node_modules/@cchistory/source-adapters/dist/core/file-read-plan.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js +2 -11
- package/node_modules/@cchistory/source-adapters/dist/core/git-project.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js +4 -4
- package/node_modules/@cchistory/source-adapters/dist/core/parser.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts +8 -6
- package/node_modules/@cchistory/source-adapters/dist/core/probe.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js +54 -36
- package/node_modules/@cchistory/source-adapters/dist/core/probe.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts +2 -28
- package/node_modules/@cchistory/source-adapters/dist/core/projections.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js +2 -695
- package/node_modules/@cchistory/source-adapters/dist/core/projections.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/projections.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts +18 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js +27 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js +75 -0
- package/node_modules/@cchistory/source-adapters/dist/core/read-budget.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/session-grouping.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/source-identity.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts +1 -13
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js +1 -246
- package/node_modules/@cchistory/source-adapters/dist/core/token-usage.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/tokens.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts +1 -25
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js +1 -79
- package/node_modules/@cchistory/source-adapters/dist/core/type-guards.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts +6 -35
- package/node_modules/@cchistory/source-adapters/dist/core/types.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js +14 -10
- package/node_modules/@cchistory/source-adapters/dist/core/vscode-state.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts +6 -0
- package/node_modules/@cchistory/source-adapters/dist/index.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.js +4 -0
- package/node_modules/@cchistory/source-adapters/dist/index.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/index.test.js +2 -0
- package/node_modules/@cchistory/source-adapters/dist/index.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts +1 -30
- package/node_modules/@cchistory/source-adapters/dist/masks.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/masks.js +1 -341
- package/node_modules/@cchistory/source-adapters/dist/masks.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/accio.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/amp.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/antigravity.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/claude.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codebuddy.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts +14 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js +103 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex/activity-evidence.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/codex.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js +5 -3
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor-agent.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/cursor.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/factory-droid.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/gemini.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js +24 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/grok.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/kimi.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/lobechat.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/openclaw.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/opencode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.d.ts.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js +11 -9
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode/runtime.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js +2 -1
- package/node_modules/@cchistory/source-adapters/dist/platforms/zcode.test.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts +8 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.d.ts.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js +7 -0
- package/node_modules/@cchistory/source-adapters/dist/probe-reference.test.js.map +1 -0
- package/node_modules/@cchistory/source-adapters/dist/test-helpers.js.map +1 -1
- package/node_modules/@cchistory/source-adapters/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +428 -0
- package/node_modules/commander/index.js +1224 -0
- package/node_modules/commander/package.json +38 -0
- package/node_modules/commander/typings/index.d.ts +310 -0
- package/node_modules/discontinuous-range/.npmignore +28 -0
- package/node_modules/discontinuous-range/.travis.yml +4 -0
- package/node_modules/discontinuous-range/LICENSE +21 -0
- package/node_modules/discontinuous-range/README.md +23 -0
- package/node_modules/discontinuous-range/index.js +144 -0
- package/node_modules/discontinuous-range/package.json +27 -0
- package/node_modules/discontinuous-range/test/main-test.js +96 -0
- package/node_modules/moo/LICENSE +29 -0
- package/node_modules/moo/README.md +385 -0
- package/node_modules/moo/moo.js +645 -0
- package/node_modules/moo/package.json +29 -0
- package/node_modules/nearley/LICENSE.txt +21 -0
- package/node_modules/nearley/README.md +80 -0
- package/node_modules/nearley/bin/nearley-railroad.js +121 -0
- package/node_modules/nearley/bin/nearley-test.js +64 -0
- package/node_modules/nearley/bin/nearley-unparse.js +29 -0
- package/node_modules/nearley/bin/nearleyc.js +38 -0
- package/node_modules/nearley/builtin/cow.ne +2 -0
- package/node_modules/nearley/builtin/number.ne +51 -0
- package/node_modules/nearley/builtin/postprocessors.ne +36 -0
- package/node_modules/nearley/builtin/string.ne +26 -0
- package/node_modules/nearley/builtin/whitespace.ne +5 -0
- package/node_modules/nearley/lib/compile.js +307 -0
- package/node_modules/nearley/lib/generate.js +244 -0
- package/node_modules/nearley/lib/lint.js +28 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.js +132 -0
- package/node_modules/nearley/lib/nearley-language-bootstrapped.ne +126 -0
- package/node_modules/nearley/lib/nearley.js +564 -0
- package/node_modules/nearley/lib/stream.js +18 -0
- package/node_modules/nearley/lib/unparse.js +139 -0
- package/node_modules/nearley/package.json +63 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts +237 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-mapper.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/ast-visitor.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.d.ts +11 -0
- package/node_modules/pgsql-ast-parser/index.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/index.js +6484 -0
- package/node_modules/pgsql-ast-parser/index.js.map +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts +1 -0
- package/node_modules/pgsql-ast-parser/interfaces.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/keywords.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts +15 -0
- package/node_modules/pgsql-ast-parser/lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/lexer.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/array.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/geometric.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts +10 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-builder.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-iso.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval-lexer.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/literal-syntaxes/interval.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/package.json +69 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts +33 -0
- package/node_modules/pgsql-ast-parser/parser.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts +2 -0
- package/node_modules/pgsql-ast-parser/pg-escape.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/readme.md +255 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.spec.ts +296 -0
- package/node_modules/pgsql-ast-parser/src/ast-mapper.ts +1378 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.spec.ts +57 -0
- package/node_modules/pgsql-ast-parser/src/ast-visitor.ts +101 -0
- package/node_modules/pgsql-ast-parser/src/index.ts +10 -0
- package/node_modules/pgsql-ast-parser/src/interfaces.ts +0 -0
- package/node_modules/pgsql-ast-parser/src/keywords.ts +8 -0
- package/node_modules/pgsql-ast-parser/src/lexer.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/lexer.ts +267 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array-lexer.ts +27 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/array.spec.ts +55 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.ne +88 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/geometric.spec.ts +131 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-builder.ts +148 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso-lexer.ts +17 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-iso.ne +53 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval-lexer.ts +26 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.ne +54 -0
- package/node_modules/pgsql-ast-parser/src/literal-syntaxes/interval.spec.ts +106 -0
- package/node_modules/pgsql-ast-parser/src/parser.ts +142 -0
- package/node_modules/pgsql-ast-parser/src/pg-escape.ts +14 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.ne +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-index.spec.ts +35 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.ne +123 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-table.spec.ts +476 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.ne +33 -0
- package/node_modules/pgsql-ast-parser/src/syntax/alter-type.spec.ts +29 -0
- package/node_modules/pgsql-ast-parser/src/syntax/ast.ts +1150 -0
- package/node_modules/pgsql-ast-parser/src/syntax/base.ne +369 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.ne +17 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-extension.spec.ts +37 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.ne +62 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-index.spec.ts +245 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.ne +174 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-table.spec.ts +761 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.ne +40 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-type.spec.ts +32 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.ne +68 -0
- package/node_modules/pgsql-ast-parser/src/syntax/create-view.spec.ts +187 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.ne +13 -0
- package/node_modules/pgsql-ast-parser/src/syntax/deallocate.spec.ts +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.ne +36 -0
- package/node_modules/pgsql-ast-parser/src/syntax/delete.spec.ts +71 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.ne +28 -0
- package/node_modules/pgsql-ast-parser/src/syntax/drop.spec.ts +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/edge-cases.spec.ts +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.ne +350 -0
- package/node_modules/pgsql-ast-parser/src/syntax/expr.spec.ts +1638 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.ne +114 -0
- package/node_modules/pgsql-ast-parser/src/syntax/functions.spec.ts +235 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.ne +63 -0
- package/node_modules/pgsql-ast-parser/src/syntax/insert.spec.ts +292 -0
- package/node_modules/pgsql-ast-parser/src/syntax/main.ne +77 -0
- package/node_modules/pgsql-ast-parser/src/syntax/nearley.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.ne +8 -0
- package/node_modules/pgsql-ast-parser/src/syntax/prepare.spec.ts +44 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.ne +19 -0
- package/node_modules/pgsql-ast-parser/src/syntax/refresh-materialized-view.spec.ts +42 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.ne +223 -0
- package/node_modules/pgsql-ast-parser/src/syntax/select.spec.ts +1063 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.ne +101 -0
- package/node_modules/pgsql-ast-parser/src/syntax/sequence.spec.ts +103 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.ne +168 -0
- package/node_modules/pgsql-ast-parser/src/syntax/simple-statements.spec.ts +327 -0
- package/node_modules/pgsql-ast-parser/src/syntax/spec-utils.ts +333 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.ne +18 -0
- package/node_modules/pgsql-ast-parser/src/syntax/union.spec.ts +125 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.ne +56 -0
- package/node_modules/pgsql-ast-parser/src/syntax/update.spec.ts +87 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.ne +41 -0
- package/node_modules/pgsql-ast-parser/src/syntax/with.spec.ts +155 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.spec.ts +85 -0
- package/node_modules/pgsql-ast-parser/src/to-sql.ts +1555 -0
- package/node_modules/pgsql-ast-parser/src/utils.ts +47 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/alter-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts +826 -0
- package/node_modules/pgsql-ast-parser/syntax/ast.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-extension.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-index.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-table.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-type.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/create-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/deallocate.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/delete.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/drop.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/edge-cases.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/expr.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/functions.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/insert.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts +29 -0
- package/node_modules/pgsql-ast-parser/syntax/main.ne.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/prepare.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/refresh-materialized-view.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/select.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/sequence.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/simple-statements.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts +35 -0
- package/node_modules/pgsql-ast-parser/syntax/spec-utils.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/union.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/update.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/syntax/with.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts +7 -0
- package/node_modules/pgsql-ast-parser/to-sql.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts +3 -0
- package/node_modules/pgsql-ast-parser/to-sql.spec.d.ts.map +1 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts +16 -0
- package/node_modules/pgsql-ast-parser/utils.d.ts.map +1 -0
- package/node_modules/railroad-diagrams/.gitattributes +22 -0
- package/node_modules/railroad-diagrams/.npmignore +163 -0
- package/node_modules/railroad-diagrams/README.md +86 -0
- package/node_modules/railroad-diagrams/css-example.py-js +183 -0
- package/node_modules/railroad-diagrams/example.html +141 -0
- package/node_modules/railroad-diagrams/generator.html +59 -0
- package/node_modules/railroad-diagrams/package.json +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.css +23 -0
- package/node_modules/railroad-diagrams/railroad-diagrams.js +524 -0
- package/node_modules/railroad-diagrams/railroad_diagrams.py +427 -0
- package/node_modules/randexp/LICENSE +19 -0
- package/node_modules/randexp/README.md +134 -0
- package/node_modules/randexp/lib/randexp.js +245 -0
- package/node_modules/randexp/package.json +48 -0
- package/node_modules/ret/LICENSE +19 -0
- package/node_modules/ret/README.md +183 -0
- package/node_modules/ret/lib/index.js +282 -0
- package/node_modules/ret/lib/positions.js +17 -0
- package/node_modules/ret/lib/sets.js +82 -0
- package/node_modules/ret/lib/types.js +10 -0
- package/node_modules/ret/lib/util.js +111 -0
- package/node_modules/ret/package.json +35 -0
- package/package.json +22 -6
- package/schemas/cchistory-lite-agent-v1.schema.json +6 -7
- package/schemas/cchistory-lite-error-v1.schema.json +58 -8
- package/schemas/cchistory-lite-query-result-v2.schema.json +66 -11
- package/schemas/cchistory-lite-query-result-v3.schema.json +219 -0
- package/schemas/cchistory-lite-query-v3.schema.json +57 -0
- package/schemas/cchistory-lite-source-inventory-v1.schema.json +72 -0
- package/skills/using-cchistory-lite/SKILL.md +125 -53
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts +0 -8
- package/node_modules/@cchistory/live-runtime/dist/node-memory.d.ts.map +0 -1
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js +0 -110
- package/node_modules/@cchistory/live-runtime/dist/node-memory.js.map +0 -1
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# Display constants
|
|
2
|
+
VERTICAL_SEPARATION = 8
|
|
3
|
+
ARC_RADIUS = 10
|
|
4
|
+
DIAGRAM_CLASS = 'railroad-diagram'
|
|
5
|
+
TRANSLATE_HALF_PIXEL = True
|
|
6
|
+
INTERNAL_ALIGNMENT = 'center'
|
|
7
|
+
DEBUG=False
|
|
8
|
+
|
|
9
|
+
# Assume a monospace font with each char .5em wide, and the em is 16px
|
|
10
|
+
CHARACTER_ADVANCE = 8
|
|
11
|
+
|
|
12
|
+
def e(text):
|
|
13
|
+
return str(text).replace('&', '&').replace('"', '"').replace('<', '<')
|
|
14
|
+
|
|
15
|
+
def determineGaps(outer, inner):
|
|
16
|
+
diff = outer - inner
|
|
17
|
+
if INTERNAL_ALIGNMENT == 'left':
|
|
18
|
+
return 0, diff
|
|
19
|
+
elif INTERNAL_ALIGNMENT == 'right':
|
|
20
|
+
return diff, 0
|
|
21
|
+
else:
|
|
22
|
+
return diff/2, diff/2
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
class DiagramItem(object):
|
|
27
|
+
def __init__(self, name, attrs=None, text=None):
|
|
28
|
+
self.name = name
|
|
29
|
+
self.attrs = attrs or {}
|
|
30
|
+
self.children = [text] if text else []
|
|
31
|
+
self.needsSpace = False
|
|
32
|
+
|
|
33
|
+
def format(self, x, y, width):
|
|
34
|
+
raise NotImplementedError # Virtual
|
|
35
|
+
|
|
36
|
+
def addTo(self, parent):
|
|
37
|
+
parent.children.append(self)
|
|
38
|
+
return self
|
|
39
|
+
|
|
40
|
+
def writeSvg(self, write):
|
|
41
|
+
write('<{0}'.format(self.name))
|
|
42
|
+
for name, value in sorted(self.attrs.items()):
|
|
43
|
+
write(' {0}="{1}"'.format(name, e(value)))
|
|
44
|
+
write('>\n')
|
|
45
|
+
for child in self.children:
|
|
46
|
+
if isinstance(child, DiagramItem):
|
|
47
|
+
child.writeSvg(write)
|
|
48
|
+
else:
|
|
49
|
+
write(e(child))
|
|
50
|
+
write('</{0}>'.format(self.name))
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Path(DiagramItem):
|
|
54
|
+
def __init__(self, x, y):
|
|
55
|
+
DiagramItem.__init__(self, 'path', {'d': 'M%s %s' % (x, y)})
|
|
56
|
+
|
|
57
|
+
def m(self, x, y):
|
|
58
|
+
self.attrs['d'] += 'm{0} {1}'.format(x,y)
|
|
59
|
+
return self
|
|
60
|
+
|
|
61
|
+
def h(self, val):
|
|
62
|
+
self.attrs['d'] += 'h{0}'.format(val)
|
|
63
|
+
return self
|
|
64
|
+
|
|
65
|
+
right = h
|
|
66
|
+
|
|
67
|
+
def left(self, val):
|
|
68
|
+
return self.h(-val)
|
|
69
|
+
|
|
70
|
+
def v(self, val):
|
|
71
|
+
self.attrs['d'] += 'v{0}'.format(val)
|
|
72
|
+
return self
|
|
73
|
+
|
|
74
|
+
down = v
|
|
75
|
+
|
|
76
|
+
def up(self, val):
|
|
77
|
+
return self.v(-val)
|
|
78
|
+
|
|
79
|
+
def arc(self, sweep):
|
|
80
|
+
x = ARC_RADIUS
|
|
81
|
+
y = ARC_RADIUS
|
|
82
|
+
if sweep[0] == 'e' or sweep[1] == 'w':
|
|
83
|
+
x *= -1
|
|
84
|
+
if sweep[0] == 's' or sweep[1] == 'n':
|
|
85
|
+
y *= -1
|
|
86
|
+
cw = 1 if sweep == 'ne' or sweep == 'es' or sweep == 'sw' or sweep == 'wn' else 0
|
|
87
|
+
self.attrs['d'] += 'a{0} {0} 0 0 {1} {2} {3}'.format(ARC_RADIUS, cw, x, y)
|
|
88
|
+
return self
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def format(self):
|
|
92
|
+
self.attrs['d'] += 'h.5'
|
|
93
|
+
return self
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def wrapString(value):
|
|
97
|
+
return value if isinstance(value, DiagramItem) else Terminal(value)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class Diagram(DiagramItem):
|
|
101
|
+
def __init__(self, *items):
|
|
102
|
+
DiagramItem.__init__(self, 'svg', {'class': DIAGRAM_CLASS})
|
|
103
|
+
self.items = [Start()] + [wrapString(item) for item in items] + [End()]
|
|
104
|
+
self.width = 1 + sum(item.width + (20 if item.needsSpace else 0)
|
|
105
|
+
for item in self.items)
|
|
106
|
+
self.up = max(item.up for item in self.items)
|
|
107
|
+
self.down = max(item.down for item in self.items)
|
|
108
|
+
self.formatted = False
|
|
109
|
+
|
|
110
|
+
def format(self, paddingTop=20, paddingRight=None, paddingBottom=None, paddingLeft=None):
|
|
111
|
+
if paddingRight is None:
|
|
112
|
+
paddingRight = paddingTop
|
|
113
|
+
if paddingBottom is None:
|
|
114
|
+
paddingBottom = paddingTop
|
|
115
|
+
if paddingLeft is None:
|
|
116
|
+
paddingLeft = paddingRight
|
|
117
|
+
x = paddingLeft
|
|
118
|
+
y = paddingTop + self.up
|
|
119
|
+
g = DiagramItem('g')
|
|
120
|
+
if TRANSLATE_HALF_PIXEL:
|
|
121
|
+
g.attrs['transform'] = 'translate(.5 .5)'
|
|
122
|
+
for item in self.items:
|
|
123
|
+
if item.needsSpace:
|
|
124
|
+
Path(x, y).h(10).addTo(g)
|
|
125
|
+
x += 10
|
|
126
|
+
item.format(x, y, item.width).addTo(g)
|
|
127
|
+
x += item.width
|
|
128
|
+
if item.needsSpace:
|
|
129
|
+
Path(x, y).h(10).addTo(g)
|
|
130
|
+
x += 10
|
|
131
|
+
self.attrs['width'] = self.width + paddingLeft + paddingRight
|
|
132
|
+
self.attrs['height'] = self.up + self.down + paddingTop + paddingBottom
|
|
133
|
+
self.attrs['viewBox'] = "0 0 {width} {height}".format(**self.attrs)
|
|
134
|
+
g.addTo(self)
|
|
135
|
+
self.formatted = True
|
|
136
|
+
return self
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def writeSvg(self, write):
|
|
140
|
+
if not self.formatted:
|
|
141
|
+
self.format()
|
|
142
|
+
return DiagramItem.writeSvg(self, write)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class Sequence(DiagramItem):
|
|
146
|
+
def __init__(self, *items):
|
|
147
|
+
DiagramItem.__init__(self, 'g')
|
|
148
|
+
self.items = [wrapString(item) for item in items]
|
|
149
|
+
self.width = sum(item.width + (20 if item.needsSpace else 0)
|
|
150
|
+
for item in self.items)
|
|
151
|
+
self.up = max(item.up for item in self.items)
|
|
152
|
+
self.down = max(item.down for item in self.items)
|
|
153
|
+
if DEBUG:
|
|
154
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
155
|
+
self.attrs['data-type'] = "sequence"
|
|
156
|
+
|
|
157
|
+
def format(self, x, y, width):
|
|
158
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
159
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
160
|
+
Path(x+leftGap+self.width, y).h(rightGap).addTo(self)
|
|
161
|
+
x += leftGap
|
|
162
|
+
for item in self.items:
|
|
163
|
+
if item.needsSpace:
|
|
164
|
+
Path(x, y).h(10).addTo(self)
|
|
165
|
+
x += 10
|
|
166
|
+
item.format(x, y, item.width).addTo(self)
|
|
167
|
+
x += item.width
|
|
168
|
+
if item.needsSpace:
|
|
169
|
+
Path(x, y).h(10).addTo(self)
|
|
170
|
+
x += 10
|
|
171
|
+
return self
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
class Choice(DiagramItem):
|
|
175
|
+
def __init__(self, default, *items):
|
|
176
|
+
DiagramItem.__init__(self, 'g')
|
|
177
|
+
assert default < len(items)
|
|
178
|
+
self.default = default
|
|
179
|
+
self.items = [wrapString(item) for item in items]
|
|
180
|
+
self.width = ARC_RADIUS * 4 + max(item.width for item in self.items)
|
|
181
|
+
self.up = 0
|
|
182
|
+
self.down = 0
|
|
183
|
+
for i, item in enumerate(self.items):
|
|
184
|
+
if i < default:
|
|
185
|
+
self.up += max(ARC_RADIUS, item.up + item.down + VERTICAL_SEPARATION)
|
|
186
|
+
elif i == default:
|
|
187
|
+
self.up += max(ARC_RADIUS, item.up)
|
|
188
|
+
self.down += max(ARC_RADIUS, item.down)
|
|
189
|
+
else:
|
|
190
|
+
assert i > default
|
|
191
|
+
self.down += max(ARC_RADIUS, VERTICAL_SEPARATION + item.up + item.down)
|
|
192
|
+
if DEBUG:
|
|
193
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
194
|
+
self.attrs['data-type'] = "choice"
|
|
195
|
+
|
|
196
|
+
def format(self, x, y, width):
|
|
197
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
198
|
+
|
|
199
|
+
# Hook up the two sides if self is narrower than its stated width.
|
|
200
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
201
|
+
Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
|
|
202
|
+
x += leftGap
|
|
203
|
+
|
|
204
|
+
last = len(self.items) - 1
|
|
205
|
+
innerWidth = self.width - ARC_RADIUS * 4
|
|
206
|
+
|
|
207
|
+
# Do the elements that curve above
|
|
208
|
+
above = self.items[:self.default]
|
|
209
|
+
if above:
|
|
210
|
+
distanceFromY = max(
|
|
211
|
+
ARC_RADIUS * 2,
|
|
212
|
+
self.items[self.default].up
|
|
213
|
+
+ VERTICAL_SEPARATION
|
|
214
|
+
+ self.items[self.default - 1].down)
|
|
215
|
+
for i, item in list(enumerate(above))[::-1]:
|
|
216
|
+
Path(x, y).arc('se').up(distanceFromY - ARC_RADIUS * 2).arc('wn').addTo(self)
|
|
217
|
+
item.format(x + ARC_RADIUS * 2, y - distanceFromY, innerWidth).addTo(self)
|
|
218
|
+
Path(x + ARC_RADIUS * 2 + innerWidth, y - distanceFromY).arc('ne') \
|
|
219
|
+
.down(distanceFromY - ARC_RADIUS*2).arc('ws').addTo(self)
|
|
220
|
+
distanceFromY += max(
|
|
221
|
+
ARC_RADIUS,
|
|
222
|
+
item.up
|
|
223
|
+
+ VERTICAL_SEPARATION
|
|
224
|
+
+ (self.items[i - 1].down if i > 0 else 0))
|
|
225
|
+
|
|
226
|
+
# Do the straight-line path.
|
|
227
|
+
Path(x, y).right(ARC_RADIUS * 2).addTo(self)
|
|
228
|
+
self.items[self.default].format(x + ARC_RADIUS * 2, y, innerWidth).addTo(self)
|
|
229
|
+
Path(x + ARC_RADIUS * 2 + innerWidth, y).right(ARC_RADIUS * 2).addTo(self)
|
|
230
|
+
|
|
231
|
+
# Do the elements that curve below
|
|
232
|
+
below = self.items[self.default + 1:]
|
|
233
|
+
for i, item in enumerate(below):
|
|
234
|
+
if i == 0:
|
|
235
|
+
distanceFromY = max(
|
|
236
|
+
ARC_RADIUS * 2,
|
|
237
|
+
self.items[self.default].down
|
|
238
|
+
+ VERTICAL_SEPARATION
|
|
239
|
+
+ item.up)
|
|
240
|
+
Path(x, y).arc('ne').down(distanceFromY - ARC_RADIUS * 2).arc('ws').addTo(self)
|
|
241
|
+
item.format(x + ARC_RADIUS * 2, y + distanceFromY, innerWidth).addTo(self)
|
|
242
|
+
Path(x + ARC_RADIUS * 2 + innerWidth, y + distanceFromY).arc('se') \
|
|
243
|
+
.up(distanceFromY - ARC_RADIUS * 2).arc('wn').addTo(self)
|
|
244
|
+
distanceFromY += max(
|
|
245
|
+
ARC_RADIUS,
|
|
246
|
+
item.down
|
|
247
|
+
+ VERTICAL_SEPARATION
|
|
248
|
+
+ (below[i + 1].up if i+1 < len(below) else 0))
|
|
249
|
+
return self
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
def Optional(item, skip=False):
|
|
253
|
+
return Choice(0 if skip else 1, Skip(), item)
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
class OneOrMore(DiagramItem):
|
|
257
|
+
def __init__(self, item, repeat=None):
|
|
258
|
+
DiagramItem.__init__(self, 'g')
|
|
259
|
+
repeat = repeat or Skip()
|
|
260
|
+
self.item = wrapString(item)
|
|
261
|
+
self.rep = wrapString(repeat)
|
|
262
|
+
self.width = max(self.item.width, self.rep.width) + ARC_RADIUS * 2
|
|
263
|
+
self.up = self.item.up
|
|
264
|
+
self.down = max(
|
|
265
|
+
ARC_RADIUS * 2,
|
|
266
|
+
self.item.down + VERTICAL_SEPARATION + self.rep.up + self.rep.down)
|
|
267
|
+
self.needsSpace = True
|
|
268
|
+
if DEBUG:
|
|
269
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
270
|
+
self.attrs['data-type'] = "oneormore"
|
|
271
|
+
|
|
272
|
+
def format(self, x, y, width):
|
|
273
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
274
|
+
|
|
275
|
+
# Hook up the two sides if self is narrower than its stated width.
|
|
276
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
277
|
+
Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
|
|
278
|
+
x += leftGap
|
|
279
|
+
|
|
280
|
+
# Draw item
|
|
281
|
+
Path(x, y).right(ARC_RADIUS).addTo(self)
|
|
282
|
+
self.item.format(x + ARC_RADIUS, y, self.width - ARC_RADIUS * 2).addTo(self)
|
|
283
|
+
Path(x + self.width - ARC_RADIUS, y).right(ARC_RADIUS).addTo(self)
|
|
284
|
+
|
|
285
|
+
# Draw repeat arc
|
|
286
|
+
distanceFromY = max(ARC_RADIUS*2, self.item.down + VERTICAL_SEPARATION + self.rep.up)
|
|
287
|
+
Path(x + ARC_RADIUS, y).arc('nw').down(distanceFromY - ARC_RADIUS * 2) \
|
|
288
|
+
.arc('ws').addTo(self)
|
|
289
|
+
self.rep.format(x + ARC_RADIUS, y + distanceFromY, self.width - ARC_RADIUS*2).addTo(self)
|
|
290
|
+
Path(x + self.width - ARC_RADIUS, y + distanceFromY).arc('se') \
|
|
291
|
+
.up(distanceFromY - ARC_RADIUS * 2).arc('en').addTo(self)
|
|
292
|
+
|
|
293
|
+
return self
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def ZeroOrMore(item, repeat=None):
|
|
297
|
+
result = Optional(OneOrMore(item, repeat))
|
|
298
|
+
return result
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
class Start(DiagramItem):
|
|
302
|
+
def __init__(self):
|
|
303
|
+
DiagramItem.__init__(self, 'path')
|
|
304
|
+
self.width = 20
|
|
305
|
+
self.up = 10
|
|
306
|
+
self.down = 10
|
|
307
|
+
if DEBUG:
|
|
308
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
309
|
+
self.attrs['data-type'] = "start"
|
|
310
|
+
|
|
311
|
+
def format(self, x, y, _width):
|
|
312
|
+
self.attrs['d'] = 'M {0} {1} v 20 m 10 -20 v 20 m -10 -10 h 20.5'.format(x, y - 10)
|
|
313
|
+
return self
|
|
314
|
+
|
|
315
|
+
|
|
316
|
+
class End(DiagramItem):
|
|
317
|
+
def __init__(self):
|
|
318
|
+
DiagramItem.__init__(self, 'path')
|
|
319
|
+
self.width = 20
|
|
320
|
+
self.up = 10
|
|
321
|
+
self.down = 10
|
|
322
|
+
if DEBUG:
|
|
323
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
324
|
+
self.attrs['data-type'] = "end"
|
|
325
|
+
|
|
326
|
+
def format(self, x, y, _width):
|
|
327
|
+
self.attrs['d'] = 'M {0} {1} h 20 m -10 -10 v 20 m 10 -20 v 20'.format(x, y)
|
|
328
|
+
return self
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class Terminal(DiagramItem):
|
|
332
|
+
def __init__(self, text):
|
|
333
|
+
DiagramItem.__init__(self, 'g')
|
|
334
|
+
self.text = text
|
|
335
|
+
self.width = len(text) * CHARACTER_ADVANCE + 20
|
|
336
|
+
self.up = 11
|
|
337
|
+
self.down = 11
|
|
338
|
+
self.needsSpace = True
|
|
339
|
+
if DEBUG:
|
|
340
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
341
|
+
self.attrs['data-type'] = "terminal"
|
|
342
|
+
|
|
343
|
+
def format(self, x, y, width):
|
|
344
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
345
|
+
|
|
346
|
+
# Hook up the two sides if self is narrower than its stated width.
|
|
347
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
348
|
+
Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
|
|
349
|
+
|
|
350
|
+
DiagramItem('rect', {'x': x + leftGap, 'y': y - 11, 'width': self.width,
|
|
351
|
+
'height': self.up + self.down, 'rx': 10, 'ry': 10}).addTo(self)
|
|
352
|
+
DiagramItem('text', {'x': x + width / 2, 'y': y + 4}, self.text).addTo(self)
|
|
353
|
+
return self
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
class NonTerminal(DiagramItem):
|
|
357
|
+
def __init__(self, text):
|
|
358
|
+
DiagramItem.__init__(self, 'g')
|
|
359
|
+
self.text = text
|
|
360
|
+
self.width = len(text) * CHARACTER_ADVANCE + 20
|
|
361
|
+
self.up = 11
|
|
362
|
+
self.down = 11
|
|
363
|
+
self.needsSpace = True
|
|
364
|
+
if DEBUG:
|
|
365
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
366
|
+
self.attrs['data-type'] = "non-terminal"
|
|
367
|
+
|
|
368
|
+
def format(self, x, y, width):
|
|
369
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
370
|
+
|
|
371
|
+
# Hook up the two sides if self is narrower than its stated width.
|
|
372
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
373
|
+
Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
|
|
374
|
+
|
|
375
|
+
DiagramItem('rect', {'x': x + leftGap, 'y': y - 11, 'width': self.width,
|
|
376
|
+
'height': self.up + self.down}).addTo(self)
|
|
377
|
+
DiagramItem('text', {'x': x + width / 2, 'y': y + 4}, self.text).addTo(self)
|
|
378
|
+
return self
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
class Comment(DiagramItem):
|
|
382
|
+
def __init__(self, text):
|
|
383
|
+
DiagramItem.__init__(self, 'g')
|
|
384
|
+
self.text = text
|
|
385
|
+
self.width = len(text) * 7 + 10
|
|
386
|
+
self.up = 11
|
|
387
|
+
self.down = 11
|
|
388
|
+
self.needsSpace = True
|
|
389
|
+
if DEBUG:
|
|
390
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
391
|
+
self.attrs['data-type'] = "comment"
|
|
392
|
+
|
|
393
|
+
def format(self, x, y, width):
|
|
394
|
+
leftGap, rightGap = determineGaps(width, self.width)
|
|
395
|
+
|
|
396
|
+
# Hook up the two sides if self is narrower than its stated width.
|
|
397
|
+
Path(x, y).h(leftGap).addTo(self)
|
|
398
|
+
Path(x + leftGap + self.width, y).h(rightGap).addTo(self)
|
|
399
|
+
|
|
400
|
+
DiagramItem('text', {'x': x + width / 2, 'y': y + 5, 'class': 'comment'}, self.text).addTo(self)
|
|
401
|
+
return self
|
|
402
|
+
|
|
403
|
+
|
|
404
|
+
class Skip(DiagramItem):
|
|
405
|
+
def __init__(self):
|
|
406
|
+
DiagramItem.__init__(self, 'g')
|
|
407
|
+
self.width = 0
|
|
408
|
+
self.up = 0
|
|
409
|
+
self.down = 0
|
|
410
|
+
if DEBUG:
|
|
411
|
+
self.attrs['data-updown'] = "{0} {1}".format(self.up, self.down)
|
|
412
|
+
self.attrs['data-type'] = "skip"
|
|
413
|
+
|
|
414
|
+
def format(self, x, y, width):
|
|
415
|
+
Path(x, y).right(width).addTo(self)
|
|
416
|
+
return self
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
if __name__ == '__main__':
|
|
420
|
+
def add(name, diagram):
|
|
421
|
+
sys.stdout.write('<h1>{0}</h1>\n'.format(e(name)))
|
|
422
|
+
diagram.writeSvg(sys.stdout.write)
|
|
423
|
+
sys.stdout.write('\n')
|
|
424
|
+
|
|
425
|
+
import sys
|
|
426
|
+
sys.stdout.write("<!doctype html><title>Test</title><style>svg.railroad-diagram{background-color:hsl(30,20%,95%);}svg.railroad-diagram path{stroke-width:3;stroke:black;fill:rgba(0,0,0,0);}svg.railroad-diagram text{font:bold 14px monospace;text-anchor:middle;}svg.railroad-diagram text.label{text-anchor:start;}svg.railroad-diagram text.comment{font:italic 12px monospace;}svg.railroad-diagram rect{stroke-width:3;stroke:black;fill:hsl(120,100%,90%);}</style>")
|
|
427
|
+
exec(open('css-example.py-js').read())
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Copyright (C) 2011 by Roly Fentanes
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
5
|
+
in the Software without restriction, including without limitation the rights
|
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
8
|
+
furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
|
11
|
+
all copies or substantial portions of the Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
19
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# randexp.js
|
|
2
|
+
|
|
3
|
+
randexp will generate a random string that matches a given RegExp Javascript object.
|
|
4
|
+
|
|
5
|
+
[](http://travis-ci.org/fent/randexp.js)
|
|
6
|
+
[](https://david-dm.org/fent/randexp.js)
|
|
7
|
+
[](https://codecov.io/gh/fent/randexp.js)
|
|
8
|
+
|
|
9
|
+
# Usage
|
|
10
|
+
|
|
11
|
+
```js
|
|
12
|
+
var RandExp = require('randexp');
|
|
13
|
+
|
|
14
|
+
// supports grouping and piping
|
|
15
|
+
new RandExp(/hello+ (world|to you)/).gen();
|
|
16
|
+
// => hellooooooooooooooooooo world
|
|
17
|
+
|
|
18
|
+
// sets and ranges and references
|
|
19
|
+
new RandExp(/<([a-z]\w{0,20})>foo<\1>/).gen();
|
|
20
|
+
// => <m5xhdg>foo<m5xhdg>
|
|
21
|
+
|
|
22
|
+
// wildcard
|
|
23
|
+
new RandExp(/random stuff: .+/).gen();
|
|
24
|
+
// => random stuff: l3m;Hf9XYbI [YPaxV>U*4-_F!WXQh9>;rH3i l!8.zoh?[utt1OWFQrE ^~8zEQm]~tK
|
|
25
|
+
|
|
26
|
+
// ignore case
|
|
27
|
+
new RandExp(/xxx xtreme dragon warrior xxx/i).gen();
|
|
28
|
+
// => xxx xtReME dRAGON warRiOR xXX
|
|
29
|
+
|
|
30
|
+
// dynamic regexp shortcut
|
|
31
|
+
new RandExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i');
|
|
32
|
+
// is the same as
|
|
33
|
+
new RandExp(new RegExp('(sun|mon|tue|wednes|thurs|fri|satur)day', 'i'));
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
If you're only going to use `gen()` once with a regexp and want slightly shorter syntax for it
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
var randexp = require('randexp').randexp;
|
|
40
|
+
|
|
41
|
+
randexp(/[1-6]/); // 4
|
|
42
|
+
randexp('great|good( job)?|excellent'); // great
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
If you miss the old syntax
|
|
46
|
+
|
|
47
|
+
```js
|
|
48
|
+
require('randexp').sugar();
|
|
49
|
+
|
|
50
|
+
/yes|no|maybe|i don't know/.gen(); // maybe
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
# Motivation
|
|
54
|
+
|
|
55
|
+
Regular expressions are used in every language, every programmer is familiar with them. Regex can be used to easily express complex strings. What better way to generate a random string than with a language you can use to express the string you want?
|
|
56
|
+
|
|
57
|
+
Thanks to [String-Random](http://search.cpan.org/~steve/String-Random-0.22/lib/String/Random.pm) for giving me the idea to make this in the first place and [randexp](https://github.com/benburkert/randexp) for the sweet `.gen()` syntax.
|
|
58
|
+
|
|
59
|
+
# Default Range
|
|
60
|
+
|
|
61
|
+
The default generated character range includes printable ASCII. In order to add or remove characters,
|
|
62
|
+
a `defaultRange` attribute is exposed. you can `subtract(from, to)` and `add(from, to)`
|
|
63
|
+
```js
|
|
64
|
+
var randexp = new RandExp(/random stuff: .+/);
|
|
65
|
+
randexp.defaultRange.subtract(32, 126);
|
|
66
|
+
randexp.defaultRange.add(0, 65535);
|
|
67
|
+
randexp.gen();
|
|
68
|
+
// => random stuff: 湐箻ໜ䫴㳸長���邓蕲뤀쑡篷皇硬剈궦佔칗븛뀃匫鴔事좍ﯣ⭼ꝏ䭍詳蒂䥂뽭
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
# Custom PRNG
|
|
72
|
+
|
|
73
|
+
The default randomness is provided by `Math.random()`. If you need to use a seedable or cryptographic PRNG, you
|
|
74
|
+
can override `RandExp.prototype.randInt` or `randexp.randInt` (where `randexp` is an instance of `RandExp`). `randInt(from, to)` accepts an inclusive range and returns a randomly selected
|
|
75
|
+
number within that range.
|
|
76
|
+
|
|
77
|
+
# Infinite Repetitionals
|
|
78
|
+
|
|
79
|
+
Repetitional tokens such as `*`, `+`, and `{3,}` have an infinite max range. In this case, randexp looks at its min and adds 100 to it to get a useable max value. If you want to use another int other than 100 you can change the `max` property in `RandExp.prototype` or the RandExp instance.
|
|
80
|
+
|
|
81
|
+
```js
|
|
82
|
+
var randexp = new RandExp(/no{1,}/);
|
|
83
|
+
randexp.max = 1000000;
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
With `RandExp.sugar()`
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
var regexp = /(hi)*/;
|
|
90
|
+
regexp.max = 1000000;
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
# Bad Regular Expressions
|
|
94
|
+
|
|
95
|
+
There are some regular expressions which can never match any string.
|
|
96
|
+
|
|
97
|
+
* Ones with badly placed positionals such as `/a^/` and `/$c/m`. Randexp will ignore positional tokens.
|
|
98
|
+
|
|
99
|
+
* Back references to non-existing groups like `/(a)\1\2/`. Randexp will ignore those references, returning an empty string for them. If the group exists only after the reference is used such as in `/\1 (hey)/`, it will too be ignored.
|
|
100
|
+
|
|
101
|
+
* Custom negated character sets with two sets inside that cancel each other out. Example: `/[^\w\W]/`. If you give this to randexp, it will return an empty string for this set since it can't match anything.
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
# Projects based on randexp.js
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
## JSON-Schema Faker
|
|
108
|
+
|
|
109
|
+
Use generators to populate JSON Schema samples. See: [jsf on github](https://github.com/json-schema-faker/json-schema-faker/) and [jsf demo page](http://json-schema-faker.js.org/).
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
# Install
|
|
113
|
+
|
|
114
|
+
### Node.js
|
|
115
|
+
|
|
116
|
+
npm install randexp
|
|
117
|
+
|
|
118
|
+
### Browser
|
|
119
|
+
|
|
120
|
+
Download the [minified version](https://github.com/fent/randexp.js/releases) from the latest release.
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
# Tests
|
|
124
|
+
|
|
125
|
+
Tests are written with [mocha](https://mochajs.org)
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
npm test
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
# License
|
|
133
|
+
|
|
134
|
+
MIT
|